ctxr-cli 0.33.0 → 0.35.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 (378) hide show
  1. package/README.md +40 -6
  2. package/dist/commands/archive.d.ts +5 -4
  3. package/dist/commands/archive.d.ts.map +1 -1
  4. package/dist/commands/archive.js +7 -7
  5. package/dist/commands/archive.js.map +1 -1
  6. package/dist/commands/catalog-show.d.ts +8 -0
  7. package/dist/commands/catalog-show.d.ts.map +1 -1
  8. package/dist/commands/catalog-show.js +29 -2
  9. package/dist/commands/catalog-show.js.map +1 -1
  10. package/dist/commands/context-gather.d.ts.map +1 -1
  11. package/dist/commands/context-gather.js +3 -2
  12. package/dist/commands/context-gather.js.map +1 -1
  13. package/dist/commands/doctor.d.ts +5 -1
  14. package/dist/commands/doctor.d.ts.map +1 -1
  15. package/dist/commands/doctor.js +4 -0
  16. package/dist/commands/doctor.js.map +1 -1
  17. package/dist/commands/graph-build.d.ts +4 -1
  18. package/dist/commands/graph-build.d.ts.map +1 -1
  19. package/dist/commands/graph-build.js +14 -5
  20. package/dist/commands/graph-build.js.map +1 -1
  21. package/dist/commands/land.d.ts +27 -7
  22. package/dist/commands/land.d.ts.map +1 -1
  23. package/dist/commands/land.js +307 -32
  24. package/dist/commands/land.js.map +1 -1
  25. package/dist/commands/plugin-build.d.ts +33 -0
  26. package/dist/commands/plugin-build.d.ts.map +1 -0
  27. package/dist/commands/plugin-build.js +51 -0
  28. package/dist/commands/plugin-build.js.map +1 -0
  29. package/dist/commands/publish-check.d.ts.map +1 -1
  30. package/dist/commands/publish-check.js +35 -4
  31. package/dist/commands/publish-check.js.map +1 -1
  32. package/dist/commands/publish-gather.d.ts.map +1 -1
  33. package/dist/commands/publish-gather.js +2 -3
  34. package/dist/commands/publish-gather.js.map +1 -1
  35. package/dist/commands/review-list.d.ts +19 -5
  36. package/dist/commands/review-list.d.ts.map +1 -1
  37. package/dist/commands/review-list.js +55 -6
  38. package/dist/commands/review-list.js.map +1 -1
  39. package/dist/commands/rollup-gather.d.ts.map +1 -1
  40. package/dist/commands/rollup-gather.js +2 -3
  41. package/dist/commands/rollup-gather.js.map +1 -1
  42. package/dist/commands/second-opinion.d.ts +33 -0
  43. package/dist/commands/second-opinion.d.ts.map +1 -0
  44. package/dist/commands/second-opinion.js +56 -0
  45. package/dist/commands/second-opinion.js.map +1 -0
  46. package/dist/commands/serve.d.ts.map +1 -1
  47. package/dist/commands/serve.js +14 -2
  48. package/dist/commands/serve.js.map +1 -1
  49. package/dist/commands/session-discard.d.ts +18 -0
  50. package/dist/commands/session-discard.d.ts.map +1 -0
  51. package/dist/commands/session-discard.js +31 -0
  52. package/dist/commands/session-discard.js.map +1 -0
  53. package/dist/commands/session-list.d.ts +17 -6
  54. package/dist/commands/session-list.d.ts.map +1 -1
  55. package/dist/commands/session-list.js +31 -11
  56. package/dist/commands/session-list.js.map +1 -1
  57. package/dist/commands/session-rebase.d.ts +18 -0
  58. package/dist/commands/session-rebase.d.ts.map +1 -0
  59. package/dist/commands/session-rebase.js +43 -0
  60. package/dist/commands/session-rebase.js.map +1 -0
  61. package/dist/commands/session-start.d.ts +8 -0
  62. package/dist/commands/session-start.d.ts.map +1 -1
  63. package/dist/commands/session-start.js +52 -38
  64. package/dist/commands/session-start.js.map +1 -1
  65. package/dist/commands/session-status.d.ts +17 -0
  66. package/dist/commands/session-status.d.ts.map +1 -0
  67. package/dist/commands/session-status.js +38 -0
  68. package/dist/commands/session-status.js.map +1 -0
  69. package/dist/commands/session-submit.d.ts +23 -0
  70. package/dist/commands/session-submit.d.ts.map +1 -0
  71. package/dist/commands/session-submit.js +42 -0
  72. package/dist/commands/session-submit.js.map +1 -0
  73. package/dist/commands/shared-stores-status.d.ts +24 -0
  74. package/dist/commands/shared-stores-status.d.ts.map +1 -0
  75. package/dist/commands/shared-stores-status.js +51 -0
  76. package/dist/commands/shared-stores-status.js.map +1 -0
  77. package/dist/commands/shared-stores-sync.d.ts +27 -0
  78. package/dist/commands/shared-stores-sync.d.ts.map +1 -0
  79. package/dist/commands/shared-stores-sync.js +115 -0
  80. package/dist/commands/shared-stores-sync.js.map +1 -0
  81. package/dist/commands/verify.d.ts.map +1 -1
  82. package/dist/commands/verify.js +2 -4
  83. package/dist/commands/verify.js.map +1 -1
  84. package/dist/config/schema.d.ts +16 -0
  85. package/dist/config/schema.d.ts.map +1 -1
  86. package/dist/config/schema.js +32 -0
  87. package/dist/config/schema.js.map +1 -1
  88. package/dist/core/agents-doc.d.ts +10 -0
  89. package/dist/core/agents-doc.d.ts.map +1 -1
  90. package/dist/core/agents-doc.js +26 -1
  91. package/dist/core/agents-doc.js.map +1 -1
  92. package/dist/core/approval/decision.d.ts +39 -1
  93. package/dist/core/approval/decision.d.ts.map +1 -1
  94. package/dist/core/approval/decision.js +53 -6
  95. package/dist/core/approval/decision.js.map +1 -1
  96. package/dist/core/approval/session-group.d.ts +156 -0
  97. package/dist/core/approval/session-group.d.ts.map +1 -0
  98. package/dist/core/approval/session-group.js +359 -0
  99. package/dist/core/approval/session-group.js.map +1 -0
  100. package/dist/core/approval/session-marker.d.ts +79 -0
  101. package/dist/core/approval/session-marker.d.ts.map +1 -0
  102. package/dist/core/approval/session-marker.js +146 -0
  103. package/dist/core/approval/session-marker.js.map +1 -0
  104. package/dist/core/approval/store-forges.d.ts +15 -0
  105. package/dist/core/approval/store-forges.d.ts.map +1 -0
  106. package/dist/core/approval/store-forges.js +33 -0
  107. package/dist/core/approval/store-forges.js.map +1 -0
  108. package/dist/core/browse/approve.d.ts +8 -0
  109. package/dist/core/browse/approve.d.ts.map +1 -1
  110. package/dist/core/browse/approve.js +366 -48
  111. package/dist/core/browse/approve.js.map +1 -1
  112. package/dist/core/browse/link-resolver.d.ts +9 -4
  113. package/dist/core/browse/link-resolver.d.ts.map +1 -1
  114. package/dist/core/browse/link-resolver.js +12 -7
  115. package/dist/core/browse/link-resolver.js.map +1 -1
  116. package/dist/core/browse/review.d.ts +5 -0
  117. package/dist/core/browse/review.d.ts.map +1 -1
  118. package/dist/core/browse/review.js +8 -0
  119. package/dist/core/browse/review.js.map +1 -1
  120. package/dist/core/checks/integrity-checks.d.ts.map +1 -1
  121. package/dist/core/checks/integrity-checks.js +7 -1
  122. package/dist/core/checks/integrity-checks.js.map +1 -1
  123. package/dist/core/checks/manifest.d.ts.map +1 -1
  124. package/dist/core/checks/manifest.js +2 -0
  125. package/dist/core/checks/manifest.js.map +1 -1
  126. package/dist/core/checks/shared-stores-checks.d.ts +17 -0
  127. package/dist/core/checks/shared-stores-checks.d.ts.map +1 -0
  128. package/dist/core/checks/shared-stores-checks.js +84 -0
  129. package/dist/core/checks/shared-stores-checks.js.map +1 -0
  130. package/dist/core/errors.d.ts +17 -0
  131. package/dist/core/errors.d.ts.map +1 -1
  132. package/dist/core/errors.js +21 -0
  133. package/dist/core/errors.js.map +1 -1
  134. package/dist/core/forge/github.d.ts +14 -0
  135. package/dist/core/forge/github.d.ts.map +1 -1
  136. package/dist/core/forge/github.js +17 -0
  137. package/dist/core/forge/github.js.map +1 -1
  138. package/dist/core/fs/atomic.d.ts +3 -2
  139. package/dist/core/fs/atomic.d.ts.map +1 -1
  140. package/dist/core/fs/atomic.js +3 -2
  141. package/dist/core/fs/atomic.js.map +1 -1
  142. package/dist/core/git/fast-forward.d.ts +23 -0
  143. package/dist/core/git/fast-forward.d.ts.map +1 -0
  144. package/dist/core/git/fast-forward.js +38 -0
  145. package/dist/core/git/fast-forward.js.map +1 -0
  146. package/dist/core/git/repo.d.ts +11 -0
  147. package/dist/core/git/repo.d.ts.map +1 -1
  148. package/dist/core/git/repo.js +25 -0
  149. package/dist/core/git/repo.js.map +1 -1
  150. package/dist/core/graph/model.d.ts +27 -0
  151. package/dist/core/graph/model.d.ts.map +1 -1
  152. package/dist/core/graph/model.js +68 -2
  153. package/dist/core/graph/model.js.map +1 -1
  154. package/dist/core/graph/persist.d.ts.map +1 -1
  155. package/dist/core/graph/persist.js +3 -2
  156. package/dist/core/graph/persist.js.map +1 -1
  157. package/dist/core/mcp/cli-runner.d.ts +41 -0
  158. package/dist/core/mcp/cli-runner.d.ts.map +1 -0
  159. package/dist/core/mcp/cli-runner.js +81 -0
  160. package/dist/core/mcp/cli-runner.js.map +1 -0
  161. package/dist/core/mcp/jsonrpc.d.ts +13 -1
  162. package/dist/core/mcp/jsonrpc.d.ts.map +1 -1
  163. package/dist/core/mcp/jsonrpc.js +1 -1
  164. package/dist/core/mcp/jsonrpc.js.map +1 -1
  165. package/dist/core/mcp/member-sessions.d.ts +48 -0
  166. package/dist/core/mcp/member-sessions.d.ts.map +1 -0
  167. package/dist/core/mcp/member-sessions.js +85 -0
  168. package/dist/core/mcp/member-sessions.js.map +1 -0
  169. package/dist/core/mcp/ownership.d.ts +51 -0
  170. package/dist/core/mcp/ownership.d.ts.map +1 -0
  171. package/dist/core/mcp/ownership.js +101 -0
  172. package/dist/core/mcp/ownership.js.map +1 -0
  173. package/dist/core/mcp/paths.d.ts +48 -0
  174. package/dist/core/mcp/paths.d.ts.map +1 -0
  175. package/dist/core/mcp/paths.js +111 -0
  176. package/dist/core/mcp/paths.js.map +1 -0
  177. package/dist/core/mcp/sessions.d.ts +25 -50
  178. package/dist/core/mcp/sessions.d.ts.map +1 -1
  179. package/dist/core/mcp/sessions.js +31 -123
  180. package/dist/core/mcp/sessions.js.map +1 -1
  181. package/dist/core/mcp/tool-map.d.ts +94 -0
  182. package/dist/core/mcp/tool-map.d.ts.map +1 -0
  183. package/dist/core/mcp/tool-map.js +211 -0
  184. package/dist/core/mcp/tool-map.js.map +1 -0
  185. package/dist/core/mcp/tools/capture.d.ts +7 -2
  186. package/dist/core/mcp/tools/capture.d.ts.map +1 -1
  187. package/dist/core/mcp/tools/capture.js +69 -18
  188. package/dist/core/mcp/tools/capture.js.map +1 -1
  189. package/dist/core/mcp/tools/cli.d.ts +97 -0
  190. package/dist/core/mcp/tools/cli.d.ts.map +1 -0
  191. package/dist/core/mcp/tools/cli.js +271 -0
  192. package/dist/core/mcp/tools/cli.js.map +1 -0
  193. package/dist/core/mcp/tools/edit.d.ts +62 -28
  194. package/dist/core/mcp/tools/edit.d.ts.map +1 -1
  195. package/dist/core/mcp/tools/edit.js +182 -153
  196. package/dist/core/mcp/tools/edit.js.map +1 -1
  197. package/dist/core/mcp/tools/files.d.ts +37 -11
  198. package/dist/core/mcp/tools/files.d.ts.map +1 -1
  199. package/dist/core/mcp/tools/files.js +122 -100
  200. package/dist/core/mcp/tools/files.js.map +1 -1
  201. package/dist/core/mcp/tools/index.d.ts +12 -3
  202. package/dist/core/mcp/tools/index.d.ts.map +1 -1
  203. package/dist/core/mcp/tools/index.js +161 -58
  204. package/dist/core/mcp/tools/index.js.map +1 -1
  205. package/dist/core/mcp/tools/sessions.d.ts +145 -0
  206. package/dist/core/mcp/tools/sessions.d.ts.map +1 -0
  207. package/dist/core/mcp/tools/sessions.js +226 -0
  208. package/dist/core/mcp/tools/sessions.js.map +1 -0
  209. package/dist/core/notes/list.d.ts.map +1 -1
  210. package/dist/core/notes/list.js +5 -0
  211. package/dist/core/notes/list.js.map +1 -1
  212. package/dist/core/plugin/build.d.ts +70 -0
  213. package/dist/core/plugin/build.d.ts.map +1 -0
  214. package/dist/core/plugin/build.js +159 -0
  215. package/dist/core/plugin/build.js.map +1 -0
  216. package/dist/core/plugin/routes.d.ts +35 -0
  217. package/dist/core/plugin/routes.d.ts.map +1 -0
  218. package/dist/core/plugin/routes.js +77 -0
  219. package/dist/core/plugin/routes.js.map +1 -0
  220. package/dist/core/plugin/zip.d.ts +17 -0
  221. package/dist/core/plugin/zip.d.ts.map +1 -0
  222. package/dist/core/plugin/zip.js +75 -0
  223. package/dist/core/plugin/zip.js.map +1 -0
  224. package/dist/core/reconcile.d.ts.map +1 -1
  225. package/dist/core/reconcile.js +2 -1
  226. package/dist/core/reconcile.js.map +1 -1
  227. package/dist/core/retrieval/pass.d.ts.map +1 -1
  228. package/dist/core/retrieval/pass.js +5 -4
  229. package/dist/core/retrieval/pass.js.map +1 -1
  230. package/dist/core/rollup.d.ts.map +1 -1
  231. package/dist/core/rollup.js +2 -3
  232. package/dist/core/rollup.js.map +1 -1
  233. package/dist/core/root.d.ts.map +1 -1
  234. package/dist/core/root.js +33 -2
  235. package/dist/core/root.js.map +1 -1
  236. package/dist/core/second-opinion/environment.d.ts +21 -0
  237. package/dist/core/second-opinion/environment.d.ts.map +1 -0
  238. package/dist/core/second-opinion/environment.js +70 -0
  239. package/dist/core/second-opinion/environment.js.map +1 -0
  240. package/dist/core/second-opinion/judge.d.ts +29 -0
  241. package/dist/core/second-opinion/judge.d.ts.map +1 -0
  242. package/dist/core/second-opinion/judge.js +55 -0
  243. package/dist/core/second-opinion/judge.js.map +1 -0
  244. package/dist/core/second-opinion/launch.d.ts +16 -0
  245. package/dist/core/second-opinion/launch.d.ts.map +1 -0
  246. package/dist/core/second-opinion/launch.js +75 -0
  247. package/dist/core/second-opinion/launch.js.map +1 -0
  248. package/dist/core/second-opinion/lineup.d.ts +82 -0
  249. package/dist/core/second-opinion/lineup.d.ts.map +1 -0
  250. package/dist/core/second-opinion/lineup.js +113 -0
  251. package/dist/core/second-opinion/lineup.js.map +1 -0
  252. package/dist/core/second-opinion/modes.d.ts +98 -0
  253. package/dist/core/second-opinion/modes.d.ts.map +1 -0
  254. package/dist/core/second-opinion/modes.js +224 -0
  255. package/dist/core/second-opinion/modes.js.map +1 -0
  256. package/dist/core/second-opinion/prompts.d.ts +18 -0
  257. package/dist/core/second-opinion/prompts.d.ts.map +1 -0
  258. package/dist/core/second-opinion/prompts.js +65 -0
  259. package/dist/core/second-opinion/prompts.js.map +1 -0
  260. package/dist/core/session/commit.d.ts +29 -0
  261. package/dist/core/session/commit.d.ts.map +1 -0
  262. package/dist/core/session/commit.js +22 -0
  263. package/dist/core/session/commit.js.map +1 -0
  264. package/dist/core/session/discard.d.ts +24 -0
  265. package/dist/core/session/discard.d.ts.map +1 -0
  266. package/dist/core/session/discard.js +68 -0
  267. package/dist/core/session/discard.js.map +1 -0
  268. package/dist/core/session/list.d.ts +48 -0
  269. package/dist/core/session/list.d.ts.map +1 -0
  270. package/dist/core/session/list.js +55 -0
  271. package/dist/core/session/list.js.map +1 -0
  272. package/dist/core/session/rebase.d.ts +34 -0
  273. package/dist/core/session/rebase.d.ts.map +1 -0
  274. package/dist/core/session/rebase.js +87 -0
  275. package/dist/core/session/rebase.js.map +1 -0
  276. package/dist/core/session/remote.d.ts +80 -0
  277. package/dist/core/session/remote.d.ts.map +1 -0
  278. package/dist/core/session/remote.js +102 -0
  279. package/dist/core/session/remote.js.map +1 -0
  280. package/dist/core/session/resolve.d.ts +41 -0
  281. package/dist/core/session/resolve.d.ts.map +1 -0
  282. package/dist/core/session/resolve.js +109 -0
  283. package/dist/core/session/resolve.js.map +1 -0
  284. package/dist/core/session/start.d.ts +46 -0
  285. package/dist/core/session/start.d.ts.map +1 -0
  286. package/dist/core/session/start.js +33 -0
  287. package/dist/core/session/start.js.map +1 -0
  288. package/dist/core/session/status.d.ts +47 -0
  289. package/dist/core/session/status.d.ts.map +1 -0
  290. package/dist/core/session/status.js +55 -0
  291. package/dist/core/session/status.js.map +1 -0
  292. package/dist/core/session/submit.d.ts +67 -0
  293. package/dist/core/session/submit.d.ts.map +1 -0
  294. package/dist/core/session/submit.js +254 -0
  295. package/dist/core/session/submit.js.map +1 -0
  296. package/dist/core/shared-stores-location.d.ts +17 -0
  297. package/dist/core/shared-stores-location.d.ts.map +1 -0
  298. package/dist/core/shared-stores-location.js +22 -0
  299. package/dist/core/shared-stores-location.js.map +1 -0
  300. package/dist/core/shared-stores.d.ts +69 -0
  301. package/dist/core/shared-stores.d.ts.map +1 -0
  302. package/dist/core/shared-stores.js +100 -0
  303. package/dist/core/shared-stores.js.map +1 -0
  304. package/dist/core/skills.d.ts +20 -2
  305. package/dist/core/skills.d.ts.map +1 -1
  306. package/dist/core/skills.js +70 -13
  307. package/dist/core/skills.js.map +1 -1
  308. package/dist/run.d.ts +12 -0
  309. package/dist/run.d.ts.map +1 -1
  310. package/dist/run.js +194 -55
  311. package/dist/run.js.map +1 -1
  312. package/dist/version.d.ts +1 -1
  313. package/dist/version.js +1 -1
  314. package/package.json +1 -1
  315. package/templates/agents/shared-stores.md +11 -0
  316. package/templates/approve/copies-missing.md +1 -0
  317. package/templates/approve/elsewhere-heading.md +1 -0
  318. package/templates/approve/elsewhere-intro.md +1 -0
  319. package/templates/approve/homed-elsewhere.md +1 -0
  320. package/templates/approve/not-decider.md +1 -0
  321. package/templates/approve/part-heading.md +1 -0
  322. package/templates/approve/parts-changed.md +1 -0
  323. package/templates/approve/session-decision-note.md +1 -0
  324. package/templates/approve/session-intro.md +1 -0
  325. package/templates/approve/session-no-decision.md +1 -0
  326. package/templates/approve/store-unreachable.md +1 -0
  327. package/templates/land/resolver.md +2 -0
  328. package/templates/mcp/Delete.md +6 -0
  329. package/templates/mcp/Edit.md +6 -5
  330. package/templates/mcp/Glob.md +2 -2
  331. package/templates/mcp/Grep.md +2 -1
  332. package/templates/mcp/Move.md +7 -0
  333. package/templates/mcp/Read.md +4 -4
  334. package/templates/mcp/Write.md +4 -4
  335. package/templates/mcp/ctxr.md +7 -0
  336. package/templates/mcp/ctxr_write.md +8 -0
  337. package/templates/mcp/server-instructions.md +11 -3
  338. package/templates/mcp/session_discard.md +4 -0
  339. package/templates/mcp/session_list.md +7 -0
  340. package/templates/mcp/session_rebase.md +5 -0
  341. package/templates/mcp/session_start.md +7 -0
  342. package/templates/mcp/session_status.md +3 -0
  343. package/templates/mcp/session_submit.md +8 -0
  344. package/templates/plugin/README.md +13 -0
  345. package/templates/plugin/chatgpt-mcp.json +19 -0
  346. package/templates/plugin/chatgpt-plugin.json +13 -0
  347. package/templates/plugin/claude-mcp.json +8 -0
  348. package/templates/plugin/claude-plugin.json +6 -0
  349. package/templates/plugin/page.html +47 -0
  350. package/templates/second-opinion/poll-answer.md +7 -0
  351. package/templates/second-opinion/taste-panel.md +14 -0
  352. package/templates/session/pages/bare-route.md +2 -0
  353. package/templates/session/pages/block.md +8 -0
  354. package/templates/session/pages/condition-preview.md +1 -0
  355. package/templates/session/pages/condition.md +1 -0
  356. package/templates/session/pages/moved.md +1 -0
  357. package/templates/session/pages/stops-working.md +1 -0
  358. package/templates/session/pages/table-head-preview.md +2 -0
  359. package/templates/session/pages/table-head.md +2 -0
  360. package/templates/skills/ctxr-connection-finding.md +4 -1
  361. package/templates/skills/ctxr-land.md +26 -7
  362. package/templates/skills/ctxr-placement.md +10 -0
  363. package/templates/skills/ctxr-publish.md +2 -1
  364. package/templates/skills/ctxr-rollup.md +3 -0
  365. package/templates/skills/ctxr-second-opinion.md +52 -36
  366. package/templates/skills/ctxr-session-lifecycle.md +60 -33
  367. package/templates/skills/ctxr-submit.md +65 -56
  368. package/templates/skills/mcp/_preamble.md +44 -0
  369. package/dist/core/mcp/drafts.d.ts +0 -30
  370. package/dist/core/mcp/drafts.d.ts.map +0 -1
  371. package/dist/core/mcp/drafts.js +0 -52
  372. package/dist/core/mcp/drafts.js.map +0 -1
  373. package/templates/skills/ctxr-second-opinion/run.mjs +0 -542
  374. /package/templates/{skills/ctxr-second-opinion → second-opinion}/critic-contract.md +0 -0
  375. /package/templates/{skills/ctxr-second-opinion → second-opinion}/lenses.md +0 -0
  376. /package/templates/{skills/ctxr-second-opinion → second-opinion}/personas/architect.md +0 -0
  377. /package/templates/{skills/ctxr-second-opinion → second-opinion}/personas/pragmatist.md +0 -0
  378. /package/templates/{skills/ctxr-second-opinion → second-opinion}/personas/skeptic.md +0 -0
@@ -0,0 +1,111 @@
1
+ import path from 'node:path';
2
+ import { DEFAULT_LOG_PATH } from '../../config/defaults.js';
3
+ import { isUnderAnyPrefix, isUnderPrefix } from '../fs/prefix.js';
4
+ import { admitsNotePath } from '../notes/list.js';
5
+ import { CONFIG_FILE_NAME } from '../root.js';
6
+ import { ToolRefusal } from './jsonrpc.js';
7
+ /**
8
+ * serve-the-session-lifecycle-to-chat-apps D5: what the file tools and the
9
+ * command runners may read and change, as predicates over a store-relative,
10
+ * `/`-separated path. Kept free of any session or snapshot, so the file tools
11
+ * over the served commit, the same tools inside a session, and `ctxr_write`'s
12
+ * before- and after-run checks all ask the same question.
13
+ */
14
+ /** The store's entry document, readable though it is not a note. */
15
+ export const ENTRY_DOCUMENT = 'AGENTS.md';
16
+ /**
17
+ * D5, revision 7: the one protected-path predicate. Inside a session a member
18
+ * may change what a local session may change except these: the configuration
19
+ * (it grants MCP scopes), anything whose first segment begins with `.git` —
20
+ * the hooks directory among them, because a commit in a session worktree runs
21
+ * that worktree's hooks on the server — derived and cache paths, the
22
+ * worktrees path, and the managed skills path, which `ctxr update` owns.
23
+ * Null when the path may be changed.
24
+ */
25
+ export function protectedReason(rel, config) {
26
+ if (rel === CONFIG_FILE_NAME)
27
+ return 'configuration';
28
+ if ((rel.split('/')[0] ?? '').startsWith('.git'))
29
+ return 'git';
30
+ if (isUnderAnyPrefix(rel, config.derived.paths))
31
+ return 'derived';
32
+ if (isUnderPrefix(rel, config.session.worktrees_path))
33
+ return 'worktrees';
34
+ if (isUnderPrefix(rel, config.harness.skills_path))
35
+ return 'skills';
36
+ return null;
37
+ }
38
+ const PROTECTED_WORDS = {
39
+ configuration: 'the store configuration',
40
+ git: "git's own files and the hooks directory, which a commit on the server would run",
41
+ derived: 'a derived or cache path',
42
+ worktrees: 'the session worktrees path',
43
+ skills: 'the managed skills path',
44
+ };
45
+ export function protectedRefusal(rel, reason) {
46
+ return new ToolRefusal('mcp.path_protected', `"${rel}" is ${PROTECTED_WORDS[reason]}, which cannot be changed from here; change it in a local session.`, { path: rel, reason });
47
+ }
48
+ /** D5: the paths the owned skills read that are not notes: templates, house conventions, the mission, the log and the skills. */
49
+ export function widenedReadablePrefixes(config) {
50
+ return [
51
+ config.templates.path,
52
+ config.harness.guidance_path,
53
+ config.harness.skills_path,
54
+ config.organize.log_path ?? DEFAULT_LOG_PATH,
55
+ ...(config.organize.mission_path !== undefined ? [config.organize.mission_path] : []),
56
+ ];
57
+ }
58
+ /** Never read or returned, whatever else applies: configuration, `.git`, derived paths and the worktrees path. */
59
+ export function neverReadablePrefixes(config) {
60
+ return [CONFIG_FILE_NAME, '.git', ...config.derived.paths, config.session.worktrees_path];
61
+ }
62
+ /**
63
+ * D5: hidden from the file tools. `retrieval.exclude_paths` stays hidden — it
64
+ * is the operator's declared intent — except the capture tier, which `Read`
65
+ * marks, and the widened readable set, which the skills need.
66
+ */
67
+ export function hiddenPrefixes(config) {
68
+ const captureRoot = config.ingest.capture_root.replace(/\/+$/, '');
69
+ return [...config.retrieval.exclude_paths.filter((p) => p.replace(/\/+$/, '') !== captureRoot), ...neverReadablePrefixes(config)];
70
+ }
71
+ /** Whether `rel` is a path the file tools may name at all (a file or a directory to search). */
72
+ export function nameablePath(rel, config) {
73
+ if (rel === '')
74
+ return true;
75
+ if (isUnderAnyPrefix(rel, neverReadablePrefixes(config)))
76
+ return false;
77
+ if (isUnderAnyPrefix(rel, widenedReadablePrefixes(config)))
78
+ return true;
79
+ return !isUnderAnyPrefix(rel, hiddenPrefixes(config));
80
+ }
81
+ /** What `Read` answers for, as one predicate: a note, a markdown capture, the entry document, or the widened set. Grep and Glob return nothing else. */
82
+ export function readablePath(rel, config) {
83
+ if (!nameablePath(rel, config) || rel === '')
84
+ return false;
85
+ if (isUnderAnyPrefix(rel, widenedReadablePrefixes(config)))
86
+ return true;
87
+ if (admitsNotePath(rel, config) || rel === ENTRY_DOCUMENT)
88
+ return true;
89
+ return rel.endsWith('.md') && isUnderAnyPrefix(rel, [config.ingest.capture_root]);
90
+ }
91
+ /**
92
+ * The exclusions ripgrep is given: the hidden prefixes that contain nothing in
93
+ * the widened set. A hidden prefix that does contain some (the default
94
+ * `.contexture/` holds the templates) is searched and filtered by
95
+ * `readablePath` afterwards, because a later positive glob would turn
96
+ * ripgrep's exclusions into an allowlist.
97
+ */
98
+ export function searchExclusions(config) {
99
+ const widened = widenedReadablePrefixes(config).map((p) => p.replace(/\/+$/, ''));
100
+ return hiddenPrefixes(config).filter((hidden) => !widened.some((w) => isUnderPrefix(w, hidden)) || isUnderAnyPrefix(hidden, neverReadablePrefixes(config)));
101
+ }
102
+ /** A caller's path as a normalized store-relative one (a leading `/` names the store root); refused when it leaves the store. `''` is the root. */
103
+ export function normalizeStorePath(input) {
104
+ const cleaned = input.trim().replace(/\\/g, '/');
105
+ const normalized = path.posix.normalize(`/${cleaned}`).replace(/^\/+/, '').replace(/\/+$/, '');
106
+ if (normalized === '..' || normalized.startsWith('../') || cleaned.split('/').includes('..')) {
107
+ throw new ToolRefusal('mcp.path_outside_store', `"${input}" is outside the store.`);
108
+ }
109
+ return normalized;
110
+ }
111
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/core/mcp/paths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;;;;;GAMG;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAI1C;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,MAAmB;IAC9D,IAAI,GAAG,KAAK,gBAAgB;QAAE,OAAO,eAAe,CAAC;IACrD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/D,IAAI,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,K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schema.js';
2
2
  import { type ForgeCredentials } from '../forge/credentials.js';
3
- import type { ForgeClient, PullRequest } from '../forge/github.js';
3
+ import type { ForgeClient } from '../forge/github.js';
4
4
  import type { GitRunner } from '../git/exec.js';
5
+ import type { CommitOptions } from '../session/commit.js';
6
+ import { type StartedSession } from '../session/start.js';
5
7
  /**
6
8
  * serve-the-store-over-mcp design.md D9, D13: the write side the MCP surface
7
- * shares between `capture` and the member drafts. Everything it writes is an
8
- * ordinary session — a worktree under the configured worktrees path, on a
9
- * branch under the session prefix, with a pull request — so the approval page
10
- * lists it and `ctxr land` lands it with no MCP-specific path anywhere.
9
+ * shares between its tools. Everything it writes is an ordinary session — a
10
+ * worktree under the configured worktrees path, on a branch under the session
11
+ * prefix, with a pull request — so the approval page lists it and `ctxr land`
12
+ * lands it with no MCP-specific path anywhere.
13
+ *
14
+ * serve-the-session-lifecycle-to-chat-apps D3: starting, submitting,
15
+ * rebasing and discarding are `src/core/session/`'s, the same calls
16
+ * `ctxr session <verb>` makes. What stays here is what the MCP layer adds:
17
+ * the server's forge credential on every remote step, the member as commit
18
+ * author, and the surface's wording of a refusal. The per-member draft's
19
+ * helpers are gone with the draft.
11
20
  */
12
21
  export interface WriteDeps {
13
22
  git: GitRunner;
@@ -25,60 +34,26 @@ export interface WriteDeps {
25
34
  /** The store root's path inside its repository, when the caller has already resolved it; asked of git otherwise. */
26
35
  repoPrefix?: string;
27
36
  }
28
- export interface Session {
29
- /** The worktree directory's name: the key the approval page addresses it by. */
30
- name: string;
31
- path: string;
32
- branch: string;
33
- label: string | null;
34
- }
35
- export type PullState = {
36
- kind: 'open';
37
- pull: PullRequest;
38
- } | {
39
- kind: 'merged';
40
- } | {
41
- kind: 'closed-unmerged';
42
- } | {
43
- kind: 'none';
44
- };
45
37
  export declare class WriteRefusal extends Error {
46
38
  readonly code: string;
47
39
  readonly details?: Record<string, unknown> | undefined;
48
40
  constructor(code: string, message: string, details?: Record<string, unknown> | undefined);
49
41
  }
50
- /** One write at a time across `capture`, `Edit` and `Write` (design.md D9, D13). */
42
+ /** One write at a time across every tool that changes a worktree, the ownership record or the forge (design.md D9, D13). */
51
43
  export declare class Mutex {
52
44
  private tail;
53
45
  run<T>(fn: () => Promise<T>): Promise<T>;
54
46
  }
55
- export declare function approvalUrl(deps: WriteDeps, session: Session): string;
56
- /** The session worktrees on disk whose label starts with `labelPrefix`, with their branches. */
57
- export declare function sessionsLabelled(deps: WriteDeps, labelPrefix: string): Promise<Session[]>;
58
- /** What the forge says about the pull requests for `branch`: the open one, else merged, else closed, else none. */
59
- export declare function pullStateFor(deps: WriteDeps, branch: string): Promise<PullState>;
60
- /** A session whose pull request was closed without merging is removed: worktree and local branch (D9, D13). */
61
- export declare function removeSession(deps: WriteDeps, session: Session): Promise<void>;
62
- /** A new session from the freshly fetched default branch, exactly as `ctxr session start` names and places one. */
63
- export declare function startSession(deps: WriteDeps, label: string): Promise<Session>;
64
- /** The store-relative path's location inside the repository, for `git show <branch>:<path>`. */
65
- export declare function repoPathOf(deps: WriteDeps, storeRelative: string): Promise<string>;
66
- /**
67
- * Stages `paths` and commits them authored by the member, with the store's
68
- * hooks running as for any commit. On a refusal the worktree is restored to
69
- * its tip — a draft never keeps a change its pull request does not carry —
70
- * and the hook's output is the refusal (design.md D13).
71
- */
72
- export declare function commitAs(deps: WriteDeps, session: Session, email: string, paths: readonly string[], subject: string, trailer: string): Promise<string>;
73
- export declare function restore(deps: WriteDeps, session: Session): Promise<void>;
47
+ /** The approval page for a session, at the server's own address. */
48
+ export declare function approvalUrl(deps: WriteDeps, sessionName: string): string;
74
49
  /**
75
- * Publishes whatever the session holds that the forge does not: its branch,
76
- * pushed when the remote lacks the local tip, and a pull request, found by
77
- * head before one is opened. Idempotent, so a retry after any partial
78
- * failure converges on exactly one pull request (design.md D9, D13).
50
+ * A new session from the freshly fetched default branch, through the core
51
+ * `ctxr session start` calls. A closed pull request's branch stays on the
52
+ * remote, so a generated name the remote already carries is stepped past.
79
53
  */
80
- export declare function publish(deps: WriteDeps, session: Session, pull: {
81
- title: string;
82
- body: string;
83
- }): Promise<PullRequest>;
54
+ export declare function startSession(deps: WriteDeps, label: string | undefined): Promise<StartedSession>;
55
+ /** D3: the member as the commit's author, with a trailer naming them; the recording login commits when the host has no identity. */
56
+ export declare function memberCommit(deps: WriteDeps, email: string, trailer: string): Omit<CommitOptions, 'message'>;
57
+ /** A WriteRefusal or a core refusal, as a refusal the client model can read rather than a protocol error. */
58
+ export declare function asToolRefusal(err: unknown): unknown;
84
59
  //# sourceMappingURL=sessions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/core/mcp/sessions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3D;;;;;;GAMG;AAEH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,SAAS,CAAC;IACf,8GAA8G;IAC9G,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,KAAK,EAAE,WAAW,CAAC;IACnB,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAClD,GAAG,IAAI,IAAI,CAAC;IACZ,+GAA+G;IAC/G,cAAc,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,oHAAoH;IACpH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,OAAO;IACtB,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IAC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,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAE5G;AAED,6GAA6G;AAC7G,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAInD"}
@@ -1,7 +1,8 @@
1
- import path from 'node:path';
1
+ import { ContextureError } from '../errors.js';
2
2
  import { runRemoteGit } from '../forge/credentials.js';
3
- import { addWorktree, removeWorktree } from '../git/worktree.js';
4
- import { generateSessionBranchName, listSessionWorktreeDirs, sessionLabelFromDirName, sessionLabelSlug, worktreePathFor } from '../session.js';
3
+ import { fetchDefaultBranch } from '../session/status.js';
4
+ import { startSession as startCoreSession } from '../session/start.js';
5
+ import { ToolRefusal } from './jsonrpc.js';
5
6
  export class WriteRefusal extends Error {
6
7
  code;
7
8
  details;
@@ -12,7 +13,7 @@ export class WriteRefusal extends Error {
12
13
  this.name = 'WriteRefusal';
13
14
  }
14
15
  }
15
- /** One write at a time across `capture`, `Edit` and `Write` (design.md D9, D13). */
16
+ /** One write at a time across every tool that changes a worktree, the ownership record or the forge (design.md D9, D13). */
16
17
  export class Mutex {
17
18
  tail = Promise.resolve();
18
19
  run(fn) {
@@ -21,64 +22,9 @@ export class Mutex {
21
22
  return next;
22
23
  }
23
24
  }
24
- function firstLines(text, count = 6) {
25
- return text.trim().split('\n').slice(0, count).join('\n');
26
- }
27
- export function approvalUrl(deps, session) {
28
- return `${deps.baseUrl.replace(/\/+$/, '')}/approve/${encodeURIComponent(session.name)}`;
29
- }
30
- /** The session worktrees on disk whose label starts with `labelPrefix`, with their branches. */
31
- export async function sessionsLabelled(deps, labelPrefix) {
32
- const root = path.join(deps.canonicalRoot, deps.config.session.worktrees_path);
33
- const sessions = [];
34
- for (const name of await listSessionWorktreeDirs(deps.canonicalRoot, deps.config)) {
35
- const label = sessionLabelFromDirName(deps.config, name);
36
- if (label === null || !label.startsWith(labelPrefix))
37
- continue;
38
- const dir = path.join(root, name);
39
- const branch = (await deps.git.run(['symbolic-ref', '--short', 'HEAD'], { cwd: dir, allowFailure: true })).stdout.trim();
40
- if (branch === '')
41
- continue;
42
- sessions.push({ name, path: dir, branch, label });
43
- }
44
- return sessions.sort((a, b) => (a.name < b.name ? -1 : 1));
45
- }
46
- /** What the forge says about the pull requests for `branch`: the open one, else merged, else closed, else none. */
47
- export async function pullStateFor(deps, branch) {
48
- const pulls = await deps.forge.pullsForHead(branch);
49
- const open = pulls.find((p) => p.state === 'open');
50
- if (open !== undefined)
51
- return { kind: 'open', pull: open };
52
- if (pulls.some((p) => p.merged))
53
- return { kind: 'merged' };
54
- if (pulls.length > 0)
55
- return { kind: 'closed-unmerged' };
56
- return { kind: 'none' };
57
- }
58
- /** A session whose pull request was closed without merging is removed: worktree and local branch (D9, D13). */
59
- export async function removeSession(deps, session) {
60
- await removeWorktree(deps.git, deps.canonicalRoot, session.path);
61
- await deps.git.run(['branch', '-D', session.branch], { cwd: deps.canonicalRoot, allowFailure: true });
62
- }
63
- /** A new session from the freshly fetched default branch, exactly as `ctxr session start` names and places one. */
64
- export async function startSession(deps, label) {
65
- const slug = sessionLabelSlug(label);
66
- const defaultBranch = deps.config.git.default_branch;
67
- await runRemoteGit(deps.git, deps.credentials, deps.env, ['fetch', '--quiet', 'origin', `+refs/heads/${defaultBranch}:refs/remotes/origin/${defaultBranch}`], {
68
- cwd: deps.canonicalRoot,
69
- allowFailure: true,
70
- });
71
- const hasRemote = (await deps.git.run(['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${defaultBranch}`], { cwd: deps.canonicalRoot, allowFailure: true })).exitCode === 0;
72
- // Names carry a timestamp to the second, and a closed pull request's branch stays on the remote: step past any taken name.
73
- let branch = generateSessionBranchName(deps.config, deps.now(), slug);
74
- for (let step = 1; step <= 60 && (await branchTaken(deps, branch)); step += 1) {
75
- branch = generateSessionBranchName(deps.config, new Date(deps.now().getTime() + step * 1000), slug);
76
- }
77
- const dir = worktreePathFor({ root: deps.canonicalRoot, config: deps.config }, branch);
78
- const added = await addWorktree(deps.git, deps.canonicalRoot, dir, branch, hasRemote ? `origin/${defaultBranch}` : defaultBranch, { allowFailure: true });
79
- if (added.exitCode !== 0)
80
- throw new WriteRefusal('mcp.session_not_started', `A session could not be started: ${firstLines(added.stderr)}`);
81
- return { name: path.basename(dir), path: dir, branch, label: slug };
25
+ /** The approval page for a session, at the server's own address. */
26
+ export function approvalUrl(deps, sessionName) {
27
+ return `${deps.baseUrl.replace(/\/+$/, '')}/approve/${encodeURIComponent(sessionName)}`;
82
28
  }
83
29
  async function branchTaken(deps, branch) {
84
30
  const local = await deps.git.run(['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`], { cwd: deps.canonicalRoot, allowFailure: true });
@@ -87,68 +33,30 @@ async function branchTaken(deps, branch) {
87
33
  const remote = await runRemoteGit(deps.git, deps.credentials, deps.env, ['ls-remote', '--exit-code', 'origin', `refs/heads/${branch}`], { cwd: deps.canonicalRoot, allowFailure: true });
88
34
  return remote.exitCode === 0;
89
35
  }
90
- /** The store-relative path's location inside the repository, for `git show <branch>:<path>`. */
91
- export async function repoPathOf(deps, storeRelative) {
92
- const prefix = deps.repoPrefix ?? (await deps.git.run(['rev-parse', '--show-prefix'], { cwd: deps.canonicalRoot, allowFailure: true })).stdout.trim();
93
- return `${prefix}${storeRelative}`;
94
- }
95
- /** The committer: the host's git identity when it has one, else the recording login's noreply address, as `ctxr land` falls back. */
96
- async function committerEnv(deps, cwd) {
97
- const email = (await deps.git.run(['config', '--get', 'user.email'], { cwd, allowFailure: true })).stdout.trim();
98
- if (email !== '' || deps.env.GIT_COMMITTER_EMAIL || deps.env.EMAIL)
99
- return {};
100
- const address = `${deps.recordingLogin.replace(/\[bot\]$/, '')}@users.noreply.github.com`;
101
- return { GIT_COMMITTER_NAME: deps.recordingLogin, GIT_COMMITTER_EMAIL: address };
102
- }
103
36
  /**
104
- * Stages `paths` and commits them authored by the member, with the store's
105
- * hooks running as for any commit. On a refusal the worktree is restored to
106
- * its tip — a draft never keeps a change its pull request does not carry —
107
- * and the hook's output is the refusal (design.md D13).
37
+ * A new session from the freshly fetched default branch, through the core
38
+ * `ctxr session start` calls. A closed pull request's branch stays on the
39
+ * remote, so a generated name the remote already carries is stepped past.
108
40
  */
109
- export async function commitAs(deps, session, email, paths, subject, trailer) {
110
- const run = (args, env) => deps.git.run(args, { cwd: session.path, allowFailure: true, ...(env ? { env } : {}) });
111
- const added = await run(['add', '--', ...paths]);
112
- if (added.exitCode !== 0) {
113
- await restore(deps, session);
114
- throw new WriteRefusal('mcp.commit_refused', `The change could not be staged: ${firstLines(added.stderr)}`);
115
- }
116
- const name = email.split('@')[0] ?? email;
117
- const env = { ...deps.env, ...(await committerEnv(deps, session.path)), GIT_AUTHOR_NAME: name, GIT_AUTHOR_EMAIL: email };
118
- const committed = await run(['commit', '--quiet', '-m', subject, '-m', `${trailer}: ${email}`], env);
119
- if (committed.exitCode !== 0) {
120
- await restore(deps, session);
121
- throw new WriteRefusal('mcp.commit_refused', `The store refused the change: ${firstLines(`${committed.stdout}\n${committed.stderr}`, 12)}`);
122
- }
123
- return (await run(['rev-parse', 'HEAD'])).stdout.trim();
124
- }
125
- export async function restore(deps, session) {
126
- await deps.git.run(['reset', '--quiet', '--hard', 'HEAD'], { cwd: session.path, allowFailure: true });
127
- await deps.git.run(['clean', '-fdq'], { cwd: session.path, allowFailure: true });
128
- }
129
- /**
130
- * Publishes whatever the session holds that the forge does not: its branch,
131
- * pushed when the remote lacks the local tip, and a pull request, found by
132
- * head before one is opened. Idempotent, so a retry after any partial
133
- * failure converges on exactly one pull request (design.md D9, D13).
134
- */
135
- export async function publish(deps, session, pull) {
136
- const tip = (await deps.git.run(['rev-parse', 'HEAD'], { cwd: session.path })).stdout.trim();
137
- const remote = await runRemoteGit(deps.git, deps.credentials, deps.env, ['ls-remote', 'origin', `refs/heads/${session.branch}`], { cwd: session.path, allowFailure: true });
138
- if (remote.exitCode !== 0 || remote.stdout.split(/\s/)[0] !== tip) {
139
- const pushed = await runRemoteGit(deps.git, deps.credentials, deps.env, ['push', '--quiet', 'origin', `HEAD:refs/heads/${session.branch}`], { cwd: session.path, allowFailure: true });
140
- if (pushed.exitCode !== 0) {
141
- throw new WriteRefusal('mcp.push_failed', `The change is saved in its session but could not be pushed yet (${firstLines(pushed.stderr, 2)}). Retry the same call to publish it.`, { session: session.name });
142
- }
143
- }
144
- const state = await pullStateFor(deps, session.branch);
145
- if (state.kind === 'open')
146
- return state.pull;
147
- try {
148
- return await deps.forge.createPull({ head: session.branch, base: deps.config.git.default_branch, title: pull.title, body: pull.body });
149
- }
150
- catch (err) {
151
- throw new WriteRefusal('mcp.pull_request_failed', `The change is pushed but its pull request could not be opened yet (${err instanceof Error ? firstLines(err.message, 2) : String(err)}). Retry the same call to open it.`, { session: session.name });
152
- }
41
+ export async function startSession(deps, label) {
42
+ return startCoreSession({
43
+ git: deps.git,
44
+ config: deps.config,
45
+ fetch: (cwd) => fetchDefaultBranch({ git: deps.git, config: deps.config, env: deps.env, credentials: deps.credentials }, cwd),
46
+ now: deps.now,
47
+ branchTaken: (branch) => branchTaken(deps, branch),
48
+ }, deps.canonicalRoot, label);
49
+ }
50
+ /** D3: the member as the commit's author, with a trailer naming them; the recording login commits when the host has no identity. */
51
+ export function memberCommit(deps, email, trailer) {
52
+ return { author: { name: email.split('@')[0] ?? email, email }, trailer: { key: trailer, value: email }, fallbackCommitter: deps.recordingLogin };
53
+ }
54
+ /** A WriteRefusal or a core refusal, as a refusal the client model can read rather than a protocol error. */
55
+ export function asToolRefusal(err) {
56
+ if (err instanceof WriteRefusal)
57
+ return new ToolRefusal(err.code, err.message, err.details);
58
+ if (err instanceof ContextureError)
59
+ return new ToolRefusal(err.finding.code, err.finding.message, err.finding.details);
60
+ return err;
153
61
  }
154
62
  //# sourceMappingURL=sessions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../src/core/mcp/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAA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,OAAO,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,iBAAiB,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;AACpJ,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,IAAI,GAAG,YAAY,YAAY;QAAE,OAAO,IAAI,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5F,IAAI,GAAG,YAAY,eAAe;QAAE,OAAO,IAAI,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvH,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * serve-the-session-lifecycle-to-chat-apps D9 and revisions 2, 3 and 6: the
3
+ * one place a `ctxr` command is mapped to the MCP tool that runs it. The tool
4
+ * registry (`tools/index.ts`) registers exactly the tools listed here, in
5
+ * this order; the rendered skills' preamble, the drift check over the MCP
6
+ * render and the tool/command alignment check all read this module, so no
7
+ * tool name is ever derived from a command name by rule.
8
+ *
9
+ * Every tool is one of four kinds:
10
+ * - `file`: Claude Code's own file tools, plus `Move` and `Delete`, which stand
11
+ * in for the `git mv` and `git rm` a local agent runs;
12
+ * - `command`: one `ctxr` command, named for its path, taking its options as
13
+ * fields (plus `session`, the one field the MCP layer adds);
14
+ * - `runner`: `ctxr` and `ctxr_write`, through which every allowlisted command
15
+ * without a tool of its own runs (D4);
16
+ * - `exception`: a tool with no command, each with its reason.
17
+ */
18
+ export type ToolKind = 'file' | 'command' | 'runner' | 'exception';
19
+ export interface ToolEntry {
20
+ name: string;
21
+ kind: ToolKind;
22
+ /** `command` only: the command path, space-separated, as `ctxr <path>` takes it. */
23
+ command?: string;
24
+ /** `runner` and `exception`: why the tool is not a command of its own. */
25
+ reason?: string;
26
+ }
27
+ /** The one field the MCP layer adds to a command's options: a local command finds its session from its working directory, a stateless server cannot. */
28
+ export declare const SESSION_FIELD = "session";
29
+ /** The fields of the two runners (D4, D9). */
30
+ export declare const RUNNER_FIELDS: readonly ['args', "session", 'input'];
31
+ /** The literal argument `ctxr_write` replaces with the path of a file holding the call's `input` (D4). */
32
+ export declare const INPUT_ARGUMENT = "@input";
33
+ /** D4: read-only commands `ctxr` runs, as command paths matched before any option. */
34
+ export declare const CTXR_READ_COMMANDS: readonly ['lint', 'doctor', 'catalog show', 'catalog check', 'graph query', 'graph diff', 'context gather', 'source check', 'source hash', 'rollup stale', 'rollup gather', 'publish check', 'publish urls', 'publish gather', 'shared-stores status'];
35
+ /** D4: writing commands `ctxr_write` runs inside a member's own session. `session capture` is one of them (revision 2). */
36
+ export declare const CTXR_WRITE_COMMANDS: readonly ['ingest', 'archive', 'entry append', 'rollup write', 'source stamp', 'source add-alt', 'session capture', 'catalog build', 'graph build', 'update'];
37
+ /**
38
+ * Commands a shipped skill names that have no counterpart over MCP, so the
39
+ * preamble marks them `none` and the agent skips the step. `shared-stores
40
+ * sync` refreshes the canonical clone's mounts; the server keeps no mounts,
41
+ * and a chat session cannot change into one (mount-shared-stores).
42
+ */
43
+ export declare const UNAVAILABLE_COMMANDS: readonly ['shared-stores sync'];
44
+ /** D3: the session commands with a typed tool of their own. */
45
+ export declare const SESSION_COMMAND_TOOLS: {
46
+ readonly 'session start': 'session_start';
47
+ readonly 'session list': 'session_list';
48
+ readonly 'session status': 'session_status';
49
+ readonly 'session submit': 'session_submit';
50
+ readonly 'session rebase': 'session_rebase';
51
+ readonly 'session discard': 'session_discard';
52
+ };
53
+ /**
54
+ * D6: the git and gh steps the shipped skills name, and the tool each one is in
55
+ * this environment; null marks the server's own work, which the agent skips (the
56
+ * lifecycle skill's canonical-clone refresh). A step not listed here has no
57
+ * counterpart over MCP, and the drift check over the MCP render refuses it. The
58
+ * preamble's tables are rendered from this and `SESSION_COMMAND_TOOLS`.
59
+ */
60
+ export declare const GIT_STEP_TOOLS: Readonly<Record<string, string | null>>;
61
+ /** The registry, in `tools/list` order. */
62
+ export declare const TOOL_REGISTRY: readonly ToolEntry[];
63
+ export declare const TOOL_NAMES: readonly string[];
64
+ /** The command path at the front of `argv` that `allowlist` holds, longest first; null when none does. Matched before any option. */
65
+ export declare function matchCommand(argv: readonly string[], allowlist: readonly string[]): string | null;
66
+ export type CommandRoute = {
67
+ via: 'tool';
68
+ tool: string;
69
+ } | {
70
+ via: 'ctxr';
71
+ } | {
72
+ via: 'ctxr_write';
73
+ };
74
+ /** How a `ctxr <command path>` step runs over MCP; null when the surface does not run it. */
75
+ export declare function routeForCommand(commandPath: string): CommandRoute | null;
76
+ /** The file tools: Claude Code's own, plus the two that stand in for `git mv` and `git rm` (D9). */
77
+ export declare const FILE_TOOLS: readonly ['Read', 'Grep', 'Glob', 'Edit', 'Write', 'Move', 'Delete'];
78
+ /** The named exceptions (D9): tools with no command, each with its reason in the registry. */
79
+ export declare const NAMED_EXCEPTIONS: readonly ['find', 'gather', 'capture'];
80
+ /** The command runners (D4, D9). */
81
+ export declare const RUNNERS: readonly ['ctxr', 'ctxr_write'];
82
+ /** One CLI command as the alignment check sees it: its path and the snake_case names of its options and arguments. */
83
+ export interface CommandShape {
84
+ path: string;
85
+ params: readonly string[];
86
+ }
87
+ /**
88
+ * D9: what is wrong with a registry against the CLI's commands, one line per
89
+ * problem, each naming the tool. Empty when every tool is a file tool, a
90
+ * runner, a named exception, or a command-named tool whose fields other than
91
+ * `session` are options or arguments that command registers.
92
+ */
93
+ export declare function alignmentProblems(registry: readonly ToolEntry[], toolFields: Readonly<Record<string, readonly string[]>>, commands: readonly CommandShape[]): string[];
94
+ //# sourceMappingURL=tool-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-map.d.ts","sourceRoot":"","sources":["../../../src/core/mcp/tool-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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