@nanonets/graft 0.24.0 → 0.25.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 (791) hide show
  1. package/README.md +26 -21
  2. package/dist/ask/ask.d.ts +8 -0
  3. package/dist/ask/ask.d.ts.map +1 -1
  4. package/dist/ask/ask.js +33 -12
  5. package/dist/ask/ask.js.map +1 -1
  6. package/dist/blast/render.js +1 -1
  7. package/dist/blast/render.js.map +1 -1
  8. package/dist/brand.js +1 -1
  9. package/dist/brand.js.map +1 -1
  10. package/dist/check/learning-edits.d.ts +18 -3
  11. package/dist/check/learning-edits.d.ts.map +1 -1
  12. package/dist/check/learning-edits.js +54 -10
  13. package/dist/check/learning-edits.js.map +1 -1
  14. package/dist/check/local-check.d.ts +7 -3
  15. package/dist/check/local-check.d.ts.map +1 -1
  16. package/dist/check/local-check.js +55 -11
  17. package/dist/check/local-check.js.map +1 -1
  18. package/dist/check/types.d.ts +11 -2
  19. package/dist/check/types.d.ts.map +1 -1
  20. package/dist/claude/format.d.ts +11 -7
  21. package/dist/claude/format.d.ts.map +1 -1
  22. package/dist/claude/format.js +50 -28
  23. package/dist/claude/format.js.map +1 -1
  24. package/dist/claude/hook-io.d.ts +44 -0
  25. package/dist/claude/hook-io.d.ts.map +1 -0
  26. package/dist/claude/hook-io.js +144 -0
  27. package/dist/claude/hook-io.js.map +1 -0
  28. package/dist/claude/hook-layers.d.ts +4 -2
  29. package/dist/claude/hook-layers.d.ts.map +1 -1
  30. package/dist/claude/hook-layers.js +21 -4
  31. package/dist/claude/hook-layers.js.map +1 -1
  32. package/dist/claude/hooks.d.ts +9 -32
  33. package/dist/claude/hooks.d.ts.map +1 -1
  34. package/dist/claude/hooks.js +154 -350
  35. package/dist/claude/hooks.js.map +1 -1
  36. package/dist/claude/init.d.ts.map +1 -1
  37. package/dist/claude/init.js +56 -18
  38. package/dist/claude/init.js.map +1 -1
  39. package/dist/claude/note-signals.d.ts +6 -0
  40. package/dist/claude/note-signals.d.ts.map +1 -1
  41. package/dist/claude/note-signals.js +14 -3
  42. package/dist/claude/note-signals.js.map +1 -1
  43. package/dist/claude/post-bash.d.ts +26 -0
  44. package/dist/claude/post-bash.d.ts.map +1 -0
  45. package/dist/claude/post-bash.js +191 -0
  46. package/dist/claude/post-bash.js.map +1 -0
  47. package/dist/claude/pre-bash-skills.d.ts +21 -0
  48. package/dist/claude/pre-bash-skills.d.ts.map +1 -0
  49. package/dist/claude/pre-bash-skills.js +253 -0
  50. package/dist/claude/pre-bash-skills.js.map +1 -0
  51. package/dist/claude/pre-bash.d.ts +50 -0
  52. package/dist/claude/pre-bash.d.ts.map +1 -0
  53. package/dist/claude/pre-bash.js +245 -0
  54. package/dist/claude/pre-bash.js.map +1 -0
  55. package/dist/claude/prompt-consent.d.ts +19 -0
  56. package/dist/claude/prompt-consent.d.ts.map +1 -0
  57. package/dist/claude/prompt-consent.js +14 -0
  58. package/dist/claude/prompt-consent.js.map +1 -0
  59. package/dist/claude/prompt-hook.d.ts +76 -0
  60. package/dist/claude/prompt-hook.d.ts.map +1 -0
  61. package/dist/claude/prompt-hook.js +303 -0
  62. package/dist/claude/prompt-hook.js.map +1 -0
  63. package/dist/claude/prompt-skills.d.ts +19 -0
  64. package/dist/claude/prompt-skills.d.ts.map +1 -0
  65. package/dist/claude/prompt-skills.js +305 -0
  66. package/dist/claude/prompt-skills.js.map +1 -0
  67. package/dist/claude/session-metrics.js +4 -4
  68. package/dist/claude/session-metrics.js.map +1 -1
  69. package/dist/claude/settings-merge.d.ts +10 -0
  70. package/dist/claude/settings-merge.d.ts.map +1 -1
  71. package/dist/claude/settings-merge.js +46 -17
  72. package/dist/claude/settings-merge.js.map +1 -1
  73. package/dist/claude/shim-template.d.ts.map +1 -1
  74. package/dist/claude/shim-template.js +86 -28
  75. package/dist/claude/shim-template.js.map +1 -1
  76. package/dist/claude/skill-template.d.ts +2 -0
  77. package/dist/claude/skill-template.d.ts.map +1 -1
  78. package/dist/claude/skill-template.js +53 -34
  79. package/dist/claude/skill-template.js.map +1 -1
  80. package/dist/claude/skill-use.d.ts +16 -0
  81. package/dist/claude/skill-use.d.ts.map +1 -0
  82. package/dist/claude/skill-use.js +78 -0
  83. package/dist/claude/skill-use.js.map +1 -0
  84. package/dist/claude/skills-hook-util.d.ts +25 -0
  85. package/dist/claude/skills-hook-util.d.ts.map +1 -0
  86. package/dist/claude/skills-hook-util.js +71 -0
  87. package/dist/claude/skills-hook-util.js.map +1 -0
  88. package/dist/claude/skills-wiring.d.ts +26 -0
  89. package/dist/claude/skills-wiring.d.ts.map +1 -0
  90. package/dist/claude/skills-wiring.js +110 -0
  91. package/dist/claude/skills-wiring.js.map +1 -0
  92. package/dist/claude/start-init.d.ts +13 -0
  93. package/dist/claude/start-init.d.ts.map +1 -0
  94. package/dist/claude/start-init.js +75 -0
  95. package/dist/claude/start-init.js.map +1 -0
  96. package/dist/claude/start-skills.d.ts +31 -0
  97. package/dist/claude/start-skills.d.ts.map +1 -0
  98. package/dist/claude/start-skills.js +274 -0
  99. package/dist/claude/start-skills.js.map +1 -0
  100. package/dist/claude/state.d.ts +19 -7
  101. package/dist/claude/state.d.ts.map +1 -1
  102. package/dist/claude/state.js +59 -4
  103. package/dist/claude/state.js.map +1 -1
  104. package/dist/claude/stop-skills.d.ts +23 -0
  105. package/dist/claude/stop-skills.d.ts.map +1 -0
  106. package/dist/claude/stop-skills.js +233 -0
  107. package/dist/claude/stop-skills.js.map +1 -0
  108. package/dist/claude/stop.d.ts +23 -0
  109. package/dist/claude/stop.d.ts.map +1 -0
  110. package/dist/claude/stop.js +219 -0
  111. package/dist/claude/stop.js.map +1 -0
  112. package/dist/claude/tally.d.ts +29 -41
  113. package/dist/claude/tally.d.ts.map +1 -1
  114. package/dist/claude/tally.js +111 -165
  115. package/dist/claude/tally.js.map +1 -1
  116. package/dist/claude/walls-hook.d.ts +52 -0
  117. package/dist/claude/walls-hook.d.ts.map +1 -0
  118. package/dist/claude/walls-hook.js +279 -0
  119. package/dist/claude/walls-hook.js.map +1 -0
  120. package/dist/cli-epilogue.d.ts.map +1 -1
  121. package/dist/cli-epilogue.js +24 -14
  122. package/dist/cli-epilogue.js.map +1 -1
  123. package/dist/cli-meta.js +3 -3
  124. package/dist/cli-meta.js.map +1 -1
  125. package/dist/cli-picker.d.ts +24 -0
  126. package/dist/cli-picker.d.ts.map +1 -1
  127. package/dist/cli-picker.js +44 -11
  128. package/dist/cli-picker.js.map +1 -1
  129. package/dist/cli.d.ts.map +1 -1
  130. package/dist/cli.js +475 -390
  131. package/dist/cli.js.map +1 -1
  132. package/dist/cloud/head-learnings.d.ts +13 -0
  133. package/dist/cloud/head-learnings.d.ts.map +1 -0
  134. package/dist/cloud/head-learnings.js +84 -0
  135. package/dist/cloud/head-learnings.js.map +1 -0
  136. package/dist/cloud/lookup-activity.d.ts +18 -0
  137. package/dist/cloud/lookup-activity.d.ts.map +1 -0
  138. package/dist/cloud/lookup-activity.js +56 -0
  139. package/dist/cloud/lookup-activity.js.map +1 -0
  140. package/dist/cloud/nudge.d.ts +15 -7
  141. package/dist/cloud/nudge.d.ts.map +1 -1
  142. package/dist/cloud/nudge.js +45 -33
  143. package/dist/cloud/nudge.js.map +1 -1
  144. package/dist/cloud/onboarding.d.ts +273 -0
  145. package/dist/cloud/onboarding.d.ts.map +1 -0
  146. package/dist/cloud/onboarding.js +612 -0
  147. package/dist/cloud/onboarding.js.map +1 -0
  148. package/dist/cloud/other-repos.d.ts +39 -0
  149. package/dist/cloud/other-repos.d.ts.map +1 -0
  150. package/dist/cloud/other-repos.js +137 -0
  151. package/dist/cloud/other-repos.js.map +1 -0
  152. package/dist/cloud/pair.d.ts +86 -0
  153. package/dist/cloud/pair.d.ts.map +1 -0
  154. package/dist/cloud/pair.js +270 -0
  155. package/dist/cloud/pair.js.map +1 -0
  156. package/dist/cloud/workspace-sync.d.ts +75 -11
  157. package/dist/cloud/workspace-sync.d.ts.map +1 -1
  158. package/dist/cloud/workspace-sync.js +409 -53
  159. package/dist/cloud/workspace-sync.js.map +1 -1
  160. package/dist/cloud/workspace.d.ts +95 -10
  161. package/dist/cloud/workspace.d.ts.map +1 -1
  162. package/dist/cloud/workspace.js +112 -9
  163. package/dist/cloud/workspace.js.map +1 -1
  164. package/dist/graph/native.d.ts +2 -0
  165. package/dist/graph/native.d.ts.map +1 -1
  166. package/dist/graph/native.js +29 -4
  167. package/dist/graph/native.js.map +1 -1
  168. package/dist/hosts/claude-global.d.ts +14 -0
  169. package/dist/hosts/claude-global.d.ts.map +1 -1
  170. package/dist/hosts/claude-global.js +39 -4
  171. package/dist/hosts/claude-global.js.map +1 -1
  172. package/dist/hosts/codex-hooks.d.ts +6 -0
  173. package/dist/hosts/codex-hooks.d.ts.map +1 -1
  174. package/dist/hosts/codex-hooks.js +89 -16
  175. package/dist/hosts/codex-hooks.js.map +1 -1
  176. package/dist/hosts/codex-trust.d.ts +28 -0
  177. package/dist/hosts/codex-trust.d.ts.map +1 -0
  178. package/dist/hosts/codex-trust.js +280 -0
  179. package/dist/hosts/codex-trust.js.map +1 -0
  180. package/dist/hosts/cursor-hooks.d.ts.map +1 -1
  181. package/dist/hosts/cursor-hooks.js +3 -1
  182. package/dist/hosts/cursor-hooks.js.map +1 -1
  183. package/dist/init/candidates.d.ts +60 -0
  184. package/dist/init/candidates.d.ts.map +1 -0
  185. package/dist/init/candidates.js +202 -0
  186. package/dist/init/candidates.js.map +1 -0
  187. package/dist/init/claude-call.d.ts +51 -0
  188. package/dist/init/claude-call.d.ts.map +1 -0
  189. package/dist/init/claude-call.js +199 -0
  190. package/dist/init/claude-call.js.map +1 -0
  191. package/dist/init/discover-worker.d.ts +18 -0
  192. package/dist/init/discover-worker.d.ts.map +1 -0
  193. package/dist/init/discover-worker.js +111 -0
  194. package/dist/init/discover-worker.js.map +1 -0
  195. package/dist/init/handover.d.ts +16 -0
  196. package/dist/init/handover.d.ts.map +1 -0
  197. package/dist/init/handover.js +92 -0
  198. package/dist/init/handover.js.map +1 -0
  199. package/dist/init/howtos.d.ts +20 -0
  200. package/dist/init/howtos.d.ts.map +1 -0
  201. package/dist/init/howtos.js +90 -0
  202. package/dist/init/howtos.js.map +1 -0
  203. package/dist/init/init-record.d.ts +134 -0
  204. package/dist/init/init-record.d.ts.map +1 -0
  205. package/dist/init/init-record.js +339 -0
  206. package/dist/init/init-record.js.map +1 -0
  207. package/dist/init/install-paths.d.ts +6 -0
  208. package/dist/init/install-paths.d.ts.map +1 -0
  209. package/dist/init/install-paths.js +87 -0
  210. package/dist/init/install-paths.js.map +1 -0
  211. package/dist/init/install-record.d.ts +21 -0
  212. package/dist/init/install-record.d.ts.map +1 -0
  213. package/dist/init/install-record.js +144 -0
  214. package/dist/init/install-record.js.map +1 -0
  215. package/dist/init/keep-answer.d.ts +43 -0
  216. package/dist/init/keep-answer.d.ts.map +1 -0
  217. package/dist/init/keep-answer.js +118 -0
  218. package/dist/init/keep-answer.js.map +1 -0
  219. package/dist/init/keep-gate.d.ts +30 -0
  220. package/dist/init/keep-gate.d.ts.map +1 -0
  221. package/dist/init/keep-gate.js +178 -0
  222. package/dist/init/keep-gate.js.map +1 -0
  223. package/dist/init/keep-list.d.ts +67 -0
  224. package/dist/init/keep-list.d.ts.map +1 -0
  225. package/dist/init/keep-list.js +232 -0
  226. package/dist/init/keep-list.js.map +1 -0
  227. package/dist/init/keep.d.ts +52 -0
  228. package/dist/init/keep.d.ts.map +1 -0
  229. package/dist/init/keep.js +393 -0
  230. package/dist/init/keep.js.map +1 -0
  231. package/dist/init/look-back-mine.d.ts +37 -0
  232. package/dist/init/look-back-mine.d.ts.map +1 -0
  233. package/dist/init/look-back-mine.js +215 -0
  234. package/dist/init/look-back-mine.js.map +1 -0
  235. package/dist/init/look-back.d.ts +81 -0
  236. package/dist/init/look-back.d.ts.map +1 -0
  237. package/dist/init/look-back.js +170 -0
  238. package/dist/init/look-back.js.map +1 -0
  239. package/dist/init/miners.d.ts +46 -0
  240. package/dist/init/miners.d.ts.map +1 -0
  241. package/dist/init/miners.js +141 -0
  242. package/dist/init/miners.js.map +1 -0
  243. package/dist/init/name-call.d.ts +37 -0
  244. package/dist/init/name-call.d.ts.map +1 -0
  245. package/dist/init/name-call.js +151 -0
  246. package/dist/init/name-call.js.map +1 -0
  247. package/dist/init/plain-file.d.ts +11 -0
  248. package/dist/init/plain-file.d.ts.map +1 -0
  249. package/dist/init/plain-file.js +83 -0
  250. package/dist/init/plain-file.js.map +1 -0
  251. package/dist/init/prefs.d.ts +70 -0
  252. package/dist/init/prefs.d.ts.map +1 -0
  253. package/dist/init/prefs.js +282 -0
  254. package/dist/init/prefs.js.map +1 -0
  255. package/dist/init/relay.d.ts +15 -0
  256. package/dist/init/relay.d.ts.map +1 -0
  257. package/dist/init/relay.js +15 -0
  258. package/dist/init/relay.js.map +1 -0
  259. package/dist/init/replay-runs.d.ts +121 -0
  260. package/dist/init/replay-runs.d.ts.map +1 -0
  261. package/dist/init/replay-runs.js +457 -0
  262. package/dist/init/replay-runs.js.map +1 -0
  263. package/dist/init/replay-tamper.d.ts +18 -0
  264. package/dist/init/replay-tamper.d.ts.map +1 -0
  265. package/dist/init/replay-tamper.js +87 -0
  266. package/dist/init/replay-tamper.js.map +1 -0
  267. package/dist/init/review-screen.d.ts +74 -0
  268. package/dist/init/review-screen.d.ts.map +1 -0
  269. package/dist/init/review-screen.js +258 -0
  270. package/dist/init/review-screen.js.map +1 -0
  271. package/dist/init/review-tty.d.ts +29 -0
  272. package/dist/init/review-tty.d.ts.map +1 -0
  273. package/dist/init/review-tty.js +218 -0
  274. package/dist/init/review-tty.js.map +1 -0
  275. package/dist/init/review.d.ts +12 -0
  276. package/dist/init/review.d.ts.map +1 -0
  277. package/dist/init/review.js +12 -0
  278. package/dist/init/review.js.map +1 -0
  279. package/dist/init/run.d.ts +87 -0
  280. package/dist/init/run.d.ts.map +1 -0
  281. package/dist/init/run.js +347 -0
  282. package/dist/init/run.js.map +1 -0
  283. package/dist/init/sessions.d.ts +63 -0
  284. package/dist/init/sessions.d.ts.map +1 -0
  285. package/dist/init/sessions.js +377 -0
  286. package/dist/init/sessions.js.map +1 -0
  287. package/dist/init/transcript.d.ts +81 -0
  288. package/dist/init/transcript.d.ts.map +1 -0
  289. package/dist/init/transcript.js +216 -0
  290. package/dist/init/transcript.js.map +1 -0
  291. package/dist/init/types.d.ts +139 -0
  292. package/dist/init/types.d.ts.map +1 -0
  293. package/dist/init/types.js +2 -0
  294. package/dist/init/types.js.map +1 -0
  295. package/dist/mcp/brains.d.ts +72 -0
  296. package/dist/mcp/brains.d.ts.map +1 -0
  297. package/dist/mcp/brains.js +220 -0
  298. package/dist/mcp/brains.js.map +1 -0
  299. package/dist/mcp/server.d.ts +3 -1
  300. package/dist/mcp/server.d.ts.map +1 -1
  301. package/dist/mcp/server.js +40 -5
  302. package/dist/mcp/server.js.map +1 -1
  303. package/dist/mcp/tools.d.ts.map +1 -1
  304. package/dist/mcp/tools.js +7 -2
  305. package/dist/mcp/tools.js.map +1 -1
  306. package/dist/notes/cold-start.d.ts +5 -184
  307. package/dist/notes/cold-start.d.ts.map +1 -1
  308. package/dist/notes/cold-start.js +5 -575
  309. package/dist/notes/cold-start.js.map +1 -1
  310. package/dist/notes/edit-overlap.d.ts.map +1 -1
  311. package/dist/notes/edit-overlap.js +4 -1
  312. package/dist/notes/edit-overlap.js.map +1 -1
  313. package/dist/notes/every-repo.d.ts +18 -0
  314. package/dist/notes/every-repo.d.ts.map +1 -0
  315. package/dist/notes/every-repo.js +86 -0
  316. package/dist/notes/every-repo.js.map +1 -0
  317. package/dist/notes/guardrails.d.ts +8 -0
  318. package/dist/notes/guardrails.d.ts.map +1 -0
  319. package/dist/notes/guardrails.js +38 -0
  320. package/dist/notes/guardrails.js.map +1 -0
  321. package/dist/notes/lesson-index.d.ts +13 -0
  322. package/dist/notes/lesson-index.d.ts.map +1 -0
  323. package/dist/notes/lesson-index.js +135 -0
  324. package/dist/notes/lesson-index.js.map +1 -0
  325. package/dist/notes/linked-learnings.d.ts +8 -0
  326. package/dist/notes/linked-learnings.d.ts.map +1 -0
  327. package/dist/notes/linked-learnings.js +113 -0
  328. package/dist/notes/linked-learnings.js.map +1 -0
  329. package/dist/notes/notes.d.ts +8 -4
  330. package/dist/notes/notes.d.ts.map +1 -1
  331. package/dist/notes/notes.js +9 -7
  332. package/dist/notes/notes.js.map +1 -1
  333. package/dist/notes/pr-reviews.d.ts +4 -0
  334. package/dist/notes/pr-reviews.d.ts.map +1 -1
  335. package/dist/notes/pr-reviews.js +6 -5
  336. package/dist/notes/pr-reviews.js.map +1 -1
  337. package/dist/notes/replace.d.ts +14 -0
  338. package/dist/notes/replace.d.ts.map +1 -0
  339. package/dist/notes/replace.js +38 -0
  340. package/dist/notes/replace.js.map +1 -0
  341. package/dist/notes/repo-notes-dir.d.ts +2 -0
  342. package/dist/notes/repo-notes-dir.d.ts.map +1 -0
  343. package/dist/notes/repo-notes-dir.js +16 -0
  344. package/dist/notes/repo-notes-dir.js.map +1 -0
  345. package/dist/notes/repo-trail.d.ts +1 -1
  346. package/dist/notes/repo-trail.d.ts.map +1 -1
  347. package/dist/notes/repo-trail.js +24 -4
  348. package/dist/notes/repo-trail.js.map +1 -1
  349. package/dist/search/grep.d.ts.map +1 -1
  350. package/dist/search/grep.js +4 -2
  351. package/dist/search/grep.js.map +1 -1
  352. package/dist/search/user-regexp.d.ts +26 -0
  353. package/dist/search/user-regexp.d.ts.map +1 -0
  354. package/dist/search/user-regexp.js +150 -0
  355. package/dist/search/user-regexp.js.map +1 -0
  356. package/dist/skills/anchors-cli.d.ts +38 -0
  357. package/dist/skills/anchors-cli.d.ts.map +1 -0
  358. package/dist/skills/anchors-cli.js +279 -0
  359. package/dist/skills/anchors-cli.js.map +1 -0
  360. package/dist/skills/anchors-git.d.ts +29 -0
  361. package/dist/skills/anchors-git.d.ts.map +1 -0
  362. package/dist/skills/anchors-git.js +241 -0
  363. package/dist/skills/anchors-git.js.map +1 -0
  364. package/dist/skills/anchors-wide.d.ts +25 -0
  365. package/dist/skills/anchors-wide.d.ts.map +1 -0
  366. package/dist/skills/anchors-wide.js +481 -0
  367. package/dist/skills/anchors-wide.js.map +1 -0
  368. package/dist/skills/anchors.d.ts +32 -0
  369. package/dist/skills/anchors.d.ts.map +1 -0
  370. package/dist/skills/anchors.js +485 -0
  371. package/dist/skills/anchors.js.map +1 -0
  372. package/dist/skills/check-result.d.ts +26 -0
  373. package/dist/skills/check-result.d.ts.map +1 -0
  374. package/dist/skills/check-result.js +46 -0
  375. package/dist/skills/check-result.js.map +1 -0
  376. package/dist/skills/cli-skills-1b.d.ts +17 -0
  377. package/dist/skills/cli-skills-1b.d.ts.map +1 -0
  378. package/dist/skills/cli-skills-1b.js +166 -0
  379. package/dist/skills/cli-skills-1b.js.map +1 -0
  380. package/dist/skills/cli-skills-2.d.ts +35 -0
  381. package/dist/skills/cli-skills-2.d.ts.map +1 -0
  382. package/dist/skills/cli-skills-2.js +129 -0
  383. package/dist/skills/cli-skills-2.js.map +1 -0
  384. package/dist/skills/cli-skills-report-1b.d.ts +49 -0
  385. package/dist/skills/cli-skills-report-1b.d.ts.map +1 -0
  386. package/dist/skills/cli-skills-report-1b.js +191 -0
  387. package/dist/skills/cli-skills-report-1b.js.map +1 -0
  388. package/dist/skills/cli-skills-report.d.ts +86 -0
  389. package/dist/skills/cli-skills-report.d.ts.map +1 -0
  390. package/dist/skills/cli-skills-report.js +121 -0
  391. package/dist/skills/cli-skills-report.js.map +1 -0
  392. package/dist/skills/cli-skills.d.ts +30 -0
  393. package/dist/skills/cli-skills.d.ts.map +1 -0
  394. package/dist/skills/cli-skills.js +379 -0
  395. package/dist/skills/cli-skills.js.map +1 -0
  396. package/dist/skills/codex-sandbox.d.ts +6 -0
  397. package/dist/skills/codex-sandbox.d.ts.map +1 -0
  398. package/dist/skills/codex-sandbox.js +55 -0
  399. package/dist/skills/codex-sandbox.js.map +1 -0
  400. package/dist/skills/compile-split.d.ts +57 -0
  401. package/dist/skills/compile-split.d.ts.map +1 -0
  402. package/dist/skills/compile-split.js +550 -0
  403. package/dist/skills/compile-split.js.map +1 -0
  404. package/dist/skills/compile-version.d.ts +37 -0
  405. package/dist/skills/compile-version.d.ts.map +1 -0
  406. package/dist/skills/compile-version.js +56 -0
  407. package/dist/skills/compile-version.js.map +1 -0
  408. package/dist/skills/compile-waits.d.ts +12 -0
  409. package/dist/skills/compile-waits.d.ts.map +1 -0
  410. package/dist/skills/compile-waits.js +52 -0
  411. package/dist/skills/compile-waits.js.map +1 -0
  412. package/dist/skills/compile-words.d.ts +85 -0
  413. package/dist/skills/compile-words.d.ts.map +1 -0
  414. package/dist/skills/compile-words.js +445 -0
  415. package/dist/skills/compile-words.js.map +1 -0
  416. package/dist/skills/compile.d.ts +42 -0
  417. package/dist/skills/compile.d.ts.map +1 -0
  418. package/dist/skills/compile.js +505 -0
  419. package/dist/skills/compile.js.map +1 -0
  420. package/dist/skills/credit-facts.d.ts +8 -0
  421. package/dist/skills/credit-facts.d.ts.map +1 -0
  422. package/dist/skills/credit-facts.js +32 -0
  423. package/dist/skills/credit-facts.js.map +1 -0
  424. package/dist/skills/credit.d.ts +86 -0
  425. package/dist/skills/credit.d.ts.map +1 -0
  426. package/dist/skills/credit.js +259 -0
  427. package/dist/skills/credit.js.map +1 -0
  428. package/dist/skills/directive-words.d.ts +11 -0
  429. package/dist/skills/directive-words.d.ts.map +1 -0
  430. package/dist/skills/directive-words.js +33 -0
  431. package/dist/skills/directive-words.js.map +1 -0
  432. package/dist/skills/fidelity.d.ts +42 -0
  433. package/dist/skills/fidelity.d.ts.map +1 -0
  434. package/dist/skills/fidelity.js +138 -0
  435. package/dist/skills/fidelity.js.map +1 -0
  436. package/dist/skills/fold-gated.d.ts +3 -0
  437. package/dist/skills/fold-gated.d.ts.map +1 -0
  438. package/dist/skills/fold-gated.js +78 -0
  439. package/dist/skills/fold-gated.js.map +1 -0
  440. package/dist/skills/fold.d.ts +87 -0
  441. package/dist/skills/fold.d.ts.map +1 -0
  442. package/dist/skills/fold.js +348 -0
  443. package/dist/skills/fold.js.map +1 -0
  444. package/dist/skills/follow-learnings.d.ts +128 -0
  445. package/dist/skills/follow-learnings.d.ts.map +1 -0
  446. package/dist/skills/follow-learnings.js +278 -0
  447. package/dist/skills/follow-learnings.js.map +1 -0
  448. package/dist/skills/forget-notice.d.ts +44 -0
  449. package/dist/skills/forget-notice.d.ts.map +1 -0
  450. package/dist/skills/forget-notice.js +131 -0
  451. package/dist/skills/forget-notice.js.map +1 -0
  452. package/dist/skills/front-version.d.ts +12 -0
  453. package/dist/skills/front-version.d.ts.map +1 -0
  454. package/dist/skills/front-version.js +87 -0
  455. package/dist/skills/front-version.js.map +1 -0
  456. package/dist/skills/host-facts.d.ts +51 -0
  457. package/dist/skills/host-facts.d.ts.map +1 -0
  458. package/dist/skills/host-facts.js +134 -0
  459. package/dist/skills/host-facts.js.map +1 -0
  460. package/dist/skills/learning-steps.d.ts +43 -0
  461. package/dist/skills/learning-steps.d.ts.map +1 -0
  462. package/dist/skills/learning-steps.js +294 -0
  463. package/dist/skills/learning-steps.js.map +1 -0
  464. package/dist/skills/ledger.d.ts +43 -0
  465. package/dist/skills/ledger.d.ts.map +1 -0
  466. package/dist/skills/ledger.js +336 -0
  467. package/dist/skills/ledger.js.map +1 -0
  468. package/dist/skills/lesson-gate.d.ts +25 -0
  469. package/dist/skills/lesson-gate.d.ts.map +1 -0
  470. package/dist/skills/lesson-gate.js +316 -0
  471. package/dist/skills/lesson-gate.js.map +1 -0
  472. package/dist/skills/lessons.d.ts +60 -0
  473. package/dist/skills/lessons.d.ts.map +1 -0
  474. package/dist/skills/lessons.js +396 -0
  475. package/dist/skills/lessons.js.map +1 -0
  476. package/dist/skills/offer-answers.d.ts +20 -0
  477. package/dist/skills/offer-answers.d.ts.map +1 -0
  478. package/dist/skills/offer-answers.js +51 -0
  479. package/dist/skills/offer-answers.js.map +1 -0
  480. package/dist/skills/offer-drift.d.ts +35 -0
  481. package/dist/skills/offer-drift.d.ts.map +1 -0
  482. package/dist/skills/offer-drift.js +98 -0
  483. package/dist/skills/offer-drift.js.map +1 -0
  484. package/dist/skills/offer-lesson.d.ts +31 -0
  485. package/dist/skills/offer-lesson.d.ts.map +1 -0
  486. package/dist/skills/offer-lesson.js +123 -0
  487. package/dist/skills/offer-lesson.js.map +1 -0
  488. package/dist/skills/offer-lines.d.ts +40 -0
  489. package/dist/skills/offer-lines.d.ts.map +1 -0
  490. package/dist/skills/offer-lines.js +80 -0
  491. package/dist/skills/offer-lines.js.map +1 -0
  492. package/dist/skills/offer-moment.d.ts +102 -0
  493. package/dist/skills/offer-moment.d.ts.map +1 -0
  494. package/dist/skills/offer-moment.js +260 -0
  495. package/dist/skills/offer-moment.js.map +1 -0
  496. package/dist/skills/offer-repair.d.ts +36 -0
  497. package/dist/skills/offer-repair.d.ts.map +1 -0
  498. package/dist/skills/offer-repair.js +212 -0
  499. package/dist/skills/offer-repair.js.map +1 -0
  500. package/dist/skills/offer-retire.d.ts +53 -0
  501. package/dist/skills/offer-retire.d.ts.map +1 -0
  502. package/dist/skills/offer-retire.js +149 -0
  503. package/dist/skills/offer-retire.js.map +1 -0
  504. package/dist/skills/offer-update.d.ts +54 -0
  505. package/dist/skills/offer-update.d.ts.map +1 -0
  506. package/dist/skills/offer-update.js +115 -0
  507. package/dist/skills/offer-update.js.map +1 -0
  508. package/dist/skills/offer-words-1b.d.ts +32 -0
  509. package/dist/skills/offer-words-1b.d.ts.map +1 -0
  510. package/dist/skills/offer-words-1b.js +80 -0
  511. package/dist/skills/offer-words-1b.js.map +1 -0
  512. package/dist/skills/offer-words-2.d.ts +123 -0
  513. package/dist/skills/offer-words-2.d.ts.map +1 -0
  514. package/dist/skills/offer-words-2.js +194 -0
  515. package/dist/skills/offer-words-2.js.map +1 -0
  516. package/dist/skills/offer-words.d.ts +65 -0
  517. package/dist/skills/offer-words.d.ts.map +1 -0
  518. package/dist/skills/offer-words.js +205 -0
  519. package/dist/skills/offer-words.js.map +1 -0
  520. package/dist/skills/offers.d.ts +66 -0
  521. package/dist/skills/offers.d.ts.map +1 -0
  522. package/dist/skills/offers.js +284 -0
  523. package/dist/skills/offers.js.map +1 -0
  524. package/dist/skills/own-folder.d.ts +9 -0
  525. package/dist/skills/own-folder.d.ts.map +1 -0
  526. package/dist/skills/own-folder.js +36 -0
  527. package/dist/skills/own-folder.js.map +1 -0
  528. package/dist/skills/person.d.ts +34 -0
  529. package/dist/skills/person.d.ts.map +1 -0
  530. package/dist/skills/person.js +102 -0
  531. package/dist/skills/person.js.map +1 -0
  532. package/dist/skills/probe-clean.d.ts +9 -0
  533. package/dist/skills/probe-clean.d.ts.map +1 -0
  534. package/dist/skills/probe-clean.js +48 -0
  535. package/dist/skills/probe-clean.js.map +1 -0
  536. package/dist/skills/probes.d.ts +26 -0
  537. package/dist/skills/probes.d.ts.map +1 -0
  538. package/dist/skills/probes.js +225 -0
  539. package/dist/skills/probes.js.map +1 -0
  540. package/dist/skills/recall.d.ts +119 -0
  541. package/dist/skills/recall.d.ts.map +1 -0
  542. package/dist/skills/recall.js +370 -0
  543. package/dist/skills/recall.js.map +1 -0
  544. package/dist/skills/receipts.d.ts +44 -0
  545. package/dist/skills/receipts.d.ts.map +1 -0
  546. package/dist/skills/receipts.js +223 -0
  547. package/dist/skills/receipts.js.map +1 -0
  548. package/dist/skills/run-checkout.d.ts +4 -0
  549. package/dist/skills/run-checkout.d.ts.map +1 -0
  550. package/dist/skills/run-checkout.js +37 -0
  551. package/dist/skills/run-checkout.js.map +1 -0
  552. package/dist/skills/runblock.d.ts +47 -0
  553. package/dist/skills/runblock.d.ts.map +1 -0
  554. package/dist/skills/runblock.js +227 -0
  555. package/dist/skills/runblock.js.map +1 -0
  556. package/dist/skills/save-gate.d.ts +64 -0
  557. package/dist/skills/save-gate.d.ts.map +1 -0
  558. package/dist/skills/save-gate.js +354 -0
  559. package/dist/skills/save-gate.js.map +1 -0
  560. package/dist/skills/save-parse.d.ts +42 -0
  561. package/dist/skills/save-parse.d.ts.map +1 -0
  562. package/dist/skills/save-parse.js +172 -0
  563. package/dist/skills/save-parse.js.map +1 -0
  564. package/dist/skills/save-store.d.ts +12 -0
  565. package/dist/skills/save-store.d.ts.map +1 -0
  566. package/dist/skills/save-store.js +22 -0
  567. package/dist/skills/save-store.js.map +1 -0
  568. package/dist/skills/save-verify.d.ts +59 -0
  569. package/dist/skills/save-verify.d.ts.map +1 -0
  570. package/dist/skills/save-verify.js +390 -0
  571. package/dist/skills/save-verify.js.map +1 -0
  572. package/dist/skills/settings.d.ts +48 -0
  573. package/dist/skills/settings.d.ts.map +1 -0
  574. package/dist/skills/settings.js +155 -0
  575. package/dist/skills/settings.js.map +1 -0
  576. package/dist/skills/skill-diff.d.ts +40 -0
  577. package/dist/skills/skill-diff.d.ts.map +1 -0
  578. package/dist/skills/skill-diff.js +191 -0
  579. package/dist/skills/skill-diff.js.map +1 -0
  580. package/dist/skills/skill-file.d.ts +24 -0
  581. package/dist/skills/skill-file.d.ts.map +1 -0
  582. package/dist/skills/skill-file.js +97 -0
  583. package/dist/skills/skill-file.js.map +1 -0
  584. package/dist/skills/skill-rebuild.d.ts +27 -0
  585. package/dist/skills/skill-rebuild.d.ts.map +1 -0
  586. package/dist/skills/skill-rebuild.js +85 -0
  587. package/dist/skills/skill-rebuild.js.map +1 -0
  588. package/dist/skills/skillmd.d.ts +17 -0
  589. package/dist/skills/skillmd.d.ts.map +1 -0
  590. package/dist/skills/skillmd.js +219 -0
  591. package/dist/skills/skillmd.js.map +1 -0
  592. package/dist/skills/skills.d.ts +28 -8
  593. package/dist/skills/skills.d.ts.map +1 -1
  594. package/dist/skills/skills.js +106 -53
  595. package/dist/skills/skills.js.map +1 -1
  596. package/dist/skills/staleness.d.ts +27 -0
  597. package/dist/skills/staleness.d.ts.map +1 -0
  598. package/dist/skills/staleness.js +178 -0
  599. package/dist/skills/staleness.js.map +1 -0
  600. package/dist/skills/state.d.ts +36 -0
  601. package/dist/skills/state.d.ts.map +1 -0
  602. package/dist/skills/state.js +259 -0
  603. package/dist/skills/state.js.map +1 -0
  604. package/dist/skills/store-fs.d.ts +77 -0
  605. package/dist/skills/store-fs.d.ts.map +1 -0
  606. package/dist/skills/store-fs.js +194 -0
  607. package/dist/skills/store-fs.js.map +1 -0
  608. package/dist/skills/store-held.d.ts +44 -0
  609. package/dist/skills/store-held.d.ts.map +1 -0
  610. package/dist/skills/store-held.js +147 -0
  611. package/dist/skills/store-held.js.map +1 -0
  612. package/dist/skills/store.d.ts +73 -0
  613. package/dist/skills/store.d.ts.map +1 -0
  614. package/dist/skills/store.js +279 -0
  615. package/dist/skills/store.js.map +1 -0
  616. package/dist/skills/types.d.ts +8 -0
  617. package/dist/skills/types.d.ts.map +1 -1
  618. package/dist/skills/update-gate.d.ts +36 -0
  619. package/dist/skills/update-gate.d.ts.map +1 -0
  620. package/dist/skills/update-gate.js +357 -0
  621. package/dist/skills/update-gate.js.map +1 -0
  622. package/dist/skills/update-plan.d.ts +40 -0
  623. package/dist/skills/update-plan.d.ts.map +1 -0
  624. package/dist/skills/update-plan.js +196 -0
  625. package/dist/skills/update-plan.js.map +1 -0
  626. package/dist/skills/validate.d.ts +11 -0
  627. package/dist/skills/validate.d.ts.map +1 -0
  628. package/dist/skills/validate.js +112 -0
  629. package/dist/skills/validate.js.map +1 -0
  630. package/dist/skills/value-line.d.ts +94 -0
  631. package/dist/skills/value-line.d.ts.map +1 -0
  632. package/dist/skills/value-line.js +355 -0
  633. package/dist/skills/value-line.js.map +1 -0
  634. package/dist/skills/versions-fs.d.ts +45 -0
  635. package/dist/skills/versions-fs.d.ts.map +1 -0
  636. package/dist/skills/versions-fs.js +234 -0
  637. package/dist/skills/versions-fs.js.map +1 -0
  638. package/dist/skills/versions.d.ts +56 -0
  639. package/dist/skills/versions.d.ts.map +1 -0
  640. package/dist/skills/versions.js +351 -0
  641. package/dist/skills/versions.js.map +1 -0
  642. package/dist/telemetry/contract.d.ts +15 -1
  643. package/dist/telemetry/contract.d.ts.map +1 -1
  644. package/dist/telemetry/contract.js +80 -11
  645. package/dist/telemetry/contract.js.map +1 -1
  646. package/dist/telemetry/gate.js +4 -4
  647. package/dist/telemetry/gate.js.map +1 -1
  648. package/dist/telemetry/index.d.ts +1 -1
  649. package/dist/telemetry/index.d.ts.map +1 -1
  650. package/dist/telemetry/index.js +1 -1
  651. package/dist/telemetry/index.js.map +1 -1
  652. package/dist/telemetry/notice.js +5 -5
  653. package/dist/telemetry/notice.js.map +1 -1
  654. package/dist/telemetry/queue.d.ts.map +1 -1
  655. package/dist/telemetry/queue.js +7 -7
  656. package/dist/telemetry/queue.js.map +1 -1
  657. package/dist/telemetry/track.d.ts.map +1 -1
  658. package/dist/telemetry/track.js +4 -3
  659. package/dist/telemetry/track.js.map +1 -1
  660. package/dist/trace/checks.d.ts +63 -0
  661. package/dist/trace/checks.d.ts.map +1 -0
  662. package/dist/trace/checks.js +495 -0
  663. package/dist/trace/checks.js.map +1 -0
  664. package/dist/trace/claude.d.ts +124 -0
  665. package/dist/trace/claude.d.ts.map +1 -0
  666. package/dist/trace/claude.js +303 -0
  667. package/dist/trace/claude.js.map +1 -0
  668. package/dist/trace/codex-exec.d.ts +22 -0
  669. package/dist/trace/codex-exec.d.ts.map +1 -0
  670. package/dist/trace/codex-exec.js +129 -0
  671. package/dist/trace/codex-exec.js.map +1 -0
  672. package/dist/trace/codex-meta.d.ts +23 -0
  673. package/dist/trace/codex-meta.d.ts.map +1 -0
  674. package/dist/trace/codex-meta.js +112 -0
  675. package/dist/trace/codex-meta.js.map +1 -0
  676. package/dist/trace/codex.d.ts +33 -0
  677. package/dist/trace/codex.d.ts.map +1 -0
  678. package/dist/trace/codex.js +485 -0
  679. package/dist/trace/codex.js.map +1 -0
  680. package/dist/trace/cursor.d.ts +16 -0
  681. package/dist/trace/cursor.d.ts.map +1 -0
  682. package/dist/trace/cursor.js +133 -0
  683. package/dist/trace/cursor.js.map +1 -0
  684. package/dist/trace/dialect.d.ts +43 -0
  685. package/dist/trace/dialect.d.ts.map +1 -0
  686. package/dist/trace/dialect.js +95 -0
  687. package/dist/trace/dialect.js.map +1 -0
  688. package/dist/trace/epochs.d.ts +10 -0
  689. package/dist/trace/epochs.d.ts.map +1 -0
  690. package/dist/trace/epochs.js +16 -0
  691. package/dist/trace/epochs.js.map +1 -0
  692. package/dist/trace/failure.d.ts +15 -0
  693. package/dist/trace/failure.d.ts.map +1 -0
  694. package/dist/trace/failure.js +69 -0
  695. package/dist/trace/failure.js.map +1 -0
  696. package/dist/trace/gate-file.d.ts +71 -0
  697. package/dist/trace/gate-file.d.ts.map +1 -0
  698. package/dist/trace/gate-file.js +329 -0
  699. package/dist/trace/gate-file.js.map +1 -0
  700. package/dist/trace/guard-fast.d.ts +22 -0
  701. package/dist/trace/guard-fast.d.ts.map +1 -0
  702. package/dist/trace/guard-fast.js +213 -0
  703. package/dist/trace/guard-fast.js.map +1 -0
  704. package/dist/trace/housekeeping.d.ts +5 -0
  705. package/dist/trace/housekeeping.d.ts.map +1 -0
  706. package/dist/trace/housekeeping.js +93 -0
  707. package/dist/trace/housekeeping.js.map +1 -0
  708. package/dist/trace/jobs.d.ts +52 -0
  709. package/dist/trace/jobs.d.ts.map +1 -0
  710. package/dist/trace/jobs.js +182 -0
  711. package/dist/trace/jobs.js.map +1 -0
  712. package/dist/trace/known-repo.d.ts +3 -0
  713. package/dist/trace/known-repo.d.ts.map +1 -0
  714. package/dist/trace/known-repo.js +55 -0
  715. package/dist/trace/known-repo.js.map +1 -0
  716. package/dist/trace/pool.d.ts +40 -0
  717. package/dist/trace/pool.d.ts.map +1 -0
  718. package/dist/trace/pool.js +154 -0
  719. package/dist/trace/pool.js.map +1 -0
  720. package/dist/trace/repairs.d.ts +27 -0
  721. package/dist/trace/repairs.d.ts.map +1 -0
  722. package/dist/trace/repairs.js +303 -0
  723. package/dist/trace/repairs.js.map +1 -0
  724. package/dist/trace/run-calls.d.ts +82 -0
  725. package/dist/trace/run-calls.d.ts.map +1 -0
  726. package/dist/trace/run-calls.js +331 -0
  727. package/dist/trace/run-calls.js.map +1 -0
  728. package/dist/trace/run-join.d.ts +20 -0
  729. package/dist/trace/run-join.d.ts.map +1 -0
  730. package/dist/trace/run-join.js +99 -0
  731. package/dist/trace/run-join.js.map +1 -0
  732. package/dist/trace/run-sheets.d.ts +26 -0
  733. package/dist/trace/run-sheets.d.ts.map +1 -0
  734. package/dist/trace/run-sheets.js +145 -0
  735. package/dist/trace/run-sheets.js.map +1 -0
  736. package/dist/trace/run-turns.d.ts +24 -0
  737. package/dist/trace/run-turns.d.ts.map +1 -0
  738. package/dist/trace/run-turns.js +67 -0
  739. package/dist/trace/run-turns.js.map +1 -0
  740. package/dist/trace/run-verdict.d.ts +24 -0
  741. package/dist/trace/run-verdict.d.ts.map +1 -0
  742. package/dist/trace/run-verdict.js +176 -0
  743. package/dist/trace/run-verdict.js.map +1 -0
  744. package/dist/trace/runs.d.ts +54 -0
  745. package/dist/trace/runs.d.ts.map +1 -0
  746. package/dist/trace/runs.js +501 -0
  747. package/dist/trace/runs.js.map +1 -0
  748. package/dist/trace/skill-session.d.ts +64 -0
  749. package/dist/trace/skill-session.d.ts.map +1 -0
  750. package/dist/trace/skill-session.js +232 -0
  751. package/dist/trace/skill-session.js.map +1 -0
  752. package/dist/trace/tamper.d.ts +12 -0
  753. package/dist/trace/tamper.d.ts.map +1 -0
  754. package/dist/trace/tamper.js +405 -0
  755. package/dist/trace/tamper.js.map +1 -0
  756. package/dist/trace/typed.d.ts +30 -0
  757. package/dist/trace/typed.d.ts.map +1 -0
  758. package/dist/trace/typed.js +132 -0
  759. package/dist/trace/typed.js.map +1 -0
  760. package/dist/trace/wall-state.d.ts +86 -0
  761. package/dist/trace/wall-state.d.ts.map +1 -0
  762. package/dist/trace/wall-state.js +279 -0
  763. package/dist/trace/wall-state.js.map +1 -0
  764. package/dist/trace/walls.d.ts +40 -0
  765. package/dist/trace/walls.d.ts.map +1 -0
  766. package/dist/trace/walls.js +318 -0
  767. package/dist/trace/walls.js.map +1 -0
  768. package/dist/upkeep-run.d.ts.map +1 -1
  769. package/dist/upkeep-run.js +2 -23
  770. package/dist/upkeep-run.js.map +1 -1
  771. package/dist/upkeep.d.ts.map +1 -1
  772. package/dist/upkeep.js +2 -3
  773. package/dist/upkeep.js.map +1 -1
  774. package/dist/util/private-fs.d.ts +6 -0
  775. package/dist/util/private-fs.d.ts.map +1 -1
  776. package/dist/util/private-fs.js +9 -1
  777. package/dist/util/private-fs.js.map +1 -1
  778. package/dist/util/state.d.ts.map +1 -1
  779. package/dist/util/state.js +17 -3
  780. package/dist/util/state.js.map +1 -1
  781. package/dist/vendor/tree-sitter-swift/LICENSE +21 -0
  782. package/dist/vendor/tree-sitter-swift/node-types.json +30694 -0
  783. package/dist/vendor/tree-sitter-swift/prebuilds/darwin-arm64/tree-sitter-swift.node +0 -0
  784. package/dist/vendor/tree-sitter-swift/prebuilds/darwin-x64/tree-sitter-swift.node +0 -0
  785. package/dist/vendor/tree-sitter-swift/prebuilds/linux-arm64/tree-sitter-swift.node +0 -0
  786. package/dist/vendor/tree-sitter-swift/prebuilds/linux-x64/tree-sitter-swift.node +0 -0
  787. package/dist/vendor/tree-sitter-swift/prebuilds/win32-arm64/tree-sitter-swift.node +0 -0
  788. package/dist/vendor/tree-sitter-swift/prebuilds/win32-x64/tree-sitter-swift.node +0 -0
  789. package/package.json +6 -3
  790. package/scripts/stamp-telemetry-key.mjs +8 -5
  791. package/scripts/vendor-grammars.mjs +35 -0
@@ -1,44 +1,49 @@
1
1
  import { readFileSync, existsSync } from 'node:fs';
2
- import { execFileSync, spawn } from 'node:child_process';
2
+ import { execFileSync } from 'node:child_process';
3
3
  import { join, basename, isAbsolute, relative, resolve } from 'node:path';
4
4
  import { homedir } from 'node:os';
5
5
  import { readWiring } from './stats.js';
6
- import { formatBlastRadius, relevantRetrieval, formatOrientation, notesForPrompt, notesOnTouch, standingDirective } from './format.js';
6
+ import { formatBlastRadius, formatOrientation, notesOnTouch, standingDirective, teamNotesDirective } from './format.js';
7
7
  import { commitLines, listNotes, setupCommitLine, standingLearnings } from '../notes/notes.js';
8
8
  import { liveLearnings } from '../notes/learning-fields.js';
9
9
  import { noteAuthor, teammatesOn } from '../notes/git-facts.js';
10
10
  import { indexFreshness, staleBanner } from '../context/check.js';
11
- import { patchStats, readStats, acquireLock, readSession, writeSession, resolveContextDir } from './state.js';
12
- import { graftCliPath, claudeScriptPath } from './paths.js';
11
+ import { dropStoredPrompts, patchStats, readSession, writeSession, resolveContextDir } from './state.js';
12
+ import { emit, emitHook, graftJson, payloadSessionId, withContextDirArg } from './hook-io.js';
13
+ import { codexPostBashPart, postBashPart, sessionStartPart } from './skills-wiring.js';
14
+ import { handlePrompt } from './prompt-hook.js';
13
15
  import { runUpkeep } from '../upkeep-run.js';
14
16
  import { runningVersion, wiredHostIds } from '../upkeep.js';
15
17
  import { hostsWiredForTrail } from '../hosts/registry.js';
16
18
  import { flushClosedSessions, summarizeSession } from '../telemetry/sessions.js';
17
19
  import { maybeFlushInBackground } from '../telemetry/flush.js';
18
- import { hasSavingsTally, lastAssistantTurn, lastTurnBilling } from './tally.js';
19
- import { scopeOf, scopesOfGraph } from '../graph/scopes.js';
20
+ import { handleStopEvent } from './stop.js';
21
+ import { main as preBashMain } from './pre-bash.js';
20
22
  import { classifyToolUse, commandInvokesGraft, isMcpToolName, isGraftMcpTool, parseSavings, recordToolUse } from './session-metrics.js';
21
- import { adoptRepoBrand, brand, cmd, commandOnPath, repoWiredForTrail, tag, trailHandoverLine, trailOnPath } from '../brand.js';
23
+ import { adoptRepoBrand, brand, commandOnPath, repoWiredForTrail, tag, trailHandoverLine, trailOnPath } from '../brand.js';
22
24
  import { fitTrailServerToMachine } from '../hosts/claude-global.js';
23
25
  import { globalCopyCovers } from './hook-layers.js';
24
- import { NOTE_ASKS_PER_SESSION, noteAsk, noteSignals } from './note-signals.js';
25
- import { keepsNotes, noteCount, repoPlace } from '../notes/home.js';
26
+ import { keepsNotes, noteCounts, repoPlace } from '../notes/home.js';
26
27
  import { branchesStale, overlapMark, readBranchCache, refreshBranches, SESSION_REFRESH_MS } from '../notes/branches.js';
27
28
  import { learningFiles } from '../notes/repo-trail.js';
28
29
  import { inWorkspace, maybeSyncInBackground } from '../cloud/workspace-sync.js';
29
30
  import { cacheDir, readJson, writeJsonAtomic } from '../util/state.js';
30
31
  import { countBucket } from '../telemetry/contract.js';
32
+ import { detectHost } from '../trace/host.js';
31
33
  import { track } from '../telemetry/track.js';
32
34
  import { skillsDirective } from '../skills/skills.js';
33
- /** Prompts shorter than this never trigger retrieval — they are almost always
34
- * conversational ("yes go ahead", "thanks") and the coverage gate can't judge
35
- * them reliably with so few terms. */
36
- const MIN_PROMPT_CHARS = 12;
35
+ import { everyRepoLearnings } from '../notes/every-repo.js';
36
+ import { hostFacts } from '../skills/host-facts.js';
37
+ import { trailNow } from '../skills/settings.js';
38
+ import { recordSkillUse, skillOfToolUse } from './skill-use.js';
39
+ import { keptContext, keptNotice } from './start-init.js';
40
+ export { lastFileScopeHint, promptAskTimeout } from './prompt-hook.js';
37
41
  function readStdin() {
38
42
  const seam = process.env.GRAFT_TEST_STDIN;
39
43
  const raw = seam !== undefined ? seam : safeReadFd0();
40
44
  try {
41
- return JSON.parse(raw);
45
+ const input = JSON.parse(raw);
46
+ return input && typeof input === 'object' && !Array.isArray(input) ? input : {};
42
47
  }
43
48
  catch {
44
49
  return {};
@@ -58,132 +63,11 @@ export function underGraft(dir, file) {
58
63
  const posix = rel.replace(/^[/\\]+/, '').replace(/\\/g, '/');
59
64
  return posix.startsWith('graft/') || posix.startsWith('.trail/cache/');
60
65
  }
61
- /** Default budget for a graft child process invoked from a hook, matching the 8s
62
- * the installed hook entries carry. */
63
- const CHILD_TIMEOUT_MS = 8000;
64
- /** Headroom left for the hook's own work (read stdin, score, write session, emit)
65
- * after its `graft ask` child returns. */
66
- const HOOK_OVERHEAD_MS = 2000;
67
- /** Floor, so a hand-edited tiny timeout can't leave the child no time at all. */
68
- const MIN_CHILD_TIMEOUT_MS = 4000;
69
- /**
70
- * How long the prompt hook may let `graft ask` run — derived from the budget that is
71
- * *actually installed* in this repo's `.claude/settings.json`, not from what the
72
- * current version of `settings-merge.ts` would install.
73
- *
74
- * A query now brings the graph up to date first, so `graft init` raises the
75
- * UserPromptSubmit budget to 15s to cover the one cold rebuild after an upgrade. But
76
- * `mergeGraftSettings` only runs during `graft init` — upgrading the npm package does
77
- * not re-run it. So every repo wired before that change keeps `"timeout": 8000`, and
78
- * hard-coding a 13s child there means Claude Code kills the hook first: `emit()` and
79
- * `writeSession()` never run, the turn gets no retrieval pack at all, and the SIGKILLed
80
- * child can't even release the build lock. Reading the installed number keeps the child
81
- * strictly inside whatever budget this repo really has.
82
- */
83
- export function promptAskTimeout(dir) {
84
- const installed = installedHookTimeout(dir, 'UserPromptSubmit');
85
- if (installed === null)
86
- return CHILD_TIMEOUT_MS - HOOK_OVERHEAD_MS;
87
- return Math.max(MIN_CHILD_TIMEOUT_MS, installed - HOOK_OVERHEAD_MS);
88
- }
89
- /**
90
- * Every settings file Claude Code merges hook definitions from, for a session
91
- * rooted at `dir`. The per-repo file is not the only place graft's hooks can be
92
- * installed: declaring them once at the user level wires every repo on the
93
- * machine at once, and such a repo has no `.claude/settings.json` at all.
94
- */
95
- function hookSettingsFiles(dir) {
96
- const user = process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude');
97
- return [
98
- join(dir, '.claude', 'settings.json'),
99
- join(dir, '.claude', 'settings.local.json'),
100
- join(user, 'settings.json'),
101
- ];
102
- }
103
- /** The timeout on one settings file's graft hook entry for `event`, or null if it
104
- * can't be read (no settings file, hand-edited shape, unparseable JSON). */
105
- function hookTimeoutIn(file, event) {
106
- try {
107
- const settings = JSON.parse(readFileSync(file, 'utf8'));
108
- const blocks = settings?.hooks?.[event];
109
- if (!Array.isArray(blocks))
110
- return null;
111
- for (const block of blocks) {
112
- for (const h of block?.hooks ?? []) {
113
- if (typeof h?.command === 'string' && /(graft|trail)-hooks\.cjs/.test(h.command) && typeof h.timeout === 'number') {
114
- return h.timeout;
115
- }
116
- }
117
- }
118
- return null;
119
- }
120
- catch {
121
- return null;
122
- }
123
- }
124
- /**
125
- * The budget this hook is actually running under, or null when no settings file
126
- * declares one.
127
- *
128
- * The smallest declared timeout wins rather than the nearest, because when more
129
- * than one file declares the hook Claude Code runs every matching entry and this
130
- * process cannot tell which one launched it. Guessing high is the expensive
131
- * mistake: an overrunning child gets the whole hook SIGKILLed, so `emit()` and
132
- * `writeSession()` never run and the turn silently gets no retrieval at all.
133
- * Guessing low only shortens one query.
134
- */
135
- function installedHookTimeout(dir, event) {
136
- let smallest = null;
137
- for (const file of hookSettingsFiles(dir)) {
138
- const timeout = hookTimeoutIn(file, event);
139
- if (timeout === null)
140
- continue;
141
- if (smallest === null || timeout < smallest)
142
- smallest = timeout;
143
- }
144
- return smallest;
145
- }
146
- /**
147
- * Append `--dir <contextDir>` for the hooks' own `graft ask`/`graft check`
148
- * children — the one place in this file that spawns the CLI itself rather
149
- * than reading `graft/` off disk (which already resolves through
150
- * `resolveContextDir` inside `util/state.ts` and `claude/stats.ts`). A no-op
151
- * when `GRAFT_DIR` isn't set, so an unconfigured repo's spawned CLI sees
152
- * byte-identical argv to before this existed.
153
- */
154
- function withContextDirArg(dir, args) {
155
- return process.env.GRAFT_DIR ? [...args, '--dir', resolveContextDir(dir)] : args;
156
- }
157
- function graftJson(dir, args, timeout = CHILD_TIMEOUT_MS) {
158
- try {
159
- // GRAFT_TEST_CLI is a test seam (mirrors GRAFT_TEST_STDIN/GRAFT_TEST_SYNC_RUN) so
160
- // tests can point the prompt hook's `graft ask`/`graft check` calls at a stub
161
- // script and observe the exact args it was invoked with, instead of shelling
162
- // out to the real CLI (which isn't built relative to the TS source under test).
163
- const cliPath = process.env.GRAFT_TEST_CLI ?? graftCliPath();
164
- const out = execFileSync(process.execPath, [cliPath, ...args], { cwd: dir, encoding: 'utf8', timeout, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true });
165
- return JSON.parse(out);
166
- }
167
- catch (e) {
168
- // `graft check` exits non-zero when the graph is stale (by design) but still
169
- // prints valid JSON to stdout; recover it from the thrown error before giving up.
170
- if (e && typeof e.stdout === 'string' && e.stdout.trim()) {
171
- try {
172
- return JSON.parse(e.stdout);
173
- }
174
- catch { /* not JSON — fall through */ }
175
- }
176
- return null;
177
- }
178
- }
179
66
  function checkStaleCount(dir) {
180
67
  const r = graftJson(dir, withContextDirArg(dir, ['check', '.', '--json']));
181
68
  const g = r?.graph ?? {};
182
69
  return (g.changed?.length ?? 0) + (g.added?.length ?? 0) + (g.removed?.length ?? 0);
183
70
  }
184
- function emit(eventName, additionalContext) {
185
- process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: eventName, additionalContext } }));
186
- }
187
71
  /**
188
72
  * The absolute path of the file a PostToolUse edit touched, across host edit-tool
189
73
  * shapes:
@@ -264,49 +148,6 @@ async function editOverlap(input, dir, file) {
264
148
  return null;
265
149
  }
266
150
  }
267
- /**
268
- * The "you're working in backend/, weight it" hint: on a multi-scope repo,
269
- * narrow the prompt hook's `ask` call to whatever scope the last-edited file
270
- * (`stats.lastFile`, captured at {@link handlePostEdit}) sits in.
271
- *
272
- * `lastFile` is only a basename (not a repo-relative path — see
273
- * `handlePostEdit`), so this is a best-effort lookup against the CURRENT
274
- * graph: any file node whose path ends in `/<lastFile>` (or equals it, for a
275
- * repo-root file). Fails soft in every direction a hook must never crash on —
276
- * no graph, a single-scope graph, a lastFile no longer in the graph (moved,
277
- * deleted, or edited before the first build), or a basename that lands in
278
- * more than one scope (ambiguous: could be either sub-project) all skip the
279
- * hint silently, logging one line to stderr so the miss is visible without
280
- * ever failing the hook.
281
- */
282
- export function lastFileScopeHint(dir, lastFile) {
283
- if (!lastFile)
284
- return null;
285
- try {
286
- const w = readWiring(dir);
287
- if (!w)
288
- return null;
289
- const scopes = scopesOfGraph(w);
290
- if (scopes.length <= 1)
291
- return null; // single-scope: no hint, no --in
292
- const matches = (w.nodes ?? []).filter((n) => n.kind === 'file' && (n.path === lastFile || n.path.endsWith(`/${lastFile}`)));
293
- if (matches.length === 0) {
294
- console.error(`${tag()} prompt hook: lastFile "${lastFile}" not found in the graph — skipping scope hint`);
295
- return null;
296
- }
297
- const prefixes = new Set(matches.map((n) => scopeOf(n.path, scopes).prefix));
298
- if (prefixes.size > 1) {
299
- console.error(`${tag()} prompt hook: lastFile "${lastFile}" matches more than one scope — skipping scope hint`);
300
- return null;
301
- }
302
- const [prefix] = prefixes;
303
- return prefix === '' ? null : prefix; // root scope: nothing to narrow
304
- }
305
- catch (e) {
306
- console.error(`${tag()} prompt hook: scope hint lookup failed (${e?.message ?? e}) — skipping`);
307
- return null;
308
- }
309
- }
310
151
  /**
311
152
  * PostToolUse on a retrieval tool. Two jobs, both a pure parse of the payload the
312
153
  * hook already received (no re-run):
@@ -327,10 +168,7 @@ export function lastFileScopeHint(dir, lastFile) {
327
168
  * nothing is written.
328
169
  */
329
170
  function handleToolUse(input, dir) {
330
- recordToolUse(dir, input?.session_id || 'default', { ...classifyAndScore(input?.tool_name, input?.tool_input?.command, () => input?.tool_response ?? input), host: 'claude-code' });
331
- const learned = learningsOnTouch(input, dir);
332
- if (learned)
333
- emit('PostToolUse', learned);
171
+ recordToolUse(dir, payloadSessionId(input), { ...classifyAndScore(input?.tool_name, input?.tool_input?.command, () => input?.tool_response ?? input), host: telemetryHost(input) });
334
172
  }
335
173
  /**
336
174
  * Under trail, the learnings about the file a Read, Edit or Write just touched,
@@ -359,7 +197,7 @@ export function learningsOnTouch(input, dir) {
359
197
  const notes = liveLearnings(listNotes(dir, { branches: false }));
360
198
  if (!notes.length)
361
199
  return null;
362
- const id = input?.session_id || 'default';
200
+ const id = payloadSessionId(input);
363
201
  const s = readSession(dir, id);
364
202
  const text = notesOnTouch(notes, touch, s);
365
203
  if (text)
@@ -371,6 +209,24 @@ export function learningsOnTouch(input, dir) {
371
209
  return null;
372
210
  }
373
211
  }
212
+ /**
213
+ * PostToolUse's one answer: the skills part's, with the learnings about what
214
+ * the call touched added to its context. Two JSON objects on stdout would be
215
+ * read as neither. A block is the whole answer, so then no learning is used up.
216
+ */
217
+ export function withTouchLearnings(out, input, dir) {
218
+ if (out.block)
219
+ return out;
220
+ const learned = learningsOnTouch(input, dir);
221
+ if (!learned)
222
+ return out;
223
+ return { ...out, context: [out.context, learned].filter(Boolean).join('\n\n') };
224
+ }
225
+ /** Who to put a tool use down to: Cursor and Copilot CLI run these hooks too. */
226
+ function telemetryHost(input) {
227
+ const host = detectHost(input).host;
228
+ return host === 'cursor' || host === 'copilot' ? host : 'claude-code';
229
+ }
374
230
  /**
375
231
  * Classify a tool use and, only when it could carry a graft footer, parse the
376
232
  * savings out of its (lazily-serialised) output.
@@ -422,118 +278,7 @@ function handleCursorMcp(input, dir) {
422
278
  }
423
279
  /** Cursor keys a chat by `conversation_id` (its `session_id` equivalent). */
424
280
  function cursorSessionId(input) {
425
- return input?.conversation_id || input?.session_id || 'default';
426
- }
427
- /**
428
- * At turn end: what did this turn's input tokens actually cost?
429
- *
430
- * Deliberately ungated, unlike {@link countTallyTurn}: the blended rate has to
431
- * describe the session, and graft turns are not a fair sample of it — they are
432
- * the long, tool-heavy, cache-warm ones. Sampling only those would report a
433
- * cheaper token than the session really pays.
434
- *
435
- * Accumulates the pair, never the ratio, so the rate re-blends every turn. A
436
- * turn already billed (a duplicate Stop, or a Stop racing the transcript write)
437
- * is skipped on its uuid.
438
- */
439
- function sampleTurnCost(input, dir) {
440
- try {
441
- const id = input?.session_id || 'default';
442
- const billing = lastTurnBilling(input?.transcript_path);
443
- if (!billing)
444
- return;
445
- const s = readSession(dir, id);
446
- if (billing.uuid === s.lastBillingUuid)
447
- return;
448
- s.inputCostMicros = (s.inputCostMicros ?? 0) + billing.costMicros;
449
- s.inputTokensBilled = (s.inputTokensBilled ?? 0) + billing.tokens;
450
- s.lastBillingUuid = billing.uuid;
451
- writeSession(dir, id, s);
452
- }
453
- catch {
454
- // A billing estimate is never worth failing the graph sync over.
455
- }
456
- }
457
- /**
458
- * At turn end: did the reply the user just read say what graft saved?
459
- *
460
- * Runs only on turns the tool-savings hook flagged, so a conversational turn
461
- * costs nothing. A turn we cannot observe — a host whose Stop hook names no
462
- * transcript, an unreadable file, or a Stop that fires before the final prose
463
- * is on disk — is counted in NEITHER total: the ratio these two numbers form
464
- * has to mean "of the turns we could check", not "of the turns we tried to".
465
- */
466
- function countTallyTurn(input, dir) {
467
- try {
468
- const id = input?.session_id || 'default';
469
- const s = readSession(dir, id);
470
- if (!s.turnUsedGraft)
471
- return;
472
- const turn = lastAssistantTurn(input?.transcript_path);
473
- // Same reply as last time we looked: no new prose has landed, so this Stop
474
- // is a duplicate or a race with the transcript write. Drop the turn rather
475
- // than judge it on a stale message.
476
- if (!turn || turn.uuid === s.lastTallyUuid) {
477
- writeSession(dir, id, { ...s, turnUsedGraft: false });
478
- return;
479
- }
480
- s.graftTurns = (s.graftTurns ?? 0) + 1;
481
- if (hasSavingsTally(turn.text))
482
- s.reportedTurns = (s.reportedTurns ?? 0) + 1;
483
- s.turnUsedGraft = false;
484
- s.lastTallyUuid = turn.uuid;
485
- writeSession(dir, id, s);
486
- }
487
- catch {
488
- // A turn-end metric is never worth failing the graph sync over.
489
- }
490
- }
491
- /**
492
- * Under trail, a sign in the transcript that the session found something the
493
- * code won't tell the next person (a check that failed then passed after an
494
- * edit, a correction, an undone edit, a picked option, a commit; see
495
- * note-signals.ts) asks the agent to save a learning, by blocking the stop
496
- * with the reason. Each sign is asked about once, and a session is asked at
497
- * most NOTE_ASKS_PER_SESSION times; a saved learning starts the signs over.
498
- * Never blocks twice in a row: Claude Code sets `stop_hook_active` on the
499
- * stop that follows a block.
500
- */
501
- function askForNote(input, dir) {
502
- try {
503
- if (brand() !== 'trail' || input?.stop_hook_active || !input?.transcript_path || !keepsNotes(dir))
504
- return;
505
- const id = input?.session_id || 'default';
506
- const s = readSession(dir, id);
507
- const asked = s.noteAsks ?? [];
508
- if (asked.length >= NOTE_ASKS_PER_SESSION)
509
- return;
510
- const sign = noteSignals(readFileSync(input.transcript_path, 'utf8'), dir).find((x) => !asked.includes(x.key));
511
- if (!sign)
512
- return;
513
- writeSession(dir, id, { ...s, noteAsks: [...asked, sign.key] });
514
- process.stdout.write(JSON.stringify({ decision: 'block', reason: noteAsk(sign) }));
515
- }
516
- catch {
517
- // A missed reminder costs one note; a broken Stop hook costs the session.
518
- }
519
- }
520
- function handleStop(input, dir) {
521
- sampleTurnCost(input, dir);
522
- countTallyTurn(input, dir);
523
- // sync-run.js ships next to this module inside the package, so it resolves in
524
- // any repo that installs graft (not just graft's own). Defensive existsSync:
525
- // if the package is somehow incomplete, skip rather than wedge on syncing:true.
526
- // GRAFT_TEST_SYNC_RUN is a test seam (mirrors GRAFT_TEST_STDIN) so tests can point
527
- // this at a stub file inside their own sandbox instead of writing into src/claude/.
528
- const syncRun = process.env.GRAFT_TEST_SYNC_RUN ?? claudeScriptPath('sync-run.js');
529
- if (!existsSync(syncRun))
530
- return;
531
- const stats = readStats(dir);
532
- if (stats?.dirty && acquireLock(dir)) {
533
- patchStats(dir, { syncing: true });
534
- const child = spawn(process.execPath, [syncRun, dir], { detached: true, stdio: 'ignore', windowsHide: true });
535
- child.unref();
536
- }
281
+ return payloadSessionId({ session_id: input?.conversation_id || input?.session_id });
537
282
  }
538
283
  const DAY_MS = 24 * 60 * 60 * 1000;
539
284
  /**
@@ -587,7 +332,7 @@ export function trackLearningsCommitted(dir) {
587
332
  }
588
333
  }
589
334
  /**
590
- * Team learnings sitting uncommitted in `.trail/learnings/` (from trail init's
335
+ * Learnings added to this repo but sitting uncommitted in `.trail/learnings/` (from trail init's
591
336
  * read of past sessions, or a session that ended before committing) reach no
592
337
  * teammate. Once a day per repo, the first reply says so, with the line that
593
338
  * makes the case for committing them. Empty when everything is committed.
@@ -613,8 +358,8 @@ export function uncommittedDirective(dir, now = Date.now()) {
613
358
  return `${tag()} trail's shared setup here (.trail/ and .claude/settings.json) isn't committed yet, so teammates' Claude can't read the learnings. Say so once, at the end of your first reply, with this line, word for word: ${line}\n`;
614
359
  }
615
360
  const line = commitLines({}, teammatesOn(place.checkout), 'repo').uncommitted;
616
- const them = n === 1 ? "learning in .trail/learnings/ isn't committed yet, so no teammate's agent has it" : `learnings in .trail/learnings/ aren't committed yet, so no teammate's agent has them`;
617
- return `${tag()} ${n} team ${them}. Say so once, at the end of your first reply, with this line, word for word: ${line}\n`;
361
+ const them = n === 1 ? "learning added to this repo (in .trail/learnings/) isn't committed yet, so no teammate's agent has it" : "learnings added to this repo (in .trail/learnings/) aren't committed yet, so no teammate's agent has them";
362
+ return `${tag()} ${n} ${them}. Say so once, at the end of your first reply, with this line, word for word: ${line}\n`;
618
363
  }
619
364
  catch {
620
365
  return '';
@@ -668,6 +413,75 @@ function trailAtStart(dir) {
668
413
  trackRepoSeen(dir);
669
414
  trackLearningsCommitted(dir);
670
415
  }
416
+ /**
417
+ * The learnings part of the session-start text. It needs nothing from
418
+ * `graft/`: the learnings are their own files. Empty on any read failure,
419
+ * which costs the session its learnings, never its start.
420
+ */
421
+ function learningsAtStart(dir) {
422
+ // 1b (P21, J16): every-repo personal learnings load in every repo, a plain one too, skills on or off; never a
423
+ // lesson (R47: everyRepoLearnings leaves them out). Shown as standing learnings, phase 0's framing.
424
+ let every = [];
425
+ try {
426
+ every = everyRepoLearnings();
427
+ }
428
+ catch { /* none this time */ }
429
+ try {
430
+ if (!keepsNotes(dir))
431
+ return { kept: false, count: 0, extra: standingDirective(every) };
432
+ const skills = skillsDirective(dir);
433
+ const standing = brand() === 'trail' ? standingDirective(withEvery(standingLearnings(dir), every)) + uncommittedDirective(dir) : standingDirective(every);
434
+ return { kept: true, count: noteCounts(dir), extra: skills + standing };
435
+ }
436
+ catch {
437
+ return { kept: false, count: 0, extra: standingDirective(every) };
438
+ }
439
+ }
440
+ /** This repo's standing learnings, then the every-repo ones not already among them (by id). */
441
+ function withEvery(here, every) {
442
+ const ids = new Set(here.map((n) => n.id).filter(Boolean));
443
+ return [...here, ...every.filter((n) => !n.id || !ids.has(n.id))];
444
+ }
445
+ /**
446
+ * D87: what the person kept on `trail init`'s screen, named once at the next interactive startup or resume in that
447
+ * repo with its undo. Skills on or off. A notice where the host shows one, else context from Trail.
448
+ */
449
+ function keptAtStart(input, dir) {
450
+ try {
451
+ const source = typeof input?.source === 'string' && input.source ? input.source : 'startup';
452
+ if (source !== 'startup' && source !== 'resume')
453
+ return {};
454
+ if (typeof input?.agent_id === 'string' && input.agent_id)
455
+ return {};
456
+ if (String(process.env.CLAUDE_CODE_ENTRYPOINT ?? '').startsWith('sdk'))
457
+ return {};
458
+ const cwd = typeof input?.cwd === 'string' && input.cwd ? input.cwd : dir;
459
+ const line = keptNotice(repoPlace(cwd).key, process.env, trailNow(process.env));
460
+ if (!line)
461
+ return {};
462
+ return hostFacts(process.env, detectHost(input).host).startNotice ? { notice: line } : { context: keptContext(line) };
463
+ }
464
+ catch {
465
+ return {};
466
+ }
467
+ }
468
+ /**
469
+ * The session-start text: the orientation from `graft/INDEX.md` with the
470
+ * learnings in it, or, where INDEX.md is missing (never built here; `graft/` is
471
+ * git-ignored, so a teammate's fresh clone has none), the learnings alone.
472
+ */
473
+ function orientationAtStart(dir, learnings) {
474
+ try {
475
+ const idx = readFileSync(join(resolveContextDir(dir), 'INDEX.md'), 'utf8');
476
+ const banner = staleBanner(indexFreshness(dir)) ?? undefined;
477
+ // Where the map is: `.trail/cache/` in a repo on trail, `graft/` elsewhere (context/map-dir.ts).
478
+ const mapDir = relative(dir, resolveContextDir(dir)).split('\\').join('/') || 'graft';
479
+ return formatOrientation(idx, undefined, banner, learnings.count, learnings.kept, learnings.extra, mapDir);
480
+ }
481
+ catch {
482
+ return learnings.kept ? `${tag()} ${teamNotesDirective(learnings.count, true)}${learnings.extra}` : learnings.extra;
483
+ }
484
+ }
671
485
  /** The repo's committed `.mcp.json` still registers trail's server (set up before 0.23). */
672
486
  function repoNamesTrailServer(dir) {
673
487
  try {
@@ -678,16 +492,36 @@ function repoNamesTrailServer(dir) {
678
492
  }
679
493
  }
680
494
  export async function main(event) {
495
+ // Shims before pre-bash.js existed send PreToolUse here: hand it straight
496
+ // over, before any of the work the other events share.
497
+ if (event === 'pre-bash') {
498
+ await preBashMain(event);
499
+ return;
500
+ }
681
501
  // trail's own headless Claude calls (the first-run read of past sessions) run with this set.
682
502
  if (process.env.TRAIL_NO_HOOKS === '1')
683
503
  return;
504
+ const input = readStdin();
684
505
  // Registered in the repo and in ~/.claude, Claude Code runs both: one answers.
685
- if (globalCopyCovers(event, process.argv[1]))
506
+ // Who sent the payload decides first: Copilot CLI runs only the repo's copy.
507
+ if (globalCopyCovers(event, process.argv[1], homedir(), process.env, input))
686
508
  return;
687
- const input = readStdin();
688
509
  const dir = projectDir(input);
510
+ // A failed Bash call (PostToolUseFailure, D34): the skills mark, and 1b's wall fix as its one answer, before any of
511
+ // the work the other events share.
512
+ if (event === 'post-bash-fail') {
513
+ emitHook('PostToolUseFailure', await postBashPart(input, dir, true));
514
+ return;
515
+ }
516
+ // Codex's PostToolUse on Bash, on every exit (3.4): the skills mark, and the wall fix where its context reaches the model.
517
+ if (event === 'codex-post-bash') {
518
+ emitHook('PostToolUse', await codexPostBashPart(input, dir));
519
+ return;
520
+ }
689
521
  adoptRepoBrand(dir, process.env, hostsWiredForTrail);
690
522
  if (event === 'session-start') {
523
+ // The skills part first, so nothing below can skip it (a repo with no graft/INDEX.md included).
524
+ const skills = await sessionStartPart(input, dir);
691
525
  // Before anything is emitted: refresh this repo's wiring if it was written by
692
526
  // an older graft, and pick up any cached "newer version on npm" answer.
693
527
  // background:false — the registry check stays off the network here; the CLI
@@ -703,27 +537,22 @@ export async function main(event) {
703
537
  // terminal never fires it) goes now. Once a day at most, never waited on.
704
538
  flushClosedSessions(dir);
705
539
  maybeFlushInBackground();
540
+ // Once per repo: older versions kept the prompt in each session file.
541
+ try {
542
+ dropStoredPrompts(dir);
543
+ }
544
+ catch { /* tried again next session */ }
706
545
  trailAtStart(dir);
707
546
  // A repo on trail, opened on a machine that has graft but not the trail command.
708
547
  // Only while its .mcp.json still names a trail server: once it doesn't, trail: true takes back the stand-in.
709
548
  if (repoWiredForTrail(dir))
710
549
  fitTrailServerToMachine(homedir(), resolve(dir), { trail: trailOnPath() || !repoNamesTrailServer(dir), graft: commandOnPath('graft') });
711
- try {
712
- const idx = readFileSync(join(resolveContextDir(dir), 'INDEX.md'), 'utf8');
713
- const banner = staleBanner(indexFreshness(dir)) ?? undefined;
714
- const kept = keepsNotes(dir);
715
- const skills = kept ? skillsDirective(dir, cmd('graft skills show')) : '';
716
- const underTrail = kept && brand() === 'trail';
717
- const standing = underTrail ? standingDirective(standingLearnings(dir)) + uncommittedDirective(dir) : '';
718
- const mapDir = relative(dir, resolveContextDir(dir)).split('\\').join('/') || 'graft';
719
- const orientation = formatOrientation(idx, undefined, banner, noteCount(dir), kept, skills + standing, mapDir);
720
- emit('SessionStart', upkeep.length ? `${upkeep.join('\n')}\n\n${orientation}` : orientation);
721
- }
722
- catch {
723
- // No INDEX.md (never built here). An upgrade nudge is still worth saying.
724
- if (upkeep.length)
725
- emit('SessionStart', upkeep.join('\n'));
726
- }
550
+ const text = orientationAtStart(dir, learningsAtStart(dir));
551
+ const kept = keptAtStart(input, dir);
552
+ // The skills context comes after the learnings; its notice is for the person.
553
+ const out = [upkeep.join('\n'), text, skills.context, kept.context].filter(Boolean).join('\n\n');
554
+ const notice = [skills.notice, kept.notice].filter(Boolean).join('\n') || undefined;
555
+ emitHook('SessionStart', { context: out, notice });
727
556
  return;
728
557
  }
729
558
  // Claude closing: send the queue from a detached child, so quitting isn't slowed.
@@ -737,6 +566,10 @@ export async function main(event) {
737
566
  }
738
567
  if (event === 'tool-savings') {
739
568
  handleToolUse(input, dir);
569
+ recordSkillUse(skillOfToolUse(input), input, dir);
570
+ // PostToolUse on Bash: the skills mark, and the post-tool offer channel's context (3.4),
571
+ // then the learnings about the file the call touched, in the same one answer.
572
+ emitHook('PostToolUse', withTouchLearnings(await postBashPart(input, dir, false), input, dir));
740
573
  return;
741
574
  }
742
575
  if (event === 'cursor-post-tool') {
@@ -756,47 +589,18 @@ export async function main(event) {
756
589
  return;
757
590
  }
758
591
  if (event === 'stop') {
759
- handleStop(input, dir);
760
- askForNote(input, dir);
592
+ await handleStopEvent(input, dir);
761
593
  return;
762
594
  }
595
+ // An edit's payload, not a Stop's: the turn-end bookkeeping only, so its one answer stays the edit's.
763
596
  if (event === 'post-edit-sync') {
764
597
  await handlePostEdit(input, dir);
765
- handleStop(input, dir);
598
+ await handleStopEvent(input, dir, { skills: false });
766
599
  return;
767
600
  }
768
601
  if (event === 'prompt') {
769
- const prompt = String(input?.prompt ?? '').trim();
770
- // Background completion notices are machine events, not user queries.
771
- if (prompt.length < MIN_PROMPT_CHARS || prompt.startsWith('<task-notification>'))
772
- return;
773
- // Pointers-only, small, gated. No --source: per-prompt injected tokens are
774
- // fresh full-price input on every turn (unlike the cached SessionStart
775
- // orientation), so the pack carries locators, never inlined code — the agent
776
- // pulls spans itself via `graft ask --source` when a pointer looks right.
777
- // relevantRetrieval then drops the pack entirely when the prompt barely
778
- // overlaps the top hit or when every hit was already injected this session.
779
- const askArgs = withContextDirArg(dir, ['ask', prompt, '.', '--json', '-n', '3']);
780
- // "You're working in backend/, weight it": only fires on a multi-scope
781
- // repo whose lastFile resolves cleanly to one scope — see lastFileScopeHint.
782
- const scopeHint = lastFileScopeHint(dir, readStats(dir)?.lastFile);
783
- if (scopeHint)
784
- askArgs.push('--in', scopeHint);
785
- const ask = graftJson(dir, askArgs, promptAskTimeout(dir));
786
- if (!ask)
787
- return;
788
- const id = input.session_id || 'default';
789
- const s = readSession(dir, id);
790
- s.lastQuery = prompt;
791
- const agent = input?.agent?.name;
792
- if (agent)
793
- s.perAgentQuery[agent] = prompt;
794
- // Learnings first: what an earlier session worked out matters more than where code is.
795
- const notes = brand() === 'trail' ? notesForPrompt(ask, s) : null;
796
- const txt = [notes, relevantRetrieval(ask, s)].filter(Boolean).join('\n\n');
797
- if (txt)
798
- emit('UserPromptSubmit', txt);
799
- writeSession(dir, id, s);
602
+ await handlePrompt(input, dir);
603
+ return;
800
604
  }
801
605
  }
802
606
  //# sourceMappingURL=hooks.js.map