From cdd77ffee5900118acf462935d22a123b99632fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Sandstr=C3=B6m?= Date: Wed, 17 Jun 2026 14:01:29 +0200 Subject: [PATCH] fix(memory): --help must not run a side-effectful subcommand `kit memory --help` (e.g. `kit memory install --help`) ran the subcommand instead of printing help, so asking for help on `install` actually installed the hooks. cmdMemory now treats a --help/-h flag anywhere as "show help" before dispatching. Verified by smoke (install/index --help print help, no side effect). Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 3 +++ src/commands/memory.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39fc4654..f65bbb60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ## [Unreleased] +### Fixed +- **A `--help`/`-h` flag never executes a side-effectful subcommand.** `kit memory --help` (e.g. `kit memory install --help`) previously ran the subcommand instead of printing help, so `kit memory install --help` would actually install the hooks. It now shows help and does nothing else. + ## [1.3.1] - 2026-06-17 ### Security diff --git a/src/commands/memory.ts b/src/commands/memory.ts index e7db8382..be84d4ff 100644 --- a/src/commands/memory.ts +++ b/src/commands/memory.ts @@ -43,6 +43,9 @@ import { export async function cmdMemory(): Promise { const subcommand = process.argv[3]; if (!subcommand || subcommand === "--help" || subcommand === "-h") return memHelp(); + // A --help/-h flag after a subcommand means "show help", never run a + // side-effectful subcommand (e.g. `kit memory install --help` must not install). + if (hasFlag(process.argv, "--help") || hasFlag(process.argv, "-h")) return memHelp(); // One handler per subcommand — keeps this dispatcher flat (was a complexity-132 // if-chain). Each handler reads process.argv itself, so no args thread through.