Repository navigation
OpenCode 2: /plannotator-annotate with extra words opens the file, and failures are shown - #1739
Merged
Merged
Conversation
…ash-command failures
On OpenCode 2, `/plannotator-annotate . notes.md` (also `notes.md .`,
`please notes.md`) opened nothing and showed nothing. The CLI bridge passed
the words as ONE argument (`annotate ". notes.md" --json`), which the real
CLI reads as a single path ("File not found: . notes.md"), so its tolerant
resolution never ran. The failure only went to the log, which OpenCode 2
discards.
- annotateCliTargets: when the input names nothing as a whole, its words
go to the CLI as separate arguments (shared annotateTargetWords: quotes
group a path with spaces, an unterminated quote is prose, backslashes kept,
known flags dropped). One argument as before for a whole-input match (an
unquoted path with spaces), a single word, or any dash word. The tool's
single target is never re-split.
- A failed OpenCode 2 slash command posts a transcript notice through
session.synthetic with resume: false (no model turn), dropped from model
requests like the session-URL notice. The OpenCode 1 CLI runtime shows an
error toast. Tool launches keep reporting failures as the tool result.
- Tests: the stub CLI now reads one argument as one path like the real one;
a new test runs the REAL CLI through runNativeCommand.
… requests The context filter matched any user message starting with 'Plannotator /plannotator-annotate failed: ', so a person who pasted the failure line they saw and asked about it lost that message from every later model request (and the cached prefix shifted). The notice's text now ends with a marker its visible description lacks, and the filter matches only text ending with it.
…ate targets
annotateTargetWords grouped text between two prose apostrophes into one
word ('it's notes.md, don't' hid notes.md). A quote now groups only when it
opens and closes a word. Uses its own scanner, so review-args is back to
main unchanged.
A URL followed by prose went to the CLI as one 'URL' because the URL probe
matches on the scheme alone; a URL holding whitespace is now split like
other prose.
1 task
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
On OpenCode 2 (seen in the 0.28.6 release smoke, also in 0.28.5),
/plannotator-annotate . notes.mdopened nothing and showed the user nothing.notes.md .andplease notes.mdfailed the same way. The only trace wasFile not found: . notes.mdin the OpenCode log. A single file and a real list of files worked, and OpenCode 1 opened notes.md correctly.Cause
buildAnnotateCliArgsinapps/opencode-plugin/cli-bridge.tspassed the whole string to the CLI as ONE argument:annotate ". notes.md" --json. The real CLI treats one argument as one path, so it never ran its tolerant resolution. That resolution, given separate words, drops.and opens notes.md. The fix(mod, opencode): name a review by what the CLI opened, not the typed words #1737 test passed only because its stub CLI split its one argument on whitespace and dropped., which the real CLI does not do.cliFailure/reportFailure). OpenCode 2 discards that log, so the user saw nothing at all.Fix
Separate words. The new
annotateCliTargets(cli-bridge) passes the slash command's words to the CLI as separate arguments when the input as a whole names nothing. The split is done by the sharedannotateTargetWords(packages/shared/annotate-args.ts). It uses the same quote rule as review arguments (scanQuotedWords, now exported fromreview-args.ts): quotes group a path with spaces, and backslashes are kept so Windows paths work. An unterminated quote is read as prose (an apostrophe) and splits on whitespace. Known flags are dropped. The input stays ONE argument, as before, in three cases:my notes.md)-, so a mistyped flag, or a flag written in prose such as--require-approval, never reaches the CLI as a real flag.The
plannotatortool's single target is never re-split, and strict flags are unchanged. The bundle pre-check reads the same words, so"a b.md" "c d.md"now works as a list of files.Visible failure. A failed OpenCode 2 slash command (a refused argument or the CLI's startup error) now posts a transcript notice,
Plannotator /plannotator-annotate failed: <reason>(createCommandFailureNotifierinv2-client.ts). It usessession.syntheticwith adescriptionandresume: false, the mechanism the session-URL notice already uses.session.promptwithqueue(the tool's late-failure path)? It would start a model turn, and a slash command must never reach the model unless it says so. The tool uses it because there the agent was told to wait for a decision.contexthook drops it from model requests, exactly like the URL notice. There is one shared, known gap: a notice that the host promotes alone at an idle boundary stays in that one request.Note:
./ notes.mdstill does not open notes.md, and that is by design../is an explicit path to a folder, so the CLI reads two targets and gives its ambiguity error, the same as on OpenCode 1's embedded path. The user now sees that error.Tests
apps/opencode-plugin/annotate-words-cli.test.ts(new) runs the REAL CLI (apps/hook/server/index.ts) throughrunNativeCommand, in a sandbox: temp HOME, XDG dirs and data dir.. notes.md,notes.md .andplease notes.mdopen notes.md, and the feedback names it as the target."my notes.md" pleaseand unquotedmy notes.mdopen the file.syntheticnotice withresume: falseand no prompt../ notes.mdshows the ambiguity error.cli-bridge.ts.plannotator-tool.test.ts: the "targets" stub now behaves like the real CLI. One argument is one path ("File not found"), and several arguments go through the shared selection. The fix(mod, opencode): name a review by what the CLI opened, not the typed words #1737 test now fails without the fix. The tool's startup-error test also checks that no failure notice is posted.annotateTargetWords(quotes, apostrophes, backslashes, flags),annotateCliTargets, and dropping the failure notice from the model context.bun testinapps/opencode-plugin(362 pass),apps/pi-extensionand the relevantpackages/sharedtests pass, andbun run typecheckis clean. Not checked against a live OpenCode 2.