fix: single submit_plan with text/path auto-detect for OpenCode#333
Merged
Conversation
PR #318 replaced the original text-based submit_plan with a file-path-only version and split prompt injection between plan/non-plan agents. This caused regressions: the agent couldn't figure out file paths from non-plan agents, and the 80+ line prompt with TodoWrite replacements was fragile against OpenCode upstream changes. This restores the original submit_plan(plan) that accepts markdown text directly — the contract that worked uniformly across all agents — and keeps the file-based workflow as submit_plan_file(path) for users who want persistent plan files. Key changes: - Two tools: submit_plan (text) + submit_plan_file (path) - Unified prompt for all primary agents (not just plan mode) - Removed aggressive TodoWrite string replacements and system-reminder - Kept adversarial stripping of OpenCode's STRICTLY FORBIDDEN rules - Extracted shared server helpers to reduce duplication Addresses #328 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collapses submit_plan + submit_plan_file back into one tool that auto-detects whether the argument is plan text or a file path. First submission: agent passes markdown text (simple, works from any agent). On deny: response includes the history path where the plan was saved, so the agent can Edit the file for targeted revisions and resubmit with the path. Key changes: - One tool: submit_plan(plan) accepts text or absolute .md file path - Server surfaces historyPath through waitForDecision (already saved by saveToHistory, just not returned before) - Deny response includes file path hint for Edit-based revision workflow - Unified prompt for all primary agents (~25 lines, no TodoWrite warfare) - Still strips OpenCode's STRICTLY FORBIDDEN rules and suppresses plan_exit Addresses #328 and rcdailey's feedback on PR #333 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…o-tier prompt - Remove historyPath from deny flow — internal history directory should not be exposed to agents. Text submissions get text feedback; file submissions get file feedback. No crossover. - Error when agent passes an absolute .md path that doesn't exist instead of silently treating it as plan text. - Restore two-tier prompt: plan agent gets full planning instructions, other primary agents get a minimal reminder (matching pre-v0.13.0 behavior). - Clean up stale prompt copy referencing historyPath-based revision flow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…oisy logs - Override todowrite description to defer to submit_plan during active planning - Tool description now instructs agent to explore and ask questions before submitting - Sequenced planning prompt: explore, ask, then write - Remove success logs from integration saves (stderr was bleeding through) - Append resubmit reminder to OpenCode deny feedback Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Collapses the two-tool approach (
submit_plan+submit_plan_file) back into a singlesubmit_plan(plan)that auto-detects whether the argument is markdown text or a file path, based on rcdailey's feedback that one tool is sufficient.Provenance
submit_plan(plan: string)— text-based, uniform across agentssubmit_plan(path: string)— file-only, 80+ line prompt, TodoWrite warfaresubmit_plan(plan)— text or path, one tool, ~25 line promptHow it works
First submission: Agent passes plan as markdown text →
submit_plan(plan: "# My Plan\n..."). Simple, works from any agent.On deny: Response includes the history path where the plan was saved:
On revision: Agent edits the file with Edit tool (targeted changes, not full rewrite), then calls
submit_plan(plan: "/path/to/plan.md"). Auto-detected as file path.Auto-detection logic
Plan markdown virtually never satisfies all three conditions (absolute path +
.mdextension + exists on disk).What changed
apps/opencode-plugin/index.ts: Single tool, auto-detect, unified ~25 line prompt for all primary agents, removed TodoWrite warfarepackages/server/index.ts: SurfacehistoryPaththroughwaitForDecision()(the server already saved plans to history viasaveToHistory()— just never returned the path)packages/shared/feedback-templates.ts: Deny response includes file path hint whenhistoryPathis providedpackages/shared/feedback-templates.test.ts: Updated test for new wording, added history path testWhat's preserved
stripConflictingPlanModeRules()— still strips "STRICTLY FORBIDDEN" from system promptexperimental.chat.messages.transform— still filters "STRICTLY FORBIDDEN" from user messagesplan_exitsuppression viatool.definitionhook.mdpermission override for plan agentTest plan
bun test apps/opencode-plugin/plan-mode.test.ts— 10 passbun test packages/shared/feedback-templates.test.ts— 6 passFixes #328
🤖 Generated with Claude Code