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.
- package/README.md +14 -17
- package/assets/init/.qfai/assistant/agent/architecture-reviewer.md +2 -2
- package/assets/init/.qfai/assistant/agent/fullstack-engineer.md +101 -0
- package/assets/init/.qfai/assistant/agent/implementation-reviewer.md +73 -1
- package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +2 -2
- package/assets/init/.qfai/assistant/agent/requirements-reviewer.md +12 -2
- package/assets/init/.qfai/assistant/rule/agent-selection.md +22 -42
- package/assets/init/.qfai/assistant/rule/drift-protocol.md +1 -1
- package/assets/init/.qfai/assistant/rule/references/asset-authoring.md +1 -1
- package/assets/init/.qfai/assistant/rule/references/codex-delegation.md +4 -4
- package/assets/init/.qfai/assistant/rule/references/reviewer-findings.md +1 -1
- package/assets/init/.qfai/assistant/rule/references/worker-edit-boundary.md +3 -3
- package/assets/init/.qfai/assistant/rule/research-first-protocol.md +7 -6
- package/assets/init/.qfai/assistant/rule/review-convergence.md +1 -1
- package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +76 -60
- package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +2 -4
- package/assets/init/.qfai/assistant/rule/workflow.md +4 -4
- package/assets/init/.qfai/assistant/skill/qfai-configure/SKILL.md +15 -46
- package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +1 -13
- package/assets/init/.qfai/assistant/skill/qfai-grill/SKILL.md +8 -7
- package/assets/init/.qfai/assistant/skill/qfai-grilling/SKILL.md +15 -15
- package/assets/init/.qfai/assistant/skill/qfai-grilling/references/delegated-session.md +18 -18
- package/assets/init/.qfai/assistant/skill/qfai-grilling/references/session-record.md +3 -3
- package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +0 -14
- package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +52 -20
- package/assets/init/.qfai/assistant/skill/qfai-maintain/SKILL.md +0 -1
- package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/SKILL.md +2 -13
- package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-guide.md +8 -11
- package/assets/init/.qfai/assistant/skill/qfai-migration-v1-to-v2/references/migration-placement.md +0 -7
- package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +1 -9
- package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/generator-prompt.md +1 -1
- package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/iteration-loop.md +2 -2
- package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +4 -4
- package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +1 -1
- package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +1 -2
- package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +4 -4
- package/assets/init/.qfai/assistant/skill/qfai-sdd/SKILL.md +0 -13
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/concrete-abstract-cycle.md +2 -2
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +12 -0
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +1 -1
- package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md +2 -2
- package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +0 -11
- package/assets/init/.qfai/assistant/skill/qfai-verify/SKILL.md +0 -9
- package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +18 -18
- package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +0 -1
- package/assets/init/.qfai/assistant/step/common-grilling-record/STEP.md +0 -1
- package/assets/init/.qfai/assistant/step/common-policy-check/STEP.md +0 -1
- package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +2 -3
- package/assets/init/.qfai/assistant/step/discussion-interview/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/discussion-oq/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/discussion-research/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/implement-acceptance/STEP.md +0 -4
- package/assets/init/.qfai/assistant/step/implement-backport/STEP.md +0 -5
- package/assets/init/.qfai/assistant/step/implement-benchmark/STEP.md +0 -4
- package/assets/init/.qfai/assistant/step/implement-bisect/STEP.md +0 -5
- package/assets/init/.qfai/assistant/step/implement-credentials/STEP.md +0 -4
- package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +0 -5
- package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +0 -6
- package/assets/init/.qfai/assistant/step/implement-minimize/STEP.md +0 -5
- package/assets/init/.qfai/assistant/step/implement-oracle-parity/STEP.md +0 -6
- package/assets/init/.qfai/assistant/step/implement-procedure/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/implement-quarantine/STEP.md +0 -4
- package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +0 -4
- package/assets/init/.qfai/assistant/step/implement-regression-fix/STEP.md +0 -4
- package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +0 -6
- package/assets/init/.qfai/assistant/step/implement-revert/STEP.md +0 -4
- package/assets/init/.qfai/assistant/step/implement-scaffold/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/implement-seam/STEP.md +0 -4
- package/assets/init/.qfai/assistant/step/implement-stress-harness/STEP.md +0 -5
- package/assets/init/.qfai/assistant/step/implement-sweep/STEP.md +0 -5
- package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +3 -10
- package/assets/init/.qfai/assistant/step/implement-test-fix/STEP.md +0 -5
- package/assets/init/.qfai/assistant/step/implement-tooling/STEP.md +0 -3
- package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +1 -4
- package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +3 -5
- package/assets/init/.qfai/assistant/step/prototyping-handoff/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +17 -19
- package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +2 -4
- package/assets/init/.qfai/assistant/step/sdd-cycle/STEP.md +1 -3
- package/assets/init/.qfai/assistant/step/sdd-flow/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/sdd-gate/STEP.md +0 -1
- package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +7 -9
- package/assets/init/.qfai/assistant/step/triage-answer/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/triage-close/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/triage-cluster/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/triage-decompose/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/triage-dedupe/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/triage-investigate/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/triage-operate/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/triage-owned-cleanup/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/triage-request-info/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/triage-security-intake/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/verify-advisory/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/verify-change-note/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/verify-context/STEP.md +7 -26
- package/assets/init/.qfai/assistant/step/verify-external/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/verify-manual/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/verify-release-notes/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +0 -2
- package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +0 -2
- package/assets/init/root/.agents/rules/grilling.md +9 -9
- package/dist/cli/index.cjs +324 -1147
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.mjs +309 -1132
- package/dist/cli/index.mjs.map +1 -1
- package/dist/graph/cli.cjs +14 -2
- package/dist/graph/cli.cjs.map +1 -1
- package/dist/graph/cli.d.cts +1 -1
- package/dist/graph/cli.d.ts +1 -1
- package/dist/graph/cli.mjs +14 -2
- package/dist/graph/cli.mjs.map +1 -1
- package/dist/graph/hook.cjs.map +1 -1
- package/dist/graph/hook.mjs.map +1 -1
- package/dist/index.cjs +983 -1975
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -19
- package/dist/index.d.ts +2 -19
- package/dist/index.mjs +878 -1869
- package/dist/index.mjs.map +1 -1
- package/dist/process-qqX2Owgq.d.cts +18 -0
- package/dist/process-qqX2Owgq.d.ts +18 -0
- package/package.json +1 -1
- package/assets/defaults/agent-routing/_contract.yml +0 -77
- package/assets/defaults/agent-routing/common.yml +0 -14
- package/assets/defaults/agent-routing/qfai-discussion.yml +0 -57
- package/assets/defaults/agent-routing/qfai-implement.yml +0 -236
- package/assets/defaults/agent-routing/qfai-maintain.yml +0 -12
- package/assets/defaults/agent-routing/qfai-prototyping.yml +0 -48
- package/assets/defaults/agent-routing/qfai-sdd.yml +0 -56
- package/assets/defaults/agent-routing/qfai-triage.yml +0 -108
- package/assets/defaults/agent-routing/qfai-verify.yml +0 -92
- package/assets/defaults/agent-routing/skills.yml +0 -59
- package/assets/defaults/review-profiles.yml +0 -25
- package/assets/init/.qfai/assistant/agent/acceptance-test-engineer.md +0 -81
- package/assets/init/.qfai/assistant/agent/backend-engineer.md +0 -90
- package/assets/init/.qfai/assistant/agent/completion-reviewer.md +0 -88
- package/assets/init/.qfai/assistant/agent/delivery-planner.md +0 -85
- package/assets/init/.qfai/assistant/agent/devops-ci-engineer.md +0 -78
- package/assets/init/.qfai/assistant/agent/discovery-analyst.md +0 -81
- package/assets/init/.qfai/assistant/agent/doc-steward.md +0 -78
- package/assets/init/.qfai/assistant/agent/frontend-engineer.md +0 -94
- package/assets/init/.qfai/assistant/agent/orchestrator.md +0 -92
- package/assets/init/.qfai/assistant/agent/product-experience-architect.md +0 -101
- package/assets/init/.qfai/assistant/agent/qa-gatekeeper.md +0 -153
- package/assets/init/.qfai/assistant/agent/qa-strategist.md +0 -82
- package/assets/init/.qfai/assistant/agent/requirements-analyst.md +0 -96
- package/assets/init/.qfai/assistant/agent/solution-architect.md +0 -89
- package/assets/init/.qfai/assistant/agent/test-design-analyst.md +0 -132
- package/dist/process-C21nTvkT.d.cts +0 -12
- package/dist/process-C21nTvkT.d.ts +0 -12
package/dist/cli/index.mjs
CHANGED
|
@@ -359,11 +359,6 @@ var SHIPPED_WORKFLOW_NAMES = /* @__PURE__ */ new Set([
|
|
|
359
359
|
]);
|
|
360
360
|
|
|
361
361
|
// src/core/config.ts
|
|
362
|
-
function routingEntryName(entry) {
|
|
363
|
-
if (typeof entry.step === "string" && entry.step.length > 0) return entry.step;
|
|
364
|
-
if (typeof entry.skill === "string" && entry.skill.length > 0) return entry.skill;
|
|
365
|
-
return void 0;
|
|
366
|
-
}
|
|
367
362
|
var defaultConfig = {
|
|
368
363
|
paths: {
|
|
369
364
|
contractsDir: ".qfai/spec/03_contract",
|
|
@@ -497,8 +492,6 @@ function normalizeConfig(raw, configPath, issues) {
|
|
|
497
492
|
const uiux = normalizeUiux(raw.uiux, configPath, issues);
|
|
498
493
|
const prototyping = normalizePrototyping(raw.prototyping, configPath, issues);
|
|
499
494
|
const report2 = normalizeReport(raw.report, configPath, issues);
|
|
500
|
-
const routing = normalizeRouting(raw.routing, configPath, issues);
|
|
501
|
-
const reviewProfiles = normalizeReviewProfiles(raw.reviewProfiles, configPath, issues);
|
|
502
495
|
const base = {
|
|
503
496
|
paths: normalizePaths(raw.paths, configPath, issues),
|
|
504
497
|
validation: normalizeValidation(raw.validation, configPath, issues),
|
|
@@ -513,66 +506,12 @@ function normalizeConfig(raw, configPath, issues) {
|
|
|
513
506
|
if (report2) {
|
|
514
507
|
base.report = report2;
|
|
515
508
|
}
|
|
516
|
-
if (routing) {
|
|
517
|
-
base.routing = routing;
|
|
518
|
-
}
|
|
519
|
-
if (reviewProfiles) {
|
|
520
|
-
base.reviewProfiles = reviewProfiles;
|
|
521
|
-
}
|
|
522
509
|
const baseBranch = readOptionalString(raw.baseBranch, "baseBranch", configPath, issues);
|
|
523
510
|
if (baseBranch !== void 0) {
|
|
524
511
|
base.baseBranch = baseBranch;
|
|
525
512
|
}
|
|
526
513
|
return base;
|
|
527
514
|
}
|
|
528
|
-
function normalizeRouting(raw, configPath, issues) {
|
|
529
|
-
if (raw === void 0) return void 0;
|
|
530
|
-
if (!Array.isArray(raw)) {
|
|
531
|
-
issues.push(
|
|
532
|
-
configIssue(configPath, "routing must be a list of entries keyed by step or skill.")
|
|
533
|
-
);
|
|
534
|
-
return void 0;
|
|
535
|
-
}
|
|
536
|
-
const entries = [];
|
|
537
|
-
const seen = /* @__PURE__ */ new Set();
|
|
538
|
-
for (const [index, value] of raw.entries()) {
|
|
539
|
-
const name = isRecord(value) ? routingEntryName(value) : void 0;
|
|
540
|
-
const keys = isRecord(value) ? [value.step, value.skill].filter((key) => key !== void 0) : [];
|
|
541
|
-
if (!isRecord(value) || name === void 0 || keys.length !== 1) {
|
|
542
|
-
issues.push(
|
|
543
|
-
configIssue(configPath, `routing[${index}] must have exactly one non-empty step or skill.`)
|
|
544
|
-
);
|
|
545
|
-
continue;
|
|
546
|
-
}
|
|
547
|
-
if (seen.has(name)) {
|
|
548
|
-
issues.push(configIssue(configPath, `routing has duplicate entry ${name}.`));
|
|
549
|
-
continue;
|
|
550
|
-
}
|
|
551
|
-
seen.add(name);
|
|
552
|
-
entries.push(
|
|
553
|
-
isNonEmptyString(value.step) ? { ...value, step: name } : { ...value, skill: name }
|
|
554
|
-
);
|
|
555
|
-
}
|
|
556
|
-
return entries;
|
|
557
|
-
}
|
|
558
|
-
function normalizeReviewProfiles(raw, configPath, issues) {
|
|
559
|
-
if (raw === void 0) return void 0;
|
|
560
|
-
if (!isRecord(raw)) {
|
|
561
|
-
issues.push(
|
|
562
|
-
configIssue(configPath, "reviewProfiles must be a map of profile names to entries.")
|
|
563
|
-
);
|
|
564
|
-
return void 0;
|
|
565
|
-
}
|
|
566
|
-
const profiles = {};
|
|
567
|
-
for (const [name, value] of Object.entries(raw)) {
|
|
568
|
-
if (!isNonEmptyString(name) || !isRecord(value)) {
|
|
569
|
-
issues.push(configIssue(configPath, `reviewProfiles.${name} must be an entry.`));
|
|
570
|
-
continue;
|
|
571
|
-
}
|
|
572
|
-
profiles[name] = { ...value };
|
|
573
|
-
}
|
|
574
|
-
return profiles;
|
|
575
|
-
}
|
|
576
515
|
function normalizePaths(raw, configPath, issues) {
|
|
577
516
|
const base = defaultConfig.paths;
|
|
578
517
|
if (!raw) {
|
|
@@ -1119,9 +1058,6 @@ async function exists(target) {
|
|
|
1119
1058
|
function isRecord(value) {
|
|
1120
1059
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1121
1060
|
}
|
|
1122
|
-
function isNonEmptyString(value) {
|
|
1123
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
1124
|
-
}
|
|
1125
1061
|
|
|
1126
1062
|
// src/core/fs.ts
|
|
1127
1063
|
import { access as access2, readdir } from "fs/promises";
|
|
@@ -4436,23 +4372,23 @@ async function collectTexts(directory, files, specsDir, errors) {
|
|
|
4436
4372
|
const file = path9.join(directory, entry.name);
|
|
4437
4373
|
const registerPath = file === path9.join(specsDir, "decisions.md") || file === path9.join(specsDir, "decisions") || file.startsWith(`${path9.join(specsDir, "decisions")}${path9.sep}`);
|
|
4438
4374
|
if (registerPath) {
|
|
4439
|
-
const
|
|
4375
|
+
const stat20 = await fs.lstat(file).catch((error2) => {
|
|
4440
4376
|
errors.push({
|
|
4441
4377
|
file,
|
|
4442
4378
|
message: `Unreadable decision path: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
4443
4379
|
});
|
|
4444
4380
|
return void 0;
|
|
4445
4381
|
});
|
|
4446
|
-
if (!
|
|
4382
|
+
if (!stat20) {
|
|
4447
4383
|
files.set(file, "");
|
|
4448
4384
|
continue;
|
|
4449
4385
|
}
|
|
4450
|
-
if (
|
|
4386
|
+
if (stat20.isSymbolicLink() || stat20.isFile() && stat20.nlink > 1 || !stat20.isFile() && !stat20.isDirectory()) {
|
|
4451
4387
|
files.set(file, "");
|
|
4452
4388
|
errors.push({ file, message: "Linked or nonregular decision path" });
|
|
4453
4389
|
continue;
|
|
4454
4390
|
}
|
|
4455
|
-
if (
|
|
4391
|
+
if (stat20.isDirectory() && file !== path9.join(specsDir, "decisions")) files.set(file, "");
|
|
4456
4392
|
}
|
|
4457
4393
|
if (entry.isDirectory()) await collectTexts(file, files, specsDir, errors);
|
|
4458
4394
|
else if (entry.isFile()) {
|
|
@@ -5923,8 +5859,7 @@ function parseSkillFrontmatter(content) {
|
|
|
5923
5859
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
5924
5860
|
return { parseError: "frontmatter must parse to an object" };
|
|
5925
5861
|
}
|
|
5926
|
-
|
|
5927
|
-
return { ...readDeclaredRoles(root.roles), ...readDeclaredProfile(root["routing-profile"]) };
|
|
5862
|
+
return {};
|
|
5928
5863
|
}
|
|
5929
5864
|
function skillFrontmatterMapping(content) {
|
|
5930
5865
|
const raw = content.match(FRONTMATTER_PATTERN)?.[1];
|
|
@@ -5938,31 +5873,6 @@ function skillFrontmatterMapping(content) {
|
|
|
5938
5873
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return void 0;
|
|
5939
5874
|
return { ...parsed };
|
|
5940
5875
|
}
|
|
5941
|
-
function readDeclaredProfile(profile) {
|
|
5942
|
-
if (profile === void 0) {
|
|
5943
|
-
return {};
|
|
5944
|
-
}
|
|
5945
|
-
if (typeof profile !== "string" || profile.trim().length === 0) {
|
|
5946
|
-
return { profileError: "frontmatter.routing-profile must be a non-empty profile name" };
|
|
5947
|
-
}
|
|
5948
|
-
return { routingProfile: profile.trim() };
|
|
5949
|
-
}
|
|
5950
|
-
function readDeclaredRoles(roles) {
|
|
5951
|
-
if (roles === void 0) {
|
|
5952
|
-
return {};
|
|
5953
|
-
}
|
|
5954
|
-
if (!Array.isArray(roles)) {
|
|
5955
|
-
return { rolesError: "frontmatter.roles must be a list of agent ids" };
|
|
5956
|
-
}
|
|
5957
|
-
const names = [];
|
|
5958
|
-
for (const entry of roles) {
|
|
5959
|
-
if (typeof entry !== "string" || entry.trim().length === 0) {
|
|
5960
|
-
return { rolesError: "frontmatter.roles must contain only non-empty agent ids" };
|
|
5961
|
-
}
|
|
5962
|
-
names.push(entry.trim());
|
|
5963
|
-
}
|
|
5964
|
-
return { roles: names };
|
|
5965
|
-
}
|
|
5966
5876
|
|
|
5967
5877
|
// src/core/contracts/screenContracts.ts
|
|
5968
5878
|
import path15 from "path";
|
|
@@ -7454,10 +7364,7 @@ function toPosixPath2(value) {
|
|
|
7454
7364
|
}
|
|
7455
7365
|
|
|
7456
7366
|
// src/core/prototyping/policy.ts
|
|
7457
|
-
var PROTOTYPING_REQUIRED_ROLE_IDS = [
|
|
7458
|
-
"product-experience-architect",
|
|
7459
|
-
"product-surface-reviewer"
|
|
7460
|
-
];
|
|
7367
|
+
var PROTOTYPING_REQUIRED_ROLE_IDS = ["product-surface-reviewer"];
|
|
7461
7368
|
var PROTOTYPING_ROLE_WRAPPER_INTEGRATIONS = [
|
|
7462
7369
|
{ id: "claude", dir: ".claude/agents", suffix: ".md", label: "Claude Code" },
|
|
7463
7370
|
{ id: "github", dir: ".github/agents", suffix: ".agent.md", label: "GitHub Copilot" }
|
|
@@ -10048,18 +9955,8 @@ import { parse as parseYaml7 } from "yaml";
|
|
|
10048
9955
|
// src/core/emittedRuleCodes.ts
|
|
10049
9956
|
var EMITTED_RULE_CODES = [
|
|
10050
9957
|
"QFAI-AGENT-005",
|
|
10051
|
-
"QFAI-AGENT-007",
|
|
10052
|
-
"QFAI-AGENT-008",
|
|
10053
|
-
"QFAI-AGENT-009",
|
|
10054
|
-
"QFAI-AGENT-010",
|
|
10055
9958
|
"QFAI-AGENT-011",
|
|
10056
9959
|
"QFAI-AGENT-012",
|
|
10057
|
-
"QFAI-AGENT-013",
|
|
10058
|
-
"QFAI-AGENT-015",
|
|
10059
|
-
"QFAI-AGENT-016",
|
|
10060
|
-
"QFAI-AGENT-017",
|
|
10061
|
-
"QFAI-AGENT-018",
|
|
10062
|
-
"QFAI-AGENT-019",
|
|
10063
9960
|
"QFAI-ASSETS-001",
|
|
10064
9961
|
"QFAI-ASSETS-002",
|
|
10065
9962
|
"QFAI-ASSETS-003",
|
|
@@ -10262,17 +10159,8 @@ var EMITTED_RULE_CODES = [
|
|
|
10262
10159
|
];
|
|
10263
10160
|
var ERROR_ONLY_RULE_CODES = [
|
|
10264
10161
|
"QFAI-AGENT-005",
|
|
10265
|
-
"QFAI-AGENT-007",
|
|
10266
|
-
"QFAI-AGENT-008",
|
|
10267
|
-
"QFAI-AGENT-009",
|
|
10268
|
-
"QFAI-AGENT-010",
|
|
10269
10162
|
"QFAI-AGENT-011",
|
|
10270
10163
|
"QFAI-AGENT-012",
|
|
10271
|
-
"QFAI-AGENT-013",
|
|
10272
|
-
"QFAI-AGENT-015",
|
|
10273
|
-
"QFAI-AGENT-016",
|
|
10274
|
-
"QFAI-AGENT-017",
|
|
10275
|
-
"QFAI-AGENT-018",
|
|
10276
10164
|
"QFAI-ASSETS-001",
|
|
10277
10165
|
"QFAI-ASSETS-002",
|
|
10278
10166
|
"QFAI-ASSETS-003",
|
|
@@ -11220,8 +11108,8 @@ import { readFile as readFile10, realpath as realpath4 } from "fs/promises";
|
|
|
11220
11108
|
import path26 from "path";
|
|
11221
11109
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
11222
11110
|
async function resolveToolVersion() {
|
|
11223
|
-
if ("2.
|
|
11224
|
-
return "2.
|
|
11111
|
+
if ("2.3.0".length > 0) {
|
|
11112
|
+
return "2.3.0";
|
|
11225
11113
|
}
|
|
11226
11114
|
try {
|
|
11227
11115
|
const packagePath = await resolvePackageJsonPath();
|
|
@@ -16558,7 +16446,7 @@ function facts(column) {
|
|
|
16558
16446
|
|
|
16559
16447
|
// src/cli/commands/init.ts
|
|
16560
16448
|
import path72 from "path";
|
|
16561
|
-
import { randomUUID as
|
|
16449
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
16562
16450
|
import { constants as constants6 } from "fs";
|
|
16563
16451
|
import {
|
|
16564
16452
|
lstat as lstat21,
|
|
@@ -18075,7 +17963,7 @@ async function writeReminderHooks(plan) {
|
|
|
18075
17963
|
}
|
|
18076
17964
|
|
|
18077
17965
|
// src/core/graph/prepare.ts
|
|
18078
|
-
import {
|
|
17966
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
18079
17967
|
import { access as access15, cp, mkdir as mkdir11, rm as rm9 } from "fs/promises";
|
|
18080
17968
|
import os2 from "os";
|
|
18081
17969
|
import path61 from "path";
|
|
@@ -18098,7 +17986,12 @@ function graphEnvironmentKey(environment = graphExecutionEnvironment()) {
|
|
|
18098
17986
|
return `${environment.platform}-${environment.architecture}`;
|
|
18099
17987
|
}
|
|
18100
17988
|
function graphRuntimePaths(root, environment = graphExecutionEnvironment()) {
|
|
18101
|
-
|
|
17989
|
+
return graphRuntimeFiles(
|
|
17990
|
+
path57.join(root, ".qfai", "tools", "runtimes", graphEnvironmentKey(environment)),
|
|
17991
|
+
environment
|
|
17992
|
+
);
|
|
17993
|
+
}
|
|
17994
|
+
function graphRuntimeFiles(directory, environment = graphExecutionEnvironment()) {
|
|
18102
17995
|
return {
|
|
18103
17996
|
directory,
|
|
18104
17997
|
codegraph: path57.join(
|
|
@@ -18257,7 +18150,14 @@ var runGraphProcess = async (command, args, options) => {
|
|
|
18257
18150
|
return { exitCode: 0, stdout: result.stdout };
|
|
18258
18151
|
} catch (cause) {
|
|
18259
18152
|
if (!(cause instanceof Error) || !("code" in cause)) throw cause;
|
|
18260
|
-
|
|
18153
|
+
const signal = "signal" in cause && typeof cause.signal === "string" ? cause.signal : void 0;
|
|
18154
|
+
const failure2 = signal ? `was stopped (${signal})` : typeof cause.code === "string" ? `could not start (${cause.code})` : void 0;
|
|
18155
|
+
return {
|
|
18156
|
+
exitCode: typeof cause.code === "number" ? cause.code : 1,
|
|
18157
|
+
stdout: "",
|
|
18158
|
+
...failure2 ? { failure: failure2 } : {},
|
|
18159
|
+
...options.captureStderr && "stderr" in cause && typeof cause.stderr === "string" ? { stderr: cause.stderr } : {}
|
|
18160
|
+
};
|
|
18261
18161
|
}
|
|
18262
18162
|
};
|
|
18263
18163
|
async function npmCommand() {
|
|
@@ -18418,9 +18318,10 @@ async function prepareGraphRuntimes(root, run2 = runGraphProcess) {
|
|
|
18418
18318
|
documents: "documents-not-ready"
|
|
18419
18319
|
};
|
|
18420
18320
|
}
|
|
18421
|
-
const
|
|
18422
|
-
|
|
18423
|
-
|
|
18321
|
+
const staged = graphRuntimeFiles(
|
|
18322
|
+
path61.join(path61.dirname(current.directory), `.p-${randomBytes2(4).toString("hex")}`)
|
|
18323
|
+
);
|
|
18324
|
+
await assertGraphStoragePath(root, staged.directory);
|
|
18424
18325
|
const notReady = {
|
|
18425
18326
|
runtime: "not-ready",
|
|
18426
18327
|
tools: {
|
|
@@ -18431,7 +18332,8 @@ async function prepareGraphRuntimes(root, run2 = runGraphProcess) {
|
|
|
18431
18332
|
documents: "documents-not-ready",
|
|
18432
18333
|
previousInstallation: codegraphReady || graphifyReady ? "retained" : "none"
|
|
18433
18334
|
};
|
|
18434
|
-
await mkdir11(staged.directory, { recursive: true });
|
|
18335
|
+
await mkdir11(path61.dirname(staged.directory), { recursive: true });
|
|
18336
|
+
await mkdir11(staged.directory);
|
|
18435
18337
|
try {
|
|
18436
18338
|
if (codegraphReady) {
|
|
18437
18339
|
await cp(
|
|
@@ -18474,10 +18376,15 @@ async function prepareGraphRuntimes(root, run2 = runGraphProcess) {
|
|
|
18474
18376
|
};
|
|
18475
18377
|
const codeVersion = await run2(process.execPath, [staged.codegraph, "--version"], {
|
|
18476
18378
|
cwd: root,
|
|
18477
|
-
env
|
|
18379
|
+
env,
|
|
18380
|
+
captureStderr: true
|
|
18478
18381
|
});
|
|
18479
18382
|
if (codeVersion.exitCode !== 0 || codeVersion.stdout.trim() !== GRAPH_VERSIONS.codegraph) {
|
|
18480
|
-
return {
|
|
18383
|
+
return {
|
|
18384
|
+
...notReady,
|
|
18385
|
+
failedStep: "CodeGraph compatibility",
|
|
18386
|
+
recovery: versionCheckRecovery("CodeGraph", codeVersion, GRAPH_VERSIONS.codegraph, root)
|
|
18387
|
+
};
|
|
18481
18388
|
}
|
|
18482
18389
|
}
|
|
18483
18390
|
if (graphifyReady) {
|
|
@@ -18536,10 +18443,19 @@ async function prepareGraphRuntimes(root, run2 = runGraphProcess) {
|
|
|
18536
18443
|
"-c",
|
|
18537
18444
|
'from importlib.metadata import version; print(version("graphifyy"))'
|
|
18538
18445
|
],
|
|
18539
|
-
{ cwd: root, env: pythonEnvironment }
|
|
18446
|
+
{ cwd: root, env: pythonEnvironment, captureStderr: true }
|
|
18540
18447
|
);
|
|
18541
18448
|
if (graphifyVersion.exitCode !== 0 || graphifyVersion.stdout.trim() !== GRAPH_VERSIONS.graphify) {
|
|
18542
|
-
return {
|
|
18449
|
+
return {
|
|
18450
|
+
...notReady,
|
|
18451
|
+
failedStep: "Graphify compatibility",
|
|
18452
|
+
recovery: versionCheckRecovery(
|
|
18453
|
+
"Graphify",
|
|
18454
|
+
graphifyVersion,
|
|
18455
|
+
GRAPH_VERSIONS.graphify,
|
|
18456
|
+
root
|
|
18457
|
+
)
|
|
18458
|
+
};
|
|
18543
18459
|
}
|
|
18544
18460
|
}
|
|
18545
18461
|
await replaceGraphDirectory(staged.directory, current.directory, root);
|
|
@@ -18550,8 +18466,31 @@ async function prepareGraphRuntimes(root, run2 = runGraphProcess) {
|
|
|
18550
18466
|
documents: "documents-not-ready"
|
|
18551
18467
|
};
|
|
18552
18468
|
} finally {
|
|
18553
|
-
await rm9(
|
|
18554
|
-
}
|
|
18469
|
+
await rm9(staged.directory, { recursive: true, force: true });
|
|
18470
|
+
}
|
|
18471
|
+
}
|
|
18472
|
+
var CAUSE_LINES = 5;
|
|
18473
|
+
var CAUSE_CHARACTERS = 500;
|
|
18474
|
+
var STAGED_TOOL_DEPTH = 166;
|
|
18475
|
+
var WINDOWS_PATH_LIMIT = 260;
|
|
18476
|
+
var WINDOWS_PATH_MARGIN = 20;
|
|
18477
|
+
function versionCheckRecovery(engine, result, expected, root) {
|
|
18478
|
+
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}.`;
|
|
18479
|
+
const pathLimit = windowsPathLimitRecovery(root);
|
|
18480
|
+
return pathLimit ? `${cause}
|
|
18481
|
+
${pathLimit}` : cause;
|
|
18482
|
+
}
|
|
18483
|
+
function shownOutput(text3, prefix) {
|
|
18484
|
+
const lines = (text3 ?? "").split(/\r?\n/).map((line) => line.replaceAll(" ", " ").trim()).filter((line) => line.length > 0).slice(0, CAUSE_LINES).join(" | ");
|
|
18485
|
+
if (lines.length === 0) return "";
|
|
18486
|
+
const bounded = lines.length > CAUSE_CHARACTERS ? `${lines.slice(0, CAUSE_CHARACTERS)}...` : lines;
|
|
18487
|
+
return `${prefix}${formatReportPath(bounded)}`;
|
|
18488
|
+
}
|
|
18489
|
+
function windowsPathLimitRecovery(root, platform = process.platform) {
|
|
18490
|
+
if (platform !== "win32") return void 0;
|
|
18491
|
+
const longest = root.length + STAGED_TOOL_DEPTH;
|
|
18492
|
+
if (longest < WINDOWS_PATH_LIMIT - WINDOWS_PATH_MARGIN) return void 0;
|
|
18493
|
+
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.`;
|
|
18555
18494
|
}
|
|
18556
18495
|
function rerunByHand(engine, command) {
|
|
18557
18496
|
const raw = path61.join(os2.tmpdir(), "qfai-graph-check", engine);
|
|
@@ -19013,17 +18952,17 @@ async function prepareGraphIntegration(root, run2 = runGraphProcess) {
|
|
|
19013
18952
|
|
|
19014
18953
|
// src/core/graph/documents.ts
|
|
19015
18954
|
import { mkdir as mkdir18, readFile as readFile33, rm as rm12, writeFile as writeFile14 } from "fs/promises";
|
|
19016
|
-
import { randomUUID as
|
|
18955
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
19017
18956
|
|
|
19018
18957
|
// src/core/graph/documentReuse.ts
|
|
19019
|
-
import { randomUUID as
|
|
18958
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
19020
18959
|
import { cp as cp3, lstat as lstat19, mkdir as mkdir16, readdir as readdir20, rename as rename6, rm as rm11, writeFile as writeFile13 } from "fs/promises";
|
|
19021
18960
|
import path68 from "path";
|
|
19022
18961
|
|
|
19023
18962
|
// src/core/graph/reuse.ts
|
|
19024
18963
|
import os3 from "os";
|
|
19025
18964
|
import path67 from "path";
|
|
19026
|
-
import { randomUUID as
|
|
18965
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
19027
18966
|
import {
|
|
19028
18967
|
cp as cp2,
|
|
19029
18968
|
lstat as lstat18,
|
|
@@ -19037,7 +18976,7 @@ import {
|
|
|
19037
18976
|
} from "fs/promises";
|
|
19038
18977
|
|
|
19039
18978
|
// src/core/graph/locks.ts
|
|
19040
|
-
import { randomUUID as
|
|
18979
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
19041
18980
|
import { unlink as unlink2 } from "fs/promises";
|
|
19042
18981
|
import path70 from "path";
|
|
19043
18982
|
|
|
@@ -19589,7 +19528,7 @@ async function aimTestFileGlobsAtRepository(root, configPath) {
|
|
|
19589
19528
|
}
|
|
19590
19529
|
async function writeConfigByRename(target, content) {
|
|
19591
19530
|
const { mode } = await stat12(target);
|
|
19592
|
-
const temp = path72.join(path72.dirname(target), `.${path72.basename(target)}.${
|
|
19531
|
+
const temp = path72.join(path72.dirname(target), `.${path72.basename(target)}.${randomUUID7()}.tmp`);
|
|
19593
19532
|
try {
|
|
19594
19533
|
const handle = await open9(
|
|
19595
19534
|
temp,
|
|
@@ -20560,8 +20499,8 @@ function buildCopilotInstructions() {
|
|
|
20560
20499
|
}
|
|
20561
20500
|
|
|
20562
20501
|
// src/cli/commands/report.ts
|
|
20563
|
-
import { mkdir as mkdir23, readFile as
|
|
20564
|
-
import
|
|
20502
|
+
import { mkdir as mkdir23, readFile as readFile66, writeFile as writeFile19 } from "fs/promises";
|
|
20503
|
+
import path130 from "path";
|
|
20565
20504
|
|
|
20566
20505
|
// src/core/normalize.ts
|
|
20567
20506
|
function normalizeIssuePaths(root, issues) {
|
|
@@ -20809,8 +20748,8 @@ async function writeBusinessFlowReports(root, config, flowIds) {
|
|
|
20809
20748
|
}
|
|
20810
20749
|
|
|
20811
20750
|
// src/core/validate.ts
|
|
20812
|
-
import
|
|
20813
|
-
import { readdir as
|
|
20751
|
+
import path127 from "path";
|
|
20752
|
+
import { readdir as readdir35 } from "fs/promises";
|
|
20814
20753
|
|
|
20815
20754
|
// src/core/validators/storyTreeStructure.ts
|
|
20816
20755
|
import { readFile as readFile36, readdir as readdir23 } from "fs/promises";
|
|
@@ -25057,8 +24996,7 @@ async function validateStepTree(root, config) {
|
|
|
25057
24996
|
...[...parents.values()].flatMap(
|
|
25058
24997
|
(parent) => requiresListIssues(parent.rel, parent.requires, tree)
|
|
25059
24998
|
),
|
|
25060
|
-
...orphanIssues(tree)
|
|
25061
|
-
...parentRolesIssues(tree)
|
|
24999
|
+
...orphanIssues(tree)
|
|
25062
25000
|
];
|
|
25063
25001
|
}
|
|
25064
25002
|
function finding2(message, file, rule2) {
|
|
@@ -25108,8 +25046,7 @@ async function readParents(root, skillsDir, entries) {
|
|
|
25108
25046
|
name: entry.name,
|
|
25109
25047
|
rel,
|
|
25110
25048
|
steps,
|
|
25111
|
-
requires: mapping?.requires ?? []
|
|
25112
|
-
roles: mapping?.roles
|
|
25049
|
+
requires: mapping?.requires ?? []
|
|
25113
25050
|
});
|
|
25114
25051
|
}
|
|
25115
25052
|
}
|
|
@@ -25275,30 +25212,6 @@ function orphanIssues(tree) {
|
|
|
25275
25212
|
)
|
|
25276
25213
|
);
|
|
25277
25214
|
}
|
|
25278
|
-
function stringList2(value) {
|
|
25279
|
-
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
25280
|
-
}
|
|
25281
|
-
function parentRolesIssues(tree) {
|
|
25282
|
-
const rolesOf = new Map(
|
|
25283
|
-
tree.steps.map((step) => [step.dir, stringList2(step.frontmatter?.roles)])
|
|
25284
|
-
);
|
|
25285
|
-
return [...tree.parents.values()].flatMap((parent) => {
|
|
25286
|
-
const declared = new Set(stringList2(parent.roles));
|
|
25287
|
-
const needed = /* @__PURE__ */ new Set([
|
|
25288
|
-
"orchestrator",
|
|
25289
|
-
...stringList2(parent.steps).flatMap((name) => rolesOf.get(name) ?? [])
|
|
25290
|
-
]);
|
|
25291
|
-
const missing = [...needed].filter((role) => !declared.has(role)).sort();
|
|
25292
|
-
if (missing.length === 0) return [];
|
|
25293
|
-
return [
|
|
25294
|
-
finding2(
|
|
25295
|
-
`${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.`,
|
|
25296
|
-
parent.rel,
|
|
25297
|
-
"parentRolesMissing"
|
|
25298
|
-
)
|
|
25299
|
-
];
|
|
25300
|
-
});
|
|
25301
|
-
}
|
|
25302
25215
|
|
|
25303
25216
|
// src/core/validators/assistantAnchorReferences.ts
|
|
25304
25217
|
import { readdir as readdir27, readFile as readFile48, realpath as realpath11, stat as stat13 } from "fs/promises";
|
|
@@ -26383,7 +26296,7 @@ function collectLayer(layer, layerName, target, errors) {
|
|
|
26383
26296
|
}
|
|
26384
26297
|
function flattenTokens(obj, prefix, target, errors) {
|
|
26385
26298
|
for (const [key, value] of Object.entries(obj)) {
|
|
26386
|
-
const
|
|
26299
|
+
const path138 = `${prefix}.${key}`;
|
|
26387
26300
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
26388
26301
|
const record2 = value;
|
|
26389
26302
|
if ("$value" in record2) {
|
|
@@ -26399,9 +26312,9 @@ function flattenTokens(obj, prefix, target, errors) {
|
|
|
26399
26312
|
if (typeof record2.platform === "string") {
|
|
26400
26313
|
token2.platform = record2.platform;
|
|
26401
26314
|
}
|
|
26402
|
-
target.set(
|
|
26315
|
+
target.set(path138, token2);
|
|
26403
26316
|
} else {
|
|
26404
|
-
flattenTokens(record2,
|
|
26317
|
+
flattenTokens(record2, path138, target, errors);
|
|
26405
26318
|
}
|
|
26406
26319
|
}
|
|
26407
26320
|
}
|
|
@@ -26411,44 +26324,44 @@ function resolveAllReferences(result) {
|
|
|
26411
26324
|
for (const [key, val] of result.primitives) allTokens.set(key, val);
|
|
26412
26325
|
for (const [key, val] of result.semantics) allTokens.set(key, val);
|
|
26413
26326
|
for (const [key, val] of result.components) allTokens.set(key, val);
|
|
26414
|
-
for (const [
|
|
26415
|
-
resolveTokenRef(
|
|
26327
|
+
for (const [path138] of allTokens) {
|
|
26328
|
+
resolveTokenRef(path138, allTokens, /* @__PURE__ */ new Set(), 0, result);
|
|
26416
26329
|
}
|
|
26417
26330
|
}
|
|
26418
|
-
function resolveTokenRef(
|
|
26419
|
-
if (result.resolved.has(
|
|
26420
|
-
return result.resolved.get(
|
|
26331
|
+
function resolveTokenRef(path138, allTokens, visited, depth, result) {
|
|
26332
|
+
if (result.resolved.has(path138)) {
|
|
26333
|
+
return result.resolved.get(path138);
|
|
26421
26334
|
}
|
|
26422
26335
|
if (depth > MAX_RESOLVE_DEPTH) {
|
|
26423
26336
|
result.errors.push({
|
|
26424
|
-
message: `Max reference depth exceeded at: ${
|
|
26425
|
-
path:
|
|
26337
|
+
message: `Max reference depth exceeded at: ${path138}`,
|
|
26338
|
+
path: path138
|
|
26426
26339
|
});
|
|
26427
26340
|
return void 0;
|
|
26428
26341
|
}
|
|
26429
|
-
if (visited.has(
|
|
26342
|
+
if (visited.has(path138)) {
|
|
26430
26343
|
result.errors.push({
|
|
26431
|
-
message: `Circular reference detected: ${
|
|
26432
|
-
path:
|
|
26344
|
+
message: `Circular reference detected: ${path138}`,
|
|
26345
|
+
path: path138
|
|
26433
26346
|
});
|
|
26434
26347
|
return void 0;
|
|
26435
26348
|
}
|
|
26436
|
-
const token2 = allTokens.get(
|
|
26349
|
+
const token2 = allTokens.get(path138);
|
|
26437
26350
|
if (!token2) {
|
|
26438
26351
|
return void 0;
|
|
26439
26352
|
}
|
|
26440
26353
|
if (typeof token2.$value !== "string") {
|
|
26441
26354
|
const rawValue2 = stringifyTokenValue(token2.$value);
|
|
26442
|
-
result.resolved.set(
|
|
26355
|
+
result.resolved.set(path138, rawValue2);
|
|
26443
26356
|
return rawValue2;
|
|
26444
26357
|
}
|
|
26445
26358
|
const rawValue = stringifyTokenValue(token2.$value);
|
|
26446
26359
|
const refs = [...rawValue.matchAll(REF_PATTERN)];
|
|
26447
26360
|
if (refs.length === 0) {
|
|
26448
|
-
result.resolved.set(
|
|
26361
|
+
result.resolved.set(path138, rawValue);
|
|
26449
26362
|
return rawValue;
|
|
26450
26363
|
}
|
|
26451
|
-
visited.add(
|
|
26364
|
+
visited.add(path138);
|
|
26452
26365
|
let resolved = rawValue;
|
|
26453
26366
|
for (const ref of refs) {
|
|
26454
26367
|
const refPath = ref[1];
|
|
@@ -26456,8 +26369,8 @@ function resolveTokenRef(path140, allTokens, visited, depth, result) {
|
|
|
26456
26369
|
const refToken = allTokens.get(refPath);
|
|
26457
26370
|
if (!refToken) {
|
|
26458
26371
|
result.errors.push({
|
|
26459
|
-
message: `Unresolved token reference: {${refPath}} at ${
|
|
26460
|
-
path:
|
|
26372
|
+
message: `Unresolved token reference: {${refPath}} at ${path138}`,
|
|
26373
|
+
path: path138
|
|
26461
26374
|
});
|
|
26462
26375
|
continue;
|
|
26463
26376
|
}
|
|
@@ -26466,7 +26379,7 @@ function resolveTokenRef(path140, allTokens, visited, depth, result) {
|
|
|
26466
26379
|
resolved = resolved.split(`{${refPath}}`).join(refValue);
|
|
26467
26380
|
}
|
|
26468
26381
|
}
|
|
26469
|
-
result.resolved.set(
|
|
26382
|
+
result.resolved.set(path138, resolved);
|
|
26470
26383
|
return resolved;
|
|
26471
26384
|
}
|
|
26472
26385
|
function stringifyTokenValue(value) {
|
|
@@ -28132,305 +28045,8 @@ function resolveFreshnessReferenceNow() {
|
|
|
28132
28045
|
}
|
|
28133
28046
|
|
|
28134
28047
|
// src/core/validators/agentDefinition.ts
|
|
28135
|
-
import { readFile as readFile61, readdir as readdir31 } from "fs/promises";
|
|
28136
|
-
import path108 from "path";
|
|
28137
|
-
import { parse as parseYaml18 } from "yaml";
|
|
28138
|
-
|
|
28139
|
-
// src/core/routingDefaults.ts
|
|
28140
28048
|
import { readFile as readFile59, readdir as readdir29 } from "fs/promises";
|
|
28141
28049
|
import path106 from "path";
|
|
28142
|
-
var ROUTING_DEFAULTS_REL = "packages/qfai/assets/defaults/agent-routing";
|
|
28143
|
-
function routingDefaultsDir() {
|
|
28144
|
-
return path106.resolve(getInitAssetsDir(), "..", "defaults", "agent-routing");
|
|
28145
|
-
}
|
|
28146
|
-
async function readRoutingDefaultsFiles() {
|
|
28147
|
-
const dir = routingDefaultsDir();
|
|
28148
|
-
const names = (await readdir29(dir)).filter((name) => name.endsWith(".yml")).sort();
|
|
28149
|
-
return Promise.all(
|
|
28150
|
-
names.map(async (name) => ({
|
|
28151
|
-
rel: `${ROUTING_DEFAULTS_REL}/${name}`,
|
|
28152
|
-
text: await readFile59(path106.join(dir, name), "utf-8")
|
|
28153
|
-
}))
|
|
28154
|
-
);
|
|
28155
|
-
}
|
|
28156
|
-
|
|
28157
|
-
// src/core/validators/skillRoles.ts
|
|
28158
|
-
import { readdir as readdir30, readFile as readFile60, stat as stat18 } from "fs/promises";
|
|
28159
|
-
import path107 from "path";
|
|
28160
|
-
var MANIFEST_EXTERNAL_ROLES = /* @__PURE__ */ new Set(["orchestrator"]);
|
|
28161
|
-
function emptySkillRouting(kind = "skill") {
|
|
28162
|
-
return { kind, agents: /* @__PURE__ */ new Map(), phases: 0 };
|
|
28163
|
-
}
|
|
28164
|
-
function recordRoutedAgents(entry, value, binding, known) {
|
|
28165
|
-
if (!Array.isArray(value)) {
|
|
28166
|
-
return 0;
|
|
28167
|
-
}
|
|
28168
|
-
let usable = 0;
|
|
28169
|
-
for (const agent of value) {
|
|
28170
|
-
if (typeof agent !== "string" || agent.length === 0) {
|
|
28171
|
-
continue;
|
|
28172
|
-
}
|
|
28173
|
-
usable += 1;
|
|
28174
|
-
if (known && !known.has(agent)) {
|
|
28175
|
-
continue;
|
|
28176
|
-
}
|
|
28177
|
-
if (binding === "required" || !entry.agents.has(agent)) {
|
|
28178
|
-
entry.agents.set(agent, binding);
|
|
28179
|
-
}
|
|
28180
|
-
}
|
|
28181
|
-
return usable;
|
|
28182
|
-
}
|
|
28183
|
-
async function validateSkillRoles(root, config, routing, profiles, issues) {
|
|
28184
|
-
const skillsDir = resolvePath(root, config, "skillsDir");
|
|
28185
|
-
const crossCheckSeverity = "error";
|
|
28186
|
-
for (const [skill, entry] of routing) {
|
|
28187
|
-
const skillPath = entry.kind === "step" ? joinAssistantLayer(root, "step", skill, "STEP.md") : path107.join(skillsDir, skill, "SKILL.md");
|
|
28188
|
-
const rel = path107.relative(root, skillPath).replace(/\\/g, "/");
|
|
28189
|
-
let gate = reportManifestGateDefects(skill, entry, profiles, rel, issues, crossCheckSeverity);
|
|
28190
|
-
if (entry.phases === 0) {
|
|
28191
|
-
continue;
|
|
28192
|
-
}
|
|
28193
|
-
const frontmatter = await readSkillFrontmatter(skillPath);
|
|
28194
|
-
if (!frontmatter) {
|
|
28195
|
-
continue;
|
|
28196
|
-
}
|
|
28197
|
-
if (frontmatter.parseError) {
|
|
28198
|
-
issues.push(unreadableFrontmatter(rel, skill, frontmatter.parseError, crossCheckSeverity));
|
|
28199
|
-
continue;
|
|
28200
|
-
}
|
|
28201
|
-
gate = reportSkillGateDefects(skill, entry, frontmatter, rel, issues, crossCheckSeverity) && gate;
|
|
28202
|
-
if (frontmatter.rolesError) {
|
|
28203
|
-
issues.push(
|
|
28204
|
-
issue(
|
|
28205
|
-
"QFAI-AGENT-016",
|
|
28206
|
-
`${rel} declares an unusable roles: frontmatter (${frontmatter.rolesError}); the ${skill} routing cross-check cannot run.`,
|
|
28207
|
-
crossCheckSeverity,
|
|
28208
|
-
rel,
|
|
28209
|
-
"agentDefinition.invalidSkillRoles"
|
|
28210
|
-
)
|
|
28211
|
-
);
|
|
28212
|
-
continue;
|
|
28213
|
-
}
|
|
28214
|
-
if (!frontmatter.roles || !gate) {
|
|
28215
|
-
continue;
|
|
28216
|
-
}
|
|
28217
|
-
const selected = collectSelections(skill, entry, profiles);
|
|
28218
|
-
reportUndeclaredRoutedAgents(selected, frontmatter.roles, rel, issues);
|
|
28219
|
-
reportUnselectableRoles(
|
|
28220
|
-
skill,
|
|
28221
|
-
selected,
|
|
28222
|
-
frontmatter.roles,
|
|
28223
|
-
entry.reviewProfile,
|
|
28224
|
-
rel,
|
|
28225
|
-
issues,
|
|
28226
|
-
crossCheckSeverity
|
|
28227
|
-
);
|
|
28228
|
-
}
|
|
28229
|
-
await reportUnroutedSkills(root, skillsDir, "SKILL.md", routing, issues, crossCheckSeverity);
|
|
28230
|
-
const stepsDir = joinAssistantLayer(root, "step");
|
|
28231
|
-
await reportUnroutedSkills(root, stepsDir, "STEP.md", routing, issues, crossCheckSeverity);
|
|
28232
|
-
}
|
|
28233
|
-
function unreadableFrontmatter(rel, skill, reason, crossCheckSeverity) {
|
|
28234
|
-
return issue(
|
|
28235
|
-
"QFAI-AGENT-016",
|
|
28236
|
-
`${rel} carries an unreadable frontmatter block (${reason}); the ${skill} routing cross-check cannot run.`,
|
|
28237
|
-
crossCheckSeverity,
|
|
28238
|
-
rel,
|
|
28239
|
-
"agentDefinition.unreadableSkillFrontmatter"
|
|
28240
|
-
);
|
|
28241
|
-
}
|
|
28242
|
-
async function readSkillFrontmatter(skillPath) {
|
|
28243
|
-
try {
|
|
28244
|
-
if (!(await stat18(skillPath)).isFile()) {
|
|
28245
|
-
return void 0;
|
|
28246
|
-
}
|
|
28247
|
-
return parseSkillFrontmatter(await readFile60(skillPath, "utf-8"));
|
|
28248
|
-
} catch {
|
|
28249
|
-
return void 0;
|
|
28250
|
-
}
|
|
28251
|
-
}
|
|
28252
|
-
function reportManifestGateDefects(skill, entry, profiles, rel, issues, crossCheckSeverity) {
|
|
28253
|
-
let trusted = true;
|
|
28254
|
-
if (entry.reviewProfileConflict) {
|
|
28255
|
-
const { first, second } = entry.reviewProfileConflict;
|
|
28256
|
-
issues.push(
|
|
28257
|
-
issue(
|
|
28258
|
-
"QFAI-AGENT-018",
|
|
28259
|
-
`The routing sends "${skill}" through two different review profiles ("${first}" and "${second}"); one skill has one review gate.`,
|
|
28260
|
-
crossCheckSeverity,
|
|
28261
|
-
rel,
|
|
28262
|
-
"agentDefinition.conflictingReviewProfile"
|
|
28263
|
-
)
|
|
28264
|
-
);
|
|
28265
|
-
trusted = false;
|
|
28266
|
-
}
|
|
28267
|
-
if (entry.reviewProfileUnusable) {
|
|
28268
|
-
return false;
|
|
28269
|
-
}
|
|
28270
|
-
const routed = entry.reviewProfile;
|
|
28271
|
-
if (routed === void 0) {
|
|
28272
|
-
return trusted;
|
|
28273
|
-
}
|
|
28274
|
-
const selection = profiles.get(routed);
|
|
28275
|
-
if (selection === void 0) {
|
|
28276
|
-
issues.push(
|
|
28277
|
-
issue(
|
|
28278
|
-
"QFAI-AGENT-018",
|
|
28279
|
-
`The routing sends "${skill}" through review profile "${routed}", which review-profiles.yml does not define.`,
|
|
28280
|
-
crossCheckSeverity,
|
|
28281
|
-
rel,
|
|
28282
|
-
"agentDefinition.unknownReviewProfile"
|
|
28283
|
-
)
|
|
28284
|
-
);
|
|
28285
|
-
return false;
|
|
28286
|
-
}
|
|
28287
|
-
return trusted && !selection.incomplete;
|
|
28288
|
-
}
|
|
28289
|
-
function reportSkillGateDefects(skill, entry, frontmatter, rel, issues, crossCheckSeverity) {
|
|
28290
|
-
if (frontmatter.profileError) {
|
|
28291
|
-
issues.push(
|
|
28292
|
-
issue(
|
|
28293
|
-
"QFAI-AGENT-016",
|
|
28294
|
-
`${rel} declares an unusable routing-profile: (${frontmatter.profileError}); the ${skill} review gate cannot be checked.`,
|
|
28295
|
-
crossCheckSeverity,
|
|
28296
|
-
rel,
|
|
28297
|
-
"agentDefinition.invalidRoutingProfile"
|
|
28298
|
-
)
|
|
28299
|
-
);
|
|
28300
|
-
return false;
|
|
28301
|
-
}
|
|
28302
|
-
const declared = frontmatter.routingProfile;
|
|
28303
|
-
if (declared === void 0) {
|
|
28304
|
-
return true;
|
|
28305
|
-
}
|
|
28306
|
-
if (entry.reviewProfileUnusable) {
|
|
28307
|
-
return false;
|
|
28308
|
-
}
|
|
28309
|
-
const routed = entry.reviewProfile;
|
|
28310
|
-
if (routed === declared) {
|
|
28311
|
-
return true;
|
|
28312
|
-
}
|
|
28313
|
-
const found = routed === void 0 ? "declares no review_profile" : `declares ${routed}`;
|
|
28314
|
-
issues.push(
|
|
28315
|
-
issue(
|
|
28316
|
-
"QFAI-AGENT-018",
|
|
28317
|
-
`${rel} declares routing-profile: ${declared} but the route for "${skill}" ${found}.`,
|
|
28318
|
-
crossCheckSeverity,
|
|
28319
|
-
rel,
|
|
28320
|
-
"agentDefinition.routingProfileMismatch"
|
|
28321
|
-
)
|
|
28322
|
-
);
|
|
28323
|
-
return false;
|
|
28324
|
-
}
|
|
28325
|
-
function collectSelections(skill, entry, profiles) {
|
|
28326
|
-
const selected = /* @__PURE__ */ new Map();
|
|
28327
|
-
for (const [agent, binding] of entry.agents) {
|
|
28328
|
-
selected.set(agent, {
|
|
28329
|
-
binding,
|
|
28330
|
-
source: `the routing binds it to ${skill} as ${binding}`
|
|
28331
|
-
});
|
|
28332
|
-
}
|
|
28333
|
-
const profileName = entry.reviewProfile;
|
|
28334
|
-
if (!profileName) {
|
|
28335
|
-
return selected;
|
|
28336
|
-
}
|
|
28337
|
-
for (const [reviewer, binding] of profiles.get(profileName)?.reviewers ?? []) {
|
|
28338
|
-
const prior = selected.get(reviewer);
|
|
28339
|
-
if (prior && (prior.binding === "required" || binding === "conditional")) {
|
|
28340
|
-
continue;
|
|
28341
|
-
}
|
|
28342
|
-
const clause2 = binding === "required" ? "always_required" : "conditional_required";
|
|
28343
|
-
selected.set(reviewer, {
|
|
28344
|
-
binding,
|
|
28345
|
-
source: `review profile "${profileName}" selects it as ${clause2}`
|
|
28346
|
-
});
|
|
28347
|
-
}
|
|
28348
|
-
return selected;
|
|
28349
|
-
}
|
|
28350
|
-
function reportUndeclaredRoutedAgents(selected, declared, rel, issues) {
|
|
28351
|
-
const declaredSet = new Set(declared);
|
|
28352
|
-
for (const [agent, selection] of selected) {
|
|
28353
|
-
if (declaredSet.has(agent)) {
|
|
28354
|
-
continue;
|
|
28355
|
-
}
|
|
28356
|
-
issues.push(
|
|
28357
|
-
issue(
|
|
28358
|
-
"QFAI-AGENT-019",
|
|
28359
|
-
`${rel} omits routed agent "${agent}" from roles: (${selection.source})`,
|
|
28360
|
-
// A `conditional` omission is a documentation gap and stays a warning;
|
|
28361
|
-
// a `required` one means a reviewer the profile mandates is not
|
|
28362
|
-
// reachable, which is a gate.
|
|
28363
|
-
selection.binding === "required" ? "error" : "warning",
|
|
28364
|
-
rel,
|
|
28365
|
-
"agentDefinition.routedAgentNotDeclared"
|
|
28366
|
-
)
|
|
28367
|
-
);
|
|
28368
|
-
}
|
|
28369
|
-
}
|
|
28370
|
-
function reportUnselectableRoles(skill, selected, declared, profileName, rel, issues, crossCheckSeverity) {
|
|
28371
|
-
const profileLabel = profileName ? `review profile "${profileName}"` : "declared review profile";
|
|
28372
|
-
for (const role of declared) {
|
|
28373
|
-
if (selected.has(role) || MANIFEST_EXTERNAL_ROLES.has(role)) {
|
|
28374
|
-
continue;
|
|
28375
|
-
}
|
|
28376
|
-
issues.push(
|
|
28377
|
-
issue(
|
|
28378
|
-
"QFAI-AGENT-015",
|
|
28379
|
-
`${rel} declares role "${role}" that no ${skill} routing phase and no ${profileLabel} selects.`,
|
|
28380
|
-
crossCheckSeverity,
|
|
28381
|
-
rel,
|
|
28382
|
-
"agentDefinition.roleNeverSelected"
|
|
28383
|
-
)
|
|
28384
|
-
);
|
|
28385
|
-
}
|
|
28386
|
-
}
|
|
28387
|
-
async function reportUnroutedSkills(root, skillsDir, docName, routing, issues, crossCheckSeverity) {
|
|
28388
|
-
let entries;
|
|
28389
|
-
try {
|
|
28390
|
-
entries = await readdir30(skillsDir);
|
|
28391
|
-
} catch {
|
|
28392
|
-
return;
|
|
28393
|
-
}
|
|
28394
|
-
for (const name of entries.sort()) {
|
|
28395
|
-
if ((routing.get(name)?.phases ?? 0) > 0) {
|
|
28396
|
-
continue;
|
|
28397
|
-
}
|
|
28398
|
-
const skillPath = path107.join(skillsDir, name, docName);
|
|
28399
|
-
const frontmatter = await readSkillFrontmatter(skillPath);
|
|
28400
|
-
const rel = path107.relative(root, skillPath).replace(/\\/g, "/");
|
|
28401
|
-
if (frontmatter?.parseError) {
|
|
28402
|
-
issues.push(unreadableFrontmatter(rel, name, frontmatter.parseError, crossCheckSeverity));
|
|
28403
|
-
continue;
|
|
28404
|
-
}
|
|
28405
|
-
if (frontmatter?.profileError) {
|
|
28406
|
-
issues.push(
|
|
28407
|
-
issue(
|
|
28408
|
-
"QFAI-AGENT-016",
|
|
28409
|
-
`${rel} declares an unusable routing-profile: (${frontmatter.profileError}); the ${name} review gate cannot be checked.`,
|
|
28410
|
-
crossCheckSeverity,
|
|
28411
|
-
rel,
|
|
28412
|
-
"agentDefinition.invalidRoutingProfile"
|
|
28413
|
-
)
|
|
28414
|
-
);
|
|
28415
|
-
continue;
|
|
28416
|
-
}
|
|
28417
|
-
const profile = frontmatter?.routingProfile;
|
|
28418
|
-
if (!profile) {
|
|
28419
|
-
continue;
|
|
28420
|
-
}
|
|
28421
|
-
issues.push(
|
|
28422
|
-
issue(
|
|
28423
|
-
"QFAI-AGENT-017",
|
|
28424
|
-
`${rel} declares routing-profile: ${profile} but the routing sends no phases to "${name}".`,
|
|
28425
|
-
crossCheckSeverity,
|
|
28426
|
-
rel,
|
|
28427
|
-
"agentDefinition.skillNotRouted"
|
|
28428
|
-
)
|
|
28429
|
-
);
|
|
28430
|
-
}
|
|
28431
|
-
}
|
|
28432
|
-
|
|
28433
|
-
// src/core/validators/agentDefinition.ts
|
|
28434
28050
|
var REQUIRED_AGENT_SECTIONS = [
|
|
28435
28051
|
"## Mission",
|
|
28436
28052
|
"## Domain Responsibilities",
|
|
@@ -28439,23 +28055,18 @@ var REQUIRED_AGENT_SECTIONS = [
|
|
|
28439
28055
|
"## Stop conditions",
|
|
28440
28056
|
"## Sign-off"
|
|
28441
28057
|
];
|
|
28442
|
-
|
|
28443
|
-
var RERUN_POLICIES = /* @__PURE__ */ new Set(["failed-agents-only", "changed-scope-dependents"]);
|
|
28444
|
-
async function validateAgentDefinition(root, config) {
|
|
28058
|
+
async function validateAgentDefinition(root) {
|
|
28445
28059
|
const issues = [];
|
|
28446
|
-
const agentsDir =
|
|
28060
|
+
const agentsDir = path106.join(root, ".qfai", "assistant", "agent");
|
|
28447
28061
|
if (!await exists3(agentsDir)) {
|
|
28448
28062
|
return [];
|
|
28449
28063
|
}
|
|
28450
|
-
const
|
|
28451
|
-
const reviewerIds = /* @__PURE__ */ new Set();
|
|
28452
|
-
for (const name of await readdir31(agentsDir)) {
|
|
28064
|
+
for (const name of await readdir29(agentsDir)) {
|
|
28453
28065
|
if (!name.endsWith(".md")) continue;
|
|
28454
28066
|
const id = name.slice(0, -3);
|
|
28455
|
-
const filePath =
|
|
28067
|
+
const filePath = path106.join(agentsDir, name);
|
|
28456
28068
|
const rel = `.qfai/assistant/agent/${name}`;
|
|
28457
|
-
|
|
28458
|
-
const content = await readFile61(filePath, "utf-8");
|
|
28069
|
+
const content = await readFile59(filePath, "utf-8");
|
|
28459
28070
|
const frontmatter = parseAgentFrontmatter(content);
|
|
28460
28071
|
if (!frontmatter.ok) {
|
|
28461
28072
|
issues.push(
|
|
@@ -28481,7 +28092,6 @@ async function validateAgentDefinition(root, config) {
|
|
|
28481
28092
|
);
|
|
28482
28093
|
continue;
|
|
28483
28094
|
}
|
|
28484
|
-
if (frontmatter.frontmatter.kind === "reviewer") reviewerIds.add(id);
|
|
28485
28095
|
for (const heading of REQUIRED_AGENT_SECTIONS) {
|
|
28486
28096
|
if (!content.includes(heading)) {
|
|
28487
28097
|
issues.push(
|
|
@@ -28496,438 +28106,12 @@ async function validateAgentDefinition(root, config) {
|
|
|
28496
28106
|
}
|
|
28497
28107
|
}
|
|
28498
28108
|
}
|
|
28499
|
-
const defaultsDir = path108.resolve(getInitAssetsDir(), "..", "defaults");
|
|
28500
|
-
const profilesPath = path108.join(defaultsDir, "review-profiles.yml");
|
|
28501
|
-
const routing = await validateRouting(config.routing ?? [], agentIds, issues);
|
|
28502
|
-
const profiles = await validateProfiles(
|
|
28503
|
-
profilesPath,
|
|
28504
|
-
config.reviewProfiles ?? {},
|
|
28505
|
-
reviewerIds,
|
|
28506
|
-
issues
|
|
28507
|
-
);
|
|
28508
|
-
if (routing !== void 0 && profiles !== void 0) {
|
|
28509
|
-
await validateSkillRoles(root, config, routing, profiles, issues);
|
|
28510
|
-
}
|
|
28511
28109
|
return issues;
|
|
28512
28110
|
}
|
|
28513
|
-
function routingListOf(file, issues) {
|
|
28514
|
-
const shapeError = (message, rule2) => {
|
|
28515
|
-
issues.push(issue("QFAI-AGENT-007", `${file.rel} ${message}`, "error", file.rel, rule2));
|
|
28516
|
-
};
|
|
28517
|
-
let parsed;
|
|
28518
|
-
try {
|
|
28519
|
-
parsed = parseYaml18(file.text);
|
|
28520
|
-
} catch {
|
|
28521
|
-
shapeError("could not be parsed", "agentDefinition.routingParse");
|
|
28522
|
-
return void 0;
|
|
28523
|
-
}
|
|
28524
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
28525
|
-
shapeError("must parse to an object", "agentDefinition.invalidRoutingShape");
|
|
28526
|
-
return void 0;
|
|
28527
|
-
}
|
|
28528
|
-
const list2 = Reflect.get(parsed, "routing");
|
|
28529
|
-
if (!Array.isArray(list2)) {
|
|
28530
|
-
shapeError("must contain routing array", "agentDefinition.invalidRoutingShape");
|
|
28531
|
-
return void 0;
|
|
28532
|
-
}
|
|
28533
|
-
const routing = list2;
|
|
28534
|
-
return routing;
|
|
28535
|
-
}
|
|
28536
|
-
async function readDefaultRoutes(issues) {
|
|
28537
|
-
const routes = [];
|
|
28538
|
-
let complete = true;
|
|
28539
|
-
for (const file of await readRoutingDefaultsFiles()) {
|
|
28540
|
-
const list2 = routingListOf(file, issues);
|
|
28541
|
-
if (list2 === void 0) complete = false;
|
|
28542
|
-
else routes.push(...list2.map((route) => ({ route, source: file.rel })));
|
|
28543
|
-
}
|
|
28544
|
-
return complete ? routes : void 0;
|
|
28545
|
-
}
|
|
28546
|
-
async function validateRouting(overrides, agentIds, issues) {
|
|
28547
|
-
const routed = /* @__PURE__ */ new Map();
|
|
28548
|
-
const defaults = await readDefaultRoutes(issues);
|
|
28549
|
-
if (defaults === void 0) return void 0;
|
|
28550
|
-
try {
|
|
28551
|
-
const effective = /* @__PURE__ */ new Map();
|
|
28552
|
-
for (const entry of defaults) {
|
|
28553
|
-
const { route } = entry;
|
|
28554
|
-
if (route && typeof route === "object" && !Array.isArray(route)) {
|
|
28555
|
-
const name = routingEntryName({
|
|
28556
|
-
step: Reflect.get(route, "step"),
|
|
28557
|
-
skill: Reflect.get(route, "skill")
|
|
28558
|
-
});
|
|
28559
|
-
if (name !== void 0) effective.set(name, entry);
|
|
28560
|
-
}
|
|
28561
|
-
}
|
|
28562
|
-
for (const route of overrides) {
|
|
28563
|
-
const name = routingEntryName(route);
|
|
28564
|
-
if (name !== void 0) effective.set(name, { route, source: "qfai.config.yaml" });
|
|
28565
|
-
}
|
|
28566
|
-
for (const [routeIndex, { route, source }] of [...effective.values()].entries()) {
|
|
28567
|
-
if (!route || typeof route !== "object" || Array.isArray(route)) {
|
|
28568
|
-
continue;
|
|
28569
|
-
}
|
|
28570
|
-
const routeObj = route;
|
|
28571
|
-
const routeName = routingEntryName(routeObj);
|
|
28572
|
-
const routedEntry = collectRouteHeader(
|
|
28573
|
-
routeObj,
|
|
28574
|
-
routed,
|
|
28575
|
-
issues,
|
|
28576
|
-
source,
|
|
28577
|
-
formatSkillLabel(routeName, routeIndex)
|
|
28578
|
-
);
|
|
28579
|
-
if (!Array.isArray(routeObj.phases)) {
|
|
28580
|
-
continue;
|
|
28581
|
-
}
|
|
28582
|
-
for (const [phaseIndex, phase] of routeObj.phases.entries()) {
|
|
28583
|
-
if (!phase || typeof phase !== "object" || Array.isArray(phase)) {
|
|
28584
|
-
continue;
|
|
28585
|
-
}
|
|
28586
|
-
const phaseObj = phase;
|
|
28587
|
-
if (phaseObj.iteration !== void 0) {
|
|
28588
|
-
const declared = phaseObj.iteration;
|
|
28589
|
-
if (typeof declared !== "string" || !ROUTING_ITERATIONS.has(declared)) {
|
|
28590
|
-
issues.push(
|
|
28591
|
-
issue(
|
|
28592
|
-
"QFAI-AGENT-013",
|
|
28593
|
-
`${formatSkillLabel(routeName, routeIndex)} phase[${phaseIndex}] declares iteration ${JSON.stringify(declared)}; allowed: ${[...ROUTING_ITERATIONS].sort().join(", ")}`,
|
|
28594
|
-
"error",
|
|
28595
|
-
source,
|
|
28596
|
-
"agentDefinition.routingIteration"
|
|
28597
|
-
)
|
|
28598
|
-
);
|
|
28599
|
-
}
|
|
28600
|
-
}
|
|
28601
|
-
if (phaseObj.rerun_policy !== void 0) {
|
|
28602
|
-
const declared = phaseObj.rerun_policy;
|
|
28603
|
-
if (typeof declared !== "string" || !RERUN_POLICIES.has(declared)) {
|
|
28604
|
-
issues.push(
|
|
28605
|
-
issue(
|
|
28606
|
-
"QFAI-AGENT-013",
|
|
28607
|
-
`${formatSkillLabel(routeName, routeIndex)} phase[${phaseIndex}] declares rerun_policy ${JSON.stringify(declared)}; allowed: ${[...RERUN_POLICIES].sort().join(", ")}`,
|
|
28608
|
-
"error",
|
|
28609
|
-
source,
|
|
28610
|
-
"agentDefinition.rerunPolicy"
|
|
28611
|
-
)
|
|
28612
|
-
);
|
|
28613
|
-
}
|
|
28614
|
-
}
|
|
28615
|
-
validateAgentRefs(
|
|
28616
|
-
source,
|
|
28617
|
-
phaseObj.mandatory_agents,
|
|
28618
|
-
agentIds,
|
|
28619
|
-
issues,
|
|
28620
|
-
formatSkillLabel(routeName, routeIndex),
|
|
28621
|
-
routeIndex,
|
|
28622
|
-
phaseIndex,
|
|
28623
|
-
"mandatory_agents"
|
|
28624
|
-
);
|
|
28625
|
-
validateAgentRefs(
|
|
28626
|
-
source,
|
|
28627
|
-
phaseObj.conditional_agents,
|
|
28628
|
-
agentIds,
|
|
28629
|
-
issues,
|
|
28630
|
-
formatSkillLabel(routeName, routeIndex),
|
|
28631
|
-
routeIndex,
|
|
28632
|
-
phaseIndex,
|
|
28633
|
-
"conditional_agents"
|
|
28634
|
-
);
|
|
28635
|
-
validateAgentRefs(
|
|
28636
|
-
source,
|
|
28637
|
-
phaseObj.blocking_agents,
|
|
28638
|
-
agentIds,
|
|
28639
|
-
issues,
|
|
28640
|
-
formatSkillLabel(routeName, routeIndex),
|
|
28641
|
-
routeIndex,
|
|
28642
|
-
phaseIndex,
|
|
28643
|
-
"blocking_agents"
|
|
28644
|
-
);
|
|
28645
|
-
if (Array.isArray(phaseObj.parallel_groups)) {
|
|
28646
|
-
for (const group of phaseObj.parallel_groups) {
|
|
28647
|
-
validateAgentRefs(
|
|
28648
|
-
source,
|
|
28649
|
-
group,
|
|
28650
|
-
agentIds,
|
|
28651
|
-
issues,
|
|
28652
|
-
formatSkillLabel(routeName, routeIndex),
|
|
28653
|
-
routeIndex,
|
|
28654
|
-
phaseIndex,
|
|
28655
|
-
"parallel_groups"
|
|
28656
|
-
);
|
|
28657
|
-
}
|
|
28658
|
-
}
|
|
28659
|
-
validateAgentFieldShapes(
|
|
28660
|
-
source,
|
|
28661
|
-
phaseObj,
|
|
28662
|
-
issues,
|
|
28663
|
-
formatSkillLabel(routeName, routeIndex),
|
|
28664
|
-
phaseIndex
|
|
28665
|
-
);
|
|
28666
|
-
if (routedEntry) {
|
|
28667
|
-
collectPhaseAgents(routedEntry, phaseObj, agentIds);
|
|
28668
|
-
}
|
|
28669
|
-
}
|
|
28670
|
-
}
|
|
28671
|
-
} catch {
|
|
28672
|
-
issues.push(
|
|
28673
|
-
issue(
|
|
28674
|
-
"QFAI-AGENT-007",
|
|
28675
|
-
"the routing defaults could not be read",
|
|
28676
|
-
"error",
|
|
28677
|
-
ROUTING_DEFAULTS_REL,
|
|
28678
|
-
"agentDefinition.routingParse"
|
|
28679
|
-
)
|
|
28680
|
-
);
|
|
28681
|
-
return void 0;
|
|
28682
|
-
}
|
|
28683
|
-
return routed;
|
|
28684
|
-
}
|
|
28685
|
-
var PHASE_AGENT_FIELDS = [
|
|
28686
|
-
["mandatory_agents", "required"],
|
|
28687
|
-
["blocking_agents", "required"],
|
|
28688
|
-
["conditional_agents", "conditional"]
|
|
28689
|
-
];
|
|
28690
|
-
function collectRouteHeader(routeObj, routed, issues, routingPathRel, skillLabel) {
|
|
28691
|
-
const name = routingEntryName(routeObj);
|
|
28692
|
-
if (name === void 0) {
|
|
28693
|
-
return void 0;
|
|
28694
|
-
}
|
|
28695
|
-
const kind = name === routeObj.step ? "step" : "skill";
|
|
28696
|
-
const entry = routed.get(name) ?? emptySkillRouting(kind);
|
|
28697
|
-
const declared = routeObj.review_profile;
|
|
28698
|
-
if (typeof declared === "string" && declared.trim().length > 0) {
|
|
28699
|
-
const profile = declared.trim();
|
|
28700
|
-
if (entry.reviewProfile === void 0) {
|
|
28701
|
-
entry.reviewProfile = profile;
|
|
28702
|
-
} else if (entry.reviewProfile !== profile) {
|
|
28703
|
-
entry.reviewProfileConflict ??= { first: entry.reviewProfile, second: profile };
|
|
28704
|
-
}
|
|
28705
|
-
} else if (declared !== void 0) {
|
|
28706
|
-
entry.reviewProfileUnusable = true;
|
|
28707
|
-
issues.push(
|
|
28708
|
-
issue(
|
|
28709
|
-
"QFAI-AGENT-013",
|
|
28710
|
-
`${skillLabel} declares review_profile ${JSON.stringify(declared)}; expected the name of a review-profiles.yml profile`,
|
|
28711
|
-
"error",
|
|
28712
|
-
routingPathRel,
|
|
28713
|
-
"agentDefinition.routingReviewProfileShape"
|
|
28714
|
-
)
|
|
28715
|
-
);
|
|
28716
|
-
}
|
|
28717
|
-
routed.set(name, entry);
|
|
28718
|
-
return entry;
|
|
28719
|
-
}
|
|
28720
|
-
function collectPhaseAgents(entry, phase, catalogIds) {
|
|
28721
|
-
let dispatchable = 0;
|
|
28722
|
-
for (const [field, binding] of PHASE_AGENT_FIELDS) {
|
|
28723
|
-
dispatchable += recordRoutedAgents(entry, phase[field], binding, catalogIds);
|
|
28724
|
-
}
|
|
28725
|
-
if (Array.isArray(phase.parallel_groups)) {
|
|
28726
|
-
for (const group of phase.parallel_groups) {
|
|
28727
|
-
dispatchable += recordRoutedAgents(entry, group, "conditional", catalogIds);
|
|
28728
|
-
}
|
|
28729
|
-
}
|
|
28730
|
-
if (dispatchable > 0) {
|
|
28731
|
-
entry.phases += 1;
|
|
28732
|
-
}
|
|
28733
|
-
}
|
|
28734
|
-
function validateAgentFieldShapes(rel, phase, issues, skill, phaseIndex) {
|
|
28735
|
-
const report2 = (field, value) => {
|
|
28736
|
-
issues.push(
|
|
28737
|
-
issue(
|
|
28738
|
-
"QFAI-AGENT-013",
|
|
28739
|
-
`${skill} phase[${phaseIndex}] declares ${field} ${JSON.stringify(value)}; expected a list of agent ids`,
|
|
28740
|
-
"error",
|
|
28741
|
-
rel,
|
|
28742
|
-
"agentDefinition.routingAgentFieldShape"
|
|
28743
|
-
)
|
|
28744
|
-
);
|
|
28745
|
-
};
|
|
28746
|
-
for (const [field] of PHASE_AGENT_FIELDS) {
|
|
28747
|
-
const value = phase[field];
|
|
28748
|
-
if (value !== void 0 && !Array.isArray(value)) {
|
|
28749
|
-
report2(field, value);
|
|
28750
|
-
}
|
|
28751
|
-
}
|
|
28752
|
-
const groups = phase.parallel_groups;
|
|
28753
|
-
if (groups === void 0) {
|
|
28754
|
-
return;
|
|
28755
|
-
}
|
|
28756
|
-
if (!Array.isArray(groups)) {
|
|
28757
|
-
report2("parallel_groups", groups);
|
|
28758
|
-
return;
|
|
28759
|
-
}
|
|
28760
|
-
for (const group of groups) {
|
|
28761
|
-
if (!Array.isArray(group)) {
|
|
28762
|
-
report2("parallel_groups entry", group);
|
|
28763
|
-
}
|
|
28764
|
-
}
|
|
28765
|
-
}
|
|
28766
|
-
function validateAgentRefs(routingPathRel, value, catalogIds, issues, skill, routeIndex, phaseIndex, field) {
|
|
28767
|
-
if (!Array.isArray(value)) {
|
|
28768
|
-
return;
|
|
28769
|
-
}
|
|
28770
|
-
for (const entry of value) {
|
|
28771
|
-
if (typeof entry !== "string") {
|
|
28772
|
-
continue;
|
|
28773
|
-
}
|
|
28774
|
-
if (!catalogIds.has(entry)) {
|
|
28775
|
-
issues.push(
|
|
28776
|
-
issue(
|
|
28777
|
-
"QFAI-AGENT-008",
|
|
28778
|
-
`routing references unknown agent "${entry}" in ${skill} phase ${phaseIndex} field ${field}`,
|
|
28779
|
-
"error",
|
|
28780
|
-
// Sourced from the caller's resolved routing path (manifestPathRel)
|
|
28781
|
-
// so the file: argument always points at the actual location read.
|
|
28782
|
-
routingPathRel,
|
|
28783
|
-
"agentDefinition.unknownRoutingAgent"
|
|
28784
|
-
)
|
|
28785
|
-
);
|
|
28786
|
-
}
|
|
28787
|
-
}
|
|
28788
|
-
}
|
|
28789
|
-
async function validateProfiles(profilesPath, overrides, reviewerIds, issues) {
|
|
28790
|
-
const rel = "packages/qfai/assets/defaults/review-profiles.yml";
|
|
28791
|
-
const selections = /* @__PURE__ */ new Map();
|
|
28792
|
-
const parsed = parseYaml18(await readFile61(profilesPath, "utf-8"));
|
|
28793
|
-
try {
|
|
28794
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
28795
|
-
issues.push(
|
|
28796
|
-
issue(
|
|
28797
|
-
"QFAI-AGENT-009",
|
|
28798
|
-
"review-profiles.yml must parse to an object",
|
|
28799
|
-
"error",
|
|
28800
|
-
rel,
|
|
28801
|
-
"agentDefinition.invalidProfilesShape"
|
|
28802
|
-
)
|
|
28803
|
-
);
|
|
28804
|
-
return void 0;
|
|
28805
|
-
}
|
|
28806
|
-
const profilesRoot = parsed;
|
|
28807
|
-
if (!profilesRoot.profiles || typeof profilesRoot.profiles !== "object" || Array.isArray(profilesRoot.profiles)) {
|
|
28808
|
-
issues.push(
|
|
28809
|
-
issue(
|
|
28810
|
-
"QFAI-AGENT-009",
|
|
28811
|
-
"review-profiles.yml must contain profiles object",
|
|
28812
|
-
"error",
|
|
28813
|
-
rel,
|
|
28814
|
-
"agentDefinition.invalidProfilesShape"
|
|
28815
|
-
)
|
|
28816
|
-
);
|
|
28817
|
-
return void 0;
|
|
28818
|
-
}
|
|
28819
|
-
const profiles = { ...profilesRoot.profiles, ...overrides };
|
|
28820
|
-
for (const [profileName, profile] of Object.entries(profiles)) {
|
|
28821
|
-
if (!profile || typeof profile !== "object" || Array.isArray(profile)) {
|
|
28822
|
-
continue;
|
|
28823
|
-
}
|
|
28824
|
-
const profileObj = profile;
|
|
28825
|
-
const source = Object.hasOwn(overrides, profileName) ? "qfai.config.yaml" : rel;
|
|
28826
|
-
const shapesUsable = validateReviewerFieldShapes(profileObj, issues, profileName, source);
|
|
28827
|
-
selections.set(profileName, {
|
|
28828
|
-
reviewers: collectProfileReviewers(
|
|
28829
|
-
profileObj.always_required,
|
|
28830
|
-
profileObj.conditional_required,
|
|
28831
|
-
reviewerIds
|
|
28832
|
-
),
|
|
28833
|
-
incomplete: !shapesUsable
|
|
28834
|
-
});
|
|
28835
|
-
validateReviewerRefs(
|
|
28836
|
-
profileObj.always_required,
|
|
28837
|
-
reviewerIds,
|
|
28838
|
-
issues,
|
|
28839
|
-
profileName,
|
|
28840
|
-
"always",
|
|
28841
|
-
source
|
|
28842
|
-
);
|
|
28843
|
-
validateReviewerRefs(
|
|
28844
|
-
profileObj.conditional_required,
|
|
28845
|
-
reviewerIds,
|
|
28846
|
-
issues,
|
|
28847
|
-
profileName,
|
|
28848
|
-
"conditional",
|
|
28849
|
-
source
|
|
28850
|
-
);
|
|
28851
|
-
}
|
|
28852
|
-
} catch {
|
|
28853
|
-
issues.push(
|
|
28854
|
-
issue(
|
|
28855
|
-
"QFAI-AGENT-009",
|
|
28856
|
-
"review-profiles.yml could not be parsed",
|
|
28857
|
-
"error",
|
|
28858
|
-
rel,
|
|
28859
|
-
"agentDefinition.profilesParse"
|
|
28860
|
-
)
|
|
28861
|
-
);
|
|
28862
|
-
return void 0;
|
|
28863
|
-
}
|
|
28864
|
-
return selections;
|
|
28865
|
-
}
|
|
28866
|
-
function collectProfileReviewers(always, conditional, reviewerIds) {
|
|
28867
|
-
const reviewers = /* @__PURE__ */ new Map();
|
|
28868
|
-
for (const [value, binding] of [
|
|
28869
|
-
[conditional, "conditional"],
|
|
28870
|
-
[always, "required"]
|
|
28871
|
-
]) {
|
|
28872
|
-
if (!Array.isArray(value)) {
|
|
28873
|
-
continue;
|
|
28874
|
-
}
|
|
28875
|
-
for (const entry of value) {
|
|
28876
|
-
if (typeof entry === "string" && entry.length > 0 && reviewerIds.has(entry)) {
|
|
28877
|
-
reviewers.set(entry, binding);
|
|
28878
|
-
}
|
|
28879
|
-
}
|
|
28880
|
-
}
|
|
28881
|
-
return reviewers;
|
|
28882
|
-
}
|
|
28883
|
-
function validateReviewerFieldShapes(profileObj, issues, profileName, profilesPathRel) {
|
|
28884
|
-
let usable = true;
|
|
28885
|
-
for (const field of ["always_required", "conditional_required"]) {
|
|
28886
|
-
const value = profileObj[field];
|
|
28887
|
-
if (value === void 0 || Array.isArray(value)) {
|
|
28888
|
-
continue;
|
|
28889
|
-
}
|
|
28890
|
-
usable = false;
|
|
28891
|
-
issues.push(
|
|
28892
|
-
issue(
|
|
28893
|
-
"QFAI-AGENT-009",
|
|
28894
|
-
`review-profiles.yml profile "${profileName}" declares ${field} ${JSON.stringify(value)}; expected a list of reviewer ids`,
|
|
28895
|
-
"error",
|
|
28896
|
-
profilesPathRel,
|
|
28897
|
-
"agentDefinition.invalidProfilesShape"
|
|
28898
|
-
)
|
|
28899
|
-
);
|
|
28900
|
-
}
|
|
28901
|
-
return usable;
|
|
28902
|
-
}
|
|
28903
|
-
function formatSkillLabel(skill, routeIndex) {
|
|
28904
|
-
return typeof skill === "string" && skill.length > 0 ? skill : `route-${routeIndex}`;
|
|
28905
|
-
}
|
|
28906
|
-
function validateReviewerRefs(value, reviewerIds, issues, profileName, field, profilesPathRel) {
|
|
28907
|
-
if (!Array.isArray(value)) {
|
|
28908
|
-
return;
|
|
28909
|
-
}
|
|
28910
|
-
for (const entry of value) {
|
|
28911
|
-
if (typeof entry !== "string") {
|
|
28912
|
-
continue;
|
|
28913
|
-
}
|
|
28914
|
-
if (!reviewerIds.has(entry)) {
|
|
28915
|
-
issues.push(
|
|
28916
|
-
issue(
|
|
28917
|
-
"QFAI-AGENT-010",
|
|
28918
|
-
`review-profiles.yml profile "${profileName}" references non-reviewer agent "${entry}" in ${field}_required`,
|
|
28919
|
-
"error",
|
|
28920
|
-
profilesPathRel,
|
|
28921
|
-
"agentDefinition.nonReviewerInProfile"
|
|
28922
|
-
)
|
|
28923
|
-
);
|
|
28924
|
-
}
|
|
28925
|
-
}
|
|
28926
|
-
}
|
|
28927
28111
|
|
|
28928
28112
|
// src/core/validators/designAudit.ts
|
|
28929
|
-
import { readdir as
|
|
28930
|
-
import
|
|
28113
|
+
import { readdir as readdir30 } from "fs/promises";
|
|
28114
|
+
import path107 from "path";
|
|
28931
28115
|
var COSMETIC_CATEGORIES = ["generic-shell", "stock-imagery", "placeholder-copy"];
|
|
28932
28116
|
var PRIMARY_TASKS_MAX = 7;
|
|
28933
28117
|
var PRIMARY_TASKS_MAX_LABEL = `at most ${PRIMARY_TASKS_MAX}`;
|
|
@@ -29123,19 +28307,19 @@ async function checkTokenDrift(root, auditConfig, cfg) {
|
|
|
29123
28307
|
const findings = [];
|
|
29124
28308
|
const configuredDir = cfg.uiux?.designTokensDir;
|
|
29125
28309
|
if (!configuredDir) return findings;
|
|
29126
|
-
const tokensDir =
|
|
28310
|
+
const tokensDir = path107.resolve(root, configuredDir);
|
|
29127
28311
|
let hasTokenFiles;
|
|
29128
28312
|
try {
|
|
29129
|
-
const entries = await
|
|
28313
|
+
const entries = await readdir30(tokensDir);
|
|
29130
28314
|
hasTokenFiles = entries.some((e) => /\.ya?ml$/i.test(e));
|
|
29131
28315
|
} catch {
|
|
29132
28316
|
return findings;
|
|
29133
28317
|
}
|
|
29134
28318
|
if (!hasTokenFiles) return findings;
|
|
29135
|
-
const contractsUiDir =
|
|
28319
|
+
const contractsUiDir = path107.join(root, cfg.paths.contractsDir, "ui");
|
|
29136
28320
|
let htmlFiles;
|
|
29137
28321
|
try {
|
|
29138
|
-
const entries = await
|
|
28322
|
+
const entries = await readdir30(contractsUiDir);
|
|
29139
28323
|
htmlFiles = entries.filter((e) => /\.html?$/i.test(e));
|
|
29140
28324
|
} catch {
|
|
29141
28325
|
return findings;
|
|
@@ -29143,7 +28327,7 @@ async function checkTokenDrift(root, auditConfig, cfg) {
|
|
|
29143
28327
|
let rawCount = 0;
|
|
29144
28328
|
const sampleLiterals = [];
|
|
29145
28329
|
for (const htmlFile of htmlFiles) {
|
|
29146
|
-
const content = await readSafe(
|
|
28330
|
+
const content = await readSafe(path107.join(contractsUiDir, htmlFile));
|
|
29147
28331
|
if (!content) continue;
|
|
29148
28332
|
const matches = content.match(RAW_COLOR_RE);
|
|
29149
28333
|
if (matches) {
|
|
@@ -29194,7 +28378,7 @@ function deduplicateFindings(issues, maxPerRule) {
|
|
|
29194
28378
|
async function validateDesignAudit(root, config) {
|
|
29195
28379
|
const auditConfig = resolveAuditConfig(config);
|
|
29196
28380
|
if (!auditConfig.enabled) return [];
|
|
29197
|
-
const discussionDir =
|
|
28381
|
+
const discussionDir = path107.join(root, config.paths.discussionDir);
|
|
29198
28382
|
const uiContractScreens = await readUiContractScreenContracts(root, config.paths.contractsDir);
|
|
29199
28383
|
const packRoot = await findLatestDiscussionPackDir(discussionDir);
|
|
29200
28384
|
if (uiContractScreens.length === 0) {
|
|
@@ -29202,7 +28386,7 @@ async function validateDesignAudit(root, config) {
|
|
|
29202
28386
|
const uiBearing = await isDiscussionUiBearingPack(packRoot);
|
|
29203
28387
|
if (!uiBearing) return [];
|
|
29204
28388
|
}
|
|
29205
|
-
const contractsPath = packRoot ?
|
|
28389
|
+
const contractsPath = packRoot ? path107.join(packRoot, "uiux", "40_screen_contracts.md") : null;
|
|
29206
28390
|
const contractsContent = contractsPath ? await readSafe(contractsPath) : "";
|
|
29207
28391
|
if (uiContractScreens.length === 0 && !contractsContent) return [];
|
|
29208
28392
|
const findings = [];
|
|
@@ -29220,7 +28404,7 @@ async function validateDesignAudit(root, config) {
|
|
|
29220
28404
|
|
|
29221
28405
|
// src/core/validators/layoutAntiPatterns.ts
|
|
29222
28406
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
29223
|
-
import
|
|
28407
|
+
import path108 from "path";
|
|
29224
28408
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
29225
28409
|
|
|
29226
28410
|
// src/core/validators/uixDetection.ts
|
|
@@ -29229,10 +28413,10 @@ async function isUiBearingSpec(root) {
|
|
|
29229
28413
|
}
|
|
29230
28414
|
|
|
29231
28415
|
// src/core/validators/uix/threeLayer.ts
|
|
29232
|
-
import
|
|
28416
|
+
import path110 from "path";
|
|
29233
28417
|
|
|
29234
28418
|
// src/core/validators/uix/designInheritance.ts
|
|
29235
|
-
import
|
|
28419
|
+
import path109 from "path";
|
|
29236
28420
|
|
|
29237
28421
|
// src/core/validators/uix/placeholder.ts
|
|
29238
28422
|
var PLACEHOLDER_RE = /^(?:tbd|todo|example|lorem|placeholder|n\/a|none)$/i;
|
|
@@ -29264,7 +28448,7 @@ function declaresInheritedDesign(contextContent) {
|
|
|
29264
28448
|
return readDesignDirectionDeclaration(contextContent).kind === "inherit";
|
|
29265
28449
|
}
|
|
29266
28450
|
async function packInheritsDesign(root) {
|
|
29267
|
-
const content = await readSafe(
|
|
28451
|
+
const content = await readSafe(path109.join(root, "01_Context.md"));
|
|
29268
28452
|
return content ? declaresInheritedDesign(content) : false;
|
|
29269
28453
|
}
|
|
29270
28454
|
async function findInheritanceConflicts(root, contextContent, config, projectRoot) {
|
|
@@ -29274,7 +28458,7 @@ async function findInheritanceConflicts(root, contextContent, config, projectRoo
|
|
|
29274
28458
|
};
|
|
29275
28459
|
}
|
|
29276
28460
|
async function findNewScreens(root, config, projectRoot) {
|
|
29277
|
-
const contracts = await readSafe(
|
|
28461
|
+
const contracts = await readSafe(path109.join(root, "uiux", "40_screen_contracts.md"));
|
|
29278
28462
|
if (!contracts) return [];
|
|
29279
28463
|
const packScreens = [...maskNonSpecRegions(contracts).matchAll(SCREEN_ID_RE)].map((match) => match[1] ?? "").filter((id) => !isPlaceholder2(id));
|
|
29280
28464
|
if (packScreens.length === 0) return [];
|
|
@@ -29323,7 +28507,7 @@ async function validateThreeLayerFamilyCompleteness(root, _config) {
|
|
|
29323
28507
|
const issues = [];
|
|
29324
28508
|
for (const required of CANONICAL_REQUIRED_SIDECAR_FILES) {
|
|
29325
28509
|
if (inherited && OMITTED_WHEN_INHERITED.has(required)) continue;
|
|
29326
|
-
const content = await readSafe(
|
|
28510
|
+
const content = await readSafe(path110.join(root, "uiux", required));
|
|
29327
28511
|
if (!content) {
|
|
29328
28512
|
issues.push(
|
|
29329
28513
|
threeLayerIssue(
|
|
@@ -29340,7 +28524,7 @@ async function validateThreeLayerFamilyCompleteness(root, _config) {
|
|
|
29340
28524
|
}
|
|
29341
28525
|
|
|
29342
28526
|
// src/core/validators/uix/trendScan.ts
|
|
29343
|
-
import
|
|
28527
|
+
import path111 from "path";
|
|
29344
28528
|
var REQUIRED_CATEGORIES = [
|
|
29345
28529
|
"user expectation / market norm",
|
|
29346
28530
|
"product neighbor / comparable flow",
|
|
@@ -29436,7 +28620,7 @@ async function validateTrendScan(root, _config) {
|
|
|
29436
28620
|
if (!await isUiBearingSpec(root) || await packInheritsDesign(root)) {
|
|
29437
28621
|
return [];
|
|
29438
28622
|
}
|
|
29439
|
-
const sourcesPath =
|
|
28623
|
+
const sourcesPath = path111.join(root, "04_Sources.md");
|
|
29440
28624
|
const content = await readSafe(sourcesPath);
|
|
29441
28625
|
if (!content) {
|
|
29442
28626
|
return [
|
|
@@ -29520,7 +28704,7 @@ async function validateTrendScan(root, _config) {
|
|
|
29520
28704
|
}
|
|
29521
28705
|
|
|
29522
28706
|
// src/core/validators/uix/screenContract.ts
|
|
29523
|
-
import
|
|
28707
|
+
import path112 from "path";
|
|
29524
28708
|
var REQUIRED_FIELDS = [
|
|
29525
28709
|
"screen_id",
|
|
29526
28710
|
"route",
|
|
@@ -29657,7 +28841,7 @@ function assignNestedChild(block, key, value) {
|
|
|
29657
28841
|
}
|
|
29658
28842
|
async function validateScreenContractSchema(root, _config) {
|
|
29659
28843
|
if (!await isUiBearingSpec(root)) return [];
|
|
29660
|
-
const contractsPath =
|
|
28844
|
+
const contractsPath = path112.join(root, "uiux", "40_screen_contracts.md");
|
|
29661
28845
|
const content = await readSafe(contractsPath);
|
|
29662
28846
|
if (!content) return [];
|
|
29663
28847
|
const screens = parseScreenBlocks2(content);
|
|
@@ -29728,10 +28912,10 @@ async function validateScreenContractSchema(root, _config) {
|
|
|
29728
28912
|
}
|
|
29729
28913
|
|
|
29730
28914
|
// src/core/validators/uix/canonical.ts
|
|
29731
|
-
import
|
|
28915
|
+
import path118 from "path";
|
|
29732
28916
|
|
|
29733
28917
|
// src/core/validators/uix/classification.ts
|
|
29734
|
-
import
|
|
28918
|
+
import path113 from "path";
|
|
29735
28919
|
var VALID_PRIMARY_SURFACES = [
|
|
29736
28920
|
"web",
|
|
29737
28921
|
"mobile",
|
|
@@ -29752,7 +28936,7 @@ function classificationIssue(code, message, severity, file, suggestedAction) {
|
|
|
29752
28936
|
};
|
|
29753
28937
|
}
|
|
29754
28938
|
async function validateClassification(root, config, projectRoot) {
|
|
29755
|
-
const contextPath =
|
|
28939
|
+
const contextPath = path113.join(root, "01_Context.md");
|
|
29756
28940
|
const content = await readSafe(contextPath);
|
|
29757
28941
|
if (!content) {
|
|
29758
28942
|
return [];
|
|
@@ -29977,8 +29161,8 @@ async function inheritanceRefusals(root, content, config, projectRoot) {
|
|
|
29977
29161
|
}
|
|
29978
29162
|
|
|
29979
29163
|
// src/core/validators/uix/foundation.ts
|
|
29980
|
-
import { readdir as
|
|
29981
|
-
import
|
|
29164
|
+
import { readdir as readdir31 } from "fs/promises";
|
|
29165
|
+
import path114 from "path";
|
|
29982
29166
|
function canonicalIssue(code, message, severity, file, suggestedAction) {
|
|
29983
29167
|
return {
|
|
29984
29168
|
code,
|
|
@@ -29992,7 +29176,7 @@ function canonicalIssue(code, message, severity, file, suggestedAction) {
|
|
|
29992
29176
|
async function validateSidecarMissing(root, _config) {
|
|
29993
29177
|
if (!await isUiBearingSpec(root)) return [];
|
|
29994
29178
|
try {
|
|
29995
|
-
await
|
|
29179
|
+
await readdir31(path114.join(root, "uiux"));
|
|
29996
29180
|
return [];
|
|
29997
29181
|
} catch (err) {
|
|
29998
29182
|
if (isEnoent(err)) {
|
|
@@ -30011,7 +29195,7 @@ async function validateSidecarMissing(root, _config) {
|
|
|
30011
29195
|
}
|
|
30012
29196
|
|
|
30013
29197
|
// src/core/validators/uix/comparisonValidator.ts
|
|
30014
|
-
import
|
|
29198
|
+
import path115 from "path";
|
|
30015
29199
|
function canonicalIssue2(code, message, severity, file, suggestedAction) {
|
|
30016
29200
|
return {
|
|
30017
29201
|
code,
|
|
@@ -30025,7 +29209,7 @@ function canonicalIssue2(code, message, severity, file, suggestedAction) {
|
|
|
30025
29209
|
async function validateExplorationArtifacts(root, _config) {
|
|
30026
29210
|
if (!await isUiBearingSpec(root)) return [];
|
|
30027
29211
|
const issues = [];
|
|
30028
|
-
const reviewBundlePath =
|
|
29212
|
+
const reviewBundlePath = path115.join(root, "uiux", "50_review_input_bundle.md");
|
|
30029
29213
|
const reviewBundleContent = await readSafe(reviewBundlePath);
|
|
30030
29214
|
if (reviewBundleContent && !/best-of-history/i.test(reviewBundleContent)) {
|
|
30031
29215
|
issues.push(
|
|
@@ -30042,7 +29226,7 @@ async function validateExplorationArtifacts(root, _config) {
|
|
|
30042
29226
|
}
|
|
30043
29227
|
|
|
30044
29228
|
// src/core/validators/uix/oqClosure.ts
|
|
30045
|
-
import
|
|
29229
|
+
import path116 from "path";
|
|
30046
29230
|
function canonicalIssue3(code, message, severity, file, suggestedAction) {
|
|
30047
29231
|
return {
|
|
30048
29232
|
code,
|
|
@@ -30055,8 +29239,8 @@ function canonicalIssue3(code, message, severity, file, suggestedAction) {
|
|
|
30055
29239
|
}
|
|
30056
29240
|
async function validateOqClosure(root, _config) {
|
|
30057
29241
|
if (!await isUiBearingSpec(root)) return [];
|
|
30058
|
-
const rootOqPath =
|
|
30059
|
-
const uiuxOqPath =
|
|
29242
|
+
const rootOqPath = path116.join(root, "11_OQ-Register.md");
|
|
29243
|
+
const uiuxOqPath = path116.join(root, "uiux", "11_OQ-Register.md");
|
|
30060
29244
|
const rootContent = await readSafe(rootOqPath);
|
|
30061
29245
|
const content = rootContent || await readSafe(uiuxOqPath);
|
|
30062
29246
|
if (!content) return [];
|
|
@@ -30107,7 +29291,7 @@ async function validateOqClosure(root, _config) {
|
|
|
30107
29291
|
}
|
|
30108
29292
|
|
|
30109
29293
|
// src/core/validators/uix/competitiveRefs.ts
|
|
30110
|
-
import
|
|
29294
|
+
import path117 from "path";
|
|
30111
29295
|
var DEFAULT_COMPETITIVE_REFS_MIN = 3;
|
|
30112
29296
|
var H2_PREFIX = String.raw`^ {0,3}##(?!#)`;
|
|
30113
29297
|
function registryHeadingRe(heading) {
|
|
@@ -30282,7 +29466,7 @@ async function validateCompetitiveReferences(root, config) {
|
|
|
30282
29466
|
if (!await isUiBearingSpec(root)) {
|
|
30283
29467
|
return [];
|
|
30284
29468
|
}
|
|
30285
|
-
const content = await readSafe(
|
|
29469
|
+
const content = await readSafe(path117.join(root, "04_Sources.md"));
|
|
30286
29470
|
const masked = content ? maskNonSpecRegions(content) : null;
|
|
30287
29471
|
const inherited = await packInheritsDesign(root);
|
|
30288
29472
|
const issues = [];
|
|
@@ -30356,7 +29540,7 @@ async function runCanonicalUixValidators(root, config) {
|
|
|
30356
29540
|
return perPack.flat();
|
|
30357
29541
|
}
|
|
30358
29542
|
async function resolvePackRoots(root, config) {
|
|
30359
|
-
if (await readSafe(
|
|
29543
|
+
if (await readSafe(path118.join(root, "01_Context.md"))) {
|
|
30360
29544
|
return [root];
|
|
30361
29545
|
}
|
|
30362
29546
|
const latest = await findLatestPack(resolvePath(root, config, "discussionDir"), "discussion");
|
|
@@ -30585,8 +29769,8 @@ function validatePrototypingSkillContent(content) {
|
|
|
30585
29769
|
}
|
|
30586
29770
|
|
|
30587
29771
|
// src/core/validators/testTodoStubs.ts
|
|
30588
|
-
import { readFile as
|
|
30589
|
-
import
|
|
29772
|
+
import { readFile as readFile60 } from "fs/promises";
|
|
29773
|
+
import path119 from "path";
|
|
30590
29774
|
var nonCodeSpan = (open12, close, escaped, multiline, nests = false) => ({ open: open12, close, escaped, multiline, nests });
|
|
30591
29775
|
var RUST_RAW_STRING_OPENER = /b?r(#*)"/y;
|
|
30592
29776
|
var BLOCK_COMMENT = nonCodeSpan("/*", "*/", false, true);
|
|
@@ -31191,7 +30375,7 @@ function maskSpan(content, blank2, start, span) {
|
|
|
31191
30375
|
return i;
|
|
31192
30376
|
}
|
|
31193
30377
|
function resolveStubDialect(relFile) {
|
|
31194
|
-
const ext =
|
|
30378
|
+
const ext = path119.extname(relFile).toLowerCase();
|
|
31195
30379
|
return STUB_DIALECTS.find((dialect) => dialect.extensions.includes(ext)) ?? null;
|
|
31196
30380
|
}
|
|
31197
30381
|
function reportEmptyTestFileGlobs() {
|
|
@@ -31265,9 +30449,9 @@ async function validateTestTodoStubs(root, config, options = {}) {
|
|
|
31265
30449
|
const sourceExtensions = options.globs === void 0 ? null : new Set(STUB_SOURCE_EXTENSIONS.map((ext) => `.${ext}`));
|
|
31266
30450
|
const namedTestFile = options.globs === void 0 ? null : namedTestFileMatcher(accepted);
|
|
31267
30451
|
const wanted = (absolutePath) => {
|
|
31268
|
-
const relative =
|
|
30452
|
+
const relative = path119.relative(root, absolutePath).replace(/\\/g, "/");
|
|
31269
30453
|
const named2 = namedTestFile !== null && (namedTestFile(relative) || namedTestFile(absolutePath.replace(/\\/g, "/")));
|
|
31270
|
-
if (sourceExtensions && !sourceExtensions.has(
|
|
30454
|
+
if (sourceExtensions && !sourceExtensions.has(path119.extname(absolutePath).toLowerCase()) && !named2) {
|
|
31271
30455
|
return false;
|
|
31272
30456
|
}
|
|
31273
30457
|
return options.fileFilter ? options.fileFilter(relative) : true;
|
|
@@ -31318,15 +30502,15 @@ async function validateTestTodoStubs(root, config, options = {}) {
|
|
|
31318
30502
|
const skippedTestSeverity = "error";
|
|
31319
30503
|
const unscannedExtensions = /* @__PURE__ */ new Set();
|
|
31320
30504
|
for (const absFile of files) {
|
|
31321
|
-
const relFile =
|
|
30505
|
+
const relFile = path119.relative(root, absFile).replace(/\\/g, "/");
|
|
31322
30506
|
const dialect = resolveStubDialect(relFile);
|
|
31323
30507
|
if (!dialect) {
|
|
31324
|
-
unscannedExtensions.add(
|
|
30508
|
+
unscannedExtensions.add(path119.extname(relFile).toLowerCase() || "(no extension)");
|
|
31325
30509
|
continue;
|
|
31326
30510
|
}
|
|
31327
30511
|
let content;
|
|
31328
30512
|
try {
|
|
31329
|
-
content = await
|
|
30513
|
+
content = await readFile60(absFile, "utf-8");
|
|
31330
30514
|
} catch {
|
|
31331
30515
|
continue;
|
|
31332
30516
|
}
|
|
@@ -31359,15 +30543,15 @@ async function validateTestTodoStubs(root, config, options = {}) {
|
|
|
31359
30543
|
}
|
|
31360
30544
|
|
|
31361
30545
|
// src/core/validators/assistantTreeMigration.ts
|
|
31362
|
-
import { readdir as
|
|
31363
|
-
import
|
|
30546
|
+
import { readdir as readdir32 } from "fs/promises";
|
|
30547
|
+
import path120 from "path";
|
|
31364
30548
|
async function validateAssistantTreeMigration(root, _config) {
|
|
31365
30549
|
const issues = [];
|
|
31366
|
-
const assistantRoot =
|
|
30550
|
+
const assistantRoot = path120.join(root, ".qfai", "assistant");
|
|
31367
30551
|
if (await exists3(assistantRoot)) {
|
|
31368
30552
|
let dirEntries;
|
|
31369
30553
|
try {
|
|
31370
|
-
dirEntries = await
|
|
30554
|
+
dirEntries = await readdir32(assistantRoot, { withFileTypes: true });
|
|
31371
30555
|
} catch {
|
|
31372
30556
|
dirEntries = [];
|
|
31373
30557
|
}
|
|
@@ -31405,8 +30589,8 @@ async function validateAssistantTreeMigration(root, _config) {
|
|
|
31405
30589
|
}
|
|
31406
30590
|
|
|
31407
30591
|
// src/core/validators/skillDocReferences.ts
|
|
31408
|
-
import { readdir as
|
|
31409
|
-
import
|
|
30592
|
+
import { readdir as readdir33, readFile as readFile61 } from "fs/promises";
|
|
30593
|
+
import path121 from "path";
|
|
31410
30594
|
var QFAI_SKILL_ID_RE = /^qfai-/;
|
|
31411
30595
|
async function validateSkillDocReferences(root, config) {
|
|
31412
30596
|
const issues = [];
|
|
@@ -31414,7 +30598,7 @@ async function validateSkillDocReferences(root, config) {
|
|
|
31414
30598
|
if (!await exists3(skillsDir)) return issues;
|
|
31415
30599
|
let entries;
|
|
31416
30600
|
try {
|
|
31417
|
-
entries = await
|
|
30601
|
+
entries = await readdir33(skillsDir, { withFileTypes: true });
|
|
31418
30602
|
} catch (err) {
|
|
31419
30603
|
if (isEnoent(err)) return issues;
|
|
31420
30604
|
throw err;
|
|
@@ -31422,11 +30606,11 @@ async function validateSkillDocReferences(root, config) {
|
|
|
31422
30606
|
for (const entry of entries) {
|
|
31423
30607
|
if (!entry.isDirectory()) continue;
|
|
31424
30608
|
const skillId = entry.name;
|
|
31425
|
-
const skillDoc =
|
|
31426
|
-
const skillDocRelPath =
|
|
30609
|
+
const skillDoc = path121.join(skillsDir, skillId, "SKILL.md");
|
|
30610
|
+
const skillDocRelPath = path121.relative(root, skillDoc).replace(/\\/g, "/");
|
|
31427
30611
|
let body;
|
|
31428
30612
|
try {
|
|
31429
|
-
body = await
|
|
30613
|
+
body = await readFile61(skillDoc, "utf-8");
|
|
31430
30614
|
} catch (err) {
|
|
31431
30615
|
if (isEnoent(err)) continue;
|
|
31432
30616
|
throw err;
|
|
@@ -31474,7 +30658,7 @@ async function validateSkillDocReferences(root, config) {
|
|
|
31474
30658
|
}
|
|
31475
30659
|
|
|
31476
30660
|
// src/core/validators/reviewerGate.ts
|
|
31477
|
-
import
|
|
30661
|
+
import path122 from "path";
|
|
31478
30662
|
|
|
31479
30663
|
// src/core/validators/mockHrefPairs.ts
|
|
31480
30664
|
var MOCK_HREF_TEMPLATE_REL = "packages/qfai/assets/init/.qfai/assistant/skill/qfai-discussion/templates/03_Story-Workshop.md";
|
|
@@ -31491,8 +30675,8 @@ var MOCK_HREF_PAIRS = [
|
|
|
31491
30675
|
|
|
31492
30676
|
// src/core/validators/reviewerGate.ts
|
|
31493
30677
|
async function detectMockHrefDrift(root) {
|
|
31494
|
-
const templateAbs =
|
|
31495
|
-
const validatorAbs =
|
|
30678
|
+
const templateAbs = path122.join(root, MOCK_HREF_TEMPLATE_REL);
|
|
30679
|
+
const validatorAbs = path122.join(root, MOCK_HREF_VALIDATOR_REL);
|
|
31496
30680
|
if (!await exists3(templateAbs)) return [];
|
|
31497
30681
|
if (!await exists3(validatorAbs)) return [];
|
|
31498
30682
|
const templateText = await readSafe(templateAbs);
|
|
@@ -31516,8 +30700,8 @@ async function detectMockHrefDrift(root) {
|
|
|
31516
30700
|
}
|
|
31517
30701
|
|
|
31518
30702
|
// src/core/validators/skillManifestDrift.ts
|
|
31519
|
-
import { readFile as
|
|
31520
|
-
import
|
|
30703
|
+
import { readFile as readFile62 } from "fs/promises";
|
|
30704
|
+
import path123 from "path";
|
|
31521
30705
|
|
|
31522
30706
|
// src/core/validators/skillManifestPairs.ts
|
|
31523
30707
|
var SKILL_MANIFEST_PROBE_IMPL_REL = "packages/qfai/src/core/doctor/skillManifestProbe.ts";
|
|
@@ -31539,7 +30723,7 @@ async function readSafe7(abs) {
|
|
|
31539
30723
|
return null;
|
|
31540
30724
|
}
|
|
31541
30725
|
try {
|
|
31542
|
-
return await
|
|
30726
|
+
return await readFile62(abs, "utf-8");
|
|
31543
30727
|
} catch {
|
|
31544
30728
|
return null;
|
|
31545
30729
|
}
|
|
@@ -31547,8 +30731,8 @@ async function readSafe7(abs) {
|
|
|
31547
30731
|
async function detectSkillManifestDrift(root) {
|
|
31548
30732
|
const issues = [];
|
|
31549
30733
|
for (const pair of SKILL_MANIFEST_PAIRS) {
|
|
31550
|
-
const probeAbs =
|
|
31551
|
-
const schemaAbs =
|
|
30734
|
+
const probeAbs = path123.join(root, pair.probeImplRel);
|
|
30735
|
+
const schemaAbs = path123.join(root, pair.schemaRel);
|
|
31552
30736
|
const probeText = await readSafe7(probeAbs);
|
|
31553
30737
|
const schemaText = await readSafe7(schemaAbs);
|
|
31554
30738
|
if (probeText === null || schemaText === null) {
|
|
@@ -31571,12 +30755,12 @@ async function detectSkillManifestDrift(root) {
|
|
|
31571
30755
|
}
|
|
31572
30756
|
|
|
31573
30757
|
// src/core/validators/autopilotPolicy.ts
|
|
31574
|
-
import { readdir as
|
|
31575
|
-
import
|
|
31576
|
-
var SKILL_DIR_REL =
|
|
30758
|
+
import { readdir as readdir34, readFile as readFile63 } from "fs/promises";
|
|
30759
|
+
import path124 from "path";
|
|
30760
|
+
var SKILL_DIR_REL = path124.join(".qfai", "assistant", "skill");
|
|
31577
30761
|
var QFAI_SKILL_ID_RE2 = /^qfai-/;
|
|
31578
30762
|
var SECTION_HEADING_RE = /^##\s+Default Autopilot Policy\s*$/im;
|
|
31579
|
-
var BASELINE_REL =
|
|
30763
|
+
var BASELINE_REL = path124.join("rule", "shared-skill-operating-baseline.md");
|
|
31580
30764
|
var BASELINE_HEADING_RE = /^##\s+Default Autopilot Policy \(Shared\)\s*$/m;
|
|
31581
30765
|
var AUTO_DECIDE_ALLOWED_TOKENS = [
|
|
31582
30766
|
"output formatting",
|
|
@@ -31775,7 +30959,7 @@ function missingBaselineBuckets(content) {
|
|
|
31775
30959
|
async function readQfaiSkills(skillsDir) {
|
|
31776
30960
|
let entries;
|
|
31777
30961
|
try {
|
|
31778
|
-
entries = await
|
|
30962
|
+
entries = await readdir34(skillsDir, { withFileTypes: true });
|
|
31779
30963
|
} catch (err) {
|
|
31780
30964
|
if (isEnoent(err)) return [];
|
|
31781
30965
|
throw err;
|
|
@@ -31783,9 +30967,9 @@ async function readQfaiSkills(skillsDir) {
|
|
|
31783
30967
|
const skills = [];
|
|
31784
30968
|
for (const entry of entries) {
|
|
31785
30969
|
if (!entry.isDirectory() || !QFAI_SKILL_ID_RE2.test(entry.name)) continue;
|
|
31786
|
-
const skillDoc =
|
|
30970
|
+
const skillDoc = path124.join(skillsDir, entry.name, "SKILL.md");
|
|
31787
30971
|
try {
|
|
31788
|
-
skills.push({ skillId: entry.name, skillDoc, body: await
|
|
30972
|
+
skills.push({ skillId: entry.name, skillDoc, body: await readFile63(skillDoc, "utf-8") });
|
|
31789
30973
|
} catch (err) {
|
|
31790
30974
|
if (isEnoent(err)) continue;
|
|
31791
30975
|
throw err;
|
|
@@ -31796,14 +30980,14 @@ async function readQfaiSkills(skillsDir) {
|
|
|
31796
30980
|
async function baselineIssues(root, baselinePath) {
|
|
31797
30981
|
let content;
|
|
31798
30982
|
try {
|
|
31799
|
-
content = await
|
|
30983
|
+
content = await readFile63(baselinePath, "utf-8");
|
|
31800
30984
|
} catch (err) {
|
|
31801
30985
|
if (!isEnoent(err)) throw err;
|
|
31802
30986
|
content = null;
|
|
31803
30987
|
}
|
|
31804
30988
|
const missing = content === null ? null : missingBaselineBuckets(content);
|
|
31805
30989
|
if (missing !== null && missing.length === 0) return [];
|
|
31806
|
-
const relPath =
|
|
30990
|
+
const relPath = path124.relative(root, baselinePath).replace(/\\/g, "/");
|
|
31807
30991
|
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(", ")}].`;
|
|
31808
30992
|
return [
|
|
31809
30993
|
issue("QFAI-POLICY-001", message, "error", relPath, "reviewerGate.autopilotPolicyMissing")
|
|
@@ -31838,21 +31022,21 @@ function skillPolicyIssues(relPath, skillId, result) {
|
|
|
31838
31022
|
return issues;
|
|
31839
31023
|
}
|
|
31840
31024
|
async function validateAutopilotPolicy(root, options = {}) {
|
|
31841
|
-
const skillsDir = options.config ? resolvePath(root, options.config, "skillsDir") :
|
|
31025
|
+
const skillsDir = options.config ? resolvePath(root, options.config, "skillsDir") : path124.join(root, SKILL_DIR_REL);
|
|
31842
31026
|
if (!await exists3(skillsDir)) return [];
|
|
31843
31027
|
const skills = await readQfaiSkills(skillsDir);
|
|
31844
31028
|
if (skills.length === 0) return [];
|
|
31845
|
-
const issues = await baselineIssues(root,
|
|
31029
|
+
const issues = await baselineIssues(root, path124.join(path124.dirname(skillsDir), BASELINE_REL));
|
|
31846
31030
|
for (const { skillId, skillDoc, body } of skills) {
|
|
31847
|
-
const relPath =
|
|
31031
|
+
const relPath = path124.relative(root, skillDoc).replace(/\\/g, "/");
|
|
31848
31032
|
issues.push(...skillPolicyIssues(relPath, skillId, parseAutopilotPolicy(body, skillId)));
|
|
31849
31033
|
}
|
|
31850
31034
|
return issues;
|
|
31851
31035
|
}
|
|
31852
31036
|
|
|
31853
31037
|
// src/core/validators/handoffSchemaDrift.ts
|
|
31854
|
-
import { readFile as
|
|
31855
|
-
import
|
|
31038
|
+
import { readFile as readFile64 } from "fs/promises";
|
|
31039
|
+
import path125 from "path";
|
|
31856
31040
|
|
|
31857
31041
|
// src/core/validators/handoffSchemaPairs.ts
|
|
31858
31042
|
var HANDOFF_SCHEMA_REL = "packages/qfai/src/core/schemas/handoff.ts";
|
|
@@ -31875,11 +31059,11 @@ function schemaFields(schemaText) {
|
|
|
31875
31059
|
);
|
|
31876
31060
|
}
|
|
31877
31061
|
async function detectHandoffSchemaDrift(root) {
|
|
31878
|
-
const schemaAbs =
|
|
31062
|
+
const schemaAbs = path125.join(root, HANDOFF_SCHEMA_REL);
|
|
31879
31063
|
if (!await exists3(schemaAbs)) return [];
|
|
31880
31064
|
let schemaText;
|
|
31881
31065
|
try {
|
|
31882
|
-
schemaText = await
|
|
31066
|
+
schemaText = await readFile64(schemaAbs, "utf-8");
|
|
31883
31067
|
} catch {
|
|
31884
31068
|
return [];
|
|
31885
31069
|
}
|
|
@@ -31888,11 +31072,11 @@ async function detectHandoffSchemaDrift(root) {
|
|
|
31888
31072
|
const fields = schemaFields(schemaText);
|
|
31889
31073
|
const issues = [];
|
|
31890
31074
|
for (const pair of HANDOFF_WRITER_PAIRS) {
|
|
31891
|
-
const writerAbs =
|
|
31075
|
+
const writerAbs = path125.join(root, pair.writerRel);
|
|
31892
31076
|
if (!await exists3(writerAbs)) continue;
|
|
31893
31077
|
let writerText;
|
|
31894
31078
|
try {
|
|
31895
|
-
writerText = await
|
|
31079
|
+
writerText = await readFile64(writerAbs, "utf-8");
|
|
31896
31080
|
} catch {
|
|
31897
31081
|
continue;
|
|
31898
31082
|
}
|
|
@@ -31910,13 +31094,13 @@ async function detectHandoffSchemaDrift(root) {
|
|
|
31910
31094
|
}
|
|
31911
31095
|
|
|
31912
31096
|
// src/core/validators/packageSelfGovernance.ts
|
|
31913
|
-
import
|
|
31097
|
+
import path126 from "path";
|
|
31914
31098
|
async function handoffSchemaDriftEvaluable(root) {
|
|
31915
|
-
if (!await exists3(
|
|
31099
|
+
if (!await exists3(path126.join(root, HANDOFF_SCHEMA_REL))) {
|
|
31916
31100
|
return false;
|
|
31917
31101
|
}
|
|
31918
31102
|
for (const pair of HANDOFF_WRITER_PAIRS) {
|
|
31919
|
-
if (await exists3(
|
|
31103
|
+
if (await exists3(path126.join(root, pair.writerRel))) {
|
|
31920
31104
|
return true;
|
|
31921
31105
|
}
|
|
31922
31106
|
}
|
|
@@ -31924,7 +31108,7 @@ async function handoffSchemaDriftEvaluable(root) {
|
|
|
31924
31108
|
}
|
|
31925
31109
|
async function skillManifestDriftEvaluable(root) {
|
|
31926
31110
|
for (const pair of SKILL_MANIFEST_PAIRS) {
|
|
31927
|
-
if (await exists3(
|
|
31111
|
+
if (await exists3(path126.join(root, pair.probeImplRel)) && await exists3(path126.join(root, pair.schemaRel))) {
|
|
31928
31112
|
return true;
|
|
31929
31113
|
}
|
|
31930
31114
|
}
|
|
@@ -32014,10 +31198,10 @@ async function validateProject(root, configResult, options = {}) {
|
|
|
32014
31198
|
const specsRoot = resolvePath(root, config, "specsDir");
|
|
32015
31199
|
let oldLayoutRoot;
|
|
32016
31200
|
const oldLayoutFiles = [];
|
|
32017
|
-
for (const candidate2 of /* @__PURE__ */ new Set([specsRoot,
|
|
31201
|
+
for (const candidate2 of /* @__PURE__ */ new Set([specsRoot, path127.join(root, ".qfai", "specs")])) {
|
|
32018
31202
|
let entries = [];
|
|
32019
31203
|
try {
|
|
32020
|
-
entries = await
|
|
31204
|
+
entries = await readdir35(candidate2);
|
|
32021
31205
|
} catch (error2) {
|
|
32022
31206
|
if (error2.code !== "ENOENT") throw error2;
|
|
32023
31207
|
}
|
|
@@ -32145,7 +31329,7 @@ function isUnder2(base, candidate2) {
|
|
|
32145
31329
|
return candidate2 === base || candidate2.startsWith(`${base}/`);
|
|
32146
31330
|
}
|
|
32147
31331
|
function toRepoRelative2(root, absolute) {
|
|
32148
|
-
return
|
|
31332
|
+
return path127.relative(root, absolute).split(path127.sep).join("/");
|
|
32149
31333
|
}
|
|
32150
31334
|
function consumesPlatformOption(profile) {
|
|
32151
31335
|
switch (profile) {
|
|
@@ -32562,7 +31746,7 @@ async function runUiuxValidators(root, config, timings, platformOption) {
|
|
|
32562
31746
|
["mermaid screen flow", () => validateMermaidScreenFlow(root, config)],
|
|
32563
31747
|
["UI definition consistency", () => validateUiDefinitionConsistency(root, config)],
|
|
32564
31748
|
["research summary", () => validateResearchSummary(root, config)],
|
|
32565
|
-
["agent definition", () => validateAgentDefinition(root
|
|
31749
|
+
["agent definition", () => validateAgentDefinition(root)],
|
|
32566
31750
|
["design audit", () => validateDesignAudit(root, config)],
|
|
32567
31751
|
["canonical UIX", () => runCanonicalUixValidators(root, config)]
|
|
32568
31752
|
];
|
|
@@ -32594,7 +31778,7 @@ async function runUiuxValidators(root, config, timings, platformOption) {
|
|
|
32594
31778
|
}
|
|
32595
31779
|
async function validatePrototypingSkill(root, config) {
|
|
32596
31780
|
const skillsDir = resolvePath(root, config, "skillsDir");
|
|
32597
|
-
const prototypingSkillPath =
|
|
31781
|
+
const prototypingSkillPath = path127.join(skillsDir, "qfai-prototyping", "SKILL.md");
|
|
32598
31782
|
const prototypingSkillContent = await readSafe(prototypingSkillPath);
|
|
32599
31783
|
if (prototypingSkillContent.length === 0) {
|
|
32600
31784
|
return [];
|
|
@@ -32603,16 +31787,16 @@ async function validatePrototypingSkill(root, config) {
|
|
|
32603
31787
|
return validatePrototypingSkillContent([prototypingSkillContent, ...stepBodies].join("\n")).issues;
|
|
32604
31788
|
}
|
|
32605
31789
|
async function readPrototypingStepBodies(root) {
|
|
32606
|
-
const stepDir =
|
|
31790
|
+
const stepDir = path127.join(root, ".qfai", "assistant", "step");
|
|
32607
31791
|
let names;
|
|
32608
31792
|
try {
|
|
32609
|
-
names = await
|
|
31793
|
+
names = await readdir35(stepDir);
|
|
32610
31794
|
} catch (error2) {
|
|
32611
31795
|
if (isEnoent(error2)) return [];
|
|
32612
31796
|
throw error2;
|
|
32613
31797
|
}
|
|
32614
31798
|
const stepNames = names.filter((name) => name.startsWith("prototyping-")).sort();
|
|
32615
|
-
return Promise.all(stepNames.map((name) => readSafe(
|
|
31799
|
+
return Promise.all(stepNames.map((name) => readSafe(path127.join(stepDir, name, "STEP.md"))));
|
|
32616
31800
|
}
|
|
32617
31801
|
function countIssues(issues) {
|
|
32618
31802
|
return issues.reduce(
|
|
@@ -32629,13 +31813,13 @@ function countIssues(issues) {
|
|
|
32629
31813
|
|
|
32630
31814
|
// src/cli/commands/validate.ts
|
|
32631
31815
|
import { mkdir as mkdir22, writeFile as writeFile18 } from "fs/promises";
|
|
32632
|
-
import
|
|
31816
|
+
import path129 from "path";
|
|
32633
31817
|
|
|
32634
31818
|
// src/core/runLog.ts
|
|
32635
|
-
import { mkdir as mkdir21, readdir as
|
|
32636
|
-
import
|
|
31819
|
+
import { mkdir as mkdir21, readdir as readdir36, readFile as readFile65, writeFile as writeFile17 } from "fs/promises";
|
|
31820
|
+
import path128 from "path";
|
|
32637
31821
|
async function writeValidateRunLog(input) {
|
|
32638
|
-
const root =
|
|
31822
|
+
const root = path128.resolve(input.root);
|
|
32639
31823
|
const outDir = resolvePath(root, input.config, "outDir");
|
|
32640
31824
|
await mkdir21(outDir, { recursive: true });
|
|
32641
31825
|
const { runId, reportDir } = await allocateRunReportDir(outDir, input.startedAt);
|
|
@@ -32683,10 +31867,10 @@ async function writeValidateRunLog(input) {
|
|
|
32683
31867
|
errors,
|
|
32684
31868
|
warnings
|
|
32685
31869
|
});
|
|
32686
|
-
await writeJson(
|
|
32687
|
-
await writeJson(
|
|
32688
|
-
await writeJson(
|
|
32689
|
-
await writeFile17(
|
|
31870
|
+
await writeJson(path128.join(reportDir, "run.json"), runJson);
|
|
31871
|
+
await writeJson(path128.join(reportDir, "validator.json"), validatorJson);
|
|
31872
|
+
await writeJson(path128.join(reportDir, "traceability.json"), traceabilityJson);
|
|
31873
|
+
await writeFile17(path128.join(reportDir, "summary.md"), `${summaryMd}
|
|
32690
31874
|
`, "utf-8");
|
|
32691
31875
|
await writeLatestValidateLog(
|
|
32692
31876
|
outDir,
|
|
@@ -32713,10 +31897,10 @@ async function writeLatestValidateLog(outDir, runId, buildContents) {
|
|
|
32713
31897
|
if (await hasNewerRunDir(outDir, runId)) {
|
|
32714
31898
|
return;
|
|
32715
31899
|
}
|
|
32716
|
-
const filePath =
|
|
31900
|
+
const filePath = path128.join(outDir, "validate.log");
|
|
32717
31901
|
let existingRunId;
|
|
32718
31902
|
try {
|
|
32719
|
-
existingRunId = RUN_ID_LINE_RE.exec(await
|
|
31903
|
+
existingRunId = RUN_ID_LINE_RE.exec(await readFile65(filePath, "utf-8"))?.[1] ?? null;
|
|
32720
31904
|
} catch {
|
|
32721
31905
|
existingRunId = null;
|
|
32722
31906
|
}
|
|
@@ -32728,7 +31912,7 @@ async function writeLatestValidateLog(outDir, runId, buildContents) {
|
|
|
32728
31912
|
}
|
|
32729
31913
|
async function hasNewerRunDir(runRoot, runId) {
|
|
32730
31914
|
try {
|
|
32731
|
-
const entries = await
|
|
31915
|
+
const entries = await readdir36(runRoot, { withFileTypes: true });
|
|
32732
31916
|
return entries.some(
|
|
32733
31917
|
(entry) => entry.isDirectory() && RUN_DIR_RE.test(entry.name) && entry.name > runId
|
|
32734
31918
|
);
|
|
@@ -32868,7 +32052,7 @@ async function allocateRunDir(parentDir, startedAt) {
|
|
|
32868
32052
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
32869
32053
|
const candidateDate = new Date(startedAt.getTime() + attempt);
|
|
32870
32054
|
const runId = `run-${formatTimestamp17(candidateDate)}`;
|
|
32871
|
-
const runDir =
|
|
32055
|
+
const runDir = path128.join(parentDir, runId);
|
|
32872
32056
|
try {
|
|
32873
32057
|
await mkdir21(runDir);
|
|
32874
32058
|
return { runId, runDir };
|
|
@@ -32951,7 +32135,7 @@ async function runValidate(options) {
|
|
|
32951
32135
|
if (format === "text") {
|
|
32952
32136
|
emitStartedLine(options.profile ?? "full");
|
|
32953
32137
|
}
|
|
32954
|
-
const root =
|
|
32138
|
+
const root = path129.resolve(options.root);
|
|
32955
32139
|
const configResult = await loadConfig(root);
|
|
32956
32140
|
const ciProfileIssue = buildCiProfileIssue(options.profile);
|
|
32957
32141
|
let validated;
|
|
@@ -33060,11 +32244,11 @@ function scopedReportPath(configuredPath, flowIds) {
|
|
|
33060
32244
|
return `${dir}${stem}.flow-${suffix}${ext}`;
|
|
33061
32245
|
}
|
|
33062
32246
|
function profileSuffixedReportPath(configured, profile) {
|
|
33063
|
-
const dir =
|
|
33064
|
-
const base =
|
|
33065
|
-
const ext =
|
|
32247
|
+
const dir = path129.posix.dirname(configured.replace(/\\/g, "/"));
|
|
32248
|
+
const base = path129.posix.basename(configured.replace(/\\/g, "/"));
|
|
32249
|
+
const ext = path129.posix.extname(base);
|
|
33066
32250
|
const stem = ext.length > 0 ? base.slice(0, -ext.length) : base;
|
|
33067
|
-
return
|
|
32251
|
+
return path129.posix.join(dir, `${stem}-${profile}${ext}`);
|
|
33068
32252
|
}
|
|
33069
32253
|
var GATE_GROUP_FAMILIES = {
|
|
33070
32254
|
hygiene: ["QFAI-HYG-*"],
|
|
@@ -33310,6 +32494,16 @@ function formatTextIssueLine(item) {
|
|
|
33310
32494
|
const suppressed = item.suppressed ? " suppressed=true" : "";
|
|
33311
32495
|
return `[${item.severity}] ${item.code} ${item.message}${location}${refs}${suppressed}`;
|
|
33312
32496
|
}
|
|
32497
|
+
function textGroupFixes(head, shown, failOn) {
|
|
32498
|
+
if (shouldEmitIssueDetail(head, failOn)) {
|
|
32499
|
+
return new Set(shown.map(resolveIssueFix));
|
|
32500
|
+
}
|
|
32501
|
+
if (head.severity !== "warning") {
|
|
32502
|
+
return /* @__PURE__ */ new Set();
|
|
32503
|
+
}
|
|
32504
|
+
const known = shown.map((item) => item.suggested_action ?? ISSUE_FIX_BY_CODE[item.code]);
|
|
32505
|
+
return new Set(known.filter((fix) => fix !== void 0));
|
|
32506
|
+
}
|
|
33313
32507
|
function emitText(result, failOn) {
|
|
33314
32508
|
for (const group of groupIssues(result.issues)) {
|
|
33315
32509
|
const shown = group.items.slice(0, TEXT_ISSUES_PER_GROUP);
|
|
@@ -33325,10 +32519,8 @@ function emitText(result, failOn) {
|
|
|
33325
32519
|
`
|
|
33326
32520
|
);
|
|
33327
32521
|
}
|
|
33328
|
-
|
|
33329
|
-
|
|
33330
|
-
emitTextField("fix", fix);
|
|
33331
|
-
}
|
|
32522
|
+
for (const fix of textGroupFixes(group.head, shown, failOn)) {
|
|
32523
|
+
emitTextField("fix", fix);
|
|
33332
32524
|
}
|
|
33333
32525
|
}
|
|
33334
32526
|
process.stdout.write(
|
|
@@ -33544,12 +32736,12 @@ function issueKey(issue2) {
|
|
|
33544
32736
|
}
|
|
33545
32737
|
async function emitJson(result, root, jsonPath) {
|
|
33546
32738
|
const abs = resolveJsonPath(root, jsonPath);
|
|
33547
|
-
await mkdir22(
|
|
32739
|
+
await mkdir22(path129.dirname(abs), { recursive: true });
|
|
33548
32740
|
await writeFile18(abs, `${JSON.stringify(result, null, 2)}
|
|
33549
32741
|
`, "utf-8");
|
|
33550
32742
|
}
|
|
33551
32743
|
function resolveJsonPath(root, jsonPath) {
|
|
33552
|
-
return
|
|
32744
|
+
return path129.isAbsolute(jsonPath) ? jsonPath : path129.resolve(root, jsonPath);
|
|
33553
32745
|
}
|
|
33554
32746
|
var GITHUB_ANNOTATION_LIMIT_PER_LEVEL = 10;
|
|
33555
32747
|
var ISSUE_EXPECTED_BY_CODE = {
|
|
@@ -33608,11 +32800,6 @@ var ISSUE_EXPECTED_BY_CODE = {
|
|
|
33608
32800
|
"QFAI-DCON-030": "Root DESIGN.md is required as the brand SSOT for UI-bearing projects (file missing).",
|
|
33609
32801
|
"QFAI-DCON-033": "Root DESIGN.md exists but failed to parse per design-md-spec (front-matter is malformed).",
|
|
33610
32802
|
"QFAI-DCON-034": "Root DESIGN.md must be the project's own brand SSOT, not the unreplaced qfai sample seeded by `qfai init`.",
|
|
33611
|
-
"QFAI-AGENT-015": "Every role a step or skill declares is dispatchable: some routing phase or its review profile selects it.",
|
|
33612
|
-
"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.",
|
|
33613
|
-
"QFAI-AGENT-017": "Every step or skill that declares a `routing-profile:` is routed at least one dispatchable phase by the routing manifest.",
|
|
33614
|
-
"QFAI-AGENT-018": "Each routed step or skill has exactly one review gate, named by both sides and defined in the review-profile manifest.",
|
|
33615
|
-
"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.",
|
|
33616
32803
|
"QFAI-RESEARCH-012": "The latest discussion pack carries a `## Research Summary` section, so the research-first protocol has something to check.",
|
|
33617
32804
|
// The apply-order family. Each of these reads a column or a declaration that
|
|
33618
32805
|
// nothing read before them, so a project meeting one of them for the first
|
|
@@ -33645,7 +32832,7 @@ var ISSUE_EXPECTED_BY_CODE = {
|
|
|
33645
32832
|
"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.",
|
|
33646
32833
|
"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.",
|
|
33647
32834
|
"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.",
|
|
33648
|
-
"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
|
|
32835
|
+
"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.",
|
|
33649
32836
|
"QFAI-SAAS-001": "The saas-package profile finds a design-system attestation at its configured path.",
|
|
33650
32837
|
"QFAI-SAAS-002": "A cross-skill handoff, when present, parses as an object and conforms to the handoff schema.",
|
|
33651
32838
|
"QFAI-DRIFT-001": "Upstream SSOT files are unchanged relative to the base branch, or the change carries an approved Change Request.",
|
|
@@ -33667,13 +32854,8 @@ var ISSUE_EXPECTED_BY_CODE = {
|
|
|
33667
32854
|
"QFAI-ASSISTANT-002": "Every canonical `.qfai/assistant/` layer directory is seeded.",
|
|
33668
32855
|
"QFAI-CFG-002": "Every value in qfai.config.yaml has the type and range its key declares.",
|
|
33669
32856
|
"QFAI-AGENT-005": "Every agent definition file has each required section heading.",
|
|
33670
|
-
"QFAI-AGENT-007": "The agent routing manifest and its defaults file can be read and parse to the shape the routing check expects.",
|
|
33671
|
-
"QFAI-AGENT-008": "Every agent a routing phase names is a defined agent.",
|
|
33672
|
-
"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.",
|
|
33673
|
-
"QFAI-AGENT-010": "Every id a review profile lists in its `_required` fields is a reviewer agent.",
|
|
33674
32857
|
"QFAI-AGENT-011": "Every agent definition file carries front matter that parses.",
|
|
33675
32858
|
"QFAI-AGENT-012": "An agent definition's front-matter `name` equals its file's agent id.",
|
|
33676
|
-
"QFAI-AGENT-013": "Every routing phase declares an `iteration`, `rerun_policy`, `review_profile` and agent fields drawn from the values the routing check allows.",
|
|
33677
32859
|
"QFAI-ASSETS-001": "The drift-protocol rule file exists under the assistant tree.",
|
|
33678
32860
|
"QFAI-ASSETS-002": "The test-layers rule file exists under the assistant tree.",
|
|
33679
32861
|
"QFAI-AUD-001": "Every screen in a UI contract lists at least one `primary_tasks` entry.",
|
|
@@ -33819,12 +33001,7 @@ var ISSUE_FIX_BY_CODE = {
|
|
|
33819
33001
|
// two rows, two CAPs on one directory) pass no `suggested_action`, and one
|
|
33820
33002
|
// repair covers them: the `Spec` cell is the mapping, so the fix is always to
|
|
33821
33003
|
// make each row name exactly one directory that no other row names.
|
|
33822
|
-
"QFAI-
|
|
33823
|
-
"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.",
|
|
33824
|
-
"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.",
|
|
33825
|
-
"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.",
|
|
33826
|
-
"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`.",
|
|
33827
|
-
"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:`.",
|
|
33004
|
+
"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:`.",
|
|
33828
33005
|
// The orphan-prohibition emitter passes no `suggested_action` on any path, so
|
|
33829
33006
|
// every rung of the ladder depends on this catalog for its `fix:` line. The
|
|
33830
33007
|
// even codes are repaired by writing a `Parent`, the odd ones by pointing an
|
|
@@ -33871,7 +33048,7 @@ function escapeGitHubCommandProperty(value) {
|
|
|
33871
33048
|
// src/cli/commands/report.ts
|
|
33872
33049
|
function resolveReportPaths(root, config, options) {
|
|
33873
33050
|
const outRoot = resolvePath(root, config, "outDir");
|
|
33874
|
-
const defaultOut = options.format === "json" ?
|
|
33051
|
+
const defaultOut = options.format === "json" ? path130.join(outRoot, "report.json") : path130.join(outRoot, "report.md");
|
|
33875
33052
|
const configuredValidateJson = config.output.validateJsonPath;
|
|
33876
33053
|
const flowIds = options.flowIds ?? [];
|
|
33877
33054
|
const scopedValidateJson = flowIds.length > 0 ? scopedReportPath(configuredValidateJson, flowIds) : configuredValidateJson;
|
|
@@ -33882,15 +33059,15 @@ function resolveReportPaths(root, config, options) {
|
|
|
33882
33059
|
const out = options.outPath ?? scopedOut;
|
|
33883
33060
|
return {
|
|
33884
33061
|
validateJsonPath: scopedValidateJson,
|
|
33885
|
-
outPath:
|
|
33062
|
+
outPath: path130.isAbsolute(out) ? out : path130.resolve(root, out)
|
|
33886
33063
|
};
|
|
33887
33064
|
}
|
|
33888
33065
|
function inputCarriesRequestedScope(inputPath, scopedValidateJsonPath, profile) {
|
|
33889
|
-
const accepted = /* @__PURE__ */ new Set([
|
|
33066
|
+
const accepted = /* @__PURE__ */ new Set([path130.basename(scopedValidateJsonPath)]);
|
|
33890
33067
|
if (profile) {
|
|
33891
|
-
accepted.add(
|
|
33068
|
+
accepted.add(path130.basename(profileSuffixedReportPath(scopedValidateJsonPath, profile)));
|
|
33892
33069
|
}
|
|
33893
|
-
return accepted.has(
|
|
33070
|
+
return accepted.has(path130.basename(inputPath));
|
|
33894
33071
|
}
|
|
33895
33072
|
function buildMissingInputGuidance(inputPath, flowIds, profile, expectedValidateJsonPath) {
|
|
33896
33073
|
const header = [`qfai report: input file not found: ${inputPath}`, ""];
|
|
@@ -33919,7 +33096,7 @@ function buildMissingInputGuidance(inputPath, flowIds, profile, expectedValidate
|
|
|
33919
33096
|
].join("\n");
|
|
33920
33097
|
}
|
|
33921
33098
|
async function runReport(options) {
|
|
33922
|
-
const root =
|
|
33099
|
+
const root = path130.resolve(options.root);
|
|
33923
33100
|
const configResult = await loadConfig(root);
|
|
33924
33101
|
const flowIds = options.flowIds ?? [];
|
|
33925
33102
|
const storyTree = await isStoryTreeProject(root, configResult.config);
|
|
@@ -33972,7 +33149,7 @@ async function runReport(options) {
|
|
|
33972
33149
|
[
|
|
33973
33150
|
`qfai report: the --in validate result does not match the --${unit} scope: ${inputPath}`,
|
|
33974
33151
|
`report with --${unit} takes counts, issues, and waiver totals from the input file as they are.`,
|
|
33975
|
-
`Pass the scoped validate result named ${
|
|
33152
|
+
`Pass the scoped validate result named ${path130.basename(paths.validateJsonPath)}. For example:`,
|
|
33976
33153
|
` qfai validate ${scopeArgs}`,
|
|
33977
33154
|
` qfai report ${scopeArgs}`
|
|
33978
33155
|
].join("\n")
|
|
@@ -33995,7 +33172,7 @@ async function runReport(options) {
|
|
|
33995
33172
|
const data = await createReportData(root, configResult.config, validation, flowIds);
|
|
33996
33173
|
const output = options.format === "json" ? formatReportJson(data) : formatReportMarkdown(data, options.baseUrl ? { baseUrl: options.baseUrl } : {});
|
|
33997
33174
|
const outPath = paths.outPath;
|
|
33998
|
-
await mkdir23(
|
|
33175
|
+
await mkdir23(path130.dirname(outPath), { recursive: true });
|
|
33999
33176
|
await writeFile19(outPath, `${output}
|
|
34000
33177
|
`, "utf-8");
|
|
34001
33178
|
await writeBusinessFlowReports(root, configResult.config, flowIds);
|
|
@@ -34034,7 +33211,7 @@ function resolveFailOn2(options, fallback) {
|
|
|
34034
33211
|
}
|
|
34035
33212
|
function resolveInputPath(root, configuredPath, inputPath, profile) {
|
|
34036
33213
|
const input = inputPath ?? (profile ? profileSuffixedReportPath(configuredPath, profile) : configuredPath);
|
|
34037
|
-
return
|
|
33214
|
+
return path130.isAbsolute(input) ? input : path130.resolve(root, input);
|
|
34038
33215
|
}
|
|
34039
33216
|
async function loadValidationResult(inputPath, flowIds, profile, expectedValidateJsonPath) {
|
|
34040
33217
|
try {
|
|
@@ -34056,7 +33233,7 @@ function warnOnProfileMismatch(inputPath, validation, profile) {
|
|
|
34056
33233
|
);
|
|
34057
33234
|
}
|
|
34058
33235
|
async function readValidationResult(inputPath) {
|
|
34059
|
-
const raw = await
|
|
33236
|
+
const raw = await readFile66(inputPath, "utf-8");
|
|
34060
33237
|
const parsed = JSON.parse(raw);
|
|
34061
33238
|
if (!isValidationResult(parsed)) {
|
|
34062
33239
|
throw new Error(`validate.json has an invalid shape: ${inputPath}`);
|
|
@@ -34138,23 +33315,23 @@ async function writeValidationResults(root, configuredPath, result, requestedPro
|
|
|
34138
33315
|
);
|
|
34139
33316
|
}
|
|
34140
33317
|
async function writeValidationResult(root, outputPath, result) {
|
|
34141
|
-
const abs =
|
|
34142
|
-
await mkdir23(
|
|
33318
|
+
const abs = path130.isAbsolute(outputPath) ? outputPath : path130.resolve(root, outputPath);
|
|
33319
|
+
await mkdir23(path130.dirname(abs), { recursive: true });
|
|
34143
33320
|
await writeFile19(abs, `${JSON.stringify(result, null, 2)}
|
|
34144
33321
|
`, "utf-8");
|
|
34145
33322
|
}
|
|
34146
33323
|
|
|
34147
33324
|
// src/cli/commands/sddMergeDocs.ts
|
|
34148
33325
|
import { execFile as execFile4 } from "child_process";
|
|
34149
|
-
import { readFile as
|
|
34150
|
-
import
|
|
33326
|
+
import { readFile as readFile67, writeFile as writeFile21 } from "fs/promises";
|
|
33327
|
+
import path132 from "path";
|
|
34151
33328
|
import { promisify as promisify5 } from "util";
|
|
34152
33329
|
|
|
34153
33330
|
// src/core/storyTree/sentenceMerge.ts
|
|
34154
33331
|
import { execFile as execFile3 } from "child_process";
|
|
34155
33332
|
import { mkdtemp as mkdtemp2, rm as rm14, writeFile as writeFile20 } from "fs/promises";
|
|
34156
33333
|
import os4 from "os";
|
|
34157
|
-
import
|
|
33334
|
+
import path131 from "path";
|
|
34158
33335
|
import { promisify as promisify4 } from "util";
|
|
34159
33336
|
var execute3 = promisify4(execFile3);
|
|
34160
33337
|
var MAX_BUFFER = 64 * 1024 * 1024;
|
|
@@ -34328,9 +33505,9 @@ async function isGitConflictOutput(working, base, ours, theirs) {
|
|
|
34328
33505
|
return false;
|
|
34329
33506
|
}
|
|
34330
33507
|
async function runMergeFile(base, ours, theirs, options) {
|
|
34331
|
-
const dir = await mkdtemp2(
|
|
33508
|
+
const dir = await mkdtemp2(path131.join(os4.tmpdir(), "qfai-merge-docs-"));
|
|
34332
33509
|
try {
|
|
34333
|
-
const files = ["ours", "base", "theirs"].map((name) =>
|
|
33510
|
+
const files = ["ours", "base", "theirs"].map((name) => path131.join(dir, name));
|
|
34334
33511
|
const [oursFile = "", baseFile = "", theirsFile = ""] = files;
|
|
34335
33512
|
await Promise.all([
|
|
34336
33513
|
writeFile20(oursFile, ours, "utf8"),
|
|
@@ -34537,13 +33714,13 @@ var OWN_MARKER = /^(?:<<<<<<< ours|>>>>>>> theirs)\r?$/mu;
|
|
|
34537
33714
|
var REGULAR_FILE = /* @__PURE__ */ new Set(["100644", "100755"]);
|
|
34538
33715
|
var SCHEMA_VIOLATION = "QFAI-DOCSCHEMA-001";
|
|
34539
33716
|
async function runSddMergeDocsCommand(options) {
|
|
34540
|
-
const root =
|
|
33717
|
+
const root = path132.resolve(options.root);
|
|
34541
33718
|
try {
|
|
34542
33719
|
const loaded2 = await loadConfig(root);
|
|
34543
33720
|
if (loaded2.issues.length) throw new Error("Correct qfai.config.yaml before merging documents.");
|
|
34544
|
-
const scope =
|
|
33721
|
+
const scope = path132.relative(root, resolvePath(root, loaded2.config, "specsDir")) || ".";
|
|
34545
33722
|
const unmerged = readUnmerged(await gitText(root, ["ls-files", "-u", "-z", "--", scope]));
|
|
34546
|
-
const label = scope.split(
|
|
33723
|
+
const label = scope.split(path132.sep).join("/");
|
|
34547
33724
|
if (unmerged.size === 0) {
|
|
34548
33725
|
info(`qfai sdd merge-docs: no conflicted document under ${label}; nothing to merge.`);
|
|
34549
33726
|
return EXIT_CODES.ok;
|
|
@@ -34577,10 +33754,10 @@ async function mergeOne(root, file, stages) {
|
|
|
34577
33754
|
const present = [stages.base, stages.ours, stages.theirs].filter((stage) => stage !== void 0);
|
|
34578
33755
|
if (present.some((stage) => !REGULAR_FILE.has(stage.mode)))
|
|
34579
33756
|
return left("it is not a regular file");
|
|
34580
|
-
const target =
|
|
33757
|
+
const target = path132.join(root, ...file.split("/"));
|
|
34581
33758
|
let working;
|
|
34582
33759
|
try {
|
|
34583
|
-
working = await
|
|
33760
|
+
working = await readFile67(target, "utf8");
|
|
34584
33761
|
} catch (failure2) {
|
|
34585
33762
|
return left(
|
|
34586
33763
|
`the working file could not be read: ${failure2 instanceof Error ? failure2.message : String(failure2)}`
|
|
@@ -34644,12 +33821,12 @@ import fs2, {
|
|
|
34644
33821
|
lstat as lstat24,
|
|
34645
33822
|
mkdir as mkdir24,
|
|
34646
33823
|
readlink as readlink5,
|
|
34647
|
-
readdir as
|
|
33824
|
+
readdir as readdir37,
|
|
34648
33825
|
rmdir as rmdir2,
|
|
34649
33826
|
unlink as unlink3,
|
|
34650
33827
|
writeFile as writeFile22
|
|
34651
33828
|
} from "fs/promises";
|
|
34652
|
-
import
|
|
33829
|
+
import path133 from "path";
|
|
34653
33830
|
import { promisify as promisify6 } from "util";
|
|
34654
33831
|
var execute5 = promisify6(execFile5);
|
|
34655
33832
|
var MAX_BYTES = 16 * 1024 * 1024;
|
|
@@ -34697,10 +33874,10 @@ async function commit(root, ref) {
|
|
|
34697
33874
|
return value;
|
|
34698
33875
|
}
|
|
34699
33876
|
async function repositoryPaths(projectRoot, directories) {
|
|
34700
|
-
const root = (await git2(
|
|
33877
|
+
const root = (await git2(path133.resolve(projectRoot), ["rev-parse", "--show-toplevel"])).toString().trim();
|
|
34701
33878
|
const relative = directories.map((directory) => {
|
|
34702
|
-
const value =
|
|
34703
|
-
if (value === ".." || value.startsWith("../") ||
|
|
33879
|
+
const value = path133.relative(root, path133.resolve(projectRoot, directory)).split(path133.sep).join("/");
|
|
33880
|
+
if (value === ".." || value.startsWith("../") || path133.isAbsolute(value))
|
|
34704
33881
|
throw new Error("The story tree must be inside the repository.");
|
|
34705
33882
|
return value;
|
|
34706
33883
|
});
|
|
@@ -34727,23 +33904,23 @@ async function blob(root, sha, file) {
|
|
|
34727
33904
|
return git2(root, ["cat-file", "blob", match[1]]);
|
|
34728
33905
|
}
|
|
34729
33906
|
async function regular(root, file) {
|
|
34730
|
-
const relative =
|
|
34731
|
-
if (relative === "" || relative.startsWith(`..${
|
|
33907
|
+
const relative = path133.relative(root, path133.resolve(root, file));
|
|
33908
|
+
if (relative === "" || relative.startsWith(`..${path133.sep}`) || relative === ".." || path133.isAbsolute(relative))
|
|
34732
33909
|
throw new Error(`Candidate is outside the repository: ${file}`);
|
|
34733
33910
|
let current = root;
|
|
34734
|
-
for (const part of relative.split(
|
|
34735
|
-
current =
|
|
33911
|
+
for (const part of relative.split(path133.sep)) {
|
|
33912
|
+
current = path133.join(current, part);
|
|
34736
33913
|
const stats = await lstat24(current);
|
|
34737
33914
|
if (stats.isSymbolicLink()) throw new Error(`Linked candidate path: ${file}`);
|
|
34738
|
-
if (current ===
|
|
33915
|
+
if (current === path133.resolve(root, file) && !stats.isFile())
|
|
34739
33916
|
throw new Error(`Candidate is not a regular file: ${file}`);
|
|
34740
|
-
if (current ===
|
|
33917
|
+
if (current === path133.resolve(root, file) && stats.nlink > 1)
|
|
34741
33918
|
throw new Error(`Hardlinked candidate path: ${file}`);
|
|
34742
33919
|
}
|
|
34743
33920
|
}
|
|
34744
33921
|
async function original(root, file) {
|
|
34745
33922
|
await regular(root, file);
|
|
34746
|
-
const bytes = await readBoundedRegularFile(
|
|
33923
|
+
const bytes = await readBoundedRegularFile(path133.resolve(root, file), MAX_BYTES);
|
|
34747
33924
|
if (bytes === void 0)
|
|
34748
33925
|
throw new Error(`Candidate is unreadable, oversized or not regular: ${file}`);
|
|
34749
33926
|
return bytes;
|
|
@@ -34751,7 +33928,7 @@ async function original(root, file) {
|
|
|
34751
33928
|
async function inspectLinkPointer(root, file, id) {
|
|
34752
33929
|
let current = root;
|
|
34753
33930
|
for (const part of file.split("/")) {
|
|
34754
|
-
current =
|
|
33931
|
+
current = path133.join(current, part);
|
|
34755
33932
|
const stats = await lstat24(current).catch((failure2) => {
|
|
34756
33933
|
if (typeof failure2 === "object" && failure2 !== null && "code" in failure2 && failure2.code === "ENOENT")
|
|
34757
33934
|
return void 0;
|
|
@@ -34848,7 +34025,7 @@ async function fixedSpecTexts(root, sha, specs, additional = []) {
|
|
|
34848
34025
|
for (const directory of directories) {
|
|
34849
34026
|
let component = "";
|
|
34850
34027
|
for (const part of directory.split("/").filter(Boolean)) {
|
|
34851
|
-
component = component ?
|
|
34028
|
+
component = component ? path133.posix.join(component, part) : part;
|
|
34852
34029
|
components.add(component);
|
|
34853
34030
|
}
|
|
34854
34031
|
}
|
|
@@ -34866,7 +34043,7 @@ async function fixedSpecTexts(root, sha, specs, additional = []) {
|
|
|
34866
34043
|
const pathspecs = directories.map((directory) => directory || ".");
|
|
34867
34044
|
const listing = await git2(root, ["ls-tree", "-r", "-l", "-z", sha, "--", ...pathspecs]);
|
|
34868
34045
|
const entries = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(listing);
|
|
34869
|
-
const decisionPages = `${
|
|
34046
|
+
const decisionPages = `${path133.posix.join(specs, "decisions")}/`;
|
|
34870
34047
|
const wanted = /* @__PURE__ */ new Map();
|
|
34871
34048
|
for (const entry of entries.split("\0").filter(Boolean)) {
|
|
34872
34049
|
const match = /^([0-7]+) blob ([a-f0-9]+) +(\d+)\t(.+)$/.exec(entry);
|
|
@@ -34875,9 +34052,9 @@ async function fixedSpecTexts(root, sha, specs, additional = []) {
|
|
|
34875
34052
|
`The fixed story tree has a non-blob: ${entry.slice(entry.indexOf(" ") + 1)}`
|
|
34876
34053
|
);
|
|
34877
34054
|
const file = match[4];
|
|
34878
|
-
if ((file ===
|
|
34055
|
+
if ((file === path133.posix.join(specs, "decisions.md") || file.startsWith(decisionPages)) && !/^100[0-7]{3}$/.test(match[1]))
|
|
34879
34056
|
throw new Error(`Linked decision path in fixed tree: ${file}`);
|
|
34880
|
-
if (!SUFFIXES.has(
|
|
34057
|
+
if (!SUFFIXES.has(path133.extname(file).toLowerCase()) && !file.startsWith(decisionPages))
|
|
34881
34058
|
continue;
|
|
34882
34059
|
if (Number(match[3]) > MAX_BYTES) throw new Error(`Candidate exceeds 16 MiB: ${file}`);
|
|
34883
34060
|
wanted.set(file, match[2]);
|
|
@@ -34909,7 +34086,7 @@ async function buildDecisionRenumberPlan(options) {
|
|
|
34909
34086
|
root,
|
|
34910
34087
|
relative: [specs = ""]
|
|
34911
34088
|
} = await repositoryPaths(options.root, [options.specsDir]);
|
|
34912
|
-
const decisionFile =
|
|
34089
|
+
const decisionFile = path133.posix.join(specs, "decisions.md");
|
|
34913
34090
|
const headSha = await commit(root, "HEAD");
|
|
34914
34091
|
const baseSha = await commit(root, options.base);
|
|
34915
34092
|
const ancestors = (await git2(root, ["merge-base", "--all", headSha, baseSha])).toString().trim().split(/\s+/);
|
|
@@ -34934,7 +34111,7 @@ async function buildDecisionRenumberPlan(options) {
|
|
|
34934
34111
|
const headRows = records(headTexts, decisionFile);
|
|
34935
34112
|
const ancestorTexts = await fixedSpecTexts(root, ancestorSha, specs);
|
|
34936
34113
|
const ancestorRows = ancestorBytes || [...ancestorTexts.keys()].some(
|
|
34937
|
-
(file) => file.startsWith(`${
|
|
34114
|
+
(file) => file.startsWith(`${path133.posix.join(specs, "decisions")}/`)
|
|
34938
34115
|
) ? records(ancestorTexts, decisionFile) : [];
|
|
34939
34116
|
if (headRows.filter((row) => row.id === options.from).length !== 1)
|
|
34940
34117
|
throw new Error("The source must be one unique current DEC row.");
|
|
@@ -35001,7 +34178,7 @@ async function buildDecisionRenumberPlan(options) {
|
|
|
35001
34178
|
continue;
|
|
35002
34179
|
}
|
|
35003
34180
|
if (!tracked.has(file) || !committed) throw new Error(`Untracked candidate: ${file}`);
|
|
35004
|
-
if (!SUFFIXES.has(
|
|
34181
|
+
if (!SUFFIXES.has(path133.extname(file).toLowerCase()))
|
|
35005
34182
|
throw new Error(`Unsupported candidate suffix: ${file}`);
|
|
35006
34183
|
if (source.replace(/\r\n/g, "\n") !== text2(committed, file).replace(/\r\n/g, "\n") || (await git2(root, [
|
|
35007
34184
|
"diff",
|
|
@@ -35068,7 +34245,7 @@ async function buildDecisionRenumberPlan(options) {
|
|
|
35068
34245
|
};
|
|
35069
34246
|
}
|
|
35070
34247
|
async function applyDecisionRenumberPlan(plan, io = {}) {
|
|
35071
|
-
const read2 = io.readFile ?? ((file) => original(plan.root,
|
|
34248
|
+
const read2 = io.readFile ?? ((file) => original(plan.root, path133.relative(plan.root, file)));
|
|
35072
34249
|
const write = io.writeFile ?? writeFile22;
|
|
35073
34250
|
const checkRefs = async () => {
|
|
35074
34251
|
if (await commit(plan.root, "HEAD") !== plan.headSha || await commit(plan.root, plan.baseRef) !== plan.baseSha)
|
|
@@ -35076,7 +34253,7 @@ async function applyDecisionRenumberPlan(plan, io = {}) {
|
|
|
35076
34253
|
};
|
|
35077
34254
|
const checkOriginal = async (change) => {
|
|
35078
34255
|
await regular(plan.root, change.file);
|
|
35079
|
-
if (!(await read2(
|
|
34256
|
+
if (!(await read2(path133.resolve(plan.root, change.file))).equals(change.original))
|
|
35080
34257
|
throw new Error(`Stale candidate bytes: ${change.file}`);
|
|
35081
34258
|
if ((await git2(plan.root, ["diff", "--cached", "--name-only", plan.headSha, "--", change.file])).length)
|
|
35082
34259
|
throw new Error(`Stale candidate index: ${change.file}`);
|
|
@@ -35089,14 +34266,14 @@ async function applyDecisionRenumberPlan(plan, io = {}) {
|
|
|
35089
34266
|
await checkRefs();
|
|
35090
34267
|
await checkOriginal(change);
|
|
35091
34268
|
attempted.push(change);
|
|
35092
|
-
await write(
|
|
34269
|
+
await write(path133.resolve(plan.root, change.file), change.replacement);
|
|
35093
34270
|
}
|
|
35094
34271
|
} catch (failure2) {
|
|
35095
34272
|
const unrestored = [];
|
|
35096
34273
|
for (const change of attempted.reverse()) {
|
|
35097
34274
|
try {
|
|
35098
34275
|
await regular(plan.root, change.file);
|
|
35099
|
-
const file =
|
|
34276
|
+
const file = path133.resolve(plan.root, change.file);
|
|
35100
34277
|
const current = await read2(file);
|
|
35101
34278
|
if (current.equals(change.original)) continue;
|
|
35102
34279
|
if (!current.equals(change.replacement)) {
|
|
@@ -35141,12 +34318,12 @@ async function runSddNextIdCommand(options) {
|
|
|
35141
34318
|
}
|
|
35142
34319
|
|
|
35143
34320
|
// src/cli/commands/sddPreflight.ts
|
|
35144
|
-
import { readFile as
|
|
35145
|
-
import
|
|
34321
|
+
import { readFile as readFile69 } from "fs/promises";
|
|
34322
|
+
import path135 from "path";
|
|
35146
34323
|
|
|
35147
34324
|
// src/core/preflight/sddPreflight.ts
|
|
35148
|
-
import { mkdir as mkdir25, open as open11, readFile as
|
|
35149
|
-
import
|
|
34325
|
+
import { mkdir as mkdir25, open as open11, readFile as readFile68, stat as stat18, writeFile as writeFile23 } from "fs/promises";
|
|
34326
|
+
import path134 from "path";
|
|
35150
34327
|
var REQ_ID_RE = /\bREQ-\d{4}\b/g;
|
|
35151
34328
|
var PREFLIGHT_SUMMARY_FILE = "preflight_summary.md";
|
|
35152
34329
|
var PREFLIGHT_RUN_ROOT = "preflight";
|
|
@@ -35208,7 +34385,7 @@ async function runSddPreflight(root, config, options = {}) {
|
|
|
35208
34385
|
};
|
|
35209
34386
|
}
|
|
35210
34387
|
const selectedInputPath = readiness.latestPackDir;
|
|
35211
|
-
const reqPath = selectedInputPath === null ? null :
|
|
34388
|
+
const reqPath = selectedInputPath === null ? null : path134.join(selectedInputPath, "06_REQ.md");
|
|
35212
34389
|
return await completeReadyPreflight({
|
|
35213
34390
|
source: "discussion-pack",
|
|
35214
34391
|
selectedInputPath,
|
|
@@ -35251,13 +34428,13 @@ function toSummaryPaths(run2) {
|
|
|
35251
34428
|
};
|
|
35252
34429
|
}
|
|
35253
34430
|
async function allocatePreflightRun(reportRoot, startedAt) {
|
|
35254
|
-
const runRoot =
|
|
34431
|
+
const runRoot = path134.join(reportRoot, PREFLIGHT_RUN_ROOT);
|
|
35255
34432
|
await mkdir25(runRoot, { recursive: true });
|
|
35256
34433
|
const { runId, runDir } = await allocateRunDir(runRoot, startedAt);
|
|
35257
34434
|
return {
|
|
35258
34435
|
runId,
|
|
35259
|
-
summaryPath:
|
|
35260
|
-
latestSummaryPath:
|
|
34436
|
+
summaryPath: path134.join(runDir, PREFLIGHT_SUMMARY_FILE),
|
|
34437
|
+
latestSummaryPath: path134.join(reportRoot, PREFLIGHT_SUMMARY_FILE),
|
|
35261
34438
|
runRoot
|
|
35262
34439
|
};
|
|
35263
34440
|
}
|
|
@@ -35271,7 +34448,7 @@ async function publishPreflightSummary(run2, body) {
|
|
|
35271
34448
|
}
|
|
35272
34449
|
let existingRunId;
|
|
35273
34450
|
try {
|
|
35274
|
-
existingRunId = PREFLIGHT_RUN_ID_LINE_RE.exec(await
|
|
34451
|
+
existingRunId = PREFLIGHT_RUN_ID_LINE_RE.exec(await readFile68(run2.latestSummaryPath, "utf-8"))?.[1] ?? null;
|
|
35275
34452
|
} catch {
|
|
35276
34453
|
existingRunId = null;
|
|
35277
34454
|
}
|
|
@@ -35331,7 +34508,7 @@ async function resolveStoryWorkshopGaps(packDir) {
|
|
|
35331
34508
|
if (packDir === null) {
|
|
35332
34509
|
return [];
|
|
35333
34510
|
}
|
|
35334
|
-
const text3 = await readSafe8(
|
|
34511
|
+
const text3 = await readSafe8(path134.join(packDir, "03_Story-Workshop.md"));
|
|
35335
34512
|
if (text3.length === 0 || containsMermaidBlock(text3)) {
|
|
35336
34513
|
return [];
|
|
35337
34514
|
}
|
|
@@ -35443,14 +34620,14 @@ function isTableSeparator2(line, columnCount) {
|
|
|
35443
34620
|
}
|
|
35444
34621
|
async function readSafe8(filePath) {
|
|
35445
34622
|
try {
|
|
35446
|
-
return await
|
|
34623
|
+
return await readFile68(filePath, "utf-8");
|
|
35447
34624
|
} catch {
|
|
35448
34625
|
return "";
|
|
35449
34626
|
}
|
|
35450
34627
|
}
|
|
35451
34628
|
async function isReadableFile2(filePath) {
|
|
35452
34629
|
try {
|
|
35453
|
-
if (!(await
|
|
34630
|
+
if (!(await stat18(filePath)).isFile()) return false;
|
|
35454
34631
|
await (await open11(filePath, "r")).close();
|
|
35455
34632
|
return true;
|
|
35456
34633
|
} catch {
|
|
@@ -35461,7 +34638,7 @@ async function isReadableFile2(filePath) {
|
|
|
35461
34638
|
// src/cli/commands/sddPreflight.ts
|
|
35462
34639
|
var CARRY_OVER_HEADING = "## Open Questions (Carry-over)";
|
|
35463
34640
|
function toRelative2(root, target) {
|
|
35464
|
-
const relative =
|
|
34641
|
+
const relative = path135.relative(root, target);
|
|
35465
34642
|
return (relative === "" ? target : relative).replace(/\\/g, "/");
|
|
35466
34643
|
}
|
|
35467
34644
|
function renderText2(root, result) {
|
|
@@ -35507,7 +34684,7 @@ async function resolveSelectedPackDir(root) {
|
|
|
35507
34684
|
async function readRecordedCarryOver(summaryPath) {
|
|
35508
34685
|
let text3;
|
|
35509
34686
|
try {
|
|
35510
|
-
text3 = await
|
|
34687
|
+
text3 = await readFile69(summaryPath, "utf-8");
|
|
35511
34688
|
} catch {
|
|
35512
34689
|
return [];
|
|
35513
34690
|
}
|
|
@@ -35538,7 +34715,7 @@ async function resolveCarryOver(root, config, explicit) {
|
|
|
35538
34715
|
return provided;
|
|
35539
34716
|
}
|
|
35540
34717
|
return await readRecordedCarryOver(
|
|
35541
|
-
|
|
34718
|
+
path135.join(resolvePath(root, config, "outDir"), "preflight_summary.md")
|
|
35542
34719
|
);
|
|
35543
34720
|
}
|
|
35544
34721
|
async function runSddPreflightCommand(options) {
|
|
@@ -35570,7 +34747,7 @@ async function runSddPreflightCommand(options) {
|
|
|
35570
34747
|
result = await runSddPreflight(options.root, config, {
|
|
35571
34748
|
...packDir === void 0 ? {} : { packDir },
|
|
35572
34749
|
...assumptions.length > 0 ? { assumptions } : {},
|
|
35573
|
-
...options.importPath === void 0 ? {} : { importPath:
|
|
34750
|
+
...options.importPath === void 0 ? {} : { importPath: path135.resolve(options.root, options.importPath) }
|
|
35574
34751
|
});
|
|
35575
34752
|
} catch (err) {
|
|
35576
34753
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -35623,8 +34800,8 @@ async function runSddRenumberDecisionCommand(options) {
|
|
|
35623
34800
|
}
|
|
35624
34801
|
|
|
35625
34802
|
// src/cli/commands/workflow.ts
|
|
35626
|
-
import { readFile as
|
|
35627
|
-
import
|
|
34803
|
+
import { readFile as readFile71 } from "fs/promises";
|
|
34804
|
+
import path137 from "path";
|
|
35628
34805
|
|
|
35629
34806
|
// src/core/workflow/extraction.ts
|
|
35630
34807
|
var INTENTS = [
|
|
@@ -35896,11 +35073,11 @@ function objectFaults(value, shape, at) {
|
|
|
35896
35073
|
}
|
|
35897
35074
|
|
|
35898
35075
|
// src/core/workflow/plans.ts
|
|
35899
|
-
import { readFile as
|
|
35900
|
-
import
|
|
35076
|
+
import { readFile as readFile70, stat as stat19 } from "fs/promises";
|
|
35077
|
+
import path136 from "path";
|
|
35901
35078
|
|
|
35902
35079
|
// src/core/workflow/planFormat.ts
|
|
35903
|
-
import { parse as
|
|
35080
|
+
import { parse as parseYaml18 } from "yaml";
|
|
35904
35081
|
|
|
35905
35082
|
// src/core/workflow/routes.ts
|
|
35906
35083
|
var WORKFLOW_ROUTES = [
|
|
@@ -36175,7 +35352,7 @@ function refused(refuse, reason, subject) {
|
|
|
36175
35352
|
function unknownKeys(value, known, refuse) {
|
|
36176
35353
|
for (const key of Object.keys(value)) if (!known.includes(key)) refuse("unknown-key", key);
|
|
36177
35354
|
}
|
|
36178
|
-
function
|
|
35355
|
+
function stringList2(value) {
|
|
36179
35356
|
if (Array.isArray(value) && value.every((item) => typeof item === "string")) return value;
|
|
36180
35357
|
return void 0;
|
|
36181
35358
|
}
|
|
@@ -36229,7 +35406,7 @@ function stageOf(value, refuse) {
|
|
|
36229
35406
|
unknownKeys(value, STAGE_KEYS, refuse);
|
|
36230
35407
|
const { id, kind } = value;
|
|
36231
35408
|
const steps = stepsOf(value.steps, refuse);
|
|
36232
|
-
const after = value.after === void 0 ? [] :
|
|
35409
|
+
const after = value.after === void 0 ? [] : stringList2(value.after);
|
|
36233
35410
|
if (typeof id !== "string" || id === "" || typeof kind !== "string" || !steps || !after) {
|
|
36234
35411
|
return refused(refuse, "shape", typeof id === "string" ? id : "stages");
|
|
36235
35412
|
}
|
|
@@ -36259,7 +35436,7 @@ function isArtifact(value) {
|
|
|
36259
35436
|
}
|
|
36260
35437
|
function servesOf(value, kind, id, refuse) {
|
|
36261
35438
|
if (value === void 0) return void 0;
|
|
36262
|
-
const names =
|
|
35439
|
+
const names = stringList2(value);
|
|
36263
35440
|
const written = kindWrites(kind);
|
|
36264
35441
|
if (!names || names.length === 0 || new Set(names).size !== names.length || names.some((name) => written.some((artifact) => artifact === name))) {
|
|
36265
35442
|
refuse("shape", id);
|
|
@@ -36350,7 +35527,7 @@ function outcomeOf(value, refuse) {
|
|
|
36350
35527
|
const { outcome, routes } = value;
|
|
36351
35528
|
if (typeof outcome !== "string" || outcome === "") return null;
|
|
36352
35529
|
if (routes === "decision-table") return { outcome, routes };
|
|
36353
|
-
const named2 =
|
|
35530
|
+
const named2 = stringList2(routes);
|
|
36354
35531
|
if (!named2 || named2.length === 0) return null;
|
|
36355
35532
|
for (const route of named2) if (!isWorkflowRoute(route)) refuse("destination", route);
|
|
36356
35533
|
return { outcome, routes: named2 };
|
|
@@ -36386,7 +35563,7 @@ function pointRefusals(plan, refuse) {
|
|
|
36386
35563
|
}
|
|
36387
35564
|
function documentOf(text3) {
|
|
36388
35565
|
try {
|
|
36389
|
-
return
|
|
35566
|
+
return parseYaml18(text3);
|
|
36390
35567
|
} catch {
|
|
36391
35568
|
return void 0;
|
|
36392
35569
|
}
|
|
@@ -36397,7 +35574,7 @@ function headerOf(document, route, refuse) {
|
|
|
36397
35574
|
}
|
|
36398
35575
|
const family = typeof document.family === "string" ? document.family : "";
|
|
36399
35576
|
if (!ROUTE_FAMILIES.some((each) => each === family)) refuse("family", family || "family");
|
|
36400
|
-
const decisionPoints =
|
|
35577
|
+
const decisionPoints = stringList2(document.decisionPoints);
|
|
36401
35578
|
if (!decisionPoints) refuse("shape", "decisionPoints");
|
|
36402
35579
|
const { releasePoint } = document;
|
|
36403
35580
|
if (releasePoint !== void 0 && typeof releasePoint !== "string") {
|
|
@@ -36437,18 +35614,18 @@ function parsePlan(text3, route) {
|
|
|
36437
35614
|
|
|
36438
35615
|
// src/core/workflow/plans.ts
|
|
36439
35616
|
function packagePlansDir() {
|
|
36440
|
-
return
|
|
35617
|
+
return path136.resolve(getInitAssetsDir(), "..", "defaults", "workflows");
|
|
36441
35618
|
}
|
|
36442
35619
|
async function readIfPresent(file) {
|
|
36443
35620
|
try {
|
|
36444
|
-
return await
|
|
35621
|
+
return await readFile70(file, "utf8");
|
|
36445
35622
|
} catch (error2) {
|
|
36446
35623
|
if (isRecord2(error2) && error2.code === "ENOENT") return void 0;
|
|
36447
35624
|
return null;
|
|
36448
35625
|
}
|
|
36449
35626
|
}
|
|
36450
35627
|
async function loadPackagePlan(route) {
|
|
36451
|
-
const text3 = await readIfPresent(
|
|
35628
|
+
const text3 = await readIfPresent(path136.join(packagePlansDir(), `${route}.yml`));
|
|
36452
35629
|
if (text3 === void 0) {
|
|
36453
35630
|
return { ok: false, refusals: [{ route, reason: "file-missing", subject: route }] };
|
|
36454
35631
|
}
|
|
@@ -36469,7 +35646,7 @@ function planSteps(plans) {
|
|
|
36469
35646
|
async function contractRefusals(root, steps) {
|
|
36470
35647
|
const found = await Promise.all(
|
|
36471
35648
|
[...steps].map(async ([step, route]) => {
|
|
36472
|
-
const entry = await
|
|
35649
|
+
const entry = await stat19(path136.join(root, stepPath(step))).catch(() => void 0);
|
|
36473
35650
|
return entry?.isFile() ? [] : [{ route, reason: "step-missing", subject: step }];
|
|
36474
35651
|
})
|
|
36475
35652
|
);
|
|
@@ -36939,7 +36116,7 @@ async function readStdin() {
|
|
|
36939
36116
|
async function readExtraction(root, inPath) {
|
|
36940
36117
|
let text3;
|
|
36941
36118
|
try {
|
|
36942
|
-
text3 = inPath === "-" ? await readStdin() : await
|
|
36119
|
+
text3 = inPath === "-" ? await readStdin() : await readFile71(path137.resolve(root, inPath), "utf8");
|
|
36943
36120
|
} catch {
|
|
36944
36121
|
const message = "The input file cannot be read, so check the path and try again.";
|
|
36945
36122
|
return { ok: false, document: refusal(message, [{ reason: "io-error", subject: inPath }]) };
|