Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
TypeScript antigravity-skillsbusiness-knowledgeclaude-codeclaude-skillscodebase-analysiscodexcodex-skillsdeveloper-tools-ai-agentgemini-cli-skillskarpathy-llm-wikiknowledge-baseknowledge-graphmemoryopencode-skillspi-agentunderstandcodevibe-coding
fix(hooks): emit PostToolUse additional context
KumamuKuma10842f1168af
diff --git a/tests/hooks/post-tool-use-auto-update.test.mjs b/tests/hooks/post-tool-use-auto-update.test.mjsindex e49d6ec3..555eb7a8 100644--- a/tests/hooks/post-tool-use-auto-update.test.mjs+++ b/tests/hooks/post-tool-use-auto-update.test.mjs@@ -41,13 +41,23 @@ function runHook({}describe('PostToolUse auto-update hook', () => {- it('emits the auto-update instruction after a git commit', () => {+ it('injects the auto-update instruction as PostToolUse additional context', () => {const result = runHook();+ const output = JSON.parse(result.stdout);expect(result.status).toBe(0);expect(result.stderr).toBe('');- expect(result.stdout).toContain('[understand-anything] Commit detected');- expect(result.stdout).toContain(`${result.pluginRoot}/hooks/auto-update-prompt.md`);+ expect(output).toEqual({+ hookSpecificOutput: {+ hookEventName: 'PostToolUse',+ additionalContext: expect.stringContaining(+ '[understand-anything] Commit detected',+ ),+ },+ });+ expect(output.hookSpecificOutput.additionalContext).toContain(+ `${result.pluginRoot}/hooks/auto-update-prompt.md`,+ );});it('stays silent for unrelated Bash commands', () => {diff --git a/understand-anything-plugin/hooks/post-tool-use-auto-update.mjs b/understand-anything-plugin/hooks/post-tool-use-auto-update.mjsindex 4b165d28..fb7dad6d 100644--- a/understand-anything-plugin/hooks/post-tool-use-auto-update.mjs+++ b/understand-anything-plugin/hooks/post-tool-use-auto-update.mjs@@ -38,11 +38,19 @@ async function main() {if (!existsSync(`${dataDir}/knowledge-graph.json`)) return;const pluginRoot = process.env.CLAUDE_PLUGIN_ROOT ?? '';- process.stdout.write(+ const additionalContext =`[understand-anything] Commit detected with auto-update enabled. ` +- `You MUST read the file at ${pluginRoot}/hooks/auto-update-prompt.md ` +- 'and execute its instructions to incrementally update the knowledge graph. ' +- 'Do not ask the user for confirmation — just do it.',+ `You MUST read the file at ${pluginRoot}/hooks/auto-update-prompt.md ` ++ 'and execute its instructions to incrementally update the knowledge graph. ' ++ 'Do not ask the user for confirmation — just do it.';++ process.stdout.write(+ JSON.stringify({+ hookSpecificOutput: {+ hookEventName: 'PostToolUse',+ additionalContext,+ },+ }),);}