feat: add systemMessage support for SessionStart hook and tune defaults

Add systemMessage field to HookResult so SessionStart can display a
colored timeline directly to the user in the CLI. The handler now
parallel-fetches both markdown (for Claude context) and ANSI-colored
(for user display) timelines, appending a viewer URL link.

Also update default settings to hide verbose token columns (read/work
tokens, savings amount) and disable full observation expansion, keeping
the cleaner index-only view by default.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-02-16 00:05:13 -05:00
parent 5ccaf40ad0
commit 34358ab33d
7 changed files with 46 additions and 28 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5 -1
View File
@@ -17,7 +17,11 @@ export const claudeCodeAdapter: PlatformAdapter = {
},
formatOutput(result) {
if (result.hookSpecificOutput) {
return { hookSpecificOutput: result.hookSpecificOutput };
const output: Record<string, unknown> = { hookSpecificOutput: result.hookSpecificOutput };
if (result.systemMessage) {
output.systemMessage = result.systemMessage;
}
return output;
}
return { continue: result.continue ?? true, suppressOutput: result.suppressOutput ?? true };
}
+14 -3
View File
@@ -48,14 +48,25 @@ export const contextHandler: EventHandler = {
};
}
const result = await response.text();
const additionalContext = result.trim();
// Fetch both markdown (for Claude context) and colored (for user display) in parallel
const colorUrl = `${url}&colors=true`;
const [contextResult, colorResult] = await Promise.all([
response.text(),
fetch(colorUrl).then(r => r.ok ? r.text() : '').catch(() => '')
]);
const additionalContext = contextResult.trim();
const coloredTimeline = colorResult.trim();
const systemMessage = coloredTimeline
? `${coloredTimeline}\n\nView Observations Live @ http://localhost:${port}`
: undefined;
return {
hookSpecificOutput: {
hookEventName: 'SessionStart',
additionalContext
}
},
systemMessage
};
} catch (error) {
// Worker unreachable — return empty context gracefully
+1
View File
@@ -16,6 +16,7 @@ export interface HookResult {
continue?: boolean;
suppressOutput?: boolean;
hookSpecificOutput?: { hookEventName: string; additionalContext: string };
systemMessage?: string;
exitCode?: number;
}
+4 -4
View File
@@ -95,15 +95,15 @@ export class SettingsDefaultsManager {
CLAUDE_CODE_PATH: '', // Empty means auto-detect via 'which claude'
CLAUDE_MEM_MODE: 'code', // Default mode profile
// Token Economics
CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS: 'true',
CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS: 'true',
CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT: 'true',
CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS: 'false',
CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS: 'false',
CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT: 'false',
CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT: 'true',
// Observation Filtering
CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES: DEFAULT_OBSERVATION_TYPES_STRING,
CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS: DEFAULT_OBSERVATION_CONCEPTS_STRING,
// Display Configuration
CLAUDE_MEM_CONTEXT_FULL_COUNT: '5',
CLAUDE_MEM_CONTEXT_FULL_COUNT: '0',
CLAUDE_MEM_CONTEXT_FULL_FIELD: 'narrative',
CLAUDE_MEM_CONTEXT_SESSION_COUNT: '10',
// Feature Toggles