borgmcp 1.1.14 → 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 +86 -37
  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
@@ -0,0 +1,337 @@
1
+ /**
2
+ * Renderer + inbox-Monitor liveness probe for `borg_stream-status`.
3
+ *
4
+ * Split out from `index.ts` so the 5-state precedence logic and the
5
+ * `pgrep`-based liveness check can be unit-tested without spinning up
6
+ * the MCP server. drone-4's 18:30:51 UX contract is the spec for the
7
+ * rendered output shape; this module is the implementation surface.
8
+ *
9
+ * Top-line states (drone-4 contract):
10
+ * 1. Stream not started.
11
+ * 2. Stream connected, awaiting first content event.
12
+ * 3. Stream connected, last content <X> ago.
13
+ * 4. Stream disconnected (reconnect attempt N).
14
+ * 5. Stream connected (no inbox-Monitor — wake path broken).
15
+ *
16
+ * Precedence when both `disconnected` and `no inbox-Monitor` apply:
17
+ * prefer (4) — wire-disconnect is the upstream cause and resolves
18
+ * automatically when the wire comes back up; State 5 only matters
19
+ * when the wire is healthy but the file-watch isn't.
20
+ */
21
+
22
+ import { spawnSync } from 'node:child_process';
23
+ import { statSync } from 'node:fs';
24
+ import type { StreamStatus } from './log-stream.js';
25
+ import {
26
+ heartbeatPathFor,
27
+ legacyHeartbeatPathFor,
28
+ HEARTBEAT_STALE_MS,
29
+ } from './inbox-monitor.js';
30
+ import { shellEscape } from './shell-escape.js';
31
+
32
+ /**
33
+ * Best-effort check: is a process tailing this inbox file?
34
+ *
35
+ * Returns:
36
+ * - true: at least one process matches `tail.*<inboxPath>` in pgrep
37
+ * - false: pgrep ran cleanly and found no match
38
+ * - null: cannot determine (pgrep unavailable, spawn error, no inbox path)
39
+ *
40
+ * The null case is informative — it means we don't know, so the
41
+ * renderer must NOT fire State 5 (which would be misleading). State 5
42
+ * only fires when we positively know the wake path is broken.
43
+ *
44
+ * Why `pgrep` and not a more elegant check: Claude Code Monitors are
45
+ * tail-based subprocesses spawned by the harness, completely opaque to
46
+ * the MCP server. The MCP server has no IPC channel into the harness's
47
+ * task table. The cheapest reliable signal we can get from inside the
48
+ * MCP server is "is there a tail subprocess open against this path?"
49
+ * — which is what `pgrep -f` answers.
50
+ *
51
+ * macOS + Linux ship `pgrep`. Windows doesn't (borgmcp targets Mac /
52
+ * Linux per package.json `os` field; the null branch handles other
53
+ * platforms gracefully).
54
+ */
55
+ export function checkInboxMonitorHealthy(
56
+ inboxPath: string | null,
57
+ monitorStateRoot?: string | null
58
+ ): boolean | null {
59
+ if (!inboxPath) return null;
60
+ try {
61
+ // `-f` matches against the full command line so we catch the
62
+ // `tail -n 0 -F <inboxPath>` form. `-l` lists matches; we only
63
+ // need the exit code (0 = match, 1 = no match) and a sanity check
64
+ // on stdout (some pgrep variants exit 0 with empty stdout under
65
+ // permission errors — treat empty stdout as "no match" for safety).
66
+ const res = spawnSync('pgrep', ['-f', inboxPath], {
67
+ encoding: 'utf-8',
68
+ timeout: 2_000,
69
+ });
70
+ if (res.error) return null;
71
+ if (res.status === 0 && res.stdout.trim().length > 0) {
72
+ // gh#822: a tail PROCESS is present — but presence ≠ health (a hung tail
73
+ // still matches pgrep). Upgrade presence→health via the holder heartbeat
74
+ // sidecar: if it exists and is STALE past the conservative threshold, the
75
+ // holder is wedged → wake path broken (false). If it's fresh → healthy.
76
+ // If it's ABSENT, fall back to presence (an old pre-#822 monitor, or a
77
+ // #822 monitor armed <1 tick ago that hasn't written its first heartbeat)
78
+ // → report healthy; never false-flag a monitor that simply lacks the
79
+ // sidecar (conservative — err toward NOT warning).
80
+ return !isHeartbeatStale(inboxPath, monitorStateRoot);
81
+ }
82
+ if (res.status === 1) return false;
83
+ // pgrep exits 2 for syntax error, 3 for fatal — treat as unknown.
84
+ return null;
85
+ } catch {
86
+ return null;
87
+ }
88
+ }
89
+
90
+ /**
91
+ * gh#822: are all present holder heartbeat sidecars stale past the threshold?
92
+ * A fresh legacy sidecar wins during migration; absent sidecars (old monitor /
93
+ * just-armed) still fall back to process presence. Only present-and-all-stale
94
+ * state is a wedged-holder signal.
95
+ */
96
+ export function isHeartbeatStale(inboxPath: string, monitorStateRoot?: string | null): boolean {
97
+ const paths = [heartbeatPathFor(inboxPath, monitorStateRoot)];
98
+ if (monitorStateRoot) paths.push(legacyHeartbeatPathFor(inboxPath));
99
+ let sawHeartbeat = false;
100
+ for (const path of new Set(paths)) {
101
+ try {
102
+ const mtimeMs = statSync(path).mtimeMs;
103
+ sawHeartbeat = true;
104
+ if (Date.now() - mtimeMs <= HEARTBEAT_STALE_MS) return false;
105
+ } catch {
106
+ // absent / unreadable → keep evaluating the migration counterpart
107
+ }
108
+ }
109
+ return sawHeartbeat;
110
+ }
111
+
112
+ export interface RenderInputs {
113
+ status: StreamStatus;
114
+ /**
115
+ * Tri-state Monitor liveness: true = healthy, false = wake-path
116
+ * broken, null = cannot determine.
117
+ */
118
+ inboxMonitorHealthy: boolean | null;
119
+ /**
120
+ * Inbox path for the State-5 self-arm instruction. Pass null when
121
+ * unknown (no active cube); State 5 will then surface the failure
122
+ * mode but omit the exact command.
123
+ */
124
+ inboxPath: string | null;
125
+ /** Explicit worktree-local root for the Monitor command, when known. */
126
+ monitorStateRoot?: string | null;
127
+ /** Drone label for the Monitor description copy. */
128
+ droneLabel: string | null;
129
+ /** Cube name for the Monitor description copy. */
130
+ cubeName: string | null;
131
+ /** Relative-time formatter (injected so the renderer is pure). */
132
+ humanAgo: (d: Date) => string;
133
+ }
134
+
135
+ /**
136
+ * Render the `borg_stream-status` markdown body per drone-4's 18:30:51
137
+ * contract. Pure function — no I/O, no clock reads. Caller assembles
138
+ * the inputs.
139
+ */
140
+ export function renderStreamStatus(inputs: RenderInputs): string {
141
+ const { status, inboxMonitorHealthy, inboxPath, monitorStateRoot, droneLabel, cubeName, humanAgo } =
142
+ inputs;
143
+
144
+ const isNotStarted =
145
+ status.reconnectAttempts === 0 &&
146
+ status.lastWireActivityAt === null &&
147
+ !status.connected;
148
+ const ownedByOther = status.ownership?.state === 'owned-by-other-process';
149
+ const orphanedInitialization = status.ownership?.state === 'orphaned-initialization';
150
+ const ownershipInitializing = status.ownership?.state === 'initializing';
151
+
152
+ // Top-line verdict — 5 states + override per drone-4 contract.
153
+ // Precedence: disconnected > no-inbox-Monitor (wire-down upstream
154
+ // cause; State 5 only applies when wire is healthy).
155
+ let summary: string;
156
+ if (orphanedInitialization) {
157
+ summary = '**Stream blocked by an orphaned initialization lock.**';
158
+ } else if (ownedByOther) {
159
+ summary = '**Stream owned by another Borg MCP process.**';
160
+ } else if (isNotStarted) {
161
+ summary = '**Stream not started.**';
162
+ } else if (!status.connected) {
163
+ summary = `**Stream disconnected (reconnect attempt ${status.reconnectAttempts}).**`;
164
+ } else if (inboxMonitorHealthy === false) {
165
+ summary = '**Stream connected (no inbox-Monitor — wake path broken).**';
166
+ } else if (status.lastContentEventAt === null) {
167
+ // State 2: wire works, no content yet. Collapses two underlying
168
+ // conditions per drone-4 contract — fresh connect pre-first-content
169
+ // and quiet cube post-reconnect. The body's heartbeat field
170
+ // distinguishes them (populated vs `_(none)_`).
171
+ summary = '**Stream connected, awaiting first content event.**';
172
+ } else {
173
+ summary = `**Stream connected, last content ${humanAgo(
174
+ new Date(status.lastContentEventAt)
175
+ )}.**`;
176
+ }
177
+
178
+ const lines: string[] = [];
179
+ lines.push(summary);
180
+ lines.push('');
181
+ lines.push('# Log-stream status');
182
+ lines.push('');
183
+
184
+ if (orphanedInitialization) {
185
+ lines.push('- **state**: _(orphaned stream-owner initialization)_');
186
+ } else if (ownershipInitializing) {
187
+ lines.push('- **state**: _(stream-owner initialization in progress)_');
188
+ } else if (ownedByOther) {
189
+ lines.push('- **state**: _(stream owner is another local process)_');
190
+ } else if (isNotStarted) {
191
+ lines.push('- **state**: _(stream not started)_');
192
+ } else {
193
+ lines.push(`- **connected**: ${status.connected}`);
194
+ }
195
+
196
+ // Body shape per drone-4 contract: three timestamp lines (content,
197
+ // heartbeat, wire) — looks redundant in the common case where they
198
+ // coincide, but the asymmetric "content quiet, heartbeats alive" case
199
+ // is exactly the diagnostic scenario this surface exists to support.
200
+ lines.push(
201
+ `- **last content event**: ${
202
+ status.lastContentEventAt
203
+ ? `${status.lastContentEventAt} (${humanAgo(
204
+ new Date(status.lastContentEventAt)
205
+ )})`
206
+ : '_(none yet)_'
207
+ }`
208
+ );
209
+ lines.push(
210
+ `- **last heartbeat at**: ${
211
+ status.lastHeartbeatAt
212
+ ? `${status.lastHeartbeatAt} (${humanAgo(
213
+ new Date(status.lastHeartbeatAt)
214
+ )})`
215
+ : '_(none)_'
216
+ }`
217
+ );
218
+ lines.push(
219
+ `- **last wire activity**: ${
220
+ status.lastWireActivityAt
221
+ ? `${status.lastWireActivityAt} (${humanAgo(
222
+ new Date(status.lastWireActivityAt)
223
+ )})`
224
+ : '_(none)_'
225
+ }`
226
+ );
227
+ lines.push(
228
+ `- **last persisted event id**: ${status.lastPersistedEventId ?? '_(none)_'}`
229
+ );
230
+ lines.push(`- **reconnect attempts**: ${status.reconnectAttempts}`);
231
+ lines.push(`- **run-loop restarts**: ${status.runLoopRestartCount}`);
232
+ lines.push(`- **stream ownership**: ${status.ownership?.state ?? '_(unknown)_'}`);
233
+ if (status.ownership?.lockPath) {
234
+ lines.push(`- **ownership lock path**: ${status.ownership.lockPath}`);
235
+ }
236
+
237
+ if (ownedByOther) {
238
+ const owner = status.ownership!;
239
+ lines.push(`- **stream owner pid**: ${owner.pid ?? '_(unknown)_'}`);
240
+ lines.push(`- **stream owner cwd**: ${owner.cwd ?? '_(unknown)_'}`);
241
+ lines.push(
242
+ `- **stream owner heartbeat age**: ${
243
+ typeof owner.ageMs === 'number' && Number.isFinite(owner.ageMs)
244
+ ? `${Math.max(0, Math.round(owner.ageMs / 1000))}s`
245
+ : '_(unknown)_'
246
+ }`
247
+ );
248
+ }
249
+
250
+ // State-5 body line + self-arm instruction. Only fires when we
251
+ // POSITIVELY detected wake-path breakage AND the wire is up — the
252
+ // disconnected case takes precedence above and would never reach
253
+ // here. When `inboxMonitorHealthy === null` (couldn't determine) we
254
+ // stay silent; surfacing an uncertain failure mode is worse UX than
255
+ // omitting it.
256
+ if (status.connected && inboxMonitorHealthy === false) {
257
+ lines.push(
258
+ `- **inbox-monitor**: _(no watcher detected — wake path broken)_`
259
+ );
260
+ if (inboxPath && droneLabel && cubeName) {
261
+ lines.push('');
262
+ lines.push('## Real-time wake-up (do this now)');
263
+ lines.push(
264
+ 'No process is tailing this drone\'s inbox file — this session won\'t wake on real-time cube activity, only on its fallback timer, and will miss live coordination from other drones. Arm an inbox Monitor:'
265
+ );
266
+ lines.push('');
267
+ lines.push(
268
+ `> Monitor command: \`${monitorCommand(inboxPath, monitorStateRoot)}\` — persistent, 1h timeout, description "borg inbox for ${droneLabel} on cube ${cubeName}".`
269
+ );
270
+ }
271
+ }
272
+
273
+ return lines.join('\n');
274
+ }
275
+
276
+ /**
277
+ * Gate predicate for the regen wake-path warning (gh#51 — extracted
278
+ * from the inline ternary in `src/index.ts` for direct unit-test
279
+ * coverage of the (connected × healthy) cross-product).
280
+ *
281
+ * Returns true ONLY when the wire is up AND we positively detected a
282
+ * dead inbox Monitor (`=== false` strict). The `null` branch
283
+ * (couldn't determine) stays silent — surfacing an uncertain failure
284
+ * mode is worse UX than omitting it (mirrors the State-5 precedence
285
+ * rule in `renderStreamStatus`). When disconnected, the wire-down case
286
+ * is the upstream cause and takes precedence; no point warning about
287
+ * the wake path when the wake-path's input has no events to deliver.
288
+ */
289
+ export function shouldShowWakePathWarning(
290
+ streamStatus: StreamStatus,
291
+ inboxMonitorHealthy: boolean | null
292
+ ): boolean {
293
+ return streamStatus.connected && inboxMonitorHealthy === false;
294
+ }
295
+
296
+ /**
297
+ * Wake-path-broken prefix for `borg_regen` output (gh#43).
298
+ *
299
+ * Pure function — caller decides whether to call (gates on
300
+ * `shouldShowWakePathWarning`). Returns an empty string when called
301
+ * with insufficient context to render the Monitor command (e.g., no
302
+ * inbox path on a no-active-cube path), so callers can always prepend
303
+ * the result unconditionally.
304
+ *
305
+ * Mirrors the State-5 self-arm instruction shape in
306
+ * `renderStreamStatus` so a drone sees the same Monitor command via
307
+ * both `borg_stream-status` and `borg_regen`. The differentiator: regen
308
+ * runs on every /loop iteration, so the prefix gives passive
309
+ * self-healing (worst-case latency = the /loop fallback heartbeat),
310
+ * whereas stream-status only surfaces the warning when actively
311
+ * called.
312
+ */
313
+ export function formatWakePathPrefix(inputs: {
314
+ inboxPath: string | null;
315
+ monitorStateRoot?: string | null;
316
+ droneLabel: string | null;
317
+ cubeName: string | null;
318
+ }): string {
319
+ const { inboxPath, monitorStateRoot, droneLabel, cubeName } = inputs;
320
+ if (!inboxPath || !droneLabel || !cubeName) return '';
321
+ return [
322
+ `## ⚠ Wake path broken — arm Monitor NOW`,
323
+ ``,
324
+ `No process is tailing this drone's inbox file. SSE delivery is healthy (entries reach disk), but Claude Code has no event source to wake on. Until you arm a Monitor, this session only wakes on the /loop fallback heartbeat and will miss live coordination from other drones:`,
325
+ ``,
326
+ `> Monitor command: \`${monitorCommand(inboxPath, monitorStateRoot)}\` — persistent, 1h timeout, description "borg inbox for ${droneLabel} on cube ${cubeName}".`,
327
+ ``,
328
+ `---`,
329
+ ``,
330
+ ].join('\n');
331
+ }
332
+
333
+ function monitorCommand(inboxPath: string, monitorStateRoot?: string | null): string {
334
+ return monitorStateRoot
335
+ ? `borg-inbox-monitor --state-root ${shellEscape(monitorStateRoot)} ${shellEscape(inboxPath)}`
336
+ : `borg-inbox-monitor ${shellEscape(inboxPath)}`;
337
+ }
@@ -0,0 +1,163 @@
1
+ /**
2
+ * gh#473 PR2 — non-clobbering sync output rendering.
3
+ *
4
+ * The dry-run output is UX-LOAD-BEARING: it must CLEARLY communicate each
5
+ * conflict (which role/section or taxonomy class, cube-current vs
6
+ * template-new, and how to accept) so the operator SEES what would be
7
+ * clobbered. Pure string logic (mirrors `roster-render.ts` /
8
+ * `list-roles-render.ts`) so it is unit-testable without the MCP runtime.
9
+ *
10
+ * The shape mirrors the worker's `NonClobberSyncResult`.
11
+ */
12
+
13
+ export type FragmentKind = 'add' | 'unchanged' | 'conflict';
14
+
15
+ export interface FragmentView {
16
+ key: string;
17
+ kind: FragmentKind;
18
+ label: string;
19
+ cubeValue: string | null;
20
+ templateValue: string;
21
+ }
22
+
23
+ export interface NonClobberSyncResult {
24
+ dryRun: boolean;
25
+ roles: Array<{
26
+ name: string;
27
+ status: 'new' | 'existing' | 'custom-skipped';
28
+ fragments: FragmentView[];
29
+ }>;
30
+ taxonomy: FragmentView[];
31
+ applied: { added: string[]; acceptedConflicts: string[] };
32
+ rejectedConflicts: string[];
33
+ // `decisions` keys that matched no classified conflict (typo'd / stale).
34
+ // Optional for back-compat with older worker responses.
35
+ unmatchedDecisions?: string[];
36
+ }
37
+
38
+ /** Truncate long fragment bodies for at-a-glance diffs. */
39
+ function trunc(s: string | null, n = 200): string {
40
+ if (s == null) return '(absent)';
41
+ const flat = s.replace(/\n/g, '⏎');
42
+ return flat.length > n ? flat.slice(0, n) + '…' : flat;
43
+ }
44
+
45
+ /**
46
+ * Render a `NonClobberSyncResult` as an operator-facing markdown report.
47
+ *
48
+ * Conflicts are the headline: each is surfaced with both sides + its
49
+ * stable accept key, and the report states explicitly that conflicts are
50
+ * KEPT (the cube's version) unless accepted. ADDs are reported as safe
51
+ * auto-applies. Custom roles are reported untouched.
52
+ */
53
+ export function renderSyncRolesResult(
54
+ result: NonClobberSyncResult,
55
+ templateName: string
56
+ ): string {
57
+ // Defensive guard against client/worker deploy skew (gh#9 class). A
58
+ // pre-#473 worker returns the legacy sync-roles shape
59
+ // ({ updated, added, unchanged, skipped, dryRun }) with no `roles[]`, so
60
+ // `result.roles.flatMap(...)` below would throw `undefined.flatMap`.
61
+ // Detect the legacy shape and render an actionable message instead of
62
+ // crashing — the skew window (0.9.47+ client + pre-#473 worker) becomes a
63
+ // clean "redeploy the worker" prompt, not an exception.
64
+ const maybeLegacy = result as unknown as Record<string, unknown>;
65
+ if (maybeLegacy.roles === undefined && 'updated' in maybeLegacy) {
66
+ return [
67
+ `## borg_sync-roles — unavailable (server out of date)`,
68
+ ``,
69
+ `The borg server returned the legacy sync-roles response shape — it is running a version older than #473, which the non-clobbering sync view does not support.`,
70
+ ``,
71
+ `**Action:** a server (worker) deploy is pending. Retry \`borg_sync-roles\` once it lands.`,
72
+ ].join('\n');
73
+ }
74
+
75
+ const mode = result.dryRun
76
+ ? '**DRY RUN** (review conflicts below; re-run with `apply: true` + a `decisions` map to commit)'
77
+ : '**APPLIED**';
78
+ const lines: string[] = [`## borg_sync-roles — ${mode}`, `Template: ${templateName}`, ''];
79
+
80
+ // Gather all fragments across roles + taxonomy for tallying.
81
+ const allFragments: FragmentView[] = [
82
+ ...result.roles.flatMap((r) => r.fragments),
83
+ ...result.taxonomy,
84
+ ];
85
+ const conflicts = allFragments.filter((f) => f.kind === 'conflict');
86
+ const adds = allFragments.filter((f) => f.kind === 'add');
87
+ const newRoles = result.roles.filter((r) => r.status === 'new');
88
+ const customRoles = result.roles.filter((r) => r.status === 'custom-skipped');
89
+
90
+ // ── Conflicts (the headline — what would be clobbered) ──
91
+ if (conflicts.length > 0) {
92
+ lines.push(
93
+ `### ⚠ ${conflicts.length} CONFLICT(s) — these fragments differ between your cube and the template`
94
+ );
95
+ if (result.dryRun) {
96
+ lines.push(
97
+ 'These differ between your cube and the template — may be because you evolved them, or because the template changed them. ' +
98
+ 'Surfaced for review, never silently overwritten. Each defaults to **KEEP (reject)** — your version survives. ' +
99
+ 'To take the template version of a specific fragment, pass its key in `decisions` as `"<key>": "accept"`.'
100
+ );
101
+ } else {
102
+ lines.push('Unless explicitly accepted, each conflict was KEPT (your version preserved).');
103
+ }
104
+ lines.push('');
105
+ for (const f of conflicts) {
106
+ const applied = result.applied.acceptedConflicts.includes(f.key);
107
+ const status = result.dryRun
108
+ ? '(would KEEP your version)'
109
+ : applied
110
+ ? '✓ accepted — template version applied'
111
+ : '↩ kept your version';
112
+ lines.push(`- **${f.label}** \`${f.key}\` ${status}`);
113
+ lines.push(` - cube (current): "${trunc(f.cubeValue)}"`);
114
+ lines.push(` - template (new): "${trunc(f.templateValue)}"`);
115
+ }
116
+ lines.push('');
117
+ }
118
+
119
+ // ── Unmatched decision keys (typo'd / stale — intended accept dropped) ──
120
+ const unmatched = result.unmatchedDecisions ?? [];
121
+ if (unmatched.length > 0) {
122
+ lines.push(
123
+ `### ⚠ ${unmatched.length} decision key(s) matched no conflict and were ignored`
124
+ );
125
+ lines.push(
126
+ 'These keys in your `decisions` map did not correspond to any classified conflict this run ' +
127
+ '(typo or stale key) — their intended accept had NO effect. Check the exact keys against the conflicts above:'
128
+ );
129
+ for (const k of unmatched) {
130
+ lines.push(`- \`${k}\``);
131
+ }
132
+ lines.push('');
133
+ }
134
+
135
+ // ── Additions (safe auto-apply, zero clobber risk) ──
136
+ if (newRoles.length > 0 || adds.length > 0) {
137
+ lines.push(`### Additions (safe — auto-applied, zero clobber risk)`);
138
+ for (const r of newRoles) {
139
+ const note = result.dryRun ? '(new role — would be created)' : '✓ created';
140
+ lines.push(`- new role **${r.name}** ${note}`);
141
+ }
142
+ for (const f of adds) {
143
+ const note = result.dryRun ? '(would be added)' : '✓ added';
144
+ lines.push(`- **${f.label}** \`${f.key}\` ${note}`);
145
+ }
146
+ lines.push('');
147
+ }
148
+
149
+ // ── Custom roles (never touched) ──
150
+ if (customRoles.length > 0) {
151
+ lines.push(
152
+ `### Custom roles (untouched): ${customRoles.map((r) => r.name).join(', ')}`
153
+ );
154
+ lines.push('');
155
+ }
156
+
157
+ // ── Clean no-op ──
158
+ if (conflicts.length === 0 && adds.length === 0 && newRoles.length === 0) {
159
+ lines.push('✓ Cube roles + taxonomy are **up to date** with the template (no changes).');
160
+ }
161
+
162
+ return lines.join('\n').trimEnd();
163
+ }