Commit Graph

6 Commits

  • fix(hooks): use \${CLAUDE_PLUGIN_ROOT} so plugin path expands at runtime
    Hook echo commands referenced \${PLUGIN_DIR}, which Claude Code does not
    inject into hook commands. The documented variable is \${CLAUDE_PLUGIN_ROOT}
    (used elsewhere in skills/understand/SKILL.md and friends). Also switched
    the surrounding single quotes to double quotes so the variable actually
    expands at runtime instead of being passed literally.
    
    Without this fix, the auto-update hook silently sent Claude a non-existent
    file path, so the knowledge graph never incrementally updated even when
    autoUpdate: true was configured.
    
    Builds on the direction identified in #96; closes #96.
    
    Co-Authored-By: xiaolai <lixiaolai@gmail.com>
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
  • fix: use printf instead of echo to pipe TOOL_INPUT into grep
    echo interprets escape sequences and flags (e.g. -e, -n) in some
    shells, which can corrupt or truncate the hook event JSON before it
    reaches grep. printf '%s' passes the value as a plain string with
    no interpretation, eliminating any risk of mishandled special chars.
    
    Co-Authored-By: Claude Code <noreply@anthropic.com>
  • chore: remove old prompt templates and update hook references
    Delete the 5 prompt template files from skills/understand/ now that
    they live in agents/. Update auto-update-prompt.md hook to reference
    agent definitions instead of deleted prompt files.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
  • fix: use POSIX-compatible pipe instead of bash herestring in hooks
    The PostToolUse hook used `<<<` (bash herestring) which fails when
    Claude Code runs hooks under `/bin/sh`. Replace with `echo | grep`
    for POSIX compatibility.
  • fix: address review findings — sort mutation, injection, directory baseline, error handling
    - C1: use [...array].sort() to avoid mutating fingerprint inputs
    - C2: replace echo piping with here-string to prevent shell injection in hooks
    - M1/M2: add allKnownFiles param to classifyUpdate for correct directory baseline
    - M3: add try-catch to loadFingerprints for corrupted JSON resilience
    - M5: add hasStructuralAnalysis flag for conservative no-tree-sitter classification
    - m3: replace fragile sed with node JSON.parse in SessionStart hook
    - Add 7 new tests covering all fixes
    
    Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
  • feat: add hooks for auto-update prompts and change classification logic
    - Introduced hooks in `hooks.json` for PostToolUse and SessionStart events to prompt users about knowledge graph updates based on commit and session changes.
    - Implemented `change-classifier.ts` to classify updates based on structural changes, including SKIP, PARTIAL_UPDATE, ARCHITECTURE_UPDATE, and FULL_UPDATE actions.
    - Added comprehensive tests for change classification in `change-classifier.test.ts` to ensure correct behavior across various scenarios.
    - Created `fingerprint.ts` to manage file fingerprints, including content hashing, structural analysis, and comparison of fingerprints to detect changes.
    - Developed tests for fingerprint extraction and comparison in `fingerprint.test.ts` to validate functionality and ensure accurate change detection.