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

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/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.36",
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,
@@ -15979,6 +16246,15 @@ var TestSuiteError = class extends Error {
15979
16246
  this.suggestion = options.suggestion;
15980
16247
  }
15981
16248
  };
16249
+ function runtimeRoute(runtimeUrl) {
16250
+ const url = new URL(runtimeUrl);
16251
+ const hashRoute = url.hash.startsWith("#/") ? new URL(url.hash.slice(1), url.origin) : null;
16252
+ return {
16253
+ url,
16254
+ path: hashRoute?.pathname || url.pathname,
16255
+ params: hashRoute?.searchParams || url.searchParams
16256
+ };
16257
+ }
15982
16258
  async function exists3(filePath) {
15983
16259
  try {
15984
16260
  await stat6(filePath);
@@ -16773,6 +17049,24 @@ function pathInside(root, candidate) {
16773
17049
  const resolvedCandidate = path10.resolve(candidate);
16774
17050
  return resolvedCandidate === resolvedRoot || resolvedCandidate.startsWith(`${resolvedRoot}${path10.sep}`);
16775
17051
  }
17052
+ async function pathInsideReal(root, candidate) {
17053
+ if (!pathInside(root, candidate)) return false;
17054
+ try {
17055
+ const [realRoot, realCandidate] = await Promise.all([realpath2(root), realpath2(candidate)]);
17056
+ return pathInside(realRoot, realCandidate);
17057
+ } catch {
17058
+ return false;
17059
+ }
17060
+ }
17061
+ async function assertCurrentRunPathScope(runDir, artifactPath, message) {
17062
+ if (!pathInside(runDir, artifactPath)) {
17063
+ fail(message, { rule_id: "test_suite.run.evidence_scope", path: artifactPath });
17064
+ }
17065
+ if (!await exists3(artifactPath)) return;
17066
+ if (!await pathInsideReal(runDir, artifactPath)) {
17067
+ fail(message, { rule_id: "test_suite.run.evidence_scope", path: artifactPath });
17068
+ }
17069
+ }
16776
17070
  async function assertCurrentRunArtifact(manifest, artifactPath) {
16777
17071
  if (!await exists3(artifactPath)) {
16778
17072
  fail(`execution evidence artifact not found: ${artifactPath}`, { rule_id: "test_suite.run.evidence_missing", path: artifactPath });
@@ -16785,9 +17079,7 @@ async function assertCurrentRunArtifact(manifest, artifactPath) {
16785
17079
  async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
16786
17080
  if (!await exists3(evidencePath)) fail(`execution evidence not found: ${evidencePath}`, { rule_id: "test_suite.run.evidence_missing", path: evidencePath });
16787
17081
  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
- }
17082
+ await assertCurrentRunPathScope(runDir, evidencePath, "formal execution evidence must stay inside the current report run directory");
16791
17083
  const info = await stat6(evidencePath);
16792
17084
  if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
16793
17085
  fail("execution evidence predates the current run", { rule_id: "test_suite.run.evidence_stale", path: evidencePath });
@@ -16820,7 +17112,7 @@ async function evidenceJsonRecords(evidencePath) {
16820
17112
  }
16821
17113
  return records;
16822
17114
  }
16823
- async function browserEvidenceScreenshots(manifest, manifestPath, step, evidencePath) {
17115
+ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidencePath, expectedResult = "pass") {
16824
17116
  const jsonRecords = await evidenceJsonRecords(evidencePath);
16825
17117
  const screenshotPaths = [];
16826
17118
  let matchedRecord = false;
@@ -16834,10 +17126,13 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16834
17126
  const runtimeEnvironment = String(value.runtime_environment || "profile").trim();
16835
17127
  if (!["profile", "local-browser"].includes(runtimeEnvironment)) continue;
16836
17128
  try {
16837
- const runtimeOrigin = new URL(runtimeUrl).origin;
17129
+ const parsed = runtimeRoute(runtimeUrl);
17130
+ const runtimeOrigin = parsed.url.origin;
16838
17131
  const profileOrigin = manifest.profile_origin ? new URL(manifest.profile_origin).origin : "";
16839
17132
  if (runtimeEnvironment === "profile" && profileOrigin && runtimeOrigin !== profileOrigin) continue;
16840
- if (runtimeEnvironment === "local-browser" && !/^(?:localhost|127\.0\.0\.1|\[::1\])$/.test(new URL(runtimeUrl).hostname)) continue;
17133
+ if (runtimeEnvironment === "local-browser" && !/^(?:localhost|127\.0\.0\.1|\[::1\])$/.test(parsed.url.hostname)) continue;
17134
+ const workspaceMatch = /^\/w:([^/]+)(?:\/|$)/i.exec(parsed.path);
17135
+ if (manifest.workspace && workspaceMatch && decodeURIComponent(workspaceMatch[1]) !== manifest.workspace) continue;
16841
17136
  } catch {
16842
17137
  continue;
16843
17138
  }
@@ -16846,13 +17141,14 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16846
17141
  if (runtimeScope === "project" && !/^\d+$/.test(projectId)) continue;
16847
17142
  if (runtimeScope === "step" && (!/^\d+$/.test(projectId) || !/^\d+$/.test(runtimeStepId))) continue;
16848
17143
  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;
17144
+ if (assertions.length === 0) continue;
17145
+ if (expectedResult === "pass" && assertions.some((assertion) => assertion.passed !== true)) continue;
17146
+ if (expectedResult !== "pass" && !assertions.some((assertion) => assertion.passed === false)) continue;
16850
17147
  const screenshot = typeof value.screenshot === "string" ? value.screenshot.trim() : "";
16851
17148
  if (!screenshot) continue;
16852
17149
  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
- }
17150
+ await assertCurrentRunArtifact(manifest, source);
17151
+ await assertCurrentRunPathScope(path10.dirname(manifestPath), screenshotPath, "browser screenshot must stay inside the current report run directory");
16856
17152
  await assertCurrentRunArtifact(manifest, screenshotPath);
16857
17153
  if (!await isValidCurrentRunScreenshot(screenshotPath)) {
16858
17154
  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 +17157,7 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16861
17157
  const domSnapshot = typeof value.dom_snapshot === "string" ? value.dom_snapshot.trim() : "";
16862
17158
  if (!domSnapshot) continue;
16863
17159
  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
- }
17160
+ await assertCurrentRunPathScope(path10.dirname(manifestPath), domPath, "browser DOM evidence must stay inside the current report run directory");
16867
17161
  await assertCurrentRunArtifact(manifest, domPath);
16868
17162
  }
16869
17163
  matchedRecord = true;
@@ -16871,12 +17165,58 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16871
17165
  }
16872
17166
  if (!matchedRecord) {
16873
17167
  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",
17168
+ `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
17169
  { rule_id: "test_suite.run.unexecuted_evidence", path: evidencePath }
16876
17170
  );
16877
17171
  }
16878
17172
  return [...new Set(screenshotPaths)];
16879
17173
  }
17174
+ var BLOCKER_BROWSER_FIELDS = [
17175
+ "browser_verified",
17176
+ "runtime_scope",
17177
+ "runtime_environment",
17178
+ "runtime_url",
17179
+ "browser_tool",
17180
+ "project_id",
17181
+ "step_id",
17182
+ "screenshot",
17183
+ "dom_snapshot",
17184
+ "observed",
17185
+ "assertions",
17186
+ "source_evidence"
17187
+ ];
17188
+ async function structuredBlockedEvidenceSource(manifest, step, evidencePath) {
17189
+ const records = await evidenceJsonRecords(evidencePath);
17190
+ if (records.some(({ value }) => BLOCKER_BROWSER_FIELDS.some((field) => Object.hasOwn(value, field)))) return void 0;
17191
+ for (const { value, source } of records) {
17192
+ if (value.case_id !== step.case_id || value.case_step_id !== step.step_id) continue;
17193
+ if (value.blocked !== true && String(value.status || "").toLowerCase() !== "blocked") continue;
17194
+ const blocker = asRecord(value.blocker);
17195
+ if (typeof blocker.kind !== "string" || !blocker.kind.trim()) continue;
17196
+ if (typeof blocker.message !== "string" || !blocker.message.trim()) continue;
17197
+ await assertCurrentRunArtifact(manifest, source);
17198
+ return source;
17199
+ }
17200
+ return void 0;
17201
+ }
17202
+ async function hasStructuredBlockedEvidence(manifest, step, evidencePath) {
17203
+ return Boolean(await structuredBlockedEvidenceSource(manifest, step, evidencePath));
17204
+ }
17205
+ async function hasStructuredTerminalEvidence(manifest, step, evidencePath, result) {
17206
+ if (result === "blocked") return hasStructuredBlockedEvidence(manifest, step, evidencePath);
17207
+ for (const { value, source } of await evidenceJsonRecords(evidencePath)) {
17208
+ if (value.case_id !== step.case_id || value.case_step_id !== step.step_id) continue;
17209
+ if (value.failed !== true && !["fail", "failed", "error"].includes(String(value.status || "").toLowerCase())) continue;
17210
+ const failure = asRecord(value.failure);
17211
+ const error = asRecord(value.error);
17212
+ const detail = Object.keys(failure).length > 0 ? failure : error;
17213
+ if (typeof detail.kind !== "string" || !detail.kind.trim()) continue;
17214
+ if (typeof detail.message !== "string" || !detail.message.trim()) continue;
17215
+ await assertCurrentRunArtifact(manifest, source);
17216
+ return true;
17217
+ }
17218
+ return false;
17219
+ }
16880
17220
  function replaceReportMetadata(text5, key, value) {
16881
17221
  const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16882
17222
  const line = new RegExp(`^${escaped}:.*(?:\\r?\\n|$)`, "m");
@@ -16900,7 +17240,7 @@ async function browserReportEvidence(manifest) {
16900
17240
  const result = { assertions: [], screenshots: [] };
16901
17241
  const priority = { page: 1, project: 2, step: 3 };
16902
17242
  for (const step of manifest.steps) {
16903
- if (step.status !== "pass" || !["browser", "e2e_create_page"].includes(step.runner)) continue;
17243
+ if (step.status === "planned" || !["browser", "e2e_create_page"].includes(step.runner)) continue;
16904
17244
  for (const evidencePath of step.evidence) {
16905
17245
  for (const { value, source } of await evidenceJsonRecords(evidencePath)) {
16906
17246
  if (value.case_id !== step.case_id || value.case_step_id !== step.step_id || value.browser_verified !== true) continue;
@@ -16918,9 +17258,9 @@ async function browserReportEvidence(manifest) {
16918
17258
  }
16919
17259
  const assertions = Array.isArray(value.assertions) ? value.assertions.map(asRecord) : [];
16920
17260
  for (const assertion of assertions) {
16921
- if (assertion.passed !== true) continue;
17261
+ if (step.status === "pass" && assertion.passed !== true) continue;
16922
17262
  const label = String(assertion.name || assertion.message || "").trim();
16923
- if (label) result.assertions.push(label);
17263
+ if (label) result.assertions.push(assertion.passed === false ? `\u5931\u8D25\u65AD\u8A00\uFF1A${label}` : label);
16924
17264
  }
16925
17265
  const screenshot = String(value.screenshot || "").trim();
16926
17266
  if (screenshot) result.screenshots.push({ stepId: step.step_id, path: path10.resolve(path10.dirname(source), screenshot) });
@@ -16952,8 +17292,21 @@ async function syncTestSuiteRunReportUnlocked(manifestFile) {
16952
17292
  report = replaceReportMetadata(report, "executed_cases", executedCase);
16953
17293
  report = replaceReportMetadata(report, "planned_steps", manifest.steps.map((step) => `${manifest.case_id}/${step.step_id}`).join(", "));
16954
17294
  report = replaceReportMetadata(report, "executed_steps", executedSteps.length > 0 ? executedSteps.map((step) => `${manifest.case_id}/${step.step_id}`).join(", ") : "pending");
17295
+ const stoppedStep = manifest.steps.find((step) => step.status === "fail" || step.status === "blocked");
17296
+ report = replaceReportMetadata(report, "stopped_after_fail", stoppedStep ? `${manifest.case_id}/${stoppedStep.step_id}` : null);
17297
+ const browserBlocked = stoppedStep?.status === "blocked" && ["browser", "e2e_create_page"].includes(stoppedStep.runner);
17298
+ let blockerEvidence;
17299
+ if (browserBlocked) {
17300
+ for (const evidencePath of stoppedStep.evidence) {
17301
+ blockerEvidence = await structuredBlockedEvidenceSource(manifest, stoppedStep, evidencePath);
17302
+ if (blockerEvidence) break;
17303
+ }
17304
+ }
17305
+ report = replaceReportMetadata(report, "browser_status", blockerEvidence ? "blocked" : null);
17306
+ report = replaceReportMetadata(report, "blocker_evidence", blockerEvidence ? path10.relative(runDir, blockerEvidence) : null);
16955
17307
  report = replaceReportMetadata(report, "runtime_profile", manifest.profile);
16956
17308
  report = replaceReportMetadata(report, "profile_origin", manifest.profile_origin || null);
17309
+ report = replaceReportMetadata(report, "runtime_workspace", manifest.workspace || null);
16957
17310
  report = replaceReportMetadata(report, "runtime_scope", evidence.scope || null);
16958
17311
  report = replaceReportMetadata(report, "runtime_environment", evidence.environment || null);
16959
17312
  report = replaceReportMetadata(report, "runtime_url", evidence.runtimeUrl || null);
@@ -17019,13 +17372,28 @@ async function assertFormalExecutionEvidence(manifest, manifestPath, step, evide
17019
17372
  }
17020
17373
  }
17021
17374
  if (step.runner === "observe") {
17022
- const validObservation = jsonRecords.some(({ value, source }) => {
17375
+ let validObservation = false;
17376
+ for (const { value, source } of jsonRecords) {
17023
17377
  const observed = value.observed === true || ["passed", "observed", "verified"].includes(String(value.status || ""));
17024
- const assertions = Array.isArray(value.assertions) ? value.assertions : [];
17378
+ const assertions = Array.isArray(value.assertions) ? value.assertions.map(asRecord).filter((assertion) => Object.keys(assertion).length > 0) : [];
17025
17379
  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 });
17380
+ if (!observed || assertions.length === 0 || !assertions.every((assertion) => assertion.passed === true) || !sourceEvidence) continue;
17381
+ await assertCurrentRunArtifact(manifest, source);
17382
+ const sourcePath = path10.resolve(path10.dirname(source), sourceEvidence);
17383
+ const runDir = path10.dirname(path10.resolve(manifestPath));
17384
+ if (!pathInside(runDir, sourcePath)) {
17385
+ fail("observe source_evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: sourcePath });
17386
+ }
17387
+ if (!await exists3(sourcePath) || !(await stat6(sourcePath)).isFile()) continue;
17388
+ const [realRunDir, realSourcePath] = await Promise.all([realpath2(runDir), realpath2(sourcePath)]);
17389
+ if (!pathInside(realRunDir, realSourcePath)) {
17390
+ fail("observe source_evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: sourcePath });
17391
+ }
17392
+ await assertCurrentRunArtifact(manifest, sourcePath);
17393
+ validObservation = true;
17394
+ break;
17395
+ }
17396
+ 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
17397
  }
17030
17398
  }
17031
17399
  async function writeExecutionManifest(manifestPath, manifest, incrementRevision = false) {
@@ -17043,7 +17411,7 @@ function currentManifestStep(manifest) {
17043
17411
  }
17044
17412
  async function startTestSuiteRun(options) {
17045
17413
  const scenarioDir = scenarioPath(options.suiteRoot ?? DEFAULT_SUITE_ROOT, options.scenario);
17046
- await validateScenario(scenarioDir);
17414
+ const scenario = await validateScenario(scenarioDir);
17047
17415
  const rows2 = await readCases(path10.join(scenarioDir, "cases.csv"));
17048
17416
  const row = rows2.find((item) => item.case_id === options.caseId && item.status !== "deprecated");
17049
17417
  if (!row) fail(`${scenarioDir}: active case not found: ${options.caseId}`, { rule_id: "test_suite.run.case_not_found" });
@@ -17059,6 +17427,7 @@ async function startTestSuiteRun(options) {
17059
17427
  scenario_id: options.scenario,
17060
17428
  case_id: options.caseId,
17061
17429
  profile: options.profile,
17430
+ workspace: scenario.workspace,
17062
17431
  ...options.profileOrigin ? { profile_origin: options.profileOrigin } : {},
17063
17432
  revision: 0,
17064
17433
  ...options.skillSource ? { skill_source: options.skillSource } : {},
@@ -17218,6 +17587,20 @@ async function recordTestSuiteRunStep(options) {
17218
17587
  const evidencePath = path10.resolve(options.evidence);
17219
17588
  await assertCurrentRunEvidence(validated.manifest, validated.manifestPath, evidencePath);
17220
17589
  if (options.result === "pass") await assertFormalExecutionEvidence(validated.manifest, validated.manifestPath, validated.step, evidencePath);
17590
+ if (options.result !== "pass" && !["browser", "e2e_create_page"].includes(validated.step.runner)) {
17591
+ if (!await hasStructuredTerminalEvidence(validated.manifest, validated.step, evidencePath, options.result)) {
17592
+ fail("non-browser fail/blocked evidence must identify the current case/step and include structured failure.kind/message or blocker.kind/message", {
17593
+ rule_id: "test_suite.run.terminal_evidence",
17594
+ path: evidencePath
17595
+ });
17596
+ }
17597
+ }
17598
+ if (options.result !== "pass" && ["browser", "e2e_create_page"].includes(validated.step.runner)) {
17599
+ const structuredBlocker = options.result === "blocked" && await hasStructuredBlockedEvidence(validated.manifest, validated.step, evidencePath);
17600
+ if (!structuredBlocker) {
17601
+ await browserEvidenceScreenshots(validated.manifest, validated.manifestPath, validated.step, evidencePath, options.result);
17602
+ }
17603
+ }
17221
17604
  validated.step.status = options.result;
17222
17605
  validated.step.evidence = [.../* @__PURE__ */ new Set([...validated.step.evidence, evidencePath])];
17223
17606
  validated.step.recorded_at = (/* @__PURE__ */ new Date()).toISOString();
@@ -17814,6 +18197,9 @@ function reportRuntimeEvidenceMissing(text5) {
17814
18197
  if (!reportHasAnyKeyValue(text5, ["profile_origin:"])) {
17815
18198
  missing.push("profile_origin");
17816
18199
  }
18200
+ if (!reportHasAnyKeyValue(text5, ["runtime_workspace:"])) {
18201
+ missing.push("runtime_workspace");
18202
+ }
17817
18203
  if (!reportHasAnyKeyValue(text5, ["runtime_user:", "runtime_profile:", "browser_user:"])) {
17818
18204
  missing.push("runtime_user/runtime_profile");
17819
18205
  }
@@ -17838,6 +18224,7 @@ function reportRuntimeEvidenceInvalid(text5) {
17838
18224
  const runtimeScope = reportKeyValue(text5, "runtime_scope:");
17839
18225
  const runtimeEnvironment = reportKeyValue(text5, "runtime_environment:");
17840
18226
  const profileOrigin = reportKeyValue(text5, "profile_origin:");
18227
+ const runtimeWorkspace = reportKeyValue(text5, "runtime_workspace:");
17841
18228
  const runtimeUser = reportKeyValue(text5, "runtime_user:") || reportKeyValue(text5, "runtime_profile:") || reportKeyValue(text5, "browser_user:");
17842
18229
  const actionLog = reportKeyValue(text5, "browser_action_log:") || reportKeyValue(text5, "browser_actions:");
17843
18230
  const assertions = reportKeyValue(text5, "visible_assertions:") || reportKeyValue(text5, "visible_assertion:");
@@ -17849,17 +18236,20 @@ function reportRuntimeEvidenceInvalid(text5) {
17849
18236
  if (!["page", "project", "step"].includes(runtimeScope)) invalid.push("runtime_scope");
17850
18237
  if (!["profile", "local-browser"].includes(runtimeEnvironment)) invalid.push("runtime_environment");
17851
18238
  try {
17852
- const url = new URL(runtimeUrl);
18239
+ const parsed = runtimeRoute(runtimeUrl);
18240
+ const url = parsed.url;
17853
18241
  const configuredOrigin = new URL(profileOrigin);
17854
18242
  if (!["http:", "https:"].includes(url.protocol) || !url.hostname) invalid.push("runtime_url");
17855
18243
  if (runtimeEnvironment === "profile" && url.origin !== configuredOrigin.origin) invalid.push("runtime_url/profile_origin");
17856
18244
  if (runtimeEnvironment === "local-browser" && !/^(?:localhost|127\.0\.0\.1|\[::1\])$/.test(url.hostname)) {
17857
18245
  invalid.push("runtime_url/local_browser");
17858
18246
  }
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);
18247
+ const runtimePath = parsed.path;
18248
+ const runtimeParams = parsed.params;
18249
+ const isWorkspacePageRoute = runtimeScope === "page" && /^\/w:[^/]+(?:\/.*)?$/i.test(runtimePath);
18250
+ const workspaceMatch = /^\/w:([^/]+)(?:\/|$)/i.exec(runtimePath);
18251
+ if (workspaceMatch && decodeURIComponent(workspaceMatch[1]) !== runtimeWorkspace) invalid.push("runtime_url/workspace");
18252
+ const isSupportedUiRoute = /(?:\/project(?:$|\/|\?|_detail)|\/myProject|\/projectContinue|\/pages\/)/i.test(runtimePath) || /^\/w:[^/]+\/(?:userManagement|console)(?:\/|$)/i.test(runtimePath) || isWorkspacePageRoute;
17863
18253
  if (/(^|\.)example\.(?:com|org|net)$/i.test(url.hostname) || /\/(?:api|bpmax)(?:\/|$)/i.test(runtimePath) || !isSupportedUiRoute) {
17864
18254
  invalid.push("runtime_url/ui_route");
17865
18255
  }
@@ -17952,6 +18342,18 @@ function linesForCase(text5, caseId) {
17952
18342
  const pattern = new RegExp(`\\b${escaped}\\b`);
17953
18343
  return text5.split(/\r?\n/).filter((line) => pattern.test(line));
17954
18344
  }
18345
+ async function reportHasValidBlockedEvidence(text5, reportPath, runDir, manifest) {
18346
+ if (reportKeyValue(text5, "browser_status:").toLowerCase() !== "blocked") return false;
18347
+ const evidenceValue = reportKeyValue(text5, "blocker_evidence:");
18348
+ if (!evidenceValue) return false;
18349
+ const evidencePath = path10.resolve(path10.dirname(reportPath), evidenceValue);
18350
+ if (!await exists3(evidencePath) || !(await stat6(evidencePath)).isFile() || !await pathInsideReal(runDir, evidencePath)) return false;
18351
+ await assertCurrentRunArtifact(manifest, evidencePath);
18352
+ const blockedStep = manifest.steps.find((step) => step.status === "blocked");
18353
+ return Boolean(
18354
+ blockedStep && ["browser", "e2e_create_page"].includes(blockedStep.runner) && await hasStructuredBlockedEvidence(manifest, blockedStep, evidencePath)
18355
+ );
18356
+ }
17955
18357
  async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
17956
18358
  if (!await exists3(root)) return [`report root not found: ${root}`];
17957
18359
  const errors = [];
@@ -18003,9 +18405,10 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18003
18405
  const executedSteps = reportStepList(text5, "executed_steps:");
18004
18406
  const missingExecutedSteps = plannedSteps.filter((stepId) => !executedSteps.includes(stepId));
18005
18407
  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
- }
18408
+ const stoppedAfterFail = reportKeyValue(text5, "stopped_after_fail:");
18409
+ let validTerminalStop = false;
18410
+ let validBlockedEvidence = false;
18411
+ let validNonBrowserTerminalStop = false;
18009
18412
  if (unexpectedExecutedSteps.length > 0) {
18010
18413
  errors.push(`[test_suite.report.step_reconciliation] ${reportPath}: executed_steps \u5305\u542B\u672A\u767B\u8BB0\u6B65\u9AA4: ${unexpectedExecutedSteps.join(", ")}`);
18011
18414
  }
@@ -18013,10 +18416,12 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18013
18416
  if (manifestValue) {
18014
18417
  const manifestPath = path10.resolve(path10.dirname(reportPath), manifestValue);
18015
18418
  const runRoot = path10.resolve(runDir);
18016
- if (!manifestPath.startsWith(`${runRoot}${path10.sep}`)) {
18419
+ if (!pathInside(runRoot, manifestPath)) {
18017
18420
  errors.push(`[test_suite.report.execution_manifest_scope] ${reportPath}: execution_manifest \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
18018
18421
  } else if (!await exists3(manifestPath)) {
18019
18422
  errors.push(`[test_suite.report.execution_manifest_missing] ${reportPath}: execution_manifest \u4E0D\u5B58\u5728: ${manifestValue}`);
18423
+ } else if (!await pathInsideReal(runRoot, manifestPath)) {
18424
+ errors.push(`[test_suite.report.execution_manifest_scope] ${reportPath}: execution_manifest \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
18020
18425
  } else {
18021
18426
  try {
18022
18427
  const manifest = await readExecutionManifest(manifestPath);
@@ -18031,6 +18436,35 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18031
18436
  if (executedSteps.some((step) => !manifestExecuted.includes(step))) {
18032
18437
  errors.push(`[test_suite.report.execution_manifest_steps] ${reportPath}: executed_steps \u542B manifest \u4E2D\u672A\u6267\u884C\u7684\u6B65\u9AA4`);
18033
18438
  }
18439
+ const terminalIndex = manifest.steps.findIndex((step) => step.status === "fail" || step.status === "blocked");
18440
+ if (terminalIndex >= 0 && (manifest.result === "fail" || manifest.result === "blocked")) {
18441
+ const expectedStop = `${manifest.case_id}/${manifest.steps[terminalIndex].step_id}`;
18442
+ const expectedExecuted = manifest.steps.slice(0, terminalIndex + 1).map((step) => `${manifest.case_id}/${step.step_id}`);
18443
+ const expectedUnexecuted = manifest.steps.slice(terminalIndex + 1).map((step) => `${manifest.case_id}/${step.step_id}`);
18444
+ const resultMatchesManifest = manifest.result === "fail" ? /^(?:fail|failed|error|失败)$/.test(resultValue) : /^(?:blocked|阻塞)$/.test(resultValue);
18445
+ 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);
18446
+ validNonBrowserTerminalStop = false;
18447
+ if (validTerminalStop && !["browser", "e2e_create_page"].includes(manifest.steps[terminalIndex].runner)) {
18448
+ const terminalStep = manifest.steps[terminalIndex];
18449
+ for (const evidencePath of terminalStep.evidence) {
18450
+ const resolvedEvidencePath = path10.isAbsolute(evidencePath) ? path10.resolve(evidencePath) : path10.resolve(path10.dirname(manifestPath), evidencePath);
18451
+ if (!pathInside(runRoot, resolvedEvidencePath) || !await pathInsideReal(runRoot, resolvedEvidencePath)) {
18452
+ 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}`);
18453
+ continue;
18454
+ }
18455
+ if (await hasStructuredTerminalEvidence(manifest, terminalStep, resolvedEvidencePath, manifest.result)) {
18456
+ validNonBrowserTerminalStop = true;
18457
+ break;
18458
+ }
18459
+ }
18460
+ if (!validNonBrowserTerminalStop) {
18461
+ 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`);
18462
+ }
18463
+ }
18464
+ if (validTerminalStop && manifest.result === "blocked") {
18465
+ validBlockedEvidence = await reportHasValidBlockedEvidence(text5, reportPath, runDir, manifest);
18466
+ }
18467
+ }
18034
18468
  if (reportClaimsCompleteResult(resultValue)) {
18035
18469
  const incomplete = manifest.steps.filter((step) => step.status !== "pass" || step.evidence.length === 0);
18036
18470
  if (manifest.result !== "pass" || incomplete.length > 0) {
@@ -18045,6 +18479,12 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18045
18479
  }
18046
18480
  }
18047
18481
  }
18482
+ if (missingExecutedSteps.length > 0 && !validTerminalStop) {
18483
+ errors.push(`[test_suite.report.step_reconciliation] ${reportPath}: planned_steps \u4E2D\u5B58\u5728\u672A\u6267\u884C\u6B65\u9AA4: ${missingExecutedSteps.join(", ")}`);
18484
+ }
18485
+ if (stoppedAfterFail && !validTerminalStop) {
18486
+ 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`);
18487
+ }
18048
18488
  if ((NOT_RUN_RE.test(text5) || BLOCKED_RE.test(text5)) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
18049
18489
  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
18490
  }
@@ -18078,6 +18518,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18078
18518
  if (/browser[_ -]?blocked|浏览器阻塞|无可用浏览器工具/i.test(text5) && !/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5)) {
18079
18519
  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
18520
  }
18521
+ if (/browser_status:\s*blocked/i.test(text5) && !validBlockedEvidence) {
18522
+ 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`);
18523
+ }
18081
18524
  if (/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|诊断/.test(resultValue)) {
18082
18525
  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
18526
  }
@@ -18096,7 +18539,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18096
18539
  }
18097
18540
  const imageMatches = [...text5.matchAll(IMAGE_RE)];
18098
18541
  const imageRefs = imageMatches.map((match) => match[1]);
18099
- if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
18542
+ if (imageRefs.length === 0 && !validBlockedEvidence && !validNonBrowserTerminalStop) {
18543
+ errors.push(`${reportPath}: missing embedded screenshot image`);
18544
+ }
18100
18545
  const validCurrentRunImages = [];
18101
18546
  const window = reportExecutionWindow(runName, text5);
18102
18547
  for (const imageRef of imageRefs) {
@@ -20784,7 +21229,7 @@ function prettyCreatedIssue(issue3) {
20784
21229
  }
20785
21230
  function registerIssueCommands(program2, deps = {}) {
20786
21231
  const createIssue = deps.createIssue || createGitLabIssue;
20787
- const issue3 = program2.command("issue").description("Report bugs and create GitLab issues for bpmax-cli");
21232
+ 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
21233
  const registerCreateLike = (name) => {
20789
21234
  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
21235
  const input = await buildIssueInput(options);
@@ -24917,7 +25362,7 @@ function collect(value, previous = []) {
24917
25362
  return previous;
24918
25363
  }
24919
25364
  function registerTaskbookCommands(program2) {
24920
- const taskbook = program2.command("taskbook").description("Manage BPMAX AI implementation taskbooks and prompt gates");
25365
+ 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
25366
  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
25367
  printResult(options.format, await initTaskbook(options.out, options.title));
24923
25368
  });
@@ -24973,7 +25418,7 @@ async function resolveE2eSkillSource(sourceSkill) {
24973
25418
  return { source: `installed:${status.current}`, version: VERSION };
24974
25419
  }
24975
25420
  function registerTestSuiteCommands(program2) {
24976
- const suite = program2.command("test-suite").description("Manage local BPMAX AI test case suites under .ai_test");
25421
+ 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
25422
  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
25423
  await requireLatestProof(options.latestProof);
24979
25424
  printResult(options.format, await lintSuiteDetailed(options.root, { explain: Boolean(options.explain) }));
@@ -25257,7 +25702,10 @@ async function detectCurrentInstallMethod() {
25257
25702
  }
25258
25703
  async function runNpmInstall(version, options = {}) {
25259
25704
  const runner = options.runner || runCommand;
25260
- return runner("npm", ["install", "-g", `${options.packageName || NPM_PACKAGE}@${version}`], {
25705
+ const isWindows = (options.platform || process.platform) === "win32";
25706
+ const npmCommand = isWindows ? "npm.cmd" : "npm";
25707
+ return runner(npmCommand, ["install", "-g", `${options.packageName || NPM_PACKAGE}@${version}`], {
25708
+ ...isWindows ? { shell: true } : {},
25261
25709
  timeoutMs: NPM_INSTALL_TIMEOUT_MS
25262
25710
  });
25263
25711
  }