@warpgogol/forge 9.3.0 → 9.4.0

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 (472) hide show
  1. package/AGENTS.md +32 -0
  2. package/CHANGELOG.md +33 -0
  3. package/README.md +2 -2
  4. package/bin/cli.ts +4 -4
  5. package/dist/bin/cli.js +4 -4
  6. package/dist/bin/cli.js.map +1 -1
  7. package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
  8. package/dist/os/adr/handlers/list-create.js +23 -2
  9. package/dist/os/adr/handlers/list-create.js.map +1 -1
  10. package/dist/os/adr/types.d.ts +2 -0
  11. package/dist/os/adr/types.d.ts.map +1 -1
  12. package/dist/os/adr/types.js +2 -2
  13. package/dist/os/adr/types.js.map +1 -1
  14. package/dist/os/compass/handlers/compass-audit-handler.d.ts.map +1 -1
  15. package/dist/os/compass/handlers/compass-audit-handler.js +3 -1
  16. package/dist/os/compass/handlers/compass-audit-handler.js.map +1 -1
  17. package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts.map +1 -1
  18. package/dist/os/compass/handlers/compass-header-scaffold-handler.js +6 -12
  19. package/dist/os/compass/handlers/compass-header-scaffold-handler.js.map +1 -1
  20. package/dist/os/compass/handlers/git-revision.d.ts +2 -0
  21. package/dist/os/compass/handlers/git-revision.d.ts.map +1 -1
  22. package/dist/os/compass/handlers/git-revision.js +7 -2
  23. package/dist/os/compass/handlers/git-revision.js.map +1 -1
  24. package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
  25. package/dist/os/compass/handlers/summary-record.js +24 -14
  26. package/dist/os/compass/handlers/summary-record.js.map +1 -1
  27. package/dist/os/conformance/conformance.module.d.ts.map +1 -1
  28. package/dist/os/conformance/conformance.module.js +21 -4
  29. package/dist/os/conformance/conformance.module.js.map +1 -1
  30. package/dist/os/conformance/handlers/conformance-validate.d.ts.map +1 -1
  31. package/dist/os/conformance/handlers/conformance-validate.js +64 -8
  32. package/dist/os/conformance/handlers/conformance-validate.js.map +1 -1
  33. package/dist/os/core/archive-regen.d.ts +99 -0
  34. package/dist/os/core/archive-regen.d.ts.map +1 -0
  35. package/dist/os/core/archive-regen.js +220 -0
  36. package/dist/os/core/archive-regen.js.map +1 -0
  37. package/dist/os/core/core.module.d.ts.map +1 -1
  38. package/dist/os/core/core.module.js +159 -18
  39. package/dist/os/core/core.module.js.map +1 -1
  40. package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
  41. package/dist/os/core/handlers/assets-helpers.js +8 -3
  42. package/dist/os/core/handlers/assets-helpers.js.map +1 -1
  43. package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +1 -1
  44. package/dist/os/core/handlers/forge-autonomy-validate.js +3 -1
  45. package/dist/os/core/handlers/forge-autonomy-validate.js.map +1 -1
  46. package/dist/os/core/handlers/package-health.d.ts +130 -0
  47. package/dist/os/core/handlers/package-health.d.ts.map +1 -1
  48. package/dist/os/core/handlers/package-health.js +548 -7
  49. package/dist/os/core/handlers/package-health.js.map +1 -1
  50. package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
  51. package/dist/os/core/handlers/release-prepare.js +5 -2
  52. package/dist/os/core/handlers/release-prepare.js.map +1 -1
  53. package/dist/os/flow/digest.d.ts.map +1 -1
  54. package/dist/os/flow/digest.js +3 -1
  55. package/dist/os/flow/digest.js.map +1 -1
  56. package/dist/os/flow/dirty-classify.d.ts +48 -0
  57. package/dist/os/flow/dirty-classify.d.ts.map +1 -0
  58. package/dist/os/flow/dirty-classify.js +81 -0
  59. package/dist/os/flow/dirty-classify.js.map +1 -0
  60. package/dist/os/flow/flow.module.d.ts.map +1 -1
  61. package/dist/os/flow/flow.module.js +85 -19
  62. package/dist/os/flow/flow.module.js.map +1 -1
  63. package/dist/os/flow/gate-engine.d.ts +13 -0
  64. package/dist/os/flow/gate-engine.d.ts.map +1 -0
  65. package/dist/os/flow/gate-engine.js +32 -0
  66. package/dist/os/flow/gate-engine.js.map +1 -0
  67. package/dist/os/flow/git.d.ts +45 -4
  68. package/dist/os/flow/git.d.ts.map +1 -1
  69. package/dist/os/flow/git.js +95 -27
  70. package/dist/os/flow/git.js.map +1 -1
  71. package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -1
  72. package/dist/os/flow/handlers/flow-backmerge.js +12 -5
  73. package/dist/os/flow/handlers/flow-backmerge.js.map +1 -1
  74. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
  75. package/dist/os/flow/handlers/flow-check.js +25 -3
  76. package/dist/os/flow/handlers/flow-check.js.map +1 -1
  77. package/dist/os/flow/handlers/flow-cut.d.ts +4 -1
  78. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
  79. package/dist/os/flow/handlers/flow-cut.js +54 -31
  80. package/dist/os/flow/handlers/flow-cut.js.map +1 -1
  81. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -1
  82. package/dist/os/flow/handlers/flow-discard.js +33 -5
  83. package/dist/os/flow/handlers/flow-discard.js.map +1 -1
  84. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -1
  85. package/dist/os/flow/handlers/flow-fix.js +13 -10
  86. package/dist/os/flow/handlers/flow-fix.js.map +1 -1
  87. package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -1
  88. package/dist/os/flow/handlers/flow-hold.js +13 -7
  89. package/dist/os/flow/handlers/flow-hold.js.map +1 -1
  90. package/dist/os/flow/handlers/flow-install.d.ts +2 -1
  91. package/dist/os/flow/handlers/flow-install.d.ts.map +1 -1
  92. package/dist/os/flow/handlers/flow-install.js +56 -13
  93. package/dist/os/flow/handlers/flow-install.js.map +1 -1
  94. package/dist/os/flow/handlers/flow-integrate.d.ts +48 -2
  95. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  96. package/dist/os/flow/handlers/flow-integrate.js +536 -65
  97. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  98. package/dist/os/flow/handlers/flow-open.d.ts +14 -0
  99. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
  100. package/dist/os/flow/handlers/flow-open.js +117 -12
  101. package/dist/os/flow/handlers/flow-open.js.map +1 -1
  102. package/dist/os/flow/handlers/flow-status.d.ts +13 -0
  103. package/dist/os/flow/handlers/flow-status.d.ts.map +1 -1
  104. package/dist/os/flow/handlers/flow-status.js +35 -14
  105. package/dist/os/flow/handlers/flow-status.js.map +1 -1
  106. package/dist/os/flow/index.d.ts +1 -0
  107. package/dist/os/flow/index.d.ts.map +1 -1
  108. package/dist/os/flow/index.js +3 -1
  109. package/dist/os/flow/index.js.map +1 -1
  110. package/dist/os/flow/line-version.d.ts.map +1 -1
  111. package/dist/os/flow/line-version.js +2 -1
  112. package/dist/os/flow/line-version.js.map +1 -1
  113. package/dist/os/flow/locks.d.ts +37 -1
  114. package/dist/os/flow/locks.d.ts.map +1 -1
  115. package/dist/os/flow/locks.js +34 -14
  116. package/dist/os/flow/locks.js.map +1 -1
  117. package/dist/os/flow/preflight.d.ts +114 -0
  118. package/dist/os/flow/preflight.d.ts.map +1 -0
  119. package/dist/os/flow/preflight.js +620 -0
  120. package/dist/os/flow/preflight.js.map +1 -0
  121. package/dist/os/flow/publish.d.ts +7 -0
  122. package/dist/os/flow/publish.d.ts.map +1 -1
  123. package/dist/os/flow/publish.js +165 -3
  124. package/dist/os/flow/publish.js.map +1 -1
  125. package/dist/os/flow/registry.d.ts +26 -1
  126. package/dist/os/flow/registry.d.ts.map +1 -1
  127. package/dist/os/flow/registry.js +27 -6
  128. package/dist/os/flow/registry.js.map +1 -1
  129. package/dist/os/flow/scripts.d.ts +4 -0
  130. package/dist/os/flow/scripts.d.ts.map +1 -1
  131. package/dist/os/flow/scripts.js +13 -3
  132. package/dist/os/flow/scripts.js.map +1 -1
  133. package/dist/os/flow/session-checkout.d.ts +33 -0
  134. package/dist/os/flow/session-checkout.d.ts.map +1 -0
  135. package/dist/os/flow/session-checkout.js +151 -0
  136. package/dist/os/flow/session-checkout.js.map +1 -0
  137. package/dist/os/flow/worktree-path.d.ts.map +1 -1
  138. package/dist/os/flow/worktree-path.js +9 -3
  139. package/dist/os/flow/worktree-path.js.map +1 -1
  140. package/dist/os/instructions/handlers/budget-validate.d.ts +1 -0
  141. package/dist/os/instructions/handlers/budget-validate.d.ts.map +1 -1
  142. package/dist/os/instructions/handlers/budget-validate.js +12 -4
  143. package/dist/os/instructions/handlers/budget-validate.js.map +1 -1
  144. package/dist/os/instructions/instructions.module.d.ts.map +1 -1
  145. package/dist/os/instructions/instructions.module.js +4 -1
  146. package/dist/os/instructions/instructions.module.js.map +1 -1
  147. package/dist/os/mission/open-missions.d.ts +8 -0
  148. package/dist/os/mission/open-missions.d.ts.map +1 -0
  149. package/dist/os/mission/open-missions.js +42 -0
  150. package/dist/os/mission/open-missions.js.map +1 -0
  151. package/dist/os/queue/manifest.d.ts.map +1 -1
  152. package/dist/os/queue/manifest.js +11 -1
  153. package/dist/os/queue/manifest.js.map +1 -1
  154. package/dist/os/rfc/acceptance.d.ts +14 -0
  155. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  156. package/dist/os/rfc/acceptance.js +18 -10
  157. package/dist/os/rfc/acceptance.js.map +1 -1
  158. package/dist/os/rfc/decision-log.d.ts.map +1 -1
  159. package/dist/os/rfc/decision-log.js +11 -2
  160. package/dist/os/rfc/decision-log.js.map +1 -1
  161. package/dist/os/rfc/frontmatter-io.d.ts +23 -0
  162. package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
  163. package/dist/os/rfc/frontmatter-io.js +82 -1
  164. package/dist/os/rfc/frontmatter-io.js.map +1 -1
  165. package/dist/os/rfc/handlers/implement-stamp-deviations.d.ts.map +1 -1
  166. package/dist/os/rfc/handlers/implement-stamp-deviations.js +24 -2
  167. package/dist/os/rfc/handlers/implement-stamp-deviations.js.map +1 -1
  168. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  169. package/dist/os/rfc/handlers/implement-stamp.js +16 -3
  170. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  171. package/dist/os/rfc/handlers/index-graph.d.ts.map +1 -1
  172. package/dist/os/rfc/handlers/index-graph.js +5 -4
  173. package/dist/os/rfc/handlers/index-graph.js.map +1 -1
  174. package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
  175. package/dist/os/rfc/handlers/list-create.js +83 -8
  176. package/dist/os/rfc/handlers/list-create.js.map +1 -1
  177. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts +48 -0
  178. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts.map +1 -1
  179. package/dist/os/rfc/handlers/rfc-evidence-sync.js +131 -2
  180. package/dist/os/rfc/handlers/rfc-evidence-sync.js.map +1 -1
  181. package/dist/os/rfc/handlers/validate-rules.d.ts +21 -1
  182. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  183. package/dist/os/rfc/handlers/validate-rules.js +77 -5
  184. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  185. package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
  186. package/dist/os/rfc/handlers/validate.js +64 -6
  187. package/dist/os/rfc/handlers/validate.js.map +1 -1
  188. package/dist/os/rfc/next-id.d.ts +38 -0
  189. package/dist/os/rfc/next-id.d.ts.map +1 -0
  190. package/dist/os/rfc/next-id.js +165 -0
  191. package/dist/os/rfc/next-id.js.map +1 -0
  192. package/dist/os/rfc/probe-batch.d.ts.map +1 -1
  193. package/dist/os/rfc/probe-batch.js +6 -1
  194. package/dist/os/rfc/probe-batch.js.map +1 -1
  195. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  196. package/dist/os/rfc/rfc.module.js +36 -8
  197. package/dist/os/rfc/rfc.module.js.map +1 -1
  198. package/dist/os/rfc/types.d.ts +35 -6
  199. package/dist/os/rfc/types.d.ts.map +1 -1
  200. package/dist/os/rfc/types.js +6 -6
  201. package/dist/os/rfc/types.js.map +1 -1
  202. package/dist/os/rfc/verification-evidence.d.ts +1 -1
  203. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  204. package/dist/os/rfc/verification-evidence.js +81 -28
  205. package/dist/os/rfc/verification-evidence.js.map +1 -1
  206. package/dist/os/rfc/verification-origin.d.ts +8 -0
  207. package/dist/os/rfc/verification-origin.d.ts.map +1 -1
  208. package/dist/os/rfc/verification-origin.js +47 -0
  209. package/dist/os/rfc/verification-origin.js.map +1 -1
  210. package/dist/os/session/handlers/save.d.ts.map +1 -1
  211. package/dist/os/session/handlers/save.js +31 -7
  212. package/dist/os/session/handlers/save.js.map +1 -1
  213. package/dist/os/spec/spec-schema.d.ts +8 -0
  214. package/dist/os/spec/spec-schema.d.ts.map +1 -1
  215. package/dist/os/spec/spec-schema.js +1 -0
  216. package/dist/os/spec/spec-schema.js.map +1 -1
  217. package/dist/os/spec/spec-status.d.ts +8 -0
  218. package/dist/os/spec/spec-status.d.ts.map +1 -1
  219. package/dist/os/spec/spec-status.js +18 -6
  220. package/dist/os/spec/spec-status.js.map +1 -1
  221. package/dist/os/spec/spec-validate.d.ts.map +1 -1
  222. package/dist/os/spec/spec-validate.js +62 -15
  223. package/dist/os/spec/spec-validate.js.map +1 -1
  224. package/dist/os/spec/spec.module.d.ts.map +1 -1
  225. package/dist/os/spec/spec.module.js +13 -5
  226. package/dist/os/spec/spec.module.js.map +1 -1
  227. package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -1
  228. package/dist/os/system/handlers/system-map-validate.js +2 -1
  229. package/dist/os/system/handlers/system-map-validate.js.map +1 -1
  230. package/dist/os/system/handlers/system-outbox-scan.d.ts +11 -0
  231. package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -1
  232. package/dist/os/system/handlers/system-outbox-scan.js +54 -6
  233. package/dist/os/system/handlers/system-outbox-scan.js.map +1 -1
  234. package/dist/os/system/handlers/system-task-create.d.ts.map +1 -1
  235. package/dist/os/system/handlers/system-task-create.js +6 -1
  236. package/dist/os/system/handlers/system-task-create.js.map +1 -1
  237. package/dist/os/system/handlers/system-versionset-record.d.ts +14 -0
  238. package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -1
  239. package/dist/os/system/handlers/system-versionset-record.js +246 -6
  240. package/dist/os/system/handlers/system-versionset-record.js.map +1 -1
  241. package/dist/os/system/repo.d.ts +1 -1
  242. package/dist/os/system/repo.d.ts.map +1 -1
  243. package/dist/os/system/repo.js +53 -3
  244. package/dist/os/system/repo.js.map +1 -1
  245. package/dist/os/system/scenario-schemas.d.ts +109 -3
  246. package/dist/os/system/scenario-schemas.d.ts.map +1 -1
  247. package/dist/os/system/scenario-schemas.js +66 -10
  248. package/dist/os/system/scenario-schemas.js.map +1 -1
  249. package/dist/os/system/system.module.d.ts.map +1 -1
  250. package/dist/os/system/system.module.js +69 -17
  251. package/dist/os/system/system.module.js.map +1 -1
  252. package/dist/os/system/tests/contract-fixtures.d.ts +17 -0
  253. package/dist/os/system/tests/contract-fixtures.d.ts.map +1 -0
  254. package/dist/os/system/tests/contract-fixtures.js +109 -0
  255. package/dist/os/system/tests/contract-fixtures.js.map +1 -0
  256. package/dist/src/config/forge-config.d.ts +54 -18
  257. package/dist/src/config/forge-config.d.ts.map +1 -1
  258. package/dist/src/config/forge-config.js +41 -9
  259. package/dist/src/config/forge-config.js.map +1 -1
  260. package/dist/src/conformance/index.d.ts +6 -0
  261. package/dist/src/conformance/index.d.ts.map +1 -1
  262. package/dist/src/conformance/index.js +36 -1
  263. package/dist/src/conformance/index.js.map +1 -1
  264. package/dist/src/formal/proof-runner.d.ts.map +1 -1
  265. package/dist/src/formal/proof-runner.js +10 -2
  266. package/dist/src/formal/proof-runner.js.map +1 -1
  267. package/dist/src/migration-adapters/node-typescript-pnpm/index.js +3 -1
  268. package/dist/src/migration-adapters/node-typescript-pnpm/index.js.map +1 -1
  269. package/dist/src/migration-adapters/phaser-pnpm/index.js +3 -1
  270. package/dist/src/migration-adapters/phaser-pnpm/index.js.map +1 -1
  271. package/dist/src/onboarding/agents-generate.js +4 -4
  272. package/dist/src/onboarding/agents-generate.js.map +1 -1
  273. package/dist/src/onboarding/nested-agents-generate.d.ts.map +1 -1
  274. package/dist/src/onboarding/nested-agents-generate.js +3 -1
  275. package/dist/src/onboarding/nested-agents-generate.js.map +1 -1
  276. package/dist/src/onboarding/scaffold-project.js +2 -2
  277. package/dist/src/onboarding/scaffold-project.js.map +1 -1
  278. package/dist/src/onboarding/upgrade.d.ts.map +1 -1
  279. package/dist/src/onboarding/upgrade.js +14 -2
  280. package/dist/src/onboarding/upgrade.js.map +1 -1
  281. package/dist/src/onboarding/workspace-discovery.d.ts.map +1 -1
  282. package/dist/src/onboarding/workspace-discovery.js +3 -1
  283. package/dist/src/onboarding/workspace-discovery.js.map +1 -1
  284. package/dist/src/skill-schema.d.ts +3 -0
  285. package/dist/src/skill-schema.d.ts.map +1 -1
  286. package/dist/src/skill-schema.js +9 -2
  287. package/dist/src/skill-schema.js.map +1 -1
  288. package/dist/src/spec/resolve-spec-source.d.ts +45 -0
  289. package/dist/src/spec/resolve-spec-source.d.ts.map +1 -0
  290. package/dist/src/spec/resolve-spec-source.js +153 -0
  291. package/dist/src/spec/resolve-spec-source.js.map +1 -0
  292. package/dist/src/utils/command-inventory.d.ts +28 -0
  293. package/dist/src/utils/command-inventory.d.ts.map +1 -0
  294. package/dist/src/utils/command-inventory.js +84 -0
  295. package/dist/src/utils/command-inventory.js.map +1 -0
  296. package/dist/src/utils/io.d.ts.map +1 -1
  297. package/dist/src/utils/io.js +6 -1
  298. package/dist/src/utils/io.js.map +1 -1
  299. package/dist/src/utils/repo-path.d.ts +10 -0
  300. package/dist/src/utils/repo-path.d.ts.map +1 -0
  301. package/dist/src/utils/repo-path.js +52 -0
  302. package/dist/src/utils/repo-path.js.map +1 -0
  303. package/dist/src/utils/spawn.d.ts +23 -0
  304. package/dist/src/utils/spawn.d.ts.map +1 -0
  305. package/dist/src/utils/spawn.js +83 -0
  306. package/dist/src/utils/spawn.js.map +1 -0
  307. package/docs/branch-model.md +1 -1
  308. package/docs/guides/existing-project.md +1 -1
  309. package/docs/maintainers/publishing.md +1 -1
  310. package/docs/reference/cli.md +8 -2
  311. package/docs/reference/profiles.md +1 -1
  312. package/os/adr/handlers/list-create.ts +26 -2
  313. package/os/adr/types.ts +4 -2
  314. package/os/compass/handlers/compass-audit-handler.ts +6 -1
  315. package/os/compass/handlers/compass-header-scaffold-handler.ts +12 -11
  316. package/os/compass/handlers/git-revision.ts +8 -2
  317. package/os/compass/handlers/summary-record.ts +25 -14
  318. package/os/compass/handlers/tests/compass-invariant-binding.test.ts +3 -2
  319. package/os/conformance/conformance.module.ts +21 -4
  320. package/os/conformance/handlers/conformance-validate.ts +108 -16
  321. package/os/conformance/handlers/tests/conformance-package-consumer.test.ts +200 -0
  322. package/os/core/archive-regen.ts +279 -0
  323. package/os/core/core.module.ts +176 -29
  324. package/os/core/docs-archive.test.ts +413 -3
  325. package/os/core/handlers/assets-helpers.ts +8 -3
  326. package/os/core/handlers/forge-autonomy-validate.ts +3 -1
  327. package/os/core/handlers/package-health.test.ts +418 -4
  328. package/os/core/handlers/package-health.ts +629 -7
  329. package/os/core/handlers/release-prepare.ts +5 -2
  330. package/os/flow/digest.ts +3 -1
  331. package/os/flow/dirty-classify.ts +112 -0
  332. package/os/flow/flow.module.ts +92 -24
  333. package/os/flow/gate-engine.ts +45 -0
  334. package/os/flow/git.ts +117 -29
  335. package/os/flow/handlers/flow-backmerge.ts +14 -4
  336. package/os/flow/handlers/flow-check.ts +27 -2
  337. package/os/flow/handlers/flow-cut.ts +97 -46
  338. package/os/flow/handlers/flow-discard.ts +33 -5
  339. package/os/flow/handlers/flow-fix.ts +22 -10
  340. package/os/flow/handlers/flow-hold.ts +20 -7
  341. package/os/flow/handlers/flow-install.ts +59 -12
  342. package/os/flow/handlers/flow-integrate.ts +808 -182
  343. package/os/flow/handlers/flow-open.ts +135 -11
  344. package/os/flow/handlers/flow-status.ts +45 -13
  345. package/os/flow/index.ts +3 -1
  346. package/os/flow/line-version.ts +2 -1
  347. package/os/flow/locks.ts +56 -14
  348. package/os/flow/preflight.ts +763 -0
  349. package/os/flow/publish.ts +200 -5
  350. package/os/flow/registry.ts +43 -7
  351. package/os/flow/scripts.ts +23 -7
  352. package/os/flow/session-checkout.ts +186 -0
  353. package/os/flow/tests/dirty-classify.test.ts +116 -0
  354. package/os/flow/tests/fixtures/branch-names.yaml +40 -40
  355. package/os/flow/tests/flow-discard.test.ts +32 -0
  356. package/os/flow/tests/flow-guard-parity.test.ts +10 -2
  357. package/os/flow/tests/flow-install.test.ts +7 -3
  358. package/os/flow/tests/flow-integrate.gate-report.test.ts +144 -0
  359. package/os/flow/tests/flow-integrate.preflight.test.ts +561 -0
  360. package/os/flow/tests/flow-integrate.reattach.test.ts +197 -0
  361. package/os/flow/tests/flow-integrate.remediation.test.ts +254 -0
  362. package/os/flow/tests/flow-integrate.test.ts +348 -17
  363. package/os/flow/tests/flow-open.pending.test.ts +277 -0
  364. package/os/flow/tests/flow-open.test.ts +52 -9
  365. package/os/flow/tests/flow-push-publish.test.ts +124 -0
  366. package/os/flow/tests/flow-status.test.ts +31 -1
  367. package/os/flow/tests/locks.test.ts +39 -3
  368. package/os/flow/tests/scripts.test.ts +18 -2
  369. package/os/flow/tests/state-roots.test.ts +8 -5
  370. package/os/flow/worktree-path.ts +9 -3
  371. package/os/formal/handlers/proof-check.test.ts +6 -3
  372. package/os/instructions/budget.test.ts +31 -0
  373. package/os/instructions/handlers/budget-validate.ts +13 -4
  374. package/os/instructions/instructions.module.ts +4 -1
  375. package/os/mission/open-missions.ts +50 -0
  376. package/os/queue/decision-ledger.test.ts +18 -0
  377. package/os/queue/manifest.ts +17 -1
  378. package/os/rfc/acceptance.ts +30 -10
  379. package/os/rfc/decision-log.ts +13 -2
  380. package/os/rfc/frontmatter-io.ts +89 -1
  381. package/os/rfc/handlers/implement-stamp-deviations.test.ts +83 -0
  382. package/os/rfc/handlers/implement-stamp-deviations.ts +22 -2
  383. package/os/rfc/handlers/implement-stamp-stale.test.ts +5 -1
  384. package/os/rfc/handlers/implement-stamp.ts +16 -3
  385. package/os/rfc/handlers/index-graph.ts +5 -4
  386. package/os/rfc/handlers/lifecycle.test.ts +136 -0
  387. package/os/rfc/handlers/list-create.test.ts +82 -0
  388. package/os/rfc/handlers/list-create.ts +101 -8
  389. package/os/rfc/handlers/rfc-evidence-sync.test.ts +504 -0
  390. package/os/rfc/handlers/rfc-evidence-sync.ts +192 -2
  391. package/os/rfc/handlers/tests/index-graph.test.ts +2 -1
  392. package/os/rfc/handlers/validate-rules-rfc1454.test.ts +73 -0
  393. package/os/rfc/handlers/validate-rules.ts +103 -7
  394. package/os/rfc/handlers/validate.ts +68 -4
  395. package/os/rfc/next-id.ts +232 -0
  396. package/os/rfc/probe-batch.ts +6 -1
  397. package/os/rfc/rfc.module.ts +41 -8
  398. package/os/rfc/types.ts +28 -6
  399. package/os/rfc/verification-emit-freshness.test.ts +5 -1
  400. package/os/rfc/verification-emit.test.ts +5 -1
  401. package/os/rfc/verification-evidence.ts +99 -33
  402. package/os/rfc/verification-origin.ts +59 -0
  403. package/os/rfc/verification-refresh.test.ts +5 -1
  404. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +5 -1
  405. package/os/session/handlers/save.ts +35 -7
  406. package/os/session/tests/session-save.test.ts +154 -0
  407. package/os/spec/spec-schema.ts +3 -0
  408. package/os/spec/spec-status.ts +22 -6
  409. package/os/spec/spec-validate.package-source.test.ts +187 -0
  410. package/os/spec/spec-validate.ts +65 -14
  411. package/os/spec/spec.module.ts +13 -5
  412. package/os/system/handlers/system-map-validate.ts +4 -2
  413. package/os/system/handlers/system-outbox-scan.ts +65 -21
  414. package/os/system/handlers/system-task-create.ts +6 -1
  415. package/os/system/handlers/system-versionset-record.ts +301 -16
  416. package/os/system/repo.ts +59 -18
  417. package/os/system/scenario-schemas.ts +91 -12
  418. package/os/system/system.module.ts +70 -17
  419. package/os/system/tests/contract-fixtures.ts +139 -0
  420. package/os/system/tests/scenario-pin-drift-check.test.ts +114 -0
  421. package/os/system/tests/scenario-validator-check.test.ts +96 -0
  422. package/os/system/tests/system-task-dispatch.test.ts +4 -1
  423. package/os/system/tests/system-versionset.test.ts +7 -3
  424. package/os/system/tests/version-set-v2.test.ts +78 -0
  425. package/package.json +9 -1
  426. package/profiles/forge-shell.yaml +1 -2
  427. package/profiles/knowledge.yaml +1 -1
  428. package/profiles/system.yaml +2 -2
  429. package/profiles/typescript.yaml +0 -1
  430. package/skills/fo/fo-doctor/SKILL.md +151 -0
  431. package/skills/fo/fo-handoff/SKILL.md +22 -0
  432. package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +2 -1
  433. package/skills/fo/fo-idea-implement/SKILL.md +5 -2
  434. package/skills/fo/fo-idea-plan/SKILL.md +5 -5
  435. package/skills/fo/fo-session-retro/SKILL.md +37 -11
  436. package/skills/fo/fo-spec-ingest/SKILL.md +8 -0
  437. package/skills/fo/fo-system-dispatch/SKILL.md +1 -0
  438. package/skills/meta/skill-create/SKILL.md +2 -1
  439. package/src/bin-entry.test.ts +3 -1
  440. package/src/config/forge-config.ts +57 -13
  441. package/src/conformance/index.ts +46 -1
  442. package/src/formal/proof-runner.ts +10 -2
  443. package/src/migration-adapters/node-typescript-pnpm/index.ts +3 -1
  444. package/src/migration-adapters/phaser-pnpm/index.ts +3 -1
  445. package/src/onboarding/agents-generate.ts +4 -4
  446. package/src/onboarding/nested-agents-generate.ts +3 -1
  447. package/src/onboarding/scaffold-project.ts +2 -2
  448. package/src/onboarding/upgrade.ts +13 -2
  449. package/src/onboarding/workspace-discovery.ts +3 -1
  450. package/src/pipeline-status.test.ts +1 -1
  451. package/src/skill-schema.ts +9 -2
  452. package/src/spec/resolve-spec-source.ts +184 -0
  453. package/src/tests/acceptance-probe-kinds.test.ts +3 -1
  454. package/src/tests/agents-generate-domain.test.ts +3 -2
  455. package/src/tests/agents-generate.test.ts +2 -1
  456. package/src/tests/create-flow.test.ts +3 -1
  457. package/src/tests/create.test.ts +12 -2
  458. package/src/tests/editable-generated-region.test.ts +2 -2
  459. package/src/tests/fixtures/agents-generate-business-before.txt +2 -0
  460. package/src/tests/implement-stamp.test.ts +5 -2
  461. package/src/tests/profile-flow-hooks.test.ts +15 -0
  462. package/src/tests/rfc-implement-stamp-governance.test.ts +6 -2
  463. package/src/tests/rfc-verification-verdict-ingest.test.ts +5 -1
  464. package/src/tests/scaffold-project.test.ts +3 -1
  465. package/src/tests/upgrade.test.ts +79 -3
  466. package/src/tests/workspace-discovery.test.ts +4 -3
  467. package/src/utils/command-inventory.ts +105 -0
  468. package/src/utils/io.ts +6 -1
  469. package/src/utils/repo-path.ts +49 -0
  470. package/src/utils/spawn.ts +88 -0
  471. package/src/tests/rfc-evidence-sync.test.ts +0 -369
  472. package/src/tests/skill-agents-sync.test.ts +0 -192
@@ -6,17 +6,40 @@
6
6
  <item>Do not modify files — read-only validation.</item>
7
7
  </non-goals>
8
8
  </MODULE_CONTRACT>
9
+ <KEY_DECISIONS>
10
+ <item>parseHealthScanConfig + isShippedEntry mirror repo-extract's copy filter through the SAME decision inputs it consumes — real YAML parse (comment-bearing lists survive), isKeyMaterial default excludePathSegments (.input/signing-key, .input/batches) when the key is absent, isDbFile default .db excludeExtensions, copyFiltered's BASE_IGNORE_DIRS/IGNORE_FILES for non-standalone exports, and statSync symlink-following like cp's filter — a hand-maintained list or partial parser drifts from what the extract actually ships (F-0064's whole premise).</item>
11
+ <item>scanFixturePathEscapes judges each candidate via one shared literal core (literalEscapesInLine: TS-family quoted mode, raw `../` chain mode elsewhere, same-line pkg-health-10: suppression) while doc files (prose links are never resolved) and binary/generated files (UTF-8 noise, .map sources) are exempt wholesale; pkgHealth10Suppressions in extract.config.yaml covers files that cannot carry an in-source comment such as JSON (RFC-1517 r1).</item>
12
+ <item>loadCommandInventory unions context.commandRegistry.listCommands() with docs/command-manifest.generated.yaml — the getLiveCommands merge precedent from os/rfc/handlers/lifecycle.ts — because `werkstatt run` injects no commandRegistry and lazy-loaded modules are invisible to it; a registry-only read would silently disable the docs gate on the primary dispatch path (RFC-1518 r1, deviation D-001).</item>
13
+ <item>scanDocsSurface resolves dead-reference candidates through two mechanical disambiguators: first-segment namespace membership (property paths like context.site and config keys like bindings.commands are never command refs) and registered-or-TLD-tail resolution (registered forge.dev/context.index.build count for coverage while unregistered warpgogol.com/context.io are domains, not commands) — without them the gate produced ~230 false positives on the real workspace (RFC-1518 r1, deviation D-002).</item>
14
+ <item>The docs gate runs before the private/extractable skips so PKG-HEALTH-12 dead references judge every package's docs (dead refs are package-local), while PKG-HEALTH-11 coverage stays scoped to published packages — private packages (werkstatt-site's ~500-command surface) document commands in site-facing docs outside DOCS_SURFACE, and the manifest merge preserves manifest module provenance when registry entries omit module (RFC-1518 r1, deviation D-003).</item>
15
+ <item>Module attribution is provider-aware: deriveModulePackageMap returns separate workshop/site maps because module names collide across buckets (deploy is engine() AND sitePlugin()), and each command resolves through the map matching its manifest siteScope — a flat last-write-wins map silently misattributed the engine deploy.* family to the private site package (RFC-1518 r2, deviation D-004).</item>
16
+ </KEY_DECISIONS>
9
17
  <CHANGE_SUMMARY>
10
- <item>PKG-HEALTH-05: reject any versionBump in extract.config.yaml — version in package.json is source of truth.</item>
11
- <item>RFC-1254: PKG-HEALTH-06 lint-surface probe — extractable packages run `pnpm --dir <projectDir> run lint` (eslint fallback), per-package pass/fail, error-severity violation</item>
12
- <item>RFC-1254: retune PKG-HEALTH-02 — repo-extract generates ci.yml from the config `ci:` provider block, so the check now flags only extractable packages whose exported repo would ship no CI (no ci: provider AND no in-package workflow)</item>
13
- <item>RFC-1255: PKG-HEALTH-07 generated-CI script contract (build/lint/typecheck/test), PKG-HEALTH-08 repository.url vs git.remote for provenance publish, PKG-HEALTH-09 files[] src-reachability coverage; "extractable": false opt-out suppresses all extract-dependent checks</item>
14
- <history>RFC-1097</history>
18
+ <item>RFC-1518: docs-drift gate PKG-HEALTH-11/12 in forge.package.health
19
+
20
+ Live-inventory docs gate: PKG-HEALTH-11 flags registered commands absent
21
+ from the package DOCS_SURFACE, PKG-HEALTH-12 flags dead x.y doc tokens.
22
+ loadCommandInventory unions the runtime registry with the generated
23
+ command manifest (getLiveCommands precedent); namespace + TLD-tail
24
+ resolution keep property paths and domains silent. Same-line
25
+ pkg-health-11/12 markers journal intentional exceptions.
26
+
27
+ Audit diff to land green: canonical forge.* names in forge docs,
28
+ leitstand.access.* expansions, registered-surface listings for
29
+ projektarchiv-operations/werkstatt-journal/werkstatt-engine, and 100+
30
+ journaled suppressions for code paths, family prefixes, and the planned
31
+ werkstatt-knowledge CLI surface.</item>
32
+ <item>RFC-1518: attribution merge, private-package docs gate, suppression journal</item>
33
+ <item>RFC-1518: key decision for private-package docs-gate scope</item>
34
+ <item>RFC-1518: provider-aware module attribution, per-rule markers, tld-tail scoping</item>
35
+ <item>RFC-1518: key decision for provider-aware attribution</item>
36
+ <history>PKG-HEALTH-05, RFC-1097, RFC-1254, RFC-1255, RFC-1517</history>
15
37
  </CHANGE_SUMMARY>
16
38
  */
17
39
 
18
40
  import * as fs from "../../../src/utils/sync-fs.ts";
19
41
  import path from "node:path";
42
+ import { parse as parseYaml } from "yaml";
20
43
  import type {
21
44
  ForgeCommandInput,
22
45
  ForgeCommandResult,
@@ -38,6 +61,8 @@ export interface PackageHealthResult {
38
61
  violations: PackageHealthViolation[];
39
62
  passed: boolean;
40
63
  lintSurface: Record<string, "pass" | "fail">;
64
+ /** RFC-1518: journaled docs-gate suppressions (file:line + reason). */
65
+ suppressions?: DocsSuppression[];
41
66
  }
42
67
 
43
68
  export interface LintProbeOutcome {
@@ -45,6 +70,481 @@ export interface LintProbeOutcome {
45
70
  detail: string;
46
71
  }
47
72
 
73
+ // RFC-1517: one `../` chain literal escaping the package root — the F-0064
74
+ // defect class that only surfaced post-extract as ENOENT.
75
+ export interface FixtureEscape {
76
+ /** Shipped file, relative to the scanned package root (as passed in). */
77
+ file: string;
78
+ line: number;
79
+ /** The offending `../` chain literal as written. */
80
+ literal: string;
81
+ /** Absolute resolution showing the escape. */
82
+ resolvedTo: string;
83
+ }
84
+
85
+ /**
86
+ * The shipped-set + suppression view of one extract.config.yaml. Mirrors
87
+ * repo-extract's copy filter exactly: `isKeyMaterial` defaults
88
+ * `excludePathSegments` to the signing-key guards when the key is ABSENT, and
89
+ * `isDbFile` defaults `excludeExtensions` to `[".db"]`. `monorepoMode`
90
+ * distinguishes copyFiltered (non-standalone exports additionally drop
91
+ * BASE_IGNORE_DIRS/IGNORE_FILES) from copyStandalonePackage — the same
92
+ * `standalone || projectDir startsWith "packages/"` predicate extract.js
93
+ * applies.
94
+ */
95
+ export interface HealthScanConfig {
96
+ ignoreDirs: Set<string>;
97
+ excludeSegments: string[];
98
+ excludeExtensions: string[];
99
+ /** `pkgHealth10Suppressions:` — package-relative paths skipped by the scan. */
100
+ suppressions: Set<string>;
101
+ /** False for standalone exports — copyFiltered's extra ignore sets apply. */
102
+ monorepoMode: boolean;
103
+ }
104
+
105
+ const DEFAULT_KEY_SEGMENTS = [".input/signing-key", ".input/batches"];
106
+ const BASE_IGNORE_DIRS = new Set(["node_modules", ".turbo", "dist", ".env", ".DS_Store", "Thumbs.db"]);
107
+ const IGNORE_FILES = new Set([
108
+ ".env",
109
+ ".env.local",
110
+ ".env.production",
111
+ ".env.production.local",
112
+ "pnpm-lock.yaml",
113
+ "package-lock.json",
114
+ "yarn.lock",
115
+ "changelog.config.yaml",
116
+ ]);
117
+
118
+ /** Parse the scan-relevant keys of one extract.config.yaml (real YAML — comments and flow style included). */
119
+ export function parseHealthScanConfig(configRaw: string | null): HealthScanConfig {
120
+ let parsed: Record<string, unknown> = {};
121
+ if (configRaw !== null) {
122
+ try {
123
+ const doc = parseYaml(configRaw) as unknown;
124
+ if (doc !== null && typeof doc === "object") parsed = doc as Record<string, unknown>;
125
+ } catch {
126
+ // An unparseable config fails repo-extract itself — scan with defaults.
127
+ parsed = {};
128
+ }
129
+ }
130
+ const strList = (key: string): string[] | undefined => {
131
+ const v = parsed[key];
132
+ return Array.isArray(v) ? v.filter((e): e is string => typeof e === "string") : undefined;
133
+ };
134
+ const projectDir = typeof parsed["projectDir"] === "string" ? parsed["projectDir"] : "";
135
+ const standalone = parsed["standalone"] === true || projectDir.startsWith("packages/");
136
+ return {
137
+ ignoreDirs: new Set([
138
+ ...(standalone ? ["node_modules", ".turbo"] : [...BASE_IGNORE_DIRS]),
139
+ ...(strList("ignoreDirs") ?? []),
140
+ ]),
141
+ excludeSegments: strList("excludePathSegments") ?? DEFAULT_KEY_SEGMENTS,
142
+ excludeExtensions: strList("excludeExtensions") ?? [".db"],
143
+ suppressions: new Set(strList("pkgHealth10Suppressions") ?? []),
144
+ monorepoMode: !standalone,
145
+ };
146
+ }
147
+
148
+ // String-literal-aware mode for TS-family sources; other extensions get the
149
+ // raw `../` chain scan (bounded by root-escape resolution, escaped by the
150
+ // same-line `pkg-health-10:` suppression comment).
151
+ const TS_FAMILY_RE = /\.(?:ts|mts|tsx|cts)$/;
152
+ // Doc files carry `../` only as prose links — never resolved, always noise.
153
+ const DOC_FILE_RE = /\.(?:md|markdown|mdx|txt|adoc|rst)$/i;
154
+ // Binary/generated bytes produce UTF-8 noise (and .map sources arrays) —
155
+ // skipped like git grep -I's binary exclusion.
156
+ const BINARY_FILE_RE =
157
+ /\.(?:png|jpe?g|gif|webp|ico|icns|woff2?|ttf|otf|eot|zip|gz|tgz|bz2|xz|7z|wasm|pdf|mp[34]|webm|mov|map|db|sqlite)$/i;
158
+ const QUOTED_PARENT_RE = /["'`]([^"'`\n]*(?:\.\.\/)+[^"'`\n]*)["'`]/g;
159
+ const RAW_PARENT_RE = /(?:\.\.\/)+[^\s"'`)\],;:}]*/g;
160
+ const SUPPRESS_RE = /pkg-health-10:/;
161
+
162
+ /** File extensions the fixture scan judges (docs and binaries are excluded). */
163
+ export function fixtureScanSkipped(file: string): boolean {
164
+ return DOC_FILE_RE.test(file) || BINARY_FILE_RE.test(file);
165
+ }
166
+
167
+ /**
168
+ * The single `../` literal matcher shared by the working-tree scan and the
169
+ * publish at-ref scan — apply the per-extension mode to one source line and
170
+ * report every literal resolving outside `rootAbs`. Same-line
171
+ * `pkg-health-10:` suppression only (JSON and fixture templates cannot carry
172
+ * comments — those go through the config suppressions list instead).
173
+ */
174
+ export function literalEscapesInLine(
175
+ file: string,
176
+ text: string,
177
+ lineNo: number,
178
+ fileDirAbs: string,
179
+ rootAbs: string,
180
+ ): FixtureEscape[] {
181
+ if (SUPPRESS_RE.test(text)) return [];
182
+ const re = TS_FAMILY_RE.test(file) ? QUOTED_PARENT_RE : RAW_PARENT_RE;
183
+ const out: FixtureEscape[] = [];
184
+ for (const m of text.matchAll(re)) {
185
+ const literal = m[1] ?? m[0];
186
+ if (!literal.includes("../")) continue;
187
+ const resolvedTo = path.resolve(fileDirAbs, literal);
188
+ if (resolvedTo !== rootAbs && !resolvedTo.startsWith(rootAbs + path.sep)) {
189
+ out.push({ file, line: lineNo, literal, resolvedTo });
190
+ }
191
+ }
192
+ return out;
193
+ }
194
+
195
+ /**
196
+ * Scan shipped files for `../` path literals that resolve outside
197
+ * `packageRoot` — the fixture-path defect class that passed monorepo suites
198
+ * and ENOENT'd only inside the standalone extract (F-0064). `shippedFiles`
199
+ * are package-root-relative paths on disk; `suppressions` (from
200
+ * `pkgHealth10Suppressions` in extract.config.yaml) skips files that cannot
201
+ * carry an in-source comment. Shared by PKG-HEALTH-10 and the publish
202
+ * `preflight-extract-gates` step so both report the same escapes.
203
+ */
204
+ export function scanFixturePathEscapes(
205
+ packageRoot: string,
206
+ shippedFiles: string[],
207
+ suppressions?: ReadonlySet<string>,
208
+ ): FixtureEscape[] {
209
+ const root = path.resolve(packageRoot);
210
+ const escapes: FixtureEscape[] = [];
211
+ for (const file of shippedFiles) {
212
+ if (suppressions?.has(file) || fixtureScanSkipped(file)) continue;
213
+ const abs = path.join(root, file);
214
+ let source: string;
215
+ try {
216
+ source = fs.readFileSync(abs, "utf8");
217
+ } catch {
218
+ continue;
219
+ }
220
+ const lines = source.split("\n");
221
+ for (let i = 0; i < lines.length; i++) {
222
+ escapes.push(...literalEscapesInLine(file, lines[i]!, i + 1, path.dirname(abs), root));
223
+ }
224
+ }
225
+ return escapes.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line);
226
+ }
227
+
228
+ // RFC-1518 CHECKS 11/12: the package's declared docs surface diffed against
229
+ // the live command inventory — PKG-HEALTH-11 covers registered-but-undocumented
230
+ // commands, PKG-HEALTH-12 covers doc tokens resolving to no registered command
231
+ // (the REMEDIATION-04 dead-token class applied to authored reference docs).
232
+ export const DOCS_SURFACE = ["docs/**/*.md", "README.md", "AGENTS.md"] as const;
233
+ export const DOCS_SURFACE_EXCLUDES = [
234
+ "docs/audits/archive/**",
235
+ "**/CHANGELOG.md",
236
+ "**/*.generated.md",
237
+ ] as const;
238
+ const DOCS_SURFACE_EXCLUDE_RES = [
239
+ /(^|\/)docs\/audits\/archive\//,
240
+ /(^|\/)CHANGELOG\.md$/,
241
+ /\.generated\.md$/,
242
+ ];
243
+
244
+ // A command token is x.y-shaped with every segment starting with a letter —
245
+ // numeric segments (versions like 9.1.0) and uppercase names (AGENTS.md)
246
+ // never qualify. Tokens ending in a file extension or common TLD are config
247
+ // paths or domains, not command mentions (known non-command dotted paths).
248
+ const DOC_TOKEN_RE = /\b([a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+)\b/g;
249
+ // File-extension tails — applied unconditionally (a command never ends in one).
250
+ const DOC_REF_EXT_RE =
251
+ /\.(?:ts|mts|cts|js|mjs|cjs|jsx|tsx|json|ya?ml|toml|md|mdx|markdown|astro|css|scss|less|html|xml|svg|png|jpe?g|gif|webp|ico|icns|woff2?|ttf|otf|eot|zip|gz|tgz|bz2|xz|7z|wasm|pdf|mp[34]|webm|mov|map|db|sqlite3?|lock|sh|bash|zsh|fish|py|rb|go|rs|java|kt|cs|php|pl|lua|sql|csv|tsv|txt|log|env|ini|cfg|conf|d.ts|editorconfig|gitignore|npmrc|dockerfile|jsonl|hex|pem)$/i;
252
+ // TLD-shaped tails (domains, not commands) — fallback heuristic only when no
253
+ // live inventory is available; registered namespaces can end in one
254
+ // (forge.dev, forge.build would otherwise be filtered out).
255
+ const DOC_TLD_TAIL_RE =
256
+ /\.(?:com|org|net|io|dev|ai|app|de|uk|eu|co|me|cloud|site|xyz|build|systems|watch|pro|info|gg|wtf|zone|land|run)$/i;
257
+ const DOC_SUPPRESS_11_RE = /pkg-health-11(?:\s*\|\s*pkg-health-12)?:\s*([^\n]*?)\s*(?:-->\s*)?$/;
258
+ const DOC_SUPPRESS_12_RE = /(?:pkg-health-11\s*\|\s*)?pkg-health-12:\s*([^\n]*?)\s*(?:-->\s*)?$/;
259
+
260
+ export interface DocsSuppression {
261
+ ruleId: "PKG-HEALTH-11" | "PKG-HEALTH-12";
262
+ /** Owning package name — suppressions aggregate across the whole workspace. */
263
+ packageName?: string;
264
+ file: string;
265
+ line: number;
266
+ token: string;
267
+ reason: string;
268
+ }
269
+
270
+ interface DocsSurfaceScan {
271
+ /** All command-shaped tokens on unsuppressed surface lines. */
272
+ documented: Set<string>;
273
+ /** Tokens exempted from coverage by a same-line pkg-health-11 marker. */
274
+ suppressed11: Map<string, DocsSuppression>;
275
+ /** Dead-reference candidates: token → first file:line sighting. */
276
+ refs: Map<string, { file: string; line: number }>;
277
+ suppressions: DocsSuppression[];
278
+ }
279
+
280
+ /** Collect the package's DOCS_SURFACE files — docs trees, README, AGENTS — minus the fixed excludes. */
281
+ export function collectDocsSurfaceFiles(pkgDir: string): string[] {
282
+ const files: string[] = [];
283
+ const docsDir = path.join(pkgDir, "docs");
284
+ const walk = (dir: string): void => {
285
+ let entries: fs.Dirent[];
286
+ try {
287
+ entries = fs.readdirSync(dir, { withFileTypes: true });
288
+ } catch {
289
+ return;
290
+ }
291
+ for (const e of entries) {
292
+ const abs = path.join(dir, e.name);
293
+ if (e.isDirectory()) walk(abs);
294
+ else if (e.isFile() && e.name.endsWith(".md")) files.push(abs);
295
+ }
296
+ };
297
+ if (fs.existsSync(docsDir)) walk(docsDir);
298
+ for (const top of ["README.md", "AGENTS.md"]) {
299
+ const abs = path.join(pkgDir, top);
300
+ if (fs.existsSync(abs)) files.push(abs);
301
+ }
302
+ return files
303
+ .filter((f) => {
304
+ const rel = path.relative(pkgDir, f).split(path.sep).join("/");
305
+ return !DOCS_SURFACE_EXCLUDE_RES.some((re) => re.test(rel));
306
+ })
307
+ .sort();
308
+ }
309
+
310
+ /**
311
+ * Scan one package's docs surface: build the documented-token set, the
312
+ * pkg-health-11 exemption set, and the dead-reference candidates (tokens on
313
+ * unsuppressed lines). pkg-health-12 markers exempt their whole line.
314
+ */
315
+ export function scanDocsSurface(
316
+ pkgDir: string,
317
+ files: string[],
318
+ commandNamespaces?: ReadonlySet<string>,
319
+ registeredCommands?: ReadonlySet<string>,
320
+ ): DocsSurfaceScan {
321
+ const documented = new Set<string>();
322
+ const suppressed11 = new Map<string, DocsSuppression>();
323
+ const refs = new Map<string, { file: string; line: number }>();
324
+ const suppressions: DocsSuppression[] = [];
325
+ for (const abs of files) {
326
+ const rel = path.relative(pkgDir, abs).split(path.sep).join("/");
327
+ let source: string;
328
+ try {
329
+ source = fs.readFileSync(abs, "utf8");
330
+ } catch {
331
+ continue;
332
+ }
333
+ const lines = source.split("\n");
334
+ for (let i = 0; i < lines.length; i++) {
335
+ const line = lines[i]!;
336
+ const tokens = [...line.matchAll(DOC_TOKEN_RE)]
337
+ .map((m) => m[1]!)
338
+ .filter((t) => !DOC_REF_EXT_RE.test(t))
339
+ .filter((t) => {
340
+ if (!commandNamespaces) return !DOC_TLD_TAIL_RE.test(t);
341
+ // A token whose first segment is no registered command namespace is
342
+ // a property path (import.meta.url), config key (bindings.commands),
343
+ // or prose — never a command reference.
344
+ return commandNamespaces.has(t.split(".", 1)[0]!);
345
+ })
346
+ // Registered commands always count (forge.dev, context.index.build).
347
+ // Unregistered tokens ending in a TLD tail are domains (warpgogol.com)
348
+ // or TLD-shaped property paths (context.io) — never command refs.
349
+ // Registered commands always count (forge.dev, context.index.build).
350
+ // Unregistered TWO-segment tokens ending in a TLD tail are domains
351
+ // (warpgogol.com) or TLD-shaped property paths (context.io); a 3+
352
+ // segment token under a registered namespace (deploy.smoke.run after
353
+ // removal) stays a dead-reference candidate — never TLD-exempt.
354
+ .filter((t) => !registeredCommands || registeredCommands.has(t) || t.split(".").length > 2 || !DOC_TLD_TAIL_RE.test(t));
355
+ const s11 = line.match(DOC_SUPPRESS_11_RE);
356
+ const s12 = line.match(DOC_SUPPRESS_12_RE);
357
+ // A marker with an empty reason does not suppress — an exemption needs
358
+ // a justification. Both markers are evaluated: a line may carry an 11
359
+ // and a 12 marker (or the combined pkg-health-11|pkg-health-12 form).
360
+ const reason = (m: RegExpMatchArray | null) => (m?.[1] ?? "").replace(/-->\s*$/, "").trim();
361
+ const m11 = s11 ? reason(s11) || null : null;
362
+ const m12 = s12 ? reason(s12) || null : null;
363
+ for (const token of tokens) {
364
+ if (m11) {
365
+ const entry = { ruleId: "PKG-HEALTH-11" as const, file: rel, line: i + 1, token, reason: m11 };
366
+ suppressed11.set(token, entry);
367
+ suppressions.push(entry);
368
+ } else {
369
+ documented.add(token);
370
+ }
371
+ if (m12) {
372
+ suppressions.push({ ruleId: "PKG-HEALTH-12", file: rel, line: i + 1, token, reason: m12 });
373
+ documented.add(token);
374
+ } else if (!refs.has(token)) {
375
+ refs.set(token, { file: rel, line: i + 1 });
376
+ }
377
+ }
378
+ }
379
+ }
380
+ return { documented, suppressed11, refs, suppressions };
381
+ }
382
+
383
+ /**
384
+ * Map kernel module names → owning package dir — the same module enumeration
385
+ * the workspace registry (and command.manifest.generate) was built from:
386
+ * tools/kernel.config.ts inline loaders plus the WORKSHOP_MODULE_MAP buckets
387
+ * in werkstatt-engine's module-map.ts. Never a hand-maintained list.
388
+ * Returns separate workshop/site maps — module names can collide across
389
+ * buckets (deploy is both engine() and sitePlugin()) and commands attribute
390
+ * through the map matching their siteScope.
391
+ */
392
+ export function deriveModulePackageMap(workspaceRoot: string): { workshop: Map<string, string>; site: Map<string, string> } {
393
+ const out = new Map<string, string>();
394
+ const site = new Map<string, string>();
395
+ const mmPath = path.join(workspaceRoot, "packages", "werkstatt-engine", "src", "kernel", "module-map.ts");
396
+ try {
397
+ const mm = fs.readFileSync(mmPath, "utf8");
398
+ const bucketToConst: Record<string, string> = { engine: "ENGINE", sitePlugin: "SITE", forge: "FORGE" };
399
+ const constToSpec: Record<string, string> = {};
400
+ for (const m of mm.matchAll(/const (\w+) = "(@warpgogol\/[^"]+)"/g)) constToSpec[m[1]!] = m[2]!;
401
+ for (const m of mm.matchAll(/["']?([\w-]+)["']?:\s*(engine|sitePlugin|forge)\(/g)) {
402
+ const spec = constToSpec[bucketToConst[m[2]!]!];
403
+ // Module names can collide across buckets (deploy: engine + sitePlugin) —
404
+ // keep the maps separate so siteScope commands resolve via SITE only.
405
+ if (spec) (m[2] === "sitePlugin" ? site : out).set(m[1]!, `packages/${spec.split("/")[1]}`);
406
+ }
407
+ } catch {
408
+ // module-map absent — inline loaders still map
409
+ }
410
+ const kcPath = path.join(workspaceRoot, "tools", "kernel.config.ts");
411
+ try {
412
+ const kc = fs.readFileSync(kcPath, "utf8");
413
+ for (const m of kc.matchAll(/["']?(\w[\w-]*)["']?:\s*async[^=]*=>[^;]*?import\("(@warpgogol\/[^"]+)"/g)) {
414
+ out.set(m[1]!, `packages/${m[2]!.split("/")[1]}`);
415
+ }
416
+ } catch {
417
+ // no kernel config — inventory attribution is empty
418
+ }
419
+ return { workshop: out, site };
420
+ }
421
+
422
+ /**
423
+ * The live command inventory: context.commandRegistry (the same enumeration
424
+ * command.manifest.generate consumes) UNION docs/command-manifest.generated.yaml
425
+ * — the getLiveCommands merge pattern from os/rfc/handlers/lifecycle.ts.
426
+ * Registry entries win on collision; the manifest covers commands whose modules
427
+ * are not loaded in the current dispatch (werkstatt run injects no registry;
428
+ * site-scope modules live outside the forge registry).
429
+ */
430
+ export function loadCommandInventory(
431
+ workspaceRoot: string,
432
+ commandRegistry?: { listCommands(): Array<{ name: string; module?: string; siteScope?: boolean }> },
433
+ ): Array<{ name: string; module?: string; siteScope?: boolean }> {
434
+ const byName = new Map<string, { name: string; module?: string; siteScope?: boolean }>();
435
+ const manifestPath = path.join(workspaceRoot, "docs", "command-manifest.generated.yaml");
436
+ try {
437
+ const raw = fs.readFileSync(manifestPath, "utf8");
438
+ const parsed = parseYaml(raw) as {
439
+ commands?: Array<{ name?: unknown; module?: unknown; siteScope?: unknown; providers?: unknown }>;
440
+ } | null;
441
+ for (const c of parsed?.commands ?? []) {
442
+ if (typeof c.name === "string" && c.name.length > 0) {
443
+ byName.set(c.name, {
444
+ name: c.name,
445
+ module: typeof c.module === "string" ? c.module : undefined,
446
+ siteScope:
447
+ typeof c.siteScope === "boolean"
448
+ ? c.siteScope
449
+ : Array.isArray(c.providers) && c.providers.includes("site-module")
450
+ ? true
451
+ : undefined,
452
+ });
453
+ }
454
+ }
455
+ } catch {
456
+ // manifest absent or unparsable — registry-only inventory
457
+ }
458
+ for (const c of commandRegistry?.listCommands() ?? []) {
459
+ // Merge, don't overwrite: ForgeCliRegistry entries carry no `module`, so a
460
+ // bare set() would erase the manifest's provenance under the standalone CLI.
461
+ const prev = byName.get(c.name);
462
+ byName.set(c.name, {
463
+ name: c.name,
464
+ module: c.module ?? prev?.module,
465
+ siteScope: c.siteScope ?? prev?.siteScope,
466
+ });
467
+ }
468
+ return [...byName.values()];
469
+ }
470
+
471
+ /**
472
+ * Whether repo-extract's copy filter would ship one entry — shared by the
473
+ * working-tree walk (PKG-HEALTH-10) and the at-ref enumeration (publish
474
+ * preflight) so both judge the same set. `rel` is package-root-relative.
475
+ */
476
+ export function isShippedEntry(
477
+ rel: string,
478
+ name: string,
479
+ isDir: boolean,
480
+ cfg: HealthScanConfig,
481
+ ): boolean {
482
+ if (cfg.ignoreDirs.has(name)) return false;
483
+ if (isDir) return !cfg.excludeSegments.some((seg) => rel.includes(seg));
484
+ if (name.endsWith(".tsbuildinfo")) return false;
485
+ if (cfg.monorepoMode && IGNORE_FILES.has(name)) return false;
486
+ if (cfg.excludeSegments.some((seg) => rel.includes(seg))) return false;
487
+ if (cfg.excludeExtensions.some((ext) => name.endsWith(ext))) return false;
488
+ return true;
489
+ }
490
+
491
+ /**
492
+ * Derive the file set repo-extract will ship for a package — a walk of
493
+ * `projectRoot` honoring the same config keys the copy filters consume (see
494
+ * parseHealthScanConfig). Symlinks are followed through statSync like
495
+ * repo-extract's `cp` filter; a realpath-set bounds link cycles. Never a
496
+ * hand-maintained file list.
497
+ */
498
+ export function deriveShippedFiles(
499
+ projectRoot: string,
500
+ extractConfigRaw: string | null,
501
+ ): string[] {
502
+ const cfg = parseHealthScanConfig(extractConfigRaw);
503
+ const root = path.resolve(projectRoot);
504
+ const shipped: string[] = [];
505
+ const visited = new Set<string>();
506
+ const collect = (dir: string): void => {
507
+ let entries: fs.Dirent[];
508
+ try {
509
+ entries = fs.readdirSync(dir, { withFileTypes: true });
510
+ } catch {
511
+ return;
512
+ }
513
+ for (const e of entries) {
514
+ const abs = path.join(dir, e.name);
515
+ const rel = path.relative(root, abs).split(path.sep).join("/");
516
+ // Dirent.isFile()/isDirectory() are false for symlinks — repo-extract's
517
+ // cp stats through links, so the scan must as well.
518
+ let stats: fs.Stats | null = null;
519
+ if (e.isSymbolicLink()) {
520
+ try {
521
+ stats = fs.statSync(abs);
522
+ } catch {
523
+ stats = null;
524
+ }
525
+ }
526
+ const isDir = stats ? stats.isDirectory() : e.isDirectory();
527
+ const isFile = stats ? stats.isFile() : e.isFile();
528
+ if (!isShippedEntry(rel, e.name, isDir, cfg)) continue;
529
+ if (isDir) {
530
+ let real = abs;
531
+ try {
532
+ real = fs.realpathSync(abs);
533
+ } catch {
534
+ // keep the syntactic path
535
+ }
536
+ if (visited.has(real)) continue;
537
+ visited.add(real);
538
+ collect(abs);
539
+ } else if (isFile) {
540
+ shipped.push(rel);
541
+ }
542
+ }
543
+ };
544
+ collect(root);
545
+ return shipped.sort();
546
+ }
547
+
48
548
  function defaultLintRunner(projectDir: string, hasLintScript: boolean): LintProbeOutcome {
49
549
  const args = hasLintScript
50
550
  ? ["--dir", projectDir, "run", "lint"]
@@ -246,9 +746,30 @@ export async function runPackageHealth(
246
746
 
247
747
  const violations: PackageHealthViolation[] = [];
248
748
  const lintSurface: Record<string, "pass" | "fail"> = {};
749
+ const suppressions: DocsSuppression[] = [];
249
750
  let packagesChecked = 0;
250
751
 
251
- const entries = fs.readdirSync(packagesDir, { withFileTypes: true });
752
+ // RFC-1518 CHECKS 11/12 inputs — the live command inventory (registry
753
+ // union generated manifest, the getLiveCommands merge), attributed to
754
+ // owning packages through the kernel module enumeration.
755
+ const commandInfos = loadCommandInventory(workspaceRoot, context.commandRegistry);
756
+ const allCommands = new Set(commandInfos.map((c) => c.name));
757
+ const allNamespaces = new Set(commandInfos.map((c) => c.name.split(".", 1)[0]!));
758
+ const moduleToPkg = deriveModulePackageMap(workspaceRoot);
759
+ const pkgCommands = new Map<string, string[]>();
760
+ let attributed = 0;
761
+ for (const c of commandInfos) {
762
+ // Provider-aware attribution: a module name can exist in both the workshop
763
+ // and site buckets (deploy does), so siteScope commands resolve via the
764
+ // site map only — a last-write-wins flat map silently misattributes.
765
+ const map = c.siteScope === true ? moduleToPkg.site : moduleToPkg.workshop;
766
+ const pkg = c.module !== undefined ? map.get(c.module) : undefined;
767
+ if (pkg === undefined) continue;
768
+ attributed++;
769
+ (pkgCommands.get(pkg) ?? pkgCommands.set(pkg, []).get(pkg)!).push(c.name);
770
+ }
771
+
772
+ const entries = fs.readdirSync(packagesDir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
252
773
  for (const entry of entries) {
253
774
  if (!entry.isDirectory()) continue;
254
775
  if (entry.name.startsWith(".")) continue;
@@ -259,10 +780,54 @@ export async function runPackageHealth(
259
780
  if (!pkg) continue;
260
781
 
261
782
  const isPrivate = pkg["private"] === true;
783
+ const packageName = String(pkg["name"] ?? entry.name);
784
+
785
+ // RFC-1518 CHECKS 11/12: the package's declared docs surface diffed
786
+ // against the live command inventory (F-0073). Coverage counts a token
787
+ // documented anywhere on the surface; dead refs flag at doc:line. Runs
788
+ // for EVERY package with a package.json — docs drift is orthogonal to
789
+ // publishability, so private/extractable:false packages are scanned too.
790
+ if (commandInfos.length > 0) {
791
+ const rel = path.relative(workspaceRoot, pkgDir).split(path.sep).join("/");
792
+ const surfaceFiles = collectDocsSurfaceFiles(pkgDir);
793
+ const scan = scanDocsSurface(pkgDir, surfaceFiles, allNamespaces, allCommands);
794
+ suppressions.push(...scan.suppressions.map((s) => ({ ...s, packageName })));
795
+ const expectedDoc = fs.existsSync(path.join(pkgDir, "docs", "reference", "cli.md"))
796
+ ? "docs/reference/cli.md"
797
+ : "README.md";
798
+ // Coverage applies to published packages — the command's stated contract.
799
+ // Private packages (site plugin, lifecycle core) document their command
800
+ // surfaces in site-facing docs outside this audit; their dead refs still
801
+ // flag via PKG-HEALTH-12 (deviation D-003).
802
+ for (const cmd of isPrivate ? [] : (pkgCommands.get(rel) ?? [])) {
803
+ if (!scan.documented.has(cmd) && !scan.suppressed11.has(cmd)) {
804
+ violations.push({
805
+ ruleId: "PKG-HEALTH-11",
806
+ packageName,
807
+ severity: "error",
808
+ message: `registered command "${cmd}" appears in no docs-surface file — document it in ${expectedDoc}`,
809
+ file: pkgDir,
810
+ fixHint: `Add a "${cmd}" reference to ${expectedDoc}, or journal a same-line "<!-- pkg-health-11: <reason> -->" exemption.`,
811
+ });
812
+ }
813
+ }
814
+ for (const [token, at] of [...scan.refs.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {
815
+ if (!allCommands.has(token)) {
816
+ violations.push({
817
+ ruleId: "PKG-HEALTH-12",
818
+ packageName,
819
+ severity: "error",
820
+ message: `${at.file}:${at.line} references "${token}" — no such registered command`,
821
+ file: path.join(pkgDir, at.file),
822
+ fixHint: `Fix the reference to a registered command, or journal a same-line "<!-- pkg-health-12: <reason> -->" exemption.`,
823
+ });
824
+ }
825
+ }
826
+ }
827
+
262
828
  if (isPrivate) continue;
263
829
 
264
830
  packagesChecked++;
265
- const packageName = String(pkg["name"] ?? entry.name);
266
831
 
267
832
  // CHECK 1: engines.node exists and matches root
268
833
  const pkgEngines = pkg["engines"] as Record<string, string> | undefined;
@@ -454,9 +1019,60 @@ export async function runPackageHealth(
454
1019
  });
455
1020
  }
456
1021
  }
1022
+
1023
+ // RFC-1517 CHECK 10: a `../` literal in a shipped file that resolves
1024
+ // outside the package root passes the monorepo suite and ENOENTs only
1025
+ // inside the standalone extract (F-0064). Same scan the publish
1026
+ // preflight runs — the defect surfaces here on routine health runs.
1027
+ const healthProjectDir = projectDirMatch
1028
+ ? path.resolve(workspaceRoot, projectDirMatch[1])
1029
+ : pkgDir;
1030
+ const healthScanCfg = parseHealthScanConfig(extractConfigRaw);
1031
+ for (const esc of scanFixturePathEscapes(
1032
+ healthProjectDir,
1033
+ deriveShippedFiles(healthProjectDir, extractConfigRaw),
1034
+ healthScanCfg.suppressions,
1035
+ )) {
1036
+ violations.push({
1037
+ ruleId: "PKG-HEALTH-10",
1038
+ packageName,
1039
+ severity: "error",
1040
+ message: `${esc.file}:${esc.line} path literal "${esc.literal}" resolves outside the package root (${esc.resolvedTo}) — the standalone extract will ENOENT.`,
1041
+ file: path.join(healthProjectDir, esc.file),
1042
+ fixHint:
1043
+ 'Rebind the reference to a path inside the package root, mark a justified non-path use with a same-line "// pkg-health-10: <reason>" comment, or list the file in pkgHealth10Suppressions in extract.config.yaml.',
1044
+ });
1045
+ }
457
1046
  }
458
1047
  }
459
1048
 
1049
+ suppressions.sort(
1050
+ (a, b) => (a.packageName ?? "").localeCompare(b.packageName ?? "") || a.file.localeCompare(b.file) || a.line - b.line,
1051
+ );
1052
+ if (packagesChecked > 0 && commandInfos.length === 0) {
1053
+ violations.push({
1054
+ ruleId: "PKG-HEALTH-12",
1055
+ packageName: "(workspace)",
1056
+ severity: "warning",
1057
+ message:
1058
+ "no command inventory available — docs-drift gate skipped (context.commandRegistry unset and docs/command-manifest.generated.yaml absent or unparsable)",
1059
+ file: workspaceRoot,
1060
+ fixHint: "Run `werkstatt run command.manifest.generate`, or dispatch through a host that injects commandRegistry.",
1061
+ });
1062
+ } else if (packagesChecked > 0 && commandInfos.length > 0 && attributed === 0) {
1063
+ // Inventory exists but no command resolved to a package — module→package
1064
+ // attribution is unavailable (e.g. a consumer workshop without the
1065
+ // werkstatt-engine module-map) and PKG-HEALTH-11 would silently inert.
1066
+ violations.push({
1067
+ ruleId: "PKG-HEALTH-12",
1068
+ packageName: "(workspace)",
1069
+ severity: "warning",
1070
+ message: `${commandInfos.length} inventoried command(s) resolved to no package — module attribution unavailable, PKG-HEALTH-11 coverage skipped`,
1071
+ file: workspaceRoot,
1072
+ fixHint: "Check that packages/werkstatt-engine/src/kernel/module-map.ts or tools/kernel.config.ts declares the command modules.",
1073
+ });
1074
+ }
1075
+
460
1076
  const errors = violations.filter((v) => v.severity === "error");
461
1077
  const warnings = violations.filter((v) => v.severity === "warning");
462
1078
  const passed = errors.length === 0;
@@ -489,6 +1105,11 @@ export async function runPackageHealth(
489
1105
  `forge.package.health: ${parts.join(", ")} across ${packagesChecked} package(s).`,
490
1106
  );
491
1107
  }
1108
+ if (suppressions.length > 0) {
1109
+ logger.info(
1110
+ `forge.package.health: ${suppressions.length} docs-gate suppression(s) journaled (see data.suppressions for file:line + reason).`,
1111
+ );
1112
+ }
492
1113
  }
493
1114
  }
494
1115
 
@@ -499,6 +1120,7 @@ export async function runPackageHealth(
499
1120
  violations,
500
1121
  passed,
501
1122
  lintSurface,
1123
+ suppressions,
502
1124
  },
503
1125
  exitCode: passed ? 0 : 1,
504
1126
  summary: passed