even-keel 0.2.4 → 0.3.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (477) hide show
  1. package/.claude-plugin/marketplace.json +16 -4
  2. package/.env.example +2 -2
  3. package/CHANGELOG.md +23 -0
  4. package/README.md +10 -8
  5. package/dist/src/account/aws.js +76 -0
  6. package/dist/src/account/azure.js +36 -0
  7. package/dist/src/account/cloud-errors.js +72 -0
  8. package/dist/src/account/cloud.js +335 -0
  9. package/dist/src/account/credit.js +49 -7
  10. package/dist/src/account/gcloud.js +71 -0
  11. package/dist/src/account/header-levels.js +3 -2
  12. package/dist/src/account/homes.js +49 -5
  13. package/dist/src/account/keycheck.js +57 -4
  14. package/dist/src/account/management.js +41 -0
  15. package/dist/src/account/model.js +41 -18
  16. package/dist/src/account/network.js +8 -3
  17. package/dist/src/account/service-defaults.js +12 -3
  18. package/dist/src/account/settingsGuard.js +92 -0
  19. package/dist/src/account/settingsGuardStrip.js +36 -0
  20. package/dist/src/account/settingsHook.js +15 -0
  21. package/dist/src/account/settingsLayer.js +190 -0
  22. package/dist/src/account/settingsUninstall.js +7 -0
  23. package/dist/src/account/share.js +23 -6
  24. package/dist/src/account/spend.js +155 -0
  25. package/dist/src/account/watcher.js +189 -24
  26. package/dist/src/agent/adapters.js +13 -2
  27. package/dist/src/agent/env.js +22 -7
  28. package/dist/src/agent/model-slots.js +32 -0
  29. package/dist/src/agent/process.js +32 -6
  30. package/dist/src/agent/projectRules.js +3 -2
  31. package/dist/src/agent/providers.js +18 -1
  32. package/dist/src/agent/scripted.js +319 -0
  33. package/dist/src/agent/windows.js +35 -3
  34. package/dist/src/badge/action.js +41 -0
  35. package/dist/src/badge/check.js +60 -0
  36. package/dist/src/badge/collect.js +174 -0
  37. package/dist/src/badge/dates.js +29 -0
  38. package/dist/src/badge/drawing.js +3 -0
  39. package/dist/src/badge/fonts.generated.js +11 -0
  40. package/dist/src/badge/model.js +9 -0
  41. package/dist/src/badge/privacy.js +151 -0
  42. package/dist/src/badge/push.js +117 -0
  43. package/dist/src/badge/render.js +490 -0
  44. package/dist/src/badge/settings.js +43 -0
  45. package/dist/src/badge/stats.js +31 -0
  46. package/dist/src/badge/status.js +57 -0
  47. package/dist/src/badge/text.js +52 -0
  48. package/dist/src/badge/theme.js +54 -0
  49. package/dist/src/badge/translate.js +162 -0
  50. package/dist/src/builtin/adapter.js +40 -0
  51. package/dist/src/builtin/control.js +179 -0
  52. package/dist/src/builtin/editor.js +117 -0
  53. package/dist/src/builtin/export-store.js +67 -0
  54. package/dist/src/builtin/export.js +202 -0
  55. package/dist/src/builtin/exporting.js +25 -0
  56. package/dist/src/builtin/files.js +155 -0
  57. package/dist/src/builtin/links.js +25 -0
  58. package/dist/src/builtin/model.js +59 -0
  59. package/dist/src/builtin/routes.js +108 -0
  60. package/dist/src/builtin/source.js +240 -0
  61. package/dist/src/builtin/store.js +520 -0
  62. package/dist/src/builtin/switch.js +77 -0
  63. package/dist/src/chain/answers.js +27 -0
  64. package/dist/src/chain/archive.js +0 -1
  65. package/dist/src/chain/dispatcher.js +105 -12
  66. package/dist/src/chain/fence.js +30 -0
  67. package/dist/src/chain/handover.js +27 -9
  68. package/dist/src/chain/launches.js +4 -4
  69. package/dist/src/chain/limitNotice.js +1 -1
  70. package/dist/src/chain/lists.js +42 -6
  71. package/dist/src/chain/log.js +3 -1
  72. package/dist/src/chain/maincheck.js +116 -10
  73. package/dist/src/chain/mainci.js +26 -7
  74. package/dist/src/chain/mainfix.js +12 -1
  75. package/dist/src/chain/milestone-sequence.js +40 -0
  76. package/dist/src/chain/milestones.js +3 -2
  77. package/dist/src/chain/order.js +20 -5
  78. package/dist/src/chain/overage.js +7 -2
  79. package/dist/src/chain/places.js +1 -1
  80. package/dist/src/chain/prompts.js +64 -6
  81. package/dist/src/chain/relay.js +35 -14
  82. package/dist/src/chain/reviews.js +8 -4
  83. package/dist/src/chain/rules.js +40 -11
  84. package/dist/src/chain/snapshots.js +2 -0
  85. package/dist/src/chain/start.js +21 -1
  86. package/dist/src/chain/store.js +16 -6
  87. package/dist/src/chain/unchanged.js +68 -5
  88. package/dist/src/ci/adapters.js +3 -1
  89. package/dist/src/ci/forgejo-profile.js +3 -24
  90. package/dist/src/ci/forgejo.js +2 -1
  91. package/dist/src/ci/github.js +10 -2
  92. package/dist/src/ci/gitlab.js +10 -3
  93. package/dist/src/ci/http.js +4 -0
  94. package/dist/src/ci/model.js +79 -6
  95. package/dist/src/ci/report.js +6 -3
  96. package/dist/src/ci/shared.js +9 -0
  97. package/dist/src/ci/verdict.js +18 -7
  98. package/dist/src/ci/watcher.js +95 -23
  99. package/dist/src/ci/wiring.js +15 -0
  100. package/dist/src/claude/adapter.js +34 -8
  101. package/dist/src/claude/cli.js +32 -8
  102. package/dist/src/claude/instructions.js +42 -7
  103. package/dist/src/claude/oauth.js +67 -0
  104. package/dist/src/claude/sdk/host.js +9 -4
  105. package/dist/src/claude/tree.js +45 -14
  106. package/dist/src/cli-check/run.js +3 -3
  107. package/dist/src/cli-check/support.js +4 -4
  108. package/dist/src/cli.js +54 -17
  109. package/dist/src/codex/adapter.js +2 -0
  110. package/dist/src/codex/cli.js +34 -18
  111. package/dist/src/codex/protection.js +17 -11
  112. package/dist/src/codex/rollout.js +9 -2
  113. package/dist/src/codex/turns.js +6 -3
  114. package/dist/src/codex/window.js +14 -0
  115. package/dist/src/config-form.js +63 -7
  116. package/dist/src/config-store.js +29 -7
  117. package/dist/src/config.js +45 -15
  118. package/dist/src/copilot/adapter.js +2 -0
  119. package/dist/src/copilot/cli.js +8 -11
  120. package/dist/src/copilot/home.js +1 -1
  121. package/dist/src/copilot/transcript.js +1 -2
  122. package/dist/src/demo/agent.js +97 -0
  123. package/dist/src/demo/model.js +6 -0
  124. package/dist/src/demo/scenario.js +139 -0
  125. package/dist/src/demo/service.js +161 -0
  126. package/dist/src/diagnostics/stop.js +16 -0
  127. package/dist/src/env-file.js +4 -0
  128. package/dist/src/error-reason.js +10 -0
  129. package/dist/src/event-log/log.js +97 -0
  130. package/dist/src/event-log/model.js +1 -0
  131. package/dist/src/event-log/page-events.js +71 -0
  132. package/dist/src/event-log/watch.js +236 -0
  133. package/dist/src/events.js +57 -1
  134. package/dist/src/forgejo/adapter.js +49 -0
  135. package/dist/src/forgejo/api.js +95 -0
  136. package/dist/src/forgejo/editor.js +196 -0
  137. package/dist/src/forgejo/model.js +90 -0
  138. package/dist/src/forgejo/profile.js +24 -0
  139. package/dist/src/forgejo/source.js +292 -0
  140. package/dist/src/forgejo/trust.js +45 -0
  141. package/dist/src/git/branches.js +88 -0
  142. package/dist/src/git/clone-progress.js +168 -0
  143. package/dist/src/git/remote-run.js +162 -0
  144. package/dist/src/git/run.js +6 -2
  145. package/dist/src/git/setup.js +4 -5
  146. package/dist/src/git/slot.js +9 -7
  147. package/dist/src/git/worktree.js +13 -10
  148. package/dist/src/github/adapter.js +1 -0
  149. package/dist/src/github/editor.js +214 -0
  150. package/dist/src/github/edits.js +31 -0
  151. package/dist/src/github/model.js +10 -4
  152. package/dist/src/github/source.js +66 -15
  153. package/dist/src/gitlab/adapter.js +1 -0
  154. package/dist/src/gitlab/api.js +4 -2
  155. package/dist/src/gitlab/editor.js +248 -0
  156. package/dist/src/gitlab/model.js +43 -4
  157. package/dist/src/gitlab/source.js +113 -22
  158. package/dist/src/guard.js +26 -10
  159. package/dist/src/hotkeys.js +51 -0
  160. package/dist/src/huly/adapter.js +1 -0
  161. package/dist/src/huly/collab.js +15 -0
  162. package/dist/src/huly/editor.js +241 -0
  163. package/dist/src/huly/marks.js +48 -0
  164. package/dist/src/huly/model.js +22 -5
  165. package/dist/src/huly/source.js +111 -48
  166. package/dist/src/intake/github.js +10 -0
  167. package/dist/src/intake/intake.js +41 -1
  168. package/dist/src/intake/model.js +8 -3
  169. package/dist/src/jira/adapter.js +1 -0
  170. package/dist/src/jira/api.js +28 -7
  171. package/dist/src/jira/editor.js +243 -0
  172. package/dist/src/jira/model.js +19 -5
  173. package/dist/src/jira/source.js +41 -9
  174. package/dist/src/jobs/model.js +1 -0
  175. package/dist/src/jobs/runner.js +236 -0
  176. package/dist/src/limits/chatgpt.js +11 -0
  177. package/dist/src/limits/copilot.js +51 -18
  178. package/dist/src/limits/model.js +62 -8
  179. package/dist/src/limits/overage-session.js +2 -2
  180. package/dist/src/limits/overage.js +8 -5
  181. package/dist/src/limits/reset.js +7 -0
  182. package/dist/src/limits/usage.js +60 -5
  183. package/dist/src/linear/adapter.js +1 -0
  184. package/dist/src/linear/editor.js +220 -0
  185. package/dist/src/linear/estimate.js +32 -0
  186. package/dist/src/linear/model.js +24 -3
  187. package/dist/src/linear/source.js +74 -21
  188. package/dist/src/main.js +53 -23
  189. package/dist/src/notice/en-advice.js +28 -0
  190. package/dist/src/notice/en-review.js +29 -0
  191. package/dist/src/notice/en-startup.js +21 -0
  192. package/dist/src/notice/en-values.js +47 -0
  193. package/dist/src/notice/en.js +265 -96
  194. package/dist/src/notice/kinds.js +26 -0
  195. package/dist/src/notice/notice.js +49 -6
  196. package/dist/src/npm-access.js +58 -0
  197. package/dist/src/opencode/adapter.js +4 -2
  198. package/dist/src/opencode/cli.js +34 -25
  199. package/dist/src/opencode/go.js +51 -0
  200. package/dist/src/opencode/home.js +41 -8
  201. package/dist/src/opencode/transcript.js +5 -5
  202. package/dist/src/opencode/usage.js +10 -4
  203. package/dist/src/opencode/window.js +54 -0
  204. package/dist/src/packages/check.js +11 -5
  205. package/dist/src/packages/gateway.js +76 -6
  206. package/dist/src/packages/launch.js +6 -3
  207. package/dist/src/packages/model.js +61 -2
  208. package/dist/src/packages/npm.js +55 -6
  209. package/dist/src/packages/plugins.js +23 -2
  210. package/dist/src/packages/service.js +104 -17
  211. package/dist/src/packages/settings.js +13 -0
  212. package/dist/src/packages/store.js +1 -1
  213. package/dist/src/paths.js +32 -0
  214. package/dist/src/profiles/control.js +1 -0
  215. package/dist/src/profiles/model.js +2 -2
  216. package/dist/src/profiles/oauth-error.js +1 -9
  217. package/dist/src/profiles/oauth-response.js +2 -0
  218. package/dist/src/profiles/service.js +46 -4
  219. package/dist/src/profiles/store.js +10 -5
  220. package/dist/src/projects/add.js +25 -2
  221. package/dist/src/projects/branch-control.js +86 -0
  222. package/dist/src/projects/branch-move.js +39 -0
  223. package/dist/src/projects/branch.js +13 -0
  224. package/dist/src/projects/check.js +80 -36
  225. package/dist/src/projects/creation.js +166 -0
  226. package/dist/src/projects/git-found.js +62 -0
  227. package/dist/src/projects/git-mode.js +116 -0
  228. package/dist/src/projects/own-folder.js +8 -0
  229. package/dist/src/projects/place.js +235 -0
  230. package/dist/src/projects/remote-branches.js +24 -0
  231. package/dist/src/projects/target-read.js +95 -0
  232. package/dist/src/projects/target.js +56 -0
  233. package/dist/src/review/events.js +1 -1
  234. package/dist/src/review/note.js +58 -0
  235. package/dist/src/review/open.js +3 -3
  236. package/dist/src/review/wiring.js +25 -3
  237. package/dist/src/secrets/catalog.js +4 -1
  238. package/dist/src/server-control.js +1 -0
  239. package/dist/src/server-guard.js +4 -0
  240. package/dist/src/server-request.js +88 -10
  241. package/dist/src/server-response.js +143 -0
  242. package/dist/src/server-security.js +16 -0
  243. package/dist/src/server.js +105 -117
  244. package/dist/src/service/account-packages.js +116 -0
  245. package/dist/src/service/accounts.js +109 -81
  246. package/dist/src/service/badge-private.js +62 -0
  247. package/dist/src/service/badge.js +203 -0
  248. package/dist/src/service/chain-prompts.js +87 -0
  249. package/dist/src/service/chain.js +120 -190
  250. package/dist/src/service/cleanup.js +114 -0
  251. package/dist/src/service/cli-check.js +1 -1
  252. package/dist/src/service/closing.js +57 -0
  253. package/dist/src/service/demo.js +46 -0
  254. package/dist/src/service/hosting.js +239 -18
  255. package/dist/src/service/install-check.js +78 -0
  256. package/dist/src/service/lifecycle.js +4 -7
  257. package/dist/src/service/stats.js +3 -3
  258. package/dist/src/service/trackers.js +27 -1
  259. package/dist/src/service/vocabulary.js +17 -0
  260. package/dist/src/service.js +215 -19
  261. package/dist/src/sessions/agents.js +10 -2
  262. package/dist/src/sessions/approvals.js +1 -1
  263. package/dist/src/sessions/ask.js +32 -6
  264. package/dist/src/sessions/boot.js +7 -0
  265. package/dist/src/sessions/chat.js +16 -4
  266. package/dist/src/sessions/commandPrompt.js +13 -6
  267. package/dist/src/sessions/history.js +2 -0
  268. package/dist/src/sessions/keepwarm.js +1 -1
  269. package/dist/src/sessions/launch.js +21 -25
  270. package/dist/src/sessions/lingering.js +30 -7
  271. package/dist/src/sessions/mail.js +7 -6
  272. package/dist/src/sessions/mailRelay.js +2 -2
  273. package/dist/src/sessions/mailbox.js +1 -1
  274. package/dist/src/sessions/monitor.js +47 -3
  275. package/dist/src/sessions/note.js +44 -19
  276. package/dist/src/sessions/permission.js +32 -10
  277. package/dist/src/sessions/protection.js +38 -14
  278. package/dist/src/sessions/rare.js +130 -0
  279. package/dist/src/sessions/runs-store.js +20 -0
  280. package/dist/src/sessions/runs.js +140 -0
  281. package/dist/src/sessions/tail.js +4 -0
  282. package/dist/src/sessions/transcript.js +64 -8
  283. package/dist/src/settings/defaults.js +1 -0
  284. package/dist/src/settings/registry.js +86 -24
  285. package/dist/src/settings/store.js +14 -5
  286. package/dist/src/setup.js +5 -0
  287. package/dist/src/shown-work.js +22 -0
  288. package/dist/src/state/settings.js +1 -0
  289. package/dist/src/stats/base-sql.js +7 -1
  290. package/dist/src/stats/checkpoint.js +8 -5
  291. package/dist/src/stats/model.js +1 -1
  292. package/dist/src/stats/reader.js +50 -25
  293. package/dist/src/stats/rules-reader.js +6 -2
  294. package/dist/src/stats/steps-reader.js +5 -0
  295. package/dist/src/stats/tally-schema.js +1 -1
  296. package/dist/src/storage/backup-model.js +3 -0
  297. package/dist/src/storage/backup-schedule.js +197 -0
  298. package/dist/src/storage/backup-worker.js +9 -0
  299. package/dist/src/storage/backup.js +141 -0
  300. package/dist/src/storage/browser-hotkeys.js +25 -0
  301. package/dist/src/storage/context-windows.js +39 -0
  302. package/dist/src/storage/copy.js +44 -13
  303. package/dist/src/storage/database.js +343 -4
  304. package/dist/src/storage/left-folders.js +16 -0
  305. package/dist/src/storage/migrations.js +98 -1
  306. package/dist/src/storage/owner.js +12 -7
  307. package/dist/src/storage/schema.js +1 -1
  308. package/dist/src/storage/startup.js +25 -0
  309. package/dist/src/storage/state-files.js +1 -1
  310. package/dist/src/storage/vacuum.js +29 -0
  311. package/dist/src/taskmcp/args.js +146 -0
  312. package/dist/src/taskmcp/calls.js +741 -0
  313. package/dist/src/taskmcp/downloads.js +87 -0
  314. package/dist/src/taskmcp/files.js +58 -0
  315. package/dist/src/taskmcp/retries.js +57 -0
  316. package/dist/src/taskmcp/server.js +81 -0
  317. package/dist/src/taskmcp/tools.js +128 -0
  318. package/dist/src/taskmcp/vocabulary.js +75 -0
  319. package/dist/src/tools/panel.js +41 -8
  320. package/dist/src/tools/sessionSettings.js +2 -1
  321. package/dist/src/tools/settings.js +16 -3
  322. package/dist/src/tracker/adapters.js +3 -1
  323. package/dist/src/tracker/card.js +16 -12
  324. package/dist/src/tracker/close.js +57 -0
  325. package/dist/src/tracker/closer.js +18 -15
  326. package/dist/src/tracker/closes.js +6 -0
  327. package/dist/src/tracker/control.js +32 -13
  328. package/dist/src/tracker/diagnostics.js +5 -2
  329. package/dist/src/tracker/editor.js +108 -0
  330. package/dist/src/tracker/export-target.js +30 -0
  331. package/dist/src/tracker/export.js +168 -0
  332. package/dist/src/tracker/health.js +5 -0
  333. package/dist/src/tracker/link.js +127 -24
  334. package/dist/src/tracker/markers.js +7 -0
  335. package/dist/src/tracker/model.js +0 -12
  336. package/dist/src/tracker/parents.js +8 -0
  337. package/dist/src/tracker/questions.js +24 -3
  338. package/dist/src/tracker/readers.js +19 -3
  339. package/dist/src/tracker/source.js +5 -0
  340. package/dist/src/tracker/start.js +61 -6
  341. package/dist/src/tracker/templates.js +102 -0
  342. package/dist/src/tracker/trackers.js +20 -10
  343. package/dist/src/updates/runner.js +1 -1
  344. package/dist/src/updates/settle.js +11 -3
  345. package/dist/src/updates/updater.js +4 -4
  346. package/dist/tally/src/builtin-tasks.js +45 -0
  347. package/dist/tally/src/catalogue.js +70 -0
  348. package/dist/tally/src/classify.js +1 -0
  349. package/dist/tally/src/collect.js +33 -10
  350. package/dist/tally/src/copilot.js +1 -0
  351. package/dist/tally/src/db-classify.js +46 -0
  352. package/dist/tally/src/db.js +66 -60
  353. package/dist/tally/src/migrations/10-rework-label.sql +73 -0
  354. package/dist/tally/src/migrations/11-catalogue-prices.sql +53 -0
  355. package/dist/tally/src/migrations/12-key-spends.sql +30 -0
  356. package/dist/tally/src/migrations/13-normal-spans.sql +110 -0
  357. package/dist/tally/src/migrations/14-model-families.sql +25 -0
  358. package/dist/tally/src/migrations/15-task-moves.sql +32 -0
  359. package/dist/tally/src/migrations.js +1 -1
  360. package/dist/tally/src/opencode.js +1 -0
  361. package/dist/tally/src/parse.js +3 -0
  362. package/dist/tally/src/rollout.js +2 -1
  363. package/dist/tally/src/rule-hook-size.js +2 -1
  364. package/dist/tally/src/rule-hook.js +3 -0
  365. package/dist/tally/src/task-moves.js +32 -0
  366. package/dist/web/assets/BadgeDialog-Dx2EERWr.js +1 -0
  367. package/dist/web/assets/BadgeDialog-W0giN4k2.css +1 -0
  368. package/dist/web/assets/DescriptionEditor-BL_6314d.js +216 -0
  369. package/dist/web/assets/ProjectPackages-D-Hqs0sG.js +1 -0
  370. package/dist/web/assets/Select-B5xZpiCG.js +1 -0
  371. package/dist/web/assets/Select-CYemy5Na.css +1 -0
  372. package/dist/web/assets/TaskCard-B9EJ_Qa2.js +2 -0
  373. package/dist/web/assets/TaskCard-BV2lQojC.css +1 -0
  374. package/dist/web/assets/TranscriptWindow-BN6jSpev.css +1 -0
  375. package/dist/web/assets/TranscriptWindow-E8DxggYC.js +4 -0
  376. package/dist/web/assets/accountParts-c2gPSGKK.js +3 -0
  377. package/dist/web/assets/accountParts-tFRVownp.css +1 -0
  378. package/dist/web/assets/blocks-B03KxlgQ.js +12 -0
  379. package/dist/web/assets/blocks-Dx3DACiG.css +1 -0
  380. package/dist/web/assets/cardDrafts-Cb5dNpJ3.js +12 -0
  381. package/dist/web/assets/cardDrafts-izWnctoh.css +1 -0
  382. package/dist/web/assets/cardSide-63fNWHHv.css +1 -0
  383. package/dist/web/assets/cardSide-CIGvmTwG.js +2 -0
  384. package/dist/web/assets/description-C-o9LBbp.css +1 -0
  385. package/dist/web/assets/feedLine-Buzox_AA.js +1 -0
  386. package/dist/web/assets/feedLine-CBjZXWwX.css +1 -0
  387. package/dist/web/assets/hooks-DdmIE6gF.js +1 -0
  388. package/dist/web/assets/index-CkYiatZt.css +1 -0
  389. package/dist/web/assets/index-DELgEMlH.js +25 -0
  390. package/dist/web/assets/lib-B8qNeB0X.css +1 -0
  391. package/dist/web/assets/lib-C1i2rKJZ.js +18 -0
  392. package/dist/web/assets/overview-B7iEgjQD.css +1 -0
  393. package/dist/web/assets/overview-D9PUjFeR.js +7 -0
  394. package/dist/web/assets/packageGroups-B34vA6-0.js +1 -0
  395. package/dist/web/assets/packages-Dld4uH9X.css +1 -0
  396. package/dist/web/assets/react-dom-vGPErQYp.js +1 -0
  397. package/dist/web/assets/rules-BVB-I2tg.js +1 -0
  398. package/dist/web/assets/rules-Bgil4ZBp.css +1 -0
  399. package/dist/web/assets/secret-CmK85pY6.js +1 -0
  400. package/dist/web/assets/secret-DldsC74x.css +1 -0
  401. package/dist/web/assets/useFileDrop-eZtIxL1H.js +1 -0
  402. package/dist/web/assets/useHeightGlide-BmtdsmN0.css +1 -0
  403. package/dist/web/assets/useHeightGlide-DQvvOoIL.js +3 -0
  404. package/dist/web/assets/useRowFocus-CwOoEmzD.js +1 -0
  405. package/dist/web/index.html +30 -9
  406. package/dist/web/theme.js +6 -0
  407. package/even-keel.config.example.json +5 -4
  408. package/package.json +21 -5
  409. package/plugins/agent-bridge/.claude-plugin/plugin.json +16 -0
  410. package/plugins/{checkpoint → agent-bridge}/README.md +20 -6
  411. package/plugins/agent-bridge/hooks/addressban.mjs +64 -0
  412. package/plugins/{checkpoint → agent-bridge}/hooks/checkpoint-mark.mjs +4 -3
  413. package/plugins/{checkpoint → agent-bridge}/hooks/evenkeel.mjs +28 -11
  414. package/plugins/agent-bridge/hooks/git-ban.mjs +31 -0
  415. package/plugins/agent-bridge/hooks/gitban.mjs +83 -0
  416. package/plugins/agent-bridge/hooks/handoff.mjs +20 -0
  417. package/plugins/{checkpoint → agent-bridge}/hooks/hooks.json +10 -0
  418. package/plugins/{checkpoint → agent-bridge}/hooks/mailbox.mjs +6 -3
  419. package/plugins/{checkpoint → agent-bridge}/hooks/nudges.mjs +11 -7
  420. package/plugins/{checkpoint/opencode/checkpoint.mjs → agent-bridge/opencode/agent-bridge.mjs} +15 -9
  421. package/plugins/forgejo/.claude-plugin/plugin.json +7 -0
  422. package/plugins/forgejo/.mcp.json +13 -0
  423. package/plugins/forgejo/README.md +23 -0
  424. package/plugins/forgejo/skills/task/SKILL.md +55 -0
  425. package/plugins/github/.claude-plugin/plugin.json +1 -1
  426. package/plugins/github/README.md +1 -1
  427. package/plugins/github/skills/task/SKILL.md +2 -2
  428. package/plugins/gitlab/.claude-plugin/plugin.json +1 -1
  429. package/plugins/gitlab/skills/task/SKILL.md +2 -2
  430. package/plugins/huly/.claude-plugin/plugin.json +1 -1
  431. package/plugins/huly/skills/task/SKILL.md +4 -4
  432. package/plugins/jira/.claude-plugin/plugin.json +1 -1
  433. package/plugins/jira/skills/task/SKILL.md +3 -3
  434. package/plugins/linear/.claude-plugin/plugin.json +1 -1
  435. package/plugins/linear/README.md +1 -1
  436. package/plugins/linear/skills/task/SKILL.md +3 -3
  437. package/plugins/tally/.claude-plugin/plugin.json +1 -1
  438. package/plugins/tally/skills/session-audit/SKILL.md +5 -5
  439. package/plugins/tasks/.claude-plugin/plugin.json +9 -0
  440. package/plugins/tasks/.mcp.json +8 -0
  441. package/plugins/tasks/README.md +42 -0
  442. package/plugins/tasks/hooks/calibration-context.mjs +45 -0
  443. package/plugins/tasks/hooks/calibration.mjs +92 -0
  444. package/plugins/tasks/hooks/check-service.mjs +15 -0
  445. package/plugins/tasks/hooks/hooks.json +28 -0
  446. package/plugins/tasks/hooks/service-check.mjs +34 -0
  447. package/plugins/tasks/hooks/show-calibration.mjs +19 -0
  448. package/plugins/tasks/opencode/tasks.mjs +28 -0
  449. package/plugins/tasks/skills/split/SKILL.md +29 -0
  450. package/plugins/tasks/skills/task/SKILL.md +61 -0
  451. package/service/EvenKeelTray.cs +4 -20
  452. package/service/install.sh +25 -2
  453. package/service/uninstall.ps1 +16 -0
  454. package/service/uninstall.sh +10 -0
  455. package/tally/tally.config.json +2 -0
  456. package/dist/web/assets/Loader-CRe-GCoI.js +0 -31
  457. package/dist/web/assets/Loader-DJJTBsaF.css +0 -1
  458. package/dist/web/assets/TaskCard-Br2QIllc.css +0 -1
  459. package/dist/web/assets/TaskCard-C2xeaHWD.js +0 -2
  460. package/dist/web/assets/TranscriptWindow-B9zsSmIg.css +0 -1
  461. package/dist/web/assets/TranscriptWindow-COL_WTrF.js +0 -4
  462. package/dist/web/assets/feedLine-D0lnFyBZ.js +0 -1
  463. package/dist/web/assets/index-DQje9Nfo.js +0 -25
  464. package/dist/web/assets/index-mDBlgk2Y.css +0 -1
  465. package/dist/web/assets/media-BlW-XXN0.js +0 -1
  466. package/dist/web/assets/media-DR8nAbPy.css +0 -1
  467. package/dist/web/assets/useModels-1oIk0mDX.css +0 -1
  468. package/dist/web/assets/useModels-DRW63oka.js +0 -15
  469. package/plugins/checkpoint/.claude-plugin/plugin.json +0 -9
  470. package/plugins/checkpoint/hooks/handoff.mjs +0 -9
  471. /package/plugins/{checkpoint → agent-bridge}/hooks/context-checkpoint.mjs +0 -0
  472. /package/plugins/{checkpoint → agent-bridge}/hooks/merge-check.mjs +0 -0
  473. /package/plugins/{checkpoint → agent-bridge}/hooks/merges.mjs +0 -0
  474. /package/plugins/{checkpoint → agent-bridge}/hooks/permission.mjs +0 -0
  475. /package/plugins/{checkpoint → agent-bridge}/hooks/schema-hint.mjs +0 -0
  476. /package/plugins/{checkpoint → agent-bridge}/hooks/standard-gate.mjs +0 -0
  477. /package/plugins/{checkpoint → agent-bridge}/hooks/standards.mjs +0 -0
@@ -13,6 +13,19 @@ export function defaultSettings(servers) {
13
13
  }
14
14
  return settings;
15
15
  }
16
+ const SECRET_NAME = /KEY|TOKEN|SECRET|PASS|PWD|AUTH|COOKIE|CREDENTIAL|SESSION|PRIVATE|SIGNATURE/i;
17
+ const SECRET_VALUE = /^(Bearer|Basic|Token|Digest)\s|^(sk-|sk_|ghp_|gho_|ghs_|github_pat_|glpat-|xox[abpr]-|lin_api_)/i;
18
+ /**
19
+ * A setting the page must not see (BTN-1116): an `env` key or header named like a credential (`API_KEY`,
20
+ * `Authorization`, `Cookie`, `X-Api-Key`), or a value that is one whatever its name (`Bearer …`, `ghp_…`).
21
+ */
22
+ export function isSecretSetting(name, value) {
23
+ return SECRET_NAME.test(name) || SECRET_VALUE.test(value.trim());
24
+ }
25
+ /** Settings as the page gets them: a secret's value stays in the service, `null` says only that it is set. */
26
+ export function pageSettings(settings) {
27
+ return Object.fromEntries(Object.entries(settings).map(([name, value]) => [name, isSecretSetting(name, value) ? null : value]));
28
+ }
16
29
  export function applySettings(entry, settings) {
17
30
  const field = typeof entry.command === 'string' ? 'env' : 'headers';
18
31
  const own = settable(entry);
@@ -5,7 +5,7 @@ import { isRecord } from '../storage/projects.js';
5
5
  import { refuseNewer, SCHEMA_VERSION, versionOf } from '../storage/schema.js';
6
6
  /**
7
7
  * `state/packages.json` names a project by its id, as the service does (BTN-271). `undefined` — no file yet: the
8
- * catalog is seeded from what sessions get today (`seed.ts`).
8
+ * catalog is seeded from what sessions get today (`seedPackages` in `plugins.ts`).
9
9
  */
10
10
  export function loadPackages(file) {
11
11
  let text;
package/dist/src/paths.js CHANGED
@@ -50,6 +50,38 @@ export function spelledUnder(path, folder, platform = process.platform) {
50
50
  return path;
51
51
  return paths.join(paths.resolve(folder), inner.slice(outer.length + 1));
52
52
  }
53
+ /**
54
+ * `path` relative to `folder` with forward slashes on any platform, when it lies strictly inside it, links and case of
55
+ * the drive letter aside; `null` — the folder itself or a path outside it.
56
+ */
57
+ export function relativeUnder(path, folder, platform = process.platform) {
58
+ const paths = pathsOf(platform);
59
+ const inner = realOf(path, platform);
60
+ const outer = realOf(folder, platform);
61
+ if (!foldCase(inner, platform).startsWith(`${foldCase(outer, platform)}${paths.sep}`))
62
+ return null;
63
+ return inner.slice(outer.length + 1).split(paths.sep).join('/');
64
+ }
65
+ /**
66
+ * `relativeUnder` by the paths as they are written, links not followed: for a path a person reads, where a link out of
67
+ * the folder is still named by its place in it. `null` — the folder itself or a path not written under it.
68
+ */
69
+ export function writtenUnder(path, folder, platform = process.platform) {
70
+ const paths = pathsOf(platform);
71
+ const inner = paths.resolve(path);
72
+ const outer = paths.resolve(folder);
73
+ if (!foldCase(inner, platform).startsWith(`${foldCase(outer, platform)}${paths.sep}`))
74
+ return null;
75
+ return inner.slice(outer.length + 1).split(paths.sep).join('/');
76
+ }
77
+ /**
78
+ * A path as a notice names it (BTN-1150): written from `folder` when it lies under it (`writtenUnder`), with the whole
79
+ * one as `full` for the tip and the log; as it is otherwise.
80
+ */
81
+ export function shownUnder(path, folder, platform = process.platform) {
82
+ const short = writtenUnder(path, folder, platform);
83
+ return short === null ? { path } : { path: short, full: path };
84
+ }
53
85
  export function samePath(a, b, platform = process.platform) {
54
86
  return pathKey(a, platform) === pathKey(b, platform);
55
87
  }
@@ -19,6 +19,7 @@ export function profilesControl(profiles, checkLink) {
19
19
  console.log(`page: the profile ${name} is removed`);
20
20
  },
21
21
  setDefault: (id) => profiles.setDefault(id),
22
+ setDisabled: (id, disabled) => profiles.setDisabled(id, disabled),
22
23
  setRules: (id, rules) => {
23
24
  profiles.setRules(id, rules);
24
25
  console.log(`page: the chain rules of the profile ${profiles.current().profiles.find((profile) => profile.id === id)?.name} are saved`);
@@ -3,9 +3,9 @@
3
3
  * milestone rules split one tracker project between Even Keel projects and stay with them.
4
4
  */
5
5
  export const PROFILE_RULE_KEYS = ['active', 'terminal', 'requiredLabels', 'excludedLabels'];
6
- /** The trackers' kinds in the adapters' order, then the CIs'. */
6
+ /** The trackers' kinds in the adapters' order, then the CIs'; Even Keel's own tracker has no profiles. */
7
7
  export function profileKinds(trackers, cis = {}) {
8
- const own = Object.entries(trackers).map(([kind, adapter]) => [
8
+ const own = Object.entries(trackers).filter(([, adapter]) => adapter.own !== true).map(([kind, adapter]) => [
9
9
  kind,
10
10
  {
11
11
  title: adapter.title,
@@ -1,3 +1,4 @@
1
+ export { errorReason as oauthReason } from '../error-reason.js';
1
2
  export class OAuthRefused extends Error {
2
3
  }
3
4
  /** OAuth errors that a later try may get past; any other OAuth error of a 4xx answer is the provider's refusal. */
@@ -10,12 +11,3 @@ export function oauthHttpError(status, error, refused = status === 401 || reject
10
11
  return refused || ['invalid_grant', 'invalid_client', 'bad_verification_code'].includes(String(error))
11
12
  ? new OAuthRefused(message) : new Error(message);
12
13
  }
13
- export function oauthReason(error, secrets) {
14
- let message = error instanceof Error ? error.message || error.name : typeof error === 'string' ? error : 'Unknown error';
15
- const values = secrets.filter((value) => !!value).flatMap((value) => [value, encodeURIComponent(value), new URLSearchParams({ v: value }).toString().slice(2)]);
16
- for (const value of [...new Set(values)].sort((a, b) => b.length - a.length))
17
- message = message.replaceAll(value, '[redacted]');
18
- return message.replace(/\b(Bearer|Basic)\s+[^\s,;]+/gi, '$1 [redacted]')
19
- .replace(/\b(code|state|access_token|refresh_token|client_secret|code_verifier)\s*[=:]\s*[^\s&,;]+/gi, '$1=[redacted]')
20
- .replace(/[\s\u0000-\u001f\u007f]+/g, ' ').trim().slice(0, 500);
21
- }
@@ -1,8 +1,10 @@
1
1
  import { createHash } from 'node:crypto';
2
+ import { securePage } from '../server-security.js';
2
3
  const RETURN_SCRIPT = "history.replaceState(null, '', '/settings#trackers'); location.reload()";
3
4
  const SCRIPT_HASH = createHash('sha256').update(RETURN_SCRIPT).digest('base64');
4
5
  /** Commit a same-origin page before navigating: Strict cookies stay absent across HTTP redirects. */
5
6
  export function oauthCallbackPage(response, status = 200) {
7
+ securePage(response);
6
8
  response.writeHead(status, {
7
9
  'content-type': 'text/html; charset=utf-8',
8
10
  'cache-control': 'no-store',
@@ -98,6 +98,7 @@ export class Profiles {
98
98
  kind: profile.kind,
99
99
  name: profile.name,
100
100
  isDefault: profile.isDefault,
101
+ disabled: profile.disabled === true,
101
102
  fields: (this.deps.kinds[profile.kind]?.variables ?? Object.keys(profile.values)).map((name) => {
102
103
  const value = profile.values[name] || null;
103
104
  return { name, secret: isSecret(name), set: value !== null, value: isSecret(name) ? null : value };
@@ -162,6 +163,7 @@ export class Profiles {
162
163
  login: account.login,
163
164
  expiresAt: account.expiresAt,
164
165
  ...(oauth === undefined ? {} : { mcpOAuth: oauth }),
166
+ ...(stored?.disabled ? { disabled: true } : {}),
165
167
  };
166
168
  const profiles = stored === undefined ? [...this.set.profiles, profile] : this.set.profiles.map((each) => (each.id === profile.id ? profile : each));
167
169
  this.checks.set(profile.id, { state: 'ok', error: null, at: this.now() });
@@ -208,6 +210,38 @@ export class Profiles {
208
210
  const updated = Object.keys(moves).length === 0 ? rest : { ...rest, moves };
209
211
  this.replace({ ...this.set, profiles: this.set.profiles.map((each) => (each.id === id ? updated : each)) }, null);
210
212
  }
213
+ /**
214
+ * Turns the profile off or on (BTN-830). Off: nothing of its host is reached until it is on again, so it is refused while
215
+ * a chain, running or paused, is on a project or feed of it. On: it is checked again at once; no chain starts by itself.
216
+ */
217
+ setDisabled(id, disabled) {
218
+ const profile = this.profile(id);
219
+ if (profile === undefined)
220
+ throw fail('profiles.unknown', {});
221
+ if ((profile.disabled === true) === disabled)
222
+ return;
223
+ if (disabled) {
224
+ const chains = this.deps.chains?.(this.projectsOn(profile).map(([projectId]) => projectId)) ?? [];
225
+ if (chains.length > 0) {
226
+ throw fail('profiles.chainsRunning', { profile: profile.name, chains: chains.map((each) => each.label).join(', '), projects: chains.map((each) => each.id).join(',') });
227
+ }
228
+ clearTimeout(this.retries.get(id)?.timer);
229
+ this.retries.delete(id);
230
+ this.checks.delete(id);
231
+ }
232
+ const { disabled: _, ...rest } = profile;
233
+ const updated = disabled ? { ...rest, disabled: true } : rest;
234
+ this.deps.log(`profiles: ${profile.name} turned ${disabled ? 'off' : 'on'}`);
235
+ this.replace({ ...this.set, profiles: this.set.profiles.map((each) => (each.id === id ? updated : each)) }, null);
236
+ if (!disabled && this.running)
237
+ void this.recheck(id);
238
+ }
239
+ /** The turned-off profile the project or feed runs on, if it does (BTN-830). */
240
+ disabledFor(projectId) {
241
+ const project = this.deps.projects()[projectId];
242
+ const profile = project === undefined ? undefined : profileFor(this.set, projectId, project.kind);
243
+ return profile?.disabled ? profile : undefined;
244
+ }
211
245
  /** The projects and feeds the chain has started on the old default stay on it, linked to it by name (BTN-435). */
212
246
  setDefault(id) {
213
247
  const profile = this.profile(id);
@@ -259,13 +293,15 @@ export class Profiles {
259
293
  throw fail('profiles.unknown', {});
260
294
  if (kind.projects === undefined)
261
295
  throw fail('profiles.unknownKind', { kind: profile.kind });
296
+ if (profile.disabled)
297
+ throw new NoticeError(disabledNotice(profile));
262
298
  return kind.projects(profile.values, query, this.deps.timeoutMs);
263
299
  }
264
300
  /** The profile the project runs on, if its tracker refused its credentials at the last check: its chain waits. */
265
301
  refused(projectId) {
266
302
  const project = this.deps.projects()[projectId];
267
303
  const profile = project === undefined ? undefined : profileFor(this.set, projectId, project.kind);
268
- return profile !== undefined && this.checks.get(profile.id)?.state === 'refused' ? profile : undefined;
304
+ return profile !== undefined && !profile.disabled && this.checks.get(profile.id)?.state === 'refused' ? profile : undefined;
269
305
  }
270
306
  start() {
271
307
  this.running = true;
@@ -287,13 +323,13 @@ export class Profiles {
287
323
  }
288
324
  /** Checks every profile, or the one, against its tracker. */
289
325
  async recheck(id) {
290
- const profiles = this.set.profiles.filter((profile) => id === undefined || profile.id === id);
326
+ const profiles = this.set.profiles.filter((profile) => (id === undefined || profile.id === id) && !profile.disabled);
291
327
  await Promise.all(profiles.map((profile) => this.recheckOne(profile)));
292
328
  }
293
329
  /** A tracker or CI link of the profile answers again: checks it again if its last check got no answer, at most once a minute. */
294
330
  recheckSoon(id) {
295
331
  const check = this.checks.get(id);
296
- if (check?.state !== 'unreachable')
332
+ if (check?.state !== 'unreachable' || this.profile(id)?.disabled)
297
333
  return;
298
334
  if (check.at !== null && Date.parse(this.now()) - Date.parse(check.at) < SOON_MS)
299
335
  return;
@@ -303,7 +339,7 @@ export class Profiles {
303
339
  retryLater(id, state) {
304
340
  const before = this.retries.get(id);
305
341
  clearTimeout(before?.timer);
306
- if (state !== 'unreachable' || !this.running) {
342
+ if (state !== 'unreachable' || !this.running || this.profile(id)?.disabled) {
307
343
  this.retries.delete(id);
308
344
  return;
309
345
  }
@@ -334,6 +370,8 @@ export class Profiles {
334
370
  if (before?.state !== check.state)
335
371
  this.deps.log(`profiles: ${profile.name}: ${englishOf(failure)}`);
336
372
  }
373
+ if (this.profile(profile.id)?.disabled)
374
+ return;
337
375
  this.checks.set(profile.id, check);
338
376
  this.retryLater(profile.id, check.state);
339
377
  if (account !== undefined)
@@ -446,6 +484,10 @@ export class Profiles {
446
484
  return (this.deps.now?.() ?? new Date()).toISOString();
447
485
  }
448
486
  }
487
+ /** `profiles.disabled` of a turned-off profile, with its id for the page's "Turn on" (BTN-830); none for no profile. */
488
+ export function disabledNotice(profile, project) {
489
+ return profile === undefined ? undefined : notice('profiles.disabled', { profile: profile.name, id: profile.id, ...(project === undefined ? {} : { project }) });
490
+ }
449
491
  const keysOf = (projects) => projects.map(([, project]) => project.key).join(', ');
450
492
  /** Atlassian grants MCP to whoever is signed in in the browser: another person than the tracker's is worth a warning, not a refusal. */
451
493
  function otherPerson(tracker, grant) {
@@ -1,5 +1,5 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import { FORGEJO_PROFILE, FORGEJO_TOKEN, FORGEJO_URL, hostOf } from '../ci/forgejo-profile.js';
2
+ import { FORGEJO_TOKEN, FORGEJO_URL, forgejoName, hostOf } from '../ci/forgejo-profile.js';
3
3
  import { inTransaction } from '../storage/database.js';
4
4
  import { setStateValue, stateValue } from '../storage/service-state.js';
5
5
  import { profilesOfEnv } from './model.js';
@@ -28,6 +28,7 @@ export async function readProfiles(db) {
28
28
  ...(Object.keys(moves).length === 0 ? {} : { moves }),
29
29
  // A grant of a kind that lost MCP OAuth (Linear, GitHub: BTN-604) is dropped; the next save clears its row.
30
30
  ...(row.mcp_oauth === 'null' || MCP_OAUTH[row.kind] === undefined ? {} : { mcpOAuth: JSON.parse(row.mcp_oauth) }),
31
+ ...(row.disabled ? { disabled: true } : {}),
31
32
  };
32
33
  }),
33
34
  links: Object.fromEntries(links.map((link) => [link.id, link.profile_id])),
@@ -53,6 +54,7 @@ export function saveProfiles(db, { profiles, links, feeds = {} }, now = new Date
53
54
  rules: JSON.stringify(profile.rules ?? {}),
54
55
  mcp_oauth: JSON.stringify(profile.mcpOAuth ?? null),
55
56
  moves: JSON.stringify(profile.moves ?? {}),
57
+ disabled: profile.disabled === true,
56
58
  }));
57
59
  return inTransaction(db, async (tx) => {
58
60
  await tx.query('update projects set profile_id = ($1::json ->> id) where profile_id is distinct from ($1::json ->> id)', [JSON.stringify(links)]);
@@ -64,7 +66,7 @@ export function saveProfiles(db, { profiles, links, feeds = {} }, now = new Date
64
66
  await tx.query(`insert into tracker_profiles select * from json_populate_recordset(null::tracker_profiles, $1)
65
67
  on conflict (id) do update set kind = excluded.kind, name = excluded.name, credentials = excluded.credentials,
66
68
  is_default = excluded.is_default, login = excluded.login, expires_at = excluded.expires_at, position = excluded.position,
67
- rules = excluded.rules, mcp_oauth = excluded.mcp_oauth, moves = excluded.moves`, [JSON.stringify(rows)]);
69
+ rules = excluded.rules, mcp_oauth = excluded.mcp_oauth, moves = excluded.moves, disabled = excluded.disabled`, [JSON.stringify(rows)]);
68
70
  });
69
71
  }
70
72
  /**
@@ -101,15 +103,18 @@ export async function importForgejo({ db, env, webs, log }) {
101
103
  return stored;
102
104
  const token = env[FORGEJO_TOKEN];
103
105
  const byHost = new Map();
104
- for (const web of token ? await webs() : []) {
106
+ // `FORGEJO_URL` beside the token names the tracker's server (BTN-476): its host goes first and becomes the default.
107
+ const own = env[FORGEJO_URL];
108
+ for (const web of token ? [...(own ? [own] : []), ...(await webs())] : []) {
105
109
  const host = hostOf(web);
106
- if (host !== null && !byHost.has(host))
110
+ const known = stored.profiles.some((profile) => profile.kind === 'forgejo' && hostOf(profile.values[FORGEJO_URL] ?? '') === host);
111
+ if (host !== null && !known && !byHost.has(host))
107
112
  byHost.set(host, web);
108
113
  }
109
114
  const hasDefault = stored.profiles.some((profile) => profile.kind === 'forgejo' && profile.isDefault);
110
115
  const made = [...byHost.values()].map((web, index) => {
111
116
  const values = { [FORGEJO_URL]: web, [FORGEJO_TOKEN]: token };
112
- return { id: randomUUID(), kind: 'forgejo', name: FORGEJO_PROFILE.profileName(values, null), values, isDefault: !hasDefault && index === 0, login: null, expiresAt: null };
117
+ return { id: randomUUID(), kind: 'forgejo', name: forgejoName(web), values, isDefault: !hasDefault && index === 0, login: null, expiresAt: null };
113
118
  });
114
119
  const set = { ...stored, profiles: [...stored.profiles, ...made] };
115
120
  await inTransaction(db, async (tx) => {
@@ -1,11 +1,34 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { mkdir } from 'node:fs/promises';
3
+ import { DEFAULT_BRANCH } from '../config.js';
1
4
  import { NoticeError } from '../notice/notice.js';
5
+ import { moveBranch } from './branch-move.js';
2
6
  import { checkRepo } from './check.js';
7
+ import { ownFolder, projectsDir } from './own-folder.js';
8
+ /**
9
+ * The checkout goes onto the draft's branch first, created or taken from a remote (BTN-754); the entry is written once
10
+ * it stands there. A project without git has no checkout: its folder, typed or Even Keel's own, is made once the entry is in.
11
+ */
3
12
  export async function addProject(deps, draft) {
4
- const repo = await checkRepo(deps.git, draft, deps.configStore.raw(), process.platform, undefined, {}, deps.folders);
13
+ const ownDir = deps.projectsDir ?? projectsDir();
14
+ const repo = await checkRepo(deps.git, draft, deps.configStore.raw(), process.platform, undefined, {}, deps.folders, ownDir);
5
15
  if (repo.notice !== null)
6
16
  throw new NoticeError(repo.notice);
7
- const id = deps.configStore.addProject({ ...draft, repo: repo.root ?? draft.repo });
17
+ const id = draft.git === false ? await addPlain(deps, draft, draft.repo.trim() === '' ? null : repo.root, ownDir) : await addCheckout(deps, draft, repo);
8
18
  if (draft.profile !== null)
9
19
  deps.profiles.link(id, draft.profile);
10
20
  console.log(`page: the project ${draft.key.trim()} is added to the config`);
21
+ return id;
22
+ }
23
+ async function addCheckout(deps, draft, repo) {
24
+ const root = repo.root ?? draft.repo;
25
+ const branch = draft.branch.trim() || repo.current || DEFAULT_BRANCH;
26
+ return moveBranch(deps.git, root, repo.branches, branch, () => deps.configStore.addProject({ ...draft, repo: root }));
27
+ }
28
+ async function addPlain(deps, draft, typed, ownDir) {
29
+ const id = randomUUID();
30
+ const folder = typed ?? ownFolder(ownDir, draft.key, id);
31
+ deps.configStore.addProject({ ...draft, repo: folder }, {}, id);
32
+ await mkdir(folder, { recursive: true });
33
+ return id;
11
34
  }
@@ -0,0 +1,86 @@
1
+ import { isBranchName, readBranches } from '../git/branches.js';
2
+ import { fail } from '../notice/notice.js';
3
+ import { moveBranch } from './branch-move.js';
4
+ /**
5
+ * The project's main branch and its main checkout as one (BTN-754). A new branch saved on the page moves the checkout;
6
+ * a checkout moved by hand does not move the branch: it is shown as a drift, read when the settings open and when the
7
+ * chain starts, never polled, and the page offers to adopt the checkout's branch or to put the checkout back.
8
+ */
9
+ export class BranchControl {
10
+ deps;
11
+ drift = new Map();
12
+ constructor(deps) {
13
+ this.deps = deps;
14
+ }
15
+ /** The projects whose checkout stands off their branch, as last read. */
16
+ view() {
17
+ return Object.fromEntries(this.drift);
18
+ }
19
+ /** The checkout's branches for the settings' field; reading them notes the drift. */
20
+ async branches(project) {
21
+ const read = await readBranches(this.deps.git, this.repoOf(project));
22
+ if (read === null)
23
+ throw fail('branch.noRepo', { project });
24
+ this.note(project, read.current);
25
+ return read;
26
+ }
27
+ /** The chain's start reads the checkout too, so its card warns before a task's launch refuses (`git.wrongBranch`). */
28
+ async refresh(project) {
29
+ if (this.deps.repo(project) === undefined)
30
+ return;
31
+ try {
32
+ await this.branches(project);
33
+ }
34
+ catch (error) {
35
+ console.warn(`git: the branches of ${project} were not read: ${error instanceof Error ? error.message : String(error)}`);
36
+ }
37
+ }
38
+ /** The settings saved with another branch: the checkout goes there in `repo` first, then `write` saves the form. */
39
+ async change(project, repo, branch, write) {
40
+ if (!(await isBranchName(this.deps.git, repo, branch)))
41
+ throw fail('config.branch', { where: `${this.deps.key(project)}.branch`, value: JSON.stringify(branch) });
42
+ // The chain merges a task in hand into the branch it started from: the branch holds until the task ends, moved or not.
43
+ this.requireIdle(project);
44
+ const result = await moveBranch(this.deps.git, repo, null, branch, write, project);
45
+ this.note(project, branch, branch);
46
+ return result;
47
+ }
48
+ /** "Make it the main branch": the checkout's branch becomes `branch`, git is not touched. */
49
+ async adopt(project) {
50
+ this.requireIdle(project);
51
+ const { current } = await this.branches(project);
52
+ if (current === null)
53
+ throw fail('branch.noRepo', { project });
54
+ this.deps.write(project, current);
55
+ this.note(project, current, current);
56
+ console.log(`page: the main branch of ${project} is now ${current}, the branch its checkout stands on`);
57
+ }
58
+ /** "Put the folder back": the checkout goes onto `branch`, with the same refusals as a save. */
59
+ async restore(project) {
60
+ this.requireIdle(project);
61
+ const branch = this.deps.branch(project);
62
+ await moveBranch(this.deps.git, this.repoOf(project), null, branch, () => undefined, project);
63
+ this.note(project, branch);
64
+ }
65
+ requireIdle(project) {
66
+ if (this.deps.busy(project))
67
+ throw fail('branch.busy', { project });
68
+ }
69
+ repoOf(project) {
70
+ const repo = this.deps.repo(project);
71
+ if (repo === undefined)
72
+ throw fail('config.unknownProject', { key: project });
73
+ return repo;
74
+ }
75
+ note(project, current, branch = this.deps.branch(project)) {
76
+ const before = this.drift.get(project);
77
+ const now = current === branch ? undefined : { branch, current };
78
+ if (JSON.stringify(before) === JSON.stringify(now))
79
+ return;
80
+ if (now === undefined)
81
+ this.drift.delete(project);
82
+ else
83
+ this.drift.set(project, now);
84
+ this.deps.changed();
85
+ }
86
+ }
@@ -0,0 +1,39 @@
1
+ import { moveCheckout, readBranches } from '../git/branches.js';
2
+ import { fail } from '../notice/notice.js';
3
+ import { branchMove } from './branch.js';
4
+ /**
5
+ * Puts the main checkout on `branch` (BTN-754), then `write`s the setting: git refuses first, and the config stays as it
6
+ * was; a write that fails puts the checkout back where it stood. `known` — the branches already read, else read here;
7
+ * `project` names the project in a refusal.
8
+ */
9
+ export async function moveBranch(git, repo, known, branch, write, project = '') {
10
+ const branches = known ?? (await readBranches(git, repo));
11
+ if (branches === null)
12
+ throw fail('branch.noRepo', { project });
13
+ const move = branchMove(branches, branch);
14
+ await moveCheckout(git, repo, branch, move);
15
+ try {
16
+ return write();
17
+ }
18
+ catch (error) {
19
+ await putBack(git, repo, branches, branch, move);
20
+ throw error;
21
+ }
22
+ }
23
+ async function putBack(git, repo, before, branch, move) {
24
+ if (move.kind === 'stay')
25
+ return;
26
+ const back = before.current === null ? ['switch', '--detach', before.head ?? 'HEAD@{1}'] : ['switch', before.current];
27
+ const switched = await git(repo, back);
28
+ if (switched.code !== 0) {
29
+ console.warn(`git: ${repo} was not put back after a failed write (git ${back.join(' ')}): ${switched.out}`);
30
+ return;
31
+ }
32
+ // A branch this move made is dropped again: it has nothing of its own yet.
33
+ if (move.kind !== 'switch') {
34
+ const dropped = await git(repo, ['branch', '-D', branch]);
35
+ if (dropped.code !== 0)
36
+ console.warn(`git: ${repo} kept the branch ${branch} made before a failed write: ${dropped.out}`);
37
+ }
38
+ console.log(`git: ${repo} is put back on ${before.current ?? before.head} after a failed write`);
39
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The project's main branch and the main checkout as one thing (BTN-754): the field offers the repository's branches,
3
+ * and a new value moves the checkout. Pure — the page reads the same move to say what saving will do.
4
+ */
5
+ export function branchMove(repo, target) {
6
+ const name = target.trim();
7
+ if (name === repo.current)
8
+ return { kind: 'stay' };
9
+ const found = repo.branches.find((branch) => branch.name === name);
10
+ if (found === undefined)
11
+ return { kind: 'create', from: repo.current, head: repo.head };
12
+ return found.remote === null ? { kind: 'switch', from: repo.current } : { kind: 'track', remote: found.remote, from: repo.current };
13
+ }