feat: 添加钩子命令,简化 Claude Code 钩子操作接口,支持会话上下文加载和通知功能

This commit is contained in:
catlog22
2025-12-21 23:28:19 +08:00
parent 6d3f10d1d7
commit 210f0f1012
7 changed files with 432 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ import { sessionCommand } from './commands/session.js';
import { cliCommand } from './commands/cli.js';
import { memoryCommand } from './commands/memory.js';
import { coreMemoryCommand } from './commands/core-memory.js';
import { hookCommand } from './commands/hook.js';
import { readFileSync, existsSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
@@ -229,5 +230,15 @@ export function run(argv: string[]): void {
.option('--prefix <prefix>', 'Add prefix to imported memory IDs')
.action((subcommand, args, options) => coreMemoryCommand(subcommand, args, options));
// Hook command - CLI endpoint for Claude Code hooks
program
.command('hook [subcommand] [args...]')
.description('CLI endpoint for Claude Code hooks (session-context, notify)')
.option('--stdin', 'Read input from stdin (for Claude Code hooks)')
.option('--session-id <id>', 'Session ID')
.option('--prompt <text>', 'Prompt text')
.option('--type <type>', 'Context type: session-start, context')
.action((subcommand, args, options) => hookCommand(subcommand, args, options));
program.parse(argv);
}