fix: add curated suggestions for open-url and close-session#1175
Merged
Conversation
Last night's help-conformance benchmark showed agents guessing open-url and close-session with no "did you mean" hint (the Levenshtein fallback doesn't cover either token — both exceed the edit-distance threshold for their length). Add curated entries pointing them at `open <url>` and `close`.
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
thymikee
commented
Jul 10, 2026
thymikee
left a comment
Member
Author
There was a problem hiding this comment.
Independent adversarial review, done in a scratch worktree off origin/fix/vocab-suggestions (44c1cff). Tiny, well-scoped change — quick pass as requested.
Findings
No blockers. One nit:
- NIT: the "last-wins"/precedence conventions aren't in question here since these are simple 1:1 curated map entries, but worth a beat noting the PR doesn't need a code comment update — the existing file-level doc comment on
COMMAND_ALIAS_SUGGESTIONSalready generically covers new entries ("Keys must be lowercase... eachexamplemust parse as a valid invocation").
Verified sound
- Pre-fix "no suggestion" claim: confirmed by tracing
getNearestCommandNames. Foropen-url(length 8 → threshold 3 pernearestMatchThreshold),commandNameDistancetakes thestartsWithfast path againstopenand returnsabs(8-4) = 4 > 3, so it's filtered out; no prefix match either (no registered command name starts withopen-url). Same forclose-session(length 13, distanceabs(13-5)=8vs threshold 3). Both guesses got zero suggestion before this PR — the stated bug is real. - Curated-map conventions: both new entries (
{ command: 'open', example: 'open <url>' },{ command: 'close', example: 'close' }) follow the existing shape and match the file's own drift-test contract. - Registry-drift tests cover the new entries:
every curated alias suggestion target resolves to a registered commandandevery curated alias suggestion example parses as a valid invocationboth iteratelistCommandAliasSuggestionEntries(), so they automatically coveropen-url/close-sessionwithout any test changes needed. <url>placeholder tokenization: the drift test substitutes any token starting with<withcom.example.appbefore callingparseArgs. Foropen <url>, that's not just syntactically convenient —open's real schema (positionalArgs: ['appOrUrl?', 'url?'],app: stringField('App name, bundle id, package, or URL.')) genuinely accepts a bare URL/string as its first positional, so the substitution exercises a real, valid invocation shape, not a coincidental parse.- Semantic correctness of the mappings:
closewith no args resolves toclient.sessions.close(...)(percloseCommandDefinitioninsrc/commands/management/app.ts), which is exactly what "close-session" should mean — not just closing an app. - Tests: all 22 tests in
command-suggestions.test.tspass (including the 2 new ones) in an isolated worktree build. - Gates:
lint,typecheck,format:check,check:layering,fallow audit --base origin/mainall pass clean. - CI: all green except one
Smoke Testsjob. Pulled its log — it failed in thePrepare iOS runnerstep with"Daemon request timed out"/xcodebuildrunner-prep timeout, matching the known pre-existing Apple process-spawn-under-CPU-contention flake, not anything related to this PR's CLI-parser-only diff.
Verdict
APPROVE-worthy. Small, correct, well-tested; the one CI failure is an unrelated known flake.
|
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
open-urlandclose-sessionas command names (1x each), and the CLI produced no "Did you mean" hint for either — the Levenshtein nearest-name fallback doesn't cover them because both tokens exceed the edit-distance threshold for their length versus the real command names (open,close).node bin/agent-device.mjs open-urlandnode bin/agent-device.mjs close-sessionboth returned a bareUnknown command: ...with no hint.src/cli/parser/command-suggestions.tsfollowing the existing convention:open-url→open <url>,close-session→close.src/cli/parser/__tests__/command-suggestions.test.ts.Test plan
node bin/agent-device.mjs open-urlnow printsUnknown command: open-url. Did you mean open <url>?node bin/agent-device.mjs close-sessionnow printsUnknown command: close-session. Did you mean close?npx vitest run src/cli/parser— 170/170 passing (includes the two new cases plus the registry-drift guards)pnpm lint,pnpm typecheck,pnpm format:check,pnpm check:layeringall cleannpx fallow audit --base origin/main— no issues in the 2 changed files