borgmcp 1.1.15 → 2.0.1

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 (459) 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.map +1 -0
  71. package/dist/codex-app-wake.js +432 -2
  72. package/dist/codex-app-wake.js.map +1 -0
  73. package/dist/codex-launch.d.ts.map +1 -0
  74. package/dist/codex-launch.js +102 -2
  75. package/dist/codex-launch.js.map +1 -0
  76. package/dist/codex-remote.d.ts +6 -1
  77. package/dist/codex-remote.d.ts.map +1 -0
  78. package/dist/codex-remote.js +394 -1
  79. package/dist/codex-remote.js.map +1 -0
  80. package/dist/codex-wake-resolve.d.ts.map +1 -0
  81. package/dist/codex-wake-resolve.js +127 -1
  82. package/dist/codex-wake-resolve.js.map +1 -0
  83. package/dist/config-utils.d.ts +2 -2
  84. package/dist/config-utils.d.ts.map +1 -0
  85. package/dist/config-utils.js +766 -3
  86. package/dist/config-utils.js.map +1 -0
  87. package/dist/config.d.ts +98 -61
  88. package/dist/config.d.ts.map +1 -0
  89. package/dist/config.js +426 -1
  90. package/dist/config.js.map +1 -0
  91. package/dist/console-prefix.d.ts.map +1 -0
  92. package/dist/console-prefix.js +96 -1
  93. package/dist/console-prefix.js.map +1 -0
  94. package/dist/cube-name.d.ts.map +1 -0
  95. package/dist/cube-name.js +67 -1
  96. package/dist/cube-name.js.map +1 -0
  97. package/dist/cubes.d.ts +126 -18
  98. package/dist/cubes.d.ts.map +1 -0
  99. package/dist/cubes.js +412 -4
  100. package/dist/cubes.js.map +1 -0
  101. package/dist/debug.d.ts.map +1 -0
  102. package/dist/debug.js +71 -1
  103. package/dist/debug.js.map +1 -0
  104. package/dist/direct-log.d.ts.map +1 -0
  105. package/dist/direct-log.js +11 -1
  106. package/dist/direct-log.js.map +1 -0
  107. package/dist/docs-sections.d.ts +11 -10
  108. package/dist/docs-sections.d.ts.map +1 -0
  109. package/dist/docs-sections.js +113 -3
  110. package/dist/docs-sections.js.map +1 -0
  111. package/dist/drone-lifecycle.d.ts +5 -21
  112. package/dist/drone-lifecycle.d.ts.map +1 -0
  113. package/dist/drone-lifecycle.js +57 -8
  114. package/dist/drone-lifecycle.js.map +1 -0
  115. package/dist/drone-management.d.ts +29 -0
  116. package/dist/drone-management.d.ts.map +1 -0
  117. package/dist/drone-management.js +109 -0
  118. package/dist/drone-management.js.map +1 -0
  119. package/dist/ensure-mcp-config.d.ts.map +1 -0
  120. package/dist/ensure-mcp-config.js +36 -1
  121. package/dist/ensure-mcp-config.js.map +1 -0
  122. package/dist/evict-drone.d.ts +10 -2
  123. package/dist/evict-drone.d.ts.map +1 -0
  124. package/dist/evict-drone.js +60 -1
  125. package/dist/evict-drone.js.map +1 -0
  126. package/dist/gc-orphan-inboxes.d.ts.map +1 -0
  127. package/dist/gc-orphan-inboxes.js +177 -1
  128. package/dist/gc-orphan-inboxes.js.map +1 -0
  129. package/dist/inbox-monitor.d.ts +1 -1
  130. package/dist/inbox-monitor.d.ts.map +1 -0
  131. package/dist/inbox-monitor.js +856 -3
  132. package/dist/inbox-monitor.js.map +1 -0
  133. package/dist/index.d.ts +6 -4
  134. package/dist/index.d.ts.map +1 -0
  135. package/dist/index.js +1034 -37
  136. package/dist/index.js.map +1 -0
  137. package/dist/launch-all-cmd.d.ts.map +1 -0
  138. package/dist/launch-all-cmd.js +377 -37
  139. package/dist/launch-all-cmd.js.map +1 -0
  140. package/dist/launch-all-command.d.ts.map +1 -0
  141. package/dist/launch-all-command.js +24 -1
  142. package/dist/launch-all-command.js.map +1 -0
  143. package/dist/launch-all-deps.d.ts +3 -8
  144. package/dist/launch-all-deps.d.ts.map +1 -0
  145. package/dist/launch-all-deps.js +99 -1
  146. package/dist/launch-all-deps.js.map +1 -0
  147. package/dist/launch-all-discovery.d.ts +1 -0
  148. package/dist/launch-all-discovery.d.ts.map +1 -0
  149. package/dist/launch-all-discovery.js +90 -4
  150. package/dist/launch-all-discovery.js.map +1 -0
  151. package/dist/launch-all-locks.d.ts.map +1 -0
  152. package/dist/launch-all-locks.js +54 -1
  153. package/dist/launch-all-locks.js.map +1 -0
  154. package/dist/launch-gate.d.ts +2 -2
  155. package/dist/launch-gate.d.ts.map +1 -0
  156. package/dist/launch-gate.js +73 -1
  157. package/dist/launch-gate.js.map +1 -0
  158. package/dist/lifecycle-log-guard.d.ts.map +1 -0
  159. package/dist/lifecycle-log-guard.js +93 -2
  160. package/dist/lifecycle-log-guard.js.map +1 -0
  161. package/dist/list-roles-render.d.ts.map +1 -0
  162. package/dist/list-roles-render.js +40 -6
  163. package/dist/list-roles-render.js.map +1 -0
  164. package/dist/local-log-routing.d.ts +19 -0
  165. package/dist/local-log-routing.d.ts.map +1 -0
  166. package/dist/local-log-routing.js +67 -0
  167. package/dist/local-log-routing.js.map +1 -0
  168. package/dist/local-manage-tool-result.d.ts +8 -0
  169. package/dist/local-manage-tool-result.d.ts.map +1 -0
  170. package/dist/local-manage-tool-result.js +10 -0
  171. package/dist/local-manage-tool-result.js.map +1 -0
  172. package/dist/local-server-cursor.d.ts +34 -0
  173. package/dist/local-server-cursor.d.ts.map +1 -0
  174. package/dist/local-server-cursor.js +151 -0
  175. package/dist/local-server-cursor.js.map +1 -0
  176. package/dist/log-audit.d.ts.map +1 -0
  177. package/dist/log-audit.js +194 -3
  178. package/dist/log-audit.js.map +1 -0
  179. package/dist/log-stream.d.ts +31 -18
  180. package/dist/log-stream.d.ts.map +1 -0
  181. package/dist/log-stream.js +1214 -12
  182. package/dist/log-stream.js.map +1 -0
  183. package/dist/model-presets.d.ts.map +1 -0
  184. package/dist/model-presets.js +19 -1
  185. package/dist/model-presets.js.map +1 -0
  186. package/dist/name-validator.d.ts.map +1 -0
  187. package/dist/name-validator.js +22 -1
  188. package/dist/name-validator.js.map +1 -0
  189. package/dist/opencode-drone.d.ts.map +1 -0
  190. package/dist/opencode-drone.js +438 -4
  191. package/dist/opencode-drone.js.map +1 -0
  192. package/dist/opencode-plugin.d.ts +1 -1
  193. package/dist/opencode-plugin.d.ts.map +1 -0
  194. package/dist/opencode-plugin.js +29 -4
  195. package/dist/opencode-plugin.js.map +1 -0
  196. package/dist/parse-assimilate-args.d.ts +1 -1
  197. package/dist/parse-assimilate-args.d.ts.map +1 -0
  198. package/dist/parse-assimilate-args.js +125 -1
  199. package/dist/parse-assimilate-args.js.map +1 -0
  200. package/dist/parse-launch-all-args.d.ts.map +1 -0
  201. package/dist/parse-launch-all-args.js +70 -1
  202. package/dist/parse-launch-all-args.js.map +1 -0
  203. package/dist/postinstall-banner.d.ts.map +1 -0
  204. package/dist/postinstall-banner.js +27 -2
  205. package/dist/postinstall-banner.js.map +1 -0
  206. package/dist/postinstall.d.ts.map +1 -0
  207. package/dist/postinstall.js +32 -5
  208. package/dist/postinstall.js.map +1 -0
  209. package/dist/readiness-probe.d.ts.map +1 -0
  210. package/dist/readiness-probe.js +9 -1
  211. package/dist/readiness-probe.js.map +1 -0
  212. package/dist/regen-format.d.ts.map +1 -0
  213. package/dist/regen-format.js +545 -13
  214. package/dist/regen-format.js.map +1 -0
  215. package/dist/regen.d.ts.map +1 -0
  216. package/dist/regen.js +141 -5
  217. package/dist/regen.js.map +1 -0
  218. package/dist/remote-client.d.ts +65 -175
  219. package/dist/remote-client.d.ts.map +1 -0
  220. package/dist/remote-client.js +942 -1
  221. package/dist/remote-client.js.map +1 -0
  222. package/dist/reset-local-seat-cmd.d.ts +50 -0
  223. package/dist/reset-local-seat-cmd.d.ts.map +1 -0
  224. package/dist/reset-local-seat-cmd.js +169 -0
  225. package/dist/reset-local-seat-cmd.js.map +1 -0
  226. package/dist/role-match.d.ts.map +1 -0
  227. package/dist/role-match.js +23 -1
  228. package/dist/role-match.js.map +1 -0
  229. package/dist/role-resolver.d.ts.map +1 -0
  230. package/dist/role-resolver.js +60 -1
  231. package/dist/role-resolver.js.map +1 -0
  232. package/dist/roster-render.d.ts.map +1 -0
  233. package/dist/roster-render.js +121 -3
  234. package/dist/roster-render.js.map +1 -0
  235. package/dist/seat-probe.d.ts +32 -13
  236. package/dist/seat-probe.d.ts.map +1 -0
  237. package/dist/seat-probe.js +78 -1
  238. package/dist/seat-probe.js.map +1 -0
  239. package/dist/seat-store.d.ts +76 -0
  240. package/dist/seat-store.d.ts.map +1 -0
  241. package/dist/seat-store.js +309 -0
  242. package/dist/seat-store.js.map +1 -0
  243. package/dist/seats.d.ts +303 -0
  244. package/dist/seats.d.ts.map +1 -0
  245. package/dist/seats.js +551 -0
  246. package/dist/seats.js.map +1 -0
  247. package/dist/self-path.d.ts +27 -0
  248. package/dist/self-path.d.ts.map +1 -0
  249. package/dist/self-path.js +43 -0
  250. package/dist/self-path.js.map +1 -0
  251. package/dist/server-endpoint.d.ts +9 -0
  252. package/dist/server-endpoint.d.ts.map +1 -0
  253. package/dist/server-endpoint.js +38 -0
  254. package/dist/server-endpoint.js.map +1 -0
  255. package/dist/server-errors.d.ts +50 -0
  256. package/dist/server-errors.d.ts.map +1 -0
  257. package/dist/server-errors.js +79 -0
  258. package/dist/server-errors.js.map +1 -0
  259. package/dist/server-handshake.d.ts +197 -0
  260. package/dist/server-handshake.d.ts.map +1 -0
  261. package/dist/server-handshake.js +505 -0
  262. package/dist/server-handshake.js.map +1 -0
  263. package/dist/server-response.d.ts +3 -0
  264. package/dist/server-response.d.ts.map +1 -0
  265. package/dist/server-response.js +67 -0
  266. package/dist/server-response.js.map +1 -0
  267. package/dist/server-trust.d.ts +14 -0
  268. package/dist/server-trust.d.ts.map +1 -0
  269. package/dist/server-trust.js +225 -0
  270. package/dist/server-trust.js.map +1 -0
  271. package/dist/setup-confirm.d.ts +3 -3
  272. package/dist/setup-confirm.d.ts.map +1 -0
  273. package/dist/setup-confirm.js +126 -2
  274. package/dist/setup-confirm.js.map +1 -0
  275. package/dist/setup.d.ts +5 -3
  276. package/dist/setup.d.ts.map +1 -0
  277. package/dist/setup.js +169 -46
  278. package/dist/setup.js.map +1 -0
  279. package/dist/shell-escape.d.ts.map +1 -0
  280. package/dist/shell-escape.js +22 -1
  281. package/dist/shell-escape.js.map +1 -0
  282. package/dist/spawn.d.ts +2 -2
  283. package/dist/spawn.d.ts.map +1 -0
  284. package/dist/spawn.js +29 -10
  285. package/dist/spawn.js.map +1 -0
  286. package/dist/startup-services.d.ts +0 -1
  287. package/dist/startup-services.d.ts.map +1 -0
  288. package/dist/startup-services.js +26 -1
  289. package/dist/startup-services.js.map +1 -0
  290. package/dist/stream-owner.d.ts +6 -2
  291. package/dist/stream-owner.d.ts.map +1 -0
  292. package/dist/stream-owner.js +547 -2
  293. package/dist/stream-owner.js.map +1 -0
  294. package/dist/stream-status.d.ts +1 -1
  295. package/dist/stream-status.d.ts.map +1 -0
  296. package/dist/stream-status.js +268 -3
  297. package/dist/stream-status.js.map +1 -0
  298. package/dist/sync-roles-render.d.ts.map +1 -0
  299. package/dist/sync-roles-render.js +118 -3
  300. package/dist/sync-roles-render.js.map +1 -0
  301. package/dist/sync.d.ts +1 -1
  302. package/dist/sync.d.ts.map +1 -0
  303. package/dist/sync.js +286 -22
  304. package/dist/sync.js.map +1 -0
  305. package/dist/terminal-title.d.ts.map +1 -0
  306. package/dist/terminal-title.js +68 -1
  307. package/dist/terminal-title.js.map +1 -0
  308. package/dist/token-store.d.ts +17 -111
  309. package/dist/token-store.d.ts.map +1 -0
  310. package/dist/token-store.js +81 -1
  311. package/dist/token-store.js.map +1 -0
  312. package/dist/tool-manifest.d.ts +4 -8
  313. package/dist/tool-manifest.d.ts.map +1 -0
  314. package/dist/tool-manifest.js +554 -1
  315. package/dist/tool-manifest.js.map +1 -0
  316. package/dist/tool-scope.d.ts +8 -12
  317. package/dist/tool-scope.d.ts.map +1 -0
  318. package/dist/tool-scope.js +97 -1
  319. package/dist/tool-scope.js.map +1 -0
  320. package/dist/types.d.ts +1 -5
  321. package/dist/types.d.ts.map +1 -0
  322. package/dist/types.js +5 -0
  323. package/dist/types.js.map +1 -0
  324. package/dist/unknown-subcommand.d.ts +1 -1
  325. package/dist/unknown-subcommand.d.ts.map +1 -0
  326. package/dist/unknown-subcommand.js +37 -1
  327. package/dist/unknown-subcommand.js.map +1 -0
  328. package/dist/version.d.ts +1 -1
  329. package/dist/version.d.ts.map +1 -0
  330. package/dist/version.js +78 -2
  331. package/dist/version.js.map +1 -0
  332. package/dist/working-repo.d.ts.map +1 -0
  333. package/dist/working-repo.js +81 -1
  334. package/dist/working-repo.js.map +1 -0
  335. package/dist/worktree-lifecycle.d.ts.map +1 -0
  336. package/dist/worktree-lifecycle.js +205 -2
  337. package/dist/worktree-lifecycle.js.map +1 -0
  338. package/docs/EXTRACTION_PROVENANCE.md +40 -0
  339. package/docs/LOCAL_SERVER.md +103 -0
  340. package/docs/RELEASING.md +120 -0
  341. package/package.json +52 -34
  342. package/src/agent-runtime.ts +69 -0
  343. package/src/assimilate-cmd.ts +1864 -0
  344. package/src/assimilate-deps.ts +444 -0
  345. package/src/assimilate-guard.ts +84 -0
  346. package/src/assimilate-welcome.ts +39 -0
  347. package/src/auth-env.ts +21 -0
  348. package/src/backends/launch-all-pastelist.ts +18 -0
  349. package/src/backends/launch-all-tmux.ts +75 -0
  350. package/src/backends/launch-all-windows.ts +110 -0
  351. package/src/bare-launch-menu.ts +148 -0
  352. package/src/claude-launch-args.ts +35 -0
  353. package/src/claude.ts +561 -0
  354. package/src/cleanup-cmd.ts +581 -0
  355. package/src/clear-rewake-core.ts +34 -0
  356. package/src/clear-rewake.ts +18 -0
  357. package/src/cli-help.ts +116 -0
  358. package/src/cli-platform.ts +127 -0
  359. package/src/cli-tool-approval.ts +716 -0
  360. package/src/codex-app-server.ts +238 -0
  361. package/src/codex-app-wake.ts +512 -0
  362. package/src/codex-launch.ts +140 -0
  363. package/src/codex-remote.ts +500 -0
  364. package/src/codex-wake-resolve.ts +155 -0
  365. package/src/config-utils.ts +811 -0
  366. package/src/config.ts +595 -0
  367. package/src/console-prefix.ts +99 -0
  368. package/src/cube-name.ts +69 -0
  369. package/src/cubes.ts +583 -0
  370. package/src/debug.ts +73 -0
  371. package/src/direct-log.ts +9 -0
  372. package/src/docs-sections.ts +129 -0
  373. package/src/drone-lifecycle.ts +62 -0
  374. package/src/drone-management.ts +162 -0
  375. package/src/ensure-mcp-config.ts +54 -0
  376. package/src/evict-drone.ts +82 -0
  377. package/src/gc-orphan-inboxes.ts +229 -0
  378. package/src/inbox-monitor.ts +1005 -0
  379. package/src/index.ts +1201 -0
  380. package/src/launch-all-cmd.ts +450 -0
  381. package/src/launch-all-command.ts +30 -0
  382. package/src/launch-all-deps.ts +188 -0
  383. package/src/launch-all-discovery.ts +118 -0
  384. package/src/launch-all-locks.ts +74 -0
  385. package/src/launch-gate.ts +80 -0
  386. package/src/lifecycle-log-guard.ts +144 -0
  387. package/src/list-roles-render.ts +52 -0
  388. package/src/local-log-routing.ts +106 -0
  389. package/src/local-manage-tool-result.ts +10 -0
  390. package/src/local-server-cursor.ts +188 -0
  391. package/src/log-audit.ts +207 -0
  392. package/src/log-stream.ts +1505 -0
  393. package/src/model-presets.ts +22 -0
  394. package/src/name-validator.ts +23 -0
  395. package/src/opencode-drone.ts +528 -0
  396. package/src/opencode-plugin.ts +38 -0
  397. package/src/parse-assimilate-args.ts +125 -0
  398. package/src/parse-launch-all-args.ts +100 -0
  399. package/src/postinstall-banner.ts +37 -0
  400. package/src/postinstall.ts +36 -0
  401. package/src/readiness-probe.ts +12 -0
  402. package/src/regen-format.ts +651 -0
  403. package/src/regen.ts +150 -0
  404. package/src/remote-client.ts +1379 -0
  405. package/src/reset-local-seat-cmd.ts +227 -0
  406. package/src/role-match.ts +29 -0
  407. package/src/role-resolver.ts +93 -0
  408. package/src/roster-render.ts +196 -0
  409. package/src/seat-probe.ts +115 -0
  410. package/src/seat-store.ts +333 -0
  411. package/src/seats.ts +741 -0
  412. package/src/self-path.ts +51 -0
  413. package/src/server-endpoint.ts +38 -0
  414. package/src/server-errors.ts +93 -0
  415. package/src/server-handshake.ts +783 -0
  416. package/src/server-response.ts +76 -0
  417. package/src/server-trust.ts +245 -0
  418. package/src/setup-confirm.ts +171 -0
  419. package/src/setup.ts +186 -0
  420. package/src/shell-escape.ts +22 -0
  421. package/src/spawn.ts +31 -0
  422. package/src/startup-services.ts +36 -0
  423. package/src/stream-owner.ts +686 -0
  424. package/src/stream-status.ts +337 -0
  425. package/src/sync-roles-render.ts +163 -0
  426. package/src/sync.ts +363 -0
  427. package/src/terminal-title.ts +76 -0
  428. package/src/token-store.ts +102 -0
  429. package/src/tool-manifest.ts +610 -0
  430. package/src/tool-scope.ts +110 -0
  431. package/src/types.ts +5 -0
  432. package/src/unknown-subcommand.ts +35 -0
  433. package/src/version.ts +82 -0
  434. package/src/working-repo.ts +99 -0
  435. package/src/worktree-lifecycle.ts +254 -0
  436. package/dist/auth-recovery.d.ts +0 -33
  437. package/dist/auth-recovery.js +0 -1
  438. package/dist/auth.d.ts +0 -103
  439. package/dist/auth.js +0 -39
  440. package/dist/device-auth.d.ts +0 -75
  441. package/dist/device-auth.js +0 -1
  442. package/dist/drone-address.d.ts +0 -26
  443. package/dist/drone-address.js +0 -1
  444. package/dist/get-started.d.ts +0 -20
  445. package/dist/get-started.js +0 -2
  446. package/dist/health-beat.d.ts +0 -134
  447. package/dist/health-beat.js +0 -1
  448. package/dist/role-section.d.ts +0 -110
  449. package/dist/role-section.js +0 -8
  450. package/dist/setup-action.d.ts +0 -20
  451. package/dist/setup-action.js +0 -1
  452. package/dist/stale-version-check.d.ts +0 -40
  453. package/dist/stale-version-check.js +0 -1
  454. package/dist/subscription-retry.d.ts +0 -40
  455. package/dist/subscription-retry.js +0 -1
  456. package/dist/templates.d.ts +0 -107
  457. package/dist/templates.js +0 -359
  458. package/dist/token-crypto.d.ts +0 -50
  459. package/dist/token-crypto.js +0 -1
@@ -1,2 +1,205 @@
1
- import{join as c}from"node:path";function h(e,o){const t=`${o}-`;return`wt-${e.startsWith(t)?e.slice(t.length):e}`}function p(e){return c(e,".borg","worktrees")}function x(e,o,t,r){if(t.length===0)throw new Error("computeWorktreePath: suffix must be non-empty (empty leaf would collapse the path to the repo-level dir)");const n=r!==void 0&&r>=2?`${t}-${r}`:t;return c(p(e),o,n)}function d(e,o){const t=e("git",["status","--porcelain"],o);return t.status===0&&t.stdout.trim()===""}const g=/^\.claude\//;function $(e,o){const t=e("git",["status","--porcelain"],o),r={staged:[],unstaged:[],untracked:[],localConfig:[]};if(t.status!==0)return r;for(const n of t.stdout.split(`
2
- `)){if(!n.trim())continue;const s=n.slice(3);if(n.startsWith("??"))r.untracked.push(s);else{const a=n[0],u=n[1];a!==" "&&a!=="?"&&r.staged.push(s),u!==" "&&u!=="?"&&r.unstaged.push(s)}g.test(s)&&r.localConfig.push(s)}return r}function f(e,o,t,r){return e("git",["merge-base","--is-ancestor",t,r],o).status===0}function i(e,o,t,r){return e("git",["merge-base","--is-ancestor",t,r],o).status===0}function k(e,o,t,r){if(!d(e,o))return{action:"skipped-dirty",message:"uncommitted changes present; sync skipped (nothing discarded)"};if(!f(e,o,t,r))return{action:"skipped-diverged",message:`${t} has diverged from ${r}; resolve manually (no auto-merge/rebase)`};const n=e("git",["rev-list","--count",`${t}..${r}`],o);return n.status===0&&n.stdout.trim()==="0"?{action:"already-current"}:e("git",["merge","--ff-only",r],o).status!==0?{action:"skipped-diverged",message:"ff-only merge unexpectedly failed"}:{action:"fast-forwarded"}}function l(e,o,t){return e("git",["rev-parse","--verify","--quiet",`refs/heads/${t}`],o).status===0}function b(e,o,t,r){return d(e,o)?i(e,o,"HEAD",r)?l(e,o,t)&&!i(e,o,t,r)?{action:"blocked-target-unmerged",message:`branch ${t} exists with commits not on ${r}; resolve before adopting (a force-switch would discard them)`}:(e("git",["switch","-C",t,r],o),{action:"adopted"}):{action:"blocked-unmerged",message:`current HEAD has commits not on ${r}; commit/push or set aside before adopting`}:{action:"skipped-dirty",message:"uncommitted changes present; not switching (nothing discarded)"}}function v(e,o,t,r,n={prune:!1}){return i(e,o,t,r)?n.prune?(e("git",["branch","-d",t],o),{action:"pruned",branch:t}):{action:"announced",branch:t,message:`${t} is merged into ${r} and can be pruned: \`git branch -d ${t}\` (or re-run with --prune)`}:{action:"not-merged",branch:t}}export{b as adoptWorktree,$ as classifyDirty,v as cleanupMerged,x as computeWorktreePath,d as isCleanTree,f as isFastForward,i as isMerged,l as localBranchExists,h as perWorktreeBranchName,k as syncWorktree,p as worktreesHome};
1
+ /**
2
+ * gh#33 worktree lifecycle as product behavior.
3
+ *
4
+ * Pure git-decision helpers behind an injected `runSync` seam (matching
5
+ * the `AssimilateDeps.runSync` shape), so every branch is unit-testable
6
+ * without a live repo. This module DECIDES + emits git command sequences;
7
+ * it never launches agents and never touches the cube API.
8
+ *
9
+ * Design spec: docs/superpowers/specs/2026-05-29-worktree-lifecycle-design.md
10
+ * Q-resolutions baked in (SPEC-APPROVED 3a80412d):
11
+ * Q1 branch naming — `wt-<suffix>` prefix-stripped, full-basename fallback.
12
+ * Q2 idle-sync — ff-only, clean-gated; never merge/rebase; never over dirty.
13
+ * Q3 post-merge — auto-return to wt-<basename>; ANNOUNCE the prunable
14
+ * merged branch, prune only when explicitly requested.
15
+ * Q4 uniform — no primary-worktree carve-out; main is never a working branch.
16
+ */
17
+ import { join } from 'node:path';
18
+ /**
19
+ * Per-worktree branch name (Q1). Strips the repo basename prefix from the
20
+ * worktree dir basename for readability (`borg-mcp-codex-builder` ->
21
+ * `wt-codex-builder`); falls back to the full dir basename when there is
22
+ * no shared prefix (`myrepo-feature` under repo `otherrepo` ->
23
+ * `wt-myrepo-feature`).
24
+ */
25
+ export function perWorktreeBranchName(worktreeBasename, repoBasename) {
26
+ const prefix = `${repoBasename}-`;
27
+ const suffix = worktreeBasename.startsWith(prefix)
28
+ ? worktreeBasename.slice(prefix.length)
29
+ : worktreeBasename;
30
+ return `wt-${suffix}`;
31
+ }
32
+ /**
33
+ * gh#556 Part 1 — the home for NEW drone worktrees: `<homeDir>/.borg/worktrees`.
34
+ * (`~/.borg` is the established borg home — it already holds the encrypted
35
+ * credentials file, see config.ts.)
36
+ */
37
+ export function worktreesHome(homeDir) {
38
+ return join(homeDir, '.borg', 'worktrees');
39
+ }
40
+ /**
41
+ * gh#556 Part 1 — where a NEW drone worktree lives:
42
+ * `<homeDir>/.borg/worktrees/<repoBase>/<suffix>` (collision variant `<suffix>-<n>`
43
+ * for n>=2; the caller loops n until the path is free).
44
+ *
45
+ * Pure (homeDir injected) so the path scheme + collision dedup + containment are
46
+ * unit-testable without touching $HOME or spawning git.
47
+ *
48
+ * Path-safety / no-traversal: `suffix` is validated upstream BEFORE it reaches here —
49
+ * `--worktree` via validateName (NAME_RE excludes `.`/`/`) or the role default via
50
+ * roleSlug (strips everything but `[a-z0-9-]`); `repoBase` is a single `basename(...)`
51
+ * component. So the result is always CONTAINED under `worktreesHome(homeDir)`.
52
+ * As defense-in-depth this throws on an EMPTY suffix — an empty leaf would let
53
+ * `join` collapse the path up to the repo-level dir (the degenerate-path bug); the
54
+ * caller also guards empty before calling, fail-loud.
55
+ */
56
+ export function computeWorktreePath(homeDir, repoBase, suffix, n) {
57
+ if (suffix.length === 0) {
58
+ throw new Error('computeWorktreePath: suffix must be non-empty (empty leaf would collapse the path to the repo-level dir)');
59
+ }
60
+ const leaf = n !== undefined && n >= 2 ? `${suffix}-${n}` : suffix;
61
+ return join(worktreesHome(homeDir), repoBase, leaf);
62
+ }
63
+ /** True iff the working tree is clean (`git status --porcelain` empty). */
64
+ export function isCleanTree(runSync, cwd) {
65
+ const r = runSync('git', ['status', '--porcelain'], cwd);
66
+ return r.status === 0 && r.stdout.trim() === '';
67
+ }
68
+ const LOCAL_CONFIG_RE = /^\.claude\//;
69
+ /**
70
+ * Classify a dirty tree into staged / unstaged / untracked buckets, and
71
+ * flag local-config files separately. The STAGED bucket is load-bearing:
72
+ * the live UNBLOCK case (b15894be) had a *staged* leftover diff that
73
+ * blocked `pull --ff-only`, which an unstaged-only check would miss.
74
+ */
75
+ export function classifyDirty(runSync, cwd) {
76
+ const r = runSync('git', ['status', '--porcelain'], cwd);
77
+ const out = { staged: [], unstaged: [], untracked: [], localConfig: [] };
78
+ if (r.status !== 0)
79
+ return out;
80
+ for (const line of r.stdout.split('\n')) {
81
+ if (!line.trim())
82
+ continue;
83
+ const path = line.slice(3);
84
+ if (line.startsWith('??')) {
85
+ out.untracked.push(path);
86
+ }
87
+ else {
88
+ const x = line[0]; // staged (index) column
89
+ const y = line[1]; // unstaged (work-tree) column
90
+ if (x !== ' ' && x !== '?')
91
+ out.staged.push(path);
92
+ if (y !== ' ' && y !== '?')
93
+ out.unstaged.push(path);
94
+ }
95
+ if (LOCAL_CONFIG_RE.test(path))
96
+ out.localConfig.push(path);
97
+ }
98
+ return out;
99
+ }
100
+ /** True iff `branch` is an ancestor of `ref` — i.e. a clean fast-forward target. */
101
+ export function isFastForward(runSync, cwd, branch, ref) {
102
+ return runSync('git', ['merge-base', '--is-ancestor', branch, ref], cwd).status === 0;
103
+ }
104
+ /** True iff `branch`'s tip is an ancestor of `ref` — i.e. fully merged into it. */
105
+ export function isMerged(runSync, cwd, branch, ref) {
106
+ return runSync('git', ['merge-base', '--is-ancestor', branch, ref], cwd).status === 0;
107
+ }
108
+ /**
109
+ * Idle-sync the current per-worktree branch to `ref` (Q2). NEVER discards
110
+ * work: dirty -> skipped-dirty (no mutation). Only fast-forwards (no
111
+ * merge/rebase): diverged -> skipped-diverged. The caller fetches first.
112
+ *
113
+ * `already-current` when the branch tip already equals `ref` (the common
114
+ * no-op case on every launch).
115
+ */
116
+ export function syncWorktree(runSync, cwd, branch, ref) {
117
+ if (!isCleanTree(runSync, cwd)) {
118
+ return {
119
+ action: 'skipped-dirty',
120
+ message: 'uncommitted changes present; sync skipped (nothing discarded)',
121
+ };
122
+ }
123
+ if (!isFastForward(runSync, cwd, branch, ref)) {
124
+ return {
125
+ action: 'skipped-diverged',
126
+ message: `${branch} has diverged from ${ref}; resolve manually (no auto-merge/rebase)`,
127
+ };
128
+ }
129
+ // Already at ref? merge --ff-only is a no-op but we report it distinctly
130
+ // so callers can stay quiet on the common case.
131
+ const ahead = runSync('git', ['rev-list', '--count', `${branch}..${ref}`], cwd);
132
+ if (ahead.status === 0 && ahead.stdout.trim() === '0') {
133
+ return { action: 'already-current' };
134
+ }
135
+ const ff = runSync('git', ['merge', '--ff-only', ref], cwd);
136
+ if (ff.status !== 0) {
137
+ return { action: 'skipped-diverged', message: 'ff-only merge unexpectedly failed' };
138
+ }
139
+ return { action: 'fast-forwarded' };
140
+ }
141
+ /** True iff a local branch named `branch` already exists. */
142
+ export function localBranchExists(runSync, cwd, branch) {
143
+ return runSync('git', ['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`], cwd).status === 0;
144
+ }
145
+ /**
146
+ * Migration (Q4/Q5/§4.5): bring a detached/stale worktree onto
147
+ * `wt-<basename>` at `ref`. Idempotent: re-running on an already-adopted
148
+ * clean worktree is a lossless reset to `ref`. Never discards:
149
+ * - dirty work tree -> skipped-dirty (surface)
150
+ * - current HEAD unmerged -> blocked-unmerged (surface)
151
+ * - TARGET `branch` exists with commits not on `ref` -> blocked-target-
152
+ * unmerged (surface). This is load-bearing: the switch uses `-C`
153
+ * (force-create/reset), which would ORPHAN commits on a pre-existing
154
+ * `wt-` branch. The HEAD-merged check alone misses this when the
155
+ * target branch != HEAD (e.g. on `main` while a prior `wt-x` holds
156
+ * committed-but-unmerged work). gh#33 CR-v2 blocker 078d1630.
157
+ */
158
+ export function adoptWorktree(runSync, cwd, branch, ref) {
159
+ if (!isCleanTree(runSync, cwd)) {
160
+ return {
161
+ action: 'skipped-dirty',
162
+ message: 'uncommitted changes present; not switching (nothing discarded)',
163
+ };
164
+ }
165
+ if (!isMerged(runSync, cwd, 'HEAD', ref)) {
166
+ return {
167
+ action: 'blocked-unmerged',
168
+ message: `current HEAD has commits not on ${ref}; commit/push or set aside before adopting`,
169
+ };
170
+ }
171
+ // Guard the TARGET branch ref before the `switch -C` force-reset. If
172
+ // `branch` already exists and is NOT an ancestor of `ref`, it carries
173
+ // committed-unmerged work that `-C` would discard — block instead.
174
+ // (Absent, or an ancestor of `ref` = a clean reset target → proceed.)
175
+ if (localBranchExists(runSync, cwd, branch) && !isMerged(runSync, cwd, branch, ref)) {
176
+ return {
177
+ action: 'blocked-target-unmerged',
178
+ message: `branch ${branch} exists with commits not on ${ref}; resolve before adopting (a force-switch would discard them)`,
179
+ };
180
+ }
181
+ runSync('git', ['switch', '-C', branch, ref], cwd);
182
+ return { action: 'adopted' };
183
+ }
184
+ /**
185
+ * Post-merge cleanup (Q3): when `feature` is fully merged into `ref`,
186
+ * either ANNOUNCE it as prunable (default) or actually prune it with the
187
+ * safe `git branch -d` (which itself refuses to delete an unmerged
188
+ * branch — defense in depth against a stale local ref). Unmerged ->
189
+ * not-merged (never touched).
190
+ */
191
+ export function cleanupMerged(runSync, cwd, feature, ref, opts = { prune: false }) {
192
+ if (!isMerged(runSync, cwd, feature, ref)) {
193
+ return { action: 'not-merged', branch: feature };
194
+ }
195
+ if (!opts.prune) {
196
+ return {
197
+ action: 'announced',
198
+ branch: feature,
199
+ message: `${feature} is merged into ${ref} and can be pruned: \`git branch -d ${feature}\` (or re-run with --prune)`,
200
+ };
201
+ }
202
+ runSync('git', ['branch', '-d', feature], cwd);
203
+ return { action: 'pruned', branch: feature };
204
+ }
205
+ //# sourceMappingURL=worktree-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-lifecycle.js","sourceRoot":"","sources":["../src/worktree-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AASjC;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,gBAAwB,EAAE,YAAoB;IAClF,MAAM,MAAM,GAAG,GAAG,YAAY,GAAG,CAAC;IAClC,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC;QAChD,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QACvC,CAAC,CAAC,gBAAgB,CAAC;IACrB,OAAO,MAAM,MAAM,EAAE,CAAC;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAe,EACf,QAAgB,EAChB,MAAc,EACd,CAAU;IAEV,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,0GAA0G,CAAC,CAAC;IAC9H,CAAC;IAC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AE,CAAC;QAChB,OAAO;YACL,MAAM,EAAE,WAAW;YACnB,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,GAAG,OAAO,mBAAmB,GAAG,uCAAuC,OAAO,6BAA6B;SACrH,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,40 @@
1
+ # Extraction Provenance
2
+
3
+ The initial standalone source was extracted from `Byte-Ventures/borg-mcp` commit `17ff8ce14e12122a8cc9089f6b94174c02fa2a04` on branch `main`.
4
+
5
+ The extraction copied the monorepo's `client/src/` production boundary and top-level `client/__tests__/*.test.ts` unit tests. It did not import monorepo Git history, worker or website source, deployment configuration, local state, credentials files, build output, or the live integration suite.
6
+
7
+ [`provenance/extraction-map.json`](../provenance/extraction-map.json) records every one of the 225 source-client files with source and destination SHA-256 hashes plus one of four dispositions: byte-identical copy, standalone transformation, shared-package replacement, or exclusion. The map is generated against the detached exact-source checkout with `scripts/generate-extraction-map.mjs`; it is repository evidence and is not included in the npm artifact.
8
+
9
+ ## Deliberate Transformations
10
+
11
+ - Replaced the monorepo dependency on `borgmcp-shared` with the exact audited registry release `borgmcp-shared@0.4.2` and a fresh standalone lockfile.
12
+ - Replaced local template, role-section, drone-address, and log high-water-mark implementations with `borgmcp-shared` exports.
13
+ - Removed monorepo-only website anti-drift tests and re-anchored remaining filesystem tests to this repository.
14
+ - Removed consumer lifecycle hooks, parent-directory deployment scripts, minification, and private integration-environment configuration.
15
+ - Added standalone source typecheck, unit/release tests, readable build, onboarding smoke, artifact verification, and public-source sensitivity scanning.
16
+ - Made the package root export side-effect-free while retaining `borg-mcp` executable behavior.
17
+ - Kept self-hosted `--host --enroll` preview-only while implementing the
18
+ client-generated PENDING credential/retry tuple and capability-gated,
19
+ repository-idempotent cube creation required for local dogfood.
20
+ - Initially set the standalone package identity to `2.0.0`. Its immutable
21
+ lightweight release tag failed before packaging, so the reviewed recovery
22
+ identity is `2.0.1`; extraction and versioning do not authorize publication.
23
+
24
+ ## Review Holds
25
+
26
+ Google OAuth / Cloud sign-in has been fully removed from this local-only client.
27
+ `src/auth.ts`, `src/device-auth.ts`, and all installed-application OAuth client
28
+ material are deleted, along with the hosted API default and the Cloud
29
+ subscription/billing/dashboard tools. `scripts/verify-public-source.mjs` now
30
+ forbids ANY Google OAuth client ID or `GOCSPX` value anywhere in the source or
31
+ packed artifact (zero tolerance), and a no-cloud egress guard asserts the packed
32
+ artifact reaches no hosted authority.
33
+
34
+ Local enrollment now uses the reviewed client-generated credential/retry
35
+ contract, with a pre-request `PENDING` record in the local 0600-permission seat
36
+ store, exact-tuple ambiguous retry, and verified activation. The contract now
37
+ resolves to the audited registry `borgmcp-shared@0.4.2`. The matching
38
+ `borgmcp-server@0.1.7` release is published and registry-verified; client
39
+ publication remains gated by reviewed `v2.0.1` source, a fresh annotated tag,
40
+ and exact registry integrity and signature verification.
@@ -0,0 +1,103 @@
1
+ # Self-Hosted Server
2
+
3
+ Install and initialize the server in the human operator's terminal:
4
+
5
+ ```bash
6
+ npm install -g borgmcp-server
7
+ borg-mcp-server setup
8
+ borg-mcp-server start
9
+ ```
10
+
11
+ Keep the server running. Open a second operator terminal in the project checkout
12
+ and run:
13
+
14
+ ```bash
15
+ borg assimilate --host 127.0.0.1:7091 --enroll
16
+ ```
17
+
18
+ The labeled hidden prompt awaits the owner enrollment invitation (single-use,
19
+ shown once). An owner enrollment invitation comes from setup or the offline
20
+ `borg-mcp-server owner-invite` recovery command. A later ordinary client uses a
21
+ client enrollment invitation from `borg-mcp-server client-invite`. Never put an
22
+ enrollment invitation in argv, environment variables, logs, or diagnostics.
23
+ The offline replacement commands visibly prompt for the recovery credential;
24
+ never put that credential in argv or environment variables either.
25
+
26
+ Before sending the invitation,
27
+ the client generates a 256-bit credential and UUID retry key and persists the
28
+ exact tuple as `PENDING` in the local seat store on this machine — a
29
+ 0600-permission file store, parity with the server's TLS keys. An ambiguous
30
+ exchange retries that tuple exactly; the credential becomes active only after the
31
+ versioned response is decoded and the authenticated protocol handshake succeeds.
32
+ A new process resumes that pending enrollment before displaying another
33
+ invitation prompt.
34
+
35
+ `--cube-name <name>` explicitly selects the repository cube name. Without an
36
+ explicit name, Borg uses the `origin` repository name or, when `origin` is
37
+ absent, proposes the sanitized repository-directory basename before consuming
38
+ an enrollment invitation. Confirm interactively or pass `--yes`; bare
39
+ repositories fail closed.
40
+
41
+ The connection is HTTPS-only. Borg validates the server trust material, stores
42
+ enrollment and session credentials in the local seat store on this machine (a
43
+ 0600-permission file store), and persists only an opaque credential reference
44
+ with the active cube. Local requests
45
+ use the server's `/api/cubes/*` coordination routes. They cannot use hosted OAuth
46
+ credentials or change authority implicitly.
47
+
48
+ The current client does not install or start `borgmcp-server`. The server must
49
+ already be running and trusted. An owner enrollment carrying the persisted
50
+ `create_cube` capability creates one idempotent cube per repository during
51
+ normal assimilation, using the server-owned `default` role template; repeating
52
+ an ambiguous request does not duplicate the cube, and distinct repositories can
53
+ create distinct bounded cubes. An ordinary enrolled client is denied before a
54
+ create request is sent. Cloud-only capabilities fail explicitly rather than
55
+ being redirected.
56
+
57
+ After the first attach, the launched agent should run `borg_whoami` and
58
+ `borg_roster` to verify its seat and begin coordinating. To create a second seat,
59
+ the operator runs the explicit local assimilation command from the intended
60
+ worktree. A fresh worktree operation creates a distinct drone; an ambiguous
61
+ retry of that same operation resumes the same drone.
62
+
63
+ An identical `--here` rerun validates the saved local seat and reattaches by
64
+ re-sending the same client-generated session bearer — the sole server correlator —
65
+ instead of choosing another role or minting a new drone. The bearer is REUSED, not
66
+ rotated: the server binds only its digest, so a re-sent identical bearer resolves to
67
+ the existing seat. Ambiguous liveness or transport results never authorize a
68
+ replacement; only an authoritative eviction mints a fresh bearer and permits a
69
+ remint. (The `retry_key` idempotency key applies to enrollment and cube-creation
70
+ only — never to seat re-attach, which is idempotent through the bearer itself.)
71
+
72
+ The default discovery endpoint is `https://127.0.0.1:7091`. Explicit `--host` values may include another port but must pass the same trust and endpoint policy.
73
+
74
+ ## Recovery commands
75
+
76
+ - No saved or rejected enrollment: rerun `borg assimilate --host <server> --enroll`
77
+ from the operator's interactive terminal.
78
+ - Rejected or expired invitation: keep the server running and mint a replacement
79
+ scoped invitation with `borg-mcp-server owner-invite` for an unclaimed owner
80
+ client or `borg-mcp-server client-invite` for an ordinary client, then rerun
81
+ `borg assimilate --host <server> --enroll` with the replacement invitation.
82
+ - Rejected or unloadable local seat: run `borg reset-local-seat --host <server>`
83
+ to clear ONLY this worktree's saved local seat, then — with the server still
84
+ running — ask the operator for a fresh scoped invitation and rerun
85
+ `borg assimilate --host <server> --enroll`.
86
+ - Unreachable server: start or restart it with `borg-mcp-server start`, then
87
+ rerun `borg assimilate --host <server>`.
88
+ - Trust mismatch after an intentional server re-initialization: verify the
89
+ expected server identity, stop and restart `borg-mcp-server start`, then retry.
90
+ - Busy local seat store: wait for the other Borg process to finish, then rerun
91
+ the same command. If the local seat store cannot be read or written, ensure its
92
+ directory on this machine is readable and writable, then rerun.
93
+ - Unusable project name: rerun with `--cube-name <name>`.
94
+ - Incompatible response: verify compatible client and server versions, then
95
+ retry the same endpoint.
96
+
97
+ ## Release status
98
+
99
+ This self-hosted path consumes the published `borgmcp-shared@0.4.2` v2 registry
100
+ release. The matching server owner-enrollment, cube-create, attach, restart, log,
101
+ and SSE implementation must also pass the full process-level local dogfood gate.
102
+ Until that gate opens the self-hosted path remains preview-only, and the client
103
+ publish is deferred accordingly.
@@ -0,0 +1,120 @@
1
+ # Publishing `borgmcp`
2
+
3
+ The GitHub Actions workflow publishes one immutable, reviewed `borgmcp` version
4
+ from a protected annotated tag. The protected publish job uses npm Trusted
5
+ Publishing; no long-lived npm token is stored or exposed.
6
+
7
+ ## Immutable Failed Release Evidence
8
+
9
+ The existing lightweight `v2.0.0` tag points to
10
+ `90a078264f4d61c0140ad0a30357a4df42c34ab0`. Immutable workflow run
11
+ `29693915689` rejected it at annotated-tag verification and failed before package
12
+ creation or npm publication; the publish job was skipped and
13
+ `borgmcp@2.0.0` remains absent from npm. Never delete, move, replace, reuse, or
14
+ rerun that tag or run. Recovery uses the unused `v2.0.1` identity from a fresh
15
+ reviewed protected-main commit and requires the complete release gate again.
16
+
17
+ ## Release Prerequisites
18
+
19
+ The standalone client was extracted from private-monorepo commit
20
+ `17ff8ce14e12122a8cc9089f6b94174c02fa2a04` without importing its Git history.
21
+ Before creating the release tag, independently verify all of these conditions:
22
+
23
+ - the extraction review confirms no private backend secrets, deployment
24
+ configuration, customer data, local state, or duplicated shared contracts
25
+ entered the public package;
26
+ - the exact audited registry dependency `borgmcp-shared@0.4.2` remains locked to
27
+ its canonical tarball and integrity;
28
+ - the client and matching server pass the complete local dogfood gate;
29
+ - the selected stable client version is unused and the exact release commit is
30
+ on protected `main`;
31
+ - the repository and protected npm environment settings pass an operator audit;
32
+ - the exact release source passes Code Review, Security Review, Release Quality,
33
+ extraction, and package gates; and
34
+ - the immutable annotated tag and publication receive explicit release
35
+ authorization.
36
+
37
+ `scripts/verify-release-readiness.mjs` makes the source-side blockers
38
+ machine-checkable. A release tag created before they are resolved fails before
39
+ dependency installation or publication.
40
+
41
+ ## Repository Controls
42
+
43
+ Repository settings are operator-owned and are not changed by this workflow.
44
+ Before preparing a candidate, independently verify:
45
+
46
+ 1. The `npm-publish` environment disables administrator bypass, requires the
47
+ reviewed human approver, and allows only the protected release refs. Its
48
+ `NPM_EXPECTED_OWNER` variable must match the sole reviewed maintainer of the
49
+ existing `borgmcp` package. It must contain no npm token.
50
+ 2. npm Trusted Publishing is configured for organization `Byte-Ventures`,
51
+ repository `borg-mcp-client`, workflow `publish.yml`, and environment
52
+ `npm-publish`.
53
+ 3. `refs/tags/v*.*.*` cannot be updated, deleted, or force-moved. Release tags
54
+ are annotated, match the package version, and point to a commit on protected
55
+ `main`.
56
+ 4. `main` requires reviewed pull requests, resolved threads, and current CI.
57
+ 5. GitHub Actions permits only the full-SHA-pinned GitHub-owned actions present
58
+ in this repository. The default workflow token remains read-only.
59
+ 6. Private vulnerability reporting, secret scanning, push protection, CodeQL,
60
+ and Dependabot security updates remain enabled.
61
+
62
+ ## Release Workflow
63
+
64
+ The only trigger is a protected annotated `v<package version>` tag. Manual
65
+ dispatch is intentionally absent so a second run cannot rebuild or publish an
66
+ existing tag. The workflow rejects reruns, root `.npmrc`
67
+ configuration, non-tag events, lightweight or malformed tags, version mismatch,
68
+ source/tag mismatch, and tags whose commits are not on protected `main`.
69
+
70
+ The unprivileged `verify` job performs one sequence:
71
+
72
+ 1. Verify the public-source boundary, extraction readiness, exact shared-package
73
+ pin, and canonical registry lock metadata.
74
+ 2. Install the lockfile once with lifecycle scripts disabled and audit it.
75
+ 3. Run type checks, tests, and one readable build; reject generated `dist` drift.
76
+ 4. Produce one npm tarball.
77
+ 5. Verify that tarball once for package identity, license/notice, source and map
78
+ completeness, executable bins, archive safety, dependency integrity, and
79
+ absence of credentials, private endpoints, local paths, links, or lifecycle
80
+ hooks.
81
+ 6. Install the exact local tarball once with scripts disabled and require package
82
+ import plus MCP initialize/tool discovery through npm's generated bin shim.
83
+ 7. Upload only the tarball and its verifier-generated report as the same-run
84
+ release artifact.
85
+
86
+ The protected `publish` job alone receives `id-token: write`. It downloads the
87
+ same-run artifact and rejects a report whose package name or version differs
88
+ from the release, a version that already exists, an unclaimed package, or an
89
+ owner set that differs from `NPM_EXPECTED_OWNER`. It requires the GitHub OIDC
90
+ request context, rejects a legacy `NODE_AUTH_TOKEN`, and publishes the exact
91
+ tarball path once with lifecycle scripts disabled and provenance enabled. It
92
+ does not install project dependencies, rebuild, retest, repack, or reverify the
93
+ package.
94
+
95
+ The dependent, unprivileged `registry-verification` job has no environment or
96
+ OIDC permission. It polls registry visibility with fixed attempt and delay
97
+ bounds, compares `dist.integrity` exactly with the same-run report, installs the
98
+ exact published version with lifecycle scripts disabled, and runs
99
+ `npm audit signatures` to verify registry signatures and the Trusted Publishing
100
+ attestation.
101
+
102
+ No separate checksum file is needed: the tarball verifier records canonical
103
+ SHA-512 SRI in the artifact report. GitHub's same-run artifact transport and the
104
+ report bind the reviewed candidate without repeated SHA512 choreography.
105
+
106
+ Rely on npm's signature and Trusted Publishing attestation validation. Do not
107
+ reconstruct DSSE, in-toto, SLSA, workflow-ref, or builder statements locally.
108
+ Do not add cross-run tuple variables, cross-run artifact selection, duplicate
109
+ builds, duplicate package verification, checksum bundles, or SBOM ceremony.
110
+
111
+ A post-publication verification failure is a release incident; it never means
112
+ the immutable npm publication did not happen and never authorizes a rerun.
113
+
114
+ ## Stop And Recovery Conditions
115
+
116
+ Stop when source, settings, ownership, tag, artifact, test, audit, review, or
117
+ authorization evidence is missing or inconsistent. Never move or reuse a failed
118
+ tag, rerun a failed release workflow, overwrite an npm version, unpublish to hide
119
+ a failure, or substitute a local rebuild. Recovery starts from a fresh reviewed
120
+ source change and, after any registry mutation, a separately authorized version.
package/package.json CHANGED
@@ -1,61 +1,75 @@
1
1
  {
2
2
  "name": "borgmcp",
3
- "version": "1.1.15",
4
- "description": "Coordinate AI coding agents in shared cubes. Works with Claude Code and Codex. Create projects, assign roles, and share a live activity log.",
3
+ "version": "2.0.1",
4
+ "description": "Coordinate AI coding agents in shared cubes. Works with Claude Code, Codex, and OpenCode.",
5
5
  "type": "module",
6
- "main": "dist/index.js",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
7
15
  "bin": {
8
- "borg": "dist/claude.js",
9
- "borg-setup": "dist/setup.js",
10
- "borg-mcp": "dist/index.js",
11
- "borg-regen": "dist/regen.js",
12
- "borg-clear-rewake": "dist/clear-rewake.js",
13
- "borg-log-audit": "dist/log-audit.js",
14
- "borg-inbox-monitor": "dist/inbox-monitor.js"
16
+ "borg": "./dist/claude.js",
17
+ "borg-setup": "./dist/setup.js",
18
+ "borg-mcp": "./dist/index.js",
19
+ "borg-regen": "./dist/regen.js",
20
+ "borg-clear-rewake": "./dist/clear-rewake.js",
21
+ "borg-log-audit": "./dist/log-audit.js",
22
+ "borg-inbox-monitor": "./dist/inbox-monitor.js"
15
23
  },
16
24
  "scripts": {
17
- "prebuild": "rm -rf dist",
18
- "build": "tsc",
19
- "postbuild": "chmod +x dist/claude.js dist/setup.js dist/index.js dist/regen.js dist/clear-rewake.js dist/log-audit.js dist/inbox-monitor.js",
20
- "minify": "node scripts/minify-dist.js",
21
- "dev": "tsc --watch",
25
+ "clean": "node scripts/clean.mjs",
26
+ "build": "npm run clean && tsc -p tsconfig.json && node scripts/set-bin-mode.mjs",
27
+ "check": "tsc -p tsconfig.json --noEmit",
28
+ "dev": "tsc -p tsconfig.json --watch",
22
29
  "start": "node dist/index.js",
23
- "postinstall": "node dist/postinstall.js || true",
24
- "test:integration": "vitest run --config ./vitest.integration.config.ts",
25
- "safe-deploy": "bash ../scripts/safe-deploy.sh",
26
- "onboarding-smoke": "bash ../scripts/onboarding-smoke.sh",
27
- "prepublishOnly": "npm run safe-deploy && npm run build && npm run test:integration && npm run minify && npm run onboarding-smoke"
30
+ "test": "npm run test:unit && npm run test:release",
31
+ "test:unit": "vitest run --config vitest.config.ts",
32
+ "test:release": "node --test test/release-lane.test.mjs",
33
+ "onboarding:smoke": "node scripts/onboarding-smoke.mjs",
34
+ "release:check": "npm run verify:public-source && npm run verify:release && npm run verify:lock && npm run check && npm test && npm run build && npm run onboarding:smoke && npm run verify:package",
35
+ "verify:artifact": "node scripts/verify-packed-artifact.mjs",
36
+ "verify:public-source": "node scripts/verify-public-source.mjs",
37
+ "verify:package": "node scripts/verify-local-package.mjs",
38
+ "verify:release": "node scripts/verify-release-readiness.mjs",
39
+ "verify:lock": "node scripts/verify-lock-registry.mjs"
28
40
  },
29
41
  "files": [
30
42
  "dist",
43
+ "src",
44
+ "docs/*.md",
31
45
  "README.md",
32
- "LICENSE"
46
+ "LICENSE",
47
+ "NOTICE",
48
+ "SECURITY.md",
49
+ "CONTRIBUTING.md"
33
50
  ],
34
51
  "keywords": [
35
52
  "mcp",
36
- "claude",
37
53
  "claude-code",
38
- "anthropic",
54
+ "codex",
55
+ "opencode",
39
56
  "multi-agent",
40
- "coordination",
41
- "agent",
42
- "borg"
57
+ "coordination"
43
58
  ],
44
- "author": "Theodor Storm <theodor@byteventures.se>",
45
- "license": "SEE LICENSE IN LICENSE",
46
- "homepage": "https://borgmcp.ai",
59
+ "author": "Byte Ventures IO AB",
60
+ "license": "Apache-2.0",
61
+ "homepage": "https://github.com/Byte-Ventures/borg-mcp-client",
47
62
  "repository": {
48
63
  "type": "git",
49
- "url": "git+https://github.com/Byte-Ventures/borg-mcp.git"
64
+ "url": "git+https://github.com/Byte-Ventures/borg-mcp-client.git"
50
65
  },
51
66
  "bugs": {
52
- "url": "https://github.com/Byte-Ventures/borg-mcp/issues"
67
+ "url": "https://github.com/Byte-Ventures/borg-mcp-client/issues"
53
68
  },
54
69
  "dependencies": {
55
70
  "@modelcontextprotocol/sdk": "^1.0.4",
56
- "@napi-rs/keyring": "^1.3.0",
71
+ "borgmcp-shared": "0.4.2",
57
72
  "chalk": "^5.3.0",
58
- "open": "^10.0.0",
59
73
  "prompts": "^2.4.2",
60
74
  "which": "^4.0.0"
61
75
  },
@@ -63,10 +77,14 @@
63
77
  "@types/node": "^22.10.2",
64
78
  "@types/prompts": "^2.4.9",
65
79
  "@types/which": "^3.0.4",
66
- "esbuild": "^0.28.1",
80
+ "tsx": "^4.20.5",
67
81
  "typescript": "^6.0.3",
68
82
  "vitest": "^3.2.6"
69
83
  },
84
+ "engines": {
85
+ "node": ">=20"
86
+ },
87
+ "packageManager": "npm@11.18.0",
70
88
  "publishConfig": {
71
89
  "access": "public"
72
90
  }