@warpgogol/forge 9.1.0 → 9.2.3

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 (380) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +15 -8
  3. package/README.uk.md +15 -8
  4. package/bin/cli.ts +3 -2
  5. package/dist/bin/cli.js +3 -2
  6. package/dist/bin/cli.js.map +1 -1
  7. package/dist/os/core/core.module.d.ts.map +1 -1
  8. package/dist/os/core/core.module.js +6 -4
  9. package/dist/os/core/core.module.js.map +1 -1
  10. package/dist/os/flow/branch-name.d.ts +56 -0
  11. package/dist/os/flow/branch-name.d.ts.map +1 -0
  12. package/dist/os/flow/branch-name.js +108 -0
  13. package/dist/os/flow/branch-name.js.map +1 -0
  14. package/dist/os/flow/digest.d.ts +73 -0
  15. package/dist/os/flow/digest.d.ts.map +1 -0
  16. package/dist/os/flow/digest.js +634 -0
  17. package/dist/os/flow/digest.js.map +1 -0
  18. package/dist/os/flow/flow.module.d.ts +3 -0
  19. package/dist/os/flow/flow.module.d.ts.map +1 -0
  20. package/dist/os/flow/flow.module.js +716 -0
  21. package/dist/os/flow/flow.module.js.map +1 -0
  22. package/dist/os/flow/git.d.ts +68 -0
  23. package/dist/os/flow/git.d.ts.map +1 -0
  24. package/dist/os/flow/git.js +257 -0
  25. package/dist/os/flow/git.js.map +1 -0
  26. package/dist/os/flow/guard-files.d.ts +50 -0
  27. package/dist/os/flow/guard-files.d.ts.map +1 -0
  28. package/dist/os/flow/guard-files.js +147 -0
  29. package/dist/os/flow/guard-files.js.map +1 -0
  30. package/dist/os/flow/handlers/flow-backmerge.d.ts +27 -0
  31. package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -0
  32. package/dist/os/flow/handlers/flow-backmerge.js +332 -0
  33. package/dist/os/flow/handlers/flow-backmerge.js.map +1 -0
  34. package/dist/os/flow/handlers/flow-check.d.ts +42 -0
  35. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -0
  36. package/dist/os/flow/handlers/flow-check.js +347 -0
  37. package/dist/os/flow/handlers/flow-check.js.map +1 -0
  38. package/dist/os/flow/handlers/flow-cut.d.ts +63 -0
  39. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -0
  40. package/dist/os/flow/handlers/flow-cut.js +636 -0
  41. package/dist/os/flow/handlers/flow-cut.js.map +1 -0
  42. package/dist/os/flow/handlers/flow-digest.d.ts +5 -0
  43. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -0
  44. package/dist/os/flow/handlers/flow-digest.js +110 -0
  45. package/dist/os/flow/handlers/flow-digest.js.map +1 -0
  46. package/dist/os/flow/handlers/flow-discard.d.ts +22 -0
  47. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -0
  48. package/dist/os/flow/handlers/flow-discard.js +200 -0
  49. package/dist/os/flow/handlers/flow-discard.js.map +1 -0
  50. package/dist/os/flow/handlers/flow-fix.d.ts +47 -0
  51. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -0
  52. package/dist/os/flow/handlers/flow-fix.js +443 -0
  53. package/dist/os/flow/handlers/flow-fix.js.map +1 -0
  54. package/dist/os/flow/handlers/flow-hold.d.ts +32 -0
  55. package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -0
  56. package/dist/os/flow/handlers/flow-hold.js +359 -0
  57. package/dist/os/flow/handlers/flow-hold.js.map +1 -0
  58. package/dist/os/flow/handlers/flow-install.d.ts +92 -0
  59. package/dist/os/flow/handlers/flow-install.d.ts.map +1 -0
  60. package/dist/os/flow/handlers/flow-install.js +883 -0
  61. package/dist/os/flow/handlers/flow-install.js.map +1 -0
  62. package/dist/os/flow/handlers/flow-integrate.d.ts +35 -0
  63. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -0
  64. package/dist/os/flow/handlers/flow-integrate.js +419 -0
  65. package/dist/os/flow/handlers/flow-integrate.js.map +1 -0
  66. package/dist/os/flow/handlers/flow-open.d.ts +63 -0
  67. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -0
  68. package/dist/os/flow/handlers/flow-open.js +294 -0
  69. package/dist/os/flow/handlers/flow-open.js.map +1 -0
  70. package/dist/os/flow/handlers/flow-push.d.ts +22 -0
  71. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -0
  72. package/dist/os/flow/handlers/flow-push.js +306 -0
  73. package/dist/os/flow/handlers/flow-push.js.map +1 -0
  74. package/dist/os/flow/handlers/flow-status.d.ts +65 -0
  75. package/dist/os/flow/handlers/flow-status.d.ts.map +1 -0
  76. package/dist/os/flow/handlers/flow-status.js +193 -0
  77. package/dist/os/flow/handlers/flow-status.js.map +1 -0
  78. package/dist/os/flow/handlers/flow-unhold.d.ts +20 -0
  79. package/dist/os/flow/handlers/flow-unhold.d.ts.map +1 -0
  80. package/dist/os/flow/handlers/flow-unhold.js +158 -0
  81. package/dist/os/flow/handlers/flow-unhold.js.map +1 -0
  82. package/dist/os/flow/handlers/flow-version.d.ts +39 -0
  83. package/dist/os/flow/handlers/flow-version.d.ts.map +1 -0
  84. package/dist/os/flow/handlers/flow-version.js +122 -0
  85. package/dist/os/flow/handlers/flow-version.js.map +1 -0
  86. package/dist/os/flow/index.d.ts +30 -0
  87. package/dist/os/flow/index.d.ts.map +1 -0
  88. package/dist/os/flow/index.js +83 -0
  89. package/dist/os/flow/index.js.map +1 -0
  90. package/dist/os/flow/line-version.d.ts +23 -0
  91. package/dist/os/flow/line-version.d.ts.map +1 -0
  92. package/dist/os/flow/line-version.js +83 -0
  93. package/dist/os/flow/line-version.js.map +1 -0
  94. package/dist/os/flow/locks.d.ts +34 -0
  95. package/dist/os/flow/locks.d.ts.map +1 -0
  96. package/dist/os/flow/locks.js +147 -0
  97. package/dist/os/flow/locks.js.map +1 -0
  98. package/dist/os/flow/markers.d.ts +49 -0
  99. package/dist/os/flow/markers.d.ts.map +1 -0
  100. package/dist/os/flow/markers.js +112 -0
  101. package/dist/os/flow/markers.js.map +1 -0
  102. package/dist/os/flow/publish.d.ts +28 -0
  103. package/dist/os/flow/publish.d.ts.map +1 -0
  104. package/dist/os/flow/publish.js +153 -0
  105. package/dist/os/flow/publish.js.map +1 -0
  106. package/dist/os/flow/registry.d.ts +142 -0
  107. package/dist/os/flow/registry.d.ts.map +1 -0
  108. package/dist/os/flow/registry.js +198 -0
  109. package/dist/os/flow/registry.js.map +1 -0
  110. package/dist/os/flow/release-level.d.ts +23 -0
  111. package/dist/os/flow/release-level.d.ts.map +1 -0
  112. package/dist/os/flow/release-level.js +102 -0
  113. package/dist/os/flow/release-level.js.map +1 -0
  114. package/dist/os/flow/release-lines.d.ts +25 -0
  115. package/dist/os/flow/release-lines.d.ts.map +1 -0
  116. package/dist/os/flow/release-lines.js +172 -0
  117. package/dist/os/flow/release-lines.js.map +1 -0
  118. package/dist/os/flow/release-tags.d.ts +72 -0
  119. package/dist/os/flow/release-tags.d.ts.map +1 -0
  120. package/dist/os/flow/release-tags.js +166 -0
  121. package/dist/os/flow/release-tags.js.map +1 -0
  122. package/dist/os/flow/repo-kind.d.ts +41 -0
  123. package/dist/os/flow/repo-kind.d.ts.map +1 -0
  124. package/dist/os/flow/repo-kind.js +92 -0
  125. package/dist/os/flow/repo-kind.js.map +1 -0
  126. package/dist/os/flow/scripts.d.ts +20 -0
  127. package/dist/os/flow/scripts.d.ts.map +1 -0
  128. package/dist/os/flow/scripts.js +49 -0
  129. package/dist/os/flow/scripts.js.map +1 -0
  130. package/dist/os/flow/semver.d.ts +21 -0
  131. package/dist/os/flow/semver.d.ts.map +1 -0
  132. package/dist/os/flow/semver.js +73 -0
  133. package/dist/os/flow/semver.js.map +1 -0
  134. package/dist/os/flow/tests/helpers.d.ts +52 -0
  135. package/dist/os/flow/tests/helpers.d.ts.map +1 -0
  136. package/dist/os/flow/tests/helpers.js +189 -0
  137. package/dist/os/flow/tests/helpers.js.map +1 -0
  138. package/dist/os/flow/version-files.d.ts +21 -0
  139. package/dist/os/flow/version-files.d.ts.map +1 -0
  140. package/dist/os/flow/version-files.js +94 -0
  141. package/dist/os/flow/version-files.js.map +1 -0
  142. package/dist/os/flow/worktree-path.d.ts +31 -0
  143. package/dist/os/flow/worktree-path.d.ts.map +1 -0
  144. package/dist/os/flow/worktree-path.js +80 -0
  145. package/dist/os/flow/worktree-path.js.map +1 -0
  146. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  147. package/dist/os/mission/handlers/archive.js +43 -6
  148. package/dist/os/mission/handlers/archive.js.map +1 -1
  149. package/dist/os/program/handlers/seal.d.ts.map +1 -1
  150. package/dist/os/program/handlers/seal.js +1 -1
  151. package/dist/os/program/handlers/seal.js.map +1 -1
  152. package/dist/os/program/handlers/validate.d.ts.map +1 -1
  153. package/dist/os/program/handlers/validate.js +1 -1
  154. package/dist/os/program/handlers/validate.js.map +1 -1
  155. package/dist/os/program/program.module.d.ts.map +1 -1
  156. package/dist/os/program/program.module.js +2 -1
  157. package/dist/os/program/program.module.js.map +1 -1
  158. package/dist/os/program/schemas.d.ts +4 -6
  159. package/dist/os/program/schemas.d.ts.map +1 -1
  160. package/dist/os/program/schemas.js +16 -6
  161. package/dist/os/program/schemas.js.map +1 -1
  162. package/dist/os/program/state.d.ts +0 -1
  163. package/dist/os/program/state.d.ts.map +1 -1
  164. package/dist/os/program/state.js +1 -7
  165. package/dist/os/program/state.js.map +1 -1
  166. package/dist/os/rfc/acceptance.d.ts +21 -0
  167. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  168. package/dist/os/rfc/acceptance.js +62 -13
  169. package/dist/os/rfc/acceptance.js.map +1 -1
  170. package/dist/os/rfc/frontmatter-io.d.ts +19 -0
  171. package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
  172. package/dist/os/rfc/frontmatter-io.js +65 -12
  173. package/dist/os/rfc/frontmatter-io.js.map +1 -1
  174. package/dist/os/rfc/handlers/validate-rules.d.ts +2 -5
  175. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  176. package/dist/os/rfc/handlers/validate-rules.js +10 -8
  177. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  178. package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
  179. package/dist/os/rfc/handlers/validate.js +15 -5
  180. package/dist/os/rfc/handlers/validate.js.map +1 -1
  181. package/dist/os/rfc/index.d.ts +2 -2
  182. package/dist/os/rfc/index.d.ts.map +1 -1
  183. package/dist/os/rfc/index.js +5 -2
  184. package/dist/os/rfc/index.js.map +1 -1
  185. package/dist/os/rfc/probe-batch.d.ts +71 -0
  186. package/dist/os/rfc/probe-batch.d.ts.map +1 -0
  187. package/dist/os/rfc/probe-batch.js +251 -0
  188. package/dist/os/rfc/probe-batch.js.map +1 -0
  189. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  190. package/dist/os/rfc/rfc.module.js +16 -2
  191. package/dist/os/rfc/rfc.module.js.map +1 -1
  192. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  193. package/dist/os/rfc/verification-evidence.js +21 -10
  194. package/dist/os/rfc/verification-evidence.js.map +1 -1
  195. package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
  196. package/dist/os/rfc/verification-refresh.js +20 -13
  197. package/dist/os/rfc/verification-refresh.js.map +1 -1
  198. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +1 -1
  199. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +21 -7
  200. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +1 -1
  201. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +1 -1
  202. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +1 -1
  203. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +1 -1
  204. package/dist/os/werkstatt/werkstatt.module.d.ts.map +1 -1
  205. package/dist/os/werkstatt/werkstatt.module.js +2 -82
  206. package/dist/os/werkstatt/werkstatt.module.js.map +1 -1
  207. package/dist/src/config/forge-config.d.ts +0 -3
  208. package/dist/src/config/forge-config.d.ts.map +1 -1
  209. package/dist/src/config/forge-config.js +2 -4
  210. package/dist/src/config/forge-config.js.map +1 -1
  211. package/dist/src/index.d.ts +3 -0
  212. package/dist/src/index.d.ts.map +1 -1
  213. package/dist/src/index.js +2 -0
  214. package/dist/src/index.js.map +1 -1
  215. package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
  216. package/dist/src/onboarding/agents-generate.js +49 -4
  217. package/dist/src/onboarding/agents-generate.js.map +1 -1
  218. package/dist/src/onboarding/create.d.ts +13 -0
  219. package/dist/src/onboarding/create.d.ts.map +1 -1
  220. package/dist/src/onboarding/create.js +95 -9
  221. package/dist/src/onboarding/create.js.map +1 -1
  222. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  223. package/dist/src/onboarding/doctor.js +2 -47
  224. package/dist/src/onboarding/doctor.js.map +1 -1
  225. package/dist/src/onboarding/upgrade.d.ts +5 -0
  226. package/dist/src/onboarding/upgrade.d.ts.map +1 -1
  227. package/dist/src/onboarding/upgrade.js +70 -1
  228. package/dist/src/onboarding/upgrade.js.map +1 -1
  229. package/dist/src/types.d.ts +9 -0
  230. package/dist/src/types.d.ts.map +1 -1
  231. package/dist/src/types.js +2 -2
  232. package/docs/branch-model.md +98 -0
  233. package/docs/maintainers/publishing.md +14 -6
  234. package/docs/reference/cli.md +125 -0
  235. package/docs/reference/profiles.md +1 -0
  236. package/os/core/core.module.ts +7 -4
  237. package/os/flow/assets/flow-guard.sh +176 -0
  238. package/os/flow/branch-name.ts +139 -0
  239. package/os/flow/digest.ts +761 -0
  240. package/os/flow/flow.module.ts +740 -0
  241. package/os/flow/git.ts +342 -0
  242. package/os/flow/guard-files.ts +172 -0
  243. package/os/flow/handlers/flow-backmerge.ts +488 -0
  244. package/os/flow/handlers/flow-check.ts +450 -0
  245. package/os/flow/handlers/flow-cut.ts +912 -0
  246. package/os/flow/handlers/flow-digest.ts +124 -0
  247. package/os/flow/handlers/flow-discard.ts +301 -0
  248. package/os/flow/handlers/flow-fix.ts +597 -0
  249. package/os/flow/handlers/flow-hold.ts +500 -0
  250. package/os/flow/handlers/flow-install.ts +1185 -0
  251. package/os/flow/handlers/flow-integrate.ts +607 -0
  252. package/os/flow/handlers/flow-open.ts +447 -0
  253. package/os/flow/handlers/flow-push.ts +373 -0
  254. package/os/flow/handlers/flow-status.ts +283 -0
  255. package/os/flow/handlers/flow-unhold.ts +220 -0
  256. package/os/flow/handlers/flow-version.ts +196 -0
  257. package/os/flow/index.ts +102 -0
  258. package/os/flow/line-version.ts +113 -0
  259. package/os/flow/locks.ts +177 -0
  260. package/os/flow/markers.ts +135 -0
  261. package/os/flow/publish.ts +201 -0
  262. package/os/flow/registry.ts +266 -0
  263. package/os/flow/release-level.ts +139 -0
  264. package/os/flow/release-lines.ts +208 -0
  265. package/os/flow/release-tags.ts +231 -0
  266. package/os/flow/repo-kind.ts +117 -0
  267. package/os/flow/scripts.ts +73 -0
  268. package/os/flow/semver.ts +82 -0
  269. package/os/flow/tests/branch-name.test.ts +136 -0
  270. package/os/flow/tests/fixtures/branch-names.yaml +56 -0
  271. package/os/flow/tests/flow-backmerge.test.ts +267 -0
  272. package/os/flow/tests/flow-check-version.test.ts +138 -0
  273. package/os/flow/tests/flow-check.test.ts +213 -0
  274. package/os/flow/tests/flow-cut.rerun.test.ts +95 -0
  275. package/os/flow/tests/flow-cut.test.ts +319 -0
  276. package/os/flow/tests/flow-digest.test.ts +313 -0
  277. package/os/flow/tests/flow-discard.test.ts +220 -0
  278. package/os/flow/tests/flow-fix.test.ts +359 -0
  279. package/os/flow/tests/flow-guard-merge.test.ts +100 -0
  280. package/os/flow/tests/flow-guard-parity.test.ts +115 -0
  281. package/os/flow/tests/flow-guard-push.test.ts +100 -0
  282. package/os/flow/tests/flow-guard.test.ts +135 -0
  283. package/os/flow/tests/flow-hold.test.ts +465 -0
  284. package/os/flow/tests/flow-install-baseline.rerun.test.ts +73 -0
  285. package/os/flow/tests/flow-install-baseline.test.ts +164 -0
  286. package/os/flow/tests/flow-install-markers.test.ts +161 -0
  287. package/os/flow/tests/flow-install.rerun.test.ts +212 -0
  288. package/os/flow/tests/flow-install.test.ts +330 -0
  289. package/os/flow/tests/flow-integrate.rerun.test.ts +92 -0
  290. package/os/flow/tests/flow-integrate.test.ts +229 -0
  291. package/os/flow/tests/flow-open.test.ts +200 -0
  292. package/os/flow/tests/flow-push-publish.test.ts +282 -0
  293. package/os/flow/tests/flow-push.test.ts +160 -0
  294. package/os/flow/tests/flow-stale.test.ts +136 -0
  295. package/os/flow/tests/flow-status.test.ts +93 -0
  296. package/os/flow/tests/flow-version-level.test.ts +116 -0
  297. package/os/flow/tests/flow-version.test.ts +169 -0
  298. package/os/flow/tests/helpers.ts +235 -0
  299. package/os/flow/tests/is-flow-adopted.test.ts +71 -0
  300. package/os/flow/tests/registry.test.ts +150 -0
  301. package/os/flow/tests/repository-line-version.test.ts +100 -0
  302. package/os/flow/tests/scripts.test.ts +97 -0
  303. package/os/flow/tests/state-roots.test.ts +127 -0
  304. package/os/flow/tests/version-files.test.ts +145 -0
  305. package/os/flow/version-files.ts +115 -0
  306. package/os/flow/worktree-path.ts +107 -0
  307. package/os/mission/handlers/archive.test.ts +27 -0
  308. package/os/mission/handlers/archive.ts +46 -6
  309. package/os/program/handlers/seal.ts +1 -1
  310. package/os/program/handlers/validate.ts +1 -1
  311. package/os/program/program.module.ts +2 -1
  312. package/os/program/schemas.ts +51 -34
  313. package/os/program/state.ts +1 -9
  314. package/os/rfc/acceptance.ts +84 -19
  315. package/os/rfc/frontmatter-io.ts +78 -12
  316. package/os/rfc/handlers/implement-stamp-stale.test.ts +22 -0
  317. package/os/rfc/handlers/validate-rules.test.ts +9 -6
  318. package/os/rfc/handlers/validate-rules.ts +12 -10
  319. package/os/rfc/handlers/validate.ts +17 -5
  320. package/os/rfc/index.ts +13 -1
  321. package/os/rfc/probe-batch.ts +329 -0
  322. package/os/rfc/rfc.module.ts +19 -2
  323. package/os/rfc/verification-emit-check.test.ts +22 -0
  324. package/os/rfc/verification-emit-freshness.test.ts +22 -0
  325. package/os/rfc/verification-emit.test.ts +22 -0
  326. package/os/rfc/verification-evidence.ts +21 -16
  327. package/os/rfc/verification-refresh.test.ts +22 -0
  328. package/os/rfc/verification-refresh.ts +20 -18
  329. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +9 -0
  330. package/os/werkstatt/handlers/werkstatt-lock-recover.ts +22 -5
  331. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +1 -1
  332. package/os/werkstatt/werkstatt.module.ts +2 -85
  333. package/package.json +17 -1
  334. package/profiles/forge-shell.yaml +22 -10
  335. package/profiles/godot-game.yaml +24 -13
  336. package/profiles/knowledge.yaml +19 -0
  337. package/profiles/phaser-game.yaml +25 -13
  338. package/profiles/site-workshop.yaml +27 -10
  339. package/profiles/typescript.yaml +26 -9
  340. package/skills/fo/fo-session-retro/SKILL.md +18 -7
  341. package/skills/fo/fo-step-commit/SKILL.md +2 -1
  342. package/src/config/forge-config.ts +2 -6
  343. package/src/index.ts +8 -0
  344. package/src/onboarding/agents-generate.ts +49 -5
  345. package/src/onboarding/create.ts +101 -9
  346. package/src/onboarding/doctor.ts +2 -51
  347. package/src/onboarding/upgrade.ts +86 -1
  348. package/src/tests/agents-generate-flow.test.ts +132 -0
  349. package/src/tests/create-flow.test.ts +114 -0
  350. package/src/tests/create.test.ts +22 -21
  351. package/src/tests/doctor-autonomy.test.ts +2 -1
  352. package/src/tests/implement-stamp.test.ts +26 -3
  353. package/src/tests/profile-flow-hooks.test.ts +77 -0
  354. package/src/tests/program-schemas.test.ts +66 -6
  355. package/src/tests/program-spec-node.test.ts +1 -5
  356. package/src/tests/rfc-evidence-sync.test.ts +22 -0
  357. package/src/tests/rfc-implement-stamp-governance.test.ts +25 -1
  358. package/src/tests/rfc-verification-verdict-ingest.test.ts +22 -0
  359. package/src/tests/upgrade-flow.test.ts +174 -0
  360. package/src/types.ts +11 -2
  361. package/dist/os/werkstatt/handlers/session-close.d.ts +0 -13
  362. package/dist/os/werkstatt/handlers/session-close.d.ts.map +0 -1
  363. package/dist/os/werkstatt/handlers/session-close.js +0 -56
  364. package/dist/os/werkstatt/handlers/session-close.js.map +0 -1
  365. package/dist/os/werkstatt/handlers/session-engine.d.ts +0 -3
  366. package/dist/os/werkstatt/handlers/session-engine.d.ts.map +0 -1
  367. package/dist/os/werkstatt/handlers/session-engine.js +0 -28
  368. package/dist/os/werkstatt/handlers/session-engine.js.map +0 -1
  369. package/dist/os/werkstatt/handlers/session-open.d.ts +0 -10
  370. package/dist/os/werkstatt/handlers/session-open.d.ts.map +0 -1
  371. package/dist/os/werkstatt/handlers/session-open.js +0 -46
  372. package/dist/os/werkstatt/handlers/session-open.js.map +0 -1
  373. package/dist/os/werkstatt/handlers/session-status.d.ts +0 -9
  374. package/dist/os/werkstatt/handlers/session-status.d.ts.map +0 -1
  375. package/dist/os/werkstatt/handlers/session-status.js +0 -34
  376. package/dist/os/werkstatt/handlers/session-status.js.map +0 -1
  377. package/os/werkstatt/handlers/session-close.ts +0 -82
  378. package/os/werkstatt/handlers/session-engine.ts +0 -34
  379. package/os/werkstatt/handlers/session-open.ts +0 -68
  380. package/os/werkstatt/handlers/session-status.ts +0 -55
@@ -0,0 +1,500 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>flow.hold — pull one integration item out of the unpushed develop
4
+ tail (RFC-1491): refuse per FLOW-HOLD-01..06, then under the integration
5
+ lock cherry-pick the tail above the item into a detached temporary
6
+ worktree, keep a held auto branch at the item's tip, reset develop to the
7
+ replayed tip and journal the hold with per-item rewrites.</purpose>
8
+ <non-goals>
9
+ <item>No unhold — handlers/flow-unhold.ts owns that direction.</item>
10
+ <item>No push — the held work stays local until flow.push.</item>
11
+ </non-goals>
12
+ </MODULE_CONTRACT>
13
+ <KEY_DECISIONS>
14
+ <item>All refusals happen before any mutation; a cherry-pick conflict aborts and removes the temporary worktree so FLOW-HOLD-07 leaves nothing changed.</item>
15
+ <item>Rewrites are journaled only for attributed replayed items — unattributed runs re-form from unclaimed commits on the new tail on their own.</item>
16
+ </KEY_DECISIONS>
17
+ <CHANGE_SUMMARY>
18
+ <item>RFC-1491: step 4 — flow.hold (replay, held branch, registry held entry, journal rewrites)</item>
19
+ <item>RFC-1491: step 4 — flow.hold replay + flow.unhold worktree restore</item>
20
+ <item>RFC-1491: independent-review pass — shared lock constants, publishable pending filter, declared rules, hold ordering, sha-pinned refspecs</item>
21
+ <item>RFC-1491: digest segments develop by first-parent chain; hold of the topmost item skips the empty replay
22
+
23
+ Steering-session verification of wave 2 found two outbound defects:
24
+ - flow.digest attributed items by index spans over the date-ordered tail; after a fix release and its back-merge, the fix cut record (whose range lives on main) claimed the develop integration that shared its base, so the operator saw 'feat: dev work' labelled as the fix release. Segments now follow develop's first-parent chain and item commit counts come from the base..tip range.
25
+ - flow.hold on the item at the tip of develop ran cherry-pick on an empty range and refused FLOW-HOLD-07. An empty tail now resets develop to the item's base.</item>
26
+ <item>RFC-1501: one argv-shaped read-only git allowlist for the recording and read-only adapters (RFC-1501)
27
+
28
+ READ_ONLY_GIT_QUERIES / isReadOnlyGitQuery replace the recording adapter's
29
+ first-argument allowlist; the read-only adapter and the static scan use the same
30
+ table. The kernel forwards --dry-run into commands that declare a dry-run flag,
31
+ and flow.push / flow.hold dry-runs no longer fetch. The switch-over runbook goes
32
+ back to werkstatt run flow.install --dry-run.</item>
33
+ </CHANGE_SUMMARY>
34
+ */
35
+
36
+ import { join } from "node:path";
37
+
38
+ import type {
39
+ Diagnostic,
40
+ ForgeCommandInput,
41
+ ForgeCommandResult,
42
+ ForgeRuntimeContext,
43
+ WorkspaceIO,
44
+ } from "../../../src/types.ts";
45
+ import { resolveIo } from "../../../src/utils/io.ts";
46
+ import { formatFlowBranch, parseFlowBranch } from "../branch-name.ts";
47
+ import { collectDigest, type FlowDigestItem } from "../digest.ts";
48
+ import {
49
+ git,
50
+ gitCommit,
51
+ listLocalBranches,
52
+ listRemoteBranches,
53
+ requireGit,
54
+ statusTracked,
55
+ topLevel,
56
+ } from "../git.ts";
57
+ import { LockTimeoutError, withFlowLock } from "../locks.ts";
58
+ import { INTEGRATE_LOCK_STALE_MS, INTEGRATE_LOCK_WAIT_MS } from "./flow-integrate.ts";
59
+ import {
60
+ appendJournal,
61
+ commonGitDir,
62
+ FlowRegistrySchemaError,
63
+ INTEGRATE_LOCK_RELATIVE_PATH,
64
+ readRegistry,
65
+ registryPath,
66
+ updateRegistry,
67
+ type FlowRegistryEntry,
68
+ } from "../registry.ts";
69
+ import { primaryWorktree } from "../worktree-path.ts";
70
+ import { nextFlowSeq } from "./flow-open.ts";
71
+
72
+ export interface FlowHoldData {
73
+ held: boolean;
74
+ item: string | null;
75
+ branch: string | null;
76
+ replayedTip: string | null;
77
+ rewrites: Array<{
78
+ branch: string;
79
+ kind: "integration" | "backmerge" | "release";
80
+ base: string;
81
+ sha: string;
82
+ }>;
83
+ diagnostics: Diagnostic[];
84
+ }
85
+
86
+ function refuse(ruleId: string, message: string, fixHint?: string): FlowHoldData {
87
+ return {
88
+ held: false,
89
+ item: null,
90
+ branch: null,
91
+ replayedTip: null,
92
+ rewrites: [],
93
+ diagnostics: [{ ruleId, severity: "error", message, fixHint }],
94
+ };
95
+ }
96
+
97
+ async function isAncestor(
98
+ repoRoot: string,
99
+ io: WorkspaceIO,
100
+ older: string,
101
+ newer: string,
102
+ ): Promise<boolean> {
103
+ const r = await git(repoRoot, io, ["merge-base", "--is-ancestor", older, newer]);
104
+ return r.exitCode === 0;
105
+ }
106
+
107
+ /**
108
+ * The hold's held-branch name: `auto/<kind>-<YYMMDD>-<NN>-held-<slug>` with
109
+ * the original slug truncated to 43 chars and a dangling `-` dropped
110
+ * (AUDIT-RFC-1491-G2 — stays within the 48-char slug limit).
111
+ */
112
+ export function heldBranchName(
113
+ itemBranch: string,
114
+ candidates: string[],
115
+ now: Date,
116
+ ): string | null {
117
+ const parsed = parseFlowBranch(itemBranch);
118
+ if (parsed === null) return null;
119
+ const truncated = parsed.slug.slice(0, 43).replace(/-+$/, "");
120
+ const slug = `held-${truncated}`;
121
+ if (slug.length > 48) return null;
122
+ const yy = String(now.getUTCFullYear() % 100).padStart(2, "0");
123
+ const mm = String(now.getUTCMonth() + 1).padStart(2, "0");
124
+ const dd = String(now.getUTCDate()).padStart(2, "0");
125
+ const seq = nextFlowSeq(candidates, `${yy}${mm}${dd}`);
126
+ if (seq > 99) return null;
127
+ return formatFlowBranch({ kind: parsed.kind, date: now, seq, slug });
128
+ }
129
+
130
+ /**
131
+ * Core of flow.hold — callable with an injected clock. Every refusal is a
132
+ * diagnostic in the returned data; nothing mutates unless held: true.
133
+ */
134
+ export async function holdFlowItem(
135
+ repoRoot: string,
136
+ io: WorkspaceIO,
137
+ opts: { item: string; reason: string; dryRun: boolean; now?: Date },
138
+ ): Promise<FlowHoldData> {
139
+ const now = opts.now ?? new Date();
140
+ let digest: Awaited<ReturnType<typeof collectDigest>>;
141
+ try {
142
+ // RFC-1501: a dry-run never fetches (fetch rewrites and prunes
143
+ // remote-tracking refs); it judges the item like flow.digest --no-fetch.
144
+ digest = await collectDigest(repoRoot, io, { fetch: !opts.dryRun });
145
+ } catch (error) {
146
+ if (error instanceof FlowRegistrySchemaError) {
147
+ return refuse("FLOW-07", error.message);
148
+ }
149
+ throw error;
150
+ }
151
+ const item = digest.items.find((i) => i.id === opts.item) as FlowDigestItem | undefined;
152
+ if (item === undefined) {
153
+ return refuse(
154
+ "FLOW-HOLD-01",
155
+ `item '${opts.item}' is not in a freshly computed digest — run flow.digest and quote a current item id`,
156
+ );
157
+ }
158
+
159
+ if (item.kind !== "integration") {
160
+ return refuse(
161
+ "FLOW-HOLD-05",
162
+ `item ${item.id} is a ${item.kind} item — only integration items can be held`,
163
+ "releases, back-merges and unattributed commits cannot be held; discard or discard-resolve them instead",
164
+ );
165
+ }
166
+
167
+ // FLOW-HOLD-02: an unpushed release tag above the item's base would lose
168
+ // its commit — "already released locally".
169
+ for (const tag of digest.tags) {
170
+ const tagged = await git(repoRoot, io, ["rev-list", "-1", tag]);
171
+ if (tagged.exitCode !== 0) continue;
172
+ const commit = tagged.stdout.trim();
173
+ if (
174
+ (await isAncestor(repoRoot, io, commit, "develop")) &&
175
+ !(await isAncestor(repoRoot, io, commit, item.base))
176
+ ) {
177
+ return refuse(
178
+ "FLOW-HOLD-02",
179
+ `release tag ${tag} points at a commit above ${item.base.slice(0, 9)} — the work is already released locally`,
180
+ "push first (flow.push) or delete the tag if it was created in error",
181
+ );
182
+ }
183
+ }
184
+
185
+ const common = await commonGitDir(io, repoRoot);
186
+ const primary = await primaryWorktree(io, repoRoot);
187
+
188
+ // FLOW-HOLD-03: an open entry rebased later would resurrect held commits.
189
+ let registry;
190
+ try {
191
+ registry = await readRegistry(io, common);
192
+ } catch (error) {
193
+ if (error instanceof FlowRegistrySchemaError) {
194
+ return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`);
195
+ }
196
+ throw error;
197
+ }
198
+ for (const entry of registry.branches) {
199
+ if (entry.held !== null) continue;
200
+ if (
201
+ (await isAncestor(repoRoot, io, entry.baseSha, "develop")) &&
202
+ !(await isAncestor(repoRoot, io, entry.baseSha, item.base))
203
+ ) {
204
+ return refuse(
205
+ "FLOW-HOLD-03",
206
+ `open branch ${entry.name} is based above ${item.base.slice(0, 9)} — a later rebase would bring the held commits back`,
207
+ "integrate or discard it first, then re-run flow.hold",
208
+ );
209
+ }
210
+ }
211
+
212
+ const primaryBranch = (
213
+ await git(primary, io, ["symbolic-ref", "--short", "-q", "HEAD"])
214
+ ).stdout.trim();
215
+ const dirty = await statusTracked(primary, io);
216
+ if (primaryBranch !== "develop" || dirty.length > 0) {
217
+ return refuse(
218
+ "FLOW-HOLD-04",
219
+ primaryBranch !== "develop"
220
+ ? `the primary worktree is on ${primaryBranch || "detached HEAD"}, not develop`
221
+ : `the primary worktree is dirty (${dirty.length} tracked change(s))`,
222
+ "switch the primary to develop and commit or stash its changes",
223
+ );
224
+ }
225
+
226
+ const merges = await git(repoRoot, io, ["rev-list", "--merges", `${item.tip}..develop`]);
227
+ if (merges.exitCode === 0 && merges.stdout.trim().length > 0) {
228
+ return refuse(
229
+ "FLOW-HOLD-06",
230
+ `a merge commit lies above ${item.id} on the tail — cherry-pick replay cannot reorder merges`,
231
+ "the tail above the item must be linear; resolve the merge first",
232
+ );
233
+ }
234
+
235
+ // Held branch name — allocated before the lock so a refusal is cheap.
236
+ const [local, remote] = await Promise.all([
237
+ listLocalBranches(repoRoot, io),
238
+ listRemoteBranches(repoRoot, io),
239
+ ]);
240
+ const remoteNames = remote.map((r) => r.slice(r.indexOf("/") + 1));
241
+ const candidates = [
242
+ ...local,
243
+ ...remoteNames,
244
+ ...registry.branches.map((b) => b.name),
245
+ item.branch ?? "",
246
+ ];
247
+ const heldName = heldBranchName(item.branch ?? "", candidates, now);
248
+ if (heldName === null) {
249
+ return refuse(
250
+ "FLOW-HOLD-01",
251
+ `cannot derive a held branch name from '${item.branch}' — 99 held branches today or an unparseable branch`,
252
+ );
253
+ }
254
+
255
+ if (opts.dryRun) {
256
+ return {
257
+ held: false,
258
+ item: item.id,
259
+ branch: heldName,
260
+ replayedTip: null,
261
+ rewrites: [],
262
+ diagnostics: [],
263
+ };
264
+ }
265
+
266
+ const lockPath = join(common, INTEGRATE_LOCK_RELATIVE_PATH);
267
+ try {
268
+ return await withFlowLock(
269
+ lockPath,
270
+ { waitMs: INTEGRATE_LOCK_WAIT_MS, staleMs: INTEGRATE_LOCK_STALE_MS },
271
+ () => executeHold(repoRoot, primary, common, io, item, heldName, digest, opts.reason, now),
272
+ io,
273
+ );
274
+ } catch (error) {
275
+ if (error instanceof LockTimeoutError) {
276
+ return refuse(
277
+ "FLOW-07",
278
+ `integration lock ${error.lockPath} still held`,
279
+ "a live flow command holds the lock — retry, or remove it if the holder died",
280
+ );
281
+ }
282
+ if (error instanceof FlowRegistrySchemaError) {
283
+ return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`);
284
+ }
285
+ throw error;
286
+ }
287
+ }
288
+
289
+ async function executeHold(
290
+ repoRoot: string,
291
+ primary: string,
292
+ common: string,
293
+ io: WorkspaceIO,
294
+ item: FlowDigestItem,
295
+ heldName: string,
296
+ digest: Awaited<ReturnType<typeof collectDigest>>,
297
+ reason: string,
298
+ now: Date,
299
+ ): Promise<FlowHoldData> {
300
+ const holdWorktree = join(common, "forge", "hold-worktree");
301
+ let worktreeAdded = false;
302
+ try {
303
+ // A stale temp worktree from a crashed hold is reclaimed first.
304
+ if (await io.exists(holdWorktree)) {
305
+ await git(repoRoot, io, ["worktree", "remove", "--force", holdWorktree]);
306
+ }
307
+ const add = await git(repoRoot, io, [
308
+ "worktree",
309
+ "add",
310
+ "--detach",
311
+ holdWorktree,
312
+ item.base,
313
+ ]);
314
+ if (add.exitCode !== 0) {
315
+ return refuse(
316
+ "FLOW-HOLD-07",
317
+ `temporary hold worktree could not be created: ${add.stderr.trim()}`,
318
+ );
319
+ }
320
+ worktreeAdded = true;
321
+
322
+ // The topmost item has nothing above it — the replayed tip is its base.
323
+ const above = await git(repoRoot, io, ["rev-list", "--count", `${item.tip}..develop`]);
324
+ const pick =
325
+ above.exitCode === 0 && above.stdout.trim() === "0"
326
+ ? above
327
+ : await gitCommit(holdWorktree, io, [
328
+ "cherry-pick",
329
+ "--keep-redundant-commits",
330
+ "--allow-empty",
331
+ `${item.tip}..develop`,
332
+ ], "hold");
333
+ if (pick.exitCode !== 0) {
334
+ const conflicts = await git(holdWorktree, io, [
335
+ "diff",
336
+ "--name-only",
337
+ "--diff-filter=U",
338
+ ]);
339
+ const paths = conflicts.stdout.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
340
+ await git(holdWorktree, io, ["cherry-pick", "--abort"]);
341
+ const detail = paths.length > 0
342
+ ? `conflicts on ${paths.join(", ")}`
343
+ : `failed: ${pick.stderr.trim().split("\n").slice(-1)[0] ?? "unknown error"}`;
344
+ return refuse(
345
+ "FLOW-HOLD-07",
346
+ `replaying the tail above ${item.id} ${detail} — nothing changed`,
347
+ "resolve the conflict by reordering the work, or drop the hold idea",
348
+ );
349
+ }
350
+
351
+ const replayedTip = (await git(holdWorktree, io, ["rev-parse", "HEAD"])).stdout.trim();
352
+
353
+ // New ranges of the replayed attributed items — each keeps its commit
354
+ // count (keep-redundant), partitioned over the new tail in order.
355
+ const newTail = await git(repoRoot, io, [
356
+ "rev-list",
357
+ "--reverse",
358
+ `${item.base}..${replayedTip}`,
359
+ ]);
360
+ const newCommits = newTail.stdout.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
361
+ const heldIndex = digest.items.findIndex((i) => i.id === item.id);
362
+ const rewrites: FlowHoldData["rewrites"] = [];
363
+ let offset = 0;
364
+ for (const replayed of digest.items.slice(heldIndex + 1)) {
365
+ const base = offset === 0 ? item.base : rewritesBase(newCommits, offset - 1);
366
+ const sha = newCommits[offset + replayed.commits - 1] ?? replayedTip;
367
+ if (replayed.branch !== null) {
368
+ rewrites.push({
369
+ branch: replayed.branch,
370
+ kind: replayed.kind as "integration" | "backmerge" | "release",
371
+ base,
372
+ sha,
373
+ });
374
+ }
375
+ offset += replayed.commits;
376
+ }
377
+
378
+ const branch = await git(repoRoot, io, ["branch", heldName, item.tip]);
379
+ if (branch.exitCode !== 0) {
380
+ return refuse(
381
+ "FLOW-HOLD-07",
382
+ `git branch ${heldName} failed: ${branch.stderr.trim()}`,
383
+ );
384
+ }
385
+
386
+ const reset = await git(primary, io, ["reset", "--keep", replayedTip]);
387
+ if (reset.exitCode !== 0) {
388
+ // Roll back the held branch ref — nothing is marked held while the
389
+ // work still sits on the tail.
390
+ await git(repoRoot, io, ["branch", "-D", heldName]);
391
+ return refuse(
392
+ "FLOW-HOLD-07",
393
+ `git reset --keep ${replayedTip.slice(0, 9)} in the primary failed: ${reset.stderr.trim()} — develop is unchanged`,
394
+ );
395
+ }
396
+
397
+ const parsed = parseFlowBranch(item.branch ?? "");
398
+ const entry: FlowRegistryEntry = {
399
+ name: heldName,
400
+ kind: parsed?.kind ?? "session",
401
+ base: "develop",
402
+ baseSha: item.base,
403
+ worktree: null,
404
+ owner: { kind: "session", id: `hold-${item.id}` },
405
+ brief: `hold of ${item.branch ?? item.id}`,
406
+ openedAt: now.toISOString(),
407
+ updatedAt: now.toISOString(),
408
+ held: {
409
+ heldAt: now.toISOString(),
410
+ riskCategory: item.category,
411
+ reason,
412
+ tip: item.tip,
413
+ },
414
+ port: null,
415
+ };
416
+ await updateRegistry(io, common, (r) => ({
417
+ ...r,
418
+ branches: [...r.branches.filter((b) => b.name !== heldName), entry],
419
+ }));
420
+
421
+ await appendJournal(io, common, {
422
+ event: "hold",
423
+ branch: heldName,
424
+ base: digest.develop.local,
425
+ sha: replayedTip,
426
+ detail: reason,
427
+ rewrites,
428
+ });
429
+
430
+ return {
431
+ held: true,
432
+ item: item.id,
433
+ branch: heldName,
434
+ replayedTip,
435
+ rewrites,
436
+ diagnostics: [],
437
+ };
438
+ } finally {
439
+ if (worktreeAdded) {
440
+ await git(repoRoot, io, ["worktree", "remove", "--force", holdWorktree]);
441
+ }
442
+ }
443
+ }
444
+
445
+ function rewritesBase(newCommits: string[], index: number): string {
446
+ return newCommits[index] ?? "";
447
+ }
448
+
449
+ export async function runFlowHold(
450
+ input: ForgeCommandInput,
451
+ context: ForgeRuntimeContext,
452
+ ): Promise<ForgeCommandResult<FlowHoldData>> {
453
+ const { workspaceRoot, logger, outputFormat } = context;
454
+ const io: WorkspaceIO = resolveIo(context.io);
455
+ await requireGit(io);
456
+
457
+ const repoRoot = await topLevel(workspaceRoot, io);
458
+ if (repoRoot === null) {
459
+ throw new Error("flow.hold must run inside a git repository");
460
+ }
461
+
462
+ const item = typeof input.flags["item"] === "string" ? input.flags["item"] : "";
463
+ const reason = typeof input.flags["reason"] === "string" ? input.flags["reason"] : "";
464
+ if (item.length === 0 || reason.length === 0) {
465
+ return {
466
+ data: refuse(
467
+ "FLOW-HOLD-01",
468
+ "--item <id> and --reason <text> are both required",
469
+ ),
470
+ exitCode: 1,
471
+ summary: "[flow.hold] missing required flags",
472
+ };
473
+ }
474
+
475
+ const data = await holdFlowItem(repoRoot, io, {
476
+ item,
477
+ reason,
478
+ dryRun: input.flags["dry-run"] === true,
479
+ });
480
+ const errors = data.diagnostics.filter((d) => d.severity === "error");
481
+
482
+ if (outputFormat === "pretty") {
483
+ for (const d of data.diagnostics) {
484
+ if (d.severity === "error") logger.error(` ${d.ruleId}: ${d.message}`);
485
+ else logger.warn(` ${d.ruleId}: ${d.message}`);
486
+ }
487
+ if (data.held) {
488
+ logger.info(` held ${data.item} as ${data.branch}`);
489
+ logger.info(` unhold with: pnpm exec forge flow.unhold --branch ${data.branch}`);
490
+ }
491
+ }
492
+
493
+ return {
494
+ data,
495
+ exitCode: errors.length > 0 ? 1 : 0,
496
+ summary: data.held
497
+ ? `[flow.hold] ${data.item} held as ${data.branch}`
498
+ : `[flow.hold] refused — ${errors.length} error(s)`,
499
+ };
500
+ }