bpmax-cli 0.2.1-beta.34 → 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
@@ -311,6 +311,7 @@ function capabilityForRequest(method, path16) {
311
311
  if (normalizedMethod === "DELETE" && /^\/form_template\/[^/]+$/.test(normalizedPath)) return "config.form_template.delete";
312
312
  if (normalizedMethod === "POST" && normalizedPath === "/form_template/publish") return "config.form_template.submit";
313
313
  if (normalizedMethod === "POST" && normalizedPath === "/flow_page_template") return `${pageTemplatePrefix}.create`;
314
+ if (normalizedMethod === "GET" && normalizedPath === "/flow_page_template") return `${pageTemplatePrefix}.export`;
314
315
  if (normalizedMethod === "GET" && /^\/flow_page_template\/[^/]+$/.test(normalizedPath)) return `${pageTemplatePrefix}.export`;
315
316
  if (normalizedMethod === "PUT" && /^\/flow_page_template\/[^/]+$/.test(normalizedPath)) return `${pageTemplatePrefix}.submit`;
316
317
  if (normalizedMethod === "DELETE" && /^\/flow_page_template\/[^/]+$/.test(normalizedPath)) return `${pageTemplatePrefix}.delete`;
@@ -455,6 +456,9 @@ function flowPageTemplateCapabilityPrefix(path16) {
455
456
  if (type === "4") {
456
457
  return "config.console_template";
457
458
  }
459
+ if (type === "5") {
460
+ return "config.flow_detail_template";
461
+ }
458
462
  if (type === "6") {
459
463
  return "config.step_detail_template";
460
464
  }
@@ -492,7 +496,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
492
496
  // package.json
493
497
  var package_default = {
494
498
  name: "bpmax-cli",
495
- version: "0.2.1-beta.34",
499
+ version: "0.2.1-beta.36",
496
500
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
497
501
  type: "module",
498
502
  bin: {
@@ -512,7 +516,7 @@ var package_default = {
512
516
  build: "tsup",
513
517
  dev: "tsx src/bin.ts",
514
518
  "install:skills": "node scripts/install-skills.mjs",
515
- test: "vitest run",
519
+ test: "vitest run --exclude '.worktrees/**'",
516
520
  typecheck: "tsc --noEmit"
517
521
  },
518
522
  engines: {
@@ -1562,6 +1566,7 @@ var runCommand = (command, args, options = {}) => new Promise((resolve) => {
1562
1566
  const child = spawn(command, args, {
1563
1567
  cwd: options.cwd,
1564
1568
  env: options.env,
1569
+ shell: options.shell,
1565
1570
  stdio: ["ignore", "pipe", "pipe"]
1566
1571
  });
1567
1572
  let stdout = "";
@@ -4301,6 +4306,7 @@ var LOCAL_UUID_DOMAIN_DIR = {
4301
4306
  "list-template": "think_flow_page_template",
4302
4307
  "filter-template": "think_flow_page_template",
4303
4308
  "project-detail-template": "think_flow_page_template",
4309
+ "flow-detail-template": "think_flow_page_template",
4304
4310
  "step-detail-template": "think_flow_page_template",
4305
4311
  "console-template": "think_flow_page_template",
4306
4312
  dataset: "think_data_set",
@@ -4317,6 +4323,7 @@ var REMOTE_UUID_EXPORT_PATH = {
4317
4323
  "list-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
4318
4324
  "filter-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
4319
4325
  "project-detail-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
4326
+ "flow-detail-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
4320
4327
  "step-detail-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
4321
4328
  "console-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
4322
4329
  "user-model": (uuid) => `/user_model/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
@@ -4434,6 +4441,23 @@ var CONFIG_DOMAINS = {
4434
4441
  writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
4435
4442
  notes: ["type=2 project detail template. Create and edit both use the typed flow_page_template adapter; create automatically finalizes data_set_id/flow_type through PUT when needed; activate/delete remain domain-specific operations."]
4436
4443
  },
4444
+ "flow-detail-template": {
4445
+ capability: "config.flow_detail_template",
4446
+ exportPath: (id) => `/flow_page_template/${id}?type=5&skip_i18n=true`,
4447
+ exportStatus: "supported",
4448
+ buildStatus: "supported",
4449
+ submitStatus: "supported",
4450
+ createPath: "/flow_page_template",
4451
+ createMethod: "POST",
4452
+ deletePath: (id) => `/flow_page_template/${id}`,
4453
+ deleteMethod: "DELETE",
4454
+ submitPath: (id) => `/flow_page_template/${id}`,
4455
+ submitMethod: "PUT",
4456
+ expectedType: 5,
4457
+ readEndpoints: ["GET /api/flow_page_template?type=5&flow_type=:flow_type&flow_key=:flow_key", "GET /api/flow_page_template/:id?type=5&skip_i18n=true"],
4458
+ writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
4459
+ notes: ["type=5 flow report/document template managed by the report_template editor. The flow-detail-template command name is retained for compatibility; this domain is distinct from type=2 project detail templates and type=6 step detail templates."]
4460
+ },
4437
4461
  "step-detail-template": {
4438
4462
  capability: "config.step_detail_template",
4439
4463
  exportPath: (id) => `/flow_page_template/${id}?type=6&skip_i18n=true`,
@@ -4610,6 +4634,28 @@ function configAdapterMatrix() {
4610
4634
  const supportsDelete = Boolean(definition.deletePath) || ["workspace-flow", "api-platform", "nav-config"].includes(domain);
4611
4635
  const supportsPublish = domain === "dataset";
4612
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;
4613
4659
  return {
4614
4660
  domain,
4615
4661
  capability_prefix: definition.capability,
@@ -4645,6 +4691,7 @@ function configAdapterMatrix() {
4645
4691
  publishes_on_submit: domain === "form-template",
4646
4692
  relation_fields_submit: domain === "dataset"
4647
4693
  },
4694
+ ...semanticCapabilities ? { semantic_capabilities: semanticCapabilities } : {},
4648
4695
  notes: definition.notes
4649
4696
  };
4650
4697
  });
@@ -6601,12 +6648,256 @@ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLab
6601
6648
  if (typeof script !== "string") {
6602
6649
  return;
6603
6650
  }
6604
- const hasRowLoop = /\.(forEach|map|reduce|filter)\s*\(|for\s*\([^)]*\b(of|in)\b/i.test(script);
6605
- const hasMetric = /(count|total|amount|qty|quantity|inventory|stock|sale|销量|库存|项目数|数量|金额|合计|总数)/i.test(script);
6606
6651
  const dataSourceText = typeof dataSource === "string" ? dataSource : JSON.stringify(dataSource) ?? "";
6607
- const hasAggregation = /(aggs|aggregations)\b|size\s*:\s*0|['\"]size['\"]\s*:\s*0/i.test(`${dataSourceText}
6608
- ${script}`);
6609
- 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) {
6610
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`);
6611
6902
  }
6612
6903
  }
@@ -7372,6 +7663,63 @@ function validatePageTemplateName(work, errors) {
7372
7663
  }
7373
7664
  throw new Error(message);
7374
7665
  }
7666
+ function lintFlowDetailTemplateWork(work, errors, warnings = []) {
7667
+ const configuredType = pageTemplateType(work);
7668
+ if (configuredType !== void 0 && configuredType !== 5) {
7669
+ errors.push(`flow-detail-template \u5FC5\u987B\u4F7F\u7528 flow_page_template.type=5\uFF0C\u5F53\u524D\u4E3A ${configuredType}\u3002`);
7670
+ }
7671
+ const content = parseTemplateContent(work, errors);
7672
+ if (!isRecord3(content)) {
7673
+ errors.push("flow-detail-template content \u5FC5\u987B\u662F\u5305\u542B fields \u548C templateFile \u7684 JSON \u5BF9\u8C61\u3002");
7674
+ return;
7675
+ }
7676
+ if (!Array.isArray(content.fields)) {
7677
+ errors.push("flow-detail-template content.fields \u5FC5\u987B\u662F\u6570\u7EC4\u3002");
7678
+ } else {
7679
+ const seenFields = /* @__PURE__ */ new Set();
7680
+ content.fields.forEach((item, index) => {
7681
+ const itemPath = `flow-detail-template content.fields[${index}]`;
7682
+ if (!isRecord3(item)) {
7683
+ errors.push(`${itemPath} \u5FC5\u987B\u662F\u5BF9\u8C61\u3002`);
7684
+ return;
7685
+ }
7686
+ for (const key of ["field", "desc", "expression"]) {
7687
+ if (typeof item[key] !== "string" || !item[key].trim()) {
7688
+ errors.push(`${itemPath}.${key} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002`);
7689
+ }
7690
+ }
7691
+ const field = typeof item.field === "string" ? item.field.trim() : "";
7692
+ if (field) {
7693
+ if (seenFields.has(field)) {
7694
+ errors.push(`${itemPath}.field \u4E0E\u5DF2\u6709\u62A5\u544A\u5B57\u6BB5 ${JSON.stringify(field)} \u91CD\u590D\u3002`);
7695
+ }
7696
+ seenFields.add(field);
7697
+ }
7698
+ });
7699
+ }
7700
+ if (!Array.isArray(content.templateFile)) {
7701
+ errors.push("flow-detail-template content.templateFile \u5FC5\u987B\u662F\u6570\u7EC4\u3002");
7702
+ } else {
7703
+ if (content.templateFile.length === 0) {
7704
+ errors.push("flow-detail-template content.templateFile \u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u62A5\u544A\u6A21\u677F\u6587\u4EF6\uFF1B\u5E73\u53F0\u751F\u6210\u62A5\u544A\u65F6\u8BFB\u53D6\u7B2C\u4E00\u4E2A\u6587\u4EF6\u3002");
7705
+ }
7706
+ content.templateFile.forEach((item, index) => {
7707
+ const itemPath = `flow-detail-template content.templateFile[${index}]`;
7708
+ if (!isRecord3(item)) {
7709
+ errors.push(`${itemPath} \u5FC5\u987B\u662F\u5BF9\u8C61\u3002`);
7710
+ return;
7711
+ }
7712
+ for (const key of ["name", "url"]) {
7713
+ if (typeof item[key] !== "string" || !item[key].trim()) {
7714
+ errors.push(`${itemPath}.${key} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002`);
7715
+ }
7716
+ }
7717
+ });
7718
+ if (content.templateFile.length > 1) {
7719
+ warnings.push("flow-detail-template \u914D\u7F6E\u4E86\u591A\u4E2A templateFile\uFF1B\u5E73\u53F0\u751F\u6210\u62A5\u544A\u65F6\u53EA\u4F7F\u7528\u7B2C\u4E00\u4E2A\u6587\u4EF6\uFF0C\u8BF7\u786E\u8BA4\u6392\u5E8F\u3002");
7720
+ }
7721
+ }
7722
+ }
7375
7723
  function normalizePageTemplatePayload(domain, work) {
7376
7724
  const definition = CONFIG_DOMAINS[domain];
7377
7725
  validatePageTemplateName(work);
@@ -7401,6 +7749,13 @@ function normalizePageTemplatePayload(domain, work) {
7401
7749
  throw new Error(`step-detail-template lint failed: ${errors.join("; ")}`);
7402
7750
  }
7403
7751
  }
7752
+ if (domain === "flow-detail-template") {
7753
+ const errors = [];
7754
+ lintFlowDetailTemplateWork(work, errors);
7755
+ if (errors.length) {
7756
+ throw new Error(`flow-detail-template lint failed: ${errors.join("; ")}`);
7757
+ }
7758
+ }
7404
7759
  const basic = isRecord3(work.basic) ? work.basic : work;
7405
7760
  const rawContent = work.content ?? basic.content;
7406
7761
  const type = definition.expectedType;
@@ -10210,7 +10565,7 @@ function buildDomainSubmitPayload(domain, work, options = {}, raw) {
10210
10565
  if (domain === "nav-config") {
10211
10566
  return buildNavConfigSubmitPayload(work, isRecord3(raw) ? raw : void 0, options);
10212
10567
  }
10213
- if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "step-detail-template" || domain === "console-template") {
10568
+ if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "flow-detail-template" || domain === "step-detail-template" || domain === "console-template") {
10214
10569
  return normalizePageTemplatePayload(domain, work);
10215
10570
  }
10216
10571
  throw new Error(`${CONFIG_SUBMIT_UNSUPPORTED_MESSAGE} Domain: ${domain}.`);
@@ -11397,7 +11752,7 @@ function normalizeTypedReadbackComparable(domain, value) {
11397
11752
  normalized.sub_ids = [...new Set(normalized.sub_ids.map(normalizeComparableId))].sort((left, right) => String(left).localeCompare(String(right)));
11398
11753
  }
11399
11754
  }
11400
- if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "step-detail-template" || domain === "console-template") {
11755
+ if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "flow-detail-template" || domain === "step-detail-template" || domain === "console-template") {
11401
11756
  if (Object.prototype.hasOwnProperty.call(normalized, "data_set_id")) {
11402
11757
  normalized.data_set_id = normalizeComparableId(normalized.data_set_id);
11403
11758
  }
@@ -11455,7 +11810,7 @@ function assertJsonSubset(expected, actual, label) {
11455
11810
  }
11456
11811
  }
11457
11812
  function isPageTemplateCreateFinalizeDomain(domain) {
11458
- return domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "step-detail-template";
11813
+ return domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "flow-detail-template" || domain === "step-detail-template";
11459
11814
  }
11460
11815
  function pageTemplateCreateNeedsFinalize(domain, payload, comparison) {
11461
11816
  if (!isPageTemplateCreateFinalizeDomain(domain)) {
@@ -11482,6 +11837,64 @@ async function readbackConfigDomain(config, profile, domain, id) {
11482
11837
  readback: data
11483
11838
  };
11484
11839
  }
11840
+ async function listFlowDetailTemplates(profile, options) {
11841
+ const flowType = options.flowType.trim();
11842
+ if (!flowType) {
11843
+ throw new Error("flow-detail-template list requires --flow-type.");
11844
+ }
11845
+ const page = options.page ?? 1;
11846
+ const pageSize = options.pageSize ?? 100;
11847
+ if (!Number.isSafeInteger(page) || page < 1) {
11848
+ throw new Error("flow-detail-template list --page \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\u3002");
11849
+ }
11850
+ if (!Number.isSafeInteger(pageSize) || pageSize < 1 || pageSize > 1e3) {
11851
+ throw new Error("flow-detail-template list --page-size \u5FC5\u987B\u662F 1-1000 \u7684\u6574\u6570\u3002");
11852
+ }
11853
+ const definition = CONFIG_DOMAINS["flow-detail-template"];
11854
+ await ensureConfigCapability(profile, `${definition.capability}.export`);
11855
+ const params = new URLSearchParams({
11856
+ type: "5",
11857
+ flow_type: flowType,
11858
+ flow_key: options.flowKey?.trim() ?? "",
11859
+ page: String(page),
11860
+ page_size: String(pageSize),
11861
+ sort: "-create_time"
11862
+ });
11863
+ const name = options.name?.trim();
11864
+ if (name) params.set("name", name);
11865
+ const endpoint = `/flow_page_template?${params.toString()}`;
11866
+ const response = await apiRequest(
11867
+ createApiClient(profile),
11868
+ "GET",
11869
+ endpoint,
11870
+ { capability: `${definition.capability}.export` }
11871
+ );
11872
+ const templates = extractListData(response).filter((record) => Number(record.type) === 5).map((record) => ({
11873
+ id: record.id ?? null,
11874
+ uuid: record.uuid ?? null,
11875
+ name: record.name ?? "",
11876
+ desc: record.desc ?? "",
11877
+ status: record.status ?? null,
11878
+ flow_type: record.flow_type ?? "",
11879
+ flow_key: record.flow_key ?? "",
11880
+ create_time: record.create_time ?? null,
11881
+ update_time: record.update_time ?? null,
11882
+ readback_hash: hashJson(record)
11883
+ }));
11884
+ const pagination = isRecord3(response) ? pickDefined(response, ["currentPage", "pageSize", "totalPages", "count"]) : {};
11885
+ return {
11886
+ domain: "flow-detail-template",
11887
+ semantic_type: "flow-report-template",
11888
+ flow_type: flowType,
11889
+ flow_key: options.flowKey?.trim() ?? "",
11890
+ name: name ?? "",
11891
+ source_api: `GET /api${endpoint}`,
11892
+ ...pagination,
11893
+ match_count: templates.length,
11894
+ templates,
11895
+ verified_at: (/* @__PURE__ */ new Date()).toISOString()
11896
+ };
11897
+ }
11485
11898
  async function resolveFlowAppContextFlowId(profile, flow) {
11486
11899
  const trimmed = flow.trim();
11487
11900
  if (!trimmed) {
@@ -11871,7 +12284,14 @@ async function resolveConfigUuidId(options) {
11871
12284
  { capability: `${definition.capability}.export` }
11872
12285
  );
11873
12286
  const remoteRecord = isRecord3(response) && isRecord3(response.data) ? response.data : response;
11874
- const remote = isRecord3(remoteRecord) ? {
12287
+ const hasRemoteIdentity = isRecord3(remoteRecord) && [
12288
+ remoteRecord.id,
12289
+ remoteRecord.origin_template_id,
12290
+ remoteRecord.uuid,
12291
+ remoteRecord.type,
12292
+ remoteRecord.name
12293
+ ].some((value) => value !== void 0 && value !== null && value !== "");
12294
+ const remote = hasRemoteIdentity && isRecord3(remoteRecord) ? {
11875
12295
  id: numericIdString(remoteRecord.id),
11876
12296
  origin_template_id: numericIdString(remoteRecord.origin_template_id),
11877
12297
  name: remoteRecord.name ?? remoteRecord.title ?? null,
@@ -12030,6 +12450,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
12030
12450
  }
12031
12451
  const raw = typeof meta.raw_file === "string" ? await readJsonFile(meta.raw_file) : void 0;
12032
12452
  let formTemplateWarnings = [];
12453
+ let flowDetailTemplateWarnings = [];
12033
12454
  let stepDetailReferenceAudit;
12034
12455
  let stepDetailAnalysis;
12035
12456
  if (domain === "flow-template" && isRecord3(work)) {
@@ -12068,6 +12489,14 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
12068
12489
  throw new Error(`step-detail-template lint failed: ${errors.join("; ")}`);
12069
12490
  }
12070
12491
  }
12492
+ if (domain === "flow-detail-template" && isRecord3(work)) {
12493
+ const errors = [];
12494
+ flowDetailTemplateWarnings = [];
12495
+ lintFlowDetailTemplateWork(work, errors, flowDetailTemplateWarnings);
12496
+ if (errors.length) {
12497
+ throw new Error(`flow-detail-template lint failed: ${errors.join("; ")}`);
12498
+ }
12499
+ }
12071
12500
  const payloadWork = (domain === "dataset" || domain === "dataset-field") && createMode && isRecord3(work) ? { ...work, mode: "create" } : work;
12072
12501
  const payload = buildDomainSubmitPayload(domain, payloadWork, options, raw);
12073
12502
  if (domain === "flow-template" && options.publishLive) {
@@ -12088,6 +12517,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
12088
12517
  base_hash: createMode ? null : typeof meta.base_hash === "string" ? meta.base_hash : null,
12089
12518
  payload,
12090
12519
  ...formTemplateWarnings.length ? { form_template_warnings: formTemplateWarnings } : {},
12520
+ ...flowDetailTemplateWarnings.length ? { flow_detail_template_warnings: flowDetailTemplateWarnings } : {},
12091
12521
  ...stepDetailReferenceAudit ? {
12092
12522
  step_detail_references: stepDetailReferenceAudit.references,
12093
12523
  step_detail_warnings: stepDetailReferenceAudit.warnings,
@@ -12107,6 +12537,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
12107
12537
  submit_file: outFile,
12108
12538
  payload_keys: Object.keys(payload),
12109
12539
  ...formTemplateWarnings.length ? { warnings: formTemplateWarnings } : {},
12540
+ ...flowDetailTemplateWarnings.length ? { warnings: flowDetailTemplateWarnings } : {},
12110
12541
  ...stepDetailReferenceAudit ? {
12111
12542
  step_detail_references: stepDetailReferenceAudit.references,
12112
12543
  warnings: stepDetailReferenceAudit.warnings,
@@ -12253,6 +12684,9 @@ async function lintConfigWorkFile(file, options = {}) {
12253
12684
  if (options.domain === "step-detail-template") {
12254
12685
  stepDetailAnalysis = lintStepDetailTemplateWork(value, errors, warnings);
12255
12686
  }
12687
+ if (options.domain === "flow-detail-template") {
12688
+ lintFlowDetailTemplateWork(value, errors, warnings);
12689
+ }
12256
12690
  if ((Object.prototype.hasOwnProperty.call(value, "content") || isRecord3(value.basic)) && pageTemplateType(value) === 1) {
12257
12691
  validateListTemplateActionGate(value, errors);
12258
12692
  }
@@ -12631,6 +13065,13 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
12631
13065
  throw new Error(`step-detail-template lint failed: ${stepDetailAnalysis.errors.join("; ")}`);
12632
13066
  }
12633
13067
  }
13068
+ if (domain === "flow-detail-template") {
13069
+ const errors = [];
13070
+ lintFlowDetailTemplateWork(submit.payload, errors);
13071
+ if (errors.length) {
13072
+ throw new Error(`flow-detail-template lint failed: ${errors.join("; ")}`);
13073
+ }
13074
+ }
12634
13075
  if (domain === "dataset-field") {
12635
13076
  validateDatasetFieldCreatePayload(submit.payload);
12636
13077
  }
@@ -12815,6 +13256,13 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
12815
13256
  throw new Error(`step-detail-template lint failed: ${stepDetailAnalysis.errors.join("; ")}`);
12816
13257
  }
12817
13258
  }
13259
+ if (domain === "flow-detail-template") {
13260
+ const errors = [];
13261
+ lintFlowDetailTemplateWork(submit.payload, errors);
13262
+ if (errors.length) {
13263
+ throw new Error(`flow-detail-template lint failed: ${errors.join("; ")}`);
13264
+ }
13265
+ }
12818
13266
  if (domain === "form-template" && submitMode === "create") {
12819
13267
  validateNonEmptyFormCreatePayload(submit.payload);
12820
13268
  await ensureConfigCapability(profile, `${definition.capability}.create`);
@@ -13410,6 +13858,7 @@ var CONFIG_DOMAINS2 = [
13410
13858
  ["list-template", "bpmax-list-template-editor", "\u5217\u8868\u6A21\u677F"],
13411
13859
  ["filter-template", "bpmax-filter-template-editor", "\u7B5B\u9009\u6A21\u677F"],
13412
13860
  ["project-detail-template", "bpmax-project-detail-template-editor", "\u9879\u76EE\u8BE6\u60C5\u6A21\u677F"],
13861
+ ["flow-detail-template", "bpmax-flow-detail-template-editor", "\u6D41\u7A0B\u62A5\u544A\u6A21\u677F\uFF08type=5\uFF09"],
13413
13862
  ["console-template", "bpmax-console-template-editor", "\u63A7\u5236\u53F0\u6A21\u677F"],
13414
13863
  ["dataset", "bpmax-dataset-template-editor", "\u6570\u636E\u96C6"],
13415
13864
  ["dataset-field", "bpmax-dataset-field-template-editor", "\u6570\u636E\u96C6\u5B57\u6BB5"],
@@ -15379,6 +15828,21 @@ function registerConfigCommands(program2) {
15379
15828
  await writeResponseOut(options.responseOut, result);
15380
15829
  printResult(options.format, result);
15381
15830
  });
15831
+ if (domain === "flow-detail-template") {
15832
+ domainCommand.command("list").description("List type=5 flow report/document templates for a flow").requiredOption("--flow-type <flowType>", "Main flow type, e.g. flow48198545").option("--flow-key <flowKey>", "Subflow key; omit or pass empty for the main flow", "").option("--name <name>", "Optional template name filter").option("--page <page>", "Page number", (value) => Number(value), 1).option("--page-size <pageSize>", "Page size, 1-1000", (value) => Number(value), 100).option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (options) => {
15833
+ const configData = await loadConfig();
15834
+ const resolved = resolveProfile(configData, options.profile);
15835
+ const result = await listFlowDetailTemplates(resolved, {
15836
+ flowType: options.flowType,
15837
+ flowKey: options.flowKey,
15838
+ name: options.name,
15839
+ page: options.page,
15840
+ pageSize: options.pageSize
15841
+ });
15842
+ await saveConfig(configData);
15843
+ printResult(options.format, result);
15844
+ });
15845
+ }
15382
15846
  if (domain === "project-detail-template") {
15383
15847
  domainCommand.command("resolve-default").description("Resolve the flow-specific default project detail template used by /project_detail/0/<project_id>").requiredOption("--flow-type <flowType>", "Flow type, e.g. flow48198545").option("--flow-key <flowKey>", "Flow key for subflow defaults", "").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (options) => {
15384
15848
  const configData = await loadConfig();
@@ -15586,7 +16050,6 @@ import axios7 from "axios";
15586
16050
 
15587
16051
  // src/core/test-suite.ts
15588
16052
  import { createHash as createHash5 } from "crypto";
15589
- import { existsSync } from "fs";
15590
16053
  import {
15591
16054
  copyFile,
15592
16055
  cp as cp3,
@@ -15783,6 +16246,15 @@ var TestSuiteError = class extends Error {
15783
16246
  this.suggestion = options.suggestion;
15784
16247
  }
15785
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
+ }
15786
16258
  async function exists3(filePath) {
15787
16259
  try {
15788
16260
  await stat6(filePath);
@@ -16577,6 +17049,24 @@ function pathInside(root, candidate) {
16577
17049
  const resolvedCandidate = path10.resolve(candidate);
16578
17050
  return resolvedCandidate === resolvedRoot || resolvedCandidate.startsWith(`${resolvedRoot}${path10.sep}`);
16579
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
+ }
16580
17070
  async function assertCurrentRunArtifact(manifest, artifactPath) {
16581
17071
  if (!await exists3(artifactPath)) {
16582
17072
  fail(`execution evidence artifact not found: ${artifactPath}`, { rule_id: "test_suite.run.evidence_missing", path: artifactPath });
@@ -16589,9 +17079,7 @@ async function assertCurrentRunArtifact(manifest, artifactPath) {
16589
17079
  async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
16590
17080
  if (!await exists3(evidencePath)) fail(`execution evidence not found: ${evidencePath}`, { rule_id: "test_suite.run.evidence_missing", path: evidencePath });
16591
17081
  const runDir = path10.dirname(path10.resolve(manifestPath));
16592
- if (!pathInside(runDir, evidencePath)) {
16593
- fail("formal execution evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: evidencePath });
16594
- }
17082
+ await assertCurrentRunPathScope(runDir, evidencePath, "formal execution evidence must stay inside the current report run directory");
16595
17083
  const info = await stat6(evidencePath);
16596
17084
  if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
16597
17085
  fail("execution evidence predates the current run", { rule_id: "test_suite.run.evidence_stale", path: evidencePath });
@@ -16624,7 +17112,7 @@ async function evidenceJsonRecords(evidencePath) {
16624
17112
  }
16625
17113
  return records;
16626
17114
  }
16627
- async function browserEvidenceScreenshots(manifest, manifestPath, step, evidencePath) {
17115
+ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidencePath, expectedResult = "pass") {
16628
17116
  const jsonRecords = await evidenceJsonRecords(evidencePath);
16629
17117
  const screenshotPaths = [];
16630
17118
  let matchedRecord = false;
@@ -16638,10 +17126,13 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16638
17126
  const runtimeEnvironment = String(value.runtime_environment || "profile").trim();
16639
17127
  if (!["profile", "local-browser"].includes(runtimeEnvironment)) continue;
16640
17128
  try {
16641
- const runtimeOrigin = new URL(runtimeUrl).origin;
17129
+ const parsed = runtimeRoute(runtimeUrl);
17130
+ const runtimeOrigin = parsed.url.origin;
16642
17131
  const profileOrigin = manifest.profile_origin ? new URL(manifest.profile_origin).origin : "";
16643
17132
  if (runtimeEnvironment === "profile" && profileOrigin && runtimeOrigin !== profileOrigin) continue;
16644
- 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;
16645
17136
  } catch {
16646
17137
  continue;
16647
17138
  }
@@ -16650,13 +17141,14 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16650
17141
  if (runtimeScope === "project" && !/^\d+$/.test(projectId)) continue;
16651
17142
  if (runtimeScope === "step" && (!/^\d+$/.test(projectId) || !/^\d+$/.test(runtimeStepId))) continue;
16652
17143
  const assertions = Array.isArray(value.assertions) ? value.assertions.map(asRecord).filter((assertion) => Object.keys(assertion).length > 0) : [];
16653
- 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;
16654
17147
  const screenshot = typeof value.screenshot === "string" ? value.screenshot.trim() : "";
16655
17148
  if (!screenshot) continue;
16656
17149
  const screenshotPath = path10.resolve(path10.dirname(source), screenshot);
16657
- if (!pathInside(path10.dirname(manifestPath), screenshotPath)) {
16658
- fail("browser screenshot must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: screenshotPath });
16659
- }
17150
+ await assertCurrentRunArtifact(manifest, source);
17151
+ await assertCurrentRunPathScope(path10.dirname(manifestPath), screenshotPath, "browser screenshot must stay inside the current report run directory");
16660
17152
  await assertCurrentRunArtifact(manifest, screenshotPath);
16661
17153
  if (!await isValidCurrentRunScreenshot(screenshotPath)) {
16662
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 });
@@ -16665,9 +17157,7 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16665
17157
  const domSnapshot = typeof value.dom_snapshot === "string" ? value.dom_snapshot.trim() : "";
16666
17158
  if (!domSnapshot) continue;
16667
17159
  const domPath = path10.resolve(path10.dirname(source), domSnapshot);
16668
- if (!pathInside(path10.dirname(manifestPath), domPath)) {
16669
- fail("browser DOM evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: domPath });
16670
- }
17160
+ await assertCurrentRunPathScope(path10.dirname(manifestPath), domPath, "browser DOM evidence must stay inside the current report run directory");
16671
17161
  await assertCurrentRunArtifact(manifest, domPath);
16672
17162
  }
16673
17163
  matchedRecord = true;
@@ -16675,12 +17165,58 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
16675
17165
  }
16676
17166
  if (!matchedRecord) {
16677
17167
  fail(
16678
- "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`,
16679
17169
  { rule_id: "test_suite.run.unexecuted_evidence", path: evidencePath }
16680
17170
  );
16681
17171
  }
16682
17172
  return [...new Set(screenshotPaths)];
16683
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
+ }
16684
17220
  function replaceReportMetadata(text5, key, value) {
16685
17221
  const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16686
17222
  const line = new RegExp(`^${escaped}:.*(?:\\r?\\n|$)`, "m");
@@ -16704,7 +17240,7 @@ async function browserReportEvidence(manifest) {
16704
17240
  const result = { assertions: [], screenshots: [] };
16705
17241
  const priority = { page: 1, project: 2, step: 3 };
16706
17242
  for (const step of manifest.steps) {
16707
- 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;
16708
17244
  for (const evidencePath of step.evidence) {
16709
17245
  for (const { value, source } of await evidenceJsonRecords(evidencePath)) {
16710
17246
  if (value.case_id !== step.case_id || value.case_step_id !== step.step_id || value.browser_verified !== true) continue;
@@ -16722,9 +17258,9 @@ async function browserReportEvidence(manifest) {
16722
17258
  }
16723
17259
  const assertions = Array.isArray(value.assertions) ? value.assertions.map(asRecord) : [];
16724
17260
  for (const assertion of assertions) {
16725
- if (assertion.passed !== true) continue;
17261
+ if (step.status === "pass" && assertion.passed !== true) continue;
16726
17262
  const label = String(assertion.name || assertion.message || "").trim();
16727
- if (label) result.assertions.push(label);
17263
+ if (label) result.assertions.push(assertion.passed === false ? `\u5931\u8D25\u65AD\u8A00\uFF1A${label}` : label);
16728
17264
  }
16729
17265
  const screenshot = String(value.screenshot || "").trim();
16730
17266
  if (screenshot) result.screenshots.push({ stepId: step.step_id, path: path10.resolve(path10.dirname(source), screenshot) });
@@ -16756,8 +17292,21 @@ async function syncTestSuiteRunReportUnlocked(manifestFile) {
16756
17292
  report = replaceReportMetadata(report, "executed_cases", executedCase);
16757
17293
  report = replaceReportMetadata(report, "planned_steps", manifest.steps.map((step) => `${manifest.case_id}/${step.step_id}`).join(", "));
16758
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);
16759
17307
  report = replaceReportMetadata(report, "runtime_profile", manifest.profile);
16760
17308
  report = replaceReportMetadata(report, "profile_origin", manifest.profile_origin || null);
17309
+ report = replaceReportMetadata(report, "runtime_workspace", manifest.workspace || null);
16761
17310
  report = replaceReportMetadata(report, "runtime_scope", evidence.scope || null);
16762
17311
  report = replaceReportMetadata(report, "runtime_environment", evidence.environment || null);
16763
17312
  report = replaceReportMetadata(report, "runtime_url", evidence.runtimeUrl || null);
@@ -16823,13 +17372,28 @@ async function assertFormalExecutionEvidence(manifest, manifestPath, step, evide
16823
17372
  }
16824
17373
  }
16825
17374
  if (step.runner === "observe") {
16826
- const validObservation = jsonRecords.some(({ value, source }) => {
17375
+ let validObservation = false;
17376
+ for (const { value, source } of jsonRecords) {
16827
17377
  const observed = value.observed === true || ["passed", "observed", "verified"].includes(String(value.status || ""));
16828
- 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) : [];
16829
17379
  const sourceEvidence = typeof value.source_evidence === "string" ? value.source_evidence : "";
16830
- return observed && assertions.length > 0 && Boolean(sourceEvidence) && existsSync(path10.resolve(path10.dirname(source), sourceEvidence));
16831
- });
16832
- 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 });
16833
17397
  }
16834
17398
  }
16835
17399
  async function writeExecutionManifest(manifestPath, manifest, incrementRevision = false) {
@@ -16847,7 +17411,7 @@ function currentManifestStep(manifest) {
16847
17411
  }
16848
17412
  async function startTestSuiteRun(options) {
16849
17413
  const scenarioDir = scenarioPath(options.suiteRoot ?? DEFAULT_SUITE_ROOT, options.scenario);
16850
- await validateScenario(scenarioDir);
17414
+ const scenario = await validateScenario(scenarioDir);
16851
17415
  const rows2 = await readCases(path10.join(scenarioDir, "cases.csv"));
16852
17416
  const row = rows2.find((item) => item.case_id === options.caseId && item.status !== "deprecated");
16853
17417
  if (!row) fail(`${scenarioDir}: active case not found: ${options.caseId}`, { rule_id: "test_suite.run.case_not_found" });
@@ -16863,6 +17427,7 @@ async function startTestSuiteRun(options) {
16863
17427
  scenario_id: options.scenario,
16864
17428
  case_id: options.caseId,
16865
17429
  profile: options.profile,
17430
+ workspace: scenario.workspace,
16866
17431
  ...options.profileOrigin ? { profile_origin: options.profileOrigin } : {},
16867
17432
  revision: 0,
16868
17433
  ...options.skillSource ? { skill_source: options.skillSource } : {},
@@ -17022,6 +17587,20 @@ async function recordTestSuiteRunStep(options) {
17022
17587
  const evidencePath = path10.resolve(options.evidence);
17023
17588
  await assertCurrentRunEvidence(validated.manifest, validated.manifestPath, evidencePath);
17024
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
+ }
17025
17604
  validated.step.status = options.result;
17026
17605
  validated.step.evidence = [.../* @__PURE__ */ new Set([...validated.step.evidence, evidencePath])];
17027
17606
  validated.step.recorded_at = (/* @__PURE__ */ new Date()).toISOString();
@@ -17618,6 +18197,9 @@ function reportRuntimeEvidenceMissing(text5) {
17618
18197
  if (!reportHasAnyKeyValue(text5, ["profile_origin:"])) {
17619
18198
  missing.push("profile_origin");
17620
18199
  }
18200
+ if (!reportHasAnyKeyValue(text5, ["runtime_workspace:"])) {
18201
+ missing.push("runtime_workspace");
18202
+ }
17621
18203
  if (!reportHasAnyKeyValue(text5, ["runtime_user:", "runtime_profile:", "browser_user:"])) {
17622
18204
  missing.push("runtime_user/runtime_profile");
17623
18205
  }
@@ -17642,6 +18224,7 @@ function reportRuntimeEvidenceInvalid(text5) {
17642
18224
  const runtimeScope = reportKeyValue(text5, "runtime_scope:");
17643
18225
  const runtimeEnvironment = reportKeyValue(text5, "runtime_environment:");
17644
18226
  const profileOrigin = reportKeyValue(text5, "profile_origin:");
18227
+ const runtimeWorkspace = reportKeyValue(text5, "runtime_workspace:");
17645
18228
  const runtimeUser = reportKeyValue(text5, "runtime_user:") || reportKeyValue(text5, "runtime_profile:") || reportKeyValue(text5, "browser_user:");
17646
18229
  const actionLog = reportKeyValue(text5, "browser_action_log:") || reportKeyValue(text5, "browser_actions:");
17647
18230
  const assertions = reportKeyValue(text5, "visible_assertions:") || reportKeyValue(text5, "visible_assertion:");
@@ -17653,17 +18236,20 @@ function reportRuntimeEvidenceInvalid(text5) {
17653
18236
  if (!["page", "project", "step"].includes(runtimeScope)) invalid.push("runtime_scope");
17654
18237
  if (!["profile", "local-browser"].includes(runtimeEnvironment)) invalid.push("runtime_environment");
17655
18238
  try {
17656
- const url = new URL(runtimeUrl);
18239
+ const parsed = runtimeRoute(runtimeUrl);
18240
+ const url = parsed.url;
17657
18241
  const configuredOrigin = new URL(profileOrigin);
17658
18242
  if (!["http:", "https:"].includes(url.protocol) || !url.hostname) invalid.push("runtime_url");
17659
18243
  if (runtimeEnvironment === "profile" && url.origin !== configuredOrigin.origin) invalid.push("runtime_url/profile_origin");
17660
18244
  if (runtimeEnvironment === "local-browser" && !/^(?:localhost|127\.0\.0\.1|\[::1\])$/.test(url.hostname)) {
17661
18245
  invalid.push("runtime_url/local_browser");
17662
18246
  }
17663
- const hashRoute = url.hash.startsWith("#/") ? new URL(url.hash.slice(1), url.origin) : null;
17664
- const runtimePath = hashRoute?.pathname || url.pathname;
17665
- const runtimeParams = hashRoute?.searchParams || url.searchParams;
17666
- const isSupportedUiRoute = /(?:\/project(?:$|\/|\?|_detail)|\/myProject|\/projectContinue|\/pages\/)/i.test(runtimePath) || /\/w:[^/]+\/userManagement(?:\/|$)/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;
17667
18253
  if (/(^|\.)example\.(?:com|org|net)$/i.test(url.hostname) || /\/(?:api|bpmax)(?:\/|$)/i.test(runtimePath) || !isSupportedUiRoute) {
17668
18254
  invalid.push("runtime_url/ui_route");
17669
18255
  }
@@ -17756,6 +18342,18 @@ function linesForCase(text5, caseId) {
17756
18342
  const pattern = new RegExp(`\\b${escaped}\\b`);
17757
18343
  return text5.split(/\r?\n/).filter((line) => pattern.test(line));
17758
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
+ }
17759
18357
  async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
17760
18358
  if (!await exists3(root)) return [`report root not found: ${root}`];
17761
18359
  const errors = [];
@@ -17807,9 +18405,10 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
17807
18405
  const executedSteps = reportStepList(text5, "executed_steps:");
17808
18406
  const missingExecutedSteps = plannedSteps.filter((stepId) => !executedSteps.includes(stepId));
17809
18407
  const unexpectedExecutedSteps = executedSteps.filter((stepId) => !plannedSteps.includes(stepId));
17810
- if (missingExecutedSteps.length > 0) {
17811
- errors.push(`[test_suite.report.step_reconciliation] ${reportPath}: planned_steps \u4E2D\u5B58\u5728\u672A\u6267\u884C\u6B65\u9AA4: ${missingExecutedSteps.join(", ")}`);
17812
- }
18408
+ const stoppedAfterFail = reportKeyValue(text5, "stopped_after_fail:");
18409
+ let validTerminalStop = false;
18410
+ let validBlockedEvidence = false;
18411
+ let validNonBrowserTerminalStop = false;
17813
18412
  if (unexpectedExecutedSteps.length > 0) {
17814
18413
  errors.push(`[test_suite.report.step_reconciliation] ${reportPath}: executed_steps \u5305\u542B\u672A\u767B\u8BB0\u6B65\u9AA4: ${unexpectedExecutedSteps.join(", ")}`);
17815
18414
  }
@@ -17817,10 +18416,12 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
17817
18416
  if (manifestValue) {
17818
18417
  const manifestPath = path10.resolve(path10.dirname(reportPath), manifestValue);
17819
18418
  const runRoot = path10.resolve(runDir);
17820
- if (!manifestPath.startsWith(`${runRoot}${path10.sep}`)) {
18419
+ if (!pathInside(runRoot, manifestPath)) {
17821
18420
  errors.push(`[test_suite.report.execution_manifest_scope] ${reportPath}: execution_manifest \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
17822
18421
  } else if (!await exists3(manifestPath)) {
17823
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`);
17824
18425
  } else {
17825
18426
  try {
17826
18427
  const manifest = await readExecutionManifest(manifestPath);
@@ -17835,6 +18436,35 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
17835
18436
  if (executedSteps.some((step) => !manifestExecuted.includes(step))) {
17836
18437
  errors.push(`[test_suite.report.execution_manifest_steps] ${reportPath}: executed_steps \u542B manifest \u4E2D\u672A\u6267\u884C\u7684\u6B65\u9AA4`);
17837
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
+ }
17838
18468
  if (reportClaimsCompleteResult(resultValue)) {
17839
18469
  const incomplete = manifest.steps.filter((step) => step.status !== "pass" || step.evidence.length === 0);
17840
18470
  if (manifest.result !== "pass" || incomplete.length > 0) {
@@ -17849,6 +18479,12 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
17849
18479
  }
17850
18480
  }
17851
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
+ }
17852
18488
  if ((NOT_RUN_RE.test(text5) || BLOCKED_RE.test(text5)) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
17853
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`);
17854
18490
  }
@@ -17882,6 +18518,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
17882
18518
  if (/browser[_ -]?blocked|浏览器阻塞|无可用浏览器工具/i.test(text5) && !/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5)) {
17883
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`);
17884
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
+ }
17885
18524
  if (/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|诊断/.test(resultValue)) {
17886
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`);
17887
18526
  }
@@ -17900,7 +18539,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
17900
18539
  }
17901
18540
  const imageMatches = [...text5.matchAll(IMAGE_RE)];
17902
18541
  const imageRefs = imageMatches.map((match) => match[1]);
17903
- 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
+ }
17904
18545
  const validCurrentRunImages = [];
17905
18546
  const window = reportExecutionWindow(runName, text5);
17906
18547
  for (const imageRef of imageRefs) {
@@ -20588,7 +21229,7 @@ function prettyCreatedIssue(issue3) {
20588
21229
  }
20589
21230
  function registerIssueCommands(program2, deps = {}) {
20590
21231
  const createIssue = deps.createIssue || createGitLabIssue;
20591
- 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)");
20592
21233
  const registerCreateLike = (name) => {
20593
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) => {
20594
21235
  const input = await buildIssueInput(options);
@@ -22862,13 +23503,20 @@ function registerProjectCommands(program2) {
22862
23503
  );
22863
23504
  printResult(options.format, result);
22864
23505
  });
22865
- project.command("get <id>").description("Get project detail").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (id, options) => {
23506
+ project.command("get [id]").description("Get project detail").option("--project-id <projectId>", "Project id (compatibility alias for the positional id)").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (id, options) => {
23507
+ const resolvedId = id?.trim() || options.projectId?.trim();
23508
+ if (!resolvedId) {
23509
+ throw new Error("project get requires <id> or --project-id <id>.");
23510
+ }
23511
+ if (id?.trim() && options.projectId?.trim() && id.trim() !== options.projectId.trim()) {
23512
+ throw new Error(`project get received conflicting ids: positional=${id.trim()}, --project-id=${options.projectId.trim()}.`);
23513
+ }
22866
23514
  const config = await loadConfig();
22867
23515
  const profile = resolveProfile(config, options.profile);
22868
23516
  const result = await apiRequest(
22869
23517
  createApiClient(profile),
22870
23518
  "GET",
22871
- `/project/${id}`
23519
+ `/project/${resolvedId}`
22872
23520
  );
22873
23521
  printResult(options.format, attachProjectDetailUrl(profile, result));
22874
23522
  });
@@ -23574,6 +24222,10 @@ var schemaEntries = [
23574
24222
  { name: "config.project_detail_template.create", description: "Create project detail template config through a verified typed adapter.", method: "POST", path: "/api/flow_page_template" },
23575
24223
  { name: "config.project_detail_template.delete", description: "Delete project detail template config through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id" },
23576
24224
  { name: "config.project_detail_template.submit", description: "Submit project detail template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id" },
24225
+ { name: "config.flow_detail_template.export", description: "List or export type=5 flow report/document template config.", method: "GET", path: "/api/flow_page_template/:id?type=5&skip_i18n=true" },
24226
+ { name: "config.flow_detail_template.create", description: "Create a type=5 flow report/document template through a verified typed adapter.", method: "POST", path: "/api/flow_page_template" },
24227
+ { name: "config.flow_detail_template.delete", description: "Delete a type=5 flow report/document template through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id" },
24228
+ { name: "config.flow_detail_template.submit", description: "Submit type=5 flow report/document template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id" },
23577
24229
  { name: "config.console_template.export", description: "Export console template config.", method: "GET", path: "/api/flow_page_template/:id?skip_i18n=true" },
23578
24230
  { name: "config.console_template.create", description: "Create console template config through a verified typed adapter.", method: "POST", path: "/api/flow_page_template" },
23579
24231
  { name: "config.console_template.delete", description: "Delete console template config through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id" },
@@ -23908,6 +24560,15 @@ var CONFIG_TASK_RULES = [
23908
24560
  constraintEvidence: /默认详情模板|resolve-default|详情页|project_detail|project-detail-template lint/i,
23909
24561
  mentionPattern: /项目详情模板|项目详情页|project-detail-template|project_detail/
23910
24562
  },
24563
+ {
24564
+ domain: "flow-detail-template",
24565
+ skill: "bpmax-flow-detail-template-editor",
24566
+ lockPattern: /flow-detail-template:(?:\d+|new-[A-Za-z0-9_-]+)/,
24567
+ writeEvidence: [/bpmax-cli config flow-detail-template lint/, /bpmax-cli config flow-detail-template build/, /bpmax-cli config flow-detail-template submit/, /bpmax-cli config flow-detail-template verify/],
24568
+ readonlyEvidence: [/bpmax-cli config flow-detail-template (?:list|export)|流程报告.*回读|流程报表.*回读|readback/i],
24569
+ constraintEvidence: /type=5|流程报告模板|流程报表模板|flow-detail-template lint/i,
24570
+ mentionPattern: /流程报告模板|流程报表模板|flow-detail-template|flow_detail_template/
24571
+ },
23911
24572
  {
23912
24573
  domain: "step-detail-template",
23913
24574
  skill: "bpmax-flow-template-editor",
@@ -24545,6 +25206,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
24545
25206
  "| \u6D41\u7A0B\u6A21\u677F | bpmax-flow-template-editor | bpmax-cli config flow-template export/lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | project_after_create_path\u3001message_template\u3001matrix_owner\u3001\u6D41\u7A0B\u6A21\u677F\u7EA6\u675F |",
24546
25207
  "| \u8868\u5355\u6A21\u677F | bpmax-form-template-editor | bpmax-cli config form-template export/lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | \u5B57\u6BB5 schema\u3001\u8868\u5355\u987A\u5E8F\u3001raw.value\u3001layout\u3001sub_form\u3001form-template inspect |",
24547
25208
  "| \u5217\u8868\u6A21\u677F | bpmax-list-template-editor | bpmax-cli config list-template lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | \u64CD\u4F5C\u5217\u3001\u8BE6\u60C5\u52A8\u4F5C\u3001\u5220\u9664\u6743\u9650 guard\uFF08\u9996\u9009 ctx.$CAN_DELETE\uFF0C\u7981\u6B62\u5F53\u524D\u73AF\u8282\u4E3A\u7A7A\u6761\u4EF6\uFF09\u3001icon\u3001\u67E5\u8BE2\u5B89\u5168\u3001\u771F\u5B9E\u5217\u8868\u9875 |",
25209
+ "| \u6D41\u7A0B\u62A5\u544A\u6A21\u677F | bpmax-flow-detail-template-editor | bpmax-cli config flow-detail-template list/export/lint/build/submit/verify | type=5\uFF0C\u5185\u5BB9\u4E3A fields + templateFile\uFF0C\u4E0D\u80FD\u4E0E\u9879\u76EE\u8BE6\u60C5 type=2 \u6216\u73AF\u8282\u8BE6\u60C5 type=6 \u6DF7\u7528 |",
24548
25210
  "| \u73AF\u8282\u8BE6\u60C5\u6A21\u677F | bpmax-flow-template-editor | bpmax-cli config step-detail-template export/lint/build/submit/verify\uFF1B\u6D41\u7A0B\u7ED1\u5B9A\u8FD8\u9700 flow-template verify | type=6\u3001content.layout\u3001\u6A21\u5757\u58F0\u660E\u3001step_detail_id \u8FDC\u7AEF\u5B58\u5728\u6027\u4E0E\u8282\u70B9\u9002\u914D |",
24549
25211
  "| \u5BFC\u822A\u914D\u7F6E | bpmax-nav-config-editor | bpmax-cli config nav-config lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | PC/H5 \u5BFC\u822A\u3001\u5FEB\u6377\u5165\u53E3\u3001\u6D4F\u89C8\u5668\u6253\u5F00\u9A8C\u8BC1 |",
24550
25212
  "",
@@ -24700,7 +25362,7 @@ function collect(value, previous = []) {
24700
25362
  return previous;
24701
25363
  }
24702
25364
  function registerTaskbookCommands(program2) {
24703
- 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)");
24704
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) => {
24705
25367
  printResult(options.format, await initTaskbook(options.out, options.title));
24706
25368
  });
@@ -24756,7 +25418,7 @@ async function resolveE2eSkillSource(sourceSkill) {
24756
25418
  return { source: `installed:${status.current}`, version: VERSION };
24757
25419
  }
24758
25420
  function registerTestSuiteCommands(program2) {
24759
- 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)");
24760
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) => {
24761
25423
  await requireLatestProof(options.latestProof);
24762
25424
  printResult(options.format, await lintSuiteDetailed(options.root, { explain: Boolean(options.explain) }));
@@ -25040,7 +25702,10 @@ async function detectCurrentInstallMethod() {
25040
25702
  }
25041
25703
  async function runNpmInstall(version, options = {}) {
25042
25704
  const runner = options.runner || runCommand;
25043
- 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 } : {},
25044
25709
  timeoutMs: NPM_INSTALL_TIMEOUT_MS
25045
25710
  });
25046
25711
  }
@@ -25547,6 +26212,7 @@ function commandEndpointHint(argv) {
25547
26212
  "list-template": "/flow_page_template",
25548
26213
  "filter-template": "/flow_page_template",
25549
26214
  "project-detail-template": "/flow_page_template",
26215
+ "flow-detail-template": "/flow_page_template",
25550
26216
  "step-detail-template": "/flow_page_template",
25551
26217
  "console-template": "/flow_page_template"
25552
26218
  };