bpmax-cli 0.2.1-beta.2 → 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 (106) hide show
  1. package/README.md +28 -1
  2. package/dist/bin.js +2132 -101
  3. package/dist/bin.js.map +1 -1
  4. package/package.json +1 -1
  5. package/skills/bpmax-ai-taskbook/SKILL.md +4 -1
  6. package/skills/bpmax-api-platform-editor/SKILL.md +24 -31
  7. package/skills/bpmax-api-platform-editor/agents/openai.yaml +2 -2
  8. package/skills/bpmax-api-platform-editor/references/platform-api-map.md +2 -2
  9. package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +3 -3
  10. package/skills/bpmax-blueprint-doc-workflow/SKILL.md +87 -0
  11. package/skills/bpmax-blueprint-doc-workflow/agents/openai.yaml +4 -0
  12. package/skills/bpmax-blueprint-doc-workflow/references/blueprint-structure.md +60 -0
  13. package/skills/bpmax-blueprint-doc-workflow/references/per-flow-required-structure.md +98 -0
  14. package/skills/bpmax-blueprint-doc-workflow/references/sample-forbidden-term.xml +12 -0
  15. package/skills/bpmax-blueprint-doc-workflow/references/sample-mermaid-codeblock.xml +12 -0
  16. package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-boundary.xml +10 -0
  17. package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-whiteboard.xml +10 -0
  18. package/skills/bpmax-blueprint-doc-workflow/references/sample-pass.xml +55 -0
  19. package/skills/bpmax-blueprint-doc-workflow/scripts/lint_blueprint_doc.py +257 -0
  20. package/skills/bpmax-builder-shared/template_script_hard_rules.py +3 -1
  21. package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +16 -0
  22. package/skills/bpmax-cli/SKILL.md +30 -0
  23. package/skills/bpmax-console-template-editor/SKILL.md +109 -523
  24. package/skills/bpmax-console-template-editor/agents/openai.yaml +2 -2
  25. package/skills/bpmax-console-template-editor/references/full-detail-guide.md +45 -0
  26. package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +13 -12
  27. package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +65 -78
  28. package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +86 -30
  29. package/skills/bpmax-dataset-field-template-editor/SKILL.md +124 -594
  30. package/skills/bpmax-dataset-field-template-editor/references/full-detail-guide.md +570 -0
  31. package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +1 -1
  32. package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +11 -77
  33. package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +4 -57
  34. package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +2 -0
  35. package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +4 -78
  36. package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +3 -89
  37. package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +14 -0
  38. package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +2 -0
  39. package/skills/bpmax-dataset-template-editor/SKILL.md +112 -768
  40. package/skills/bpmax-dataset-template-editor/references/full-detail-guide.md +753 -0
  41. package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +1 -0
  42. package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +2 -2
  43. package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +8 -1
  44. package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +9 -90
  45. package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +8 -1
  46. package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +8 -1
  47. package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +1 -2
  48. package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +8 -1
  49. package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +8 -1
  50. package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +6 -40
  51. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +18 -4
  52. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +112 -533
  53. package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +43 -4
  54. package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +6 -5
  55. package/skills/bpmax-e2e-flow-test-operator/references/full-detail-guide.md +563 -0
  56. package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +4 -4
  57. package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +1 -1
  58. package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +3 -1
  59. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +7 -5
  60. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +2 -2
  61. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +5 -1
  62. package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +71 -0
  63. package/skills/bpmax-filter-template-editor/SKILL.md +110 -551
  64. package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +18 -18
  65. package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +29 -26
  66. package/skills/bpmax-filter-template-editor/references/full-detail-guide.md +56 -0
  67. package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +10 -9
  68. package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +7 -57
  69. package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +4 -48
  70. package/skills/bpmax-flow-template-editor/SKILL.md +109 -1084
  71. package/skills/bpmax-flow-template-editor/agents/openai.yaml +2 -2
  72. package/skills/bpmax-flow-template-editor/references/diff-strategy.md +3 -3
  73. package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +9 -9
  74. package/skills/bpmax-flow-template-editor/references/full-detail-guide.md +1155 -0
  75. package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +1 -1
  76. package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +3 -3
  77. package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +7 -7
  78. package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +2 -2
  79. package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +2 -2
  80. package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +7 -23
  81. package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +1 -1
  82. package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +19 -75
  83. package/skills/bpmax-form-template-editor/SKILL.md +111 -1104
  84. package/skills/bpmax-form-template-editor/agents/openai.yaml +2 -2
  85. package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +51 -51
  86. package/skills/bpmax-form-template-editor/references/full-detail-guide.md +1108 -0
  87. package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +4 -4
  88. package/skills/bpmax-form-template-editor/references/payload-checklist.md +1 -1
  89. package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +8 -0
  90. package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +42 -19
  91. package/skills/bpmax-list-template-editor/SKILL.md +110 -466
  92. package/skills/bpmax-list-template-editor/agents/openai.yaml +2 -2
  93. package/skills/bpmax-list-template-editor/references/full-detail-guide.md +454 -0
  94. package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +6 -9
  95. package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +1 -1
  96. package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +9 -78
  97. package/skills/bpmax-nav-config-editor/SKILL.md +13 -17
  98. package/skills/bpmax-nav-config-editor/agents/openai.yaml +2 -2
  99. package/skills/bpmax-nav-config-editor/references/api-workflow.md +2 -2
  100. package/skills/bpmax-nav-config-editor/references/runtime-probing.md +11 -12
  101. package/skills/bpmax-project/SKILL.md +1 -0
  102. package/skills/bpmax-project-detail-template-editor/SKILL.md +11 -33
  103. package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +2 -2
  104. package/skills/bpmax-role-editor/SKILL.md +7 -30
  105. package/skills/bpmax-user-mock-operator/SKILL.md +1 -1
  106. 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.2",
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: {
@@ -3131,7 +3131,7 @@ function validatePluginLintManifest(item, issues, context) {
3131
3131
  }
3132
3132
  }
3133
3133
  function isAllowedPluginConfigScanPath(scanPath) {
3134
- return scanPath === "data.meta.<plugin_key>" || scanPath === "data.nodes[].<plugin_key>" || /^data\.nodes\[\]\.[A-Za-z0-9_]+_(?:triggers|configs|plugins)\[\]$/.test(scanPath);
3134
+ return scanPath === "data.meta.<plugin_key>" || scanPath === "data.nodes[].<plugin_key>" || /^data\.nodes\[\]\.<plugin_key>\.[A-Za-z0-9_]+\[\]$/.test(scanPath) || /^data\.nodes\[\]\.[A-Za-z0-9_]+_(?:triggers|configs|plugins)\[\]$/.test(scanPath);
3135
3135
  }
3136
3136
  async function validatePluginLintRuleFiles(skillDir, files, issues) {
3137
3137
  for (const file of files) {
@@ -3517,6 +3517,35 @@ function collectFlowTemplatePluginConfigsByPath(flowWork, scanPath, pluginKey) {
3517
3517
  });
3518
3518
  return occurrences2;
3519
3519
  }
3520
+ const pluginArrayMatch = scanPath.match(/^data\.nodes\[\]\.<plugin_key>\.([A-Za-z0-9_]+)\[\]$/);
3521
+ if (pluginArrayMatch) {
3522
+ const field2 = pluginArrayMatch[1];
3523
+ const data2 = typeof flowWork.data === "object" && flowWork.data !== null && !Array.isArray(flowWork.data) ? flowWork.data : {};
3524
+ const nodes2 = Array.isArray(data2.nodes) ? data2.nodes : [];
3525
+ const occurrences2 = [];
3526
+ nodes2.forEach((node, nodeIndex) => {
3527
+ if (!node || typeof node !== "object" || Array.isArray(node)) {
3528
+ return;
3529
+ }
3530
+ const nodeRecord = node;
3531
+ const pluginConfig = nodeRecord[pluginKey];
3532
+ if (!pluginConfig || typeof pluginConfig !== "object" || Array.isArray(pluginConfig)) {
3533
+ return;
3534
+ }
3535
+ const values = pluginConfig[field2];
3536
+ if (!Array.isArray(values)) {
3537
+ return;
3538
+ }
3539
+ const nodeName = typeof nodeRecord.name === "string" && nodeRecord.name.trim() ? nodeRecord.name.trim() : `nodes[${nodeIndex}]`;
3540
+ values.forEach((value, valueIndex) => {
3541
+ occurrences2.push({
3542
+ location: `${nodeName}.${pluginKey}.${field2}[${valueIndex}]`,
3543
+ config: value
3544
+ });
3545
+ });
3546
+ });
3547
+ return occurrences2;
3548
+ }
3520
3549
  const match = scanPath.match(/^data\.nodes\[\]\.([A-Za-z0-9_]+)\[\]$/);
3521
3550
  if (!match) {
3522
3551
  return [];
@@ -3613,6 +3642,25 @@ async function lintFlowTemplatePluginExtensions(options) {
3613
3642
  ...platformLintDeclarations.map((item) => item.lint.plugin_key),
3614
3643
  ...installedLintDeclarations.map((item) => item.lint.plugin_key)
3615
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
+ }
3616
3664
  for (const pluginKey of allPluginKeys) {
3617
3665
  const declarations = [
3618
3666
  ...platformLintDeclarations.filter((item) => item.lint.plugin_key === pluginKey).map((item) => item.lint),
@@ -3953,6 +4001,8 @@ function configAdapterMatrix() {
3953
4001
  return Object.entries(CONFIG_DOMAINS).map(([domain, definition]) => {
3954
4002
  const supportsCreate = Boolean(definition.createPath) || ["flow-template", "api-platform", "role", "nav-config"].includes(domain);
3955
4003
  const supportsDelete = Boolean(definition.deletePath) || ["workspace-flow", "api-platform", "nav-config"].includes(domain);
4004
+ const supportsPublish = domain === "dataset";
4005
+ const supportsRelationFields = domain === "dataset";
3956
4006
  return {
3957
4007
  domain,
3958
4008
  capability_prefix: definition.capability,
@@ -3970,6 +4020,8 @@ function configAdapterMatrix() {
3970
4020
  create: supportsCreate,
3971
4021
  build: definition.buildStatus === "supported",
3972
4022
  submit: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy",
4023
+ publish: supportsPublish,
4024
+ relationFields: supportsRelationFields,
3973
4025
  delete: supportsDelete,
3974
4026
  verify: definition.exportStatus === "supported",
3975
4027
  dry_run: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy"
@@ -3978,12 +4030,13 @@ function configAdapterMatrix() {
3978
4030
  work_file: definition.buildStatus === "supported",
3979
4031
  meta_file_for_build: definition.buildStatus === "supported",
3980
4032
  payload_file_for_submit: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy",
3981
- base_hash_for_submit: domain === "workspace-flow"
4033
+ base_hash_for_submit: domain === "workspace-flow" || domain === "dataset"
3982
4034
  },
3983
4035
  side_effects: {
3984
4036
  writes_workspace_binding: domain === "workspace-flow",
3985
4037
  full_replacement_submit: domain === "workspace-flow",
3986
- publishes_on_submit: domain === "form-template"
4038
+ publishes_on_submit: domain === "form-template",
4039
+ relation_fields_submit: domain === "dataset"
3987
4040
  },
3988
4041
  notes: definition.notes
3989
4042
  };
@@ -4294,6 +4347,108 @@ function validateFlowTemplateFormDrivenCreateBaseline(value, errors, options = {
4294
4347
  }
4295
4348
  throw new Error(message);
4296
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
+ }
4297
4452
  function validateFlowTemplateProjectAfterCreatePath(value, errors) {
4298
4453
  const data = isRecord3(value.data) ? value.data : {};
4299
4454
  const meta = isRecord3(data.meta) ? data.meta : {};
@@ -4334,6 +4489,479 @@ function validateFlowTemplateStandardPageCreateFormTemplate(value, errors) {
4334
4489
  }
4335
4490
  throw new Error(message);
4336
4491
  }
4492
+ function startConditionalJumpScriptLooksLikeIndexReturn(script) {
4493
+ const text5 = script.trim();
4494
+ if (!text5) {
4495
+ return false;
4496
+ }
4497
+ const directReturns = Array.from(text5.matchAll(/\breturn\s+([^;]+)\s*;?/g));
4498
+ if (!directReturns.length) {
4499
+ return false;
4500
+ }
4501
+ return directReturns.some((match) => {
4502
+ const expression = match[1].trim();
4503
+ if (/[=!<>]=?|&&|\|\||\?/.test(expression)) {
4504
+ return false;
4505
+ }
4506
+ return /^-?\d+$/.test(expression) || /^(routeIndex|resultIndex|targetIndex|index)\b/.test(expression) || /\b(result|options)\.indexOf\s*\(/.test(expression) || /^Number(?:\.parseInt)?\s*\(/.test(expression);
4507
+ });
4508
+ }
4509
+ function startConditionalJumpScriptIsCatchAll(script) {
4510
+ const text5 = script.trim();
4511
+ return /^return\s+true\s*;?\s*$/.test(text5) || /^return\s+Boolean\s*\(\s*true\s*\)\s*;?\s*$/.test(text5);
4512
+ }
4513
+ function validateFlowTemplateStartConditionalJump(value, errors) {
4514
+ const nextErrors = [];
4515
+ const data = isRecord3(value.data) ? value.data : {};
4516
+ const meta = isRecord3(data.meta) ? data.meta : {};
4517
+ const jumps = meta.condational_jump;
4518
+ if (jumps === void 0 || jumps === null || jumps === "") {
4519
+ return;
4520
+ }
4521
+ if (!Array.isArray(jumps)) {
4522
+ nextErrors.push("data.meta.condational_jump must be an array when start conditional routing is configured.");
4523
+ } else if (jumps.length === 0) {
4524
+ return;
4525
+ }
4526
+ const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
4527
+ const firstNodeId = nodes.length ? String(nodes[0].id ?? "").trim() : "";
4528
+ const nodeIds = new Set(nodes.map((node) => String(node.id ?? "").trim()).filter(Boolean));
4529
+ if (Array.isArray(jumps) && jumps.length && !nodes.length) {
4530
+ nextErrors.push("data.meta.condational_jump is configured but data.nodes is empty; start jump targets must point to real nodes or -1.");
4531
+ }
4532
+ if (Array.isArray(jumps) && jumps.length) {
4533
+ nodes.forEach((node, index) => {
4534
+ const id = String(node.id ?? "").trim();
4535
+ if (!id) {
4536
+ nextErrors.push(`data.nodes[${index}].id is required when data.meta.condational_jump is configured.`);
4537
+ }
4538
+ });
4539
+ }
4540
+ let lastJumpScript = "";
4541
+ let lastJumpResult = "";
4542
+ if (Array.isArray(jumps)) {
4543
+ jumps.forEach((jump, index) => {
4544
+ const pathName = `data.meta.condational_jump[${index}]`;
4545
+ if (!isRecord3(jump)) {
4546
+ nextErrors.push(`${pathName} must be an object with name, result, condition_mode, and a boolean condition script.`);
4547
+ return;
4548
+ }
4549
+ const name = typeof jump.name === "string" ? jump.name.trim() : "";
4550
+ if (!name) {
4551
+ nextErrors.push(`${pathName}.name is required so every explicit start route can be audited.`);
4552
+ }
4553
+ const rawResult = jump.result;
4554
+ if (Array.isArray(rawResult) || isRecord3(rawResult) || rawResult === void 0 || rawResult === null || String(rawResult).trim() === "") {
4555
+ nextErrors.push(`${pathName}.result must be a target node id or -1; it must not be empty, an array, an object, or a node name.`);
4556
+ } else {
4557
+ const result = String(rawResult).trim();
4558
+ if (result !== "-1" && !nodeIds.has(result)) {
4559
+ nextErrors.push(`${pathName}.result (${result}) must point to an existing data.nodes[].id or -1 for success end.`);
4560
+ }
4561
+ lastJumpResult = result;
4562
+ }
4563
+ const mode = typeof jump.condition_mode === "string" && jump.condition_mode.trim() ? jump.condition_mode.trim() : "code";
4564
+ let script = "";
4565
+ if (mode === "standard") {
4566
+ if (typeof jump.standard_condition === "string" && jump.standard_condition.trim()) {
4567
+ script = jump.standard_condition.trim();
4568
+ } else {
4569
+ nextErrors.push(`${pathName}.standard_condition is required when condition_mode is standard; condition is ignored by the backend in this mode.`);
4570
+ }
4571
+ } else if (mode === "code") {
4572
+ if (typeof jump.condition === "string" && jump.condition.trim()) {
4573
+ script = jump.condition.trim();
4574
+ } else {
4575
+ nextErrors.push(`${pathName}.condition is required when condition_mode is code or omitted; standard_condition is ignored by the backend in code mode.`);
4576
+ }
4577
+ } else {
4578
+ nextErrors.push(`${pathName}.condition_mode must be code or standard.`);
4579
+ }
4580
+ if (script) {
4581
+ lastJumpScript = script;
4582
+ if (index < jumps.length - 1 && startConditionalJumpScriptIsCatchAll(script)) {
4583
+ nextErrors.push(
4584
+ `${pathName} is a catch-all start route but is not the final item; return true must only appear on the last explicit fallback route.`
4585
+ );
4586
+ }
4587
+ if (startConditionalJumpScriptLooksLikeIndexReturn(script)) {
4588
+ nextErrors.push(
4589
+ `${pathName} must return boolean/truthy for this explicit start edge, not a node-level result index; do not copy node.condational_nodes scripts such as return 0/1/-1 into data.meta.condational_jump.`
4590
+ );
4591
+ }
4592
+ }
4593
+ });
4594
+ }
4595
+ if (Array.isArray(jumps) && jumps.length && nodes.length) {
4596
+ if (!lastJumpResult || !startConditionalJumpScriptIsCatchAll(lastJumpScript)) {
4597
+ nextErrors.push(
4598
+ "data.meta.condational_jump must end with an explicit catch-all route using condition script return true; this documents the default start path instead of relying on implicit fallback."
4599
+ );
4600
+ }
4601
+ }
4602
+ if (!nextErrors.length) {
4603
+ return;
4604
+ }
4605
+ if (errors) {
4606
+ errors.push(...nextErrors);
4607
+ return;
4608
+ }
4609
+ throw new Error(`flow-template start conditional jump gate failed: ${nextErrors.join("; ")}`);
4610
+ }
4611
+ function isFlowTemplateEndpointTarget(value) {
4612
+ return /^-\d+$/.test(value.trim());
4613
+ }
4614
+ function isFlowTemplateSpecialStepTarget(value) {
4615
+ const normalized = value.trim();
4616
+ return normalized === "[source]" || normalized === "anyNode";
4617
+ }
4618
+ function isFlowTemplateBackSourceTarget(value) {
4619
+ return value.trim() === "[source]";
4620
+ }
4621
+ function isFlowTemplateConditionalTarget(value, conditionNames) {
4622
+ const match = value.trim().match(/^(.+)\[condition\]\d+$/);
4623
+ if (!match) {
4624
+ return false;
4625
+ }
4626
+ return conditionNames.has(match[1].trim());
4627
+ }
4628
+ function validateFlowTemplateActionTarget(errors, pathName, target, nodeIds, conditionNames, options = {}) {
4629
+ const normalizedTarget = target.trim();
4630
+ if (!normalizedTarget) {
4631
+ if (options.actionString) {
4632
+ errors.push(`${pathName} target step is required after "|"; use "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID" or "\u6309\u94AE\u6587\u6848|\u6761\u4EF6\u540D[condition]0".`);
4633
+ } else {
4634
+ errors.push(`${pathName} target step is required; use a node id, -1, [source], anyNode, or \u6761\u4EF6\u540D[condition]0.`);
4635
+ }
4636
+ return;
4637
+ }
4638
+ const conditionalTargetAllowed = options.allowConditionalTarget !== false;
4639
+ const specialTargetAllowed = options.allowAnyNode === false ? isFlowTemplateBackSourceTarget(normalizedTarget) : isFlowTemplateSpecialStepTarget(normalizedTarget);
4640
+ if (!nodeIds.has(normalizedTarget) && !isFlowTemplateEndpointTarget(normalizedTarget) && !specialTargetAllowed && !(conditionalTargetAllowed && isFlowTemplateConditionalTarget(normalizedTarget, conditionNames))) {
4641
+ const allowedTargets = conditionalTargetAllowed ? "an existing data.nodes[].id, an endpoint like -1, [source], anyNode, or a condational_nodes reference like \u6761\u4EF6\u540D[condition]0" : options.allowAnyNode === false ? "an existing data.nodes[].id, an endpoint like -1, or [source]" : "an existing data.nodes[].id, an endpoint like -1, [source], or anyNode";
4642
+ errors.push(`${pathName} target (${normalizedTarget}) must be ${allowedTargets}.`);
4643
+ }
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
+ }
4684
+ function validateFlowTemplateApproveActionShape(value, errors) {
4685
+ const nextErrors = [];
4686
+ const data = isRecord3(value.data) ? value.data : {};
4687
+ const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
4688
+ const nodeIds = new Set(nodes.map((node) => String(node.id ?? "").trim()).filter(Boolean));
4689
+ nodes.forEach((node, nodeIndex) => {
4690
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
4691
+ validateFlowTemplateOwnerStrategyShape(node, nodeName, nextErrors);
4692
+ const conditionNames = /* @__PURE__ */ new Set();
4693
+ if (node.condational_nodes !== void 0 && node.condational_nodes !== null && node.condational_nodes !== "" && !Array.isArray(node.condational_nodes)) {
4694
+ nextErrors.push(`${nodeName}.condational_nodes must be an array of condition route objects.`);
4695
+ }
4696
+ const conditionalNodes = Array.isArray(node.condational_nodes) ? node.condational_nodes : [];
4697
+ conditionalNodes.forEach((conditionNode, conditionIndex) => {
4698
+ const conditionPath = `${nodeName}.condational_nodes[${conditionIndex}]`;
4699
+ if (!isRecord3(conditionNode)) {
4700
+ nextErrors.push(`${conditionPath} must be an object with name, result, condition_mode, and an index-returning condition script.`);
4701
+ return;
4702
+ }
4703
+ const conditionName = typeof conditionNode.name === "string" ? conditionNode.name.trim() : "";
4704
+ if (conditionName) {
4705
+ conditionNames.add(conditionName);
4706
+ } else {
4707
+ nextErrors.push(`${conditionPath}.name is required so approve_to_step/approve_actions can reference this condational_nodes entry.`);
4708
+ }
4709
+ const conditionMode = typeof conditionNode.condition_mode === "string" && conditionNode.condition_mode.trim() ? conditionNode.condition_mode.trim() : "code";
4710
+ if (conditionMode === "standard") {
4711
+ if (typeof conditionNode.standard_condition !== "string" || !conditionNode.standard_condition.trim()) {
4712
+ nextErrors.push(`${conditionPath}.standard_condition is required when condition_mode is standard; condition is ignored by the backend in this mode.`);
4713
+ }
4714
+ } else if (conditionMode === "code") {
4715
+ if (typeof conditionNode.condition !== "string" || !conditionNode.condition.trim()) {
4716
+ nextErrors.push(`${conditionPath}.condition is required when condition_mode is code or omitted; standard_condition is ignored by the backend in code mode.`);
4717
+ }
4718
+ } else {
4719
+ nextErrors.push(`${conditionPath}.condition_mode must be code or standard.`);
4720
+ }
4721
+ const conditionResult = conditionNode.result;
4722
+ const resultPath = `${conditionPath}.result`;
4723
+ if (!Array.isArray(conditionResult) || !conditionResult.length) {
4724
+ nextErrors.push(`${resultPath} must be a non-empty array of target node ids.`);
4725
+ return;
4726
+ }
4727
+ conditionResult.forEach((target, targetIndex) => {
4728
+ const targetPath = `${resultPath}[${targetIndex}]`;
4729
+ if (Array.isArray(target) || isRecord3(target) || target === void 0 || target === null) {
4730
+ nextErrors.push(`${targetPath} must be a target node id, endpoint like -1, or [source].`);
4731
+ return;
4732
+ }
4733
+ validateFlowTemplateActionTarget(
4734
+ nextErrors,
4735
+ targetPath,
4736
+ String(target),
4737
+ nodeIds,
4738
+ conditionNames,
4739
+ { allowConditionalTarget: false, allowAnyNode: false }
4740
+ );
4741
+ });
4742
+ });
4743
+ [
4744
+ ["approve_to_step", node.approve_to_step],
4745
+ ["approve_fail", node.approve_fail]
4746
+ ].forEach(([fieldName, fieldValue]) => {
4747
+ if (fieldValue === void 0 || fieldValue === null || fieldValue === "") {
4748
+ return;
4749
+ }
4750
+ if (Array.isArray(fieldValue) || isRecord3(fieldValue)) {
4751
+ nextErrors.push(`${nodeName}.${fieldName} must be a target node id, endpoint like -1, [source], anyNode, or \u6761\u4EF6\u540D[condition]0.`);
4752
+ return;
4753
+ }
4754
+ validateFlowTemplateActionTarget(nextErrors, `${nodeName}.${fieldName}`, String(fieldValue), nodeIds, conditionNames);
4755
+ });
4756
+ const actionGroups = [
4757
+ ["approve_actions", node.approve_actions],
4758
+ ["approve_fail_actions", node.approve_fail_actions]
4759
+ ];
4760
+ actionGroups.forEach(([fieldName, fieldValue]) => {
4761
+ if (fieldValue === void 0 || fieldValue === null || fieldValue === "") {
4762
+ return;
4763
+ }
4764
+ const pathPrefix = `${nodeName}.${fieldName}`;
4765
+ if (!Array.isArray(fieldValue)) {
4766
+ nextErrors.push(`${pathPrefix} must be an array of action strings.`);
4767
+ return;
4768
+ }
4769
+ fieldValue.forEach((action, actionIndex) => {
4770
+ const pathName = `${pathPrefix}[${actionIndex}]`;
4771
+ if (typeof action !== "string") {
4772
+ nextErrors.push(`${pathName} must be a string action in "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID" format.`);
4773
+ return;
4774
+ }
4775
+ const parts = action.split("|");
4776
+ if (parts.length < 2) {
4777
+ const raw = action.trim();
4778
+ if (raw && (nodeIds.has(raw) || isFlowTemplateEndpointTarget(raw) || isFlowTemplateSpecialStepTarget(raw) || isFlowTemplateConditionalTarget(raw, conditionNames))) {
4779
+ nextErrors.push(`${pathName} is a bare target (${raw}); action strings must be "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID", not just a node id.`);
4780
+ } else {
4781
+ nextErrors.push(`${pathName} must contain "|" and use "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID" or "\u6309\u94AE\u6587\u6848|\u6761\u4EF6\u540D[condition]0".`);
4782
+ }
4783
+ return;
4784
+ }
4785
+ const label = parts[0].trim();
4786
+ const target = parts[1].trim();
4787
+ if (!label) {
4788
+ nextErrors.push(`${pathName} label is required before "|".`);
4789
+ }
4790
+ validateFlowTemplateActionTarget(nextErrors, pathName, target, nodeIds, conditionNames, { actionString: true });
4791
+ });
4792
+ });
4793
+ });
4794
+ if (!nextErrors.length) {
4795
+ return;
4796
+ }
4797
+ if (errors) {
4798
+ errors.push(...nextErrors);
4799
+ return;
4800
+ }
4801
+ throw new Error(`flow-template approve action gate failed: ${nextErrors.join("; ")}`);
4802
+ }
4803
+ function validateOptionalBoolean(errors, value, fieldName, pathName) {
4804
+ if (value[fieldName] !== void 0 && typeof value[fieldName] !== "boolean") {
4805
+ errors.push(`${pathName}.${fieldName} must be a boolean when provided.`);
4806
+ }
4807
+ }
4808
+ function validateFlowTemplatePluginRejectionControl(value, errors) {
4809
+ const nextErrors = [];
4810
+ const data = isRecord3(value.data) ? value.data : {};
4811
+ const meta = isRecord3(data.meta) ? data.meta : {};
4812
+ const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
4813
+ nodes.forEach((node, nodeIndex) => {
4814
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
4815
+ const config = node.plugin_rejection_control;
4816
+ const pathName = `${nodeName}.plugin_rejection_control`;
4817
+ if (config === void 0 || config === null || config === "") {
4818
+ return;
4819
+ }
4820
+ if (!isRecord3(config)) {
4821
+ nextErrors.push(`${pathName} must be an object when configured.`);
4822
+ return;
4823
+ }
4824
+ validateOptionalBoolean(nextErrors, config, "enabled", pathName);
4825
+ validateOptionalBoolean(nextErrors, config, "disabled_form_validate", pathName);
4826
+ [
4827
+ "reject_to_pre",
4828
+ "reject_to_owner",
4829
+ "reject_to_specific_step",
4830
+ "reject_to_end",
4831
+ "review_default",
4832
+ "review_to_me",
4833
+ "review_to_all",
4834
+ "review_to_any_node"
4835
+ ].forEach((fieldName) => validateOptionalBoolean(nextErrors, config, fieldName, pathName));
4836
+ if (config.enabled !== true) {
4837
+ return;
4838
+ }
4839
+ if (typeof config.button_text !== "string" || !config.button_text.trim()) {
4840
+ nextErrors.push(`${pathName}.button_text is required when plugin rejection control is enabled.`);
4841
+ }
4842
+ const hasNativeRejectTarget = typeof node.approve_fail === "string" && node.approve_fail.trim() || Array.isArray(node.approve_fail_actions) && node.approve_fail_actions.length > 0;
4843
+ const hasPluginRejectMethod = config.reject_to_pre === true || config.reject_to_owner === true || config.reject_to_specific_step === true || config.reject_to_end === true;
4844
+ if (!hasNativeRejectTarget && !hasPluginRejectMethod) {
4845
+ nextErrors.push(
4846
+ `${pathName} must enable at least one reject method (reject_to_pre, reject_to_owner, reject_to_specific_step, reject_to_end) or keep a native approve_fail/approve_fail_actions target.`
4847
+ );
4848
+ }
4849
+ if (config.reject_to_owner === true && meta.allow_jump_start !== true && !hasNativeRejectTarget && config.reject_to_pre !== true && config.reject_to_specific_step !== true && config.reject_to_end !== true) {
4850
+ nextErrors.push(
4851
+ `${pathName}.reject_to_owner is the only configured reject method but requires data.meta.allow_jump_start = true; otherwise the runtime will not offer any usable plugin reject method.`
4852
+ );
4853
+ }
4854
+ });
4855
+ if (!nextErrors.length) {
4856
+ return;
4857
+ }
4858
+ if (errors) {
4859
+ errors.push(...nextErrors);
4860
+ return;
4861
+ }
4862
+ throw new Error(`flow-template plugin rejection control gate failed: ${nextErrors.join("; ")}`);
4863
+ }
4864
+ var FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS = /* @__PURE__ */ new Set([
4865
+ "eq",
4866
+ "ne",
4867
+ "gt",
4868
+ "gte",
4869
+ "lt",
4870
+ "lte",
4871
+ "contains",
4872
+ "isEmpty",
4873
+ "isNotEmpty"
4874
+ ]);
4875
+ function validateFlowTemplateStandardConditionEditorRules(value, errors) {
4876
+ const nextErrors = [];
4877
+ const data = isRecord3(value.data) ? value.data : {};
4878
+ const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
4879
+ const visitConditionGroup = (group, pathName) => {
4880
+ if (!isRecord3(group)) {
4881
+ nextErrors.push(`${pathName} must be a condition group object with logic and conditions.`);
4882
+ return;
4883
+ }
4884
+ const logic = typeof group.logic === "string" ? group.logic.trim() : "AND";
4885
+ if (logic !== "AND" && logic !== "OR") {
4886
+ nextErrors.push(`${pathName}.logic must be AND or OR.`);
4887
+ }
4888
+ if (!Array.isArray(group.conditions)) {
4889
+ nextErrors.push(`${pathName}.conditions must be an array.`);
4890
+ return;
4891
+ }
4892
+ group.conditions.forEach((condition, conditionIndex) => {
4893
+ const conditionPath = `${pathName}.conditions[${conditionIndex}]`;
4894
+ if (!isRecord3(condition)) {
4895
+ nextErrors.push(`${conditionPath} must be a condition object or nested condition group.`);
4896
+ return;
4897
+ }
4898
+ if (Array.isArray(condition.conditions) || typeof condition.logic === "string") {
4899
+ visitConditionGroup(condition, conditionPath);
4900
+ return;
4901
+ }
4902
+ const leftValue = typeof condition.leftValue === "string" ? condition.leftValue.trim() : "";
4903
+ if (!leftValue) {
4904
+ nextErrors.push(`${conditionPath}.leftValue is required and must match a form_template rule.field value.`);
4905
+ }
4906
+ const leftValueType = typeof condition.leftValueType === "string" && condition.leftValueType.trim() ? condition.leftValueType.trim() : "field";
4907
+ if (leftValueType !== "field" && leftValueType !== "constant" && leftValueType !== "variable") {
4908
+ nextErrors.push(`${conditionPath}.leftValueType must be field, constant, or variable.`);
4909
+ }
4910
+ const operator = typeof condition.operator === "string" ? condition.operator.trim() : "";
4911
+ if (!operator || !FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS.has(operator)) {
4912
+ nextErrors.push(`${conditionPath}.operator must be one of ${Array.from(FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS).join(", ")}.`);
4913
+ }
4914
+ const rightValueType = typeof condition.rightValueType === "string" && condition.rightValueType.trim() ? condition.rightValueType.trim() : "constant";
4915
+ if (rightValueType !== "field" && rightValueType !== "constant" && rightValueType !== "variable") {
4916
+ nextErrors.push(`${conditionPath}.rightValueType must be field, constant, or variable.`);
4917
+ }
4918
+ const isWewfDerived = condition._wewf_operator !== void 0 || condition._wewf_source_rule_id !== void 0 || condition._wewf_field_key !== void 0;
4919
+ if (isWewfDerived && condition._bpmax_editor_field_resolved !== true) {
4920
+ nextErrors.push(
4921
+ `${conditionPath} is WEWF-derived but does not prove BPMAX editor field resolution; leftValue must be resolved from form_template rule.field (for example main.<field_key>) before using condition_mode=standard.`
4922
+ );
4923
+ }
4924
+ if (isWewfDerived && typeof condition._wewf_field_key === "string" && condition._wewf_field_key.trim() && condition._wewf_field_key.trim() === leftValue && !leftValue.includes(".")) {
4925
+ nextErrors.push(
4926
+ `${conditionPath}.leftValue (${leftValue}) still looks like a raw WEWF field key; standard condition editor values must use the BPMAX form_template rule.field value.`
4927
+ );
4928
+ }
4929
+ });
4930
+ };
4931
+ nodes.forEach((node, nodeIndex) => {
4932
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
4933
+ const conditionalNodes = Array.isArray(node.condational_nodes) ? node.condational_nodes : [];
4934
+ conditionalNodes.forEach((conditionNode, conditionIndex) => {
4935
+ if (!isRecord3(conditionNode)) {
4936
+ return;
4937
+ }
4938
+ const conditionMode = typeof conditionNode.condition_mode === "string" && conditionNode.condition_mode.trim() ? conditionNode.condition_mode.trim() : "code";
4939
+ if (conditionMode !== "standard") {
4940
+ return;
4941
+ }
4942
+ const conditionPath = `${nodeName}.condational_nodes[${conditionIndex}]`;
4943
+ if (!Array.isArray(conditionNode.condition_result_rules)) {
4944
+ nextErrors.push(`${conditionPath}.condition_result_rules must be an array when condition_mode is standard.`);
4945
+ return;
4946
+ }
4947
+ const resultLength = Array.isArray(conditionNode.result) ? conditionNode.result.length : 0;
4948
+ if (conditionNode.condition_result_rules.length !== resultLength) {
4949
+ nextErrors.push(`${conditionPath}.condition_result_rules length must equal result length (${resultLength}).`);
4950
+ }
4951
+ conditionNode.condition_result_rules.forEach((group, groupIndex) => {
4952
+ visitConditionGroup(group, `${conditionPath}.condition_result_rules[${groupIndex}]`);
4953
+ });
4954
+ });
4955
+ });
4956
+ if (!nextErrors.length) {
4957
+ return;
4958
+ }
4959
+ if (errors) {
4960
+ errors.push(...nextErrors);
4961
+ return;
4962
+ }
4963
+ throw new Error(`flow-template standard condition editor gate failed: ${nextErrors.join("; ")}`);
4964
+ }
4337
4965
  function looksLikeParseEvalFunctionBody(script) {
4338
4966
  const text5 = script.trim();
4339
4967
  if (!text5) {
@@ -4701,7 +5329,7 @@ function lintListTemplateQuerySafety(content, errors) {
4701
5329
  /* @__PURE__ */ new Set(["$template", "customQuery", "beforeSearch", "tabFilters", "query", "url", "api", "dataSource"])
4702
5330
  );
4703
5331
  queryTexts.forEach((text5) => {
4704
- 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)) {
4705
5333
  return;
4706
5334
  }
4707
5335
  if (/(\/bpmax\/project\/list|\/api\/project\/list|ESProjectList)/i.test(text5)) {
@@ -4712,6 +5340,183 @@ function lintListTemplateQuerySafety(content, errors) {
4712
5340
  }
4713
5341
  });
4714
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
+ }
4715
5520
  function listTemplateNodeLabel(node) {
4716
5521
  return [
4717
5522
  node.title,
@@ -4910,6 +5715,14 @@ function normalizePageTemplatePayload(domain, work) {
4910
5715
  if (domain === "list-template") {
4911
5716
  validateListTemplateActionGate(work);
4912
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
+ }
4913
5726
  const basic = isRecord3(work.basic) ? work.basic : work;
4914
5727
  const rawContent = work.content ?? basic.content;
4915
5728
  const type = definition.expectedType;
@@ -5008,6 +5821,10 @@ function normalizeFlowTemplatePayload(work) {
5008
5821
  validateFlowTemplateRemoteTemplateRefs({ ...work, data });
5009
5822
  validateFlowTemplateProjectAfterCreatePath({ ...work, data });
5010
5823
  validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
5824
+ validateFlowTemplateStartConditionalJump({ ...work, data });
5825
+ validateFlowTemplateApproveActionShape({ ...work, data });
5826
+ validateFlowTemplatePluginRejectionControl({ ...work, data });
5827
+ validateFlowTemplateStandardConditionEditorRules({ ...work, data });
5011
5828
  validateFlowTemplateCodeModeMessages({ ...work, data });
5012
5829
  validateFlowTemplateRuntimeScripts({ ...work, data });
5013
5830
  validateFlowTemplateFeishuChatPlugin({ ...work, data });
@@ -5118,6 +5935,62 @@ function exactConfirmOrDryRun(confirm3, expectedConfirm, options = {}) {
5118
5935
  }
5119
5936
  throw new Error(`confirmation text mismatch. expected: ${expectedConfirm}. actual: ${confirm3}.`);
5120
5937
  }
5938
+ function configReadbackHint(domain, id) {
5939
+ if (id === void 0 || id === null || id === "") {
5940
+ return null;
5941
+ }
5942
+ const value = String(id);
5943
+ return {
5944
+ command: `bpmax-cli config ${domain} export --id ${value} --inline --format json`,
5945
+ unified_command: `bpmax-cli config readback ${domain} --id ${value} --format json`
5946
+ };
5947
+ }
5948
+ function configResponseKey(domain, payload, response, readback) {
5949
+ if (isRecord3(response)) {
5950
+ const key = response.key ?? response.field ?? response.custom_key;
5951
+ if (key !== void 0) return key;
5952
+ if (isRecord3(response.data)) {
5953
+ const nested = response.data.key ?? response.data.field ?? response.data.custom_key;
5954
+ if (nested !== void 0) return nested;
5955
+ }
5956
+ }
5957
+ if (isRecord3(readback)) {
5958
+ const key = readback.key ?? readback.field ?? readback.custom_key;
5959
+ if (key !== void 0) return key;
5960
+ }
5961
+ if (isRecord3(payload)) {
5962
+ if (domain === "dataset") return payload.custom_key ?? payload.customKey ?? null;
5963
+ return payload.key ?? payload.field ?? null;
5964
+ }
5965
+ return null;
5966
+ }
5967
+ function standardConfigWriteResponse(input) {
5968
+ const resolvedId = input.executedId ?? input.id;
5969
+ return {
5970
+ id: resolvedId,
5971
+ request_id: input.id,
5972
+ key: configResponseKey(input.domain, input.payload, input.response, input.readback),
5973
+ readback_hint: configReadbackHint(input.domain, resolvedId)
5974
+ };
5975
+ }
5976
+ function dryRunFields(expectedConfirm) {
5977
+ return {
5978
+ ok: true,
5979
+ dry_run: true,
5980
+ operation_executed: false,
5981
+ confirm_required: true,
5982
+ required_confirm: expectedConfirm,
5983
+ expected_confirm: expectedConfirm
5984
+ };
5985
+ }
5986
+ function executedFields() {
5987
+ return {
5988
+ ok: true,
5989
+ dry_run: false,
5990
+ operation_executed: true,
5991
+ confirm_required: false
5992
+ };
5993
+ }
5121
5994
  function validateDatasetFieldCreatePayload(payload) {
5122
5995
  if (!isRecord3(payload)) {
5123
5996
  throw new Error("dataset-field create requires an object payload.");
@@ -5138,7 +6011,8 @@ function normalizeDatasetFieldPayload(work) {
5138
6011
  if (mode !== void 0 && mode !== "edit" && mode !== "create") {
5139
6012
  throw new Error("dataset-field typed adapter supports mode edit or create. Delete requires a dedicated adapter.");
5140
6013
  }
5141
- const source = isRecord3(work.source) ? work.source : work;
6014
+ const hasSourceObject = isRecord3(work.source);
6015
+ const source = hasSourceObject ? work.source : work;
5142
6016
  const sourcePayload = isRecord3(work.x_wewf_source_payload) ? work.x_wewf_source_payload : {};
5143
6017
  const payload = {
5144
6018
  data_set_id: firstNonEmpty(work.data_set_id, work.dataSetId, work.dataset_id, sourcePayload.data_set_id, sourcePayload.dataSetId, sourcePayload.dataset_id),
@@ -5162,7 +6036,7 @@ function normalizeDatasetFieldPayload(work) {
5162
6036
  payload.source_fk = virtual.joinField || "";
5163
6037
  } else {
5164
6038
  payload.source_table = source.table ?? source.sourceTable ?? source.source_table ?? "";
5165
- 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 ?? "";
5166
6040
  payload.source_fk = source.fk ?? source.sourceFk ?? source.source_fk ?? "";
5167
6041
  }
5168
6042
  payload.sourceTable = payload.source_table;
@@ -5544,6 +6418,216 @@ function validateFormTemplateValueValidateMaps(payload, errors) {
5544
6418
  }
5545
6419
  }
5546
6420
  }
6421
+ function formTemplateControlOptions(rule, value) {
6422
+ const candidates = [
6423
+ rule?.options,
6424
+ isRecord3(rule?.props) ? rule.props.options : void 0,
6425
+ value?.options,
6426
+ isRecord3(value?.value) ? value.value.options : void 0,
6427
+ isRecord3(value?.props) ? value.props.options : void 0
6428
+ ];
6429
+ for (const candidate of candidates) {
6430
+ if (Array.isArray(candidate)) {
6431
+ return candidate;
6432
+ }
6433
+ }
6434
+ return [];
6435
+ }
6436
+ function formTemplateControlValueType(rule, value) {
6437
+ if (value && Object.prototype.hasOwnProperty.call(value, "value_type")) {
6438
+ return value.value_type;
6439
+ }
6440
+ if (rule && Object.prototype.hasOwnProperty.call(rule, "value_type")) {
6441
+ return rule.value_type;
6442
+ }
6443
+ if (value && isRecord3(value.value) && Object.prototype.hasOwnProperty.call(value.value, "value_type")) {
6444
+ return value.value.value_type;
6445
+ }
6446
+ return void 0;
6447
+ }
6448
+ function validateRadioFormTemplateControl(field, rule, value, errors) {
6449
+ const options = formTemplateControlOptions(rule, value);
6450
+ if (!options.length) {
6451
+ errors.push(`form-template radio field ${field} must include non-empty options on rule/value before build/submit.`);
6452
+ }
6453
+ for (const [index, option] of options.entries()) {
6454
+ if (!isRecord3(option)) {
6455
+ errors.push(`form-template radio field ${field} options[${index}] must be an object with label/value.`);
6456
+ continue;
6457
+ }
6458
+ const hasLabel = typeof option.label === "string" && option.label.length > 0 || typeof option.title === "string" && option.title.length > 0;
6459
+ const hasValue = Object.prototype.hasOwnProperty.call(option, "value") || Object.prototype.hasOwnProperty.call(option, "key");
6460
+ if (!hasLabel || !hasValue) {
6461
+ errors.push(`form-template radio field ${field} options[${index}] must include label and value.`);
6462
+ }
6463
+ }
6464
+ const valueType = formTemplateControlValueType(rule, value);
6465
+ if (valueType === void 0) {
6466
+ errors.push(`form-template radio field ${field} must include value_type=string.`);
6467
+ } else if (valueType !== "string") {
6468
+ errors.push(`form-template radio field ${field} value_type must be string.`);
6469
+ }
6470
+ const validateMap = value?.validateMap;
6471
+ if (!isRecord3(validateMap) || !Object.prototype.hasOwnProperty.call(validateMap, "required")) {
6472
+ errors.push(`form-template radio field ${field} must include value.validateMap.required.`);
6473
+ }
6474
+ }
6475
+ function validateFormTemplateControlContracts(payload, errors) {
6476
+ const validatePair = (field, rule, value) => {
6477
+ const type = typeof rule?.type === "string" ? rule.type : typeof value?.field_type === "string" ? value.field_type : "";
6478
+ if (type === "serial_number") {
6479
+ errors.push(`form-template field ${field} uses legacy serial_number; use BPMAX frontend control type sn_number.`);
6480
+ }
6481
+ if (type === "sn_number") {
6482
+ return;
6483
+ }
6484
+ if (type === "radio") {
6485
+ validateRadioFormTemplateControl(field, rule, value, errors);
6486
+ }
6487
+ };
6488
+ if (isRecord3(payload.fields)) {
6489
+ for (const [field, bundle] of Object.entries(payload.fields)) {
6490
+ if (!isRecord3(bundle)) {
6491
+ continue;
6492
+ }
6493
+ validatePair(field, isRecord3(bundle.rule) ? bundle.rule : void 0, isRecord3(bundle.value) ? bundle.value : void 0);
6494
+ }
6495
+ }
6496
+ const rawValueByField = /* @__PURE__ */ new Map();
6497
+ if (Array.isArray(payload.value)) {
6498
+ for (const item of payload.value) {
6499
+ if (isRecord3(item) && typeof item.field === "string" && item.field) {
6500
+ rawValueByField.set(item.field, item);
6501
+ }
6502
+ }
6503
+ }
6504
+ if (Array.isArray(payload.rule)) {
6505
+ for (const row of payload.rule) {
6506
+ if (!Array.isArray(row)) {
6507
+ continue;
6508
+ }
6509
+ for (const item of row) {
6510
+ if (!isRecord3(item) || typeof item.field !== "string" || !item.field) {
6511
+ continue;
6512
+ }
6513
+ validatePair(item.field, item, rawValueByField.get(item.field));
6514
+ }
6515
+ }
6516
+ }
6517
+ }
6518
+ var FORM_TEMPLATE_VISUAL_WIDE_TYPES = /* @__PURE__ */ new Set([
6519
+ "sub_form",
6520
+ "i_textarea",
6521
+ "textarea",
6522
+ "rich_text",
6523
+ "editor",
6524
+ "upload",
6525
+ "file",
6526
+ "image",
6527
+ "images",
6528
+ "raw"
6529
+ ]);
6530
+ function shouldRunFormTemplateVisualLint(payload) {
6531
+ const lintHints = isRecord3(payload.lintHints) ? payload.lintHints : {};
6532
+ const visualReview = isRecord3(lintHints.visualReview) ? lintHints.visualReview : {};
6533
+ return visualReview.enabled === true || visualReview.required === true || payload.mode === "visual_review";
6534
+ }
6535
+ function formTemplateVisualReviewHints(payload) {
6536
+ const lintHints = isRecord3(payload.lintHints) ? payload.lintHints : {};
6537
+ return isRecord3(lintHints.visualReview) ? lintHints.visualReview : {};
6538
+ }
6539
+ function numericHint(value, fallback) {
6540
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
6541
+ }
6542
+ function formTemplateRuleTitle(rule, value) {
6543
+ const title = rule.title ?? value?.title ?? rule.label ?? value?.label;
6544
+ return typeof title === "string" ? title.trim() : "";
6545
+ }
6546
+ function formTemplateRuleWidth(rule) {
6547
+ const props = isRecord3(rule.props) ? rule.props : {};
6548
+ const candidates = [
6549
+ rule.span,
6550
+ rule.colSpan,
6551
+ rule.width,
6552
+ props.span,
6553
+ props.colSpan,
6554
+ props.width
6555
+ ];
6556
+ for (const candidate of candidates) {
6557
+ if (typeof candidate === "number" && Number.isFinite(candidate) && candidate > 0) {
6558
+ return candidate;
6559
+ }
6560
+ if (typeof candidate === "string" && /^\d+$/.test(candidate.trim())) {
6561
+ return Number(candidate.trim());
6562
+ }
6563
+ }
6564
+ return void 0;
6565
+ }
6566
+ function validateStructuredFormTemplateVisualReview(payload, errors) {
6567
+ if (!shouldRunFormTemplateVisualLint(payload)) {
6568
+ return;
6569
+ }
6570
+ const hints = formTemplateVisualReviewHints(payload);
6571
+ if (hints.confirmedNonBehavioralProps !== true) {
6572
+ errors.push(
6573
+ "form-template visual lint requires lintHints.visualReview.confirmedNonBehavioralProps=true after confirming the diff only changes layout, label/control width, spacing, or other non-behavioral display props."
6574
+ );
6575
+ }
6576
+ if (!Array.isArray(payload.layout) || !isRecord3(payload.fields)) {
6577
+ errors.push("form-template visual lint requires structured work with layout and fields.");
6578
+ return;
6579
+ }
6580
+ const maxColumnsPerRow = Math.floor(numericHint(hints.maxColumnsPerRow, 2));
6581
+ const maxRowTitleChars = Math.floor(numericHint(hints.maxRowTitleChars, 24));
6582
+ const maxTitleCharsInMultiColumn = Math.floor(numericHint(hints.maxTitleCharsInMultiColumn, 12));
6583
+ for (const [rowIndex, row] of payload.layout.entries()) {
6584
+ if (!Array.isArray(row)) {
6585
+ errors.push(`form-template visual lint layout row ${rowIndex} must be an array.`);
6586
+ continue;
6587
+ }
6588
+ if (!row.length) {
6589
+ errors.push(`form-template visual lint layout row ${rowIndex} is empty; remove empty visual rows before submit.`);
6590
+ continue;
6591
+ }
6592
+ if (row.length > maxColumnsPerRow) {
6593
+ errors.push(`form-template visual lint layout row ${rowIndex} has ${row.length} fields; maxColumnsPerRow=${maxColumnsPerRow} for readable desktop data entry.`);
6594
+ }
6595
+ let rowTitleChars = 0;
6596
+ for (const ref of row) {
6597
+ if (typeof ref !== "string" || !ref) {
6598
+ continue;
6599
+ }
6600
+ const bundle = payload.fields[ref];
6601
+ if (!isRecord3(bundle) || !isRecord3(bundle.rule)) {
6602
+ continue;
6603
+ }
6604
+ const value = isRecord3(bundle.value) ? bundle.value : void 0;
6605
+ const rule = bundle.rule;
6606
+ const title = formTemplateRuleTitle(rule, value);
6607
+ rowTitleChars += title.length;
6608
+ const type = typeof rule.type === "string" ? rule.type : typeof value?.field_type === "string" ? value.field_type : "";
6609
+ if (row.length > 1 && FORM_TEMPLATE_VISUAL_WIDE_TYPES.has(type)) {
6610
+ errors.push(`form-template visual lint field ${ref} (${title || type}) type=${type} must be in a single-field row for readable editing.`);
6611
+ }
6612
+ if (row.length > 1 && title.length > maxTitleCharsInMultiColumn) {
6613
+ errors.push(`form-template visual lint field ${ref} title is too long for a multi-column row (${title.length} > ${maxTitleCharsInMultiColumn}); move it to a single row or shorten the visible label.`);
6614
+ }
6615
+ const width = formTemplateRuleWidth(rule);
6616
+ if (row.length > 1 && typeof width === "number" && width > 12) {
6617
+ errors.push(`form-template visual lint field ${ref} declares width/span=${width} inside a multi-column row; wide controls must be single-row or use <=12 grid width.`);
6618
+ }
6619
+ }
6620
+ if (row.length > 1 && rowTitleChars > maxRowTitleChars) {
6621
+ errors.push(`form-template visual lint layout row ${rowIndex} title length total is ${rowTitleChars}; maxRowTitleChars=${maxRowTitleChars}. Split the row for readability.`);
6622
+ }
6623
+ }
6624
+ }
6625
+ function validateFormTemplateWorkLint(payload, errors) {
6626
+ validateFormTemplateNameLength(payload, errors);
6627
+ validateFormTemplateValueValidateMaps(payload, errors);
6628
+ validateFormTemplateControlContracts(payload, errors);
6629
+ validateStructuredFormTemplateVisualReview(payload, errors);
6630
+ }
5547
6631
  function stripFormTemplateCreateIds(payload) {
5548
6632
  const next = { ...payload };
5549
6633
  if (Array.isArray(next.rule)) {
@@ -6715,6 +7799,10 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
6715
7799
  validateFlowTemplateRemoteTemplateRefs(work);
6716
7800
  validateFlowTemplateProjectAfterCreatePath(work);
6717
7801
  validateFlowTemplateStandardPageCreateFormTemplate(work);
7802
+ validateFlowTemplateStartConditionalJump(work);
7803
+ validateFlowTemplateApproveActionShape(work);
7804
+ validateFlowTemplatePluginRejectionControl(work);
7805
+ validateFlowTemplateStandardConditionEditorRules(work);
6718
7806
  validateFlowTemplateCodeModeMessages(work);
6719
7807
  validateFlowTemplateRuntimeScripts(work);
6720
7808
  validateFlowTemplateFeishuChatPlugin(work);
@@ -6730,6 +7818,14 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
6730
7818
  if (!createShell.name) {
6731
7819
  throw new Error("flow-template create requires name.");
6732
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
+ }
6733
7829
  const expectedConfirm = `create flow-template ${createShell.name}`;
6734
7830
  if (confirm3 !== expectedConfirm) {
6735
7831
  return {
@@ -6742,14 +7838,6 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
6742
7838
  next: `Run again with --confirm "${expectedConfirm}" to create.`
6743
7839
  };
6744
7840
  }
6745
- const pluginLint = await runFlowTemplatePluginLint(work, {
6746
- profile,
6747
- agent: options.agent || "codex",
6748
- requireInstalled: true
6749
- });
6750
- if (pluginLint?.errors.length) {
6751
- throw new Error(`flow-template plugin lint failed: ${pluginLint.errors.join("; ")}`);
6752
- }
6753
7841
  const client = createApiClient(profile);
6754
7842
  const createResponse = await apiRequest(
6755
7843
  client,
@@ -6835,13 +7923,30 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
6835
7923
  if (!isRecord3(formWork) || formWork.mode !== "create") {
6836
7924
  throw new Error("flow-app create requires form work with mode=create.");
6837
7925
  }
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("; ")}`);
7947
+ }
6838
7948
  const formPayload = buildDomainSubmitPayload("form-template", formWork);
6839
7949
  const flowWorkRecord = isRecord3(flowWork) ? flowWork : {};
6840
- validateFlowTemplateRemoteTemplateRefs(flowWorkRecord);
6841
- validateFlowTemplateFormDrivenCreateBaseline(flowWorkRecord, void 0, {
6842
- force: true,
6843
- context: "flow-app create"
6844
- });
6845
7950
  const flowShell = {
6846
7951
  name: String(flowWorkRecord.name || name),
6847
7952
  category: flowWorkRecord.category || "system",
@@ -6857,25 +7962,43 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
6857
7962
  { step: "create_form_template", method: "POST", path: "/form_template", payload: formPayload },
6858
7963
  { step: "publish_form_template", method: "POST", path: "/form_template/publish", payload: { id: "<draft-form-id>" } },
6859
7964
  { step: "create_flow_template", method: "POST", path: "/flow/flow_type", payload: flowShell },
6860
- { step: "save_flow_draft", method: "PUT", path: "/flow?flow_type=<platform-flow-type>&publish=2" },
6861
- ...options.publishLive !== false ? [{ step: "publish_flow_live", method: "PUT", path: "/flow?flow_type=<platform-flow-type>&publish=1" }] : [],
6862
- { 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
+ },
6863
7987
  { step: "verify_workspace_binding", method: "GET", path: "/workspace/by_key", params: { key: workspace } }
6864
7988
  ]
6865
7989
  };
6866
7990
  if (!exactConfirmOrDryRun(confirm3, expectedConfirm, { equivalentConfirms: [acceptedConfirmWithWorkspacePrefix] })) {
6867
7991
  return {
6868
- ok: true,
6869
- dry_run: true,
6870
- operation_executed: false,
6871
- confirm_required: true,
6872
- expected_confirm: expectedConfirm,
7992
+ ...dryRunFields(expectedConfirm),
6873
7993
  accepted_confirms: [expectedConfirm, acceptedConfirmWithWorkspacePrefix],
6874
7994
  domain: "flow-app",
6875
7995
  workspace,
6876
7996
  name,
7997
+ preflight,
6877
7998
  operation_plan: dryRunPlan,
6878
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.",
6879
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.",
6880
8003
  "Verify matrix rule records contain real approver user values before connecting business flow matrix_owner or cc_matrix.",
6881
8004
  "Use bpmax-project safe project create/handoff for matrix rule records; do not treat local seed-rules.json as online data."
@@ -7008,10 +8131,7 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
7008
8131
  verified_at: (/* @__PURE__ */ new Date()).toISOString()
7009
8132
  };
7010
8133
  return {
7011
- ok: true,
7012
- dry_run: false,
7013
- operation_executed: true,
7014
- confirm_required: false,
8134
+ ...executedFields(),
7015
8135
  domain: "flow-app",
7016
8136
  workspace,
7017
8137
  name,
@@ -7525,11 +8645,19 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
7525
8645
  }
7526
8646
  if (domain === "form-template" && isRecord3(work)) {
7527
8647
  const errors = [];
7528
- validateFormTemplateValueValidateMaps(work, errors);
8648
+ validateFormTemplateWorkLint(work, errors);
7529
8649
  if (errors.length) {
7530
8650
  throw new Error(`form-template lint failed: ${errors.join("; ")}`);
7531
8651
  }
7532
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
+ }
7533
8661
  const payload = buildDomainSubmitPayload(domain, work, options, raw);
7534
8662
  if (domain === "flow-template" && options.publishLive) {
7535
8663
  payload.publish_live = true;
@@ -7561,14 +8689,24 @@ async function runFlowTemplatePluginLint(flowWork, options = {}) {
7561
8689
  }
7562
8690
  const agent = options.agent || "codex";
7563
8691
  const client = createApiClient(options.profile);
7564
- const platformSkills = await listPluginSkills(client);
7565
- 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({
7566
8700
  profile: options.profile,
7567
8701
  agent,
7568
8702
  flowWork,
7569
8703
  platformSkills,
7570
8704
  requireInstalled: Boolean(options.requireInstalled)
7571
8705
  });
8706
+ if (discoveryWarning) {
8707
+ result.warnings.push(discoveryWarning);
8708
+ }
8709
+ return result;
7572
8710
  }
7573
8711
  function hasPotentialFlowTemplatePluginExtension(flowWork) {
7574
8712
  if (collectFlowTemplatePluginKeys(flowWork).length) {
@@ -7604,12 +8742,14 @@ async function lintConfigWorkFile(file, options = {}) {
7604
8742
  }
7605
8743
  const shouldLintFormTemplate = options.domain ? options.domain === "form-template" : looksLikeFormTemplateWork(value);
7606
8744
  if (shouldLintFormTemplate) {
7607
- validateFormTemplateNameLength(value, errors);
7608
- validateFormTemplateValueValidateMaps(value, errors);
8745
+ validateFormTemplateWorkLint(value, errors);
7609
8746
  }
7610
8747
  if ((Object.prototype.hasOwnProperty.call(value, "content") || isRecord3(value.basic)) && pageTemplateType(value) === 1) {
7611
8748
  validateListTemplateActionGate(value, errors);
7612
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
+ }
7613
8753
  if (value.domain === "nav-config" || Object.prototype.hasOwnProperty.call(value, "configs")) {
7614
8754
  lintNavConfigWork(value, errors);
7615
8755
  }
@@ -7618,6 +8758,10 @@ async function lintConfigWorkFile(file, options = {}) {
7618
8758
  validateFlowTemplateRemoteTemplateRefs(flowWork, errors);
7619
8759
  validateFlowTemplateProjectAfterCreatePath(flowWork, errors);
7620
8760
  validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
8761
+ validateFlowTemplateStartConditionalJump(flowWork, errors);
8762
+ validateFlowTemplateApproveActionShape(flowWork, errors);
8763
+ validateFlowTemplatePluginRejectionControl(flowWork, errors);
8764
+ validateFlowTemplateStandardConditionEditorRules(flowWork, errors);
7621
8765
  validateFlowTemplateCodeModeMessages(flowWork, errors);
7622
8766
  validateFlowTemplateRuntimeScripts(flowWork, errors);
7623
8767
  validateFlowTemplateFeishuChatPlugin(flowWork, errors);
@@ -7689,7 +8833,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7689
8833
  const expectedConfirm2 = `submit ${domain} ${id}`;
7690
8834
  if (confirm3 !== expectedConfirm2) {
7691
8835
  return {
7692
- dry_run: true,
8836
+ ...dryRunFields(expectedConfirm2),
7693
8837
  domain,
7694
8838
  id,
7695
8839
  endpoint: endpoint2,
@@ -7719,7 +8863,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7719
8863
  throw new Error(`workspace-flow submit verification failed; missing bindings: ${missingBindings.map((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key)).join(", ")}`);
7720
8864
  }
7721
8865
  return {
7722
- dry_run: false,
8866
+ ...executedFields(),
7723
8867
  domain,
7724
8868
  id,
7725
8869
  endpoint: endpoint2,
@@ -7757,7 +8901,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7757
8901
  await ensureConfigCapability(profile, `${definition.capability}.export`);
7758
8902
  if (confirm3 !== expectedConfirm2) {
7759
8903
  return {
7760
- dry_run: true,
8904
+ ...dryRunFields(expectedConfirm2),
7761
8905
  domain,
7762
8906
  id,
7763
8907
  endpoint: "/workspace",
@@ -7773,14 +8917,15 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7773
8917
  { data: submit2.payload, capability: `${definition.capability}.create` }
7774
8918
  );
7775
8919
  const readback3 = await readRemoteConfigDomain(profile, domain, `key:${workspaceKey}`, definition);
8920
+ const createdId = responseDataId(response3) ?? (isRecord3(readback3) ? readback3.id ?? null : null);
7776
8921
  return {
7777
- dry_run: false,
8922
+ ...executedFields(),
7778
8923
  domain,
7779
- id,
8924
+ ...standardConfigWriteResponse({ domain, id, executedId: createdId, payload: submit2.payload, response: response3, readback: readback3 }),
7780
8925
  endpoint: "/workspace",
7781
8926
  method: "POST",
7782
8927
  response: response3,
7783
- created_id: responseDataId(response3) ?? (isRecord3(readback3) ? readback3.id ?? null : null),
8928
+ created_id: createdId,
7784
8929
  readback_hash: hashJson(readback3)
7785
8930
  };
7786
8931
  }
@@ -7801,7 +8946,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7801
8946
  const endpoint2 = `/workspace/${encodeURIComponent(workspaceId)}`;
7802
8947
  if (confirm3 !== expectedConfirm2) {
7803
8948
  return {
7804
- dry_run: true,
8949
+ ...dryRunFields(expectedConfirm2),
7805
8950
  domain,
7806
8951
  id,
7807
8952
  endpoint: endpoint2,
@@ -7820,9 +8965,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7820
8965
  );
7821
8966
  const readback2 = await readRemoteConfigDomain(profile, domain, workspaceKey ? `key:${workspaceKey}` : workspaceId, definition);
7822
8967
  return {
7823
- dry_run: false,
8968
+ ...executedFields(),
7824
8969
  domain,
7825
- id,
8970
+ ...standardConfigWriteResponse({ domain, id, payload: submit2.payload, response: response2, readback: readback2 }),
7826
8971
  endpoint: endpoint2,
7827
8972
  method: "PUT",
7828
8973
  response: response2,
@@ -7872,7 +9017,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7872
9017
  }
7873
9018
  if (confirm3 !== expectedConfirm2) {
7874
9019
  return {
7875
- dry_run: true,
9020
+ ...dryRunFields(expectedConfirm2),
7876
9021
  domain,
7877
9022
  id,
7878
9023
  operation_plan: submit2.payload,
@@ -7882,7 +9027,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7882
9027
  };
7883
9028
  }
7884
9029
  return {
7885
- dry_run: false,
9030
+ ...executedFields(),
7886
9031
  domain,
7887
9032
  id,
7888
9033
  ...domain === "role" ? await submitRoleOperations(profile, id, submit2) : await submitAggregateConfigDomain(profile, domain, id, submit2)
@@ -7919,6 +9064,14 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7919
9064
  if (domain === "list-template") {
7920
9065
  validateListTemplateActionGate(submit.payload);
7921
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
+ }
7922
9075
  if (domain === "dataset-field") {
7923
9076
  validateDatasetFieldCreatePayload(submit.payload);
7924
9077
  }
@@ -7926,7 +9079,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7926
9079
  const expectedConfirm2 = `submit ${domain} ${id}`;
7927
9080
  if (confirm3 !== expectedConfirm2) {
7928
9081
  return {
7929
- dry_run: true,
9082
+ ...dryRunFields(expectedConfirm2),
7930
9083
  domain,
7931
9084
  id,
7932
9085
  endpoint: definition.createPath,
@@ -7953,9 +9106,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7953
9106
  }
7954
9107
  }
7955
9108
  return {
7956
- dry_run: false,
9109
+ ...executedFields(),
7957
9110
  domain,
7958
- id,
9111
+ ...standardConfigWriteResponse({ domain, id, executedId: createdId ?? null, payload: submit.payload, response: response2 }),
7959
9112
  created_id: createdId ?? null,
7960
9113
  endpoint: definition.createPath,
7961
9114
  method: definition.createMethod,
@@ -7969,6 +9122,10 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7969
9122
  validateFlowTemplateRemoteTemplateRefs(submit.payload);
7970
9123
  validateFlowTemplateProjectAfterCreatePath(submit.payload);
7971
9124
  validateFlowTemplateStandardPageCreateFormTemplate(submit.payload);
9125
+ validateFlowTemplateStartConditionalJump(submit.payload);
9126
+ validateFlowTemplateApproveActionShape(submit.payload);
9127
+ validateFlowTemplatePluginRejectionControl(submit.payload);
9128
+ validateFlowTemplateStandardConditionEditorRules(submit.payload);
7972
9129
  validateFlowTemplateCodeModeMessages(submit.payload);
7973
9130
  validateFlowTemplateRuntimeScripts(submit.payload);
7974
9131
  validateFlowTemplateFeishuChatPlugin(submit.payload);
@@ -7986,13 +9143,21 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7986
9143
  if (domain === "list-template") {
7987
9144
  validateListTemplateActionGate(submit.payload);
7988
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
+ }
7989
9154
  if (domain === "form-template" && submitMode === "create") {
7990
9155
  await ensureConfigCapability(profile, `${definition.capability}.create`);
7991
9156
  const expectedConfirm2 = `submit ${domain} ${id}`;
7992
9157
  const endpoint2 = "/form_template";
7993
9158
  if (confirm3 !== expectedConfirm2) {
7994
9159
  return {
7995
- dry_run: true,
9160
+ ...dryRunFields(expectedConfirm2),
7996
9161
  domain,
7997
9162
  id,
7998
9163
  endpoint: endpoint2,
@@ -8033,9 +9198,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
8033
9198
  { capability: `${definition.capability}.export` }
8034
9199
  );
8035
9200
  return {
8036
- dry_run: false,
9201
+ ...executedFields(),
8037
9202
  domain,
8038
- id,
9203
+ ...standardConfigWriteResponse({ domain, id, executedId: publishedId, payload: submit.payload, response: publishResponse2, readback: publishedReadback }),
8039
9204
  endpoint: endpoint2,
8040
9205
  method: "POST",
8041
9206
  response: response2,
@@ -8077,7 +9242,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
8077
9242
  }
8078
9243
  if (confirm3 !== expectedConfirm) {
8079
9244
  return {
8080
- dry_run: true,
9245
+ ...dryRunFields(expectedConfirm),
8081
9246
  domain,
8082
9247
  id,
8083
9248
  endpoint,
@@ -8107,9 +9272,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
8107
9272
  }
8108
9273
  const readback = await readBackConfigDomain(profile, domain, id, definition);
8109
9274
  return {
8110
- dry_run: false,
9275
+ ...executedFields(),
8111
9276
  domain,
8112
- id,
9277
+ ...standardConfigWriteResponse({ domain, id, payload: submitPayload, response }),
8113
9278
  endpoint,
8114
9279
  method: definition.submitMethod,
8115
9280
  ...publishMode ? { publish_mode: publishMode } : {},
@@ -8203,7 +9368,7 @@ async function runDatasetLifecycleAction(config, profile, action, id, confirm3)
8203
9368
  ];
8204
9369
  if (confirm3 !== expectedConfirm) {
8205
9370
  return {
8206
- dry_run: true,
9371
+ ...dryRunFields(expectedConfirm),
8207
9372
  domain: "dataset",
8208
9373
  id,
8209
9374
  action: commandAction,
@@ -8229,15 +9394,186 @@ async function runDatasetLifecycleAction(config, profile, action, id, confirm3)
8229
9394
  }
8230
9395
  const readback = await readRemoteConfigDomain(profile, "dataset", id, definition);
8231
9396
  return {
8232
- dry_run: false,
9397
+ ...executedFields(),
8233
9398
  domain: "dataset",
8234
9399
  id,
8235
9400
  action: commandAction,
8236
9401
  operations: executableOperations,
8237
9402
  operation_responses: responses,
9403
+ readback_hash: hashJson(readback),
9404
+ readback_hint: configReadbackHint("dataset", id),
8238
9405
  readback
8239
9406
  };
8240
9407
  }
9408
+ function normalizeConfigBatchItems(manifest) {
9409
+ if (Array.isArray(manifest)) {
9410
+ return manifest.map((raw) => ({ raw, item: isRecord3(raw) ? raw : null }));
9411
+ }
9412
+ if (!isRecord3(manifest)) {
9413
+ throw new Error("config batch manifest must be a JSON object or array.");
9414
+ }
9415
+ const items = manifest.operations ?? manifest.items ?? manifest.rows;
9416
+ if (!Array.isArray(items)) {
9417
+ throw new Error("config batch manifest requires operations, items, or rows array.");
9418
+ }
9419
+ return items.map((raw) => ({ raw, item: isRecord3(raw) ? raw : null }));
9420
+ }
9421
+ function assertBatchItemDomain(domain) {
9422
+ if (typeof domain !== "string" || !Object.prototype.hasOwnProperty.call(CONFIG_DOMAINS, domain)) {
9423
+ throw new Error(`config batch item requires a supported domain, got ${String(domain)}.`);
9424
+ }
9425
+ return domain;
9426
+ }
9427
+ async function writeOptionalBatchResponse(file, value) {
9428
+ if (typeof file !== "string" || !file.trim()) {
9429
+ return null;
9430
+ }
9431
+ await writeJsonFile(file, value);
9432
+ return file;
9433
+ }
9434
+ async function runConfigBatchSubmit(config, profile, manifestFile, options = {}) {
9435
+ const manifest = await readJsonFile(manifestFile);
9436
+ const items = normalizeConfigBatchItems(manifest);
9437
+ const results = [];
9438
+ for (let index = 0; index < items.length; index += 1) {
9439
+ const batchItem = items[index];
9440
+ const item = batchItem.item;
9441
+ if (!item) {
9442
+ const result = {
9443
+ ok: false,
9444
+ index,
9445
+ domain: null,
9446
+ id: "",
9447
+ action: "submit",
9448
+ error: "config batch submit item must be a JSON object."
9449
+ };
9450
+ results.push(result);
9451
+ if (!options.continueOnError) break;
9452
+ continue;
9453
+ }
9454
+ let domain = null;
9455
+ let id = "";
9456
+ try {
9457
+ domain = assertBatchItemDomain(item.domain);
9458
+ id = typeof item.id === "string" ? item.id : "";
9459
+ const payload = typeof item.payload === "string" ? item.payload : "";
9460
+ if (!id || !payload) {
9461
+ throw new Error("config batch submit item requires id and payload.");
9462
+ }
9463
+ const response = await submitConfigDomain(config, profile, domain, id, payload, item.confirm);
9464
+ const executed = !isRecord3(response) || response.operation_executed !== false && response.dry_run !== true;
9465
+ const result = executed ? {
9466
+ ok: true,
9467
+ index,
9468
+ domain,
9469
+ id,
9470
+ action: "submit",
9471
+ response
9472
+ } : {
9473
+ ok: false,
9474
+ index,
9475
+ domain,
9476
+ id,
9477
+ action: "submit",
9478
+ error: `config batch submit item did not execute; confirm_required=${String(isRecord3(response) ? response.required_confirm ?? response.expected_confirm ?? "" : "")}`,
9479
+ response
9480
+ };
9481
+ results.push(result);
9482
+ await writeOptionalBatchResponse(item.response_out, result);
9483
+ if (!result.ok && !options.continueOnError) break;
9484
+ } catch (error) {
9485
+ const result = {
9486
+ ok: false,
9487
+ index,
9488
+ domain,
9489
+ id,
9490
+ action: "submit",
9491
+ error: error instanceof Error ? error.message : String(error || "")
9492
+ };
9493
+ results.push(result);
9494
+ await writeOptionalBatchResponse(item.response_out, result);
9495
+ if (!options.continueOnError) break;
9496
+ }
9497
+ }
9498
+ const failures = results.filter((item) => item.ok === false);
9499
+ return {
9500
+ ok: failures.length === 0,
9501
+ manifest_file: manifestFile,
9502
+ action: "submit",
9503
+ continue_on_error: Boolean(options.continueOnError),
9504
+ total: items.length,
9505
+ completed: results.length,
9506
+ succeeded: results.length - failures.length,
9507
+ failed: failures.length,
9508
+ results
9509
+ };
9510
+ }
9511
+ async function runConfigBatchReadback(config, profile, manifestFile, options = {}) {
9512
+ const manifest = await readJsonFile(manifestFile);
9513
+ const items = normalizeConfigBatchItems(manifest);
9514
+ const results = [];
9515
+ for (let index = 0; index < items.length; index += 1) {
9516
+ const batchItem = items[index];
9517
+ const item = batchItem.item;
9518
+ if (!item) {
9519
+ const result = {
9520
+ ok: false,
9521
+ index,
9522
+ domain: null,
9523
+ id: "",
9524
+ action: "readback",
9525
+ error: "config batch readback item must be a JSON object."
9526
+ };
9527
+ results.push(result);
9528
+ if (!options.continueOnError) break;
9529
+ continue;
9530
+ }
9531
+ let domain = null;
9532
+ let id = "";
9533
+ try {
9534
+ domain = assertBatchItemDomain(item.domain);
9535
+ id = typeof item.id === "string" ? item.id : "";
9536
+ if (!id) {
9537
+ throw new Error("config batch readback item requires id.");
9538
+ }
9539
+ const response = await readbackConfigDomain(config, profile, domain, id);
9540
+ const result = {
9541
+ ok: true,
9542
+ index,
9543
+ domain,
9544
+ id,
9545
+ action: "readback",
9546
+ response
9547
+ };
9548
+ results.push(result);
9549
+ await writeOptionalBatchResponse(item.response_out, result);
9550
+ } catch (error) {
9551
+ const result = {
9552
+ ok: false,
9553
+ index,
9554
+ domain,
9555
+ id,
9556
+ action: "readback",
9557
+ error: error instanceof Error ? error.message : String(error || "")
9558
+ };
9559
+ results.push(result);
9560
+ await writeOptionalBatchResponse(item.response_out, result);
9561
+ if (!options.continueOnError) break;
9562
+ }
9563
+ }
9564
+ const failures = results.filter((item) => item.ok === false);
9565
+ return {
9566
+ ok: failures.length === 0,
9567
+ manifest_file: manifestFile,
9568
+ action: "readback",
9569
+ continue_on_error: Boolean(options.continueOnError),
9570
+ total: items.length,
9571
+ completed: results.length,
9572
+ succeeded: results.length - failures.length,
9573
+ failed: failures.length,
9574
+ results
9575
+ };
9576
+ }
8241
9577
 
8242
9578
  // src/core/config-workspace.ts
8243
9579
  import { mkdir as mkdir6, readFile as readFile9, writeFile as writeFile6 } from "fs/promises";
@@ -8316,13 +9652,12 @@ function renderConfigWorkspaceGuide(options) {
8316
9652
  ([directory, purpose]) => `| \`${directory}\` | ${purpose} |`
8317
9653
  ).join("\n");
8318
9654
  return `${start}
8319
- # BPMAX \u914D\u7F6E\u5DE5\u4F5C\u533A\uFF1A${display(options.env)}
9655
+ # BPMAX \u914D\u7F6E\u76EE\u5F55\uFF1A${display(options.env)}
8320
9656
 
8321
9657
  ## \u73AF\u5883
8322
9658
  - Profile: \`${display(options.profileName)}\`
8323
9659
  - Env: \`${display(options.env)}\`
8324
9660
  - BPMAX: \`${display(options.environment.bpmax_base_url || options.profile.origin)}\`
8325
- - Workspace: \`${display(options.environment.workspace || options.profile.workspace)}\`
8326
9661
  - sysconfigdiff: \`${display(options.environment.sysconfigdiff_base_url)}\`
8327
9662
  - sysconfig user: \`${display(options.environment.username)}\`
8328
9663
  - secrets: \`[REDACTED]\`
@@ -8333,8 +9668,20 @@ ${configEnabled ? "" : "> \u5F53\u524D profile \u7684 API Key \u5C1A\u672A\u5F00
8333
9668
  | --- | --- |
8334
9669
  ${directoryRows}
8335
9670
 
9671
+ ## \u672C\u5730\u6587\u4EF6\u7EA6\u5B9A
9672
+ - \u4E34\u65F6\u6587\u4EF6\u3001\u5BFC\u51FA\u7684 work\u3001submit payload\u3001\u622A\u56FE\u3001diff \u548C proof \u90FD\u5199\u5230 \`.codex/tmp/\` \u4E0B\uFF1B\u4E0D\u8981\u5728\u4ED3\u5E93\u6839\u76EE\u5F55\u6216 \`think_*/\` \u76EE\u5F55\u65C1\u6563\u843D ad-hoc \u4E34\u65F6\u6587\u4EF6\u3002
9673
+ - \`think_*/\` \u76EE\u5F55\u662F sysconfigdiff \u62C9\u53D6\u7684\u672C\u5730\u955C\u50CF\u3002\u76EE\u5F55\u540D\u5E38\u7528 \`key'value___key2'value2\` \u5F62\u5F0F\uFF0C\u5355\u5F15\u53F7\u662F\u76EE\u5F55\u540D\u7684\u5B57\u9762\u5B57\u7B26\uFF0C\u4E0D\u662F shell \u5F15\u53F7\uFF1B\u811A\u672C\u5904\u7406\u8DEF\u5F84\u65F6\u5FC5\u987B\u6309\u666E\u901A\u6587\u4EF6\u540D\u5904\u7406\u3002
9674
+ - \u5E38\u89C1\u6587\u4EF6\u5F62\u6001\uFF1A
9675
+ - \`configuration\` \u662F\u914D\u7F6E\u5143\u6570\u636E\uFF0C\`configuration.content\` \u662F\u5B9E\u9645\u914D\u7F6E\u5185\u5BB9\u3002
9676
+ - \`flow\` \u662F\u6D41\u7A0B\u5143\u6570\u636E\uFF0C\`flow.data\` \u53CA \`flow.data.*\` \u4F34\u968F\u6587\u4EF6\u627F\u8F7D\u8282\u70B9\u3001\u6761\u4EF6\u3001\u811A\u672C\u548C\u6D88\u606F\u6A21\u677F\u7B49\u6D41\u7A0B\u903B\u8F91\u3002
9677
+ - \`data_set\` \u662F\u6570\u636E\u96C6\u5143\u6570\u636E\uFF0C\`data_set.*_script\`\u3001\`data_set.post_es_mapping\` \u662F\u6570\u636E\u5904\u7406\u811A\u672C\u548C ES \u6620\u5C04\u3002
9678
+ - \u5982\u679C\u672C\u5730\u955C\u50CF\u548C\u7EBF\u4E0A typed export/readback \u4E0D\u4E00\u81F4\uFF0C\u4EE5\u7EBF\u4E0A typed export/readback \u4E3A\u51C6\uFF1B\u672C\u5730\u955C\u50CF\u53EA\u80FD\u7528\u4E8E\u5B9A\u4F4D\u3001\u5BF9\u7167\u548C\u7406\u89E3\u5386\u53F2\u7ED3\u6784\u3002
9679
+
8336
9680
  ## \u5F3A\u5236\u89C4\u5219
9681
+ - \u5F53\u524D\u76EE\u5F55\u7ED1\u5B9A Profile\uFF1A\`${display(options.profileName)}\`\u3002\u5728\u5F53\u524D\u76EE\u5F55\u6267\u884C\u7684\u6240\u6709 \`bpmax-cli\` \u547D\u4EE4\u90FD\u5FC5\u987B\u663E\u5F0F\u4F7F\u7528 \`--profile ${profileArg}\`\uFF1B\u4E0D\u5F97\u7701\u7565 profile\u3001\u4E0D\u5F97\u4F9D\u8D56\u5168\u5C40 \`current_profile\`\uFF0C\u4E5F\u4E0D\u5F97\u5207\u6362\u5230\u5176\u5B83\u73AF\u5883/profile\u3002
9682
+ - \u4FEE\u6539 BPMAX \u914D\u7F6E\u5FC5\u987B\u5148\u8BFB\u53D6\u5E76\u9075\u5B88\u5BF9\u5E94\u7684 BPMAX \u914D\u7F6E Skill\uFF0C\u4F8B\u5982 \`bpmax-flow-template-editor\`\u3001\`bpmax-form-template-editor\`\u3001\`bpmax-list-template-editor\`\u3001\`bpmax-nav-config-editor\` \u7B49\uFF1B\u4E0D\u5F97\u8131\u79BB Skill \u81EA\u884C\u5224\u65AD\u914D\u7F6E\u7ED3\u6784\u3002
8337
9683
  - \u914D\u7F6E\u5199\u64CD\u4F5C\u53EA\u80FD\u4F7F\u7528 typed CLI\uFF1A\`${commandPrefix3} config <domain> submit\`\uFF1B\u63D2\u4EF6\u914D\u7F6E\u53EA\u80FD\u4F7F\u7528 \`${commandPrefix3} config plugin <domain> submit\`\u3002
9684
+ - \u4E0D\u5F97\u76F4\u63A5\u7F16\u8F91 \`think_*/\` \u76EE\u5F55\u4E2D\u7684\u914D\u7F6E\u6587\u4EF6\u6765\u5B8C\u6210\u7EBF\u4E0A\u914D\u7F6E\u4FEE\u6539\uFF1B\u8FD9\u4E9B\u6587\u4EF6\u53EA\u80FD\u4F5C\u4E3A\u53EA\u8BFB\u955C\u50CF\u3001diff \u4F9D\u636E\u6216 skill/typed CLI \u7684\u8F93\u5165\u53C2\u8003\u3002\u9700\u8981\u4FEE\u6539\u65F6\u5FC5\u987B\u8D70 export -> work -> lint -> build -> dry-run -> confirm submit -> verify -> \u9875\u9762\u9A8C\u6536\u95ED\u73AF\u3002
8338
9685
  - \u5982\u679C CLI \u63D0\u793A\u7F3A\u5C11 capability\u3001\u5F53\u524D profile \u672A\u5F00\u542F\u914D\u7F6E\u80FD\u529B\uFF0C\u6216\u672A\u6765\u65B0\u589E domain \u5C1A\u672A\u8FDB\u5165 adapter \u77E9\u9635 / \`config plugin adapters\`\uFF0C\u5FC5\u987B\u505C\u6B62\u8FDC\u7AEF\u5199\u5165\uFF1B\u4E0D\u5F97\u624B\u5199 raw API\u3002
8339
9686
  - \u7981\u6B62\u7528 \`bpmax-cli api\`\u3001curl\u3001\u9875\u9762 fetch\u3001\u9875\u9762 axios \u6216\u65E7 submit \u811A\u672C\u76F4\u63A5\u5199\u914D\u7F6E\u3002
8340
9687
  - \u63D0\u4EA4\u524D\u5FC5\u987B\u5B8C\u6210 export\u3001work \u4FEE\u6539\u3001lint\u3001build\u3001dry-run\u3001\u7CBE\u786E \`--confirm\`\u3001verify \u548C\u9875\u9762\u9A8C\u6536\u3002
@@ -8346,17 +9693,17 @@ ${directoryRows}
8346
9693
  ${rows}
8347
9694
  | \u63D2\u4EF6 typed config | \u63D2\u4EF6\u4E13\u9879 skill | \`${commandPrefix3} config plugin <domain> ...\` |
8348
9695
  | \u6700\u65B0\u914D\u7F6E\u540C\u6B65 | \`bpmax-config-latest\` | \`${commandPrefix3} config latest pull ${options.env}\` |
8349
- | \u957F\u671F\u8BB0\u5FC6 | \`bpmax-memory-protocol\` | \`${commandPrefix3} memory search --scope all --query "<workspace> <flow_type> <task>"\` |
9696
+ | \u957F\u671F\u8BB0\u5FC6 | \`bpmax-memory-protocol\` | \`${commandPrefix3} memory search --scope all --query "<env> <flow_type> <task>"\` |
8350
9697
  | \u5B8C\u6574\u914D\u7F6E\u7F16\u6392 | \`bpmax-e2e-flow-config-orchestrator\` | \u6309\u7F16\u6392 Skill \u6267\u884C |
8351
9698
  | \u7AEF\u5230\u7AEF\u56DE\u5F52 | \`bpmax-e2e-flow-test-operator\` | \u6309\u56DE\u5F52 Skill \u6267\u884C |
8352
9699
 
8353
9700
  ## \u6807\u51C6\u95ED\u73AF
8354
9701
  \`\`\`bash
8355
9702
  ${commandPrefix3} config <domain> export --id <id> --profile ${profileArg}
8356
- ${commandPrefix3} config <domain> lint --work <work-file>
9703
+ ${commandPrefix3} config <domain> lint --work <work-file> --profile ${profileArg}
8357
9704
  # build/submit must use typed CLI and an enabled config capability.
8358
9705
  # If capability is missing or the domain is not listed by config adapters, stop before remote writes.
8359
- ${commandPrefix3} config <domain> build --work <work-file> --meta <meta-file> --out <submit-file>
9706
+ ${commandPrefix3} config <domain> build --work <work-file> --meta <meta-file> --out <submit-file> --profile ${profileArg}
8360
9707
  ${commandPrefix3} config <domain> submit --id <id> --payload <submit-file> --profile ${profileArg}
8361
9708
  ${commandPrefix3} config <domain> submit --id <id> --payload <submit-file> --profile ${profileArg} --confirm "submit <domain> <id>"
8362
9709
  ${commandPrefix3} config <domain> verify --id <id> --expect <work-file> --profile ${profileArg}
@@ -8386,17 +9733,19 @@ ${commandPrefix3} config latest pull ${envArg} --profile ${profileArg} --format
8386
9733
  \`\`\`
8387
9734
 
8388
9735
  ## Memory \u4F7F\u7528\u89C4\u5219
8389
- \u5F00\u59CB\u914D\u7F6E\u3001\u6392\u67E5\u6216\u6D4B\u8BD5\u524D\uFF0C\u5148\u8C03\u7528 \`bpmax-memory-protocol\` \u6216\u76F4\u63A5\u641C\u7D22 BPMAX memory\u3002\u67E5\u8BE2\u8BCD\u81F3\u5C11\u5305\u542B\u4E1A\u52A1\u540D\u3001workspace\u3001flow_type\u3001\u6A21\u677F/\u6570\u636E\u96C6/\u5BF9\u8C61 id \u548C\u76EE\u6807\u52A8\u4F5C\u3002
9736
+ \u5F00\u59CB\u914D\u7F6E\u3001\u6392\u67E5\u6216\u6D4B\u8BD5\u524D\uFF0C\u5982\u679C\u5F53\u524D\u76EE\u5F55\u5B58\u5728 \`MEMORY.md\`\uFF0C\u5FC5\u987B\u5148\u8BFB\u53D6\u5E76\u53C2\u8003\u5176\u4E2D\u4E0E\u672C\u6B21\u5BF9\u8C61\u76F8\u5173\u7684\u5386\u53F2\u51B3\u7B56\u3001\u53CD\u6A21\u5F0F\u3001\u73AF\u5883\u7EA6\u675F\u548C\u672A\u5B8C\u6210\u72B6\u6001\uFF1B\u4E0D\u8981\u53EA\u4F9D\u8D56\u5BF9\u8BDD\u4E0A\u4E0B\u6587\u3002
9737
+
9738
+ \u540C\u65F6\u8C03\u7528 \`bpmax-memory-protocol\` \u6216\u76F4\u63A5\u641C\u7D22 BPMAX memory\u3002\u67E5\u8BE2\u8BCD\u81F3\u5C11\u5305\u542B\u73AF\u5883\u540D\u3001\u4E1A\u52A1\u540D\u3001flow_type\u3001\u6A21\u677F/\u6570\u636E\u96C6/\u5BF9\u8C61 id \u548C\u76EE\u6807\u52A8\u4F5C\uFF1B\u4E0D\u8981\u628A BPMAX \`w:...\` \u5DE5\u4F5C\u533A\u5F53\u6210\u914D\u7F6E\u8303\u56F4\u8FB9\u754C\u3002
8390
9739
 
8391
9740
  \`\`\`bash
8392
9741
  ${commandPrefix3} memory status --profile ${profileArg} --format json
8393
- ${commandPrefix3} memory search --profile ${profileArg} --scope all --query "${display(options.environment.workspace || options.profile.workspace)} <flow_type> <task>" --format json
9742
+ ${commandPrefix3} memory search --profile ${profileArg} --scope all --query "${display(options.env)} <flow_type> <task>" --format json
8394
9743
  \`\`\`
8395
9744
 
8396
- \u9A8C\u8BC1\u901A\u8FC7\u540E\uFF0C\u53EA\u5199\u53EF\u590D\u7528\u7ED3\u8BBA\uFF1A\`decision\`\u3001\`task_learning\`\u3001\`anti_pattern\`\u3001\`environmental\` \u6216 \`convention\`\u3002\u672A\u5B8C\u6210\u6216\u4E2D\u65AD\u6001\u53EA\u5199 \`session_state\`\u3002\u7981\u6B62\u5199\u5165 API Key\u3001Authorization\u3001token\u3001password\u3001\u9A8C\u8BC1\u7801\u3001\u624B\u673A\u53F7\u3001\u5B8C\u6574 payload \u6216\u5927\u6BB5\u63A5\u53E3\u54CD\u5E94\u3002
9745
+ \u9A8C\u8BC1\u901A\u8FC7\u540E\uFF0C\u53EA\u5199\u53EF\u590D\u7528\u7ED3\u8BBA\uFF1A\`decision\`\u3001\`task_learning\`\u3001\`anti_pattern\`\u3001\`environmental\` \u6216 \`convention\`\u3002\u672A\u5B8C\u6210\u6216\u4E2D\u65AD\u6001\u53EA\u5199 \`session_state\`\u3002\u5982\u679C\u672C\u5730 \`MEMORY.md\` \u5B58\u5728\uFF0C\u4E5F\u8981\u628A\u672C\u6B21\u53EF\u590D\u7528\u7ED3\u8BBA\u6216\u4E2D\u65AD\u72B6\u6001\u8865\u5165\u5176\u4E2D\uFF0C\u4FDD\u6301\u548C\u8FDC\u7AEF memory \u53E3\u5F84\u4E00\u81F4\u3002\u7981\u6B62\u5199\u5165 API Key\u3001Authorization\u3001token\u3001password\u3001\u9A8C\u8BC1\u7801\u3001\u624B\u673A\u53F7\u3001\u5B8C\u6574 payload \u6216\u5927\u6BB5\u63A5\u53E3\u54CD\u5E94\u3002
8397
9746
 
8398
9747
  \`\`\`bash
8399
- ${commandPrefix3} memory add --profile ${profileArg} --scope user --text "<learning>" --metadata '{"type":"task_learning","project_id":"bpmax","workspace":"${display(options.environment.workspace || options.profile.workspace)}"}' --format json
9748
+ ${commandPrefix3} memory add --profile ${profileArg} --scope user --text "<learning>" --metadata '{"type":"task_learning","project_id":"bpmax","env":"${display(options.env)}"}' --format json
8400
9749
  \`\`\`
8401
9750
  ${end}
8402
9751
  `;
@@ -9872,7 +11221,24 @@ function registerConfigCommands(program2) {
9872
11221
  };
9873
11222
  registerFlowAppContextCommand("context");
9874
11223
  registerFlowAppContextCommand("inspect");
9875
- 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) => {
9876
11242
  const configData = await loadConfig();
9877
11243
  const resolved = resolveProfile(configData, options.profile);
9878
11244
  const result = await createFlowAppFromWork(
@@ -9884,7 +11250,8 @@ function registerConfigCommands(program2) {
9884
11250
  {
9885
11251
  workspace: options.workspace,
9886
11252
  name: options.name,
9887
- publishLive: !options.draftOnly
11253
+ publishLive: !options.draftOnly,
11254
+ agent: options.agent
9888
11255
  }
9889
11256
  );
9890
11257
  await writeResponseOut(options.responseOut, result);
@@ -9932,6 +11299,25 @@ function registerConfigCommands(program2) {
9932
11299
  await saveConfig(configData);
9933
11300
  printResult(options.format, result);
9934
11301
  });
11302
+ const batch = config.command("batch").description("Run guarded typed config operations from a manifest");
11303
+ batch.command("submit").description("Submit typed config payloads from a batch manifest and keep per-row evidence").requiredOption("--manifest <file>", "Batch manifest JSON file").option("--profile <profile>", "Profile name").option("--continue-on-error", "Continue after a row fails and return a final failed summary").option("--format <format>", "Output format", "json").action(async (options) => {
11304
+ const configData = await loadConfig();
11305
+ const resolved = resolveProfile(configData, options.profile);
11306
+ const result = await runConfigBatchSubmit(configData, resolved, options.manifest, {
11307
+ continueOnError: Boolean(options.continueOnError)
11308
+ });
11309
+ await saveConfig(configData);
11310
+ printResult(options.format, result);
11311
+ });
11312
+ batch.command("readback").description("Read back typed config objects from a batch manifest and keep per-row evidence").requiredOption("--manifest <file>", "Batch manifest JSON file").option("--profile <profile>", "Profile name").option("--continue-on-error", "Continue after a row fails and return a final failed summary").option("--format <format>", "Output format", "json").action(async (options) => {
11313
+ const configData = await loadConfig();
11314
+ const resolved = resolveProfile(configData, options.profile);
11315
+ const result = await runConfigBatchReadback(configData, resolved, options.manifest, {
11316
+ continueOnError: Boolean(options.continueOnError)
11317
+ });
11318
+ await saveConfig(configData);
11319
+ printResult(options.format, result);
11320
+ });
9935
11321
  Object.keys(CONFIG_DOMAINS).forEach((domain) => {
9936
11322
  const domainCommand = domain === "workspace" ? workspace.description("Initialize local sysconfig workspaces and manage BPMAX workspace configuration") : config.command(domain).description(`Manage BPMAX ${domain} configuration`);
9937
11323
  const createCommand = domainCommand.command("create").description(domain === "flow-template" ? "Create a new main flow template through the typed adapter" : `Create a ${domain} config object through a verified typed adapter; dry-run unless --confirm is exact`).option("--profile <profile>", "Profile name").option("--confirm <text>", "Exact confirmation text").option("--publish-live", "For flow-template, publish the created flow to live after saving draft").option("--response-out <file>", "Write the full JSON response to a file").option("--format <format>", "Output format", "pretty");
@@ -9977,15 +11363,13 @@ function registerConfigCommands(program2) {
9977
11363
  const resolved = resolveProfile(configData, options.profile);
9978
11364
  const workFormat = options.workFormat === "structured" ? "structured" : "raw";
9979
11365
  const result = await exportConfigDomain(configData, resolved, domain, options.id, options.out, { workFormat });
9980
- if (domain === "flow-template" && (options.summary || options.inline)) {
9981
- const workFile = typeof result.work_file === "string" ? result.work_file : void 0;
9982
- const work = workFile ? await readJsonFile(workFile) : void 0;
9983
- if (options.summary) {
9984
- result.summary = summarizeFlowTemplateWork(work);
9985
- }
9986
- if (options.inline) {
9987
- result.work = work;
9988
- }
11366
+ const workFile = typeof result.work_file === "string" ? result.work_file : void 0;
11367
+ const work = (options.inline || domain === "flow-template" && options.summary) && workFile ? await readJsonFile(workFile) : void 0;
11368
+ if (domain === "flow-template" && options.summary) {
11369
+ result.summary = summarizeFlowTemplateWork(work);
11370
+ }
11371
+ if (options.inline) {
11372
+ result.work = work;
9989
11373
  }
9990
11374
  await saveConfig(configData);
9991
11375
  printResult(options.format, result);
@@ -10066,6 +11450,29 @@ function registerConfigCommands(program2) {
10066
11450
  printResult(options.format, result);
10067
11451
  });
10068
11452
  if (domain === "dataset") {
11453
+ const relationFields = domainCommand.command("relation-fields").description("Manage dataset relationFields through the typed dataset adapter");
11454
+ relationFields.command("submit").description("Submit dataset relationFields payload with the standard dataset evidence response").requiredOption("--id <id>", "Remote dataset id").requiredOption("--payload <file>", "Submit payload JSON file produced by config dataset build").option("--profile <profile>", "Profile name").option("--confirm <text>", "Exact confirmation text").option("--response-out <file>", "Write the full JSON response to a file").option("--format <format>", "Output format", "pretty").action(async (options) => {
11455
+ const configData = await loadConfig();
11456
+ const resolved = resolveProfile(configData, options.profile);
11457
+ const result = await submitConfigDomain(
11458
+ configData,
11459
+ resolved,
11460
+ "dataset",
11461
+ options.id,
11462
+ options.payload,
11463
+ options.confirm
11464
+ );
11465
+ await saveConfig(configData);
11466
+ await writeResponseOut(options.responseOut, result);
11467
+ printResult(options.format, result);
11468
+ });
11469
+ relationFields.command("readback").description("Read back dataset relationFields evidence using the unified readback shape").requiredOption("--id <id>", "Remote dataset id").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (options) => {
11470
+ const configData = await loadConfig();
11471
+ const resolved = resolveProfile(configData, options.profile);
11472
+ const result = await readbackConfigDomain(configData, resolved, "dataset", options.id);
11473
+ await saveConfig(configData);
11474
+ printResult(options.format, result);
11475
+ });
10069
11476
  [
10070
11477
  ["publish", "Publish/start a dataset and trigger ES batch generation"],
10071
11478
  ["pause", "Pause a published or pending dataset"],
@@ -12133,6 +13540,156 @@ function registerInitCommand(program2, deps = {}) {
12133
13540
  });
12134
13541
  }
12135
13542
 
13543
+ // src/commands/issue.ts
13544
+ import { readFile as readFile12 } from "fs/promises";
13545
+
13546
+ // src/core/issues.ts
13547
+ import axios7, { AxiosHeaders as AxiosHeaders3 } from "axios";
13548
+ var DEFAULT_GITLAB_URL = "https://gitlab.yitaiyitai.com";
13549
+ var DEFAULT_GITLAB_PROJECT = "bpmax/bpmax-cli";
13550
+ function normalizeBaseUrl2(baseUrl = DEFAULT_GITLAB_URL) {
13551
+ const normalized = baseUrl.trim().replace(/\/+$/g, "");
13552
+ if (!normalized) {
13553
+ throw new Error("GitLab base URL is required.");
13554
+ }
13555
+ return normalized;
13556
+ }
13557
+ function normalizeGitLabProject(project = DEFAULT_GITLAB_PROJECT) {
13558
+ const normalized = project.trim().replace(/^\/+|\/+$/g, "");
13559
+ if (!normalized) {
13560
+ throw new Error("GitLab project is required.");
13561
+ }
13562
+ return normalized;
13563
+ }
13564
+ function gitLabProjectApiPath(project = DEFAULT_GITLAB_PROJECT) {
13565
+ return encodeURIComponent(normalizeGitLabProject(project));
13566
+ }
13567
+ function buildGitLabIssuePayload(input) {
13568
+ const title = input.title.trim();
13569
+ if (!title) {
13570
+ throw new Error("Issue title is required.");
13571
+ }
13572
+ const description = input.description?.trim();
13573
+ const labels = (input.labels || []).map((label) => label.trim()).filter(Boolean);
13574
+ const assigneeIds = (input.assigneeIds || []).filter((id) => Number.isInteger(id) && id > 0);
13575
+ return {
13576
+ title,
13577
+ ...description ? { description } : {},
13578
+ ...labels.length > 0 ? { labels: labels.join(",") } : {},
13579
+ ...assigneeIds.length > 0 ? { assignee_ids: assigneeIds } : {},
13580
+ ...input.confidential !== void 0 ? { confidential: input.confidential } : {}
13581
+ };
13582
+ }
13583
+ function resolveGitLabToken(options) {
13584
+ const env = options.env || process.env;
13585
+ const candidates = [
13586
+ options.tokenEnv ? env[options.tokenEnv] : void 0,
13587
+ env.GITLAB_TOKEN,
13588
+ env.GL_TOKEN,
13589
+ env.PRIVATE_TOKEN,
13590
+ "-1pFevGtvjq4fXSxzZJQ"
13591
+ ];
13592
+ const token = candidates.find((candidate) => candidate?.trim());
13593
+ if (!token) {
13594
+ const envHint = options.tokenEnv ? options.tokenEnv : "GITLAB_TOKEN";
13595
+ throw new Error(`GitLab token is required. Set ${envHint}.`);
13596
+ }
13597
+ return token.trim();
13598
+ }
13599
+ async function createGitLabIssue(input, options) {
13600
+ const token = options.token.trim();
13601
+ if (!token) {
13602
+ throw new Error("GitLab token is required.");
13603
+ }
13604
+ const baseUrl = normalizeBaseUrl2(options.baseUrl);
13605
+ const projectPath = gitLabProjectApiPath(options.project);
13606
+ const client = options.client || axios7.create({ baseURL: baseUrl });
13607
+ const headers = AxiosHeaders3.from();
13608
+ headers.set("PRIVATE-TOKEN", token);
13609
+ const response = await client.request({
13610
+ method: "POST",
13611
+ url: `/api/v4/projects/${projectPath}/issues`,
13612
+ headers,
13613
+ data: buildGitLabIssuePayload(input)
13614
+ });
13615
+ return response.data;
13616
+ }
13617
+
13618
+ // src/commands/issue.ts
13619
+ async function readDescription(options) {
13620
+ if (options.descriptionFile && options.description) {
13621
+ throw new Error("Use either --description or --description-file, not both.");
13622
+ }
13623
+ if (!options.descriptionFile) {
13624
+ return options.description;
13625
+ }
13626
+ return readFile12(options.descriptionFile, "utf8");
13627
+ }
13628
+ function parseAssigneeIds(values) {
13629
+ return (values || []).flatMap(
13630
+ (value) => value.split(",").map((part) => {
13631
+ const parsed = Number(part.trim());
13632
+ if (!Number.isInteger(parsed) || parsed <= 0) {
13633
+ throw new Error(`Invalid assignee id: ${part}`);
13634
+ }
13635
+ return parsed;
13636
+ })
13637
+ );
13638
+ }
13639
+ async function buildIssueInput(options) {
13640
+ return {
13641
+ title: options.title,
13642
+ description: await readDescription(options),
13643
+ labels: options.label || [],
13644
+ assigneeIds: parseAssigneeIds(options.assigneeId),
13645
+ confidential: options.confidential
13646
+ };
13647
+ }
13648
+ function prettyCreatedIssue(issue3) {
13649
+ return issue3.web_url;
13650
+ }
13651
+ function registerIssueCommands(program2, deps = {}) {
13652
+ const createIssue = deps.createIssue || createGitLabIssue;
13653
+ const issue3 = program2.command("issue").description("Report bugs and create GitLab issues for bpmax-cli");
13654
+ const registerCreateLike = (name) => {
13655
+ 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) => {
13656
+ const input = await buildIssueInput(options);
13657
+ const payload = buildGitLabIssuePayload(input);
13658
+ const project = options.project || DEFAULT_GITLAB_PROJECT;
13659
+ const gitlabUrl = options.gitlabUrl || DEFAULT_GITLAB_URL;
13660
+ if (options.dryRun) {
13661
+ printResult(options.format, {
13662
+ ok: true,
13663
+ dry_run: true,
13664
+ gitlab_url: gitlabUrl,
13665
+ project,
13666
+ payload
13667
+ });
13668
+ return;
13669
+ }
13670
+ const token = resolveGitLabToken({
13671
+ tokenEnv: options.tokenEnv,
13672
+ env: deps.env
13673
+ });
13674
+ const created = await createIssue(input, {
13675
+ baseUrl: gitlabUrl,
13676
+ project,
13677
+ token
13678
+ });
13679
+ if (options.format === "pretty") {
13680
+ printResult("pretty", prettyCreatedIssue(created));
13681
+ return;
13682
+ }
13683
+ printResult(options.format, {
13684
+ ok: true,
13685
+ issue: created
13686
+ });
13687
+ });
13688
+ };
13689
+ registerCreateLike("create");
13690
+ registerCreateLike("report");
13691
+ }
13692
+
12136
13693
  // src/commands/memory.ts
12137
13694
  function parseLimit(input, fallback) {
12138
13695
  const value = Number(input ?? fallback);
@@ -12213,7 +13770,7 @@ function registerMemoryCommands(program2) {
12213
13770
  }
12214
13771
 
12215
13772
  // src/commands/matrix.ts
12216
- import { readFile as readFile12 } from "fs/promises";
13773
+ import { readFile as readFile13 } from "fs/promises";
12217
13774
  var UUID_VALUE_PATTERN2 = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/i;
12218
13775
  var UUID_PATH_PATTERN = /uuid'[^'"\s/]+/i;
12219
13776
  async function parseSeedRules(input) {
@@ -12221,7 +13778,7 @@ async function parseSeedRules(input) {
12221
13778
  if (source === "") {
12222
13779
  throw new Error("--rules file path is empty.");
12223
13780
  }
12224
- const raw = source ? await readFile12(source, "utf8") : input;
13781
+ const raw = source ? await readFile13(source, "utf8") : input;
12225
13782
  let parsed;
12226
13783
  try {
12227
13784
  parsed = JSON.parse(raw);
@@ -12951,7 +14508,8 @@ async function printCreateFormHandoff(client, format, profile, flowIdentifiers,
12951
14508
  const agentWarning = [
12952
14509
  "Agent must reply with the full create form URL exactly as provided.",
12953
14510
  'Use the Markdown link text "\u586B\u5199\u8868\u5355" and the complete URL from reply_markdown/url/pc_url.',
12954
- "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."
12955
14513
  ].join(" ");
12956
14514
  printResult(format, {
12957
14515
  handoff: true,
@@ -12965,11 +14523,16 @@ async function printCreateFormHandoff(client, format, profile, flowIdentifiers,
12965
14523
  ...prefill ? {
12966
14524
  prefill_token: prefill.token,
12967
14525
  prefill_expires_in: prefill.expires_in,
12968
- prefill_expires_at: prefill.expires_at
14526
+ prefill_expires_at: prefill.expires_at,
14527
+ prefill_status: "token_generated"
12969
14528
  } : {
14529
+ prefill_status: "fallback_init_value",
12970
14530
  prefill_fallback: "init_value",
12971
14531
  ...prefillError ? { prefill_error: prefillError } : {}
12972
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.",
12973
14536
  init_value: initValue,
12974
14537
  init_value_keys: Object.keys(options.form),
12975
14538
  prefill_context: prefillContext,
@@ -13066,7 +14629,7 @@ function isRiskyFormField(field) {
13066
14629
  const type = field.type?.toLowerCase() ?? "";
13067
14630
  const label = field.label?.toLowerCase() ?? "";
13068
14631
  const key = field.key.toLowerCase();
13069
- return /(serial|sequence|auto[_-]?number|auto[_-]?no|流水|编号)/.test(`${type} ${label} ${key}`) || /(plugin_|selector|upload|rich[_-]?text|editor|relation[_-]?project|relation[_-]?form|associated[_-]?form|sub[_-]?form|table)/.test(type);
14632
+ return type === "sn_number" || /(serial|sequence|auto[_-]?number|auto[_-]?no|流水|编号)/.test(`${type} ${label} ${key}`) || /(plugin_|selector|upload|rich[_-]?text|editor|relation[_-]?project|relation[_-]?form|associated[_-]?form|sub[_-]?form|table)/.test(type);
13070
14633
  }
13071
14634
  function collectHandoffReasons(fields, template) {
13072
14635
  const reasons = /* @__PURE__ */ new Set();
@@ -13534,7 +15097,7 @@ import { spawn as spawn2 } from "child_process";
13534
15097
  import { fileURLToPath as fileURLToPath3 } from "url";
13535
15098
 
13536
15099
  // src/core/recipes.ts
13537
- import { access, mkdir as mkdir10, readdir as readdir4, readFile as readFile13, writeFile as writeFile10 } from "fs/promises";
15100
+ import { access, mkdir as mkdir10, readdir as readdir4, readFile as readFile14, writeFile as writeFile10 } from "fs/promises";
13538
15101
  import path11 from "path";
13539
15102
  var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
13540
15103
  var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
@@ -13616,7 +15179,7 @@ function parseRecipeDefinition(input) {
13616
15179
  };
13617
15180
  }
13618
15181
  async function loadRecipe(recipeDir) {
13619
- const raw = await readFile13(path11.join(recipeDir, "recipe.json"), "utf8");
15182
+ const raw = await readFile14(path11.join(recipeDir, "recipe.json"), "utf8");
13620
15183
  return parseRecipeDefinition(JSON.parse(raw));
13621
15184
  }
13622
15185
  async function listRecipes(recipesDir) {
@@ -13715,7 +15278,7 @@ async function renderArgv(options) {
13715
15278
  const rendered = [];
13716
15279
  for (const token of options.recipe.command.argv) {
13717
15280
  if (token.startsWith("@")) {
13718
- const raw = await readFile13(resolveRecipeFile(options.recipeDir, token), "utf8");
15281
+ const raw = await readFile14(resolveRecipeFile(options.recipeDir, token), "utf8");
13719
15282
  rendered.push(renderTemplate(raw, options.variables));
13720
15283
  } else {
13721
15284
  rendered.push(renderTemplate(token, options.variables));
@@ -14173,7 +15736,7 @@ function registerSetupCommand(program2, deps = {}) {
14173
15736
  }
14174
15737
 
14175
15738
  // src/core/taskbook.ts
14176
- import { mkdir as mkdir11, readFile as readFile14, writeFile as writeFile11 } from "fs/promises";
15739
+ import { mkdir as mkdir11, readFile as readFile15, writeFile as writeFile11 } from "fs/promises";
14177
15740
  import path12 from "path";
14178
15741
  var TaskbookError = class extends Error {
14179
15742
  };
@@ -14381,7 +15944,7 @@ function addUuidIssues(text5, issues, path15) {
14381
15944
  }
14382
15945
  }
14383
15946
  async function readTaskbookText(file) {
14384
- const raw = await readFile14(file, "utf8");
15947
+ const raw = await readFile15(file, "utf8");
14385
15948
  try {
14386
15949
  const parsed = JSON.parse(raw);
14387
15950
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
@@ -15031,12 +16594,13 @@ import {
15031
16594
  cp as cp3,
15032
16595
  mkdir as mkdir12,
15033
16596
  readdir as readdir5,
15034
- readFile as readFile15,
16597
+ readFile as readFile16,
15035
16598
  rm as rm4,
15036
16599
  stat as stat6,
15037
16600
  writeFile as writeFile12
15038
16601
  } from "fs/promises";
15039
16602
  import path13 from "path";
16603
+ import { inflateSync } from "zlib";
15040
16604
  var DEFAULT_SUITE_ROOT = ".ai_test/suite";
15041
16605
  var DEFAULT_DRAFT_ROOT = ".ai_test/suite_draft";
15042
16606
  var DEFAULT_REPORT_ROOT = ".ai_test/report";
@@ -15089,6 +16653,7 @@ var CONFIG_BASIS_ALLOWED_PREFIXES = [
15089
16653
  ".codex/skills/"
15090
16654
  ];
15091
16655
  var REPORT_REQUIRED_KEYS = ["run_id:", "scenario_id:", "source_suite:", "result:"];
16656
+ var REPORT_EXECUTION_KEYS = ["planned_cases:", "executed_cases:", "precondition_check:", "state_file:", "report_run:", "browser_tool:", "rerun_policy:"];
15092
16657
  var REPORT_REQUIRED_HEADINGS = [
15093
16658
  "## 1. \u6D4B\u8BD5\u8303\u56F4",
15094
16659
  "## 2. \u6267\u884C\u73AF\u5883",
@@ -15106,18 +16671,38 @@ var ID_AS_ENTRY_RE = /(发起表单|处理表单|表单模板|数据集|列表
15106
16671
  var URL_RE = /https?:\/\/|\/w:[^\s,,;;]+|\/project\?|\/project_detail\/|\/projectContinue\?/;
15107
16672
  var SHA_RE = /^[0-9a-f]{40}$/;
15108
16673
  var CONFIG_BASIS_REASON_RE = /(依据|覆盖|校验|验证|对应|因为|reason=|why=|=>|->)/;
15109
- var PREP_TOKEN_RE = /(账号|入口|样本|准备操作|预期|主数据|权限|自动化|依赖流程|清理策略|绑定解析|定位规则|模拟用户)=/g;
16674
+ var PREP_TOKEN_RE = /(账号|入口|样本|准备操作|预期|主数据|权限|自动化|依赖流程|清理策略|绑定解析|定位规则|模拟用户|precondition_check|browser_tool|live_draft|state_file|report_run|login_profile|mock_user|unmock_done|resume_policy)=/g;
15110
16675
  var TEST_DATA_TOKEN_RE = /(业务场景|业务逻辑|样本数据|合理性|客户口径|数据约束)=/g;
15111
16676
  var GENERIC_SAMPLE_VALUE_RE = /(^|[=,;,\s])(sample|test|mock|demo|xxx|todo|tbd|placeholder|随便|假数据|占位|待补)(?=$|[,;,\s])/i;
15112
16677
  var SENSITIVE_TEST_DATA_RE = /authorization|bearer\s+[A-Za-z0-9._-]+|cookie|set-cookie|api[-_]?key|token|password|passwd|pwd|secret|session|验证码|手机号|\b1[3-9]\d{9}\b/i;
15113
16678
  var RAW_PAYLOAD_TEST_DATA_RE = /(^|[;;]\s*)(payload|完整payload|request|请求体|headers?)\s*=/i;
15114
16679
  var PLACEHOLDER_RE = /<[^>]+>/;
16680
+ var CASE_CONTENT_GARBLED_RE = /\uFFFD|�|Ã.|Â.|â[€\u0080-\u00BF]|锛|鈥|乱码|���|\?\?\?/i;
16681
+ var HOLLOW_CASE_TEXT_RE = /(^|[=,;,\s])(todo|tbd|xxx|placeholder|占位|待补|随便写|后补|暂无|无具体步骤|略)(?=$|[,;,\s])/i;
15115
16682
  var IMAGE_RE = /!\[[^\]]*]\(([^)]+)\)/g;
15116
16683
  var YBS_NONZERO_DETAIL_RE = /https:\/\/yaditest\.yitaiyitai\.com\/w:ybs\/project_detail\/(?!0\/)\d+\//;
15117
16684
  var YBS_PC_CREATE_WRONG_RE = /https:\/\/yaditest\.yitaiyitai\.com\/w:ybs\/pages\/projectCreate\/projectCreate\?flow_type=/;
15118
16685
  var IDENTITY_MOCK_CASE_RE = /(非处理人|越权|只读|多角色|角色隔离|无权限|低权限|unauthorized|limited|readonly|permission)/;
15119
16686
  var IDENTITY_MOCK_VALUE_RE = /(mock|模拟).*(unmock|退出模拟|恢复)|bpmax-user-mock-operator/;
15120
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|复用模板|可复用|首次运行沉淀|沉淀模板/;
16688
+ var ERROR_CAPTURE_CASE_RE = /(negative|boundary|异常|错误|失败|报错|重复|无效|非法|invalid|error|扫码.*(异常|错误|无效)|错误\s*SN|异常\s*SN|无效\s*SN)/i;
16689
+ var ERROR_CAPTURE_EVIDENCE_RE = /(expected_error_text|error_capture_required|错误提示|提示文案|报错文案|toast|校验文案).*(screenshot|截图)|截图.*(错误提示|提示文案|报错文案|toast|校验文案)/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;
16692
+ var LIVE_DRAFT_RE = /(live|draft|已发布|草稿|发布态|live_draft=)/i;
16693
+ var MULTI_ROLE_VALUE_RE = /[,、/]\s*[^,、/\s]+|多角色|跨角色/;
16694
+ var RESUME_POLICY_VALUE_RE = /(full_rerun|checkpoint|evidence_only|从头重跑|检查点|仅补证据)/i;
16695
+ var FULL_RERUN_RE = /(full_rerun|重新运行|全量重跑|从头重跑)/i;
16696
+ var PARTIAL_RERUN_RE = /(checkpoint|evidence_only|检查点|仅补证据)/i;
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;
16700
+ var NOT_RUN_RE = /(not[_ -]?run|未执行|未跑|跳过)/i;
16701
+ var BLOCKED_RE = /(blocked|阻塞|卡住|无法继续)/i;
16702
+ var PASS_CASE_RE = /\b(pass|passed|success|通过)\b|(^|[||,,;;\s])通过($|[||,,;;\s])/i;
16703
+ var HISTORICAL_EVIDENCE_RE = /(历史|旧报告|旧截图|旧结果|旧状态|复用.*(报告|截图|结果|状态)|historical|old report|old screenshot|old result|reused)/i;
16704
+ var PAGE_CONCLUSION_RE = /(页面.*(通过|已验证|真实|可见|不可见)|浏览器回归.*(通过|完成)|完整链路.*通过|真实页面.*通过)/;
16705
+ var API_ONLY_PASS_EVIDENCE_RE = /(接口回读|readback|缓存命中|cache hit|status matrix|状态矩阵|接口一致|API\s*(验证|通过|evidence))/i;
15121
16706
  var TestSuiteError = class extends Error {
15122
16707
  code;
15123
16708
  rule_id;
@@ -15140,7 +16725,7 @@ async function exists3(filePath) {
15140
16725
  }
15141
16726
  }
15142
16727
  async function readText(filePath) {
15143
- return readFile15(filePath, "utf8");
16728
+ return readFile16(filePath, "utf8");
15144
16729
  }
15145
16730
  function fail(message, options = {}) {
15146
16731
  throw new TestSuiteError(message, options);
@@ -15390,6 +16975,87 @@ function hasE2eReusableAsset(row) {
15390
16975
  const evidencePlan = [row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
15391
16976
  return E2E_REUSABLE_ASSET_RE.test(evidencePlan);
15392
16977
  }
16978
+ function validateReadableCaseContent(filePath, caseId, row) {
16979
+ for (const field of ["title", "preconditions", "config_basis", "prep_data", "steps", "expected_result", "test_data"]) {
16980
+ const value = row[field].trim();
16981
+ if (!value) continue;
16982
+ if (CASE_CONTENT_GARBLED_RE.test(value)) {
16983
+ fail(`${filePath}:${caseId}: \`${field}\` \u5305\u542B\u4E71\u7801\u6216\u5F02\u5E38\u7F16\u7801\u7247\u6BB5\uFF1Bpromote \u524D\u5FC5\u987B\u4FEE\u590D\u6587\u672C\u7F16\u7801`, { rule_id: "test_suite.case.content_garbled" });
16984
+ }
16985
+ if (HOLLOW_CASE_TEXT_RE.test(value)) {
16986
+ fail(`${filePath}:${caseId}: \`${field}\` \u5305\u542B\u7A7A\u6D1E\u5360\u4F4D\u5185\u5BB9\uFF1B\u5FC5\u987B\u5199\u6E05\u53EF\u6267\u884C\u4E1A\u52A1\u6B65\u9AA4\u548C\u9884\u671F\u7ED3\u679C`, { rule_id: "test_suite.case.content_hollow" });
16987
+ }
16988
+ }
16989
+ if (row.steps.trim().length < 12 || !/[>;;。]|打开|点击|填写|选择|提交|等待|截图|校验|验证/.test(row.steps)) {
16990
+ fail(`${filePath}:${caseId}: \`steps\` \u5FC5\u987B\u662F\u53EF\u8BFB\u3001\u53EF\u6267\u884C\u7684\u6B65\u9AA4\uFF0C\u4E0D\u80FD\u662F\u4E00\u53E5\u6CDB\u6CDB\u5907\u6CE8`, { rule_id: "test_suite.case.content_steps" });
16991
+ }
16992
+ }
16993
+ function validatePreflightEvidence(filePath, caseId, row, prepTokens) {
16994
+ if (!prepTokens.precondition_check) {
16995
+ fail(`${filePath}:${caseId}: \`prep_data\` \u5FC5\u987B\u5305\u542B \`precondition_check=\`\uFF0C\u5426\u5219\u53EA\u80FD\u8FDB\u5165\u51C6\u5907\u9636\u6BB5\uFF0C\u4E0D\u80FD\u5F00\u59CB\u6B63\u5F0F E2E \u6267\u884C`, { rule_id: "test_suite.case.precondition_check" });
16996
+ }
16997
+ if (!prepTokens.browser_tool || !BROWSER_TOOL_RE.test(prepTokens.browser_tool)) {
16998
+ fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E\u6D4F\u89C8\u5668\u5DE5\u5177\u8BC1\u636E\uFF0C\u4F8B\u5982 \`browser_tool=Chrome DevTools\` \u6216 AppleScript fallback`, { rule_id: "test_suite.case.browser_tool" });
16999
+ }
17000
+ if (!prepTokens.live_draft || !LIVE_DRAFT_RE.test(prepTokens.live_draft)) {
17001
+ fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E\u672C\u8F6E\u76EE\u6807\u662F live \u53D1\u5E03\u6001\u8FD8\u662F draft \u8349\u7A3F\u6001`, { rule_id: "test_suite.case.live_draft" });
17002
+ }
17003
+ if (!prepTokens.state_file && !prepTokens.report_run) {
17004
+ fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E .codex/tmp/e2e_states \u72B6\u6001\u6587\u4EF6\u6216 .ai_test/report/<run> \u62A5\u544A\u8BC1\u636E\u8DEF\u5F84`, { rule_id: "test_suite.case.state_file" });
17005
+ }
17006
+ const policy = prepTokens.resume_policy;
17007
+ if (!policy || !RESUME_POLICY_VALUE_RE.test(policy)) {
17008
+ fail(`${filePath}:${caseId}: \u6B63\u5F0F E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E \`resume_policy=full_rerun|checkpoint|evidence_only\`\uFF1B\u9ED8\u8BA4\u91CD\u65B0\u8FD0\u884C\u5FC5\u987B\u4F7F\u7528 full_rerun`, { rule_id: "test_suite.case.resume_policy_required" });
17009
+ }
17010
+ if (policy && PARTIAL_RERUN_RE.test(policy) && !/(边界|范围|局部|检查点|仅补证据|用户确认|只验证|scope|boundary|confirmed)/i.test([row.prep_data, row.steps, row.expected_result, row.evidence_required].join(" "))) {
17011
+ fail(`${filePath}:${caseId}: checkpoint/evidence_only \u5FC5\u987B\u5199\u6E05\u5C40\u90E8\u8FB9\u754C\uFF0C\u5386\u53F2\u8BC1\u636E\u4E0D\u5F97\u4F5C\u4E3A\u672C\u8F6E\u901A\u8FC7\u7ED3\u8BBA`, { rule_id: "test_suite.case.resume_policy_boundary" });
17012
+ }
17013
+ for (const [token, value] of Object.entries({ state_file: prepTokens.state_file, report_run: prepTokens.report_run })) {
17014
+ if (!value) continue;
17015
+ const markers = reportRunMarkers(value).filter((marker) => !/<run_id>|<date>|\{run_id\}|\{date\}|\$RUN_ID|\$RUN_DATE/i.test(value));
17016
+ if (markers.length > 0 && !value.includes("<run_id>") && !value.includes("<date>")) {
17017
+ fail(`${filePath}:${caseId}: \`${token}=\` \u4E0D\u5F97\u5199\u6B7B\u5386\u53F2 run/date\uFF1B\u8BF7\u4F7F\u7528\u672C\u8F6E <run_id>/<date> \u6A21\u677F\u6216\u6267\u884C\u65F6\u751F\u6210\u7684\u65B0\u8DEF\u5F84`, { rule_id: "test_suite.case.current_run_template" });
17018
+ }
17019
+ }
17020
+ }
17021
+ function validateErrorCaptureEvidence(filePath, caseId, row) {
17022
+ const caseText = [row.type, row.title, row.preconditions, row.steps, row.expected_result, row.tags].join(" ");
17023
+ if (!ERROR_CAPTURE_CASE_RE.test(caseText)) return;
17024
+ const evidenceText = [row.prep_data, row.steps, row.expected_result, row.evidence_required].join(" ");
17025
+ if (!ERROR_CAPTURE_EVIDENCE_RE.test(evidenceText)) {
17026
+ fail(`${filePath}:${caseId}: \u8D1F\u5411/\u9519\u8BEF\u63D0\u793A\u7528\u4F8B\u5FC5\u987B\u5305\u542B expected_error_text \u6216 error_capture_required\uFF0C\u5E76\u8981\u6C42\u771F\u5B9E\u63D0\u793A\u6587\u6848\u622A\u56FE`, { rule_id: "test_suite.case.error_capture" });
17027
+ }
17028
+ }
17029
+ function validateResumePolicy(filePath, caseId, row, prepTokens) {
17030
+ const manualText = [row.preconditions, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
17031
+ if (!/(人工介入|手工|补救|续跑|dirty_resumed|局部复核|partial rerun)/i.test(manualText)) return;
17032
+ const text5 = [row.preconditions, row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
17033
+ const policy = prepTokens.resume_policy || text5;
17034
+ if (!RESUME_POLICY_VALUE_RE.test(policy)) {
17035
+ fail(`${filePath}:${caseId}: \u4EBA\u5DE5\u4ECB\u5165\u6216\u7EED\u8DD1\u7528\u4F8B\u5FC5\u987B\u58F0\u660E \`resume_policy=full_rerun|checkpoint|evidence_only\``, { rule_id: "test_suite.case.resume_policy" });
17036
+ }
17037
+ if (!/dirty_resumed|局部复核|partial|从头重跑|检查点/.test(text5)) {
17038
+ fail(`${filePath}:${caseId}: \u4EBA\u5DE5\u4ECB\u5165\u6216\u7EED\u8DD1\u7528\u4F8B\u5FC5\u987B\u6807\u8BB0 dirty_resumed\uFF0C\u6216\u660E\u786E\u8BF4\u660E\u5C40\u90E8/\u5B8C\u6574\u91CD\u8DD1\u8303\u56F4`, { rule_id: "test_suite.case.resume_scope" });
17039
+ }
17040
+ }
17041
+ function validateMultiRoleEvidence(filePath, caseId, row, prepTokens) {
17042
+ const text5 = [row.roles, row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
17043
+ if (!MULTI_ROLE_VALUE_RE.test(row.roles) && !/多角色|跨角色/.test(text5)) return;
17044
+ if (!prepTokens.login_profile) {
17045
+ fail(`${filePath}:${caseId}: \u591A\u89D2\u8272 E2E \u7528\u4F8B\u5FC5\u987B\u8BB0\u5F55\u6BCF\u4E2A\u89D2\u8272\u7684 login_profile`, { rule_id: "test_suite.case.multi_role_login_profile" });
17046
+ }
17047
+ const hasMockUser = Boolean(prepTokens.mock_user) || /bpmax-user-mock-operator|mock_user|模拟用户.*[=,,]/i.test(text5);
17048
+ if (!hasMockUser) {
17049
+ fail(`${filePath}:${caseId}: \u591A\u89D2\u8272 E2E \u7528\u4F8B\u5FC5\u987B\u8BB0\u5F55 mock_user \u6216 bpmax-user-mock-operator\uFF0C\u8BF4\u660E\u5982\u4F55\u5207\u6362\u8EAB\u4EFD`, { rule_id: "test_suite.case.multi_role_mock_user" });
17050
+ }
17051
+ const hasUnmock = Boolean(prepTokens.unmock_done) || /unmock|退出模拟|恢复身份|恢复管理员/i.test(text5);
17052
+ if (!hasUnmock) {
17053
+ fail(`${filePath}:${caseId}: \u591A\u89D2\u8272 E2E \u7528\u4F8B\u5FC5\u987B\u8BB0\u5F55 unmock_done\uFF0C\u8BF4\u660E\u6D4B\u8BD5\u7ED3\u675F\u540E\u5982\u4F55\u6062\u590D\u539F\u59CB\u8EAB\u4EFD`, { rule_id: "test_suite.case.multi_role_unmock" });
17054
+ }
17055
+ if (!/(分别截图|独立截图|每个角色|separate evidence|per-role|角色证据)/i.test(text5)) {
17056
+ fail(`${filePath}:${caseId}: \u591A\u89D2\u8272 E2E \u7528\u4F8B\u5FC5\u987B\u8981\u6C42\u6BCF\u4E2A\u89D2\u8272\u5355\u72EC\u6D4F\u89C8\u5668\u8BC1\u636E\uFF0C\u4E0D\u80FD\u590D\u7528\u622A\u56FE`, { rule_id: "test_suite.case.multi_role_screenshot" });
17057
+ }
17058
+ }
15393
17059
  function bootstrapActionForCase(row) {
15394
17060
  const rawText = [row.title, row.prep_data, row.steps, row.evidence_required, row.tags].join(" ");
15395
17061
  const text5 = rawText.toLowerCase();
@@ -15409,6 +17075,7 @@ async function validateCase(filePath, row, seen) {
15409
17075
  if (!caseId) fail(`${filePath}: case_id is required`);
15410
17076
  if (seen.has(caseId)) fail(`${filePath}: duplicate case_id \`${caseId}\``);
15411
17077
  seen.add(caseId);
17078
+ validateReadableCaseContent(filePath, caseId, row);
15412
17079
  for (const field of ["title", "config_basis", "steps", "expected_result", "status", "updated_at"]) {
15413
17080
  if (!row[field].trim()) fail(`${filePath}:${caseId}: \`${field}\` is required`);
15414
17081
  }
@@ -15452,6 +17119,10 @@ async function validateCase(filePath, row, seen) {
15452
17119
  if (UUID_RE2.test(browserText)) fail(`${filePath}:${caseId}: browser-executed cases must not use UUID as the execution entrypoint`);
15453
17120
  if (YBS_NONZERO_DETAIL_RE.test(browserText)) fail(`${filePath}:${caseId}: YBS detail URLs must use /w:ybs/project_detail/0/<project_id> unless verified otherwise`);
15454
17121
  if (YBS_PC_CREATE_WRONG_RE.test(browserText)) fail(`${filePath}:${caseId}: YBS PC create URLs must use /w:ybs/project/create?flow_type=<flow_type>`);
17122
+ validatePreflightEvidence(filePath, caseId, row, prepTokens);
17123
+ validateErrorCaptureEvidence(filePath, caseId, row);
17124
+ validateResumePolicy(filePath, caseId, row, prepTokens);
17125
+ validateMultiRoleEvidence(filePath, caseId, row, prepTokens);
15455
17126
  validateBusinessTestData(filePath, caseId, row);
15456
17127
  }
15457
17128
  async function collectE2eAccelerationGaps(root) {
@@ -15595,10 +17266,10 @@ async function fileMap(root) {
15595
17266
  return result;
15596
17267
  }
15597
17268
  async function sha256(filePath) {
15598
- return createHash6("sha256").update(await readFile15(filePath)).digest("hex");
17269
+ return createHash6("sha256").update(await readFile16(filePath)).digest("hex");
15599
17270
  }
15600
17271
  async function readForDiff(filePath) {
15601
- const buffer = await readFile15(filePath);
17272
+ const buffer = await readFile16(filePath);
15602
17273
  if (buffer.includes(0)) return [`<binary sha256=${createHash6("sha256").update(buffer).digest("hex")}>
15603
17274
  `];
15604
17275
  return buffer.toString("utf8").split(/(?<=\n)/);
@@ -15900,12 +17571,269 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
15900
17571
  await mkdir12(path13.join(reportDir, "screenshots"), { recursive: true });
15901
17572
  await writeFile12(
15902
17573
  path13.join(reportDir, "summary.md"),
15903
- ["# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B", "", `run_id: ${path13.basename(reportDir)}`, "status: draft", "", "## \u573A\u666F\u62A5\u544A", "", "## \u603B\u7ED3", ""].join("\n"),
17574
+ [
17575
+ "# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B",
17576
+ "",
17577
+ `run_id: ${path13.basename(reportDir)}`,
17578
+ "rerun_policy: full_rerun",
17579
+ "status: draft",
17580
+ "",
17581
+ "## \u573A\u666F\u62A5\u544A",
17582
+ "",
17583
+ "## \u622A\u56FE\u76EE\u5F55",
17584
+ "",
17585
+ `screenshots: ${path13.join(path13.basename(reportDir), "screenshots")}`,
17586
+ "",
17587
+ "## \u603B\u7ED3",
17588
+ ""
17589
+ ].join("\n"),
15904
17590
  "utf8"
15905
17591
  );
15906
17592
  }
15907
17593
  return reportDir;
15908
17594
  }
17595
+ function reportKeyValue(text5, key) {
17596
+ const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17597
+ const match = new RegExp(`^${escaped}[ \\t]*(.+)$`, "im").exec(text5);
17598
+ return match?.[1]?.trim() ?? "";
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
+ }
17774
+ function reportCaseList(text5, key) {
17775
+ const value = reportKeyValue(text5, key);
17776
+ return value.split(/[,\s,、;;]+/).map((item) => item.trim()).filter((item) => /^[A-Za-z0-9_-]+$/.test(item));
17777
+ }
17778
+ function reportRunDate(runName) {
17779
+ return runName.slice(0, 8);
17780
+ }
17781
+ function reportKeyValues(text5, key) {
17782
+ const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17783
+ return [...text5.matchAll(new RegExp(`^${escaped}[ \\t]*(.+)$`, "gim"))].map((match) => match[1]?.trim() ?? "").filter(Boolean);
17784
+ }
17785
+ function reportRunMarkers(value) {
17786
+ return [...value.matchAll(RUN_MARKER_RE)].map((match) => match[0]);
17787
+ }
17788
+ function reportContainsHistoricalRun(value, runName) {
17789
+ const runDate = reportRunDate(runName);
17790
+ return reportRunMarkers(value).some((marker) => marker !== runName && marker !== runDate);
17791
+ }
17792
+ function parseReportTime(value) {
17793
+ if (!value.trim()) return null;
17794
+ const date = new Date(value.trim());
17795
+ if (Number.isNaN(date.getTime())) return null;
17796
+ return date;
17797
+ }
17798
+ function reportDayWindow(runName) {
17799
+ const date = reportRunDate(runName);
17800
+ const start = /* @__PURE__ */ new Date(`${date.slice(0, 4)}-${date.slice(4, 6)}-${date.slice(6, 8)}T00:00:00+08:00`);
17801
+ const end = new Date(start.getTime() + 24 * 60 * 60 * 1e3);
17802
+ return { start, end };
17803
+ }
17804
+ function reportExecutionWindow(runName, text5) {
17805
+ const fallback = reportDayWindow(runName);
17806
+ const startedAt = parseReportTime(reportKeyValue(text5, "started_at:"));
17807
+ const finishedAt = parseReportTime(reportKeyValue(text5, "finished_at:"));
17808
+ if (!startedAt || !finishedAt || finishedAt < startedAt) return fallback;
17809
+ return { start: startedAt, end: finishedAt };
17810
+ }
17811
+ function isWithinWindow(date, window) {
17812
+ return date >= window.start && date <= window.end;
17813
+ }
17814
+ function caseEvidencePattern(caseId) {
17815
+ const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17816
+ return new RegExp(`\\b${escaped}\\b.*?(screenshots/|\\.ai_test/report/|\\.codex/tmp/e2e|evidence|\u622A\u56FE|\u8BC1\u636E|\u9879\u76EE|project|step)`, "i");
17817
+ }
17818
+ function caseResultPattern(caseId) {
17819
+ const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17820
+ return new RegExp(`\\b${escaped}\\b[^\\n]*(pass|passed|success|\u901A\u8FC7)`, "i");
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
+ }
17832
+ function linesForCase(text5, caseId) {
17833
+ const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17834
+ const pattern = new RegExp(`\\b${escaped}\\b`);
17835
+ return text5.split(/\r?\n/).filter((line) => pattern.test(line));
17836
+ }
15909
17837
  async function lintReport(root = DEFAULT_REPORT_ROOT) {
15910
17838
  if (!await exists3(root)) return [`report root not found: ${root}`];
15911
17839
  const errors = [];
@@ -15922,12 +17850,87 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
15922
17850
  for (const reportName of scenarioReports) {
15923
17851
  const reportPath = path13.join(runDir, reportName);
15924
17852
  const text5 = await readText(reportPath);
15925
- for (const key of REPORT_REQUIRED_KEYS) if (!text5.includes(key)) errors.push(`${reportPath}: missing \`${key}\``);
17853
+ for (const key of REPORT_REQUIRED_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
17854
+ for (const key of REPORT_EXECUTION_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
15926
17855
  for (const heading of REPORT_REQUIRED_HEADINGS) if (!text5.includes(heading)) errors.push(`${reportPath}: missing \`${heading}\``);
15927
- const imageRefs = [...text5.matchAll(IMAGE_RE)].map((match) => match[1]);
15928
- if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
17856
+ const runId = reportKeyValue(text5, "run_id:");
17857
+ if (runId && runId !== runName) {
17858
+ errors.push(`[test_suite.report.run_id_current] ${reportPath}: run_id \u5FC5\u987B\u7B49\u4E8E\u62A5\u544A\u76EE\u5F55\u540D ${runName}\uFF0C\u4E0D\u80FD\u590D\u7528\u5176\u4ED6 run \u7684\u62A5\u544A\u5934`);
17859
+ }
17860
+ const rerunPolicy = reportKeyValue(text5, "rerun_policy:") || reportKeyValue(text5, "resume_policy:");
17861
+ const isFullRerun = FULL_RERUN_RE.test(rerunPolicy) || /重新运行|全量重跑|从头重跑/.test(text5);
17862
+ const isPartialRerun = PARTIAL_RERUN_RE.test(rerunPolicy);
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
+ }
17867
+ if (isPartialRerun && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|对照/.test(resultValue)) {
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`);
17869
+ }
17870
+ const plannedCases = reportCaseList(text5, "planned_cases:");
17871
+ const executedCases = reportCaseList(text5, "executed_cases:");
17872
+ const missingExecuted = plannedCases.filter((caseId) => !executedCases.includes(caseId));
17873
+ const unexpectedExecuted = executedCases.filter((caseId) => !plannedCases.includes(caseId));
17874
+ if (plannedCases.length > 0 && missingExecuted.length > 0) {
17875
+ errors.push(`[test_suite.report.case_reconciliation] ${reportPath}: planned_cases \u4E2D\u5B58\u5728\u672A\u6267\u884C\u7528\u4F8B: ${missingExecuted.join(", ")}\uFF1B\u62A5\u544A\u5FC5\u987B\u5199\u660E blocked/not run \u539F\u56E0\u5E76\u964D\u7EA7\u7ED3\u8BBA`);
17876
+ }
17877
+ if (unexpectedExecuted.length > 0) {
17878
+ errors.push(`[test_suite.report.case_reconciliation] ${reportPath}: executed_cases \u5305\u542B\u4E0D\u5728 planned_cases \u4E2D\u7684\u7528\u4F8B: ${unexpectedExecuted.join(", ")}`);
17879
+ }
17880
+ if ((NOT_RUN_RE.test(text5) || BLOCKED_RE.test(text5)) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
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`);
17882
+ }
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)) {
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`);
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
+ }
17910
+ if (/browser[_ -]?blocked|浏览器阻塞|无可用浏览器工具/i.test(text5) && !/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5)) {
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`);
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
+ }
15929
17916
  const screenshotsDir = path13.join(runDir, "screenshots");
15930
17917
  if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
17918
+ if (isFullRerun) {
17919
+ for (const key of ["state_file:", "precondition_check:", "report_run:"]) {
17920
+ for (const value of reportKeyValues(text5, key)) {
17921
+ const markers = reportRunMarkers(value);
17922
+ const hasCurrentMarker = markers.some((marker) => marker === runName || marker === reportRunDate(runName));
17923
+ if (!hasCurrentMarker || reportContainsHistoricalRun(value, runName)) {
17924
+ errors.push(`[test_suite.report.current_run_state] ${reportPath}: full_rerun \u7684 ${key} \u5FC5\u987B\u6307\u5411\u672C\u8F6E ${runName} \u6216\u672C\u8F6E\u65E5\u671F ${reportRunDate(runName)}\uFF0C\u4E0D\u80FD\u5F15\u7528\u5386\u53F2\u6216\u65E0 run \u6807\u8BB0\u7684\u72B6\u6001/\u62A5\u544A: ${value}`);
17925
+ }
17926
+ }
17927
+ }
17928
+ }
17929
+ const imageMatches = [...text5.matchAll(IMAGE_RE)];
17930
+ const imageRefs = imageMatches.map((match) => match[1]);
17931
+ if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
17932
+ const validCurrentRunImages = [];
17933
+ const window = reportExecutionWindow(runName, text5);
15931
17934
  for (const imageRef of imageRefs) {
15932
17935
  if (imageRef.includes("://")) {
15933
17936
  errors.push(`${reportPath}: screenshot must be a local file under this run's screenshots directory`);
@@ -15939,7 +17942,34 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
15939
17942
  errors.push(`${reportPath}: image reference must stay under this run's screenshots directory: ${imageRef}`);
15940
17943
  continue;
15941
17944
  }
15942
- if (!await exists3(imagePath)) errors.push(`${reportPath}: missing image file: ${imageRef}`);
17945
+ if (!await exists3(imagePath)) {
17946
+ errors.push(`${reportPath}: missing image file: ${imageRef}`);
17947
+ continue;
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
+ }
17953
+ validCurrentRunImages.push(imageRef);
17954
+ if (isFullRerun) {
17955
+ const imageStat = await stat6(imagePath);
17956
+ if (!isWithinWindow(imageStat.mtime, window)) {
17957
+ errors.push(`[test_suite.report.current_run_screenshot] ${reportPath}: full_rerun \u622A\u56FE\u5FC5\u987B\u5728\u672C\u8F6E\u6267\u884C\u65F6\u95F4\u5185\u751F\u6210\uFF0C\u4E0D\u80FD\u590D\u7528\u5386\u53F2\u622A\u56FE: ${imageRef}`);
17958
+ }
17959
+ }
17960
+ }
17961
+ if (isFullRerun) {
17962
+ for (const caseId of executedCases) {
17963
+ const caseLines = linesForCase(text5, caseId);
17964
+ const hasPassResult = caseResultPattern(caseId).test(text5) || caseLines.some((line) => PASS_CASE_RE.test(line));
17965
+ const hasCurrentEvidence = caseEvidencePattern(caseId).test(text5) || validCurrentRunImages.some((imageRef) => imageRef.includes(caseId));
17966
+ if (hasPassResult && caseLines.some((line) => HISTORICAL_EVIDENCE_RE.test(line))) {
17967
+ errors.push(`[test_suite.report.case_evidence_current_run] ${reportPath}: full_rerun \u4E2D ${caseId} \u7684\u901A\u8FC7\u7ED3\u8BBA\u4E0D\u80FD\u4F7F\u7528\u5386\u53F2/\u65E7\u62A5\u544A/\u65E7\u622A\u56FE\u4F5C\u4E3A\u672C\u8F6E\u8BC1\u636E`);
17968
+ }
17969
+ if (hasPassResult && !hasCurrentEvidence) {
17970
+ errors.push(`[test_suite.report.case_evidence_current_run] ${reportPath}: full_rerun \u4E2D ${caseId} \u7684\u901A\u8FC7\u7ED3\u8BBA\u5FC5\u987B\u6709\u672C\u8F6E\u622A\u56FE\u3001\u9879\u76EE/step \u6216\u8BC1\u636E\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u590D\u7528\u65E7\u7ED3\u679C`);
17971
+ }
17972
+ }
15943
17973
  }
15944
17974
  }
15945
17975
  }
@@ -16009,7 +18039,7 @@ function registerTestSuiteCommands(program2) {
16009
18039
  }
16010
18040
 
16011
18041
  // src/core/update.ts
16012
- import { access as access2, mkdir as mkdir13, readFile as readFile16, realpath, writeFile as writeFile13 } from "fs/promises";
18042
+ import { access as access2, mkdir as mkdir13, readFile as readFile17, realpath, writeFile as writeFile13 } from "fs/promises";
16013
18043
  import path14 from "path";
16014
18044
  var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
16015
18045
  var UPDATE_STATE_FILE = "update-state.json";
@@ -16126,7 +18156,7 @@ function updateStatePath(configDir = getConfigDir()) {
16126
18156
  }
16127
18157
  async function readUpdateState(configDir) {
16128
18158
  try {
16129
- const raw = await readFile16(updateStatePath(configDir), "utf8");
18159
+ const raw = await readFile17(updateStatePath(configDir), "utf8");
16130
18160
  const parsed = JSON.parse(raw);
16131
18161
  if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
16132
18162
  return null;
@@ -16665,6 +18695,7 @@ registerSchemaCommands(program);
16665
18695
  registerUserCommands(program);
16666
18696
  registerEsCommands(program);
16667
18697
  registerFlowCommands(program);
18698
+ registerIssueCommands(program);
16668
18699
  registerMemoryCommands(program);
16669
18700
  registerMatrixCommands(program);
16670
18701
  registerPluginCommands(program);