From f63b61eebc6e5c9bb4a791b286172805b316e5ab Mon Sep 17 00:00:00 2001 From: m0Nst3r873 Date: Fri, 26 Jun 2026 20:01:44 +0800 Subject: [PATCH] refactor(cli): hide internal hook commands from --help output --- src/index.ts | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2823e71..8800559 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import { createRequire } from 'node:module'; -import { Command } from 'commander'; +import { Command, Option } from 'commander'; import { setVerbose, setSilent, log } from './utils/logger.js'; import type { GlobalOptions } from './types.js'; @@ -431,7 +431,7 @@ hooksCmd // ─── Usage tracking commands ──────────────────────────── program - .command('track [toolName] [toolInput]') + .command('track [toolName] [toolInput]', { hidden: true }) .description('Track a tool usage event (called by PostToolUse hook)') .option('--stdin', 'Read hook data from STDIN (Claude Code hook format)') .option('--tool ', 'Tool identifier for usage attribution (e.g. claude, claude-internal)') @@ -446,7 +446,7 @@ program }); program - .command('track-slash') + .command('track-slash', { hidden: true }) .description('Track a slash command usage (called by UserPromptSubmit hook)') .option('--stdin', 'Read hook data from STDIN') .option('--tool ', 'Tool identifier for usage attribution (e.g. claude, claude-internal)') @@ -466,7 +466,7 @@ program }); program - .command('save-session') + .command('save-session', { hidden: true }) .description('Save current session tool usage summary') .option('--summary ', 'Session summary text') .action(async (cmdOpts) => { @@ -495,7 +495,7 @@ program }); program - .command('dashboard-report') + .command('dashboard-report', { hidden: true }) .description('Report session state to dashboard (called by hooks)') .option('--stdin', 'Read hook data from STDIN') .option('--tool ', 'Tool identifier (e.g. claude, claude-internal)') @@ -509,7 +509,7 @@ program // ─── Contribute commands ────────────────────────────────── program - .command('contribute-check') + .command('contribute-check', { hidden: true }) .description('Check if session qualifies for contribution (called by PostToolUse hook)') .option('--stdin', 'Read hook data from STDIN') .option('--tool ', 'Tool identifier (e.g. claude, claude-internal)') @@ -546,7 +546,7 @@ program }); program - .command('auto-recall') + .command('auto-recall', { hidden: true }) .description('Auto-recall team knowledge on tool errors (called by PostToolUse hook)') .option('--stdin', 'Read hook data from STDIN') .action(async (cmdOpts) => { @@ -557,7 +557,7 @@ program }); program - .command('todowrite-hint') + .command('todowrite-hint', { hidden: true }) .description('Remind the agent to invoke teamai-recall when TodoWrite is used (PostToolUse hook)') .option('--stdin', 'Read hook data from STDIN') .option('--tool ', 'Source AI tool (claude / codebuddy / cursor)') @@ -572,18 +572,18 @@ program .command('import') .description('Import knowledge from local files, Claude/Cursor rules, git workspace, MRs, or iWiki') .option('--dir ', 'Scan local directory for importable Markdown files') - .option('--from-claude', 'Scan Claude/Cursor rule directories (~/.claude/rules, ~/.cursor/rules)') - .option('--workspace', 'Generate codebase.md from current git workspace') + .addOption(new Option('--from-claude', 'Scan Claude/Cursor rule directories').hideHelp()) + .addOption(new Option('--workspace', 'Generate codebase.md from current git workspace').hideHelp()) .option('--from-mr ', 'Extract learning and codebase suggestions from a merged MR/PR URL') .option('--from-iwiki ', 'Import documents from iWiki Space ID or page URL (requires TAI_PAT_TOKEN)') - .option('--resume', 'Resume an interrupted import session') + .addOption(new Option('--resume', 'Resume an interrupted import session').hideHelp()) .option('--all', 'Accept all suggestions without interactive confirmation') - .option('--output ', 'Write drafts to this directory instead of pushing to team repo') - .option('--existing-codebase ', 'Path to existing codebase.md (used with --from-mr; overrides auto-detection from team repo)') + .addOption(new Option('--output ', 'Write drafts to this directory').hideHelp()) + .addOption(new Option('--existing-codebase ', 'Path to existing codebase.md').hideHelp()) .option('--from-repo ', 'Clone a remote repo and generate per-repo codebase summary') .option('--depth ', 'Shallow clone depth for --from-repo (default 1)', '1') - .option('--ssh', 'Force SSH clone even if HTTPS token is available') - .option('--domain ', 'Skip AI recommendation and assign repo to this domain explicitly') + .addOption(new Option('--ssh', 'Force SSH clone').hideHelp()) + .addOption(new Option('--domain ', 'Skip AI recommendation').hideHelp()) .option('--from-repo-list ', 'Batch import repos from a YAML whitelist') .option('--concurrency ', 'Concurrent repos for --from-repo-list (default 3)', '3') .option('--skip-aggregate', 'Skip domain-*.md / index.md regeneration') @@ -594,9 +594,9 @@ program .option('--exclude-archived', 'Exclude archived repos from --from-org (default true)') .option('--include-pattern ', 'Regex to include repos by full name (used with --from-org)') .option('--exclude-pattern ', 'Regex to exclude repos by full name (used with --from-org)') - .option('--skip-import', 'Only write drafts; skip the actual --from-repo-list run') - .option('--iwiki-dual', 'Enable dual-output mode for --from-iwiki (write codebase sections in addition to learning)') - .option('--require-review', 'Defer codebase section writes to .teamai/pending-review.jsonl for human review') + .addOption(new Option('--skip-import', 'Only write drafts').hideHelp()) + .addOption(new Option('--iwiki-dual', 'Enable dual-output mode').hideHelp()) + .addOption(new Option('--require-review', 'Defer writes to pending-review').hideHelp()) .action(async (cmdOpts) => { const globalOpts = program.opts() as GlobalOptions; const { importCmd } = await import('./import.js'); @@ -604,7 +604,7 @@ program }); program - .command('mr-hint') + .command('mr-hint', { hidden: true }) .description('Hint AI about recently merged but un-imported MRs (SessionStart hook)') .option('--stdin', 'Read hook data from STDIN') .option('--tool ', 'Source AI tool (claude / codebuddy / cursor)') @@ -662,7 +662,7 @@ program }); program - .command('domains [repoUrl]') + .command('domains [repoUrl]', { hidden: true }) .description('Inspect / accept / reject domain-drift signals (subcommand: drift)') .option('--apply', 'Apply drift for the given repoUrl') .option('--apply-all', 'Apply all drift items above confidence threshold') @@ -685,7 +685,7 @@ program // ─── Unified hook dispatch (replaces individual hook subcommands) ──── program - .command('hook-dispatch ') + .command('hook-dispatch ', { hidden: true }) .description('Unified hook dispatcher — handles all teamai hooks for a given event in one process') .option('--tool ', 'Tool identifier (e.g. claude, claude-internal, cursor)') .option('--matcher ', 'Hook matcher for PostToolUse (e.g. Skill, Bash)')