Skip to content

fix: remove noPromptSeparator for OpenCode to prevent slash command errors (#527)#529

Open
chr1syy wants to merge 1 commit intoRunMaestro:mainfrom
chr1syy:fix/opencode-prompt-separator
Open

fix: remove noPromptSeparator for OpenCode to prevent slash command errors (#527)#529
chr1syy wants to merge 1 commit intoRunMaestro:mainfrom
chr1syy:fix/opencode-prompt-separator

Conversation

@chr1syy
Copy link
Contributor

@chr1syy chr1syy commented Mar 7, 2026

This pull request updates the handling of prompt separators for the opencode agent to prevent misinterpretation of prompt content by the argument parser. The main change is the removal of the noPromptSeparator property, ensuring that the -- separator is used before prompts, which avoids issues when prompts contain leading --- (such as YAML frontmatter).

Agent prompt separator handling:

  • Removed the noPromptSeparator property from the opencode agent definition in definitions.ts, so the -- separator is now always used to prevent yargs from misinterpreting prompt content as flags.
  • Updated related tests in definitions.test.ts and detector.test.ts to reflect the removal of noPromptSeparator, verifying it is now undefined and documenting the reason for the change (Opencode: Custom Slash Command Error #527) [1] [2] [3].

closes #527

Summary by CodeRabbit

Tests & Bug Fixes

  • Fixed prompt separator handling in agent configuration to prevent parsing errors
  • Updated test expectations to reflect configuration improvements

…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>
@coderabbitai
Copy link

coderabbitai bot commented Mar 7, 2026

📝 Walkthrough

Walkthrough

The noPromptSeparator property was removed from the OpenCode agent definition and its corresponding test expectations were updated to reflect undefined instead of true. This is a configuration change to address prompt separator handling in the agent.

Changes

Cohort / File(s) Summary
OpenCode Agent Configuration
src/main/agents/definitions.ts
Removed the noPromptSeparator property from the OpenCode agent definition; adjusted handling to prevent prompt separator misinterpretation by yargs.
Test Updates
src/__tests__/main/agents/definitions.test.ts, src/__tests__/main/agents/detector.test.ts
Updated test expectations for opencode.noPromptSeparator from true to undefined with clarifying comments about the separator removal behavior.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: removing noPromptSeparator for OpenCode to fix slash command errors.
Linked Issues check ✅ Passed The PR directly addresses issue #527 by removing noPromptSeparator to prevent yargs from misinterpreting prompts with leading dashes, fixing slash command errors.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objective: removing noPromptSeparator from OpenCode definitions and updating corresponding test expectations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a bug (#527) where OpenCode's yargs-based CLI would misinterpret slash-command prompts containing leading --- (YAML frontmatter) as flags, by removing noPromptSeparator: true from the OpenCode agent definition and allowing the default -- argument separator to be injected before the prompt.

  • Removes noPromptSeparator: true from the opencode entry in AGENT_DEFINITIONS (definitions.ts); the spawner's default branch in ChildProcessSpawner.ts already appends ['--', prompt] when neither promptArgs nor noPromptSeparator is set, so no changes to the spawner were needed.
  • Updates both definitions.test.ts and detector.test.ts to assert opencode.noPromptSeparator is undefined, with clear comments explaining the reasoning.
  • The inline comment on the noPromptSeparator type definition (line 98 of definitions.ts) still references "OpenCode doesn't support it", which is now stale — a minor cleanup is suggested.

Confidence Score: 5/5

  • Safe to merge — minimal, well-targeted change with accurate test coverage and no risk of regression.
  • The fix is a single-property removal in a definition object. The spawner already handles the -- separator as its default path, so no additional logic changes are required. All affected tests are updated and pass. The only finding is a stale inline comment in the type definition, which is cosmetic.
  • No files require special attention beyond the minor stale comment on line 98 of src/main/agents/definitions.ts.

Important Files Changed

Filename Overview
src/main/agents/definitions.ts Removes noPromptSeparator: true from the OpenCode agent definition so the default -- separator is now used, preventing yargs from misinterpreting YAML-frontmatter prompts as flags; type-definition comment on line 98 still references "OpenCode doesn't support it" and is now stale.
src/tests/main/agents/definitions.test.ts Test updated to assert opencode.noPromptSeparator is undefined; correctly reflects the new default-separator behaviour introduced in this PR.
src/tests/main/agents/detector.test.ts Detector test renamed and updated to expect noPromptSeparator to be undefined for OpenCode; change is accurate and well-commented.

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
Loading

Comments Outside Diff (1)

  1. src/main/agents/definitions.ts, line 98 (link)

    Stale noPromptSeparator comment references OpenCode

    The inline comment on the noPromptSeparator type property still explicitly says "(OpenCode doesn't support it)", but this PR changes OpenCode to rely on the default -- separator behaviour — i.e., OpenCode now does support (and benefits from) the -- separator. The parenthetical example is no longer accurate and could confuse future contributors about which agents use this flag.

Last reviewed commit: f0b005c

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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 ChildProcessSpawner stops 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 shared noPromptSeparator docs with this new behavior.

These comments now say OpenCode relies on --, but AgentConfig.noPromptSeparator still 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7acc502 and f0b005c.

📒 Files selected for processing (3)
  • src/__tests__/main/agents/definitions.test.ts
  • src/__tests__/main/agents/detector.test.ts
  • src/main/agents/definitions.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opencode: Custom Slash Command Error

1 participant