@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,16 +6,448 @@
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
  import * as fs from "../../../src/utils/sync-fs.js";
18
40
  import path from "node:path";
41
+ import { parse as parseYaml } from "yaml";
42
+ const DEFAULT_KEY_SEGMENTS = [".input/signing-key", ".input/batches"];
43
+ const BASE_IGNORE_DIRS = new Set(["node_modules", ".turbo", "dist", ".env", ".DS_Store", "Thumbs.db"]);
44
+ const IGNORE_FILES = new Set([
45
+ ".env",
46
+ ".env.local",
47
+ ".env.production",
48
+ ".env.production.local",
49
+ "pnpm-lock.yaml",
50
+ "package-lock.json",
51
+ "yarn.lock",
52
+ "changelog.config.yaml",
53
+ ]);
54
+ /** Parse the scan-relevant keys of one extract.config.yaml (real YAML — comments and flow style included). */
55
+ export function parseHealthScanConfig(configRaw) {
56
+ let parsed = {};
57
+ if (configRaw !== null) {
58
+ try {
59
+ const doc = parseYaml(configRaw);
60
+ if (doc !== null && typeof doc === "object")
61
+ parsed = doc;
62
+ }
63
+ catch {
64
+ // An unparseable config fails repo-extract itself — scan with defaults.
65
+ parsed = {};
66
+ }
67
+ }
68
+ const strList = (key) => {
69
+ const v = parsed[key];
70
+ return Array.isArray(v) ? v.filter((e) => typeof e === "string") : undefined;
71
+ };
72
+ const projectDir = typeof parsed["projectDir"] === "string" ? parsed["projectDir"] : "";
73
+ const standalone = parsed["standalone"] === true || projectDir.startsWith("packages/");
74
+ return {
75
+ ignoreDirs: new Set([
76
+ ...(standalone ? ["node_modules", ".turbo"] : [...BASE_IGNORE_DIRS]),
77
+ ...(strList("ignoreDirs") ?? []),
78
+ ]),
79
+ excludeSegments: strList("excludePathSegments") ?? DEFAULT_KEY_SEGMENTS,
80
+ excludeExtensions: strList("excludeExtensions") ?? [".db"],
81
+ suppressions: new Set(strList("pkgHealth10Suppressions") ?? []),
82
+ monorepoMode: !standalone,
83
+ };
84
+ }
85
+ // String-literal-aware mode for TS-family sources; other extensions get the
86
+ // raw `../` chain scan (bounded by root-escape resolution, escaped by the
87
+ // same-line `pkg-health-10:` suppression comment).
88
+ const TS_FAMILY_RE = /\.(?:ts|mts|tsx|cts)$/;
89
+ // Doc files carry `../` only as prose links — never resolved, always noise.
90
+ const DOC_FILE_RE = /\.(?:md|markdown|mdx|txt|adoc|rst)$/i;
91
+ // Binary/generated bytes produce UTF-8 noise (and .map sources arrays) —
92
+ // skipped like git grep -I's binary exclusion.
93
+ const BINARY_FILE_RE = /\.(?: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;
94
+ const QUOTED_PARENT_RE = /["'`]([^"'`\n]*(?:\.\.\/)+[^"'`\n]*)["'`]/g;
95
+ const RAW_PARENT_RE = /(?:\.\.\/)+[^\s"'`)\],;:}]*/g;
96
+ const SUPPRESS_RE = /pkg-health-10:/;
97
+ /** File extensions the fixture scan judges (docs and binaries are excluded). */
98
+ export function fixtureScanSkipped(file) {
99
+ return DOC_FILE_RE.test(file) || BINARY_FILE_RE.test(file);
100
+ }
101
+ /**
102
+ * The single `../` literal matcher shared by the working-tree scan and the
103
+ * publish at-ref scan — apply the per-extension mode to one source line and
104
+ * report every literal resolving outside `rootAbs`. Same-line
105
+ * `pkg-health-10:` suppression only (JSON and fixture templates cannot carry
106
+ * comments — those go through the config suppressions list instead).
107
+ */
108
+ export function literalEscapesInLine(file, text, lineNo, fileDirAbs, rootAbs) {
109
+ if (SUPPRESS_RE.test(text))
110
+ return [];
111
+ const re = TS_FAMILY_RE.test(file) ? QUOTED_PARENT_RE : RAW_PARENT_RE;
112
+ const out = [];
113
+ for (const m of text.matchAll(re)) {
114
+ const literal = m[1] ?? m[0];
115
+ if (!literal.includes("../"))
116
+ continue;
117
+ const resolvedTo = path.resolve(fileDirAbs, literal);
118
+ if (resolvedTo !== rootAbs && !resolvedTo.startsWith(rootAbs + path.sep)) {
119
+ out.push({ file, line: lineNo, literal, resolvedTo });
120
+ }
121
+ }
122
+ return out;
123
+ }
124
+ /**
125
+ * Scan shipped files for `../` path literals that resolve outside
126
+ * `packageRoot` — the fixture-path defect class that passed monorepo suites
127
+ * and ENOENT'd only inside the standalone extract (F-0064). `shippedFiles`
128
+ * are package-root-relative paths on disk; `suppressions` (from
129
+ * `pkgHealth10Suppressions` in extract.config.yaml) skips files that cannot
130
+ * carry an in-source comment. Shared by PKG-HEALTH-10 and the publish
131
+ * `preflight-extract-gates` step so both report the same escapes.
132
+ */
133
+ export function scanFixturePathEscapes(packageRoot, shippedFiles, suppressions) {
134
+ const root = path.resolve(packageRoot);
135
+ const escapes = [];
136
+ for (const file of shippedFiles) {
137
+ if (suppressions?.has(file) || fixtureScanSkipped(file))
138
+ continue;
139
+ const abs = path.join(root, file);
140
+ let source;
141
+ try {
142
+ source = fs.readFileSync(abs, "utf8");
143
+ }
144
+ catch {
145
+ continue;
146
+ }
147
+ const lines = source.split("\n");
148
+ for (let i = 0; i < lines.length; i++) {
149
+ escapes.push(...literalEscapesInLine(file, lines[i], i + 1, path.dirname(abs), root));
150
+ }
151
+ }
152
+ return escapes.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line);
153
+ }
154
+ // RFC-1518 CHECKS 11/12: the package's declared docs surface diffed against
155
+ // the live command inventory — PKG-HEALTH-11 covers registered-but-undocumented
156
+ // commands, PKG-HEALTH-12 covers doc tokens resolving to no registered command
157
+ // (the REMEDIATION-04 dead-token class applied to authored reference docs).
158
+ export const DOCS_SURFACE = ["docs/**/*.md", "README.md", "AGENTS.md"];
159
+ export const DOCS_SURFACE_EXCLUDES = [
160
+ "docs/audits/archive/**",
161
+ "**/CHANGELOG.md",
162
+ "**/*.generated.md",
163
+ ];
164
+ const DOCS_SURFACE_EXCLUDE_RES = [
165
+ /(^|\/)docs\/audits\/archive\//,
166
+ /(^|\/)CHANGELOG\.md$/,
167
+ /\.generated\.md$/,
168
+ ];
169
+ // A command token is x.y-shaped with every segment starting with a letter —
170
+ // numeric segments (versions like 9.1.0) and uppercase names (AGENTS.md)
171
+ // never qualify. Tokens ending in a file extension or common TLD are config
172
+ // paths or domains, not command mentions (known non-command dotted paths).
173
+ const DOC_TOKEN_RE = /\b([a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+)\b/g;
174
+ // File-extension tails — applied unconditionally (a command never ends in one).
175
+ const DOC_REF_EXT_RE = /\.(?: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;
176
+ // TLD-shaped tails (domains, not commands) — fallback heuristic only when no
177
+ // live inventory is available; registered namespaces can end in one
178
+ // (forge.dev, forge.build would otherwise be filtered out).
179
+ const DOC_TLD_TAIL_RE = /\.(?: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;
180
+ const DOC_SUPPRESS_11_RE = /pkg-health-11(?:\s*\|\s*pkg-health-12)?:\s*([^\n]*?)\s*(?:-->\s*)?$/;
181
+ const DOC_SUPPRESS_12_RE = /(?:pkg-health-11\s*\|\s*)?pkg-health-12:\s*([^\n]*?)\s*(?:-->\s*)?$/;
182
+ /** Collect the package's DOCS_SURFACE files — docs trees, README, AGENTS — minus the fixed excludes. */
183
+ export function collectDocsSurfaceFiles(pkgDir) {
184
+ const files = [];
185
+ const docsDir = path.join(pkgDir, "docs");
186
+ const walk = (dir) => {
187
+ let entries;
188
+ try {
189
+ entries = fs.readdirSync(dir, { withFileTypes: true });
190
+ }
191
+ catch {
192
+ return;
193
+ }
194
+ for (const e of entries) {
195
+ const abs = path.join(dir, e.name);
196
+ if (e.isDirectory())
197
+ walk(abs);
198
+ else if (e.isFile() && e.name.endsWith(".md"))
199
+ files.push(abs);
200
+ }
201
+ };
202
+ if (fs.existsSync(docsDir))
203
+ walk(docsDir);
204
+ for (const top of ["README.md", "AGENTS.md"]) {
205
+ const abs = path.join(pkgDir, top);
206
+ if (fs.existsSync(abs))
207
+ files.push(abs);
208
+ }
209
+ return files
210
+ .filter((f) => {
211
+ const rel = path.relative(pkgDir, f).split(path.sep).join("/");
212
+ return !DOCS_SURFACE_EXCLUDE_RES.some((re) => re.test(rel));
213
+ })
214
+ .sort();
215
+ }
216
+ /**
217
+ * Scan one package's docs surface: build the documented-token set, the
218
+ * pkg-health-11 exemption set, and the dead-reference candidates (tokens on
219
+ * unsuppressed lines). pkg-health-12 markers exempt their whole line.
220
+ */
221
+ export function scanDocsSurface(pkgDir, files, commandNamespaces, registeredCommands) {
222
+ const documented = new Set();
223
+ const suppressed11 = new Map();
224
+ const refs = new Map();
225
+ const suppressions = [];
226
+ for (const abs of files) {
227
+ const rel = path.relative(pkgDir, abs).split(path.sep).join("/");
228
+ let source;
229
+ try {
230
+ source = fs.readFileSync(abs, "utf8");
231
+ }
232
+ catch {
233
+ continue;
234
+ }
235
+ const lines = source.split("\n");
236
+ for (let i = 0; i < lines.length; i++) {
237
+ const line = lines[i];
238
+ const tokens = [...line.matchAll(DOC_TOKEN_RE)]
239
+ .map((m) => m[1])
240
+ .filter((t) => !DOC_REF_EXT_RE.test(t))
241
+ .filter((t) => {
242
+ if (!commandNamespaces)
243
+ return !DOC_TLD_TAIL_RE.test(t);
244
+ // A token whose first segment is no registered command namespace is
245
+ // a property path (import.meta.url), config key (bindings.commands),
246
+ // or prose — never a command reference.
247
+ return commandNamespaces.has(t.split(".", 1)[0]);
248
+ })
249
+ // Registered commands always count (forge.dev, context.index.build).
250
+ // Unregistered tokens ending in a TLD tail are domains (warpgogol.com)
251
+ // or TLD-shaped property paths (context.io) — never command refs.
252
+ // Registered commands always count (forge.dev, context.index.build).
253
+ // Unregistered TWO-segment tokens ending in a TLD tail are domains
254
+ // (warpgogol.com) or TLD-shaped property paths (context.io); a 3+
255
+ // segment token under a registered namespace (deploy.smoke.run after
256
+ // removal) stays a dead-reference candidate — never TLD-exempt.
257
+ .filter((t) => !registeredCommands || registeredCommands.has(t) || t.split(".").length > 2 || !DOC_TLD_TAIL_RE.test(t));
258
+ const s11 = line.match(DOC_SUPPRESS_11_RE);
259
+ const s12 = line.match(DOC_SUPPRESS_12_RE);
260
+ // A marker with an empty reason does not suppress — an exemption needs
261
+ // a justification. Both markers are evaluated: a line may carry an 11
262
+ // and a 12 marker (or the combined pkg-health-11|pkg-health-12 form).
263
+ const reason = (m) => (m?.[1] ?? "").replace(/-->\s*$/, "").trim();
264
+ const m11 = s11 ? reason(s11) || null : null;
265
+ const m12 = s12 ? reason(s12) || null : null;
266
+ for (const token of tokens) {
267
+ if (m11) {
268
+ const entry = { ruleId: "PKG-HEALTH-11", file: rel, line: i + 1, token, reason: m11 };
269
+ suppressed11.set(token, entry);
270
+ suppressions.push(entry);
271
+ }
272
+ else {
273
+ documented.add(token);
274
+ }
275
+ if (m12) {
276
+ suppressions.push({ ruleId: "PKG-HEALTH-12", file: rel, line: i + 1, token, reason: m12 });
277
+ documented.add(token);
278
+ }
279
+ else if (!refs.has(token)) {
280
+ refs.set(token, { file: rel, line: i + 1 });
281
+ }
282
+ }
283
+ }
284
+ }
285
+ return { documented, suppressed11, refs, suppressions };
286
+ }
287
+ /**
288
+ * Map kernel module names → owning package dir — the same module enumeration
289
+ * the workspace registry (and command.manifest.generate) was built from:
290
+ * tools/kernel.config.ts inline loaders plus the WORKSHOP_MODULE_MAP buckets
291
+ * in werkstatt-engine's module-map.ts. Never a hand-maintained list.
292
+ * Returns separate workshop/site maps — module names can collide across
293
+ * buckets (deploy is both engine() and sitePlugin()) and commands attribute
294
+ * through the map matching their siteScope.
295
+ */
296
+ export function deriveModulePackageMap(workspaceRoot) {
297
+ const out = new Map();
298
+ const site = new Map();
299
+ const mmPath = path.join(workspaceRoot, "packages", "werkstatt-engine", "src", "kernel", "module-map.ts");
300
+ try {
301
+ const mm = fs.readFileSync(mmPath, "utf8");
302
+ const bucketToConst = { engine: "ENGINE", sitePlugin: "SITE", forge: "FORGE" };
303
+ const constToSpec = {};
304
+ for (const m of mm.matchAll(/const (\w+) = "(@warpgogol\/[^"]+)"/g))
305
+ constToSpec[m[1]] = m[2];
306
+ for (const m of mm.matchAll(/["']?([\w-]+)["']?:\s*(engine|sitePlugin|forge)\(/g)) {
307
+ const spec = constToSpec[bucketToConst[m[2]]];
308
+ // Module names can collide across buckets (deploy: engine + sitePlugin) —
309
+ // keep the maps separate so siteScope commands resolve via SITE only.
310
+ if (spec)
311
+ (m[2] === "sitePlugin" ? site : out).set(m[1], `packages/${spec.split("/")[1]}`);
312
+ }
313
+ }
314
+ catch {
315
+ // module-map absent — inline loaders still map
316
+ }
317
+ const kcPath = path.join(workspaceRoot, "tools", "kernel.config.ts");
318
+ try {
319
+ const kc = fs.readFileSync(kcPath, "utf8");
320
+ for (const m of kc.matchAll(/["']?(\w[\w-]*)["']?:\s*async[^=]*=>[^;]*?import\("(@warpgogol\/[^"]+)"/g)) {
321
+ out.set(m[1], `packages/${m[2].split("/")[1]}`);
322
+ }
323
+ }
324
+ catch {
325
+ // no kernel config — inventory attribution is empty
326
+ }
327
+ return { workshop: out, site };
328
+ }
329
+ /**
330
+ * The live command inventory: context.commandRegistry (the same enumeration
331
+ * command.manifest.generate consumes) UNION docs/command-manifest.generated.yaml
332
+ * — the getLiveCommands merge pattern from os/rfc/handlers/lifecycle.ts.
333
+ * Registry entries win on collision; the manifest covers commands whose modules
334
+ * are not loaded in the current dispatch (werkstatt run injects no registry;
335
+ * site-scope modules live outside the forge registry).
336
+ */
337
+ export function loadCommandInventory(workspaceRoot, commandRegistry) {
338
+ const byName = new Map();
339
+ const manifestPath = path.join(workspaceRoot, "docs", "command-manifest.generated.yaml");
340
+ try {
341
+ const raw = fs.readFileSync(manifestPath, "utf8");
342
+ const parsed = parseYaml(raw);
343
+ for (const c of parsed?.commands ?? []) {
344
+ if (typeof c.name === "string" && c.name.length > 0) {
345
+ byName.set(c.name, {
346
+ name: c.name,
347
+ module: typeof c.module === "string" ? c.module : undefined,
348
+ siteScope: typeof c.siteScope === "boolean"
349
+ ? c.siteScope
350
+ : Array.isArray(c.providers) && c.providers.includes("site-module")
351
+ ? true
352
+ : undefined,
353
+ });
354
+ }
355
+ }
356
+ }
357
+ catch {
358
+ // manifest absent or unparsable — registry-only inventory
359
+ }
360
+ for (const c of commandRegistry?.listCommands() ?? []) {
361
+ // Merge, don't overwrite: ForgeCliRegistry entries carry no `module`, so a
362
+ // bare set() would erase the manifest's provenance under the standalone CLI.
363
+ const prev = byName.get(c.name);
364
+ byName.set(c.name, {
365
+ name: c.name,
366
+ module: c.module ?? prev?.module,
367
+ siteScope: c.siteScope ?? prev?.siteScope,
368
+ });
369
+ }
370
+ return [...byName.values()];
371
+ }
372
+ /**
373
+ * Whether repo-extract's copy filter would ship one entry — shared by the
374
+ * working-tree walk (PKG-HEALTH-10) and the at-ref enumeration (publish
375
+ * preflight) so both judge the same set. `rel` is package-root-relative.
376
+ */
377
+ export function isShippedEntry(rel, name, isDir, cfg) {
378
+ if (cfg.ignoreDirs.has(name))
379
+ return false;
380
+ if (isDir)
381
+ return !cfg.excludeSegments.some((seg) => rel.includes(seg));
382
+ if (name.endsWith(".tsbuildinfo"))
383
+ return false;
384
+ if (cfg.monorepoMode && IGNORE_FILES.has(name))
385
+ return false;
386
+ if (cfg.excludeSegments.some((seg) => rel.includes(seg)))
387
+ return false;
388
+ if (cfg.excludeExtensions.some((ext) => name.endsWith(ext)))
389
+ return false;
390
+ return true;
391
+ }
392
+ /**
393
+ * Derive the file set repo-extract will ship for a package — a walk of
394
+ * `projectRoot` honoring the same config keys the copy filters consume (see
395
+ * parseHealthScanConfig). Symlinks are followed through statSync like
396
+ * repo-extract's `cp` filter; a realpath-set bounds link cycles. Never a
397
+ * hand-maintained file list.
398
+ */
399
+ export function deriveShippedFiles(projectRoot, extractConfigRaw) {
400
+ const cfg = parseHealthScanConfig(extractConfigRaw);
401
+ const root = path.resolve(projectRoot);
402
+ const shipped = [];
403
+ const visited = new Set();
404
+ const collect = (dir) => {
405
+ let entries;
406
+ try {
407
+ entries = fs.readdirSync(dir, { withFileTypes: true });
408
+ }
409
+ catch {
410
+ return;
411
+ }
412
+ for (const e of entries) {
413
+ const abs = path.join(dir, e.name);
414
+ const rel = path.relative(root, abs).split(path.sep).join("/");
415
+ // Dirent.isFile()/isDirectory() are false for symlinks — repo-extract's
416
+ // cp stats through links, so the scan must as well.
417
+ let stats = null;
418
+ if (e.isSymbolicLink()) {
419
+ try {
420
+ stats = fs.statSync(abs);
421
+ }
422
+ catch {
423
+ stats = null;
424
+ }
425
+ }
426
+ const isDir = stats ? stats.isDirectory() : e.isDirectory();
427
+ const isFile = stats ? stats.isFile() : e.isFile();
428
+ if (!isShippedEntry(rel, e.name, isDir, cfg))
429
+ continue;
430
+ if (isDir) {
431
+ let real = abs;
432
+ try {
433
+ real = fs.realpathSync(abs);
434
+ }
435
+ catch {
436
+ // keep the syntactic path
437
+ }
438
+ if (visited.has(real))
439
+ continue;
440
+ visited.add(real);
441
+ collect(abs);
442
+ }
443
+ else if (isFile) {
444
+ shipped.push(rel);
445
+ }
446
+ }
447
+ };
448
+ collect(root);
449
+ return shipped.sort();
450
+ }
19
451
  function defaultLintRunner(projectDir, hasLintScript) {
20
452
  const args = hasLintScript
21
453
  ? ["--dir", projectDir, "run", "lint"]
@@ -204,8 +636,29 @@ export async function runPackageHealth(_input, context, lintRunner = defaultLint
204
636
  const rootNodeRange = rootEngines?.["node"];
205
637
  const violations = [];
206
638
  const lintSurface = {};
639
+ const suppressions = [];
207
640
  let packagesChecked = 0;
208
- const entries = fs.readdirSync(packagesDir, { withFileTypes: true });
641
+ // RFC-1518 CHECKS 11/12 inputs — the live command inventory (registry
642
+ // union generated manifest, the getLiveCommands merge), attributed to
643
+ // owning packages through the kernel module enumeration.
644
+ const commandInfos = loadCommandInventory(workspaceRoot, context.commandRegistry);
645
+ const allCommands = new Set(commandInfos.map((c) => c.name));
646
+ const allNamespaces = new Set(commandInfos.map((c) => c.name.split(".", 1)[0]));
647
+ const moduleToPkg = deriveModulePackageMap(workspaceRoot);
648
+ const pkgCommands = new Map();
649
+ let attributed = 0;
650
+ for (const c of commandInfos) {
651
+ // Provider-aware attribution: a module name can exist in both the workshop
652
+ // and site buckets (deploy does), so siteScope commands resolve via the
653
+ // site map only — a last-write-wins flat map silently misattributes.
654
+ const map = c.siteScope === true ? moduleToPkg.site : moduleToPkg.workshop;
655
+ const pkg = c.module !== undefined ? map.get(c.module) : undefined;
656
+ if (pkg === undefined)
657
+ continue;
658
+ attributed++;
659
+ (pkgCommands.get(pkg) ?? pkgCommands.set(pkg, []).get(pkg)).push(c.name);
660
+ }
661
+ const entries = fs.readdirSync(packagesDir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
209
662
  for (const entry of entries) {
210
663
  if (!entry.isDirectory())
211
664
  continue;
@@ -217,10 +670,52 @@ export async function runPackageHealth(_input, context, lintRunner = defaultLint
217
670
  if (!pkg)
218
671
  continue;
219
672
  const isPrivate = pkg["private"] === true;
673
+ const packageName = String(pkg["name"] ?? entry.name);
674
+ // RFC-1518 CHECKS 11/12: the package's declared docs surface diffed
675
+ // against the live command inventory (F-0073). Coverage counts a token
676
+ // documented anywhere on the surface; dead refs flag at doc:line. Runs
677
+ // for EVERY package with a package.json — docs drift is orthogonal to
678
+ // publishability, so private/extractable:false packages are scanned too.
679
+ if (commandInfos.length > 0) {
680
+ const rel = path.relative(workspaceRoot, pkgDir).split(path.sep).join("/");
681
+ const surfaceFiles = collectDocsSurfaceFiles(pkgDir);
682
+ const scan = scanDocsSurface(pkgDir, surfaceFiles, allNamespaces, allCommands);
683
+ suppressions.push(...scan.suppressions.map((s) => ({ ...s, packageName })));
684
+ const expectedDoc = fs.existsSync(path.join(pkgDir, "docs", "reference", "cli.md"))
685
+ ? "docs/reference/cli.md"
686
+ : "README.md";
687
+ // Coverage applies to published packages — the command's stated contract.
688
+ // Private packages (site plugin, lifecycle core) document their command
689
+ // surfaces in site-facing docs outside this audit; their dead refs still
690
+ // flag via PKG-HEALTH-12 (deviation D-003).
691
+ for (const cmd of isPrivate ? [] : (pkgCommands.get(rel) ?? [])) {
692
+ if (!scan.documented.has(cmd) && !scan.suppressed11.has(cmd)) {
693
+ violations.push({
694
+ ruleId: "PKG-HEALTH-11",
695
+ packageName,
696
+ severity: "error",
697
+ message: `registered command "${cmd}" appears in no docs-surface file — document it in ${expectedDoc}`,
698
+ file: pkgDir,
699
+ fixHint: `Add a "${cmd}" reference to ${expectedDoc}, or journal a same-line "<!-- pkg-health-11: <reason> -->" exemption.`,
700
+ });
701
+ }
702
+ }
703
+ for (const [token, at] of [...scan.refs.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {
704
+ if (!allCommands.has(token)) {
705
+ violations.push({
706
+ ruleId: "PKG-HEALTH-12",
707
+ packageName,
708
+ severity: "error",
709
+ message: `${at.file}:${at.line} references "${token}" — no such registered command`,
710
+ file: path.join(pkgDir, at.file),
711
+ fixHint: `Fix the reference to a registered command, or journal a same-line "<!-- pkg-health-12: <reason> -->" exemption.`,
712
+ });
713
+ }
714
+ }
715
+ }
220
716
  if (isPrivate)
221
717
  continue;
222
718
  packagesChecked++;
223
- const packageName = String(pkg["name"] ?? entry.name);
224
719
  // CHECK 1: engines.node exists and matches root
225
720
  const pkgEngines = pkg["engines"];
226
721
  const pkgNodeRange = pkgEngines?.["node"];
@@ -401,8 +896,50 @@ export async function runPackageHealth(_input, context, lintRunner = defaultLint
401
896
  });
402
897
  }
403
898
  }
899
+ // RFC-1517 CHECK 10: a `../` literal in a shipped file that resolves
900
+ // outside the package root passes the monorepo suite and ENOENTs only
901
+ // inside the standalone extract (F-0064). Same scan the publish
902
+ // preflight runs — the defect surfaces here on routine health runs.
903
+ const healthProjectDir = projectDirMatch
904
+ ? path.resolve(workspaceRoot, projectDirMatch[1])
905
+ : pkgDir;
906
+ const healthScanCfg = parseHealthScanConfig(extractConfigRaw);
907
+ for (const esc of scanFixturePathEscapes(healthProjectDir, deriveShippedFiles(healthProjectDir, extractConfigRaw), healthScanCfg.suppressions)) {
908
+ violations.push({
909
+ ruleId: "PKG-HEALTH-10",
910
+ packageName,
911
+ severity: "error",
912
+ message: `${esc.file}:${esc.line} path literal "${esc.literal}" resolves outside the package root (${esc.resolvedTo}) — the standalone extract will ENOENT.`,
913
+ file: path.join(healthProjectDir, esc.file),
914
+ fixHint: '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.',
915
+ });
916
+ }
404
917
  }
405
918
  }
919
+ suppressions.sort((a, b) => (a.packageName ?? "").localeCompare(b.packageName ?? "") || a.file.localeCompare(b.file) || a.line - b.line);
920
+ if (packagesChecked > 0 && commandInfos.length === 0) {
921
+ violations.push({
922
+ ruleId: "PKG-HEALTH-12",
923
+ packageName: "(workspace)",
924
+ severity: "warning",
925
+ message: "no command inventory available — docs-drift gate skipped (context.commandRegistry unset and docs/command-manifest.generated.yaml absent or unparsable)",
926
+ file: workspaceRoot,
927
+ fixHint: "Run `werkstatt run command.manifest.generate`, or dispatch through a host that injects commandRegistry.",
928
+ });
929
+ }
930
+ else if (packagesChecked > 0 && commandInfos.length > 0 && attributed === 0) {
931
+ // Inventory exists but no command resolved to a package — module→package
932
+ // attribution is unavailable (e.g. a consumer workshop without the
933
+ // werkstatt-engine module-map) and PKG-HEALTH-11 would silently inert.
934
+ violations.push({
935
+ ruleId: "PKG-HEALTH-12",
936
+ packageName: "(workspace)",
937
+ severity: "warning",
938
+ message: `${commandInfos.length} inventoried command(s) resolved to no package — module attribution unavailable, PKG-HEALTH-11 coverage skipped`,
939
+ file: workspaceRoot,
940
+ fixHint: "Check that packages/werkstatt-engine/src/kernel/module-map.ts or tools/kernel.config.ts declares the command modules.",
941
+ });
942
+ }
406
943
  const errors = violations.filter((v) => v.severity === "error");
407
944
  const warnings = violations.filter((v) => v.severity === "warning");
408
945
  const passed = errors.length === 0;
@@ -432,6 +969,9 @@ export async function runPackageHealth(_input, context, lintRunner = defaultLint
432
969
  parts.push(`${warnings.length} warning${warnings.length === 1 ? "" : "s"}`);
433
970
  logger.error(`forge.package.health: ${parts.join(", ")} across ${packagesChecked} package(s).`);
434
971
  }
972
+ if (suppressions.length > 0) {
973
+ logger.info(`forge.package.health: ${suppressions.length} docs-gate suppression(s) journaled (see data.suppressions for file:line + reason).`);
974
+ }
435
975
  }
436
976
  }
437
977
  return {
@@ -441,6 +981,7 @@ export async function runPackageHealth(_input, context, lintRunner = defaultLint
441
981
  violations,
442
982
  passed,
443
983
  lintSurface,
984
+ suppressions,
444
985
  },
445
986
  exitCode: passed ? 0 : 1,
446
987
  summary: passed