@flyingrobots/graft 0.6.1 → 0.7.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 (561) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/README.md +1 -1
  3. package/dist/adapters/json-text-decoder.d.ts +3 -0
  4. package/dist/adapters/json-text-decoder.d.ts.map +1 -0
  5. package/dist/adapters/json-text-decoder.js +12 -0
  6. package/dist/adapters/json-text-decoder.js.map +1 -0
  7. package/dist/adapters/node-paths.d.ts +3 -0
  8. package/dist/adapters/node-paths.d.ts.map +1 -0
  9. package/dist/adapters/node-paths.js +29 -0
  10. package/dist/adapters/node-paths.js.map +1 -0
  11. package/dist/adapters/repo-paths.d.ts.map +1 -1
  12. package/dist/adapters/repo-paths.js +40 -5
  13. package/dist/adapters/repo-paths.js.map +1 -1
  14. package/dist/api/tool-bridge.d.ts +1 -1
  15. package/dist/api/tool-bridge.d.ts.map +1 -1
  16. package/dist/api/tool-bridge.js +1 -1
  17. package/dist/api/tool-bridge.js.map +1 -1
  18. package/dist/cli/cli-error.d.ts.map +1 -1
  19. package/dist/cli/cli-error.js +47 -10
  20. package/dist/cli/cli-error.js.map +1 -1
  21. package/dist/cli/command-parser.d.ts +12 -3
  22. package/dist/cli/command-parser.d.ts.map +1 -1
  23. package/dist/cli/command-parser.js +161 -2
  24. package/dist/cli/command-parser.js.map +1 -1
  25. package/dist/cli/daemon-status-model.d.ts +87 -0
  26. package/dist/cli/daemon-status-model.d.ts.map +1 -0
  27. package/dist/cli/daemon-status-model.js +142 -0
  28. package/dist/cli/daemon-status-model.js.map +1 -0
  29. package/dist/cli/daemon-status-render.d.ts +3 -0
  30. package/dist/cli/daemon-status-render.d.ts.map +1 -0
  31. package/dist/cli/daemon-status-render.js +100 -0
  32. package/dist/cli/daemon-status-render.js.map +1 -0
  33. package/dist/cli/daemon-status.d.ts +7 -0
  34. package/dist/cli/daemon-status.d.ts.map +1 -0
  35. package/dist/cli/daemon-status.js +79 -0
  36. package/dist/cli/daemon-status.js.map +1 -0
  37. package/dist/cli/git-graft-enhance-model.d.ts +67 -0
  38. package/dist/cli/git-graft-enhance-model.d.ts.map +1 -0
  39. package/dist/cli/git-graft-enhance-model.js +55 -0
  40. package/dist/cli/git-graft-enhance-model.js.map +1 -0
  41. package/dist/cli/git-graft-enhance-render.d.ts +3 -0
  42. package/dist/cli/git-graft-enhance-render.d.ts.map +1 -0
  43. package/dist/cli/git-graft-enhance-render.js +29 -0
  44. package/dist/cli/git-graft-enhance-render.js.map +1 -0
  45. package/dist/cli/git-graft-enhance.d.ts +14 -0
  46. package/dist/cli/git-graft-enhance.d.ts.map +1 -0
  47. package/dist/cli/git-graft-enhance.js +29 -0
  48. package/dist/cli/git-graft-enhance.js.map +1 -0
  49. package/dist/cli/index-cmd.d.ts.map +1 -1
  50. package/dist/cli/index-cmd.js +18 -21
  51. package/dist/cli/index-cmd.js.map +1 -1
  52. package/dist/cli/index-model.d.ts +5 -9
  53. package/dist/cli/index-model.d.ts.map +1 -1
  54. package/dist/cli/index-model.js +20 -18
  55. package/dist/cli/index-model.js.map +1 -1
  56. package/dist/cli/init-client-config.d.ts +12 -7
  57. package/dist/cli/init-client-config.d.ts.map +1 -1
  58. package/dist/cli/init-client-config.js +105 -43
  59. package/dist/cli/init-client-config.js.map +1 -1
  60. package/dist/cli/init-model.d.ts +9 -2
  61. package/dist/cli/init-model.d.ts.map +1 -1
  62. package/dist/cli/init-model.js +52 -4
  63. package/dist/cli/init-model.js.map +1 -1
  64. package/dist/cli/init-render.d.ts.map +1 -1
  65. package/dist/cli/init-render.js +2 -2
  66. package/dist/cli/init-render.js.map +1 -1
  67. package/dist/cli/init.d.ts.map +1 -1
  68. package/dist/cli/init.js +11 -9
  69. package/dist/cli/init.js.map +1 -1
  70. package/dist/cli/json-document.d.ts +5 -0
  71. package/dist/cli/json-document.d.ts.map +1 -1
  72. package/dist/cli/json-document.js +9 -0
  73. package/dist/cli/json-document.js.map +1 -1
  74. package/dist/cli/main.d.ts +7 -0
  75. package/dist/cli/main.d.ts.map +1 -1
  76. package/dist/cli/main.js +49 -7
  77. package/dist/cli/main.js.map +1 -1
  78. package/dist/cli/migrate-local-history.d.ts.map +1 -1
  79. package/dist/cli/migrate-local-history.js +3 -2
  80. package/dist/cli/migrate-local-history.js.map +1 -1
  81. package/dist/cli/peer-command.d.ts +1 -1
  82. package/dist/cli/peer-command.d.ts.map +1 -1
  83. package/dist/cli/peer-command.js +1 -1
  84. package/dist/cli/peer-command.js.map +1 -1
  85. package/dist/contracts/capabilities.d.ts +5 -5
  86. package/dist/contracts/capabilities.d.ts.map +1 -1
  87. package/dist/contracts/capabilities.js +89 -0
  88. package/dist/contracts/capabilities.js.map +1 -1
  89. package/dist/contracts/causal-ontology.d.ts +17 -17
  90. package/dist/contracts/json-object.d.ts +0 -1
  91. package/dist/contracts/json-object.d.ts.map +1 -1
  92. package/dist/contracts/json-object.js +0 -10
  93. package/dist/contracts/json-object.js.map +1 -1
  94. package/dist/contracts/output-schema-cli.d.ts +277 -25
  95. package/dist/contracts/output-schema-cli.d.ts.map +1 -1
  96. package/dist/contracts/output-schema-cli.js +35 -3
  97. package/dist/contracts/output-schema-cli.js.map +1 -1
  98. package/dist/contracts/output-schema-fragments.d.ts +212 -87
  99. package/dist/contracts/output-schema-fragments.d.ts.map +1 -1
  100. package/dist/contracts/output-schema-fragments.js +49 -2
  101. package/dist/contracts/output-schema-fragments.js.map +1 -1
  102. package/dist/contracts/output-schema-mcp.d.ts +372 -47
  103. package/dist/contracts/output-schema-mcp.d.ts.map +1 -1
  104. package/dist/contracts/output-schema-mcp.js +217 -1
  105. package/dist/contracts/output-schema-mcp.js.map +1 -1
  106. package/dist/contracts/output-schema-meta.d.ts +2 -2
  107. package/dist/contracts/output-schema-meta.d.ts.map +1 -1
  108. package/dist/contracts/output-schemas.d.ts +7 -7
  109. package/dist/contracts/output-schemas.d.ts.map +1 -1
  110. package/dist/contracts/output-schemas.js +294 -6
  111. package/dist/contracts/output-schemas.js.map +1 -1
  112. package/dist/git/diff.d.ts +11 -0
  113. package/dist/git/diff.d.ts.map +1 -1
  114. package/dist/git/diff.js +50 -6
  115. package/dist/git/diff.js.map +1 -1
  116. package/dist/mcp/burden.d.ts.map +1 -1
  117. package/dist/mcp/burden.js +9 -0
  118. package/dist/mcp/burden.js.map +1 -1
  119. package/dist/mcp/context.d.ts +3 -2
  120. package/dist/mcp/context.d.ts.map +1 -1
  121. package/dist/mcp/context.js +2 -37
  122. package/dist/mcp/context.js.map +1 -1
  123. package/dist/mcp/daemon-server.d.ts +2 -0
  124. package/dist/mcp/daemon-server.d.ts.map +1 -1
  125. package/dist/mcp/daemon-server.js +6 -1
  126. package/dist/mcp/daemon-server.js.map +1 -1
  127. package/dist/mcp/daemon-session-host.d.ts +1 -0
  128. package/dist/mcp/daemon-session-host.d.ts.map +1 -1
  129. package/dist/mcp/daemon-session-host.js +3 -0
  130. package/dist/mcp/daemon-session-host.js.map +1 -1
  131. package/dist/mcp/daemon-stdio-bridge.d.ts +1 -0
  132. package/dist/mcp/daemon-stdio-bridge.d.ts.map +1 -1
  133. package/dist/mcp/daemon-stdio-bridge.js +1 -0
  134. package/dist/mcp/daemon-stdio-bridge.js.map +1 -1
  135. package/dist/mcp/monitor-tick-job.d.ts +1 -0
  136. package/dist/mcp/monitor-tick-job.d.ts.map +1 -1
  137. package/dist/mcp/monitor-tick-job.js +84 -29
  138. package/dist/mcp/monitor-tick-job.js.map +1 -1
  139. package/dist/mcp/monitor-types.d.ts +1 -1
  140. package/dist/mcp/monitor-types.d.ts.map +1 -1
  141. package/dist/mcp/persisted-local-history-graph.d.ts +2 -2
  142. package/dist/mcp/persisted-local-history-graph.d.ts.map +1 -1
  143. package/dist/mcp/persisted-local-history-graph.js +3 -2
  144. package/dist/mcp/persisted-local-history-graph.js.map +1 -1
  145. package/dist/mcp/persisted-local-history.d.ts +5 -5
  146. package/dist/mcp/persisted-local-history.js +2 -2
  147. package/dist/mcp/persisted-local-history.js.map +1 -1
  148. package/dist/mcp/persistent-monitor-runtime.d.ts +1 -0
  149. package/dist/mcp/persistent-monitor-runtime.d.ts.map +1 -1
  150. package/dist/mcp/persistent-monitor-runtime.js +35 -0
  151. package/dist/mcp/persistent-monitor-runtime.js.map +1 -1
  152. package/dist/mcp/repo-tool-worker-context.d.ts.map +1 -1
  153. package/dist/mcp/repo-tool-worker-context.js +5 -2
  154. package/dist/mcp/repo-tool-worker-context.js.map +1 -1
  155. package/dist/mcp/server-context.d.ts.map +1 -1
  156. package/dist/mcp/server-context.js +13 -0
  157. package/dist/mcp/server-context.js.map +1 -1
  158. package/dist/mcp/server-tool-access.d.ts +1 -1
  159. package/dist/mcp/server-tool-access.d.ts.map +1 -1
  160. package/dist/mcp/server-tool-access.js +3 -1
  161. package/dist/mcp/server-tool-access.js.map +1 -1
  162. package/dist/mcp/server.d.ts +3 -0
  163. package/dist/mcp/server.d.ts.map +1 -1
  164. package/dist/mcp/server.js +5 -3
  165. package/dist/mcp/server.js.map +1 -1
  166. package/dist/mcp/tool-registry.d.ts.map +1 -1
  167. package/dist/mcp/tool-registry.js +18 -0
  168. package/dist/mcp/tool-registry.js.map +1 -1
  169. package/dist/mcp/tools/code-find.d.ts.map +1 -1
  170. package/dist/mcp/tools/code-find.js +20 -0
  171. package/dist/mcp/tools/code-find.js.map +1 -1
  172. package/dist/mcp/tools/code-show.d.ts.map +1 -1
  173. package/dist/mcp/tools/code-show.js +24 -0
  174. package/dist/mcp/tools/code-show.js.map +1 -1
  175. package/dist/mcp/tools/diagnostic-models.d.ts +2 -0
  176. package/dist/mcp/tools/diagnostic-models.d.ts.map +1 -1
  177. package/dist/mcp/tools/doctor.d.ts.map +1 -1
  178. package/dist/mcp/tools/doctor.js +18 -1
  179. package/dist/mcp/tools/doctor.js.map +1 -1
  180. package/dist/mcp/tools/export-surface-diff.d.ts +3 -0
  181. package/dist/mcp/tools/export-surface-diff.d.ts.map +1 -0
  182. package/dist/mcp/tools/export-surface-diff.js +24 -0
  183. package/dist/mcp/tools/export-surface-diff.js.map +1 -0
  184. package/dist/mcp/tools/file-outline.js +1 -1
  185. package/dist/mcp/tools/file-outline.js.map +1 -1
  186. package/dist/mcp/tools/graft-edit.d.ts +3 -0
  187. package/dist/mcp/tools/graft-edit.d.ts.map +1 -0
  188. package/dist/mcp/tools/graft-edit.js +192 -0
  189. package/dist/mcp/tools/graft-edit.js.map +1 -0
  190. package/dist/mcp/tools/knowledge-map.d.ts +3 -0
  191. package/dist/mcp/tools/knowledge-map.d.ts.map +1 -0
  192. package/dist/mcp/tools/knowledge-map.js +31 -0
  193. package/dist/mcp/tools/knowledge-map.js.map +1 -0
  194. package/dist/mcp/tools/monitor-nudge.d.ts +3 -0
  195. package/dist/mcp/tools/monitor-nudge.d.ts.map +1 -0
  196. package/dist/mcp/tools/monitor-nudge.js +17 -0
  197. package/dist/mcp/tools/monitor-nudge.js.map +1 -0
  198. package/dist/mcp/tools/precision-warp.d.ts +3 -3
  199. package/dist/mcp/tools/precision-warp.d.ts.map +1 -1
  200. package/dist/mcp/tools/precision-warp.js +24 -15
  201. package/dist/mcp/tools/precision-warp.js.map +1 -1
  202. package/dist/mcp/tools/refactor-difficulty.d.ts +3 -0
  203. package/dist/mcp/tools/refactor-difficulty.d.ts.map +1 -0
  204. package/dist/mcp/tools/refactor-difficulty.js +36 -0
  205. package/dist/mcp/tools/refactor-difficulty.js.map +1 -0
  206. package/dist/mcp/tools/safe-read.js +2 -2
  207. package/dist/mcp/tools/safe-read.js.map +1 -1
  208. package/dist/mcp/tools/structural-blame.d.ts +3 -0
  209. package/dist/mcp/tools/structural-blame.d.ts.map +1 -0
  210. package/dist/mcp/tools/structural-blame.js +44 -0
  211. package/dist/mcp/tools/structural-blame.js.map +1 -0
  212. package/dist/mcp/tools/structural-churn.d.ts +3 -0
  213. package/dist/mcp/tools/structural-churn.d.ts.map +1 -0
  214. package/dist/mcp/tools/structural-churn.js +28 -0
  215. package/dist/mcp/tools/structural-churn.js.map +1 -0
  216. package/dist/mcp/tools/structural-log.d.ts +3 -0
  217. package/dist/mcp/tools/structural-log.d.ts.map +1 -0
  218. package/dist/mcp/tools/structural-log.js +38 -0
  219. package/dist/mcp/tools/structural-log.js.map +1 -0
  220. package/dist/mcp/tools/structural-review.d.ts +3 -0
  221. package/dist/mcp/tools/structural-review.d.ts.map +1 -0
  222. package/dist/mcp/tools/structural-review.js +55 -0
  223. package/dist/mcp/tools/structural-review.js.map +1 -0
  224. package/dist/mcp/warp-pool.d.ts +4 -4
  225. package/dist/mcp/warp-pool.d.ts.map +1 -1
  226. package/dist/mcp/warp-pool.js.map +1 -1
  227. package/dist/mcp/workspace-router-model.d.ts +2 -2
  228. package/dist/mcp/workspace-router-model.d.ts.map +1 -1
  229. package/dist/mcp/workspace-router-runtime.d.ts +3 -3
  230. package/dist/mcp/workspace-router-runtime.d.ts.map +1 -1
  231. package/dist/mcp/workspace-router-runtime.js +4 -1
  232. package/dist/mcp/workspace-router-runtime.js.map +1 -1
  233. package/dist/mcp/workspace-router.d.ts +3 -2
  234. package/dist/mcp/workspace-router.d.ts.map +1 -1
  235. package/dist/mcp/workspace-router.js +6 -0
  236. package/dist/mcp/workspace-router.js.map +1 -1
  237. package/dist/operations/adaptive-projection.d.ts +22 -0
  238. package/dist/operations/adaptive-projection.d.ts.map +1 -0
  239. package/dist/operations/adaptive-projection.js +36 -0
  240. package/dist/operations/adaptive-projection.js.map +1 -0
  241. package/dist/operations/agent-handoff.d.ts +25 -0
  242. package/dist/operations/agent-handoff.d.ts.map +1 -0
  243. package/dist/operations/agent-handoff.js +36 -0
  244. package/dist/operations/agent-handoff.js.map +1 -0
  245. package/dist/operations/capture-range.d.ts +33 -0
  246. package/dist/operations/capture-range.d.ts.map +1 -0
  247. package/dist/operations/capture-range.js +45 -0
  248. package/dist/operations/capture-range.js.map +1 -0
  249. package/dist/operations/conversation-primer.d.ts +27 -0
  250. package/dist/operations/conversation-primer.d.ts.map +1 -0
  251. package/dist/operations/conversation-primer.js +52 -0
  252. package/dist/operations/conversation-primer.js.map +1 -0
  253. package/dist/operations/cross-session-resume.d.ts +28 -0
  254. package/dist/operations/cross-session-resume.d.ts.map +1 -0
  255. package/dist/operations/cross-session-resume.js +79 -0
  256. package/dist/operations/cross-session-resume.js.map +1 -0
  257. package/dist/operations/deterministic-replay.d.ts +39 -0
  258. package/dist/operations/deterministic-replay.d.ts.map +1 -0
  259. package/dist/operations/deterministic-replay.js +90 -0
  260. package/dist/operations/deterministic-replay.js.map +1 -0
  261. package/dist/operations/export-surface-diff.d.ts +36 -0
  262. package/dist/operations/export-surface-diff.d.ts.map +1 -0
  263. package/dist/operations/export-surface-diff.js +298 -0
  264. package/dist/operations/export-surface-diff.js.map +1 -0
  265. package/dist/operations/footprint-parallelism.d.ts +25 -0
  266. package/dist/operations/footprint-parallelism.d.ts.map +1 -0
  267. package/dist/operations/footprint-parallelism.js +79 -0
  268. package/dist/operations/footprint-parallelism.js.map +1 -0
  269. package/dist/operations/graft-diff.d.ts.map +1 -1
  270. package/dist/operations/graft-diff.js +14 -7
  271. package/dist/operations/graft-diff.js.map +1 -1
  272. package/dist/operations/horizon-of-readability.d.ts +23 -0
  273. package/dist/operations/horizon-of-readability.d.ts.map +1 -0
  274. package/dist/operations/horizon-of-readability.js +39 -0
  275. package/dist/operations/horizon-of-readability.js.map +1 -0
  276. package/dist/operations/import-reference-impact.d.ts +13 -0
  277. package/dist/operations/import-reference-impact.d.ts.map +1 -0
  278. package/dist/operations/import-reference-impact.js +101 -0
  279. package/dist/operations/import-reference-impact.js.map +1 -0
  280. package/dist/operations/knowledge-map.d.ts +30 -0
  281. package/dist/operations/knowledge-map.d.ts.map +1 -0
  282. package/dist/operations/knowledge-map.js +64 -0
  283. package/dist/operations/knowledge-map.js.map +1 -0
  284. package/dist/operations/observation-cache.d.ts +8 -2
  285. package/dist/operations/observation-cache.d.ts.map +1 -1
  286. package/dist/operations/observation-cache.js +17 -5
  287. package/dist/operations/observation-cache.js.map +1 -1
  288. package/dist/operations/projection-safety.d.ts +31 -0
  289. package/dist/operations/projection-safety.d.ts.map +1 -0
  290. package/dist/operations/projection-safety.js +77 -0
  291. package/dist/operations/projection-safety.js.map +1 -0
  292. package/dist/operations/repo-workspace.js +3 -3
  293. package/dist/operations/repo-workspace.js.map +1 -1
  294. package/dist/operations/semantic-drift.d.ts +27 -0
  295. package/dist/operations/semantic-drift.d.ts.map +1 -0
  296. package/dist/operations/semantic-drift.js +46 -0
  297. package/dist/operations/semantic-drift.js.map +1 -0
  298. package/dist/operations/session-filtration.d.ts +36 -0
  299. package/dist/operations/session-filtration.d.ts.map +1 -0
  300. package/dist/operations/session-filtration.js +48 -0
  301. package/dist/operations/session-filtration.js.map +1 -0
  302. package/dist/operations/session-replay.d.ts +17 -0
  303. package/dist/operations/session-replay.d.ts.map +1 -0
  304. package/dist/operations/session-replay.js +59 -0
  305. package/dist/operations/session-replay.js.map +1 -0
  306. package/dist/operations/sludge-detector.d.ts +45 -0
  307. package/dist/operations/sludge-detector.d.ts.map +1 -0
  308. package/dist/operations/sludge-detector.js +278 -0
  309. package/dist/operations/sludge-detector.js.map +1 -0
  310. package/dist/operations/structural-blame.d.ts +67 -0
  311. package/dist/operations/structural-blame.d.ts.map +1 -0
  312. package/dist/operations/structural-blame.js +111 -0
  313. package/dist/operations/structural-blame.js.map +1 -0
  314. package/dist/operations/structural-review.d.ts +47 -0
  315. package/dist/operations/structural-review.d.ts.map +1 -0
  316. package/dist/operations/structural-review.js +225 -0
  317. package/dist/operations/structural-review.js.map +1 -0
  318. package/dist/operations/teaching-hints.d.ts +18 -0
  319. package/dist/operations/teaching-hints.d.ts.map +1 -0
  320. package/dist/operations/teaching-hints.js +35 -0
  321. package/dist/operations/teaching-hints.js.map +1 -0
  322. package/dist/parser/diff.d.ts +2 -0
  323. package/dist/parser/diff.d.ts.map +1 -1
  324. package/dist/parser/diff.js +7 -0
  325. package/dist/parser/diff.js.map +1 -1
  326. package/dist/ports/paths.d.ts +17 -0
  327. package/dist/ports/paths.d.ts.map +1 -0
  328. package/dist/ports/{warp.js → paths.js} +2 -2
  329. package/dist/ports/paths.js.map +1 -0
  330. package/dist/warp/ast-emitter.d.ts +28 -0
  331. package/dist/warp/ast-emitter.d.ts.map +1 -0
  332. package/dist/warp/ast-emitter.js +90 -0
  333. package/dist/warp/ast-emitter.js.map +1 -0
  334. package/dist/warp/ast-import-resolver.d.ts +13 -0
  335. package/dist/warp/ast-import-resolver.d.ts.map +1 -0
  336. package/dist/warp/ast-import-resolver.js +259 -0
  337. package/dist/warp/ast-import-resolver.js.map +1 -0
  338. package/dist/warp/commit-meta.d.ts +8 -0
  339. package/dist/warp/commit-meta.d.ts.map +1 -0
  340. package/dist/warp/commit-meta.js +13 -0
  341. package/dist/warp/commit-meta.js.map +1 -0
  342. package/dist/warp/context.d.ts +10 -0
  343. package/dist/warp/context.d.ts.map +1 -0
  344. package/dist/warp/context.js +26 -0
  345. package/dist/warp/context.js.map +1 -0
  346. package/dist/warp/dead-symbols.d.ts +40 -0
  347. package/dist/warp/dead-symbols.d.ts.map +1 -0
  348. package/dist/warp/dead-symbols.js +127 -0
  349. package/dist/warp/dead-symbols.js.map +1 -0
  350. package/dist/warp/drift-sentinel.d.ts +30 -0
  351. package/dist/warp/drift-sentinel.d.ts.map +1 -0
  352. package/dist/warp/drift-sentinel.js +65 -0
  353. package/dist/warp/drift-sentinel.js.map +1 -0
  354. package/dist/warp/index-head.d.ts +32 -0
  355. package/dist/warp/index-head.d.ts.map +1 -0
  356. package/dist/warp/index-head.js +245 -0
  357. package/dist/warp/index-head.js.map +1 -0
  358. package/dist/warp/observers.d.ts +6 -6
  359. package/dist/warp/observers.d.ts.map +1 -1
  360. package/dist/warp/observers.js +5 -4
  361. package/dist/warp/observers.js.map +1 -1
  362. package/dist/warp/open.d.ts +5 -4
  363. package/dist/warp/open.d.ts.map +1 -1
  364. package/dist/warp/open.js +24 -49
  365. package/dist/warp/open.js.map +1 -1
  366. package/dist/warp/outline-diff-trailer.d.ts +26 -0
  367. package/dist/warp/outline-diff-trailer.d.ts.map +1 -0
  368. package/dist/warp/outline-diff-trailer.js +68 -0
  369. package/dist/warp/outline-diff-trailer.js.map +1 -0
  370. package/dist/warp/refactor-difficulty.d.ts +38 -0
  371. package/dist/warp/refactor-difficulty.d.ts.map +1 -0
  372. package/dist/warp/refactor-difficulty.js +169 -0
  373. package/dist/warp/refactor-difficulty.js.map +1 -0
  374. package/dist/warp/references.d.ts +22 -0
  375. package/dist/warp/references.d.ts.map +1 -0
  376. package/dist/warp/references.js +57 -0
  377. package/dist/warp/references.js.map +1 -0
  378. package/dist/warp/stale-docs.d.ts +56 -0
  379. package/dist/warp/stale-docs.d.ts.map +1 -0
  380. package/dist/warp/stale-docs.js +149 -0
  381. package/dist/warp/stale-docs.js.map +1 -0
  382. package/dist/warp/structural-drift-detection.d.ts +49 -0
  383. package/dist/warp/structural-drift-detection.d.ts.map +1 -0
  384. package/dist/warp/structural-drift-detection.js +51 -0
  385. package/dist/warp/structural-drift-detection.js.map +1 -0
  386. package/dist/warp/structural-queries.d.ts +49 -0
  387. package/dist/warp/structural-queries.d.ts.map +1 -0
  388. package/dist/warp/structural-queries.js +175 -0
  389. package/dist/warp/structural-queries.js.map +1 -0
  390. package/dist/warp/symbol-timeline.d.ts +34 -0
  391. package/dist/warp/symbol-timeline.d.ts.map +1 -0
  392. package/dist/warp/symbol-timeline.js +127 -0
  393. package/dist/warp/symbol-timeline.js.map +1 -0
  394. package/dist/warp/traverse-hydrate.d.ts +23 -0
  395. package/dist/warp/traverse-hydrate.d.ts.map +1 -0
  396. package/dist/warp/traverse-hydrate.js +39 -0
  397. package/dist/warp/traverse-hydrate.js.map +1 -0
  398. package/dist/warp/warp-reference-count.d.ts +19 -0
  399. package/dist/warp/warp-reference-count.d.ts.map +1 -0
  400. package/dist/warp/warp-reference-count.js +32 -0
  401. package/dist/warp/warp-reference-count.js.map +1 -0
  402. package/dist/warp/warp-structural-blame.d.ts +20 -0
  403. package/dist/warp/warp-structural-blame.d.ts.map +1 -0
  404. package/dist/warp/warp-structural-blame.js +43 -0
  405. package/dist/warp/warp-structural-blame.js.map +1 -0
  406. package/dist/warp/warp-structural-churn.d.ts +30 -0
  407. package/dist/warp/warp-structural-churn.d.ts.map +1 -0
  408. package/dist/warp/warp-structural-churn.js +213 -0
  409. package/dist/warp/warp-structural-churn.js.map +1 -0
  410. package/dist/warp/warp-structural-log.d.ts +35 -0
  411. package/dist/warp/warp-structural-log.d.ts.map +1 -0
  412. package/dist/warp/warp-structural-log.js +104 -0
  413. package/dist/warp/warp-structural-log.js.map +1 -0
  414. package/docs/CLI.md +68 -4
  415. package/docs/MCP.md +23 -0
  416. package/docs/SETUP.md +101 -20
  417. package/package.json +5 -3
  418. package/src/adapters/json-text-decoder.ts +11 -0
  419. package/src/adapters/node-paths.ts +35 -0
  420. package/src/adapters/repo-paths.ts +45 -4
  421. package/src/api/tool-bridge.ts +2 -1
  422. package/src/cli/cli-error.ts +49 -10
  423. package/src/cli/command-parser.ts +185 -3
  424. package/src/cli/daemon-status-model.ts +238 -0
  425. package/src/cli/daemon-status-render.ts +102 -0
  426. package/src/cli/daemon-status.ts +100 -0
  427. package/src/cli/git-graft-enhance-model.ts +131 -0
  428. package/src/cli/git-graft-enhance-render.ts +33 -0
  429. package/src/cli/git-graft-enhance.ts +54 -0
  430. package/src/cli/index-cmd.ts +18 -22
  431. package/src/cli/index-model.ts +21 -22
  432. package/src/cli/init-client-config.ts +167 -38
  433. package/src/cli/init-model.ts +57 -2
  434. package/src/cli/init-render.ts +2 -2
  435. package/src/cli/init.ts +11 -9
  436. package/src/cli/json-document.ts +11 -0
  437. package/src/cli/main.ts +53 -6
  438. package/src/cli/migrate-local-history.ts +3 -2
  439. package/src/cli/peer-command.ts +2 -1
  440. package/src/contracts/capabilities.ts +90 -0
  441. package/src/contracts/json-object.ts +1 -11
  442. package/src/contracts/output-schema-cli.ts +36 -3
  443. package/src/contracts/output-schema-fragments.ts +52 -2
  444. package/src/contracts/output-schema-mcp.ts +219 -0
  445. package/src/contracts/output-schemas.ts +300 -6
  446. package/src/git/diff.ts +61 -0
  447. package/src/mcp/burden.ts +9 -0
  448. package/src/mcp/context.ts +5 -42
  449. package/src/mcp/daemon-server.ts +8 -1
  450. package/src/mcp/daemon-session-host.ts +4 -0
  451. package/src/mcp/daemon-stdio-bridge.ts +2 -0
  452. package/src/mcp/monitor-tick-job.ts +90 -39
  453. package/src/mcp/monitor-types.ts +1 -1
  454. package/src/mcp/persisted-local-history-graph.ts +5 -4
  455. package/src/mcp/persisted-local-history.ts +2 -2
  456. package/src/mcp/persistent-monitor-runtime.ts +37 -0
  457. package/src/mcp/repo-tool-worker-context.ts +5 -2
  458. package/src/mcp/server-context.ts +15 -2
  459. package/src/mcp/server-tool-access.ts +4 -1
  460. package/src/mcp/server.ts +8 -3
  461. package/src/mcp/tool-registry.ts +18 -0
  462. package/src/mcp/tools/code-find.ts +23 -0
  463. package/src/mcp/tools/code-show.ts +27 -0
  464. package/src/mcp/tools/diagnostic-models.ts +2 -0
  465. package/src/mcp/tools/doctor.ts +18 -1
  466. package/src/mcp/tools/export-surface-diff.ts +26 -0
  467. package/src/mcp/tools/file-outline.ts +1 -1
  468. package/src/mcp/tools/graft-edit.ts +276 -0
  469. package/src/mcp/tools/knowledge-map.ts +34 -0
  470. package/src/mcp/tools/monitor-nudge.ts +19 -0
  471. package/src/mcp/tools/precision-warp.ts +27 -16
  472. package/src/mcp/tools/refactor-difficulty.ts +42 -0
  473. package/src/mcp/tools/safe-read.ts +2 -2
  474. package/src/mcp/tools/structural-blame.ts +55 -0
  475. package/src/mcp/tools/structural-churn.ts +28 -0
  476. package/src/mcp/tools/structural-log.ts +41 -0
  477. package/src/mcp/tools/structural-review.ts +63 -0
  478. package/src/mcp/warp-pool.ts +6 -6
  479. package/src/mcp/workspace-router-model.ts +2 -2
  480. package/src/mcp/workspace-router-runtime.ts +11 -8
  481. package/src/mcp/workspace-router.ts +9 -2
  482. package/src/operations/adaptive-projection.ts +54 -0
  483. package/src/operations/agent-handoff.ts +59 -0
  484. package/src/operations/capture-range.ts +64 -0
  485. package/src/operations/conversation-primer.ts +82 -0
  486. package/src/operations/cross-session-resume.ts +104 -0
  487. package/src/operations/deterministic-replay.ts +143 -0
  488. package/src/operations/export-surface-diff.ts +355 -0
  489. package/src/operations/footprint-parallelism.ts +98 -0
  490. package/src/operations/graft-diff.ts +14 -7
  491. package/src/operations/horizon-of-readability.ts +60 -0
  492. package/src/operations/import-reference-impact.ts +143 -0
  493. package/src/operations/knowledge-map.ts +96 -0
  494. package/src/operations/observation-cache.ts +20 -4
  495. package/src/operations/projection-safety.ts +111 -0
  496. package/src/operations/repo-workspace.ts +3 -3
  497. package/src/operations/semantic-drift.ts +70 -0
  498. package/src/operations/session-filtration.ts +76 -0
  499. package/src/operations/session-replay.ts +73 -0
  500. package/src/operations/sludge-detector.ts +356 -0
  501. package/src/operations/structural-blame.ts +197 -0
  502. package/src/operations/structural-review.ts +317 -0
  503. package/src/operations/teaching-hints.ts +52 -0
  504. package/src/parser/diff.ts +7 -0
  505. package/src/ports/paths.ts +22 -0
  506. package/src/warp/ast-emitter.ts +133 -0
  507. package/src/warp/ast-import-resolver.ts +333 -0
  508. package/src/warp/commit-meta.ts +19 -0
  509. package/src/warp/context.ts +48 -0
  510. package/src/warp/dead-symbols.ts +174 -0
  511. package/src/warp/drift-sentinel.ts +101 -0
  512. package/src/warp/index-head.ts +348 -0
  513. package/src/warp/observers.ts +8 -7
  514. package/src/warp/open.ts +40 -66
  515. package/src/warp/outline-diff-trailer.ts +100 -0
  516. package/src/warp/plumbing.d.ts +11 -2
  517. package/src/warp/refactor-difficulty.ts +257 -0
  518. package/src/warp/references.ts +77 -0
  519. package/src/warp/stale-docs.ts +210 -0
  520. package/src/warp/structural-drift-detection.ts +97 -0
  521. package/src/warp/structural-queries.ts +258 -0
  522. package/src/warp/symbol-timeline.ts +209 -0
  523. package/src/warp/traverse-hydrate.ts +61 -0
  524. package/src/warp/warp-reference-count.ts +47 -0
  525. package/src/warp/warp-structural-blame.ts +65 -0
  526. package/src/warp/warp-structural-churn.ts +309 -0
  527. package/src/warp/warp-structural-log.ts +149 -0
  528. package/dist/ports/warp.d.ts +0 -45
  529. package/dist/ports/warp.d.ts.map +0 -1
  530. package/dist/ports/warp.js.map +0 -1
  531. package/dist/warp/identity-resolver.d.ts +0 -14
  532. package/dist/warp/identity-resolver.d.ts.map +0 -1
  533. package/dist/warp/identity-resolver.js +0 -31
  534. package/dist/warp/identity-resolver.js.map +0 -1
  535. package/dist/warp/indexer-git.d.ts +0 -22
  536. package/dist/warp/indexer-git.d.ts.map +0 -1
  537. package/dist/warp/indexer-git.js +0 -148
  538. package/dist/warp/indexer-git.js.map +0 -1
  539. package/dist/warp/indexer-graph.d.ts +0 -17
  540. package/dist/warp/indexer-graph.d.ts.map +0 -1
  541. package/dist/warp/indexer-graph.js +0 -179
  542. package/dist/warp/indexer-graph.js.map +0 -1
  543. package/dist/warp/indexer-model.d.ts +0 -51
  544. package/dist/warp/indexer-model.d.ts.map +0 -1
  545. package/dist/warp/indexer-model.js +0 -21
  546. package/dist/warp/indexer-model.js.map +0 -1
  547. package/dist/warp/indexer.d.ts +0 -9
  548. package/dist/warp/indexer.d.ts.map +0 -1
  549. package/dist/warp/indexer.js +0 -112
  550. package/dist/warp/indexer.js.map +0 -1
  551. package/dist/warp/symbol-identity.d.ts +0 -11
  552. package/dist/warp/symbol-identity.d.ts.map +0 -1
  553. package/dist/warp/symbol-identity.js +0 -67
  554. package/dist/warp/symbol-identity.js.map +0 -1
  555. package/src/ports/warp.ts +0 -55
  556. package/src/warp/identity-resolver.ts +0 -35
  557. package/src/warp/indexer-git.ts +0 -182
  558. package/src/warp/indexer-graph.ts +0 -276
  559. package/src/warp/indexer-model.ts +0 -69
  560. package/src/warp/indexer.ts +0 -186
  561. package/src/warp/symbol-identity.ts +0 -100
@@ -0,0 +1,348 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Index HEAD — emit compact structural facts into WARP.
3
+ //
4
+ // Also emits a commit node and commit→sym edges (adds/changes/removes)
5
+ // so the structural query layer can detect what changed between ticks.
6
+ // ---------------------------------------------------------------------------
7
+
8
+ import { Buffer } from "node:buffer";
9
+ import type { GitClient } from "../ports/git.js";
10
+ import type { PathOps } from "../ports/paths.js";
11
+ import type { WarpContext } from "./context.js";
12
+ import type { PatchBuilderV2 } from "@git-stunts/git-warp";
13
+ import { patchGraph, observeGraph, materializeGraph } from "./context.js";
14
+ import { detectLang } from "../parser/lang.js";
15
+ import { parseStructuredTree } from "../parser/runtime.js";
16
+ import { extractOutlineForFile } from "../parser/outline.js";
17
+ import { attachAstSnapshot, emitAstNodes } from "./ast-emitter.js";
18
+ import { resolveImportEdges } from "./ast-import-resolver.js";
19
+ import type { OutlineEntry } from "../parser/types.js";
20
+ import { getCommitMeta } from "./commit-meta.js";
21
+
22
+ export const DEFAULT_INDEX_MAX_FILES_PER_CALL = 64;
23
+ export const DEFAULT_INDEX_MAX_PATCH_JSON_BYTES = 2 * 1024 * 1024;
24
+
25
+ // ---------------------------------------------------------------------------
26
+ // Sym-node emission from outline entries (richer than the AST-only walker:
27
+ // includes signatures for change detection).
28
+ // ---------------------------------------------------------------------------
29
+
30
+ function emitOutlineSyms(
31
+ patch: PatchBuilderV2,
32
+ filePath: string,
33
+ entries: readonly OutlineEntry[],
34
+ jumpLookup: ReadonlyMap<string, { start: number; end: number }>,
35
+ parentPath = "",
36
+ ): Set<string> {
37
+ const emitted = new Set<string>();
38
+ const fileId = `file:${filePath}`;
39
+
40
+ for (const entry of entries) {
41
+ const symbolPath = parentPath.length > 0 ? `${parentPath}.${entry.name}` : entry.name;
42
+ const symId = `sym:${filePath}:${symbolPath}`;
43
+ emitted.add(symId);
44
+
45
+ patch.addNode(symId);
46
+ patch.setProperty(symId, "name", entry.name);
47
+ patch.setProperty(symId, "kind", entry.kind);
48
+ patch.setProperty(symId, "exported", entry.exported);
49
+ patch.setProperty(symId, "filePath", filePath);
50
+ if (entry.signature !== undefined) {
51
+ patch.setProperty(symId, "signature", entry.signature);
52
+ }
53
+ const jump = jumpLookup.get(entry.name);
54
+ if (jump !== undefined) {
55
+ patch.setProperty(symId, "startLine", jump.start);
56
+ patch.setProperty(symId, "endLine", jump.end);
57
+ }
58
+ patch.addEdge(fileId, symId, "contains");
59
+
60
+ if (entry.children !== undefined && entry.children.length > 0) {
61
+ for (const childId of emitOutlineSyms(patch, filePath, entry.children, jumpLookup, symbolPath)) {
62
+ emitted.add(childId);
63
+ }
64
+ }
65
+ }
66
+ return emitted;
67
+ }
68
+
69
+
70
+ // ---------------------------------------------------------------------------
71
+ // Directory chain emission (inlined from indexer-graph.ts to avoid dep on
72
+ // the legacy indexer module).
73
+ // ---------------------------------------------------------------------------
74
+
75
+ function emitDirectoryChain(patch: PatchBuilderV2, filePath: string): void {
76
+ const parts = filePath.split("/");
77
+ if (parts.length <= 1) return;
78
+
79
+ let current = "";
80
+ for (let index = 0; index < parts.length - 1; index++) {
81
+ const parent = current;
82
+ const part = parts[index] ?? "";
83
+ current = current.length > 0 ? `${current}/${part}` : part;
84
+ const dirId = `dir:${current}`;
85
+ patch.addNode(dirId);
86
+ patch.setProperty(dirId, "path", current);
87
+
88
+ if (parent.length > 0) {
89
+ patch.addEdge(`dir:${parent}`, dirId, "contains");
90
+ }
91
+ }
92
+
93
+ patch.addEdge(`dir:${current}`, `file:${filePath}`, "contains");
94
+ }
95
+
96
+ // ---------------------------------------------------------------------------
97
+ // Public API
98
+ // ---------------------------------------------------------------------------
99
+
100
+ export interface IndexHeadOptions {
101
+ readonly cwd: string;
102
+ readonly git: GitClient;
103
+ readonly pathOps: PathOps;
104
+ readonly ctx: WarpContext;
105
+ readonly paths?: readonly string[] | undefined;
106
+ readonly maxFilesPerCall?: number | undefined;
107
+ readonly maxPatchJsonBytes?: number | undefined;
108
+ }
109
+
110
+ export interface IndexHeadResult {
111
+ readonly ok: true;
112
+ readonly filesIndexed: number;
113
+ readonly nodesEmitted: number;
114
+ }
115
+
116
+ interface HeadCommitMetadata {
117
+ readonly message: string;
118
+ readonly author: string;
119
+ readonly email: string;
120
+ readonly timestamp: string;
121
+ }
122
+
123
+ /**
124
+ * Index the current HEAD by writing one bounded patch per file.
125
+ *
126
+ * Full tree-sitter syntax is attached as file-node blob content. The graph
127
+ * itself only stores compact query facts: files, symbols, import/reference
128
+ * anchors, directories, and commit-to-symbol touch edges.
129
+ *
130
+ * Emits a `commit:{sha}` node with edges to sym nodes labelled
131
+ * "adds", "changes", or "removes" so structural queries can detect
132
+ * what changed between ticks.
133
+ */
134
+ export async function indexHead(opts: IndexHeadOptions): Promise<IndexHeadResult> {
135
+ const { cwd, git, pathOps, ctx } = opts;
136
+ const maxFilesPerCall = opts.maxFilesPerCall ?? DEFAULT_INDEX_MAX_FILES_PER_CALL;
137
+ const maxPatchJsonBytes = opts.maxPatchJsonBytes ?? DEFAULT_INDEX_MAX_PATCH_JSON_BYTES;
138
+
139
+ const headResult = await git.run({ args: ["rev-parse", "HEAD"], cwd });
140
+ if (headResult.status !== 0) {
141
+ throw new Error(`git rev-parse HEAD failed: ${headResult.stderr}`);
142
+ }
143
+ const headSha = headResult.stdout.trim();
144
+ const commitMeta = await getCommitMeta(git, headSha, cwd);
145
+
146
+ const allFiles = await listTrackedFiles(cwd, git);
147
+ const knownFiles = new Set(allFiles);
148
+ const parseableFiles = selectParseableFiles(allFiles, opts.paths);
149
+
150
+ if (parseableFiles.length > maxFilesPerCall) {
151
+ throw new Error(
152
+ `indexHead refused to index ${String(parseableFiles.length)} files in one call. ` +
153
+ `Lazy indexing policy allows at most ${String(maxFilesPerCall)} files; ` +
154
+ `pass explicit paths or index on read.`,
155
+ );
156
+ }
157
+
158
+ let filesIndexed = 0;
159
+ for (const filePath of parseableFiles) {
160
+ const indexed = await indexHeadFile({
161
+ cwd,
162
+ git,
163
+ pathOps,
164
+ ctx,
165
+ headSha,
166
+ commitMeta,
167
+ knownFiles,
168
+ filePath,
169
+ maxPatchJsonBytes,
170
+ });
171
+ if (indexed) filesIndexed++;
172
+ }
173
+
174
+ return { ok: true, filesIndexed, nodesEmitted: filesIndexed };
175
+ }
176
+
177
+ // ---------------------------------------------------------------------------
178
+ // Helpers
179
+ // ---------------------------------------------------------------------------
180
+
181
+ function collectSymIds(
182
+ target: Map<string, string | undefined>,
183
+ filePath: string,
184
+ entries: readonly OutlineEntry[],
185
+ parentPath = "",
186
+ ): void {
187
+ for (const entry of entries) {
188
+ const symbolPath = parentPath.length > 0 ? `${parentPath}.${entry.name}` : entry.name;
189
+ target.set(`sym:${filePath}:${symbolPath}`, entry.signature);
190
+ if (entry.children !== undefined && entry.children.length > 0) {
191
+ collectSymIds(target, filePath, entry.children, symbolPath);
192
+ }
193
+ }
194
+ }
195
+
196
+ async function listTrackedFiles(cwd: string, git: GitClient): Promise<readonly string[]> {
197
+ const result = await git.run({ args: ["ls-files"], cwd });
198
+ if (result.status !== 0) {
199
+ throw new Error(`git ls-files failed: ${result.stderr}`);
200
+ }
201
+ return result.stdout.trim().split("\n").filter((filePath) => filePath.length > 0);
202
+ }
203
+
204
+ function selectParseableFiles(
205
+ allFiles: readonly string[],
206
+ requestedPaths: readonly string[] | undefined,
207
+ ): readonly string[] {
208
+ const tracked = new Set(allFiles);
209
+ const candidates = requestedPaths !== undefined && requestedPaths.length > 0
210
+ ? requestedPaths.map((filePath) => filePath.trim()).filter((filePath) => filePath.length > 0 && tracked.has(filePath))
211
+ : allFiles;
212
+
213
+ return candidates.filter((filePath) => detectLang(filePath) !== null);
214
+ }
215
+
216
+ async function readPriorSymsForFile(
217
+ ctx: WarpContext,
218
+ filePath: string,
219
+ ): Promise<Map<string, string | undefined>> {
220
+ const priorSyms = new Map<string, string | undefined>();
221
+ const priorObs = await observeGraph(ctx, { match: `sym:${filePath}:*`, expose: ["signature"] });
222
+ const priorNodes = await priorObs.getNodes();
223
+ for (const nodeId of priorNodes) {
224
+ const props = await priorObs.getNodeProps(nodeId);
225
+ const sig = typeof props?.["signature"] === "string" ? props["signature"] : undefined;
226
+ priorSyms.set(nodeId, sig);
227
+ }
228
+ return priorSyms;
229
+ }
230
+
231
+ async function readPriorAstAnchorsForFile(
232
+ ctx: WarpContext,
233
+ filePath: string,
234
+ ): Promise<readonly string[]> {
235
+ const obs = await observeGraph(ctx, { match: `ast:${filePath}:*`, expose: [] });
236
+ return obs.getNodes();
237
+ }
238
+
239
+ function patchJsonByteLength(patch: PatchBuilderV2): number {
240
+ return Buffer.byteLength(JSON.stringify(patch.build()), "utf8");
241
+ }
242
+
243
+ function assertPatchWithinBudget(
244
+ patch: PatchBuilderV2,
245
+ filePath: string,
246
+ maxPatchJsonBytes: number,
247
+ ): void {
248
+ const bytes = patchJsonByteLength(patch);
249
+ if (bytes > maxPatchJsonBytes) {
250
+ throw new Error(
251
+ `indexHead refused to write ${filePath}: estimated patch payload ${String(bytes)} bytes ` +
252
+ `exceeds ${String(maxPatchJsonBytes)} bytes. Index smaller slices or attach bulky data as blobs.`,
253
+ );
254
+ }
255
+ }
256
+
257
+ async function indexHeadFile(input: {
258
+ readonly cwd: string;
259
+ readonly git: GitClient;
260
+ readonly pathOps: PathOps;
261
+ readonly ctx: WarpContext;
262
+ readonly headSha: string;
263
+ readonly commitMeta: HeadCommitMetadata;
264
+ readonly knownFiles: ReadonlySet<string>;
265
+ readonly filePath: string;
266
+ readonly maxPatchJsonBytes: number;
267
+ }): Promise<boolean> {
268
+ const { cwd, git, pathOps, ctx, headSha, commitMeta, knownFiles, filePath, maxPatchJsonBytes } = input;
269
+ const lang = detectLang(filePath);
270
+ if (lang === null) return false;
271
+
272
+ const contentResult = await git.run({ args: ["show", `HEAD:${filePath}`], cwd });
273
+ if (contentResult.status !== 0) return false;
274
+
275
+ const tree = parseStructuredTree(lang, contentResult.stdout);
276
+ try {
277
+ const outlineResult = extractOutlineForFile(filePath, contentResult.stdout);
278
+ const outline = outlineResult?.entries ?? [];
279
+ const jumpLookup = new Map<string, { start: number; end: number }>();
280
+ for (const jt of outlineResult?.jumpTable ?? []) {
281
+ jumpLookup.set(jt.symbol, { start: jt.start, end: jt.end });
282
+ }
283
+
284
+ const currentSyms = new Map<string, string | undefined>();
285
+ collectSymIds(currentSyms, filePath, outline);
286
+
287
+ let priorSyms = new Map<string, string | undefined>();
288
+ let priorAstAnchors: readonly string[] = [];
289
+ try {
290
+ await materializeGraph(ctx);
291
+ priorSyms = await readPriorSymsForFile(ctx, filePath);
292
+ priorAstAnchors = await readPriorAstAnchorsForFile(ctx, filePath);
293
+ } catch {
294
+ // No prior state: first lazy index writes adds only.
295
+ }
296
+
297
+ await patchGraph(ctx, async (patch) => {
298
+ const tick = patch.build().lamport;
299
+ const commitId = `commit:${headSha}`;
300
+ const fileId = `file:${filePath}`;
301
+
302
+ patch.addNode(commitId);
303
+ patch.setProperty(commitId, "sha", headSha);
304
+ patch.setProperty(commitId, "tick", tick);
305
+ patch.setProperty(commitId, "message", commitMeta.message);
306
+ patch.setProperty(commitId, "author", commitMeta.author);
307
+ patch.setProperty(commitId, "email", commitMeta.email);
308
+ patch.setProperty(commitId, "date", commitMeta.timestamp);
309
+ patch.setProperty(commitId, "timestamp", commitMeta.timestamp);
310
+
311
+ patch.addNode(fileId);
312
+ patch.setProperty(fileId, "path", filePath);
313
+ patch.setProperty(fileId, "lang", lang);
314
+ patch.setProperty(fileId, "indexedCommit", headSha);
315
+ patch.addEdge(commitId, fileId, "touches");
316
+
317
+ emitDirectoryChain(patch, filePath);
318
+ for (const anchorId of priorAstAnchors) {
319
+ patch.removeNode(anchorId);
320
+ }
321
+ emitOutlineSyms(patch, filePath, outline, jumpLookup);
322
+ emitAstNodes(patch, filePath, tree.root);
323
+ resolveImportEdges(patch, filePath, tree.root, pathOps, knownFiles);
324
+ await attachAstSnapshot(patch, filePath, tree.root);
325
+
326
+ for (const [symId, sig] of currentSyms) {
327
+ if (!priorSyms.has(symId)) {
328
+ patch.addEdge(commitId, symId, "adds");
329
+ } else if (priorSyms.get(symId) !== sig) {
330
+ patch.addEdge(commitId, symId, "changes");
331
+ }
332
+ }
333
+
334
+ for (const symId of priorSyms.keys()) {
335
+ if (!currentSyms.has(symId)) {
336
+ patch.addEdge(commitId, symId, "removes");
337
+ patch.removeNode(symId);
338
+ }
339
+ }
340
+
341
+ assertPatchWithinBudget(patch, filePath, maxPatchJsonBytes);
342
+ });
343
+
344
+ return true;
345
+ } finally {
346
+ tree.delete();
347
+ }
348
+ }
@@ -5,14 +5,15 @@
5
5
  * walks the graph directly, maintains shadow state, or implements
6
6
  * traversal algorithms.
7
7
  *
8
- * Each function returns an observer with a focused lens. The lens
9
- * determines the aperture — what the observer can see.
8
+ * Each function returns a lens or an observer with a focused lens.
9
+ * The lens determines the aperture — what the observer can see.
10
10
  */
11
11
 
12
- import type { WarpHandle, WarpObserver, WarpObserverLens } from "../ports/warp.js";
12
+ import type { Lens, Observer } from "@git-stunts/git-warp";
13
+ import type { WarpContext } from "./context.js";
14
+ import { observeGraph } from "./context.js";
13
15
 
14
- /** Lens config for creating focused observers. */
15
- export type Lens = WarpObserverLens;
16
+ export type { Lens };
16
17
 
17
18
  /**
18
19
  * Observe all symbols in a specific file.
@@ -95,6 +96,6 @@ export function commitsLens(): Lens {
95
96
  * Create an observer on the current frontier with a given lens.
96
97
  * Observers are static snapshots — create a new one after writes.
97
98
  */
98
- export function observe(warp: WarpHandle, lens: Lens): Promise<WarpObserver> {
99
- return warp.observer(lens);
99
+ export function observe(ctx: WarpContext, lens: Lens): Promise<Observer> {
100
+ return observeGraph(ctx, lens);
100
101
  }
package/src/warp/open.ts CHANGED
@@ -2,92 +2,66 @@
2
2
  * WARP graph initialization — opens the graft-ast graph backed by
3
3
  * the repo's own .git directory.
4
4
  *
5
- * Single entry point. Returns a WARP port handle ready for patch
6
- * writes and observer reads.
5
+ * Sole construction adapter. After this, git-warp types flow directly.
7
6
  */
8
7
 
9
- import RawWarpApp, { GitGraphAdapter } from "@git-stunts/git-warp";
8
+ import WarpApp, { GitGraphAdapter } from "@git-stunts/git-warp";
10
9
  import GitPlumbing from "@git-stunts/plumbing";
11
- import type {
12
- WarpHandle,
13
- WarpMaterializeReceipt,
14
- WarpObserver,
15
- WarpObserverLens,
16
- WarpObserverOptions,
17
- WarpPatchBuilder,
18
- } from "../ports/warp.js";
19
10
  import { DEFAULT_WARP_WRITER_ID } from "./writer-id.js";
20
11
 
21
12
  export const GRAPH_NAME = "graft-ast";
13
+ export const DEFAULT_WARP_CHECKPOINT_EVERY = 128;
14
+ const WARP_GIT_MAX_BUFFER_BYTES = 128 * 1024 * 1024;
22
15
 
23
- export interface OpenWarpOptions {
24
- readonly cwd: string;
25
- readonly writerId?: string;
16
+ interface GitExecuteOptions {
17
+ readonly args: string[];
18
+ readonly input?: string | Uint8Array;
19
+ readonly env?: Record<string, string>;
20
+ readonly maxBytes?: number;
26
21
  }
27
22
 
28
- function toRawLens(lens: WarpObserverLens): {
29
- match: string | string[];
30
- expose?: string[];
31
- redact?: string[];
32
- } {
33
- return {
34
- match: typeof lens.match === "string" ? lens.match : [...lens.match],
35
- ...(lens.expose !== undefined ? { expose: [...lens.expose] } : {}),
36
- ...(lens.redact !== undefined ? { redact: [...lens.redact] } : {}),
37
- };
23
+ interface GitStreamLike {
24
+ readonly finished: Promise<{ code: number; stderr: string; error?: Error | undefined }>;
25
+ collect(opts?: { maxBytes?: number; asString?: boolean; encoding?: string }): Promise<Uint8Array | string>;
26
+ [Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
38
27
  }
39
28
 
40
- function toRawObserverOptions(options: WarpObserverOptions | undefined): {
41
- source?: { kind: "live"; ceiling: number | null };
42
- } | undefined {
43
- if (options === undefined) {
44
- return undefined;
45
- }
46
- if (options.source === undefined) {
47
- return {};
48
- }
49
- return {
50
- source: {
51
- kind: options.source.kind,
52
- ceiling: options.source.ceiling,
53
- },
54
- };
29
+ function raiseWarpGitBufferLimit(plumbing: GitPlumbing): GitPlumbing {
30
+ const execute = plumbing.execute.bind(plumbing);
31
+ plumbing.execute = ((options: GitExecuteOptions) => execute({
32
+ ...options,
33
+ maxBytes: options.maxBytes ?? WARP_GIT_MAX_BUFFER_BYTES,
34
+ })) as GitPlumbing["execute"];
35
+
36
+ const executeStream = plumbing.executeStream.bind(plumbing);
37
+ plumbing.executeStream = (async (options: { args: string[]; input?: string | Uint8Array; env?: Record<string, string> }) => {
38
+ const stream = await executeStream(options);
39
+ const collect = stream.collect.bind(stream);
40
+ stream.collect = (opts = {}) => collect({
41
+ ...opts,
42
+ maxBytes: opts.maxBytes ?? WARP_GIT_MAX_BUFFER_BYTES,
43
+ });
44
+ return stream as GitStreamLike;
45
+ }) as GitPlumbing["executeStream"];
46
+
47
+ return plumbing;
55
48
  }
56
49
 
57
- function wrapWarpApp(app: RawWarpApp): WarpHandle {
58
- return {
59
- async hasNode(nodeId: string): Promise<boolean> {
60
- const observer = await app.observer({ match: nodeId });
61
- const nodes = await observer.getNodes();
62
- return nodes.includes(nodeId);
63
- },
64
- observer(lens, options): Promise<WarpObserver> {
65
- return app.observer(toRawLens(lens), toRawObserverOptions(options)) as Promise<WarpObserver>;
66
- },
67
- patch(build): Promise<string> {
68
- return app.patch((patch) => build(patch as unknown as WarpPatchBuilder));
69
- },
70
- async materialize(): Promise<void> {
71
- await app.core().materialize();
72
- },
73
- async materializeReceipts(): Promise<readonly WarpMaterializeReceipt[]> {
74
- const { receipts } = await app.core().materialize({ receipts: true });
75
- return receipts as readonly WarpMaterializeReceipt[];
76
- },
77
- };
50
+ export interface OpenWarpOptions {
51
+ readonly cwd: string;
52
+ readonly writerId?: string;
53
+ readonly checkpointEvery?: number;
78
54
  }
79
55
 
80
- export async function openWarp(options: OpenWarpOptions): Promise<WarpHandle> {
81
- // createDefault() wires the ShellRunnerFactory (required port)
82
- const plumbing = GitPlumbing.createDefault({ cwd: options.cwd });
56
+ export async function openWarp(options: OpenWarpOptions): Promise<WarpApp> {
57
+ const plumbing = raiseWarpGitBufferLimit(GitPlumbing.createDefault({ cwd: options.cwd }));
83
58
  const persistence = new GitGraphAdapter({ plumbing });
84
59
 
85
- const app = await RawWarpApp.open({
60
+ return WarpApp.open({
86
61
  persistence,
87
62
  graphName: GRAPH_NAME,
88
63
  writerId: options.writerId ?? DEFAULT_WARP_WRITER_ID,
64
+ checkpointPolicy: { every: options.checkpointEvery ?? DEFAULT_WARP_CHECKPOINT_EVERY },
89
65
  onDeleteWithData: "cascade",
90
66
  });
91
-
92
- return wrapWarpApp(app);
93
67
  }
@@ -0,0 +1,100 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Outline Diff Commit Trailer — structural summary in git commit messages
3
+ // ---------------------------------------------------------------------------
4
+
5
+ /** A single symbol change to include in the trailer. */
6
+ export interface SymbolDiffEntry {
7
+ readonly name: string;
8
+ readonly kind: string;
9
+ readonly changeKind: "added" | "removed" | "changed";
10
+ }
11
+
12
+ /** Options for trailer formatting. */
13
+ export interface TrailerOptions {
14
+ /** Maximum entries before truncation. Default: 20. */
15
+ readonly maxEntries?: number;
16
+ }
17
+
18
+ /** Short kind abbreviations for the trailer format. */
19
+ const KIND_ABBREV: Readonly<Record<string, string>> = {
20
+ function: "fn",
21
+ class: "class",
22
+ interface: "iface",
23
+ type: "type",
24
+ variable: "var",
25
+ method: "method",
26
+ property: "prop",
27
+ };
28
+
29
+ function abbrevKind(kind: string): string {
30
+ return KIND_ABBREV[kind] ?? kind;
31
+ }
32
+
33
+ /**
34
+ * Format a list of symbol changes as a Git commit trailer.
35
+ *
36
+ * Format: `Structural-Diff: added fn:X; removed class:Y; changed fn:Z`
37
+ *
38
+ * Returns empty string if there are no changes.
39
+ */
40
+ export function formatStructuralDiffTrailer(
41
+ entries: readonly SymbolDiffEntry[],
42
+ options?: TrailerOptions,
43
+ ): string {
44
+ if (entries.length === 0) return "";
45
+
46
+ const max = options?.maxEntries ?? 20;
47
+ const display = entries.slice(0, max);
48
+ const parts = display.map(
49
+ (e) => `${e.changeKind} ${abbrevKind(e.kind)}:${e.name}`,
50
+ );
51
+
52
+ let trailer = `Structural-Diff: ${parts.join("; ")}`;
53
+
54
+ if (entries.length > max) {
55
+ trailer += `; ... (${String(entries.length)} total)`;
56
+ }
57
+
58
+ return trailer;
59
+ }
60
+
61
+ // ---------------------------------------------------------------------------
62
+ // Parser
63
+ // ---------------------------------------------------------------------------
64
+
65
+ const TRAILER_PREFIX = "Structural-Diff:";
66
+
67
+ const ENTRY_RE = /^(added|removed|changed)\s+(\w+):(\w+)$/;
68
+
69
+ /**
70
+ * Parse a Structural-Diff trailer back into structured entries.
71
+ *
72
+ * Skips malformed entries gracefully.
73
+ */
74
+ export function parseStructuralDiffTrailer(text: string): SymbolDiffEntry[] {
75
+ const idx = text.indexOf(TRAILER_PREFIX);
76
+ if (idx === -1) return [];
77
+
78
+ const body = text.slice(idx + TRAILER_PREFIX.length).trim();
79
+ const parts = body.split(";").map((p) => p.trim());
80
+ const results: SymbolDiffEntry[] = [];
81
+
82
+ for (const part of parts) {
83
+ if (part.startsWith("...")) continue;
84
+ const match = ENTRY_RE.exec(part);
85
+ if (match === null) continue;
86
+
87
+ const changeKind = match[1] as "added" | "removed" | "changed";
88
+ const abbrev = match[2] ?? "unknown";
89
+ const name = match[3] ?? "unknown";
90
+
91
+ // Reverse the abbreviation
92
+ const kind = Object.entries(KIND_ABBREV).find(
93
+ ([, v]) => v === abbrev,
94
+ )?.[0] ?? abbrev;
95
+
96
+ results.push({ name, kind, changeKind });
97
+ }
98
+
99
+ return results;
100
+ }
@@ -5,8 +5,17 @@ declare module "@git-stunts/plumbing" {
5
5
  readonly emptyTree: string;
6
6
  constructor(options: { runner: unknown; cwd?: string });
7
7
  static createDefault(options?: { cwd?: string; env?: string }): GitPlumbing;
8
- execute(options: { args: string[]; input?: string | Uint8Array }): Promise<string>;
9
- executeStream(options: { args: string[] }): Promise<{
8
+ execute(options: {
9
+ args: string[];
10
+ input?: string | Uint8Array;
11
+ env?: Record<string, string>;
12
+ maxBytes?: number;
13
+ }): Promise<string>;
14
+ executeStream(options: {
15
+ args: string[];
16
+ input?: string | Uint8Array;
17
+ env?: Record<string, string>;
18
+ }): Promise<{
10
19
  finished: Promise<{ code: number; stderr: string; error?: Error }>;
11
20
  collect(opts?: { maxBytes?: number; asString?: boolean; encoding?: string }): Promise<Uint8Array | string>;
12
21
  [Symbol.asyncIterator](): AsyncIterator<Uint8Array>;