fix: remove noPromptSeparator for OpenCode to prevent slash command errors (#527)#529
fix: remove noPromptSeparator for OpenCode to prevent slash command errors (#527)#529chr1syy wants to merge 1 commit intoRunMaestro:mainfrom
Conversation
…rrors (RunMaestro#527) OpenCode's yargs parser misinterprets leading '---' (YAML frontmatter in slash command prompts) as flags, causing exit code 1 when resuming sessions. Adding '--' separator before the prompt safely terminates flag parsing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes a bug (#527) where OpenCode's yargs-based CLI would misinterpret slash-command prompts containing leading
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Batch-mode prompt dispatch\nChildProcessSpawner] --> B{promptArgs defined?}
B -- Yes --> C[Use promptArgs fn\ne.g. -p prompt]
B -- No --> D{noPromptSeparator?}
D -- true --> E[Append prompt directly\nno separator]
D -- false / undefined --> F["Append -- prompt\n(default, now used for OpenCode)"]
style F fill:#22c55e,color:#fff
style E fill:#f59e0b,color:#fff
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/__tests__/main/agents/definitions.test.ts (1)
70-71: Cover the emitted argv, not just the missing flag.This only proves the config field is absent. It won’t catch a future regression where
ChildProcessSpawnerstops inserting--by default. Please add a behavioral test around the final OpenCode args for a prompt that starts with---—ideally on the resume path mentioned in#527.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/__tests__/main/agents/definitions.test.ts` around lines 70 - 71, The test only checks that opencode.noPromptSeparator is undefined but doesn’t assert the actual spawned argv; update the test in definitions.test.ts to cover the emitted argv from ChildProcessSpawner/OpenCode invocation for a prompt that begins with '---' (use the resume path case referenced in `#527`) and assert that the final args include a '--' separator immediately before the prompt so we catch regressions where ChildProcessSpawner stops inserting '--' by default; locate the test that references opencode?.noPromptSeparator and add an assertion against the captured spawn argv (from the mocked ChildProcessSpawner/OpenCode call) ensuring '--' appears in the correct position.src/main/agents/definitions.ts (1)
218-219: Align the sharednoPromptSeparatordocs with this new behavior.These comments now say OpenCode relies on
--, butAgentConfig.noPromptSeparatorstill says “OpenCode doesn't support it,” and the batch-mode example above still shows the prompt without the separator. That leaves the contract contradictory right next to the fix.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/agents/definitions.ts` around lines 218 - 219, Update the documentation/comments to reflect that the CLI now uses the '--' separator: change the AgentConfig.noPromptSeparator docstring (and any comment that currently says "OpenCode doesn't support it") to state that OpenCode requires/uses '--' to separate flags from prompt input, and update the batch-mode example near the prompt usage to include the '--' line before the prompt (so examples and the AgentConfig.noPromptSeparator contract are consistent with the new behavior). Ensure you edit the AgentConfig.noPromptSeparator declaration and the batch-mode example strings so both mention the '--' separator and remove the old contradictory text.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/__tests__/main/agents/definitions.test.ts`:
- Around line 70-71: The test only checks that opencode.noPromptSeparator is
undefined but doesn’t assert the actual spawned argv; update the test in
definitions.test.ts to cover the emitted argv from ChildProcessSpawner/OpenCode
invocation for a prompt that begins with '---' (use the resume path case
referenced in `#527`) and assert that the final args include a '--' separator
immediately before the prompt so we catch regressions where ChildProcessSpawner
stops inserting '--' by default; locate the test that references
opencode?.noPromptSeparator and add an assertion against the captured spawn argv
(from the mocked ChildProcessSpawner/OpenCode call) ensuring '--' appears in the
correct position.
In `@src/main/agents/definitions.ts`:
- Around line 218-219: Update the documentation/comments to reflect that the CLI
now uses the '--' separator: change the AgentConfig.noPromptSeparator docstring
(and any comment that currently says "OpenCode doesn't support it") to state
that OpenCode requires/uses '--' to separate flags from prompt input, and update
the batch-mode example near the prompt usage to include the '--' line before the
prompt (so examples and the AgentConfig.noPromptSeparator contract are
consistent with the new behavior). Ensure you edit the
AgentConfig.noPromptSeparator declaration and the batch-mode example strings so
both mention the '--' separator and remove the old contradictory text.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 24c3e96e-fcd0-4820-b01d-daaa25e4bb75
📒 Files selected for processing (3)
src/__tests__/main/agents/definitions.test.tssrc/__tests__/main/agents/detector.test.tssrc/main/agents/definitions.ts
This pull request updates the handling of prompt separators for the
opencodeagent to prevent misinterpretation of prompt content by the argument parser. The main change is the removal of thenoPromptSeparatorproperty, ensuring that the--separator is used before prompts, which avoids issues when prompts contain leading---(such as YAML frontmatter).Agent prompt separator handling:
noPromptSeparatorproperty from theopencodeagent definition indefinitions.ts, so the--separator is now always used to prevent yargs from misinterpreting prompt content as flags.definitions.test.tsanddetector.test.tsto reflect the removal ofnoPromptSeparator, verifying it is nowundefinedand documenting the reason for the change (Opencode: Custom Slash Command Error #527) [1] [2] [3].closes #527
Summary by CodeRabbit
Tests & Bug Fixes