borgmcp 1.1.15 → 2.0.2

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 (466) hide show
  1. package/CONTRIBUTING.md +15 -0
  2. package/LICENSE +201 -33
  3. package/NOTICE +2 -0
  4. package/README.md +85 -36
  5. package/SECURITY.md +7 -0
  6. package/dist/agent-runtime.d.ts.map +1 -0
  7. package/dist/agent-runtime.js +63 -1
  8. package/dist/agent-runtime.js.map +1 -0
  9. package/dist/assimilate-cmd.d.ts +96 -17
  10. package/dist/assimilate-cmd.d.ts.map +1 -0
  11. package/dist/assimilate-cmd.js +1396 -48
  12. package/dist/assimilate-cmd.js.map +1 -0
  13. package/dist/assimilate-deps.d.ts.map +1 -0
  14. package/dist/assimilate-deps.js +384 -3
  15. package/dist/assimilate-deps.js.map +1 -0
  16. package/dist/assimilate-guard.d.ts +5 -7
  17. package/dist/assimilate-guard.d.ts.map +1 -0
  18. package/dist/assimilate-guard.js +60 -2
  19. package/dist/assimilate-guard.js.map +1 -0
  20. package/dist/assimilate-welcome.d.ts +1 -1
  21. package/dist/assimilate-welcome.d.ts.map +1 -0
  22. package/dist/assimilate-welcome.js +32 -2
  23. package/dist/assimilate-welcome.js.map +1 -0
  24. package/dist/auth-env.d.ts +7 -50
  25. package/dist/auth-env.d.ts.map +1 -0
  26. package/dist/auth-env.js +22 -1
  27. package/dist/auth-env.js.map +1 -0
  28. package/dist/backends/launch-all-pastelist.d.ts.map +1 -0
  29. package/dist/backends/launch-all-pastelist.js +11 -4
  30. package/dist/backends/launch-all-pastelist.js.map +1 -0
  31. package/dist/backends/launch-all-tmux.d.ts.map +1 -0
  32. package/dist/backends/launch-all-tmux.js +49 -1
  33. package/dist/backends/launch-all-tmux.js.map +1 -0
  34. package/dist/backends/launch-all-windows.d.ts.map +1 -0
  35. package/dist/backends/launch-all-windows.js +86 -12
  36. package/dist/backends/launch-all-windows.js.map +1 -0
  37. package/dist/bare-launch-menu.d.ts.map +1 -0
  38. package/dist/bare-launch-menu.js +83 -6
  39. package/dist/bare-launch-menu.js.map +1 -0
  40. package/dist/claude-launch-args.d.ts.map +1 -0
  41. package/dist/claude-launch-args.js +34 -1
  42. package/dist/claude-launch-args.js.map +1 -0
  43. package/dist/claude.d.ts.map +1 -0
  44. package/dist/claude.js +486 -14
  45. package/dist/claude.js.map +1 -0
  46. package/dist/cleanup-cmd.d.ts +5 -5
  47. package/dist/cleanup-cmd.d.ts.map +1 -0
  48. package/dist/cleanup-cmd.js +453 -14
  49. package/dist/cleanup-cmd.js.map +1 -0
  50. package/dist/clear-rewake-core.d.ts.map +1 -0
  51. package/dist/clear-rewake-core.js +23 -2
  52. package/dist/clear-rewake-core.js.map +1 -0
  53. package/dist/clear-rewake.d.ts.map +1 -0
  54. package/dist/clear-rewake.js +19 -1
  55. package/dist/clear-rewake.js.map +1 -0
  56. package/dist/cli-help.d.ts +5 -0
  57. package/dist/cli-help.d.ts.map +1 -0
  58. package/dist/cli-help.js +104 -56
  59. package/dist/cli-help.js.map +1 -0
  60. package/dist/cli-platform.d.ts.map +1 -0
  61. package/dist/cli-platform.js +106 -4
  62. package/dist/cli-platform.js.map +1 -0
  63. package/dist/cli-tool-approval.d.ts +84 -0
  64. package/dist/cli-tool-approval.d.ts.map +1 -0
  65. package/dist/cli-tool-approval.js +583 -0
  66. package/dist/cli-tool-approval.js.map +1 -0
  67. package/dist/codex-app-server.d.ts.map +1 -0
  68. package/dist/codex-app-server.js +228 -4
  69. package/dist/codex-app-server.js.map +1 -0
  70. package/dist/codex-app-wake.d.ts +9 -11
  71. package/dist/codex-app-wake.d.ts.map +1 -0
  72. package/dist/codex-app-wake.js +436 -2
  73. package/dist/codex-app-wake.js.map +1 -0
  74. package/dist/codex-launch.d.ts.map +1 -0
  75. package/dist/codex-launch.js +102 -2
  76. package/dist/codex-launch.js.map +1 -0
  77. package/dist/codex-remote.d.ts +6 -1
  78. package/dist/codex-remote.d.ts.map +1 -0
  79. package/dist/codex-remote.js +394 -1
  80. package/dist/codex-remote.js.map +1 -0
  81. package/dist/codex-wake-resolve.d.ts +4 -4
  82. package/dist/codex-wake-resolve.d.ts.map +1 -0
  83. package/dist/codex-wake-resolve.js +127 -1
  84. package/dist/codex-wake-resolve.js.map +1 -0
  85. package/dist/config-utils.d.ts +2 -2
  86. package/dist/config-utils.d.ts.map +1 -0
  87. package/dist/config-utils.js +766 -3
  88. package/dist/config-utils.js.map +1 -0
  89. package/dist/config.d.ts +98 -61
  90. package/dist/config.d.ts.map +1 -0
  91. package/dist/config.js +426 -1
  92. package/dist/config.js.map +1 -0
  93. package/dist/console-prefix.d.ts.map +1 -0
  94. package/dist/console-prefix.js +96 -1
  95. package/dist/console-prefix.js.map +1 -0
  96. package/dist/cube-name.d.ts.map +1 -0
  97. package/dist/cube-name.js +67 -1
  98. package/dist/cube-name.js.map +1 -0
  99. package/dist/cubes.d.ts +126 -18
  100. package/dist/cubes.d.ts.map +1 -0
  101. package/dist/cubes.js +412 -4
  102. package/dist/cubes.js.map +1 -0
  103. package/dist/debug.d.ts.map +1 -0
  104. package/dist/debug.js +71 -1
  105. package/dist/debug.js.map +1 -0
  106. package/dist/direct-log.d.ts.map +1 -0
  107. package/dist/direct-log.js +11 -1
  108. package/dist/direct-log.js.map +1 -0
  109. package/dist/docs-sections.d.ts +11 -10
  110. package/dist/docs-sections.d.ts.map +1 -0
  111. package/dist/docs-sections.js +113 -3
  112. package/dist/docs-sections.js.map +1 -0
  113. package/dist/drone-lifecycle.d.ts +5 -21
  114. package/dist/drone-lifecycle.d.ts.map +1 -0
  115. package/dist/drone-lifecycle.js +57 -8
  116. package/dist/drone-lifecycle.js.map +1 -0
  117. package/dist/drone-management.d.ts +29 -0
  118. package/dist/drone-management.d.ts.map +1 -0
  119. package/dist/drone-management.js +109 -0
  120. package/dist/drone-management.js.map +1 -0
  121. package/dist/ensure-mcp-config.d.ts.map +1 -0
  122. package/dist/ensure-mcp-config.js +36 -1
  123. package/dist/ensure-mcp-config.js.map +1 -0
  124. package/dist/evict-drone.d.ts +10 -2
  125. package/dist/evict-drone.d.ts.map +1 -0
  126. package/dist/evict-drone.js +60 -1
  127. package/dist/evict-drone.js.map +1 -0
  128. package/dist/gc-orphan-inboxes.d.ts.map +1 -0
  129. package/dist/gc-orphan-inboxes.js +177 -1
  130. package/dist/gc-orphan-inboxes.js.map +1 -0
  131. package/dist/inbox-monitor.d.ts +1 -1
  132. package/dist/inbox-monitor.d.ts.map +1 -0
  133. package/dist/inbox-monitor.js +856 -3
  134. package/dist/inbox-monitor.js.map +1 -0
  135. package/dist/index.d.ts +6 -4
  136. package/dist/index.d.ts.map +1 -0
  137. package/dist/index.js +1034 -37
  138. package/dist/index.js.map +1 -0
  139. package/dist/launch-all-cmd.d.ts.map +1 -0
  140. package/dist/launch-all-cmd.js +377 -37
  141. package/dist/launch-all-cmd.js.map +1 -0
  142. package/dist/launch-all-command.d.ts.map +1 -0
  143. package/dist/launch-all-command.js +24 -1
  144. package/dist/launch-all-command.js.map +1 -0
  145. package/dist/launch-all-deps.d.ts +3 -8
  146. package/dist/launch-all-deps.d.ts.map +1 -0
  147. package/dist/launch-all-deps.js +99 -1
  148. package/dist/launch-all-deps.js.map +1 -0
  149. package/dist/launch-all-discovery.d.ts +1 -0
  150. package/dist/launch-all-discovery.d.ts.map +1 -0
  151. package/dist/launch-all-discovery.js +90 -4
  152. package/dist/launch-all-discovery.js.map +1 -0
  153. package/dist/launch-all-locks.d.ts.map +1 -0
  154. package/dist/launch-all-locks.js +54 -1
  155. package/dist/launch-all-locks.js.map +1 -0
  156. package/dist/launch-gate.d.ts +2 -2
  157. package/dist/launch-gate.d.ts.map +1 -0
  158. package/dist/launch-gate.js +73 -1
  159. package/dist/launch-gate.js.map +1 -0
  160. package/dist/lifecycle-log-guard.d.ts.map +1 -0
  161. package/dist/lifecycle-log-guard.js +93 -2
  162. package/dist/lifecycle-log-guard.js.map +1 -0
  163. package/dist/list-roles-render.d.ts.map +1 -0
  164. package/dist/list-roles-render.js +40 -6
  165. package/dist/list-roles-render.js.map +1 -0
  166. package/dist/local-log-routing.d.ts +19 -0
  167. package/dist/local-log-routing.d.ts.map +1 -0
  168. package/dist/local-log-routing.js +67 -0
  169. package/dist/local-log-routing.js.map +1 -0
  170. package/dist/local-manage-tool-result.d.ts +8 -0
  171. package/dist/local-manage-tool-result.d.ts.map +1 -0
  172. package/dist/local-manage-tool-result.js +10 -0
  173. package/dist/local-manage-tool-result.js.map +1 -0
  174. package/dist/local-server-cursor.d.ts +34 -0
  175. package/dist/local-server-cursor.d.ts.map +1 -0
  176. package/dist/local-server-cursor.js +151 -0
  177. package/dist/local-server-cursor.js.map +1 -0
  178. package/dist/log-audit.d.ts.map +1 -0
  179. package/dist/log-audit.js +194 -3
  180. package/dist/log-audit.js.map +1 -0
  181. package/dist/log-stream.d.ts +35 -18
  182. package/dist/log-stream.d.ts.map +1 -0
  183. package/dist/log-stream.js +1270 -12
  184. package/dist/log-stream.js.map +1 -0
  185. package/dist/model-presets.d.ts.map +1 -0
  186. package/dist/model-presets.js +19 -1
  187. package/dist/model-presets.js.map +1 -0
  188. package/dist/name-validator.d.ts.map +1 -0
  189. package/dist/name-validator.js +22 -1
  190. package/dist/name-validator.js.map +1 -0
  191. package/dist/opencode-drone.d.ts.map +1 -0
  192. package/dist/opencode-drone.js +438 -4
  193. package/dist/opencode-drone.js.map +1 -0
  194. package/dist/opencode-plugin.d.ts +1 -1
  195. package/dist/opencode-plugin.d.ts.map +1 -0
  196. package/dist/opencode-plugin.js +29 -4
  197. package/dist/opencode-plugin.js.map +1 -0
  198. package/dist/parse-assimilate-args.d.ts +1 -1
  199. package/dist/parse-assimilate-args.d.ts.map +1 -0
  200. package/dist/parse-assimilate-args.js +125 -1
  201. package/dist/parse-assimilate-args.js.map +1 -0
  202. package/dist/parse-launch-all-args.d.ts.map +1 -0
  203. package/dist/parse-launch-all-args.js +70 -1
  204. package/dist/parse-launch-all-args.js.map +1 -0
  205. package/dist/postinstall-banner.d.ts.map +1 -0
  206. package/dist/postinstall-banner.js +27 -2
  207. package/dist/postinstall-banner.js.map +1 -0
  208. package/dist/postinstall.d.ts.map +1 -0
  209. package/dist/postinstall.js +32 -5
  210. package/dist/postinstall.js.map +1 -0
  211. package/dist/readiness-probe.d.ts.map +1 -0
  212. package/dist/readiness-probe.js +9 -1
  213. package/dist/readiness-probe.js.map +1 -0
  214. package/dist/regen-format.d.ts.map +1 -0
  215. package/dist/regen-format.js +545 -13
  216. package/dist/regen-format.js.map +1 -0
  217. package/dist/regen.d.ts.map +1 -0
  218. package/dist/regen.js +141 -5
  219. package/dist/regen.js.map +1 -0
  220. package/dist/remote-client.d.ts +88 -173
  221. package/dist/remote-client.d.ts.map +1 -0
  222. package/dist/remote-client.js +997 -1
  223. package/dist/remote-client.js.map +1 -0
  224. package/dist/reset-local-seat-cmd.d.ts +50 -0
  225. package/dist/reset-local-seat-cmd.d.ts.map +1 -0
  226. package/dist/reset-local-seat-cmd.js +169 -0
  227. package/dist/reset-local-seat-cmd.js.map +1 -0
  228. package/dist/role-match.d.ts.map +1 -0
  229. package/dist/role-match.js +23 -1
  230. package/dist/role-match.js.map +1 -0
  231. package/dist/role-resolver.d.ts.map +1 -0
  232. package/dist/role-resolver.js +60 -1
  233. package/dist/role-resolver.js.map +1 -0
  234. package/dist/roster-render.d.ts.map +1 -0
  235. package/dist/roster-render.js +121 -3
  236. package/dist/roster-render.js.map +1 -0
  237. package/dist/seat-probe.d.ts +32 -13
  238. package/dist/seat-probe.d.ts.map +1 -0
  239. package/dist/seat-probe.js +78 -1
  240. package/dist/seat-probe.js.map +1 -0
  241. package/dist/seat-store.d.ts +76 -0
  242. package/dist/seat-store.d.ts.map +1 -0
  243. package/dist/seat-store.js +309 -0
  244. package/dist/seat-store.js.map +1 -0
  245. package/dist/seats.d.ts +375 -0
  246. package/dist/seats.d.ts.map +1 -0
  247. package/dist/seats.js +670 -0
  248. package/dist/seats.js.map +1 -0
  249. package/dist/self-path.d.ts +27 -0
  250. package/dist/self-path.d.ts.map +1 -0
  251. package/dist/self-path.js +43 -0
  252. package/dist/self-path.js.map +1 -0
  253. package/dist/server-endpoint.d.ts +9 -0
  254. package/dist/server-endpoint.d.ts.map +1 -0
  255. package/dist/server-endpoint.js +38 -0
  256. package/dist/server-endpoint.js.map +1 -0
  257. package/dist/server-errors.d.ts +50 -0
  258. package/dist/server-errors.d.ts.map +1 -0
  259. package/dist/server-errors.js +79 -0
  260. package/dist/server-errors.js.map +1 -0
  261. package/dist/server-handshake.d.ts +197 -0
  262. package/dist/server-handshake.d.ts.map +1 -0
  263. package/dist/server-handshake.js +533 -0
  264. package/dist/server-handshake.js.map +1 -0
  265. package/dist/server-response.d.ts +3 -0
  266. package/dist/server-response.d.ts.map +1 -0
  267. package/dist/server-response.js +67 -0
  268. package/dist/server-response.js.map +1 -0
  269. package/dist/server-trust.d.ts +14 -0
  270. package/dist/server-trust.d.ts.map +1 -0
  271. package/dist/server-trust.js +225 -0
  272. package/dist/server-trust.js.map +1 -0
  273. package/dist/session-continuity.d.ts +33 -0
  274. package/dist/session-continuity.d.ts.map +1 -0
  275. package/dist/session-continuity.js +220 -0
  276. package/dist/session-continuity.js.map +1 -0
  277. package/dist/setup-confirm.d.ts +3 -3
  278. package/dist/setup-confirm.d.ts.map +1 -0
  279. package/dist/setup-confirm.js +126 -2
  280. package/dist/setup-confirm.js.map +1 -0
  281. package/dist/setup.d.ts +5 -3
  282. package/dist/setup.d.ts.map +1 -0
  283. package/dist/setup.js +169 -46
  284. package/dist/setup.js.map +1 -0
  285. package/dist/shell-escape.d.ts.map +1 -0
  286. package/dist/shell-escape.js +22 -1
  287. package/dist/shell-escape.js.map +1 -0
  288. package/dist/spawn.d.ts +2 -2
  289. package/dist/spawn.d.ts.map +1 -0
  290. package/dist/spawn.js +29 -10
  291. package/dist/spawn.js.map +1 -0
  292. package/dist/startup-services.d.ts +0 -1
  293. package/dist/startup-services.d.ts.map +1 -0
  294. package/dist/startup-services.js +26 -1
  295. package/dist/startup-services.js.map +1 -0
  296. package/dist/stream-owner.d.ts +6 -2
  297. package/dist/stream-owner.d.ts.map +1 -0
  298. package/dist/stream-owner.js +547 -2
  299. package/dist/stream-owner.js.map +1 -0
  300. package/dist/stream-status.d.ts +1 -1
  301. package/dist/stream-status.d.ts.map +1 -0
  302. package/dist/stream-status.js +268 -3
  303. package/dist/stream-status.js.map +1 -0
  304. package/dist/sync-roles-render.d.ts.map +1 -0
  305. package/dist/sync-roles-render.js +118 -3
  306. package/dist/sync-roles-render.js.map +1 -0
  307. package/dist/sync.d.ts +1 -1
  308. package/dist/sync.d.ts.map +1 -0
  309. package/dist/sync.js +286 -22
  310. package/dist/sync.js.map +1 -0
  311. package/dist/terminal-title.d.ts.map +1 -0
  312. package/dist/terminal-title.js +68 -1
  313. package/dist/terminal-title.js.map +1 -0
  314. package/dist/token-store.d.ts +17 -111
  315. package/dist/token-store.d.ts.map +1 -0
  316. package/dist/token-store.js +81 -1
  317. package/dist/token-store.js.map +1 -0
  318. package/dist/tool-manifest.d.ts +4 -8
  319. package/dist/tool-manifest.d.ts.map +1 -0
  320. package/dist/tool-manifest.js +554 -1
  321. package/dist/tool-manifest.js.map +1 -0
  322. package/dist/tool-scope.d.ts +8 -12
  323. package/dist/tool-scope.d.ts.map +1 -0
  324. package/dist/tool-scope.js +97 -1
  325. package/dist/tool-scope.js.map +1 -0
  326. package/dist/types.d.ts +1 -5
  327. package/dist/types.d.ts.map +1 -0
  328. package/dist/types.js +5 -0
  329. package/dist/types.js.map +1 -0
  330. package/dist/unknown-subcommand.d.ts +1 -1
  331. package/dist/unknown-subcommand.d.ts.map +1 -0
  332. package/dist/unknown-subcommand.js +37 -1
  333. package/dist/unknown-subcommand.js.map +1 -0
  334. package/dist/version.d.ts +1 -1
  335. package/dist/version.d.ts.map +1 -0
  336. package/dist/version.js +78 -2
  337. package/dist/version.js.map +1 -0
  338. package/dist/working-repo.d.ts.map +1 -0
  339. package/dist/working-repo.js +81 -1
  340. package/dist/working-repo.js.map +1 -0
  341. package/dist/worktree-lifecycle.d.ts.map +1 -0
  342. package/dist/worktree-lifecycle.js +205 -2
  343. package/dist/worktree-lifecycle.js.map +1 -0
  344. package/docs/EXTRACTION_PROVENANCE.md +42 -0
  345. package/docs/LOCAL_SERVER.md +103 -0
  346. package/docs/RELEASING.md +129 -0
  347. package/package.json +52 -34
  348. package/src/agent-runtime.ts +69 -0
  349. package/src/assimilate-cmd.ts +1864 -0
  350. package/src/assimilate-deps.ts +444 -0
  351. package/src/assimilate-guard.ts +84 -0
  352. package/src/assimilate-welcome.ts +39 -0
  353. package/src/auth-env.ts +21 -0
  354. package/src/backends/launch-all-pastelist.ts +18 -0
  355. package/src/backends/launch-all-tmux.ts +75 -0
  356. package/src/backends/launch-all-windows.ts +110 -0
  357. package/src/bare-launch-menu.ts +148 -0
  358. package/src/claude-launch-args.ts +35 -0
  359. package/src/claude.ts +561 -0
  360. package/src/cleanup-cmd.ts +581 -0
  361. package/src/clear-rewake-core.ts +34 -0
  362. package/src/clear-rewake.ts +18 -0
  363. package/src/cli-help.ts +116 -0
  364. package/src/cli-platform.ts +127 -0
  365. package/src/cli-tool-approval.ts +716 -0
  366. package/src/codex-app-server.ts +238 -0
  367. package/src/codex-app-wake.ts +524 -0
  368. package/src/codex-launch.ts +140 -0
  369. package/src/codex-remote.ts +500 -0
  370. package/src/codex-wake-resolve.ts +155 -0
  371. package/src/config-utils.ts +811 -0
  372. package/src/config.ts +595 -0
  373. package/src/console-prefix.ts +99 -0
  374. package/src/cube-name.ts +69 -0
  375. package/src/cubes.ts +583 -0
  376. package/src/debug.ts +73 -0
  377. package/src/direct-log.ts +9 -0
  378. package/src/docs-sections.ts +129 -0
  379. package/src/drone-lifecycle.ts +62 -0
  380. package/src/drone-management.ts +162 -0
  381. package/src/ensure-mcp-config.ts +54 -0
  382. package/src/evict-drone.ts +82 -0
  383. package/src/gc-orphan-inboxes.ts +229 -0
  384. package/src/inbox-monitor.ts +1005 -0
  385. package/src/index.ts +1201 -0
  386. package/src/launch-all-cmd.ts +450 -0
  387. package/src/launch-all-command.ts +30 -0
  388. package/src/launch-all-deps.ts +188 -0
  389. package/src/launch-all-discovery.ts +118 -0
  390. package/src/launch-all-locks.ts +74 -0
  391. package/src/launch-gate.ts +80 -0
  392. package/src/lifecycle-log-guard.ts +144 -0
  393. package/src/list-roles-render.ts +52 -0
  394. package/src/local-log-routing.ts +106 -0
  395. package/src/local-manage-tool-result.ts +10 -0
  396. package/src/local-server-cursor.ts +188 -0
  397. package/src/log-audit.ts +207 -0
  398. package/src/log-stream.ts +1567 -0
  399. package/src/model-presets.ts +22 -0
  400. package/src/name-validator.ts +23 -0
  401. package/src/opencode-drone.ts +528 -0
  402. package/src/opencode-plugin.ts +38 -0
  403. package/src/parse-assimilate-args.ts +125 -0
  404. package/src/parse-launch-all-args.ts +100 -0
  405. package/src/postinstall-banner.ts +37 -0
  406. package/src/postinstall.ts +36 -0
  407. package/src/readiness-probe.ts +12 -0
  408. package/src/regen-format.ts +651 -0
  409. package/src/regen.ts +150 -0
  410. package/src/remote-client.ts +1457 -0
  411. package/src/reset-local-seat-cmd.ts +227 -0
  412. package/src/role-match.ts +29 -0
  413. package/src/role-resolver.ts +93 -0
  414. package/src/roster-render.ts +196 -0
  415. package/src/seat-probe.ts +115 -0
  416. package/src/seat-store.ts +333 -0
  417. package/src/seats.ts +911 -0
  418. package/src/self-path.ts +51 -0
  419. package/src/server-endpoint.ts +38 -0
  420. package/src/server-errors.ts +95 -0
  421. package/src/server-handshake.ts +816 -0
  422. package/src/server-response.ts +76 -0
  423. package/src/server-trust.ts +245 -0
  424. package/src/session-continuity.ts +280 -0
  425. package/src/setup-confirm.ts +171 -0
  426. package/src/setup.ts +186 -0
  427. package/src/shell-escape.ts +22 -0
  428. package/src/spawn.ts +31 -0
  429. package/src/startup-services.ts +36 -0
  430. package/src/stream-owner.ts +686 -0
  431. package/src/stream-status.ts +337 -0
  432. package/src/sync-roles-render.ts +163 -0
  433. package/src/sync.ts +363 -0
  434. package/src/terminal-title.ts +76 -0
  435. package/src/token-store.ts +102 -0
  436. package/src/tool-manifest.ts +610 -0
  437. package/src/tool-scope.ts +110 -0
  438. package/src/types.ts +5 -0
  439. package/src/unknown-subcommand.ts +35 -0
  440. package/src/version.ts +82 -0
  441. package/src/working-repo.ts +99 -0
  442. package/src/worktree-lifecycle.ts +254 -0
  443. package/dist/auth-recovery.d.ts +0 -33
  444. package/dist/auth-recovery.js +0 -1
  445. package/dist/auth.d.ts +0 -103
  446. package/dist/auth.js +0 -39
  447. package/dist/device-auth.d.ts +0 -75
  448. package/dist/device-auth.js +0 -1
  449. package/dist/drone-address.d.ts +0 -26
  450. package/dist/drone-address.js +0 -1
  451. package/dist/get-started.d.ts +0 -20
  452. package/dist/get-started.js +0 -2
  453. package/dist/health-beat.d.ts +0 -134
  454. package/dist/health-beat.js +0 -1
  455. package/dist/role-section.d.ts +0 -110
  456. package/dist/role-section.js +0 -8
  457. package/dist/setup-action.d.ts +0 -20
  458. package/dist/setup-action.js +0 -1
  459. package/dist/stale-version-check.d.ts +0 -40
  460. package/dist/stale-version-check.js +0 -1
  461. package/dist/subscription-retry.d.ts +0 -40
  462. package/dist/subscription-retry.js +0 -1
  463. package/dist/templates.d.ts +0 -107
  464. package/dist/templates.js +0 -359
  465. package/dist/token-crypto.d.ts +0 -50
  466. package/dist/token-crypto.js +0 -1
@@ -0,0 +1,171 @@
1
+ /**
2
+ * gh#818 P3 — disclose + confirm the `borg setup` global-config mutation.
3
+ *
4
+ * Step-1 of the setup wizard writes the user's GLOBAL agent config
5
+ * (registers the borg MCP server + hooks). Before gh#818 this happened
6
+ * silently on first run. This module adds informed-consent disclosure:
7
+ * it lists WHICH files will be written (well-known `os.homedir()` paths)
8
+ * and asks to continue before the first mutation.
9
+ *
10
+ * Pure / dep-injected (mirrors `resolveCliChoice` + `setup-action.ts`) so
11
+ * the decision is unit-testable without spawning a prompt or touching argv.
12
+ *
13
+ * SECURITY (SR-light, gh#818 221c43df): the disclosure lists file PATHS +
14
+ * at most the PUBLIC `BORG_API_URL` — there is NO token/secret in the
15
+ * written config to echo. Local credentials live in the local 0600-permission
16
+ * seat store, and the written config never contains a token or secret.
17
+ */
18
+
19
+ export interface ConfigMutationTarget {
20
+ /** Human-readable config file path (tilde form). */
21
+ file: string;
22
+ /** What is added to it. */
23
+ change: string;
24
+ }
25
+
26
+ /**
27
+ * The set of global config files Step-1 writes, scoped to the detected
28
+ * agent CLIs. Paths mirror `config-utils.ts`:
29
+ * Claude Code: ~/.claude.json (MCP server) + ~/.claude/settings.json (hook)
30
+ * Codex: ~/.codex/config.toml (MCP server) + ~/.codex/hooks.json (hooks)
31
+ * OpenCode: ~/.config/opencode/opencode.json (MCP server)
32
+ */
33
+ export function configMutationTargets(deps: {
34
+ claude: boolean;
35
+ codex: boolean;
36
+ opencode?: boolean;
37
+ }): ConfigMutationTarget[] {
38
+ const targets: ConfigMutationTarget[] = [];
39
+ if (deps.claude) {
40
+ targets.push({
41
+ file: '~/.claude.json',
42
+ change: 'registers the borg MCP server',
43
+ });
44
+ targets.push({
45
+ file: '~/.claude/settings.json',
46
+ change: 'adds a UserPromptSubmit hook',
47
+ });
48
+ }
49
+ if (deps.codex) {
50
+ targets.push({
51
+ file: '~/.codex/config.toml',
52
+ change: 'registers the borg MCP server',
53
+ });
54
+ targets.push({
55
+ file: '~/.codex/hooks.json',
56
+ change: 'adds SessionStart + UserPromptSubmit hooks',
57
+ });
58
+ }
59
+ if (deps.opencode) {
60
+ targets.push({
61
+ file: '~/.config/opencode/opencode.json',
62
+ change: 'registers the borg MCP server (with BORG_SESSION activation)',
63
+ });
64
+ }
65
+ return targets;
66
+ }
67
+
68
+ /**
69
+ * Disclosure text: the files Step-1 will write + an undo note. Pure so SR
70
+ * can pin "lists paths only, no secret". Lists the public `BORG_API_URL`
71
+ * only by reference (the MCP-server registration env), never a credential.
72
+ */
73
+ export function formatConfigMutationDisclosure(
74
+ targets: ConfigMutationTarget[]
75
+ ): string {
76
+ const lines: string[] = [];
77
+ lines.push('borg setup will register the borg MCP server in your agent config:');
78
+ for (const t of targets) {
79
+ lines.push(` • ${t.file} (${t.change})`);
80
+ }
81
+ lines.push(
82
+ 'These changes are additive and reversible — remove the "borg" entries to undo.'
83
+ );
84
+ return lines.join('\n');
85
+ }
86
+
87
+ export type ConfirmDecision = 'proceed' | 'abort';
88
+
89
+ export interface ConfirmConfigMutationDeps {
90
+ /** `process.stdin.isTTY === true`. */
91
+ isTTY: boolean;
92
+ /** `--yes` / `-y` present in argv. */
93
+ yes: boolean;
94
+ /**
95
+ * Injected interactive confirm — returns the user's yes(true)/no(false).
96
+ * Only invoked in the TTY-and-not-`--yes` path; NEVER called otherwise
97
+ * (so a non-TTY never reads stdin — see item 1 below).
98
+ */
99
+ confirm: () => Promise<boolean>;
100
+ }
101
+
102
+ /**
103
+ * Decide whether to proceed with the Step-1 config mutation.
104
+ *
105
+ * The six CR-binding build-gate items (gh#818, 3b3e85a5) live here:
106
+ * 1. (THE load-bearing headless no-regress) non-TTY → 'proceed' WITHOUT
107
+ * prompting. We return before touching `confirm`, so a non-TTY run
108
+ * (CI / pipe / headless) never reads stdin → no hang.
109
+ * 2. `--yes`/`-y` → 'proceed' without prompting (scripted-but-TTY +
110
+ * explicit non-interactive). No collision with --no-browser/--device.
111
+ * 3. TTY + interactive → ask; decline → 'abort' (the caller exits BEFORE
112
+ * any write).
113
+ * 6. This dep-injected shape IS the testable seam.
114
+ */
115
+ export async function confirmConfigMutation(
116
+ deps: ConfirmConfigMutationDeps
117
+ ): Promise<ConfirmDecision> {
118
+ if (!deps.isTTY) return 'proceed'; // item 1 — never block on stdin
119
+ if (deps.yes) return 'proceed'; // item 2 — explicit bypass
120
+ const ok = await deps.confirm(); // item 3 — interactive consent
121
+ return ok ? 'proceed' : 'abort';
122
+ }
123
+
124
+ /**
125
+ * Scan argv for the `--yes` / `-y` bypass. Kept separate so the flag set
126
+ * is pinned in tests (item 2 — no collision with the existing
127
+ * --no-browser/--device scan in setup.ts).
128
+ */
129
+ export function parseYesFlag(argv: string[]): boolean {
130
+ return argv.includes('--yes') || argv.includes('-y');
131
+ }
132
+
133
+ /**
134
+ * gh#844 — whether Step-1 has ANY config mutation worth disclosing.
135
+ *
136
+ * The disclosure + confirm prompt exists to obtain informed consent for the
137
+ * config writes Step-1 performs (gh#818). On a pure refresh — the normal
138
+ * setup re-run where every DETECTED agent CLI already has the full
139
+ * borg setup (MCP server registered AND every hook write already applied) —
140
+ * there is no mutation to consent to, so the prompt is redundant and skipped.
141
+ *
142
+ * CRITICAL (gh#844 SR finding 8d9c732e): the gate must cover the FULL disclosed
143
+ * mutation set — MCP registration AND every hook write (claude UserPromptSubmit
144
+ * + the legacy SessionStart removal; codex SessionStart + UserPromptSubmit) —
145
+ * not MCP registration alone. Otherwise an MCP-configured user with a pending
146
+ * hook write (e.g. a pre-gh#673 upgrader whose legacy global hook must be
147
+ * removed) would have settings.json mutated with consent silently skipped.
148
+ * Caller derives `claudeHookPending`/`codexHookPending` from the SAME peeks
149
+ * that gate the individual writers, so the gate and the writers cannot drift.
150
+ *
151
+ * Scoped to DETECTED CLIs: a claude-only user is never gated on codex config
152
+ * state (and vice-versa). A naive `!isMcpServerConfigured() ||
153
+ * !isCodexMcpServerConfigured()` gate would mis-fire for single-CLI users —
154
+ * the absent CLI's config is unconfigured, so the OR would always be true.
155
+ */
156
+ export function setupMutationPending(deps: {
157
+ claude: boolean;
158
+ codex: boolean;
159
+ opencode: boolean;
160
+ claudeMcpConfigured: boolean;
161
+ codexMcpConfigured: boolean;
162
+ opencodeMcpConfigured: boolean;
163
+ claudeHookPending: boolean;
164
+ codexHookPending: boolean;
165
+ }): boolean {
166
+ return (
167
+ (deps.claude && (!deps.claudeMcpConfigured || deps.claudeHookPending)) ||
168
+ (deps.codex && (!deps.codexMcpConfigured || deps.codexHookPending)) ||
169
+ (deps.opencode && !deps.opencodeMcpConfigured)
170
+ );
171
+ }
package/src/setup.ts ADDED
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Borg MCP Setup Wizard
4
+ *
5
+ * Interactive setup flow:
6
+ * 1. Configure agent CLI MCP settings + orientation hooks
7
+ * 2. Print how to connect to a local self-hosted Borg server
8
+ *
9
+ * There is no cloud authority: setup offers/executes NO cloud auth, Google
10
+ * auth, subscription, or checkout.
11
+ */
12
+
13
+ import prompts from 'prompts';
14
+ import chalk from 'chalk';
15
+ import which from 'which';
16
+ import {
17
+ confirmConfigMutation,
18
+ configMutationTargets,
19
+ formatConfigMutationDisclosure,
20
+ parseYesFlag,
21
+ setupMutationPending,
22
+ } from './setup-confirm.js';
23
+ import {
24
+ addUserPromptSubmitHook,
25
+ addCodexSessionStartHook,
26
+ addCodexUserPromptSubmitHook,
27
+ isMcpServerConfigured,
28
+ isCodexMcpServerConfigured,
29
+ isOpenCodeMcpServerConfigured,
30
+ isSessionStartHookRegistered,
31
+ isUserPromptSubmitHookRegistered,
32
+ isCodexSessionStartHookRegistered,
33
+ isCodexUserPromptSubmitHookRegistered,
34
+ removeSessionStartHook,
35
+ } from './config-utils.js';
36
+ import { ensureCliMcpConfigured } from './ensure-mcp-config.js';
37
+ import { handleVersionFlag } from './version.js';
38
+ import { initDebugFromArgv } from './debug.js';
39
+ import { defaultApprovalIo, setupApprovalWarnings } from './cli-tool-approval.js';
40
+
41
+ /**
42
+ * Main setup wizard
43
+ */
44
+ async function main() {
45
+ initDebugFromArgv(process.argv);
46
+ handleVersionFlag();
47
+ console.log(chalk.blue.bold('\n◼ Borg MCP Setup Wizard ◼'));
48
+
49
+ let claudeCliPath: string | null = null;
50
+ let codexCliPath: string | null = null;
51
+ let opencodeCliPath: string | null = null;
52
+ try { claudeCliPath = which.sync('claude'); } catch { /* optional */ }
53
+ try { codexCliPath = which.sync('codex'); } catch { /* optional */ }
54
+ try { opencodeCliPath = which.sync('opencode'); } catch { /* optional */ }
55
+
56
+ if (claudeCliPath) console.log(chalk.gray(`Found Claude CLI: ${claudeCliPath}`));
57
+ if (codexCliPath) console.log(chalk.gray(`Found Codex CLI: ${codexCliPath}`));
58
+ if (opencodeCliPath) console.log(chalk.gray(`Found OpenCode CLI: ${opencodeCliPath}`));
59
+ if (claudeCliPath || codexCliPath || opencodeCliPath) console.log('');
60
+
61
+ if (!claudeCliPath && !codexCliPath && !opencodeCliPath) {
62
+ console.error(chalk.red('◼ No supported agent CLI found\n'));
63
+ console.error(chalk.yellow('Please install Claude Code, Codex, or OpenCode first:'));
64
+ console.error(chalk.gray(' Claude Code: https://claude.ai/download'));
65
+ console.error(chalk.gray(' Codex: https://developers.openai.com/codex'));
66
+ console.error(chalk.gray(' OpenCode: https://opencode.ai\n'));
67
+ process.exit(1);
68
+ }
69
+
70
+ // Step 1: Configure every detected agent CLI
71
+ console.log(chalk.blue('◼ Agent CLI Integration'));
72
+
73
+ const yes = parseYesFlag(process.argv);
74
+
75
+ const claudeDetected = claudeCliPath !== null;
76
+ const codexDetected = codexCliPath !== null;
77
+ const opencodeDetected = opencodeCliPath !== null;
78
+ const claudeMcpConfigured = isMcpServerConfigured();
79
+ const codexMcpConfigured = isCodexMcpServerConfigured();
80
+ const opencodeMcpConfigured = isOpenCodeMcpServerConfigured();
81
+ const claudeLegacyHookPending = claudeDetected && isSessionStartHookRegistered();
82
+ const claudeUpsHookPending = claudeDetected && !isUserPromptSubmitHookRegistered();
83
+ const codexSessionHookPending = codexDetected && !isCodexSessionStartHookRegistered();
84
+ const codexUpsHookPending = codexDetected && !isCodexUserPromptSubmitHookRegistered();
85
+ const claudeHookPending = claudeLegacyHookPending || claudeUpsHookPending;
86
+ const codexHookPending = codexSessionHookPending || codexUpsHookPending;
87
+
88
+ if (
89
+ setupMutationPending({
90
+ claude: claudeDetected,
91
+ codex: codexDetected,
92
+ opencode: opencodeDetected,
93
+ claudeMcpConfigured,
94
+ codexMcpConfigured,
95
+ opencodeMcpConfigured,
96
+ claudeHookPending,
97
+ codexHookPending,
98
+ })
99
+ ) {
100
+ console.log(
101
+ formatConfigMutationDisclosure(
102
+ configMutationTargets({ claude: claudeDetected, codex: codexDetected, opencode: opencodeDetected })
103
+ )
104
+ );
105
+ const mutationDecision = await confirmConfigMutation({
106
+ isTTY: process.stdin.isTTY === true,
107
+ yes,
108
+ confirm: async () => {
109
+ const { proceed } = await prompts({
110
+ type: 'confirm',
111
+ name: 'proceed',
112
+ message: 'Continue with these changes?',
113
+ initial: true,
114
+ });
115
+ return proceed === true;
116
+ },
117
+ });
118
+ if (mutationDecision === 'abort') {
119
+ console.log(chalk.yellow('\n◼ Setup cancelled — no changes made.\n'));
120
+ process.exit(0);
121
+ }
122
+ }
123
+ console.log('');
124
+
125
+ if (claudeCliPath) {
126
+ try {
127
+ ensureCliMcpConfigured('claude');
128
+ if (claudeLegacyHookPending) removeSessionStartHook();
129
+ if (claudeUpsHookPending) addUserPromptSubmitHook();
130
+ console.log(chalk.green('◼ borg configured for Claude Code'));
131
+ } catch (error: any) {
132
+ console.error(chalk.red(`\n◼ Failed to configure Claude Code: ${error.message}\n`));
133
+ process.exit(1);
134
+ }
135
+ }
136
+ if (codexCliPath) {
137
+ try {
138
+ ensureCliMcpConfigured('codex');
139
+ if (codexSessionHookPending) addCodexSessionStartHook();
140
+ if (codexUpsHookPending) addCodexUserPromptSubmitHook();
141
+ console.log(chalk.green('◼ borg configured for Codex'));
142
+ } catch (error: any) {
143
+ console.error(chalk.red(`\n◼ Failed to configure Codex: ${error.message}\n`));
144
+ process.exit(1);
145
+ }
146
+ }
147
+ if (opencodeCliPath) {
148
+ try {
149
+ ensureCliMcpConfigured('opencode');
150
+ console.log(chalk.green('◼ borg configured for OpenCode'));
151
+ } catch (error: any) {
152
+ console.error(chalk.red(`\n◼ Failed to configure OpenCode: ${error.message}\n`));
153
+ process.exit(1);
154
+ }
155
+ }
156
+ const approvalIo = defaultApprovalIo(async () => '', () => false, {
157
+ cwd: process.cwd(),
158
+ env: process.env,
159
+ codexArgs: [],
160
+ });
161
+ for (const warning of await setupApprovalWarnings(approvalIo, {
162
+ codex: codexDetected,
163
+ opencode: opencodeDetected,
164
+ })) {
165
+ console.log(chalk.yellow(`warning: ${warning}`));
166
+ }
167
+ console.log('');
168
+
169
+ // Step 2: Server connection — local self-hosted only.
170
+ console.log(chalk.blue('◼ Server Connection'));
171
+ console.log(chalk.gray('Local self-hosted server mode — no account or subscription needed.'));
172
+
173
+ // Success message
174
+ console.log(chalk.green.bold('\nSetup complete!\n'));
175
+ console.log(chalk.yellow('🔄 Restart Claude Code / Codex / OpenCode (or open a new session) for the changes to take effect.\n'));
176
+ console.log(chalk.gray('◼ Next steps:'));
177
+ console.log(chalk.gray('1. cd into your project, then run "borg assimilate --host <host>" to join a cube'));
178
+ console.log(chalk.gray(' (this connects to your local server and launches your agent)'));
179
+ console.log(chalk.gray('2. Use `borg assimilate --host <host> --enroll` from the operator terminal to enroll a new client\n'));
180
+ }
181
+
182
+ // Run wizard
183
+ main().catch((error) => {
184
+ console.error(chalk.red(`\n◼ Setup failed: ${error.message}\n`));
185
+ process.exit(1);
186
+ });
@@ -0,0 +1,22 @@
1
+ // POSIX-safe shell-escaping for paste-intended emission.
2
+ //
3
+ // Sprint 18 (gh-tracked via dispatch 10:41:47Z): when the CLI emits a
4
+ // `cd <path>` line for the user to copy-paste into their shell, the path is
5
+ // a filesystem-controlled string with no character constraints (unlike
6
+ // DB-CHECK-constrained role/cube names). Paths can legally contain spaces,
7
+ // `$VAR`, backticks, `$(cmd)`, embedded single-quotes, and other shell
8
+ // metacharacters that would execute on paste under naive emission.
9
+ //
10
+ // drone-11 SR-LANE (cube entry 2026-05-19T10:44:35Z) escalation: double-
11
+ // quoting handles spaces but `$VAR` / backtick / `$(cmd)` still expand
12
+ // inside double-quotes. Single-quotes with internal-quote escape (`'\''`
13
+ // = close-quote / escaped-quote / re-open-quote) defang every shell
14
+ // metachar including embedded `'`. POSIX-defined, copy-paste-runnable
15
+ // across bash / zsh / dash / sh.
16
+ //
17
+ // Behavior: returns the input wrapped in single-quotes with any internal
18
+ // `'` rewritten as `'\''`. Empty string returns `''`.
19
+
20
+ export function shellEscape(s: string): string {
21
+ return `'${s.replace(/'/g, `'\\''`)}'`;
22
+ }
package/src/spawn.ts ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `borg spawn` — deprecation stub.
3
+ *
4
+ * Replaced by `borg assimilate [role] --worktree <name>` (see
5
+ * `assimilate-cmd.ts`). The new command folds worktree creation,
6
+ * cube creation, template application, and drone assimilation into one
7
+ * shell call. This file remains so existing
8
+ * scripts and tab-completion entries fail loudly with an actionable
9
+ * migration message rather than silently mis-routing.
10
+ *
11
+ * `validateName` continues to be re-exported from here for callers
12
+ * that still depend on the symbol (it lives in `name-validator.ts`
13
+ * now — single source of truth).
14
+ */
15
+
16
+ export { validateName } from './name-validator.js';
17
+
18
+ export async function runSpawn(): Promise<number> {
19
+ const msg =
20
+ 'borg spawn is removed. Use:\n' +
21
+ ' borg assimilate [role] --worktree <name>\n' +
22
+ '\n' +
23
+ 'Example: if you previously ran `borg spawn drone-2`, the equivalent is\n' +
24
+ ' borg assimilate --worktree drone-2\n' +
25
+ '(role is optional; defaults per first-drone rules)\n' +
26
+ '\n' +
27
+ 'If you want a specific role:\n' +
28
+ ' borg assimilate builder --worktree drone-2\n';
29
+ process.stderr.write(msg);
30
+ return 2;
31
+ }
@@ -0,0 +1,36 @@
1
+ export type McpStartupTask = () => void | Promise<void>;
2
+
3
+ /** Required named services: omission from index wiring is a type error. */
4
+ export interface McpStartupServices {
5
+ sessionStartHook: McpStartupTask;
6
+ auditHook: McpStartupTask;
7
+ sseStream: McpStartupTask;
8
+ openCode: McpStartupTask;
9
+ }
10
+
11
+ /**
12
+ * Run normal long-lived MCP child startup work. The assimilation readiness
13
+ * child must reach the initialize response without acquiring leases, fetching
14
+ * SSE, mutating hooks, or starting timers because it is intentionally killed
15
+ * immediately after that response.
16
+ */
17
+ export async function runMcpStartupServices(
18
+ readinessProbe: boolean,
19
+ services: McpStartupServices
20
+ ): Promise<void> {
21
+ if (readinessProbe) return;
22
+ const tasks = [
23
+ services.sessionStartHook,
24
+ services.auditHook,
25
+ services.sseStream,
26
+ services.openCode,
27
+ ];
28
+ for (const task of tasks) {
29
+ try {
30
+ await task();
31
+ } catch {
32
+ // Every background service is best-effort and independent. A failure in
33
+ // one must neither break MCP initialize nor suppress later services.
34
+ }
35
+ }
36
+ }