claude-git-hooks 2.35.3 → 2.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,141 @@ Todos los cambios notables en este proyecto se documentarán en este archivo.
5
5
  El formato está basado en [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  y este proyecto adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.43.0] - 2026-04-30
9
+
10
+ ### ✨ Added
11
+ - Headless mode for git hooks via CLAUDE_HOOKS_HEADLESS=1 environment variable, routing all LLM calls through the Anthropic SDK instead of the Claude CLI for CI/ECS environments (CT-805)
12
+ - Unit tests for pre-commit and prepare-commit-msg hooks covering headless mode propagation and error messaging (CT-805)
13
+
14
+ ### 🔧 Changed
15
+ - Hook error messages now show SDK-specific guidance ("Check that ANTHROPIC_API_KEY is set") in headless mode and CLI-specific guidance otherwise (CT-805)
16
+ - Headless flag propagated through full analysis chain: runAnalysis, orchestrateBatches, judgeAndFix, and analyzeCode all accept and forward the headless option (CT-805)
17
+
18
+ ### 🐛 Fixed
19
+ - Cross-platform path separator handling in hooks-verified marker test (#150)
20
+ - Contract documentation test updated to match current CLAUDE.md section heading (#150)
21
+
22
+
23
+ ## [2.42.0] - 2026-04-30
24
+
25
+ ### ✨ Added
26
+ - Added `Hooks-Verified: true` Git trailer to commits that pass pre-commit analysis, coordinated via a tree-SHA marker file in `.git/` (CT-802)
27
+ - Added `hooks-verified-marker.js` utility for marker file CRUD between pre-commit (writes) and prepare-commit-msg (reads/validates/consumes)
28
+ - Added `getStagedTreeSha()`, `hasHooksVerifiedTrailer()`, and `appendTrailer()` to git-operations for tree fingerprinting and canonical trailer formatting via `git interpret-trailers`
29
+ - Added hooks-verified marker writing to the `analyze` command when staged-scope analysis completes without critical/blocker issues (CT-802)
30
+
31
+ ### 🔧 Changed
32
+ - Reorganized CLAUDE.md project documentation into `.library/` structure with indexed books, shelves, and domain reading lists (#149)
33
+ - Updated commit-workflow domain reading list and hook books to document the new Hooks-Verified trailer pipeline
34
+
35
+ ### 🐛 Fixed
36
+ - Deferred trailer append in prepare-commit-msg until the final message is written, preventing the auto-generated message flow from overwriting the `Hooks-Verified` trailer (CT-802)
37
+
38
+
39
+ ## [2.41.1] - 2026-04-30
40
+
41
+ ### ✨ Added
42
+ - Added headless mode and JSON output support for `analyze`, `create-pr`, and `lint` commands (#148, CT-799)
43
+
44
+ ### 🔧 Changed
45
+ - Redistributed CLAUDE.md content into `.library/` — new `conventions.md` coding standards reference, enriched book indexes with key exports, and expanded domain quick-reference tables
46
+
47
+
48
+ ## [2.41.0] - 2026-04-30
49
+
50
+ ### ✨ Added
51
+ - Added `--headless` flag to `analyze`, `create-pr`, and `lint` commands for non-interactive CI execution (CT-799)
52
+ - Added `--format json` output mode that emits a single structured JSON line to stdout, routing all other output to stderr (CT-799)
53
+ - Added `CostTracker` integration in headless mode for `analyze` and `create-pr` to report Claude API costs in JSON output (CT-799)
54
+ - Added exit code 2 for usage errors (e.g., `--format json` without `--headless`) across `analyze`, `create-pr`, and `lint` (CT-799)
55
+ - Added early fatal guard for detached HEAD state in `create-pr` with actionable fix instructions (CT-804, #147)
56
+
57
+ ### 🔧 Changed
58
+ - Updated `interactive-ui.js` display helpers (`showSuccess`, `showError`, `showWarning`, `showInfo`) to delegate to `logger.js`, enabling JSON mode output routing to stderr
59
+ - Updated `displayLintResults` to accept a `{ silent }` option that suppresses decorative output in JSON mode
60
+ - Updated `create-pr` headless mode to resolve all 11 interactive decision points with documented defaults (auto-push, squash for unknown strategy, skip tag prompts)
61
+
62
+
63
+ ## [2.40.0] - 2026-04-30
64
+
65
+ ### ✨ Added
66
+ - Added early detached HEAD detection in `create-pr` command with actionable error message and remediation steps (CT-804)
67
+ - Added Operational Contract documentation in CLAUDE.md defining runtime environment requirements for CI/container orchestrators
68
+ - Added CWD & Branch Contract reference book (`.library/books/cwd-contract.md`) with command-level HEAD tolerance matrix
69
+ - Added smoke tests to prevent accidental deletion of contract documentation
70
+
71
+ ### 🔧 Changed
72
+ - Moved branch detection earlier in `create-pr` flow (before interactive prompts) to fail fast on detached HEAD
73
+ - Replaced `error()` + `return` with `fatal()` for detached HEAD guard in `create-pr`, ensuring consistent process termination
74
+
75
+
76
+ ## [2.39.0] - 2026-04-29
77
+
78
+ ### ✨ Added
79
+ - Added `--headless` flag to `install` command for CI/container environments — skips all side effects: dependency checks, git config, `.gitignore` updates, shell completions, linter availability check, and GitHub token setup (CT-803)
80
+ - Added `--verify-sdk` flag to `install` command — opt-in 1-token SDK ping (haiku, 10s timeout) to validate `ANTHROPIC_API_KEY` after installation; exits 1 in headless mode on failure, warns in interactive mode (CT-803)
81
+ - Added `verifySDKConnection()` to `claude-client.js` — minimal SDK connectivity check that delegates to `_executeSDK('ping')` and never throws (CT-803)
82
+ - Added `--headless` bypass for authorization guard in CLI router — CI runners skip RBAC checks entirely; governance enforced at branch-protection level (CT-803)
83
+
84
+ ### 🔧 Changed
85
+ - Install orchestration expanded from 20 to 21 steps to accommodate the new SDK verification step
86
+
87
+ ### ⚠️ Deprecated
88
+ - Deprecated `--skip-auth` flag on `install` command — use `--headless` instead for full CI/container mode; logs a deprecation warning when used
89
+
90
+
91
+ ## [2.38.0] - 2026-04-29
92
+
93
+ ### ✨ Added
94
+ - Added headless mode (`--headless`) for `analyze-pr` command — skips all interactive prompts for CI/automation pipelines
95
+ - Added JSON output mode (`--format json`) for `analyze-pr` — emits a single structured JSON document to stdout with verdict, severity counts, comments, and cost data (requires `--headless`)
96
+ - Added cost tracking for headless `analyze-pr` runs via `CostTracker` integration (#144)
97
+ - Added Langfuse trace flushing after headless SDK calls for observability (#144)
98
+ - Added `fatal()` function to helpers.js for process-terminating errors, separating logging from exit behavior
99
+ - Added JSON mode to logger (`setJSONMode`) — routes `info`/`success`/`warning`/`debug` to stderr, reserving stdout for structured output
100
+
101
+ ### 🔧 Changed
102
+ - Changed `error()` in helpers.js to log-only (no longer calls `process.exit`) — callers needing termination should use `fatal()` instead
103
+ - Changed `bin/claude-hooks` to use `fatal()` for unknown command errors
104
+ - Changed `helpers.info()`, `helpers.success()`, and `helpers.warning()` to delegate to logger equivalents, respecting JSON mode routing
105
+
106
+
107
+ ## [2.37.0] - 2026-04-29
108
+
109
+ ### ✨ Added
110
+ - Added cost tracking for headless SDK calls — per-call USD cost calculation with cache token multipliers, hardcoded Anthropic pricing table, and CloudWatch-friendly structured JSON logs (`cost-tracker.js`)
111
+ - Added optional Langfuse tracing integration for headless SDK calls — records LLM generations (model, tokens, cost, prompt/response) as traces; disabled by default, activated via `LANGFUSE_ENABLED` env var (`langfuse-tracer.js`)
112
+ - Added `costTracker` option to `analyzeCode()`, `executeClaudeWithRetry()`, and `executeClaude()` for external cost accumulation across multiple calls
113
+ - Added `._costs` field to `analyzeCode()` results in headless mode — contains per-call token usage and USD cost snapshot
114
+
115
+ ### 🔧 Changed
116
+ - Changed `_executeSDK()` return type from plain text string to `{ text, usage, model }` — callers now receive normalized token usage and resolved model ID
117
+ - Normalized SDK usage fields with defaults (0 for missing cache token counts) to ensure consistent downstream processing
118
+ - Updated library documentation with new books for `cost-tracker.js` and `langfuse-tracer.js`, updated `claude-client.js` book with observability details
119
+
120
+
121
+ ## [2.36.0] - 2026-04-28
122
+
123
+ ### ✨ Added
124
+ - Added SDK adapter for headless mode in claude-client — dual execution backend: CLI spawn for local/interactive use, or Anthropic SDK direct calls for headless/ECS environments (#141)
125
+ - Added `_executeSDK()` function for direct Anthropic SDK calls with lazy-loaded `@anthropic-ai/sdk` dependency
126
+ - Added `resolveModelAlias()` and `MODEL_ALIASES` constant with environment variable overrides (`CLAUDE_MODEL_SONNET`, `CLAUDE_MODEL_OPUS`, `CLAUDE_MODEL_HAIKU`)
127
+ - Added `headless` option to `analyzeCode()`, `executeClaudeWithRetry()`, and `executeClaude()` for SDK-based execution
128
+ - Added `claude.defaultModel` to hardcoded config as fallback model for SDK headless mode
129
+
130
+ ### 🔧 Changed
131
+ - Changed `analyzeCode()` to return parsed JSON object instead of raw response text
132
+ - Changed `executeClaude()` to branch between SDK path (when `headless: true`) and CLI spawn path
133
+ - SDK errors marked with `fromSDK: true` are no longer retried by `withRetry` — the Anthropic SDK already retries internally (2 attempts for rate limits, timeouts, and 5xx)
134
+ - Updated claude-client library book to document dual-backend architecture, SDK gotchas, and new exports
135
+
136
+ ### 🐛 Fixed
137
+ - Fixed Spotless timeouts and cmd.exe per-file mode (#141)
138
+
139
+ ### 🗑️ Removed
140
+ - Removed `.library/CATEGORY_COMPLETENESS_REPORT.md` and `.library/CLASSIFICATION_REPORT.md` reports
141
+
142
+
8
143
  ## [2.35.3] - 2026-04-22
9
144
 
10
145
  ### ✨ Added