Session Migrate
opencode TUI plugin to migrate (re-parent) sessions across projects and rescue orphaned sessions
4
55
近 7 天 11
36.3
生态多维模型
9 天前
2026-10-11
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-session-migrate@0.2.1"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-session-migrate@0.2.1"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-session-migrateOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
A opencode TUI plugin to migrate sessions between projects and rescue orphaned sessions.
Features
- List sessions across all projects, not just the current one.
- Detect orphaned sessions (directory no longer exists on disk, or a global session whose directory lives inside a known project worktree).
- Migrate a session to another project, worktree, or your home directory.
- Migrate child (forked) sessions along with the parent.
Requirements
- opencode
>=2.0.0(CLI plugin API)
OpenCode v1
The 1.x line targets the OpenCode v2 plugin API and is not compatible with OpenCode v1. The last release supporting OpenCode v1 is 0.2.1.
If you are still on OpenCode v1, install that exact version:
opencode plugin -g opencode-session-migrate@0.2.1
Or pin it in your tui.json:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["opencode-session-migrate@0.2.1"]
}
Pin the exact version. OpenCode only checks unpinned packages for updates and skips exact npm versions when updating, so @0.2.1 will not drift to latest (1.x, which requires OpenCode v2). An unpinned entry, on the other hand, resolves to latest.
Installation
CLI plugin
opencode plugin add github:sim590/opencode-session-migrate
Alternatively, add the package to cli.json (global config at ~/.config/opencode/cli.json, or $XDG_CONFIG_HOME/opencode/cli.json):
{
"$schema": "https://opencode.ai/cli.json",
"plugins": ["opencode-session-migrate"]
}
To configure options, use the object form:
{
"$schema": "https://opencode.ai/cli.json",
"plugins": [
{
"package": "opencode-session-migrate",
"options": { "enabled": true, "keybind": "alt+m", "debug": false }
}
]
}
See the CLI plugins documentation for configuration details.
Restart opencode after changing your config.
Usage
- Press
alt+manywhere, or run/migrate(or find "Migrate sessions" in the command palette). - Pick a session, then a destination: the current project, your home directory, or any other project.
alt+m("M" for Migrate) is the default because OpenCode v2 already usesctrl+ofor its built-in "open menu".
Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | true |
Set to false to disable the plugin. |
keybind |
string | "alt+m" |
Key binding that opens the migrate dialog. |
debug |
boolean | false |
Write debug logs to /tmp/opencode-session-migrate.log. |
How it works
- Sessions across projects are listed through the V2 API. Orphans are detected client-side by checking whether each session's directory still exists on disk, or whether a global session's directory lives inside a known project canonical directory.
- Migration uses the native
session.moveendpoint (POST /api/session/{sessionID}/move) rather than writing directly to SQLite. Child sessions are moved too, and migration refreshes the session and project caches.
Limitations
- The built-in select does not support a colored gutter, so orphaned sessions are marked with a leading
!in the title. - The
alt+mhint does not appear in the built-in session list footer (the plugin API does not allow extending it). Use the command palette or/migrateif you forget the binding.
License
MIT
同类生态推荐
Session Diff
opencode-session-diff
OpenCode sidebar panel listing the current session's file changes (±line counts)
Quotes Tui
opencode-quotes-tui
OpenCode TUI plugin that replaces the home screen tips with a random quote
Session Recap
@kitlangton/opencode-session-recap
Transient session recaps for the OpenCode V2 TUI