Repository navigation
fix(cli): a lone word that is a nested subcommand is a mistyped command, not a task - #100
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
637132a to
5931c27
Compare
|
Thanks for the command-tree regression tests. Holding merge: no CI run or combined status was returned for current head 5931c27, and the automated review receipt is for the older 637132a commit. Please attach current-head CI for the workspace and shipped binary invocation; verify |
5931c27 to
aee5e34
Compare
|
Rebased onto modularized
|
What a customer would see
hanzo balanceandhanzo quota, typed by two people on 25 Nov 2026, each opened a coding-agent session. The real commands arehanzo billing balanceandhanzo sandbox quota. After this change:Cause
misspelled()insrc/main.rs(called fromrun) compared a lone word only with the top-level command names, by similarity (0.85). A word that is exactly a subcommand deeper in the tree is neither top-level nor similar to one, so it fell through to the coding session.Fix
A lone word that is exactly the name or alias of ONE visible command deeper in the tree is answered with that path (
nested()collects them; a hidden command hides its subtree). If a near top-level command also fits, it is named second in the same sentence:A word that names two or more deeper commands is ambiguous and changes nothing: the near top-level match if there is one, otherwise a task, as on main. The tree passed in is the merged one (
augment), so the generated groups (billing,sandbox) are in it. A quoted multi-word task, a backend name, a word with flags after it, and a word found nowhere are unchanged. On main a near top-level match won outright, which gave the opposite action forundeploy(hanzo deploy) andmodelsformode; that is why the exact path now comes first.Tests (written first)
Red, as run (against the first version of this branch, where a near top-level match won and several deep matches were listed):
tests::a_lone_word_that_is_one_nested_command_names_its_pathFAILED (undeployanswered only "did you meanhanzo deploy")tests::only_a_unique_nested_match_is_namedFAILED (two deep matches,go, still gave an answer)Against
mainthese two were not run. By reading: onmainthe first fails atbalance(no message at all) and the second atsolo.Green, after: the whole
hanzobin suite 459 passed (includes the existinga_lone_near_miss_names_the_command_and_a_task_still_runs:stautsstill suggestsstatus, a quoted task andwhoamiandclaudeunchanged);tests/cli.rs25 passed;cargo clippy --locked --all-targets -- -D warningsclean.What the new tests cover: on the real tree,
balanceandquota(one path each on current main),undeploy(exact path first,hanzo deploysecond),create(many matches: still a task) and an unknown word (still a task). In a small tree: a unique name that also has a near top-level match (exact first, near second), an alias, a hidden command that is skipped, two matches and no near match (a task), and a near-only word.Measured risk
Each word typed alone, on main and with this change (a throwaway test, not committed):
hanzo patrol unit fixhanzo ai records commithanzo content generatehanzo graph diffhanzo devretiredcheck runs first)hanzo linkhanzo linkhanzo formhanzo o11y query_range formatorhanzo formhanzo deployhanzo ai deployments owner undeployorhanzo deployhanzo modelshanzo billing modeorhanzo modelsRisk
Of the words measured, four one-word tasks are newly refused:
fix,commit,generate,diff. The table is a sample, not the whole list: any ordinary word that is exactly one deeper command's name is refused the same way. A read of the generated commands also findsdocs(team docs),clone(o11y dashboards clone),schedule(marketing campaigns schedule),apply(affiliate apply) andemail(notify send email). The way out is in the message:hanzo dev "fix"runs it as a coding task; it is the same one retype the existing near-miss rule already costs forlint. Whether that trade is right is the maintainers' call. Two words that were already refused (format,mode) andundeploynow name the exact command as well. Every other word measured behaves as on main.Not tested
cargo fmt --checkalready reports diffs on main in other places; the lines this PR touches are clean.How to revert
git revertthe commit; it is one commit.Built by one agent; an independent review follows. Nothing merged; production is Zach's call.