observability-toolkit-hooks 0.0.0-stage → 1.0.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 (305) hide show
  1. package/CONFIG.md +144 -0
  2. package/README.md +201 -2
  3. package/dist/handlers/compact.js +38 -0
  4. package/dist/handlers/mcp-status.js +66 -0
  5. package/dist/handlers/notification.js +45 -0
  6. package/dist/handlers/post-tool-agent.js +157 -0
  7. package/dist/handlers/post-tool-changelog-sync.js +148 -0
  8. package/dist/handlers/post-tool-code-structure.js +116 -0
  9. package/dist/handlers/post-tool-edit-ledger.js +15 -0
  10. package/dist/handlers/post-tool-failure.js +83 -0
  11. package/dist/handlers/post-tool-git.js +79 -0
  12. package/dist/handlers/post-tool-mcp.js +105 -0
  13. package/dist/handlers/post-tool-outcome.js +48 -0
  14. package/dist/handlers/post-tool-task-state.js +74 -0
  15. package/dist/handlers/post-tool.js +132 -0
  16. package/dist/handlers/pre-tool-agent.js +192 -0
  17. package/dist/handlers/pre-tool.js +218 -0
  18. package/dist/handlers/session-end.js +39 -0
  19. package/dist/handlers/session-start.js +262 -0
  20. package/dist/handlers/stop-error-reminder.js +195 -0
  21. package/dist/handlers/stop-quality-evaluation.js +58 -0
  22. package/dist/handlers/stop-session-summary.js +62 -0
  23. package/dist/handlers/stop-token-metrics.js +83 -0
  24. package/dist/handlers/stop.js +25 -0
  25. package/dist/handlers/subagent.js +105 -0
  26. package/dist/handlers/tool-event-router.js +39 -0
  27. package/dist/handlers/user-prompt.js +218 -0
  28. package/dist/hook-runner.js +10 -0
  29. package/dist/hook-runner.js.map +7 -0
  30. package/dist/lib/agent/agent-context.js +123 -0
  31. package/dist/lib/agent/agent-evaluations.js +155 -0
  32. package/dist/lib/agent/agent-file-budget.js +65 -0
  33. package/dist/lib/agent/agent-sources.js +165 -0
  34. package/dist/lib/agent/synth-spans.js +51 -0
  35. package/dist/lib/core/bounded-label.js +6 -0
  36. package/dist/lib/core/category-rules.js +11 -0
  37. package/dist/lib/core/child-result.js +19 -0
  38. package/dist/lib/core/config-dir-recovery.js +22 -0
  39. package/dist/lib/core/constants.js +171 -0
  40. package/dist/lib/core/detached-runner.js +55 -0
  41. package/dist/lib/core/file-utils.js +353 -0
  42. package/dist/lib/core/format-utils.js +51 -0
  43. package/dist/lib/core/http-utils.js +74 -0
  44. package/dist/lib/core/http1-fetch.js +14 -0
  45. package/dist/lib/core/identity-key-resolver.js +149 -0
  46. package/dist/lib/core/jsonl-tail.js +207 -0
  47. package/dist/lib/core/load-envrc.js +72 -0
  48. package/dist/lib/core/parsers.js +43 -0
  49. package/dist/lib/core/regex.js +27 -0
  50. package/dist/lib/core/settings-env.js +31 -0
  51. package/dist/lib/core/shell-command.js +122 -0
  52. package/dist/lib/core/units.js +97 -0
  53. package/dist/lib/git/git-cache.js +158 -0
  54. package/dist/lib/git/git-commit.js +189 -0
  55. package/dist/lib/git/git-exec.js +30 -0
  56. package/dist/lib/mcp/mcp-completeness.js +40 -0
  57. package/dist/lib/mcp/mcp-config.js +118 -0
  58. package/dist/lib/mcp/mcp-failure-latch.js +22 -0
  59. package/dist/lib/mcp/mcp-identity-launcher.js +43 -0
  60. package/dist/lib/otel/attributes.js +322 -0
  61. package/dist/lib/otel/evaluation-attrs.js +51 -0
  62. package/dist/lib/otel/file-exporters.js +169 -0
  63. package/dist/lib/otel/host-resource.js +61 -0
  64. package/dist/lib/otel/otel-headers-helper.js +26 -0
  65. package/dist/lib/otel/otel-monitor.js +181 -0
  66. package/dist/lib/otel/otel.js +235 -0
  67. package/dist/lib/otel/otlp-headers.js +101 -0
  68. package/dist/lib/otel/otlp-post.js +122 -0
  69. package/dist/lib/otel/otlp-serialize.js +142 -0
  70. package/dist/lib/otel/otlp-signal.js +2 -0
  71. package/dist/lib/otel/remote-spans.js +142 -0
  72. package/dist/lib/otel/service-identity.js +10 -0
  73. package/dist/lib/otel/telemetry-alerts.js +43 -0
  74. package/dist/lib/otel/token-metrics.js +122 -0
  75. package/dist/lib/otel/trace-context.js +81 -0
  76. package/dist/lib/quality/judge-meta-eval.js +70 -0
  77. package/dist/lib/quality/judge-prompts.js +104 -0
  78. package/dist/lib/quality/judge-providers.js +193 -0
  79. package/dist/lib/quality/judge-transport.js +93 -0
  80. package/dist/lib/quality/llm-judge.js +170 -0
  81. package/dist/lib/quality/quality-budget.js +99 -0
  82. package/dist/lib/quality/quality-degradation.js +156 -0
  83. package/dist/lib/quality/quality-eval-handoff.js +74 -0
  84. package/dist/lib/quality/quality-evaluator.js +178 -0
  85. package/dist/lib/quality/quality-sampler.js +43 -0
  86. package/dist/lib/quality/quality-signals.js +150 -0
  87. package/dist/lib/runtime/categorizers.js +101 -0
  88. package/dist/lib/runtime/hook-input.js +16 -0
  89. package/dist/lib/runtime/hook-output.js +50 -0
  90. package/dist/lib/runtime/output-analyzer.js +160 -0
  91. package/dist/lib/runtime/run-handlers.js +32 -0
  92. package/dist/lib/runtime/tool-input.js +111 -0
  93. package/dist/lib/runtime/tool-output.js +44 -0
  94. package/dist/lib/runtime/unknown-tool.js +32 -0
  95. package/dist/lib/session/edit-ledger.js +29 -0
  96. package/dist/lib/session/forked-skill.js +39 -0
  97. package/dist/lib/session/handoffs.js +77 -0
  98. package/dist/lib/session/session-state.js +169 -0
  99. package/dist/lib/session/skill-rules.js +196 -0
  100. package/dist/lib/session/task-tracker.js +83 -0
  101. package/dist/lib/shipper/shipper-credentials.js +38 -0
  102. package/dist/lib/shipper/shipper-cursor.js +89 -0
  103. package/dist/lib/shipper/shipper-status.js +174 -0
  104. package/dist/lib/shipper/span-shipper.js +272 -0
  105. package/dist/lib/shipper/telemetry-shipper.js +39 -0
  106. package/dist/lib/transcript/agent-transcript-metrics.js +34 -0
  107. package/dist/lib/transcript/context-breakdown.js +134 -0
  108. package/dist/lib/transcript/context-history.js +69 -0
  109. package/dist/lib/transcript/context-tracker.js +226 -0
  110. package/dist/lib/transcript/message-count.js +49 -0
  111. package/dist/lib/transcript/model-ids.js +36 -0
  112. package/dist/lib/transcript/model-pricing.js +153 -0
  113. package/dist/lib/transcript/token-metrics-checkpoint.js +152 -0
  114. package/dist/lib/transcript/tool-call-durations.js +64 -0
  115. package/dist/lib/transcript/transcript-entry.js +67 -0
  116. package/dist/lib/transcript/transcript-fold.js +130 -0
  117. package/dist/lib/transcript/transcript-layout.js +39 -0
  118. package/dist/lib/transcript/transcript-parser.js +117 -0
  119. package/dist/runner/agent-context-4XTCLMLZ.js +23 -0
  120. package/dist/runner/agent-context-4XTCLMLZ.js.map +7 -0
  121. package/dist/runner/agent-file-budget-Q33ESBBE.js +68 -0
  122. package/dist/runner/agent-file-budget-Q33ESBBE.js.map +7 -0
  123. package/dist/runner/agent-transcript-metrics-W5CZZFMI.js +39 -0
  124. package/dist/runner/agent-transcript-metrics-W5CZZFMI.js.map +7 -0
  125. package/dist/runner/chunk-2NTNAJZE.js +49 -0
  126. package/dist/runner/chunk-2NTNAJZE.js.map +7 -0
  127. package/dist/runner/chunk-4KWBQTTG.js +78 -0
  128. package/dist/runner/chunk-4KWBQTTG.js.map +7 -0
  129. package/dist/runner/chunk-52RY6LQT.js +699 -0
  130. package/dist/runner/chunk-52RY6LQT.js.map +7 -0
  131. package/dist/runner/chunk-7OM5CYES.js +8695 -0
  132. package/dist/runner/chunk-7OM5CYES.js.map +7 -0
  133. package/dist/runner/chunk-7PEOKGYR.js +1568 -0
  134. package/dist/runner/chunk-7PEOKGYR.js.map +7 -0
  135. package/dist/runner/chunk-AGSGKELQ.js +126 -0
  136. package/dist/runner/chunk-AGSGKELQ.js.map +7 -0
  137. package/dist/runner/chunk-AVM7PJFW.js +12 -0
  138. package/dist/runner/chunk-AVM7PJFW.js.map +7 -0
  139. package/dist/runner/chunk-C3WHUMU5.js +178 -0
  140. package/dist/runner/chunk-C3WHUMU5.js.map +7 -0
  141. package/dist/runner/chunk-DGB4NSSD.js +157 -0
  142. package/dist/runner/chunk-DGB4NSSD.js.map +7 -0
  143. package/dist/runner/chunk-DNSTWC26.js +151 -0
  144. package/dist/runner/chunk-DNSTWC26.js.map +7 -0
  145. package/dist/runner/chunk-FDJJ3TYU.js +449 -0
  146. package/dist/runner/chunk-FDJJ3TYU.js.map +7 -0
  147. package/dist/runner/chunk-FGKYDQHZ.js +137 -0
  148. package/dist/runner/chunk-FGKYDQHZ.js.map +7 -0
  149. package/dist/runner/chunk-GG2I4TGI.js +582 -0
  150. package/dist/runner/chunk-GG2I4TGI.js.map +7 -0
  151. package/dist/runner/chunk-GNNKUMRF.js +60 -0
  152. package/dist/runner/chunk-GNNKUMRF.js.map +7 -0
  153. package/dist/runner/chunk-I7TD2QVR.js +118 -0
  154. package/dist/runner/chunk-I7TD2QVR.js.map +7 -0
  155. package/dist/runner/chunk-IJ4SLUBV.js +78 -0
  156. package/dist/runner/chunk-IJ4SLUBV.js.map +7 -0
  157. package/dist/runner/chunk-IY7AP7NA.js +32 -0
  158. package/dist/runner/chunk-IY7AP7NA.js.map +7 -0
  159. package/dist/runner/chunk-J3F3Z3EQ.js +177 -0
  160. package/dist/runner/chunk-J3F3Z3EQ.js.map +7 -0
  161. package/dist/runner/chunk-JLEO5OHU.js +104 -0
  162. package/dist/runner/chunk-JLEO5OHU.js.map +7 -0
  163. package/dist/runner/chunk-JRNNLOPR.js +168 -0
  164. package/dist/runner/chunk-JRNNLOPR.js.map +7 -0
  165. package/dist/runner/chunk-KGSA5JYP.js +82 -0
  166. package/dist/runner/chunk-KGSA5JYP.js.map +7 -0
  167. package/dist/runner/chunk-LBCZAYFR.js +125 -0
  168. package/dist/runner/chunk-LBCZAYFR.js.map +7 -0
  169. package/dist/runner/chunk-LHWRXY2G.js +41 -0
  170. package/dist/runner/chunk-LHWRXY2G.js.map +7 -0
  171. package/dist/runner/chunk-LQ2LGUYJ.js +41 -0
  172. package/dist/runner/chunk-LQ2LGUYJ.js.map +7 -0
  173. package/dist/runner/chunk-LYY6RCIE.js +158 -0
  174. package/dist/runner/chunk-LYY6RCIE.js.map +7 -0
  175. package/dist/runner/chunk-M4R4QIQH.js +41 -0
  176. package/dist/runner/chunk-M4R4QIQH.js.map +7 -0
  177. package/dist/runner/chunk-MC75VXMX.js +207 -0
  178. package/dist/runner/chunk-MC75VXMX.js.map +7 -0
  179. package/dist/runner/chunk-NKZU4RRG.js +104 -0
  180. package/dist/runner/chunk-NKZU4RRG.js.map +7 -0
  181. package/dist/runner/chunk-PJHWHJ3K.js +56 -0
  182. package/dist/runner/chunk-PJHWHJ3K.js.map +7 -0
  183. package/dist/runner/chunk-RIGVYJ2O.js +114 -0
  184. package/dist/runner/chunk-RIGVYJ2O.js.map +7 -0
  185. package/dist/runner/chunk-RWRGC7ZK.js +93 -0
  186. package/dist/runner/chunk-RWRGC7ZK.js.map +7 -0
  187. package/dist/runner/chunk-SRMAJQMV.js +54 -0
  188. package/dist/runner/chunk-SRMAJQMV.js.map +7 -0
  189. package/dist/runner/chunk-TRMFD36J.js +47 -0
  190. package/dist/runner/chunk-TRMFD36J.js.map +7 -0
  191. package/dist/runner/chunk-U4IOZYQ3.js +21 -0
  192. package/dist/runner/chunk-U4IOZYQ3.js.map +7 -0
  193. package/dist/runner/chunk-UEXDE3WP.js +83 -0
  194. package/dist/runner/chunk-UEXDE3WP.js.map +7 -0
  195. package/dist/runner/chunk-UW3GQZSM.js +50 -0
  196. package/dist/runner/chunk-UW3GQZSM.js.map +7 -0
  197. package/dist/runner/chunk-V2GSP6VR.js +46 -0
  198. package/dist/runner/chunk-V2GSP6VR.js.map +7 -0
  199. package/dist/runner/chunk-VOV4Y5VU.js +81 -0
  200. package/dist/runner/chunk-VOV4Y5VU.js.map +7 -0
  201. package/dist/runner/chunk-VT5T6OEI.js +65 -0
  202. package/dist/runner/chunk-VT5T6OEI.js.map +7 -0
  203. package/dist/runner/chunk-VUYVFWIN.js +12 -0
  204. package/dist/runner/chunk-VUYVFWIN.js.map +7 -0
  205. package/dist/runner/chunk-VVGOPPEN.js +36 -0
  206. package/dist/runner/chunk-VVGOPPEN.js.map +7 -0
  207. package/dist/runner/chunk-VXFSLM6P.js +14 -0
  208. package/dist/runner/chunk-VXFSLM6P.js.map +7 -0
  209. package/dist/runner/chunk-W3EK7JUT.js +26125 -0
  210. package/dist/runner/chunk-W3EK7JUT.js.map +7 -0
  211. package/dist/runner/chunk-WJHNCOUF.js +52 -0
  212. package/dist/runner/chunk-WJHNCOUF.js.map +7 -0
  213. package/dist/runner/chunk-WU7ANGCW.js +269 -0
  214. package/dist/runner/chunk-WU7ANGCW.js.map +7 -0
  215. package/dist/runner/chunk-X7XLMSZX.js +44 -0
  216. package/dist/runner/chunk-X7XLMSZX.js.map +7 -0
  217. package/dist/runner/chunk-XSO3B4QN.js +124 -0
  218. package/dist/runner/chunk-XSO3B4QN.js.map +7 -0
  219. package/dist/runner/chunk-YGFN3LN2.js +174 -0
  220. package/dist/runner/chunk-YGFN3LN2.js.map +7 -0
  221. package/dist/runner/chunk-YHYDBLVB.js +33 -0
  222. package/dist/runner/chunk-YHYDBLVB.js.map +7 -0
  223. package/dist/runner/compact-36NP3PKT.js +60 -0
  224. package/dist/runner/compact-36NP3PKT.js.map +7 -0
  225. package/dist/runner/getMachineId-bsd-AGENNHN6.js +42 -0
  226. package/dist/runner/getMachineId-bsd-AGENNHN6.js.map +7 -0
  227. package/dist/runner/getMachineId-bsd-I5WZGCL4.js +33 -0
  228. package/dist/runner/getMachineId-bsd-I5WZGCL4.js.map +7 -0
  229. package/dist/runner/getMachineId-bsd-ZXK225P7.js +33 -0
  230. package/dist/runner/getMachineId-bsd-ZXK225P7.js.map +7 -0
  231. package/dist/runner/getMachineId-darwin-47GDLEXL.js +42 -0
  232. package/dist/runner/getMachineId-darwin-47GDLEXL.js.map +7 -0
  233. package/dist/runner/getMachineId-darwin-5CRLMDD6.js +33 -0
  234. package/dist/runner/getMachineId-darwin-5CRLMDD6.js.map +7 -0
  235. package/dist/runner/getMachineId-darwin-ADG4I32N.js +33 -0
  236. package/dist/runner/getMachineId-darwin-ADG4I32N.js.map +7 -0
  237. package/dist/runner/getMachineId-linux-5KVS3T2M.js +27 -0
  238. package/dist/runner/getMachineId-linux-5KVS3T2M.js.map +7 -0
  239. package/dist/runner/getMachineId-linux-GDFB5GSO.js +34 -0
  240. package/dist/runner/getMachineId-linux-GDFB5GSO.js.map +7 -0
  241. package/dist/runner/getMachineId-linux-NQMWCRO3.js +27 -0
  242. package/dist/runner/getMachineId-linux-NQMWCRO3.js.map +7 -0
  243. package/dist/runner/getMachineId-unsupported-5PFIGMVX.js +18 -0
  244. package/dist/runner/getMachineId-unsupported-5PFIGMVX.js.map +7 -0
  245. package/dist/runner/getMachineId-unsupported-DW27K3ZX.js +18 -0
  246. package/dist/runner/getMachineId-unsupported-DW27K3ZX.js.map +7 -0
  247. package/dist/runner/getMachineId-unsupported-XV3FHTHD.js +25 -0
  248. package/dist/runner/getMachineId-unsupported-XV3FHTHD.js.map +7 -0
  249. package/dist/runner/getMachineId-win-5JVMW3EI.js +44 -0
  250. package/dist/runner/getMachineId-win-5JVMW3EI.js.map +7 -0
  251. package/dist/runner/getMachineId-win-SNESQF7R.js +35 -0
  252. package/dist/runner/getMachineId-win-SNESQF7R.js.map +7 -0
  253. package/dist/runner/getMachineId-win-UJYHSBM2.js +35 -0
  254. package/dist/runner/getMachineId-win-UJYHSBM2.js.map +7 -0
  255. package/dist/runner/git-commit-BA53DOJQ.js +30 -0
  256. package/dist/runner/git-commit-BA53DOJQ.js.map +7 -0
  257. package/dist/runner/hook-runner-JHH6PGKE.js +220 -0
  258. package/dist/runner/hook-runner-JHH6PGKE.js.map +7 -0
  259. package/dist/runner/judge-transport-R4TF5LEH.js +91 -0
  260. package/dist/runner/judge-transport-R4TF5LEH.js.map +7 -0
  261. package/dist/runner/mcp-status-QEUH2KGX.js +89 -0
  262. package/dist/runner/mcp-status-QEUH2KGX.js.map +7 -0
  263. package/dist/runner/notification-FKMBCSXF.js +69 -0
  264. package/dist/runner/notification-FKMBCSXF.js.map +7 -0
  265. package/dist/runner/post-tool-3MRHTBKH.js +192 -0
  266. package/dist/runner/post-tool-3MRHTBKH.js.map +7 -0
  267. package/dist/runner/post-tool-agent-BB34MNHI.js +370 -0
  268. package/dist/runner/post-tool-agent-BB34MNHI.js.map +7 -0
  269. package/dist/runner/post-tool-changelog-sync-OP2TT2I7.js +147 -0
  270. package/dist/runner/post-tool-changelog-sync-OP2TT2I7.js.map +7 -0
  271. package/dist/runner/post-tool-code-structure-LE7J2SC2.js +130 -0
  272. package/dist/runner/post-tool-code-structure-LE7J2SC2.js.map +7 -0
  273. package/dist/runner/post-tool-edit-ledger-IJMEYHKF.js +30 -0
  274. package/dist/runner/post-tool-edit-ledger-IJMEYHKF.js.map +7 -0
  275. package/dist/runner/post-tool-failure-XTH2I2Z7.js +111 -0
  276. package/dist/runner/post-tool-failure-XTH2I2Z7.js.map +7 -0
  277. package/dist/runner/post-tool-git-E46HZGZO.js +94 -0
  278. package/dist/runner/post-tool-git-E46HZGZO.js.map +7 -0
  279. package/dist/runner/post-tool-mcp-AMCDY5GH.js +144 -0
  280. package/dist/runner/post-tool-mcp-AMCDY5GH.js.map +7 -0
  281. package/dist/runner/post-tool-task-state-TLDOI33H.js +100 -0
  282. package/dist/runner/post-tool-task-state-TLDOI33H.js.map +7 -0
  283. package/dist/runner/pre-tool-SQE2FZQO.js +245 -0
  284. package/dist/runner/pre-tool-SQE2FZQO.js.map +7 -0
  285. package/dist/runner/pre-tool-agent-OZUPVFUI.js +218 -0
  286. package/dist/runner/pre-tool-agent-OZUPVFUI.js.map +7 -0
  287. package/dist/runner/quality-evaluator-XYNDKDRG.js +901 -0
  288. package/dist/runner/quality-evaluator-XYNDKDRG.js.map +7 -0
  289. package/dist/runner/session-end-3MJTDLLA.js +57 -0
  290. package/dist/runner/session-end-3MJTDLLA.js.map +7 -0
  291. package/dist/runner/session-start-5ZMCLKBS.js +352 -0
  292. package/dist/runner/session-start-5ZMCLKBS.js.map +7 -0
  293. package/dist/runner/shipper-status-MADX6SPG.js +37 -0
  294. package/dist/runner/shipper-status-MADX6SPG.js.map +7 -0
  295. package/dist/runner/span-shipper-4HQDHC47.js +3408 -0
  296. package/dist/runner/span-shipper-4HQDHC47.js.map +7 -0
  297. package/dist/runner/stop-RTKSIYJV.js +596 -0
  298. package/dist/runner/stop-RTKSIYJV.js.map +7 -0
  299. package/dist/runner/subagent-CBCG4OLZ.js +116 -0
  300. package/dist/runner/subagent-CBCG4OLZ.js.map +7 -0
  301. package/dist/runner/token-metrics-AD2RAFGM.js +31 -0
  302. package/dist/runner/token-metrics-AD2RAFGM.js.map +7 -0
  303. package/dist/runner/user-prompt-T5NZ2UJD.js +376 -0
  304. package/dist/runner/user-prompt-T5NZ2UJD.js.map +7 -0
  305. package/package.json +68 -5
@@ -0,0 +1,178 @@
1
+ import { createRequire as __hookRunnerCreateRequire } from 'node:module';
2
+ const require = __hookRunnerCreateRequire(import.meta.url);
3
+ import {
4
+ commandInvocations,
5
+ isOptionArg,
6
+ programOf
7
+ } from "./chunk-JLEO5OHU.js";
8
+ import {
9
+ resolveOutputText
10
+ } from "./chunk-M4R4QIQH.js";
11
+ import {
12
+ getStringField
13
+ } from "./chunk-NKZU4RRG.js";
14
+ import {
15
+ classifyExecError,
16
+ git
17
+ } from "./chunk-SRMAJQMV.js";
18
+ import {
19
+ sessionStateDir
20
+ } from "./chunk-DNSTWC26.js";
21
+ import {
22
+ GIT_COMMIT_SUBCOMMAND,
23
+ GIT_TIMEOUT_MS,
24
+ loadJson,
25
+ writeJsonAtomic
26
+ } from "./chunk-52RY6LQT.js";
27
+
28
+ // lib/git/git-commit.ts
29
+ import { createHash } from "node:crypto";
30
+ import { rmSync } from "node:fs";
31
+ import { join } from "node:path";
32
+ var GIT_PROGRAM = "git";
33
+ var GIT_OPTIONS_WITH_VALUE = /* @__PURE__ */ new Set(["-C", "-c", "--git-dir", "--work-tree", "--namespace", "--config-env"]);
34
+ var HELP_FLAGS = /* @__PURE__ */ new Set(["-h", "--help"]);
35
+ var COMMIT_WRAPPER_SCRIPTS = /* @__PURE__ */ new Set(["conventional-commit.sh"]);
36
+ function isGitCommitCommand(command) {
37
+ if (!command.includes(GIT_COMMIT_SUBCOMMAND)) return false;
38
+ return commandInvocations(command).some((argv) => {
39
+ const program = programOf(argv);
40
+ if (COMMIT_WRAPPER_SCRIPTS.has(program)) return true;
41
+ if (program !== GIT_PROGRAM) return false;
42
+ let i = 1;
43
+ for (let arg = argv[i]; arg !== void 0 && isOptionArg(arg); arg = argv[i]) i += GIT_OPTIONS_WITH_VALUE.has(arg) ? 2 : 1;
44
+ return argv[i] === GIT_COMMIT_SUBCOMMAND && !argv.slice(i + 1).some((arg) => HELP_FLAGS.has(arg));
45
+ });
46
+ }
47
+ var COMMIT_SUCCESS_PATTERN = /\[.+\s[a-f0-9]+\]/;
48
+ var NOTHING_TO_COMMIT = "nothing to commit";
49
+ var commandOf = (input) => getStringField(input, "command") ?? "";
50
+ var eventCwd = (input) => input.cwd || process.cwd();
51
+ var COMMIT_REFLOG_ACTION = /^commit( \([a-z]+\))?:/;
52
+ var REFLOG_FIELD_SEPARATOR = " ";
53
+ var HEAD_SNAPSHOT_DIR = "git-head-snapshots";
54
+ var UNBORN_HEAD = "";
55
+ var UNBORN_HEAD_EXIT = 1;
56
+ function snapshotPath(sessionId, command, toolUseId) {
57
+ const key = createHash("sha1").update(toolUseId || command).digest("hex");
58
+ return join(sessionStateDir(sessionId), HEAD_SNAPSHOT_DIR, `${key}.json`);
59
+ }
60
+ async function readHead(cwd) {
61
+ try {
62
+ return (await git(cwd, ["rev-parse", "-q", "--verify", "HEAD"], GIT_TIMEOUT_MS.HOOK_PATH)).trim();
63
+ } catch (error) {
64
+ return error.code === UNBORN_HEAD_EXIT ? UNBORN_HEAD : void 0;
65
+ }
66
+ }
67
+ async function recordCommitHeadSnapshot(input) {
68
+ const command = commandOf(input);
69
+ if (!input.session_id || !isGitCommitCommand(command)) return;
70
+ const path = snapshotPath(input.session_id, command, input.tool_use_id);
71
+ const head = await readHead(eventCwd(input));
72
+ if (head === void 0) {
73
+ rmSync(path, { force: true });
74
+ return;
75
+ }
76
+ writeJsonAtomic(path, { head }, { silent: true });
77
+ }
78
+ function discardCommitHeadSnapshot(input) {
79
+ const command = commandOf(input);
80
+ if (!input.session_id || !isGitCommitCommand(command)) return;
81
+ rmSync(snapshotPath(input.session_id, command, input.tool_use_id), { force: true });
82
+ }
83
+ function takeHeadSnapshot(input, command) {
84
+ if (!input.session_id) return void 0;
85
+ const path = snapshotPath(input.session_id, command, input.tool_use_id);
86
+ const snapshot = loadJson(path);
87
+ rmSync(path, { force: true });
88
+ return typeof snapshot?.head === "string" ? snapshot.head : void 0;
89
+ }
90
+ async function headMovedByCommit(cwd, before) {
91
+ try {
92
+ const stdout = await git(
93
+ cwd,
94
+ ["reflog", "-1", `--format=%H${REFLOG_FIELD_SEPARATOR}%gs`, "HEAD"],
95
+ GIT_TIMEOUT_MS.HOOK_PATH
96
+ );
97
+ const [sha = "", subject = ""] = stdout.trim().split(REFLOG_FIELD_SEPARATOR);
98
+ return sha !== "" && sha !== before && COMMIT_REFLOG_ACTION.test(subject);
99
+ } catch {
100
+ return false;
101
+ }
102
+ }
103
+ var COMMIT_FILES_ARGS = [
104
+ "diff-tree",
105
+ "-m",
106
+ "--first-parent",
107
+ "--root",
108
+ "--name-only",
109
+ "-r",
110
+ "HEAD"
111
+ ];
112
+ var SHA_RE = /^[0-9a-f]{40}$/;
113
+ async function getCommittedFiles(cwd) {
114
+ try {
115
+ const stdout = await git(cwd, COMMIT_FILES_ARGS, GIT_TIMEOUT_MS.HOOK_PATH);
116
+ const lines = stdout.split("\n").map((line) => line.trim()).filter(Boolean);
117
+ const commit = lines.find((line) => SHA_RE.test(line));
118
+ const files = [...new Set(lines.filter((line) => !SHA_RE.test(line)))];
119
+ return { files, outcome: "ok", commit };
120
+ } catch (error) {
121
+ return { files: [], outcome: classifyExecError(error) };
122
+ }
123
+ }
124
+ var COMMIT_LINE_MARKER = "";
125
+ async function commitsInRange(cwd, base) {
126
+ try {
127
+ const range = base === UNBORN_HEAD ? "HEAD" : `${base}..HEAD`;
128
+ const stdout = await git(
129
+ cwd,
130
+ ["log", "-m", "--first-parent", "--name-only", `--format=${COMMIT_LINE_MARKER}%H`, range],
131
+ GIT_TIMEOUT_MS.HOOK_PATH
132
+ );
133
+ const lines = stdout.split("\n").map((line) => line.trim()).filter(Boolean);
134
+ const result = [];
135
+ let current = null;
136
+ for (const line of lines) {
137
+ if (line.startsWith(COMMIT_LINE_MARKER)) {
138
+ if (current) result.push(current);
139
+ current = { sha: line.slice(1), files: [] };
140
+ } else if (current) {
141
+ if (!current.files.includes(line)) current.files.push(line);
142
+ }
143
+ }
144
+ if (current) result.push(current);
145
+ return result;
146
+ } catch {
147
+ return [];
148
+ }
149
+ }
150
+ async function resolveCommitEvent(input) {
151
+ const command = commandOf(input);
152
+ if (!isGitCommitCommand(command)) return null;
153
+ const before = takeHeadSnapshot(input, command);
154
+ const cwd = eventCwd(input);
155
+ const output = resolveOutputText(input);
156
+ const fastPathLanded = COMMIT_SUCCESS_PATTERN.test(output) && !output.includes(NOTHING_TO_COMMIT);
157
+ const speculativeFiles = !fastPathLanded && before !== void 0 ? getCommittedFiles(cwd) : null;
158
+ const landed = fastPathLanded || before !== void 0 && await headMovedByCommit(cwd, before);
159
+ if (!landed) return null;
160
+ const [head, commits] = await Promise.all([
161
+ speculativeFiles ?? getCommittedFiles(cwd),
162
+ before === void 0 ? Promise.resolve([]) : commitsInRange(cwd, before)
163
+ ]);
164
+ if (commits.length <= 1) return { ...head, commitCount: 1, commandFiles: head.files };
165
+ const commandFiles = [...new Set(commits.flatMap((commit) => commit.files))];
166
+ return { ...head, commitCount: commits.length, commandFiles, base: before };
167
+ }
168
+
169
+ export {
170
+ isGitCommitCommand,
171
+ commandOf,
172
+ UNBORN_HEAD,
173
+ recordCommitHeadSnapshot,
174
+ discardCommitHeadSnapshot,
175
+ getCommittedFiles,
176
+ resolveCommitEvent
177
+ };
178
+ //# sourceMappingURL=chunk-C3WHUMU5.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../lib/git/git-commit.ts"],
4
+ "sourcesContent": ["/**\n * Did a Bash `git commit` land, and which files did it touch (HSF11). A quiet\n * commit is detected against the HEAD PreToolUse snapshotted before the command\n * (HSF10): \"did this command move HEAD\", not \"did HEAD move recently\".\n */\n\nimport { createHash } from 'node:crypto';\nimport { rmSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { classifyExecError, type ExecOutcome } from '../core/child-result.js';\nimport { GIT_COMMIT_SUBCOMMAND, GIT_TIMEOUT_MS } from '../core/constants.js';\nimport { loadJson, writeJsonAtomic } from '../core/file-utils.js';\nimport { commandInvocations, isOptionArg, programOf } from '../core/shell-command.js';\nimport type { HookInput, PostToolHookInput } from '../runtime/hook-input.js';\nimport { getStringField } from '../runtime/tool-input.js';\nimport { resolveOutputText } from '../runtime/tool-output.js';\nimport { sessionStateDir } from '../session/session-state.js';\nimport { git } from './git-exec.js';\n\nconst GIT_PROGRAM = 'git';\n\n/** Global options whose value is the next word (`git -C <dir> commit`). */\nconst GIT_OPTIONS_WITH_VALUE = new Set(['-C', '-c', '--git-dir', '--work-tree', '--namespace', '--config-env']);\n\nconst HELP_FLAGS = new Set(['-h', '--help']);\n\n/** Scripts that run `git commit` themselves; their commits are found through the HEAD snapshot. */\nconst COMMIT_WRAPPER_SCRIPTS = new Set(['conventional-commit.sh']);\n\n/** A simple command that is `git [global options] commit` or a wrapper script (HSF18); `echo git commit` does not count. */\nexport function isGitCommitCommand(command: string): boolean {\n if (!command.includes(GIT_COMMIT_SUBCOMMAND)) return false;\n return commandInvocations(command).some((argv) => {\n const program = programOf(argv);\n if (COMMIT_WRAPPER_SCRIPTS.has(program)) return true;\n if (program !== GIT_PROGRAM) return false;\n let i = 1;\n for (let arg = argv[i]; arg !== undefined && isOptionArg(arg); arg = argv[i]) i += GIT_OPTIONS_WITH_VALUE.has(arg) ? 2 : 1;\n return argv[i] === GIT_COMMIT_SUBCOMMAND && !argv.slice(i + 1).some((arg) => HELP_FLAGS.has(arg));\n });\n}\n\n/** git's `[branch sha]` line on a successful commit. */\nconst COMMIT_SUCCESS_PATTERN = /\\[.+\\s[a-f0-9]+\\]/;\n\nconst NOTHING_TO_COMMIT = 'nothing to commit';\n\ntype BashCommandInput = Pick<HookInput, 'session_id' | 'tool_input' | 'tool_use_id' | 'cwd'>;\n\nexport const commandOf = (input: Pick<HookInput, 'tool_input'>): string => getStringField(input, 'command') ?? '';\nconst eventCwd = (input: Pick<HookInput, 'cwd'>): string => input.cwd || process.cwd();\n\n/** `commit`, `commit (amend|initial|merge)`; never checkout/reset/rebase. */\nconst COMMIT_REFLOG_ACTION = /^commit( \\([a-z]+\\))?:/;\n\nconst REFLOG_FIELD_SEPARATOR = '\\t';\n\nconst HEAD_SNAPSHOT_DIR = 'git-head-snapshots';\n\n/** Recorded for a repo with no commits yet, so its first commit still reads as a move. */\nexport const UNBORN_HEAD = '';\n\n/** `git rev-parse -q --verify HEAD` exits 1 on an unborn branch, 128 outside a repo. */\nconst UNBORN_HEAD_EXIT = 1;\n\ninterface HeadSnapshot {\n head: string;\n}\n\n/** Keyed by the call's `tool_use_id`, so identical commands in flight do not share a snapshot; by command text when the payload has none. */\nfunction snapshotPath(sessionId: string, command: string, toolUseId: string | undefined): string {\n const key = createHash('sha1').update(toolUseId || command).digest('hex');\n return join(sessionStateDir(sessionId), HEAD_SNAPSHOT_DIR, `${key}.json`);\n}\n\nasync function readHead(cwd: string): Promise<string | undefined> {\n try {\n return (await git(cwd, ['rev-parse', '-q', '--verify', 'HEAD'], GIT_TIMEOUT_MS.HOOK_PATH)).trim();\n } catch (error) {\n return (error as { code?: unknown }).code === UNBORN_HEAD_EXIT ? UNBORN_HEAD : undefined;\n }\n}\n\n/** PreToolUse half (HSF10). Outside a repo nothing is recorded and a stale snapshot is removed. */\nexport async function recordCommitHeadSnapshot(input: BashCommandInput): Promise<void> {\n const command = commandOf(input);\n if (!input.session_id || !isGitCommitCommand(command)) return;\n const path = snapshotPath(input.session_id, command, input.tool_use_id);\n const head = await readHead(eventCwd(input));\n if (head === undefined) {\n rmSync(path, { force: true });\n return;\n }\n writeJsonAtomic<HeadSnapshot>(path, { head }, { silent: true });\n}\n\n/** PostToolUseFailure half (HSF19): a failed commit never reaches `resolveCommitEvent`. */\nexport function discardCommitHeadSnapshot(input: Pick<HookInput, 'session_id' | 'tool_input' | 'tool_use_id'>): void {\n const command = commandOf(input);\n if (!input.session_id || !isGitCommitCommand(command)) return;\n rmSync(snapshotPath(input.session_id, command, input.tool_use_id), { force: true });\n}\n\nfunction takeHeadSnapshot(input: BashCommandInput, command: string): string | undefined {\n if (!input.session_id) return undefined;\n const path = snapshotPath(input.session_id, command, input.tool_use_id);\n const snapshot = loadJson<Partial<HeadSnapshot>>(path);\n rmSync(path, { force: true });\n return typeof snapshot?.head === 'string' ? snapshot.head : undefined;\n}\n\nasync function headMovedByCommit(cwd: string, before: string): Promise<boolean> {\n try {\n const stdout = await git(\n cwd, ['reflog', '-1', `--format=%H${REFLOG_FIELD_SEPARATOR}%gs`, 'HEAD'], GIT_TIMEOUT_MS.HOOK_PATH,\n );\n const [sha = '', subject = ''] = stdout.trim().split(REFLOG_FIELD_SEPARATOR);\n return sha !== '' && sha !== before && COMMIT_REFLOG_ACTION.test(subject);\n } catch {\n return false;\n }\n}\n\n/** 'verdict' here means git ran and exited non-zero, most often \"not a git repository\". */\ntype CommitFilesOutcome = 'ok' | ExecOutcome;\n\nexport interface CommittedFiles {\n files: string[];\n outcome: CommitFilesOutcome;\n /** From `diff-tree`'s first line (HSF13); absent on failure outcomes. */\n commit?: string;\n}\n\n/**\n * Against the first parent, not `git show`: its combined diff drops every file\n * identical to a parent, so a merge whose only conflicts were Markdown read as\n * docs-only and skipped review. `--root` keeps an initial commit's files; `-m`\n * still emits one block per parent, hence the dedupe. The SHA leads the output.\n */\nconst COMMIT_FILES_ARGS = [\n 'diff-tree', '-m', '--first-parent', '--root', '--name-only', '-r', 'HEAD',\n];\n\nconst SHA_RE = /^[0-9a-f]{40}$/;\n\n/**\n * An empty `files` never means \"no changes\": git could not answer, and the docs-only\n * skip must fail open into reviewing. Paths come back verbatim (`core.quotePath=false`):\n * git's quoted form of a non-ASCII path matched nothing when joined onto the root.\n */\nexport async function getCommittedFiles(cwd: string): Promise<CommittedFiles> {\n try {\n const stdout = await git(cwd, COMMIT_FILES_ARGS, GIT_TIMEOUT_MS.HOOK_PATH);\n const lines = stdout.split('\\n').map(line => line.trim()).filter(Boolean);\n // With -m a merge repeats the SHA line per parent block.\n const commit = lines.find(line => SHA_RE.test(line));\n const files = [...new Set(lines.filter(line => !SHA_RE.test(line)))];\n return { files, outcome: 'ok', commit };\n } catch (error) {\n return { files: [], outcome: classifyExecError(error) };\n }\n}\n\n/** Commit-line marker in `commitsInRange`'s output; no file line starts with it. */\nconst COMMIT_LINE_MARKER = '\\u0001';\n\ninterface RangeCommit {\n sha: string;\n files: string[];\n}\n\n/** Resolved once per event by the router. */\nexport interface CommitEvent extends CommittedFiles {\n /** HEAD moves since the snapshot; 1 without one. Above 1 for /git-commit-smart's multi-commit run. */\n commitCount: number;\n /** Every file those commits touched; `files` when `commitCount` is 1. */\n commandFiles: string[];\n /** HEAD before the command, only when `commitCount` > 1. */\n base?: string;\n}\n\n/** `base..HEAD` (whole history for an unborn base), newest first. Empty on failure. */\nasync function commitsInRange(cwd: string, base: string): Promise<RangeCommit[]> {\n try {\n const range = base === UNBORN_HEAD ? 'HEAD' : `${base}..HEAD`;\n const stdout = await git(\n cwd, ['log', '-m', '--first-parent', '--name-only', `--format=${COMMIT_LINE_MARKER}%H`, range], GIT_TIMEOUT_MS.HOOK_PATH,\n );\n const lines = stdout.split('\\n').map((line) => line.trim()).filter(Boolean);\n const result: RangeCommit[] = [];\n let current: RangeCommit | null = null;\n for (const line of lines) {\n if (line.startsWith(COMMIT_LINE_MARKER)) {\n if (current) result.push(current);\n current = { sha: line.slice(1), files: [] };\n } else if (current) {\n if (!current.files.includes(line)) current.files.push(line);\n }\n }\n if (current) result.push(current);\n return result;\n } catch {\n return [];\n }\n}\n\n/**\n * The `[branch sha]` output line is the fast path and the only one that sees a commit\n * into another repo; `-q`, a redirect or a pipe drops it silently.\n * The snapshot then decides by reflog. Without a snapshot only the fast\n * path answers. On the quiet path diff-tree starts speculatively alongside the reflog read (HSF14).\n */\nexport async function resolveCommitEvent(input: PostToolHookInput): Promise<CommitEvent | null> {\n const command = commandOf(input);\n if (!isGitCommitCommand(command)) return null;\n const before = takeHeadSnapshot(input, command);\n\n const cwd = eventCwd(input);\n\n const output = resolveOutputText(input);\n const fastPathLanded = COMMIT_SUCCESS_PATTERN.test(output) && !output.includes(NOTHING_TO_COMMIT);\n\n const speculativeFiles = (!fastPathLanded && before !== undefined)\n ? getCommittedFiles(cwd)\n : null;\n\n const landed = fastPathLanded\n || (before !== undefined && await headMovedByCommit(cwd, before));\n if (!landed) return null;\n\n const [head, commits] = await Promise.all([\n speculativeFiles ?? getCommittedFiles(cwd),\n before === undefined ? Promise.resolve([]) : commitsInRange(cwd, before),\n ]);\n if (commits.length <= 1) return { ...head, commitCount: 1, commandFiles: head.files };\n const commandFiles = [...new Set(commits.flatMap(commit => commit.files))];\n return { ...head, commitCount: commits.length, commandFiles, base: before };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,YAAY;AAWrB,IAAM,cAAc;AAGpB,IAAM,yBAAyB,oBAAI,IAAI,CAAC,MAAM,MAAM,aAAa,eAAe,eAAe,cAAc,CAAC;AAE9G,IAAM,aAAa,oBAAI,IAAI,CAAC,MAAM,QAAQ,CAAC;AAG3C,IAAM,yBAAyB,oBAAI,IAAI,CAAC,wBAAwB,CAAC;AAG1D,SAAS,mBAAmB,SAA0B;AAC3D,MAAI,CAAC,QAAQ,SAAS,qBAAqB,EAAG,QAAO;AACrD,SAAO,mBAAmB,OAAO,EAAE,KAAK,CA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QAAM,UAAU,UAAU,KAAK;AAC/B,MAAI,CAAC,mBAAmB,OAAO,EAAG,QAAO;AACzC,QAAM,SAAS,iBAAiB,OAAO,OAAO;AAE9C,QAAM,MAAM,SAAS,KAAK;AAE1B,QAAM,SAAS,kBAAkB,KAAK;AACtC,QAAM,iBAAiB,uBAAuB,KAAK,MAAM,KAAK,CAAC,OAAO,SAAS,iBAAiB;AAEhG,QAAM,mBAAoB,CAAC,kBAAkB,WAAW,SACpD,kBAAkB,GAAG,IACrB;AAEJ,QAAM,SAAS,kBACT,WAAW,UAAa,MAAM,kBAAkB,KAAK,MAAM;AACjE,MAAI,CAAC,OAAQ,QAAO;AAEpB,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,QAAQ,IAAI;AAAA,IACxC,oBAAoB,kBAAkB,GAAG;AAAA,IACzC,WAAW,SAAY,QAAQ,QAAQ,CAAC,CAAC,IAAI,eAAe,KAAK,MAAM;AAAA,EACzE,CAAC;AACD,MAAI,QAAQ,UAAU,EAAG,QAAO,EAAE,GAAG,MAAM,aAAa,GAAG,cAAc,KAAK,MAAM;AACpF,QAAM,eAAe,CAAC,GAAG,IAAI,IAAI,QAAQ,QAAQ,YAAU,OAAO,KAAK,CAAC,CAAC;AACzE,SAAO,EAAE,GAAG,MAAM,aAAa,QAAQ,QAAQ,cAAc,MAAM,OAAO;AAC5E;",
6
+ "names": []
7
+ }
@@ -0,0 +1,157 @@
1
+ import { createRequire as __hookRunnerCreateRequire } from 'node:module';
2
+ const require = __hookRunnerCreateRequire(import.meta.url);
3
+ import {
4
+ resolveAgentName
5
+ } from "./chunk-LHWRXY2G.js";
6
+ import {
7
+ readString
8
+ } from "./chunk-NKZU4RRG.js";
9
+ import {
10
+ promptLinkAttrs
11
+ } from "./chunk-WU7ANGCW.js";
12
+ import {
13
+ AGENT_ATTRS,
14
+ GENAI_AGENT_ATTRIBUTES
15
+ } from "./chunk-7OM5CYES.js";
16
+ import {
17
+ CLAUDE_HOME,
18
+ readdirOrEmpty
19
+ } from "./chunk-52RY6LQT.js";
20
+
21
+ // lib/agent/agent-sources.ts
22
+ import { existsSync, readdirSync } from "node:fs";
23
+ import { join } from "node:path";
24
+ var BUILTIN_AGENTS = /* @__PURE__ */ new Set([
25
+ "Bash",
26
+ "general-purpose",
27
+ "statusline-setup",
28
+ "Explore",
29
+ "Plan",
30
+ "claude-code-guide",
31
+ "code-reviewer",
32
+ "auto-error-resolver",
33
+ "webscraping-research-analyst",
34
+ "typescript-type-validator"
35
+ ]);
36
+ var AGENTS_DIR = "agents";
37
+ var SKILLS_DIR = "skills";
38
+ var LAZY_AGENTS_DIR = "lazy-agents";
39
+ var LAZY_SKILLS_DIR = "lazy-skills";
40
+ var AGENT_FILE_EXT = ".md";
41
+ var SOURCE_LOOKUPS = {
42
+ agent: {
43
+ suffix: AGENT_FILE_EXT,
44
+ dirs: [
45
+ { dir: AGENTS_DIR, sourceType: "active" },
46
+ { dir: LAZY_AGENTS_DIR, sourceType: "lazy" }
47
+ ]
48
+ },
49
+ skill: {
50
+ suffix: "",
51
+ dirs: [
52
+ { dir: SKILLS_DIR, sourceType: "active" },
53
+ { dir: LAZY_SKILLS_DIR, sourceType: "lazy" }
54
+ ]
55
+ }
56
+ };
57
+ function findInSourceDirs(kind, name) {
58
+ const { suffix, dirs } = SOURCE_LOOKUPS[kind];
59
+ const entry = `${name}${suffix}`;
60
+ for (const { dir, sourceType } of dirs) {
61
+ if (existsSync(join(CLAUDE_HOME, dir, entry))) return sourceType;
62
+ }
63
+ return void 0;
64
+ }
65
+ var skillAgentIndex = null;
66
+ function buildSkillAgentIndex() {
67
+ const index = /* @__PURE__ */ new Map();
68
+ const skillsDir = join(CLAUDE_HOME, SKILLS_DIR);
69
+ let skillNames;
70
+ try {
71
+ skillNames = readdirSync(skillsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
72
+ } catch {
73
+ return index;
74
+ }
75
+ for (const skillName of skillNames) {
76
+ const agentsDir = join(skillsDir, skillName, AGENTS_DIR);
77
+ for (const file of readdirOrEmpty(agentsDir)) {
78
+ if (!file.toLowerCase().endsWith(AGENT_FILE_EXT)) continue;
79
+ const agentName = file.slice(0, -AGENT_FILE_EXT.length);
80
+ if (!index.has(agentName)) index.set(agentName, skillName);
81
+ }
82
+ }
83
+ return index;
84
+ }
85
+ var agentSourceCache = /* @__PURE__ */ new Map();
86
+ function resolveAgentSource(agentName) {
87
+ const dirSource = findInSourceDirs("agent", agentName);
88
+ if (dirSource) return { sourceType: dirSource };
89
+ if (BUILTIN_AGENTS.has(agentName)) return { sourceType: "builtin" };
90
+ skillAgentIndex ??= buildSkillAgentIndex();
91
+ const parentSkill = skillAgentIndex.get(agentName);
92
+ return parentSkill ? { sourceType: "skill", parentSkill } : { sourceType: "settings" };
93
+ }
94
+ function getAgentSourceType(agentName) {
95
+ const cached = agentSourceCache.get(agentName);
96
+ if (cached) return cached;
97
+ const result = resolveAgentSource(agentName);
98
+ agentSourceCache.set(agentName, result);
99
+ return result;
100
+ }
101
+ function getSkillSourceType(skillName) {
102
+ return findInSourceDirs("skill", skillName) ?? "settings";
103
+ }
104
+ function agentAttribution(input) {
105
+ const agentName = resolveAgentName(input);
106
+ return {
107
+ ...agentName ? { [GENAI_AGENT_ATTRIBUTES.AGENT_NAME]: agentName } : {},
108
+ ...input.agent_id ? { [AGENT_ATTRS.INSTANCE_ID]: input.agent_id } : {}
109
+ };
110
+ }
111
+ function toolEventAttributes(input) {
112
+ return { ...agentAttribution(input), ...promptLinkAttrs(input.session_id) };
113
+ }
114
+ function composeAgentId(agentType, info) {
115
+ return info.parentSkill ? `${info.sourceType}:${info.parentSkill}:${agentType}` : `${info.sourceType}:${agentType}`;
116
+ }
117
+ function agentIdentityAttributes(agentType, info) {
118
+ const agentId = composeAgentId(agentType, info);
119
+ return {
120
+ attrs: {
121
+ [GENAI_AGENT_ATTRIBUTES.AGENT_NAME]: agentType,
122
+ [GENAI_AGENT_ATTRIBUTES.AGENT_ID]: agentId,
123
+ [AGENT_ATTRS.SOURCE_TYPE]: info.sourceType,
124
+ ...info.parentSkill ? { [AGENT_ATTRS.PARENT_SKILL]: info.parentSkill } : {}
125
+ },
126
+ agentId
127
+ };
128
+ }
129
+ function agentInvocationAttributes(agentType, info, toolInput) {
130
+ const { attrs: identityAttrs, agentId } = agentIdentityAttributes(agentType, info);
131
+ const description = readString(toolInput, "description");
132
+ const requestedModel = readString(toolInput, "model");
133
+ const isResume = !!readString(toolInput, "resume");
134
+ const isBackground = toolInput.run_in_background === true;
135
+ return {
136
+ attrs: {
137
+ ...identityAttrs,
138
+ [AGENT_ATTRS.IS_RESUME]: isResume,
139
+ [AGENT_ATTRS.IS_BACKGROUND]: isBackground,
140
+ ...requestedModel ? { [AGENT_ATTRS.REQUESTED_MODEL]: requestedModel } : {},
141
+ ...description ? { [AGENT_ATTRS.TASK_DESCRIPTION]: description } : {}
142
+ },
143
+ agentId,
144
+ description,
145
+ requestedModel,
146
+ isResume,
147
+ isBackground
148
+ };
149
+ }
150
+
151
+ export {
152
+ getAgentSourceType,
153
+ getSkillSourceType,
154
+ toolEventAttributes,
155
+ agentInvocationAttributes
156
+ };
157
+ //# sourceMappingURL=chunk-DGB4NSSD.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../lib/agent/agent-sources.ts"],
4
+ "sourcesContent": ["/** Where an agent or skill is defined: active file, lazy file, builtin, skill-bundled, or settings-only. */\n\nimport { existsSync, readdirSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { CLAUDE_HOME } from '../core/constants.js';\nimport { readdirOrEmpty } from '../core/file-utils.js';\nimport { AGENT_ATTRS, GENAI_AGENT_ATTRIBUTES } from '../otel/attributes.js';\nimport { promptLinkAttrs } from '../otel/trace-context.js';\nimport { readString } from '../runtime/tool-input.js';\nimport { resolveAgentName, type AgentIdentityInput } from '../session/forked-skill.js';\n\nexport const BUILTIN_AGENTS = new Set([\n 'Bash', 'general-purpose', 'statusline-setup', 'Explore', 'Plan',\n 'claude-code-guide', 'code-reviewer', 'auto-error-resolver',\n 'webscraping-research-analyst', 'typescript-type-validator',\n]);\n\ntype SourceType = 'active' | 'lazy' | 'builtin' | 'skill' | 'settings';\n\ninterface AgentSourceInfo {\n sourceType: SourceType;\n parentSkill?: string;\n}\n\nconst AGENTS_DIR = 'agents';\nconst SKILLS_DIR = 'skills';\nconst LAZY_AGENTS_DIR = 'lazy-agents';\nconst LAZY_SKILLS_DIR = 'lazy-skills';\nconst AGENT_FILE_EXT = '.md';\n\n/** `dirs` order is the priority chain. */\ninterface SourceLookup {\n suffix: string;\n dirs: ReadonlyArray<{ dir: string; sourceType: SourceType }>;\n}\n\nconst SOURCE_LOOKUPS = {\n agent: {\n suffix: AGENT_FILE_EXT,\n dirs: [\n { dir: AGENTS_DIR, sourceType: 'active' },\n { dir: LAZY_AGENTS_DIR, sourceType: 'lazy' },\n ],\n },\n skill: {\n suffix: '',\n dirs: [\n { dir: SKILLS_DIR, sourceType: 'active' },\n { dir: LAZY_SKILLS_DIR, sourceType: 'lazy' },\n ],\n },\n} as const satisfies Record<string, SourceLookup>;\n\nfunction findInSourceDirs(kind: keyof typeof SOURCE_LOOKUPS, name: string): SourceType | undefined {\n const { suffix, dirs } = SOURCE_LOOKUPS[kind];\n const entry = `${name}${suffix}`;\n for (const { dir, sourceType } of dirs) {\n if (existsSync(join(CLAUDE_HOME, dir, entry))) return sourceType;\n }\n return undefined;\n}\n\n/** agent name \u2192 owning skill, built on first miss since the scan walks every skill directory. */\nlet skillAgentIndex: Map<string, string> | null = null;\n\n/** A duplicate agent name across skills resolves in filesystem order, which is not stable; treat it as ambiguous. */\nfunction buildSkillAgentIndex(): Map<string, string> {\n const index = new Map<string, string>();\n const skillsDir = join(CLAUDE_HOME, SKILLS_DIR);\n\n let skillNames: string[];\n try {\n skillNames = readdirSync(skillsDir, { withFileTypes: true })\n .filter(entry => entry.isDirectory())\n .map(entry => entry.name);\n } catch {\n return index;\n }\n\n for (const skillName of skillNames) {\n const agentsDir = join(skillsDir, skillName, AGENTS_DIR);\n for (const file of readdirOrEmpty(agentsDir)) {\n // Extension folded so the index agrees with the case-insensitive existsSync lookups.\n if (!file.toLowerCase().endsWith(AGENT_FILE_EXT)) continue;\n const agentName = file.slice(0, -AGENT_FILE_EXT.length);\n if (!index.has(agentName)) index.set(agentName, skillName);\n }\n }\n\n return index;\n}\n\n/** Tests only. */\nexport function resetSkillAgentCache(): void {\n skillAgentIndex = null;\n}\n\nconst agentSourceCache = new Map<string, AgentSourceInfo>();\n\n/** Tests only. */\nexport function resetAgentSourceCache(): void {\n agentSourceCache.clear();\n}\n\nfunction resolveAgentSource(agentName: string): AgentSourceInfo {\n const dirSource = findInSourceDirs('agent', agentName);\n if (dirSource) return { sourceType: dirSource };\n\n if (BUILTIN_AGENTS.has(agentName)) return { sourceType: 'builtin' };\n\n skillAgentIndex ??= buildSkillAgentIndex();\n const parentSkill = skillAgentIndex.get(agentName);\n return parentSkill ? { sourceType: 'skill', parentSkill } : { sourceType: 'settings' };\n}\n\n/** Priority: active file > lazy file > builtin > skill > settings. */\nexport function getAgentSourceType(agentName: string): AgentSourceInfo {\n const cached = agentSourceCache.get(agentName);\n if (cached) return cached;\n\n const result = resolveAgentSource(agentName);\n agentSourceCache.set(agentName, result);\n return result;\n}\n\n/** Priority: active dir > lazy dir > settings. */\nexport function getSkillSourceType(skillName: string): SourceType {\n return findInSourceDirs('skill', skillName) ?? 'settings';\n}\n\n/**\n * Agent attribution for tool spans (agent-auditor Q6); absent fields contribute\n * nothing. `agent_id` is the harness's per-run id and goes under the instance key,\n * not `gen_ai.agent.id`, which is the stable `composeAgentId` identity.\n */\nexport function agentAttribution(input: AgentIdentityInput): Record<string, string> {\n const agentName = resolveAgentName(input);\n return {\n ...(agentName ? { [GENAI_AGENT_ATTRIBUTES.AGENT_NAME]: agentName } : {}),\n ...(input.agent_id ? { [AGENT_ATTRS.INSTANCE_ID]: input.agent_id } : {}),\n };\n}\n\n/** What every span of a tool event carries: agent attribution plus the prompt link. Stamped once per event by its router. */\nexport function toolEventAttributes(input: AgentIdentityInput): Record<string, string> {\n return { ...agentAttribution(input), ...promptLinkAttrs(input.session_id) };\n}\n\n/** `source[:parentSkill]:type`, composed once so the pre- and post-tool spans cannot drift. */\nexport function composeAgentId(agentType: string, info: AgentSourceInfo): string {\n return info.parentSkill\n ? `${info.sourceType}:${info.parentSkill}:${agentType}`\n : `${info.sourceType}:${agentType}`;\n}\n\nexport interface AgentIdentity {\n attrs: Record<string, string | boolean>;\n agentId: string;\n}\n\n/** The per-call fields behind the invocation attrs, so span attributes, log and metric labels read one parse. */\nexport interface AgentInvocation extends AgentIdentity {\n description: string | undefined;\n requestedModel: string | undefined;\n isResume: boolean;\n isBackground: boolean;\n}\n\n/** Built once for both agent spans so neither drops a key: a finalize span without `source_type` made the dashboard count every invocation as 'other'. */\nfunction agentIdentityAttributes(agentType: string, info: AgentSourceInfo): AgentIdentity {\n const agentId = composeAgentId(agentType, info);\n return {\n attrs: {\n [GENAI_AGENT_ATTRIBUTES.AGENT_NAME]: agentType,\n [GENAI_AGENT_ATTRIBUTES.AGENT_ID]: agentId,\n [AGENT_ATTRS.SOURCE_TYPE]: info.sourceType,\n ...(info.parentSkill ? { [AGENT_ATTRS.PARENT_SKILL]: info.parentSkill } : {}),\n },\n agentId,\n };\n}\n\n/**\n * Full invocation attributes built once for prepare and rebuilt in finalize (PostToolUse\n * carries the same `tool_input`, so both calls produce the same attrs \u2014 no store needed).\n * Identity attrs + per-call flags; call sites add the span-assigned invocation_id separately.\n */\nexport function agentInvocationAttributes(\n agentType: string,\n info: AgentSourceInfo,\n toolInput: Record<string, unknown>,\n): AgentInvocation {\n const { attrs: identityAttrs, agentId } = agentIdentityAttributes(agentType, info);\n const description = readString(toolInput, 'description');\n const requestedModel = readString(toolInput, 'model');\n const isResume = !!readString(toolInput, 'resume');\n const isBackground = toolInput.run_in_background === true;\n\n return {\n attrs: {\n ...identityAttrs,\n [AGENT_ATTRS.IS_RESUME]: isResume,\n [AGENT_ATTRS.IS_BACKGROUND]: isBackground,\n ...(requestedModel ? { [AGENT_ATTRS.REQUESTED_MODEL]: requestedModel } : {}),\n ...(description ? { [AGENT_ATTRS.TASK_DESCRIPTION]: description } : {}),\n },\n agentId,\n description,\n requestedModel,\n isResume,\n isBackground,\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,YAAY,mBAAmB;AACxC,SAAS,YAAY;AAQd,IAAM,iBAAiB,oBAAI,IAAI;AAAA,EACpC;AAAA,EAAQ;AAAA,EAAmB;AAAA,EAAoB;AAAA,EAAW;AAAA,EAC1D;AAAA,EAAqB;AAAA,EAAiB;AAAA,EACtC;AAAA,EAAgC;AAClC,CAAC;AASD,IAAM,aAAa;AACnB,IAAM,aAAa;AACnB,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AACxB,IAAM,iBAAiB;AAQvB,IAAM,iBAAiB;AAAA,EACrB,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,EAAE,KAAK,YAAY,YAAY,SAAS;AAAA,MACxC,EAAE,KAAK,iBAAiB,YAAY,OAAO;AAAA,IAC7C;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,EAAE,KAAK,YAAY,YAAY,SAAS;AAAA,MACxC,EAAE,KAAK,iBAAiB,YAAY,OAAO;AAAA,IAC7C;AAAA,EACF;AACF;AAEA,SAAS,iBAAiB,MAAmC,MAAsC;AACjG,QAAM,EAAE,QAAQ,KAAK,IAAI,eAAe,IAAI;AAC5C,QAAM,QAAQ,GAAG,IAAI,GAAG,MAAM;AAC9B,aAAW,EAAE,KAAK,WAAW,KAAK,MAAM;AACtC,QAAI,WAAW,KAAK,aAAa,KAAK,KAAK,CAAC,EAAG,QAAO;AAAA,EACxD;AACA,SAAO;AACT;AAGA,IAAI,kBAA8C;AAGlD,SAAS,uBAA4C;AACnD,QAAM,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,cAAc,EAAE,CAAC,YAAY,gBAAgB,GAAG,YAAY,IAAI,CAAC;AAAA,IACvE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,151 @@
1
+ import { createRequire as __hookRunnerCreateRequire } from 'node:module';
2
+ const require = __hookRunnerCreateRequire(import.meta.url);
3
+ import {
4
+ CLAUDE_HOME,
5
+ ensureDirExists,
6
+ isJsonObject,
7
+ isSameFile,
8
+ loadJson,
9
+ readdirOrEmpty,
10
+ toSafeFilename,
11
+ writeJsonAtomic
12
+ } from "./chunk-52RY6LQT.js";
13
+ import {
14
+ DURATION_MS,
15
+ TIME_MS
16
+ } from "./chunk-RWRGC7ZK.js";
17
+
18
+ // lib/session/session-state.ts
19
+ import { existsSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
20
+ import { dirname, join } from "node:path";
21
+ var SESSION_STATE_DIRNAME = "session-state";
22
+ var PROJECTS_DIRNAME = ".projects";
23
+ var QUALITY_DIRNAME = ".quality";
24
+ var HOST_DIRNAME = ".host";
25
+ var SESSION_STATE_RETENTION_MS = DURATION_MS.THIRTY_DAYS;
26
+ var CONVERSATION_ID_ENV = "CLAUDE_CONVERSATION_ID";
27
+ function conversationIdOf(sessionId) {
28
+ return process.env[CONVERSATION_ID_ENV] || sessionId || void 0;
29
+ }
30
+ function claimOnce(markerPath, options) {
31
+ if (existsSync(markerPath)) return false;
32
+ const parentDir = dirname(markerPath);
33
+ try {
34
+ (options?.mkdir ?? ensureDirExists)(parentDir);
35
+ writeFileSync(markerPath, (/* @__PURE__ */ new Date()).toISOString(), { flag: "wx" });
36
+ return true;
37
+ } catch {
38
+ if (existsSync(markerPath)) return false;
39
+ return options?.onWriteError === "grant";
40
+ }
41
+ }
42
+ function sessionStateRoot() {
43
+ return join(CLAUDE_HOME, SESSION_STATE_DIRNAME);
44
+ }
45
+ function sessionStateDir(sessionId, root = sessionStateRoot()) {
46
+ return join(root, toSafeFilename(sessionId));
47
+ }
48
+ var MARKER_EXTENSION = ".marker";
49
+ function sessionMarkerPath(sessionId, name, root = sessionStateRoot()) {
50
+ return join(sessionStateDir(sessionId, root), `${name}${MARKER_EXTENSION}`);
51
+ }
52
+ function projectSlug(projectDir) {
53
+ return projectDir.replace(/[/.]/g, "-");
54
+ }
55
+ function projectStateDir(key, root = sessionStateRoot()) {
56
+ return join(root, PROJECTS_DIRNAME, toSafeFilename(key));
57
+ }
58
+ function qualityStateDir(root = sessionStateRoot()) {
59
+ return join(root, QUALITY_DIRNAME);
60
+ }
61
+ function hostStateDir(root = sessionStateRoot()) {
62
+ return join(root, HOST_DIRNAME);
63
+ }
64
+ function loadSessionCheckpoint(sessionId, file, isValid, ttlMs = TIME_MS.DAY) {
65
+ const filePath = join(sessionStateDir(sessionId), file);
66
+ const cp = loadJson(filePath);
67
+ if (!cp || !isValid(cp)) return { live: null, expired: null };
68
+ const ts = cp.timestamp;
69
+ if (typeof ts !== "number" || Date.now() - ts > ttlMs) return { live: null, expired: cp };
70
+ return { live: cp, expired: null };
71
+ }
72
+ function resumeOffset(cp, fileSize) {
73
+ if (!cp || fileSize < cp.offset) return 0;
74
+ return cp.offset;
75
+ }
76
+ function saveSessionCheckpoint(sessionId, file, data) {
77
+ writeJsonAtomic(join(sessionStateDir(sessionId), file), data, { silent: true });
78
+ }
79
+ var NEVER_EXPIRES_MS = Number.POSITIVE_INFINITY;
80
+ function transcriptCheckpointStore(options) {
81
+ const { file, version, isValidBody, ttlMs = NEVER_EXPIRES_MS } = options;
82
+ const isValid = (value) => isJsonObject(value) && value.version === version && typeof value.transcript === "string" && isValidBody(value);
83
+ return {
84
+ load(sessionId, transcript) {
85
+ const cp = loadSessionCheckpoint(sessionId, file, isValid, ttlMs).live;
86
+ return cp && isSameFile(cp.transcript, transcript) ? cp : null;
87
+ },
88
+ save(sessionId, transcript, body) {
89
+ const envelope = { version, transcript, timestamp: Date.now() };
90
+ saveSessionCheckpoint(sessionId, file, { ...body, ...envelope });
91
+ }
92
+ };
93
+ }
94
+ var CURRENT_SESSION_ID = "current-session-id";
95
+ var SESSION_START_BRANCH = "session-start-branch";
96
+ function writeTextBestEffort(dir, name, text) {
97
+ try {
98
+ ensureDirExists(dir);
99
+ writeFileSync(join(dir, name), text, "utf8");
100
+ } catch {
101
+ }
102
+ }
103
+ function saveCurrentSessionId(sessionId, projectDir) {
104
+ writeTextBestEffort(projectStateDir(projectSlug(projectDir)), CURRENT_SESSION_ID, sessionId);
105
+ }
106
+ function saveSessionStartBranch(sessionId, branch) {
107
+ writeTextBestEffort(sessionStateDir(sessionId), SESSION_START_BRANCH, branch);
108
+ }
109
+ function newestMtimeMs(dir) {
110
+ let newest = statSync(dir).mtimeMs;
111
+ for (const name of readdirSync(dir)) {
112
+ try {
113
+ newest = Math.max(newest, statSync(join(dir, name)).mtimeMs);
114
+ } catch {
115
+ }
116
+ }
117
+ return newest;
118
+ }
119
+ function pruneSessionState(maxAgeMs = SESSION_STATE_RETENTION_MS, root = sessionStateRoot()) {
120
+ let removed = 0;
121
+ const cutoff = Date.now() - maxAgeMs;
122
+ for (const name of readdirOrEmpty(root)) {
123
+ if (name.startsWith(".")) continue;
124
+ const dir = join(root, name);
125
+ try {
126
+ if (!statSync(dir).isDirectory() || newestMtimeMs(dir) >= cutoff) continue;
127
+ rmSync(dir, { recursive: true, force: true });
128
+ removed++;
129
+ } catch {
130
+ }
131
+ }
132
+ return removed;
133
+ }
134
+
135
+ export {
136
+ CONVERSATION_ID_ENV,
137
+ conversationIdOf,
138
+ claimOnce,
139
+ sessionStateRoot,
140
+ sessionStateDir,
141
+ sessionMarkerPath,
142
+ projectStateDir,
143
+ qualityStateDir,
144
+ hostStateDir,
145
+ resumeOffset,
146
+ transcriptCheckpointStore,
147
+ saveCurrentSessionId,
148
+ saveSessionStartBranch,
149
+ pruneSessionState
150
+ };
151
+ //# sourceMappingURL=chunk-DNSTWC26.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../lib/session/session-state.ts"],
4
+ "sourcesContent": ["/**\n * `~/.claude/session-state/<session id>/`: the one root for everything a session\n * hands between its spawn-per-event hook processes, with `pruneSessionState` as\n * the one retention rule. Records that outlive a session live in dot-prefixed\n * siblings (`.projects/<key>/`, `.quality`, `.host`), names no\n * session id can collide with.\n */\n\nimport { existsSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { CLAUDE_HOME } from '../core/constants.js';\nimport { ensureDirExists, isJsonObject, isSameFile, loadJson, readdirOrEmpty, toSafeFilename, writeJsonAtomic } from '../core/file-utils.js';\nimport { DURATION_MS, TIME_MS } from '../core/units.js';\n\nconst SESSION_STATE_DIRNAME = 'session-state';\n\nexport const PROJECTS_DIRNAME = '.projects';\n\n/** The judge's daily budget and drift window (HDF3). */\nexport const QUALITY_DIRNAME = '.quality';\n\n/** The resolved `host.id` (HSF25) and the identity email cache (HTR3). */\nconst HOST_DIRNAME = '.host';\n\n/** Task state must survive until a resume; it is the longest-lived record here and sets the retention. */\nconst SESSION_STATE_RETENTION_MS = DURATION_MS.THIRTY_DAYS;\n\nexport const CONVERSATION_ID_ENV = 'CLAUDE_CONVERSATION_ID';\n\n/** A genuine thread id only, never synthesized: undefined when neither the override nor the session id is set. */\nexport function conversationIdOf(sessionId: string | undefined): string | undefined {\n return process.env[CONVERSATION_ID_ENV] || sessionId || undefined;\n}\n\n/**\n * Atomic once-per-session claim via a `wx` write on a marker under the session dir\n * (`sessionMarkerPath`). `onWriteError` defaults to 'deny'. Pass an uncached `mkdir`\n * when the parent may be deleted between calls in one process: the default\n * `ensureDirExists` is memoized.\n */\nexport function claimOnce(\n markerPath: string,\n options?: {\n onWriteError?: 'grant' | 'deny';\n mkdir?: (dir: string) => void;\n },\n): boolean {\n if (existsSync(markerPath)) return false;\n const parentDir = dirname(markerPath);\n try {\n (options?.mkdir ?? ensureDirExists)(parentDir);\n writeFileSync(markerPath, new Date().toISOString(), { flag: 'wx' });\n return true;\n } catch {\n // A marker appearing between the check and the write is the latch working.\n if (existsSync(markerPath)) return false;\n return options?.onWriteError === 'grant';\n }\n}\n\nexport function sessionStateRoot(): string {\n return join(CLAUDE_HOME, SESSION_STATE_DIRNAME);\n}\n\nexport function sessionStateDir(sessionId: string, root: string = sessionStateRoot()): string {\n return join(root, toSafeFilename(sessionId));\n}\n\nconst MARKER_EXTENSION = '.marker';\n\n/** A `claimOnce` latch under the session dir; `name` may carry a subdirectory. `root` keeps tests out of $HOME. */\nexport function sessionMarkerPath(sessionId: string, name: string, root: string = sessionStateRoot()): string {\n return join(sessionStateDir(sessionId, root), `${name}${MARKER_EXTENSION}`);\n}\n\n/** Claude Code's `~/.claude/projects/<slug>/` spelling; the bash pointer readers derive it with `tr '/.' '--'`, keep in step. */\nexport function projectSlug(projectDir: string): string {\n return projectDir.replace(/[/.]/g, '-');\n}\n\n/** Keyed by project slug, or by conversation id for the predecessor edge. */\nexport function projectStateDir(key: string, root: string = sessionStateRoot()): string {\n return join(root, PROJECTS_DIRNAME, toSafeFilename(key));\n}\n\nexport function qualityStateDir(root: string = sessionStateRoot()): string {\n return join(root, QUALITY_DIRNAME);\n}\n\nexport function hostStateDir(root: string = sessionStateRoot()): string {\n return join(root, HOST_DIRNAME);\n}\n\n/**\n * `expired` is the parsed-but-expired checkpoint, for callers that still need e.g. a\n * watermark. The file stays until the caller's next save overwrites it: unlinking it\n * here would lose the watermark if the caller died before saving.\n */\nexport function loadSessionCheckpoint<T extends object>(\n sessionId: string,\n file: string,\n isValid: (v: unknown) => v is T,\n ttlMs: number = TIME_MS.DAY,\n): { live: T | null; expired: T | null } {\n const filePath = join(sessionStateDir(sessionId), file);\n const cp = loadJson<T>(filePath);\n if (!cp || !isValid(cp)) return { live: null, expired: null };\n const ts = (cp as Record<string, unknown>).timestamp;\n if (typeof ts !== 'number' || Date.now() - ts > ttlMs) return { live: null, expired: cp };\n return { live: cp, expired: null };\n}\n\n/** The byte offset to resume from; 0 with no checkpoint or a file shrunk below its offset (truncation/rewrite). */\nexport function resumeOffset(cp: { offset: number } | null, fileSize: number): number {\n if (!cp || fileSize < cp.offset) return 0;\n return cp.offset;\n}\n\n/** Non-fatal on failure: the next extraction falls back to a full parse. */\nexport function saveSessionCheckpoint(sessionId: string, file: string, data: object): void {\n // Atomic, because a torn checkpoint would fail validation and the next read would re-add the whole transcript.\n writeJsonAtomic(join(sessionStateDir(sessionId), file), data, { silent: true });\n}\n\n/** A checkpoint TTL for state derived from an append-only transcript, which age cannot invalidate. */\nconst NEVER_EXPIRES_MS = Number.POSITIVE_INFINITY;\n\ninterface TranscriptCheckpointEnvelope {\n version: number;\n transcript: string;\n timestamp: number;\n}\n\nexport interface TranscriptCheckpointStore<T extends object> {\n /** Null when missing, misshapen, of another version or another transcript file, or past the TTL; another spelling of the same file still matches. */\n load(sessionId: string, transcript: string): T | null;\n save(sessionId: string, transcript: string, body: T): void;\n}\n\n/** A per-session checkpoint of state derived from one transcript; the envelope is validated here, the body by `isValidBody`. */\nexport function transcriptCheckpointStore<T extends object>(options: {\n file: string;\n version: number;\n isValidBody: (value: Record<string, unknown>) => boolean;\n ttlMs?: number;\n}): TranscriptCheckpointStore<T> {\n const { file, version, isValidBody, ttlMs = NEVER_EXPIRES_MS } = options;\n const isValid = (value: unknown): value is T & TranscriptCheckpointEnvelope => isJsonObject(value)\n && value.version === version\n && typeof value.transcript === 'string'\n && isValidBody(value);\n return {\n load(sessionId, transcript): T | null {\n const cp = loadSessionCheckpoint(sessionId, file, isValid, ttlMs).live;\n return cp && isSameFile(cp.transcript, transcript) ? cp : null;\n },\n save(sessionId, transcript, body): void {\n const envelope: TranscriptCheckpointEnvelope = { version, transcript, timestamp: Date.now() };\n saveSessionCheckpoint(sessionId, file, { ...body, ...envelope });\n },\n };\n}\n\n// Pointer files read by the GCS1 pre-commit and GCS2 conventional-commit bash guards; the format is a contract.\nconst CURRENT_SESSION_ID = 'current-session-id';\nconst SESSION_START_BRANCH = 'session-start-branch';\n\nfunction writeTextBestEffort(dir: string, name: string, text: string): void {\n try {\n ensureDirExists(dir);\n writeFileSync(join(dir, name), text, 'utf8');\n } catch {\n // Readers fail open when the file is absent.\n }\n}\n\n/** Plain text, one line, no trailing newline. */\nexport function saveCurrentSessionId(sessionId: string, projectDir: string): void {\n writeTextBestEffort(projectStateDir(projectSlug(projectDir)), CURRENT_SESSION_ID, sessionId);\n}\n\nexport function saveSessionStartBranch(sessionId: string, branch: string): void {\n writeTextBestEffort(sessionStateDir(sessionId), SESSION_START_BRANCH, branch);\n}\n\nfunction newestMtimeMs(dir: string): number {\n let newest = statSync(dir).mtimeMs;\n for (const name of readdirSync(dir)) {\n try {\n newest = Math.max(newest, statSync(join(dir, name)).mtimeMs);\n } catch {\n // Raced away between readdir and stat.\n }\n }\n return newest;\n}\n\n/** The one retention sweep. Never throws. Dot-prefixed siblings are never touched; a session id cannot start with a dot. */\nexport function pruneSessionState(maxAgeMs: number = SESSION_STATE_RETENTION_MS, root: string = sessionStateRoot()): number {\n let removed = 0;\n const cutoff = Date.now() - maxAgeMs;\n for (const name of readdirOrEmpty(root)) {\n if (name.startsWith('.')) continue;\n const dir = join(root, name);\n try {\n if (!statSync(dir).isDirectory() || newestMtimeMs(dir) >= cutoff) continue;\n rmSync(dir, { recursive: true, force: true });\n removed++;\n } catch {\n // Unreadable or already gone; the next sweep sees it again.\n }\n }\n return removed;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAQA,SAAS,YAAY,aAAa,QAAQ,UAAU,qBAAqB;AACzE,SAAS,SAAS,YAAY;AAK9B,IAAM,wBAAwB;AAEvB,IAAM,mBAAmB;AAGzB,IAAM,kBAAkB;AAG/B,IAAM,eAAe;AAGrB,IAAM,6BAA6B,YAAY;AAExC,IAAM,sBAAsB;AAG5B,SAAS,iBAAiB,WAAmD;AAClF,SAAO,QAAQ,IAAI,mBAAmB,KAAK,aAAa;AAC1D;AAQO,SAAS,UACd,YAC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