feat: Implement Phase 1 of SDK agent architecture with hook integration

- Added CLI commands for context, new session, save observation, and summary.
- Created HooksDatabase for managing SDK sessions and observations.
- Implemented migration 004 to add new tables: sdk_sessions, observation_queue, observations, and session_summaries.
- Developed hook functions for context display, session initialization, observation queuing, and session finalization.
- Added comprehensive tests for database schema and hook functionality.
- Documented Phase 1 implementation in PHASE1-COMPLETE.md.
This commit is contained in:
Alex Newman
2025-10-15 19:06:51 -04:00
parent 917ab9740c
commit e81ea69143
12 changed files with 1294 additions and 129 deletions
+50
View File
@@ -223,6 +223,56 @@ program
.option('--save', 'Save the generated title to the database (requires --session-id)')
.action(generateTitle);
// Hook commands (for Claude Code hook integration)
program
.command('context')
.description('SessionStart hook - show recent session context')
.action(async () => {
const { contextHook } = await import('../hooks/index.js');
const input = await readStdin();
contextHook(JSON.parse(input));
});
program
.command('new')
.description('UserPromptSubmit hook - initialize SDK session')
.action(async () => {
const { newHook } = await import('../hooks/index.js');
const input = await readStdin();
newHook(JSON.parse(input));
});
program
.command('save')
.description('PostToolUse hook - queue observation')
.action(async () => {
const { saveHook } = await import('../hooks/index.js');
const input = await readStdin();
saveHook(JSON.parse(input));
});
program
.command('summary')
.description('Stop hook - finalize session')
.action(async () => {
const { summaryHook } = await import('../hooks/index.js');
const input = await readStdin();
summaryHook(JSON.parse(input));
});
// Helper function to read stdin
async function readStdin(): Promise<string> {
return new Promise((resolve) => {
let data = '';
process.stdin.on('data', chunk => {
data += chunk;
});
process.stdin.on('end', () => {
resolve(data);
});
});
}
// </Block> =======================================
// <Block> 1.11 ===================================