@warpgogol/forge 9.1.1 → 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 (377) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/bin/cli.ts +3 -2
  3. package/dist/bin/cli.js +3 -2
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/os/core/core.module.d.ts.map +1 -1
  6. package/dist/os/core/core.module.js +6 -4
  7. package/dist/os/core/core.module.js.map +1 -1
  8. package/dist/os/flow/branch-name.d.ts +56 -0
  9. package/dist/os/flow/branch-name.d.ts.map +1 -0
  10. package/dist/os/flow/branch-name.js +108 -0
  11. package/dist/os/flow/branch-name.js.map +1 -0
  12. package/dist/os/flow/digest.d.ts +73 -0
  13. package/dist/os/flow/digest.d.ts.map +1 -0
  14. package/dist/os/flow/digest.js +634 -0
  15. package/dist/os/flow/digest.js.map +1 -0
  16. package/dist/os/flow/flow.module.d.ts +3 -0
  17. package/dist/os/flow/flow.module.d.ts.map +1 -0
  18. package/dist/os/flow/flow.module.js +716 -0
  19. package/dist/os/flow/flow.module.js.map +1 -0
  20. package/dist/os/flow/git.d.ts +68 -0
  21. package/dist/os/flow/git.d.ts.map +1 -0
  22. package/dist/os/flow/git.js +257 -0
  23. package/dist/os/flow/git.js.map +1 -0
  24. package/dist/os/flow/guard-files.d.ts +50 -0
  25. package/dist/os/flow/guard-files.d.ts.map +1 -0
  26. package/dist/os/flow/guard-files.js +147 -0
  27. package/dist/os/flow/guard-files.js.map +1 -0
  28. package/dist/os/flow/handlers/flow-backmerge.d.ts +27 -0
  29. package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -0
  30. package/dist/os/flow/handlers/flow-backmerge.js +332 -0
  31. package/dist/os/flow/handlers/flow-backmerge.js.map +1 -0
  32. package/dist/os/flow/handlers/flow-check.d.ts +42 -0
  33. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -0
  34. package/dist/os/flow/handlers/flow-check.js +347 -0
  35. package/dist/os/flow/handlers/flow-check.js.map +1 -0
  36. package/dist/os/flow/handlers/flow-cut.d.ts +63 -0
  37. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -0
  38. package/dist/os/flow/handlers/flow-cut.js +636 -0
  39. package/dist/os/flow/handlers/flow-cut.js.map +1 -0
  40. package/dist/os/flow/handlers/flow-digest.d.ts +5 -0
  41. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -0
  42. package/dist/os/flow/handlers/flow-digest.js +110 -0
  43. package/dist/os/flow/handlers/flow-digest.js.map +1 -0
  44. package/dist/os/flow/handlers/flow-discard.d.ts +22 -0
  45. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -0
  46. package/dist/os/flow/handlers/flow-discard.js +200 -0
  47. package/dist/os/flow/handlers/flow-discard.js.map +1 -0
  48. package/dist/os/flow/handlers/flow-fix.d.ts +47 -0
  49. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -0
  50. package/dist/os/flow/handlers/flow-fix.js +443 -0
  51. package/dist/os/flow/handlers/flow-fix.js.map +1 -0
  52. package/dist/os/flow/handlers/flow-hold.d.ts +32 -0
  53. package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -0
  54. package/dist/os/flow/handlers/flow-hold.js +359 -0
  55. package/dist/os/flow/handlers/flow-hold.js.map +1 -0
  56. package/dist/os/flow/handlers/flow-install.d.ts +92 -0
  57. package/dist/os/flow/handlers/flow-install.d.ts.map +1 -0
  58. package/dist/os/flow/handlers/flow-install.js +883 -0
  59. package/dist/os/flow/handlers/flow-install.js.map +1 -0
  60. package/dist/os/flow/handlers/flow-integrate.d.ts +35 -0
  61. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -0
  62. package/dist/os/flow/handlers/flow-integrate.js +419 -0
  63. package/dist/os/flow/handlers/flow-integrate.js.map +1 -0
  64. package/dist/os/flow/handlers/flow-open.d.ts +63 -0
  65. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -0
  66. package/dist/os/flow/handlers/flow-open.js +294 -0
  67. package/dist/os/flow/handlers/flow-open.js.map +1 -0
  68. package/dist/os/flow/handlers/flow-push.d.ts +22 -0
  69. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -0
  70. package/dist/os/flow/handlers/flow-push.js +306 -0
  71. package/dist/os/flow/handlers/flow-push.js.map +1 -0
  72. package/dist/os/flow/handlers/flow-status.d.ts +65 -0
  73. package/dist/os/flow/handlers/flow-status.d.ts.map +1 -0
  74. package/dist/os/flow/handlers/flow-status.js +193 -0
  75. package/dist/os/flow/handlers/flow-status.js.map +1 -0
  76. package/dist/os/flow/handlers/flow-unhold.d.ts +20 -0
  77. package/dist/os/flow/handlers/flow-unhold.d.ts.map +1 -0
  78. package/dist/os/flow/handlers/flow-unhold.js +158 -0
  79. package/dist/os/flow/handlers/flow-unhold.js.map +1 -0
  80. package/dist/os/flow/handlers/flow-version.d.ts +39 -0
  81. package/dist/os/flow/handlers/flow-version.d.ts.map +1 -0
  82. package/dist/os/flow/handlers/flow-version.js +122 -0
  83. package/dist/os/flow/handlers/flow-version.js.map +1 -0
  84. package/dist/os/flow/index.d.ts +30 -0
  85. package/dist/os/flow/index.d.ts.map +1 -0
  86. package/dist/os/flow/index.js +83 -0
  87. package/dist/os/flow/index.js.map +1 -0
  88. package/dist/os/flow/line-version.d.ts +23 -0
  89. package/dist/os/flow/line-version.d.ts.map +1 -0
  90. package/dist/os/flow/line-version.js +83 -0
  91. package/dist/os/flow/line-version.js.map +1 -0
  92. package/dist/os/flow/locks.d.ts +34 -0
  93. package/dist/os/flow/locks.d.ts.map +1 -0
  94. package/dist/os/flow/locks.js +147 -0
  95. package/dist/os/flow/locks.js.map +1 -0
  96. package/dist/os/flow/markers.d.ts +49 -0
  97. package/dist/os/flow/markers.d.ts.map +1 -0
  98. package/dist/os/flow/markers.js +112 -0
  99. package/dist/os/flow/markers.js.map +1 -0
  100. package/dist/os/flow/publish.d.ts +28 -0
  101. package/dist/os/flow/publish.d.ts.map +1 -0
  102. package/dist/os/flow/publish.js +153 -0
  103. package/dist/os/flow/publish.js.map +1 -0
  104. package/dist/os/flow/registry.d.ts +142 -0
  105. package/dist/os/flow/registry.d.ts.map +1 -0
  106. package/dist/os/flow/registry.js +198 -0
  107. package/dist/os/flow/registry.js.map +1 -0
  108. package/dist/os/flow/release-level.d.ts +23 -0
  109. package/dist/os/flow/release-level.d.ts.map +1 -0
  110. package/dist/os/flow/release-level.js +102 -0
  111. package/dist/os/flow/release-level.js.map +1 -0
  112. package/dist/os/flow/release-lines.d.ts +25 -0
  113. package/dist/os/flow/release-lines.d.ts.map +1 -0
  114. package/dist/os/flow/release-lines.js +172 -0
  115. package/dist/os/flow/release-lines.js.map +1 -0
  116. package/dist/os/flow/release-tags.d.ts +72 -0
  117. package/dist/os/flow/release-tags.d.ts.map +1 -0
  118. package/dist/os/flow/release-tags.js +166 -0
  119. package/dist/os/flow/release-tags.js.map +1 -0
  120. package/dist/os/flow/repo-kind.d.ts +41 -0
  121. package/dist/os/flow/repo-kind.d.ts.map +1 -0
  122. package/dist/os/flow/repo-kind.js +92 -0
  123. package/dist/os/flow/repo-kind.js.map +1 -0
  124. package/dist/os/flow/scripts.d.ts +20 -0
  125. package/dist/os/flow/scripts.d.ts.map +1 -0
  126. package/dist/os/flow/scripts.js +49 -0
  127. package/dist/os/flow/scripts.js.map +1 -0
  128. package/dist/os/flow/semver.d.ts +21 -0
  129. package/dist/os/flow/semver.d.ts.map +1 -0
  130. package/dist/os/flow/semver.js +73 -0
  131. package/dist/os/flow/semver.js.map +1 -0
  132. package/dist/os/flow/tests/helpers.d.ts +52 -0
  133. package/dist/os/flow/tests/helpers.d.ts.map +1 -0
  134. package/dist/os/flow/tests/helpers.js +189 -0
  135. package/dist/os/flow/tests/helpers.js.map +1 -0
  136. package/dist/os/flow/version-files.d.ts +21 -0
  137. package/dist/os/flow/version-files.d.ts.map +1 -0
  138. package/dist/os/flow/version-files.js +94 -0
  139. package/dist/os/flow/version-files.js.map +1 -0
  140. package/dist/os/flow/worktree-path.d.ts +31 -0
  141. package/dist/os/flow/worktree-path.d.ts.map +1 -0
  142. package/dist/os/flow/worktree-path.js +80 -0
  143. package/dist/os/flow/worktree-path.js.map +1 -0
  144. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  145. package/dist/os/mission/handlers/archive.js +43 -6
  146. package/dist/os/mission/handlers/archive.js.map +1 -1
  147. package/dist/os/program/handlers/seal.d.ts.map +1 -1
  148. package/dist/os/program/handlers/seal.js +1 -1
  149. package/dist/os/program/handlers/seal.js.map +1 -1
  150. package/dist/os/program/handlers/validate.d.ts.map +1 -1
  151. package/dist/os/program/handlers/validate.js +1 -1
  152. package/dist/os/program/handlers/validate.js.map +1 -1
  153. package/dist/os/program/program.module.d.ts.map +1 -1
  154. package/dist/os/program/program.module.js +2 -1
  155. package/dist/os/program/program.module.js.map +1 -1
  156. package/dist/os/program/schemas.d.ts +4 -6
  157. package/dist/os/program/schemas.d.ts.map +1 -1
  158. package/dist/os/program/schemas.js +16 -6
  159. package/dist/os/program/schemas.js.map +1 -1
  160. package/dist/os/program/state.d.ts +0 -1
  161. package/dist/os/program/state.d.ts.map +1 -1
  162. package/dist/os/program/state.js +1 -7
  163. package/dist/os/program/state.js.map +1 -1
  164. package/dist/os/rfc/acceptance.d.ts +21 -0
  165. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  166. package/dist/os/rfc/acceptance.js +62 -13
  167. package/dist/os/rfc/acceptance.js.map +1 -1
  168. package/dist/os/rfc/frontmatter-io.d.ts +19 -0
  169. package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
  170. package/dist/os/rfc/frontmatter-io.js +65 -12
  171. package/dist/os/rfc/frontmatter-io.js.map +1 -1
  172. package/dist/os/rfc/handlers/validate-rules.d.ts +2 -5
  173. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  174. package/dist/os/rfc/handlers/validate-rules.js +10 -8
  175. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  176. package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
  177. package/dist/os/rfc/handlers/validate.js +15 -5
  178. package/dist/os/rfc/handlers/validate.js.map +1 -1
  179. package/dist/os/rfc/index.d.ts +2 -2
  180. package/dist/os/rfc/index.d.ts.map +1 -1
  181. package/dist/os/rfc/index.js +5 -2
  182. package/dist/os/rfc/index.js.map +1 -1
  183. package/dist/os/rfc/probe-batch.d.ts +71 -0
  184. package/dist/os/rfc/probe-batch.d.ts.map +1 -0
  185. package/dist/os/rfc/probe-batch.js +251 -0
  186. package/dist/os/rfc/probe-batch.js.map +1 -0
  187. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  188. package/dist/os/rfc/rfc.module.js +16 -2
  189. package/dist/os/rfc/rfc.module.js.map +1 -1
  190. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  191. package/dist/os/rfc/verification-evidence.js +21 -10
  192. package/dist/os/rfc/verification-evidence.js.map +1 -1
  193. package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
  194. package/dist/os/rfc/verification-refresh.js +20 -13
  195. package/dist/os/rfc/verification-refresh.js.map +1 -1
  196. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +1 -1
  197. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +21 -7
  198. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +1 -1
  199. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +1 -1
  200. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +1 -1
  201. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +1 -1
  202. package/dist/os/werkstatt/werkstatt.module.d.ts.map +1 -1
  203. package/dist/os/werkstatt/werkstatt.module.js +2 -82
  204. package/dist/os/werkstatt/werkstatt.module.js.map +1 -1
  205. package/dist/src/config/forge-config.d.ts +0 -3
  206. package/dist/src/config/forge-config.d.ts.map +1 -1
  207. package/dist/src/config/forge-config.js +2 -4
  208. package/dist/src/config/forge-config.js.map +1 -1
  209. package/dist/src/index.d.ts +3 -0
  210. package/dist/src/index.d.ts.map +1 -1
  211. package/dist/src/index.js +2 -0
  212. package/dist/src/index.js.map +1 -1
  213. package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
  214. package/dist/src/onboarding/agents-generate.js +49 -4
  215. package/dist/src/onboarding/agents-generate.js.map +1 -1
  216. package/dist/src/onboarding/create.d.ts +13 -0
  217. package/dist/src/onboarding/create.d.ts.map +1 -1
  218. package/dist/src/onboarding/create.js +95 -9
  219. package/dist/src/onboarding/create.js.map +1 -1
  220. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  221. package/dist/src/onboarding/doctor.js +2 -47
  222. package/dist/src/onboarding/doctor.js.map +1 -1
  223. package/dist/src/onboarding/upgrade.d.ts +5 -0
  224. package/dist/src/onboarding/upgrade.d.ts.map +1 -1
  225. package/dist/src/onboarding/upgrade.js +70 -1
  226. package/dist/src/onboarding/upgrade.js.map +1 -1
  227. package/dist/src/types.d.ts +9 -0
  228. package/dist/src/types.d.ts.map +1 -1
  229. package/dist/src/types.js +2 -2
  230. package/docs/branch-model.md +98 -0
  231. package/docs/maintainers/publishing.md +10 -8
  232. package/docs/reference/cli.md +0 -3
  233. package/os/core/core.module.ts +7 -4
  234. package/os/flow/assets/flow-guard.sh +176 -0
  235. package/os/flow/branch-name.ts +139 -0
  236. package/os/flow/digest.ts +761 -0
  237. package/os/flow/flow.module.ts +740 -0
  238. package/os/flow/git.ts +342 -0
  239. package/os/flow/guard-files.ts +172 -0
  240. package/os/flow/handlers/flow-backmerge.ts +488 -0
  241. package/os/flow/handlers/flow-check.ts +450 -0
  242. package/os/flow/handlers/flow-cut.ts +912 -0
  243. package/os/flow/handlers/flow-digest.ts +124 -0
  244. package/os/flow/handlers/flow-discard.ts +301 -0
  245. package/os/flow/handlers/flow-fix.ts +597 -0
  246. package/os/flow/handlers/flow-hold.ts +500 -0
  247. package/os/flow/handlers/flow-install.ts +1185 -0
  248. package/os/flow/handlers/flow-integrate.ts +607 -0
  249. package/os/flow/handlers/flow-open.ts +447 -0
  250. package/os/flow/handlers/flow-push.ts +373 -0
  251. package/os/flow/handlers/flow-status.ts +283 -0
  252. package/os/flow/handlers/flow-unhold.ts +220 -0
  253. package/os/flow/handlers/flow-version.ts +196 -0
  254. package/os/flow/index.ts +102 -0
  255. package/os/flow/line-version.ts +113 -0
  256. package/os/flow/locks.ts +177 -0
  257. package/os/flow/markers.ts +135 -0
  258. package/os/flow/publish.ts +201 -0
  259. package/os/flow/registry.ts +266 -0
  260. package/os/flow/release-level.ts +139 -0
  261. package/os/flow/release-lines.ts +208 -0
  262. package/os/flow/release-tags.ts +231 -0
  263. package/os/flow/repo-kind.ts +117 -0
  264. package/os/flow/scripts.ts +73 -0
  265. package/os/flow/semver.ts +82 -0
  266. package/os/flow/tests/branch-name.test.ts +136 -0
  267. package/os/flow/tests/fixtures/branch-names.yaml +56 -0
  268. package/os/flow/tests/flow-backmerge.test.ts +267 -0
  269. package/os/flow/tests/flow-check-version.test.ts +138 -0
  270. package/os/flow/tests/flow-check.test.ts +213 -0
  271. package/os/flow/tests/flow-cut.rerun.test.ts +95 -0
  272. package/os/flow/tests/flow-cut.test.ts +319 -0
  273. package/os/flow/tests/flow-digest.test.ts +313 -0
  274. package/os/flow/tests/flow-discard.test.ts +220 -0
  275. package/os/flow/tests/flow-fix.test.ts +359 -0
  276. package/os/flow/tests/flow-guard-merge.test.ts +100 -0
  277. package/os/flow/tests/flow-guard-parity.test.ts +115 -0
  278. package/os/flow/tests/flow-guard-push.test.ts +100 -0
  279. package/os/flow/tests/flow-guard.test.ts +135 -0
  280. package/os/flow/tests/flow-hold.test.ts +465 -0
  281. package/os/flow/tests/flow-install-baseline.rerun.test.ts +73 -0
  282. package/os/flow/tests/flow-install-baseline.test.ts +164 -0
  283. package/os/flow/tests/flow-install-markers.test.ts +161 -0
  284. package/os/flow/tests/flow-install.rerun.test.ts +212 -0
  285. package/os/flow/tests/flow-install.test.ts +330 -0
  286. package/os/flow/tests/flow-integrate.rerun.test.ts +92 -0
  287. package/os/flow/tests/flow-integrate.test.ts +229 -0
  288. package/os/flow/tests/flow-open.test.ts +200 -0
  289. package/os/flow/tests/flow-push-publish.test.ts +282 -0
  290. package/os/flow/tests/flow-push.test.ts +160 -0
  291. package/os/flow/tests/flow-stale.test.ts +136 -0
  292. package/os/flow/tests/flow-status.test.ts +93 -0
  293. package/os/flow/tests/flow-version-level.test.ts +116 -0
  294. package/os/flow/tests/flow-version.test.ts +169 -0
  295. package/os/flow/tests/helpers.ts +235 -0
  296. package/os/flow/tests/is-flow-adopted.test.ts +71 -0
  297. package/os/flow/tests/registry.test.ts +150 -0
  298. package/os/flow/tests/repository-line-version.test.ts +100 -0
  299. package/os/flow/tests/scripts.test.ts +97 -0
  300. package/os/flow/tests/state-roots.test.ts +127 -0
  301. package/os/flow/tests/version-files.test.ts +145 -0
  302. package/os/flow/version-files.ts +115 -0
  303. package/os/flow/worktree-path.ts +107 -0
  304. package/os/mission/handlers/archive.test.ts +27 -0
  305. package/os/mission/handlers/archive.ts +46 -6
  306. package/os/program/handlers/seal.ts +1 -1
  307. package/os/program/handlers/validate.ts +1 -1
  308. package/os/program/program.module.ts +2 -1
  309. package/os/program/schemas.ts +51 -34
  310. package/os/program/state.ts +1 -9
  311. package/os/rfc/acceptance.ts +84 -19
  312. package/os/rfc/frontmatter-io.ts +78 -12
  313. package/os/rfc/handlers/implement-stamp-stale.test.ts +22 -0
  314. package/os/rfc/handlers/validate-rules.test.ts +9 -6
  315. package/os/rfc/handlers/validate-rules.ts +12 -10
  316. package/os/rfc/handlers/validate.ts +17 -5
  317. package/os/rfc/index.ts +13 -1
  318. package/os/rfc/probe-batch.ts +329 -0
  319. package/os/rfc/rfc.module.ts +19 -2
  320. package/os/rfc/verification-emit-check.test.ts +22 -0
  321. package/os/rfc/verification-emit-freshness.test.ts +22 -0
  322. package/os/rfc/verification-emit.test.ts +22 -0
  323. package/os/rfc/verification-evidence.ts +21 -16
  324. package/os/rfc/verification-refresh.test.ts +22 -0
  325. package/os/rfc/verification-refresh.ts +20 -18
  326. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +9 -0
  327. package/os/werkstatt/handlers/werkstatt-lock-recover.ts +22 -5
  328. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +1 -1
  329. package/os/werkstatt/werkstatt.module.ts +2 -85
  330. package/package.json +17 -1
  331. package/profiles/forge-shell.yaml +22 -10
  332. package/profiles/godot-game.yaml +24 -13
  333. package/profiles/knowledge.yaml +19 -0
  334. package/profiles/phaser-game.yaml +25 -13
  335. package/profiles/site-workshop.yaml +27 -10
  336. package/profiles/typescript.yaml +26 -9
  337. package/skills/fo/fo-session-retro/SKILL.md +18 -7
  338. package/skills/fo/fo-step-commit/SKILL.md +2 -1
  339. package/src/config/forge-config.ts +2 -6
  340. package/src/index.ts +8 -0
  341. package/src/onboarding/agents-generate.ts +49 -5
  342. package/src/onboarding/create.ts +101 -9
  343. package/src/onboarding/doctor.ts +2 -51
  344. package/src/onboarding/upgrade.ts +86 -1
  345. package/src/tests/agents-generate-flow.test.ts +132 -0
  346. package/src/tests/create-flow.test.ts +114 -0
  347. package/src/tests/create.test.ts +22 -21
  348. package/src/tests/doctor-autonomy.test.ts +2 -1
  349. package/src/tests/implement-stamp.test.ts +26 -3
  350. package/src/tests/profile-flow-hooks.test.ts +77 -0
  351. package/src/tests/program-schemas.test.ts +66 -6
  352. package/src/tests/program-spec-node.test.ts +1 -5
  353. package/src/tests/rfc-evidence-sync.test.ts +22 -0
  354. package/src/tests/rfc-implement-stamp-governance.test.ts +25 -1
  355. package/src/tests/rfc-verification-verdict-ingest.test.ts +22 -0
  356. package/src/tests/upgrade-flow.test.ts +174 -0
  357. package/src/types.ts +11 -2
  358. package/dist/os/werkstatt/handlers/session-close.d.ts +0 -13
  359. package/dist/os/werkstatt/handlers/session-close.d.ts.map +0 -1
  360. package/dist/os/werkstatt/handlers/session-close.js +0 -56
  361. package/dist/os/werkstatt/handlers/session-close.js.map +0 -1
  362. package/dist/os/werkstatt/handlers/session-engine.d.ts +0 -3
  363. package/dist/os/werkstatt/handlers/session-engine.d.ts.map +0 -1
  364. package/dist/os/werkstatt/handlers/session-engine.js +0 -28
  365. package/dist/os/werkstatt/handlers/session-engine.js.map +0 -1
  366. package/dist/os/werkstatt/handlers/session-open.d.ts +0 -10
  367. package/dist/os/werkstatt/handlers/session-open.d.ts.map +0 -1
  368. package/dist/os/werkstatt/handlers/session-open.js +0 -46
  369. package/dist/os/werkstatt/handlers/session-open.js.map +0 -1
  370. package/dist/os/werkstatt/handlers/session-status.d.ts +0 -9
  371. package/dist/os/werkstatt/handlers/session-status.d.ts.map +0 -1
  372. package/dist/os/werkstatt/handlers/session-status.js +0 -34
  373. package/dist/os/werkstatt/handlers/session-status.js.map +0 -1
  374. package/os/werkstatt/handlers/session-close.ts +0 -82
  375. package/os/werkstatt/handlers/session-engine.ts +0 -34
  376. package/os/werkstatt/handlers/session-open.ts +0 -68
  377. package/os/werkstatt/handlers/session-status.ts +0 -55
@@ -0,0 +1,266 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Local branch registry and event journal for the session lifecycle
4
+ (RFC-1487). The registry lives at &lt;common-gitdir&gt;/forge/registry.yaml —
5
+ the same file from every worktree — and records every live auto branch with
6
+ its owner, base sha, worktree, opened/updated times and the reserved held
7
+ field. The journal appends one JSON line per lifecycle event to
8
+ forge/journal.jsonl.</purpose>
9
+ <non-goals>
10
+ <item>No lifecycle policy — handlers decide when entries open, update or close.</item>
11
+ <item>No commits — the registry lives under the common git dir, never in a tree.</item>
12
+ </non-goals>
13
+ </MODULE_CONTRACT>
14
+ <KEY_DECISIONS>
15
+ <item>A schema-invalid registry throws FlowRegistrySchemaError — every flow command surfaces it as FLOW-07 naming the file; a damaged registry is never silently rewritten.</item>
16
+ <item>Registry updates hold a 10 s O_EXCL lock and write via temp file + rename — parallel sessions never observe a torn file (AC-8).</item>
17
+ <item>`held` is typed null now — the wave-2 outbound RFC widens it to { heldAt, riskCategory, reason }.</item>
18
+ </KEY_DECISIONS>
19
+ <CHANGE_SUMMARY>
20
+ <item>RFC-1487: step 1 — registry, journal, common-gitdir resolution</item>
21
+ <item>RFC-1487: step 1 — worktree path contracts, O_EXCL locks, branch registry and journal</item>
22
+ <item>RFC-1490: step 2 — registry fix/port widening, FORGE_FLOW_COMMIT gitCommit helper, verified version-files writes</item>
23
+ <item>RFC-1491: step 1 — journal base/rewrites + held registry widening, W1-1 discard tip, FLOW-INT-11</item>
24
+ <item>RFC-1491: step 3 — flow.digest risk digest with journal-attributed items, categories, digestId</item>
25
+ </CHANGE_SUMMARY>
26
+ */
27
+
28
+ import { dirname, isAbsolute, join, resolve } from "node:path";
29
+
30
+ import { parse as yamlParse, stringify as yamlStringify } from "yaml";
31
+ import { z } from "zod";
32
+
33
+ import type { WorkspaceIO } from "../../src/types.ts";
34
+
35
+ import { git } from "./git.ts";
36
+ import { withFlowLock } from "./locks.ts";
37
+
38
+ export const STALE_AFTER_HOURS = 72;
39
+ export const REGISTRY_RELATIVE_PATH = "forge/registry.yaml";
40
+ export const REGISTRY_LOCK_RELATIVE_PATH = "forge/registry.lock";
41
+ export const INTEGRATE_LOCK_RELATIVE_PATH = "forge/integrate.lock";
42
+ export const JOURNAL_RELATIVE_PATH = "forge/journal.jsonl";
43
+
44
+ export const REGISTRY_LOCK_WAIT_MS = 10_000;
45
+ export const REGISTRY_LOCK_STALE_MS = 60_000;
46
+
47
+ /** Fixed risk categories for digest items and held entries (RFC-1491). */
48
+ export const RISK_CATEGORIES = [
49
+ "contract",
50
+ "migration",
51
+ "invariant",
52
+ "capability-removal",
53
+ "major-dependency",
54
+ "other",
55
+ ] as const;
56
+ export type RiskCategory = (typeof RISK_CATEGORIES)[number];
57
+
58
+ export const flowRegistryEntrySchema = z
59
+ .object({
60
+ name: z.string().min(1),
61
+ kind: z.enum(["task", "session", "fix"]),
62
+ base: z.enum(["develop", "main"]),
63
+ baseSha: z.string().regex(/^[0-9a-f]{40}$/),
64
+ worktree: z.string().min(1).nullable(),
65
+ owner: z
66
+ .object({
67
+ kind: z.enum(["session", "task"]),
68
+ id: z.string().min(1),
69
+ })
70
+ .strict(),
71
+ brief: z.string().nullable(),
72
+ openedAt: z.string().min(1),
73
+ updatedAt: z.string().min(1),
74
+ held: z
75
+ .object({
76
+ heldAt: z.string().min(1),
77
+ riskCategory: z.enum(RISK_CATEGORIES),
78
+ reason: z.string().min(1),
79
+ tip: z.string().regex(/^[0-9a-f]{40}$/),
80
+ })
81
+ .strict()
82
+ .nullable(),
83
+ port: z
84
+ .object({
85
+ mainSha: z.string().regex(/^[0-9a-f]{40}$/),
86
+ tags: z.array(z.string().min(1)).min(1),
87
+ })
88
+ .strict()
89
+ .nullable()
90
+ .default(null),
91
+ })
92
+ .strict()
93
+ .refine((e) => (e.base === "main") === (e.kind === "fix"), {
94
+ message: "base 'main' ⇔ kind 'fix' — task/session branches always base on develop (RFC-1490)",
95
+ })
96
+ .refine((e) => (e.worktree === null) === (e.held !== null), {
97
+ message: "worktree null ⇔ held — a held branch keeps no worktree, an unheld one always has one (RFC-1491)",
98
+ });
99
+
100
+ export const flowRegistrySchema = z
101
+ .object({
102
+ schema: z.literal("forge/flow-registry@1"),
103
+ branches: z.array(flowRegistryEntrySchema),
104
+ })
105
+ .strict();
106
+
107
+ export type FlowRegistryEntry = z.infer<typeof flowRegistryEntrySchema>;
108
+ export type FlowRegistryV1 = z.infer<typeof flowRegistrySchema>;
109
+
110
+ export class FlowRegistrySchemaError extends Error {
111
+ readonly file: string;
112
+ readonly detail: string;
113
+ constructor(file: string, detail: string) {
114
+ super(`registry ${file} fails the forge/flow-registry@1 schema: ${detail}`);
115
+ this.name = "FlowRegistrySchemaError";
116
+ this.file = file;
117
+ this.detail = detail;
118
+ }
119
+ }
120
+
121
+ export interface FlowJournalEvent {
122
+ at: string;
123
+ event:
124
+ | "open"
125
+ | "integrate"
126
+ | "discard"
127
+ | "cut"
128
+ | "fix"
129
+ | "backmerge"
130
+ | "hold"
131
+ | "unhold"
132
+ | "push"
133
+ | "publish";
134
+ branch: string;
135
+ sha: string;
136
+ detail: string;
137
+ /** develop before (integrate/backmerge/cut/hold); branch base (discard) — W1-1. */
138
+ base?: string;
139
+ /** hold only — the new (base, sha] range of every replayed item. */
140
+ rewrites?: Array<{
141
+ branch: string;
142
+ kind: "integration" | "backmerge" | "release";
143
+ base: string;
144
+ sha: string;
145
+ }>;
146
+ }
147
+
148
+ export function emptyRegistry(): FlowRegistryV1 {
149
+ return { schema: "forge/flow-registry@1", branches: [] };
150
+ }
151
+
152
+ export function registryPath(commonGitDir: string): string {
153
+ return join(commonGitDir, REGISTRY_RELATIVE_PATH);
154
+ }
155
+
156
+ /**
157
+ * Absolute path of the repository's common git dir — shared across all
158
+ * worktrees. `git rev-parse --git-common-dir` may answer relative to cwd.
159
+ */
160
+ export async function commonGitDir(io: WorkspaceIO, cwd: string): Promise<string> {
161
+ const result = await git(cwd, io, ["rev-parse", "--git-common-dir"]);
162
+ if (result.exitCode !== 0) {
163
+ throw new Error(
164
+ `git rev-parse --git-common-dir failed (exit ${result.exitCode}): ${result.stderr.trim()}`,
165
+ );
166
+ }
167
+ const dir = result.stdout.trim();
168
+ return isAbsolute(dir) ? dir : resolve(cwd, dir);
169
+ }
170
+
171
+ /** Read the registry; a missing file yields the empty registry. */
172
+ export async function readRegistry(
173
+ io: WorkspaceIO,
174
+ commonGitDir: string,
175
+ ): Promise<FlowRegistryV1> {
176
+ const file = registryPath(commonGitDir);
177
+ if (!(await io.exists(file))) return emptyRegistry();
178
+ let raw: unknown;
179
+ try {
180
+ raw = yamlParse(await io.readFile(file));
181
+ } catch (error) {
182
+ throw new FlowRegistrySchemaError(
183
+ file,
184
+ `unparseable YAML: ${error instanceof Error ? error.message : String(error)}`,
185
+ );
186
+ }
187
+ const parsed = flowRegistrySchema.safeParse(raw);
188
+ if (!parsed.success) {
189
+ throw new FlowRegistrySchemaError(
190
+ file,
191
+ parsed.error.issues
192
+ .map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`)
193
+ .join("; "),
194
+ );
195
+ }
196
+ return parsed.data;
197
+ }
198
+
199
+ /**
200
+ * Read-mutate-write under the registry lock (10 s wait, 60 s stale).
201
+ * Branches are stored sorted by name; the write is temp file + rename so a
202
+ * reader never sees a torn document.
203
+ */
204
+ export async function updateRegistry(
205
+ io: WorkspaceIO,
206
+ commonGitDir: string,
207
+ mutate: (r: FlowRegistryV1) => FlowRegistryV1,
208
+ ): Promise<FlowRegistryV1> {
209
+ const lockPath = join(commonGitDir, REGISTRY_LOCK_RELATIVE_PATH);
210
+ await io.mkdir(join(commonGitDir, "forge"));
211
+ return withFlowLock(
212
+ lockPath,
213
+ { waitMs: REGISTRY_LOCK_WAIT_MS, staleMs: REGISTRY_LOCK_STALE_MS },
214
+ async () => {
215
+ const current = await readRegistry(io, commonGitDir);
216
+ const next = mutate(current);
217
+ next.branches = [...next.branches].sort((a, b) => a.name.localeCompare(b.name));
218
+ const file = registryPath(commonGitDir);
219
+ const tmp = `${file}.tmp-${process.pid}`;
220
+ await io.writeFile(tmp, yamlStringify(next));
221
+ await io.rename(tmp, file);
222
+ return next;
223
+ },
224
+ io,
225
+ );
226
+ }
227
+
228
+ /** Append one journal line — best-effort bookkeeping, append-only. */
229
+ export async function appendJournal(
230
+ io: WorkspaceIO,
231
+ commonGitDir: string,
232
+ event: Omit<FlowJournalEvent, "at"> & { at?: string },
233
+ ): Promise<void> {
234
+ const file = join(commonGitDir, JOURNAL_RELATIVE_PATH);
235
+ await io.mkdir(dirname(file));
236
+ const line: FlowJournalEvent = {
237
+ at: event.at ?? new Date().toISOString(),
238
+ event: event.event,
239
+ branch: event.branch,
240
+ sha: event.sha,
241
+ detail: event.detail,
242
+ };
243
+ if (event.base !== undefined) line.base = event.base;
244
+ if (event.rewrites !== undefined) line.rewrites = event.rewrites;
245
+ await io.appendFile(file, `${JSON.stringify(line)}\n`);
246
+ }
247
+
248
+ /** Read every journal line in append order; a missing file yields []. */
249
+ export async function readJournal(
250
+ io: WorkspaceIO,
251
+ commonGitDir: string,
252
+ ): Promise<FlowJournalEvent[]> {
253
+ const file = join(commonGitDir, JOURNAL_RELATIVE_PATH);
254
+ if (!(await io.exists(file))) return [];
255
+ const events: FlowJournalEvent[] = [];
256
+ for (const line of (await io.readFile(file)).split("\n")) {
257
+ const trimmed = line.trim();
258
+ if (trimmed.length === 0) continue;
259
+ try {
260
+ events.push(JSON.parse(trimmed) as FlowJournalEvent);
261
+ } catch {
262
+ // A torn append is skipped — the journal is bookkeeping, never a gate.
263
+ }
264
+ }
265
+ return events;
266
+ }
@@ -0,0 +1,139 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Pending release level for a line (RFC-1488): count the commits in
4
+ `&lt;since&gt;..HEAD` touching the line's paths, read their `X-RFC` trailers,
5
+ resolve each RFC's `versionBump` through the canonical RFC reader named by
6
+ forge.yaml resolverDoors.rfc, and report the highest pending level plus the
7
+ next release version it implies.</purpose>
8
+ <non-goals>
9
+ <item>No tag listing or version-file reading — release-tags.ts and the handler own those.</item>
10
+ </non-goals>
11
+ </MODULE_CONTRACT>
12
+ <KEY_DECISIONS>
13
+ <item>`patch` is the floor for any commit — a change merged without an X-RFC trailer still levels the line; `none` only when zero commits touched the line.</item>
14
+ <item>Missing/unreadable RFC file counts as `patch` plus a FLOW-VER-03 warning — the RFC contract, and a safer under- than over-statement.</item>
15
+ <item>RFC frontmatter is read only via `listRfcFiles`/`readAndParseRfc` (RFC-1465) — never re-parsed locally.</item>
16
+ </KEY_DECISIONS>
17
+ <CHANGE_SUMMARY>
18
+ <item>RFC-1488: step 3 — pending level from X-RFC trailers + versionBump</item>
19
+ <item>RFC-1488: steps 2-4 — release tags, pending level (X-RFC + versionBump), flow.version command</item>
20
+ <item>RFC-1488: review r1 — parse guard, door/rules metadata, id-exact RFC binding, refname precision, FLOW-09 top-level anchor, test cleanup</item>
21
+ <item>RFC-1490: step 1 — explicit ref param on tag/level helpers + W1-2 +0.<hash>.dirty shape (AC-12)</item>
22
+ </CHANGE_SUMMARY>
23
+ */
24
+
25
+ import { join } from "node:path";
26
+
27
+ import { listRfcFiles, readAndParseRfc, rfcFileMatchesId } from "../rfc/frontmatter-io.ts";
28
+ import type { Diagnostic, WorkspaceIO } from "../../src/types.ts";
29
+ import { git } from "./git.ts";
30
+ import type { ReleaseLine } from "./release-lines.ts";
31
+ import {
32
+ bumpVersion,
33
+ formatVersion,
34
+ maxLevel,
35
+ type ReleaseLevel,
36
+ type SemVer,
37
+ } from "./semver.ts";
38
+
39
+ export interface PendingLevel {
40
+ line: string;
41
+ level: ReleaseLevel;
42
+ /** Distinct X-RFC trailer ids and each RFC's declared versionBump (null when absent/unreadable). */
43
+ rfcs: Array<{ id: string; versionBump: string | null }>;
44
+ /** lastVersion with `level` applied; null when `none` or no baseline tag. */
45
+ nextVersion: string | null;
46
+ /** FLOW-VER-03 entries for RFC files that could not be read. */
47
+ diagnostics: Diagnostic[];
48
+ }
49
+
50
+ const RFC_DIR = "docs/rfcs";
51
+ const VALID_BUMPS = new Set(["patch", "minor", "major"]);
52
+
53
+ /** Distinct `X-RFC:` trailer values in the commits of `range` touching `paths`. */
54
+ async function xRfcTrailers(
55
+ repoRoot: string,
56
+ range: string,
57
+ paths: string[],
58
+ io: WorkspaceIO,
59
+ ): Promise<string[]> {
60
+ const args = ["log", "--format=%(trailers:key=X-RFC,valueonly,separator=%x20)", range];
61
+ if (paths.length > 0) args.push("--", ...paths);
62
+ const result = await git(repoRoot, io, args);
63
+ if (result.exitCode !== 0) return [];
64
+ const ids = new Set<string>();
65
+ for (const token of result.stdout.split(/[\s]+/)) {
66
+ if (/^RFC-\d+$/i.test(token)) ids.add(token.toUpperCase());
67
+ }
68
+ return [...ids].sort();
69
+ }
70
+
71
+ /**
72
+ * Pending level of `line` over `since..HEAD` (`since` = "" → all of HEAD).
73
+ * `lastVersion` (the line's last tag version) anchors `nextVersion`; null
74
+ * keeps `nextVersion` null.
75
+ */
76
+ export async function pendingLevel(
77
+ line: ReleaseLine,
78
+ since: string,
79
+ io: WorkspaceIO,
80
+ repoRoot: string,
81
+ lastVersion: SemVer | null,
82
+ ref = "HEAD",
83
+ ): Promise<PendingLevel> {
84
+ const range = since === "" ? ref : `${since}..${ref}`;
85
+ const countArgs = ["rev-list", "--count", range];
86
+ if (line.paths.length > 0) countArgs.push("--", ...line.paths);
87
+ const count = await git(repoRoot, io, countArgs);
88
+ const commitsSince = count.exitCode === 0 ? Number.parseInt(count.stdout.trim(), 10) : 0;
89
+
90
+ const diagnostics: Diagnostic[] = [];
91
+ const rfcs: PendingLevel["rfcs"] = [];
92
+ let level: ReleaseLevel = Number.isFinite(commitsSince) && commitsSince > 0 ? "patch" : "none";
93
+
94
+ if (commitsSince > 0) {
95
+ const rfcDirPath = join(repoRoot, RFC_DIR);
96
+ const rfcFiles = await listRfcFiles(rfcDirPath);
97
+ for (const id of await xRfcTrailers(repoRoot, range, line.paths, io)) {
98
+ const fileName = rfcFiles.find((f) => rfcFileMatchesId(f, id));
99
+ if (fileName === undefined) {
100
+ diagnostics.push({
101
+ ruleId: "FLOW-VER-03",
102
+ severity: "warning",
103
+ message: `X-RFC trailer names ${id} but no RFC file under ${RFC_DIR} matches — counted as patch`,
104
+ });
105
+ rfcs.push({ id, versionBump: null });
106
+ continue;
107
+ }
108
+ const parsed = await readAndParseRfc(rfcDirPath, fileName);
109
+ // The filename match is a prefix heuristic — a trailer like RFC-148
110
+ // would otherwise bind rfc-1488-*'s bump. The frontmatter id is
111
+ // authoritative; a mismatch counts as missing.
112
+ const frontmatterId =
113
+ parsed && "parsed" in parsed
114
+ ? String(parsed.parsed.frontmatter["id"] ?? "").trim().toUpperCase()
115
+ : "";
116
+ if (!parsed || !("parsed" in parsed) || frontmatterId !== id) {
117
+ diagnostics.push({
118
+ ruleId: "FLOW-VER-03",
119
+ severity: "warning",
120
+ message: `could not read ${id} (${fileName}) — counted as patch`,
121
+ });
122
+ rfcs.push({ id, versionBump: null });
123
+ continue;
124
+ }
125
+ const raw = parsed.parsed.frontmatter["versionBump"];
126
+ const bump = typeof raw === "string" && VALID_BUMPS.has(raw) ? (raw as ReleaseLevel) : null;
127
+ if (bump !== null) level = maxLevel(level, bump);
128
+ rfcs.push({ id, versionBump: typeof raw === "string" ? raw : null });
129
+ }
130
+ }
131
+
132
+ const nextVersion =
133
+ level !== "none" && lastVersion !== null
134
+ ? formatVersion(bumpVersion(lastVersion, level as Exclude<ReleaseLevel, "none">))
135
+ : null;
136
+
137
+ return { line: line.id, level, rfcs, nextVersion, diagnostics };
138
+ }
139
+
@@ -0,0 +1,208 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Release-line discovery (RFC-1488): the repository line (tag prefix
4
+ `v`, root package.json) plus one package line per workspace-glob directory
5
+ carrying `extract.config.yaml` (tag prefix `&lt;basename&gt;@`). Discovery reads
6
+ pnpm-workspace.yaml, expands each glob's static prefix with readdir to the
7
+ glob's depth, matches with picomatch and refuses ambiguous basenames with
8
+ FLOW-VER-02.</purpose>
9
+ <non-goals>
10
+ <item>No tag reading or version math — release-tags.ts and release-level.ts own those.</item>
11
+ <item>No caching — discovery is a pure function of repository state (DNA-105).</item>
12
+ </non-goals>
13
+ </MODULE_CONTRACT>
14
+ <KEY_DECISIONS>
15
+ <item>extract.config.yaml is the publishability fact (operator decision 2026-11-01) — not independentVersionPackages, which lists only packages/forge.</item>
16
+ <item>Basename collision is an error diagnostic, not a silent merge: two dirs would emit the same tag prefix.</item>
17
+ <item>Return carries `diagnostics` next to `lines` — FLOW-VER-02 must reach flow.version's diagnostic surface; the RFC sketch shows only the line list.</item>
18
+ </KEY_DECISIONS>
19
+ <CHANGE_SUMMARY>
20
+ <item>RFC-1488: step 1 — release-line discovery via pnpm-workspace globs + extract.config.yaml</item>
21
+ <item>RFC-1488: step 1 — semver helper + release-line discovery (extract.config.yaml workspace globs)</item>
22
+ <item>RFC-1488: review r1 — parse guard, door/rules metadata, id-exact RFC binding, refname precision, FLOW-09 top-level anchor, test cleanup</item>
23
+ </CHANGE_SUMMARY>
24
+ */
25
+
26
+ import { basename, join } from "node:path";
27
+
28
+ import picomatch from "picomatch";
29
+ import { parse as parseYaml } from "yaml";
30
+
31
+ import type { Diagnostic, WorkspaceIO } from "../../src/types.ts";
32
+
33
+ export interface ReleaseLine {
34
+ /** "repo" | &lt;package directory basename&gt;, e.g. "forge", "werkstatt-engine". */
35
+ id: string;
36
+ /** "v" | "&lt;id&gt;@". */
37
+ tagPrefix: string;
38
+ /** "package.json" | "&lt;dir&gt;/package.json"; null when the version file is absent. */
39
+ versionFile: string | null;
40
+ /** [] = whole repository; ["packages/forge"] for a package line. */
41
+ paths: string[];
42
+ }
43
+
44
+ export interface ReleaseLinesOutcome {
45
+ lines: ReleaseLine[];
46
+ diagnostics: Diagnostic[];
47
+ }
48
+
49
+ const WORKSPACE_FILE = "pnpm-workspace.yaml";
50
+ const EXTRACT_CONFIG = "extract.config.yaml";
51
+ const GLOB_CHARS = /[*?[{!]/;
52
+
53
+ function diagnostic(ruleId: string, severity: "error" | "warning", message: string): Diagnostic {
54
+ return { ruleId, severity, message };
55
+ }
56
+
57
+ /** Split a workspace glob into path segments ("packages/star" → ["packages","*"]). */
58
+ function globSegments(glob: string): string[] {
59
+ return glob.split("/").filter((s) => s.length > 0);
60
+ }
61
+
62
+ /**
63
+ * Expand one workspace glob to concrete directory paths under repoRoot.
64
+ * Wildcard segments enumerate subdirectories; literal segments must exist.
65
+ * `node_modules` is never descended into. Negated globs are handled by the
66
+ * caller (their matches are subtracted afterwards).
67
+ */
68
+ async function expandGlob(repoRoot: string, glob: string, io: WorkspaceIO): Promise<string[]> {
69
+ const segments = globSegments(glob);
70
+ if (segments.length === 0) return [];
71
+ let candidates = [""];
72
+ for (const segment of segments) {
73
+ const next: string[] = [];
74
+ if (GLOB_CHARS.test(segment)) {
75
+ const matcher = picomatch(segment, { dot: true });
76
+ for (const dir of candidates) {
77
+ const abs = join(repoRoot, dir);
78
+ let entries;
79
+ try {
80
+ entries = await io.readdir(abs);
81
+ } catch {
82
+ continue;
83
+ }
84
+ for (const entry of entries) {
85
+ if (!entry.isDirectory) continue;
86
+ if (entry.name === "node_modules" || entry.name === ".git") continue;
87
+ if (!matcher(entry.name)) continue;
88
+ next.push(dir ? `${dir}/${entry.name}` : entry.name);
89
+ }
90
+ }
91
+ } else {
92
+ for (const dir of candidates) {
93
+ const child = dir ? `${dir}/${segment}` : segment;
94
+ if (await io.exists(join(repoRoot, child))) next.push(child);
95
+ }
96
+ }
97
+ candidates = next;
98
+ }
99
+ // Final picomatch over the full glob so braces/classes in earlier segments
100
+ // cannot admit a directory the whole pattern would not.
101
+ const whole = picomatch(glob, { dot: true });
102
+ return candidates.filter((c) => whole(c));
103
+ }
104
+
105
+ /**
106
+ * Discover the release lines of repoRoot. The repository line always exists;
107
+ * package lines come from pnpm-workspace.yaml `packages:` globs where the
108
+ * directory carries `extract.config.yaml`. FLOW-VER-02 names colliding
109
+ * basenames (their tag prefixes would be identical).
110
+ */
111
+ export async function discoverReleaseLines(
112
+ repoRoot: string,
113
+ io: WorkspaceIO,
114
+ ): Promise<ReleaseLinesOutcome> {
115
+ const diagnostics: Diagnostic[] = [];
116
+
117
+ const rootPackageJson = join(repoRoot, "package.json");
118
+ const repoLine: ReleaseLine = {
119
+ id: "repo",
120
+ tagPrefix: "v",
121
+ versionFile: (await io.exists(rootPackageJson)) ? "package.json" : null,
122
+ paths: [],
123
+ };
124
+
125
+ const globs: string[] = [];
126
+ const negated: string[] = [];
127
+ if (await io.exists(join(repoRoot, WORKSPACE_FILE))) {
128
+ let parsed: { packages?: unknown } | null = null;
129
+ try {
130
+ parsed = parseYaml(await io.readFile(join(repoRoot, WORKSPACE_FILE))) as
131
+ | { packages?: unknown }
132
+ | null;
133
+ } catch {
134
+ diagnostics.push(
135
+ diagnostic(
136
+ "FLOW-VER-02",
137
+ "error",
138
+ `${WORKSPACE_FILE} is not valid YAML — package lines cannot be discovered`,
139
+ ),
140
+ );
141
+ }
142
+ for (const entry of Array.isArray(parsed?.packages) ? parsed?.packages : []) {
143
+ if (typeof entry !== "string") continue;
144
+ if (entry.startsWith("!")) negated.push(entry.slice(1));
145
+ else globs.push(entry);
146
+ }
147
+ }
148
+
149
+ const negatedMatchers = negated.map((g) => picomatch(g, { dot: true }));
150
+ const packageDirs = new Set<string>();
151
+ for (const glob of globs) {
152
+ for (const dir of await expandGlob(repoRoot, glob, io)) {
153
+ if (negatedMatchers.some((m) => m(dir))) continue;
154
+ packageDirs.add(dir);
155
+ }
156
+ }
157
+
158
+ const lines: ReleaseLine[] = [repoLine];
159
+ const byId = new Map<string, string[]>();
160
+ for (const dir of [...packageDirs].sort()) {
161
+ if (!(await io.exists(join(repoRoot, dir, EXTRACT_CONFIG)))) continue;
162
+ const id = basename(dir);
163
+ const group = byId.get(id) ?? [];
164
+ group.push(dir);
165
+ byId.set(id, group);
166
+ }
167
+ for (const [id, members] of [...byId.entries()].sort(([a], [b]) => a.localeCompare(b))) {
168
+ if (members.length > 1) {
169
+ diagnostics.push(
170
+ diagnostic(
171
+ "FLOW-VER-02",
172
+ "error",
173
+ `release-line basename '${id}' is claimed by ${members.join(" and ")} — their tag prefixes would collide`,
174
+ ),
175
+ );
176
+ continue;
177
+ }
178
+ const dir = members[0]!;
179
+ lines.push({
180
+ id,
181
+ tagPrefix: `${id}@`,
182
+ versionFile: (await io.exists(join(repoRoot, dir, "package.json")))
183
+ ? `${dir}/package.json`
184
+ : null,
185
+ paths: [dir],
186
+ });
187
+ }
188
+
189
+ return { lines, diagnostics };
190
+ }
191
+
192
+ /** The version value a line's version file currently carries, or null. */
193
+ export async function readLineVersionFile(
194
+ repoRoot: string,
195
+ line: ReleaseLine,
196
+ io: WorkspaceIO,
197
+ ): Promise<string | null> {
198
+ if (line.versionFile === null) return null;
199
+ const path = join(repoRoot, line.versionFile);
200
+ if (!(await io.exists(path))) return null;
201
+ try {
202
+ const parsed = JSON.parse(await io.readFile(path)) as { version?: unknown };
203
+ return typeof parsed.version === "string" ? parsed.version : null;
204
+ } catch {
205
+ return null;
206
+ }
207
+ }
208
+