Repository navigation
fix(cli): show help for install, update, uninstall and other action verbs instead of running them - #4767
Conversation
…erbs instead of running them (thedotmack#4764) npx claude-mem uninstall --help ran the uninstall. The main() switch sent install, update, upgrade, uninstall and remove straight to their commands and ignored a trailing -h/--help, and so did repair, prune, start, stop and restart (prune --help deleted old cache versions). Print the usage text and exit 0 for those verbs when either flag follows them. The test bundles the CLI into a package-shaped temp dir because printHelp() resolves the package version relative to dist/npx-cli/, which fails when the TypeScript source is run directly.
[Medium impact] The reviewed changes are safe to merge: help requests return before action commands load or run, and the regression tests isolate installation paths from the developer's environment. SummaryAction commands now print help and return before running when a trailing argument is
No blocking issues remain in the reviewed changes. Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
Point CLAUDE_CONFIG_DIR at the temp home, drop inherited CLAUDE_MEM_WORKER_SCRIPT_PATH and CLAUDE_PLUGIN_ROOT so a regression can never reach a developer's real install, and disable Bun's transpiler cache so it does not write ~/Library/Caches/bun into the checked home on macOS. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_019t4K26AgEm5awWRyDmNN6m
|
Thanks @drakeo338, this is a clean fix and the 20 cases that fail on main are great. I pushed one test-only commit to your branch:
I'll land it once main's build fix is in. |
|
Merged, thank you @drakeo338! |
) Follow-up to #4764 (#4767). `npx claude-mem cleanup --help` and `npx claude-mem adopt --help` ignored the flag and ran the command: cleanup applied the one-time v12.4.3 purge and wrote its marker, and adopt stamped merged-worktree observations into the parent project. Both take only flags, so the worker-service handler read --help as "no --dry-run" and went ahead. Add them to HELP_AWARE_COMMANDS and to the subcommand --help test.
…5394) Follow-up to #4767 and #5288. `npx claude-mem kimi uninstall --help` removed claude-mem's hooks from Kimi's config.toml instead of printing help, and `telemetry disable --help` turned telemetry off. The same happened for the install/uninstall verbs of devin, antigravity-cli and pi, for `memory ingest --help` (the worker ran the real ingest), and for `project merge`, `backup run`, `restore <file>`, `server`, `worker` and `transcript watch`. main() only checks for -h/--help on the commands in HELP_AWARE_COMMANDS, and the handlers for these commands read their verb and ignore the rest of the arguments. Add them to the set, and add the missing `memory ingest` line to the help they now print. The subcommand --help test covers one verb per command. Its temp home now also covers %APPDATA% (Devin's config on Windows), KIMI_CODE_HOME, PI_CODING_AGENT_DIR and the worker port, so a regression cannot reach a real host config or a running worker.
Fixes #4764.
npx claude-mem <verb> --helpran the verb.main()dispatchedinstall,update/upgradeanduninstall/removewithout looking at the arguments that follow them.repair,prune,start,stopandrestartdid the same, andprune --helpdeletes old cache versions, which is the breakage the issue describes.For those verbs, a trailing
-hor--helpnow prints the usage text and exits 0 before anything runs. Commands that parse their own arguments (server,telemetry,search,pi,kimi, …) are unchanged.Tests:
tests/npx-cli/subcommand-help.test.tsruns each verb with--helpand-hagainst a bundled CLI in an isolatedHOME. It checks for exit 0, the help text, no command output and an untouchedHOME. All 20 cases fail onmainand pass here.bun test tests/npx-cli(199 tests) andtsc --noEmitpass.Prepared with an AI coding assistant; I reviewed and ran the checks above.