Skip to content

Commit 6e16997

Browse files
committed
feat(claude-code): hook emitter wires real Claude work → inspector
The producer side of the real-data wire-up. After installing, every PreToolUse / PostToolUse / UserPromptSubmit / Stop / etc. event from Claude Code emits a bridge JSONL line to a local file, where the inspector's --tail mode picks it up. - scripts/hooks/claude-code-emit.mjs (~ stdlib-only Node ESM): reads the hook payload from stdin, translates by --event flag to a bridge wire-format event, appends to ~/.cache/enchanter/claude- code.jsonl (XDG_CACHE_HOME / LOCALAPPDATA / HOME-cache fallback). Errors → sibling .err file; exit 0 always so a misconfigured hook never blocks Claude Code. Truncates large fields to 16 KB and rotates the file at 5 MB to .1 to prevent unbounded growth. - scripts/hooks/install-hooks.mjs: idempotent installer that adds the hook entries to ~/.claude/settings.json. Run once; re-run to uninstall via --uninstall. - docs/claude-code-integration.md: walkthrough + hook → wire-event mapping table + privacy notes (data stays on the local machine, truncated, file-rotated). - README.md: short subsection pointing at the doc. - bridge.ts: tighten the typecheck guard on event.phase (was comparing a typed enum to '' which TS rejects). End-to-end loop: cd client/enchanter node scripts/hooks/install-hooks.mjs enchanter inspect --tail ~/.cache/enchanter/claude-code.jsonl # ... use Claude Code in another terminal; cockpit lights up
1 parent 3673abd commit 6e16997

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/observability/bridge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function toWireRecord(event: EnchantedEvent): Record<string, unknown> {
8282
) {
8383
record.session_id = event.session_id;
8484
}
85-
if (record.phase === undefined && typeof event.phase === 'string' && event.phase !== '') {
85+
if (record.phase === undefined && typeof event.phase === 'string' && (event.phase as string).length > 0) {
8686
record.phase = event.phase;
8787
}
8888
if (record.plugin === undefined && typeof event.source === 'string' && event.source !== '') {

0 commit comments

Comments
 (0)