bpmax-cli 0.2.1-beta.35 → 0.2.1-beta.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +4 -0
  2. package/dist/bin.js +748 -52
  3. package/dist/bin.js.map +1 -1
  4. package/package.json +2 -2
  5. package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +238 -4
  6. package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +258 -0
  7. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +6 -0
  8. package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +2 -2
  9. package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +13 -9
  10. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +14 -6
  11. package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +2 -2
  12. package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +15 -0
  13. package/skills/bpmax-e2e-flow-test-operator/references/full-detail-guide.md +3 -1
  14. package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +5 -0
  15. package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +6 -0
  16. package/skills/bpmax-functional-test-design/LICENSE.upstream +24 -0
  17. package/skills/bpmax-functional-test-design/SKILL.md +80 -0
  18. package/skills/bpmax-functional-test-design/agents/openai.yaml +4 -0
  19. package/skills/bpmax-functional-test-design/references/bpmax-test-suite-output.md +95 -0
  20. package/skills/bpmax-functional-test-design/references/decision-table-testing.md +50 -0
  21. package/skills/bpmax-functional-test-design/references/domain-testing.md +43 -0
  22. package/skills/bpmax-functional-test-design/references/state-transition-testing.md +47 -0
  23. package/skills/bpmax-functional-test-design/references/technique-selection.md +38 -0
  24. package/skills/bpmax-functional-test-design/references/use-case-testing.md +55 -0
  25. package/skills/bpmax-ui-ux-audit/LICENSE.upstream +23 -0
  26. package/skills/bpmax-ui-ux-audit/SKILL.md +42 -0
  27. package/skills/bpmax-ui-ux-audit/agents/openai.yaml +4 -0
  28. package/skills/bpmax-ui-ux-audit/references/audit-framework.md +39 -0
  29. package/skills/bpmax-ui-ux-audit/references/bpmax-ux-findings.md +56 -0
package/dist/bin.js CHANGED
@@ -496,7 +496,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
496
496
  // package.json
497
497
  var package_default = {
498
498
  name: "bpmax-cli",
499
- version: "0.2.1-beta.35",
499
+ version: "0.2.1-beta.37",
500
500
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
501
501
  type: "module",
502
502
  bin: {
@@ -516,7 +516,7 @@ var package_default = {
516
516
  build: "tsup",
517
517
  dev: "tsx src/bin.ts",
518
518
  "install:skills": "node scripts/install-skills.mjs",
519
- test: "vitest run",
519
+ test: "vitest run --exclude '.worktrees/**'",
520
520
  typecheck: "tsc --noEmit"
521
521
  },
522
522
  engines: {
@@ -1566,6 +1566,7 @@ var runCommand = (command, args, options = {}) => new Promise((resolve) => {
1566
1566
  const child = spawn(command, args, {
1567
1567
  cwd: options.cwd,
1568
1568
  env: options.env,
1569
+ shell: options.shell,
1569
1570
  stdio: ["ignore", "pipe", "pipe"]
1570
1571
  });
1571
1572
  let stdout = "";
@@ -4633,6 +4634,28 @@ function configAdapterMatrix() {
4633
4634
  const supportsDelete = Boolean(definition.deletePath) || ["workspace-flow", "api-platform", "nav-config"].includes(domain);
4634
4635
  const supportsPublish = domain === "dataset";
4635
4636
  const supportsRelationFields = domain === "dataset";
4637
+ const semanticCapabilities = domain === "flow-template" ? {
4638
+ acknowledged_cc: {
4639
+ status: "unsupported",
4640
+ source_semantics: ["WEWF signorder=4", "cc_submit_required", "cc_ack"],
4641
+ migration_disposition: "cc_ack_not_supported",
4642
+ reason: "Current typed flow nodes only expose ordinary CC and approver channels; ordinary CC does not contribute confirmation and an approver changes threshold/reject semantics.",
4643
+ recommended_plugin_domain: "flow-acknowledged-cc",
4644
+ required_plugin_contract: {
4645
+ participant_channel: "acknowledged_cc",
4646
+ contributes_approval_threshold: false,
4647
+ supports_reject: false,
4648
+ completion_gate: "every resolved acknowledged-CC participant confirms",
4649
+ typed_operations: ["export", "lint", "build", "submit", "verify", "test"]
4650
+ },
4651
+ runtime_verification: [
4652
+ "\u786E\u8BA4\u578B\u6284\u9001\u4EBA\u6536\u5230\u72EC\u7ACB\u5F85\u529E\uFF0C\u800C\u4E0D\u662F\u666E\u901A\u901A\u77E5\u3002",
4653
+ "\u786E\u8BA4\u578B\u6284\u9001\u4EBA\u53EA\u80FD\u63D0\u4EA4\u786E\u8BA4\uFF0C\u4E0D\u83B7\u5F97\u666E\u901A\u5BA1\u6279\u901A\u8FC7\u6216\u62D2\u7EDD\u8BED\u4E49\u3002",
4654
+ "\u6240\u6709\u786E\u8BA4\u578B\u6284\u9001\u4EBA\u5B8C\u6210\u786E\u8BA4\u524D\u8282\u70B9\u4E0D\u5F97\u5B8C\u6210\uFF0C\u786E\u8BA4\u540E\u624D\u89E3\u9664\u5B8C\u6210\u95E8\u7981\u3002",
4655
+ "typed export/readback \u4FDD\u7559\u53C2\u4E0E\u4EBA\u3001\u786E\u8BA4\u72B6\u6001\u548C\u5B8C\u6210\u95E8\u7981\uFF0CE2E \u8986\u76D6\u5355\u4EBA\u3001\u591A\u4EBA\u3001\u7A7A\u89E3\u6790\u548C\u91CD\u590D\u63D0\u4EA4\u3002"
4656
+ ]
4657
+ }
4658
+ } : void 0;
4636
4659
  return {
4637
4660
  domain,
4638
4661
  capability_prefix: definition.capability,
@@ -4668,6 +4691,7 @@ function configAdapterMatrix() {
4668
4691
  publishes_on_submit: domain === "form-template",
4669
4692
  relation_fields_submit: domain === "dataset"
4670
4693
  },
4694
+ ...semanticCapabilities ? { semantic_capabilities: semanticCapabilities } : {},
4671
4695
  notes: definition.notes
4672
4696
  };
4673
4697
  });
@@ -6624,12 +6648,256 @@ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLab
6624
6648
  if (typeof script !== "string") {
6625
6649
  return;
6626
6650
  }
6627
- const hasRowLoop = /\.(forEach|map|reduce|filter)\s*\(|for\s*\([^)]*\b(of|in)\b/i.test(script);
6628
- const hasMetric = /(count|total|amount|qty|quantity|inventory|stock|sale|销量|库存|项目数|数量|金额|合计|总数)/i.test(script);
6629
6651
  const dataSourceText = typeof dataSource === "string" ? dataSource : JSON.stringify(dataSource) ?? "";
6630
- const hasAggregation = /(aggs|aggregations)\b|size\s*:\s*0|['\"]size['\"]\s*:\s*0/i.test(`${dataSourceText}
6631
- ${script}`);
6632
- if (hasRowLoop && hasMetric && !hasAggregation) {
6652
+ const stripJsNonCode = (text5) => {
6653
+ let output = "";
6654
+ let state = "code";
6655
+ let escaped = false;
6656
+ for (let index = 0; index < text5.length; index += 1) {
6657
+ const char = text5[index];
6658
+ const next = text5[index + 1];
6659
+ if (state === "code" && char === "/" && next === "/") {
6660
+ state = "line";
6661
+ output += " ";
6662
+ index += 1;
6663
+ continue;
6664
+ }
6665
+ if (state === "code" && char === "/" && next === "*") {
6666
+ state = "block";
6667
+ output += " ";
6668
+ index += 1;
6669
+ continue;
6670
+ }
6671
+ if (state === "code" && (char === "'" || char === '"')) {
6672
+ let end = index + 1;
6673
+ let quoteEscaped = false;
6674
+ for (; end < text5.length; end += 1) {
6675
+ if (quoteEscaped) {
6676
+ quoteEscaped = false;
6677
+ continue;
6678
+ }
6679
+ if (text5[end] === "\\") {
6680
+ quoteEscaped = true;
6681
+ continue;
6682
+ }
6683
+ if (text5[end] === char) break;
6684
+ }
6685
+ const literal = text5.slice(index + 1, end);
6686
+ const previous = output.trimEnd().slice(-1);
6687
+ if (end < text5.length && /^[A-Za-z_$][\w$]*$/.test(literal) && (previous === "{" || previous === ",") && /^\s*:/.test(text5.slice(end + 1))) {
6688
+ output += ` ${literal} `;
6689
+ index = end;
6690
+ continue;
6691
+ }
6692
+ state = char === "'" ? "single" : "double";
6693
+ output += " ";
6694
+ continue;
6695
+ }
6696
+ if (state === "code" && char === "`") {
6697
+ state = "template";
6698
+ output += " ";
6699
+ continue;
6700
+ }
6701
+ if (state === "line") {
6702
+ if (char === "\n") {
6703
+ state = "code";
6704
+ output += "\n";
6705
+ } else output += " ";
6706
+ continue;
6707
+ }
6708
+ if (state === "block") {
6709
+ if (char === "*" && next === "/") {
6710
+ state = "code";
6711
+ output += " ";
6712
+ index += 1;
6713
+ } else output += char === "\n" ? "\n" : " ";
6714
+ continue;
6715
+ }
6716
+ if (state !== "code") {
6717
+ output += char === "\n" ? "\n" : " ";
6718
+ if (escaped) {
6719
+ escaped = false;
6720
+ continue;
6721
+ }
6722
+ if (char === "\\") {
6723
+ escaped = true;
6724
+ continue;
6725
+ }
6726
+ if (state === "single" && char === "'" || state === "double" && char === '"' || state === "template" && char === "`") state = "code";
6727
+ continue;
6728
+ }
6729
+ output += char;
6730
+ }
6731
+ return output;
6732
+ };
6733
+ const paginationCode = stripJsNonCode(dataSourceText);
6734
+ const frontendCode = stripJsNonCode(script);
6735
+ const hasFrontendDetailAccess = /\brows\b|\bctx\s*\[|\bctx\.data\?*\.hits\?*\.hits\b|\.(forEach|map|reduce|filter)\s*\(|for\s*\([^)]*\b(of|in)\b/i.test(frontendCode);
6736
+ const hasMetric = /(count|total|amount|qty|quantity|inventory|stock|sale|销量|库存|项目数|数量|金额|合计|总数)/i.test(frontendCode);
6737
+ const topLevelReturnedObjects = (code) => {
6738
+ const objects = [];
6739
+ const returnPattern = /\breturn\s*{/g;
6740
+ let scanDepth = 0;
6741
+ let scanIndex = 0;
6742
+ for (let match = returnPattern.exec(code); match; match = returnPattern.exec(code)) {
6743
+ while (scanIndex < match.index) {
6744
+ if (code[scanIndex] === "{") scanDepth += 1;
6745
+ if (code[scanIndex] === "}") scanDepth -= 1;
6746
+ scanIndex += 1;
6747
+ }
6748
+ if (scanDepth !== 0) continue;
6749
+ const start = code.indexOf("{", match.index);
6750
+ let depth = 0;
6751
+ for (let index = start; index < code.length; index += 1) {
6752
+ if (code[index] === "{") depth += 1;
6753
+ if (code[index] === "}") depth -= 1;
6754
+ if (depth === 0) {
6755
+ objects.push(code.slice(start, index + 1));
6756
+ returnPattern.lastIndex = index + 1;
6757
+ break;
6758
+ }
6759
+ }
6760
+ }
6761
+ return objects;
6762
+ };
6763
+ const returnedObjects = topLevelReturnedObjects(paginationCode);
6764
+ const returnedQuery = returnedObjects.length === 1 ? returnedObjects[0] : "";
6765
+ const frontendReturnedObjects = topLevelReturnedObjects(frontendCode);
6766
+ const frontendReturnedQuery = frontendReturnedObjects.length === 1 ? frontendReturnedObjects[0] : "";
6767
+ const topLevelProperties = (objectText) => {
6768
+ if (!objectText.startsWith("{") || !objectText.endsWith("}")) return null;
6769
+ const fields = /* @__PURE__ */ new Map();
6770
+ let depth = 0;
6771
+ let start = 1;
6772
+ const entries = [];
6773
+ for (let index = 1; index < objectText.length - 1; index += 1) {
6774
+ const char = objectText[index];
6775
+ if ("{[(".includes(char)) depth += 1;
6776
+ else if ("}])".includes(char)) depth -= 1;
6777
+ else if (char === "," && depth === 0) {
6778
+ entries.push(objectText.slice(start, index));
6779
+ start = index + 1;
6780
+ }
6781
+ }
6782
+ entries.push(objectText.slice(start, -1));
6783
+ for (const entry of entries) {
6784
+ const trimmed = entry.trim();
6785
+ if (!trimmed) continue;
6786
+ if (trimmed.startsWith("...")) return null;
6787
+ const match = /^([A-Za-z_$][\w$]*)\s*:\s*([\s\S]*)$/.exec(trimmed);
6788
+ if (!match) return null;
6789
+ fields.set(match[1], [...fields.get(match[1]) || [], match[2].trim()]);
6790
+ }
6791
+ return fields;
6792
+ };
6793
+ const returnedFields = topLevelProperties(returnedQuery);
6794
+ const frontendReturnedFields = topLevelProperties(frontendReturnedQuery);
6795
+ const aggregationValue = returnedFields?.get("aggs") || returnedFields?.get("aggregations") || [];
6796
+ const hasAggregation = typeof dataSource === "string" ? Boolean(returnedFields && returnedFields.get("size")?.length === 1 && returnedFields.get("size")[0] === "0" && aggregationValue.length === 1 && aggregationValue[0].trim().startsWith("{")) : isRecord3(dataSource) && dataSource.size === 0 && (isRecord3(dataSource.aggs) || isRecord3(dataSource.aggregations));
6797
+ const mapReceivers = [...frontendCode.matchAll(/\b([A-Za-z_$][\w$]*)\s*\.\s*map\s*\(/gi)].map((match) => match[1].toLowerCase());
6798
+ const uniqueFrontendField = (name) => frontendReturnedFields?.get(name)?.length === 1 ? frontendReturnedFields.get(name)[0] : "";
6799
+ const dataExpression = uniqueFrontendField("data");
6800
+ const dataMapMatch = /^hits\s*\.\s*map\s*\(\s*\(?\s*([A-Za-z_$][\w$]*)\s*\)?\s*=>\s*\1\s*\.\s*_source\s*\)$/i.exec(dataExpression);
6801
+ const pageInfoFields = topLevelProperties(uniqueFrontendField("pageInfo"));
6802
+ const countExpression = pageInfoFields?.get("count")?.length === 1 ? pageInfoFields.get("count")[0] : "";
6803
+ const hasOnlyTrustedResultMap = mapReceivers.length === 1 && mapReceivers[0] === "hits" && Boolean(dataMapMatch);
6804
+ const topLevelPrefixBefore = (code, objectText) => {
6805
+ const objectIndex = objectText ? code.indexOf(objectText) : -1;
6806
+ if (objectIndex < 0) return "";
6807
+ let output = "";
6808
+ let depth = 0;
6809
+ for (let index = 0; index < objectIndex; index += 1) {
6810
+ const char = code[index];
6811
+ if (char === "{") {
6812
+ depth += 1;
6813
+ output += " ";
6814
+ continue;
6815
+ }
6816
+ if (char === "}") {
6817
+ depth -= 1;
6818
+ output += " ";
6819
+ continue;
6820
+ }
6821
+ output += depth === 0 ? char : char === "\n" ? "\n" : " ";
6822
+ }
6823
+ return output;
6824
+ };
6825
+ const frontendTopLevelPrefix = topLevelPrefixBefore(frontendCode, frontendReturnedQuery);
6826
+ const hitsDeclaration = /\bconst\s+hits\s*=\s*([^;]+);?/i.exec(frontendTopLevelPrefix);
6827
+ const hitsBinding = hitsDeclaration?.[1] || "";
6828
+ const hasTrustedHitsBinding = /^\s*ctx\.data\?*\.hits\?*\.hits(?:\s*(?:\|\||\?\?)\s*\[\])?\s*$/i.test(hitsBinding);
6829
+ const totalDeclaration = /\bconst\s+total\s*=\s*([^;]+);?/i.exec(frontendTopLevelPrefix);
6830
+ const totalBinding = totalDeclaration?.[1] || "";
6831
+ const hasTrustedTotalBinding = /^\s*ctx\.data\?*\.hits\?*\.total\?*\.value(?:\s*(?:\|\||\?\?)\s*0)?\s*$/i.test(totalBinding) && countExpression === "total";
6832
+ const residualFrontendPrefix = frontendTopLevelPrefix.replace(hitsDeclaration?.[0] || "", "").replace(totalDeclaration?.[0] || "", "");
6833
+ const hasReadonlyFrontendInputs = !/\bhits\b|\brows\b|\bctx\s*\[/i.test(residualFrontendPrefix);
6834
+ const hasDisallowedFrontendLoop = /\.(forEach|reduce|filter)\s*\(|for\s*\([^)]*\b(of|in)\b/i.test(frontendCode) || mapReceivers.some((receiver) => receiver !== "hits") || /\)\s*\.\s*map\s*\(/i.test(frontendCode) || /\[\s*\]\s*\(/.test(frontendCode) || mapReceivers.length > 0 && !hasOnlyTrustedResultMap;
6835
+ const topLevelPrefix = topLevelPrefixBefore(paginationCode, returnedQuery);
6836
+ const topLevelConstDeclarations = [...topLevelPrefix.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;]+);?/g)];
6837
+ let residualPaginationPrefix = topLevelPrefix;
6838
+ topLevelConstDeclarations.forEach((match) => {
6839
+ residualPaginationPrefix = residualPaginationPrefix.replace(match[0], "");
6840
+ });
6841
+ residualPaginationPrefix = residualPaginationPrefix.replace(/\breturn\s*$/, "");
6842
+ const hasOnlyConstPaginationPrefix = residualPaginationPrefix.trim() === "" && topLevelConstDeclarations.every((match) => !["ctx", "Number"].includes(match[1]));
6843
+ const assignment = (name) => {
6844
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
6845
+ const match = new RegExp(`\\bconst\\s+${escaped}\\s*=\\s*([^;]+)`).exec(topLevelPrefix);
6846
+ if (!match) return "";
6847
+ const remaining = topLevelPrefix.slice((match.index ?? 0) + match[0].length);
6848
+ if (new RegExp(`(?:^|[;\\n])\\s*${escaped}\\s*=`).test(remaining)) return "";
6849
+ return match[1] || "";
6850
+ };
6851
+ const unwrapNumber = (expression) => {
6852
+ const trimmed = expression.trim();
6853
+ const match = /^Number\s*\(([\s\S]*)\)$/.exec(trimmed);
6854
+ return (match?.[1] || trimmed).trim();
6855
+ };
6856
+ const safeFallback = (expression, source) => {
6857
+ const terms = unwrapNumber(expression).split(/\|\||\?\?/).map((term) => term.trim());
6858
+ if (!terms.some((term) => source.test(term))) return false;
6859
+ return terms.every((term) => source.test(term) || /^\d+$/.test(term) && Number(term) > 0 && Number(term) <= 1e3);
6860
+ };
6861
+ const safeConstExpression = (expression, source, seen = /* @__PURE__ */ new Set()) => {
6862
+ const trimmed = expression.trim();
6863
+ if (/^[A-Za-z_$][\w$]*$/.test(trimmed)) {
6864
+ if (seen.has(trimmed)) return false;
6865
+ const binding = assignment(trimmed);
6866
+ return Boolean(binding) && safeConstExpression(binding, source, /* @__PURE__ */ new Set([...seen, trimmed]));
6867
+ }
6868
+ return safeFallback(trimmed, source);
6869
+ };
6870
+ const safeFromExpression = (expression) => {
6871
+ const trimmed = expression.trim();
6872
+ const offsetSource2 = /^(?:ctx\.pageInfo\?*\.offset)$/;
6873
+ if (safeConstExpression(trimmed, offsetSource2)) return true;
6874
+ const formula = /^\(\s*([A-Za-z_$][\w$]*)\s*-\s*1\s*\)\s*\*\s*([A-Za-z_$][\w$]*)$/.exec(trimmed);
6875
+ if (!formula) return false;
6876
+ const pageSource2 = /^(?:ctx\.pageInfo\?*\.(?:page|pageIndex|current))$/;
6877
+ const sizeSource2 = /^(?:ctx\.pageInfo\?*\.pageSize|ctx\.config\?*\.page_size|cfg\.page_size)$/;
6878
+ return safeConstExpression(formula[1], pageSource2) && safeConstExpression(formula[2], sizeSource2);
6879
+ };
6880
+ const uniqueField = (name) => returnedFields?.get(name)?.length === 1 ? returnedFields.get(name)[0] : "";
6881
+ const fromExpression = uniqueField("from");
6882
+ const sizeExpression = uniqueField("size");
6883
+ const sizeSource = /^(?:ctx\.pageInfo\?*\.pageSize|ctx\.config\?*\.page_size|cfg\.page_size)$/;
6884
+ const pageSource = /^(?:ctx\.pageInfo\?*\.(?:page|pageIndex|current))$/;
6885
+ const offsetSource = /^(?:ctx\.pageInfo\?*\.offset)$/;
6886
+ const hasControlledFrom = safeFromExpression(fromExpression);
6887
+ const hasControlledSize = safeConstExpression(sizeExpression, sizeSource);
6888
+ const cfgBinding = assignment("cfg");
6889
+ const hasTrustedCfgBinding = !/\bcfg\.page_size\b/.test(topLevelPrefix) || /^ctx\.config(?:\s*\|\|\s*)?$/.test(cfgBinding.trim());
6890
+ const hasCanonicalPaginationDeclarations = topLevelConstDeclarations.every((declaration) => {
6891
+ const name = declaration[1];
6892
+ const expression = declaration[2];
6893
+ if (name === "cfg") return /^ctx\.config(?:\s*\|\|\s*)?$/.test(expression.trim());
6894
+ if (name === "pageSize") return safeConstExpression(expression, sizeSource);
6895
+ if (name === "page") return safeConstExpression(expression, pageSource);
6896
+ if (name === "offset") return safeConstExpression(expression, offsetSource);
6897
+ return false;
6898
+ });
6899
+ const hasServerPagination = hasControlledFrom && hasControlledSize && hasOnlyConstPaginationPrefix && hasTrustedCfgBinding && hasCanonicalPaginationDeclarations && uniqueField("track_total_hits").toLowerCase() === "true" && hasTrustedHitsBinding && hasTrustedTotalBinding && hasReadonlyFrontendInputs && hasOnlyTrustedResultMap && !hasDisallowedFrontendLoop;
6900
+ if (hasFrontendDetailAccess && hasMetric && !hasAggregation && !hasServerPagination) {
6633
6901
  errors.push(`${moduleLabel} \u7981\u6B62\u62C9\u5168\u91CF\u660E\u7EC6\u5230\u524D\u7AEF\u9010\u884C\u7EDF\u8BA1\uFF1B\u7EDF\u8BA1\u7C7B\u770B\u677F\u5FC5\u987B\u4F7F\u7528 ES size: 0 + aggs/aggregations\u3002`);
6634
6902
  }
6635
6903
  }
@@ -15782,7 +16050,6 @@ import axios7 from "axios";
15782
16050
 
15783
16051
  // src/core/test-suite.ts
15784
16052
  import { createHash as createHash5 } from "crypto";
15785
- import { existsSync } from "fs";
15786
16053
  import {
15787
16054
  copyFile,
15788
16055
  cp as cp3,
@@ -15905,6 +16172,12 @@ var CONFIG_BASIS_ALLOWED_PREFIXES = [
15905
16172
  ".codex/skills/"
15906
16173
  ];
15907
16174
  var REPORT_REQUIRED_KEYS = ["run_id:", "scenario_id:", "source_suite:", "result:"];
16175
+ var REPORT_REQUIRED_SKILLS = {
16176
+ test_design_skill: "bpmax-functional-test-design",
16177
+ ux_audit_skill: "bpmax-ui-ux-audit"
16178
+ };
16179
+ var UX_SEVERITIES = ["P0", "P1", "P2", "P3"];
16180
+ var UX_FINDING_STATUSES = /* @__PURE__ */ new Set(["open", "fixed", "verified"]);
15908
16181
  var REPORT_EXECUTION_KEYS = [
15909
16182
  "planned_cases:",
15910
16183
  "executed_cases:",
@@ -15979,6 +16252,15 @@ var TestSuiteError = class extends Error {
15979
16252
  this.suggestion = options.suggestion;
15980
16253
  }
15981
16254
  };
16255
+ function runtimeRoute(runtimeUrl) {
16256
+ const url = new URL(runtimeUrl);
16257
+ const hashRoute = url.hash.startsWith("#/") ? new URL(url.hash.slice(1), url.origin) : null;
16258
+ return {
16259
+ url,
16260
+ path: hashRoute?.pathname || url.pathname,
16261
+ params: hashRoute?.searchParams || url.searchParams
16262
+ };
16263
+ }
15982
16264
  async function exists3(filePath) {
15983
16265
  try {
15984
16266
  await stat6(filePath);
@@ -16773,6 +17055,24 @@ function pathInside(root, candidate) {
16773
17055
  const resolvedCandidate = path10.resolve(candidate);
16774
17056
  return resolvedCandidate === resolvedRoot || resolvedCandidate.startsWith(`${resolvedRoot}${path10.sep}`);
16775
17057
  }
17058
+ async function pathInsideReal(root, candidate) {
17059
+ if (!pathInside(root, candidate)) return false;
17060
+ try {
17061
+ const [realRoot, realCandidate] = await Promise.all([realpath2(root), realpath2(candidate)]);
17062
+ return pathInside(realRoot, realCandidate);
17063
+ } catch {
17064
+ return false;
17065
+ }
17066
+ }
17067
+ async function assertCurrentRunPathScope(runDir, artifactPath, message) {
17068
+ if (!pathInside(runDir, artifactPath)) {
17069
+ fail(message, { rule_id: "test_suite.run.evidence_scope", path: artifactPath });
17070
+ }
17071
+ if (!await exists3(artifactPath)) return;
17072
+ if (!await pathInsideReal(runDir, artifactPath)) {
17073
+ fail(message, { rule_id: "test_suite.run.evidence_scope", path: artifactPath });
17074
+ }
17075
+ }
16776
17076
  async function assertCurrentRunArtifact(manifest, artifactPath) {
16777
17077
  if (!await exists3(artifactPath)) {
16778
17078
  fail(`execution evidence artifact not found: ${artifactPath}`, { rule_id: "test_suite.run.evidence_missing", path: artifactPath });
@@ -16785,9 +17085,7 @@ async function assertCurrentRunArtifact(manifest, artifactPath) {
16785
17085
  async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
16786
17086
  if (!await exists3(evidencePath)) fail(`execution evidence not found: ${evidencePath}`, { rule_id: "test_suite.run.evidence_missing", path: evidencePath });
16787
17087
  const runDir = path10.dirname(path10.resolve(manifestPath));
16788
- if (!pathInside(runDir, evidencePath)) {
16789
- fail("formal execution evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: evidencePath });
16790
- }
17088
+ await assertCurrentRunPathScope(runDir, evidencePath, "formal execution evidence must stay inside the current report run directory");
16791
17089
  const info = await stat6(evidencePath);
16792
17090
  if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
16793
17091
  fail("execution evidence predates the current run", { rule_id: "test_suite.run.evidence_stale", path: evidencePath });
@@ -16820,7 +17118,7 @@ async function evidenceJsonRecords(evidencePath) {
16820
17118
  }
16821
17119
  return records;
16822
17120
  }
16823
- async function browserEvidenceScreenshots(manifest, manifestPath, step, evidencePath) {
17121
+ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidencePath, expectedResult = "pass") {
16824
17122
  const jsonRecords = await evidenceJsonRecords(evidencePath);
16825
17123
  const screenshotPaths = [];
16826
17124
  let matchedRecord = false;
@@ -16834,10 +17132,13 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16834
17132
  const runtimeEnvironment = String(value.runtime_environment || "profile").trim();
16835
17133
  if (!["profile", "local-browser"].includes(runtimeEnvironment)) continue;
16836
17134
  try {
16837
- const runtimeOrigin = new URL(runtimeUrl).origin;
17135
+ const parsed = runtimeRoute(runtimeUrl);
17136
+ const runtimeOrigin = parsed.url.origin;
16838
17137
  const profileOrigin = manifest.profile_origin ? new URL(manifest.profile_origin).origin : "";
16839
17138
  if (runtimeEnvironment === "profile" && profileOrigin && runtimeOrigin !== profileOrigin) continue;
16840
- if (runtimeEnvironment === "local-browser" && !/^(?:localhost|127\.0\.0\.1|\[::1\])$/.test(new URL(runtimeUrl).hostname)) continue;
17139
+ if (runtimeEnvironment === "local-browser" && !/^(?:localhost|127\.0\.0\.1|\[::1\])$/.test(parsed.url.hostname)) continue;
17140
+ const workspaceMatch = /^\/w:([^/]+)(?:\/|$)/i.exec(parsed.path);
17141
+ if (manifest.workspace && workspaceMatch && decodeURIComponent(workspaceMatch[1]) !== manifest.workspace) continue;
16841
17142
  } catch {
16842
17143
  continue;
16843
17144
  }
@@ -16846,13 +17147,14 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16846
17147
  if (runtimeScope === "project" && !/^\d+$/.test(projectId)) continue;
16847
17148
  if (runtimeScope === "step" && (!/^\d+$/.test(projectId) || !/^\d+$/.test(runtimeStepId))) continue;
16848
17149
  const assertions = Array.isArray(value.assertions) ? value.assertions.map(asRecord).filter((assertion) => Object.keys(assertion).length > 0) : [];
16849
- if (assertions.length === 0 || assertions.some((assertion) => assertion.passed !== true)) continue;
17150
+ if (assertions.length === 0) continue;
17151
+ if (expectedResult === "pass" && assertions.some((assertion) => assertion.passed !== true)) continue;
17152
+ if (expectedResult !== "pass" && !assertions.some((assertion) => assertion.passed === false)) continue;
16850
17153
  const screenshot = typeof value.screenshot === "string" ? value.screenshot.trim() : "";
16851
17154
  if (!screenshot) continue;
16852
17155
  const screenshotPath = path10.resolve(path10.dirname(source), screenshot);
16853
- if (!pathInside(path10.dirname(manifestPath), screenshotPath)) {
16854
- fail("browser screenshot must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: screenshotPath });
16855
- }
17156
+ await assertCurrentRunArtifact(manifest, source);
17157
+ await assertCurrentRunPathScope(path10.dirname(manifestPath), screenshotPath, "browser screenshot must stay inside the current report run directory");
16856
17158
  await assertCurrentRunArtifact(manifest, screenshotPath);
16857
17159
  if (!await isValidCurrentRunScreenshot(screenshotPath)) {
16858
17160
  fail("browser pass evidence screenshot must be a valid visible PNG of at least 100x80", { rule_id: "test_suite.run.screenshot_invalid", path: screenshotPath });
@@ -16861,9 +17163,7 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16861
17163
  const domSnapshot = typeof value.dom_snapshot === "string" ? value.dom_snapshot.trim() : "";
16862
17164
  if (!domSnapshot) continue;
16863
17165
  const domPath = path10.resolve(path10.dirname(source), domSnapshot);
16864
- if (!pathInside(path10.dirname(manifestPath), domPath)) {
16865
- fail("browser DOM evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: domPath });
16866
- }
17166
+ await assertCurrentRunPathScope(path10.dirname(manifestPath), domPath, "browser DOM evidence must stay inside the current report run directory");
16867
17167
  await assertCurrentRunArtifact(manifest, domPath);
16868
17168
  }
16869
17169
  matchedRecord = true;
@@ -16871,12 +17171,58 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16871
17171
  }
16872
17172
  if (!matchedRecord) {
16873
17173
  fail(
16874
- "browser pass evidence must match the current case/step and include browser_verified=true, runtime_url, a valid current-run screenshot, and passed assertions",
17174
+ `browser ${expectedResult} evidence must match the current case/step and include browser_verified=true, runtime_url, a valid current-run screenshot, and result-aligned assertions`,
16875
17175
  { rule_id: "test_suite.run.unexecuted_evidence", path: evidencePath }
16876
17176
  );
16877
17177
  }
16878
17178
  return [...new Set(screenshotPaths)];
16879
17179
  }
17180
+ var BLOCKER_BROWSER_FIELDS = [
17181
+ "browser_verified",
17182
+ "runtime_scope",
17183
+ "runtime_environment",
17184
+ "runtime_url",
17185
+ "browser_tool",
17186
+ "project_id",
17187
+ "step_id",
17188
+ "screenshot",
17189
+ "dom_snapshot",
17190
+ "observed",
17191
+ "assertions",
17192
+ "source_evidence"
17193
+ ];
17194
+ async function structuredBlockedEvidenceSource(manifest, step, evidencePath) {
17195
+ const records = await evidenceJsonRecords(evidencePath);
17196
+ if (records.some(({ value }) => BLOCKER_BROWSER_FIELDS.some((field) => Object.hasOwn(value, field)))) return void 0;
17197
+ for (const { value, source } of records) {
17198
+ if (value.case_id !== step.case_id || value.case_step_id !== step.step_id) continue;
17199
+ if (value.blocked !== true && String(value.status || "").toLowerCase() !== "blocked") continue;
17200
+ const blocker = asRecord(value.blocker);
17201
+ if (typeof blocker.kind !== "string" || !blocker.kind.trim()) continue;
17202
+ if (typeof blocker.message !== "string" || !blocker.message.trim()) continue;
17203
+ await assertCurrentRunArtifact(manifest, source);
17204
+ return source;
17205
+ }
17206
+ return void 0;
17207
+ }
17208
+ async function hasStructuredBlockedEvidence(manifest, step, evidencePath) {
17209
+ return Boolean(await structuredBlockedEvidenceSource(manifest, step, evidencePath));
17210
+ }
17211
+ async function hasStructuredTerminalEvidence(manifest, step, evidencePath, result) {
17212
+ if (result === "blocked") return hasStructuredBlockedEvidence(manifest, step, evidencePath);
17213
+ for (const { value, source } of await evidenceJsonRecords(evidencePath)) {
17214
+ if (value.case_id !== step.case_id || value.case_step_id !== step.step_id) continue;
17215
+ if (value.failed !== true && !["fail", "failed", "error"].includes(String(value.status || "").toLowerCase())) continue;
17216
+ const failure = asRecord(value.failure);
17217
+ const error = asRecord(value.error);
17218
+ const detail = Object.keys(failure).length > 0 ? failure : error;
17219
+ if (typeof detail.kind !== "string" || !detail.kind.trim()) continue;
17220
+ if (typeof detail.message !== "string" || !detail.message.trim()) continue;
17221
+ await assertCurrentRunArtifact(manifest, source);
17222
+ return true;
17223
+ }
17224
+ return false;
17225
+ }
16880
17226
  function replaceReportMetadata(text5, key, value) {
16881
17227
  const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16882
17228
  const line = new RegExp(`^${escaped}:.*(?:\\r?\\n|$)`, "m");
@@ -16900,7 +17246,7 @@ async function browserReportEvidence(manifest) {
16900
17246
  const result = { assertions: [], screenshots: [] };
16901
17247
  const priority = { page: 1, project: 2, step: 3 };
16902
17248
  for (const step of manifest.steps) {
16903
- if (step.status !== "pass" || !["browser", "e2e_create_page"].includes(step.runner)) continue;
17249
+ if (step.status === "planned" || !["browser", "e2e_create_page"].includes(step.runner)) continue;
16904
17250
  for (const evidencePath of step.evidence) {
16905
17251
  for (const { value, source } of await evidenceJsonRecords(evidencePath)) {
16906
17252
  if (value.case_id !== step.case_id || value.case_step_id !== step.step_id || value.browser_verified !== true) continue;
@@ -16918,9 +17264,9 @@ async function browserReportEvidence(manifest) {
16918
17264
  }
16919
17265
  const assertions = Array.isArray(value.assertions) ? value.assertions.map(asRecord) : [];
16920
17266
  for (const assertion of assertions) {
16921
- if (assertion.passed !== true) continue;
17267
+ if (step.status === "pass" && assertion.passed !== true) continue;
16922
17268
  const label = String(assertion.name || assertion.message || "").trim();
16923
- if (label) result.assertions.push(label);
17269
+ if (label) result.assertions.push(assertion.passed === false ? `\u5931\u8D25\u65AD\u8A00\uFF1A${label}` : label);
16924
17270
  }
16925
17271
  const screenshot = String(value.screenshot || "").trim();
16926
17272
  if (screenshot) result.screenshots.push({ stepId: step.step_id, path: path10.resolve(path10.dirname(source), screenshot) });
@@ -16952,8 +17298,21 @@ async function syncTestSuiteRunReportUnlocked(manifestFile) {
16952
17298
  report = replaceReportMetadata(report, "executed_cases", executedCase);
16953
17299
  report = replaceReportMetadata(report, "planned_steps", manifest.steps.map((step) => `${manifest.case_id}/${step.step_id}`).join(", "));
16954
17300
  report = replaceReportMetadata(report, "executed_steps", executedSteps.length > 0 ? executedSteps.map((step) => `${manifest.case_id}/${step.step_id}`).join(", ") : "pending");
17301
+ const stoppedStep = manifest.steps.find((step) => step.status === "fail" || step.status === "blocked");
17302
+ report = replaceReportMetadata(report, "stopped_after_fail", stoppedStep ? `${manifest.case_id}/${stoppedStep.step_id}` : null);
17303
+ const browserBlocked = stoppedStep?.status === "blocked" && ["browser", "e2e_create_page"].includes(stoppedStep.runner);
17304
+ let blockerEvidence;
17305
+ if (browserBlocked) {
17306
+ for (const evidencePath of stoppedStep.evidence) {
17307
+ blockerEvidence = await structuredBlockedEvidenceSource(manifest, stoppedStep, evidencePath);
17308
+ if (blockerEvidence) break;
17309
+ }
17310
+ }
17311
+ report = replaceReportMetadata(report, "browser_status", blockerEvidence ? "blocked" : null);
17312
+ report = replaceReportMetadata(report, "blocker_evidence", blockerEvidence ? path10.relative(runDir, blockerEvidence) : null);
16955
17313
  report = replaceReportMetadata(report, "runtime_profile", manifest.profile);
16956
17314
  report = replaceReportMetadata(report, "profile_origin", manifest.profile_origin || null);
17315
+ report = replaceReportMetadata(report, "runtime_workspace", manifest.workspace || null);
16957
17316
  report = replaceReportMetadata(report, "runtime_scope", evidence.scope || null);
16958
17317
  report = replaceReportMetadata(report, "runtime_environment", evidence.environment || null);
16959
17318
  report = replaceReportMetadata(report, "runtime_url", evidence.runtimeUrl || null);
@@ -17019,13 +17378,28 @@ async function assertFormalExecutionEvidence(manifest, manifestPath, step, evide
17019
17378
  }
17020
17379
  }
17021
17380
  if (step.runner === "observe") {
17022
- const validObservation = jsonRecords.some(({ value, source }) => {
17381
+ let validObservation = false;
17382
+ for (const { value, source } of jsonRecords) {
17023
17383
  const observed = value.observed === true || ["passed", "observed", "verified"].includes(String(value.status || ""));
17024
- const assertions = Array.isArray(value.assertions) ? value.assertions : [];
17384
+ const assertions = Array.isArray(value.assertions) ? value.assertions.map(asRecord).filter((assertion) => Object.keys(assertion).length > 0) : [];
17025
17385
  const sourceEvidence = typeof value.source_evidence === "string" ? value.source_evidence : "";
17026
- return observed && assertions.length > 0 && Boolean(sourceEvidence) && existsSync(path10.resolve(path10.dirname(source), sourceEvidence));
17027
- });
17028
- if (!validObservation) fail("observe pass evidence must include assertions and an existing source_evidence artifact", { rule_id: "test_suite.run.unexecuted_evidence", path: evidencePath });
17386
+ if (!observed || assertions.length === 0 || !assertions.every((assertion) => assertion.passed === true) || !sourceEvidence) continue;
17387
+ await assertCurrentRunArtifact(manifest, source);
17388
+ const sourcePath = path10.resolve(path10.dirname(source), sourceEvidence);
17389
+ const runDir = path10.dirname(path10.resolve(manifestPath));
17390
+ if (!pathInside(runDir, sourcePath)) {
17391
+ fail("observe source_evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: sourcePath });
17392
+ }
17393
+ if (!await exists3(sourcePath) || !(await stat6(sourcePath)).isFile()) continue;
17394
+ const [realRunDir, realSourcePath] = await Promise.all([realpath2(runDir), realpath2(sourcePath)]);
17395
+ if (!pathInside(realRunDir, realSourcePath)) {
17396
+ fail("observe source_evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: sourcePath });
17397
+ }
17398
+ await assertCurrentRunArtifact(manifest, sourcePath);
17399
+ validObservation = true;
17400
+ break;
17401
+ }
17402
+ if (!validObservation) fail("observe pass evidence must include only passed assertions and an existing source_evidence artifact", { rule_id: "test_suite.run.unexecuted_evidence", path: evidencePath });
17029
17403
  }
17030
17404
  }
17031
17405
  async function writeExecutionManifest(manifestPath, manifest, incrementRevision = false) {
@@ -17043,7 +17417,7 @@ function currentManifestStep(manifest) {
17043
17417
  }
17044
17418
  async function startTestSuiteRun(options) {
17045
17419
  const scenarioDir = scenarioPath(options.suiteRoot ?? DEFAULT_SUITE_ROOT, options.scenario);
17046
- await validateScenario(scenarioDir);
17420
+ const scenario = await validateScenario(scenarioDir);
17047
17421
  const rows2 = await readCases(path10.join(scenarioDir, "cases.csv"));
17048
17422
  const row = rows2.find((item) => item.case_id === options.caseId && item.status !== "deprecated");
17049
17423
  if (!row) fail(`${scenarioDir}: active case not found: ${options.caseId}`, { rule_id: "test_suite.run.case_not_found" });
@@ -17059,6 +17433,7 @@ async function startTestSuiteRun(options) {
17059
17433
  scenario_id: options.scenario,
17060
17434
  case_id: options.caseId,
17061
17435
  profile: options.profile,
17436
+ workspace: scenario.workspace,
17062
17437
  ...options.profileOrigin ? { profile_origin: options.profileOrigin } : {},
17063
17438
  revision: 0,
17064
17439
  ...options.skillSource ? { skill_source: options.skillSource } : {},
@@ -17072,6 +17447,19 @@ async function startTestSuiteRun(options) {
17072
17447
  steps: selectedSteps.map((step) => ({ ...step, status: "planned", evidence: [] }))
17073
17448
  };
17074
17449
  await writeExecutionManifest(manifestPath, manifest);
17450
+ await writeFile9(
17451
+ path10.join(reportDir, "ux-findings.json"),
17452
+ `${JSON.stringify({
17453
+ version: 1,
17454
+ run_id: runId,
17455
+ scenario_id: options.scenario,
17456
+ audit_status: "blocked",
17457
+ evaluated_surfaces: [],
17458
+ findings: []
17459
+ }, null, 2)}
17460
+ `,
17461
+ "utf8"
17462
+ );
17075
17463
  const scenarioReport = path10.join(reportDir, `${options.scenario}.md`);
17076
17464
  const plannedSteps = selectedSteps.map((step) => `${options.caseId}/${step.step_id}`).join(", ");
17077
17465
  await writeFile9(
@@ -17081,6 +17469,11 @@ async function startTestSuiteRun(options) {
17081
17469
  `scenario_id: ${options.scenario}`,
17082
17470
  `source_suite: ${path10.resolve(scenarioDir)}`,
17083
17471
  "result: partial",
17472
+ "test_design_skill: bpmax-functional-test-design",
17473
+ "ux_audit_skill: bpmax-ui-ux-audit",
17474
+ "ux_audit_status: blocked",
17475
+ "ux_findings: ux-findings.json",
17476
+ "ux_bug_counts: P0=0,P1=0,P2=0,P3=0",
17084
17477
  "rerun_policy: full_rerun",
17085
17478
  `started_at: ${manifest.started_at}`,
17086
17479
  "finished_at: pending",
@@ -17218,6 +17611,20 @@ async function recordTestSuiteRunStep(options) {
17218
17611
  const evidencePath = path10.resolve(options.evidence);
17219
17612
  await assertCurrentRunEvidence(validated.manifest, validated.manifestPath, evidencePath);
17220
17613
  if (options.result === "pass") await assertFormalExecutionEvidence(validated.manifest, validated.manifestPath, validated.step, evidencePath);
17614
+ if (options.result !== "pass" && !["browser", "e2e_create_page"].includes(validated.step.runner)) {
17615
+ if (!await hasStructuredTerminalEvidence(validated.manifest, validated.step, evidencePath, options.result)) {
17616
+ fail("non-browser fail/blocked evidence must identify the current case/step and include structured failure.kind/message or blocker.kind/message", {
17617
+ rule_id: "test_suite.run.terminal_evidence",
17618
+ path: evidencePath
17619
+ });
17620
+ }
17621
+ }
17622
+ if (options.result !== "pass" && ["browser", "e2e_create_page"].includes(validated.step.runner)) {
17623
+ const structuredBlocker = options.result === "blocked" && await hasStructuredBlockedEvidence(validated.manifest, validated.step, evidencePath);
17624
+ if (!structuredBlocker) {
17625
+ await browserEvidenceScreenshots(validated.manifest, validated.manifestPath, validated.step, evidencePath, options.result);
17626
+ }
17627
+ }
17221
17628
  validated.step.status = options.result;
17222
17629
  validated.step.evidence = [.../* @__PURE__ */ new Set([...validated.step.evidence, evidencePath])];
17223
17630
  validated.step.recorded_at = (/* @__PURE__ */ new Date()).toISOString();
@@ -17814,6 +18221,9 @@ function reportRuntimeEvidenceMissing(text5) {
17814
18221
  if (!reportHasAnyKeyValue(text5, ["profile_origin:"])) {
17815
18222
  missing.push("profile_origin");
17816
18223
  }
18224
+ if (!reportHasAnyKeyValue(text5, ["runtime_workspace:"])) {
18225
+ missing.push("runtime_workspace");
18226
+ }
17817
18227
  if (!reportHasAnyKeyValue(text5, ["runtime_user:", "runtime_profile:", "browser_user:"])) {
17818
18228
  missing.push("runtime_user/runtime_profile");
17819
18229
  }
@@ -17838,6 +18248,7 @@ function reportRuntimeEvidenceInvalid(text5) {
17838
18248
  const runtimeScope = reportKeyValue(text5, "runtime_scope:");
17839
18249
  const runtimeEnvironment = reportKeyValue(text5, "runtime_environment:");
17840
18250
  const profileOrigin = reportKeyValue(text5, "profile_origin:");
18251
+ const runtimeWorkspace = reportKeyValue(text5, "runtime_workspace:");
17841
18252
  const runtimeUser = reportKeyValue(text5, "runtime_user:") || reportKeyValue(text5, "runtime_profile:") || reportKeyValue(text5, "browser_user:");
17842
18253
  const actionLog = reportKeyValue(text5, "browser_action_log:") || reportKeyValue(text5, "browser_actions:");
17843
18254
  const assertions = reportKeyValue(text5, "visible_assertions:") || reportKeyValue(text5, "visible_assertion:");
@@ -17849,17 +18260,20 @@ function reportRuntimeEvidenceInvalid(text5) {
17849
18260
  if (!["page", "project", "step"].includes(runtimeScope)) invalid.push("runtime_scope");
17850
18261
  if (!["profile", "local-browser"].includes(runtimeEnvironment)) invalid.push("runtime_environment");
17851
18262
  try {
17852
- const url = new URL(runtimeUrl);
18263
+ const parsed = runtimeRoute(runtimeUrl);
18264
+ const url = parsed.url;
17853
18265
  const configuredOrigin = new URL(profileOrigin);
17854
18266
  if (!["http:", "https:"].includes(url.protocol) || !url.hostname) invalid.push("runtime_url");
17855
18267
  if (runtimeEnvironment === "profile" && url.origin !== configuredOrigin.origin) invalid.push("runtime_url/profile_origin");
17856
18268
  if (runtimeEnvironment === "local-browser" && !/^(?:localhost|127\.0\.0\.1|\[::1\])$/.test(url.hostname)) {
17857
18269
  invalid.push("runtime_url/local_browser");
17858
18270
  }
17859
- const hashRoute = url.hash.startsWith("#/") ? new URL(url.hash.slice(1), url.origin) : null;
17860
- const runtimePath = hashRoute?.pathname || url.pathname;
17861
- const runtimeParams = hashRoute?.searchParams || url.searchParams;
17862
- const isSupportedUiRoute = /(?:\/project(?:$|\/|\?|_detail)|\/myProject|\/projectContinue|\/pages\/)/i.test(runtimePath) || /^\/w:[^/]+\/(?:userManagement|console)(?:\/|$)/i.test(runtimePath);
18271
+ const runtimePath = parsed.path;
18272
+ const runtimeParams = parsed.params;
18273
+ const isWorkspacePageRoute = runtimeScope === "page" && /^\/w:[^/]+(?:\/.*)?$/i.test(runtimePath);
18274
+ const workspaceMatch = /^\/w:([^/]+)(?:\/|$)/i.exec(runtimePath);
18275
+ if (workspaceMatch && decodeURIComponent(workspaceMatch[1]) !== runtimeWorkspace) invalid.push("runtime_url/workspace");
18276
+ const isSupportedUiRoute = /(?:\/project(?:$|\/|\?|_detail)|\/myProject|\/projectContinue|\/pages\/)/i.test(runtimePath) || /^\/w:[^/]+\/(?:userManagement|console)(?:\/|$)/i.test(runtimePath) || isWorkspacePageRoute;
17863
18277
  if (/(^|\.)example\.(?:com|org|net)$/i.test(url.hostname) || /\/(?:api|bpmax)(?:\/|$)/i.test(runtimePath) || !isSupportedUiRoute) {
17864
18278
  invalid.push("runtime_url/ui_route");
17865
18279
  }
@@ -17952,12 +18366,244 @@ function linesForCase(text5, caseId) {
17952
18366
  const pattern = new RegExp(`\\b${escaped}\\b`);
17953
18367
  return text5.split(/\r?\n/).filter((line) => pattern.test(line));
17954
18368
  }
18369
+ async function reportHasValidBlockedEvidence(text5, reportPath, runDir, manifest) {
18370
+ if (reportKeyValue(text5, "browser_status:").toLowerCase() !== "blocked") return false;
18371
+ const evidenceValue = reportKeyValue(text5, "blocker_evidence:");
18372
+ if (!evidenceValue) return false;
18373
+ const evidencePath = path10.resolve(path10.dirname(reportPath), evidenceValue);
18374
+ if (!await exists3(evidencePath) || !(await stat6(evidencePath)).isFile() || !await pathInsideReal(runDir, evidencePath)) return false;
18375
+ await assertCurrentRunArtifact(manifest, evidencePath);
18376
+ const blockedStep = manifest.steps.find((step) => step.status === "blocked");
18377
+ return Boolean(
18378
+ blockedStep && ["browser", "e2e_create_page"].includes(blockedStep.runner) && await hasStructuredBlockedEvidence(manifest, blockedStep, evidencePath)
18379
+ );
18380
+ }
18381
+ function emptyUxBugCounts() {
18382
+ return { P0: 0, P1: 0, P2: 0, P3: 0 };
18383
+ }
18384
+ function parseUxBugCounts(value) {
18385
+ const counts = emptyUxBugCounts();
18386
+ const matches = [...value.matchAll(/(?:^|,)\s*(P[0-3])\s*=\s*(\d+)\s*(?=,|$)/g)];
18387
+ if (matches.length !== UX_SEVERITIES.length) return null;
18388
+ for (const match of matches) counts[match[1]] = Number(match[2]);
18389
+ return UX_SEVERITIES.every((severity) => matches.filter((match) => match[1] === severity).length === 1) ? counts : null;
18390
+ }
18391
+ function nonEmptyString(value) {
18392
+ return typeof value === "string" && value.trim().length > 0;
18393
+ }
18394
+ function nonEmptyStringArray(value) {
18395
+ return Array.isArray(value) && value.length > 0 && value.every(nonEmptyString);
18396
+ }
18397
+ async function uxManifestArtifacts(text5, reportPath, runDir) {
18398
+ const artifacts = /* @__PURE__ */ new Set();
18399
+ const manifestValue = reportKeyValue(text5, "execution_manifest:");
18400
+ if (!manifestValue) return artifacts;
18401
+ const manifestPath = path10.resolve(path10.dirname(reportPath), manifestValue);
18402
+ if (!pathInside(runDir, manifestPath) || !await exists3(manifestPath) || !await pathInsideReal(runDir, manifestPath)) {
18403
+ return artifacts;
18404
+ }
18405
+ try {
18406
+ const manifest = JSON.parse(await readText(manifestPath));
18407
+ for (const step of manifest.steps ?? []) {
18408
+ for (const item of step.evidence ?? []) {
18409
+ const evidencePath = path10.isAbsolute(item) ? path10.resolve(item) : path10.resolve(path10.dirname(manifestPath), item);
18410
+ if (!pathInside(runDir, evidencePath) || !await exists3(evidencePath) || !await pathInsideReal(runDir, evidencePath)) continue;
18411
+ artifacts.add(evidencePath);
18412
+ for (const { value, source } of await evidenceJsonRecords(evidencePath)) {
18413
+ artifacts.add(path10.resolve(source));
18414
+ for (const key of ["screenshot", "dom_snapshot", "source_evidence"]) {
18415
+ const referenced = typeof value[key] === "string" ? value[key].trim() : "";
18416
+ if (!referenced) continue;
18417
+ const referencedPath = path10.resolve(path10.dirname(source), referenced);
18418
+ if (pathInside(runDir, referencedPath) && await exists3(referencedPath) && await pathInsideReal(runDir, referencedPath)) {
18419
+ artifacts.add(referencedPath);
18420
+ }
18421
+ }
18422
+ }
18423
+ }
18424
+ }
18425
+ } catch {
18426
+ }
18427
+ return artifacts;
18428
+ }
18429
+ async function validateUxEvidence(values, options) {
18430
+ const errors = [];
18431
+ const mtimes = [];
18432
+ for (const evidenceValue of values) {
18433
+ const evidencePath = path10.resolve(options.runDir, evidenceValue);
18434
+ if (!pathInside(options.runDir, evidencePath) || !await exists3(evidencePath) || !await pathInsideReal(options.runDir, evidencePath) || evidencePath === options.findingsPath) {
18435
+ errors.push(`[test_suite.report.ux_evidence] ${options.prefix}: UX BUG \u8BC1\u636E\u5FC5\u987B\u662F\u672C\u8F6E\u76EE\u5F55\u5185\u5B58\u5728\u7684\u72EC\u7ACB\u6587\u4EF6: ${evidenceValue}`);
18436
+ continue;
18437
+ }
18438
+ const info = await stat6(evidencePath);
18439
+ if (!info.isFile()) {
18440
+ errors.push(`[test_suite.report.ux_evidence] ${options.prefix}: UX BUG \u8BC1\u636E\u5FC5\u987B\u662F\u666E\u901A\u6587\u4EF6\uFF0C\u4E0D\u80FD\u662F\u76EE\u5F55: ${evidenceValue}`);
18441
+ continue;
18442
+ }
18443
+ if (!options.manifestArtifacts.has(evidencePath)) {
18444
+ errors.push(`[test_suite.report.ux_evidence_manifest] ${options.prefix}: UX BUG \u8BC1\u636E\u5FC5\u987B\u7531\u672C\u8F6E execution manifest \u767B\u8BB0\u6216\u5F15\u7528: ${evidenceValue}`);
18445
+ }
18446
+ if (!isWithinWindow(info.mtime, options.window)) {
18447
+ errors.push(`[test_suite.report.ux_evidence_current_run] ${options.prefix}: UX BUG \u8BC1\u636E\u5FC5\u987B\u5728\u672C\u8F6E\u6267\u884C\u7A97\u53E3\u5185\u751F\u6210: ${evidenceValue}`);
18448
+ }
18449
+ const extension = path10.extname(evidencePath).toLowerCase();
18450
+ if (extension === ".png") {
18451
+ if (!await isValidCurrentRunScreenshot(evidencePath)) {
18452
+ errors.push(`[test_suite.report.ux_evidence_invalid] ${options.prefix}: UX \u622A\u56FE\u8BC1\u636E\u5FC5\u987B\u662F\u53EF\u89E3\u6790\u3001\u5C3A\u5BF8\u81F3\u5C11 100x80 \u7684\u771F\u5B9E PNG: ${evidenceValue}`);
18453
+ }
18454
+ } else if (extension === ".json") {
18455
+ try {
18456
+ const parsed = JSON.parse(await readText(evidencePath));
18457
+ if (parsed === null || typeof parsed !== "object") throw new Error("expected object or array");
18458
+ } catch {
18459
+ errors.push(`[test_suite.report.ux_evidence_invalid] ${options.prefix}: UX \u7ED3\u6784\u5316\u8BC1\u636E\u5FC5\u987B\u662F\u6709\u6548 JSON: ${evidenceValue}`);
18460
+ }
18461
+ } else if ([".html", ".htm", ".txt", ".md"].includes(extension)) {
18462
+ if (!(await readText(evidencePath)).trim()) {
18463
+ errors.push(`[test_suite.report.ux_evidence_invalid] ${options.prefix}: UX \u6587\u672C\u6216 DOM \u8BC1\u636E\u4E0D\u80FD\u4E3A\u7A7A: ${evidenceValue}`);
18464
+ }
18465
+ } else {
18466
+ errors.push(`[test_suite.report.ux_evidence_invalid] ${options.prefix}: UX \u8BC1\u636E\u53EA\u63A5\u53D7 PNG\u3001JSON\u3001HTML\u3001TXT \u6216 Markdown \u6587\u4EF6: ${evidenceValue}`);
18467
+ }
18468
+ mtimes.push(info.mtime);
18469
+ }
18470
+ return { errors, mtimes };
18471
+ }
18472
+ async function lintUxAudit(text5, reportPath, runDir, runName) {
18473
+ const errors = [];
18474
+ const testDesignSkill = reportKeyValue(text5, "test_design_skill:");
18475
+ const uxAuditSkill = reportKeyValue(text5, "ux_audit_skill:");
18476
+ if (testDesignSkill !== REPORT_REQUIRED_SKILLS.test_design_skill || uxAuditSkill !== REPORT_REQUIRED_SKILLS.ux_audit_skill) {
18477
+ errors.push(`[test_suite.report.required_skills] ${reportPath}: test_design_skill \u5FC5\u987B\u4E3A ${REPORT_REQUIRED_SKILLS.test_design_skill}\uFF0Cux_audit_skill \u5FC5\u987B\u4E3A ${REPORT_REQUIRED_SKILLS.ux_audit_skill}`);
18478
+ }
18479
+ const reportAuditStatus = reportKeyValue(text5, "ux_audit_status:").toLowerCase();
18480
+ if (!["completed", "blocked"].includes(reportAuditStatus)) {
18481
+ errors.push(`[test_suite.report.ux_audit_status] ${reportPath}: ux_audit_status \u5FC5\u987B\u662F completed \u6216 blocked`);
18482
+ }
18483
+ const countsValue = reportKeyValue(text5, "ux_bug_counts:");
18484
+ const reportedCounts = parseUxBugCounts(countsValue);
18485
+ if (!reportedCounts) {
18486
+ errors.push(`[test_suite.report.ux_bug_counts] ${reportPath}: ux_bug_counts \u5FC5\u987B\u5B8C\u6574\u4F7F\u7528 P0=<n>,P1=<n>,P2=<n>,P3=<n>`);
18487
+ }
18488
+ const findingsValue = reportKeyValue(text5, "ux_findings:");
18489
+ const scenarioId = reportKeyValue(text5, "scenario_id:");
18490
+ const resultValue = reportKeyValue(text5, "result:").toLowerCase();
18491
+ const manifestArtifacts = await uxManifestArtifacts(text5, reportPath, runDir);
18492
+ const window = reportExecutionWindow(runName, text5);
18493
+ let actualCounts = emptyUxBugCounts();
18494
+ if (!findingsValue) {
18495
+ errors.push(`[test_suite.report.ux_findings_missing] ${reportPath}: missing \`ux_findings:\``);
18496
+ } else {
18497
+ const findingsPath = path10.resolve(path10.dirname(reportPath), findingsValue);
18498
+ if (!pathInside(runDir, findingsPath)) {
18499
+ errors.push(`[test_suite.report.ux_findings_scope] ${reportPath}: ux_findings \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
18500
+ } else if (!await exists3(findingsPath)) {
18501
+ errors.push(`[test_suite.report.ux_findings_missing] ${reportPath}: ux_findings \u4E0D\u5B58\u5728: ${findingsValue}`);
18502
+ } else if (!await pathInsideReal(runDir, findingsPath)) {
18503
+ errors.push(`[test_suite.report.ux_findings_scope] ${reportPath}: ux_findings \u5FC5\u987B\u771F\u5B9E\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
18504
+ } else {
18505
+ try {
18506
+ const raw = JSON.parse(await readText(findingsPath));
18507
+ if (raw.version !== 1 || raw.run_id !== runName || raw.scenario_id !== scenarioId) {
18508
+ errors.push(`[test_suite.report.ux_findings_identity] ${reportPath}: ux-findings.json \u7684 version/run_id/scenario_id \u5FC5\u987B\u4E0E\u672C\u8F6E\u62A5\u544A\u4E00\u81F4`);
18509
+ }
18510
+ const auditStatus = typeof raw.audit_status === "string" ? raw.audit_status.toLowerCase() : "";
18511
+ if (!["completed", "blocked"].includes(auditStatus) || auditStatus !== reportAuditStatus) {
18512
+ errors.push(`[test_suite.report.ux_audit_status] ${reportPath}: \u62A5\u544A\u4E0E ux-findings.json \u7684 audit_status \u5FC5\u987B\u4E00\u81F4\u4E14\u4E3A completed|blocked`);
18513
+ }
18514
+ if (auditStatus === "completed" && !nonEmptyStringArray(raw.evaluated_surfaces)) {
18515
+ errors.push(`[test_suite.report.ux_surfaces] ${reportPath}: completed UX audit \u5FC5\u987B\u5217\u51FA evaluated_surfaces`);
18516
+ }
18517
+ if (!Array.isArray(raw.findings)) {
18518
+ errors.push(`[test_suite.report.ux_findings_invalid] ${reportPath}: findings \u5FC5\u987B\u662F\u6570\u7EC4`);
18519
+ } else {
18520
+ for (const [index, unknownFinding] of raw.findings.entries()) {
18521
+ const finding = unknownFinding;
18522
+ const prefix = `${reportPath}: findings[${index}]`;
18523
+ const severity = nonEmptyString(finding.severity) && UX_SEVERITIES.includes(finding.severity) ? finding.severity : null;
18524
+ const valid = finding.classification === "BUG" && severity && nonEmptyString(finding.bug_id) && nonEmptyString(finding.title) && nonEmptyString(finding.surface) && nonEmptyString(finding.user_impact) && nonEmptyStringArray(finding.reproduction_steps) && nonEmptyStringArray(finding.heuristic_refs) && nonEmptyStringArray(finding.evidence) && nonEmptyString(finding.recommendation) && nonEmptyString(finding.status) && UX_FINDING_STATUSES.has(finding.status);
18525
+ if (!valid || !severity) {
18526
+ errors.push(`[test_suite.report.ux_finding_invalid] ${prefix}: \u6BCF\u4E2A\u4F53\u9A8C\u95EE\u9898\u90FD\u5FC5\u987B classification=BUG\uFF0C\u5E76\u5305\u542B\u5408\u6CD5\u4E25\u91CD\u5EA6\u3001\u5F71\u54CD\u3001\u590D\u73B0\u3001\u542F\u53D1\u5F0F\u3001\u8BC1\u636E\u3001\u5EFA\u8BAE\u548C\u72B6\u6001`);
18527
+ continue;
18528
+ }
18529
+ const evidenceCheck = await validateUxEvidence(finding.evidence, {
18530
+ findingsPath,
18531
+ manifestArtifacts,
18532
+ prefix,
18533
+ reportPath,
18534
+ runDir,
18535
+ window
18536
+ });
18537
+ errors.push(...evidenceCheck.errors);
18538
+ if (finding.status === "verified") {
18539
+ if (!nonEmptyStringArray(finding.retest_evidence)) {
18540
+ errors.push(`[test_suite.report.ux_verified_evidence] ${prefix}: verified UX BUG \u5FC5\u987B\u5305\u542B retest_evidence`);
18541
+ } else {
18542
+ const retestCheck = await validateUxEvidence(finding.retest_evidence, {
18543
+ findingsPath,
18544
+ manifestArtifacts,
18545
+ prefix,
18546
+ reportPath,
18547
+ runDir,
18548
+ window
18549
+ });
18550
+ errors.push(...retestCheck.errors);
18551
+ const initialPaths = new Set(finding.evidence.map((item) => path10.resolve(runDir, item)));
18552
+ if (finding.retest_evidence.some((item) => initialPaths.has(path10.resolve(runDir, item)))) {
18553
+ errors.push(`[test_suite.report.ux_verified_evidence] ${prefix}: retest_evidence \u5FC5\u987B\u4F7F\u7528\u4FEE\u590D\u540E\u7684\u65B0\u8BC1\u636E\uFF0C\u4E0D\u80FD\u590D\u7528\u539F\u59CB evidence`);
18554
+ }
18555
+ const latestInitial = Math.max(...evidenceCheck.mtimes.map((item) => item.getTime()));
18556
+ if (retestCheck.mtimes.length === 0 || retestCheck.mtimes.some((item) => item.getTime() <= latestInitial)) {
18557
+ errors.push(`[test_suite.report.ux_verified_evidence] ${prefix}: retest_evidence \u5FC5\u987B\u665A\u4E8E\u539F\u59CB BUG \u8BC1\u636E`);
18558
+ }
18559
+ }
18560
+ } else {
18561
+ actualCounts[severity] += 1;
18562
+ }
18563
+ }
18564
+ }
18565
+ } catch (error) {
18566
+ errors.push(`[test_suite.report.ux_findings_invalid] ${reportPath}: ux_findings \u65E0\u6CD5\u89E3\u6790: ${error instanceof Error ? error.message : String(error)}`);
18567
+ }
18568
+ }
18569
+ }
18570
+ if (reportedCounts && UX_SEVERITIES.some((severity) => reportedCounts[severity] !== actualCounts[severity])) {
18571
+ errors.push(`[test_suite.report.ux_bug_counts] ${reportPath}: ux_bug_counts \u4E0E ux-findings.json \u4E0D\u4E00\u81F4`);
18572
+ }
18573
+ const counts = reportedCounts ?? actualCounts;
18574
+ if (reportAuditStatus === "blocked" && !["partial", "blocked"].includes(resultValue)) {
18575
+ errors.push(`[test_suite.report.ux_result] ${reportPath}: UX \u5BA1\u8BA1 blocked \u65F6 result \u53EA\u80FD\u662F partial \u6216 blocked`);
18576
+ } else if (counts.P0 > 0 || counts.P1 > 0) {
18577
+ if (resultValue !== "fail") errors.push(`[test_suite.report.ux_result] ${reportPath}: \u5B58\u5728 P0/P1 UX BUG \u65F6 result \u5FC5\u987B\u662F fail`);
18578
+ } else if (counts.P2 > 0 || counts.P3 > 0) {
18579
+ if (!["pass-with-warnings", "fail"].includes(resultValue)) errors.push(`[test_suite.report.ux_result] ${reportPath}: \u53EA\u6709 P2/P3 UX BUG \u65F6 result \u5FC5\u987B\u662F pass-with-warnings\uFF1B\u5B58\u5728\u5176\u4ED6\u5931\u8D25\u65F6\u53EF\u4E3A fail`);
18580
+ } else if (reportAuditStatus === "completed" && resultValue === "pass-with-warnings") {
18581
+ errors.push(`[test_suite.report.ux_result] ${reportPath}: \u65E0 UX BUG \u65F6\u4E0D\u80FD\u7528 pass-with-warnings \u89C4\u907F\u660E\u786E\u7ED3\u8BBA`);
18582
+ }
18583
+ if (reportedCounts && testDesignSkill && uxAuditSkill && reportAuditStatus && scenarioId) {
18584
+ return {
18585
+ errors,
18586
+ summary: {
18587
+ report: reportPath,
18588
+ run_id: runName,
18589
+ scenario_id: scenarioId,
18590
+ result: resultValue,
18591
+ test_design_skill: testDesignSkill,
18592
+ ux_audit_skill: uxAuditSkill,
18593
+ ux_audit_status: reportAuditStatus,
18594
+ ux_bug_counts: reportedCounts
18595
+ }
18596
+ };
18597
+ }
18598
+ return { errors };
18599
+ }
17955
18600
  async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
17956
- if (!await exists3(root)) return [`report root not found: ${root}`];
18601
+ if (!await exists3(root)) return { errors: [`report root not found: ${root}`], reports: [] };
17957
18602
  const errors = [];
18603
+ const reports = [];
17958
18604
  const resolvedRoot = path10.resolve(root);
17959
18605
  const candidateDirs = RUN_RE.test(path10.basename(resolvedRoot)) ? [resolvedRoot] : (await scenarioDirs(resolvedRoot)).filter((dir) => RUN_RE.test(path10.basename(dir)));
17960
- if (candidateDirs.length === 0) return [`report run not found under: ${resolvedRoot}`];
18606
+ if (candidateDirs.length === 0) return { errors: [`report run not found under: ${resolvedRoot}`], reports };
17961
18607
  const runDirs = options.allRuns ? candidateDirs : candidateDirs.slice(-1);
17962
18608
  for (const runDir of runDirs) {
17963
18609
  const runName = path10.basename(runDir);
@@ -17972,6 +18618,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
17972
18618
  for (const reportName of scenarioReports) {
17973
18619
  const reportPath = path10.join(runDir, reportName);
17974
18620
  const text5 = await readText(reportPath);
18621
+ const uxAudit = await lintUxAudit(text5, reportPath, runDir, runName);
18622
+ errors.push(...uxAudit.errors);
18623
+ if (uxAudit.summary) reports.push(uxAudit.summary);
17975
18624
  for (const key of REPORT_REQUIRED_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
17976
18625
  for (const key of REPORT_EXECUTION_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
17977
18626
  for (const heading of REPORT_REQUIRED_HEADINGS) if (!text5.includes(heading)) errors.push(`${reportPath}: missing \`${heading}\``);
@@ -18003,9 +18652,10 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18003
18652
  const executedSteps = reportStepList(text5, "executed_steps:");
18004
18653
  const missingExecutedSteps = plannedSteps.filter((stepId) => !executedSteps.includes(stepId));
18005
18654
  const unexpectedExecutedSteps = executedSteps.filter((stepId) => !plannedSteps.includes(stepId));
18006
- if (missingExecutedSteps.length > 0) {
18007
- errors.push(`[test_suite.report.step_reconciliation] ${reportPath}: planned_steps \u4E2D\u5B58\u5728\u672A\u6267\u884C\u6B65\u9AA4: ${missingExecutedSteps.join(", ")}`);
18008
- }
18655
+ const stoppedAfterFail = reportKeyValue(text5, "stopped_after_fail:");
18656
+ let validTerminalStop = false;
18657
+ let validBlockedEvidence = false;
18658
+ let validNonBrowserTerminalStop = false;
18009
18659
  if (unexpectedExecutedSteps.length > 0) {
18010
18660
  errors.push(`[test_suite.report.step_reconciliation] ${reportPath}: executed_steps \u5305\u542B\u672A\u767B\u8BB0\u6B65\u9AA4: ${unexpectedExecutedSteps.join(", ")}`);
18011
18661
  }
@@ -18013,10 +18663,12 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18013
18663
  if (manifestValue) {
18014
18664
  const manifestPath = path10.resolve(path10.dirname(reportPath), manifestValue);
18015
18665
  const runRoot = path10.resolve(runDir);
18016
- if (!manifestPath.startsWith(`${runRoot}${path10.sep}`)) {
18666
+ if (!pathInside(runRoot, manifestPath)) {
18017
18667
  errors.push(`[test_suite.report.execution_manifest_scope] ${reportPath}: execution_manifest \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
18018
18668
  } else if (!await exists3(manifestPath)) {
18019
18669
  errors.push(`[test_suite.report.execution_manifest_missing] ${reportPath}: execution_manifest \u4E0D\u5B58\u5728: ${manifestValue}`);
18670
+ } else if (!await pathInsideReal(runRoot, manifestPath)) {
18671
+ errors.push(`[test_suite.report.execution_manifest_scope] ${reportPath}: execution_manifest \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
18020
18672
  } else {
18021
18673
  try {
18022
18674
  const manifest = await readExecutionManifest(manifestPath);
@@ -18031,6 +18683,35 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18031
18683
  if (executedSteps.some((step) => !manifestExecuted.includes(step))) {
18032
18684
  errors.push(`[test_suite.report.execution_manifest_steps] ${reportPath}: executed_steps \u542B manifest \u4E2D\u672A\u6267\u884C\u7684\u6B65\u9AA4`);
18033
18685
  }
18686
+ const terminalIndex = manifest.steps.findIndex((step) => step.status === "fail" || step.status === "blocked");
18687
+ if (terminalIndex >= 0 && (manifest.result === "fail" || manifest.result === "blocked")) {
18688
+ const expectedStop = `${manifest.case_id}/${manifest.steps[terminalIndex].step_id}`;
18689
+ const expectedExecuted = manifest.steps.slice(0, terminalIndex + 1).map((step) => `${manifest.case_id}/${step.step_id}`);
18690
+ const expectedUnexecuted = manifest.steps.slice(terminalIndex + 1).map((step) => `${manifest.case_id}/${step.step_id}`);
18691
+ const resultMatchesManifest = manifest.result === "fail" ? /^(?:fail|failed|error|失败)$/.test(resultValue) : /^(?:blocked|阻塞)$/.test(resultValue);
18692
+ validTerminalStop = stoppedAfterFail === expectedStop && resultMatchesManifest && manifest.steps.slice(0, terminalIndex).every((step) => step.status === "pass") && manifest.steps.slice(terminalIndex + 1).every((step) => step.status === "planned") && JSON.stringify(executedSteps) === JSON.stringify(expectedExecuted) && JSON.stringify(missingExecutedSteps) === JSON.stringify(expectedUnexecuted);
18693
+ validNonBrowserTerminalStop = false;
18694
+ if (validTerminalStop && !["browser", "e2e_create_page"].includes(manifest.steps[terminalIndex].runner)) {
18695
+ const terminalStep = manifest.steps[terminalIndex];
18696
+ for (const evidencePath of terminalStep.evidence) {
18697
+ const resolvedEvidencePath = path10.isAbsolute(evidencePath) ? path10.resolve(evidencePath) : path10.resolve(path10.dirname(manifestPath), evidencePath);
18698
+ if (!pathInside(runRoot, resolvedEvidencePath) || !await pathInsideReal(runRoot, resolvedEvidencePath)) {
18699
+ errors.push(`[test_suite.report.terminal_evidence_scope] ${reportPath}: \u975E\u6D4F\u89C8\u5668 terminal evidence \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185: ${evidencePath}`);
18700
+ continue;
18701
+ }
18702
+ if (await hasStructuredTerminalEvidence(manifest, terminalStep, resolvedEvidencePath, manifest.result)) {
18703
+ validNonBrowserTerminalStop = true;
18704
+ break;
18705
+ }
18706
+ }
18707
+ if (!validNonBrowserTerminalStop) {
18708
+ errors.push(`[test_suite.report.terminal_evidence] ${reportPath}: \u975E\u6D4F\u89C8\u5668 fail/blocked \u7EC8\u6B62\u6B65\u9AA4\u5FC5\u987B\u4FDD\u7559\u4E0E\u5F53\u524D case/step \u5339\u914D\u7684\u7ED3\u6784\u5316 failure.kind/message \u6216 blocker.kind/message \u8BC1\u636E`);
18709
+ }
18710
+ }
18711
+ if (validTerminalStop && manifest.result === "blocked") {
18712
+ validBlockedEvidence = await reportHasValidBlockedEvidence(text5, reportPath, runDir, manifest);
18713
+ }
18714
+ }
18034
18715
  if (reportClaimsCompleteResult(resultValue)) {
18035
18716
  const incomplete = manifest.steps.filter((step) => step.status !== "pass" || step.evidence.length === 0);
18036
18717
  if (manifest.result !== "pass" || incomplete.length > 0) {
@@ -18045,6 +18726,12 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18045
18726
  }
18046
18727
  }
18047
18728
  }
18729
+ if (missingExecutedSteps.length > 0 && !validTerminalStop) {
18730
+ errors.push(`[test_suite.report.step_reconciliation] ${reportPath}: planned_steps \u4E2D\u5B58\u5728\u672A\u6267\u884C\u6B65\u9AA4: ${missingExecutedSteps.join(", ")}`);
18731
+ }
18732
+ if (stoppedAfterFail && !validTerminalStop) {
18733
+ errors.push(`[test_suite.report.stop_boundary] ${reportPath}: stopped_after_fail \u5FC5\u987B\u5BF9\u5E94 manifest \u4E2D\u9996\u4E2A fail/blocked \u6B65\u9AA4\uFF0C\u4E14\u4EC5\u5141\u8BB8\u5176\u540E\u7684 planned \u6B65\u9AA4\u4FDD\u6301\u672A\u6267\u884C`);
18734
+ }
18048
18735
  if ((NOT_RUN_RE.test(text5) || BLOCKED_RE.test(text5)) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
18049
18736
  errors.push(`[test_suite.report.not_run_downgrade] ${reportPath}: \u62A5\u544A\u5B58\u5728 blocked/not-run/\u672A\u6267\u884C\u7528\u4F8B\u4F46 result \u662F\u5B8C\u6574\u7ED3\u8BBA\uFF1B\u5FC5\u987B\u964D\u7EA7\u4E3A partial/stage/blocked`);
18050
18737
  }
@@ -18078,6 +18765,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18078
18765
  if (/browser[_ -]?blocked|浏览器阻塞|无可用浏览器工具/i.test(text5) && !/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5)) {
18079
18766
  errors.push(`[test_suite.report.browser_blocked] ${reportPath}: \u6D4F\u89C8\u5668\u963B\u585E\u62A5\u544A\u5FC5\u987B\u4F7F\u7528 browser_status: blocked \u6A21\u677F\uFF0C\u5E76\u505C\u6B62\u9875\u9762\u7ED3\u8BBA`);
18080
18767
  }
18768
+ if (/browser_status:\s*blocked/i.test(text5) && !validBlockedEvidence) {
18769
+ errors.push(`[test_suite.report.blocked_evidence] ${reportPath}: browser_status: blocked \u5FC5\u987B\u5F15\u7528\u672C\u8F6E\u7ED3\u6784\u5316 blocker_evidence\uFF0C\u5305\u542B\u5339\u914D case/step \u7684 blocked \u72B6\u6001\u4EE5\u53CA blocker.kind/message`);
18770
+ }
18081
18771
  if (/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|诊断/.test(resultValue)) {
18082
18772
  errors.push(`[test_suite.report.page_conclusion_browser] ${reportPath}: browser_status: blocked \u65F6\u4E0D\u80FD\u58F0\u660E\u5B8C\u6574\u9875\u9762\u901A\u8FC7\uFF1B\u5FC5\u987B\u964D\u7EA7\u4E3A partial/stage/blocked/diagnostic`);
18083
18773
  }
@@ -18096,7 +18786,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18096
18786
  }
18097
18787
  const imageMatches = [...text5.matchAll(IMAGE_RE)];
18098
18788
  const imageRefs = imageMatches.map((match) => match[1]);
18099
- if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
18789
+ if (imageRefs.length === 0 && !validBlockedEvidence && !validNonBrowserTerminalStop) {
18790
+ errors.push(`${reportPath}: missing embedded screenshot image`);
18791
+ }
18100
18792
  const validCurrentRunImages = [];
18101
18793
  const window = reportExecutionWindow(runName, text5);
18102
18794
  for (const imageRef of imageRefs) {
@@ -18141,7 +18833,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18141
18833
  }
18142
18834
  }
18143
18835
  }
18144
- return errors;
18836
+ return { errors, reports };
18145
18837
  }
18146
18838
  async function validateCopyDiffArtifacts(scenarioDir) {
18147
18839
  const diffDir = path10.join(scenarioDir, COPY_DIFF_DIR);
@@ -20784,7 +21476,7 @@ function prettyCreatedIssue(issue3) {
20784
21476
  }
20785
21477
  function registerIssueCommands(program2, deps = {}) {
20786
21478
  const createIssue = deps.createIssue || createGitLabIssue;
20787
- const issue3 = program2.command("issue").description("Report bugs and create GitLab issues for bpmax-cli");
21479
+ const issue3 = program2.command("issue").description("Report bugs and create GitLab issues for bpmax-cli").option("--profile <profile>", "Profile name (accepted for workspace-rule compatibility; ignored)");
20788
21480
  const registerCreateLike = (name) => {
20789
21481
  issue3.command(name).description(name === "create" ? "Create a GitLab issue" : "Report a bug as a GitLab issue").requiredOption("--title <title>", "Issue title").option("--description <text>", "Issue description").option("--description-file <file>", "Read issue description from a file").option("--label <label>", "Issue label, repeatable", (value, previous = []) => [...previous, value], []).option("--assignee-id <id>", "GitLab assignee id, repeatable or comma-separated", (value, previous = []) => [...previous, value], []).option("--confidential", "Create a confidential issue").option("--gitlab-url <url>", "GitLab base URL", DEFAULT_GITLAB_URL).option("--project <path>", "GitLab project path or id", DEFAULT_GITLAB_PROJECT).option("--token-env <name>", "Environment variable name that contains the GitLab token").option("--dry-run", "Print the GitLab issue payload without submitting").option("--format <format>", "Output format", "pretty").action(async (options) => {
20790
21482
  const input = await buildIssueInput(options);
@@ -24917,7 +25609,7 @@ function collect(value, previous = []) {
24917
25609
  return previous;
24918
25610
  }
24919
25611
  function registerTaskbookCommands(program2) {
24920
- const taskbook = program2.command("taskbook").description("Manage BPMAX AI implementation taskbooks and prompt gates");
25612
+ const taskbook = program2.command("taskbook").description("Manage BPMAX AI implementation taskbooks and prompt gates").option("--profile <profile>", "Profile name (accepted for workspace-rule compatibility; ignored)");
24921
25613
  taskbook.command("init").description("Create a local BPMAX AI implementation taskbook template").requiredOption("--out <file>", "Output taskbook markdown file").option("--title <title>", "Taskbook title").option("--format <format>", "Output format", "pretty").action(async (options) => {
24922
25614
  printResult(options.format, await initTaskbook(options.out, options.title));
24923
25615
  });
@@ -24973,7 +25665,7 @@ async function resolveE2eSkillSource(sourceSkill) {
24973
25665
  return { source: `installed:${status.current}`, version: VERSION };
24974
25666
  }
24975
25667
  function registerTestSuiteCommands(program2) {
24976
- const suite = program2.command("test-suite").description("Manage local BPMAX AI test case suites under .ai_test");
25668
+ const suite = program2.command("test-suite").description("Manage local BPMAX AI test case suites under .ai_test").option("--profile <profile>", "Profile name (accepted for workspace-rule compatibility; ignored by local-only commands)");
24977
25669
  suite.command("lint").description("Lint BPMAX AI test case suite scenarios").option("--root <path>", "Suite root directory", DEFAULT_SUITE_ROOT).requiredOption("--latest-proof <path>", "latest-* proof JSON written after syncing the sysconfig repo").option("--explain", "Include review.json schema and test_data alignment rules in the output").option("--format <format>", "Output format", "json").action(async (options) => {
24978
25670
  await requireLatestProof(options.latestProof);
24979
25671
  printResult(options.format, await lintSuiteDetailed(options.root, { explain: Boolean(options.explain) }));
@@ -25035,11 +25727,12 @@ function registerTestSuiteCommands(program2) {
25035
25727
  printResult(options.format, { path: reportDir });
25036
25728
  });
25037
25729
  suite.command("lint-report").description("Lint BPMAX E2E test report artifacts").option("--root <path>", "Report root directory", DEFAULT_REPORT_ROOT).option("--all-runs", "Lint every historical run instead of only the latest/current run").option("--format <format>", "Output format", "json").action(async (options) => {
25038
- const errors = await lintReport(options.root, { allRuns: Boolean(options.allRuns) });
25039
- if (errors.length > 0) {
25040
- throw new Error(errors.join("\n"));
25730
+ const lint = await lintReport(options.root, { allRuns: Boolean(options.allRuns) });
25731
+ if (lint.errors.length > 0) {
25732
+ throw new Error(lint.errors.join("\n"));
25041
25733
  }
25042
- printResult(options.format, { ok: true });
25734
+ const summary = lint.reports.length === 1 ? lint.reports[0] : { reports: lint.reports };
25735
+ printResult(options.format, { ok: true, ...summary });
25043
25736
  });
25044
25737
  }
25045
25738
 
@@ -25257,7 +25950,10 @@ async function detectCurrentInstallMethod() {
25257
25950
  }
25258
25951
  async function runNpmInstall(version, options = {}) {
25259
25952
  const runner = options.runner || runCommand;
25260
- return runner("npm", ["install", "-g", `${options.packageName || NPM_PACKAGE}@${version}`], {
25953
+ const isWindows = (options.platform || process.platform) === "win32";
25954
+ const npmCommand = isWindows ? "npm.cmd" : "npm";
25955
+ return runner(npmCommand, ["install", "-g", `${options.packageName || NPM_PACKAGE}@${version}`], {
25956
+ ...isWindows ? { shell: true } : {},
25261
25957
  timeoutMs: NPM_INSTALL_TIMEOUT_MS
25262
25958
  });
25263
25959
  }