claude-code-workflow 6.3.2 → 6.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/.claude/CLAUDE.md +9 -1
  2. package/.claude/commands/workflow/lite-plan.md +1 -1
  3. package/.claude/workflows/cli-tools-usage.md +515 -516
  4. package/ccw/dist/cli.d.ts.map +1 -1
  5. package/ccw/dist/cli.js +6 -1
  6. package/ccw/dist/cli.js.map +1 -1
  7. package/ccw/dist/commands/cli.d.ts +1 -1
  8. package/ccw/dist/commands/cli.d.ts.map +1 -1
  9. package/ccw/dist/commands/cli.js +71 -7
  10. package/ccw/dist/commands/cli.js.map +1 -1
  11. package/ccw/dist/tools/cli-executor.d.ts.map +1 -1
  12. package/ccw/dist/tools/cli-executor.js +19 -7
  13. package/ccw/dist/tools/cli-executor.js.map +1 -1
  14. package/ccw/dist/tools/cli-history-store.d.ts +33 -0
  15. package/ccw/dist/tools/cli-history-store.d.ts.map +1 -1
  16. package/ccw/dist/tools/cli-history-store.js +89 -5
  17. package/ccw/dist/tools/cli-history-store.js.map +1 -1
  18. package/ccw/src/cli.ts +263 -258
  19. package/ccw/src/commands/cli.ts +967 -884
  20. package/ccw/src/tools/cli-executor.ts +20 -7
  21. package/ccw/src/tools/cli-history-store.ts +125 -5
  22. package/codex-lens/src/codexlens/__pycache__/config.cpython-313.pyc +0 -0
  23. package/codex-lens/src/codexlens/config.py +3 -0
  24. package/codex-lens/src/codexlens/search/__pycache__/chain_search.cpython-313.pyc +0 -0
  25. package/codex-lens/src/codexlens/search/__pycache__/hybrid_search.cpython-313.pyc +0 -0
  26. package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-313.pyc +0 -0
  27. package/codex-lens/src/codexlens/search/chain_search.py +71 -1
  28. package/codex-lens/src/codexlens/search/ranking.py +274 -274
  29. package/codex-lens/src/codexlens/semantic/__pycache__/chunker.cpython-313.pyc +0 -0
  30. package/codex-lens/src/codexlens/storage/__pycache__/dir_index.cpython-313.pyc +0 -0
  31. package/codex-lens/src/codexlens/storage/__pycache__/global_index.cpython-313.pyc +0 -0
  32. package/codex-lens/src/codexlens/storage/__pycache__/index_tree.cpython-313.pyc +0 -0
  33. package/codex-lens/src/codexlens/storage/dir_index.py +1888 -1850
  34. package/codex-lens/src/codexlens/storage/global_index.py +365 -0
  35. package/codex-lens/src/codexlens/storage/index_tree.py +83 -10
  36. package/package.json +1 -1
package/ccw/src/cli.ts CHANGED
@@ -1,258 +1,263 @@
1
- import { Command } from 'commander';
2
- import { viewCommand } from './commands/view.js';
3
- import { serveCommand } from './commands/serve.js';
4
- import { stopCommand } from './commands/stop.js';
5
- import { installCommand } from './commands/install.js';
6
- import { uninstallCommand } from './commands/uninstall.js';
7
- import { upgradeCommand } from './commands/upgrade.js';
8
- import { listCommand } from './commands/list.js';
9
- import { toolCommand } from './commands/tool.js';
10
- import { sessionCommand } from './commands/session.js';
11
- import { cliCommand } from './commands/cli.js';
12
- import { memoryCommand } from './commands/memory.js';
13
- import { coreMemoryCommand } from './commands/core-memory.js';
14
- import { hookCommand } from './commands/hook.js';
15
- import { readFileSync, existsSync } from 'fs';
16
- import { fileURLToPath } from 'url';
17
- import { dirname, join } from 'path';
18
-
19
- const __filename = fileURLToPath(import.meta.url);
20
- const __dirname = dirname(__filename);
21
-
22
- interface PackageInfo {
23
- name: string;
24
- version: string;
25
- description?: string;
26
- [key: string]: unknown;
27
- }
28
-
29
- /**
30
- * Load package.json with error handling
31
- * Tries root package.json first (../../package.json from dist),
32
- * then falls back to ccw package.json (../package.json from dist)
33
- * @returns Package info with version
34
- */
35
- function loadPackageInfo(): PackageInfo {
36
- // First try root package.json (parent of ccw directory)
37
- const rootPkgPath = join(__dirname, '../../package.json');
38
- // Fallback to ccw package.json
39
- const ccwPkgPath = join(__dirname, '../package.json');
40
-
41
- try {
42
- // Try root package.json first
43
- if (existsSync(rootPkgPath)) {
44
- const content = readFileSync(rootPkgPath, 'utf8');
45
- return JSON.parse(content) as PackageInfo;
46
- }
47
-
48
- // Fallback to ccw package.json
49
- if (existsSync(ccwPkgPath)) {
50
- const content = readFileSync(ccwPkgPath, 'utf8');
51
- return JSON.parse(content) as PackageInfo;
52
- }
53
-
54
- console.error('Fatal Error: package.json not found.');
55
- console.error(`Tried locations:\n - ${rootPkgPath}\n - ${ccwPkgPath}`);
56
- process.exit(1);
57
- } catch (error) {
58
- if (error instanceof SyntaxError) {
59
- console.error('Fatal Error: package.json contains invalid JSON.');
60
- console.error(`Parse error: ${error.message}`);
61
- } else if (error instanceof Error) {
62
- console.error('Fatal Error: Could not read package.json.');
63
- console.error(`Error: ${error.message}`);
64
- }
65
- process.exit(1);
66
- }
67
- }
68
-
69
- const pkg = loadPackageInfo();
70
-
71
- export function run(argv: string[]): void {
72
- const program = new Command();
73
-
74
- program
75
- .name('ccw')
76
- .description('Claude Code Workflow CLI - Dashboard and workflow tools')
77
- .version(pkg.version);
78
-
79
- // View command (server mode with live path switching)
80
- program
81
- .command('view')
82
- .description('Open workflow dashboard server with live path switching')
83
- .option('-p, --path <path>', 'Path to project directory', '.')
84
- .option('--port <port>', 'Server port', '3456')
85
- .option('--no-browser', 'Start server without opening browser')
86
- .action(viewCommand);
87
-
88
- // Serve command (alias for view)
89
- program
90
- .command('serve')
91
- .description('Alias for view command')
92
- .option('-p, --path <path>', 'Initial project directory')
93
- .option('--port <port>', 'Server port', '3456')
94
- .option('--no-browser', 'Start server without opening browser')
95
- .action(serveCommand);
96
-
97
- // Stop command
98
- program
99
- .command('stop')
100
- .description('Stop the running CCW dashboard server')
101
- .option('--port <port>', 'Server port', '3456')
102
- .option('-f, --force', 'Force kill process on the port')
103
- .action(stopCommand);
104
-
105
- // Install command
106
- program
107
- .command('install')
108
- .description('Install Claude Code Workflow to your system (includes .codex/prompts)')
109
- .option('-m, --mode <mode>', 'Installation mode: Global or Path')
110
- .option('-p, --path <path>', 'Installation path (for Path mode)')
111
- .option('-f, --force', 'Force installation without prompts')
112
- .action(installCommand);
113
-
114
- // Uninstall command
115
- program
116
- .command('uninstall')
117
- .description('Uninstall Claude Code Workflow')
118
- .action(uninstallCommand);
119
-
120
- // Upgrade command
121
- program
122
- .command('upgrade')
123
- .description('Upgrade Claude Code Workflow installations')
124
- .option('-a, --all', 'Upgrade all installations without prompting')
125
- .action(upgradeCommand);
126
-
127
- // List command
128
- program
129
- .command('list')
130
- .description('List all installed Claude Code Workflow instances')
131
- .action(listCommand);
132
-
133
- // Tool command
134
- program
135
- .command('tool [subcommand] [args...]')
136
- .description('Execute CCW tools')
137
- .option('--path <path>', 'File path (for edit_file)')
138
- .option('--old <text>', 'Old text to replace (for edit_file)')
139
- .option('--new <text>', 'New text (for edit_file)')
140
- .option('--action <action>', 'Action to perform (for codex_lens)')
141
- .option('--query <query>', 'Search query (for codex_lens)')
142
- .option('--limit <n>', 'Max results (for codex_lens)', '20')
143
- .option('--file <file>', 'File path for symbol extraction (for codex_lens)')
144
- .option('--files <files>', 'Comma-separated file paths (for codex_lens update)')
145
- .option('--languages <langs>', 'Comma-separated languages (for codex_lens init)')
146
- .action((subcommand, args, options) => toolCommand(subcommand, args, options));
147
-
148
- // Session command
149
- program
150
- .command('session [subcommand] [args...]')
151
- .description('Workflow session lifecycle management')
152
- .option('--location <loc>', 'Session location: active|lite-plan|lite-fix (init); Filter: active|archived|both (list)')
153
- .option('--type <type>', 'Content type or session type')
154
- .option('--content <json>', 'Content for write/update')
155
- .option('--task-id <id>', 'Task ID for task content')
156
- .option('--filename <name>', 'Filename for process/chat/etc')
157
- .option('--dimension <dim>', 'Dimension for review-dim')
158
- .option('--iteration <iter>', 'Iteration for review-iter')
159
- .option('--subdir <dir>', 'Subdirectory for mkdir')
160
- .option('--raw', 'Output raw content only')
161
- .option('--no-metadata', 'Exclude metadata from list')
162
- .option('--no-update-status', 'Skip status update on archive')
163
- .action((subcommand, args, options) => sessionCommand(subcommand, args, options));
164
-
165
- // CLI command
166
- program
167
- .command('cli [subcommand] [args...]')
168
- .description('Unified CLI tool executor (gemini/qwen/codex/claude)')
169
- .option('-p, --prompt <prompt>', 'Prompt text (alternative to positional argument)')
170
- .option('-f, --file <file>', 'Read prompt from file (best for multi-line prompts)')
171
- .option('--tool <tool>', 'CLI tool to use', 'gemini')
172
- .option('--mode <mode>', 'Execution mode: analysis, write, auto', 'analysis')
173
- .option('--model <model>', 'Model override')
174
- .option('--cd <path>', 'Working directory')
175
- .option('--includeDirs <dirs>', 'Additional directories (--include-directories for gemini/qwen, --add-dir for codex/claude)')
176
- .option('--timeout <ms>', 'Timeout in milliseconds', '300000')
177
- .option('--no-stream', 'Disable streaming output')
178
- .option('--limit <n>', 'History limit')
179
- .option('--status <status>', 'Filter by status')
180
- .option('--category <category>', 'Execution category: user, internal, insight', 'user')
181
- .option('--resume [id]', 'Resume previous session (empty=last, or execution ID, or comma-separated IDs for merge)')
182
- .option('--id <id>', 'Custom execution ID (e.g., IMPL-001-step1)')
183
- .option('--no-native', 'Force prompt concatenation instead of native resume')
184
- .option('--cache [items]', 'Cache: comma-separated @patterns and text content')
185
- .option('--inject-mode <mode>', 'Inject mode: none, full, progressive (default: codex=full, others=none)')
186
- // Storage options
187
- .option('--project <path>', 'Project path for storage operations')
188
- .option('--force', 'Confirm destructive operations')
189
- .option('--cli-history', 'Target CLI history storage')
190
- .option('--memory', 'Target memory storage')
191
- .option('--storage-cache', 'Target cache storage')
192
- .option('--config', 'Target config storage')
193
- .action((subcommand, args, options) => cliCommand(subcommand, args, options));
194
-
195
- // Memory command
196
- program
197
- .command('memory [subcommand] [args...]')
198
- .description('Memory module for context tracking and prompt optimization')
199
- .option('--type <type>', 'Entity type: file, module, topic (track) OR source type: core_memory, workflow, cli_history (search)')
200
- .option('--action <action>', 'Action: read, write, mention')
201
- .option('--value <value>', 'Entity value (file path, etc.)')
202
- .option('--session <session>', 'Session ID')
203
- .option('--stdin', 'Read input from stdin (for Claude Code hooks)')
204
- .option('--source <source>', 'Import source: history, sessions, all', 'all')
205
- .option('--project <project>', 'Project name filter')
206
- .option('--limit <n>', 'Number of results (prompt search)', '20')
207
- .option('--sort <field>', 'Sort by: heat, reads, writes', 'heat')
208
- .option('--json', 'Output as JSON')
209
- .option('--context <text>', 'Current task context')
210
- .option('--older-than <age>', 'Age threshold for pruning', '30d')
211
- .option('--dry-run', 'Preview without deleting')
212
- .option('--id <id>', 'Memory/session ID (for embed command)')
213
- .option('--force', 'Force re-embed all chunks')
214
- .option('--batch-size <n>', 'Batch size for embedding', '8')
215
- .option('--top-k <n>', 'Number of semantic search results', '10')
216
- .option('--min-score <f>', 'Minimum similarity score for semantic search', '0.5')
217
- .action((subcommand, args, options) => memoryCommand(subcommand, args, options));
218
-
219
- // Core Memory command
220
- program
221
- .command('core-memory [subcommand] [args...]')
222
- .description('Manage core memory entries for strategic context')
223
- .option('--id <id>', 'Memory ID')
224
- .option('--all', 'Archive all memories')
225
- .option('--before <date>', 'Archive memories before date (YYYY-MM-DD)')
226
- .option('--interactive', 'Interactive selection')
227
- .option('--archived', 'List archived memories')
228
- .option('--limit <n>', 'Number of results', '50')
229
- .option('--json', 'Output as JSON')
230
- .option('--force', 'Skip confirmation')
231
- .option('--tool <tool>', 'Tool to use for summary: gemini, qwen', 'gemini')
232
- .option('--auto', 'Run auto-clustering')
233
- .option('--scope <scope>', 'Auto-cluster scope: all, recent, unclustered', 'recent')
234
- .option('--create', 'Create new cluster')
235
- .option('--name <name>', 'Cluster name')
236
- .option('--members <ids>', 'Cluster member IDs (comma-separated)')
237
- .option('--status <status>', 'Cluster status filter')
238
- .option('--level <level>', 'Context level: metadata, keyFiles, full')
239
- .option('--delete', 'Delete a cluster')
240
- .option('--merge <ids>', 'Merge clusters into target (comma-separated source IDs)')
241
- .option('--dedup', 'Deduplicate clusters by merging similar ones')
242
- .option('--output <file>', 'Output file path for export')
243
- .option('--overwrite', 'Overwrite existing memories when importing')
244
- .option('--prefix <prefix>', 'Add prefix to imported memory IDs')
245
- .action((subcommand, args, options) => coreMemoryCommand(subcommand, args, options));
246
-
247
- // Hook command - CLI endpoint for Claude Code hooks
248
- program
249
- .command('hook [subcommand] [args...]')
250
- .description('CLI endpoint for Claude Code hooks (session-context, notify)')
251
- .option('--stdin', 'Read input from stdin (for Claude Code hooks)')
252
- .option('--session-id <id>', 'Session ID')
253
- .option('--prompt <text>', 'Prompt text')
254
- .option('--type <type>', 'Context type: session-start, context')
255
- .action((subcommand, args, options) => hookCommand(subcommand, args, options));
256
-
257
- program.parse(argv);
258
- }
1
+ import { Command } from 'commander';
2
+ import { viewCommand } from './commands/view.js';
3
+ import { serveCommand } from './commands/serve.js';
4
+ import { stopCommand } from './commands/stop.js';
5
+ import { installCommand } from './commands/install.js';
6
+ import { uninstallCommand } from './commands/uninstall.js';
7
+ import { upgradeCommand } from './commands/upgrade.js';
8
+ import { listCommand } from './commands/list.js';
9
+ import { toolCommand } from './commands/tool.js';
10
+ import { sessionCommand } from './commands/session.js';
11
+ import { cliCommand } from './commands/cli.js';
12
+ import { memoryCommand } from './commands/memory.js';
13
+ import { coreMemoryCommand } from './commands/core-memory.js';
14
+ import { hookCommand } from './commands/hook.js';
15
+ import { readFileSync, existsSync } from 'fs';
16
+ import { fileURLToPath } from 'url';
17
+ import { dirname, join } from 'path';
18
+
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = dirname(__filename);
21
+
22
+ interface PackageInfo {
23
+ name: string;
24
+ version: string;
25
+ description?: string;
26
+ [key: string]: unknown;
27
+ }
28
+
29
+ /**
30
+ * Load package.json with error handling
31
+ * Tries root package.json first (../../package.json from dist),
32
+ * then falls back to ccw package.json (../package.json from dist)
33
+ * @returns Package info with version
34
+ */
35
+ function loadPackageInfo(): PackageInfo {
36
+ // First try root package.json (parent of ccw directory)
37
+ const rootPkgPath = join(__dirname, '../../package.json');
38
+ // Fallback to ccw package.json
39
+ const ccwPkgPath = join(__dirname, '../package.json');
40
+
41
+ try {
42
+ // Try root package.json first
43
+ if (existsSync(rootPkgPath)) {
44
+ const content = readFileSync(rootPkgPath, 'utf8');
45
+ return JSON.parse(content) as PackageInfo;
46
+ }
47
+
48
+ // Fallback to ccw package.json
49
+ if (existsSync(ccwPkgPath)) {
50
+ const content = readFileSync(ccwPkgPath, 'utf8');
51
+ return JSON.parse(content) as PackageInfo;
52
+ }
53
+
54
+ console.error('Fatal Error: package.json not found.');
55
+ console.error(`Tried locations:\n - ${rootPkgPath}\n - ${ccwPkgPath}`);
56
+ process.exit(1);
57
+ } catch (error) {
58
+ if (error instanceof SyntaxError) {
59
+ console.error('Fatal Error: package.json contains invalid JSON.');
60
+ console.error(`Parse error: ${error.message}`);
61
+ } else if (error instanceof Error) {
62
+ console.error('Fatal Error: Could not read package.json.');
63
+ console.error(`Error: ${error.message}`);
64
+ }
65
+ process.exit(1);
66
+ }
67
+ }
68
+
69
+ const pkg = loadPackageInfo();
70
+
71
+ export function run(argv: string[]): void {
72
+ const program = new Command();
73
+
74
+ program
75
+ .name('ccw')
76
+ .description('Claude Code Workflow CLI - Dashboard and workflow tools')
77
+ .version(pkg.version);
78
+
79
+ // View command (server mode with live path switching)
80
+ program
81
+ .command('view')
82
+ .description('Open workflow dashboard server with live path switching')
83
+ .option('-p, --path <path>', 'Path to project directory', '.')
84
+ .option('--port <port>', 'Server port', '3456')
85
+ .option('--no-browser', 'Start server without opening browser')
86
+ .action(viewCommand);
87
+
88
+ // Serve command (alias for view)
89
+ program
90
+ .command('serve')
91
+ .description('Alias for view command')
92
+ .option('-p, --path <path>', 'Initial project directory')
93
+ .option('--port <port>', 'Server port', '3456')
94
+ .option('--no-browser', 'Start server without opening browser')
95
+ .action(serveCommand);
96
+
97
+ // Stop command
98
+ program
99
+ .command('stop')
100
+ .description('Stop the running CCW dashboard server')
101
+ .option('--port <port>', 'Server port', '3456')
102
+ .option('-f, --force', 'Force kill process on the port')
103
+ .action(stopCommand);
104
+
105
+ // Install command
106
+ program
107
+ .command('install')
108
+ .description('Install Claude Code Workflow to your system (includes .codex/prompts)')
109
+ .option('-m, --mode <mode>', 'Installation mode: Global or Path')
110
+ .option('-p, --path <path>', 'Installation path (for Path mode)')
111
+ .option('-f, --force', 'Force installation without prompts')
112
+ .action(installCommand);
113
+
114
+ // Uninstall command
115
+ program
116
+ .command('uninstall')
117
+ .description('Uninstall Claude Code Workflow')
118
+ .action(uninstallCommand);
119
+
120
+ // Upgrade command
121
+ program
122
+ .command('upgrade')
123
+ .description('Upgrade Claude Code Workflow installations')
124
+ .option('-a, --all', 'Upgrade all installations without prompting')
125
+ .action(upgradeCommand);
126
+
127
+ // List command
128
+ program
129
+ .command('list')
130
+ .description('List all installed Claude Code Workflow instances')
131
+ .action(listCommand);
132
+
133
+ // Tool command
134
+ program
135
+ .command('tool [subcommand] [args...]')
136
+ .description('Execute CCW tools')
137
+ .option('--path <path>', 'File path (for edit_file)')
138
+ .option('--old <text>', 'Old text to replace (for edit_file)')
139
+ .option('--new <text>', 'New text (for edit_file)')
140
+ .option('--action <action>', 'Action to perform (for codex_lens)')
141
+ .option('--query <query>', 'Search query (for codex_lens)')
142
+ .option('--limit <n>', 'Max results (for codex_lens)', '20')
143
+ .option('--file <file>', 'File path for symbol extraction (for codex_lens)')
144
+ .option('--files <files>', 'Comma-separated file paths (for codex_lens update)')
145
+ .option('--languages <langs>', 'Comma-separated languages (for codex_lens init)')
146
+ .action((subcommand, args, options) => toolCommand(subcommand, args, options));
147
+
148
+ // Session command
149
+ program
150
+ .command('session [subcommand] [args...]')
151
+ .description('Workflow session lifecycle management')
152
+ .option('--location <loc>', 'Session location: active|lite-plan|lite-fix (init); Filter: active|archived|both (list)')
153
+ .option('--type <type>', 'Content type or session type')
154
+ .option('--content <json>', 'Content for write/update')
155
+ .option('--task-id <id>', 'Task ID for task content')
156
+ .option('--filename <name>', 'Filename for process/chat/etc')
157
+ .option('--dimension <dim>', 'Dimension for review-dim')
158
+ .option('--iteration <iter>', 'Iteration for review-iter')
159
+ .option('--subdir <dir>', 'Subdirectory for mkdir')
160
+ .option('--raw', 'Output raw content only')
161
+ .option('--no-metadata', 'Exclude metadata from list')
162
+ .option('--no-update-status', 'Skip status update on archive')
163
+ .action((subcommand, args, options) => sessionCommand(subcommand, args, options));
164
+
165
+ // CLI command
166
+ program
167
+ .command('cli [subcommand] [args...]')
168
+ .description('Unified CLI tool executor (gemini/qwen/codex/claude)')
169
+ .option('-p, --prompt <prompt>', 'Prompt text (alternative to positional argument)')
170
+ .option('-f, --file <file>', 'Read prompt from file (best for multi-line prompts)')
171
+ .option('--tool <tool>', 'CLI tool to use', 'gemini')
172
+ .option('--mode <mode>', 'Execution mode: analysis, write, auto', 'analysis')
173
+ .option('--model <model>', 'Model override')
174
+ .option('--cd <path>', 'Working directory')
175
+ .option('--includeDirs <dirs>', 'Additional directories (--include-directories for gemini/qwen, --add-dir for codex/claude)')
176
+ .option('--timeout <ms>', 'Timeout in milliseconds', '300000')
177
+ .option('--stream', 'Enable streaming output (default: non-streaming with caching)')
178
+ .option('--limit <n>', 'History limit')
179
+ .option('--status <status>', 'Filter by status')
180
+ .option('--category <category>', 'Execution category: user, internal, insight', 'user')
181
+ .option('--resume [id]', 'Resume previous session (empty=last, or execution ID, or comma-separated IDs for merge)')
182
+ .option('--id <id>', 'Custom execution ID (e.g., IMPL-001-step1)')
183
+ .option('--no-native', 'Force prompt concatenation instead of native resume')
184
+ .option('--cache [items]', 'Cache: comma-separated @patterns and text content')
185
+ .option('--inject-mode <mode>', 'Inject mode: none, full, progressive (default: codex=full, others=none)')
186
+ // Storage options
187
+ .option('--project <path>', 'Project path for storage operations')
188
+ .option('--force', 'Confirm destructive operations')
189
+ .option('--cli-history', 'Target CLI history storage')
190
+ .option('--memory', 'Target memory storage')
191
+ .option('--storage-cache', 'Target cache storage')
192
+ .option('--config', 'Target config storage')
193
+ // Cache subcommand options
194
+ .option('--offset <n>', 'Character offset for cache pagination', '0')
195
+ .option('--output-type <type>', 'Output type: stdout, stderr, both', 'both')
196
+ .option('--turn <n>', 'Turn number for cache (default: latest)')
197
+ .option('--raw', 'Raw output only (no formatting)')
198
+ .action((subcommand, args, options) => cliCommand(subcommand, args, options));
199
+
200
+ // Memory command
201
+ program
202
+ .command('memory [subcommand] [args...]')
203
+ .description('Memory module for context tracking and prompt optimization')
204
+ .option('--type <type>', 'Entity type: file, module, topic (track) OR source type: core_memory, workflow, cli_history (search)')
205
+ .option('--action <action>', 'Action: read, write, mention')
206
+ .option('--value <value>', 'Entity value (file path, etc.)')
207
+ .option('--session <session>', 'Session ID')
208
+ .option('--stdin', 'Read input from stdin (for Claude Code hooks)')
209
+ .option('--source <source>', 'Import source: history, sessions, all', 'all')
210
+ .option('--project <project>', 'Project name filter')
211
+ .option('--limit <n>', 'Number of results (prompt search)', '20')
212
+ .option('--sort <field>', 'Sort by: heat, reads, writes', 'heat')
213
+ .option('--json', 'Output as JSON')
214
+ .option('--context <text>', 'Current task context')
215
+ .option('--older-than <age>', 'Age threshold for pruning', '30d')
216
+ .option('--dry-run', 'Preview without deleting')
217
+ .option('--id <id>', 'Memory/session ID (for embed command)')
218
+ .option('--force', 'Force re-embed all chunks')
219
+ .option('--batch-size <n>', 'Batch size for embedding', '8')
220
+ .option('--top-k <n>', 'Number of semantic search results', '10')
221
+ .option('--min-score <f>', 'Minimum similarity score for semantic search', '0.5')
222
+ .action((subcommand, args, options) => memoryCommand(subcommand, args, options));
223
+
224
+ // Core Memory command
225
+ program
226
+ .command('core-memory [subcommand] [args...]')
227
+ .description('Manage core memory entries for strategic context')
228
+ .option('--id <id>', 'Memory ID')
229
+ .option('--all', 'Archive all memories')
230
+ .option('--before <date>', 'Archive memories before date (YYYY-MM-DD)')
231
+ .option('--interactive', 'Interactive selection')
232
+ .option('--archived', 'List archived memories')
233
+ .option('--limit <n>', 'Number of results', '50')
234
+ .option('--json', 'Output as JSON')
235
+ .option('--force', 'Skip confirmation')
236
+ .option('--tool <tool>', 'Tool to use for summary: gemini, qwen', 'gemini')
237
+ .option('--auto', 'Run auto-clustering')
238
+ .option('--scope <scope>', 'Auto-cluster scope: all, recent, unclustered', 'recent')
239
+ .option('--create', 'Create new cluster')
240
+ .option('--name <name>', 'Cluster name')
241
+ .option('--members <ids>', 'Cluster member IDs (comma-separated)')
242
+ .option('--status <status>', 'Cluster status filter')
243
+ .option('--level <level>', 'Context level: metadata, keyFiles, full')
244
+ .option('--delete', 'Delete a cluster')
245
+ .option('--merge <ids>', 'Merge clusters into target (comma-separated source IDs)')
246
+ .option('--dedup', 'Deduplicate clusters by merging similar ones')
247
+ .option('--output <file>', 'Output file path for export')
248
+ .option('--overwrite', 'Overwrite existing memories when importing')
249
+ .option('--prefix <prefix>', 'Add prefix to imported memory IDs')
250
+ .action((subcommand, args, options) => coreMemoryCommand(subcommand, args, options));
251
+
252
+ // Hook command - CLI endpoint for Claude Code hooks
253
+ program
254
+ .command('hook [subcommand] [args...]')
255
+ .description('CLI endpoint for Claude Code hooks (session-context, notify)')
256
+ .option('--stdin', 'Read input from stdin (for Claude Code hooks)')
257
+ .option('--session-id <id>', 'Session ID')
258
+ .option('--prompt <text>', 'Prompt text')
259
+ .option('--type <type>', 'Context type: session-start, context')
260
+ .action((subcommand, args, options) => hookCommand(subcommand, args, options));
261
+
262
+ program.parse(argv);
263
+ }