bpmax-cli 0.2.1-beta.19 → 0.2.1-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/bin.js +699 -34
  2. package/dist/bin.js.map +1 -1
  3. package/package.json +1 -1
  4. package/skills/bpmax-api-platform-editor/SKILL.md +24 -31
  5. package/skills/bpmax-api-platform-editor/agents/openai.yaml +2 -2
  6. package/skills/bpmax-api-platform-editor/references/platform-api-map.md +2 -2
  7. package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +3 -3
  8. package/skills/bpmax-builder-shared/template_script_hard_rules.py +3 -1
  9. package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +16 -0
  10. package/skills/bpmax-console-template-editor/SKILL.md +109 -523
  11. package/skills/bpmax-console-template-editor/agents/openai.yaml +2 -2
  12. package/skills/bpmax-console-template-editor/references/full-detail-guide.md +45 -0
  13. package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +13 -12
  14. package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +65 -78
  15. package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +86 -30
  16. package/skills/bpmax-dataset-field-template-editor/SKILL.md +124 -594
  17. package/skills/bpmax-dataset-field-template-editor/references/full-detail-guide.md +570 -0
  18. package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +1 -1
  19. package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +11 -77
  20. package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +4 -57
  21. package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +2 -0
  22. package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +4 -78
  23. package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +3 -89
  24. package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +14 -0
  25. package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +2 -0
  26. package/skills/bpmax-dataset-template-editor/SKILL.md +112 -778
  27. package/skills/bpmax-dataset-template-editor/references/full-detail-guide.md +753 -0
  28. package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +1 -0
  29. package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +2 -2
  30. package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +8 -1
  31. package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +9 -90
  32. package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +8 -1
  33. package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +8 -1
  34. package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +1 -2
  35. package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +8 -1
  36. package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +8 -1
  37. package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +6 -40
  38. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +8 -4
  39. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +111 -552
  40. package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +11 -3
  41. package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +6 -5
  42. package/skills/bpmax-e2e-flow-test-operator/references/full-detail-guide.md +563 -0
  43. package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +4 -4
  44. package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +1 -1
  45. package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +3 -1
  46. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +7 -5
  47. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +2 -2
  48. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +5 -1
  49. package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +71 -0
  50. package/skills/bpmax-filter-template-editor/SKILL.md +110 -551
  51. package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +18 -18
  52. package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +29 -26
  53. package/skills/bpmax-filter-template-editor/references/full-detail-guide.md +56 -0
  54. package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +10 -9
  55. package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +7 -57
  56. package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +4 -48
  57. package/skills/bpmax-flow-template-editor/SKILL.md +109 -1151
  58. package/skills/bpmax-flow-template-editor/agents/openai.yaml +2 -2
  59. package/skills/bpmax-flow-template-editor/references/diff-strategy.md +3 -3
  60. package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +9 -9
  61. package/skills/bpmax-flow-template-editor/references/full-detail-guide.md +1155 -0
  62. package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +1 -1
  63. package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +3 -3
  64. package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +7 -7
  65. package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +2 -2
  66. package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +2 -2
  67. package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +7 -23
  68. package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +1 -1
  69. package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +19 -75
  70. package/skills/bpmax-form-template-editor/SKILL.md +111 -1151
  71. package/skills/bpmax-form-template-editor/agents/openai.yaml +2 -2
  72. package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +51 -51
  73. package/skills/bpmax-form-template-editor/references/full-detail-guide.md +1108 -0
  74. package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +4 -4
  75. package/skills/bpmax-form-template-editor/references/payload-checklist.md +1 -1
  76. package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +8 -0
  77. package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +42 -19
  78. package/skills/bpmax-list-template-editor/SKILL.md +110 -466
  79. package/skills/bpmax-list-template-editor/agents/openai.yaml +2 -2
  80. package/skills/bpmax-list-template-editor/references/full-detail-guide.md +454 -0
  81. package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +6 -9
  82. package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +1 -1
  83. package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +9 -78
  84. package/skills/bpmax-nav-config-editor/SKILL.md +13 -17
  85. package/skills/bpmax-nav-config-editor/agents/openai.yaml +2 -2
  86. package/skills/bpmax-nav-config-editor/references/api-workflow.md +2 -2
  87. package/skills/bpmax-nav-config-editor/references/runtime-probing.md +11 -12
  88. package/skills/bpmax-project/SKILL.md +1 -0
  89. package/skills/bpmax-project-detail-template-editor/SKILL.md +11 -33
  90. package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +2 -2
  91. package/skills/bpmax-role-editor/SKILL.md +7 -30
  92. package/skills/bpmax-user-mock-operator/SKILL.md +1 -1
  93. package/skills/bpmax-user-mock-operator/agents/openai.yaml +2 -2
package/dist/bin.js CHANGED
@@ -469,7 +469,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
469
469
  // package.json
470
470
  var package_default = {
471
471
  name: "bpmax-cli",
472
- version: "0.2.1-beta.19",
472
+ version: "0.2.1-beta.20",
473
473
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
474
474
  type: "module",
475
475
  bin: {
@@ -3642,6 +3642,25 @@ async function lintFlowTemplatePluginExtensions(options) {
3642
3642
  ...platformLintDeclarations.map((item) => item.lint.plugin_key),
3643
3643
  ...installedLintDeclarations.map((item) => item.lint.plugin_key)
3644
3644
  ]);
3645
+ for (const pluginKey of usedPluginKeys) {
3646
+ if (allPluginKeys.has(pluginKey)) {
3647
+ continue;
3648
+ }
3649
+ const message = `Flow template uses unknown plugin extension ${pluginKey}; no platform or installed flow-template lint declaration was found.`;
3650
+ if (options.requireInstalled) {
3651
+ errors.push(message);
3652
+ } else {
3653
+ warnings.push(message);
3654
+ }
3655
+ pluginLints.push({
3656
+ plugin: pluginKey,
3657
+ plugin_key: pluginKey,
3658
+ domain: "flow-template-node",
3659
+ checked_locations: [],
3660
+ errors: options.requireInstalled ? [message] : [],
3661
+ warnings: options.requireInstalled ? [] : [message]
3662
+ });
3663
+ }
3645
3664
  for (const pluginKey of allPluginKeys) {
3646
3665
  const declarations = [
3647
3666
  ...platformLintDeclarations.filter((item) => item.lint.plugin_key === pluginKey).map((item) => item.lint),
@@ -4328,6 +4347,108 @@ function validateFlowTemplateFormDrivenCreateBaseline(value, errors, options = {
4328
4347
  }
4329
4348
  throw new Error(message);
4330
4349
  }
4350
+ function validateFlowAppFlowWork(value, errors, warnings) {
4351
+ validateFlowTemplateRemoteTemplateRefs(value, errors);
4352
+ validateFlowTemplateProjectAfterCreatePath(value, errors);
4353
+ validateFlowTemplateStandardPageCreateFormTemplate(value, errors);
4354
+ validateFlowTemplateStartConditionalJump(value, errors);
4355
+ validateFlowTemplateApproveActionShape(value, errors);
4356
+ validateFlowTemplatePluginRejectionControl(value, errors);
4357
+ validateFlowTemplateStandardConditionEditorRules(value, errors);
4358
+ validateFlowTemplateCodeModeMessages(value, errors);
4359
+ validateFlowTemplateRuntimeScripts(value, errors);
4360
+ validateFlowTemplateFeishuChatPlugin(value, errors);
4361
+ validateFlowTemplateFormDrivenCreateBaseline(value, errors, {
4362
+ force: true,
4363
+ context: "flow-app create"
4364
+ });
4365
+ const data = isRecord3(value.data) ? value.data : {};
4366
+ const meta = isRecord3(data.meta) ? data.meta : {};
4367
+ const afterCreatePath = typeof meta.project_after_create_path === "string" ? meta.project_after_create_path : "";
4368
+ if (/['"`]\/project\?flow_type=/.test(afterCreatePath) || afterCreatePath.includes("/project?flow_type=")) {
4369
+ warnings.push(
4370
+ "flow-app create project_after_create_path redirects to the flow list. Verify a list/default list-template/data-set path exists; otherwise the project may be created but not discoverable from that list."
4371
+ );
4372
+ }
4373
+ }
4374
+ function flowAppDraftPayloadSummary(flowWorkRecord) {
4375
+ const data = isRecord3(flowWorkRecord.data) ? flowWorkRecord.data : {};
4376
+ const meta = isRecord3(data.meta) ? data.meta : {};
4377
+ return {
4378
+ flow_type: "<platform-flow-type>",
4379
+ key: "",
4380
+ type: flowWorkRecord.type || "main",
4381
+ meta_form_id: "<published-form-id>",
4382
+ data: {
4383
+ meta: {
4384
+ ...pickDefined(meta, [
4385
+ "hide_fields",
4386
+ "use_template_project_name",
4387
+ "project_name_template",
4388
+ "project_after_create_path"
4389
+ ]),
4390
+ form_template: "<published-form-id>"
4391
+ },
4392
+ node_count: Array.isArray(data.nodes) ? data.nodes.length : 0,
4393
+ period_count: Array.isArray(data.periods) ? data.periods.length : 0
4394
+ }
4395
+ };
4396
+ }
4397
+ async function lintFlowAppWorkFiles(formWorkFile, flowWorkFile, options = {}) {
4398
+ const formWork = await readJsonFile(formWorkFile);
4399
+ const flowWork = await readJsonFile(flowWorkFile);
4400
+ const errors = [];
4401
+ const formErrors = [];
4402
+ const flowErrors = [];
4403
+ const warnings = [];
4404
+ let pluginLint;
4405
+ if (!isRecord3(formWork)) {
4406
+ formErrors.push("flow-app create requires form work to be a JSON object.");
4407
+ } else if (formWork.mode !== "create") {
4408
+ formErrors.push("flow-app create requires form work with mode=create.");
4409
+ } else {
4410
+ validateFormTemplateWorkLint(formWork, formErrors);
4411
+ }
4412
+ if (!isRecord3(flowWork)) {
4413
+ flowErrors.push("flow-app create requires flow work to be a JSON object.");
4414
+ } else if (!isFlowTemplateWork(flowWork)) {
4415
+ flowErrors.push("flow-app create requires flow work with data.nodes/data.periods or mode=create.");
4416
+ } else {
4417
+ validateFlowAppFlowWork(flowWork, flowErrors, warnings);
4418
+ if (!options.pluginLint && hasPotentialFlowTemplatePluginExtension(flowWork)) {
4419
+ flowErrors.push("flow-app plugin lint requires an initialized profile when flow work contains plugin extensions; configure or pass --profile before create preflight.");
4420
+ }
4421
+ pluginLint = await runFlowTemplatePluginLint(flowWork, options.pluginLint);
4422
+ if (pluginLint) {
4423
+ flowErrors.push(...pluginLint.errors);
4424
+ warnings.push(...pluginLint.warnings);
4425
+ }
4426
+ }
4427
+ errors.push(...formErrors, ...flowErrors);
4428
+ return {
4429
+ domain: "flow-app",
4430
+ ok: errors.length === 0,
4431
+ form_work_file: formWorkFile,
4432
+ flow_work_file: flowWorkFile,
4433
+ ...options.name ? { name: options.name } : {},
4434
+ ...options.workspace ? { workspace: normalizeWorkspaceKey(options.workspace) } : {},
4435
+ errors,
4436
+ error_groups: {
4437
+ form_template: formErrors,
4438
+ flow_template: flowErrors
4439
+ },
4440
+ ...pluginLint ? { plugin_lints: pluginLint.plugin_lints } : {},
4441
+ warnings,
4442
+ flow_type_policy: "flow_type is allocated by the platform during config flow-app create; pre-create lint intentionally does not require flow_type.",
4443
+ evidence_requirements: [
4444
+ "Save flow-app lint output before create.",
4445
+ "Save flow-app dry-run output with operation_plan payload_summary before confirm.",
4446
+ "After create, run config flow-app context and keep target context evidence.",
4447
+ "If project_after_create_path redirects to /project, verify list discoverability or add list/default-template config."
4448
+ ],
4449
+ checked_at: (/* @__PURE__ */ new Date()).toISOString()
4450
+ };
4451
+ }
4331
4452
  function validateFlowTemplateProjectAfterCreatePath(value, errors) {
4332
4453
  const data = isRecord3(value.data) ? value.data : {};
4333
4454
  const meta = isRecord3(data.meta) ? data.meta : {};
@@ -4521,6 +4642,45 @@ function validateFlowTemplateActionTarget(errors, pathName, target, nodeIds, con
4521
4642
  errors.push(`${pathName} target (${normalizedTarget}) must be ${allowedTargets}.`);
4522
4643
  }
4523
4644
  }
4645
+ var FLOW_TEMPLATE_OWNER_AUTO_RANGE_TYPES = /* @__PURE__ */ new Set(["owner", "role", "user", "leader", "continuous_leader", "group", "fieldvalue", "matrix"]);
4646
+ function validateFlowTemplateOwnerStrategyShape(node, nodeName, errors) {
4647
+ const rawType = typeof node.auto_range_type === "string" ? node.auto_range_type.trim() : "";
4648
+ if (!rawType) return;
4649
+ if (!FLOW_TEMPLATE_OWNER_AUTO_RANGE_TYPES.has(rawType)) {
4650
+ errors.push(`${nodeName}.auto_range_type must be one of owner, role, user, leader, continuous_leader, group, fieldvalue, matrix.`);
4651
+ return;
4652
+ }
4653
+ if (rawType === "owner" && typeof node.owner_is_creater !== "boolean") {
4654
+ errors.push(`${nodeName}.owner_is_creater must be a boolean when auto_range_type is owner.`);
4655
+ }
4656
+ if (rawType === "role" && (!Array.isArray(node.owner_roles) || !node.owner_roles.length) && !node.auto_range_by_role) {
4657
+ errors.push(`${nodeName}.owner_roles or auto_range_by_role is required when auto_range_type is role.`);
4658
+ }
4659
+ if (rawType === "user" && (!Array.isArray(node.auto_range_by_users) || !node.auto_range_by_users.length)) {
4660
+ errors.push(`${nodeName}.auto_range_by_users must be a non-empty array when auto_range_type is user.`);
4661
+ }
4662
+ if (rawType === "group" && (!Array.isArray(node.auto_range_by_groups) || !node.auto_range_by_groups.length)) {
4663
+ errors.push(`${nodeName}.auto_range_by_groups must be a non-empty array when auto_range_type is group.`);
4664
+ }
4665
+ if (rawType === "fieldvalue" && (typeof node.auto_range_by_script !== "string" || !node.auto_range_by_script.trim())) {
4666
+ errors.push(`${nodeName}.auto_range_by_script is required when auto_range_type is fieldvalue.`);
4667
+ }
4668
+ if (rawType === "matrix" && !isRecord3(node.matrix_owner)) {
4669
+ errors.push(`${nodeName}.matrix_owner is required when auto_range_type is matrix.`);
4670
+ }
4671
+ if (rawType === "leader") {
4672
+ const hasLegacyLeaderConfig = Boolean(node.leader_match_method || node.auto_range_by_step_owner_group_leader || node.leader_form_field_key || node.leader_rules);
4673
+ if (!hasLegacyLeaderConfig) {
4674
+ errors.push(`${nodeName}.leader_rules or leader_* config is required when auto_range_type is leader.`);
4675
+ }
4676
+ }
4677
+ if (rawType === "continuous_leader") {
4678
+ const hasContinuousConfig = Boolean(node.continuous_match_method || node.continuous_step_id || node.continuous_form_field_key);
4679
+ if (!hasContinuousConfig) {
4680
+ errors.push(`${nodeName}.continuous_* config is required when auto_range_type is continuous_leader.`);
4681
+ }
4682
+ }
4683
+ }
4524
4684
  function validateFlowTemplateApproveActionShape(value, errors) {
4525
4685
  const nextErrors = [];
4526
4686
  const data = isRecord3(value.data) ? value.data : {};
@@ -4528,6 +4688,7 @@ function validateFlowTemplateApproveActionShape(value, errors) {
4528
4688
  const nodeIds = new Set(nodes.map((node) => String(node.id ?? "").trim()).filter(Boolean));
4529
4689
  nodes.forEach((node, nodeIndex) => {
4530
4690
  const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
4691
+ validateFlowTemplateOwnerStrategyShape(node, nodeName, nextErrors);
4531
4692
  const conditionNames = /* @__PURE__ */ new Set();
4532
4693
  if (node.condational_nodes !== void 0 && node.condational_nodes !== null && node.condational_nodes !== "" && !Array.isArray(node.condational_nodes)) {
4533
4694
  nextErrors.push(`${nodeName}.condational_nodes must be an array of condition route objects.`);
@@ -5168,7 +5329,7 @@ function lintListTemplateQuerySafety(content, errors) {
5168
5329
  /* @__PURE__ */ new Set(["$template", "customQuery", "beforeSearch", "tabFilters", "query", "url", "api", "dataSource"])
5169
5330
  );
5170
5331
  queryTexts.forEach((text5) => {
5171
- if (!text5.trim() || /bpmax-allow-user-scope-project-list\s*:/i.test(text5)) {
5332
+ if (!text5.trim() || /bpmax-allow-user-scope-project-list[ \t]*:[ \t]*[^\s\r\n][^\r\n]{2,}/i.test(text5)) {
5172
5333
  return;
5173
5334
  }
5174
5335
  if (/(\/bpmax\/project\/list|\/api\/project\/list|ESProjectList)/i.test(text5)) {
@@ -5179,6 +5340,183 @@ function lintListTemplateQuerySafety(content, errors) {
5179
5340
  }
5180
5341
  });
5181
5342
  }
5343
+ var CONSOLE_TEMPLATE_SUPPORTED_DATA_SOURCE_DRIVERS = /* @__PURE__ */ new Set(["es", "mysql", "customer", "custom_bpmax", "service"]);
5344
+ var CONSOLE_TEMPLATE_OVERVIEW_SUPPORTED_ICONS = /* @__PURE__ */ new Set(["total", "finished", "delay_warning", "delay"]);
5345
+ function consoleTemplateModuleLabel(module, index) {
5346
+ const name = typeof module.name === "string" && module.name.trim() ? module.name.trim() : "<unnamed>";
5347
+ const id = module.i ?? module.id ?? module.key;
5348
+ return id === void 0 || id === null || id === "" ? `${name}[${index}]` : `${name}[${String(id)}]`;
5349
+ }
5350
+ function consoleTemplateHasCtxConfigFallback(script) {
5351
+ const compact = script.replace(/\s+/g, "");
5352
+ return [
5353
+ "ctx.config||{}",
5354
+ "ctx.config??{}",
5355
+ "constcfg=ctx.config||{}",
5356
+ "constcfg=ctx.config??{}",
5357
+ "{config={}}=ctx",
5358
+ "{config={}}=ctx||{}"
5359
+ ].some((pattern) => compact.includes(pattern));
5360
+ }
5361
+ function lintConsoleTemplateDataSource(dataSource, moduleLabel, errors) {
5362
+ const text5 = typeof dataSource === "string" ? dataSource : JSON.stringify(dataSource) ?? "";
5363
+ const projectListWaiver = typeof dataSource === "string" && /bpmax-allow-user-scope-project-list[ \t]*:[ \t]*[^\s\r\n][^\r\n]{2,}/i.test(dataSource);
5364
+ if (!text5.trim()) {
5365
+ return;
5366
+ }
5367
+ if (/raw-es-search/i.test(text5)) {
5368
+ errors.push(`${moduleLabel} dataSource \u4E0D\u80FD\u4F7F\u7528 unsupported driver raw-es-search\uFF1B\u770B\u677F\u6A21\u677F\u8BF7\u4F7F\u7528 driver: 'es' \u6216\u5DF2\u9A8C\u8BC1\u7684 typed \u6570\u636E\u6E90\u3002`);
5369
+ }
5370
+ const driverPattern = /['\"]?driver['\"]?\s*:\s*['\"]([^'\"]+)['\"]/g;
5371
+ let match;
5372
+ while (match = driverPattern.exec(text5)) {
5373
+ const driver = match[1];
5374
+ if (driver && !CONSOLE_TEMPLATE_SUPPORTED_DATA_SOURCE_DRIVERS.has(driver)) {
5375
+ errors.push(`${moduleLabel} dataSource driver ${driver} \u4E0D\u53D7\u652F\u6301\uFF1B\u5141\u8BB8\u503C\uFF1Aes/mysql/customer/custom_bpmax/service\u3002`);
5376
+ }
5377
+ }
5378
+ if (/['\"]?driver['\"]?\s*:/i.test(text5) && !/['\"]?driver['\"]?\s*:\s*['\"][^'\"]+['\"]/i.test(text5)) {
5379
+ errors.push(`${moduleLabel} dataSource driver \u5FC5\u987B\u662F\u9759\u6001\u5B57\u7B26\u4E32\u5B57\u9762\u91CF\uFF0C\u4E0D\u80FD\u901A\u8FC7\u62FC\u63A5\u3001\u51FD\u6570\u6216\u8FD0\u884C\u65F6\u8868\u8FBE\u5F0F\u751F\u6210\u3002`);
5380
+ }
5381
+ if (/\[\s*['\"][^\]]+['\"]\s*(?:\+[^\]]*)?\]\s*:/i.test(text5)) {
5382
+ errors.push(`${moduleLabel} dataSource \u5C5E\u6027\u540D\u5FC5\u987B\u662F\u9759\u6001\u6807\u8BC6\u7B26\uFF0C\u4E0D\u80FD\u4F7F\u7528\u8BA1\u7B97\u5C5E\u6027\u540D\u3002`);
5383
+ }
5384
+ if (/\bdata_set_id\b/i.test(text5) && /(raw-es-search|project\/list|ESProjectList|\$esQuery|query|search)/i.test(text5)) {
5385
+ errors.push(`${moduleLabel} \u4E0D\u80FD\u7528 data_set_id \u4F5C\u4E3A ES/project \u67E5\u8BE2\u5165\u53E3\uFF1B\u8BF7\u4F7F\u7528 data_set_key \u6216\u5DF2\u9A8C\u8BC1\u7684 typed \u6570\u636E\u6E90\u914D\u7F6E\u3002`);
5386
+ }
5387
+ if (/(\/bpmax\/project\/list|\/api\/project\/list|ESProjectList)/i.test(text5) && !projectListWaiver) {
5388
+ errors.push(`${moduleLabel} \u4E0D\u80FD\u76F4\u63A5\u4F7F\u7528 /bpmax/project/list\u3001/api/project/list \u6216 ESProjectList\uFF1B\u5982\u786E\u9700\u7528\u6237\u8303\u56F4\u67E5\u8BE2\uFF0C\u811A\u672C\u4E2D\u5FC5\u987B\u5199\u660E bpmax-allow-user-scope-project-list: <reason>\u3002`);
5389
+ }
5390
+ }
5391
+ function lintConsoleTemplateWildcardFallback(value, path15, errors) {
5392
+ if (typeof value === "string") {
5393
+ const scriptedWildcard = /(?:wildcard|value)\s*:\s*['\"](\*{1,2})['\"]/i.exec(value);
5394
+ if (scriptedWildcard) {
5395
+ errors.push(`${path15}.wildcard \u4E0D\u80FD\u7528 ${scriptedWildcard[1]} \u4F5C\u4E3A\u975E\u7A7A\u6216\u515C\u5E95\u7ED3\u679C\uFF1B\u8BF7\u5199\u660E\u786E\u7684\u7A7A\u6001\u3001\u6761\u4EF6\u6216\u805A\u5408\u7ED3\u679C\u3002`);
5396
+ }
5397
+ return;
5398
+ }
5399
+ if (Array.isArray(value)) {
5400
+ value.forEach((item, index) => lintConsoleTemplateWildcardFallback(item, `${path15}[${index}]`, errors));
5401
+ return;
5402
+ }
5403
+ if (!isRecord3(value)) {
5404
+ return;
5405
+ }
5406
+ Object.entries(value).forEach(([key, item]) => {
5407
+ const nextPath = `${path15}.${key}`;
5408
+ if ((key === "wildcard" || key === "value") && (item === "*" || item === "**")) {
5409
+ errors.push(`${nextPath} \u4E0D\u80FD\u7528 ${String(item)} \u4F5C\u4E3A\u975E\u7A7A\u6216\u515C\u5E95\u7ED3\u679C\uFF1B\u8BF7\u5199\u660E\u786E\u7684\u7A7A\u6001\u3001\u6761\u4EF6\u6216\u805A\u5408\u7ED3\u679C\u3002`);
5410
+ }
5411
+ lintConsoleTemplateWildcardFallback(item, nextPath, errors);
5412
+ });
5413
+ }
5414
+ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLabel, errors) {
5415
+ if (typeof script !== "string") {
5416
+ return;
5417
+ }
5418
+ const hasRowLoop = /\.(forEach|map|reduce|filter)\s*\(|for\s*\([^)]*\b(of|in)\b/i.test(script);
5419
+ const hasMetric = /(count|total|amount|qty|quantity|inventory|stock|sale|销量|库存|项目数|数量|金额|合计|总数)/i.test(script);
5420
+ const dataSourceText = typeof dataSource === "string" ? dataSource : JSON.stringify(dataSource) ?? "";
5421
+ const hasAggregation = /(aggs|aggregations)\b|size\s*:\s*0|['\"]size['\"]\s*:\s*0/i.test(`${dataSourceText}
5422
+ ${script}`);
5423
+ if (hasRowLoop && hasMetric && !hasAggregation) {
5424
+ 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`);
5425
+ }
5426
+ }
5427
+ function lintConsoleTemplateOverviewScript(script, moduleLabel, errors, warnings) {
5428
+ if (typeof script !== "string") {
5429
+ return;
5430
+ }
5431
+ const compact = script.replace(/\s+/g, "");
5432
+ if (!compact.includes("return[") && !/return\s+\[/.test(script)) {
5433
+ errors.push(`${moduleLabel} config \u811A\u672C\u5FC5\u987B return KPI \u5361\u7247\u6570\u7EC4\u3002`);
5434
+ }
5435
+ ["title", "amount", "icon"].forEach((key) => {
5436
+ if (!script.includes(key)) {
5437
+ errors.push(`${moduleLabel} config \u811A\u672C\u8FD4\u56DE\u7684\u5361\u7247\u5BF9\u8C61\u5FC5\u987B\u5305\u542B ${key}\u3002`);
5438
+ }
5439
+ });
5440
+ ["echarts", "xAxis", "yAxis", "series"].forEach((token) => {
5441
+ if (script.includes(token)) {
5442
+ warnings.push(`${moduleLabel} config \u811A\u672C\u5305\u542B ${token}\uFF1B\u6570\u636E\u6982\u51B5\u5E94\u8FD4\u56DE KPI \u5361\u7247\u6570\u636E\uFF0C\u4E0D\u5E94\u8FD4\u56DE ECharts options\u3002`);
5443
+ }
5444
+ });
5445
+ const iconPattern = /(?:icon|['\"]icon['\"])\s*:\s*['\"]([^'\"]+)['\"]/g;
5446
+ let match;
5447
+ while (match = iconPattern.exec(script)) {
5448
+ const icon = match[1];
5449
+ if (icon && !CONSOLE_TEMPLATE_OVERVIEW_SUPPORTED_ICONS.has(icon)) {
5450
+ errors.push(`${moduleLabel} \u4F7F\u7528\u4E86\u4E0D\u652F\u6301\u7684\u6570\u636E\u6982\u51B5 icon: ${icon}\u3002`);
5451
+ }
5452
+ }
5453
+ }
5454
+ function lintConsoleTemplateModule(module, index, errors, warnings) {
5455
+ const moduleLabel = consoleTemplateModuleLabel(module, index);
5456
+ const name = typeof module.name === "string" ? module.name : "";
5457
+ const config = isRecord3(module.config) ? module.config : void 0;
5458
+ if (!config) {
5459
+ errors.push(`${moduleLabel} config \u5FC5\u987B\u662F\u5BF9\u8C61\u3002`);
5460
+ return;
5461
+ }
5462
+ const requiredByName = {
5463
+ \u56FE\u8868: ["title", "height", "dataSource", "config"],
5464
+ \u4E00\u822C\u8868\u683C: ["title", "height", "page_size", "exportCount", "dataSource", "config"],
5465
+ \u6570\u636E\u6982\u51B5: ["title", "height", "dataSource", "config"]
5466
+ };
5467
+ const missing = (requiredByName[name] ?? []).filter((key) => config[key] === void 0 || config[key] === null || config[key] === "");
5468
+ if (missing.length) {
5469
+ errors.push(`${moduleLabel} \u7F3A\u5C11\u5FC5\u586B\u914D\u7F6E\uFF1A${missing.join(", ")}\u3002`);
5470
+ }
5471
+ lintConsoleTemplateDataSource(config.dataSource, moduleLabel, errors);
5472
+ lintConsoleTemplateWildcardFallback(config.dataSource, `${moduleLabel}.dataSource`, errors);
5473
+ const configScript = config.config;
5474
+ lintConsoleTemplateWildcardFallback(configScript, `${moduleLabel}.config`, errors);
5475
+ if (typeof configScript === "string") {
5476
+ if (name === "\u56FE\u8868" && configScript.includes("ctx.config") && !consoleTemplateHasCtxConfigFallback(configScript)) {
5477
+ errors.push(`${moduleLabel} config \u811A\u672C\u5F15\u7528 ctx.config \u65F6\u5FC5\u987B\u63D0\u4F9B\u7A7A\u5BF9\u8C61 fallback\u3002`);
5478
+ }
5479
+ if (name === "\u4E00\u822C\u8868\u683C") {
5480
+ if (/\$\{\s*(page_size|offset)\s*\}/.test(configScript)) {
5481
+ errors.push(`${moduleLabel} config \u811A\u672C\u4E0D\u80FD\u5305\u542B\u524D\u7AEF\u5206\u9875\u5360\u4F4D\u7B26 \${page_size}/\${offset}\uFF1B\u8BF7\u4F7F\u7528 typed \u53C2\u6570\u6216 ctx.pageInfo\u3002`);
5482
+ }
5483
+ const compact = configScript.replace(/\s+/g, "");
5484
+ if (compact.includes("cfg.page_size") && !configScript.includes("ctx.pageInfo") && !configScript.includes("allRows")) {
5485
+ errors.push(`${moduleLabel} config \u811A\u672C\u4F7F\u7528 cfg.page_size \u65F6\u5FC5\u987B\u5305\u542B ctx.pageInfo \u6216 allRows \u5BFC\u51FA\u5206\u652F\uFF0C\u907F\u514D\u5BFC\u51FA\u53EA\u5305\u542B\u7B2C\u4E00\u9875\u3002`);
5486
+ }
5487
+ }
5488
+ }
5489
+ lintConsoleTemplateFrontendDetailCounting(configScript, config.dataSource, moduleLabel, errors);
5490
+ if (name === "\u6570\u636E\u6982\u51B5") {
5491
+ lintConsoleTemplateOverviewScript(configScript, moduleLabel, errors, warnings);
5492
+ }
5493
+ const serialized = jsonString(config);
5494
+ if (serialized.includes("${page_size}") || serialized.includes("${offset}")) {
5495
+ errors.push(`${moduleLabel} \u5305\u542B\u7981\u6B62\u7684\u524D\u7AEF\u5206\u9875\u5360\u4F4D\u7B26 \${page_size}/\${offset}\u3002`);
5496
+ }
5497
+ }
5498
+ function lintConsoleTemplateWork(value, errors, warnings) {
5499
+ if (value.flow_type === "" || value.flow_key === "") {
5500
+ errors.push("console-template flow_type/flow_key must be null or omitted for no-flow console templates; empty strings are hidden from the console template list.");
5501
+ }
5502
+ const content = parseTemplateContent(value, errors);
5503
+ if (!isRecord3(content)) {
5504
+ errors.push("console-template content must be an object.");
5505
+ return;
5506
+ }
5507
+ const layout = Array.isArray(content.layout) ? content.layout : Array.isArray(value.modules) ? value.modules : [];
5508
+ if (!Array.isArray(layout) || layout.length === 0) {
5509
+ errors.push("console-template content.layout must contain at least one module.");
5510
+ return;
5511
+ }
5512
+ layout.forEach((item, index) => {
5513
+ if (isRecord3(item)) {
5514
+ lintConsoleTemplateModule(item, index, errors, warnings);
5515
+ } else {
5516
+ errors.push(`console-template content.layout[${index}] must be an object.`);
5517
+ }
5518
+ });
5519
+ }
5182
5520
  function listTemplateNodeLabel(node) {
5183
5521
  return [
5184
5522
  node.title,
@@ -5377,6 +5715,14 @@ function normalizePageTemplatePayload(domain, work) {
5377
5715
  if (domain === "list-template") {
5378
5716
  validateListTemplateActionGate(work);
5379
5717
  }
5718
+ if (domain === "console-template") {
5719
+ const errors = [];
5720
+ const warnings = [];
5721
+ lintConsoleTemplateWork(work, errors, warnings);
5722
+ if (errors.length) {
5723
+ throw new Error(`console-template lint failed: ${errors.join("; ")}`);
5724
+ }
5725
+ }
5380
5726
  const basic = isRecord3(work.basic) ? work.basic : work;
5381
5727
  const rawContent = work.content ?? basic.content;
5382
5728
  const type = definition.expectedType;
@@ -5665,7 +6011,8 @@ function normalizeDatasetFieldPayload(work) {
5665
6011
  if (mode !== void 0 && mode !== "edit" && mode !== "create") {
5666
6012
  throw new Error("dataset-field typed adapter supports mode edit or create. Delete requires a dedicated adapter.");
5667
6013
  }
5668
- const source = isRecord3(work.source) ? work.source : work;
6014
+ const hasSourceObject = isRecord3(work.source);
6015
+ const source = hasSourceObject ? work.source : work;
5669
6016
  const sourcePayload = isRecord3(work.x_wewf_source_payload) ? work.x_wewf_source_payload : {};
5670
6017
  const payload = {
5671
6018
  data_set_id: firstNonEmpty(work.data_set_id, work.dataSetId, work.dataset_id, sourcePayload.data_set_id, sourcePayload.dataSetId, sourcePayload.dataset_id),
@@ -5689,7 +6036,7 @@ function normalizeDatasetFieldPayload(work) {
5689
6036
  payload.source_fk = virtual.joinField || "";
5690
6037
  } else {
5691
6038
  payload.source_table = source.table ?? source.sourceTable ?? source.source_table ?? "";
5692
- payload.source_field = source.field ?? source.sourceField ?? source.source_field ?? "";
6039
+ payload.source_field = hasSourceObject ? source.field ?? source.sourceField ?? source.source_field ?? "" : source.source_field ?? source.sourceField ?? "";
5693
6040
  payload.source_fk = source.fk ?? source.sourceFk ?? source.source_fk ?? "";
5694
6041
  }
5695
6042
  payload.sourceTable = payload.source_table;
@@ -7471,6 +7818,14 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
7471
7818
  if (!createShell.name) {
7472
7819
  throw new Error("flow-template create requires name.");
7473
7820
  }
7821
+ const pluginLint = await runFlowTemplatePluginLint(work, {
7822
+ profile,
7823
+ agent: options.agent || "codex",
7824
+ requireInstalled: true
7825
+ });
7826
+ if (pluginLint?.errors.length) {
7827
+ throw new Error(`flow-template plugin lint failed: ${pluginLint.errors.join("; ")}`);
7828
+ }
7474
7829
  const expectedConfirm = `create flow-template ${createShell.name}`;
7475
7830
  if (confirm3 !== expectedConfirm) {
7476
7831
  return {
@@ -7483,14 +7838,6 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
7483
7838
  next: `Run again with --confirm "${expectedConfirm}" to create.`
7484
7839
  };
7485
7840
  }
7486
- const pluginLint = await runFlowTemplatePluginLint(work, {
7487
- profile,
7488
- agent: options.agent || "codex",
7489
- requireInstalled: true
7490
- });
7491
- if (pluginLint?.errors.length) {
7492
- throw new Error(`flow-template plugin lint failed: ${pluginLint.errors.join("; ")}`);
7493
- }
7494
7841
  const client = createApiClient(profile);
7495
7842
  const createResponse = await apiRequest(
7496
7843
  client,
@@ -7576,18 +7923,30 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
7576
7923
  if (!isRecord3(formWork) || formWork.mode !== "create") {
7577
7924
  throw new Error("flow-app create requires form work with mode=create.");
7578
7925
  }
7579
- const formLintErrors = [];
7580
- validateFormTemplateWorkLint(formWork, formLintErrors);
7581
- if (formLintErrors.length) {
7582
- throw new Error(`form-template lint failed: ${formLintErrors.join("; ")}`);
7926
+ const preflight = await lintFlowAppWorkFiles(formWorkFile, flowWorkFile, {
7927
+ workspace,
7928
+ name,
7929
+ pluginLint: {
7930
+ profile,
7931
+ agent: options.agent || "codex",
7932
+ requireInstalled: true
7933
+ }
7934
+ });
7935
+ const preflightErrors = Array.isArray(preflight.errors) ? preflight.errors.map(String) : [];
7936
+ if (preflightErrors.length) {
7937
+ const errorGroups = isRecord3(preflight.error_groups) ? preflight.error_groups : {};
7938
+ const formErrors = Array.isArray(errorGroups.form_template) ? errorGroups.form_template.map(String) : [];
7939
+ const flowErrors = Array.isArray(errorGroups.flow_template) ? errorGroups.flow_template.map(String) : [];
7940
+ if (formErrors.length) {
7941
+ throw new Error(`form-template lint failed: ${formErrors.join("; ")}`);
7942
+ }
7943
+ if (flowErrors.length && flowErrors.every((error) => error.includes("current-environment remote numeric id"))) {
7944
+ throw new Error(`flow-template online template reference gate failed: ${flowErrors.join("; ")}`);
7945
+ }
7946
+ throw new Error(`flow-app create lint failed: ${preflightErrors.join("; ")}`);
7583
7947
  }
7584
7948
  const formPayload = buildDomainSubmitPayload("form-template", formWork);
7585
7949
  const flowWorkRecord = isRecord3(flowWork) ? flowWork : {};
7586
- validateFlowTemplateRemoteTemplateRefs(flowWorkRecord);
7587
- validateFlowTemplateFormDrivenCreateBaseline(flowWorkRecord, void 0, {
7588
- force: true,
7589
- context: "flow-app create"
7590
- });
7591
7950
  const flowShell = {
7592
7951
  name: String(flowWorkRecord.name || name),
7593
7952
  category: flowWorkRecord.category || "system",
@@ -7603,9 +7962,28 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
7603
7962
  { step: "create_form_template", method: "POST", path: "/form_template", payload: formPayload },
7604
7963
  { step: "publish_form_template", method: "POST", path: "/form_template/publish", payload: { id: "<draft-form-id>" } },
7605
7964
  { step: "create_flow_template", method: "POST", path: "/flow/flow_type", payload: flowShell },
7606
- { step: "save_flow_draft", method: "PUT", path: "/flow?flow_type=<platform-flow-type>&publish=2" },
7607
- ...options.publishLive !== false ? [{ step: "publish_flow_live", method: "PUT", path: "/flow?flow_type=<platform-flow-type>&publish=1" }] : [],
7608
- { step: "bind_workspace_flow", method: "PUT", path: "/workspace/workspace_flow", params: { workspace } },
7965
+ {
7966
+ step: "save_flow_draft",
7967
+ method: "PUT",
7968
+ path: "/flow?flow_type=<platform-flow-type>&publish=2",
7969
+ payload_summary: flowAppDraftPayloadSummary(flowWorkRecord)
7970
+ },
7971
+ ...options.publishLive !== false ? [{
7972
+ step: "publish_flow_live",
7973
+ method: "PUT",
7974
+ path: "/flow?flow_type=<platform-flow-type>&publish=1",
7975
+ payload_summary: flowAppDraftPayloadSummary(flowWorkRecord)
7976
+ }] : [],
7977
+ {
7978
+ step: "bind_workspace_flow",
7979
+ method: "PUT",
7980
+ path: "/workspace/workspace_flow",
7981
+ params: { workspace },
7982
+ payload_summary: {
7983
+ append_binding: { flow_type: "<platform-flow-type>", flow_key: "", only_in_workspace: 0 },
7984
+ replacement_mode: "full workspace_flow replacement guarded by latest readback hash"
7985
+ }
7986
+ },
7609
7987
  { step: "verify_workspace_binding", method: "GET", path: "/workspace/by_key", params: { key: workspace } }
7610
7988
  ]
7611
7989
  };
@@ -7616,8 +7994,11 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
7616
7994
  domain: "flow-app",
7617
7995
  workspace,
7618
7996
  name,
7997
+ preflight,
7619
7998
  operation_plan: dryRunPlan,
7620
7999
  post_create_checklist: [
8000
+ "Save this dry-run response; operation_plan.save_flow_draft.payload_summary must show data.meta.form_template=<published-form-id> before confirm.",
8001
+ "If project_after_create_path redirects to /project, verify list discoverability after create or add list/default-list configuration.",
7621
8002
  "If this flow-app is an approval matrix app, create online matrix rule records separately; flow-app create only creates the app/form/flow/workspace binding.",
7622
8003
  "Verify matrix rule records contain real approver user values before connecting business flow matrix_owner or cc_matrix.",
7623
8004
  "Use bpmax-project safe project create/handoff for matrix rule records; do not treat local seed-rules.json as online data."
@@ -8269,6 +8650,14 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
8269
8650
  throw new Error(`form-template lint failed: ${errors.join("; ")}`);
8270
8651
  }
8271
8652
  }
8653
+ if (domain === "console-template" && isRecord3(work)) {
8654
+ const errors = [];
8655
+ const warnings = [];
8656
+ lintConsoleTemplateWork(work, errors, warnings);
8657
+ if (errors.length) {
8658
+ throw new Error(`console-template lint failed: ${errors.join("; ")}`);
8659
+ }
8660
+ }
8272
8661
  const payload = buildDomainSubmitPayload(domain, work, options, raw);
8273
8662
  if (domain === "flow-template" && options.publishLive) {
8274
8663
  payload.publish_live = true;
@@ -8300,14 +8689,24 @@ async function runFlowTemplatePluginLint(flowWork, options = {}) {
8300
8689
  }
8301
8690
  const agent = options.agent || "codex";
8302
8691
  const client = createApiClient(options.profile);
8303
- const platformSkills = await listPluginSkills(client);
8304
- return lintFlowTemplatePluginExtensions({
8692
+ let platformSkills = [];
8693
+ let discoveryWarning = "";
8694
+ try {
8695
+ platformSkills = await listPluginSkills(client);
8696
+ } catch (error) {
8697
+ discoveryWarning = `Remote plugin lint discovery unavailable; used installed local lint declarations only: ${error instanceof Error ? error.message : String(error)}`;
8698
+ }
8699
+ const result = await lintFlowTemplatePluginExtensions({
8305
8700
  profile: options.profile,
8306
8701
  agent,
8307
8702
  flowWork,
8308
8703
  platformSkills,
8309
8704
  requireInstalled: Boolean(options.requireInstalled)
8310
8705
  });
8706
+ if (discoveryWarning) {
8707
+ result.warnings.push(discoveryWarning);
8708
+ }
8709
+ return result;
8311
8710
  }
8312
8711
  function hasPotentialFlowTemplatePluginExtension(flowWork) {
8313
8712
  if (collectFlowTemplatePluginKeys(flowWork).length) {
@@ -8348,6 +8747,9 @@ async function lintConfigWorkFile(file, options = {}) {
8348
8747
  if ((Object.prototype.hasOwnProperty.call(value, "content") || isRecord3(value.basic)) && pageTemplateType(value) === 1) {
8349
8748
  validateListTemplateActionGate(value, errors);
8350
8749
  }
8750
+ if (options.domain === "console-template" || (Object.prototype.hasOwnProperty.call(value, "content") || isRecord3(value.basic)) && pageTemplateType(value) === 4) {
8751
+ lintConsoleTemplateWork(value, errors, warnings);
8752
+ }
8351
8753
  if (value.domain === "nav-config" || Object.prototype.hasOwnProperty.call(value, "configs")) {
8352
8754
  lintNavConfigWork(value, errors);
8353
8755
  }
@@ -8662,6 +9064,14 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
8662
9064
  if (domain === "list-template") {
8663
9065
  validateListTemplateActionGate(submit.payload);
8664
9066
  }
9067
+ if (domain === "console-template") {
9068
+ const errors = [];
9069
+ const warnings = [];
9070
+ lintConsoleTemplateWork(submit.payload, errors, warnings);
9071
+ if (errors.length) {
9072
+ throw new Error(`console-template lint failed: ${errors.join("; ")}`);
9073
+ }
9074
+ }
8665
9075
  if (domain === "dataset-field") {
8666
9076
  validateDatasetFieldCreatePayload(submit.payload);
8667
9077
  }
@@ -8733,6 +9143,14 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
8733
9143
  if (domain === "list-template") {
8734
9144
  validateListTemplateActionGate(submit.payload);
8735
9145
  }
9146
+ if (domain === "console-template") {
9147
+ const errors = [];
9148
+ const warnings = [];
9149
+ lintConsoleTemplateWork(submit.payload, errors, warnings);
9150
+ if (errors.length) {
9151
+ throw new Error(`console-template lint failed: ${errors.join("; ")}`);
9152
+ }
9153
+ }
8736
9154
  if (domain === "form-template" && submitMode === "create") {
8737
9155
  await ensureConfigCapability(profile, `${definition.capability}.create`);
8738
9156
  const expectedConfirm2 = `submit ${domain} ${id}`;
@@ -10803,7 +11221,24 @@ function registerConfigCommands(program2) {
10803
11221
  };
10804
11222
  registerFlowAppContextCommand("context");
10805
11223
  registerFlowAppContextCommand("inspect");
10806
- flowApp.command("create").description("Create a form template, create a main flow, bind the published form, and bind the flow to a workspace").requiredOption("--workspace <workspace>", "Target workspace key, e.g. oa or w:oa").requiredOption("--form-work <file>", "Form-template work JSON file").requiredOption("--flow-work <file>", "Flow-template work JSON file").requiredOption("--name <name>", "Flow app name used in the confirmation text").option("--profile <profile>", "Profile name").option("--draft-only", "Save the created flow as draft only instead of publishing live").option("--confirm <text>", "Exact confirmation text").option("--evidence-out <file>", "Write apply-ready target context evidence as JSON or CSV after create").option("--response-out <file>", "Write the full JSON response to a file").option("--format <format>", "Output format", "pretty").action(async (options) => {
11224
+ flowApp.command("lint").description("Lint flow-app create work files before the platform allocates flow_type").requiredOption("--form-work <file>", "Form-template work JSON file").requiredOption("--flow-work <file>", "Flow-template work JSON file").option("--workspace <workspace>", "Target workspace key, e.g. oa or w:oa").option("--name <name>", "Flow app name used for evidence context").option("--profile <profile>", "Profile name").option("--agent <agent>", "Agent adapter for installed plugin lint discovery", "codex").option("--format <format>", "Output format", "pretty").action(async (options) => {
11225
+ const pluginLint = await resolveFlowTemplatePluginLintOptions({
11226
+ profile: options.profile,
11227
+ agent: options.agent,
11228
+ requireInstalled: true
11229
+ });
11230
+ const result = await lintFlowAppWorkFiles(options.formWork, options.flowWork, {
11231
+ workspace: options.workspace,
11232
+ name: options.name,
11233
+ pluginLint
11234
+ });
11235
+ if (!result.ok) {
11236
+ printResult(options.format, result);
11237
+ throw new Error(`Flow-app lint failed for ${options.formWork} + ${options.flowWork}`);
11238
+ }
11239
+ printResult(options.format, result);
11240
+ });
11241
+ flowApp.command("create").description("Create a form template, create a main flow, bind the published form, and bind the flow to a workspace").requiredOption("--workspace <workspace>", "Target workspace key, e.g. oa or w:oa").requiredOption("--form-work <file>", "Form-template work JSON file").requiredOption("--flow-work <file>", "Flow-template work JSON file").requiredOption("--name <name>", "Flow app name used in the confirmation text").option("--profile <profile>", "Profile name").option("--agent <agent>", "Agent adapter for installed plugin lint discovery", "codex").option("--draft-only", "Save the created flow as draft only instead of publishing live").option("--confirm <text>", "Exact confirmation text").option("--evidence-out <file>", "Write apply-ready target context evidence as JSON or CSV after create").option("--response-out <file>", "Write the full JSON response to a file").option("--format <format>", "Output format", "pretty").action(async (options) => {
10807
11242
  const configData = await loadConfig();
10808
11243
  const resolved = resolveProfile(configData, options.profile);
10809
11244
  const result = await createFlowAppFromWork(
@@ -10815,7 +11250,8 @@ function registerConfigCommands(program2) {
10815
11250
  {
10816
11251
  workspace: options.workspace,
10817
11252
  name: options.name,
10818
- publishLive: !options.draftOnly
11253
+ publishLive: !options.draftOnly,
11254
+ agent: options.agent
10819
11255
  }
10820
11256
  );
10821
11257
  await writeResponseOut(options.responseOut, result);
@@ -14072,7 +14508,8 @@ async function printCreateFormHandoff(client, format, profile, flowIdentifiers,
14072
14508
  const agentWarning = [
14073
14509
  "Agent must reply with the full create form URL exactly as provided.",
14074
14510
  'Use the Markdown link text "\u586B\u5199\u8868\u5355" and the complete URL from reply_markdown/url/pc_url.',
14075
- "Do not shorten, truncate, rebuild, or replace the URL with a bare flow_type link."
14511
+ "Do not shorten, truncate, rebuild, or replace the URL with a bare flow_type link.",
14512
+ "prefill_context only describes the generated payload; browser_prefill_verified=false until a real page check confirms visible controls are populated."
14076
14513
  ].join(" ");
14077
14514
  printResult(format, {
14078
14515
  handoff: true,
@@ -14086,11 +14523,16 @@ async function printCreateFormHandoff(client, format, profile, flowIdentifiers,
14086
14523
  ...prefill ? {
14087
14524
  prefill_token: prefill.token,
14088
14525
  prefill_expires_in: prefill.expires_in,
14089
- prefill_expires_at: prefill.expires_at
14526
+ prefill_expires_at: prefill.expires_at,
14527
+ prefill_status: "token_generated"
14090
14528
  } : {
14529
+ prefill_status: "fallback_init_value",
14091
14530
  prefill_fallback: "init_value",
14092
14531
  ...prefillError ? { prefill_error: prefillError } : {}
14093
14532
  },
14533
+ browser_prefill_verified: false,
14534
+ prefill_verification_required: true,
14535
+ next_verification: "Open url in a real browser and confirm visible controls contain the expected values before treating prefill as successful.",
14094
14536
  init_value: initValue,
14095
14537
  init_value_keys: Object.keys(options.form),
14096
14538
  prefill_context: prefillContext,
@@ -16158,6 +16600,7 @@ import {
16158
16600
  writeFile as writeFile12
16159
16601
  } from "fs/promises";
16160
16602
  import path13 from "path";
16603
+ import { inflateSync } from "zlib";
16161
16604
  var DEFAULT_SUITE_ROOT = ".ai_test/suite";
16162
16605
  var DEFAULT_DRAFT_ROOT = ".ai_test/suite_draft";
16163
16606
  var DEFAULT_REPORT_ROOT = ".ai_test/report";
@@ -16244,18 +16687,22 @@ var IDENTITY_MOCK_VALUE_RE = /(mock|模拟).*(unmock|退出模拟|恢复)|bpmax-
16244
16687
  var E2E_REUSABLE_ASSET_RE = /bpmax-cli\s+e2e|record-from-evidence|create-page-submit|step-run|browser-template|scenario\s+plan|data\s+profile|reusable\s+step|复用模板|可复用|首次运行沉淀|沉淀模板/;
16245
16688
  var ERROR_CAPTURE_CASE_RE = /(negative|boundary|异常|错误|失败|报错|重复|无效|非法|invalid|error|扫码.*(异常|错误|无效)|错误\s*SN|异常\s*SN|无效\s*SN)/i;
16246
16689
  var ERROR_CAPTURE_EVIDENCE_RE = /(expected_error_text|error_capture_required|错误提示|提示文案|报错文案|toast|校验文案).*(screenshot|截图)|截图.*(错误提示|提示文案|报错文案|toast|校验文案)/i;
16247
- var BROWSER_TOOL_RE = /(Chrome DevTools|DevTools|Playwright|AppleScript|browser_tool=|浏览器工具)/i;
16690
+ var BROWSER_TOOL_RE = /(Chrome DevTools|DevTools|Playwright|AppleScript)/i;
16691
+ var REPORT_EVIDENCE_PLACEHOLDER_RE = /^(?:n\/?a|none|null|todo|tbd|xxx|unknown|pending|待补|暂无|无|未执行|跳过|-+)$/i;
16248
16692
  var LIVE_DRAFT_RE = /(live|draft|已发布|草稿|发布态|live_draft=)/i;
16249
16693
  var MULTI_ROLE_VALUE_RE = /[,、/]\s*[^,、/\s]+|多角色|跨角色/;
16250
16694
  var RESUME_POLICY_VALUE_RE = /(full_rerun|checkpoint|evidence_only|从头重跑|检查点|仅补证据)/i;
16251
16695
  var FULL_RERUN_RE = /(full_rerun|重新运行|全量重跑|从头重跑)/i;
16252
16696
  var PARTIAL_RERUN_RE = /(checkpoint|evidence_only|检查点|仅补证据)/i;
16253
16697
  var RUN_MARKER_RE = /\b\d{8}(?:-\d{3})?\b/g;
16698
+ var COMPLETE_RESULT_RE = /^(pass|passed|complete|success|通过|完整)$/i;
16699
+ var REPORT_RESULT_ALLOWED_RE = /^(?:pass|passed|complete|success|通过|完整|pass[-_]with[-_](?:warnings|evidence)|partial|stage|blocked|diagnostic|fail|failed|error|阶段|局部|不完整|阻塞|诊断|失败)$/i;
16254
16700
  var NOT_RUN_RE = /(not[_ -]?run|未执行|未跑|跳过)/i;
16255
16701
  var BLOCKED_RE = /(blocked|阻塞|卡住|无法继续)/i;
16256
16702
  var PASS_CASE_RE = /\b(pass|passed|success|通过)\b|(^|[||,,;;\s])通过($|[||,,;;\s])/i;
16257
16703
  var HISTORICAL_EVIDENCE_RE = /(历史|旧报告|旧截图|旧结果|旧状态|复用.*(报告|截图|结果|状态)|historical|old report|old screenshot|old result|reused)/i;
16258
16704
  var PAGE_CONCLUSION_RE = /(页面.*(通过|已验证|真实|可见|不可见)|浏览器回归.*(通过|完成)|完整链路.*通过|真实页面.*通过)/;
16705
+ var API_ONLY_PASS_EVIDENCE_RE = /(接口回读|readback|缓存命中|cache hit|status matrix|状态矩阵|接口一致|API\s*(验证|通过|evidence))/i;
16259
16706
  var TestSuiteError = class extends Error {
16260
16707
  code;
16261
16708
  rule_id;
@@ -17147,9 +17594,183 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
17147
17594
  }
17148
17595
  function reportKeyValue(text5, key) {
17149
17596
  const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17150
- const match = new RegExp(`^${escaped}\\s*(.+)$`, "im").exec(text5);
17597
+ const match = new RegExp(`^${escaped}[ \\t]*(.+)$`, "im").exec(text5);
17151
17598
  return match?.[1]?.trim() ?? "";
17152
17599
  }
17600
+ function reportHasAnyKeyValue(text5, keys) {
17601
+ return keys.some((key) => Boolean(reportKeyValue(text5, key)));
17602
+ }
17603
+ function reportClaimsCompleteResult(value) {
17604
+ if (!value || /(partial|stage|blocked|diagnostic|fail|error|阶段|局部|不完整|阻塞|失败|诊断)/i.test(value)) {
17605
+ return false;
17606
+ }
17607
+ return COMPLETE_RESULT_RE.test(value) || /(?:^|[_\s-])(pass(?:ed)?|complete|success)(?:$|[_\s-])/i.test(value) || /(通过|完整)/.test(value);
17608
+ }
17609
+ function crc32(value) {
17610
+ let crc = 4294967295;
17611
+ for (const byte of value) {
17612
+ crc ^= byte;
17613
+ for (let bit = 0; bit < 8; bit += 1) {
17614
+ crc = crc >>> 1 ^ (crc & 1 ? 3988292384 : 0);
17615
+ }
17616
+ }
17617
+ return (crc ^ 4294967295) >>> 0;
17618
+ }
17619
+ async function isValidCurrentRunScreenshot(filePath) {
17620
+ const buffer = await readFile16(filePath);
17621
+ const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
17622
+ if (buffer.length < 33 || !buffer.subarray(0, 8).equals(signature)) return false;
17623
+ let offset = 8;
17624
+ let width = 0;
17625
+ let height = 0;
17626
+ let bitDepth = 0;
17627
+ let colorType = -1;
17628
+ let interlace = -1;
17629
+ const idat = [];
17630
+ let hasIend = false;
17631
+ while (offset + 12 <= buffer.length) {
17632
+ const length = buffer.readUInt32BE(offset);
17633
+ const chunkEnd = offset + 12 + length;
17634
+ if (chunkEnd > buffer.length) return false;
17635
+ const type = buffer.subarray(offset + 4, offset + 8);
17636
+ const data = buffer.subarray(offset + 8, offset + 8 + length);
17637
+ const expectedCrc = buffer.readUInt32BE(offset + 8 + length);
17638
+ if (crc32(Buffer.concat([type, data])) !== expectedCrc) return false;
17639
+ const typeName = type.toString("ascii");
17640
+ if (typeName === "IHDR") {
17641
+ if (length !== 13) return false;
17642
+ width = data.readUInt32BE(0);
17643
+ height = data.readUInt32BE(4);
17644
+ bitDepth = data[8];
17645
+ colorType = data[9];
17646
+ interlace = data[12];
17647
+ } else if (typeName === "IDAT") {
17648
+ idat.push(data);
17649
+ } else if (typeName === "IEND") {
17650
+ hasIend = true;
17651
+ break;
17652
+ }
17653
+ offset = chunkEnd;
17654
+ }
17655
+ if (width < 100 || height < 80 || !idat.length || !hasIend || interlace !== 0) return false;
17656
+ const channels = { 2: 3, 6: 4 }[colorType];
17657
+ if (!channels || bitDepth !== 8) return false;
17658
+ try {
17659
+ const pixels = inflateSync(Buffer.concat(idat));
17660
+ const rowBytes = Math.ceil(width * channels * bitDepth / 8);
17661
+ const stride = rowBytes + 1;
17662
+ if (pixels.length !== stride * height) return false;
17663
+ const decoded = Buffer.alloc(rowBytes * height);
17664
+ const bytesPerPixel = Math.max(1, Math.ceil(channels * bitDepth / 8));
17665
+ const paeth = (left, up, upperLeft) => {
17666
+ const estimate = left + up - upperLeft;
17667
+ const leftDistance = Math.abs(estimate - left);
17668
+ const upDistance = Math.abs(estimate - up);
17669
+ const upperLeftDistance = Math.abs(estimate - upperLeft);
17670
+ return leftDistance <= upDistance && leftDistance <= upperLeftDistance ? left : upDistance <= upperLeftDistance ? up : upperLeft;
17671
+ };
17672
+ for (let row = 0; row < height; row += 1) {
17673
+ const filter = pixels[row * stride];
17674
+ if (filter > 4) return false;
17675
+ for (let column = 0; column < rowBytes; column += 1) {
17676
+ const source = pixels[row * stride + 1 + column];
17677
+ const targetIndex = row * rowBytes + column;
17678
+ const left = column >= bytesPerPixel ? decoded[targetIndex - bytesPerPixel] : 0;
17679
+ const up = row > 0 ? decoded[targetIndex - rowBytes] : 0;
17680
+ const upperLeft = row > 0 && column >= bytesPerPixel ? decoded[targetIndex - rowBytes - bytesPerPixel] : 0;
17681
+ const predictor = filter === 1 ? left : filter === 2 ? up : filter === 3 ? Math.floor((left + up) / 2) : filter === 4 ? paeth(left, up, upperLeft) : 0;
17682
+ decoded[targetIndex] = source + predictor & 255;
17683
+ }
17684
+ }
17685
+ const visiblePixels = /* @__PURE__ */ new Set();
17686
+ for (let index = 0; index < decoded.length; index += channels) {
17687
+ visiblePixels.add(decoded.subarray(index, index + channels).toString("hex"));
17688
+ if (visiblePixels.size >= 2) break;
17689
+ }
17690
+ if (visiblePixels.size < 2) return false;
17691
+ if (bitDepth === 8 && (colorType === 6 || colorType === 4)) {
17692
+ const alphaOffset = colorType === 6 ? 3 : 1;
17693
+ const pixelStride = colorType === 6 ? 4 : 2;
17694
+ let hasVisiblePixel = false;
17695
+ for (let index = alphaOffset; index < decoded.length; index += pixelStride) {
17696
+ if (decoded[index] > 0) {
17697
+ hasVisiblePixel = true;
17698
+ break;
17699
+ }
17700
+ }
17701
+ if (!hasVisiblePixel) return false;
17702
+ }
17703
+ return true;
17704
+ } catch {
17705
+ return false;
17706
+ }
17707
+ }
17708
+ function reportHasSupportedBrowserTool(value) {
17709
+ if (!value || /(^|\s)not\s+|unavailable|not available|disabled|blocked|missing|不可用|未启用|阻塞|缺失|无可用|^非/i.test(value)) {
17710
+ return false;
17711
+ }
17712
+ const tools = value.split(/\s*(?:\+|,|,|、|\/|;|;)\s*/).map((item) => item.trim()).filter(Boolean);
17713
+ return tools.length > 0 && tools.every((item) => /^(?:Chrome DevTools(?: MCP)?|DevTools|Playwright|AppleScript)$/i.test(item));
17714
+ }
17715
+ function reportRuntimeEvidenceMissing(text5) {
17716
+ const missing = [];
17717
+ if (!reportHasAnyKeyValue(text5, ["runtime_url:", "browser_runtime_url:"])) {
17718
+ missing.push("runtime_url");
17719
+ }
17720
+ if (!reportHasAnyKeyValue(text5, ["runtime_user:", "runtime_profile:", "browser_user:"])) {
17721
+ missing.push("runtime_user/runtime_profile");
17722
+ }
17723
+ if (!reportHasAnyKeyValue(text5, ["browser_action_log:", "browser_actions:"])) {
17724
+ missing.push("browser_action_log");
17725
+ }
17726
+ if (!reportHasAnyKeyValue(text5, ["visible_assertions:", "visible_assertion:"])) {
17727
+ missing.push("visible_assertions");
17728
+ }
17729
+ if (!reportHasAnyKeyValue(text5, ["project_id:", "step_id:"])) {
17730
+ missing.push("project_id/step_id");
17731
+ }
17732
+ return missing;
17733
+ }
17734
+ function reportRuntimeEvidenceInvalid(text5) {
17735
+ const invalid = [];
17736
+ const browserTool = reportKeyValue(text5, "browser_tool:");
17737
+ const runtimeUrl = reportKeyValue(text5, "runtime_url:") || reportKeyValue(text5, "browser_runtime_url:");
17738
+ const runtimeUser = reportKeyValue(text5, "runtime_user:") || reportKeyValue(text5, "runtime_profile:") || reportKeyValue(text5, "browser_user:");
17739
+ const actionLog = reportKeyValue(text5, "browser_action_log:") || reportKeyValue(text5, "browser_actions:");
17740
+ const assertions = reportKeyValue(text5, "visible_assertions:") || reportKeyValue(text5, "visible_assertion:");
17741
+ const projectId = reportKeyValue(text5, "project_id:");
17742
+ const stepId = reportKeyValue(text5, "step_id:");
17743
+ if (!reportHasSupportedBrowserTool(browserTool) || REPORT_EVIDENCE_PLACEHOLDER_RE.test(browserTool)) {
17744
+ invalid.push("browser_tool");
17745
+ }
17746
+ try {
17747
+ const url = new URL(runtimeUrl);
17748
+ if (!["http:", "https:"].includes(url.protocol) || !url.hostname) invalid.push("runtime_url");
17749
+ const hashRoute = url.hash.startsWith("#/") ? new URL(url.hash.slice(1), url.origin) : null;
17750
+ const runtimePath = hashRoute?.pathname || url.pathname;
17751
+ const runtimeParams = hashRoute?.searchParams || url.searchParams;
17752
+ if (/(^|\.)example\.(?:com|org|net)$/i.test(url.hostname) || /\/(?:api|bpmax)(?:\/|$)/i.test(runtimePath) || !/(?:\/project(?:$|\/|\?|_detail)|\/myProject|\/projectContinue|\/pages\/)/i.test(runtimePath)) {
17753
+ invalid.push("runtime_url/ui_route");
17754
+ }
17755
+ const pathProjectId = /\/project_detail\/\d+\/(\d+)/.exec(runtimePath)?.[1];
17756
+ const queryProjectId = runtimeParams.get("project_id") || runtimeParams.get("id");
17757
+ const urlProjectId = pathProjectId || queryProjectId;
17758
+ if (projectId && urlProjectId && projectId !== urlProjectId) invalid.push("runtime_url/project_id");
17759
+ const urlStepId = runtimeParams.get("step_id");
17760
+ if (stepId && urlStepId && stepId !== urlStepId) invalid.push("runtime_url/step_id");
17761
+ } catch {
17762
+ invalid.push("runtime_url");
17763
+ }
17764
+ if (REPORT_EVIDENCE_PLACEHOLDER_RE.test(runtimeUser) || /(todo|tbd|pending|later|待补|稍后)/i.test(runtimeUser)) invalid.push("runtime_user/runtime_profile");
17765
+ if (actionLog.length < 12 || REPORT_EVIDENCE_PLACEHOLDER_RE.test(actionLog) || API_ONLY_PASS_EVIDENCE_RE.test(actionLog) || /(todo|tbd|pending|later|待补|稍后|GET request|JSON body|response body)/i.test(actionLog)) {
17766
+ invalid.push("browser_action_log");
17767
+ }
17768
+ if (assertions.length < 12 || REPORT_EVIDENCE_PLACEHOLDER_RE.test(assertions) || API_ONLY_PASS_EVIDENCE_RE.test(assertions) || /(todo|tbd|pending|later|待补|稍后|GET request|JSON body|response body)/i.test(assertions)) {
17769
+ invalid.push("visible_assertions");
17770
+ }
17771
+ if (!/^\d+$/.test(projectId) && !/^\d+$/.test(stepId)) invalid.push("project_id/step_id");
17772
+ return [...new Set(invalid)];
17773
+ }
17153
17774
  function reportCaseList(text5, key) {
17154
17775
  const value = reportKeyValue(text5, key);
17155
17776
  return value.split(/[,\s,、;;]+/).map((item) => item.trim()).filter((item) => /^[A-Za-z0-9_-]+$/.test(item));
@@ -17159,7 +17780,7 @@ function reportRunDate(runName) {
17159
17780
  }
17160
17781
  function reportKeyValues(text5, key) {
17161
17782
  const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17162
- return [...text5.matchAll(new RegExp(`^${escaped}\\s*(.+)$`, "gim"))].map((match) => match[1]?.trim() ?? "").filter(Boolean);
17783
+ return [...text5.matchAll(new RegExp(`^${escaped}[ \\t]*(.+)$`, "gim"))].map((match) => match[1]?.trim() ?? "").filter(Boolean);
17163
17784
  }
17164
17785
  function reportRunMarkers(value) {
17165
17786
  return [...value.matchAll(RUN_MARKER_RE)].map((match) => match[0]);
@@ -17198,6 +17819,16 @@ function caseResultPattern(caseId) {
17198
17819
  const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17199
17820
  return new RegExp(`\\b${escaped}\\b[^\\n]*(pass|passed|success|\u901A\u8FC7)`, "i");
17200
17821
  }
17822
+ function caseHasFailedResult(text5, caseId) {
17823
+ return linesForCase(text5, caseId).some((line) => {
17824
+ if (!line.includes("|")) return false;
17825
+ const cells = line.split("|").map((cell) => cell.trim());
17826
+ const caseIndex = cells.findIndex((cell) => cell === caseId);
17827
+ if (caseIndex < 0 || caseIndex + 2 >= cells.length) return false;
17828
+ const resultCell = cells[caseIndex + 2].replace(/[*_`~]/g, "").trim();
17829
+ return /\b(?:fail(?:ed)?|error|blocked)\b|失败|不通过/i.test(resultCell);
17830
+ });
17831
+ }
17201
17832
  function linesForCase(text5, caseId) {
17202
17833
  const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17203
17834
  const pattern = new RegExp(`\\b${escaped}\\b`);
@@ -17230,6 +17861,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
17230
17861
  const isFullRerun = FULL_RERUN_RE.test(rerunPolicy) || /重新运行|全量重跑|从头重跑/.test(text5);
17231
17862
  const isPartialRerun = PARTIAL_RERUN_RE.test(rerunPolicy);
17232
17863
  const resultValue = reportKeyValue(text5, "result:").toLowerCase();
17864
+ if (!REPORT_RESULT_ALLOWED_RE.test(resultValue)) {
17865
+ errors.push(`[test_suite.report.result_invalid] ${reportPath}: result \u5FC5\u987B\u4F7F\u7528\u53D7\u652F\u6301\u7684\u660E\u786E\u72B6\u6001\uFF0C\u4E0D\u80FD\u4F7F\u7528\u672A\u5B9A\u4E49\u540C\u4E49\u8BCD: ${resultValue || "<empty>"}`);
17866
+ }
17233
17867
  if (isPartialRerun && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|对照/.test(resultValue)) {
17234
17868
  errors.push(`[test_suite.report.partial_policy_result] ${reportPath}: checkpoint/evidence_only \u53EA\u80FD\u7ED9\u5C40\u90E8\u6216\u5BF9\u7167\u7ED3\u8BBA\uFF0C\u4E0D\u80FD\u58F0\u660E\u5B8C\u6574\u91CD\u65B0\u8FD0\u884C\u901A\u8FC7`);
17235
17869
  }
@@ -17246,12 +17880,39 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
17246
17880
  if ((NOT_RUN_RE.test(text5) || BLOCKED_RE.test(text5)) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
17247
17881
  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`);
17248
17882
  }
17249
- if (PAGE_CONCLUSION_RE.test(text5) && !BROWSER_TOOL_RE.test(text5)) {
17883
+ if (reportClaimsCompleteResult(resultValue)) {
17884
+ const failedCases = executedCases.filter((caseId) => caseHasFailedResult(text5, caseId));
17885
+ if (failedCases.length) {
17886
+ errors.push(`[test_suite.report.failed_case_downgrade] ${reportPath}: executed_cases \u4E2D\u5B58\u5728\u5931\u8D25\u7528\u4F8B ${failedCases.join(", ")}\uFF0Cresult \u4E0D\u80FD\u58F0\u660E\u5B8C\u6574\u901A\u8FC7`);
17887
+ }
17888
+ }
17889
+ const browserToolValue = reportKeyValue(text5, "browser_tool:");
17890
+ if (PAGE_CONCLUSION_RE.test(text5) && !reportHasSupportedBrowserTool(browserToolValue)) {
17250
17891
  errors.push(`[test_suite.report.page_conclusion_browser] ${reportPath}: \u9875\u9762/\u6D4F\u89C8\u5668\u7ED3\u8BBA\u5FC5\u987B\u5305\u542B browser_tool \u8BC1\u636E\uFF1BAPI/readback \u4E0D\u80FD\u5192\u5145\u9875\u9762\u9A8C\u8BC1`);
17251
17892
  }
17893
+ const claimsCompletePagePass = PAGE_CONCLUSION_RE.test(text5) || reportClaimsCompleteResult(resultValue);
17894
+ if (claimsCompletePagePass) {
17895
+ const missingRuntimeEvidence = reportRuntimeEvidenceMissing(text5);
17896
+ if (missingRuntimeEvidence.length) {
17897
+ errors.push(`[test_suite.report.runtime_evidence_required] ${reportPath}: \u5B8C\u6574\u9875\u9762/\u5B8C\u6574\u94FE\u8DEF\u7ED3\u8BBA\u5FC5\u987B\u5305\u542B\u771F\u5B9E\u8FD0\u884C\u6001\u8BC1\u636E\u5B57\u6BB5: ${missingRuntimeEvidence.join(", ")}\uFF1B\u63A5\u53E3\u56DE\u8BFB\u3001\u7F13\u5B58\u6216\u622A\u56FE\u6587\u4EF6\u4E0D\u80FD\u5355\u72EC\u8BC1\u660E\u7528\u6237\u9875\u9762\u5DF2\u901A\u8FC7`);
17898
+ }
17899
+ const invalidRuntimeEvidence = reportRuntimeEvidenceInvalid(text5);
17900
+ if (invalidRuntimeEvidence.length) {
17901
+ errors.push(`[test_suite.report.runtime_evidence_invalid] ${reportPath}: \u5B8C\u6574\u9875\u9762/\u5B8C\u6574\u94FE\u8DEF\u7ED3\u8BBA\u5305\u542B\u65E0\u6548\u6216\u5360\u4F4D\u8FD0\u884C\u6001\u8BC1\u636E: ${invalidRuntimeEvidence.join(", ")}\uFF1B\u5FC5\u987B\u586B\u5199\u771F\u5B9E URL\u3001\u660E\u786E\u6D4F\u89C8\u5668\u5DE5\u5177\u3001\u5B9E\u9645\u9875\u9762\u52A8\u4F5C/\u53EF\u89C1\u65AD\u8A00\u548C\u6570\u5B57 project_id/step_id`);
17902
+ }
17903
+ }
17904
+ if (claimsCompletePagePass && API_ONLY_PASS_EVIDENCE_RE.test(text5)) {
17905
+ const missingRuntimeEvidence = reportRuntimeEvidenceMissing(text5);
17906
+ if (missingRuntimeEvidence.length) {
17907
+ errors.push(`[test_suite.report.api_evidence_not_page_proof] ${reportPath}: \u62A5\u544A\u4F7F\u7528\u63A5\u53E3\u56DE\u8BFB/\u7F13\u5B58/\u72B6\u6001\u77E9\u9635\u4F5C\u4E3A\u901A\u8FC7\u4F9D\u636E\u65F6\uFF0C\u5FC5\u987B\u540C\u65F6\u63D0\u4F9B runtime_url\u3001runtime_user/runtime_profile\u3001browser_action_log\u3001visible_assertions \u548C project_id/step_id\uFF1B\u5426\u5219\u53EA\u80FD\u5199 diagnostic/partial`);
17908
+ }
17909
+ }
17252
17910
  if (/browser[_ -]?blocked|浏览器阻塞|无可用浏览器工具/i.test(text5) && !/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5)) {
17253
17911
  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`);
17254
17912
  }
17913
+ if (/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|诊断/.test(resultValue)) {
17914
+ 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`);
17915
+ }
17255
17916
  const screenshotsDir = path13.join(runDir, "screenshots");
17256
17917
  if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
17257
17918
  if (isFullRerun) {
@@ -17285,6 +17946,10 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
17285
17946
  errors.push(`${reportPath}: missing image file: ${imageRef}`);
17286
17947
  continue;
17287
17948
  }
17949
+ if (!await isValidCurrentRunScreenshot(imagePath)) {
17950
+ errors.push(`[test_suite.report.screenshot_invalid] ${reportPath}: \u622A\u56FE\u5FC5\u987B\u662F\u53EF\u89E3\u6790\u3001\u5C3A\u5BF8\u81F3\u5C11 100x80 \u7684\u771F\u5B9E PNG \u6587\u4EF6: ${imageRef}`);
17951
+ continue;
17952
+ }
17288
17953
  validCurrentRunImages.push(imageRef);
17289
17954
  if (isFullRerun) {
17290
17955
  const imageStat = await stat6(imagePath);