fix: stop re-tokenising the prompt body — flag-like words in briefs survive verbatim - #28
Merged
Merged
Conversation
…vive verbatim collapseCommandArgv re-split everything after -- and dropped the delimiter, so parseArgv consumed flag-like words (--config, --no-index, %~dp0\bin …) out of long briefs, with non-boolean flags eating the following word as a value and backslash escapes mangling Windows-style paths. Add collapsePromptArgv/splitLeadingFlags: only a leading run of flags is parsed; the first non-flag span starts the verbatim body (raw slice — quotes and backslashes intact). Consumed values are folded into --name=value so parseArgv re-derives identical pairings. delegate.mjs switches to it; id-style commands (status/result/cancel/setup) and from-plan/browser keep the old collapse (they rely on trailing flags / positional splitting).
…e words survive verbatim review.mjs: parse only a leading run of flags via collapsePromptArgv; the focus text is one verbatim operand, and it now reaches the background worker over CURSOR_PLUGIN_CC_PROMPT env (same contract as delegate.mjs) instead of being re-collapsed from argv. browser.mjs: same leading-flags contract; the verbatim rest is split at most once — the first span becomes the URL only when it looks like one, everything after it stays untouched as the description.
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.
Problem
collapseCommandArgvre-splits everything after--and feeds it back throughparseArgv. Any--wordinside the user's free text — a delegate brief, a review focus, or a browser test description — is consumed as a flag: it silently disappears from the prompt, and a non-boolean one also eats the next word as its "value".The brief that reaches cursor-agent has lost
--config custom.yamland--no-index, with no error and no visible trace. Long real-world briefs (install instructions, CLI reproduction steps) hit this constantly.Fix
New
collapsePromptArgvinlib/args.mjswith a leading-flags contract: only a leading run of flag tokens is parsed as flags; the first non-flag span ends flag parsing and everything from there on is kept as ONE verbatim positional — flag-like words, quotes and backslashes in the body survive untouched. A body that itself starts with--can be forced verbatim with-- --.CURSOR_PLUGIN_CC_PROMPTenv.CURSOR_PLUGIN_CC_PROMPTinstead of argv, so the re-spawn no longer collapses it a second time.Behaviour notes
Tests
Regression tests for
splitLeadingFlags/collapsePromptArgv(delegate and review shapes) and a behavioural browser test asserting--config/--no-indexsurvive into the job prompt — all of them fail on the old implementation. Full suite: 168 tests,lint,typecheckgreen.🤖 Generated with Claude Code