7 Commits

  • fix(hooks): emit suggest-compact via hookSpecificOutput stdout
    The threshold and interval suggestions in suggest-compact.js are written
    to stderr via log(). Per the Claude Code hooks guide, non-blocking
    PreToolUse stderr (exit code 0) is only captured in the debug log — it
    does not reach the model. As shipped, the script's nudge to /compact is
    silent on Claude Code 2.1.x.
    
    Fix: alongside the existing log() call (kept for debug-log capture),
    emit the same suggestion as structured JSON on stdout:
    
      { hookSpecificOutput: {
          hookEventName: "PreToolUse",
          additionalContext: msg
      } }
    
    This is the documented mechanism for a PreToolUse hook to inject
    context into the next model turn without blocking the tool call.
    
    Verified end-to-end on Claude Code 2.1.142 (VSCode native extension,
    Windows 11) — the additionalContext now surfaces in the next turn as
    a <system-reminder> block. Counter increment and exit code behavior
    unchanged.
    
    Tests: 4 new cases in tests/hooks/suggest-compact.test.js covering
    stdout JSON at threshold, stdout JSON at +25 interval, silence below
    threshold, and stderr-retention for the debug log. Suite goes from
    19/19 -> 23/23 (suggest-compact) and full run-all stays clean for
    the unaffected suites (the 4 pre-existing Windows broken-symlink
    failures in ci/validators, lib/session-manager, and lib/utils are
    unrelated to this change).
  • test: add 3 tests for suggest-compact, session-aliases, typecheck (Round 64)
    - suggest-compact: 'default' session ID fallback when CLAUDE_SESSION_ID empty
    - session-aliases: loadAliases backfills missing version and metadata fields
    - post-edit-typecheck: valid JSON without tool_input passes through unchanged
    
    Total: 797 tests, all passing
  • fix: add cwd to prettier hook, consistent process.exit(0), and stdout pass-through
    - post-edit-format.js: add cwd based on file directory so npx resolves
      correct local prettier binary
    - post-edit-typecheck.js, post-edit-format.js: replace console.log(data)
      with process.stdout.write(data) to avoid trailing newline corruption
    - Add process.exit(0) to 4 hooks for consistent termination
      (check-console-log, post-edit-console-warn, post-edit-format,
      post-edit-typecheck)
    - run-all.js: switch from execSync to spawnSync so stderr is visible
      on the success path (hook warnings were silently discarded)
    - Add 21 tests: cwd verification, process.exit(0) checks, exact
      stdout pass-through, extension edge cases, exclusion pattern
      matching, threshold boundary values (630 → 651)
  • test: add 22 tests for readStdinJson, evaluate-session config, and suggest-compact hook
    - utils.test.js: 5 tests for readStdinJson maxSize truncation, whitespace-only stdin, trailing whitespace, and BOM prefix handling
    - evaluate-session.test.js: 4 tests for config file parsing, assistant-only transcripts, malformed JSON lines, and empty stdin
    - suggest-compact.test.js: 13 new tests covering counter file creation/increment, threshold suggestion, interval suggestion, env var handling, corrupted/empty counter files, and session isolation