You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-4Lines changed: 36 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# opencode-planner
2
2
3
3
`opencode-planner` is an OpenCode plugin that adds a dedicated `plan` agent for read-only planning before implementation. It's based on the experimental plan agent. That is, it likes to use sub-agents and a structured approach to planning.
4
-
It asks clarifying questions, and produces a markdown file. When Plannotator is installed, it can submit the finished plan for richer review. Without Plannotator, it falls back to a normal chat-based review handoff.
4
+
It asks clarifying questions, and produces a markdown file. When Plannotator is installed, it can submit the finished plan for richer review. Without Plannotator, it can open the plan in your configured external editor for review.
5
5
6
6
After review, the agent can hand back to implementation mode by calling `plan_exit` only when the host runtime exposes that tool. In current OpenCode builds, that means experimental plan mode must be enabled and the client must be `cli`. If it's not enabled, you need to prompt the build agent to start work.
7
7
@@ -36,9 +36,10 @@ If you want reproducible installs instead of automatic plugin refreshes, pin an
36
36
- injects a system reminder that keeps the planning workflow explicit
37
37
- lets users replace the plugin's base `plan` prompt with their own `agent.plan.prompt`
38
38
- lets users override agent settings such as `agent.plan.model` and provider-specific options like `agent.plan.reasoningEffort`
39
-
- denies `submit_plan` and `plan_exit` to the built-in `general` and `explore` subagents so review and implementation handoff stay on the primary `plan` agent
39
+
- denies `submit_plan`, `edit_plan`, and `plan_exit` to the built-in `general` and `explore` subagents so review and implementation handoff stay on the primary `plan` agent
40
40
- exposes a `plan_prompt` tool so the `plan` agent can reveal the plugin's prompt basis for customization
41
-
- uses `submit_plan` for review when available, otherwise falls back to manual chat review
41
+
- exposes an `edit_plan` tool so the `plan` agent can open the current plan in the configured external editor
42
+
- uses `submit_plan` for review when available, otherwise falls back to external-editor review
42
43
- can leave planner mode with `plan_exit` after approval when experimental plan mode is enabled in the CLI runtime
43
44
44
45
## Customize the plan agent
@@ -75,6 +76,37 @@ The tool returns:
75
76
- the injected planner reminder, which is plugin-controlled runtime guidance and is not customized via `agent.plan.prompt`
76
77
- a short note explaining that the final runtime prompt can still differ because of user config, other plugins, or runtime tool availability like `plan_exit`
77
78
79
+
## Review Without Plannotator
80
+
81
+
If `submit_plan` is not registered by the runtime, the plugin's `edit_plan` tool gives the `plan` agent a fallback way to open the current plan in your configured external editor.
82
+
83
+
Example:
84
+
85
+
```text
86
+
If submit_plan is unavailable, call edit_plan so I can review the plan in my editor.
87
+
```
88
+
89
+
`edit_plan` uses `VISUAL` first, then `EDITOR`. The command must launch a separate process and block until editing is complete.
90
+
91
+
Compatible examples:
92
+
93
+
-`VISUAL="gvim -f"`
94
+
-`EDITOR="gedit --wait"`
95
+
-`EDITOR="kate --block"`
96
+
-`EDITOR="code --wait"`
97
+
98
+
These work because they open a separate editor process and do not try to take over the OpenCode TUI terminal.
99
+
100
+
Bare terminal editors like `vim` or `nvim` are not sufficient on their own because the plugin does not hand the current TUI terminal over to the editor. If you want to use them, wrap them in a terminal-emulator command that opens a new window and waits for it to exit.
101
+
102
+
Examples:
103
+
104
+
-`EDITOR="gnome-terminal --wait -- nvim"`
105
+
-`EDITOR="kitty --wait nvim"`
106
+
- a small wrapper script for your terminal emulator that launches `vim` or `nvim` in a separate window and blocks until it exits
107
+
108
+
If `edit_plan` fails, the `plan` agent should fall back to telling you the plan file path and asking for review in chat.
109
+
78
110
## Auto-updates
79
111
80
112
OpenCode installs and updates npm plugins automatically. During the beta phase of this plugin, `opencode-planner@beta` gives the smoothest update path for most users.
@@ -95,7 +127,7 @@ npm run debug:plan
95
127
npm run opencode:no-plannotator -- debug config
96
128
```
97
129
98
-
`npm run debug:plan` checks the active OpenCode runtime and reports whether the local repo plugin is loaded, whether `plan_prompt`, `submit_plan`, and `plan_exit` are allowed by the `plan` agent, and whether they are actually registered as runtime tools.
130
+
`npm run debug:plan` checks the active OpenCode runtime and reports whether the local repo plugin is loaded, whether `plan_prompt`, `edit_plan`, `submit_plan`, and `plan_exit` are allowed by the `plan` agent, and whether they are actually registered as runtime tools.
Copy file name to clipboardExpand all lines: index.js
+76-1Lines changed: 76 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,7 @@
1
+
import{spawn}from"node:child_process"
2
+
import{readFile}from"node:fs/promises"
1
3
importpathfrom"path"
4
+
importprocessfrom"node:process"
2
5
3
6
constagent="plan"
4
7
constroot=".opencode/plans"
@@ -22,7 +25,7 @@ function file(id) {
22
25
functionreviewInstruction(target){
23
26
return[
24
27
`When the plan is complete, if the submit_plan tool is available, use it to submit the plan for review.`,
25
-
`Otherwise, tell the user the plan is ready at ${target} and ask for review in chat.`,
28
+
`Otherwise, call edit_plan to open the markdown plan in the configured external editor for review. If edit_plan fails, tell the user the plan is ready at ${target} and ask for review in chat.`,
26
29
].join(" ")
27
30
}
28
31
@@ -122,12 +125,76 @@ function restrictPlannerSubagent(input = {}) {
"Neither `VISUAL` nor `EDITOR` is set, so edit_plan cannot open the plan. Configure a blocking editor command such as `code --wait`, or a terminal launcher that opens your editor in a separate window and waits.",
`The external editor command exited with status ${code}${suffix}. Configure VISUAL or EDITOR to launch a separate process that waits until editing is complete.`,
0 commit comments