@carboncode/cli 0.1.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.
Files changed (159) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSES/DeepSeek-Reasonix-MIT.txt +21 -0
  3. package/README.md +109 -0
  4. package/README.zh-CN.md +91 -0
  5. package/THIRD_PARTY_NOTICES.md +14 -0
  6. package/dashboard/app.css +3233 -0
  7. package/dashboard/dist/app.js +30444 -0
  8. package/dashboard/dist/app.js.map +1 -0
  9. package/dashboard/dist/vendor-hljs.css +10 -0
  10. package/dashboard/dist/vendor-uplot.css +1 -0
  11. package/dashboard/index.html +19 -0
  12. package/data/deepseek-tokenizer.json.gz +0 -0
  13. package/dist/cli/acp-35C4ME6Y.js +711 -0
  14. package/dist/cli/acp-35C4ME6Y.js.map +1 -0
  15. package/dist/cli/chat-A6UJDPGV.js +51 -0
  16. package/dist/cli/chat-A6UJDPGV.js.map +1 -0
  17. package/dist/cli/chunk-2425HK6U.js +54 -0
  18. package/dist/cli/chunk-2425HK6U.js.map +1 -0
  19. package/dist/cli/chunk-25T6CVUP.js +172 -0
  20. package/dist/cli/chunk-25T6CVUP.js.map +1 -0
  21. package/dist/cli/chunk-2UQP6H6T.js +31 -0
  22. package/dist/cli/chunk-2UQP6H6T.js.map +1 -0
  23. package/dist/cli/chunk-3OAR6NVL.js +96 -0
  24. package/dist/cli/chunk-3OAR6NVL.js.map +1 -0
  25. package/dist/cli/chunk-3T6VBZCL.js +54 -0
  26. package/dist/cli/chunk-3T6VBZCL.js.map +1 -0
  27. package/dist/cli/chunk-4IBIPQVB.js +153 -0
  28. package/dist/cli/chunk-4IBIPQVB.js.map +1 -0
  29. package/dist/cli/chunk-4MQ3VURH.js +3106 -0
  30. package/dist/cli/chunk-4MQ3VURH.js.map +1 -0
  31. package/dist/cli/chunk-4TVNJWMA.js +11619 -0
  32. package/dist/cli/chunk-4TVNJWMA.js.map +1 -0
  33. package/dist/cli/chunk-4VR6XF4P.js +341 -0
  34. package/dist/cli/chunk-4VR6XF4P.js.map +1 -0
  35. package/dist/cli/chunk-5QCB62C4.js +25319 -0
  36. package/dist/cli/chunk-5QCB62C4.js.map +1 -0
  37. package/dist/cli/chunk-6OWJV3YW.js +390 -0
  38. package/dist/cli/chunk-6OWJV3YW.js.map +1 -0
  39. package/dist/cli/chunk-7EO27TB3.js +130 -0
  40. package/dist/cli/chunk-7EO27TB3.js.map +1 -0
  41. package/dist/cli/chunk-7L2WTRNU.js +308 -0
  42. package/dist/cli/chunk-7L2WTRNU.js.map +1 -0
  43. package/dist/cli/chunk-BHTZFEYE.js +47 -0
  44. package/dist/cli/chunk-BHTZFEYE.js.map +1 -0
  45. package/dist/cli/chunk-BSGCXZQN.js +343 -0
  46. package/dist/cli/chunk-BSGCXZQN.js.map +1 -0
  47. package/dist/cli/chunk-BSINVTTL.js +464 -0
  48. package/dist/cli/chunk-BSINVTTL.js.map +1 -0
  49. package/dist/cli/chunk-CPKCNHRR.js +323 -0
  50. package/dist/cli/chunk-CPKCNHRR.js.map +1 -0
  51. package/dist/cli/chunk-CXVWUPA3.js +96 -0
  52. package/dist/cli/chunk-CXVWUPA3.js.map +1 -0
  53. package/dist/cli/chunk-D5NFKRGO.js +160 -0
  54. package/dist/cli/chunk-D5NFKRGO.js.map +1 -0
  55. package/dist/cli/chunk-ECHSFYOY.js +109 -0
  56. package/dist/cli/chunk-ECHSFYOY.js.map +1 -0
  57. package/dist/cli/chunk-FEZK652I.js +3644 -0
  58. package/dist/cli/chunk-FEZK652I.js.map +1 -0
  59. package/dist/cli/chunk-GALC45Q2.js +696 -0
  60. package/dist/cli/chunk-GALC45Q2.js.map +1 -0
  61. package/dist/cli/chunk-IAUOP25G.js +2984 -0
  62. package/dist/cli/chunk-IAUOP25G.js.map +1 -0
  63. package/dist/cli/chunk-ILJOIQ5W.js +163 -0
  64. package/dist/cli/chunk-ILJOIQ5W.js.map +1 -0
  65. package/dist/cli/chunk-IX6XI2RG.js +225 -0
  66. package/dist/cli/chunk-IX6XI2RG.js.map +1 -0
  67. package/dist/cli/chunk-J5BYPUB5.js +62795 -0
  68. package/dist/cli/chunk-J5BYPUB5.js.map +1 -0
  69. package/dist/cli/chunk-J5XJHLWM.js +55 -0
  70. package/dist/cli/chunk-J5XJHLWM.js.map +1 -0
  71. package/dist/cli/chunk-JKGYMRX5.js +101 -0
  72. package/dist/cli/chunk-JKGYMRX5.js.map +1 -0
  73. package/dist/cli/chunk-JMBMLOBP.js +26 -0
  74. package/dist/cli/chunk-JMBMLOBP.js.map +1 -0
  75. package/dist/cli/chunk-LN3B5PMX.js +128 -0
  76. package/dist/cli/chunk-LN3B5PMX.js.map +1 -0
  77. package/dist/cli/chunk-M2UFZUX3.js +635 -0
  78. package/dist/cli/chunk-M2UFZUX3.js.map +1 -0
  79. package/dist/cli/chunk-PJS34556.js +809 -0
  80. package/dist/cli/chunk-PJS34556.js.map +1 -0
  81. package/dist/cli/chunk-QJG7OF27.js +655 -0
  82. package/dist/cli/chunk-QJG7OF27.js.map +1 -0
  83. package/dist/cli/chunk-QVC75MR3.js +232 -0
  84. package/dist/cli/chunk-QVC75MR3.js.map +1 -0
  85. package/dist/cli/chunk-S2KIUQKQ.js +378 -0
  86. package/dist/cli/chunk-S2KIUQKQ.js.map +1 -0
  87. package/dist/cli/chunk-S4XVGLRW.js +499 -0
  88. package/dist/cli/chunk-S4XVGLRW.js.map +1 -0
  89. package/dist/cli/chunk-T5TQ4NDT.js +190 -0
  90. package/dist/cli/chunk-T5TQ4NDT.js.map +1 -0
  91. package/dist/cli/chunk-TH756VLN.js +1924 -0
  92. package/dist/cli/chunk-TH756VLN.js.map +1 -0
  93. package/dist/cli/chunk-TUK7OWJA.js +51 -0
  94. package/dist/cli/chunk-TUK7OWJA.js.map +1 -0
  95. package/dist/cli/chunk-U4IJVG32.js +363 -0
  96. package/dist/cli/chunk-U4IJVG32.js.map +1 -0
  97. package/dist/cli/chunk-UI66BH6D.js +624 -0
  98. package/dist/cli/chunk-UI66BH6D.js.map +1 -0
  99. package/dist/cli/chunk-VPMBGAND.js +53 -0
  100. package/dist/cli/chunk-VPMBGAND.js.map +1 -0
  101. package/dist/cli/chunk-WLHH3OSR.js +522 -0
  102. package/dist/cli/chunk-WLHH3OSR.js.map +1 -0
  103. package/dist/cli/chunk-WRN65TRD.js +908 -0
  104. package/dist/cli/chunk-WRN65TRD.js.map +1 -0
  105. package/dist/cli/chunk-X53B3JIX.js +34320 -0
  106. package/dist/cli/chunk-X53B3JIX.js.map +1 -0
  107. package/dist/cli/chunk-XJ5SRLKK.js +50 -0
  108. package/dist/cli/chunk-XJ5SRLKK.js.map +1 -0
  109. package/dist/cli/chunk-YZSXRGFH.js +54 -0
  110. package/dist/cli/chunk-YZSXRGFH.js.map +1 -0
  111. package/dist/cli/code-4TUTAGO5.js +163 -0
  112. package/dist/cli/code-4TUTAGO5.js.map +1 -0
  113. package/dist/cli/commands-KMOZEYCF.js +356 -0
  114. package/dist/cli/commands-KMOZEYCF.js.map +1 -0
  115. package/dist/cli/commit-DTFA56VQ.js +292 -0
  116. package/dist/cli/commit-DTFA56VQ.js.map +1 -0
  117. package/dist/cli/desktop-7N3MHNBD.js +1274 -0
  118. package/dist/cli/desktop-7N3MHNBD.js.map +1 -0
  119. package/dist/cli/devtools-HW3WDT3Q.js +91 -0
  120. package/dist/cli/devtools-HW3WDT3Q.js.map +1 -0
  121. package/dist/cli/diff-E5OWTF4C.js +165 -0
  122. package/dist/cli/diff-E5OWTF4C.js.map +1 -0
  123. package/dist/cli/doctor-IEJQRJMN.js +27 -0
  124. package/dist/cli/doctor-IEJQRJMN.js.map +1 -0
  125. package/dist/cli/events-4625EGXI.js +340 -0
  126. package/dist/cli/events-4625EGXI.js.map +1 -0
  127. package/dist/cli/index.js +3536 -0
  128. package/dist/cli/index.js.map +1 -0
  129. package/dist/cli/mcp-PDI2PDLG.js +277 -0
  130. package/dist/cli/mcp-PDI2PDLG.js.map +1 -0
  131. package/dist/cli/mcp-browse-OSPXOFPZ.js +178 -0
  132. package/dist/cli/mcp-browse-OSPXOFPZ.js.map +1 -0
  133. package/dist/cli/mcp-inspect-QRFVTHMF.js +148 -0
  134. package/dist/cli/mcp-inspect-QRFVTHMF.js.map +1 -0
  135. package/dist/cli/package.json +3 -0
  136. package/dist/cli/prompt-3CDII3UO.js +16 -0
  137. package/dist/cli/prompt-3CDII3UO.js.map +1 -0
  138. package/dist/cli/prune-sessions-KZX4SXKW.js +44 -0
  139. package/dist/cli/prune-sessions-KZX4SXKW.js.map +1 -0
  140. package/dist/cli/replay-HYOSRQIV.js +291 -0
  141. package/dist/cli/replay-HYOSRQIV.js.map +1 -0
  142. package/dist/cli/run-2ZHADOUP.js +220 -0
  143. package/dist/cli/run-2ZHADOUP.js.map +1 -0
  144. package/dist/cli/server-X75PAZG5.js +3572 -0
  145. package/dist/cli/server-X75PAZG5.js.map +1 -0
  146. package/dist/cli/sessions-POOZA5CQ.js +120 -0
  147. package/dist/cli/sessions-POOZA5CQ.js.map +1 -0
  148. package/dist/cli/setup-YLPFI3OH.js +618 -0
  149. package/dist/cli/setup-YLPFI3OH.js.map +1 -0
  150. package/dist/cli/stats-NXJ3TO2D.js +16 -0
  151. package/dist/cli/stats-NXJ3TO2D.js.map +1 -0
  152. package/dist/cli/update-ZUO5MKQ6.js +15 -0
  153. package/dist/cli/update-ZUO5MKQ6.js.map +1 -0
  154. package/dist/cli/version-NXXWE3WN.js +33 -0
  155. package/dist/cli/version-NXXWE3WN.js.map +1 -0
  156. package/dist/index.d.ts +2523 -0
  157. package/dist/index.js +15408 -0
  158. package/dist/index.js.map +1 -0
  159. package/package.json +112 -0
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __cr } from 'node:module'; if (typeof globalThis.require === 'undefined') { globalThis.require = __cr(import.meta.url); }
3
+ import {
4
+ loadPricingOverride
5
+ } from "./chunk-4MQ3VURH.js";
6
+
7
+ // src/telemetry/stats.ts
8
+ var DEEPSEEK_PRICING = {
9
+ "deepseek-v4-flash": { inputCacheHit: 28e-4, inputCacheMiss: 0.14, output: 0.28 },
10
+ "deepseek-v4-pro": { inputCacheHit: 3625e-6, inputCacheMiss: 0.435, output: 0.87 },
11
+ // Compat aliases — priced as v4-flash per the deprecation notice.
12
+ "deepseek-chat": { inputCacheHit: 28e-4, inputCacheMiss: 0.14, output: 0.28 },
13
+ "deepseek-reasoner": { inputCacheHit: 28e-4, inputCacheMiss: 0.14, output: 0.28 }
14
+ };
15
+ function pricingFor(model, path) {
16
+ const defaults = DEEPSEEK_PRICING[model];
17
+ const override = loadPricingOverride(path)[model];
18
+ if (!override) return defaults;
19
+ const pricing = { ...defaults, ...override };
20
+ if (pricing.inputCacheHit === void 0 || pricing.inputCacheMiss === void 0 || pricing.output === void 0) {
21
+ return void 0;
22
+ }
23
+ return pricing;
24
+ }
25
+ var CLAUDE_SONNET_PRICING = { input: 3, output: 15 };
26
+ var DEEPSEEK_CONTEXT_TOKENS = {
27
+ "deepseek-v4-flash": 1e6,
28
+ "deepseek-v4-pro": 1e6,
29
+ "deepseek-chat": 1e6,
30
+ "deepseek-reasoner": 1e6
31
+ };
32
+ var DEFAULT_CONTEXT_TOKENS = 131072;
33
+ function costUsd(model, usage, path) {
34
+ const p = pricingFor(model, path);
35
+ if (!p) return 0;
36
+ return (usage.promptCacheHitTokens * p.inputCacheHit + usage.promptCacheMissTokens * p.inputCacheMiss + usage.completionTokens * p.output) / 1e6;
37
+ }
38
+ function inputCostUsd(model, usage, path) {
39
+ const p = pricingFor(model, path);
40
+ if (!p) return 0;
41
+ return (usage.promptCacheHitTokens * p.inputCacheHit + usage.promptCacheMissTokens * p.inputCacheMiss) / 1e6;
42
+ }
43
+ function outputCostUsd(model, usage, path) {
44
+ const p = pricingFor(model, path);
45
+ if (!p) return 0;
46
+ return usage.completionTokens * p.output / 1e6;
47
+ }
48
+ function cacheSavingsUsd(model, hitTokens, path) {
49
+ if (hitTokens <= 0) return 0;
50
+ const p = pricingFor(model, path);
51
+ if (!p) return 0;
52
+ return hitTokens * (p.inputCacheMiss - p.inputCacheHit) / 1e6;
53
+ }
54
+ function claudeEquivalentCost(usage) {
55
+ return (usage.promptTokens * CLAUDE_SONNET_PRICING.input + usage.completionTokens * CLAUDE_SONNET_PRICING.output) / 1e6;
56
+ }
57
+ var SessionStats = class {
58
+ turns = [];
59
+ /** Cost from prior runs of a resumed session, restored from session meta. */
60
+ _carryoverCost = 0;
61
+ /** Turn count from prior runs of a resumed session. */
62
+ _carryoverTurns = 0;
63
+ _carryoverCacheHit = 0;
64
+ _carryoverCacheMiss = 0;
65
+ /** Last turn's promptTokens before exit — surfaced via summary() until the next live turn lands. */
66
+ _carryoverLastPromptTokens = 0;
67
+ /** Seed totals from a resumed session's persisted meta — only call once at construction. */
68
+ seedCarryover(opts) {
69
+ if (typeof opts.totalCostUsd === "number" && opts.totalCostUsd > 0) {
70
+ this._carryoverCost = opts.totalCostUsd;
71
+ }
72
+ if (typeof opts.turnCount === "number" && opts.turnCount > 0) {
73
+ this._carryoverTurns = opts.turnCount;
74
+ }
75
+ if (typeof opts.cacheHitTokens === "number" && opts.cacheHitTokens > 0) {
76
+ this._carryoverCacheHit = opts.cacheHitTokens;
77
+ }
78
+ if (typeof opts.cacheMissTokens === "number" && opts.cacheMissTokens > 0) {
79
+ this._carryoverCacheMiss = opts.cacheMissTokens;
80
+ }
81
+ if (typeof opts.lastPromptTokens === "number" && opts.lastPromptTokens > 0) {
82
+ this._carryoverLastPromptTokens = opts.lastPromptTokens;
83
+ }
84
+ }
85
+ reset() {
86
+ this.turns.length = 0;
87
+ this._carryoverCost = 0;
88
+ this._carryoverTurns = 0;
89
+ this._carryoverCacheHit = 0;
90
+ this._carryoverCacheMiss = 0;
91
+ this._carryoverLastPromptTokens = 0;
92
+ }
93
+ record(turn, model, usage) {
94
+ const cost = costUsd(model, usage);
95
+ const stats = {
96
+ turn,
97
+ model,
98
+ usage,
99
+ cost,
100
+ cacheHitRatio: usage.cacheHitRatio
101
+ };
102
+ this.turns.push(stats);
103
+ return stats;
104
+ }
105
+ get totalCost() {
106
+ return this._carryoverCost + this.turns.reduce((sum, t) => sum + t.cost, 0);
107
+ }
108
+ get totalClaudeEquivalent() {
109
+ return this.turns.reduce((sum, t) => sum + claudeEquivalentCost(t.usage), 0);
110
+ }
111
+ get savingsVsClaude() {
112
+ const c = this.totalClaudeEquivalent;
113
+ return c > 0 ? 1 - this.totalCost / c : 0;
114
+ }
115
+ get totalInputCost() {
116
+ return this.turns.reduce((sum, t) => sum + inputCostUsd(t.model, t.usage), 0);
117
+ }
118
+ get totalOutputCost() {
119
+ return this.turns.reduce((sum, t) => sum + outputCostUsd(t.model, t.usage), 0);
120
+ }
121
+ get aggregateCacheHitRatio() {
122
+ let hit = this._carryoverCacheHit;
123
+ let miss = this._carryoverCacheMiss;
124
+ for (const t of this.turns) {
125
+ hit += t.usage.promptCacheHitTokens;
126
+ miss += t.usage.promptCacheMissTokens;
127
+ }
128
+ const denom = hit + miss;
129
+ return denom > 0 ? hit / denom : 0;
130
+ }
131
+ summary() {
132
+ const last = this.turns[this.turns.length - 1];
133
+ return {
134
+ turns: this.turns.length + this._carryoverTurns,
135
+ totalCostUsd: round(this.totalCost, 6),
136
+ totalInputCostUsd: round(this.totalInputCost, 6),
137
+ totalOutputCostUsd: round(this.totalOutputCost, 6),
138
+ claudeEquivalentUsd: round(this.totalClaudeEquivalent, 6),
139
+ savingsVsClaudePct: round(this.savingsVsClaude * 100, 2),
140
+ cacheHitRatio: round(this.aggregateCacheHitRatio, 4),
141
+ lastPromptTokens: last?.usage.promptTokens ?? this._carryoverLastPromptTokens,
142
+ lastTurnCostUsd: round(last?.cost ?? 0, 6)
143
+ };
144
+ }
145
+ };
146
+ function round(n, digits) {
147
+ const f = 10 ** digits;
148
+ return Math.round(n * f) / f;
149
+ }
150
+
151
+ export {
152
+ DEEPSEEK_PRICING,
153
+ pricingFor,
154
+ DEEPSEEK_CONTEXT_TOKENS,
155
+ DEFAULT_CONTEXT_TOKENS,
156
+ costUsd,
157
+ inputCostUsd,
158
+ outputCostUsd,
159
+ cacheSavingsUsd,
160
+ claudeEquivalentCost,
161
+ SessionStats
162
+ };
163
+ //# sourceMappingURL=chunk-ILJOIQ5W.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/telemetry/stats.ts"],"sourcesContent":["import type { Usage } from \"../client.js\";\nimport { loadPricingOverride } from \"../config.js\";\n\n/** USD per 1M tokens; display currency conversion happens at the UI boundary. */\nexport const DEEPSEEK_PRICING: Record<\n string,\n { inputCacheHit: number; inputCacheMiss: number; output: number }\n> = {\n \"deepseek-v4-flash\": { inputCacheHit: 0.0028, inputCacheMiss: 0.14, output: 0.28 },\n \"deepseek-v4-pro\": { inputCacheHit: 0.003625, inputCacheMiss: 0.435, output: 0.87 },\n // Compat aliases — priced as v4-flash per the deprecation notice.\n \"deepseek-chat\": { inputCacheHit: 0.0028, inputCacheMiss: 0.14, output: 0.28 },\n \"deepseek-reasoner\": { inputCacheHit: 0.0028, inputCacheMiss: 0.14, output: 0.28 },\n};\n\nexport type ModelPricing = (typeof DEEPSEEK_PRICING)[string];\n\nexport function pricingFor(model: string, path?: string): ModelPricing | undefined {\n const defaults = DEEPSEEK_PRICING[model];\n const override = loadPricingOverride(path)[model];\n if (!override) return defaults;\n const pricing = { ...defaults, ...override };\n if (\n pricing.inputCacheHit === undefined ||\n pricing.inputCacheMiss === undefined ||\n pricing.output === undefined\n ) {\n return undefined;\n }\n return pricing as ModelPricing;\n}\n\n/** Reference Claude Sonnet 4.6 pricing (USD per 1M tokens). */\nexport const CLAUDE_SONNET_PRICING = { input: 3.0, output: 15.0 };\n\n/** Prompt-side window only; completion caps live server-side and don't affect this gauge. */\nexport const DEEPSEEK_CONTEXT_TOKENS: Record<string, number> = {\n \"deepseek-v4-flash\": 1_000_000,\n \"deepseek-v4-pro\": 1_000_000,\n \"deepseek-chat\": 1_000_000,\n \"deepseek-reasoner\": 1_000_000,\n};\n\n/** Fallback when the caller's model id isn't in the table — safe lower bound. */\nexport const DEFAULT_CONTEXT_TOKENS = 131_072;\n\nexport function costUsd(model: string, usage: Usage, path?: string): number {\n const p = pricingFor(model, path);\n if (!p) return 0;\n return (\n (usage.promptCacheHitTokens * p.inputCacheHit +\n usage.promptCacheMissTokens * p.inputCacheMiss +\n usage.completionTokens * p.output) /\n 1_000_000\n );\n}\n\n/** Input-side cost only (prompt, cache hit + miss). Used for the panel breakdown. */\nexport function inputCostUsd(model: string, usage: Usage, path?: string): number {\n const p = pricingFor(model, path);\n if (!p) return 0;\n return (\n (usage.promptCacheHitTokens * p.inputCacheHit +\n usage.promptCacheMissTokens * p.inputCacheMiss) /\n 1_000_000\n );\n}\n\n/** Output-side cost only (completion tokens). Used for the panel breakdown. */\nexport function outputCostUsd(model: string, usage: Usage, path?: string): number {\n const p = pricingFor(model, path);\n if (!p) return 0;\n return (usage.completionTokens * p.output) / 1_000_000;\n}\n\nexport function cacheSavingsUsd(model: string, hitTokens: number, path?: string): number {\n if (hitTokens <= 0) return 0;\n const p = pricingFor(model, path);\n if (!p) return 0;\n return (hitTokens * (p.inputCacheMiss - p.inputCacheHit)) / 1_000_000;\n}\n\nexport function claudeEquivalentCost(usage: Usage): number {\n return (\n (usage.promptTokens * CLAUDE_SONNET_PRICING.input +\n usage.completionTokens * CLAUDE_SONNET_PRICING.output) /\n 1_000_000\n );\n}\n\nexport interface TurnStats {\n turn: number;\n model: string;\n usage: Usage;\n cost: number;\n cacheHitRatio: number;\n}\n\nexport interface SessionSummary {\n turns: number;\n totalCostUsd: number;\n totalInputCostUsd: number;\n /** Output-side (completion) cost aggregated across the session. */\n totalOutputCostUsd: number;\n /** @deprecated Claude reference; kept for benchmarks + replay compat, no longer surfaced in the TUI. */\n claudeEquivalentUsd: number;\n /** @deprecated. Same as claudeEquivalentUsd — synthetic ratio, not a real measurement. */\n savingsVsClaudePct: number;\n cacheHitRatio: number;\n /** Floor estimate for next call — actual cost = this + user delta + new tool outputs. */\n lastPromptTokens: number;\n lastTurnCostUsd: number;\n}\n\nexport class SessionStats {\n readonly turns: TurnStats[] = [];\n /** Cost from prior runs of a resumed session, restored from session meta. */\n private _carryoverCost = 0;\n /** Turn count from prior runs of a resumed session. */\n private _carryoverTurns = 0;\n private _carryoverCacheHit = 0;\n private _carryoverCacheMiss = 0;\n /** Last turn's promptTokens before exit — surfaced via summary() until the next live turn lands. */\n private _carryoverLastPromptTokens = 0;\n\n /** Seed totals from a resumed session's persisted meta — only call once at construction. */\n seedCarryover(opts: {\n totalCostUsd?: number;\n turnCount?: number;\n cacheHitTokens?: number;\n cacheMissTokens?: number;\n lastPromptTokens?: number;\n }): void {\n if (typeof opts.totalCostUsd === \"number\" && opts.totalCostUsd > 0) {\n this._carryoverCost = opts.totalCostUsd;\n }\n if (typeof opts.turnCount === \"number\" && opts.turnCount > 0) {\n this._carryoverTurns = opts.turnCount;\n }\n if (typeof opts.cacheHitTokens === \"number\" && opts.cacheHitTokens > 0) {\n this._carryoverCacheHit = opts.cacheHitTokens;\n }\n if (typeof opts.cacheMissTokens === \"number\" && opts.cacheMissTokens > 0) {\n this._carryoverCacheMiss = opts.cacheMissTokens;\n }\n if (typeof opts.lastPromptTokens === \"number\" && opts.lastPromptTokens > 0) {\n this._carryoverLastPromptTokens = opts.lastPromptTokens;\n }\n }\n\n reset(): void {\n this.turns.length = 0;\n this._carryoverCost = 0;\n this._carryoverTurns = 0;\n this._carryoverCacheHit = 0;\n this._carryoverCacheMiss = 0;\n this._carryoverLastPromptTokens = 0;\n }\n\n record(turn: number, model: string, usage: Usage): TurnStats {\n const cost = costUsd(model, usage);\n const stats: TurnStats = {\n turn,\n model,\n usage,\n cost,\n cacheHitRatio: usage.cacheHitRatio,\n };\n this.turns.push(stats);\n return stats;\n }\n\n get totalCost(): number {\n return this._carryoverCost + this.turns.reduce((sum, t) => sum + t.cost, 0);\n }\n\n get totalClaudeEquivalent(): number {\n return this.turns.reduce((sum, t) => sum + claudeEquivalentCost(t.usage), 0);\n }\n\n get savingsVsClaude(): number {\n const c = this.totalClaudeEquivalent;\n return c > 0 ? 1 - this.totalCost / c : 0;\n }\n\n get totalInputCost(): number {\n return this.turns.reduce((sum, t) => sum + inputCostUsd(t.model, t.usage), 0);\n }\n\n get totalOutputCost(): number {\n return this.turns.reduce((sum, t) => sum + outputCostUsd(t.model, t.usage), 0);\n }\n\n get aggregateCacheHitRatio(): number {\n let hit = this._carryoverCacheHit;\n let miss = this._carryoverCacheMiss;\n for (const t of this.turns) {\n hit += t.usage.promptCacheHitTokens;\n miss += t.usage.promptCacheMissTokens;\n }\n const denom = hit + miss;\n return denom > 0 ? hit / denom : 0;\n }\n\n summary(): SessionSummary {\n const last = this.turns[this.turns.length - 1];\n return {\n turns: this.turns.length + this._carryoverTurns,\n totalCostUsd: round(this.totalCost, 6),\n totalInputCostUsd: round(this.totalInputCost, 6),\n totalOutputCostUsd: round(this.totalOutputCost, 6),\n claudeEquivalentUsd: round(this.totalClaudeEquivalent, 6),\n savingsVsClaudePct: round(this.savingsVsClaude * 100, 2),\n cacheHitRatio: round(this.aggregateCacheHitRatio, 4),\n lastPromptTokens: last?.usage.promptTokens ?? this._carryoverLastPromptTokens,\n lastTurnCostUsd: round(last?.cost ?? 0, 6),\n };\n }\n}\n\nfunction round(n: number, digits: number): number {\n const f = 10 ** digits;\n return Math.round(n * f) / f;\n}\n"],"mappings":";;;;;;;AAIO,IAAM,mBAGT;AAAA,EACF,qBAAqB,EAAE,eAAe,OAAQ,gBAAgB,MAAM,QAAQ,KAAK;AAAA,EACjF,mBAAmB,EAAE,eAAe,SAAU,gBAAgB,OAAO,QAAQ,KAAK;AAAA;AAAA,EAElF,iBAAiB,EAAE,eAAe,OAAQ,gBAAgB,MAAM,QAAQ,KAAK;AAAA,EAC7E,qBAAqB,EAAE,eAAe,OAAQ,gBAAgB,MAAM,QAAQ,KAAK;AACnF;AAIO,SAAS,WAAW,OAAe,MAAyC;AACjF,QAAM,WAAW,iBAAiB,KAAK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QAAQ,GAAG,CAAC;AAAA,IAC3C;AAAA,EACF;AACF;AAEA,SAAS,MAAM,GAAW,QAAwB;AAChD,QAAM,IAAI,MAAM;AAChB,SAAO,KAAK,MAAM,IAAI,CAAC,IAAI;AAC7B;","names":[]}
@@ -0,0 +1,225 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __cr } from 'node:module'; if (typeof globalThis.require === 'undefined') { globalThis.require = __cr(import.meta.url); }
3
+ import {
4
+ t
5
+ } from "./chunk-IAUOP25G.js";
6
+
7
+ // src/hooks.ts
8
+ import { spawn } from "child_process";
9
+ import { existsSync, readFileSync } from "fs";
10
+ import { homedir } from "os";
11
+ import { join } from "path";
12
+ var HOOK_EVENTS = [
13
+ "PreToolUse",
14
+ "PostToolUse",
15
+ "UserPromptSubmit",
16
+ "Stop"
17
+ ];
18
+ var BLOCKING_EVENTS = /* @__PURE__ */ new Set(["PreToolUse", "UserPromptSubmit"]);
19
+ var DEFAULT_TIMEOUTS_MS = {
20
+ PreToolUse: 5e3,
21
+ UserPromptSubmit: 5e3,
22
+ PostToolUse: 3e4,
23
+ Stop: 3e4
24
+ };
25
+ var HOOK_SETTINGS_FILENAME = "settings.json";
26
+ var HOOK_SETTINGS_DIRNAME = ".carboncode";
27
+ var LEGACY_HOOK_SETTINGS_DIRNAME = ".reasonix";
28
+ function globalSettingsPath(homeDirOverride) {
29
+ return join(homeDirOverride ?? homedir(), HOOK_SETTINGS_DIRNAME, HOOK_SETTINGS_FILENAME);
30
+ }
31
+ function projectSettingsPath(projectRoot) {
32
+ return join(projectRoot, HOOK_SETTINGS_DIRNAME, HOOK_SETTINGS_FILENAME);
33
+ }
34
+ function legacyGlobalSettingsPath(homeDirOverride) {
35
+ return join(homeDirOverride ?? homedir(), LEGACY_HOOK_SETTINGS_DIRNAME, HOOK_SETTINGS_FILENAME);
36
+ }
37
+ function legacyProjectSettingsPath(projectRoot) {
38
+ return join(projectRoot, LEGACY_HOOK_SETTINGS_DIRNAME, HOOK_SETTINGS_FILENAME);
39
+ }
40
+ function readSettingsFile(path) {
41
+ if (!existsSync(path)) return null;
42
+ try {
43
+ const raw = readFileSync(path, "utf8");
44
+ const parsed = JSON.parse(raw);
45
+ if (parsed && typeof parsed === "object") return parsed;
46
+ } catch {
47
+ }
48
+ return null;
49
+ }
50
+ function readPreferredSettingsFile(primary, legacy) {
51
+ if (existsSync(primary)) return { path: primary, settings: readSettingsFile(primary) };
52
+ if (existsSync(legacy)) return { path: legacy, settings: readSettingsFile(legacy) };
53
+ return null;
54
+ }
55
+ function loadHooks(opts = {}) {
56
+ const out = [];
57
+ if (opts.projectRoot) {
58
+ const loaded2 = readPreferredSettingsFile(
59
+ projectSettingsPath(opts.projectRoot),
60
+ legacyProjectSettingsPath(opts.projectRoot)
61
+ );
62
+ if (loaded2?.settings) appendResolved(out, loaded2.settings, "project", loaded2.path);
63
+ }
64
+ const loaded = readPreferredSettingsFile(
65
+ globalSettingsPath(opts.homeDir),
66
+ legacyGlobalSettingsPath(opts.homeDir)
67
+ );
68
+ if (loaded?.settings) appendResolved(out, loaded.settings, "global", loaded.path);
69
+ return out;
70
+ }
71
+ function appendResolved(out, settings, scope, source) {
72
+ if (!settings.hooks) return;
73
+ for (const event of HOOK_EVENTS) {
74
+ const list = settings.hooks[event];
75
+ if (!Array.isArray(list)) continue;
76
+ for (const cfg of list) {
77
+ if (!cfg || typeof cfg.command !== "string" || cfg.command.trim() === "") continue;
78
+ out.push({ ...cfg, event, scope, source });
79
+ }
80
+ }
81
+ }
82
+ function matchesTool(hook, toolName) {
83
+ if (hook.event !== "PreToolUse" && hook.event !== "PostToolUse") return true;
84
+ const m = hook.match;
85
+ if (!m || m === "*") return true;
86
+ try {
87
+ const re = new RegExp(`^(?:${m})$`);
88
+ return re.test(toolName);
89
+ } catch {
90
+ return false;
91
+ }
92
+ }
93
+ var HOOK_OUTPUT_CAP_BYTES = 256 * 1024;
94
+ function defaultSpawner(input) {
95
+ return new Promise((resolve) => {
96
+ const child = spawn(input.command, {
97
+ cwd: input.cwd,
98
+ shell: true,
99
+ stdio: ["pipe", "pipe", "pipe"]
100
+ });
101
+ const stdoutChunks = [];
102
+ const stderrChunks = [];
103
+ let stdoutBytes = 0;
104
+ let stderrBytes = 0;
105
+ let truncated = false;
106
+ let timedOut = false;
107
+ const timer = setTimeout(() => {
108
+ timedOut = true;
109
+ child.kill("SIGTERM");
110
+ setTimeout(() => {
111
+ try {
112
+ child.kill("SIGKILL");
113
+ } catch {
114
+ }
115
+ }, 500);
116
+ }, input.timeoutMs);
117
+ const onChunk = (kind, chunk) => {
118
+ const target = kind === "stdout" ? stdoutChunks : stderrChunks;
119
+ const seen = kind === "stdout" ? stdoutBytes : stderrBytes;
120
+ if (seen >= HOOK_OUTPUT_CAP_BYTES) {
121
+ truncated = true;
122
+ return;
123
+ }
124
+ const remaining = HOOK_OUTPUT_CAP_BYTES - seen;
125
+ if (chunk.length > remaining) {
126
+ target.push(chunk.subarray(0, remaining));
127
+ if (kind === "stdout") stdoutBytes = HOOK_OUTPUT_CAP_BYTES;
128
+ else stderrBytes = HOOK_OUTPUT_CAP_BYTES;
129
+ truncated = true;
130
+ } else {
131
+ target.push(chunk);
132
+ if (kind === "stdout") stdoutBytes += chunk.length;
133
+ else stderrBytes += chunk.length;
134
+ }
135
+ };
136
+ child.stdout.on("data", (chunk) => onChunk("stdout", chunk));
137
+ child.stderr.on("data", (chunk) => onChunk("stderr", chunk));
138
+ child.once("error", (err) => {
139
+ clearTimeout(timer);
140
+ resolve({
141
+ exitCode: null,
142
+ stdout: Buffer.concat(stdoutChunks).toString("utf8"),
143
+ stderr: Buffer.concat(stderrChunks).toString("utf8"),
144
+ timedOut: false,
145
+ spawnError: err,
146
+ truncated: truncated || void 0
147
+ });
148
+ });
149
+ child.once("close", (code) => {
150
+ clearTimeout(timer);
151
+ resolve({
152
+ exitCode: code,
153
+ stdout: Buffer.concat(stdoutChunks).toString("utf8").trim(),
154
+ stderr: Buffer.concat(stderrChunks).toString("utf8").trim(),
155
+ timedOut,
156
+ truncated: truncated || void 0
157
+ });
158
+ });
159
+ try {
160
+ child.stdin.write(input.stdin);
161
+ child.stdin.end();
162
+ } catch {
163
+ }
164
+ });
165
+ }
166
+ function formatHookOutcomeMessage(outcome) {
167
+ if (outcome.decision === "pass") return "";
168
+ const detail = (outcome.stderr || outcome.stdout || "").trim();
169
+ const tag = `${outcome.hook.scope}/${outcome.hook.event}`;
170
+ const cmd = outcome.hook.command.length > 60 ? `${outcome.hook.command.slice(0, 60)}\u2026` : outcome.hook.command;
171
+ const truncTag = outcome.truncated ? t("hooks.truncated") : "";
172
+ const decision = t(`hooks.decision${capitalize(outcome.decision)}`);
173
+ return detail ? t("hooks.headWithDetail", { tag, cmd, decision, truncTag, detail }) : t("hooks.head", { tag, cmd, decision, truncTag });
174
+ }
175
+ function capitalize(s) {
176
+ return s.charAt(0).toUpperCase() + s.slice(1);
177
+ }
178
+ function decideOutcome(event, raw) {
179
+ if (raw.spawnError) return "error";
180
+ if (raw.timedOut) return BLOCKING_EVENTS.has(event) ? "block" : "warn";
181
+ if (raw.exitCode === 0) return "pass";
182
+ if (raw.exitCode === 2 && BLOCKING_EVENTS.has(event)) return "block";
183
+ return "warn";
184
+ }
185
+ async function runHooks(opts) {
186
+ const spawner = opts.spawner ?? defaultSpawner;
187
+ const event = opts.payload.event;
188
+ const toolName = opts.payload.toolName ?? "";
189
+ const matching = opts.hooks.filter((h) => h.event === event && matchesTool(h, toolName));
190
+ const outcomes = [];
191
+ let blocked = false;
192
+ const stdin = `${JSON.stringify(opts.payload)}
193
+ `;
194
+ for (const hook of matching) {
195
+ const start = Date.now();
196
+ const timeoutMs = hook.timeout ?? DEFAULT_TIMEOUTS_MS[event];
197
+ const cwd = hook.cwd ?? opts.payload.cwd;
198
+ const raw = await spawner({ command: hook.command, cwd, stdin, timeoutMs });
199
+ const decision = decideOutcome(event, raw);
200
+ outcomes.push({
201
+ hook,
202
+ decision,
203
+ exitCode: raw.exitCode,
204
+ stdout: raw.stdout,
205
+ stderr: raw.stderr || (raw.spawnError ? raw.spawnError.message : "") || (raw.timedOut ? `hook timed out after ${timeoutMs}ms` : ""),
206
+ durationMs: Date.now() - start,
207
+ truncated: raw.truncated
208
+ });
209
+ if (decision === "block") {
210
+ blocked = true;
211
+ break;
212
+ }
213
+ }
214
+ return { event, outcomes, blocked };
215
+ }
216
+
217
+ export {
218
+ HOOK_EVENTS,
219
+ globalSettingsPath,
220
+ projectSettingsPath,
221
+ loadHooks,
222
+ formatHookOutcomeMessage,
223
+ runHooks
224
+ };
225
+ //# sourceMappingURL=chunk-IX6XI2RG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks.ts"],"sourcesContent":["/** Shell-command hooks; project scope first, then global. Exit 0=pass, 2=block on Pre*, other=warn. */\n\nimport { spawn } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { t } from \"./i18n/index.js\";\n\nexport type HookEvent = \"PreToolUse\" | \"PostToolUse\" | \"UserPromptSubmit\" | \"Stop\";\n\n/** All four events as a const array — drives slash listing + validation. */\nexport const HOOK_EVENTS: readonly HookEvent[] = [\n \"PreToolUse\",\n \"PostToolUse\",\n \"UserPromptSubmit\",\n \"Stop\",\n] as const;\n\n/** Only the gating events can block the loop. */\nconst BLOCKING_EVENTS: ReadonlySet<HookEvent> = new Set([\"PreToolUse\", \"UserPromptSubmit\"]);\n\n/** Per-event default timeout. Tool/prompt hooks gate progress, so they're tight. */\nconst DEFAULT_TIMEOUTS_MS: Record<HookEvent, number> = {\n PreToolUse: 5_000,\n UserPromptSubmit: 5_000,\n PostToolUse: 30_000,\n Stop: 30_000,\n};\n\nexport type HookScope = \"project\" | \"global\";\n\nexport interface HookConfig {\n /** Anchored regex; `\"*\"` / omitted = every tool. Pre/PostToolUse only. */\n match?: string;\n /** Shell command to run. Spawned through the platform shell. */\n command: string;\n /** Optional human description — surfaced in `/hooks`. */\n description?: string;\n /** Per-hook timeout override in ms. */\n timeout?: number;\n /** Defaults: project scope → project root; global scope → process.cwd(). */\n cwd?: string;\n}\n\n/** Shape of `<scope>/.carboncode/settings.json` — only `hooks` for now. */\nexport interface HookSettings {\n hooks?: Partial<Record<HookEvent, HookConfig[]>>;\n}\n\n/** A loaded hook with its origin scope baked in (used for ordering and `/hooks`). */\nexport interface ResolvedHook extends HookConfig {\n event: HookEvent;\n scope: HookScope;\n /** Absolute path to the settings.json the hook came from. */\n source: string;\n}\n\n/** Outcome of a single hook invocation. */\nexport interface HookOutcome {\n /** Which hook fired. */\n hook: ResolvedHook;\n /** pass=exit 0; block=exit 2 on blocking event; warn=other non-zero; timeout=killed; error=spawn failed. */\n decision: \"pass\" | \"block\" | \"warn\" | \"timeout\" | \"error\";\n exitCode: number | null;\n /** Captured stdout (trimmed). May be empty. */\n stdout: string;\n /** Captured stderr (trimmed). The block / warn message comes from here. */\n stderr: string;\n durationMs: number;\n /** Output crossed the per-stream byte cap; surfaced so user knows we kept less than the script wrote. */\n truncated?: boolean;\n}\n\n/** Aggregate report for `runHooks`. */\nexport interface HookReport {\n event: HookEvent;\n outcomes: HookOutcome[];\n /** True iff at least one outcome was a `block` — only meaningful for blocking events. */\n blocked: boolean;\n}\n\nexport const HOOK_SETTINGS_FILENAME = \"settings.json\";\nexport const HOOK_SETTINGS_DIRNAME = \".carboncode\";\nexport const LEGACY_HOOK_SETTINGS_DIRNAME = \".reasonix\";\n\n/** Where the global settings.json lives. Equivalent to `~/.carboncode/settings.json`. */\nexport function globalSettingsPath(homeDirOverride?: string): string {\n return join(homeDirOverride ?? homedir(), HOOK_SETTINGS_DIRNAME, HOOK_SETTINGS_FILENAME);\n}\n\n/** Where the project settings.json lives for a given root. */\nexport function projectSettingsPath(projectRoot: string): string {\n return join(projectRoot, HOOK_SETTINGS_DIRNAME, HOOK_SETTINGS_FILENAME);\n}\n\nfunction legacyGlobalSettingsPath(homeDirOverride?: string): string {\n return join(homeDirOverride ?? homedir(), LEGACY_HOOK_SETTINGS_DIRNAME, HOOK_SETTINGS_FILENAME);\n}\n\nfunction legacyProjectSettingsPath(projectRoot: string): string {\n return join(projectRoot, LEGACY_HOOK_SETTINGS_DIRNAME, HOOK_SETTINGS_FILENAME);\n}\n\nfunction readSettingsFile(path: string): HookSettings | null {\n if (!existsSync(path)) return null;\n try {\n const raw = readFileSync(path, \"utf8\");\n const parsed = JSON.parse(raw);\n if (parsed && typeof parsed === \"object\") return parsed as HookSettings;\n } catch {\n /* malformed JSON → treat as no hooks; do NOT throw, the user\n * shouldn't lose the whole CLI to a typo in their settings */\n }\n return null;\n}\n\nfunction readPreferredSettingsFile(\n primary: string,\n legacy: string,\n): {\n path: string;\n settings: HookSettings | null;\n} | null {\n if (existsSync(primary)) return { path: primary, settings: readSettingsFile(primary) };\n if (existsSync(legacy)) return { path: legacy, settings: readSettingsFile(legacy) };\n return null;\n}\n\n/** Project hooks fire before global; within a scope, array order. */\nexport interface LoadHookSettingsOptions {\n /** Absolute project root, if any. Without it, only global hooks load. */\n projectRoot?: string;\n /** Override `~` for tests. */\n homeDir?: string;\n}\n\nexport function loadHooks(opts: LoadHookSettingsOptions = {}): ResolvedHook[] {\n const out: ResolvedHook[] = [];\n if (opts.projectRoot) {\n const loaded = readPreferredSettingsFile(\n projectSettingsPath(opts.projectRoot),\n legacyProjectSettingsPath(opts.projectRoot),\n );\n if (loaded?.settings) appendResolved(out, loaded.settings, \"project\", loaded.path);\n }\n const loaded = readPreferredSettingsFile(\n globalSettingsPath(opts.homeDir),\n legacyGlobalSettingsPath(opts.homeDir),\n );\n if (loaded?.settings) appendResolved(out, loaded.settings, \"global\", loaded.path);\n return out;\n}\n\nfunction appendResolved(\n out: ResolvedHook[],\n settings: HookSettings,\n scope: HookScope,\n source: string,\n): void {\n if (!settings.hooks) return;\n for (const event of HOOK_EVENTS) {\n const list = settings.hooks[event];\n if (!Array.isArray(list)) continue;\n for (const cfg of list) {\n if (!cfg || typeof cfg.command !== \"string\" || cfg.command.trim() === \"\") continue;\n out.push({ ...cfg, event, scope, source });\n }\n }\n}\n\n/** Match field is an ANCHORED regex — `\"file\"` won't trigger on `read_file`; use `\".*file\"`. */\nexport function matchesTool(hook: ResolvedHook, toolName: string): boolean {\n if (hook.event !== \"PreToolUse\" && hook.event !== \"PostToolUse\") return true;\n const m = hook.match;\n if (!m || m === \"*\") return true;\n try {\n const re = new RegExp(`^(?:${m})$`);\n return re.test(toolName);\n } catch {\n /* malformed regex → don't fire (safer than firing on every tool) */\n return false;\n }\n}\n\n/** Payload envelope passed to hook stdin. */\nexport interface HookPayload {\n event: HookEvent;\n cwd: string;\n toolName?: string;\n toolArgs?: unknown;\n toolResult?: string;\n prompt?: string;\n lastAssistantText?: string;\n turn?: number;\n}\n\n/** Test seam — same shape as Node's spawn but returns a Promise of the raw outcome bits. */\nexport interface HookSpawnInput {\n command: string;\n cwd: string;\n stdin: string;\n timeoutMs: number;\n}\n\nexport interface HookSpawnResult {\n exitCode: number | null;\n stdout: string;\n stderr: string;\n timedOut: boolean;\n /** True iff spawn() itself failed (ENOENT, EACCES, …). */\n spawnError?: Error;\n /** Output capped at byte limit — hook ran to completion but consumers see clipped view. */\n truncated?: boolean;\n}\n\n/** Per-stream cap — bounds heap exposure to a runaway child between spawn and timeout. */\nconst HOOK_OUTPUT_CAP_BYTES = 256 * 1024;\n\nexport type HookSpawner = (input: HookSpawnInput) => Promise<HookSpawnResult>;\n\n/** `shell: true` — hook is a shell command by contract; pipes / `&&` / env expansion must work. */\nfunction defaultSpawner(input: HookSpawnInput): Promise<HookSpawnResult> {\n return new Promise<HookSpawnResult>((resolve) => {\n const child = spawn(input.command, {\n cwd: input.cwd,\n shell: true,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n // Collect raw bytes per stream and decode once at close so a\n // multi-byte UTF-8 sequence split across data chunks doesn't\n // corrupt — same approach shell.ts uses for run_command output.\n const stdoutChunks: Buffer[] = [];\n const stderrChunks: Buffer[] = [];\n let stdoutBytes = 0;\n let stderrBytes = 0;\n let truncated = false;\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill(\"SIGTERM\");\n // SIGTERM may not land on Windows for shell children — followed\n // by a hard kill a moment later if the process is still around.\n setTimeout(() => {\n try {\n child.kill(\"SIGKILL\");\n } catch {\n /* already gone */\n }\n }, 500);\n }, input.timeoutMs);\n\n const onChunk = (kind: \"stdout\" | \"stderr\", chunk: Buffer) => {\n const target = kind === \"stdout\" ? stdoutChunks : stderrChunks;\n const seen = kind === \"stdout\" ? stdoutBytes : stderrBytes;\n if (seen >= HOOK_OUTPUT_CAP_BYTES) {\n truncated = true;\n return;\n }\n const remaining = HOOK_OUTPUT_CAP_BYTES - seen;\n if (chunk.length > remaining) {\n target.push(chunk.subarray(0, remaining));\n if (kind === \"stdout\") stdoutBytes = HOOK_OUTPUT_CAP_BYTES;\n else stderrBytes = HOOK_OUTPUT_CAP_BYTES;\n truncated = true;\n } else {\n target.push(chunk);\n if (kind === \"stdout\") stdoutBytes += chunk.length;\n else stderrBytes += chunk.length;\n }\n };\n child.stdout.on(\"data\", (chunk: Buffer) => onChunk(\"stdout\", chunk));\n child.stderr.on(\"data\", (chunk: Buffer) => onChunk(\"stderr\", chunk));\n child.once(\"error\", (err) => {\n clearTimeout(timer);\n resolve({\n exitCode: null,\n stdout: Buffer.concat(stdoutChunks).toString(\"utf8\"),\n stderr: Buffer.concat(stderrChunks).toString(\"utf8\"),\n timedOut: false,\n spawnError: err,\n truncated: truncated || undefined,\n });\n });\n child.once(\"close\", (code) => {\n clearTimeout(timer);\n resolve({\n exitCode: code,\n stdout: Buffer.concat(stdoutChunks).toString(\"utf8\").trim(),\n stderr: Buffer.concat(stderrChunks).toString(\"utf8\").trim(),\n timedOut,\n truncated: truncated || undefined,\n });\n });\n\n try {\n child.stdin.write(input.stdin);\n child.stdin.end();\n } catch {\n /* stdin write can race with spawn errors; the close handler\n * still fires with exit 0/null */\n }\n });\n}\n\nexport function formatHookOutcomeMessage(outcome: HookOutcome): string {\n if (outcome.decision === \"pass\") return \"\";\n const detail = (outcome.stderr || outcome.stdout || \"\").trim();\n const tag = `${outcome.hook.scope}/${outcome.hook.event}`;\n const cmd =\n outcome.hook.command.length > 60\n ? `${outcome.hook.command.slice(0, 60)}…`\n : outcome.hook.command;\n const truncTag = outcome.truncated ? t(\"hooks.truncated\") : \"\";\n const decision = t(`hooks.decision${capitalize(outcome.decision)}`);\n return detail\n ? t(\"hooks.headWithDetail\", { tag, cmd, decision, truncTag, detail })\n : t(\"hooks.head\", { tag, cmd, decision, truncTag });\n}\n\nfunction capitalize(s: string): string {\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\nexport function decideOutcome(\n event: HookEvent,\n raw: HookSpawnResult,\n): \"pass\" | \"block\" | \"warn\" | \"timeout\" | \"error\" {\n if (raw.spawnError) return \"error\";\n if (raw.timedOut) return BLOCKING_EVENTS.has(event) ? \"block\" : \"warn\";\n if (raw.exitCode === 0) return \"pass\";\n if (raw.exitCode === 2 && BLOCKING_EVENTS.has(event)) return \"block\";\n return \"warn\";\n}\n\nexport interface RunHooksOptions {\n payload: HookPayload;\n hooks: ResolvedHook[];\n /** Test seam — defaults to a real `spawn`. */\n spawner?: HookSpawner;\n}\n\n/** Stops at first `block` so a gating hook can prevent later hooks running against a phantom success. */\nexport async function runHooks(opts: RunHooksOptions): Promise<HookReport> {\n const spawner = opts.spawner ?? defaultSpawner;\n const event = opts.payload.event;\n const toolName = opts.payload.toolName ?? \"\";\n const matching = opts.hooks.filter((h) => h.event === event && matchesTool(h, toolName));\n\n const outcomes: HookOutcome[] = [];\n let blocked = false;\n const stdin = `${JSON.stringify(opts.payload)}\\n`;\n\n for (const hook of matching) {\n const start = Date.now();\n const timeoutMs = hook.timeout ?? DEFAULT_TIMEOUTS_MS[event];\n const cwd = hook.cwd ?? opts.payload.cwd;\n const raw = await spawner({ command: hook.command, cwd, stdin, timeoutMs });\n const decision = decideOutcome(event, raw);\n outcomes.push({\n hook,\n decision,\n exitCode: raw.exitCode,\n stdout: raw.stdout,\n stderr:\n raw.stderr ||\n (raw.spawnError ? raw.spawnError.message : \"\") ||\n (raw.timedOut ? `hook timed out after ${timeoutMs}ms` : \"\"),\n durationMs: Date.now() - start,\n truncated: raw.truncated,\n });\n if (decision === \"block\") {\n blocked = true;\n break;\n }\n }\n\n return { event, outcomes, blocked };\n}\n"],"mappings":";;;;;;;AAEA,SAAS,aAAa;AACtB,SAAS,YAAY,oBAAoB;AACzC,SAAS,eAAe;AACxB,SAAS,YAAY;AAMd,IAAM,cAAoC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,IAAM,kBAA0C,oBAAI,IAAI,CAAC,cAAc,kBAAkB,CAAC;AAG1F,IAAM,sBAAiD;AAAA,EACrD,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb,MAAM;AACR;AAsDO,IAAM,yBAAyB;AAC/B,IAAM,wBAAwB;AAC9B,IAAM,+BAA+B;AAGrC,SAAS,mBAAmB,iBAAkC;AACnE,SAAO,KAAK,mBAAmB,QAAQ,GAAG,uBAAuB,sBAAsB;AACzF;AAGO,SAAS,oBAAoB,aAA6B;AAC/D,SAAO,KAAK,aAAa,uBAAuB,sBAAsB;AACxE;AAEA,SAAS,yBAAyB,iBAAkC;AAClE,SAAO,KAAK,mBAAmB,QAAQ,GAAG,8BAA8B,sBAAsB;AAChG;AAEA,SAAS,0BAA0B,aAA6B;AAC9D,SAAO,KAAK,aAAa,8BAA8B,sBAAsB;AAC/E;AAEA,SAAS,iBAAiB,MAAmC;AAC3D,MAAI,CAAC,WAAW,IAAI,EAAG,QAAO;AAC9B,MAAI;AACF,UAAM,MAAM,aAAa,MAAM,MAAM;AACrC,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,QAAI,UAAU,OAAO,WAAW,SAAU,QAAO;AAAA,EACnD,QAAQ;AAAA,EAGR;AACA,SAAO;AACT;AAEA,SAAS,0BACP,SAC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