qfai 2.2.1 → 2.3.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 (158) hide show
  1. package/README.md +14 -17
  2. package/assets/init/.qfai/assistant/agent/architecture-reviewer.md +2 -2
  3. package/assets/init/.qfai/assistant/agent/fullstack-engineer.md +101 -0
  4. package/assets/init/.qfai/assistant/agent/implementation-reviewer.md +73 -1
  5. package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +2 -2
  6. package/assets/init/.qfai/assistant/agent/requirements-reviewer.md +12 -2
  7. package/assets/init/.qfai/assistant/rule/agent-selection.md +22 -42
  8. package/assets/init/.qfai/assistant/rule/drift-protocol.md +1 -1
  9. package/assets/init/.qfai/assistant/rule/references/asset-authoring.md +1 -1
  10. package/assets/init/.qfai/assistant/rule/references/codex-delegation.md +4 -4
  11. package/assets/init/.qfai/assistant/rule/references/reviewer-findings.md +1 -1
  12. package/assets/init/.qfai/assistant/rule/references/worker-edit-boundary.md +3 -3
  13. package/assets/init/.qfai/assistant/rule/research-first-protocol.md +7 -6
  14. package/assets/init/.qfai/assistant/rule/review-convergence.md +1 -1
  15. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +76 -60
  16. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +2 -4
  17. package/assets/init/.qfai/assistant/rule/workflow.md +4 -4
  18. package/assets/init/.qfai/assistant/skill/qfai-configure/SKILL.md +15 -46
  19. package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +1 -13
  20. package/assets/init/.qfai/assistant/skill/qfai-grill/SKILL.md +8 -7
  21. package/assets/init/.qfai/assistant/skill/qfai-grilling/SKILL.md +15 -15
  22. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/delegated-session.md +18 -18
  23. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/session-record.md +3 -3
  24. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +0 -14
  25. package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +52 -20
  26. package/assets/init/.qfai/assistant/skill/qfai-maintain/SKILL.md +0 -1
  27. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/SKILL.md +2 -13
  28. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-guide.md +8 -11
  29. package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-placement.md +0 -7
  30. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +1 -9
  31. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/generator-prompt.md +1 -1
  32. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/iteration-loop.md +2 -2
  33. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +4 -4
  34. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +1 -1
  35. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +1 -2
  36. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +4 -4
  37. package/assets/init/.qfai/assistant/skill/qfai-sdd/SKILL.md +0 -13
  38. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/concrete-abstract-cycle.md +2 -2
  39. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +12 -0
  40. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +1 -1
  41. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md +2 -2
  42. package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +0 -11
  43. package/assets/init/.qfai/assistant/skill/qfai-verify/SKILL.md +0 -9
  44. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +18 -18
  45. package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +0 -2
  46. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +0 -1
  47. package/assets/init/.qfai/assistant/step/common-grilling-record/STEP.md +0 -1
  48. package/assets/init/.qfai/assistant/step/common-policy-check/STEP.md +0 -1
  49. package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +2 -3
  50. package/assets/init/.qfai/assistant/step/discussion-interview/STEP.md +0 -2
  51. package/assets/init/.qfai/assistant/step/discussion-oq/STEP.md +0 -2
  52. package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +0 -2
  53. package/assets/init/.qfai/assistant/step/discussion-research/STEP.md +0 -2
  54. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +0 -2
  55. package/assets/init/.qfai/assistant/step/implement-acceptance/STEP.md +0 -4
  56. package/assets/init/.qfai/assistant/step/implement-backport/STEP.md +0 -5
  57. package/assets/init/.qfai/assistant/step/implement-benchmark/STEP.md +0 -4
  58. package/assets/init/.qfai/assistant/step/implement-bisect/STEP.md +0 -5
  59. package/assets/init/.qfai/assistant/step/implement-credentials/STEP.md +0 -4
  60. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +0 -5
  61. package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +0 -6
  62. package/assets/init/.qfai/assistant/step/implement-minimize/STEP.md +0 -5
  63. package/assets/init/.qfai/assistant/step/implement-oracle-parity/STEP.md +0 -6
  64. package/assets/init/.qfai/assistant/step/implement-procedure/STEP.md +0 -2
  65. package/assets/init/.qfai/assistant/step/implement-quarantine/STEP.md +0 -4
  66. package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +0 -4
  67. package/assets/init/.qfai/assistant/step/implement-regression-fix/STEP.md +0 -4
  68. package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +0 -6
  69. package/assets/init/.qfai/assistant/step/implement-revert/STEP.md +0 -4
  70. package/assets/init/.qfai/assistant/step/implement-scaffold/STEP.md +0 -2
  71. package/assets/init/.qfai/assistant/step/implement-seam/STEP.md +0 -4
  72. package/assets/init/.qfai/assistant/step/implement-stress-harness/STEP.md +0 -5
  73. package/assets/init/.qfai/assistant/step/implement-sweep/STEP.md +0 -5
  74. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +3 -10
  75. package/assets/init/.qfai/assistant/step/implement-test-fix/STEP.md +0 -5
  76. package/assets/init/.qfai/assistant/step/implement-tooling/STEP.md +0 -3
  77. package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +1 -4
  78. package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +3 -5
  79. package/assets/init/.qfai/assistant/step/prototyping-handoff/STEP.md +0 -2
  80. package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +17 -19
  81. package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +0 -2
  82. package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +2 -4
  83. package/assets/init/.qfai/assistant/step/sdd-cycle/STEP.md +1 -3
  84. package/assets/init/.qfai/assistant/step/sdd-flow/STEP.md +0 -2
  85. package/assets/init/.qfai/assistant/step/sdd-gate/STEP.md +0 -1
  86. package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +0 -2
  87. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +7 -9
  88. package/assets/init/.qfai/assistant/step/triage-answer/STEP.md +0 -2
  89. package/assets/init/.qfai/assistant/step/triage-close/STEP.md +0 -2
  90. package/assets/init/.qfai/assistant/step/triage-cluster/STEP.md +0 -2
  91. package/assets/init/.qfai/assistant/step/triage-decompose/STEP.md +0 -2
  92. package/assets/init/.qfai/assistant/step/triage-dedupe/STEP.md +0 -2
  93. package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +0 -2
  94. package/assets/init/.qfai/assistant/step/triage-investigate/STEP.md +0 -2
  95. package/assets/init/.qfai/assistant/step/triage-operate/STEP.md +0 -2
  96. package/assets/init/.qfai/assistant/step/triage-owned-cleanup/STEP.md +0 -2
  97. package/assets/init/.qfai/assistant/step/triage-request-info/STEP.md +0 -2
  98. package/assets/init/.qfai/assistant/step/triage-security-intake/STEP.md +0 -2
  99. package/assets/init/.qfai/assistant/step/verify-advisory/STEP.md +0 -2
  100. package/assets/init/.qfai/assistant/step/verify-change-note/STEP.md +0 -2
  101. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +0 -2
  102. package/assets/init/.qfai/assistant/step/verify-context/STEP.md +7 -26
  103. package/assets/init/.qfai/assistant/step/verify-external/STEP.md +0 -2
  104. package/assets/init/.qfai/assistant/step/verify-manual/STEP.md +0 -2
  105. package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +0 -2
  106. package/assets/init/.qfai/assistant/step/verify-release-notes/STEP.md +0 -2
  107. package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +0 -2
  108. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +0 -2
  109. package/assets/init/root/.agents/rules/grilling.md +9 -9
  110. package/dist/cli/index.cjs +324 -1147
  111. package/dist/cli/index.cjs.map +1 -1
  112. package/dist/cli/index.mjs +309 -1132
  113. package/dist/cli/index.mjs.map +1 -1
  114. package/dist/graph/cli.cjs +14 -2
  115. package/dist/graph/cli.cjs.map +1 -1
  116. package/dist/graph/cli.d.cts +1 -1
  117. package/dist/graph/cli.d.ts +1 -1
  118. package/dist/graph/cli.mjs +14 -2
  119. package/dist/graph/cli.mjs.map +1 -1
  120. package/dist/graph/hook.cjs.map +1 -1
  121. package/dist/graph/hook.mjs.map +1 -1
  122. package/dist/index.cjs +983 -1975
  123. package/dist/index.cjs.map +1 -1
  124. package/dist/index.d.cts +2 -19
  125. package/dist/index.d.ts +2 -19
  126. package/dist/index.mjs +878 -1869
  127. package/dist/index.mjs.map +1 -1
  128. package/dist/process-qqX2Owgq.d.cts +18 -0
  129. package/dist/process-qqX2Owgq.d.ts +18 -0
  130. package/package.json +1 -1
  131. package/assets/defaults/agent-routing/_contract.yml +0 -77
  132. package/assets/defaults/agent-routing/common.yml +0 -14
  133. package/assets/defaults/agent-routing/qfai-discussion.yml +0 -57
  134. package/assets/defaults/agent-routing/qfai-implement.yml +0 -236
  135. package/assets/defaults/agent-routing/qfai-maintain.yml +0 -12
  136. package/assets/defaults/agent-routing/qfai-prototyping.yml +0 -48
  137. package/assets/defaults/agent-routing/qfai-sdd.yml +0 -56
  138. package/assets/defaults/agent-routing/qfai-triage.yml +0 -108
  139. package/assets/defaults/agent-routing/qfai-verify.yml +0 -92
  140. package/assets/defaults/agent-routing/skills.yml +0 -59
  141. package/assets/defaults/review-profiles.yml +0 -25
  142. package/assets/init/.qfai/assistant/agent/acceptance-test-engineer.md +0 -81
  143. package/assets/init/.qfai/assistant/agent/backend-engineer.md +0 -90
  144. package/assets/init/.qfai/assistant/agent/completion-reviewer.md +0 -88
  145. package/assets/init/.qfai/assistant/agent/delivery-planner.md +0 -85
  146. package/assets/init/.qfai/assistant/agent/devops-ci-engineer.md +0 -78
  147. package/assets/init/.qfai/assistant/agent/discovery-analyst.md +0 -81
  148. package/assets/init/.qfai/assistant/agent/doc-steward.md +0 -78
  149. package/assets/init/.qfai/assistant/agent/frontend-engineer.md +0 -94
  150. package/assets/init/.qfai/assistant/agent/orchestrator.md +0 -92
  151. package/assets/init/.qfai/assistant/agent/product-experience-architect.md +0 -101
  152. package/assets/init/.qfai/assistant/agent/qa-gatekeeper.md +0 -153
  153. package/assets/init/.qfai/assistant/agent/qa-strategist.md +0 -82
  154. package/assets/init/.qfai/assistant/agent/requirements-analyst.md +0 -96
  155. package/assets/init/.qfai/assistant/agent/solution-architect.md +0 -89
  156. package/assets/init/.qfai/assistant/agent/test-design-analyst.md +0 -132
  157. package/dist/process-C21nTvkT.d.cts +0 -12
  158. package/dist/process-C21nTvkT.d.ts +0 -12
@@ -380,11 +380,6 @@ var SHIPPED_WORKFLOW_NAMES = /* @__PURE__ */ new Set([
380
380
  ]);
381
381
 
382
382
  // src/core/config.ts
383
- function routingEntryName(entry) {
384
- if (typeof entry.step === "string" && entry.step.length > 0) return entry.step;
385
- if (typeof entry.skill === "string" && entry.skill.length > 0) return entry.skill;
386
- return void 0;
387
- }
388
383
  var defaultConfig = {
389
384
  paths: {
390
385
  contractsDir: ".qfai/spec/03_contract",
@@ -518,8 +513,6 @@ function normalizeConfig(raw, configPath, issues) {
518
513
  const uiux = normalizeUiux(raw.uiux, configPath, issues);
519
514
  const prototyping = normalizePrototyping(raw.prototyping, configPath, issues);
520
515
  const report2 = normalizeReport(raw.report, configPath, issues);
521
- const routing = normalizeRouting(raw.routing, configPath, issues);
522
- const reviewProfiles = normalizeReviewProfiles(raw.reviewProfiles, configPath, issues);
523
516
  const base = {
524
517
  paths: normalizePaths(raw.paths, configPath, issues),
525
518
  validation: normalizeValidation(raw.validation, configPath, issues),
@@ -534,66 +527,12 @@ function normalizeConfig(raw, configPath, issues) {
534
527
  if (report2) {
535
528
  base.report = report2;
536
529
  }
537
- if (routing) {
538
- base.routing = routing;
539
- }
540
- if (reviewProfiles) {
541
- base.reviewProfiles = reviewProfiles;
542
- }
543
530
  const baseBranch = readOptionalString(raw.baseBranch, "baseBranch", configPath, issues);
544
531
  if (baseBranch !== void 0) {
545
532
  base.baseBranch = baseBranch;
546
533
  }
547
534
  return base;
548
535
  }
549
- function normalizeRouting(raw, configPath, issues) {
550
- if (raw === void 0) return void 0;
551
- if (!Array.isArray(raw)) {
552
- issues.push(
553
- configIssue(configPath, "routing must be a list of entries keyed by step or skill.")
554
- );
555
- return void 0;
556
- }
557
- const entries = [];
558
- const seen = /* @__PURE__ */ new Set();
559
- for (const [index, value] of raw.entries()) {
560
- const name = isRecord(value) ? routingEntryName(value) : void 0;
561
- const keys = isRecord(value) ? [value.step, value.skill].filter((key) => key !== void 0) : [];
562
- if (!isRecord(value) || name === void 0 || keys.length !== 1) {
563
- issues.push(
564
- configIssue(configPath, `routing[${index}] must have exactly one non-empty step or skill.`)
565
- );
566
- continue;
567
- }
568
- if (seen.has(name)) {
569
- issues.push(configIssue(configPath, `routing has duplicate entry ${name}.`));
570
- continue;
571
- }
572
- seen.add(name);
573
- entries.push(
574
- isNonEmptyString(value.step) ? { ...value, step: name } : { ...value, skill: name }
575
- );
576
- }
577
- return entries;
578
- }
579
- function normalizeReviewProfiles(raw, configPath, issues) {
580
- if (raw === void 0) return void 0;
581
- if (!isRecord(raw)) {
582
- issues.push(
583
- configIssue(configPath, "reviewProfiles must be a map of profile names to entries.")
584
- );
585
- return void 0;
586
- }
587
- const profiles = {};
588
- for (const [name, value] of Object.entries(raw)) {
589
- if (!isNonEmptyString(name) || !isRecord(value)) {
590
- issues.push(configIssue(configPath, `reviewProfiles.${name} must be an entry.`));
591
- continue;
592
- }
593
- profiles[name] = { ...value };
594
- }
595
- return profiles;
596
- }
597
536
  function normalizePaths(raw, configPath, issues) {
598
537
  const base = defaultConfig.paths;
599
538
  if (!raw) {
@@ -1140,9 +1079,6 @@ async function exists(target) {
1140
1079
  function isRecord(value) {
1141
1080
  return value !== null && typeof value === "object" && !Array.isArray(value);
1142
1081
  }
1143
- function isNonEmptyString(value) {
1144
- return typeof value === "string" && value.trim().length > 0;
1145
- }
1146
1082
 
1147
1083
  // src/core/fs.ts
1148
1084
  var import_promises2 = require("fs/promises");
@@ -4457,23 +4393,23 @@ async function collectTexts(directory, files, specsDir, errors) {
4457
4393
  const file = import_node_path9.default.join(directory, entry.name);
4458
4394
  const registerPath = file === import_node_path9.default.join(specsDir, "decisions.md") || file === import_node_path9.default.join(specsDir, "decisions") || file.startsWith(`${import_node_path9.default.join(specsDir, "decisions")}${import_node_path9.default.sep}`);
4459
4395
  if (registerPath) {
4460
- const stat21 = await import_promises5.default.lstat(file).catch((error2) => {
4396
+ const stat20 = await import_promises5.default.lstat(file).catch((error2) => {
4461
4397
  errors.push({
4462
4398
  file,
4463
4399
  message: `Unreadable decision path: ${error2 instanceof Error ? error2.message : String(error2)}`
4464
4400
  });
4465
4401
  return void 0;
4466
4402
  });
4467
- if (!stat21) {
4403
+ if (!stat20) {
4468
4404
  files.set(file, "");
4469
4405
  continue;
4470
4406
  }
4471
- if (stat21.isSymbolicLink() || stat21.isFile() && stat21.nlink > 1 || !stat21.isFile() && !stat21.isDirectory()) {
4407
+ if (stat20.isSymbolicLink() || stat20.isFile() && stat20.nlink > 1 || !stat20.isFile() && !stat20.isDirectory()) {
4472
4408
  files.set(file, "");
4473
4409
  errors.push({ file, message: "Linked or nonregular decision path" });
4474
4410
  continue;
4475
4411
  }
4476
- if (stat21.isDirectory() && file !== import_node_path9.default.join(specsDir, "decisions")) files.set(file, "");
4412
+ if (stat20.isDirectory() && file !== import_node_path9.default.join(specsDir, "decisions")) files.set(file, "");
4477
4413
  }
4478
4414
  if (entry.isDirectory()) await collectTexts(file, files, specsDir, errors);
4479
4415
  else if (entry.isFile()) {
@@ -5931,8 +5867,7 @@ function parseSkillFrontmatter(content) {
5931
5867
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
5932
5868
  return { parseError: "frontmatter must parse to an object" };
5933
5869
  }
5934
- const root = { ...parsed };
5935
- return { ...readDeclaredRoles(root.roles), ...readDeclaredProfile(root["routing-profile"]) };
5870
+ return {};
5936
5871
  }
5937
5872
  function skillFrontmatterMapping(content) {
5938
5873
  const raw = content.match(FRONTMATTER_PATTERN)?.[1];
@@ -5946,31 +5881,6 @@ function skillFrontmatterMapping(content) {
5946
5881
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return void 0;
5947
5882
  return { ...parsed };
5948
5883
  }
5949
- function readDeclaredProfile(profile) {
5950
- if (profile === void 0) {
5951
- return {};
5952
- }
5953
- if (typeof profile !== "string" || profile.trim().length === 0) {
5954
- return { profileError: "frontmatter.routing-profile must be a non-empty profile name" };
5955
- }
5956
- return { routingProfile: profile.trim() };
5957
- }
5958
- function readDeclaredRoles(roles) {
5959
- if (roles === void 0) {
5960
- return {};
5961
- }
5962
- if (!Array.isArray(roles)) {
5963
- return { rolesError: "frontmatter.roles must be a list of agent ids" };
5964
- }
5965
- const names = [];
5966
- for (const entry of roles) {
5967
- if (typeof entry !== "string" || entry.trim().length === 0) {
5968
- return { rolesError: "frontmatter.roles must contain only non-empty agent ids" };
5969
- }
5970
- names.push(entry.trim());
5971
- }
5972
- return { roles: names };
5973
- }
5974
5884
 
5975
5885
  // src/core/contracts/screenContracts.ts
5976
5886
  var import_node_path15 = __toESM(require("path"), 1);
@@ -7462,10 +7372,7 @@ function toPosixPath2(value) {
7462
7372
  }
7463
7373
 
7464
7374
  // src/core/prototyping/policy.ts
7465
- var PROTOTYPING_REQUIRED_ROLE_IDS = [
7466
- "product-experience-architect",
7467
- "product-surface-reviewer"
7468
- ];
7375
+ var PROTOTYPING_REQUIRED_ROLE_IDS = ["product-surface-reviewer"];
7469
7376
  var PROTOTYPING_ROLE_WRAPPER_INTEGRATIONS = [
7470
7377
  { id: "claude", dir: ".claude/agents", suffix: ".md", label: "Claude Code" },
7471
7378
  { id: "github", dir: ".github/agents", suffix: ".agent.md", label: "GitHub Copilot" }
@@ -10056,18 +9963,8 @@ var import_yaml7 = require("yaml");
10056
9963
  // src/core/emittedRuleCodes.ts
10057
9964
  var EMITTED_RULE_CODES = [
10058
9965
  "QFAI-AGENT-005",
10059
- "QFAI-AGENT-007",
10060
- "QFAI-AGENT-008",
10061
- "QFAI-AGENT-009",
10062
- "QFAI-AGENT-010",
10063
9966
  "QFAI-AGENT-011",
10064
9967
  "QFAI-AGENT-012",
10065
- "QFAI-AGENT-013",
10066
- "QFAI-AGENT-015",
10067
- "QFAI-AGENT-016",
10068
- "QFAI-AGENT-017",
10069
- "QFAI-AGENT-018",
10070
- "QFAI-AGENT-019",
10071
9968
  "QFAI-ASSETS-001",
10072
9969
  "QFAI-ASSETS-002",
10073
9970
  "QFAI-ASSETS-003",
@@ -10270,17 +10167,8 @@ var EMITTED_RULE_CODES = [
10270
10167
  ];
10271
10168
  var ERROR_ONLY_RULE_CODES = [
10272
10169
  "QFAI-AGENT-005",
10273
- "QFAI-AGENT-007",
10274
- "QFAI-AGENT-008",
10275
- "QFAI-AGENT-009",
10276
- "QFAI-AGENT-010",
10277
10170
  "QFAI-AGENT-011",
10278
10171
  "QFAI-AGENT-012",
10279
- "QFAI-AGENT-013",
10280
- "QFAI-AGENT-015",
10281
- "QFAI-AGENT-016",
10282
- "QFAI-AGENT-017",
10283
- "QFAI-AGENT-018",
10284
10172
  "QFAI-ASSETS-001",
10285
10173
  "QFAI-ASSETS-002",
10286
10174
  "QFAI-ASSETS-003",
@@ -11228,8 +11116,8 @@ var import_promises19 = require("fs/promises");
11228
11116
  var import_node_path26 = __toESM(require("path"), 1);
11229
11117
  var import_node_url2 = require("url");
11230
11118
  async function resolveToolVersion() {
11231
- if ("2.2.1".length > 0) {
11232
- return "2.2.1";
11119
+ if ("2.3.0".length > 0) {
11120
+ return "2.3.0";
11233
11121
  }
11234
11122
  try {
11235
11123
  const packagePath = await resolvePackageJsonPath();
@@ -18084,7 +17972,12 @@ function graphEnvironmentKey(environment = graphExecutionEnvironment()) {
18084
17972
  return `${environment.platform}-${environment.architecture}`;
18085
17973
  }
18086
17974
  function graphRuntimePaths(root, environment = graphExecutionEnvironment()) {
18087
- const directory = import_node_path57.default.join(root, ".qfai", "tools", "runtimes", graphEnvironmentKey(environment));
17975
+ return graphRuntimeFiles(
17976
+ import_node_path57.default.join(root, ".qfai", "tools", "runtimes", graphEnvironmentKey(environment)),
17977
+ environment
17978
+ );
17979
+ }
17980
+ function graphRuntimeFiles(directory, environment = graphExecutionEnvironment()) {
18088
17981
  return {
18089
17982
  directory,
18090
17983
  codegraph: import_node_path57.default.join(
@@ -18243,7 +18136,14 @@ var runGraphProcess = async (command, args, options) => {
18243
18136
  return { exitCode: 0, stdout: result.stdout };
18244
18137
  } catch (cause) {
18245
18138
  if (!(cause instanceof Error) || !("code" in cause)) throw cause;
18246
- return { exitCode: typeof cause.code === "number" ? cause.code : 1, stdout: "" };
18139
+ const signal = "signal" in cause && typeof cause.signal === "string" ? cause.signal : void 0;
18140
+ const failure2 = signal ? `was stopped (${signal})` : typeof cause.code === "string" ? `could not start (${cause.code})` : void 0;
18141
+ return {
18142
+ exitCode: typeof cause.code === "number" ? cause.code : 1,
18143
+ stdout: "",
18144
+ ...failure2 ? { failure: failure2 } : {},
18145
+ ...options.captureStderr && "stderr" in cause && typeof cause.stderr === "string" ? { stderr: cause.stderr } : {}
18146
+ };
18247
18147
  }
18248
18148
  };
18249
18149
  async function npmCommand() {
@@ -18404,9 +18304,10 @@ async function prepareGraphRuntimes(root, run2 = runGraphProcess) {
18404
18304
  documents: "documents-not-ready"
18405
18305
  };
18406
18306
  }
18407
- const tools = import_node_path61.default.join(root, ".qfai", "tools");
18408
- const stagingRoot = import_node_path61.default.join(tools, `.preparing-${(0, import_node_crypto6.randomUUID)()}`);
18409
- const staged = graphRuntimePaths(stagingRoot);
18307
+ const staged = graphRuntimeFiles(
18308
+ import_node_path61.default.join(import_node_path61.default.dirname(current.directory), `.p-${(0, import_node_crypto6.randomBytes)(4).toString("hex")}`)
18309
+ );
18310
+ await assertGraphStoragePath(root, staged.directory);
18410
18311
  const notReady = {
18411
18312
  runtime: "not-ready",
18412
18313
  tools: {
@@ -18417,7 +18318,8 @@ async function prepareGraphRuntimes(root, run2 = runGraphProcess) {
18417
18318
  documents: "documents-not-ready",
18418
18319
  previousInstallation: codegraphReady || graphifyReady ? "retained" : "none"
18419
18320
  };
18420
- await (0, import_promises51.mkdir)(staged.directory, { recursive: true });
18321
+ await (0, import_promises51.mkdir)(import_node_path61.default.dirname(staged.directory), { recursive: true });
18322
+ await (0, import_promises51.mkdir)(staged.directory);
18421
18323
  try {
18422
18324
  if (codegraphReady) {
18423
18325
  await (0, import_promises51.cp)(
@@ -18460,10 +18362,15 @@ async function prepareGraphRuntimes(root, run2 = runGraphProcess) {
18460
18362
  };
18461
18363
  const codeVersion = await run2(process.execPath, [staged.codegraph, "--version"], {
18462
18364
  cwd: root,
18463
- env
18365
+ env,
18366
+ captureStderr: true
18464
18367
  });
18465
18368
  if (codeVersion.exitCode !== 0 || codeVersion.stdout.trim() !== GRAPH_VERSIONS.codegraph) {
18466
- return { ...notReady, failedStep: "CodeGraph compatibility" };
18369
+ return {
18370
+ ...notReady,
18371
+ failedStep: "CodeGraph compatibility",
18372
+ recovery: versionCheckRecovery("CodeGraph", codeVersion, GRAPH_VERSIONS.codegraph, root)
18373
+ };
18467
18374
  }
18468
18375
  }
18469
18376
  if (graphifyReady) {
@@ -18522,10 +18429,19 @@ async function prepareGraphRuntimes(root, run2 = runGraphProcess) {
18522
18429
  "-c",
18523
18430
  'from importlib.metadata import version; print(version("graphifyy"))'
18524
18431
  ],
18525
- { cwd: root, env: pythonEnvironment }
18432
+ { cwd: root, env: pythonEnvironment, captureStderr: true }
18526
18433
  );
18527
18434
  if (graphifyVersion.exitCode !== 0 || graphifyVersion.stdout.trim() !== GRAPH_VERSIONS.graphify) {
18528
- return { ...notReady, failedStep: "Graphify compatibility" };
18435
+ return {
18436
+ ...notReady,
18437
+ failedStep: "Graphify compatibility",
18438
+ recovery: versionCheckRecovery(
18439
+ "Graphify",
18440
+ graphifyVersion,
18441
+ GRAPH_VERSIONS.graphify,
18442
+ root
18443
+ )
18444
+ };
18529
18445
  }
18530
18446
  }
18531
18447
  await replaceGraphDirectory(staged.directory, current.directory, root);
@@ -18536,8 +18452,31 @@ async function prepareGraphRuntimes(root, run2 = runGraphProcess) {
18536
18452
  documents: "documents-not-ready"
18537
18453
  };
18538
18454
  } finally {
18539
- await (0, import_promises51.rm)(stagingRoot, { recursive: true, force: true });
18540
- }
18455
+ await (0, import_promises51.rm)(staged.directory, { recursive: true, force: true });
18456
+ }
18457
+ }
18458
+ var CAUSE_LINES = 5;
18459
+ var CAUSE_CHARACTERS = 500;
18460
+ var STAGED_TOOL_DEPTH = 166;
18461
+ var WINDOWS_PATH_LIMIT = 260;
18462
+ var WINDOWS_PATH_MARGIN = 20;
18463
+ function versionCheckRecovery(engine, result, expected, root) {
18464
+ const cause = result.exitCode !== 0 || result.failure ? `Cause: the ${engine} version check ${result.failure ?? `exited with code ${result.exitCode}`}${shownOutput(result.stderr, ": ")}.` : `Cause: the ${engine} version check printed ${shownOutput(result.stdout, "") || "nothing"}, expected ${expected}.`;
18465
+ const pathLimit = windowsPathLimitRecovery(root);
18466
+ return pathLimit ? `${cause}
18467
+ ${pathLimit}` : cause;
18468
+ }
18469
+ function shownOutput(text3, prefix) {
18470
+ const lines = (text3 ?? "").split(/\r?\n/).map((line) => line.replaceAll(" ", " ").trim()).filter((line) => line.length > 0).slice(0, CAUSE_LINES).join(" | ");
18471
+ if (lines.length === 0) return "";
18472
+ const bounded = lines.length > CAUSE_CHARACTERS ? `${lines.slice(0, CAUSE_CHARACTERS)}...` : lines;
18473
+ return `${prefix}${formatReportPath(bounded)}`;
18474
+ }
18475
+ function windowsPathLimitRecovery(root, platform = process.platform) {
18476
+ if (platform !== "win32") return void 0;
18477
+ const longest = root.length + STAGED_TOOL_DEPTH;
18478
+ if (longest < WINDOWS_PATH_LIMIT - WINDOWS_PATH_MARGIN) return void 0;
18479
+ return `The graph tool files reach about ${longest} characters, near or past the Windows limit of ${WINDOWS_PATH_LIMIT}. Move the project to a shorter path, or enable Windows long paths (LongPathsEnabled), then run qfai init again.`;
18541
18480
  }
18542
18481
  function rerunByHand(engine, command) {
18543
18482
  const raw = import_node_path61.default.join(import_node_os2.default.tmpdir(), "qfai-graph-check", engine);
@@ -20536,8 +20475,8 @@ function buildCopilotInstructions() {
20536
20475
  }
20537
20476
 
20538
20477
  // src/cli/commands/report.ts
20539
- var import_promises104 = require("fs/promises");
20540
- var import_node_path132 = __toESM(require("path"), 1);
20478
+ var import_promises102 = require("fs/promises");
20479
+ var import_node_path130 = __toESM(require("path"), 1);
20541
20480
 
20542
20481
  // src/core/normalize.ts
20543
20482
  function normalizeIssuePaths(root, issues) {
@@ -20785,8 +20724,8 @@ async function writeBusinessFlowReports(root, config, flowIds) {
20785
20724
  }
20786
20725
 
20787
20726
  // src/core/validate.ts
20788
- var import_node_path129 = __toESM(require("path"), 1);
20789
- var import_promises101 = require("fs/promises");
20727
+ var import_node_path127 = __toESM(require("path"), 1);
20728
+ var import_promises99 = require("fs/promises");
20790
20729
 
20791
20730
  // src/core/validators/storyTreeStructure.ts
20792
20731
  var import_promises64 = require("fs/promises");
@@ -25033,8 +24972,7 @@ async function validateStepTree(root, config) {
25033
24972
  ...[...parents.values()].flatMap(
25034
24973
  (parent) => requiresListIssues(parent.rel, parent.requires, tree)
25035
24974
  ),
25036
- ...orphanIssues(tree),
25037
- ...parentRolesIssues(tree)
24975
+ ...orphanIssues(tree)
25038
24976
  ];
25039
24977
  }
25040
24978
  function finding2(message, file, rule2) {
@@ -25084,8 +25022,7 @@ async function readParents(root, skillsDir, entries) {
25084
25022
  name: entry.name,
25085
25023
  rel,
25086
25024
  steps,
25087
- requires: mapping?.requires ?? [],
25088
- roles: mapping?.roles
25025
+ requires: mapping?.requires ?? []
25089
25026
  });
25090
25027
  }
25091
25028
  }
@@ -25251,30 +25188,6 @@ function orphanIssues(tree) {
25251
25188
  )
25252
25189
  );
25253
25190
  }
25254
- function stringList2(value) {
25255
- return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
25256
- }
25257
- function parentRolesIssues(tree) {
25258
- const rolesOf = new Map(
25259
- tree.steps.map((step) => [step.dir, stringList2(step.frontmatter?.roles)])
25260
- );
25261
- return [...tree.parents.values()].flatMap((parent) => {
25262
- const declared = new Set(stringList2(parent.roles));
25263
- const needed = /* @__PURE__ */ new Set([
25264
- "orchestrator",
25265
- ...stringList2(parent.steps).flatMap((name) => rolesOf.get(name) ?? [])
25266
- ]);
25267
- const missing = [...needed].filter((role) => !declared.has(role)).sort();
25268
- if (missing.length === 0) return [];
25269
- return [
25270
- finding2(
25271
- `${parent.rel} roles: omits ${missing.join(", ")}. A skill run by name dispatches the agents of every step it lists, so it declares orchestrator and each of their roles.`,
25272
- parent.rel,
25273
- "parentRolesMissing"
25274
- )
25275
- ];
25276
- });
25277
- }
25278
25191
 
25279
25192
  // src/core/validators/assistantAnchorReferences.ts
25280
25193
  var import_promises78 = require("fs/promises");
@@ -26359,7 +26272,7 @@ function collectLayer(layer, layerName, target, errors) {
26359
26272
  }
26360
26273
  function flattenTokens(obj, prefix, target, errors) {
26361
26274
  for (const [key, value] of Object.entries(obj)) {
26362
- const path140 = `${prefix}.${key}`;
26275
+ const path138 = `${prefix}.${key}`;
26363
26276
  if (value && typeof value === "object" && !Array.isArray(value)) {
26364
26277
  const record2 = value;
26365
26278
  if ("$value" in record2) {
@@ -26375,9 +26288,9 @@ function flattenTokens(obj, prefix, target, errors) {
26375
26288
  if (typeof record2.platform === "string") {
26376
26289
  token2.platform = record2.platform;
26377
26290
  }
26378
- target.set(path140, token2);
26291
+ target.set(path138, token2);
26379
26292
  } else {
26380
- flattenTokens(record2, path140, target, errors);
26293
+ flattenTokens(record2, path138, target, errors);
26381
26294
  }
26382
26295
  }
26383
26296
  }
@@ -26387,44 +26300,44 @@ function resolveAllReferences(result) {
26387
26300
  for (const [key, val] of result.primitives) allTokens.set(key, val);
26388
26301
  for (const [key, val] of result.semantics) allTokens.set(key, val);
26389
26302
  for (const [key, val] of result.components) allTokens.set(key, val);
26390
- for (const [path140] of allTokens) {
26391
- resolveTokenRef(path140, allTokens, /* @__PURE__ */ new Set(), 0, result);
26303
+ for (const [path138] of allTokens) {
26304
+ resolveTokenRef(path138, allTokens, /* @__PURE__ */ new Set(), 0, result);
26392
26305
  }
26393
26306
  }
26394
- function resolveTokenRef(path140, allTokens, visited, depth, result) {
26395
- if (result.resolved.has(path140)) {
26396
- return result.resolved.get(path140);
26307
+ function resolveTokenRef(path138, allTokens, visited, depth, result) {
26308
+ if (result.resolved.has(path138)) {
26309
+ return result.resolved.get(path138);
26397
26310
  }
26398
26311
  if (depth > MAX_RESOLVE_DEPTH) {
26399
26312
  result.errors.push({
26400
- message: `Max reference depth exceeded at: ${path140}`,
26401
- path: path140
26313
+ message: `Max reference depth exceeded at: ${path138}`,
26314
+ path: path138
26402
26315
  });
26403
26316
  return void 0;
26404
26317
  }
26405
- if (visited.has(path140)) {
26318
+ if (visited.has(path138)) {
26406
26319
  result.errors.push({
26407
- message: `Circular reference detected: ${path140}`,
26408
- path: path140
26320
+ message: `Circular reference detected: ${path138}`,
26321
+ path: path138
26409
26322
  });
26410
26323
  return void 0;
26411
26324
  }
26412
- const token2 = allTokens.get(path140);
26325
+ const token2 = allTokens.get(path138);
26413
26326
  if (!token2) {
26414
26327
  return void 0;
26415
26328
  }
26416
26329
  if (typeof token2.$value !== "string") {
26417
26330
  const rawValue2 = stringifyTokenValue(token2.$value);
26418
- result.resolved.set(path140, rawValue2);
26331
+ result.resolved.set(path138, rawValue2);
26419
26332
  return rawValue2;
26420
26333
  }
26421
26334
  const rawValue = stringifyTokenValue(token2.$value);
26422
26335
  const refs = [...rawValue.matchAll(REF_PATTERN)];
26423
26336
  if (refs.length === 0) {
26424
- result.resolved.set(path140, rawValue);
26337
+ result.resolved.set(path138, rawValue);
26425
26338
  return rawValue;
26426
26339
  }
26427
- visited.add(path140);
26340
+ visited.add(path138);
26428
26341
  let resolved = rawValue;
26429
26342
  for (const ref of refs) {
26430
26343
  const refPath = ref[1];
@@ -26432,8 +26345,8 @@ function resolveTokenRef(path140, allTokens, visited, depth, result) {
26432
26345
  const refToken = allTokens.get(refPath);
26433
26346
  if (!refToken) {
26434
26347
  result.errors.push({
26435
- message: `Unresolved token reference: {${refPath}} at ${path140}`,
26436
- path: path140
26348
+ message: `Unresolved token reference: {${refPath}} at ${path138}`,
26349
+ path: path138
26437
26350
  });
26438
26351
  continue;
26439
26352
  }
@@ -26442,7 +26355,7 @@ function resolveTokenRef(path140, allTokens, visited, depth, result) {
26442
26355
  resolved = resolved.split(`{${refPath}}`).join(refValue);
26443
26356
  }
26444
26357
  }
26445
- result.resolved.set(path140, resolved);
26358
+ result.resolved.set(path138, resolved);
26446
26359
  return resolved;
26447
26360
  }
26448
26361
  function stringifyTokenValue(value) {
@@ -28108,305 +28021,8 @@ function resolveFreshnessReferenceNow() {
28108
28021
  }
28109
28022
 
28110
28023
  // src/core/validators/agentDefinition.ts
28111
- var import_promises92 = require("fs/promises");
28112
- var import_node_path108 = __toESM(require("path"), 1);
28113
- var import_yaml20 = require("yaml");
28114
-
28115
- // src/core/routingDefaults.ts
28116
28024
  var import_promises90 = require("fs/promises");
28117
28025
  var import_node_path106 = __toESM(require("path"), 1);
28118
- var ROUTING_DEFAULTS_REL = "packages/qfai/assets/defaults/agent-routing";
28119
- function routingDefaultsDir() {
28120
- return import_node_path106.default.resolve(getInitAssetsDir(), "..", "defaults", "agent-routing");
28121
- }
28122
- async function readRoutingDefaultsFiles() {
28123
- const dir = routingDefaultsDir();
28124
- const names = (await (0, import_promises90.readdir)(dir)).filter((name) => name.endsWith(".yml")).sort();
28125
- return Promise.all(
28126
- names.map(async (name) => ({
28127
- rel: `${ROUTING_DEFAULTS_REL}/${name}`,
28128
- text: await (0, import_promises90.readFile)(import_node_path106.default.join(dir, name), "utf-8")
28129
- }))
28130
- );
28131
- }
28132
-
28133
- // src/core/validators/skillRoles.ts
28134
- var import_promises91 = require("fs/promises");
28135
- var import_node_path107 = __toESM(require("path"), 1);
28136
- var MANIFEST_EXTERNAL_ROLES = /* @__PURE__ */ new Set(["orchestrator"]);
28137
- function emptySkillRouting(kind = "skill") {
28138
- return { kind, agents: /* @__PURE__ */ new Map(), phases: 0 };
28139
- }
28140
- function recordRoutedAgents(entry, value, binding, known) {
28141
- if (!Array.isArray(value)) {
28142
- return 0;
28143
- }
28144
- let usable = 0;
28145
- for (const agent of value) {
28146
- if (typeof agent !== "string" || agent.length === 0) {
28147
- continue;
28148
- }
28149
- usable += 1;
28150
- if (known && !known.has(agent)) {
28151
- continue;
28152
- }
28153
- if (binding === "required" || !entry.agents.has(agent)) {
28154
- entry.agents.set(agent, binding);
28155
- }
28156
- }
28157
- return usable;
28158
- }
28159
- async function validateSkillRoles(root, config, routing, profiles, issues) {
28160
- const skillsDir = resolvePath(root, config, "skillsDir");
28161
- const crossCheckSeverity = "error";
28162
- for (const [skill, entry] of routing) {
28163
- const skillPath = entry.kind === "step" ? joinAssistantLayer(root, "step", skill, "STEP.md") : import_node_path107.default.join(skillsDir, skill, "SKILL.md");
28164
- const rel = import_node_path107.default.relative(root, skillPath).replace(/\\/g, "/");
28165
- let gate = reportManifestGateDefects(skill, entry, profiles, rel, issues, crossCheckSeverity);
28166
- if (entry.phases === 0) {
28167
- continue;
28168
- }
28169
- const frontmatter = await readSkillFrontmatter(skillPath);
28170
- if (!frontmatter) {
28171
- continue;
28172
- }
28173
- if (frontmatter.parseError) {
28174
- issues.push(unreadableFrontmatter(rel, skill, frontmatter.parseError, crossCheckSeverity));
28175
- continue;
28176
- }
28177
- gate = reportSkillGateDefects(skill, entry, frontmatter, rel, issues, crossCheckSeverity) && gate;
28178
- if (frontmatter.rolesError) {
28179
- issues.push(
28180
- issue(
28181
- "QFAI-AGENT-016",
28182
- `${rel} declares an unusable roles: frontmatter (${frontmatter.rolesError}); the ${skill} routing cross-check cannot run.`,
28183
- crossCheckSeverity,
28184
- rel,
28185
- "agentDefinition.invalidSkillRoles"
28186
- )
28187
- );
28188
- continue;
28189
- }
28190
- if (!frontmatter.roles || !gate) {
28191
- continue;
28192
- }
28193
- const selected = collectSelections(skill, entry, profiles);
28194
- reportUndeclaredRoutedAgents(selected, frontmatter.roles, rel, issues);
28195
- reportUnselectableRoles(
28196
- skill,
28197
- selected,
28198
- frontmatter.roles,
28199
- entry.reviewProfile,
28200
- rel,
28201
- issues,
28202
- crossCheckSeverity
28203
- );
28204
- }
28205
- await reportUnroutedSkills(root, skillsDir, "SKILL.md", routing, issues, crossCheckSeverity);
28206
- const stepsDir = joinAssistantLayer(root, "step");
28207
- await reportUnroutedSkills(root, stepsDir, "STEP.md", routing, issues, crossCheckSeverity);
28208
- }
28209
- function unreadableFrontmatter(rel, skill, reason, crossCheckSeverity) {
28210
- return issue(
28211
- "QFAI-AGENT-016",
28212
- `${rel} carries an unreadable frontmatter block (${reason}); the ${skill} routing cross-check cannot run.`,
28213
- crossCheckSeverity,
28214
- rel,
28215
- "agentDefinition.unreadableSkillFrontmatter"
28216
- );
28217
- }
28218
- async function readSkillFrontmatter(skillPath) {
28219
- try {
28220
- if (!(await (0, import_promises91.stat)(skillPath)).isFile()) {
28221
- return void 0;
28222
- }
28223
- return parseSkillFrontmatter(await (0, import_promises91.readFile)(skillPath, "utf-8"));
28224
- } catch {
28225
- return void 0;
28226
- }
28227
- }
28228
- function reportManifestGateDefects(skill, entry, profiles, rel, issues, crossCheckSeverity) {
28229
- let trusted = true;
28230
- if (entry.reviewProfileConflict) {
28231
- const { first, second } = entry.reviewProfileConflict;
28232
- issues.push(
28233
- issue(
28234
- "QFAI-AGENT-018",
28235
- `The routing sends "${skill}" through two different review profiles ("${first}" and "${second}"); one skill has one review gate.`,
28236
- crossCheckSeverity,
28237
- rel,
28238
- "agentDefinition.conflictingReviewProfile"
28239
- )
28240
- );
28241
- trusted = false;
28242
- }
28243
- if (entry.reviewProfileUnusable) {
28244
- return false;
28245
- }
28246
- const routed = entry.reviewProfile;
28247
- if (routed === void 0) {
28248
- return trusted;
28249
- }
28250
- const selection = profiles.get(routed);
28251
- if (selection === void 0) {
28252
- issues.push(
28253
- issue(
28254
- "QFAI-AGENT-018",
28255
- `The routing sends "${skill}" through review profile "${routed}", which review-profiles.yml does not define.`,
28256
- crossCheckSeverity,
28257
- rel,
28258
- "agentDefinition.unknownReviewProfile"
28259
- )
28260
- );
28261
- return false;
28262
- }
28263
- return trusted && !selection.incomplete;
28264
- }
28265
- function reportSkillGateDefects(skill, entry, frontmatter, rel, issues, crossCheckSeverity) {
28266
- if (frontmatter.profileError) {
28267
- issues.push(
28268
- issue(
28269
- "QFAI-AGENT-016",
28270
- `${rel} declares an unusable routing-profile: (${frontmatter.profileError}); the ${skill} review gate cannot be checked.`,
28271
- crossCheckSeverity,
28272
- rel,
28273
- "agentDefinition.invalidRoutingProfile"
28274
- )
28275
- );
28276
- return false;
28277
- }
28278
- const declared = frontmatter.routingProfile;
28279
- if (declared === void 0) {
28280
- return true;
28281
- }
28282
- if (entry.reviewProfileUnusable) {
28283
- return false;
28284
- }
28285
- const routed = entry.reviewProfile;
28286
- if (routed === declared) {
28287
- return true;
28288
- }
28289
- const found = routed === void 0 ? "declares no review_profile" : `declares ${routed}`;
28290
- issues.push(
28291
- issue(
28292
- "QFAI-AGENT-018",
28293
- `${rel} declares routing-profile: ${declared} but the route for "${skill}" ${found}.`,
28294
- crossCheckSeverity,
28295
- rel,
28296
- "agentDefinition.routingProfileMismatch"
28297
- )
28298
- );
28299
- return false;
28300
- }
28301
- function collectSelections(skill, entry, profiles) {
28302
- const selected = /* @__PURE__ */ new Map();
28303
- for (const [agent, binding] of entry.agents) {
28304
- selected.set(agent, {
28305
- binding,
28306
- source: `the routing binds it to ${skill} as ${binding}`
28307
- });
28308
- }
28309
- const profileName = entry.reviewProfile;
28310
- if (!profileName) {
28311
- return selected;
28312
- }
28313
- for (const [reviewer, binding] of profiles.get(profileName)?.reviewers ?? []) {
28314
- const prior = selected.get(reviewer);
28315
- if (prior && (prior.binding === "required" || binding === "conditional")) {
28316
- continue;
28317
- }
28318
- const clause2 = binding === "required" ? "always_required" : "conditional_required";
28319
- selected.set(reviewer, {
28320
- binding,
28321
- source: `review profile "${profileName}" selects it as ${clause2}`
28322
- });
28323
- }
28324
- return selected;
28325
- }
28326
- function reportUndeclaredRoutedAgents(selected, declared, rel, issues) {
28327
- const declaredSet = new Set(declared);
28328
- for (const [agent, selection] of selected) {
28329
- if (declaredSet.has(agent)) {
28330
- continue;
28331
- }
28332
- issues.push(
28333
- issue(
28334
- "QFAI-AGENT-019",
28335
- `${rel} omits routed agent "${agent}" from roles: (${selection.source})`,
28336
- // A `conditional` omission is a documentation gap and stays a warning;
28337
- // a `required` one means a reviewer the profile mandates is not
28338
- // reachable, which is a gate.
28339
- selection.binding === "required" ? "error" : "warning",
28340
- rel,
28341
- "agentDefinition.routedAgentNotDeclared"
28342
- )
28343
- );
28344
- }
28345
- }
28346
- function reportUnselectableRoles(skill, selected, declared, profileName, rel, issues, crossCheckSeverity) {
28347
- const profileLabel = profileName ? `review profile "${profileName}"` : "declared review profile";
28348
- for (const role of declared) {
28349
- if (selected.has(role) || MANIFEST_EXTERNAL_ROLES.has(role)) {
28350
- continue;
28351
- }
28352
- issues.push(
28353
- issue(
28354
- "QFAI-AGENT-015",
28355
- `${rel} declares role "${role}" that no ${skill} routing phase and no ${profileLabel} selects.`,
28356
- crossCheckSeverity,
28357
- rel,
28358
- "agentDefinition.roleNeverSelected"
28359
- )
28360
- );
28361
- }
28362
- }
28363
- async function reportUnroutedSkills(root, skillsDir, docName, routing, issues, crossCheckSeverity) {
28364
- let entries;
28365
- try {
28366
- entries = await (0, import_promises91.readdir)(skillsDir);
28367
- } catch {
28368
- return;
28369
- }
28370
- for (const name of entries.sort()) {
28371
- if ((routing.get(name)?.phases ?? 0) > 0) {
28372
- continue;
28373
- }
28374
- const skillPath = import_node_path107.default.join(skillsDir, name, docName);
28375
- const frontmatter = await readSkillFrontmatter(skillPath);
28376
- const rel = import_node_path107.default.relative(root, skillPath).replace(/\\/g, "/");
28377
- if (frontmatter?.parseError) {
28378
- issues.push(unreadableFrontmatter(rel, name, frontmatter.parseError, crossCheckSeverity));
28379
- continue;
28380
- }
28381
- if (frontmatter?.profileError) {
28382
- issues.push(
28383
- issue(
28384
- "QFAI-AGENT-016",
28385
- `${rel} declares an unusable routing-profile: (${frontmatter.profileError}); the ${name} review gate cannot be checked.`,
28386
- crossCheckSeverity,
28387
- rel,
28388
- "agentDefinition.invalidRoutingProfile"
28389
- )
28390
- );
28391
- continue;
28392
- }
28393
- const profile = frontmatter?.routingProfile;
28394
- if (!profile) {
28395
- continue;
28396
- }
28397
- issues.push(
28398
- issue(
28399
- "QFAI-AGENT-017",
28400
- `${rel} declares routing-profile: ${profile} but the routing sends no phases to "${name}".`,
28401
- crossCheckSeverity,
28402
- rel,
28403
- "agentDefinition.skillNotRouted"
28404
- )
28405
- );
28406
- }
28407
- }
28408
-
28409
- // src/core/validators/agentDefinition.ts
28410
28026
  var REQUIRED_AGENT_SECTIONS = [
28411
28027
  "## Mission",
28412
28028
  "## Domain Responsibilities",
@@ -28415,23 +28031,18 @@ var REQUIRED_AGENT_SECTIONS = [
28415
28031
  "## Stop conditions",
28416
28032
  "## Sign-off"
28417
28033
  ];
28418
- var ROUTING_ITERATIONS = /* @__PURE__ */ new Set(["per-invocation", "per-ledger-item"]);
28419
- var RERUN_POLICIES = /* @__PURE__ */ new Set(["failed-agents-only", "changed-scope-dependents"]);
28420
- async function validateAgentDefinition(root, config) {
28034
+ async function validateAgentDefinition(root) {
28421
28035
  const issues = [];
28422
- const agentsDir = import_node_path108.default.join(root, ".qfai", "assistant", "agent");
28036
+ const agentsDir = import_node_path106.default.join(root, ".qfai", "assistant", "agent");
28423
28037
  if (!await exists3(agentsDir)) {
28424
28038
  return [];
28425
28039
  }
28426
- const agentIds = /* @__PURE__ */ new Set();
28427
- const reviewerIds = /* @__PURE__ */ new Set();
28428
- for (const name of await (0, import_promises92.readdir)(agentsDir)) {
28040
+ for (const name of await (0, import_promises90.readdir)(agentsDir)) {
28429
28041
  if (!name.endsWith(".md")) continue;
28430
28042
  const id = name.slice(0, -3);
28431
- const filePath = import_node_path108.default.join(agentsDir, name);
28043
+ const filePath = import_node_path106.default.join(agentsDir, name);
28432
28044
  const rel = `.qfai/assistant/agent/${name}`;
28433
- agentIds.add(id);
28434
- const content = await (0, import_promises92.readFile)(filePath, "utf-8");
28045
+ const content = await (0, import_promises90.readFile)(filePath, "utf-8");
28435
28046
  const frontmatter = parseAgentFrontmatter(content);
28436
28047
  if (!frontmatter.ok) {
28437
28048
  issues.push(
@@ -28457,7 +28068,6 @@ async function validateAgentDefinition(root, config) {
28457
28068
  );
28458
28069
  continue;
28459
28070
  }
28460
- if (frontmatter.frontmatter.kind === "reviewer") reviewerIds.add(id);
28461
28071
  for (const heading of REQUIRED_AGENT_SECTIONS) {
28462
28072
  if (!content.includes(heading)) {
28463
28073
  issues.push(
@@ -28472,438 +28082,12 @@ async function validateAgentDefinition(root, config) {
28472
28082
  }
28473
28083
  }
28474
28084
  }
28475
- const defaultsDir = import_node_path108.default.resolve(getInitAssetsDir(), "..", "defaults");
28476
- const profilesPath = import_node_path108.default.join(defaultsDir, "review-profiles.yml");
28477
- const routing = await validateRouting(config.routing ?? [], agentIds, issues);
28478
- const profiles = await validateProfiles(
28479
- profilesPath,
28480
- config.reviewProfiles ?? {},
28481
- reviewerIds,
28482
- issues
28483
- );
28484
- if (routing !== void 0 && profiles !== void 0) {
28485
- await validateSkillRoles(root, config, routing, profiles, issues);
28486
- }
28487
28085
  return issues;
28488
28086
  }
28489
- function routingListOf(file, issues) {
28490
- const shapeError = (message, rule2) => {
28491
- issues.push(issue("QFAI-AGENT-007", `${file.rel} ${message}`, "error", file.rel, rule2));
28492
- };
28493
- let parsed;
28494
- try {
28495
- parsed = (0, import_yaml20.parse)(file.text);
28496
- } catch {
28497
- shapeError("could not be parsed", "agentDefinition.routingParse");
28498
- return void 0;
28499
- }
28500
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
28501
- shapeError("must parse to an object", "agentDefinition.invalidRoutingShape");
28502
- return void 0;
28503
- }
28504
- const list2 = Reflect.get(parsed, "routing");
28505
- if (!Array.isArray(list2)) {
28506
- shapeError("must contain routing array", "agentDefinition.invalidRoutingShape");
28507
- return void 0;
28508
- }
28509
- const routing = list2;
28510
- return routing;
28511
- }
28512
- async function readDefaultRoutes(issues) {
28513
- const routes = [];
28514
- let complete = true;
28515
- for (const file of await readRoutingDefaultsFiles()) {
28516
- const list2 = routingListOf(file, issues);
28517
- if (list2 === void 0) complete = false;
28518
- else routes.push(...list2.map((route) => ({ route, source: file.rel })));
28519
- }
28520
- return complete ? routes : void 0;
28521
- }
28522
- async function validateRouting(overrides, agentIds, issues) {
28523
- const routed = /* @__PURE__ */ new Map();
28524
- const defaults = await readDefaultRoutes(issues);
28525
- if (defaults === void 0) return void 0;
28526
- try {
28527
- const effective = /* @__PURE__ */ new Map();
28528
- for (const entry of defaults) {
28529
- const { route } = entry;
28530
- if (route && typeof route === "object" && !Array.isArray(route)) {
28531
- const name = routingEntryName({
28532
- step: Reflect.get(route, "step"),
28533
- skill: Reflect.get(route, "skill")
28534
- });
28535
- if (name !== void 0) effective.set(name, entry);
28536
- }
28537
- }
28538
- for (const route of overrides) {
28539
- const name = routingEntryName(route);
28540
- if (name !== void 0) effective.set(name, { route, source: "qfai.config.yaml" });
28541
- }
28542
- for (const [routeIndex, { route, source }] of [...effective.values()].entries()) {
28543
- if (!route || typeof route !== "object" || Array.isArray(route)) {
28544
- continue;
28545
- }
28546
- const routeObj = route;
28547
- const routeName = routingEntryName(routeObj);
28548
- const routedEntry = collectRouteHeader(
28549
- routeObj,
28550
- routed,
28551
- issues,
28552
- source,
28553
- formatSkillLabel(routeName, routeIndex)
28554
- );
28555
- if (!Array.isArray(routeObj.phases)) {
28556
- continue;
28557
- }
28558
- for (const [phaseIndex, phase] of routeObj.phases.entries()) {
28559
- if (!phase || typeof phase !== "object" || Array.isArray(phase)) {
28560
- continue;
28561
- }
28562
- const phaseObj = phase;
28563
- if (phaseObj.iteration !== void 0) {
28564
- const declared = phaseObj.iteration;
28565
- if (typeof declared !== "string" || !ROUTING_ITERATIONS.has(declared)) {
28566
- issues.push(
28567
- issue(
28568
- "QFAI-AGENT-013",
28569
- `${formatSkillLabel(routeName, routeIndex)} phase[${phaseIndex}] declares iteration ${JSON.stringify(declared)}; allowed: ${[...ROUTING_ITERATIONS].sort().join(", ")}`,
28570
- "error",
28571
- source,
28572
- "agentDefinition.routingIteration"
28573
- )
28574
- );
28575
- }
28576
- }
28577
- if (phaseObj.rerun_policy !== void 0) {
28578
- const declared = phaseObj.rerun_policy;
28579
- if (typeof declared !== "string" || !RERUN_POLICIES.has(declared)) {
28580
- issues.push(
28581
- issue(
28582
- "QFAI-AGENT-013",
28583
- `${formatSkillLabel(routeName, routeIndex)} phase[${phaseIndex}] declares rerun_policy ${JSON.stringify(declared)}; allowed: ${[...RERUN_POLICIES].sort().join(", ")}`,
28584
- "error",
28585
- source,
28586
- "agentDefinition.rerunPolicy"
28587
- )
28588
- );
28589
- }
28590
- }
28591
- validateAgentRefs(
28592
- source,
28593
- phaseObj.mandatory_agents,
28594
- agentIds,
28595
- issues,
28596
- formatSkillLabel(routeName, routeIndex),
28597
- routeIndex,
28598
- phaseIndex,
28599
- "mandatory_agents"
28600
- );
28601
- validateAgentRefs(
28602
- source,
28603
- phaseObj.conditional_agents,
28604
- agentIds,
28605
- issues,
28606
- formatSkillLabel(routeName, routeIndex),
28607
- routeIndex,
28608
- phaseIndex,
28609
- "conditional_agents"
28610
- );
28611
- validateAgentRefs(
28612
- source,
28613
- phaseObj.blocking_agents,
28614
- agentIds,
28615
- issues,
28616
- formatSkillLabel(routeName, routeIndex),
28617
- routeIndex,
28618
- phaseIndex,
28619
- "blocking_agents"
28620
- );
28621
- if (Array.isArray(phaseObj.parallel_groups)) {
28622
- for (const group of phaseObj.parallel_groups) {
28623
- validateAgentRefs(
28624
- source,
28625
- group,
28626
- agentIds,
28627
- issues,
28628
- formatSkillLabel(routeName, routeIndex),
28629
- routeIndex,
28630
- phaseIndex,
28631
- "parallel_groups"
28632
- );
28633
- }
28634
- }
28635
- validateAgentFieldShapes(
28636
- source,
28637
- phaseObj,
28638
- issues,
28639
- formatSkillLabel(routeName, routeIndex),
28640
- phaseIndex
28641
- );
28642
- if (routedEntry) {
28643
- collectPhaseAgents(routedEntry, phaseObj, agentIds);
28644
- }
28645
- }
28646
- }
28647
- } catch {
28648
- issues.push(
28649
- issue(
28650
- "QFAI-AGENT-007",
28651
- "the routing defaults could not be read",
28652
- "error",
28653
- ROUTING_DEFAULTS_REL,
28654
- "agentDefinition.routingParse"
28655
- )
28656
- );
28657
- return void 0;
28658
- }
28659
- return routed;
28660
- }
28661
- var PHASE_AGENT_FIELDS = [
28662
- ["mandatory_agents", "required"],
28663
- ["blocking_agents", "required"],
28664
- ["conditional_agents", "conditional"]
28665
- ];
28666
- function collectRouteHeader(routeObj, routed, issues, routingPathRel, skillLabel) {
28667
- const name = routingEntryName(routeObj);
28668
- if (name === void 0) {
28669
- return void 0;
28670
- }
28671
- const kind = name === routeObj.step ? "step" : "skill";
28672
- const entry = routed.get(name) ?? emptySkillRouting(kind);
28673
- const declared = routeObj.review_profile;
28674
- if (typeof declared === "string" && declared.trim().length > 0) {
28675
- const profile = declared.trim();
28676
- if (entry.reviewProfile === void 0) {
28677
- entry.reviewProfile = profile;
28678
- } else if (entry.reviewProfile !== profile) {
28679
- entry.reviewProfileConflict ??= { first: entry.reviewProfile, second: profile };
28680
- }
28681
- } else if (declared !== void 0) {
28682
- entry.reviewProfileUnusable = true;
28683
- issues.push(
28684
- issue(
28685
- "QFAI-AGENT-013",
28686
- `${skillLabel} declares review_profile ${JSON.stringify(declared)}; expected the name of a review-profiles.yml profile`,
28687
- "error",
28688
- routingPathRel,
28689
- "agentDefinition.routingReviewProfileShape"
28690
- )
28691
- );
28692
- }
28693
- routed.set(name, entry);
28694
- return entry;
28695
- }
28696
- function collectPhaseAgents(entry, phase, catalogIds) {
28697
- let dispatchable = 0;
28698
- for (const [field, binding] of PHASE_AGENT_FIELDS) {
28699
- dispatchable += recordRoutedAgents(entry, phase[field], binding, catalogIds);
28700
- }
28701
- if (Array.isArray(phase.parallel_groups)) {
28702
- for (const group of phase.parallel_groups) {
28703
- dispatchable += recordRoutedAgents(entry, group, "conditional", catalogIds);
28704
- }
28705
- }
28706
- if (dispatchable > 0) {
28707
- entry.phases += 1;
28708
- }
28709
- }
28710
- function validateAgentFieldShapes(rel, phase, issues, skill, phaseIndex) {
28711
- const report2 = (field, value) => {
28712
- issues.push(
28713
- issue(
28714
- "QFAI-AGENT-013",
28715
- `${skill} phase[${phaseIndex}] declares ${field} ${JSON.stringify(value)}; expected a list of agent ids`,
28716
- "error",
28717
- rel,
28718
- "agentDefinition.routingAgentFieldShape"
28719
- )
28720
- );
28721
- };
28722
- for (const [field] of PHASE_AGENT_FIELDS) {
28723
- const value = phase[field];
28724
- if (value !== void 0 && !Array.isArray(value)) {
28725
- report2(field, value);
28726
- }
28727
- }
28728
- const groups = phase.parallel_groups;
28729
- if (groups === void 0) {
28730
- return;
28731
- }
28732
- if (!Array.isArray(groups)) {
28733
- report2("parallel_groups", groups);
28734
- return;
28735
- }
28736
- for (const group of groups) {
28737
- if (!Array.isArray(group)) {
28738
- report2("parallel_groups entry", group);
28739
- }
28740
- }
28741
- }
28742
- function validateAgentRefs(routingPathRel, value, catalogIds, issues, skill, routeIndex, phaseIndex, field) {
28743
- if (!Array.isArray(value)) {
28744
- return;
28745
- }
28746
- for (const entry of value) {
28747
- if (typeof entry !== "string") {
28748
- continue;
28749
- }
28750
- if (!catalogIds.has(entry)) {
28751
- issues.push(
28752
- issue(
28753
- "QFAI-AGENT-008",
28754
- `routing references unknown agent "${entry}" in ${skill} phase ${phaseIndex} field ${field}`,
28755
- "error",
28756
- // Sourced from the caller's resolved routing path (manifestPathRel)
28757
- // so the file: argument always points at the actual location read.
28758
- routingPathRel,
28759
- "agentDefinition.unknownRoutingAgent"
28760
- )
28761
- );
28762
- }
28763
- }
28764
- }
28765
- async function validateProfiles(profilesPath, overrides, reviewerIds, issues) {
28766
- const rel = "packages/qfai/assets/defaults/review-profiles.yml";
28767
- const selections = /* @__PURE__ */ new Map();
28768
- const parsed = (0, import_yaml20.parse)(await (0, import_promises92.readFile)(profilesPath, "utf-8"));
28769
- try {
28770
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
28771
- issues.push(
28772
- issue(
28773
- "QFAI-AGENT-009",
28774
- "review-profiles.yml must parse to an object",
28775
- "error",
28776
- rel,
28777
- "agentDefinition.invalidProfilesShape"
28778
- )
28779
- );
28780
- return void 0;
28781
- }
28782
- const profilesRoot = parsed;
28783
- if (!profilesRoot.profiles || typeof profilesRoot.profiles !== "object" || Array.isArray(profilesRoot.profiles)) {
28784
- issues.push(
28785
- issue(
28786
- "QFAI-AGENT-009",
28787
- "review-profiles.yml must contain profiles object",
28788
- "error",
28789
- rel,
28790
- "agentDefinition.invalidProfilesShape"
28791
- )
28792
- );
28793
- return void 0;
28794
- }
28795
- const profiles = { ...profilesRoot.profiles, ...overrides };
28796
- for (const [profileName, profile] of Object.entries(profiles)) {
28797
- if (!profile || typeof profile !== "object" || Array.isArray(profile)) {
28798
- continue;
28799
- }
28800
- const profileObj = profile;
28801
- const source = Object.hasOwn(overrides, profileName) ? "qfai.config.yaml" : rel;
28802
- const shapesUsable = validateReviewerFieldShapes(profileObj, issues, profileName, source);
28803
- selections.set(profileName, {
28804
- reviewers: collectProfileReviewers(
28805
- profileObj.always_required,
28806
- profileObj.conditional_required,
28807
- reviewerIds
28808
- ),
28809
- incomplete: !shapesUsable
28810
- });
28811
- validateReviewerRefs(
28812
- profileObj.always_required,
28813
- reviewerIds,
28814
- issues,
28815
- profileName,
28816
- "always",
28817
- source
28818
- );
28819
- validateReviewerRefs(
28820
- profileObj.conditional_required,
28821
- reviewerIds,
28822
- issues,
28823
- profileName,
28824
- "conditional",
28825
- source
28826
- );
28827
- }
28828
- } catch {
28829
- issues.push(
28830
- issue(
28831
- "QFAI-AGENT-009",
28832
- "review-profiles.yml could not be parsed",
28833
- "error",
28834
- rel,
28835
- "agentDefinition.profilesParse"
28836
- )
28837
- );
28838
- return void 0;
28839
- }
28840
- return selections;
28841
- }
28842
- function collectProfileReviewers(always, conditional, reviewerIds) {
28843
- const reviewers = /* @__PURE__ */ new Map();
28844
- for (const [value, binding] of [
28845
- [conditional, "conditional"],
28846
- [always, "required"]
28847
- ]) {
28848
- if (!Array.isArray(value)) {
28849
- continue;
28850
- }
28851
- for (const entry of value) {
28852
- if (typeof entry === "string" && entry.length > 0 && reviewerIds.has(entry)) {
28853
- reviewers.set(entry, binding);
28854
- }
28855
- }
28856
- }
28857
- return reviewers;
28858
- }
28859
- function validateReviewerFieldShapes(profileObj, issues, profileName, profilesPathRel) {
28860
- let usable = true;
28861
- for (const field of ["always_required", "conditional_required"]) {
28862
- const value = profileObj[field];
28863
- if (value === void 0 || Array.isArray(value)) {
28864
- continue;
28865
- }
28866
- usable = false;
28867
- issues.push(
28868
- issue(
28869
- "QFAI-AGENT-009",
28870
- `review-profiles.yml profile "${profileName}" declares ${field} ${JSON.stringify(value)}; expected a list of reviewer ids`,
28871
- "error",
28872
- profilesPathRel,
28873
- "agentDefinition.invalidProfilesShape"
28874
- )
28875
- );
28876
- }
28877
- return usable;
28878
- }
28879
- function formatSkillLabel(skill, routeIndex) {
28880
- return typeof skill === "string" && skill.length > 0 ? skill : `route-${routeIndex}`;
28881
- }
28882
- function validateReviewerRefs(value, reviewerIds, issues, profileName, field, profilesPathRel) {
28883
- if (!Array.isArray(value)) {
28884
- return;
28885
- }
28886
- for (const entry of value) {
28887
- if (typeof entry !== "string") {
28888
- continue;
28889
- }
28890
- if (!reviewerIds.has(entry)) {
28891
- issues.push(
28892
- issue(
28893
- "QFAI-AGENT-010",
28894
- `review-profiles.yml profile "${profileName}" references non-reviewer agent "${entry}" in ${field}_required`,
28895
- "error",
28896
- profilesPathRel,
28897
- "agentDefinition.nonReviewerInProfile"
28898
- )
28899
- );
28900
- }
28901
- }
28902
- }
28903
28087
 
28904
28088
  // src/core/validators/designAudit.ts
28905
- var import_promises93 = require("fs/promises");
28906
- var import_node_path109 = __toESM(require("path"), 1);
28089
+ var import_promises91 = require("fs/promises");
28090
+ var import_node_path107 = __toESM(require("path"), 1);
28907
28091
  var COSMETIC_CATEGORIES = ["generic-shell", "stock-imagery", "placeholder-copy"];
28908
28092
  var PRIMARY_TASKS_MAX = 7;
28909
28093
  var PRIMARY_TASKS_MAX_LABEL = `at most ${PRIMARY_TASKS_MAX}`;
@@ -29099,19 +28283,19 @@ async function checkTokenDrift(root, auditConfig, cfg) {
29099
28283
  const findings = [];
29100
28284
  const configuredDir = cfg.uiux?.designTokensDir;
29101
28285
  if (!configuredDir) return findings;
29102
- const tokensDir = import_node_path109.default.resolve(root, configuredDir);
28286
+ const tokensDir = import_node_path107.default.resolve(root, configuredDir);
29103
28287
  let hasTokenFiles;
29104
28288
  try {
29105
- const entries = await (0, import_promises93.readdir)(tokensDir);
28289
+ const entries = await (0, import_promises91.readdir)(tokensDir);
29106
28290
  hasTokenFiles = entries.some((e) => /\.ya?ml$/i.test(e));
29107
28291
  } catch {
29108
28292
  return findings;
29109
28293
  }
29110
28294
  if (!hasTokenFiles) return findings;
29111
- const contractsUiDir = import_node_path109.default.join(root, cfg.paths.contractsDir, "ui");
28295
+ const contractsUiDir = import_node_path107.default.join(root, cfg.paths.contractsDir, "ui");
29112
28296
  let htmlFiles;
29113
28297
  try {
29114
- const entries = await (0, import_promises93.readdir)(contractsUiDir);
28298
+ const entries = await (0, import_promises91.readdir)(contractsUiDir);
29115
28299
  htmlFiles = entries.filter((e) => /\.html?$/i.test(e));
29116
28300
  } catch {
29117
28301
  return findings;
@@ -29119,7 +28303,7 @@ async function checkTokenDrift(root, auditConfig, cfg) {
29119
28303
  let rawCount = 0;
29120
28304
  const sampleLiterals = [];
29121
28305
  for (const htmlFile of htmlFiles) {
29122
- const content = await readSafe(import_node_path109.default.join(contractsUiDir, htmlFile));
28306
+ const content = await readSafe(import_node_path107.default.join(contractsUiDir, htmlFile));
29123
28307
  if (!content) continue;
29124
28308
  const matches = content.match(RAW_COLOR_RE);
29125
28309
  if (matches) {
@@ -29170,7 +28354,7 @@ function deduplicateFindings(issues, maxPerRule) {
29170
28354
  async function validateDesignAudit(root, config) {
29171
28355
  const auditConfig = resolveAuditConfig(config);
29172
28356
  if (!auditConfig.enabled) return [];
29173
- const discussionDir = import_node_path109.default.join(root, config.paths.discussionDir);
28357
+ const discussionDir = import_node_path107.default.join(root, config.paths.discussionDir);
29174
28358
  const uiContractScreens = await readUiContractScreenContracts(root, config.paths.contractsDir);
29175
28359
  const packRoot = await findLatestDiscussionPackDir(discussionDir);
29176
28360
  if (uiContractScreens.length === 0) {
@@ -29178,7 +28362,7 @@ async function validateDesignAudit(root, config) {
29178
28362
  const uiBearing = await isDiscussionUiBearingPack(packRoot);
29179
28363
  if (!uiBearing) return [];
29180
28364
  }
29181
- const contractsPath = packRoot ? import_node_path109.default.join(packRoot, "uiux", "40_screen_contracts.md") : null;
28365
+ const contractsPath = packRoot ? import_node_path107.default.join(packRoot, "uiux", "40_screen_contracts.md") : null;
29182
28366
  const contractsContent = contractsPath ? await readSafe(contractsPath) : "";
29183
28367
  if (uiContractScreens.length === 0 && !contractsContent) return [];
29184
28368
  const findings = [];
@@ -29196,7 +28380,7 @@ async function validateDesignAudit(root, config) {
29196
28380
 
29197
28381
  // src/core/validators/layoutAntiPatterns.ts
29198
28382
  var import_node_fs15 = require("fs");
29199
- var import_node_path110 = __toESM(require("path"), 1);
28383
+ var import_node_path108 = __toESM(require("path"), 1);
29200
28384
  var import_node_url6 = require("url");
29201
28385
 
29202
28386
  // src/core/validators/uixDetection.ts
@@ -29205,10 +28389,10 @@ async function isUiBearingSpec(root) {
29205
28389
  }
29206
28390
 
29207
28391
  // src/core/validators/uix/threeLayer.ts
29208
- var import_node_path112 = __toESM(require("path"), 1);
28392
+ var import_node_path110 = __toESM(require("path"), 1);
29209
28393
 
29210
28394
  // src/core/validators/uix/designInheritance.ts
29211
- var import_node_path111 = __toESM(require("path"), 1);
28395
+ var import_node_path109 = __toESM(require("path"), 1);
29212
28396
 
29213
28397
  // src/core/validators/uix/placeholder.ts
29214
28398
  var PLACEHOLDER_RE = /^(?:tbd|todo|example|lorem|placeholder|n\/a|none)$/i;
@@ -29240,7 +28424,7 @@ function declaresInheritedDesign(contextContent) {
29240
28424
  return readDesignDirectionDeclaration(contextContent).kind === "inherit";
29241
28425
  }
29242
28426
  async function packInheritsDesign(root) {
29243
- const content = await readSafe(import_node_path111.default.join(root, "01_Context.md"));
28427
+ const content = await readSafe(import_node_path109.default.join(root, "01_Context.md"));
29244
28428
  return content ? declaresInheritedDesign(content) : false;
29245
28429
  }
29246
28430
  async function findInheritanceConflicts(root, contextContent, config, projectRoot) {
@@ -29250,7 +28434,7 @@ async function findInheritanceConflicts(root, contextContent, config, projectRoo
29250
28434
  };
29251
28435
  }
29252
28436
  async function findNewScreens(root, config, projectRoot) {
29253
- const contracts = await readSafe(import_node_path111.default.join(root, "uiux", "40_screen_contracts.md"));
28437
+ const contracts = await readSafe(import_node_path109.default.join(root, "uiux", "40_screen_contracts.md"));
29254
28438
  if (!contracts) return [];
29255
28439
  const packScreens = [...maskNonSpecRegions(contracts).matchAll(SCREEN_ID_RE)].map((match) => match[1] ?? "").filter((id) => !isPlaceholder2(id));
29256
28440
  if (packScreens.length === 0) return [];
@@ -29299,7 +28483,7 @@ async function validateThreeLayerFamilyCompleteness(root, _config) {
29299
28483
  const issues = [];
29300
28484
  for (const required of CANONICAL_REQUIRED_SIDECAR_FILES) {
29301
28485
  if (inherited && OMITTED_WHEN_INHERITED.has(required)) continue;
29302
- const content = await readSafe(import_node_path112.default.join(root, "uiux", required));
28486
+ const content = await readSafe(import_node_path110.default.join(root, "uiux", required));
29303
28487
  if (!content) {
29304
28488
  issues.push(
29305
28489
  threeLayerIssue(
@@ -29316,7 +28500,7 @@ async function validateThreeLayerFamilyCompleteness(root, _config) {
29316
28500
  }
29317
28501
 
29318
28502
  // src/core/validators/uix/trendScan.ts
29319
- var import_node_path113 = __toESM(require("path"), 1);
28503
+ var import_node_path111 = __toESM(require("path"), 1);
29320
28504
  var REQUIRED_CATEGORIES = [
29321
28505
  "user expectation / market norm",
29322
28506
  "product neighbor / comparable flow",
@@ -29412,7 +28596,7 @@ async function validateTrendScan(root, _config) {
29412
28596
  if (!await isUiBearingSpec(root) || await packInheritsDesign(root)) {
29413
28597
  return [];
29414
28598
  }
29415
- const sourcesPath = import_node_path113.default.join(root, "04_Sources.md");
28599
+ const sourcesPath = import_node_path111.default.join(root, "04_Sources.md");
29416
28600
  const content = await readSafe(sourcesPath);
29417
28601
  if (!content) {
29418
28602
  return [
@@ -29496,7 +28680,7 @@ async function validateTrendScan(root, _config) {
29496
28680
  }
29497
28681
 
29498
28682
  // src/core/validators/uix/screenContract.ts
29499
- var import_node_path114 = __toESM(require("path"), 1);
28683
+ var import_node_path112 = __toESM(require("path"), 1);
29500
28684
  var REQUIRED_FIELDS = [
29501
28685
  "screen_id",
29502
28686
  "route",
@@ -29633,7 +28817,7 @@ function assignNestedChild(block, key, value) {
29633
28817
  }
29634
28818
  async function validateScreenContractSchema(root, _config) {
29635
28819
  if (!await isUiBearingSpec(root)) return [];
29636
- const contractsPath = import_node_path114.default.join(root, "uiux", "40_screen_contracts.md");
28820
+ const contractsPath = import_node_path112.default.join(root, "uiux", "40_screen_contracts.md");
29637
28821
  const content = await readSafe(contractsPath);
29638
28822
  if (!content) return [];
29639
28823
  const screens = parseScreenBlocks2(content);
@@ -29704,10 +28888,10 @@ async function validateScreenContractSchema(root, _config) {
29704
28888
  }
29705
28889
 
29706
28890
  // src/core/validators/uix/canonical.ts
29707
- var import_node_path120 = __toESM(require("path"), 1);
28891
+ var import_node_path118 = __toESM(require("path"), 1);
29708
28892
 
29709
28893
  // src/core/validators/uix/classification.ts
29710
- var import_node_path115 = __toESM(require("path"), 1);
28894
+ var import_node_path113 = __toESM(require("path"), 1);
29711
28895
  var VALID_PRIMARY_SURFACES = [
29712
28896
  "web",
29713
28897
  "mobile",
@@ -29728,7 +28912,7 @@ function classificationIssue(code, message, severity, file, suggestedAction) {
29728
28912
  };
29729
28913
  }
29730
28914
  async function validateClassification(root, config, projectRoot) {
29731
- const contextPath = import_node_path115.default.join(root, "01_Context.md");
28915
+ const contextPath = import_node_path113.default.join(root, "01_Context.md");
29732
28916
  const content = await readSafe(contextPath);
29733
28917
  if (!content) {
29734
28918
  return [];
@@ -29953,8 +29137,8 @@ async function inheritanceRefusals(root, content, config, projectRoot) {
29953
29137
  }
29954
29138
 
29955
29139
  // src/core/validators/uix/foundation.ts
29956
- var import_promises94 = require("fs/promises");
29957
- var import_node_path116 = __toESM(require("path"), 1);
29140
+ var import_promises92 = require("fs/promises");
29141
+ var import_node_path114 = __toESM(require("path"), 1);
29958
29142
  function canonicalIssue(code, message, severity, file, suggestedAction) {
29959
29143
  return {
29960
29144
  code,
@@ -29968,7 +29152,7 @@ function canonicalIssue(code, message, severity, file, suggestedAction) {
29968
29152
  async function validateSidecarMissing(root, _config) {
29969
29153
  if (!await isUiBearingSpec(root)) return [];
29970
29154
  try {
29971
- await (0, import_promises94.readdir)(import_node_path116.default.join(root, "uiux"));
29155
+ await (0, import_promises92.readdir)(import_node_path114.default.join(root, "uiux"));
29972
29156
  return [];
29973
29157
  } catch (err) {
29974
29158
  if (isEnoent(err)) {
@@ -29987,7 +29171,7 @@ async function validateSidecarMissing(root, _config) {
29987
29171
  }
29988
29172
 
29989
29173
  // src/core/validators/uix/comparisonValidator.ts
29990
- var import_node_path117 = __toESM(require("path"), 1);
29174
+ var import_node_path115 = __toESM(require("path"), 1);
29991
29175
  function canonicalIssue2(code, message, severity, file, suggestedAction) {
29992
29176
  return {
29993
29177
  code,
@@ -30001,7 +29185,7 @@ function canonicalIssue2(code, message, severity, file, suggestedAction) {
30001
29185
  async function validateExplorationArtifacts(root, _config) {
30002
29186
  if (!await isUiBearingSpec(root)) return [];
30003
29187
  const issues = [];
30004
- const reviewBundlePath = import_node_path117.default.join(root, "uiux", "50_review_input_bundle.md");
29188
+ const reviewBundlePath = import_node_path115.default.join(root, "uiux", "50_review_input_bundle.md");
30005
29189
  const reviewBundleContent = await readSafe(reviewBundlePath);
30006
29190
  if (reviewBundleContent && !/best-of-history/i.test(reviewBundleContent)) {
30007
29191
  issues.push(
@@ -30018,7 +29202,7 @@ async function validateExplorationArtifacts(root, _config) {
30018
29202
  }
30019
29203
 
30020
29204
  // src/core/validators/uix/oqClosure.ts
30021
- var import_node_path118 = __toESM(require("path"), 1);
29205
+ var import_node_path116 = __toESM(require("path"), 1);
30022
29206
  function canonicalIssue3(code, message, severity, file, suggestedAction) {
30023
29207
  return {
30024
29208
  code,
@@ -30031,8 +29215,8 @@ function canonicalIssue3(code, message, severity, file, suggestedAction) {
30031
29215
  }
30032
29216
  async function validateOqClosure(root, _config) {
30033
29217
  if (!await isUiBearingSpec(root)) return [];
30034
- const rootOqPath = import_node_path118.default.join(root, "11_OQ-Register.md");
30035
- const uiuxOqPath = import_node_path118.default.join(root, "uiux", "11_OQ-Register.md");
29218
+ const rootOqPath = import_node_path116.default.join(root, "11_OQ-Register.md");
29219
+ const uiuxOqPath = import_node_path116.default.join(root, "uiux", "11_OQ-Register.md");
30036
29220
  const rootContent = await readSafe(rootOqPath);
30037
29221
  const content = rootContent || await readSafe(uiuxOqPath);
30038
29222
  if (!content) return [];
@@ -30083,7 +29267,7 @@ async function validateOqClosure(root, _config) {
30083
29267
  }
30084
29268
 
30085
29269
  // src/core/validators/uix/competitiveRefs.ts
30086
- var import_node_path119 = __toESM(require("path"), 1);
29270
+ var import_node_path117 = __toESM(require("path"), 1);
30087
29271
  var DEFAULT_COMPETITIVE_REFS_MIN = 3;
30088
29272
  var H2_PREFIX = String.raw`^ {0,3}##(?!#)`;
30089
29273
  function registryHeadingRe(heading) {
@@ -30258,7 +29442,7 @@ async function validateCompetitiveReferences(root, config) {
30258
29442
  if (!await isUiBearingSpec(root)) {
30259
29443
  return [];
30260
29444
  }
30261
- const content = await readSafe(import_node_path119.default.join(root, "04_Sources.md"));
29445
+ const content = await readSafe(import_node_path117.default.join(root, "04_Sources.md"));
30262
29446
  const masked = content ? maskNonSpecRegions(content) : null;
30263
29447
  const inherited = await packInheritsDesign(root);
30264
29448
  const issues = [];
@@ -30332,7 +29516,7 @@ async function runCanonicalUixValidators(root, config) {
30332
29516
  return perPack.flat();
30333
29517
  }
30334
29518
  async function resolvePackRoots(root, config) {
30335
- if (await readSafe(import_node_path120.default.join(root, "01_Context.md"))) {
29519
+ if (await readSafe(import_node_path118.default.join(root, "01_Context.md"))) {
30336
29520
  return [root];
30337
29521
  }
30338
29522
  const latest = await findLatestPack(resolvePath(root, config, "discussionDir"), "discussion");
@@ -30561,8 +29745,8 @@ function validatePrototypingSkillContent(content) {
30561
29745
  }
30562
29746
 
30563
29747
  // src/core/validators/testTodoStubs.ts
30564
- var import_promises95 = require("fs/promises");
30565
- var import_node_path121 = __toESM(require("path"), 1);
29748
+ var import_promises93 = require("fs/promises");
29749
+ var import_node_path119 = __toESM(require("path"), 1);
30566
29750
  var nonCodeSpan = (open12, close, escaped, multiline, nests = false) => ({ open: open12, close, escaped, multiline, nests });
30567
29751
  var RUST_RAW_STRING_OPENER = /b?r(#*)"/y;
30568
29752
  var BLOCK_COMMENT = nonCodeSpan("/*", "*/", false, true);
@@ -31167,7 +30351,7 @@ function maskSpan(content, blank2, start, span) {
31167
30351
  return i;
31168
30352
  }
31169
30353
  function resolveStubDialect(relFile) {
31170
- const ext = import_node_path121.default.extname(relFile).toLowerCase();
30354
+ const ext = import_node_path119.default.extname(relFile).toLowerCase();
31171
30355
  return STUB_DIALECTS.find((dialect) => dialect.extensions.includes(ext)) ?? null;
31172
30356
  }
31173
30357
  function reportEmptyTestFileGlobs() {
@@ -31241,9 +30425,9 @@ async function validateTestTodoStubs(root, config, options = {}) {
31241
30425
  const sourceExtensions = options.globs === void 0 ? null : new Set(STUB_SOURCE_EXTENSIONS.map((ext) => `.${ext}`));
31242
30426
  const namedTestFile = options.globs === void 0 ? null : namedTestFileMatcher(accepted);
31243
30427
  const wanted = (absolutePath) => {
31244
- const relative = import_node_path121.default.relative(root, absolutePath).replace(/\\/g, "/");
30428
+ const relative = import_node_path119.default.relative(root, absolutePath).replace(/\\/g, "/");
31245
30429
  const named2 = namedTestFile !== null && (namedTestFile(relative) || namedTestFile(absolutePath.replace(/\\/g, "/")));
31246
- if (sourceExtensions && !sourceExtensions.has(import_node_path121.default.extname(absolutePath).toLowerCase()) && !named2) {
30430
+ if (sourceExtensions && !sourceExtensions.has(import_node_path119.default.extname(absolutePath).toLowerCase()) && !named2) {
31247
30431
  return false;
31248
30432
  }
31249
30433
  return options.fileFilter ? options.fileFilter(relative) : true;
@@ -31294,15 +30478,15 @@ async function validateTestTodoStubs(root, config, options = {}) {
31294
30478
  const skippedTestSeverity = "error";
31295
30479
  const unscannedExtensions = /* @__PURE__ */ new Set();
31296
30480
  for (const absFile of files) {
31297
- const relFile = import_node_path121.default.relative(root, absFile).replace(/\\/g, "/");
30481
+ const relFile = import_node_path119.default.relative(root, absFile).replace(/\\/g, "/");
31298
30482
  const dialect = resolveStubDialect(relFile);
31299
30483
  if (!dialect) {
31300
- unscannedExtensions.add(import_node_path121.default.extname(relFile).toLowerCase() || "(no extension)");
30484
+ unscannedExtensions.add(import_node_path119.default.extname(relFile).toLowerCase() || "(no extension)");
31301
30485
  continue;
31302
30486
  }
31303
30487
  let content;
31304
30488
  try {
31305
- content = await (0, import_promises95.readFile)(absFile, "utf-8");
30489
+ content = await (0, import_promises93.readFile)(absFile, "utf-8");
31306
30490
  } catch {
31307
30491
  continue;
31308
30492
  }
@@ -31335,15 +30519,15 @@ async function validateTestTodoStubs(root, config, options = {}) {
31335
30519
  }
31336
30520
 
31337
30521
  // src/core/validators/assistantTreeMigration.ts
31338
- var import_promises96 = require("fs/promises");
31339
- var import_node_path122 = __toESM(require("path"), 1);
30522
+ var import_promises94 = require("fs/promises");
30523
+ var import_node_path120 = __toESM(require("path"), 1);
31340
30524
  async function validateAssistantTreeMigration(root, _config) {
31341
30525
  const issues = [];
31342
- const assistantRoot = import_node_path122.default.join(root, ".qfai", "assistant");
30526
+ const assistantRoot = import_node_path120.default.join(root, ".qfai", "assistant");
31343
30527
  if (await exists3(assistantRoot)) {
31344
30528
  let dirEntries;
31345
30529
  try {
31346
- dirEntries = await (0, import_promises96.readdir)(assistantRoot, { withFileTypes: true });
30530
+ dirEntries = await (0, import_promises94.readdir)(assistantRoot, { withFileTypes: true });
31347
30531
  } catch {
31348
30532
  dirEntries = [];
31349
30533
  }
@@ -31381,8 +30565,8 @@ async function validateAssistantTreeMigration(root, _config) {
31381
30565
  }
31382
30566
 
31383
30567
  // src/core/validators/skillDocReferences.ts
31384
- var import_promises97 = require("fs/promises");
31385
- var import_node_path123 = __toESM(require("path"), 1);
30568
+ var import_promises95 = require("fs/promises");
30569
+ var import_node_path121 = __toESM(require("path"), 1);
31386
30570
  var QFAI_SKILL_ID_RE = /^qfai-/;
31387
30571
  async function validateSkillDocReferences(root, config) {
31388
30572
  const issues = [];
@@ -31390,7 +30574,7 @@ async function validateSkillDocReferences(root, config) {
31390
30574
  if (!await exists3(skillsDir)) return issues;
31391
30575
  let entries;
31392
30576
  try {
31393
- entries = await (0, import_promises97.readdir)(skillsDir, { withFileTypes: true });
30577
+ entries = await (0, import_promises95.readdir)(skillsDir, { withFileTypes: true });
31394
30578
  } catch (err) {
31395
30579
  if (isEnoent(err)) return issues;
31396
30580
  throw err;
@@ -31398,11 +30582,11 @@ async function validateSkillDocReferences(root, config) {
31398
30582
  for (const entry of entries) {
31399
30583
  if (!entry.isDirectory()) continue;
31400
30584
  const skillId = entry.name;
31401
- const skillDoc = import_node_path123.default.join(skillsDir, skillId, "SKILL.md");
31402
- const skillDocRelPath = import_node_path123.default.relative(root, skillDoc).replace(/\\/g, "/");
30585
+ const skillDoc = import_node_path121.default.join(skillsDir, skillId, "SKILL.md");
30586
+ const skillDocRelPath = import_node_path121.default.relative(root, skillDoc).replace(/\\/g, "/");
31403
30587
  let body;
31404
30588
  try {
31405
- body = await (0, import_promises97.readFile)(skillDoc, "utf-8");
30589
+ body = await (0, import_promises95.readFile)(skillDoc, "utf-8");
31406
30590
  } catch (err) {
31407
30591
  if (isEnoent(err)) continue;
31408
30592
  throw err;
@@ -31450,7 +30634,7 @@ async function validateSkillDocReferences(root, config) {
31450
30634
  }
31451
30635
 
31452
30636
  // src/core/validators/reviewerGate.ts
31453
- var import_node_path124 = __toESM(require("path"), 1);
30637
+ var import_node_path122 = __toESM(require("path"), 1);
31454
30638
 
31455
30639
  // src/core/validators/mockHrefPairs.ts
31456
30640
  var MOCK_HREF_TEMPLATE_REL = "packages/qfai/assets/init/.qfai/assistant/skill/qfai-discussion/templates/03_Story-Workshop.md";
@@ -31467,8 +30651,8 @@ var MOCK_HREF_PAIRS = [
31467
30651
 
31468
30652
  // src/core/validators/reviewerGate.ts
31469
30653
  async function detectMockHrefDrift(root) {
31470
- const templateAbs = import_node_path124.default.join(root, MOCK_HREF_TEMPLATE_REL);
31471
- const validatorAbs = import_node_path124.default.join(root, MOCK_HREF_VALIDATOR_REL);
30654
+ const templateAbs = import_node_path122.default.join(root, MOCK_HREF_TEMPLATE_REL);
30655
+ const validatorAbs = import_node_path122.default.join(root, MOCK_HREF_VALIDATOR_REL);
31472
30656
  if (!await exists3(templateAbs)) return [];
31473
30657
  if (!await exists3(validatorAbs)) return [];
31474
30658
  const templateText = await readSafe(templateAbs);
@@ -31492,8 +30676,8 @@ async function detectMockHrefDrift(root) {
31492
30676
  }
31493
30677
 
31494
30678
  // src/core/validators/skillManifestDrift.ts
31495
- var import_promises98 = require("fs/promises");
31496
- var import_node_path125 = __toESM(require("path"), 1);
30679
+ var import_promises96 = require("fs/promises");
30680
+ var import_node_path123 = __toESM(require("path"), 1);
31497
30681
 
31498
30682
  // src/core/validators/skillManifestPairs.ts
31499
30683
  var SKILL_MANIFEST_PROBE_IMPL_REL = "packages/qfai/src/core/doctor/skillManifestProbe.ts";
@@ -31515,7 +30699,7 @@ async function readSafe7(abs) {
31515
30699
  return null;
31516
30700
  }
31517
30701
  try {
31518
- return await (0, import_promises98.readFile)(abs, "utf-8");
30702
+ return await (0, import_promises96.readFile)(abs, "utf-8");
31519
30703
  } catch {
31520
30704
  return null;
31521
30705
  }
@@ -31523,8 +30707,8 @@ async function readSafe7(abs) {
31523
30707
  async function detectSkillManifestDrift(root) {
31524
30708
  const issues = [];
31525
30709
  for (const pair of SKILL_MANIFEST_PAIRS) {
31526
- const probeAbs = import_node_path125.default.join(root, pair.probeImplRel);
31527
- const schemaAbs = import_node_path125.default.join(root, pair.schemaRel);
30710
+ const probeAbs = import_node_path123.default.join(root, pair.probeImplRel);
30711
+ const schemaAbs = import_node_path123.default.join(root, pair.schemaRel);
31528
30712
  const probeText = await readSafe7(probeAbs);
31529
30713
  const schemaText = await readSafe7(schemaAbs);
31530
30714
  if (probeText === null || schemaText === null) {
@@ -31547,12 +30731,12 @@ async function detectSkillManifestDrift(root) {
31547
30731
  }
31548
30732
 
31549
30733
  // src/core/validators/autopilotPolicy.ts
31550
- var import_promises99 = require("fs/promises");
31551
- var import_node_path126 = __toESM(require("path"), 1);
31552
- var SKILL_DIR_REL = import_node_path126.default.join(".qfai", "assistant", "skill");
30734
+ var import_promises97 = require("fs/promises");
30735
+ var import_node_path124 = __toESM(require("path"), 1);
30736
+ var SKILL_DIR_REL = import_node_path124.default.join(".qfai", "assistant", "skill");
31553
30737
  var QFAI_SKILL_ID_RE2 = /^qfai-/;
31554
30738
  var SECTION_HEADING_RE = /^##\s+Default Autopilot Policy\s*$/im;
31555
- var BASELINE_REL = import_node_path126.default.join("rule", "shared-skill-operating-baseline.md");
30739
+ var BASELINE_REL = import_node_path124.default.join("rule", "shared-skill-operating-baseline.md");
31556
30740
  var BASELINE_HEADING_RE = /^##\s+Default Autopilot Policy \(Shared\)\s*$/m;
31557
30741
  var AUTO_DECIDE_ALLOWED_TOKENS = [
31558
30742
  "output formatting",
@@ -31751,7 +30935,7 @@ function missingBaselineBuckets(content) {
31751
30935
  async function readQfaiSkills(skillsDir) {
31752
30936
  let entries;
31753
30937
  try {
31754
- entries = await (0, import_promises99.readdir)(skillsDir, { withFileTypes: true });
30938
+ entries = await (0, import_promises97.readdir)(skillsDir, { withFileTypes: true });
31755
30939
  } catch (err) {
31756
30940
  if (isEnoent(err)) return [];
31757
30941
  throw err;
@@ -31759,9 +30943,9 @@ async function readQfaiSkills(skillsDir) {
31759
30943
  const skills = [];
31760
30944
  for (const entry of entries) {
31761
30945
  if (!entry.isDirectory() || !QFAI_SKILL_ID_RE2.test(entry.name)) continue;
31762
- const skillDoc = import_node_path126.default.join(skillsDir, entry.name, "SKILL.md");
30946
+ const skillDoc = import_node_path124.default.join(skillsDir, entry.name, "SKILL.md");
31763
30947
  try {
31764
- skills.push({ skillId: entry.name, skillDoc, body: await (0, import_promises99.readFile)(skillDoc, "utf-8") });
30948
+ skills.push({ skillId: entry.name, skillDoc, body: await (0, import_promises97.readFile)(skillDoc, "utf-8") });
31765
30949
  } catch (err) {
31766
30950
  if (isEnoent(err)) continue;
31767
30951
  throw err;
@@ -31772,14 +30956,14 @@ async function readQfaiSkills(skillsDir) {
31772
30956
  async function baselineIssues(root, baselinePath) {
31773
30957
  let content;
31774
30958
  try {
31775
- content = await (0, import_promises99.readFile)(baselinePath, "utf-8");
30959
+ content = await (0, import_promises97.readFile)(baselinePath, "utf-8");
31776
30960
  } catch (err) {
31777
30961
  if (!isEnoent(err)) throw err;
31778
30962
  content = null;
31779
30963
  }
31780
30964
  const missing = content === null ? null : missingBaselineBuckets(content);
31781
30965
  if (missing !== null && missing.length === 0) return [];
31782
- const relPath = import_node_path126.default.relative(root, baselinePath).replace(/\\/g, "/");
30966
+ const relPath = import_node_path124.default.relative(root, baselinePath).replace(/\\/g, "/");
31783
30967
  const message = missing === null ? `QFAI-POLICY-001: ${relPath} does not carry the "## Default Autopilot Policy (Shared)" section that every qfai-* skill works under. Restore it with its three named buckets (auto-decide / ask-user / hard-required); \`qfai init --force\` regenerates the shipped wording. Justification: file=${relPath}, missing=## Default Autopilot Policy (Shared).` : `QFAI-POLICY-001: ${relPath} "## Default Autopilot Policy (Shared)" section is missing required bucket(s): [${missing.join(", ")}]. Every qfai-* skill works under all three named buckets (auto-decide / ask-user / hard-required). Justification: file=${relPath}, missingBuckets=[${missing.join(", ")}].`;
31784
30968
  return [
31785
30969
  issue("QFAI-POLICY-001", message, "error", relPath, "reviewerGate.autopilotPolicyMissing")
@@ -31814,21 +30998,21 @@ function skillPolicyIssues(relPath, skillId, result) {
31814
30998
  return issues;
31815
30999
  }
31816
31000
  async function validateAutopilotPolicy(root, options = {}) {
31817
- const skillsDir = options.config ? resolvePath(root, options.config, "skillsDir") : import_node_path126.default.join(root, SKILL_DIR_REL);
31001
+ const skillsDir = options.config ? resolvePath(root, options.config, "skillsDir") : import_node_path124.default.join(root, SKILL_DIR_REL);
31818
31002
  if (!await exists3(skillsDir)) return [];
31819
31003
  const skills = await readQfaiSkills(skillsDir);
31820
31004
  if (skills.length === 0) return [];
31821
- const issues = await baselineIssues(root, import_node_path126.default.join(import_node_path126.default.dirname(skillsDir), BASELINE_REL));
31005
+ const issues = await baselineIssues(root, import_node_path124.default.join(import_node_path124.default.dirname(skillsDir), BASELINE_REL));
31822
31006
  for (const { skillId, skillDoc, body } of skills) {
31823
- const relPath = import_node_path126.default.relative(root, skillDoc).replace(/\\/g, "/");
31007
+ const relPath = import_node_path124.default.relative(root, skillDoc).replace(/\\/g, "/");
31824
31008
  issues.push(...skillPolicyIssues(relPath, skillId, parseAutopilotPolicy(body, skillId)));
31825
31009
  }
31826
31010
  return issues;
31827
31011
  }
31828
31012
 
31829
31013
  // src/core/validators/handoffSchemaDrift.ts
31830
- var import_promises100 = require("fs/promises");
31831
- var import_node_path127 = __toESM(require("path"), 1);
31014
+ var import_promises98 = require("fs/promises");
31015
+ var import_node_path125 = __toESM(require("path"), 1);
31832
31016
 
31833
31017
  // src/core/validators/handoffSchemaPairs.ts
31834
31018
  var HANDOFF_SCHEMA_REL = "packages/qfai/src/core/schemas/handoff.ts";
@@ -31851,11 +31035,11 @@ function schemaFields(schemaText) {
31851
31035
  );
31852
31036
  }
31853
31037
  async function detectHandoffSchemaDrift(root) {
31854
- const schemaAbs = import_node_path127.default.join(root, HANDOFF_SCHEMA_REL);
31038
+ const schemaAbs = import_node_path125.default.join(root, HANDOFF_SCHEMA_REL);
31855
31039
  if (!await exists3(schemaAbs)) return [];
31856
31040
  let schemaText;
31857
31041
  try {
31858
- schemaText = await (0, import_promises100.readFile)(schemaAbs, "utf-8");
31042
+ schemaText = await (0, import_promises98.readFile)(schemaAbs, "utf-8");
31859
31043
  } catch {
31860
31044
  return [];
31861
31045
  }
@@ -31864,11 +31048,11 @@ async function detectHandoffSchemaDrift(root) {
31864
31048
  const fields = schemaFields(schemaText);
31865
31049
  const issues = [];
31866
31050
  for (const pair of HANDOFF_WRITER_PAIRS) {
31867
- const writerAbs = import_node_path127.default.join(root, pair.writerRel);
31051
+ const writerAbs = import_node_path125.default.join(root, pair.writerRel);
31868
31052
  if (!await exists3(writerAbs)) continue;
31869
31053
  let writerText;
31870
31054
  try {
31871
- writerText = await (0, import_promises100.readFile)(writerAbs, "utf-8");
31055
+ writerText = await (0, import_promises98.readFile)(writerAbs, "utf-8");
31872
31056
  } catch {
31873
31057
  continue;
31874
31058
  }
@@ -31886,13 +31070,13 @@ async function detectHandoffSchemaDrift(root) {
31886
31070
  }
31887
31071
 
31888
31072
  // src/core/validators/packageSelfGovernance.ts
31889
- var import_node_path128 = __toESM(require("path"), 1);
31073
+ var import_node_path126 = __toESM(require("path"), 1);
31890
31074
  async function handoffSchemaDriftEvaluable(root) {
31891
- if (!await exists3(import_node_path128.default.join(root, HANDOFF_SCHEMA_REL))) {
31075
+ if (!await exists3(import_node_path126.default.join(root, HANDOFF_SCHEMA_REL))) {
31892
31076
  return false;
31893
31077
  }
31894
31078
  for (const pair of HANDOFF_WRITER_PAIRS) {
31895
- if (await exists3(import_node_path128.default.join(root, pair.writerRel))) {
31079
+ if (await exists3(import_node_path126.default.join(root, pair.writerRel))) {
31896
31080
  return true;
31897
31081
  }
31898
31082
  }
@@ -31900,7 +31084,7 @@ async function handoffSchemaDriftEvaluable(root) {
31900
31084
  }
31901
31085
  async function skillManifestDriftEvaluable(root) {
31902
31086
  for (const pair of SKILL_MANIFEST_PAIRS) {
31903
- if (await exists3(import_node_path128.default.join(root, pair.probeImplRel)) && await exists3(import_node_path128.default.join(root, pair.schemaRel))) {
31087
+ if (await exists3(import_node_path126.default.join(root, pair.probeImplRel)) && await exists3(import_node_path126.default.join(root, pair.schemaRel))) {
31904
31088
  return true;
31905
31089
  }
31906
31090
  }
@@ -31990,10 +31174,10 @@ async function validateProject(root, configResult, options = {}) {
31990
31174
  const specsRoot = resolvePath(root, config, "specsDir");
31991
31175
  let oldLayoutRoot;
31992
31176
  const oldLayoutFiles = [];
31993
- for (const candidate2 of /* @__PURE__ */ new Set([specsRoot, import_node_path129.default.join(root, ".qfai", "specs")])) {
31177
+ for (const candidate2 of /* @__PURE__ */ new Set([specsRoot, import_node_path127.default.join(root, ".qfai", "specs")])) {
31994
31178
  let entries = [];
31995
31179
  try {
31996
- entries = await (0, import_promises101.readdir)(candidate2);
31180
+ entries = await (0, import_promises99.readdir)(candidate2);
31997
31181
  } catch (error2) {
31998
31182
  if (error2.code !== "ENOENT") throw error2;
31999
31183
  }
@@ -32121,7 +31305,7 @@ function isUnder2(base, candidate2) {
32121
31305
  return candidate2 === base || candidate2.startsWith(`${base}/`);
32122
31306
  }
32123
31307
  function toRepoRelative2(root, absolute) {
32124
- return import_node_path129.default.relative(root, absolute).split(import_node_path129.default.sep).join("/");
31308
+ return import_node_path127.default.relative(root, absolute).split(import_node_path127.default.sep).join("/");
32125
31309
  }
32126
31310
  function consumesPlatformOption(profile) {
32127
31311
  switch (profile) {
@@ -32538,7 +31722,7 @@ async function runUiuxValidators(root, config, timings, platformOption) {
32538
31722
  ["mermaid screen flow", () => validateMermaidScreenFlow(root, config)],
32539
31723
  ["UI definition consistency", () => validateUiDefinitionConsistency(root, config)],
32540
31724
  ["research summary", () => validateResearchSummary(root, config)],
32541
- ["agent definition", () => validateAgentDefinition(root, config)],
31725
+ ["agent definition", () => validateAgentDefinition(root)],
32542
31726
  ["design audit", () => validateDesignAudit(root, config)],
32543
31727
  ["canonical UIX", () => runCanonicalUixValidators(root, config)]
32544
31728
  ];
@@ -32570,7 +31754,7 @@ async function runUiuxValidators(root, config, timings, platformOption) {
32570
31754
  }
32571
31755
  async function validatePrototypingSkill(root, config) {
32572
31756
  const skillsDir = resolvePath(root, config, "skillsDir");
32573
- const prototypingSkillPath = import_node_path129.default.join(skillsDir, "qfai-prototyping", "SKILL.md");
31757
+ const prototypingSkillPath = import_node_path127.default.join(skillsDir, "qfai-prototyping", "SKILL.md");
32574
31758
  const prototypingSkillContent = await readSafe(prototypingSkillPath);
32575
31759
  if (prototypingSkillContent.length === 0) {
32576
31760
  return [];
@@ -32579,16 +31763,16 @@ async function validatePrototypingSkill(root, config) {
32579
31763
  return validatePrototypingSkillContent([prototypingSkillContent, ...stepBodies].join("\n")).issues;
32580
31764
  }
32581
31765
  async function readPrototypingStepBodies(root) {
32582
- const stepDir = import_node_path129.default.join(root, ".qfai", "assistant", "step");
31766
+ const stepDir = import_node_path127.default.join(root, ".qfai", "assistant", "step");
32583
31767
  let names;
32584
31768
  try {
32585
- names = await (0, import_promises101.readdir)(stepDir);
31769
+ names = await (0, import_promises99.readdir)(stepDir);
32586
31770
  } catch (error2) {
32587
31771
  if (isEnoent(error2)) return [];
32588
31772
  throw error2;
32589
31773
  }
32590
31774
  const stepNames = names.filter((name) => name.startsWith("prototyping-")).sort();
32591
- return Promise.all(stepNames.map((name) => readSafe(import_node_path129.default.join(stepDir, name, "STEP.md"))));
31775
+ return Promise.all(stepNames.map((name) => readSafe(import_node_path127.default.join(stepDir, name, "STEP.md"))));
32592
31776
  }
32593
31777
  function countIssues(issues) {
32594
31778
  return issues.reduce(
@@ -32604,16 +31788,16 @@ function countIssues(issues) {
32604
31788
  }
32605
31789
 
32606
31790
  // src/cli/commands/validate.ts
32607
- var import_promises103 = require("fs/promises");
32608
- var import_node_path131 = __toESM(require("path"), 1);
31791
+ var import_promises101 = require("fs/promises");
31792
+ var import_node_path129 = __toESM(require("path"), 1);
32609
31793
 
32610
31794
  // src/core/runLog.ts
32611
- var import_promises102 = require("fs/promises");
32612
- var import_node_path130 = __toESM(require("path"), 1);
31795
+ var import_promises100 = require("fs/promises");
31796
+ var import_node_path128 = __toESM(require("path"), 1);
32613
31797
  async function writeValidateRunLog(input) {
32614
- const root = import_node_path130.default.resolve(input.root);
31798
+ const root = import_node_path128.default.resolve(input.root);
32615
31799
  const outDir = resolvePath(root, input.config, "outDir");
32616
- await (0, import_promises102.mkdir)(outDir, { recursive: true });
31800
+ await (0, import_promises100.mkdir)(outDir, { recursive: true });
32617
31801
  const { runId, reportDir } = await allocateRunReportDir(outDir, input.startedAt);
32618
31802
  const relativeSpecsRoot = toRelativePath(root, resolvePath(root, input.config, "specsDir"));
32619
31803
  const latestDiscussion = await findLatestPack(
@@ -32659,10 +31843,10 @@ async function writeValidateRunLog(input) {
32659
31843
  errors,
32660
31844
  warnings
32661
31845
  });
32662
- await writeJson(import_node_path130.default.join(reportDir, "run.json"), runJson);
32663
- await writeJson(import_node_path130.default.join(reportDir, "validator.json"), validatorJson);
32664
- await writeJson(import_node_path130.default.join(reportDir, "traceability.json"), traceabilityJson);
32665
- await (0, import_promises102.writeFile)(import_node_path130.default.join(reportDir, "summary.md"), `${summaryMd}
31846
+ await writeJson(import_node_path128.default.join(reportDir, "run.json"), runJson);
31847
+ await writeJson(import_node_path128.default.join(reportDir, "validator.json"), validatorJson);
31848
+ await writeJson(import_node_path128.default.join(reportDir, "traceability.json"), traceabilityJson);
31849
+ await (0, import_promises100.writeFile)(import_node_path128.default.join(reportDir, "summary.md"), `${summaryMd}
32666
31850
  `, "utf-8");
32667
31851
  await writeLatestValidateLog(
32668
31852
  outDir,
@@ -32689,22 +31873,22 @@ async function writeLatestValidateLog(outDir, runId, buildContents) {
32689
31873
  if (await hasNewerRunDir(outDir, runId)) {
32690
31874
  return;
32691
31875
  }
32692
- const filePath = import_node_path130.default.join(outDir, "validate.log");
31876
+ const filePath = import_node_path128.default.join(outDir, "validate.log");
32693
31877
  let existingRunId;
32694
31878
  try {
32695
- existingRunId = RUN_ID_LINE_RE.exec(await (0, import_promises102.readFile)(filePath, "utf-8"))?.[1] ?? null;
31879
+ existingRunId = RUN_ID_LINE_RE.exec(await (0, import_promises100.readFile)(filePath, "utf-8"))?.[1] ?? null;
32696
31880
  } catch {
32697
31881
  existingRunId = null;
32698
31882
  }
32699
31883
  if (existingRunId !== null && existingRunId > runId) {
32700
31884
  return;
32701
31885
  }
32702
- await (0, import_promises102.writeFile)(filePath, `${buildContents()}
31886
+ await (0, import_promises100.writeFile)(filePath, `${buildContents()}
32703
31887
  `, "utf-8");
32704
31888
  }
32705
31889
  async function hasNewerRunDir(runRoot, runId) {
32706
31890
  try {
32707
- const entries = await (0, import_promises102.readdir)(runRoot, { withFileTypes: true });
31891
+ const entries = await (0, import_promises100.readdir)(runRoot, { withFileTypes: true });
32708
31892
  return entries.some(
32709
31893
  (entry) => entry.isDirectory() && RUN_DIR_RE.test(entry.name) && entry.name > runId
32710
31894
  );
@@ -32731,7 +31915,7 @@ function buildValidateLog(input) {
32731
31915
  return lines.join("\n");
32732
31916
  }
32733
31917
  async function writeJson(filePath, value) {
32734
- await (0, import_promises102.writeFile)(filePath, `${JSON.stringify(value, null, 2)}
31918
+ await (0, import_promises100.writeFile)(filePath, `${JSON.stringify(value, null, 2)}
32735
31919
  `, "utf-8");
32736
31920
  }
32737
31921
  function resolveStatus(result, override) {
@@ -32844,9 +32028,9 @@ async function allocateRunDir(parentDir, startedAt) {
32844
32028
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
32845
32029
  const candidateDate = new Date(startedAt.getTime() + attempt);
32846
32030
  const runId = `run-${formatTimestamp17(candidateDate)}`;
32847
- const runDir = import_node_path130.default.join(parentDir, runId);
32031
+ const runDir = import_node_path128.default.join(parentDir, runId);
32848
32032
  try {
32849
- await (0, import_promises102.mkdir)(runDir);
32033
+ await (0, import_promises100.mkdir)(runDir);
32850
32034
  return { runId, runDir };
32851
32035
  } catch (error2) {
32852
32036
  if (isAlreadyExistsError(error2)) {
@@ -32927,7 +32111,7 @@ async function runValidate(options) {
32927
32111
  if (format === "text") {
32928
32112
  emitStartedLine(options.profile ?? "full");
32929
32113
  }
32930
- const root = import_node_path131.default.resolve(options.root);
32114
+ const root = import_node_path129.default.resolve(options.root);
32931
32115
  const configResult = await loadConfig(root);
32932
32116
  const ciProfileIssue = buildCiProfileIssue(options.profile);
32933
32117
  let validated;
@@ -33036,11 +32220,11 @@ function scopedReportPath(configuredPath, flowIds) {
33036
32220
  return `${dir}${stem}.flow-${suffix}${ext}`;
33037
32221
  }
33038
32222
  function profileSuffixedReportPath(configured, profile) {
33039
- const dir = import_node_path131.default.posix.dirname(configured.replace(/\\/g, "/"));
33040
- const base = import_node_path131.default.posix.basename(configured.replace(/\\/g, "/"));
33041
- const ext = import_node_path131.default.posix.extname(base);
32223
+ const dir = import_node_path129.default.posix.dirname(configured.replace(/\\/g, "/"));
32224
+ const base = import_node_path129.default.posix.basename(configured.replace(/\\/g, "/"));
32225
+ const ext = import_node_path129.default.posix.extname(base);
33042
32226
  const stem = ext.length > 0 ? base.slice(0, -ext.length) : base;
33043
- return import_node_path131.default.posix.join(dir, `${stem}-${profile}${ext}`);
32227
+ return import_node_path129.default.posix.join(dir, `${stem}-${profile}${ext}`);
33044
32228
  }
33045
32229
  var GATE_GROUP_FAMILIES = {
33046
32230
  hygiene: ["QFAI-HYG-*"],
@@ -33286,6 +32470,16 @@ function formatTextIssueLine(item) {
33286
32470
  const suppressed = item.suppressed ? " suppressed=true" : "";
33287
32471
  return `[${item.severity}] ${item.code} ${item.message}${location}${refs}${suppressed}`;
33288
32472
  }
32473
+ function textGroupFixes(head, shown, failOn) {
32474
+ if (shouldEmitIssueDetail(head, failOn)) {
32475
+ return new Set(shown.map(resolveIssueFix));
32476
+ }
32477
+ if (head.severity !== "warning") {
32478
+ return /* @__PURE__ */ new Set();
32479
+ }
32480
+ const known = shown.map((item) => item.suggested_action ?? ISSUE_FIX_BY_CODE[item.code]);
32481
+ return new Set(known.filter((fix) => fix !== void 0));
32482
+ }
33289
32483
  function emitText(result, failOn) {
33290
32484
  for (const group of groupIssues(result.issues)) {
33291
32485
  const shown = group.items.slice(0, TEXT_ISSUES_PER_GROUP);
@@ -33301,10 +32495,8 @@ function emitText(result, failOn) {
33301
32495
  `
33302
32496
  );
33303
32497
  }
33304
- if (shouldEmitIssueDetail(group.head, failOn)) {
33305
- for (const fix of new Set(shown.map(resolveIssueFix))) {
33306
- emitTextField("fix", fix);
33307
- }
32498
+ for (const fix of textGroupFixes(group.head, shown, failOn)) {
32499
+ emitTextField("fix", fix);
33308
32500
  }
33309
32501
  }
33310
32502
  process.stdout.write(
@@ -33520,12 +32712,12 @@ function issueKey(issue2) {
33520
32712
  }
33521
32713
  async function emitJson(result, root, jsonPath) {
33522
32714
  const abs = resolveJsonPath(root, jsonPath);
33523
- await (0, import_promises103.mkdir)(import_node_path131.default.dirname(abs), { recursive: true });
33524
- await (0, import_promises103.writeFile)(abs, `${JSON.stringify(result, null, 2)}
32715
+ await (0, import_promises101.mkdir)(import_node_path129.default.dirname(abs), { recursive: true });
32716
+ await (0, import_promises101.writeFile)(abs, `${JSON.stringify(result, null, 2)}
33525
32717
  `, "utf-8");
33526
32718
  }
33527
32719
  function resolveJsonPath(root, jsonPath) {
33528
- return import_node_path131.default.isAbsolute(jsonPath) ? jsonPath : import_node_path131.default.resolve(root, jsonPath);
32720
+ return import_node_path129.default.isAbsolute(jsonPath) ? jsonPath : import_node_path129.default.resolve(root, jsonPath);
33529
32721
  }
33530
32722
  var GITHUB_ANNOTATION_LIMIT_PER_LEVEL = 10;
33531
32723
  var ISSUE_EXPECTED_BY_CODE = {
@@ -33584,11 +32776,6 @@ var ISSUE_EXPECTED_BY_CODE = {
33584
32776
  "QFAI-DCON-030": "Root DESIGN.md is required as the brand SSOT for UI-bearing projects (file missing).",
33585
32777
  "QFAI-DCON-033": "Root DESIGN.md exists but failed to parse per design-md-spec (front-matter is malformed).",
33586
32778
  "QFAI-DCON-034": "Root DESIGN.md must be the project's own brand SSOT, not the unreplaced qfai sample seeded by `qfai init`.",
33587
- "QFAI-AGENT-015": "Every role a step or skill declares is dispatchable: some routing phase or its review profile selects it.",
33588
- "QFAI-AGENT-016": "Every routed step's `STEP.md` and routed skill's `SKILL.md` frontmatter parses, and its `roles:` and `routing-profile:` are usable, so the routing cross-check has something to read.",
33589
- "QFAI-AGENT-017": "Every step or skill that declares a `routing-profile:` is routed at least one dispatchable phase by the routing manifest.",
33590
- "QFAI-AGENT-018": "Each routed step or skill has exactly one review gate, named by both sides and defined in the review-profile manifest.",
33591
- "QFAI-AGENT-019": "A step's or skill's `roles:` is a superset of every agent the routing manifest binds to it, including the reviewers its review profile selects.",
33592
32779
  "QFAI-RESEARCH-012": "The latest discussion pack carries a `## Research Summary` section, so the research-first protocol has something to check.",
33593
32780
  // The apply-order family. Each of these reads a column or a declaration that
33594
32781
  // nothing read before them, so a project meeting one of them for the first
@@ -33621,7 +32808,7 @@ var ISSUE_EXPECTED_BY_CODE = {
33621
32808
  "QFAI-SKILLS-013": "Every file under a skill's `references/` is cited by some document reachable from that skill's `SKILL.md`, so progressive disclosure can reach it.",
33622
32809
  "QFAI-SKILLS-014": "Every document under the skills tree can be read, so reference reachability is decided over the whole graph rather than over the part that happened to open.",
33623
32810
  "QFAI-SKILLS-015": "Every skill carries both fields a host registers it by: a `name:` that is its own directory, in lowercase letters, digits and single hyphens to 64 characters, and a `description:` with text in it, to 1024 characters and with no `<` or `>` \u2014 a skill that should not be offered to the model declares `disable-model-invocation: true` and keeps the description, rather than dropping the field and losing the registration with it.",
33624
- "QFAI-SKILLS-016": "The step layer holds only `STEP.md` steps named after their directories; each is owned by `common` or by a skill whose `steps:` lists it, `requires:` names only installed `common-*` steps, every step a skill or a workflow plan names is installed and used, and a skill that lists steps declares `orchestrator` and every role those steps declare.",
32811
+ "QFAI-SKILLS-016": "The step layer holds only `STEP.md` steps named after their directories; each is owned by `common` or by a skill whose `steps:` lists it, `requires:` names only installed `common-*` steps, every step a skill or a workflow plan names is installed and used.",
33625
32812
  "QFAI-SAAS-001": "The saas-package profile finds a design-system attestation at its configured path.",
33626
32813
  "QFAI-SAAS-002": "A cross-skill handoff, when present, parses as an object and conforms to the handoff schema.",
33627
32814
  "QFAI-DRIFT-001": "Upstream SSOT files are unchanged relative to the base branch, or the change carries an approved Change Request.",
@@ -33643,13 +32830,8 @@ var ISSUE_EXPECTED_BY_CODE = {
33643
32830
  "QFAI-ASSISTANT-002": "Every canonical `.qfai/assistant/` layer directory is seeded.",
33644
32831
  "QFAI-CFG-002": "Every value in qfai.config.yaml has the type and range its key declares.",
33645
32832
  "QFAI-AGENT-005": "Every agent definition file has each required section heading.",
33646
- "QFAI-AGENT-007": "The agent routing manifest and its defaults file can be read and parse to the shape the routing check expects.",
33647
- "QFAI-AGENT-008": "Every agent a routing phase names is a defined agent.",
33648
- "QFAI-AGENT-009": "`review-profiles.yml` can be parsed, is an object holding a `profiles` object, and each profile field is a list of reviewer ids.",
33649
- "QFAI-AGENT-010": "Every id a review profile lists in its `_required` fields is a reviewer agent.",
33650
32833
  "QFAI-AGENT-011": "Every agent definition file carries front matter that parses.",
33651
32834
  "QFAI-AGENT-012": "An agent definition's front-matter `name` equals its file's agent id.",
33652
- "QFAI-AGENT-013": "Every routing phase declares an `iteration`, `rerun_policy`, `review_profile` and agent fields drawn from the values the routing check allows.",
33653
32835
  "QFAI-ASSETS-001": "The drift-protocol rule file exists under the assistant tree.",
33654
32836
  "QFAI-ASSETS-002": "The test-layers rule file exists under the assistant tree.",
33655
32837
  "QFAI-AUD-001": "Every screen in a UI contract lists at least one `primary_tasks` entry.",
@@ -33795,12 +32977,7 @@ var ISSUE_FIX_BY_CODE = {
33795
32977
  // two rows, two CAPs on one directory) pass no `suggested_action`, and one
33796
32978
  // repair covers them: the `Spec` cell is the mapping, so the fix is always to
33797
32979
  // make each row name exactly one directory that no other row names.
33798
- "QFAI-AGENT-015": "Remove the role from the skill's `roles:`, or bind it in the package defaults (the owner's file under `packages/qfai/assets/defaults/agent-routing/`, or `review-profiles.yml`). For a project-specific binding, override the complete route or profile in `qfai.config.yaml`.",
33799
- "QFAI-AGENT-016": "Repair the `SKILL.md` frontmatter the message names: close the `---` block, and give `roles:` a list of strings and `routing-profile:` a non-empty profile name.",
33800
- "QFAI-AGENT-017": "Add a route with a dispatching phase to the owner's file under `packages/qfai/assets/defaults/agent-routing/`, or add a complete project-specific route under `qfai.config.yaml#routing`. Drop the skill's `routing-profile:` if it is deliberately un-routed.",
33801
- "QFAI-AGENT-018": "Make the skill's `routing-profile:` and the route's `review_profile:` name the same profile. Define package defaults in `packages/qfai/assets/defaults/review-profiles.yml`; use `qfai.config.yaml#routing` and `#reviewProfiles` for complete project-specific overrides.",
33802
- "QFAI-AGENT-019": "Add the agent to the skill's `roles:`, or remove its binding from the owner's file under `packages/qfai/assets/defaults/agent-routing/`, or from `review-profiles.yml`. For a project-specific binding, override the complete route or profile in `qfai.config.yaml`.",
33803
- "QFAI-SKILLS-016": "Run `qfai init --force` to restore the shipped step tree. For a step of the project's own, fix the `STEP.md` or the skill's `steps:` or `requires:` the message names: rename a `SKILL.md` under the step layer to `STEP.md`, match `name:` to the directory, set `owner:` to `common` or to the skill that lists the step, keep a step's or a skill's `requires:` to a list of installed `common-*` steps, list a common step a skill's body runs in that skill's `requires:`, and add the roles the message names to the skill's `roles:`.",
32980
+ "QFAI-SKILLS-016": "Run `qfai init --force` to restore the shipped step tree. For a step of the project's own, fix the `STEP.md` or the skill's `steps:` or `requires:` the message names: rename a `SKILL.md` under the step layer to `STEP.md`, match `name:` to the directory, set `owner:` to `common` or to the skill that lists the step, keep a step's or a skill's `requires:` to a list of installed `common-*` steps, and list a common step a skill's body runs in that skill's `requires:`.",
33804
32981
  // The orphan-prohibition emitter passes no `suggested_action` on any path, so
33805
32982
  // every rung of the ladder depends on this catalog for its `fix:` line. The
33806
32983
  // even codes are repaired by writing a `Parent`, the odd ones by pointing an
@@ -33847,7 +33024,7 @@ function escapeGitHubCommandProperty(value) {
33847
33024
  // src/cli/commands/report.ts
33848
33025
  function resolveReportPaths(root, config, options) {
33849
33026
  const outRoot = resolvePath(root, config, "outDir");
33850
- const defaultOut = options.format === "json" ? import_node_path132.default.join(outRoot, "report.json") : import_node_path132.default.join(outRoot, "report.md");
33027
+ const defaultOut = options.format === "json" ? import_node_path130.default.join(outRoot, "report.json") : import_node_path130.default.join(outRoot, "report.md");
33851
33028
  const configuredValidateJson = config.output.validateJsonPath;
33852
33029
  const flowIds = options.flowIds ?? [];
33853
33030
  const scopedValidateJson = flowIds.length > 0 ? scopedReportPath(configuredValidateJson, flowIds) : configuredValidateJson;
@@ -33858,15 +33035,15 @@ function resolveReportPaths(root, config, options) {
33858
33035
  const out = options.outPath ?? scopedOut;
33859
33036
  return {
33860
33037
  validateJsonPath: scopedValidateJson,
33861
- outPath: import_node_path132.default.isAbsolute(out) ? out : import_node_path132.default.resolve(root, out)
33038
+ outPath: import_node_path130.default.isAbsolute(out) ? out : import_node_path130.default.resolve(root, out)
33862
33039
  };
33863
33040
  }
33864
33041
  function inputCarriesRequestedScope(inputPath, scopedValidateJsonPath, profile) {
33865
- const accepted = /* @__PURE__ */ new Set([import_node_path132.default.basename(scopedValidateJsonPath)]);
33042
+ const accepted = /* @__PURE__ */ new Set([import_node_path130.default.basename(scopedValidateJsonPath)]);
33866
33043
  if (profile) {
33867
- accepted.add(import_node_path132.default.basename(profileSuffixedReportPath(scopedValidateJsonPath, profile)));
33044
+ accepted.add(import_node_path130.default.basename(profileSuffixedReportPath(scopedValidateJsonPath, profile)));
33868
33045
  }
33869
- return accepted.has(import_node_path132.default.basename(inputPath));
33046
+ return accepted.has(import_node_path130.default.basename(inputPath));
33870
33047
  }
33871
33048
  function buildMissingInputGuidance(inputPath, flowIds, profile, expectedValidateJsonPath) {
33872
33049
  const header = [`qfai report: input file not found: ${inputPath}`, ""];
@@ -33895,7 +33072,7 @@ function buildMissingInputGuidance(inputPath, flowIds, profile, expectedValidate
33895
33072
  ].join("\n");
33896
33073
  }
33897
33074
  async function runReport(options) {
33898
- const root = import_node_path132.default.resolve(options.root);
33075
+ const root = import_node_path130.default.resolve(options.root);
33899
33076
  const configResult = await loadConfig(root);
33900
33077
  const flowIds = options.flowIds ?? [];
33901
33078
  const storyTree = await isStoryTreeProject(root, configResult.config);
@@ -33948,7 +33125,7 @@ async function runReport(options) {
33948
33125
  [
33949
33126
  `qfai report: the --in validate result does not match the --${unit} scope: ${inputPath}`,
33950
33127
  `report with --${unit} takes counts, issues, and waiver totals from the input file as they are.`,
33951
- `Pass the scoped validate result named ${import_node_path132.default.basename(paths.validateJsonPath)}. For example:`,
33128
+ `Pass the scoped validate result named ${import_node_path130.default.basename(paths.validateJsonPath)}. For example:`,
33952
33129
  ` qfai validate ${scopeArgs}`,
33953
33130
  ` qfai report ${scopeArgs}`
33954
33131
  ].join("\n")
@@ -33971,8 +33148,8 @@ async function runReport(options) {
33971
33148
  const data = await createReportData(root, configResult.config, validation, flowIds);
33972
33149
  const output = options.format === "json" ? formatReportJson(data) : formatReportMarkdown(data, options.baseUrl ? { baseUrl: options.baseUrl } : {});
33973
33150
  const outPath = paths.outPath;
33974
- await (0, import_promises104.mkdir)(import_node_path132.default.dirname(outPath), { recursive: true });
33975
- await (0, import_promises104.writeFile)(outPath, `${output}
33151
+ await (0, import_promises102.mkdir)(import_node_path130.default.dirname(outPath), { recursive: true });
33152
+ await (0, import_promises102.writeFile)(outPath, `${output}
33976
33153
  `, "utf-8");
33977
33154
  await writeBusinessFlowReports(root, configResult.config, flowIds);
33978
33155
  if (ranNarrowProfileInCi) {
@@ -34010,7 +33187,7 @@ function resolveFailOn2(options, fallback) {
34010
33187
  }
34011
33188
  function resolveInputPath(root, configuredPath, inputPath, profile) {
34012
33189
  const input = inputPath ?? (profile ? profileSuffixedReportPath(configuredPath, profile) : configuredPath);
34013
- return import_node_path132.default.isAbsolute(input) ? input : import_node_path132.default.resolve(root, input);
33190
+ return import_node_path130.default.isAbsolute(input) ? input : import_node_path130.default.resolve(root, input);
34014
33191
  }
34015
33192
  async function loadValidationResult(inputPath, flowIds, profile, expectedValidateJsonPath) {
34016
33193
  try {
@@ -34032,7 +33209,7 @@ function warnOnProfileMismatch(inputPath, validation, profile) {
34032
33209
  );
34033
33210
  }
34034
33211
  async function readValidationResult(inputPath) {
34035
- const raw = await (0, import_promises104.readFile)(inputPath, "utf-8");
33212
+ const raw = await (0, import_promises102.readFile)(inputPath, "utf-8");
34036
33213
  const parsed = JSON.parse(raw);
34037
33214
  if (!isValidationResult(parsed)) {
34038
33215
  throw new Error(`validate.json has an invalid shape: ${inputPath}`);
@@ -34114,23 +33291,23 @@ async function writeValidationResults(root, configuredPath, result, requestedPro
34114
33291
  );
34115
33292
  }
34116
33293
  async function writeValidationResult(root, outputPath, result) {
34117
- const abs = import_node_path132.default.isAbsolute(outputPath) ? outputPath : import_node_path132.default.resolve(root, outputPath);
34118
- await (0, import_promises104.mkdir)(import_node_path132.default.dirname(abs), { recursive: true });
34119
- await (0, import_promises104.writeFile)(abs, `${JSON.stringify(result, null, 2)}
33294
+ const abs = import_node_path130.default.isAbsolute(outputPath) ? outputPath : import_node_path130.default.resolve(root, outputPath);
33295
+ await (0, import_promises102.mkdir)(import_node_path130.default.dirname(abs), { recursive: true });
33296
+ await (0, import_promises102.writeFile)(abs, `${JSON.stringify(result, null, 2)}
34120
33297
  `, "utf-8");
34121
33298
  }
34122
33299
 
34123
33300
  // src/cli/commands/sddMergeDocs.ts
34124
33301
  var import_node_child_process8 = require("child_process");
34125
- var import_promises106 = require("fs/promises");
34126
- var import_node_path134 = __toESM(require("path"), 1);
33302
+ var import_promises104 = require("fs/promises");
33303
+ var import_node_path132 = __toESM(require("path"), 1);
34127
33304
  var import_node_util6 = require("util");
34128
33305
 
34129
33306
  // src/core/storyTree/sentenceMerge.ts
34130
33307
  var import_node_child_process7 = require("child_process");
34131
- var import_promises105 = require("fs/promises");
33308
+ var import_promises103 = require("fs/promises");
34132
33309
  var import_node_os4 = __toESM(require("os"), 1);
34133
- var import_node_path133 = __toESM(require("path"), 1);
33310
+ var import_node_path131 = __toESM(require("path"), 1);
34134
33311
  var import_node_util5 = require("util");
34135
33312
  var execute3 = (0, import_node_util5.promisify)(import_node_child_process7.execFile);
34136
33313
  var MAX_BUFFER = 64 * 1024 * 1024;
@@ -34304,14 +33481,14 @@ async function isGitConflictOutput(working, base, ours, theirs) {
34304
33481
  return false;
34305
33482
  }
34306
33483
  async function runMergeFile(base, ours, theirs, options) {
34307
- const dir = await (0, import_promises105.mkdtemp)(import_node_path133.default.join(import_node_os4.default.tmpdir(), "qfai-merge-docs-"));
33484
+ const dir = await (0, import_promises103.mkdtemp)(import_node_path131.default.join(import_node_os4.default.tmpdir(), "qfai-merge-docs-"));
34308
33485
  try {
34309
- const files = ["ours", "base", "theirs"].map((name) => import_node_path133.default.join(dir, name));
33486
+ const files = ["ours", "base", "theirs"].map((name) => import_node_path131.default.join(dir, name));
34310
33487
  const [oursFile = "", baseFile = "", theirsFile = ""] = files;
34311
33488
  await Promise.all([
34312
- (0, import_promises105.writeFile)(oursFile, ours, "utf8"),
34313
- (0, import_promises105.writeFile)(baseFile, base, "utf8"),
34314
- (0, import_promises105.writeFile)(theirsFile, theirs, "utf8")
33489
+ (0, import_promises103.writeFile)(oursFile, ours, "utf8"),
33490
+ (0, import_promises103.writeFile)(baseFile, base, "utf8"),
33491
+ (0, import_promises103.writeFile)(theirsFile, theirs, "utf8")
34315
33492
  ]);
34316
33493
  const args = ["merge-file", "-p", ...options, oursFile, baseFile, theirsFile];
34317
33494
  try {
@@ -34329,7 +33506,7 @@ async function runMergeFile(base, ours, theirs, options) {
34329
33506
  throw failure2;
34330
33507
  }
34331
33508
  } finally {
34332
- await (0, import_promises105.rm)(dir, { recursive: true, force: true });
33509
+ await (0, import_promises103.rm)(dir, { recursive: true, force: true });
34333
33510
  }
34334
33511
  }
34335
33512
  function parseMerge(output) {
@@ -34513,13 +33690,13 @@ var OWN_MARKER = /^(?:<<<<<<< ours|>>>>>>> theirs)\r?$/mu;
34513
33690
  var REGULAR_FILE = /* @__PURE__ */ new Set(["100644", "100755"]);
34514
33691
  var SCHEMA_VIOLATION = "QFAI-DOCSCHEMA-001";
34515
33692
  async function runSddMergeDocsCommand(options) {
34516
- const root = import_node_path134.default.resolve(options.root);
33693
+ const root = import_node_path132.default.resolve(options.root);
34517
33694
  try {
34518
33695
  const loaded2 = await loadConfig(root);
34519
33696
  if (loaded2.issues.length) throw new Error("Correct qfai.config.yaml before merging documents.");
34520
- const scope = import_node_path134.default.relative(root, resolvePath(root, loaded2.config, "specsDir")) || ".";
33697
+ const scope = import_node_path132.default.relative(root, resolvePath(root, loaded2.config, "specsDir")) || ".";
34521
33698
  const unmerged = readUnmerged(await gitText(root, ["ls-files", "-u", "-z", "--", scope]));
34522
- const label = scope.split(import_node_path134.default.sep).join("/");
33699
+ const label = scope.split(import_node_path132.default.sep).join("/");
34523
33700
  if (unmerged.size === 0) {
34524
33701
  info(`qfai sdd merge-docs: no conflicted document under ${label}; nothing to merge.`);
34525
33702
  return EXIT_CODES.ok;
@@ -34553,10 +33730,10 @@ async function mergeOne(root, file, stages) {
34553
33730
  const present = [stages.base, stages.ours, stages.theirs].filter((stage) => stage !== void 0);
34554
33731
  if (present.some((stage) => !REGULAR_FILE.has(stage.mode)))
34555
33732
  return left("it is not a regular file");
34556
- const target = import_node_path134.default.join(root, ...file.split("/"));
33733
+ const target = import_node_path132.default.join(root, ...file.split("/"));
34557
33734
  let working;
34558
33735
  try {
34559
- working = await (0, import_promises106.readFile)(target, "utf8");
33736
+ working = await (0, import_promises104.readFile)(target, "utf8");
34560
33737
  } catch (failure2) {
34561
33738
  return left(
34562
33739
  `the working file could not be read: ${failure2 instanceof Error ? failure2.message : String(failure2)}`
@@ -34579,7 +33756,7 @@ async function mergeOne(root, file, stages) {
34579
33756
  );
34580
33757
  const merged = await mergeDocument(base ?? "", ours ?? "", theirs ?? "");
34581
33758
  if (merged === null) return left("a line in it reads as a merge marker");
34582
- await (0, import_promises106.writeFile)(target, merged.text, "utf8");
33759
+ await (0, import_promises104.writeFile)(target, merged.text, "utf8");
34583
33760
  return merged.conflicts === 0 ? { kind: "merged", message: "merged" } : left(`merged around ${merged.conflicts} conflict(s), left between markers`);
34584
33761
  }
34585
33762
  function readUnmerged(output) {
@@ -34616,8 +33793,8 @@ async function gitText(cwd, args) {
34616
33793
  // src/core/storyTree/renumberDecision.ts
34617
33794
  var import_node_child_process9 = require("child_process");
34618
33795
  var import_node_crypto13 = require("crypto");
34619
- var import_promises107 = __toESM(require("fs/promises"), 1);
34620
- var import_node_path135 = __toESM(require("path"), 1);
33796
+ var import_promises105 = __toESM(require("fs/promises"), 1);
33797
+ var import_node_path133 = __toESM(require("path"), 1);
34621
33798
  var import_node_util7 = require("util");
34622
33799
  var execute5 = (0, import_node_util7.promisify)(import_node_child_process9.execFile);
34623
33800
  var MAX_BYTES = 16 * 1024 * 1024;
@@ -34665,10 +33842,10 @@ async function commit(root, ref) {
34665
33842
  return value;
34666
33843
  }
34667
33844
  async function repositoryPaths(projectRoot, directories) {
34668
- const root = (await git2(import_node_path135.default.resolve(projectRoot), ["rev-parse", "--show-toplevel"])).toString().trim();
33845
+ const root = (await git2(import_node_path133.default.resolve(projectRoot), ["rev-parse", "--show-toplevel"])).toString().trim();
34669
33846
  const relative = directories.map((directory) => {
34670
- const value = import_node_path135.default.relative(root, import_node_path135.default.resolve(projectRoot, directory)).split(import_node_path135.default.sep).join("/");
34671
- if (value === ".." || value.startsWith("../") || import_node_path135.default.isAbsolute(value))
33847
+ const value = import_node_path133.default.relative(root, import_node_path133.default.resolve(projectRoot, directory)).split(import_node_path133.default.sep).join("/");
33848
+ if (value === ".." || value.startsWith("../") || import_node_path133.default.isAbsolute(value))
34672
33849
  throw new Error("The story tree must be inside the repository.");
34673
33850
  return value;
34674
33851
  });
@@ -34695,23 +33872,23 @@ async function blob(root, sha, file) {
34695
33872
  return git2(root, ["cat-file", "blob", match[1]]);
34696
33873
  }
34697
33874
  async function regular(root, file) {
34698
- const relative = import_node_path135.default.relative(root, import_node_path135.default.resolve(root, file));
34699
- if (relative === "" || relative.startsWith(`..${import_node_path135.default.sep}`) || relative === ".." || import_node_path135.default.isAbsolute(relative))
33875
+ const relative = import_node_path133.default.relative(root, import_node_path133.default.resolve(root, file));
33876
+ if (relative === "" || relative.startsWith(`..${import_node_path133.default.sep}`) || relative === ".." || import_node_path133.default.isAbsolute(relative))
34700
33877
  throw new Error(`Candidate is outside the repository: ${file}`);
34701
33878
  let current = root;
34702
- for (const part of relative.split(import_node_path135.default.sep)) {
34703
- current = import_node_path135.default.join(current, part);
34704
- const stats = await (0, import_promises107.lstat)(current);
33879
+ for (const part of relative.split(import_node_path133.default.sep)) {
33880
+ current = import_node_path133.default.join(current, part);
33881
+ const stats = await (0, import_promises105.lstat)(current);
34705
33882
  if (stats.isSymbolicLink()) throw new Error(`Linked candidate path: ${file}`);
34706
- if (current === import_node_path135.default.resolve(root, file) && !stats.isFile())
33883
+ if (current === import_node_path133.default.resolve(root, file) && !stats.isFile())
34707
33884
  throw new Error(`Candidate is not a regular file: ${file}`);
34708
- if (current === import_node_path135.default.resolve(root, file) && stats.nlink > 1)
33885
+ if (current === import_node_path133.default.resolve(root, file) && stats.nlink > 1)
34709
33886
  throw new Error(`Hardlinked candidate path: ${file}`);
34710
33887
  }
34711
33888
  }
34712
33889
  async function original(root, file) {
34713
33890
  await regular(root, file);
34714
- const bytes = await readBoundedRegularFile(import_node_path135.default.resolve(root, file), MAX_BYTES);
33891
+ const bytes = await readBoundedRegularFile(import_node_path133.default.resolve(root, file), MAX_BYTES);
34715
33892
  if (bytes === void 0)
34716
33893
  throw new Error(`Candidate is unreadable, oversized or not regular: ${file}`);
34717
33894
  return bytes;
@@ -34719,15 +33896,15 @@ async function original(root, file) {
34719
33896
  async function inspectLinkPointer(root, file, id) {
34720
33897
  let current = root;
34721
33898
  for (const part of file.split("/")) {
34722
- current = import_node_path135.default.join(current, part);
34723
- const stats = await (0, import_promises107.lstat)(current).catch((failure2) => {
33899
+ current = import_node_path133.default.join(current, part);
33900
+ const stats = await (0, import_promises105.lstat)(current).catch((failure2) => {
34724
33901
  if (typeof failure2 === "object" && failure2 !== null && "code" in failure2 && failure2.code === "ENOENT")
34725
33902
  return void 0;
34726
33903
  throw failure2;
34727
33904
  });
34728
33905
  if (!stats) return;
34729
33906
  if (!stats.isSymbolicLink()) continue;
34730
- const pointer = await (0, import_promises107.readlink)(current);
33907
+ const pointer = await (0, import_promises105.readlink)(current);
34731
33908
  if (token(id).test(pointer) || token(id).test(file))
34732
33909
  throw new Error(`Linked candidate path: ${file}`);
34733
33910
  return;
@@ -34816,7 +33993,7 @@ async function fixedSpecTexts(root, sha, specs, additional = []) {
34816
33993
  for (const directory of directories) {
34817
33994
  let component = "";
34818
33995
  for (const part of directory.split("/").filter(Boolean)) {
34819
- component = component ? import_node_path135.default.posix.join(component, part) : part;
33996
+ component = component ? import_node_path133.default.posix.join(component, part) : part;
34820
33997
  components.add(component);
34821
33998
  }
34822
33999
  }
@@ -34834,7 +34011,7 @@ async function fixedSpecTexts(root, sha, specs, additional = []) {
34834
34011
  const pathspecs = directories.map((directory) => directory || ".");
34835
34012
  const listing = await git2(root, ["ls-tree", "-r", "-l", "-z", sha, "--", ...pathspecs]);
34836
34013
  const entries = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(listing);
34837
- const decisionPages = `${import_node_path135.default.posix.join(specs, "decisions")}/`;
34014
+ const decisionPages = `${import_node_path133.default.posix.join(specs, "decisions")}/`;
34838
34015
  const wanted = /* @__PURE__ */ new Map();
34839
34016
  for (const entry of entries.split("\0").filter(Boolean)) {
34840
34017
  const match = /^([0-7]+) blob ([a-f0-9]+) +(\d+)\t(.+)$/.exec(entry);
@@ -34843,9 +34020,9 @@ async function fixedSpecTexts(root, sha, specs, additional = []) {
34843
34020
  `The fixed story tree has a non-blob: ${entry.slice(entry.indexOf(" ") + 1)}`
34844
34021
  );
34845
34022
  const file = match[4];
34846
- if ((file === import_node_path135.default.posix.join(specs, "decisions.md") || file.startsWith(decisionPages)) && !/^100[0-7]{3}$/.test(match[1]))
34023
+ if ((file === import_node_path133.default.posix.join(specs, "decisions.md") || file.startsWith(decisionPages)) && !/^100[0-7]{3}$/.test(match[1]))
34847
34024
  throw new Error(`Linked decision path in fixed tree: ${file}`);
34848
- if (!SUFFIXES.has(import_node_path135.default.extname(file).toLowerCase()) && !file.startsWith(decisionPages))
34025
+ if (!SUFFIXES.has(import_node_path133.default.extname(file).toLowerCase()) && !file.startsWith(decisionPages))
34849
34026
  continue;
34850
34027
  if (Number(match[3]) > MAX_BYTES) throw new Error(`Candidate exceeds 16 MiB: ${file}`);
34851
34028
  wanted.set(file, match[2]);
@@ -34877,7 +34054,7 @@ async function buildDecisionRenumberPlan(options) {
34877
34054
  root,
34878
34055
  relative: [specs = ""]
34879
34056
  } = await repositoryPaths(options.root, [options.specsDir]);
34880
- const decisionFile = import_node_path135.default.posix.join(specs, "decisions.md");
34057
+ const decisionFile = import_node_path133.default.posix.join(specs, "decisions.md");
34881
34058
  const headSha = await commit(root, "HEAD");
34882
34059
  const baseSha = await commit(root, options.base);
34883
34060
  const ancestors = (await git2(root, ["merge-base", "--all", headSha, baseSha])).toString().trim().split(/\s+/);
@@ -34902,7 +34079,7 @@ async function buildDecisionRenumberPlan(options) {
34902
34079
  const headRows = records(headTexts, decisionFile);
34903
34080
  const ancestorTexts = await fixedSpecTexts(root, ancestorSha, specs);
34904
34081
  const ancestorRows = ancestorBytes || [...ancestorTexts.keys()].some(
34905
- (file) => file.startsWith(`${import_node_path135.default.posix.join(specs, "decisions")}/`)
34082
+ (file) => file.startsWith(`${import_node_path133.default.posix.join(specs, "decisions")}/`)
34906
34083
  ) ? records(ancestorTexts, decisionFile) : [];
34907
34084
  if (headRows.filter((row) => row.id === options.from).length !== 1)
34908
34085
  throw new Error("The source must be one unique current DEC row.");
@@ -34969,7 +34146,7 @@ async function buildDecisionRenumberPlan(options) {
34969
34146
  continue;
34970
34147
  }
34971
34148
  if (!tracked.has(file) || !committed) throw new Error(`Untracked candidate: ${file}`);
34972
- if (!SUFFIXES.has(import_node_path135.default.extname(file).toLowerCase()))
34149
+ if (!SUFFIXES.has(import_node_path133.default.extname(file).toLowerCase()))
34973
34150
  throw new Error(`Unsupported candidate suffix: ${file}`);
34974
34151
  if (source.replace(/\r\n/g, "\n") !== text2(committed, file).replace(/\r\n/g, "\n") || (await git2(root, [
34975
34152
  "diff",
@@ -35036,15 +34213,15 @@ async function buildDecisionRenumberPlan(options) {
35036
34213
  };
35037
34214
  }
35038
34215
  async function applyDecisionRenumberPlan(plan, io = {}) {
35039
- const read2 = io.readFile ?? ((file) => original(plan.root, import_node_path135.default.relative(plan.root, file)));
35040
- const write = io.writeFile ?? import_promises107.writeFile;
34216
+ const read2 = io.readFile ?? ((file) => original(plan.root, import_node_path133.default.relative(plan.root, file)));
34217
+ const write = io.writeFile ?? import_promises105.writeFile;
35041
34218
  const checkRefs = async () => {
35042
34219
  if (await commit(plan.root, "HEAD") !== plan.headSha || await commit(plan.root, plan.baseRef) !== plan.baseSha)
35043
34220
  throw new Error("Stale plan: HEAD or base changed.");
35044
34221
  };
35045
34222
  const checkOriginal = async (change) => {
35046
34223
  await regular(plan.root, change.file);
35047
- if (!(await read2(import_node_path135.default.resolve(plan.root, change.file))).equals(change.original))
34224
+ if (!(await read2(import_node_path133.default.resolve(plan.root, change.file))).equals(change.original))
35048
34225
  throw new Error(`Stale candidate bytes: ${change.file}`);
35049
34226
  if ((await git2(plan.root, ["diff", "--cached", "--name-only", plan.headSha, "--", change.file])).length)
35050
34227
  throw new Error(`Stale candidate index: ${change.file}`);
@@ -35057,14 +34234,14 @@ async function applyDecisionRenumberPlan(plan, io = {}) {
35057
34234
  await checkRefs();
35058
34235
  await checkOriginal(change);
35059
34236
  attempted.push(change);
35060
- await write(import_node_path135.default.resolve(plan.root, change.file), change.replacement);
34237
+ await write(import_node_path133.default.resolve(plan.root, change.file), change.replacement);
35061
34238
  }
35062
34239
  } catch (failure2) {
35063
34240
  const unrestored = [];
35064
34241
  for (const change of attempted.reverse()) {
35065
34242
  try {
35066
34243
  await regular(plan.root, change.file);
35067
- const file = import_node_path135.default.resolve(plan.root, change.file);
34244
+ const file = import_node_path133.default.resolve(plan.root, change.file);
35068
34245
  const current = await read2(file);
35069
34246
  if (current.equals(change.original)) continue;
35070
34247
  if (!current.equals(change.replacement)) {
@@ -35109,12 +34286,12 @@ async function runSddNextIdCommand(options) {
35109
34286
  }
35110
34287
 
35111
34288
  // src/cli/commands/sddPreflight.ts
35112
- var import_promises109 = require("fs/promises");
35113
- var import_node_path137 = __toESM(require("path"), 1);
34289
+ var import_promises107 = require("fs/promises");
34290
+ var import_node_path135 = __toESM(require("path"), 1);
35114
34291
 
35115
34292
  // src/core/preflight/sddPreflight.ts
35116
- var import_promises108 = require("fs/promises");
35117
- var import_node_path136 = __toESM(require("path"), 1);
34293
+ var import_promises106 = require("fs/promises");
34294
+ var import_node_path134 = __toESM(require("path"), 1);
35118
34295
  var REQ_ID_RE = /\bREQ-\d{4}\b/g;
35119
34296
  var PREFLIGHT_SUMMARY_FILE = "preflight_summary.md";
35120
34297
  var PREFLIGHT_RUN_ROOT = "preflight";
@@ -35176,7 +34353,7 @@ async function runSddPreflight(root, config, options = {}) {
35176
34353
  };
35177
34354
  }
35178
34355
  const selectedInputPath = readiness.latestPackDir;
35179
- const reqPath = selectedInputPath === null ? null : import_node_path136.default.join(selectedInputPath, "06_REQ.md");
34356
+ const reqPath = selectedInputPath === null ? null : import_node_path134.default.join(selectedInputPath, "06_REQ.md");
35180
34357
  return await completeReadyPreflight({
35181
34358
  source: "discussion-pack",
35182
34359
  selectedInputPath,
@@ -35219,13 +34396,13 @@ function toSummaryPaths(run2) {
35219
34396
  };
35220
34397
  }
35221
34398
  async function allocatePreflightRun(reportRoot, startedAt) {
35222
- const runRoot = import_node_path136.default.join(reportRoot, PREFLIGHT_RUN_ROOT);
35223
- await (0, import_promises108.mkdir)(runRoot, { recursive: true });
34399
+ const runRoot = import_node_path134.default.join(reportRoot, PREFLIGHT_RUN_ROOT);
34400
+ await (0, import_promises106.mkdir)(runRoot, { recursive: true });
35224
34401
  const { runId, runDir } = await allocateRunDir(runRoot, startedAt);
35225
34402
  return {
35226
34403
  runId,
35227
- summaryPath: import_node_path136.default.join(runDir, PREFLIGHT_SUMMARY_FILE),
35228
- latestSummaryPath: import_node_path136.default.join(reportRoot, PREFLIGHT_SUMMARY_FILE),
34404
+ summaryPath: import_node_path134.default.join(runDir, PREFLIGHT_SUMMARY_FILE),
34405
+ latestSummaryPath: import_node_path134.default.join(reportRoot, PREFLIGHT_SUMMARY_FILE),
35229
34406
  runRoot
35230
34407
  };
35231
34408
  }
@@ -35233,20 +34410,20 @@ var PREFLIGHT_RUN_ID_LINE_RE = /^-\s*run id:\s*(run-\d{17})\s*$/m;
35233
34410
  async function publishPreflightSummary(run2, body) {
35234
34411
  const contents = `${body}
35235
34412
  `;
35236
- await (0, import_promises108.writeFile)(run2.summaryPath, contents, "utf-8");
34413
+ await (0, import_promises106.writeFile)(run2.summaryPath, contents, "utf-8");
35237
34414
  if (await hasNewerRunDir(run2.runRoot, run2.runId)) {
35238
34415
  return;
35239
34416
  }
35240
34417
  let existingRunId;
35241
34418
  try {
35242
- existingRunId = PREFLIGHT_RUN_ID_LINE_RE.exec(await (0, import_promises108.readFile)(run2.latestSummaryPath, "utf-8"))?.[1] ?? null;
34419
+ existingRunId = PREFLIGHT_RUN_ID_LINE_RE.exec(await (0, import_promises106.readFile)(run2.latestSummaryPath, "utf-8"))?.[1] ?? null;
35243
34420
  } catch {
35244
34421
  existingRunId = null;
35245
34422
  }
35246
34423
  if (existingRunId !== null && existingRunId > run2.runId) {
35247
34424
  return;
35248
34425
  }
35249
- await (0, import_promises108.writeFile)(run2.latestSummaryPath, contents, "utf-8");
34426
+ await (0, import_promises106.writeFile)(run2.latestSummaryPath, contents, "utf-8");
35250
34427
  }
35251
34428
  function resolvePreflightBlockers(readiness) {
35252
34429
  const blockers = [];
@@ -35299,7 +34476,7 @@ async function resolveStoryWorkshopGaps(packDir) {
35299
34476
  if (packDir === null) {
35300
34477
  return [];
35301
34478
  }
35302
- const text3 = await readSafe8(import_node_path136.default.join(packDir, "03_Story-Workshop.md"));
34479
+ const text3 = await readSafe8(import_node_path134.default.join(packDir, "03_Story-Workshop.md"));
35303
34480
  if (text3.length === 0 || containsMermaidBlock(text3)) {
35304
34481
  return [];
35305
34482
  }
@@ -35411,15 +34588,15 @@ function isTableSeparator2(line, columnCount) {
35411
34588
  }
35412
34589
  async function readSafe8(filePath) {
35413
34590
  try {
35414
- return await (0, import_promises108.readFile)(filePath, "utf-8");
34591
+ return await (0, import_promises106.readFile)(filePath, "utf-8");
35415
34592
  } catch {
35416
34593
  return "";
35417
34594
  }
35418
34595
  }
35419
34596
  async function isReadableFile2(filePath) {
35420
34597
  try {
35421
- if (!(await (0, import_promises108.stat)(filePath)).isFile()) return false;
35422
- await (await (0, import_promises108.open)(filePath, "r")).close();
34598
+ if (!(await (0, import_promises106.stat)(filePath)).isFile()) return false;
34599
+ await (await (0, import_promises106.open)(filePath, "r")).close();
35423
34600
  return true;
35424
34601
  } catch {
35425
34602
  return false;
@@ -35429,7 +34606,7 @@ async function isReadableFile2(filePath) {
35429
34606
  // src/cli/commands/sddPreflight.ts
35430
34607
  var CARRY_OVER_HEADING = "## Open Questions (Carry-over)";
35431
34608
  function toRelative2(root, target) {
35432
- const relative = import_node_path137.default.relative(root, target);
34609
+ const relative = import_node_path135.default.relative(root, target);
35433
34610
  return (relative === "" ? target : relative).replace(/\\/g, "/");
35434
34611
  }
35435
34612
  function renderText2(root, result) {
@@ -35475,7 +34652,7 @@ async function resolveSelectedPackDir(root) {
35475
34652
  async function readRecordedCarryOver(summaryPath) {
35476
34653
  let text3;
35477
34654
  try {
35478
- text3 = await (0, import_promises109.readFile)(summaryPath, "utf-8");
34655
+ text3 = await (0, import_promises107.readFile)(summaryPath, "utf-8");
35479
34656
  } catch {
35480
34657
  return [];
35481
34658
  }
@@ -35506,7 +34683,7 @@ async function resolveCarryOver(root, config, explicit) {
35506
34683
  return provided;
35507
34684
  }
35508
34685
  return await readRecordedCarryOver(
35509
- import_node_path137.default.join(resolvePath(root, config, "outDir"), "preflight_summary.md")
34686
+ import_node_path135.default.join(resolvePath(root, config, "outDir"), "preflight_summary.md")
35510
34687
  );
35511
34688
  }
35512
34689
  async function runSddPreflightCommand(options) {
@@ -35538,7 +34715,7 @@ async function runSddPreflightCommand(options) {
35538
34715
  result = await runSddPreflight(options.root, config, {
35539
34716
  ...packDir === void 0 ? {} : { packDir },
35540
34717
  ...assumptions.length > 0 ? { assumptions } : {},
35541
- ...options.importPath === void 0 ? {} : { importPath: import_node_path137.default.resolve(options.root, options.importPath) }
34718
+ ...options.importPath === void 0 ? {} : { importPath: import_node_path135.default.resolve(options.root, options.importPath) }
35542
34719
  });
35543
34720
  } catch (err) {
35544
34721
  const message = err instanceof Error ? err.message : String(err);
@@ -35591,8 +34768,8 @@ async function runSddRenumberDecisionCommand(options) {
35591
34768
  }
35592
34769
 
35593
34770
  // src/cli/commands/workflow.ts
35594
- var import_promises111 = require("fs/promises");
35595
- var import_node_path139 = __toESM(require("path"), 1);
34771
+ var import_promises109 = require("fs/promises");
34772
+ var import_node_path137 = __toESM(require("path"), 1);
35596
34773
 
35597
34774
  // src/core/workflow/extraction.ts
35598
34775
  var INTENTS = [
@@ -35864,11 +35041,11 @@ function objectFaults(value, shape, at) {
35864
35041
  }
35865
35042
 
35866
35043
  // src/core/workflow/plans.ts
35867
- var import_promises110 = require("fs/promises");
35868
- var import_node_path138 = __toESM(require("path"), 1);
35044
+ var import_promises108 = require("fs/promises");
35045
+ var import_node_path136 = __toESM(require("path"), 1);
35869
35046
 
35870
35047
  // src/core/workflow/planFormat.ts
35871
- var import_yaml21 = require("yaml");
35048
+ var import_yaml20 = require("yaml");
35872
35049
 
35873
35050
  // src/core/workflow/routes.ts
35874
35051
  var WORKFLOW_ROUTES = [
@@ -36143,7 +35320,7 @@ function refused(refuse, reason, subject) {
36143
35320
  function unknownKeys(value, known, refuse) {
36144
35321
  for (const key of Object.keys(value)) if (!known.includes(key)) refuse("unknown-key", key);
36145
35322
  }
36146
- function stringList3(value) {
35323
+ function stringList2(value) {
36147
35324
  if (Array.isArray(value) && value.every((item) => typeof item === "string")) return value;
36148
35325
  return void 0;
36149
35326
  }
@@ -36197,7 +35374,7 @@ function stageOf(value, refuse) {
36197
35374
  unknownKeys(value, STAGE_KEYS, refuse);
36198
35375
  const { id, kind } = value;
36199
35376
  const steps = stepsOf(value.steps, refuse);
36200
- const after = value.after === void 0 ? [] : stringList3(value.after);
35377
+ const after = value.after === void 0 ? [] : stringList2(value.after);
36201
35378
  if (typeof id !== "string" || id === "" || typeof kind !== "string" || !steps || !after) {
36202
35379
  return refused(refuse, "shape", typeof id === "string" ? id : "stages");
36203
35380
  }
@@ -36227,7 +35404,7 @@ function isArtifact(value) {
36227
35404
  }
36228
35405
  function servesOf(value, kind, id, refuse) {
36229
35406
  if (value === void 0) return void 0;
36230
- const names = stringList3(value);
35407
+ const names = stringList2(value);
36231
35408
  const written = kindWrites(kind);
36232
35409
  if (!names || names.length === 0 || new Set(names).size !== names.length || names.some((name) => written.some((artifact) => artifact === name))) {
36233
35410
  refuse("shape", id);
@@ -36318,7 +35495,7 @@ function outcomeOf(value, refuse) {
36318
35495
  const { outcome, routes } = value;
36319
35496
  if (typeof outcome !== "string" || outcome === "") return null;
36320
35497
  if (routes === "decision-table") return { outcome, routes };
36321
- const named2 = stringList3(routes);
35498
+ const named2 = stringList2(routes);
36322
35499
  if (!named2 || named2.length === 0) return null;
36323
35500
  for (const route of named2) if (!isWorkflowRoute(route)) refuse("destination", route);
36324
35501
  return { outcome, routes: named2 };
@@ -36354,7 +35531,7 @@ function pointRefusals(plan, refuse) {
36354
35531
  }
36355
35532
  function documentOf(text3) {
36356
35533
  try {
36357
- return (0, import_yaml21.parse)(text3);
35534
+ return (0, import_yaml20.parse)(text3);
36358
35535
  } catch {
36359
35536
  return void 0;
36360
35537
  }
@@ -36365,7 +35542,7 @@ function headerOf(document, route, refuse) {
36365
35542
  }
36366
35543
  const family = typeof document.family === "string" ? document.family : "";
36367
35544
  if (!ROUTE_FAMILIES.some((each) => each === family)) refuse("family", family || "family");
36368
- const decisionPoints = stringList3(document.decisionPoints);
35545
+ const decisionPoints = stringList2(document.decisionPoints);
36369
35546
  if (!decisionPoints) refuse("shape", "decisionPoints");
36370
35547
  const { releasePoint } = document;
36371
35548
  if (releasePoint !== void 0 && typeof releasePoint !== "string") {
@@ -36405,18 +35582,18 @@ function parsePlan(text3, route) {
36405
35582
 
36406
35583
  // src/core/workflow/plans.ts
36407
35584
  function packagePlansDir() {
36408
- return import_node_path138.default.resolve(getInitAssetsDir(), "..", "defaults", "workflows");
35585
+ return import_node_path136.default.resolve(getInitAssetsDir(), "..", "defaults", "workflows");
36409
35586
  }
36410
35587
  async function readIfPresent(file) {
36411
35588
  try {
36412
- return await (0, import_promises110.readFile)(file, "utf8");
35589
+ return await (0, import_promises108.readFile)(file, "utf8");
36413
35590
  } catch (error2) {
36414
35591
  if (isRecord2(error2) && error2.code === "ENOENT") return void 0;
36415
35592
  return null;
36416
35593
  }
36417
35594
  }
36418
35595
  async function loadPackagePlan(route) {
36419
- const text3 = await readIfPresent(import_node_path138.default.join(packagePlansDir(), `${route}.yml`));
35596
+ const text3 = await readIfPresent(import_node_path136.default.join(packagePlansDir(), `${route}.yml`));
36420
35597
  if (text3 === void 0) {
36421
35598
  return { ok: false, refusals: [{ route, reason: "file-missing", subject: route }] };
36422
35599
  }
@@ -36437,7 +35614,7 @@ function planSteps(plans) {
36437
35614
  async function contractRefusals(root, steps) {
36438
35615
  const found = await Promise.all(
36439
35616
  [...steps].map(async ([step, route]) => {
36440
- const entry = await (0, import_promises110.stat)(import_node_path138.default.join(root, stepPath(step))).catch(() => void 0);
35617
+ const entry = await (0, import_promises108.stat)(import_node_path136.default.join(root, stepPath(step))).catch(() => void 0);
36441
35618
  return entry?.isFile() ? [] : [{ route, reason: "step-missing", subject: step }];
36442
35619
  })
36443
35620
  );
@@ -36907,7 +36084,7 @@ async function readStdin() {
36907
36084
  async function readExtraction(root, inPath) {
36908
36085
  let text3;
36909
36086
  try {
36910
- text3 = inPath === "-" ? await readStdin() : await (0, import_promises111.readFile)(import_node_path139.default.resolve(root, inPath), "utf8");
36087
+ text3 = inPath === "-" ? await readStdin() : await (0, import_promises109.readFile)(import_node_path137.default.resolve(root, inPath), "utf8");
36911
36088
  } catch {
36912
36089
  const message = "The input file cannot be read, so check the path and try again.";
36913
36090
  return { ok: false, document: refusal(message, [{ reason: "io-error", subject: inPath }]) };