Session Migrate
opencode TUI plugin to migrate (re-parent) sessions across projects and rescue orphaned sessions
4
近 30 天 +2
74
近 7 天 13
38.6
生态多维模型
1 个月前
2026-08-25
快速安装与配置
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
>=1.18.0(TUI plugin API)
Installation
npm
opencode plugin -g opencode-session-migrate
Or add it to your tui.json:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["opencode-session-migrate"]
}
Local path
Point directly at the plugin file:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": [
["/path/to/opencode-session-migrate/src/index.tsx", { "keybind": "ctrl+o" }]
]
}
Restart opencode after changing your config.
Usage
- Press
ctrl+oanywhere, 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.
Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | true |
Set to false to disable the plugin. |
keybind |
string | "ctrl+o" |
Key binding that opens the migrate dialog. |
debug |
boolean | false |
Write debug logs to /tmp/opencode-session-migrate.log. |
How it works
- Orphans are detected client-side by checking whether each session's
directorystill exists on disk, or whether a global session's directory lives inside a known project worktree. - Migration updates
project_idanddirectory(and clearspath/workspace_id) directly in the opencode SQLite database, including child sessions.
Limitations
- Migration writes straight to the database, bypassing opencode's event system. The built-in session list may stay stale until a resync or restart; the plugin re-lists correctly on its own.
- The
ctrl+ohint 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 Recap
@kitlangton/opencode-session-recap
Transient session recaps for the OpenCode V2 TUI
Quotes Tui
opencode-quotes-tui
OpenCode TUI plugin that replaces the home screen tips with a random quote
Aside
opencode-aside
Claude Code's /btw side chat for opencode - ask a one-shot question in an overlay, with no tools and nothing added to the transcript