oxe-cc 1.21.1 → 1.22.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 (498) hide show
  1. package/.cursor/commands/oxe-alm.md +47 -0
  2. package/.cursor/commands/oxe-ask.md +1 -1
  3. package/.cursor/commands/oxe-capabilities.md +1 -1
  4. package/.cursor/commands/oxe-checkpoint.md +1 -1
  5. package/.cursor/commands/oxe-compact.md +1 -1
  6. package/.cursor/commands/oxe-dashboard.md +1 -1
  7. package/.cursor/commands/oxe-debug.md +1 -1
  8. package/.cursor/commands/oxe-discuss.md +45 -45
  9. package/.cursor/commands/oxe-execute.md +52 -50
  10. package/.cursor/commands/oxe-forensics.md +1 -1
  11. package/.cursor/commands/oxe-help.md +44 -44
  12. package/.cursor/commands/oxe-loop.md +1 -1
  13. package/.cursor/commands/oxe-milestone.md +1 -1
  14. package/.cursor/commands/oxe-next.md +44 -44
  15. package/.cursor/commands/oxe-obs.md +1 -1
  16. package/.cursor/commands/oxe-plan-agent.md +1 -1
  17. package/.cursor/commands/oxe-plan.md +49 -47
  18. package/.cursor/commands/oxe-project.md +1 -1
  19. package/.cursor/commands/oxe-quick.md +49 -47
  20. package/.cursor/commands/oxe-research.md +1 -1
  21. package/.cursor/commands/oxe-retro.md +1 -1
  22. package/.cursor/commands/oxe-review-pr.md +47 -47
  23. package/.cursor/commands/oxe-route.md +1 -1
  24. package/.cursor/commands/oxe-scan.md +47 -47
  25. package/.cursor/commands/oxe-security.md +1 -1
  26. package/.cursor/commands/oxe-session.md +1 -1
  27. package/.cursor/commands/oxe-ship.md +47 -47
  28. package/.cursor/commands/oxe-skill.md +1 -1
  29. package/.cursor/commands/oxe-spec.md +49 -47
  30. package/.cursor/commands/oxe-ui-review.md +1 -1
  31. package/.cursor/commands/oxe-ui-spec.md +1 -1
  32. package/.cursor/commands/oxe-update.md +1 -1
  33. package/.cursor/commands/oxe-validate-gaps.md +1 -1
  34. package/.cursor/commands/oxe-verify-audit.md +1 -1
  35. package/.cursor/commands/oxe-verify.md +50 -50
  36. package/.cursor/commands/oxe-workflow-authoring.md +1 -1
  37. package/.cursor/commands/oxe-workstream.md +1 -1
  38. package/.cursor/commands/oxe.md +51 -49
  39. package/.github/copilot-instructions.md +177 -177
  40. package/.github/dependabot.yml +31 -31
  41. package/.github/prompts/oxe-alm.prompt.md +47 -0
  42. package/.github/prompts/oxe-ask.prompt.md +47 -47
  43. package/.github/prompts/oxe-capabilities.prompt.md +47 -47
  44. package/.github/prompts/oxe-checkpoint.prompt.md +47 -47
  45. package/.github/prompts/oxe-compact.prompt.md +46 -46
  46. package/.github/prompts/oxe-dashboard.prompt.md +47 -47
  47. package/.github/prompts/oxe-debug.prompt.md +47 -47
  48. package/.github/prompts/oxe-discuss.prompt.md +47 -47
  49. package/.github/prompts/oxe-execute.prompt.md +52 -50
  50. package/.github/prompts/oxe-forensics.prompt.md +47 -47
  51. package/.github/prompts/oxe-help.prompt.md +46 -46
  52. package/.github/prompts/oxe-loop.prompt.md +47 -47
  53. package/.github/prompts/oxe-milestone.prompt.md +47 -47
  54. package/.github/prompts/oxe-next.prompt.md +46 -46
  55. package/.github/prompts/oxe-obs.prompt.md +47 -47
  56. package/.github/prompts/oxe-plan-agent.prompt.md +46 -46
  57. package/.github/prompts/oxe-plan.prompt.md +49 -47
  58. package/.github/prompts/oxe-project.prompt.md +47 -47
  59. package/.github/prompts/oxe-quick.prompt.md +49 -47
  60. package/.github/prompts/oxe-research.prompt.md +47 -47
  61. package/.github/prompts/oxe-retro.prompt.md +47 -47
  62. package/.github/prompts/oxe-review-pr.prompt.md +47 -47
  63. package/.github/prompts/oxe-route.prompt.md +47 -47
  64. package/.github/prompts/oxe-scan.prompt.md +47 -47
  65. package/.github/prompts/oxe-security.prompt.md +47 -47
  66. package/.github/prompts/oxe-session.prompt.md +47 -47
  67. package/.github/prompts/oxe-ship.prompt.md +47 -47
  68. package/.github/prompts/oxe-skill.prompt.md +47 -47
  69. package/.github/prompts/oxe-spec.prompt.md +49 -47
  70. package/.github/prompts/oxe-ui-review.prompt.md +47 -47
  71. package/.github/prompts/oxe-ui-spec.prompt.md +47 -47
  72. package/.github/prompts/oxe-update.prompt.md +46 -46
  73. package/.github/prompts/oxe-validate-gaps.prompt.md +47 -47
  74. package/.github/prompts/oxe-verify-audit.prompt.md +1 -1
  75. package/.github/prompts/oxe-verify.prompt.md +50 -50
  76. package/.github/prompts/oxe-workflow-authoring.prompt.md +1 -1
  77. package/.github/prompts/oxe-workstream.prompt.md +47 -47
  78. package/.github/prompts/oxe.prompt.md +51 -49
  79. package/.github/workflows/ci.yml +163 -163
  80. package/.github/workflows/release.yml +120 -120
  81. package/AGENTS.md +108 -102
  82. package/CHANGELOG.md +1883 -1042
  83. package/LICENSE +21 -21
  84. package/QUICKSTART.md +99 -99
  85. package/README.md +703 -673
  86. package/bin/banner.txt +18 -18
  87. package/bin/lib/oxe-acceptance-audit.cjs +195 -0
  88. package/bin/lib/oxe-adr.cjs +145 -0
  89. package/bin/lib/oxe-agent-install.cjs +679 -677
  90. package/bin/lib/oxe-alm-admin.cjs +215 -0
  91. package/bin/lib/oxe-alm-metrics.cjs +143 -0
  92. package/bin/lib/oxe-alm-prs.cjs +274 -0
  93. package/bin/lib/oxe-alm-refine.cjs +1003 -0
  94. package/bin/lib/oxe-alm.cjs +1289 -0
  95. package/bin/lib/oxe-anchor-copy.cjs +218 -0
  96. package/bin/lib/oxe-api-surface.cjs +96 -0
  97. package/bin/lib/oxe-artifact-catalog.cjs +376 -376
  98. package/bin/lib/oxe-artifact-refs.cjs +72 -0
  99. package/bin/lib/oxe-attention.cjs +97 -0
  100. package/bin/lib/oxe-autoresume.cjs +448 -0
  101. package/bin/lib/oxe-budget.cjs +154 -117
  102. package/bin/lib/oxe-change-folder.cjs +130 -0
  103. package/bin/lib/oxe-change.cjs +389 -230
  104. package/bin/lib/oxe-channels.cjs +82 -0
  105. package/bin/lib/oxe-cited-paths.cjs +180 -0
  106. package/bin/lib/oxe-cli-errors.cjs +76 -0
  107. package/bin/lib/oxe-cli-output.cjs +111 -0
  108. package/bin/lib/oxe-command-registry.cjs +31 -31
  109. package/bin/lib/oxe-commit-convention.cjs +104 -85
  110. package/bin/lib/oxe-complexity.cjs +106 -0
  111. package/bin/lib/oxe-console-decode.cjs +23 -0
  112. package/bin/lib/oxe-context-engine.cjs +874 -874
  113. package/bin/lib/oxe-coordinator-queue.cjs +67 -0
  114. package/bin/lib/oxe-core-command-handlers.cjs +84 -82
  115. package/bin/lib/oxe-criteria-ids.cjs +87 -0
  116. package/bin/lib/oxe-criterion-coverage.cjs +93 -58
  117. package/bin/lib/oxe-cross-card-conflicts.cjs +639 -0
  118. package/bin/lib/oxe-customize.cjs +146 -0
  119. package/bin/lib/oxe-dashboard.cjs +737 -737
  120. package/bin/lib/oxe-decisions.cjs +211 -0
  121. package/bin/lib/oxe-deferred.cjs +80 -0
  122. package/bin/lib/oxe-deps-audit.cjs +136 -0
  123. package/bin/lib/oxe-diff-reviewer.cjs +105 -0
  124. package/bin/lib/oxe-dir-info.cjs +138 -0
  125. package/bin/lib/oxe-docs-check.cjs +124 -0
  126. package/bin/lib/oxe-docs-publish.cjs +81 -0
  127. package/bin/lib/oxe-dom-hooks.cjs +902 -0
  128. package/bin/lib/oxe-dossier.cjs +355 -281
  129. package/bin/lib/oxe-e2e-ready.cjs +360 -0
  130. package/bin/lib/oxe-env-sanitize.cjs +155 -0
  131. package/bin/lib/oxe-event-bus.cjs +118 -118
  132. package/bin/lib/oxe-failure-cost.cjs +144 -0
  133. package/bin/lib/oxe-file-size-guard.cjs +849 -0
  134. package/bin/lib/oxe-findings.cjs +86 -0
  135. package/bin/lib/oxe-grill-cases.cjs +148 -0
  136. package/bin/lib/oxe-grill.cjs +444 -0
  137. package/bin/lib/oxe-grooming.cjs +115 -0
  138. package/bin/lib/oxe-guard.cjs +180 -0
  139. package/bin/lib/oxe-handoff.cjs +97 -0
  140. package/bin/lib/oxe-install-resolve.cjs +134 -134
  141. package/bin/lib/oxe-integration-checks.cjs +285 -0
  142. package/bin/lib/oxe-intent-context.cjs +101 -0
  143. package/bin/lib/oxe-journey.cjs +403 -0
  144. package/bin/lib/oxe-known-failures.cjs +138 -0
  145. package/bin/lib/oxe-local-config.cjs +77 -0
  146. package/bin/lib/oxe-manifest.cjs +124 -124
  147. package/bin/lib/oxe-memory-kernel.cjs +190 -188
  148. package/bin/lib/oxe-merge-train.cjs +277 -0
  149. package/bin/lib/oxe-model-resolve.cjs +74 -0
  150. package/bin/lib/oxe-model-tiers.cjs +65 -0
  151. package/bin/lib/oxe-nfr.cjs +125 -0
  152. package/bin/lib/oxe-npm-version.cjs +66 -66
  153. package/bin/lib/oxe-open-defects.cjs +121 -0
  154. package/bin/lib/oxe-operational.cjs +15949 -4484
  155. package/bin/lib/oxe-origin-guard.cjs +102 -0
  156. package/bin/lib/oxe-origin.cjs +377 -0
  157. package/bin/lib/oxe-pack-removed.cjs +208 -0
  158. package/bin/lib/oxe-parallel-run.cjs +81 -0
  159. package/bin/lib/oxe-parallel.cjs +234 -0
  160. package/bin/lib/oxe-phase-extras.cjs +185 -0
  161. package/bin/lib/oxe-phase-gates.cjs +551 -280
  162. package/bin/lib/oxe-plan-build.cjs +1520 -0
  163. package/bin/lib/oxe-plan-json.cjs +1107 -433
  164. package/bin/lib/oxe-plan-merge.cjs +253 -0
  165. package/bin/lib/oxe-plan-mutate.cjs +214 -0
  166. package/bin/lib/oxe-plan-repair.cjs +479 -0
  167. package/bin/lib/oxe-plan-review.cjs +256 -0
  168. package/bin/lib/oxe-plan-skeleton.cjs +494 -0
  169. package/bin/lib/oxe-plan-staleness.cjs +125 -0
  170. package/bin/lib/oxe-plugin-cli.cjs +97 -95
  171. package/bin/lib/oxe-plugins.cjs +432 -432
  172. package/bin/lib/oxe-policy-rules.cjs +144 -0
  173. package/bin/lib/oxe-prd.cjs +129 -0
  174. package/bin/lib/oxe-preflight.cjs +378 -0
  175. package/bin/lib/oxe-process.cjs +67 -67
  176. package/bin/lib/oxe-program-members.cjs +97 -0
  177. package/bin/lib/oxe-program.cjs +245 -205
  178. package/bin/lib/oxe-progress-run.cjs +80 -0
  179. package/bin/lib/oxe-project-env.cjs +273 -178
  180. package/bin/lib/oxe-project-health.cjs +3424 -2962
  181. package/bin/lib/oxe-promote-helpers.cjs +1561 -0
  182. package/bin/lib/oxe-provider-antigravity.cjs +114 -0
  183. package/bin/lib/oxe-provider-grok.cjs +48 -0
  184. package/bin/lib/oxe-questions.cjs +115 -0
  185. package/bin/lib/oxe-quick.cjs +537 -0
  186. package/bin/lib/oxe-ratchets.cjs +132 -0
  187. package/bin/lib/oxe-rationality.cjs +587 -556
  188. package/bin/lib/oxe-real-regression.cjs +97 -0
  189. package/bin/lib/oxe-recovery.cjs +160 -0
  190. package/bin/lib/oxe-release-ops.cjs +325 -0
  191. package/bin/lib/oxe-release.cjs +622 -593
  192. package/bin/lib/oxe-repair.cjs +153 -0
  193. package/bin/lib/oxe-repo-map.cjs +136 -0
  194. package/bin/lib/oxe-repo-rules.cjs +121 -108
  195. package/bin/lib/oxe-research-provenance.cjs +96 -0
  196. package/bin/lib/oxe-resume.cjs +406 -0
  197. package/bin/lib/oxe-review.cjs +403 -0
  198. package/bin/lib/oxe-rfc.cjs +192 -0
  199. package/bin/lib/oxe-risk-decision.cjs +141 -0
  200. package/bin/lib/oxe-runtime-semantics.cjs +521 -514
  201. package/bin/lib/oxe-scorecard.cjs +234 -164
  202. package/bin/lib/oxe-scratch.cjs +81 -0
  203. package/bin/lib/oxe-seams.cjs +159 -0
  204. package/bin/lib/oxe-semver.cjs +83 -0
  205. package/bin/lib/oxe-ship-pr.cjs +204 -0
  206. package/bin/lib/oxe-signal.cjs +173 -0
  207. package/bin/lib/oxe-skill-loader.cjs +131 -131
  208. package/bin/lib/oxe-spec-check.cjs +217 -0
  209. package/bin/lib/oxe-spec-ears.cjs +98 -0
  210. package/bin/lib/oxe-spec-edit.cjs +411 -0
  211. package/bin/lib/oxe-spec-freeze.cjs +378 -0
  212. package/bin/lib/oxe-spec-probe.cjs +146 -0
  213. package/bin/lib/oxe-spec-stress.cjs +146 -0
  214. package/bin/lib/oxe-spike.cjs +98 -98
  215. package/bin/lib/oxe-state.cjs +87 -0
  216. package/bin/lib/oxe-stub-check.cjs +355 -0
  217. package/bin/lib/oxe-suite-impact.cjs +1145 -0
  218. package/bin/lib/oxe-sync.cjs +250 -0
  219. package/bin/lib/oxe-system-design.cjs +138 -0
  220. package/bin/lib/oxe-task-gates.cjs +139 -0
  221. package/bin/lib/oxe-telemetry.cjs +201 -0
  222. package/bin/lib/oxe-test-precheck.cjs +508 -0
  223. package/bin/lib/oxe-test-rigor.cjs +663 -0
  224. package/bin/lib/oxe-test-scope.cjs +883 -0
  225. package/bin/lib/oxe-trace.cjs +168 -0
  226. package/bin/lib/oxe-turns.cjs +64 -0
  227. package/bin/lib/oxe-ui-evidence.cjs +187 -0
  228. package/bin/lib/oxe-ui-verify.cjs +55 -0
  229. package/bin/lib/oxe-unsafe-commands.cjs +94 -0
  230. package/bin/lib/oxe-verdicts.cjs +131 -0
  231. package/bin/lib/oxe-verify-dryrun.cjs +541 -152
  232. package/bin/lib/oxe-verify-remote.cjs +208 -0
  233. package/bin/lib/oxe-vitest-batch.cjs +142 -0
  234. package/bin/lib/oxe-workflow-budget.cjs +99 -0
  235. package/bin/lib/oxe-workflow-eval.cjs +118 -0
  236. package/bin/lib/oxe-workflows.cjs +147 -145
  237. package/bin/lib/oxe-worktree-deps.cjs +241 -0
  238. package/bin/lib/oxe-worktree-gc.cjs +170 -0
  239. package/bin/oxe-cc.js +10669 -6281
  240. package/commands/oxe/alm.md +54 -0
  241. package/commands/oxe/ask.md +55 -55
  242. package/commands/oxe/capabilities.md +50 -50
  243. package/commands/oxe/checkpoint.md +53 -53
  244. package/commands/oxe/compact.md +47 -47
  245. package/commands/oxe/dashboard.md +51 -51
  246. package/commands/oxe/debug.md +58 -58
  247. package/commands/oxe/discuss.md +58 -58
  248. package/commands/oxe/execute.md +63 -61
  249. package/commands/oxe/forensics.md +53 -53
  250. package/commands/oxe/help.md +48 -48
  251. package/commands/oxe/loop.md +54 -54
  252. package/commands/oxe/milestone.md +53 -53
  253. package/commands/oxe/next.md +49 -49
  254. package/commands/oxe/obs.md +53 -53
  255. package/commands/oxe/oxe.md +55 -53
  256. package/commands/oxe/plan-agent.md +57 -57
  257. package/commands/oxe/plan.md +59 -57
  258. package/commands/oxe/project.md +53 -53
  259. package/commands/oxe/quick.md +53 -53
  260. package/commands/oxe/research.md +53 -53
  261. package/commands/oxe/retro.md +53 -53
  262. package/commands/oxe/review-pr.md +53 -53
  263. package/commands/oxe/route.md +48 -48
  264. package/commands/oxe/scan.md +58 -58
  265. package/commands/oxe/security.md +53 -53
  266. package/commands/oxe/session.md +53 -53
  267. package/commands/oxe/ship.md +53 -53
  268. package/commands/oxe/skill.md +53 -53
  269. package/commands/oxe/spec.md +59 -56
  270. package/commands/oxe/ui-review.md +53 -53
  271. package/commands/oxe/ui-spec.md +53 -53
  272. package/commands/oxe/update.md +53 -53
  273. package/commands/oxe/validate-gaps.md +53 -53
  274. package/commands/oxe/verify-audit.md +50 -50
  275. package/commands/oxe/verify.md +60 -60
  276. package/commands/oxe/workflow-authoring.md +50 -50
  277. package/commands/oxe/workstream.md +53 -53
  278. package/docs/ADLC-COVERAGE.md +55 -0
  279. package/docs/CONTENT-MIGRATION-AUDIT.md +49 -49
  280. package/docs/HAPPY-PATH.md +106 -0
  281. package/docs/INCIDENT-PLAYBOOK.md +181 -181
  282. package/docs/INTEGRATION.md +182 -182
  283. package/docs/QUALITY-GATES.md +46 -46
  284. package/docs/RELEASE-READINESS.md +87 -87
  285. package/docs/ROLES.md +129 -129
  286. package/docs/RUNTIME-SMOKE-MATRIX.md +137 -137
  287. package/docs/TEAM-ADOPTION.md +153 -153
  288. package/docs/WALKTHROUGH.md +241 -241
  289. package/docs/adr/D-1-isolamento-read-only-e-sanitizacao-centralizada-de-env-vars.md +29 -0
  290. package/docs/adr/D-2-junction-segura-de-node-modules-condicionada-a-sha-256-de-pa.md +29 -0
  291. package/docs/adr/D-3-preflight-local-5s-impacto-estatico-e2e-e-leitura-explicita.md +29 -0
  292. package/docs/adr/D-4-governanca-de-release-unificada-retomada-idempotente-pos-rei.md +29 -0
  293. package/docs/adr/README.md +15 -0
  294. package/docs/cli-errors.md +20 -0
  295. package/docs/oxespace-1.5/BACKLOG.md +2056 -273
  296. package/docs/oxespace-1.5/HANDOFF-1.21.2.md +140 -0
  297. package/docs/oxevoice/BACKLOG.md +244 -244
  298. package/lib/runtime/compiler/graph-compiler.d.ts +2 -0
  299. package/lib/runtime/compiler/graph-compiler.js +11 -2
  300. package/lib/runtime/delivery/promotion-pipeline.d.ts +1 -0
  301. package/lib/runtime/delivery/promotion-pipeline.js +53 -0
  302. package/lib/runtime/events/catalog.d.ts +1 -1
  303. package/lib/runtime/events/catalog.js +18 -0
  304. package/lib/runtime/executor/action-tool-map.d.ts +3 -1
  305. package/lib/runtime/executor/action-tool-map.js +4 -1
  306. package/lib/runtime/executor/adapters/antigravity-cli.d.ts +103 -0
  307. package/lib/runtime/executor/adapters/antigravity-cli.js +530 -0
  308. package/lib/runtime/executor/adapters/claude-cli.d.ts +29 -0
  309. package/lib/runtime/executor/adapters/claude-cli.js +92 -14
  310. package/lib/runtime/executor/adapters/grok-cli.d.ts +89 -0
  311. package/lib/runtime/executor/adapters/grok-cli.js +351 -0
  312. package/lib/runtime/executor/adapters/registry.d.ts +6 -1
  313. package/lib/runtime/executor/adapters/registry.js +22 -2
  314. package/lib/runtime/executor/adapters/types.d.ts +1 -1
  315. package/lib/runtime/executor/built-in-tools.d.ts +56 -0
  316. package/lib/runtime/executor/built-in-tools.js +219 -17
  317. package/lib/runtime/executor/index.d.ts +9 -2
  318. package/lib/runtime/executor/index.js +23 -1
  319. package/lib/runtime/executor/llm-task-executor.d.ts +76 -3
  320. package/lib/runtime/executor/llm-task-executor.js +514 -31
  321. package/lib/runtime/executor/node-context.d.ts +11 -0
  322. package/lib/runtime/executor/node-context.js +10 -0
  323. package/lib/runtime/executor/node-prompt-builder.js +2 -0
  324. package/lib/runtime/executor/quota-patterns.d.ts +7 -0
  325. package/lib/runtime/executor/quota-patterns.js +39 -0
  326. package/lib/runtime/executor/shell-argv.d.ts +11 -0
  327. package/lib/runtime/executor/shell-argv.js +89 -2
  328. package/lib/runtime/executor/stream-completion.d.ts +16 -0
  329. package/lib/runtime/executor/stream-completion.js +72 -4
  330. package/lib/runtime/index.d.ts +1 -1
  331. package/lib/runtime/index.js +3 -1
  332. package/lib/runtime/models/failure.d.ts +1 -1
  333. package/lib/runtime/models/run.d.ts +1 -1
  334. package/lib/runtime/program/program-model.d.ts +20 -2
  335. package/lib/runtime/program/program-model.js +73 -6
  336. package/lib/runtime/projection/projection-engine.d.ts +6 -0
  337. package/lib/runtime/projection/projection-engine.js +30 -2
  338. package/lib/runtime/reducers/run-state-reducer.js +43 -5
  339. package/lib/runtime/scheduler/run-journal.d.ts +8 -0
  340. package/lib/runtime/scheduler/scheduler.d.ts +211 -2
  341. package/lib/runtime/scheduler/scheduler.js +982 -98
  342. package/lib/runtime/verification/runner-timeout.d.ts +7 -0
  343. package/lib/runtime/verification/runner-timeout.js +17 -0
  344. package/lib/runtime/verification/test-report-parsers.d.ts +2 -1
  345. package/lib/runtime/verification/test-report-parsers.js +9 -1
  346. package/lib/runtime/verification/verification-compiler.d.ts +34 -1
  347. package/lib/runtime/verification/verification-compiler.js +206 -74
  348. package/lib/runtime/verification/verification-manifest.d.ts +2 -0
  349. package/lib/runtime/verification/verification-manifest.js +15 -1
  350. package/lib/runtime/workspace/index.d.ts +2 -1
  351. package/lib/runtime/workspace/index.js +3 -1
  352. package/lib/runtime/workspace/strategies/ephemeral-container.d.ts +9 -0
  353. package/lib/runtime/workspace/strategies/ephemeral-container.js +37 -10
  354. package/lib/runtime/workspace/strategies/git-worktree.d.ts +15 -1
  355. package/lib/runtime/workspace/strategies/git-worktree.js +53 -1
  356. package/lib/sdk/README.md +82 -82
  357. package/lib/sdk/index.cjs +828 -815
  358. package/lib/sdk/index.d.ts +982 -982
  359. package/lib/sdk/index.types.ts +933 -933
  360. package/oxe/agents/oxe-assumptions-analyzer.md +136 -136
  361. package/oxe/agents/oxe-codebase-mapper.md +142 -142
  362. package/oxe/agents/oxe-debugger.md +145 -145
  363. package/oxe/agents/oxe-executor.md +139 -139
  364. package/oxe/agents/oxe-integration-checker.md +142 -142
  365. package/oxe/agents/oxe-plan-checker.md +143 -143
  366. package/oxe/agents/oxe-planner.md +151 -151
  367. package/oxe/agents/oxe-research-synthesizer.md +146 -146
  368. package/oxe/agents/oxe-researcher.md +163 -163
  369. package/oxe/agents/oxe-ui-auditor.md +151 -151
  370. package/oxe/agents/oxe-ui-checker.md +157 -157
  371. package/oxe/agents/oxe-ui-researcher.md +179 -179
  372. package/oxe/agents/oxe-validation-auditor.md +154 -154
  373. package/oxe/agents/oxe-verifier.md +132 -132
  374. package/oxe/migrations/config-migrations.json +15 -0
  375. package/oxe/personas/README.md +91 -91
  376. package/oxe/personas/architect.md +149 -149
  377. package/oxe/personas/db-specialist.md +149 -149
  378. package/oxe/personas/debugger.md +155 -155
  379. package/oxe/personas/executor.md +164 -164
  380. package/oxe/personas/planner.md +165 -165
  381. package/oxe/personas/researcher.md +148 -148
  382. package/oxe/personas/ui-specialist.md +164 -164
  383. package/oxe/personas/verifier.md +174 -174
  384. package/oxe/schemas/plan.schema.json +101 -85
  385. package/oxe/schemas/role-plan.schema.json +50 -0
  386. package/oxe/schemas/swarm-run.schema.json +130 -130
  387. package/oxe/templates/CONFIG.md +277 -105
  388. package/oxe/templates/DISCUSS.template.md +45 -44
  389. package/oxe/templates/EXECUTION-RUNTIME.template.md +68 -68
  390. package/oxe/templates/FIXTURE-PACK.template.json +41 -41
  391. package/oxe/templates/FIXTURE-PACK.template.md +30 -30
  392. package/oxe/templates/GLOSSARY.template.md +9 -0
  393. package/oxe/templates/IMPLEMENTATION-PACK.template.json +68 -68
  394. package/oxe/templates/IMPLEMENTATION-PACK.template.md +48 -48
  395. package/oxe/templates/PLAN.template.md +151 -151
  396. package/oxe/templates/PLUGINS.md +108 -108
  397. package/oxe/templates/PRD.template.md +53 -0
  398. package/oxe/templates/REFERENCE-ANCHORS.template.md +39 -35
  399. package/oxe/templates/RESEARCH.template.md +65 -57
  400. package/oxe/templates/RFC.template.md +43 -0
  401. package/oxe/templates/SPEC.template.md +119 -119
  402. package/oxe/templates/STATE-REFERENCE.md +125 -125
  403. package/oxe/templates/STATE.md +30 -30
  404. package/oxe/templates/SUMMARY.template.md +50 -50
  405. package/oxe/templates/VISUAL-INPUTS.template.json +27 -27
  406. package/oxe/templates/VISUAL-INPUTS.template.md +36 -36
  407. package/oxe/templates/config.template.json +38 -38
  408. package/oxe/templates/finding-rules.json +22 -0
  409. package/oxe/templates/stress-methods.md +33 -0
  410. package/oxe/workflows/agent-mode.md +150 -150
  411. package/oxe/workflows/alm.md +50 -0
  412. package/oxe/workflows/compact/plan.md +149 -0
  413. package/oxe/workflows/compact/spec.md +114 -0
  414. package/oxe/workflows/compact.md +45 -44
  415. package/oxe/workflows/conduct.md +149 -149
  416. package/oxe/workflows/debug.md +43 -43
  417. package/oxe/workflows/discuss.md +98 -86
  418. package/oxe/workflows/distill.md +164 -164
  419. package/oxe/workflows/execute.md +273 -269
  420. package/oxe/workflows/forensics.md +53 -53
  421. package/oxe/workflows/help.md +361 -355
  422. package/oxe/workflows/lean/execute.md +42 -0
  423. package/oxe/workflows/lean/plan.md +60 -0
  424. package/oxe/workflows/lean/spec.md +61 -0
  425. package/oxe/workflows/memory.md +163 -163
  426. package/oxe/workflows/next.md +47 -45
  427. package/oxe/workflows/oxe.md +168 -150
  428. package/oxe/workflows/plan.md +563 -556
  429. package/oxe/workflows/quick.md +199 -185
  430. package/oxe/workflows/references/alm-refine.md +55 -0
  431. package/oxe/workflows/references/azure-in-plan.md +5 -0
  432. package/oxe/workflows/references/change-management.md +48 -0
  433. package/oxe/workflows/references/flow-robustness-contract.md +80 -80
  434. package/oxe/workflows/references/grill.md +74 -0
  435. package/oxe/workflows/references/next-step-footer.md +33 -0
  436. package/oxe/workflows/references/plan-json-acceptance-program.md +174 -143
  437. package/oxe/workflows/references/product-docs-alm.md +51 -0
  438. package/oxe/workflows/references/workflow-runtime-contracts.json +1167 -1151
  439. package/oxe/workflows/research.md +67 -66
  440. package/oxe/workflows/route.md +32 -32
  441. package/oxe/workflows/scan.md +356 -355
  442. package/oxe/workflows/ship.md +91 -142
  443. package/oxe/workflows/size-budget.json +62 -0
  444. package/oxe/workflows/spec.md +615 -619
  445. package/oxe/workflows/swarm/board.md +119 -119
  446. package/oxe/workflows/swarm/scout.md +170 -170
  447. package/oxe/workflows/swarm-mode.md +280 -280
  448. package/oxe/workflows/ui-review.md +37 -37
  449. package/oxe/workflows/ui-spec.md +32 -32
  450. package/oxe/workflows/verify.md +273 -255
  451. package/package.json +134 -132
  452. package/packages/runtime/package.json +18 -18
  453. package/packages/runtime/src/compiler/graph-compiler.ts +349 -336
  454. package/packages/runtime/src/context/context-pack-builder.ts +339 -339
  455. package/packages/runtime/src/delivery/promotion-pipeline.ts +397 -342
  456. package/packages/runtime/src/events/catalog.ts +63 -45
  457. package/packages/runtime/src/executor/action-tool-map.ts +52 -50
  458. package/packages/runtime/src/executor/adapters/antigravity-cli.ts +619 -0
  459. package/packages/runtime/src/executor/adapters/claude-cli.ts +367 -285
  460. package/packages/runtime/src/executor/adapters/grok-cli.ts +392 -0
  461. package/packages/runtime/src/executor/adapters/http-openai.ts +16 -16
  462. package/packages/runtime/src/executor/adapters/registry.ts +53 -33
  463. package/packages/runtime/src/executor/adapters/types.ts +24 -24
  464. package/packages/runtime/src/executor/built-in-tools.ts +525 -333
  465. package/packages/runtime/src/executor/index.ts +23 -16
  466. package/packages/runtime/src/executor/llm-task-executor.ts +854 -336
  467. package/packages/runtime/src/executor/node-context.ts +226 -210
  468. package/packages/runtime/src/executor/node-prompt-builder.ts +69 -67
  469. package/packages/runtime/src/executor/quota-patterns.ts +41 -0
  470. package/packages/runtime/src/executor/shell-argv.ts +144 -66
  471. package/packages/runtime/src/executor/stream-completion.ts +230 -160
  472. package/packages/runtime/src/index.ts +56 -54
  473. package/packages/runtime/src/models/failure.ts +22 -13
  474. package/packages/runtime/src/models/run.ts +25 -24
  475. package/packages/runtime/src/plugins/capability-adapter.ts +313 -313
  476. package/packages/runtime/src/plugins/plugin-abi.ts +106 -106
  477. package/packages/runtime/src/plugins/plugin-registry.ts +241 -241
  478. package/packages/runtime/src/program/index.ts +1 -1
  479. package/packages/runtime/src/program/program-model.ts +293 -233
  480. package/packages/runtime/src/projection/projection-engine.ts +386 -361
  481. package/packages/runtime/src/reducers/run-state-reducer.ts +365 -329
  482. package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +1017 -1017
  483. package/packages/runtime/src/scheduler/run-journal.ts +107 -105
  484. package/packages/runtime/src/scheduler/scheduler.ts +2081 -1144
  485. package/packages/runtime/src/verification/contract-exports.ts +203 -203
  486. package/packages/runtime/src/verification/index.ts +3 -3
  487. package/packages/runtime/src/verification/runner-timeout.ts +17 -0
  488. package/packages/runtime/src/verification/test-report-parsers.ts +204 -198
  489. package/packages/runtime/src/verification/verification-compiler.ts +906 -766
  490. package/packages/runtime/src/verification/verification-manifest.ts +296 -281
  491. package/packages/runtime/src/workspace/index.ts +6 -5
  492. package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +159 -126
  493. package/packages/runtime/src/workspace/strategies/git-worktree.ts +190 -150
  494. package/packages/runtime/tsconfig.json +23 -23
  495. package/vscode-extension/.vscodeignore +9 -9
  496. package/vscode-extension/LICENSE +21 -21
  497. package/vscode-extension/package.json +193 -193
  498. package/vscode-extension/src/extension.js +320 -320
@@ -0,0 +1,1520 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * OXB-097: `oxe-cc plan build --from <role files…>` writes PLAN.json, PLAN.md and IMPLEMENTATION-PACK.json together.
5
+ * - covers `plan merge` (OXB-086) and then: waves also by file overlap (a hot file — written by two tasks of the same
6
+ * wave — serializes: the later task moves to the next wave), acceptance test files out of the task scopes;
7
+ * - pack symbols from the named imports of the frozen tests that resolve to a task's files, and from the role's
8
+ * `deleted` / `edited` / `created` paths; contracts from the symbols; the pack and PLAN.md carry the `phase`.
9
+ * OXB-098: `oxe-cc plan check-role <file> [--ref <git ref>]` — what the agents run BEFORE handing a plan to the TL:
10
+ * exact titles of `proves` in the frozen test files, prose × A ids, `deleted`/`edited` paths existing at the ref,
11
+ * `created` paths not existing there, the verify shape.
12
+ * OXB-106: declarative task kinds with their own pack rule — `add` (only created paths), `remove` (OXB-088:
13
+ * removed_paths, no symbols), `move` (`moves: [{from, to}]`), `test-only` (only test files, no product code),
14
+ * `config-only` (only config files, no symbols).
15
+ */
16
+
17
+ const fs = require('fs');
18
+ const path = require('path');
19
+ const { spawnSync } = require('child_process');
20
+ const merge = require('./oxe-plan-merge.cjs');
21
+
22
+ const TEST_FILE_RE = /(^|\/)(tests?|__tests__|spec|e2e)\/|\.(test|spec)\.[cm]?[jt]sx?$/i;
23
+ const NON_PROD_DIR_RE = /^(scripts|docs|roles|benchmarks|examples|fixtures|\.oxe|\.git|node_modules|dist|build|coverage)\//i;
24
+ const CONFIG_FILE_RE = /\.(json|ya?ml|toml|ini|env|cfg|conf|properties)$|(^|\/)\.[a-z]+rc(\.[a-z]+)?$|(^|\/)(Dockerfile|Makefile)$/i;
25
+ const CODE_RE = /\.(c|m)?[jt]sx?$|\.(py|go|rs|java|kt|kts|swift|rb|cs|cpp|c|h|php|scala|vue|svelte)$/i;
26
+ const RESOLVE_EXTS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mts', '.cts', '.vue', '.svelte'];
27
+ const KINDS = new Set(['add', 'remove', 'move', 'test-only', 'config-only']);
28
+ const norm = (p) => String(p).replace(/\\/g, '/').replace(/^\.\//, '');
29
+ const uniq = (xs) => [...new Set(xs.filter(Boolean))];
30
+
31
+ /** Product code: a code file that is not a test, a script, a doc or a generated folder. */
32
+ function isProductCode(file) {
33
+ const f = norm(file);
34
+ return CODE_RE.test(f) && !TEST_FILE_RE.test(f) && !NON_PROD_DIR_RE.test(f);
35
+ }
36
+
37
+ function inScope(file, scope) {
38
+ const f = norm(file);
39
+ for (const raw of scope || []) {
40
+ const s = norm(raw);
41
+ if (!s) continue;
42
+ if (/[*?[{]/.test(s)) {
43
+ const re = new RegExp(`^${s.replace(/[.+^$()|\\]/g, '\\$&').replace(/\*\*\/?/g, '\u0000').replace(/\*/g, '[^/]*').replace(/\?/g, '[^/]').replace(/\u0000/g, '.*')}$`);
44
+ if (re.test(f)) return true;
45
+ } else {
46
+ const clean = s.replace(/\/+$/, '');
47
+ if (f === clean || f.startsWith(`${clean}/`)) return true;
48
+ }
49
+ }
50
+ return false;
51
+ }
52
+
53
+ function isDirEntry(root, ref, entryPath) {
54
+ const raw = String(entryPath || '').trim();
55
+ if (raw.endsWith('/') || raw.endsWith('/**')) return true;
56
+ const cleaned = norm(raw).replace(/(\/\*\*|\/)+$/, '');
57
+ if (!cleaned) return false;
58
+ try {
59
+ const typeRes = spawnSync('git', ['cat-file', '-t', `${ref || 'HEAD'}:${cleaned}`], { cwd: root, encoding: 'utf8', windowsHide: true });
60
+ if (typeRes.status === 0 && typeRes.stdout.trim() === 'tree') return true;
61
+ } catch { /* check disk */ }
62
+ try {
63
+ const abs = path.resolve(root, cleaned);
64
+ return fs.existsSync(abs) && fs.statSync(abs).isDirectory();
65
+ } catch {
66
+ return false;
67
+ }
68
+ }
69
+
70
+ function expandDirEntry(root, ref, entryPath) {
71
+ const cleaned = norm(entryPath).replace(/(\/\*\*|\/)+$/, '');
72
+ const out = [];
73
+ try {
74
+ const gitRes = spawnSync('git', ['ls-tree', '-r', '--name-only', ref || 'HEAD', cleaned], { cwd: root, encoding: 'utf8', windowsHide: true });
75
+ if (gitRes.status === 0 && gitRes.stdout && gitRes.stdout.trim()) {
76
+ for (const line of gitRes.stdout.trim().split(/\r?\n/)) {
77
+ const p = norm(line);
78
+ if (p) out.push(p);
79
+ }
80
+ }
81
+ } catch { /* check disk */ }
82
+ if (!out.length) {
83
+ const abs = path.resolve(root, cleaned);
84
+ try {
85
+ if (fs.existsSync(abs) && fs.statSync(abs).isDirectory()) {
86
+ const walk = (d) => {
87
+ for (const ent of fs.readdirSync(d, { withFileTypes: true })) {
88
+ const full = path.join(d, ent.name);
89
+ if (ent.isDirectory()) walk(full);
90
+ else if (ent.isFile()) out.push(norm(path.relative(root, full)));
91
+ }
92
+ };
93
+ walk(abs);
94
+ }
95
+ } catch { /* ignore */ }
96
+ }
97
+ return uniq(out);
98
+ }
99
+
100
+ function filterDeletedFromVerifyCommand(cmd, deletedSet) {
101
+ if (!cmd || typeof cmd !== 'string') return null;
102
+ const segments = cmd.split(/\s+&&\s+/);
103
+ const keptSegments = [];
104
+ for (const seg of segments) {
105
+ const tokens = seg.split(/\s+/);
106
+ const matchingDeleted = tokens.filter((tok) => {
107
+ const cleanTok = norm(tok.replace(/^["']|["']$/g, ''));
108
+ return deletedSet.has(cleanTok);
109
+ });
110
+ if (!matchingDeleted.length) {
111
+ keptSegments.push(seg);
112
+ continue;
113
+ }
114
+ const remainingTokens = tokens.filter((tok) => {
115
+ const cleanTok = norm(tok.replace(/^["']|["']$/g, ''));
116
+ return !deletedSet.has(cleanTok);
117
+ });
118
+ const hasRemainingTestFile = remainingTokens.some((tok) => TEST_FILE_RE.test(norm(tok.replace(/^["']|["']$/g, ''))));
119
+ if (hasRemainingTestFile) {
120
+ keptSegments.push(remainingTokens.join(' '));
121
+ }
122
+ }
123
+ return keptSegments.length ? keptSegments.join(' && ') : null;
124
+ }
125
+
126
+ function transitiveDeletedForTask(task, allTasksById, roleByKey) {
127
+ const deleted = new Set();
128
+ const visited = new Set();
129
+ const queue = [task.id];
130
+ while (queue.length) {
131
+ const curId = queue.shift();
132
+ if (visited.has(curId)) continue;
133
+ visited.add(curId);
134
+ const curTask = allTasksById.get(curId);
135
+ const r = roleByKey.get(String(curTask && curTask.rid ? curTask.rid : curId)) || {};
136
+ for (const p of r.deleted || []) deleted.add(norm(p));
137
+ if (curTask && Array.isArray(curTask.removed_paths)) {
138
+ for (const p of curTask.removed_paths) deleted.add(norm(p));
139
+ }
140
+ const deps = curTask ? (curTask.depends_on || curTask.dependsOn || []) : [];
141
+ for (const d of deps) queue.push(d);
142
+ }
143
+ return deleted;
144
+ }
145
+
146
+ const OFFER_AUDIT_FILE = 'e2e/offer-audit.spec.ts';
147
+ const OFFER_AUDIT_TRIGGERS = [
148
+ 'src/components/Navigation/appMenus.ts',
149
+ 'src/components/Settings/SettingsModal.tsx',
150
+ ];
151
+ const DESIGN_LINT_TESTS = [
152
+ 'tests/design-lint.test.ts',
153
+ 'tests/design-lint-target-size.test.ts',
154
+ ];
155
+
156
+ function hasRepoFile(root, ref, relPath) {
157
+ if (!root) return false;
158
+ const clean = norm(relPath);
159
+ try {
160
+ if (fs.existsSync(path.join(root, clean))) return true;
161
+ } catch { /* check git */ }
162
+ try {
163
+ return spawnSync('git', ['cat-file', '-e', `${ref || 'HEAD'}:${clean}`], { cwd: root, windowsHide: true }).status === 0;
164
+ } catch {
165
+ return false;
166
+ }
167
+ }
168
+
169
+ function loadCoupledScope(root, options = {}) {
170
+ let explicit = [];
171
+ let builtinDisabled = options.builtinCoupledScope === false;
172
+ if (Array.isArray(options.coupledScope)) {
173
+ explicit = options.coupledScope;
174
+ } else if (root) {
175
+ try {
176
+ const cfgPath = path.join(root, '.oxe', 'config.json');
177
+ if (fs.existsSync(cfgPath)) {
178
+ const cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8'));
179
+ if (Array.isArray(cfg.coupled_scope)) explicit = cfg.coupled_scope;
180
+ if (cfg.builtin_coupled_scope === false || cfg.coupled_scope === false) builtinDisabled = true;
181
+ }
182
+ } catch { /* ignore */ }
183
+ }
184
+ const rules = [...explicit];
185
+ if (!builtinDisabled && root && (options.includeOfferAudit === true || hasRepoFile(root, options.ref || 'HEAD', OFFER_AUDIT_FILE))) {
186
+ const alreadyCoversOfferAudit = rules.some((r) => {
187
+ const inc = Array.isArray(r && r.include) ? r.include : (r && r.include ? [r.include] : []);
188
+ return inc.map(norm).includes(OFFER_AUDIT_FILE);
189
+ });
190
+ if (!alreadyCoversOfferAudit) {
191
+ rules.push({
192
+ when: OFFER_AUDIT_TRIGGERS,
193
+ include: [OFFER_AUDIT_FILE],
194
+ note: 'confira MENU_EFFECTS em e2e/offer-audit.spec.ts ao editar appMenus.ts ou SettingsModal.tsx',
195
+ });
196
+ }
197
+ }
198
+ return rules;
199
+ }
200
+
201
+ function matchedCoupledRules(coupledRules, changes) {
202
+ const toInclude = [];
203
+ const matchedRules = [];
204
+ const files = changes.files || [];
205
+ const created = changes.created || [];
206
+ const edited = changes.edited || [];
207
+ const deleted = changes.deleted || [];
208
+ const allChanges = [...files, ...created, ...edited, ...deleted];
209
+ for (const rule of coupledRules || []) {
210
+ if (!rule || typeof rule !== 'object') continue;
211
+ const when = rule.when ? (Array.isArray(rule.when) ? rule.when : [rule.when]) : [];
212
+ const whenDeleted = rule.when_deleted ? (Array.isArray(rule.when_deleted) ? rule.when_deleted : [rule.when_deleted]) : [];
213
+ const whenEdited = rule.when_edited ? (Array.isArray(rule.when_edited) ? rule.when_edited : [rule.when_edited]) : [];
214
+ const whenCreated = rule.when_created ? (Array.isArray(rule.when_created) ? rule.when_created : [rule.when_created]) : [];
215
+
216
+ const matchWhen = when.some((w) => allChanges.some((p) => inScope(p, [w])));
217
+ const matchDeleted = whenDeleted.some((w) => deleted.some((p) => inScope(p, [w])));
218
+ const matchEdited = whenEdited.some((w) => edited.some((p) => inScope(p, [w])));
219
+ const matchCreated = whenCreated.some((w) => created.some((p) => inScope(p, [w])));
220
+
221
+ if (matchWhen || matchDeleted || matchEdited || matchCreated) {
222
+ const inc = Array.isArray(rule.include) ? rule.include : (rule.include ? [rule.include] : []);
223
+ toInclude.push(...inc.map(norm));
224
+ matchedRules.push(rule);
225
+ }
226
+ }
227
+ return { included: uniq(toInclude), matchedRules };
228
+ }
229
+
230
+ function applyCoupledScope(coupledRules, changes) {
231
+ return matchedCoupledRules(coupledRules, changes).included;
232
+ }
233
+
234
+ /** Named imports of a test file that resolve to one of `files`: [{ name, path }]. */
235
+ function importedSymbols(root, testFile, files) {
236
+ let text = '';
237
+ try { text = fs.readFileSync(path.join(root, testFile), 'utf8'); } catch { return []; }
238
+ const out = [];
239
+ const dir = path.posix.dirname(norm(testFile));
240
+ const resolve = (spec) => {
241
+ if (!spec.startsWith('.')) return null;
242
+ const base = path.posix.normalize(path.posix.join(dir, spec));
243
+ return files.find((f) => { const n = norm(f); return n === base || n.replace(/\.[^.]+$/, '') === base || n.replace(/\/index\.[^.]+$/, '') === base; }) || null;
244
+ };
245
+ for (const m of text.matchAll(/import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g)) {
246
+ const file = resolve(m[2]);
247
+ if (file) for (const n of m[1].split(',').map((x) => x.trim().split(/\s+as\s+/)[0].trim()).filter(Boolean)) out.push({ name: n, path: norm(file) });
248
+ }
249
+ for (const m of text.matchAll(/const\s*\{([^}]+)\}\s*=\s*require\(\s*['"]([^'"]+)['"]\s*\)/g)) {
250
+ const file = resolve(m[2]);
251
+ if (file) for (const n of m[1].split(',').map((x) => x.trim().split(':')[0].trim()).filter(Boolean)) out.push({ name: n, path: norm(file) });
252
+ }
253
+ return out;
254
+ }
255
+
256
+ /** Waves by dependency AND by file overlap: a task never shares a written file with another task of its wave. */
257
+ function assignWaves(tasks) {
258
+ const byId = new Map(tasks.map((t) => [t.id, t]));
259
+ const waveFiles = new Map();
260
+ const wave = new Map();
261
+ for (const t of tasks) {
262
+ let w = Math.max(1, ...(t.depends_on || []).map((d) => (wave.get(d) || 0) + 1));
263
+ const files = (t.files || []).map(norm);
264
+ while ((waveFiles.get(w) || new Set()) && files.some((f) => (waveFiles.get(w) || new Set()).has(f))) w += 1;
265
+ wave.set(t.id, w);
266
+ if (!waveFiles.has(w)) waveFiles.set(w, new Set());
267
+ for (const f of files) waveFiles.get(w).add(f);
268
+ }
269
+ for (const t of tasks) t.wave = wave.get(t.id);
270
+ // dependents of a task moved later must stay after it
271
+ let changed = true;
272
+ while (changed) {
273
+ changed = false;
274
+ for (const t of tasks) for (const d of t.depends_on || []) if (byId.has(d) && t.wave <= byId.get(d).wave) { t.wave = byId.get(d).wave + 1; changed = true; }
275
+ }
276
+ return tasks;
277
+ }
278
+
279
+ /** Pack entry by kind (OXB-106). */
280
+ function packEntry(root, task, role, frozenFiles, frozenTests) {
281
+ const kind = task.kind && KINDS.has(task.kind) ? task.kind : null;
282
+ const deleted = uniq((role.deleted || []).map(norm));
283
+ const created = uniq((role.created || []).map(norm));
284
+ const edited = uniq((role.edited || []).map(norm));
285
+ const swept = uniq((role.swept || []).map(norm)).filter((f) => !frozenFiles.has(f));
286
+ const moves = Array.isArray(role.moves) ? role.moves.map((m) => ({ from: norm(m.from), to: norm(m.to) })) : [];
287
+ const exact = uniq([...(task.files || []).map(norm), ...deleted, ...created, ...edited, ...moves.flatMap((m) => [m.from, m.to])]).filter((f) => !frozenFiles.has(f));
288
+ const symbols = [];
289
+ for (const t of frozenTests) for (const s of importedSymbols(root, t, exact)) if (!symbols.some((x) => x.name === s.name && x.path === s.path)) symbols.push(s);
290
+ const editedClean = edited.filter((f) => !frozenFiles.has(f));
291
+ const symbolsRemoved = [];
292
+ for (const rt of Array.isArray(role.rawTasks) ? role.rawTasks : []) {
293
+ for (const sr of Array.isArray(rt.symbols_removed) ? rt.symbols_removed : []) {
294
+ if (sr && typeof sr === 'object' && sr.name && sr.path) {
295
+ const entrySr = { name: String(sr.name), path: norm(sr.path) };
296
+ if (!symbolsRemoved.some((x) => x.name === entrySr.name && x.path === entrySr.path)) symbolsRemoved.push(entrySr);
297
+ }
298
+ }
299
+ }
300
+ const entry = {
301
+ id: task.id,
302
+ mode: 'mutating',
303
+ write_set: 'closed',
304
+ exact_paths: exact,
305
+ ...(editedClean.length ? { edited_paths: editedClean } : {}),
306
+ ...(swept.length ? { swept_paths: swept } : {}),
307
+ ...(symbolsRemoved.length ? { symbols_removed: symbolsRemoved } : {}),
308
+ symbols,
309
+ contracts: [],
310
+ expected_checks: (task.verify && task.verify.commands) || [],
311
+ ...(task.phase ? { phase: task.phase } : {}),
312
+ };
313
+ for (const s of symbols) entry.contracts.push(`${s.name} exportado de ${s.path}`);
314
+ if (kind === 'remove' || deleted.length) { entry.removed_paths = uniq([...deleted, ...moves.map((m) => m.from)]); for (const p of entry.removed_paths) entry.contracts.push(`${p} não existe mais`); }
315
+ if (kind === 'move') for (const m of moves) { entry.removed_paths = uniq([...(entry.removed_paths || []), m.from]); entry.contracts.push(`${m.from} movido para ${m.to}`); }
316
+ if (kind === 'add') for (const p of created) entry.contracts.push(`${p} criado`);
317
+ if (kind === 'test-only') entry.contracts.push('só arquivos de teste: nenhum código de produto muda');
318
+ if (kind === 'config-only') entry.contracts.push('só configuração: nenhum código muda');
319
+ if (!entry.contracts.length && edited.length) for (const p of edited) entry.contracts.push(`${p} editado no escopo da tarefa`);
320
+ if (!entry.contracts.length) entry.contracts.push(`escopo fechado: ${exact.slice(0, 4).join(', ')}`);
321
+ return { entry, kind, created, deleted, moves, exact };
322
+ }
323
+
324
+ /** OXB-106: the kind rule — errors when the scope does not fit the declared kind. */
325
+ function kindErrors(task, info) {
326
+ const errs = [];
327
+ const f = info.exact;
328
+ if (info.kind === 'test-only' && f.some((p) => !TEST_FILE_RE.test(p))) errs.push(`${task.id} (test-only): ${f.filter((p) => !TEST_FILE_RE.test(p)).join(', ')} não é arquivo de teste`);
329
+ if (info.kind === 'config-only' && f.some((p) => !CONFIG_FILE_RE.test(p))) errs.push(`${task.id} (config-only): ${f.filter((p) => !CONFIG_FILE_RE.test(p)).join(', ')} não é configuração`);
330
+ if (info.kind === 'add' && info.deleted.length) errs.push(`${task.id} (add): declara deleted (${info.deleted.join(', ')}) — use remove ou move`);
331
+ if (info.kind === 'move' && !info.moves.length) errs.push(`${task.id} (move): declare moves: [{ from, to }]`);
332
+ if (info.kind === 'remove' && !info.deleted.length && !(task.files || []).length) errs.push(`${task.id} (remove): declare deleted (os caminhos que deixam de existir)`);
333
+ return errs;
334
+ }
335
+
336
+ function renderPlanMd(plan, phase) {
337
+ const lines = [`# PLAN${phase ? ` — ${phase}` : ''}`, '', `> Gerado por \`oxe-cc plan build\` a partir de ${plan.merged_from.join(', ')}. A fonte é o PLAN.json; este arquivo é a leitura humana.`, ''];
338
+ const waves = [...new Set(plan.tasks.map((t) => t.wave))].sort((a, b) => a - b);
339
+ for (const w of waves) {
340
+ lines.push(`## Onda ${w}`, '');
341
+ for (const t of plan.tasks.filter((x) => x.wave === w)) {
342
+ lines.push(
343
+ `### ${t.id} — ${t.title}`,
344
+ '',
345
+ `- **Arquivos prováveis:** ${(t.files || []).map((f) => `\`${f}\``).join(', ') || '—'}`,
346
+ `- **Depende de:** ${(t.depends_on || []).join(', ') || '—'}`,
347
+ `- **Onda:** ${t.wave}`,
348
+ ...(t.kind ? [`- **Tipo:** ${t.kind}`] : []),
349
+ ...(t.notes && String(t.notes).trim() ? [`- **Notas:** ${String(t.notes).trim().replace(/\r?\n/g, ' · ')}`] : []),
350
+ '- **Verificar:**',
351
+ ` - Comando: ${((t.verify && t.verify.commands) || []).map((c) => `\`${c}\``).join(' · ') || '—'}`,
352
+ `- **Aceite vinculado:** ${(t.acceptance || []).join(', ') || '—'}`,
353
+ '',
354
+ );
355
+ }
356
+ }
357
+ return lines.join('\n');
358
+ }
359
+
360
+ /** inputs: [{ file, doc }]; ctx: { root, phase, coupledScope, autoCloseImports }. */
361
+ function listProductionCodeFiles(root, ref = 'HEAD') {
362
+ const files = [];
363
+ try {
364
+ const gitRes = spawnSync('git', ['ls-tree', '-r', '--name-only', ref || 'HEAD'], { cwd: root, encoding: 'utf8', windowsHide: true });
365
+ if (gitRes.status === 0 && gitRes.stdout && gitRes.stdout.trim()) {
366
+ for (const line of gitRes.stdout.trim().split(/\r?\n/)) {
367
+ const p = norm(line);
368
+ if (p && CODE_RE.test(p) && !TEST_FILE_RE.test(p) && !NON_PROD_DIR_RE.test(p)) files.push(p);
369
+ }
370
+ return uniq(files);
371
+ }
372
+ } catch { /* fallback to disk */ }
373
+ const walk = (dir) => {
374
+ let entries = [];
375
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
376
+ for (const ent of entries) {
377
+ if (ent.name === 'node_modules' || ent.name === '.git' || ent.name === '.oxe') continue;
378
+ const full = path.join(dir, ent.name);
379
+ const rel = norm(path.relative(root, full));
380
+ if (ent.isDirectory()) {
381
+ if (!NON_PROD_DIR_RE.test(`${rel}/`)) walk(full);
382
+ } else if (ent.isFile() && CODE_RE.test(rel) && !TEST_FILE_RE.test(rel) && !NON_PROD_DIR_RE.test(rel)) {
383
+ files.push(rel);
384
+ }
385
+ }
386
+ };
387
+ walk(root);
388
+ return uniq(files);
389
+ }
390
+
391
+ function readRepoText(root, ref, relPath) {
392
+ const clean = norm(relPath);
393
+ if (!ref || ref === 'HEAD') {
394
+ try {
395
+ const abs = path.join(root, clean);
396
+ if (fs.existsSync(abs) && fs.statSync(abs).isFile()) return fs.readFileSync(abs, 'utf8');
397
+ } catch { /* try git */ }
398
+ }
399
+ try {
400
+ const res = spawnSync('git', ['show', `${ref || 'HEAD'}:${clean}`], { cwd: root, encoding: 'utf8', windowsHide: true });
401
+ if (res.status === 0 && typeof res.stdout === 'string') return res.stdout;
402
+ } catch { /* ignore */ }
403
+ try {
404
+ return fs.readFileSync(path.join(root, clean), 'utf8');
405
+ } catch {
406
+ return '';
407
+ }
408
+ }
409
+
410
+ function loadPathAliases(root) {
411
+ const aliases = [
412
+ { prefix: '@shared/', target: 'shared/' },
413
+ { prefix: '@electron/', target: 'electron/' },
414
+ { prefix: '@renderer/', target: 'src/' },
415
+ { prefix: '@/', target: 'src/' },
416
+ { prefix: '~/', target: 'src/' },
417
+ ];
418
+ try {
419
+ const tsPath = path.join(root, 'tsconfig.json');
420
+ if (fs.existsSync(tsPath)) {
421
+ const raw = fs.readFileSync(tsPath, 'utf8').replace(/^\s*\/\/.*$/gm, '');
422
+ const parsed = JSON.parse(raw);
423
+ const pathsObj = parsed && parsed.compilerOptions && parsed.compilerOptions.paths;
424
+ if (pathsObj && typeof pathsObj === 'object') {
425
+ const baseUrl = norm((parsed.compilerOptions && parsed.compilerOptions.baseUrl) || '');
426
+ for (const [k, vals] of Object.entries(pathsObj)) {
427
+ if (!Array.isArray(vals) || !vals.length) continue;
428
+ const pref = String(k).replace(/\*$/, '');
429
+ const tgtRaw = norm(String(vals[0]).replace(/\*$/, ''));
430
+ const tgt = baseUrl && baseUrl !== '.' ? norm(path.posix.join(baseUrl, tgtRaw)) : tgtRaw;
431
+ if (pref && !aliases.some((a) => a.prefix === pref)) {
432
+ aliases.unshift({ prefix: pref, target: tgt });
433
+ }
434
+ }
435
+ }
436
+ }
437
+ } catch { /* ignore non-strict jsonc tsconfig */ }
438
+ return aliases;
439
+ }
440
+
441
+ function resolveModuleSpecifier(importerFile, specifier, knownFilesSet, aliases = []) {
442
+ const spec = String(specifier || '').trim();
443
+ if (!spec) return null;
444
+ const bases = [];
445
+ if (spec.startsWith('.')) {
446
+ bases.push(norm(path.posix.normalize(path.posix.join(path.posix.dirname(norm(importerFile)), spec))));
447
+ } else {
448
+ for (const a of aliases) {
449
+ if (spec.startsWith(a.prefix)) {
450
+ bases.push(norm(path.posix.normalize(a.target + spec.slice(a.prefix.length))));
451
+ }
452
+ }
453
+ if (/^(src|electron|shared|resources)\//.test(spec)) {
454
+ bases.push(norm(spec));
455
+ }
456
+ }
457
+ for (const rawBase of bases) {
458
+ const strippedJs = rawBase.replace(/\.(?:[cm]?js|jsx)$/i, '');
459
+ const candidates = uniq([rawBase, strippedJs]);
460
+ for (const b of candidates) {
461
+ if (knownFilesSet.has(b)) return b;
462
+ for (const ext of RESOLVE_EXTS) {
463
+ if (knownFilesSet.has(`${b}${ext}`)) return `${b}${ext}`;
464
+ }
465
+ for (const ext of RESOLVE_EXTS) {
466
+ if (knownFilesSet.has(`${b}/index${ext}`)) return `${b}/index${ext}`;
467
+ }
468
+ }
469
+ }
470
+ return null;
471
+ }
472
+
473
+ function parseNamedClause(clause) {
474
+ const names = [];
475
+ let wildcard = /\*\s+as\s+[A-Za-z_$][\w$]*/.test(clause);
476
+ const braceMatch = clause.match(/\{([^}]+)\}/);
477
+ if (braceMatch) {
478
+ for (const part of braceMatch[1].split(',')) {
479
+ const cleaned = part.replace(/^\s*type\s+/, '').trim();
480
+ if (!cleaned) continue;
481
+ const orig = cleaned.split(/\s+as\s+/)[0].trim();
482
+ if (orig) names.push(orig);
483
+ }
484
+ }
485
+ const beforeBrace = clause.replace(/\{[^}]*\}/g, '').replace(/^\s*type\s+/, '').replace(/,/g, ' ').trim();
486
+ if (beforeBrace && !beforeBrace.startsWith('*')) {
487
+ const defName = beforeBrace.split(/\s+/)[0].trim();
488
+ if (defName) names.push('default');
489
+ }
490
+ if (clause.trim() === '*') wildcard = true;
491
+ return { names: uniq(names), wildcard };
492
+ }
493
+
494
+ function extractModuleImports(text) {
495
+ const out = [];
496
+ const src = String(text || '');
497
+ // import ... from 'spec' and export ... from 'spec'
498
+ for (const m of src.matchAll(/\b(?:import|export)\s+([\s\S]*?)\s+from\s*['"]([^'"]+)['"]/g)) {
499
+ const parsed = parseNamedClause(m[1]);
500
+ out.push({ specifier: m[2], names: parsed.names, wildcard: parsed.wildcard, isReExport: m[0].startsWith('export') });
501
+ }
502
+ // side-effect import 'spec'
503
+ for (const m of src.matchAll(/\bimport\s*['"]([^'"]+)['"]/g)) {
504
+ out.push({ specifier: m[1], names: [], wildcard: false, isReExport: false });
505
+ }
506
+ // dynamic import('spec') and require('spec')
507
+ for (const m of src.matchAll(/\b(?:import|require)\s*\(\s*['"]([^'"]+)['"]\s*\)/g)) {
508
+ out.push({ specifier: m[1], names: [], wildcard: true, isReExport: false });
509
+ }
510
+ // vitest / jest module mocks: vi.mock('spec'), vi.importActual('spec'), jest.mock('spec')
511
+ for (const m of src.matchAll(/\b(?:vi|jest)\.(?:mock|doMock|importActual|requireActual)\s*\(\s*['"]([^'"]+)['"]/g)) {
512
+ out.push({ specifier: m[1], names: [], wildcard: true, isReExport: false });
513
+ }
514
+ return out;
515
+ }
516
+
517
+ function extractExportedUnions(text) {
518
+ const unions = [];
519
+ const src = String(text || '');
520
+ // export type Foo = 'a' | 'b' (single or multi-line up to `;` or next `export`/`type`/`interface`/`const`/`function`)
521
+ for (const m of src.matchAll(/\bexport\s+type\s+([A-Z][A-Za-z0-9_]*)\s*=\s*([^;]+?)(?:;|\n(?=\s*(?:export|type|interface|const|let|var|function|class|\/\*\*)\b)|$)/g)) {
522
+ if (m[2] && m[2].includes('|')) unions.push(m[1]);
523
+ }
524
+ for (const m of src.matchAll(/\bexport\s+(?:const\s+)?enum\s+([A-Z][A-Za-z0-9_]*)\b/g)) {
525
+ unions.push(m[1]);
526
+ }
527
+ return uniq(unions);
528
+ }
529
+
530
+ function extractExhaustiveRecordKeys(text) {
531
+ const keys = [];
532
+ const src = String(text || '');
533
+ for (const m of src.matchAll(/\b(Partial\s*<\s*)?Record\s*<\s*(?:Readonly\s*<\s*)?([A-Z][A-Za-z0-9_]*)\b/g)) {
534
+ if (!m[1]) keys.push(m[2]);
535
+ }
536
+ for (const m of src.matchAll(/\[\s*[A-Za-z_$][\w$]*\s+in\s+([A-Z][A-Za-z0-9_]*)\s*\](?!\s*\?)/g)) {
537
+ keys.push(m[1]);
538
+ }
539
+ return uniq(keys);
540
+ }
541
+
542
+ function buildImportIndex(root, ref = 'HEAD') {
543
+ const files = listProductionCodeFiles(root, ref);
544
+ const known = new Set(files);
545
+ const aliases = loadPathAliases(root);
546
+ const byFile = new Map();
547
+ for (const f of files) {
548
+ const text = readRepoText(root, ref, f);
549
+ const rawImports = extractModuleImports(text);
550
+ const resolvedImports = [];
551
+ for (const imp of rawImports) {
552
+ const target = resolveModuleSpecifier(f, imp.specifier, known, aliases);
553
+ if (target) resolvedImports.push({ ...imp, target });
554
+ }
555
+ byFile.set(f, {
556
+ file: f,
557
+ text,
558
+ imports: resolvedImports,
559
+ exportedUnions: extractExportedUnions(text),
560
+ exhaustiveRecordKeys: extractExhaustiveRecordKeys(text),
561
+ });
562
+ }
563
+ return { files, known, byFile };
564
+ }
565
+
566
+ /** OXB-199: 1-hop reverse importers in production code for newly deleted paths. */
567
+ function findOrphanImporters(index, newlyDeletedPaths, declaredScope = [], alreadyDeletedSet = new Set()) {
568
+ const targetSet = new Set((newlyDeletedPaths || []).map(norm).filter((p) => p && !alreadyDeletedSet.has(p)));
569
+ if (!targetSet.size) return [];
570
+ const orphans = [];
571
+ for (const [file, info] of index.byFile.entries()) {
572
+ if (alreadyDeletedSet.has(file) || targetSet.has(file)) continue;
573
+ if (inScope(file, declaredScope)) continue;
574
+ if (info.imports.some((imp) => targetSet.has(imp.target))) {
575
+ orphans.push(file);
576
+ }
577
+ }
578
+ return orphans.sort();
579
+ }
580
+
581
+ /**
582
+ * OXB-198: When a removal task edits a file exporting a union type/enum (e.g. `AppView` in `keybindings.ts`),
583
+ * find production files that import that union type (directly or via 1-hop barrel re-export) and use it as an
584
+ * exhaustive `Record<UnionType, ...>` or `[K in UnionType]` key (e.g. `viewSwitch.ts`, `ShortcutGuide.tsx`).
585
+ */
586
+ function findCoupledUnionConsumers(index, editedFiles, declaredScope = [], deletedSet = new Set()) {
587
+ const unionSources = new Map(); // TypeName -> Set<sourceFile | barrelFile>
588
+ for (const rawFile of editedFiles || []) {
589
+ const f = norm(rawFile);
590
+ if (deletedSet.has(f)) continue;
591
+ const info = index.byFile.get(f);
592
+ if (!info || !info.exportedUnions.length) continue;
593
+ for (const typeName of info.exportedUnions) {
594
+ if (!unionSources.has(typeName)) unionSources.set(typeName, new Set());
595
+ unionSources.get(typeName).add(f);
596
+ }
597
+ }
598
+ if (!unionSources.size) return [];
599
+ // Include 1-hop barrel re-exporters (`export * from` or `export { AppView } from`)
600
+ for (const [file, info] of index.byFile.entries()) {
601
+ for (const imp of info.imports) {
602
+ if (!imp.isReExport) continue;
603
+ for (const [typeName, sources] of unionSources.entries()) {
604
+ if (sources.has(imp.target) && (imp.wildcard || imp.names.includes(typeName))) {
605
+ sources.add(file);
606
+ }
607
+ }
608
+ }
609
+ }
610
+ const coupled = [];
611
+ for (const [file, info] of index.byFile.entries()) {
612
+ if (deletedSet.has(file) || inScope(file, declaredScope)) continue;
613
+ if (!info.exhaustiveRecordKeys.length) continue;
614
+ for (const typeName of info.exhaustiveRecordKeys) {
615
+ const sources = unionSources.get(typeName);
616
+ if (!sources) continue;
617
+ const importsType = info.imports.some((imp) => sources.has(imp.target) && (imp.wildcard || imp.names.includes(typeName)));
618
+ if (importsType) {
619
+ coupled.push(file);
620
+ break;
621
+ }
622
+ }
623
+ }
624
+ return uniq(coupled).sort();
625
+ }
626
+
627
+ /** OXB-201: role path lists accept `edited`/`edited_paths`, `deleted`/`deleted_paths`, `created`/`created_paths`. */
628
+ function rolePathList(t, field) {
629
+ if (!t) return [];
630
+ const a = Array.isArray(t[field]) ? t[field] : [];
631
+ const b = Array.isArray(t[`${field}_paths`]) ? t[`${field}_paths`] : [];
632
+ return uniq([...a, ...b].map(norm));
633
+ }
634
+
635
+ /** OXB-201: renames in the recent history at `ref` (`git log --diff-filter=R`): [{ from, to }]. */
636
+ function recentRenames(root, ref = 'HEAD', max = 500) {
637
+ const out = [];
638
+ try {
639
+ const r = spawnSync('git', ['log', '--diff-filter=R', '-M', '--name-status', '--format=', `-n${max}`, ref || 'HEAD'], { cwd: root, encoding: 'utf8', windowsHide: true, maxBuffer: 64 * 1024 * 1024 });
640
+ if (r.status !== 0) return out;
641
+ for (const line of String(r.stdout || '').split(/\r?\n/)) {
642
+ const m = /^R\d*\t([^\t]+)\t([^\t]+)$/.exec(line.trim());
643
+ if (m) out.push({ from: norm(m[1]), to: norm(m[2]) });
644
+ }
645
+ } catch { /* no git */ }
646
+ return out;
647
+ }
648
+
649
+ /**
650
+ * OXB-201: the real path of a stale `edited`/`deleted` entry — the target of a rename of that exact path, or the single
651
+ * renamed file with the same basename that exists at `ref`. null when there is no candidate or more than one.
652
+ */
653
+ function staleSuggestion(root, ref, p, renames) {
654
+ const clean = norm(p);
655
+ const exists = (x) => gitHas(root, ref, x);
656
+ // follow a rename chain of the exact path (a → b → c)
657
+ let cur = clean;
658
+ const seen = new Set();
659
+ for (;;) {
660
+ const hit = renames.find((r) => r.from === cur);
661
+ if (!hit || seen.has(hit.to)) break;
662
+ seen.add(hit.to);
663
+ cur = hit.to;
664
+ }
665
+ if (cur !== clean && exists(cur)) return cur;
666
+ const base = path.posix.basename(clean);
667
+ const cands = uniq(renames.filter((r) => path.posix.basename(r.to) === base).map((r) => r.to)).filter(exists);
668
+ return cands.length === 1 ? cands[0] : null;
669
+ }
670
+
671
+ /**
672
+ * OXB-201: `edited`/`deleted` entries (of every role task, in order) that do not exist at `ref`, skipping paths created
673
+ * by an earlier task of the phase. Returns [{ index, rid, field, path, suggestion }].
674
+ */
675
+ function staleRolePaths(root, ref, tasks) {
676
+ const out = [];
677
+ const createdBefore = new Set();
678
+ let renames = null;
679
+ for (const [i, t] of (tasks || []).entries()) {
680
+ if (!t) continue;
681
+ for (const field of ['edited', 'deleted']) {
682
+ for (const p of rolePathList(t, field)) {
683
+ if (!p || /[*?[{]/.test(p)) continue;
684
+ if (createdBefore.has(p) || gitHas(root, ref, p)) continue;
685
+ if (!renames) renames = recentRenames(root, ref);
686
+ out.push({ index: i, rid: t.rid || t.id || null, field, path: p, suggestion: staleSuggestion(root, ref, p, renames) });
687
+ }
688
+ }
689
+ for (const p of rolePathList(t, 'created')) createdBefore.add(p);
690
+ }
691
+ return out;
692
+ }
693
+
694
+ /** OXB-201: replaces a stale path by its suggestion in the role task (edited/deleted/files and their *_paths). */
695
+ function applyStaleFix(t, stale) {
696
+ for (const key of [stale.field, `${stale.field}_paths`, 'files']) {
697
+ if (Array.isArray(t[key])) t[key] = uniq(t[key].map((x) => (norm(x) === stale.path ? stale.suggestion : norm(x))));
698
+ }
699
+ }
700
+
701
+ function staleMessage(at, s, ref) {
702
+ return `${at}: ${s.path} não existe em ${ref} (declarado como ${s.field})${s.suggestion ? ` — movido para ${s.suggestion}? (use --fix-stale-paths para corrigir)` : ''}`;
703
+ }
704
+
705
+ /** OXB-202: files whose change makes the third-party notices stale. */
706
+ const DEPENDENCY_MANIFEST_RE = /(^|\/)(package\.json|package-lock\.json)$/;
707
+ const NOTICES_FILE = 'THIRD_PARTY_NOTICES.md';
708
+
709
+ function readPackageScripts(root) {
710
+ try {
711
+ const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
712
+ return pkg && pkg.scripts && typeof pkg.scripts === 'object' ? pkg.scripts : {};
713
+ } catch {
714
+ return {};
715
+ }
716
+ }
717
+
718
+ /**
719
+ * OXB-202: when a task of the phase edits package.json / package-lock.json, the plan gets the `notices` phase gate
720
+ * (`npm run notices:check`) and the task gets THIRD_PARTY_NOTICES.md in its scope (when the repo has it).
721
+ */
722
+ function injectNoticesGate(root, ref, plan, warnings) {
723
+ const touching = plan.tasks.filter((t) => (t.files || []).some((f) => DEPENDENCY_MANIFEST_RE.test(norm(f)) && !/node_modules\//.test(f)));
724
+ if (!touching.length) return null;
725
+ const scripts = readPackageScripts(root);
726
+ const hasNotices = gitHas(root, ref, NOTICES_FILE) || fs.existsSync(path.join(root, NOTICES_FILE));
727
+ for (const t of touching) {
728
+ if (hasNotices && !(t.files || []).includes(NOTICES_FILE)) {
729
+ t.files = uniq([...(t.files || []), NOTICES_FILE]);
730
+ warnings.push(`${t.id}: muda ${t.files.filter((f) => DEPENDENCY_MANIFEST_RE.test(f)).join(', ')} — ${NOTICES_FILE} entrou no escopo (rode npm run notices:generate na tarefa)`);
731
+ }
732
+ }
733
+ if (typeof scripts['notices:check'] !== 'string') {
734
+ warnings.push(`${touching.map((t) => t.id).join(', ')} muda(m) package.json/lockfile, mas o package.json não tem o script notices:check — confira as licenças de terceiros antes do PR`);
735
+ return null;
736
+ }
737
+ const gates = Array.isArray(plan.phase_gates) ? plan.phase_gates : [];
738
+ if (!gates.some((g) => g && (g.id === 'notices' || String(g.command || '').includes('notices:check')))) {
739
+ gates.push({ id: 'notices', command: 'npm run notices:check', description: `licenças de terceiros em dia (${touching.map((t) => t.id).join(', ')} muda(m) package.json/lockfile)` });
740
+ }
741
+ plan.phase_gates = gates;
742
+ return 'notices';
743
+ }
744
+
745
+ /** OXB-203: the IPC contract files (shared channel types + the renderer's window typing) and the e2e IPC mock. */
746
+ const IPC_CONTRACT_FILES = ['src/types/window.d.ts', 'shared/types/ipc.ts'];
747
+ const IPC_CONSUMER_FILES = ['electron/main/e2e/mock-ipc.ts'];
748
+ const IPC_CONSUMER_RE = /\bwindow\.oxe\b|mock-ipc/;
749
+
750
+ function isFrontendTask(t) {
751
+ return (t.roles || []).some((r) => /front|^fe$|^ui$|renderer/i.test(String(r)))
752
+ || /^FE-/i.test(String(t.rid || ''))
753
+ || (Array.isArray(t.ids) && t.ids.some((id) => /(?:^|:)FE-/i.test(String(id))));
754
+ }
755
+
756
+ /**
757
+ * OXB-207: every `FE-*` / frontend task that creates or edits `.tsx` / `.css` under `src/` automatically includes
758
+ * `tests/design-lint.test.ts` and `tests/design-lint-target-size.test.ts` (when present in the repo) in `verify.commands`.
759
+ */
760
+ function injectFrontendDesignLintVerify(root, ref, task, roleInfo = {}, taskDeleted = [], overrideTests = null) {
761
+ const isFe = isFrontendTask(task)
762
+ || (Array.isArray(roleInfo.rawTasks) && roleInfo.rawTasks.some((rt) => rt && /^FE-/i.test(String(rt.id || rt.rid || ''))));
763
+ if (!isFe) return [];
764
+ const delSet = new Set((taskDeleted || []).map(norm));
765
+ const touchedUi = uniq([
766
+ ...(roleInfo.created || []),
767
+ ...(roleInfo.edited || []),
768
+ ...(task.files || []),
769
+ ...((roleInfo.moves || []).map((m) => m.to)),
770
+ ].map(norm)).filter((p) => !delSet.has(p) && !TEST_FILE_RE.test(p) && /^src\/.+\.(?:tsx|css)$/i.test(p));
771
+ if (!touchedUi.length) return [];
772
+
773
+ const candidates = Array.isArray(overrideTests)
774
+ ? overrideTests.map(norm)
775
+ : DESIGN_LINT_TESTS.filter((f) => hasRepoFile(root, ref, f) && !delSet.has(f));
776
+ if (!candidates.length) return [];
777
+
778
+ const existingCmds = (task.verify && Array.isArray(task.verify.commands))
779
+ ? [...task.verify.commands]
780
+ : (typeof task.verify === 'string' ? [task.verify] : []);
781
+ const missingTests = candidates.filter((tf) => !existingCmds.some((c) => String(c).includes(tf)));
782
+ if (missingTests.length) {
783
+ existingCmds.push(`npx vitest run ${missingTests.join(' ')}`);
784
+ task.verify = {
785
+ ...(task.verify && typeof task.verify === 'object' && !Array.isArray(task.verify) ? task.verify : {}),
786
+ commands: existingCmds,
787
+ };
788
+ }
789
+ return missingTests;
790
+ }
791
+
792
+ /**
793
+ * OXB-203 (`--pair-as-deps`): a frontend task that consumes `window.oxe` / the e2e IPC mock depends on the tasks of the
794
+ * phase that edit the IPC contract (src/types/window.d.ts, shared/types/ipc.ts) — never the other way round, and never
795
+ * when it would close a cycle. Returns [{ task, added: [ids] }].
796
+ */
797
+ function pairIpcDependencies(root, ref, tasks, options = {}) {
798
+ const contract = (options.contractFiles || IPC_CONTRACT_FILES).map(norm);
799
+ const consumerFiles = (options.consumerFiles || IPC_CONSUMER_FILES).map(norm);
800
+ const producers = tasks.filter((t) => (t.files || []).some((f) => contract.includes(norm(f))));
801
+ if (!producers.length) return [];
802
+ const byId = new Map(tasks.map((t) => [t.id, t]));
803
+ const dependsOn = (a, b, seen = new Set()) => { // does a depend (transitively) on b?
804
+ if (a === b) return true;
805
+ if (seen.has(a)) return false;
806
+ seen.add(a);
807
+ return ((byId.get(a) || {}).depends_on || []).some((d) => dependsOn(d, b, seen));
808
+ };
809
+ const out = [];
810
+ for (const t of tasks) {
811
+ if (!isFrontendTask(t) || producers.includes(t)) continue;
812
+ const files = (t.files || []).map(norm);
813
+ const consumes = files.some((f) => consumerFiles.includes(f)) || files.some((f) => CODE_RE.test(f) && IPC_CONSUMER_RE.test(readRepoText(root, ref, f)));
814
+ if (!consumes) continue;
815
+ const added = [];
816
+ for (const p of producers) {
817
+ if ((t.depends_on || []).includes(p.id) || dependsOn(p.id, t.id)) continue;
818
+ t.depends_on = uniq([...(t.depends_on || []), p.id]);
819
+ added.push(p.id);
820
+ }
821
+ if (added.length) out.push({ task: t.id, added });
822
+ }
823
+ return out;
824
+ }
825
+
826
+ const GENERIC_EXPORT_NAMES = new Set([
827
+ 'init', 'index', 'main', 'default', 'types', 'config', 'state', 'store', 'props',
828
+ 'utils', 'helper', 'helpers', 'render', 'setup', 'start', 'close', 'reset', 'create',
829
+ 'update', 'remove', 'delete', 'open', 'read', 'write', 'list', 'load', 'save',
830
+ ]);
831
+ const GENERIC_FEATURE_DIRS = new Set([
832
+ 'common', 'shared', 'layout', 'navigation', 'modal', 'modals', 'icons', 'keyboard',
833
+ 'editor', 'utils', 'hooks', 'types', 'store', 'stores', 'services', 'components',
834
+ 'main', 'renderer', 'preload', 'ipc', 'lib', 'core', 'app', 'ui', 'views', 'modes',
835
+ ]);
836
+ const URL_SCHEMES = new Set([
837
+ 'http', 'https', 'file', 'data', 'node', 'ws', 'wss', 'mailto', 'about', 'chrome',
838
+ 'javascript', 'devtools', 'electron', 'app', 'oxe', 'backend', 'frontend', 'stress',
839
+ ]);
840
+
841
+ function listAllRepoFiles(root, ref = 'HEAD') {
842
+ const files = [];
843
+ try {
844
+ const gitRes = spawnSync('git', ['ls-tree', '-r', '--name-only', ref || 'HEAD'], {
845
+ cwd: root,
846
+ encoding: 'utf8',
847
+ windowsHide: true,
848
+ maxBuffer: 16 * 1024 * 1024,
849
+ });
850
+ if (gitRes.status === 0 && gitRes.stdout && gitRes.stdout.trim()) {
851
+ for (const line of gitRes.stdout.trim().split(/\r?\n/)) {
852
+ const p = norm(line);
853
+ if (p) files.push(p);
854
+ }
855
+ return uniq(files);
856
+ }
857
+ } catch { /* fallback to disk */ }
858
+ const walk = (dir) => {
859
+ let entries = [];
860
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
861
+ for (const ent of entries) {
862
+ if (['node_modules', '.git', '.oxe', 'dist', 'build', 'coverage'].includes(ent.name)) continue;
863
+ const full = path.join(dir, ent.name);
864
+ const rel = norm(path.relative(root, full));
865
+ if (ent.isDirectory()) walk(full);
866
+ else if (ent.isFile()) files.push(rel);
867
+ }
868
+ };
869
+ walk(root);
870
+ return uniq(files);
871
+ }
872
+
873
+ function extractExportedSymbols(text) {
874
+ const out = [];
875
+ const src = String(text || '');
876
+ for (const m of src.matchAll(/\bexport\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|var|class|type|interface|enum)\s+([A-Za-z_$][\w$]*)/g)) {
877
+ if (m[1]) out.push(m[1]);
878
+ }
879
+ for (const m of src.matchAll(/\bexport\s*\{([^}]+)\}(?!\s*from\b)/g)) {
880
+ for (const part of m[1].split(',')) {
881
+ const cleaned = part.replace(/^\s*type\s+/, '').trim();
882
+ if (!cleaned) continue;
883
+ const parts = cleaned.split(/\s+as\s+/);
884
+ const exported = (parts[1] || parts[0] || '').trim();
885
+ if (exported && exported !== 'default') out.push(exported);
886
+ }
887
+ }
888
+ return uniq(out);
889
+ }
890
+
891
+ function escapeRegExp(s) {
892
+ return String(s).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
893
+ }
894
+
895
+ function hasStringLiteral(text, lit) {
896
+ if (!lit) return false;
897
+ return text.includes(`'${lit}'`) || text.includes(`"${lit}"`) || text.includes(`\`${lit}\``);
898
+ }
899
+
900
+ function toKebabSlug(name) {
901
+ return String(name || '')
902
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
903
+ .replace(/[_\s]+/g, '-')
904
+ .toLowerCase();
905
+ }
906
+
907
+ /**
908
+ * OXB-206: On removal tasks (deleting files under src/ | electron/ | shared/, or removing IPC channels / modes / routes),
909
+ * sweep non-frozen legacy tests (tests/ excluding tests/acceptance/), e2e/, appMenus.ts, and
910
+ * docs/security/threat-model-*.md for removed imports, symbols, IPC channels, modes, and routes.
911
+ */
912
+ function sweepRemovalImpacts(root, ref, task, roleInfo, sweepCtx = {}) {
913
+ const deletedBefore = sweepCtx.deletedBefore || new Set();
914
+ const frozenFiles = sweepCtx.frozenFiles || new Set();
915
+ const allRepoFiles = sweepCtx.allRepoFiles || listAllRepoFiles(root, ref);
916
+ const aliases = sweepCtx.aliases || loadPathAliases(root);
917
+ const textCache = sweepCtx.textCache || new Map();
918
+ const readText = (f) => {
919
+ if (!textCache.has(f)) textCache.set(f, readRepoText(root, ref, f));
920
+ return textCache.get(f);
921
+ };
922
+
923
+ const taskDeleted = uniq([
924
+ ...((roleInfo && roleInfo.deleted) || []).map(norm),
925
+ ...(((roleInfo && roleInfo.moves) || []).map((m) => norm(m.from))),
926
+ ]);
927
+ const newlyDeleted = taskDeleted.filter((p) => !deletedBefore.has(p));
928
+ const deletedProd = newlyDeleted.filter((p) => /^(src|electron|shared)\//.test(p));
929
+ const rawTasks = Array.isArray(roleInfo && roleInfo.rawTasks) ? roleInfo.rawTasks : [];
930
+
931
+ const explicitSymbols = new Set();
932
+ const explicitChannels = new Set();
933
+ const explicitLiterals = new Set();
934
+
935
+ for (const rt of rawTasks) {
936
+ for (const s of [...(rt.removed_symbols || []), ...(rt.symbols_removed || [])]) {
937
+ const name = typeof s === 'string' ? s.trim() : (s && s.name ? String(s.name).trim() : '');
938
+ if (name) explicitSymbols.add(name);
939
+ }
940
+ for (const ch of [...(rt.removed_channels || []), ...(rt.ipc_channels_removed || [])]) {
941
+ if (typeof ch === 'string' && ch.trim()) explicitChannels.add(ch.trim());
942
+ }
943
+ for (const lit of [
944
+ ...(rt.removed_modes || []),
945
+ ...(rt.modes_removed || []),
946
+ ...(rt.removed_routes || []),
947
+ ...(rt.routes_removed || []),
948
+ ...(rt.removed_views || []),
949
+ ...(rt.views_removed || []),
950
+ ]) {
951
+ if (typeof lit === 'string' && lit.trim()) explicitLiterals.add(lit.trim());
952
+ }
953
+ }
954
+
955
+ const hasExplicitRemovals = explicitSymbols.size > 0 || explicitChannels.size > 0 || explicitLiterals.size > 0;
956
+ const isRemovalTask =
957
+ task.kind === 'remove'
958
+ || deletedProd.length > 0
959
+ || hasExplicitRemovals
960
+ || /\b(remov|drop|strip|retir|delet)/i.test(String(task.title || ''));
961
+ if (!isRemovalTask) return { swept: [], legacyTests: [], e2eSpecs: [], menuFiles: [], threatModelDocs: [] };
962
+
963
+ // Extract quoted/backticked IPC channels, routes, and mode/tool literals from removal task title & notes
964
+ const prose = `${task.title || ''}\n${task.notes || ''}`;
965
+ for (const m of prose.matchAll(/(?:^|[\s'"`(,])([a-z][a-z0-9-]*:[a-z0-9][\w:-]*)(?=$|[\s'"`),.;])/g)) {
966
+ const ch = m[1];
967
+ const scheme = ch.split(':')[0];
968
+ if (!URL_SCHEMES.has(scheme)) explicitChannels.add(ch);
969
+ }
970
+ for (const m of prose.matchAll(/['"`]([^'"`\s]{3,60})['"`]/g)) {
971
+ const tok = m[1].trim();
972
+ if (!tok || /^[AG]\d+(?:\.\d+)?$/.test(tok)) continue;
973
+ if (/\.[a-z0-9]{1,5}$/i.test(tok) || tok.includes('/src/') || tok.includes('/electron/')) continue;
974
+ if (tok.includes(':')) {
975
+ const scheme = tok.split(':')[0];
976
+ if (!URL_SCHEMES.has(scheme)) explicitChannels.add(tok);
977
+ continue;
978
+ }
979
+ if (tok.startsWith('/') || /^(?:tool|view|mode|tab|nav)-[a-z0-9-]+$/i.test(tok) || /^[a-z][a-z0-9-]{2,}$/.test(tok)) {
980
+ explicitLiterals.add(tok);
981
+ } else if (/^[A-Za-z_$][\w$]{3,}$/.test(tok)) {
982
+ explicitSymbols.add(tok);
983
+ }
984
+ }
985
+
986
+ const allDeletedSet = new Set([...deletedBefore, ...taskDeleted]);
987
+
988
+ // Surviving production exports and IPC handlers (to prevent false-positive symbol/channel collisions)
989
+ const survivingExports = new Set();
990
+ const survivingIpcHandlers = new Set();
991
+ if (deletedProd.length) {
992
+ for (const f of allRepoFiles) {
993
+ if (allDeletedSet.has(f) || !/^(src|electron|shared)\//.test(f) || !CODE_RE.test(f) || TEST_FILE_RE.test(f)) continue;
994
+ const txt = readText(f);
995
+ for (const sym of extractExportedSymbols(txt)) survivingExports.add(sym);
996
+ if (f.startsWith('electron/')) {
997
+ for (const hm of txt.matchAll(/\b(?:ipcMain\.(?:handle|on)|handleIpc)\s*\(\s*['"`]([^'"`]+)['"`]/g)) {
998
+ survivingIpcHandlers.add(hm[1]);
999
+ }
1000
+ }
1001
+ }
1002
+ }
1003
+
1004
+ const inferredSymbols = new Set();
1005
+ const inferredChannels = new Set();
1006
+ const featureSlugs = new Set();
1007
+ const deletedDirPrefixes = new Set();
1008
+
1009
+ for (const rawDel of (roleInfo && roleInfo.rawDeleted) || []) {
1010
+ const cleaned = norm(rawDel).replace(/(\/\*\*|\/)+$/, '');
1011
+ if (/^(src|electron|shared)\//.test(cleaned) && isDirEntry(root, ref, rawDel)) {
1012
+ deletedDirPrefixes.add(cleaned);
1013
+ }
1014
+ }
1015
+
1016
+ for (const f of deletedProd) {
1017
+ const txt = readText(f);
1018
+ for (const sym of extractExportedSymbols(txt)) {
1019
+ if (sym.length >= 4 && !GENERIC_EXPORT_NAMES.has(sym.toLowerCase()) && !survivingExports.has(sym)) {
1020
+ inferredSymbols.add(sym);
1021
+ }
1022
+ }
1023
+ for (const cm of txt.matchAll(/['"`]([a-z][a-z0-9-]*:[a-z0-9][\w:-]*)['"`]/g)) {
1024
+ const ch = cm[1];
1025
+ const scheme = ch.split(':')[0];
1026
+ if (!URL_SCHEMES.has(scheme) && !survivingIpcHandlers.has(ch)) {
1027
+ inferredChannels.add(ch);
1028
+ }
1029
+ }
1030
+ const segMatch = /^(?:src\/(?:components|views|modes|features)|electron\/main\/services)\/([^/]+)(?:\/|$)/.exec(f);
1031
+ if (segMatch && segMatch[1]) {
1032
+ const segBase = segMatch[1].replace(/\.[^.]+$/, '');
1033
+ const slug = toKebabSlug(segBase);
1034
+ if (slug.length >= 4 && !GENERIC_FEATURE_DIRS.has(slug) && !GENERIC_FEATURE_DIRS.has(segBase.toLowerCase())) {
1035
+ featureSlugs.add(slug);
1036
+ featureSlugs.add(segBase.toLowerCase());
1037
+ }
1038
+ }
1039
+ }
1040
+
1041
+ const deletedTargets = new Set(deletedProd);
1042
+ const removedSymbols = new Set([...explicitSymbols, ...inferredSymbols]);
1043
+ const removedChannels = new Set([...explicitChannels, ...inferredChannels]);
1044
+ const removedLiterals = new Set([...explicitLiterals]);
1045
+
1046
+ if (!deletedTargets.size && !removedSymbols.size && !removedChannels.size && !removedLiterals.size && !featureSlugs.size) {
1047
+ return { swept: [], legacyTests: [], e2eSpecs: [], menuFiles: [], threatModelDocs: [] };
1048
+ }
1049
+
1050
+ const knownAllSet = new Set([...allRepoFiles, ...deletedTargets, ...taskDeleted]);
1051
+ const symbolRegexes = [...removedSymbols]
1052
+ .filter((sym) => explicitSymbols.has(sym) || sym.length >= 5)
1053
+ .map((sym) => new RegExp(`\\b${escapeRegExp(sym)}\\b`));
1054
+
1055
+ const matchesCodeCandidate = (candFile, kind) => {
1056
+ const txt = readText(candFile);
1057
+ if (!txt) return false;
1058
+ const rawImports = extractModuleImports(txt);
1059
+ for (const imp of rawImports) {
1060
+ if (deletedTargets.size) {
1061
+ const resolved = resolveModuleSpecifier(candFile, imp.specifier, knownAllSet, aliases);
1062
+ if (resolved && deletedTargets.has(resolved)) return true;
1063
+ for (const dirPref of deletedDirPrefixes) {
1064
+ if (resolved && (resolved === dirPref || resolved.startsWith(`${dirPref}/`))) return true;
1065
+ }
1066
+ }
1067
+ if (removedSymbols.size && imp.names.some((n) => removedSymbols.has(n))) return true;
1068
+ }
1069
+ for (const ch of removedChannels) {
1070
+ if (hasStringLiteral(txt, ch)) return true;
1071
+ }
1072
+ for (const lit of removedLiterals) {
1073
+ if (hasStringLiteral(txt, lit)) return true;
1074
+ }
1075
+ for (const re of symbolRegexes) {
1076
+ if (re.test(txt)) return true;
1077
+ }
1078
+ if (kind === 'menu' && featureSlugs.size) {
1079
+ for (const slug of featureSlugs) {
1080
+ if (
1081
+ hasStringLiteral(txt, `tool-${slug}`)
1082
+ || hasStringLiteral(txt, `view-${slug}`)
1083
+ || hasStringLiteral(txt, `mode-${slug}`)
1084
+ || hasStringLiteral(txt, slug)
1085
+ ) {
1086
+ return true;
1087
+ }
1088
+ }
1089
+ }
1090
+ if (kind === 'e2e' && featureSlugs.size) {
1091
+ const base = path.posix.basename(candFile).toLowerCase();
1092
+ for (const slug of featureSlugs) {
1093
+ if (
1094
+ base.startsWith(slug)
1095
+ || hasStringLiteral(txt, `/${slug}`)
1096
+ || hasStringLiteral(txt, `tool-${slug}`)
1097
+ || hasStringLiteral(txt, slug)
1098
+ ) {
1099
+ return true;
1100
+ }
1101
+ }
1102
+ }
1103
+ return false;
1104
+ };
1105
+
1106
+ const matchesDocCandidate = (docFile) => {
1107
+ const txt = readText(docFile);
1108
+ if (!txt) return false;
1109
+ for (const p of deletedProd) {
1110
+ if (txt.includes(p)) return true;
1111
+ }
1112
+ for (const dirPref of deletedDirPrefixes) {
1113
+ if (txt.includes(dirPref)) return true;
1114
+ }
1115
+ for (const ch of removedChannels) {
1116
+ if (txt.includes(ch)) return true;
1117
+ }
1118
+ for (const lit of removedLiterals) {
1119
+ if (txt.includes(lit)) return true;
1120
+ }
1121
+ for (const sym of explicitSymbols) {
1122
+ if (sym.length >= 4 && new RegExp(`\\b${escapeRegExp(sym)}\\b`).test(txt)) return true;
1123
+ }
1124
+ return false;
1125
+ };
1126
+
1127
+ const legacyTests = [];
1128
+ const e2eSpecs = [];
1129
+ const menuFiles = [];
1130
+ const threatModelDocs = [];
1131
+
1132
+ for (const f of allRepoFiles) {
1133
+ if (allDeletedSet.has(f) || frozenFiles.has(f)) continue;
1134
+ if (f.startsWith('tests/') && !f.startsWith('tests/acceptance/') && (CODE_RE.test(f) || TEST_FILE_RE.test(f))) {
1135
+ if (matchesCodeCandidate(f, 'test')) legacyTests.push(f);
1136
+ } else if (f.startsWith('e2e/') && (CODE_RE.test(f) || TEST_FILE_RE.test(f))) {
1137
+ if (matchesCodeCandidate(f, 'e2e')) e2eSpecs.push(f);
1138
+ } else if (/(?:^|\/)appMenus\.[cm]?[jt]sx?$/.test(f)) {
1139
+ if (matchesCodeCandidate(f, 'menu')) menuFiles.push(f);
1140
+ } else if (/^docs\/security\/threat-model-[^/]*\.md$/.test(f)) {
1141
+ if (matchesDocCandidate(f)) threatModelDocs.push(f);
1142
+ }
1143
+ }
1144
+
1145
+ legacyTests.sort();
1146
+ e2eSpecs.sort();
1147
+ menuFiles.sort();
1148
+ threatModelDocs.sort();
1149
+ const swept = uniq([...legacyTests, ...e2eSpecs, ...menuFiles, ...threatModelDocs]);
1150
+ return { swept, legacyTests, e2eSpecs, menuFiles, threatModelDocs };
1151
+ }
1152
+
1153
+ function expandRolePaths(root, ref, list) {
1154
+ const expanded = [];
1155
+ for (const p of Array.isArray(list) ? list : []) {
1156
+ if (isDirEntry(root, ref || 'HEAD', p)) {
1157
+ expanded.push(norm(p), ...expandDirEntry(root, ref || 'HEAD', p));
1158
+ } else {
1159
+ expanded.push(norm(p));
1160
+ }
1161
+ }
1162
+ return uniq(expanded);
1163
+ }
1164
+
1165
+ function build(inputs, ctx = {}) {
1166
+ const root = ctx.root || process.cwd();
1167
+ const ref = ctx.ref || 'HEAD';
1168
+ const coupledRules = loadCoupledScope(root, ctx);
1169
+ // OXB-201: stale edited/deleted paths (moved by an earlier phase) — fixed with --fix-stale-paths, an error otherwise.
1170
+ const staleErrors = [];
1171
+ const staleFixed = [];
1172
+ if (ctx.checkPaths !== false) {
1173
+ for (const { file, doc } of inputs) {
1174
+ for (const s of staleRolePaths(root, ref, (doc && doc.tasks) || [])) {
1175
+ const at = `${path.basename(file)}: tasks[${s.index}]${s.rid ? ` (${s.rid})` : ''}`;
1176
+ if (ctx.fixStalePaths && s.suggestion) {
1177
+ applyStaleFix(doc.tasks[s.index], s);
1178
+ staleFixed.push(`${at}: ${s.path} → ${s.suggestion} (corrigido pelo histórico de renames)`);
1179
+ } else staleErrors.push(staleMessage(at, s, ref));
1180
+ }
1181
+ }
1182
+ }
1183
+ const res = merge.mergeRolePlans(inputs, { key: ctx.key || 'rid' });
1184
+ const errors = [...res.errors, ...staleErrors];
1185
+ const warnings = [...res.warnings, ...staleFixed];
1186
+ const plan = res.plan;
1187
+ const frozenFiles = new Set((plan.acceptance_tests || []).flatMap((a) => (a.files || []).map(norm)));
1188
+ // role-level path declarations by key
1189
+ const roleByKey = new Map();
1190
+ for (const { doc } of inputs) for (const t of (doc && doc.tasks) || []) {
1191
+ const k = String(t.rid || t[ctx.key || 'rid'] || '');
1192
+ const cur = roleByKey.get(k) || { deleted: [], created: [], edited: [], moves: [], swept: [], rawDeleted: [], rawTasks: [] };
1193
+ cur.rawDeleted.push(...rolePathList(t, 'deleted'));
1194
+ cur.rawTasks.push(t);
1195
+ for (const f of ['deleted', 'created', 'edited']) {
1196
+ cur[f].push(...expandRolePaths(root, ref, rolePathList(t, f)));
1197
+ }
1198
+ // OXB-C24-3: `swept` (existing tests the task updates, no symbols needed) on ANY task, not only removals
1199
+ cur.swept.push(...expandRolePaths(root, ref, rolePathList(t, 'swept')));
1200
+ cur.moves.push(...(Array.isArray(t.moves) ? t.moves : []));
1201
+ roleByKey.set(k, cur);
1202
+ }
1203
+
1204
+ let importIndex = null;
1205
+ const getImportIndex = () => {
1206
+ if (!importIndex) importIndex = buildImportIndex(root, ref);
1207
+ return importIndex;
1208
+ };
1209
+ let allRepoFiles = null;
1210
+ let pathAliases = null;
1211
+ const sweepTextCache = new Map();
1212
+ const getSweepBase = () => {
1213
+ if (!allRepoFiles) allRepoFiles = listAllRepoFiles(root, ref);
1214
+ if (!pathAliases) pathAliases = loadPathAliases(root);
1215
+ return { allRepoFiles, aliases: pathAliases, textCache: sweepTextCache };
1216
+ };
1217
+
1218
+ const deletedBefore = new Set();
1219
+ const phaseSweptLegacyTests = [];
1220
+ const phaseSweptE2eSpecs = [];
1221
+ const phaseSweepTasks = [];
1222
+
1223
+ for (const t of plan.tasks) {
1224
+ const before = t.files.length;
1225
+ const r = roleByKey.get(String(t.rid)) || {};
1226
+ const taskFilesExpanded = expandRolePaths(root, ref, t.files);
1227
+ const taskDeleted = uniq([...(r.deleted || []).map(norm), ...((r.moves || []).map((m) => norm(m.from)))]);
1228
+ const newlyDeleted = taskDeleted.filter((p) => !deletedBefore.has(p));
1229
+
1230
+ // OXB-199: 1-hop reverse import closure when `--auto-close-imports` (`ctx.autoCloseImports`) is enabled
1231
+ let autoClosedImporters = [];
1232
+ if (ctx.autoCloseImports && newlyDeleted.length) {
1233
+ const currentScope = uniq([...taskFilesExpanded, ...(r.edited || []).map(norm), ...(r.created || []).map(norm), ...taskDeleted]);
1234
+ autoClosedImporters = findOrphanImporters(getImportIndex(), newlyDeleted, currentScope, deletedBefore);
1235
+ }
1236
+
1237
+ // OXB-198: exhaustive Record<UnionType, ...> shrink coupling on mode/feature removal tasks
1238
+ let unionCoupled = [];
1239
+ const isRemovalTask = t.kind === 'remove' || taskDeleted.length > 0 || /\b(remov|drop|strip|retir|delet)/i.test(String(t.title || ''));
1240
+ const candidateUnionEdited = uniq([...taskFilesExpanded, ...(r.edited || []).map(norm), ...autoClosedImporters]).filter((p) => CODE_RE.test(p) && !taskDeleted.includes(p));
1241
+ if (isRemovalTask && candidateUnionEdited.length) {
1242
+ const allDeletedSoFar = new Set([...deletedBefore, ...taskDeleted]);
1243
+ const currentScope = uniq([...taskFilesExpanded, ...(r.edited || []).map(norm), ...(r.created || []).map(norm), ...autoClosedImporters, ...taskDeleted]);
1244
+ unionCoupled = findCoupledUnionConsumers(getImportIndex(), candidateUnionEdited, currentScope, allDeletedSoFar);
1245
+ }
1246
+
1247
+ // OXB-206: sweep legacy suites (`tests/**`, `e2e/**`), `appMenus.ts`, and `docs/security/threat-model-*.md`
1248
+ const sweepRes = ctx.legacySweep === false
1249
+ ? { swept: [], legacyTests: [], e2eSpecs: [], menuFiles: [], threatModelDocs: [] }
1250
+ : sweepRemovalImpacts(root, ref, t, r, { deletedBefore, frozenFiles, ...getSweepBase() });
1251
+
1252
+ const effectiveEdited = uniq([...(r.edited || []).map(norm), ...autoClosedImporters, ...unionCoupled, ...sweepRes.swept]);
1253
+ if (autoClosedImporters.length || unionCoupled.length || sweepRes.swept.length) {
1254
+ r.edited = effectiveEdited;
1255
+ r.swept = uniq([...(r.swept || []), ...sweepRes.swept]);
1256
+ roleByKey.set(String(t.rid), r);
1257
+ }
1258
+ if (effectiveEdited.length) {
1259
+ t.edited_paths = effectiveEdited.filter((f) => !frozenFiles.has(f));
1260
+ }
1261
+
1262
+ if (sweepRes.swept.length) {
1263
+ phaseSweepTasks.push(t.id);
1264
+ const taskGates = Array.isArray(t.gates) ? [...t.gates] : [];
1265
+ if (sweepRes.legacyTests.length) {
1266
+ phaseSweptLegacyTests.push(...sweepRes.legacyTests);
1267
+ const existingCmds = (t.verify && Array.isArray(t.verify.commands)) ? t.verify.commands : [];
1268
+ const uncoveredTests = sweepRes.legacyTests.filter((tf) => !existingCmds.some((c) => String(c).includes(tf)));
1269
+ if (uncoveredTests.length) {
1270
+ t.verify = { ...(t.verify || {}), commands: [...existingCmds, `npx vitest run ${uncoveredTests.join(' ')}`] };
1271
+ }
1272
+ taskGates.push(`npx vitest run ${sweepRes.legacyTests.join(' ')}`);
1273
+ }
1274
+ if (sweepRes.e2eSpecs.length) {
1275
+ phaseSweptE2eSpecs.push(...sweepRes.e2eSpecs);
1276
+ taskGates.push(`npx playwright test ${sweepRes.e2eSpecs.join(' ')}`);
1277
+ }
1278
+ if (taskGates.length) t.gates = uniq(taskGates);
1279
+ warnings.push(`${t.id}: varredura de remoção anexou a edited_paths (${sweepRes.swept.join(', ')})`);
1280
+ }
1281
+
1282
+ const coupledMatch = matchedCoupledRules(coupledRules, {
1283
+ files: [...taskFilesExpanded, ...autoClosedImporters, ...unionCoupled, ...sweepRes.swept],
1284
+ created: r.created || [],
1285
+ edited: effectiveEdited,
1286
+ deleted: r.deleted || [],
1287
+ });
1288
+ const coupled = coupledMatch.included;
1289
+ for (const mr of coupledMatch.matchedRules) {
1290
+ if (mr.note) warnings.push(`${t.id}: ${mr.note}`);
1291
+ }
1292
+ t.files = uniq([
1293
+ ...taskFilesExpanded,
1294
+ ...autoClosedImporters,
1295
+ ...unionCoupled,
1296
+ ...sweepRes.swept,
1297
+ ...coupled,
1298
+ ...(r.created || []).map(norm),
1299
+ ...effectiveEdited,
1300
+ ...(r.deleted || []).map(norm),
1301
+ ...(r.moves || []).flatMap((m) => [norm(m.from), norm(m.to)]),
1302
+ ]).filter((f) => !frozenFiles.has(f));
1303
+ if (ctx.designLintVerify !== false) {
1304
+ injectFrontendDesignLintVerify(root, ref, t, r, taskDeleted, ctx.designLintTests);
1305
+ }
1306
+ if (before && t.files.length < before) warnings.push(`${t.id}: arquivos de aceite congelados tirados do escopo`);
1307
+ if (ctx.phase) t.phase = ctx.phase;
1308
+ for (const p of taskDeleted) deletedBefore.add(p);
1309
+ }
1310
+ // OXB-206: attach phase_gates for legacy vitest / playwright suites swept by removal tasks (excluding tests deleted later in the phase)
1311
+ const survivingSweptLegacy = uniq(phaseSweptLegacyTests).filter((f) => !deletedBefore.has(f));
1312
+ const survivingSweptE2e = uniq(phaseSweptE2eSpecs).filter((f) => !deletedBefore.has(f));
1313
+ if (survivingSweptLegacy.length || survivingSweptE2e.length) {
1314
+ const gates = Array.isArray(plan.phase_gates) ? [...plan.phase_gates] : [];
1315
+ const byTasks = uniq(phaseSweepTasks).join(', ');
1316
+ if (survivingSweptLegacy.length && !gates.some((g) => g && g.id === 'legacy-tests')) {
1317
+ gates.push({
1318
+ id: 'legacy-tests',
1319
+ command: `npx vitest run ${survivingSweptLegacy.join(' ')}`,
1320
+ description: `suítes legadas impactadas por remoção (${byTasks})`,
1321
+ });
1322
+ }
1323
+ if (survivingSweptE2e.length && !gates.some((g) => g && g.id === 'legacy-e2e')) {
1324
+ gates.push({
1325
+ id: 'legacy-e2e',
1326
+ command: `npx playwright test ${survivingSweptE2e.join(' ')}`,
1327
+ description: `suítes e2e impactadas por remoção (${byTasks})`,
1328
+ });
1329
+ }
1330
+ if (gates.length) plan.phase_gates = gates;
1331
+ }
1332
+ // OXB-202: package.json / lockfile changed → notices gate (+ THIRD_PARTY_NOTICES.md in scope).
1333
+ const noticesGate = ctx.noticesGate === false ? null : injectNoticesGate(root, ref, plan, warnings);
1334
+ // OXB-203: --pair-as-deps — frontend consumers of window.oxe / the IPC mock after the IPC contract tasks.
1335
+ const pairCfg = (() => { try { return (JSON.parse(fs.readFileSync(path.join(root, '.oxe', 'config.json'), 'utf8')).plan || {}); } catch { return {}; } })();
1336
+ const paired = ctx.pairAsDeps || pairCfg.pair_as_deps === true
1337
+ ? pairIpcDependencies(root, ref, plan.tasks, { contractFiles: pairCfg.ipc_contract_files, consumerFiles: pairCfg.ipc_consumer_files })
1338
+ : [];
1339
+ for (const p of paired) warnings.push(`${p.task}: passa a depender de ${p.added.join(', ')} (contrato IPC: ${IPC_CONTRACT_FILES.join(', ')}) — --pair-as-deps`);
1340
+ assignWaves(plan.tasks);
1341
+
1342
+ // OXB-194: filter deleted test files out of verify commands (own and transitive dependencies)
1343
+ const allTasksById = new Map(plan.tasks.map((t) => [t.id, t]));
1344
+ for (const t of plan.tasks) {
1345
+ const transitiveDel = transitiveDeletedForTask(t, allTasksById, roleByKey);
1346
+ if (t.verify && Array.isArray(t.verify.commands)) {
1347
+ const filteredCmds = [];
1348
+ for (const cmd of t.verify.commands) {
1349
+ const clean = filterDeletedFromVerifyCommand(cmd, transitiveDel);
1350
+ if (clean) filteredCmds.push(clean);
1351
+ }
1352
+ t.verify.commands = filteredCmds;
1353
+ }
1354
+ }
1355
+
1356
+ const pack = { schema_version: 1, generated_by: 'oxe-cc plan build', ...(ctx.phase ? { phase: ctx.phase } : {}), tasks: [] };
1357
+ for (const t of plan.tasks) {
1358
+ const tests = (plan.acceptance_tests || []).filter((a) => (t.acceptance || []).includes(a.criterion)).flatMap((a) => a.files || []);
1359
+ const info = packEntry(root, t, roleByKey.get(String(t.rid)) || {}, frozenFiles, tests);
1360
+ errors.push(...kindErrors(t, info));
1361
+ const removed = new Set(info.entry.removed_paths || []);
1362
+ const sweptSet = new Set(info.entry.swept_paths || []);
1363
+ const uncovered = info.exact.filter((p) => CODE_RE.test(p) && !removed.has(p) && !sweptSet.has(p));
1364
+ if (!info.entry.symbols.length && uncovered.length && !['test-only', 'config-only'].includes(info.kind)) warnings.push(`${t.id}: nenhum símbolo saiu dos testes congelados para ${uncovered.slice(0, 3).join(', ')} — declare symbols no pack antes do execute`);
1365
+ pack.tasks.push(info.entry);
1366
+ }
1367
+ if (ctx.phase) plan.phase = ctx.phase;
1368
+ try {
1369
+ const rigor = require('./oxe-test-rigor.cjs');
1370
+ errors.push(
1371
+ ...rigor.suspiciousRegexMessages(rigor.suspiciousRegexFindings(root, plan)),
1372
+ ...rigor.pausedSocketMessages(rigor.pausedSocketFindings(root, plan)),
1373
+ );
1374
+ } catch { /* */ }
1375
+ // OXB-C1 Adendo 2 (G47): warn and enrich task.notes when an in-scope file is within ~20 lines of its file-size cap.
1376
+ try {
1377
+ const fsg = require('./oxe-file-size-guard.cjs');
1378
+ const annotated = fsg.annotatePlanFileSizeNotes(root, plan, { pack });
1379
+ if (annotated.findings.length) {
1380
+ warnings.push(...fsg.fileSizeHeadroomMessages(annotated.findings).warnings);
1381
+ }
1382
+ } catch { /* */ }
1383
+ // OXB-C25: the preflight needs `ready: true`; without it, execute stopped on execution_rationality:not_ready with an
1384
+ // empty gap list while plan lint said ok. The build's own checks decide it.
1385
+ pack.ready = errors.length === 0;
1386
+ pack.critical_gaps = [];
1387
+ return { plan, pack, planMd: renderPlanMd(plan, ctx.phase), errors, warnings, map: res.map, paired, notices_gate: noticesGate };
1388
+ }
1389
+
1390
+ function gitHas(root, ref, p) {
1391
+ const clean = norm(p).replace(/(\/\*\*|\/)+$/, '');
1392
+ return spawnSync('git', ['cat-file', '-e', `${ref}:${clean}`], { cwd: root, windowsHide: true }).status === 0;
1393
+ }
1394
+
1395
+ /** OXB-098 / OXB-199: problems of one role file (including 1-hop reverse import closure on deleted paths). */
1396
+ function checkRole(root, doc, options = {}) {
1397
+ const errors = [];
1398
+ const warnings = [];
1399
+ const ref = options.ref || 'HEAD';
1400
+ const ACCEPT_RE = require('./oxe-plan-json.cjs').ACCEPT_RE;
1401
+ const coupledRules = loadCoupledScope(root, options);
1402
+ let importIndex = null;
1403
+ const getImportIndex = () => {
1404
+ if (!importIndex) importIndex = buildImportIndex(root, ref);
1405
+ return importIndex;
1406
+ };
1407
+ const deletedBefore = new Set();
1408
+ // OXB-201: edited/deleted must exist at the ref unless an earlier task creates them; a moved file gets its real path.
1409
+ const staleByIndex = new Map();
1410
+ for (const s of staleRolePaths(root, ref, (doc && doc.tasks) || [])) {
1411
+ if (!staleByIndex.has(s.index)) staleByIndex.set(s.index, []);
1412
+ staleByIndex.get(s.index).push(s);
1413
+ }
1414
+ for (const [i, t] of ((doc && doc.tasks) || []).entries()) {
1415
+ const at = `tasks[${i}]${t && t.rid ? ` (${t.rid})` : ''}`;
1416
+ if (!t || !t.rid) errors.push(`${at}: sem rid`);
1417
+ for (const c of [...(Array.isArray(t.acceptance) ? t.acceptance : []), ...(Array.isArray(t.criteria) ? t.criteria : typeof t.criteria === 'string' ? [t.criteria] : [])]) if (!ACCEPT_RE.test(String(c).trim())) errors.push(`${at}: critério em prosa "${String(c).slice(0, 50)}" — use ids A<n>`);
1418
+ for (const s of staleByIndex.get(i) || []) {
1419
+ if (options.fixStalePaths && s.suggestion) { applyStaleFix(t, s); warnings.push(`${at}: ${s.path} → ${s.suggestion} (corrigido pelo histórico de renames)`); }
1420
+ else errors.push(staleMessage(at, s, ref));
1421
+ }
1422
+ for (const p of rolePathList(t, 'created')) if (gitHas(root, ref, p)) errors.push(`${at}: ${p} já existe em ${ref} (declarado como created — é edited)`);
1423
+ const v = t.verify;
1424
+ const cmds = Array.isArray(v) ? v : v && Array.isArray(v.commands) ? v.commands : typeof v === 'string' ? [v] : [];
1425
+ if (!cmds.length && !['external_delivery', 'verify_only', 'spike'].includes(t.kind)) errors.push(`${at}: sem verify (verify.commands: ["…"])`);
1426
+ for (const c of cmds) if (typeof c !== 'string' || !c.trim() || /\.\.\.|<[^>]+>/.test(c)) errors.push(`${at}: verify "${String(c).slice(0, 60)}" não é um comando executável (placeholder)`);
1427
+ if (t.kind && !KINDS.has(t.kind) && !['external_delivery', 'verify_only', 'spike'].includes(t.kind)) warnings.push(`${at}: kind "${t.kind}" desconhecido (add|remove|move|test-only|config-only)`);
1428
+
1429
+ // OXB-199: check 1-hop reverse importers of newly deleted paths
1430
+ const expandedDeleted = expandRolePaths(root, ref, t && t.deleted).filter((p) => gitHas(root, ref, p));
1431
+ const newlyDeleted = expandedDeleted.filter((p) => !deletedBefore.has(p));
1432
+ if (newlyDeleted.length) {
1433
+ const declaredScope = uniq([
1434
+ ...expandRolePaths(root, ref, t.files),
1435
+ ...expandRolePaths(root, ref, t.edited),
1436
+ ...expandRolePaths(root, ref, t.created),
1437
+ ...expandedDeleted,
1438
+ ]);
1439
+ const orphans = findOrphanImporters(getImportIndex(), newlyDeleted, declaredScope, deletedBefore);
1440
+ if (orphans.length) {
1441
+ if (options.autoCloseImports) {
1442
+ t.files = uniq([...(t.files || []).map(norm), ...orphans]);
1443
+ } else {
1444
+ errors.push(`${at}: importadores órfãos de caminhos em deleted fora de files/deleted: ${orphans.join(', ')} (adicione a files ou use --auto-close-imports)`);
1445
+ }
1446
+ }
1447
+ }
1448
+ for (const p of expandedDeleted) deletedBefore.add(p);
1449
+
1450
+ if (coupledRules.length) {
1451
+ const coupledMatch = matchedCoupledRules(coupledRules, { files: t.files || [], created: t.created || [], edited: t.edited || [], deleted: t.deleted || [] });
1452
+ const coupled = coupledMatch.included;
1453
+ const declared = uniq([...(t.files || []), ...(t.edited || []), ...(t.created || [])].map(norm));
1454
+ const missing = coupled.filter((f) => !declared.includes(f));
1455
+ const notes = uniq(coupledMatch.matchedRules.map((mr) => mr.note).filter(Boolean));
1456
+ if (missing.length) {
1457
+ warnings.push(`${at}: escopo acoplado recomendado (${missing.join(', ')})${notes.length ? ` — ${notes.join('; ')}` : ''}`);
1458
+ } else {
1459
+ for (const note of notes) warnings.push(`${at}: ${note}`);
1460
+ }
1461
+ }
1462
+ if (t.proves && typeof t.proves === 'object' && !Array.isArray(t.proves)) {
1463
+ for (const [file, titles] of Object.entries(t.proves)) {
1464
+ let text = '';
1465
+ try { text = fs.readFileSync(path.join(root, file), 'utf8'); } catch { errors.push(`${at}: proves cita ${file}, que não existe`); continue; }
1466
+ for (const title of Array.isArray(titles) ? titles : [titles]) {
1467
+ const exact = text.includes(`'${title}'`) || text.includes(`"${title}"`) || text.includes(`\`${title}\``);
1468
+ if (!exact) errors.push(`${at}: o título "${title}" não está em ${file} (proves exige o título exato do it/test)`);
1469
+ }
1470
+ }
1471
+ }
1472
+ }
1473
+ try {
1474
+ const rigor = require('./oxe-test-rigor.cjs');
1475
+ const roleTestFiles = [
1476
+ ...((doc && Array.isArray(doc.acceptance_tests) ? doc.acceptance_tests : []).flatMap((a) => (a && a.files) || [])),
1477
+ ...((doc && Array.isArray(doc.tasks) ? doc.tasks : []).flatMap((t) => (t && t.proves && typeof t.proves === 'object' && !Array.isArray(t.proves) ? Object.keys(t.proves) : []))),
1478
+ ];
1479
+ if (roleTestFiles.length) {
1480
+ errors.push(
1481
+ ...rigor.suspiciousRegexMessages(rigor.suspiciousRegexFindings(root, roleTestFiles)),
1482
+ ...rigor.pausedSocketMessages(rigor.pausedSocketFindings(root, roleTestFiles)),
1483
+ );
1484
+ }
1485
+ } catch { /* */ }
1486
+ return { errors, warnings };
1487
+ }
1488
+
1489
+ module.exports = {
1490
+ isProductCode,
1491
+ build,
1492
+ checkRole,
1493
+ importedSymbols,
1494
+ assignWaves,
1495
+ kindErrors,
1496
+ renderPlanMd,
1497
+ KINDS,
1498
+ inScope,
1499
+ isDirEntry,
1500
+ expandDirEntry,
1501
+ filterDeletedFromVerifyCommand,
1502
+ transitiveDeletedForTask,
1503
+ loadCoupledScope,
1504
+ matchedCoupledRules,
1505
+ applyCoupledScope,
1506
+ injectFrontendDesignLintVerify,
1507
+ buildImportIndex,
1508
+ extractModuleImports,
1509
+ loadPathAliases,
1510
+ resolveModuleSpecifier,
1511
+ findOrphanImporters,
1512
+ findCoupledUnionConsumers,
1513
+ rolePathList,
1514
+ recentRenames,
1515
+ staleRolePaths,
1516
+ injectNoticesGate,
1517
+ pairIpcDependencies,
1518
+ sweepRemovalImpacts,
1519
+ IPC_CONTRACT_FILES,
1520
+ };