Enhance context hook output formatting and add file aggregation for sessions

- Updated contextHook to support colorized output for terminal and JSON format for hooks.
- Introduced ANSI color codes for improved readability in terminal output.
- Modified the output structure to include session details with color formatting.
- Added a new method in SessionStore to aggregate files read and modified from observations for a session.
- Improved error handling for JSON parsing of file data in the new method.
This commit is contained in:
Alex Newman
2025-10-21 16:37:16 -04:00
parent fe861a85bd
commit df0f3fd96c
10 changed files with 406 additions and 219 deletions
+5 -9
View File
@@ -9,21 +9,17 @@ import { stdin } from 'process';
try {
if (stdin.isTTY) {
const contextOutput = contextHook();
const result = {
hookSpecificOutput: {
hookEventName: "SessionStart",
additionalContext: contextOutput
}
};
console.log(JSON.stringify(result));
// Running manually from terminal - print formatted output with colors
const contextOutput = contextHook(undefined, true);
console.log(contextOutput);
process.exit(0);
} else {
// Running from hook - wrap in JSON format without colors
let input = '';
stdin.on('data', (chunk) => input += chunk);
stdin.on('end', () => {
const parsed = input.trim() ? JSON.parse(input) : undefined;
const contextOutput = contextHook(parsed);
const contextOutput = contextHook(parsed, false);
const result = {
hookSpecificOutput: {
hookEventName: "SessionStart",