jj-opencodeOpenCode plugin for JJ VCS - enforces 'define change before implementation' workflow
24
50
近 7 天 27
29.7
生态多维模型
7 个月前
2026-01-06
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["jj-opencode@0.2.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["jj-opencode@0.2.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D jj-opencodeopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
An OpenCode plugin that blocks edits until you declare intent.
How It Works
AI: jj describe -m "Add validation" ← declare intent, unlocks
AI: [edits files] ← all edits in this commit
[session ends] ← auto-commits, locks again
AI: jj describe -m "Add tests" ← declare intent, unlocks
AI: [edits files]
[session ends] ← auto-commits, locks again
User: "undo that"
AI: jj undo ← reverts last commit
jj new runs automatically when the session goes idle — can't accidentally mix work.
Installation
npm install -g jj-opencode
Add to ~/.config/opencode/config.json:
{
"plugin": ["jj-opencode"]
}
Commands
| Task | Command |
|---|---|
| Start work | jj describe -m "what you're doing" |
| Finish work | (automatic) |
| Undo | jj undo |
| Status | jj st |
| History | jj log |
| Push | jj_push tool |
Tools
jj_push
Safely pushes changes to a bookmark.
jj_push ← push to main (default)
jj_push bookmark="feature" ← push to specific branch
Auto-detects what to push:
- If
@has changes → pushes@ - If
@is empty (common after session idle) → pushes@- - If both empty → searches for unpushed commits, requires confirmation
Flow:
- Shows preview with commits and files
- Requires user confirmation
- Moves bookmark → pushes → verifies clean working copy
Only specify bookmark if user explicitly requested it.
JJ ≠ Git
JJ uses bookmarks, not branches. Key difference for pushing:
| Git Model | JJ Model |
|---|---|
| Push commits one by one | Move bookmark to tip, push once |
| Can rewrite after push (with force) | Commits are immutable after push |
Anti-pattern: Don't try to push commits sequentially or squash after pushing.
Subagents
Subagents that hit the edit gate are blocked and told to return to the parent agent. JJ workflow (describe/new/push) should only be managed by the primary agent.
Why?
- Guaranteed separation —
jj newruns automatically on session idle - Never lose work — every edit is in a described commit
- Clear history — every commit has meaning
License
MIT