Skip to content

About

The open source coding agent.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

20,619 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenCode logo

The open source AI coding agent.

This repository is a fork — OpenCode MEM. Install it from a release or from source; installing from npm gives you upstream OpenCode.

Discord npm Build status

English | 简体中文 | 繁體中文 | 한국어 | Deutsch | Español | Français | Italiano | Dansk | 日本語 | Polski | Русский | Bosanski | العربية | Norsk | Português (Brasil) | ไทย | Türkçe | Українська | বাংলা | Ελληνικά | Tiếng Việt

OpenCode Terminal UI


OpenCode MEM (this fork)

This repository is a fork of OpenCode, published as gpt-mem/opencode-mem. The Installation section below is upstream's: it installs upstream OpenCode. npm i -g @opencode/cli — and the legacy npm i -g opencode-ai — install upstream, never this fork.

The fork ships two lines:

Line Branch Layout Release tags
v1 memory-context-v1 packages/opencode mem-v<YYYYMMDD-HHMM>-<SHA>
v2 main packages/core + packages/cli mem-preview-<YYYYMMDD>-<slug>

Install from a release

Releases are published on the releases page. A mem-preview-* tag ends with the source commit it was built from — mem-preview-20261018-trim-web-serve-17355bd was built from 17355bd0dce18126cc73fc76c6d95ca52c0d647b. Assets: opencode-linux-x64.tar.gz (with a .sha256 companion) and, when published, opencode-darwin-arm64.tar.gz (with a .sha256 companion). Each archive contains a single opencode executable.

TAG=mem-preview-20261018-trim-web-serve-17355bd
gh release download "$TAG" --repo gpt-mem/opencode-mem \
  --pattern "opencode-darwin-arm64.tar.gz*" --clobber
shasum -a 256 -c opencode-darwin-arm64.tar.gz.sha256      # sha256sum -c on Linux
tar -xzf opencode-darwin-arm64.tar.gz

mkdir -p "$HOME/.opencode/bin"
# keep the stock binary so the fork can always be undone
[ -f "$HOME/.opencode/bin/opencode.stock-backup" ] || \
  cp "$HOME/.opencode/bin/opencode" "$HOME/.opencode/bin/opencode.stock-backup"
# copy to a new name, then rename: replacing a running executable in place
# makes macOS SIGKILL every process that mapped it
cp opencode "$HOME/.opencode/bin/opencode.new" && chmod +x "$HOME/.opencode/bin/opencode.new"
mv -f "$HOME/.opencode/bin/opencode.new" "$HOME/.opencode/bin/opencode"

Install from source (v2 line)

Requires Bun 1.4.2 — the version pinned in packageManager.

git clone https://github.com/gpt-mem/opencode-mem.git
cd opencode-mem
git checkout main
bun install

cd packages/cli
OPENCODE_CHANNEL=latest \
OPENCODE_VERSION="0.0.0-fork-at-$(git rev-parse --short=12 HEAD)" \
  bun run script/build.ts --single --skip-install --skip-web-ui

The executable lands in packages/cli/dist/cli-<os>-<arch>/bin/opencode (cli-darwin-arm64, cli-linux-x64, cli-windows-x64.exe). OPENCODE_VERSION embeds the built commit into the binary so --version names the exact build; without it the version is taken from packages/cli/package.json. OPENCODE_CHANNEL decides which database file the binary opens (packages/cli/src/database-path.ts): opencode.db for the latest|dev|beta|next|prod channels, opencode-<channel>.db for anything else. Left unset, the channel is taken from the branch name, so a build of main opens opencode-main.db — a database of its own, with none of your credentials and none of your sessions in it. A fork build that replaces the upstream binary has to share the upstream database, hence OPENCODE_CHANNEL=latest. The branch was called v2-base before it became main, so a build made from the old name opens opencode-v2-base.db. Rename that file once to keep the sessions it holds:

mv ~/.local/share/opencode/opencode-v2-base.db ~/.local/share/opencode/opencode-main.db

Check what a binary opens with:

opencode debug paths | grep ^db   # db …/opencode.db — the same file the upstream build opens

--skip-web-ui only skips the bundled web UI; --target=opencode-linux-x64 builds a single foreign target.

Install a specific version, and roll back

Any commit is installable — check out the tag or the SHA and build as above:

git checkout mem-preview-20261018-trim-web-serve-17355bd   # by tag
git checkout 17355bd0dce18126cc73fc76c6d95ca52c0d647b      # by commit

Keep one backup per installed build next to the binary (opencode.<sha>-<YYYYMMDDHHMM>.bak) and roll back by restoring it the same way a new build is installed:

cp "$HOME/.opencode/bin/opencode.<sha>-<YYYYMMDDHHMM>.bak" "$HOME/.opencode/bin/opencode.new"
chmod +x "$HOME/.opencode/bin/opencode.new"
mv -f "$HOME/.opencode/bin/opencode.new" "$HOME/.opencode/bin/opencode"

What gets installed, and where

Installing a fork build touches these paths. Nothing else is written, and nothing outside them is modified:

Path What it is
~/.opencode/bin/opencode the executable your shell runs
~/.opencode/bin/opencode.stock-backup the upstream binary, copied aside before the first fork install so the fork can be undone
~/.opencode/builds/<sha12>/opencode one directory per installed fork build; <sha12> is the commit it was built from
~/.opencode/builds/current symlink to the last installed build (the file, not the directory)
~/.opencode/builds/previous symlink to the build installed before current
~/.opencode/builds/order.txt the build queue, oldest first; rollback walks strictly backwards through it
~/.opencode/forever-install.json manifest of the active build: repository, revision, version, platform, sha256, install time

Keeping every build in its own directory is what makes "last" and "previous" selectable at the same time: current and previous are two pointers into the same queue, so switching between them never rebuilds or reinstalls anything.

# after building (see above), install the result and shift the pointers
~/.opencode/scripts/mem-builds.sh install packages/cli/dist/cli-darwin-arm64/bin/opencode
~/.opencode/scripts/mem-builds.sh status     # current / previous, with versions
~/.opencode/scripts/mem-builds.sh rollback   # current ← the build before it, previous ← the one before that
~/.opencode/scripts/mem-builds.sh list       # every build on disk, the queue and the pointers

install derives the SHA from opencode --version (fork-at-<sha>), so a binary built with OPENCODE_VERSION names its own commit. The Session Manager registers the two pointers as OpenCode last and OpenCode previous, and the agent dropdown lists them between Codex and Claude.

Verify that the fork is installed

opencode --version
# opencode v0.0.0-fork-at-950f0d869b8d     ← source build: the built commit is in the version string
# opencode v0.0.0-<slug>-<timestamp>       ← release build

The install manifest records what is installed and where it came from:

cat ~/.opencode/forever-install.json
# { "revision": "<full commit SHA>", "version": "0.0.0-fork-at-<sha>", ... }

What the fork changes on the v2 line

Tool output above 2 KiB leaves the model context by default and lands in a file instead, so a large result costs a pointer rather than its full payload on every later step.

The Ladder cache mask has been removed. Requests use the normal message history with the tool-output file pointers above; provider-native prompt caching continues to work without a client-side cache ledger.

The OPENCODE_MEMORY_* family (OPENCODE_MEMORY_CONTEXT, OPENCODE_MEMORY_INTENT, …) belongs to the v1 line (memory-context-v1). It does not exist on main: the v2 line applies the context budget unconditionally instead of behind a flag.

Installation (upstream OpenCode)

# YOLO
curl -fsSL https://opencode.ai/install | bash

# Package managers
npm i -g @opencode/cli@latest      # or bun/pnpm/yarn
scoop install opencode             # Windows
choco install opencode             # Windows
brew install anomalyco/tap/opencode # macOS and Linux (recommended, always up to date)
brew install opencode              # macOS and Linux (official brew formula, updated less)
sudo pacman -S opencode            # Arch Linux (Stable)
paru -S opencode-bin               # Arch Linux (Latest from AUR)
mise use -g opencode               # Any OS
nix run nixpkgs#opencode           # or github:anomalyco/opencode for latest dev branch

Tip

Remove versions older than 0.1.x before installing.

Desktop App (BETA)

OpenCode is also available as a desktop application. Download directly from the releases page or opencode.ai/download.

Platform Download
macOS (Apple Silicon) opencode-desktop-mac-arm64.dmg
macOS (Intel) opencode-desktop-mac-x64.dmg
Windows opencode-desktop-windows-x64.exe
Linux .deb, .rpm, or .AppImage
# macOS (Homebrew)
brew install --cask opencode-desktop
# Windows (Scoop)
scoop bucket add extras; scoop install extras/opencode-desktop

Installation Directory

The install script respects the following priority order for the installation path:

  1. $OPENCODE_INSTALL_DIR - Custom installation directory
  2. $XDG_BIN_DIR - XDG Base Directory Specification compliant path
  3. $HOME/bin - Standard user binary directory (if it exists or can be created)
  4. $HOME/.opencode/bin - Default fallback
# Examples
OPENCODE_INSTALL_DIR=/usr/local/bin curl -fsSL https://opencode.ai/install | bash
XDG_BIN_DIR=$HOME/.local/bin curl -fsSL https://opencode.ai/install | bash

Agents

OpenCode includes two built-in agents you can switch between with the Tab key.

  • build - Default, full-access agent for development work
  • plan - Read-only agent for analysis and code exploration
    • Denies file edits by default
    • Asks permission before running bash commands
    • Ideal for exploring unfamiliar codebases or planning changes

Also included is a general subagent for complex searches and multistep tasks. This is used internally and can be invoked using @general in messages.

Learn more about agents.

Documentation

For more info on how to configure OpenCode, head over to our docs.

Contributing

If you're interested in contributing to OpenCode, please read our contributing docs before submitting a pull request.

Building on OpenCode

If you are working on a project that's related to OpenCode and is using "opencode" as part of its name, for example "opencode-dashboard" or "opencode-mobile", please add a note to your README to clarify that it is not built by the OpenCode team and is not affiliated with us in any way.


Join our community Discord | X.com

About

The open source coding agent.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages