bpmax-cli 0.2.1-beta.2 → 0.2.1-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -1
- package/dist/bin.js +2303 -141
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-ai-taskbook/SKILL.md +4 -1
- package/skills/bpmax-api-platform-editor/SKILL.md +24 -31
- package/skills/bpmax-api-platform-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-api-platform-editor/references/platform-api-map.md +2 -2
- package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +3 -3
- package/skills/bpmax-blueprint-doc-workflow/SKILL.md +87 -0
- package/skills/bpmax-blueprint-doc-workflow/agents/openai.yaml +4 -0
- package/skills/bpmax-blueprint-doc-workflow/references/blueprint-structure.md +60 -0
- package/skills/bpmax-blueprint-doc-workflow/references/per-flow-required-structure.md +98 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-forbidden-term.xml +12 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-mermaid-codeblock.xml +12 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-boundary.xml +10 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-whiteboard.xml +10 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-pass.xml +55 -0
- package/skills/bpmax-blueprint-doc-workflow/scripts/lint_blueprint_doc.py +257 -0
- package/skills/bpmax-builder-shared/template_script_hard_rules.py +3 -1
- package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +16 -0
- package/skills/bpmax-cli/SKILL.md +30 -0
- package/skills/bpmax-console-template-editor/SKILL.md +109 -523
- package/skills/bpmax-console-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-console-template-editor/references/full-detail-guide.md +45 -0
- package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +13 -12
- package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +65 -78
- package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +86 -30
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +124 -594
- package/skills/bpmax-dataset-field-template-editor/references/full-detail-guide.md +570 -0
- package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +1 -1
- package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +11 -77
- package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +4 -57
- package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +2 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +4 -78
- package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +3 -89
- package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +14 -0
- package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +2 -0
- package/skills/bpmax-dataset-template-editor/SKILL.md +112 -768
- package/skills/bpmax-dataset-template-editor/references/full-detail-guide.md +753 -0
- package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +1 -0
- package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +2 -2
- package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +9 -90
- package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +1 -2
- package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +8 -1
- package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +6 -40
- package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +18 -4
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +112 -533
- package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +43 -4
- package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +6 -5
- package/skills/bpmax-e2e-flow-test-operator/references/full-detail-guide.md +563 -0
- package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +4 -4
- package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +1 -1
- package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +3 -1
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +7 -5
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +2 -2
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +5 -1
- package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +71 -0
- package/skills/bpmax-filter-template-editor/SKILL.md +110 -551
- package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +18 -18
- package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +29 -26
- package/skills/bpmax-filter-template-editor/references/full-detail-guide.md +56 -0
- package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +10 -9
- package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +7 -57
- package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +4 -48
- package/skills/bpmax-flow-template-editor/SKILL.md +109 -1084
- package/skills/bpmax-flow-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-flow-template-editor/references/diff-strategy.md +3 -3
- package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +9 -9
- package/skills/bpmax-flow-template-editor/references/full-detail-guide.md +1155 -0
- package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +1 -1
- package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +3 -3
- package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +7 -7
- package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +2 -2
- package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +2 -2
- package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +7 -23
- package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +1 -1
- package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +19 -75
- package/skills/bpmax-form-template-editor/SKILL.md +111 -1104
- package/skills/bpmax-form-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +51 -51
- package/skills/bpmax-form-template-editor/references/full-detail-guide.md +1108 -0
- package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +4 -4
- package/skills/bpmax-form-template-editor/references/payload-checklist.md +1 -1
- package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +8 -0
- package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +42 -19
- package/skills/bpmax-list-template-editor/SKILL.md +110 -466
- package/skills/bpmax-list-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-list-template-editor/references/full-detail-guide.md +454 -0
- package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +6 -9
- package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +1 -1
- package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +9 -78
- package/skills/bpmax-nav-config-editor/SKILL.md +13 -17
- package/skills/bpmax-nav-config-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-nav-config-editor/references/api-workflow.md +2 -2
- package/skills/bpmax-nav-config-editor/references/runtime-probing.md +11 -12
- package/skills/bpmax-plugin-config/SKILL.md +4 -0
- package/skills/bpmax-project/SKILL.md +1 -0
- package/skills/bpmax-project-detail-template-editor/SKILL.md +11 -33
- package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-role-editor/SKILL.md +7 -30
- package/skills/bpmax-user-mock-operator/SKILL.md +1 -1
- 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.
|
|
472
|
+
version: "0.2.1-beta.21",
|
|
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 [];
|
|
@@ -3566,6 +3595,11 @@ function collectFlowTemplatePluginKeys(flowWork) {
|
|
|
3566
3595
|
});
|
|
3567
3596
|
return [...keys];
|
|
3568
3597
|
}
|
|
3598
|
+
function isExplicitlyDisabledPluginConfig(config) {
|
|
3599
|
+
return Boolean(
|
|
3600
|
+
config && typeof config === "object" && !Array.isArray(config) && config.enabled === false
|
|
3601
|
+
);
|
|
3602
|
+
}
|
|
3569
3603
|
async function readPluginLintRuleFile(skillInstallPath, lintManifest) {
|
|
3570
3604
|
const fullPath = path4.join(skillInstallPath, lintManifest.path);
|
|
3571
3605
|
const value = JSON.parse(await readFile7(fullPath, "utf8"));
|
|
@@ -3601,6 +3635,7 @@ async function lintFlowTemplatePluginExtensions(options) {
|
|
|
3601
3635
|
)
|
|
3602
3636
|
).filter((item) => item.lint.domain === "flow-template-node");
|
|
3603
3637
|
const usedPluginKeys = new Set(collectFlowTemplatePluginKeys(options.flowWork));
|
|
3638
|
+
const hasRemoteFlowIdentity = typeof options.flowWork.flow_type === "string" && options.flowWork.flow_type.trim().length > 0;
|
|
3604
3639
|
if (!usedPluginKeys.size && !platformLintDeclarations.length && !installedLintDeclarations.length) {
|
|
3605
3640
|
return {
|
|
3606
3641
|
ok: true,
|
|
@@ -3613,6 +3648,27 @@ async function lintFlowTemplatePluginExtensions(options) {
|
|
|
3613
3648
|
...platformLintDeclarations.map((item) => item.lint.plugin_key),
|
|
3614
3649
|
...installedLintDeclarations.map((item) => item.lint.plugin_key)
|
|
3615
3650
|
]);
|
|
3651
|
+
for (const pluginKey of usedPluginKeys) {
|
|
3652
|
+
if (allPluginKeys.has(pluginKey)) {
|
|
3653
|
+
continue;
|
|
3654
|
+
}
|
|
3655
|
+
const occurrences = collectFlowTemplatePluginConfigs(options.flowWork, pluginKey);
|
|
3656
|
+
const preservesExistingDisabledExtension = hasRemoteFlowIdentity && occurrences.length > 0 && occurrences.every((occurrence) => isExplicitlyDisabledPluginConfig(occurrence.config));
|
|
3657
|
+
const message = preservesExistingDisabledExtension ? `Flow template preserves disabled plugin extension ${pluginKey} without a platform or installed flow-template lint declaration; skipped plugin-specific lint because every occurrence explicitly sets enabled=false.` : `Flow template uses unknown plugin extension ${pluginKey}; no platform or installed flow-template lint declaration was found.`;
|
|
3658
|
+
if (options.requireInstalled && !preservesExistingDisabledExtension) {
|
|
3659
|
+
errors.push(message);
|
|
3660
|
+
} else {
|
|
3661
|
+
warnings.push(message);
|
|
3662
|
+
}
|
|
3663
|
+
pluginLints.push({
|
|
3664
|
+
plugin: pluginKey,
|
|
3665
|
+
plugin_key: pluginKey,
|
|
3666
|
+
domain: "flow-template-node",
|
|
3667
|
+
checked_locations: occurrences.map((occurrence) => occurrence.location),
|
|
3668
|
+
errors: options.requireInstalled && !preservesExistingDisabledExtension ? [message] : [],
|
|
3669
|
+
warnings: options.requireInstalled && !preservesExistingDisabledExtension ? [] : [message]
|
|
3670
|
+
});
|
|
3671
|
+
}
|
|
3616
3672
|
for (const pluginKey of allPluginKeys) {
|
|
3617
3673
|
const declarations = [
|
|
3618
3674
|
...platformLintDeclarations.filter((item) => item.lint.plugin_key === pluginKey).map((item) => item.lint),
|
|
@@ -3953,6 +4009,8 @@ function configAdapterMatrix() {
|
|
|
3953
4009
|
return Object.entries(CONFIG_DOMAINS).map(([domain, definition]) => {
|
|
3954
4010
|
const supportsCreate = Boolean(definition.createPath) || ["flow-template", "api-platform", "role", "nav-config"].includes(domain);
|
|
3955
4011
|
const supportsDelete = Boolean(definition.deletePath) || ["workspace-flow", "api-platform", "nav-config"].includes(domain);
|
|
4012
|
+
const supportsPublish = domain === "dataset";
|
|
4013
|
+
const supportsRelationFields = domain === "dataset";
|
|
3956
4014
|
return {
|
|
3957
4015
|
domain,
|
|
3958
4016
|
capability_prefix: definition.capability,
|
|
@@ -3970,6 +4028,8 @@ function configAdapterMatrix() {
|
|
|
3970
4028
|
create: supportsCreate,
|
|
3971
4029
|
build: definition.buildStatus === "supported",
|
|
3972
4030
|
submit: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy",
|
|
4031
|
+
publish: supportsPublish,
|
|
4032
|
+
relationFields: supportsRelationFields,
|
|
3973
4033
|
delete: supportsDelete,
|
|
3974
4034
|
verify: definition.exportStatus === "supported",
|
|
3975
4035
|
dry_run: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy"
|
|
@@ -3978,12 +4038,13 @@ function configAdapterMatrix() {
|
|
|
3978
4038
|
work_file: definition.buildStatus === "supported",
|
|
3979
4039
|
meta_file_for_build: definition.buildStatus === "supported",
|
|
3980
4040
|
payload_file_for_submit: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy",
|
|
3981
|
-
base_hash_for_submit: domain === "workspace-flow"
|
|
4041
|
+
base_hash_for_submit: domain === "workspace-flow" || domain === "dataset"
|
|
3982
4042
|
},
|
|
3983
4043
|
side_effects: {
|
|
3984
4044
|
writes_workspace_binding: domain === "workspace-flow",
|
|
3985
4045
|
full_replacement_submit: domain === "workspace-flow",
|
|
3986
|
-
publishes_on_submit: domain === "form-template"
|
|
4046
|
+
publishes_on_submit: domain === "form-template",
|
|
4047
|
+
relation_fields_submit: domain === "dataset"
|
|
3987
4048
|
},
|
|
3988
4049
|
notes: definition.notes
|
|
3989
4050
|
};
|
|
@@ -4294,6 +4355,108 @@ function validateFlowTemplateFormDrivenCreateBaseline(value, errors, options = {
|
|
|
4294
4355
|
}
|
|
4295
4356
|
throw new Error(message);
|
|
4296
4357
|
}
|
|
4358
|
+
function validateFlowAppFlowWork(value, errors, warnings) {
|
|
4359
|
+
validateFlowTemplateRemoteTemplateRefs(value, errors);
|
|
4360
|
+
validateFlowTemplateProjectAfterCreatePath(value, errors);
|
|
4361
|
+
validateFlowTemplateStandardPageCreateFormTemplate(value, errors);
|
|
4362
|
+
validateFlowTemplateStartConditionalJump(value, errors);
|
|
4363
|
+
validateFlowTemplateApproveActionShape(value, errors);
|
|
4364
|
+
validateFlowTemplatePluginRejectionControl(value, errors);
|
|
4365
|
+
validateFlowTemplateStandardConditionEditorRules(value, errors);
|
|
4366
|
+
validateFlowTemplateCodeModeMessages(value, errors);
|
|
4367
|
+
validateFlowTemplateRuntimeScripts(value, errors);
|
|
4368
|
+
validateFlowTemplateFeishuChatPlugin(value, errors);
|
|
4369
|
+
validateFlowTemplateFormDrivenCreateBaseline(value, errors, {
|
|
4370
|
+
force: true,
|
|
4371
|
+
context: "flow-app create"
|
|
4372
|
+
});
|
|
4373
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
4374
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
4375
|
+
const afterCreatePath = typeof meta.project_after_create_path === "string" ? meta.project_after_create_path : "";
|
|
4376
|
+
if (/['"`]\/project\?flow_type=/.test(afterCreatePath) || afterCreatePath.includes("/project?flow_type=")) {
|
|
4377
|
+
warnings.push(
|
|
4378
|
+
"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."
|
|
4379
|
+
);
|
|
4380
|
+
}
|
|
4381
|
+
}
|
|
4382
|
+
function flowAppDraftPayloadSummary(flowWorkRecord) {
|
|
4383
|
+
const data = isRecord3(flowWorkRecord.data) ? flowWorkRecord.data : {};
|
|
4384
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
4385
|
+
return {
|
|
4386
|
+
flow_type: "<platform-flow-type>",
|
|
4387
|
+
key: "",
|
|
4388
|
+
type: flowWorkRecord.type || "main",
|
|
4389
|
+
meta_form_id: "<published-form-id>",
|
|
4390
|
+
data: {
|
|
4391
|
+
meta: {
|
|
4392
|
+
...pickDefined(meta, [
|
|
4393
|
+
"hide_fields",
|
|
4394
|
+
"use_template_project_name",
|
|
4395
|
+
"project_name_template",
|
|
4396
|
+
"project_after_create_path"
|
|
4397
|
+
]),
|
|
4398
|
+
form_template: "<published-form-id>"
|
|
4399
|
+
},
|
|
4400
|
+
node_count: Array.isArray(data.nodes) ? data.nodes.length : 0,
|
|
4401
|
+
period_count: Array.isArray(data.periods) ? data.periods.length : 0
|
|
4402
|
+
}
|
|
4403
|
+
};
|
|
4404
|
+
}
|
|
4405
|
+
async function lintFlowAppWorkFiles(formWorkFile, flowWorkFile, options = {}) {
|
|
4406
|
+
const formWork = await readJsonFile(formWorkFile);
|
|
4407
|
+
const flowWork = await readJsonFile(flowWorkFile);
|
|
4408
|
+
const errors = [];
|
|
4409
|
+
const formErrors = [];
|
|
4410
|
+
const flowErrors = [];
|
|
4411
|
+
const warnings = [];
|
|
4412
|
+
let pluginLint;
|
|
4413
|
+
if (!isRecord3(formWork)) {
|
|
4414
|
+
formErrors.push("flow-app create requires form work to be a JSON object.");
|
|
4415
|
+
} else if (formWork.mode !== "create") {
|
|
4416
|
+
formErrors.push("flow-app create requires form work with mode=create.");
|
|
4417
|
+
} else {
|
|
4418
|
+
validateFormTemplateWorkLint(formWork, formErrors);
|
|
4419
|
+
}
|
|
4420
|
+
if (!isRecord3(flowWork)) {
|
|
4421
|
+
flowErrors.push("flow-app create requires flow work to be a JSON object.");
|
|
4422
|
+
} else if (!isFlowTemplateWork(flowWork)) {
|
|
4423
|
+
flowErrors.push("flow-app create requires flow work with data.nodes/data.periods or mode=create.");
|
|
4424
|
+
} else {
|
|
4425
|
+
validateFlowAppFlowWork(flowWork, flowErrors, warnings);
|
|
4426
|
+
if (!options.pluginLint && hasPotentialFlowTemplatePluginExtension(flowWork)) {
|
|
4427
|
+
flowErrors.push("flow-app plugin lint requires an initialized profile when flow work contains plugin extensions; configure or pass --profile before create preflight.");
|
|
4428
|
+
}
|
|
4429
|
+
pluginLint = await runFlowTemplatePluginLint(flowWork, options.pluginLint);
|
|
4430
|
+
if (pluginLint) {
|
|
4431
|
+
flowErrors.push(...pluginLint.errors);
|
|
4432
|
+
warnings.push(...pluginLint.warnings);
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
errors.push(...formErrors, ...flowErrors);
|
|
4436
|
+
return {
|
|
4437
|
+
domain: "flow-app",
|
|
4438
|
+
ok: errors.length === 0,
|
|
4439
|
+
form_work_file: formWorkFile,
|
|
4440
|
+
flow_work_file: flowWorkFile,
|
|
4441
|
+
...options.name ? { name: options.name } : {},
|
|
4442
|
+
...options.workspace ? { workspace: normalizeWorkspaceKey(options.workspace) } : {},
|
|
4443
|
+
errors,
|
|
4444
|
+
error_groups: {
|
|
4445
|
+
form_template: formErrors,
|
|
4446
|
+
flow_template: flowErrors
|
|
4447
|
+
},
|
|
4448
|
+
...pluginLint ? { plugin_lints: pluginLint.plugin_lints } : {},
|
|
4449
|
+
warnings,
|
|
4450
|
+
flow_type_policy: "flow_type is allocated by the platform during config flow-app create; pre-create lint intentionally does not require flow_type.",
|
|
4451
|
+
evidence_requirements: [
|
|
4452
|
+
"Save flow-app lint output before create.",
|
|
4453
|
+
"Save flow-app dry-run output with operation_plan payload_summary before confirm.",
|
|
4454
|
+
"After create, run config flow-app context and keep target context evidence.",
|
|
4455
|
+
"If project_after_create_path redirects to /project, verify list discoverability or add list/default-template config."
|
|
4456
|
+
],
|
|
4457
|
+
checked_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4458
|
+
};
|
|
4459
|
+
}
|
|
4297
4460
|
function validateFlowTemplateProjectAfterCreatePath(value, errors) {
|
|
4298
4461
|
const data = isRecord3(value.data) ? value.data : {};
|
|
4299
4462
|
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
@@ -4334,6 +4497,479 @@ function validateFlowTemplateStandardPageCreateFormTemplate(value, errors) {
|
|
|
4334
4497
|
}
|
|
4335
4498
|
throw new Error(message);
|
|
4336
4499
|
}
|
|
4500
|
+
function startConditionalJumpScriptLooksLikeIndexReturn(script) {
|
|
4501
|
+
const text5 = script.trim();
|
|
4502
|
+
if (!text5) {
|
|
4503
|
+
return false;
|
|
4504
|
+
}
|
|
4505
|
+
const directReturns = Array.from(text5.matchAll(/\breturn\s+([^;]+)\s*;?/g));
|
|
4506
|
+
if (!directReturns.length) {
|
|
4507
|
+
return false;
|
|
4508
|
+
}
|
|
4509
|
+
return directReturns.some((match) => {
|
|
4510
|
+
const expression = match[1].trim();
|
|
4511
|
+
if (/[=!<>]=?|&&|\|\||\?/.test(expression)) {
|
|
4512
|
+
return false;
|
|
4513
|
+
}
|
|
4514
|
+
return /^-?\d+$/.test(expression) || /^(routeIndex|resultIndex|targetIndex|index)\b/.test(expression) || /\b(result|options)\.indexOf\s*\(/.test(expression) || /^Number(?:\.parseInt)?\s*\(/.test(expression);
|
|
4515
|
+
});
|
|
4516
|
+
}
|
|
4517
|
+
function startConditionalJumpScriptIsCatchAll(script) {
|
|
4518
|
+
const text5 = script.trim();
|
|
4519
|
+
return /^return\s+true\s*;?\s*$/.test(text5) || /^return\s+Boolean\s*\(\s*true\s*\)\s*;?\s*$/.test(text5);
|
|
4520
|
+
}
|
|
4521
|
+
function validateFlowTemplateStartConditionalJump(value, errors) {
|
|
4522
|
+
const nextErrors = [];
|
|
4523
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
4524
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
4525
|
+
const jumps = meta.condational_jump;
|
|
4526
|
+
if (jumps === void 0 || jumps === null || jumps === "") {
|
|
4527
|
+
return;
|
|
4528
|
+
}
|
|
4529
|
+
if (!Array.isArray(jumps)) {
|
|
4530
|
+
nextErrors.push("data.meta.condational_jump must be an array when start conditional routing is configured.");
|
|
4531
|
+
} else if (jumps.length === 0) {
|
|
4532
|
+
return;
|
|
4533
|
+
}
|
|
4534
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
|
|
4535
|
+
const firstNodeId = nodes.length ? String(nodes[0].id ?? "").trim() : "";
|
|
4536
|
+
const nodeIds = new Set(nodes.map((node) => String(node.id ?? "").trim()).filter(Boolean));
|
|
4537
|
+
if (Array.isArray(jumps) && jumps.length && !nodes.length) {
|
|
4538
|
+
nextErrors.push("data.meta.condational_jump is configured but data.nodes is empty; start jump targets must point to real nodes or -1.");
|
|
4539
|
+
}
|
|
4540
|
+
if (Array.isArray(jumps) && jumps.length) {
|
|
4541
|
+
nodes.forEach((node, index) => {
|
|
4542
|
+
const id = String(node.id ?? "").trim();
|
|
4543
|
+
if (!id) {
|
|
4544
|
+
nextErrors.push(`data.nodes[${index}].id is required when data.meta.condational_jump is configured.`);
|
|
4545
|
+
}
|
|
4546
|
+
});
|
|
4547
|
+
}
|
|
4548
|
+
let lastJumpScript = "";
|
|
4549
|
+
let lastJumpResult = "";
|
|
4550
|
+
if (Array.isArray(jumps)) {
|
|
4551
|
+
jumps.forEach((jump, index) => {
|
|
4552
|
+
const pathName = `data.meta.condational_jump[${index}]`;
|
|
4553
|
+
if (!isRecord3(jump)) {
|
|
4554
|
+
nextErrors.push(`${pathName} must be an object with name, result, condition_mode, and a boolean condition script.`);
|
|
4555
|
+
return;
|
|
4556
|
+
}
|
|
4557
|
+
const name = typeof jump.name === "string" ? jump.name.trim() : "";
|
|
4558
|
+
if (!name) {
|
|
4559
|
+
nextErrors.push(`${pathName}.name is required so every explicit start route can be audited.`);
|
|
4560
|
+
}
|
|
4561
|
+
const rawResult = jump.result;
|
|
4562
|
+
if (Array.isArray(rawResult) || isRecord3(rawResult) || rawResult === void 0 || rawResult === null || String(rawResult).trim() === "") {
|
|
4563
|
+
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.`);
|
|
4564
|
+
} else {
|
|
4565
|
+
const result = String(rawResult).trim();
|
|
4566
|
+
if (result !== "-1" && !nodeIds.has(result)) {
|
|
4567
|
+
nextErrors.push(`${pathName}.result (${result}) must point to an existing data.nodes[].id or -1 for success end.`);
|
|
4568
|
+
}
|
|
4569
|
+
lastJumpResult = result;
|
|
4570
|
+
}
|
|
4571
|
+
const mode = typeof jump.condition_mode === "string" && jump.condition_mode.trim() ? jump.condition_mode.trim() : "code";
|
|
4572
|
+
let script = "";
|
|
4573
|
+
if (mode === "standard") {
|
|
4574
|
+
if (typeof jump.standard_condition === "string" && jump.standard_condition.trim()) {
|
|
4575
|
+
script = jump.standard_condition.trim();
|
|
4576
|
+
} else {
|
|
4577
|
+
nextErrors.push(`${pathName}.standard_condition is required when condition_mode is standard; condition is ignored by the backend in this mode.`);
|
|
4578
|
+
}
|
|
4579
|
+
} else if (mode === "code") {
|
|
4580
|
+
if (typeof jump.condition === "string" && jump.condition.trim()) {
|
|
4581
|
+
script = jump.condition.trim();
|
|
4582
|
+
} else {
|
|
4583
|
+
nextErrors.push(`${pathName}.condition is required when condition_mode is code or omitted; standard_condition is ignored by the backend in code mode.`);
|
|
4584
|
+
}
|
|
4585
|
+
} else {
|
|
4586
|
+
nextErrors.push(`${pathName}.condition_mode must be code or standard.`);
|
|
4587
|
+
}
|
|
4588
|
+
if (script) {
|
|
4589
|
+
lastJumpScript = script;
|
|
4590
|
+
if (index < jumps.length - 1 && startConditionalJumpScriptIsCatchAll(script)) {
|
|
4591
|
+
nextErrors.push(
|
|
4592
|
+
`${pathName} is a catch-all start route but is not the final item; return true must only appear on the last explicit fallback route.`
|
|
4593
|
+
);
|
|
4594
|
+
}
|
|
4595
|
+
if (startConditionalJumpScriptLooksLikeIndexReturn(script)) {
|
|
4596
|
+
nextErrors.push(
|
|
4597
|
+
`${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.`
|
|
4598
|
+
);
|
|
4599
|
+
}
|
|
4600
|
+
}
|
|
4601
|
+
});
|
|
4602
|
+
}
|
|
4603
|
+
if (Array.isArray(jumps) && jumps.length && nodes.length) {
|
|
4604
|
+
if (!lastJumpResult || !startConditionalJumpScriptIsCatchAll(lastJumpScript)) {
|
|
4605
|
+
nextErrors.push(
|
|
4606
|
+
"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."
|
|
4607
|
+
);
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4610
|
+
if (!nextErrors.length) {
|
|
4611
|
+
return;
|
|
4612
|
+
}
|
|
4613
|
+
if (errors) {
|
|
4614
|
+
errors.push(...nextErrors);
|
|
4615
|
+
return;
|
|
4616
|
+
}
|
|
4617
|
+
throw new Error(`flow-template start conditional jump gate failed: ${nextErrors.join("; ")}`);
|
|
4618
|
+
}
|
|
4619
|
+
function isFlowTemplateEndpointTarget(value) {
|
|
4620
|
+
return /^-\d+$/.test(value.trim());
|
|
4621
|
+
}
|
|
4622
|
+
function isFlowTemplateSpecialStepTarget(value) {
|
|
4623
|
+
const normalized = value.trim();
|
|
4624
|
+
return normalized === "[source]" || normalized === "anyNode";
|
|
4625
|
+
}
|
|
4626
|
+
function isFlowTemplateBackSourceTarget(value) {
|
|
4627
|
+
return value.trim() === "[source]";
|
|
4628
|
+
}
|
|
4629
|
+
function isFlowTemplateConditionalTarget(value, conditionNames) {
|
|
4630
|
+
const match = value.trim().match(/^(.+)\[condition\]\d+$/);
|
|
4631
|
+
if (!match) {
|
|
4632
|
+
return false;
|
|
4633
|
+
}
|
|
4634
|
+
return conditionNames.has(match[1].trim());
|
|
4635
|
+
}
|
|
4636
|
+
function validateFlowTemplateActionTarget(errors, pathName, target, nodeIds, conditionNames, options = {}) {
|
|
4637
|
+
const normalizedTarget = target.trim();
|
|
4638
|
+
if (!normalizedTarget) {
|
|
4639
|
+
if (options.actionString) {
|
|
4640
|
+
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".`);
|
|
4641
|
+
} else {
|
|
4642
|
+
errors.push(`${pathName} target step is required; use a node id, -1, [source], anyNode, or \u6761\u4EF6\u540D[condition]0.`);
|
|
4643
|
+
}
|
|
4644
|
+
return;
|
|
4645
|
+
}
|
|
4646
|
+
const conditionalTargetAllowed = options.allowConditionalTarget !== false;
|
|
4647
|
+
const specialTargetAllowed = options.allowAnyNode === false ? isFlowTemplateBackSourceTarget(normalizedTarget) : isFlowTemplateSpecialStepTarget(normalizedTarget);
|
|
4648
|
+
if (!nodeIds.has(normalizedTarget) && !isFlowTemplateEndpointTarget(normalizedTarget) && !specialTargetAllowed && !(conditionalTargetAllowed && isFlowTemplateConditionalTarget(normalizedTarget, conditionNames))) {
|
|
4649
|
+
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";
|
|
4650
|
+
errors.push(`${pathName} target (${normalizedTarget}) must be ${allowedTargets}.`);
|
|
4651
|
+
}
|
|
4652
|
+
}
|
|
4653
|
+
var FLOW_TEMPLATE_OWNER_AUTO_RANGE_TYPES = /* @__PURE__ */ new Set(["owner", "role", "user", "leader", "continuous_leader", "group", "fieldvalue", "matrix"]);
|
|
4654
|
+
function validateFlowTemplateOwnerStrategyShape(node, nodeName, errors) {
|
|
4655
|
+
const rawType = typeof node.auto_range_type === "string" ? node.auto_range_type.trim() : "";
|
|
4656
|
+
if (!rawType) return;
|
|
4657
|
+
if (!FLOW_TEMPLATE_OWNER_AUTO_RANGE_TYPES.has(rawType)) {
|
|
4658
|
+
errors.push(`${nodeName}.auto_range_type must be one of owner, role, user, leader, continuous_leader, group, fieldvalue, matrix.`);
|
|
4659
|
+
return;
|
|
4660
|
+
}
|
|
4661
|
+
if (rawType === "owner" && typeof node.owner_is_creater !== "boolean") {
|
|
4662
|
+
errors.push(`${nodeName}.owner_is_creater must be a boolean when auto_range_type is owner.`);
|
|
4663
|
+
}
|
|
4664
|
+
if (rawType === "role" && (!Array.isArray(node.owner_roles) || !node.owner_roles.length) && !node.auto_range_by_role) {
|
|
4665
|
+
errors.push(`${nodeName}.owner_roles or auto_range_by_role is required when auto_range_type is role.`);
|
|
4666
|
+
}
|
|
4667
|
+
if (rawType === "user" && (!Array.isArray(node.auto_range_by_users) || !node.auto_range_by_users.length)) {
|
|
4668
|
+
errors.push(`${nodeName}.auto_range_by_users must be a non-empty array when auto_range_type is user.`);
|
|
4669
|
+
}
|
|
4670
|
+
if (rawType === "group" && (!Array.isArray(node.auto_range_by_groups) || !node.auto_range_by_groups.length)) {
|
|
4671
|
+
errors.push(`${nodeName}.auto_range_by_groups must be a non-empty array when auto_range_type is group.`);
|
|
4672
|
+
}
|
|
4673
|
+
if (rawType === "fieldvalue" && (typeof node.auto_range_by_script !== "string" || !node.auto_range_by_script.trim())) {
|
|
4674
|
+
errors.push(`${nodeName}.auto_range_by_script is required when auto_range_type is fieldvalue.`);
|
|
4675
|
+
}
|
|
4676
|
+
if (rawType === "matrix" && !isRecord3(node.matrix_owner)) {
|
|
4677
|
+
errors.push(`${nodeName}.matrix_owner is required when auto_range_type is matrix.`);
|
|
4678
|
+
}
|
|
4679
|
+
if (rawType === "leader") {
|
|
4680
|
+
const hasLegacyLeaderConfig = Boolean(node.leader_match_method || node.auto_range_by_step_owner_group_leader || node.leader_form_field_key || node.leader_rules);
|
|
4681
|
+
if (!hasLegacyLeaderConfig) {
|
|
4682
|
+
errors.push(`${nodeName}.leader_rules or leader_* config is required when auto_range_type is leader.`);
|
|
4683
|
+
}
|
|
4684
|
+
}
|
|
4685
|
+
if (rawType === "continuous_leader") {
|
|
4686
|
+
const hasContinuousConfig = Boolean(node.continuous_match_method || node.continuous_step_id || node.continuous_form_field_key);
|
|
4687
|
+
if (!hasContinuousConfig) {
|
|
4688
|
+
errors.push(`${nodeName}.continuous_* config is required when auto_range_type is continuous_leader.`);
|
|
4689
|
+
}
|
|
4690
|
+
}
|
|
4691
|
+
}
|
|
4692
|
+
function validateFlowTemplateApproveActionShape(value, errors) {
|
|
4693
|
+
const nextErrors = [];
|
|
4694
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
4695
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
|
|
4696
|
+
const nodeIds = new Set(nodes.map((node) => String(node.id ?? "").trim()).filter(Boolean));
|
|
4697
|
+
nodes.forEach((node, nodeIndex) => {
|
|
4698
|
+
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
|
|
4699
|
+
validateFlowTemplateOwnerStrategyShape(node, nodeName, nextErrors);
|
|
4700
|
+
const conditionNames = /* @__PURE__ */ new Set();
|
|
4701
|
+
if (node.condational_nodes !== void 0 && node.condational_nodes !== null && node.condational_nodes !== "" && !Array.isArray(node.condational_nodes)) {
|
|
4702
|
+
nextErrors.push(`${nodeName}.condational_nodes must be an array of condition route objects.`);
|
|
4703
|
+
}
|
|
4704
|
+
const conditionalNodes = Array.isArray(node.condational_nodes) ? node.condational_nodes : [];
|
|
4705
|
+
conditionalNodes.forEach((conditionNode, conditionIndex) => {
|
|
4706
|
+
const conditionPath = `${nodeName}.condational_nodes[${conditionIndex}]`;
|
|
4707
|
+
if (!isRecord3(conditionNode)) {
|
|
4708
|
+
nextErrors.push(`${conditionPath} must be an object with name, result, condition_mode, and an index-returning condition script.`);
|
|
4709
|
+
return;
|
|
4710
|
+
}
|
|
4711
|
+
const conditionName = typeof conditionNode.name === "string" ? conditionNode.name.trim() : "";
|
|
4712
|
+
if (conditionName) {
|
|
4713
|
+
conditionNames.add(conditionName);
|
|
4714
|
+
} else {
|
|
4715
|
+
nextErrors.push(`${conditionPath}.name is required so approve_to_step/approve_actions can reference this condational_nodes entry.`);
|
|
4716
|
+
}
|
|
4717
|
+
const conditionMode = typeof conditionNode.condition_mode === "string" && conditionNode.condition_mode.trim() ? conditionNode.condition_mode.trim() : "code";
|
|
4718
|
+
if (conditionMode === "standard") {
|
|
4719
|
+
if (typeof conditionNode.standard_condition !== "string" || !conditionNode.standard_condition.trim()) {
|
|
4720
|
+
nextErrors.push(`${conditionPath}.standard_condition is required when condition_mode is standard; condition is ignored by the backend in this mode.`);
|
|
4721
|
+
}
|
|
4722
|
+
} else if (conditionMode === "code") {
|
|
4723
|
+
if (typeof conditionNode.condition !== "string" || !conditionNode.condition.trim()) {
|
|
4724
|
+
nextErrors.push(`${conditionPath}.condition is required when condition_mode is code or omitted; standard_condition is ignored by the backend in code mode.`);
|
|
4725
|
+
}
|
|
4726
|
+
} else {
|
|
4727
|
+
nextErrors.push(`${conditionPath}.condition_mode must be code or standard.`);
|
|
4728
|
+
}
|
|
4729
|
+
const conditionResult = conditionNode.result;
|
|
4730
|
+
const resultPath = `${conditionPath}.result`;
|
|
4731
|
+
if (!Array.isArray(conditionResult) || !conditionResult.length) {
|
|
4732
|
+
nextErrors.push(`${resultPath} must be a non-empty array of target node ids.`);
|
|
4733
|
+
return;
|
|
4734
|
+
}
|
|
4735
|
+
conditionResult.forEach((target, targetIndex) => {
|
|
4736
|
+
const targetPath = `${resultPath}[${targetIndex}]`;
|
|
4737
|
+
if (Array.isArray(target) || isRecord3(target) || target === void 0 || target === null) {
|
|
4738
|
+
nextErrors.push(`${targetPath} must be a target node id, endpoint like -1, or [source].`);
|
|
4739
|
+
return;
|
|
4740
|
+
}
|
|
4741
|
+
validateFlowTemplateActionTarget(
|
|
4742
|
+
nextErrors,
|
|
4743
|
+
targetPath,
|
|
4744
|
+
String(target),
|
|
4745
|
+
nodeIds,
|
|
4746
|
+
conditionNames,
|
|
4747
|
+
{ allowConditionalTarget: false, allowAnyNode: false }
|
|
4748
|
+
);
|
|
4749
|
+
});
|
|
4750
|
+
});
|
|
4751
|
+
[
|
|
4752
|
+
["approve_to_step", node.approve_to_step],
|
|
4753
|
+
["approve_fail", node.approve_fail]
|
|
4754
|
+
].forEach(([fieldName, fieldValue]) => {
|
|
4755
|
+
if (fieldValue === void 0 || fieldValue === null || fieldValue === "") {
|
|
4756
|
+
return;
|
|
4757
|
+
}
|
|
4758
|
+
if (Array.isArray(fieldValue) || isRecord3(fieldValue)) {
|
|
4759
|
+
nextErrors.push(`${nodeName}.${fieldName} must be a target node id, endpoint like -1, [source], anyNode, or \u6761\u4EF6\u540D[condition]0.`);
|
|
4760
|
+
return;
|
|
4761
|
+
}
|
|
4762
|
+
validateFlowTemplateActionTarget(nextErrors, `${nodeName}.${fieldName}`, String(fieldValue), nodeIds, conditionNames);
|
|
4763
|
+
});
|
|
4764
|
+
const actionGroups = [
|
|
4765
|
+
["approve_actions", node.approve_actions],
|
|
4766
|
+
["approve_fail_actions", node.approve_fail_actions]
|
|
4767
|
+
];
|
|
4768
|
+
actionGroups.forEach(([fieldName, fieldValue]) => {
|
|
4769
|
+
if (fieldValue === void 0 || fieldValue === null || fieldValue === "") {
|
|
4770
|
+
return;
|
|
4771
|
+
}
|
|
4772
|
+
const pathPrefix = `${nodeName}.${fieldName}`;
|
|
4773
|
+
if (!Array.isArray(fieldValue)) {
|
|
4774
|
+
nextErrors.push(`${pathPrefix} must be an array of action strings.`);
|
|
4775
|
+
return;
|
|
4776
|
+
}
|
|
4777
|
+
fieldValue.forEach((action, actionIndex) => {
|
|
4778
|
+
const pathName = `${pathPrefix}[${actionIndex}]`;
|
|
4779
|
+
if (typeof action !== "string") {
|
|
4780
|
+
nextErrors.push(`${pathName} must be a string action in "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID" format.`);
|
|
4781
|
+
return;
|
|
4782
|
+
}
|
|
4783
|
+
const parts = action.split("|");
|
|
4784
|
+
if (parts.length < 2) {
|
|
4785
|
+
const raw = action.trim();
|
|
4786
|
+
if (raw && (nodeIds.has(raw) || isFlowTemplateEndpointTarget(raw) || isFlowTemplateSpecialStepTarget(raw) || isFlowTemplateConditionalTarget(raw, conditionNames))) {
|
|
4787
|
+
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.`);
|
|
4788
|
+
} else {
|
|
4789
|
+
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".`);
|
|
4790
|
+
}
|
|
4791
|
+
return;
|
|
4792
|
+
}
|
|
4793
|
+
const label = parts[0].trim();
|
|
4794
|
+
const target = parts[1].trim();
|
|
4795
|
+
if (!label) {
|
|
4796
|
+
nextErrors.push(`${pathName} label is required before "|".`);
|
|
4797
|
+
}
|
|
4798
|
+
validateFlowTemplateActionTarget(nextErrors, pathName, target, nodeIds, conditionNames, { actionString: true });
|
|
4799
|
+
});
|
|
4800
|
+
});
|
|
4801
|
+
});
|
|
4802
|
+
if (!nextErrors.length) {
|
|
4803
|
+
return;
|
|
4804
|
+
}
|
|
4805
|
+
if (errors) {
|
|
4806
|
+
errors.push(...nextErrors);
|
|
4807
|
+
return;
|
|
4808
|
+
}
|
|
4809
|
+
throw new Error(`flow-template approve action gate failed: ${nextErrors.join("; ")}`);
|
|
4810
|
+
}
|
|
4811
|
+
function validateOptionalBoolean(errors, value, fieldName, pathName) {
|
|
4812
|
+
if (value[fieldName] !== void 0 && typeof value[fieldName] !== "boolean") {
|
|
4813
|
+
errors.push(`${pathName}.${fieldName} must be a boolean when provided.`);
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
function validateFlowTemplatePluginRejectionControl(value, errors) {
|
|
4817
|
+
const nextErrors = [];
|
|
4818
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
4819
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
4820
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
|
|
4821
|
+
nodes.forEach((node, nodeIndex) => {
|
|
4822
|
+
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
|
|
4823
|
+
const config = node.plugin_rejection_control;
|
|
4824
|
+
const pathName = `${nodeName}.plugin_rejection_control`;
|
|
4825
|
+
if (config === void 0 || config === null || config === "") {
|
|
4826
|
+
return;
|
|
4827
|
+
}
|
|
4828
|
+
if (!isRecord3(config)) {
|
|
4829
|
+
nextErrors.push(`${pathName} must be an object when configured.`);
|
|
4830
|
+
return;
|
|
4831
|
+
}
|
|
4832
|
+
validateOptionalBoolean(nextErrors, config, "enabled", pathName);
|
|
4833
|
+
validateOptionalBoolean(nextErrors, config, "disabled_form_validate", pathName);
|
|
4834
|
+
[
|
|
4835
|
+
"reject_to_pre",
|
|
4836
|
+
"reject_to_owner",
|
|
4837
|
+
"reject_to_specific_step",
|
|
4838
|
+
"reject_to_end",
|
|
4839
|
+
"review_default",
|
|
4840
|
+
"review_to_me",
|
|
4841
|
+
"review_to_all",
|
|
4842
|
+
"review_to_any_node"
|
|
4843
|
+
].forEach((fieldName) => validateOptionalBoolean(nextErrors, config, fieldName, pathName));
|
|
4844
|
+
if (config.enabled !== true) {
|
|
4845
|
+
return;
|
|
4846
|
+
}
|
|
4847
|
+
if (typeof config.button_text !== "string" || !config.button_text.trim()) {
|
|
4848
|
+
nextErrors.push(`${pathName}.button_text is required when plugin rejection control is enabled.`);
|
|
4849
|
+
}
|
|
4850
|
+
const hasNativeRejectTarget = typeof node.approve_fail === "string" && node.approve_fail.trim() || Array.isArray(node.approve_fail_actions) && node.approve_fail_actions.length > 0;
|
|
4851
|
+
const hasPluginRejectMethod = config.reject_to_pre === true || config.reject_to_owner === true || config.reject_to_specific_step === true || config.reject_to_end === true;
|
|
4852
|
+
if (!hasNativeRejectTarget && !hasPluginRejectMethod) {
|
|
4853
|
+
nextErrors.push(
|
|
4854
|
+
`${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.`
|
|
4855
|
+
);
|
|
4856
|
+
}
|
|
4857
|
+
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) {
|
|
4858
|
+
nextErrors.push(
|
|
4859
|
+
`${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.`
|
|
4860
|
+
);
|
|
4861
|
+
}
|
|
4862
|
+
});
|
|
4863
|
+
if (!nextErrors.length) {
|
|
4864
|
+
return;
|
|
4865
|
+
}
|
|
4866
|
+
if (errors) {
|
|
4867
|
+
errors.push(...nextErrors);
|
|
4868
|
+
return;
|
|
4869
|
+
}
|
|
4870
|
+
throw new Error(`flow-template plugin rejection control gate failed: ${nextErrors.join("; ")}`);
|
|
4871
|
+
}
|
|
4872
|
+
var FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS = /* @__PURE__ */ new Set([
|
|
4873
|
+
"eq",
|
|
4874
|
+
"ne",
|
|
4875
|
+
"gt",
|
|
4876
|
+
"gte",
|
|
4877
|
+
"lt",
|
|
4878
|
+
"lte",
|
|
4879
|
+
"contains",
|
|
4880
|
+
"isEmpty",
|
|
4881
|
+
"isNotEmpty"
|
|
4882
|
+
]);
|
|
4883
|
+
function validateFlowTemplateStandardConditionEditorRules(value, errors) {
|
|
4884
|
+
const nextErrors = [];
|
|
4885
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
4886
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
|
|
4887
|
+
const visitConditionGroup = (group, pathName) => {
|
|
4888
|
+
if (!isRecord3(group)) {
|
|
4889
|
+
nextErrors.push(`${pathName} must be a condition group object with logic and conditions.`);
|
|
4890
|
+
return;
|
|
4891
|
+
}
|
|
4892
|
+
const logic = typeof group.logic === "string" ? group.logic.trim() : "AND";
|
|
4893
|
+
if (logic !== "AND" && logic !== "OR") {
|
|
4894
|
+
nextErrors.push(`${pathName}.logic must be AND or OR.`);
|
|
4895
|
+
}
|
|
4896
|
+
if (!Array.isArray(group.conditions)) {
|
|
4897
|
+
nextErrors.push(`${pathName}.conditions must be an array.`);
|
|
4898
|
+
return;
|
|
4899
|
+
}
|
|
4900
|
+
group.conditions.forEach((condition, conditionIndex) => {
|
|
4901
|
+
const conditionPath = `${pathName}.conditions[${conditionIndex}]`;
|
|
4902
|
+
if (!isRecord3(condition)) {
|
|
4903
|
+
nextErrors.push(`${conditionPath} must be a condition object or nested condition group.`);
|
|
4904
|
+
return;
|
|
4905
|
+
}
|
|
4906
|
+
if (Array.isArray(condition.conditions) || typeof condition.logic === "string") {
|
|
4907
|
+
visitConditionGroup(condition, conditionPath);
|
|
4908
|
+
return;
|
|
4909
|
+
}
|
|
4910
|
+
const leftValue = typeof condition.leftValue === "string" ? condition.leftValue.trim() : "";
|
|
4911
|
+
if (!leftValue) {
|
|
4912
|
+
nextErrors.push(`${conditionPath}.leftValue is required and must match a form_template rule.field value.`);
|
|
4913
|
+
}
|
|
4914
|
+
const leftValueType = typeof condition.leftValueType === "string" && condition.leftValueType.trim() ? condition.leftValueType.trim() : "field";
|
|
4915
|
+
if (leftValueType !== "field" && leftValueType !== "constant" && leftValueType !== "variable") {
|
|
4916
|
+
nextErrors.push(`${conditionPath}.leftValueType must be field, constant, or variable.`);
|
|
4917
|
+
}
|
|
4918
|
+
const operator = typeof condition.operator === "string" ? condition.operator.trim() : "";
|
|
4919
|
+
if (!operator || !FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS.has(operator)) {
|
|
4920
|
+
nextErrors.push(`${conditionPath}.operator must be one of ${Array.from(FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS).join(", ")}.`);
|
|
4921
|
+
}
|
|
4922
|
+
const rightValueType = typeof condition.rightValueType === "string" && condition.rightValueType.trim() ? condition.rightValueType.trim() : "constant";
|
|
4923
|
+
if (rightValueType !== "field" && rightValueType !== "constant" && rightValueType !== "variable") {
|
|
4924
|
+
nextErrors.push(`${conditionPath}.rightValueType must be field, constant, or variable.`);
|
|
4925
|
+
}
|
|
4926
|
+
const isWewfDerived = condition._wewf_operator !== void 0 || condition._wewf_source_rule_id !== void 0 || condition._wewf_field_key !== void 0;
|
|
4927
|
+
if (isWewfDerived && condition._bpmax_editor_field_resolved !== true) {
|
|
4928
|
+
nextErrors.push(
|
|
4929
|
+
`${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.`
|
|
4930
|
+
);
|
|
4931
|
+
}
|
|
4932
|
+
if (isWewfDerived && typeof condition._wewf_field_key === "string" && condition._wewf_field_key.trim() && condition._wewf_field_key.trim() === leftValue && !leftValue.includes(".")) {
|
|
4933
|
+
nextErrors.push(
|
|
4934
|
+
`${conditionPath}.leftValue (${leftValue}) still looks like a raw WEWF field key; standard condition editor values must use the BPMAX form_template rule.field value.`
|
|
4935
|
+
);
|
|
4936
|
+
}
|
|
4937
|
+
});
|
|
4938
|
+
};
|
|
4939
|
+
nodes.forEach((node, nodeIndex) => {
|
|
4940
|
+
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
|
|
4941
|
+
const conditionalNodes = Array.isArray(node.condational_nodes) ? node.condational_nodes : [];
|
|
4942
|
+
conditionalNodes.forEach((conditionNode, conditionIndex) => {
|
|
4943
|
+
if (!isRecord3(conditionNode)) {
|
|
4944
|
+
return;
|
|
4945
|
+
}
|
|
4946
|
+
const conditionMode = typeof conditionNode.condition_mode === "string" && conditionNode.condition_mode.trim() ? conditionNode.condition_mode.trim() : "code";
|
|
4947
|
+
if (conditionMode !== "standard") {
|
|
4948
|
+
return;
|
|
4949
|
+
}
|
|
4950
|
+
const conditionPath = `${nodeName}.condational_nodes[${conditionIndex}]`;
|
|
4951
|
+
if (!Array.isArray(conditionNode.condition_result_rules)) {
|
|
4952
|
+
nextErrors.push(`${conditionPath}.condition_result_rules must be an array when condition_mode is standard.`);
|
|
4953
|
+
return;
|
|
4954
|
+
}
|
|
4955
|
+
const resultLength = Array.isArray(conditionNode.result) ? conditionNode.result.length : 0;
|
|
4956
|
+
if (conditionNode.condition_result_rules.length !== resultLength) {
|
|
4957
|
+
nextErrors.push(`${conditionPath}.condition_result_rules length must equal result length (${resultLength}).`);
|
|
4958
|
+
}
|
|
4959
|
+
conditionNode.condition_result_rules.forEach((group, groupIndex) => {
|
|
4960
|
+
visitConditionGroup(group, `${conditionPath}.condition_result_rules[${groupIndex}]`);
|
|
4961
|
+
});
|
|
4962
|
+
});
|
|
4963
|
+
});
|
|
4964
|
+
if (!nextErrors.length) {
|
|
4965
|
+
return;
|
|
4966
|
+
}
|
|
4967
|
+
if (errors) {
|
|
4968
|
+
errors.push(...nextErrors);
|
|
4969
|
+
return;
|
|
4970
|
+
}
|
|
4971
|
+
throw new Error(`flow-template standard condition editor gate failed: ${nextErrors.join("; ")}`);
|
|
4972
|
+
}
|
|
4337
4973
|
function looksLikeParseEvalFunctionBody(script) {
|
|
4338
4974
|
const text5 = script.trim();
|
|
4339
4975
|
if (!text5) {
|
|
@@ -4701,14 +5337,191 @@ function lintListTemplateQuerySafety(content, errors) {
|
|
|
4701
5337
|
/* @__PURE__ */ new Set(["$template", "customQuery", "beforeSearch", "tabFilters", "query", "url", "api", "dataSource"])
|
|
4702
5338
|
);
|
|
4703
5339
|
queryTexts.forEach((text5) => {
|
|
4704
|
-
if (!text5.trim() || /bpmax-allow-user-scope-project-list\s
|
|
5340
|
+
if (!text5.trim() || /bpmax-allow-user-scope-project-list[ \t]*:[ \t]*[^\s\r\n][^\r\n]{2,}/i.test(text5)) {
|
|
4705
5341
|
return;
|
|
4706
5342
|
}
|
|
4707
5343
|
if (/(\/bpmax\/project\/list|\/api\/project\/list|ESProjectList)/i.test(text5)) {
|
|
4708
5344
|
errors.push("list-template query safety gate forbids /bpmax/project/list, /api/project/list, or ESProjectList unless the script includes bpmax-allow-user-scope-project-list: <reason>.");
|
|
4709
5345
|
}
|
|
4710
|
-
if (/\bdata_set_id\b/i.test(text5) && /(raw-es-search|project\/list|ESProjectList|\$esQuery|query|search)/i.test(text5)) {
|
|
4711
|
-
errors.push("list-template query safety gate forbids using data_set_id as an ES/project query entrypoint; use data_set_key with raw-es-search or ctx.$esQuery instead.");
|
|
5346
|
+
if (/\bdata_set_id\b/i.test(text5) && /(raw-es-search|project\/list|ESProjectList|\$esQuery|query|search)/i.test(text5)) {
|
|
5347
|
+
errors.push("list-template query safety gate forbids using data_set_id as an ES/project query entrypoint; use data_set_key with raw-es-search or ctx.$esQuery instead.");
|
|
5348
|
+
}
|
|
5349
|
+
});
|
|
5350
|
+
}
|
|
5351
|
+
var CONSOLE_TEMPLATE_SUPPORTED_DATA_SOURCE_DRIVERS = /* @__PURE__ */ new Set(["es", "mysql", "customer", "custom_bpmax", "service"]);
|
|
5352
|
+
var CONSOLE_TEMPLATE_OVERVIEW_SUPPORTED_ICONS = /* @__PURE__ */ new Set(["total", "finished", "delay_warning", "delay"]);
|
|
5353
|
+
function consoleTemplateModuleLabel(module, index) {
|
|
5354
|
+
const name = typeof module.name === "string" && module.name.trim() ? module.name.trim() : "<unnamed>";
|
|
5355
|
+
const id = module.i ?? module.id ?? module.key;
|
|
5356
|
+
return id === void 0 || id === null || id === "" ? `${name}[${index}]` : `${name}[${String(id)}]`;
|
|
5357
|
+
}
|
|
5358
|
+
function consoleTemplateHasCtxConfigFallback(script) {
|
|
5359
|
+
const compact = script.replace(/\s+/g, "");
|
|
5360
|
+
return [
|
|
5361
|
+
"ctx.config||{}",
|
|
5362
|
+
"ctx.config??{}",
|
|
5363
|
+
"constcfg=ctx.config||{}",
|
|
5364
|
+
"constcfg=ctx.config??{}",
|
|
5365
|
+
"{config={}}=ctx",
|
|
5366
|
+
"{config={}}=ctx||{}"
|
|
5367
|
+
].some((pattern) => compact.includes(pattern));
|
|
5368
|
+
}
|
|
5369
|
+
function lintConsoleTemplateDataSource(dataSource, moduleLabel, errors) {
|
|
5370
|
+
const text5 = typeof dataSource === "string" ? dataSource : JSON.stringify(dataSource) ?? "";
|
|
5371
|
+
const projectListWaiver = typeof dataSource === "string" && /bpmax-allow-user-scope-project-list[ \t]*:[ \t]*[^\s\r\n][^\r\n]{2,}/i.test(dataSource);
|
|
5372
|
+
if (!text5.trim()) {
|
|
5373
|
+
return;
|
|
5374
|
+
}
|
|
5375
|
+
if (/raw-es-search/i.test(text5)) {
|
|
5376
|
+
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`);
|
|
5377
|
+
}
|
|
5378
|
+
const driverPattern = /['\"]?driver['\"]?\s*:\s*['\"]([^'\"]+)['\"]/g;
|
|
5379
|
+
let match;
|
|
5380
|
+
while (match = driverPattern.exec(text5)) {
|
|
5381
|
+
const driver = match[1];
|
|
5382
|
+
if (driver && !CONSOLE_TEMPLATE_SUPPORTED_DATA_SOURCE_DRIVERS.has(driver)) {
|
|
5383
|
+
errors.push(`${moduleLabel} dataSource driver ${driver} \u4E0D\u53D7\u652F\u6301\uFF1B\u5141\u8BB8\u503C\uFF1Aes/mysql/customer/custom_bpmax/service\u3002`);
|
|
5384
|
+
}
|
|
5385
|
+
}
|
|
5386
|
+
if (/['\"]?driver['\"]?\s*:/i.test(text5) && !/['\"]?driver['\"]?\s*:\s*['\"][^'\"]+['\"]/i.test(text5)) {
|
|
5387
|
+
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`);
|
|
5388
|
+
}
|
|
5389
|
+
if (/\[\s*['\"][^\]]+['\"]\s*(?:\+[^\]]*)?\]\s*:/i.test(text5)) {
|
|
5390
|
+
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`);
|
|
5391
|
+
}
|
|
5392
|
+
if (/\bdata_set_id\b/i.test(text5) && /(raw-es-search|project\/list|ESProjectList|\$esQuery|query|search)/i.test(text5)) {
|
|
5393
|
+
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`);
|
|
5394
|
+
}
|
|
5395
|
+
if (/(\/bpmax\/project\/list|\/api\/project\/list|ESProjectList)/i.test(text5) && !projectListWaiver) {
|
|
5396
|
+
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`);
|
|
5397
|
+
}
|
|
5398
|
+
}
|
|
5399
|
+
function lintConsoleTemplateWildcardFallback(value, path15, errors) {
|
|
5400
|
+
if (typeof value === "string") {
|
|
5401
|
+
const scriptedWildcard = /(?:wildcard|value)\s*:\s*['\"](\*{1,2})['\"]/i.exec(value);
|
|
5402
|
+
if (scriptedWildcard) {
|
|
5403
|
+
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`);
|
|
5404
|
+
}
|
|
5405
|
+
return;
|
|
5406
|
+
}
|
|
5407
|
+
if (Array.isArray(value)) {
|
|
5408
|
+
value.forEach((item, index) => lintConsoleTemplateWildcardFallback(item, `${path15}[${index}]`, errors));
|
|
5409
|
+
return;
|
|
5410
|
+
}
|
|
5411
|
+
if (!isRecord3(value)) {
|
|
5412
|
+
return;
|
|
5413
|
+
}
|
|
5414
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
5415
|
+
const nextPath = `${path15}.${key}`;
|
|
5416
|
+
if ((key === "wildcard" || key === "value") && (item === "*" || item === "**")) {
|
|
5417
|
+
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`);
|
|
5418
|
+
}
|
|
5419
|
+
lintConsoleTemplateWildcardFallback(item, nextPath, errors);
|
|
5420
|
+
});
|
|
5421
|
+
}
|
|
5422
|
+
function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLabel, errors) {
|
|
5423
|
+
if (typeof script !== "string") {
|
|
5424
|
+
return;
|
|
5425
|
+
}
|
|
5426
|
+
const hasRowLoop = /\.(forEach|map|reduce|filter)\s*\(|for\s*\([^)]*\b(of|in)\b/i.test(script);
|
|
5427
|
+
const hasMetric = /(count|total|amount|qty|quantity|inventory|stock|sale|销量|库存|项目数|数量|金额|合计|总数)/i.test(script);
|
|
5428
|
+
const dataSourceText = typeof dataSource === "string" ? dataSource : JSON.stringify(dataSource) ?? "";
|
|
5429
|
+
const hasAggregation = /(aggs|aggregations)\b|size\s*:\s*0|['\"]size['\"]\s*:\s*0/i.test(`${dataSourceText}
|
|
5430
|
+
${script}`);
|
|
5431
|
+
if (hasRowLoop && hasMetric && !hasAggregation) {
|
|
5432
|
+
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`);
|
|
5433
|
+
}
|
|
5434
|
+
}
|
|
5435
|
+
function lintConsoleTemplateOverviewScript(script, moduleLabel, errors, warnings) {
|
|
5436
|
+
if (typeof script !== "string") {
|
|
5437
|
+
return;
|
|
5438
|
+
}
|
|
5439
|
+
const compact = script.replace(/\s+/g, "");
|
|
5440
|
+
if (!compact.includes("return[") && !/return\s+\[/.test(script)) {
|
|
5441
|
+
errors.push(`${moduleLabel} config \u811A\u672C\u5FC5\u987B return KPI \u5361\u7247\u6570\u7EC4\u3002`);
|
|
5442
|
+
}
|
|
5443
|
+
["title", "amount", "icon"].forEach((key) => {
|
|
5444
|
+
if (!script.includes(key)) {
|
|
5445
|
+
errors.push(`${moduleLabel} config \u811A\u672C\u8FD4\u56DE\u7684\u5361\u7247\u5BF9\u8C61\u5FC5\u987B\u5305\u542B ${key}\u3002`);
|
|
5446
|
+
}
|
|
5447
|
+
});
|
|
5448
|
+
["echarts", "xAxis", "yAxis", "series"].forEach((token) => {
|
|
5449
|
+
if (script.includes(token)) {
|
|
5450
|
+
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`);
|
|
5451
|
+
}
|
|
5452
|
+
});
|
|
5453
|
+
const iconPattern = /(?:icon|['\"]icon['\"])\s*:\s*['\"]([^'\"]+)['\"]/g;
|
|
5454
|
+
let match;
|
|
5455
|
+
while (match = iconPattern.exec(script)) {
|
|
5456
|
+
const icon = match[1];
|
|
5457
|
+
if (icon && !CONSOLE_TEMPLATE_OVERVIEW_SUPPORTED_ICONS.has(icon)) {
|
|
5458
|
+
errors.push(`${moduleLabel} \u4F7F\u7528\u4E86\u4E0D\u652F\u6301\u7684\u6570\u636E\u6982\u51B5 icon: ${icon}\u3002`);
|
|
5459
|
+
}
|
|
5460
|
+
}
|
|
5461
|
+
}
|
|
5462
|
+
function lintConsoleTemplateModule(module, index, errors, warnings) {
|
|
5463
|
+
const moduleLabel = consoleTemplateModuleLabel(module, index);
|
|
5464
|
+
const name = typeof module.name === "string" ? module.name : "";
|
|
5465
|
+
const config = isRecord3(module.config) ? module.config : void 0;
|
|
5466
|
+
if (!config) {
|
|
5467
|
+
errors.push(`${moduleLabel} config \u5FC5\u987B\u662F\u5BF9\u8C61\u3002`);
|
|
5468
|
+
return;
|
|
5469
|
+
}
|
|
5470
|
+
const requiredByName = {
|
|
5471
|
+
\u56FE\u8868: ["title", "height", "dataSource", "config"],
|
|
5472
|
+
\u4E00\u822C\u8868\u683C: ["title", "height", "page_size", "exportCount", "dataSource", "config"],
|
|
5473
|
+
\u6570\u636E\u6982\u51B5: ["title", "height", "dataSource", "config"]
|
|
5474
|
+
};
|
|
5475
|
+
const missing = (requiredByName[name] ?? []).filter((key) => config[key] === void 0 || config[key] === null || config[key] === "");
|
|
5476
|
+
if (missing.length) {
|
|
5477
|
+
errors.push(`${moduleLabel} \u7F3A\u5C11\u5FC5\u586B\u914D\u7F6E\uFF1A${missing.join(", ")}\u3002`);
|
|
5478
|
+
}
|
|
5479
|
+
lintConsoleTemplateDataSource(config.dataSource, moduleLabel, errors);
|
|
5480
|
+
lintConsoleTemplateWildcardFallback(config.dataSource, `${moduleLabel}.dataSource`, errors);
|
|
5481
|
+
const configScript = config.config;
|
|
5482
|
+
lintConsoleTemplateWildcardFallback(configScript, `${moduleLabel}.config`, errors);
|
|
5483
|
+
if (typeof configScript === "string") {
|
|
5484
|
+
if (name === "\u56FE\u8868" && configScript.includes("ctx.config") && !consoleTemplateHasCtxConfigFallback(configScript)) {
|
|
5485
|
+
errors.push(`${moduleLabel} config \u811A\u672C\u5F15\u7528 ctx.config \u65F6\u5FC5\u987B\u63D0\u4F9B\u7A7A\u5BF9\u8C61 fallback\u3002`);
|
|
5486
|
+
}
|
|
5487
|
+
if (name === "\u4E00\u822C\u8868\u683C") {
|
|
5488
|
+
if (/\$\{\s*(page_size|offset)\s*\}/.test(configScript)) {
|
|
5489
|
+
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`);
|
|
5490
|
+
}
|
|
5491
|
+
const compact = configScript.replace(/\s+/g, "");
|
|
5492
|
+
if (compact.includes("cfg.page_size") && !configScript.includes("ctx.pageInfo") && !configScript.includes("allRows")) {
|
|
5493
|
+
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`);
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5496
|
+
}
|
|
5497
|
+
lintConsoleTemplateFrontendDetailCounting(configScript, config.dataSource, moduleLabel, errors);
|
|
5498
|
+
if (name === "\u6570\u636E\u6982\u51B5") {
|
|
5499
|
+
lintConsoleTemplateOverviewScript(configScript, moduleLabel, errors, warnings);
|
|
5500
|
+
}
|
|
5501
|
+
const serialized = jsonString(config);
|
|
5502
|
+
if (serialized.includes("${page_size}") || serialized.includes("${offset}")) {
|
|
5503
|
+
errors.push(`${moduleLabel} \u5305\u542B\u7981\u6B62\u7684\u524D\u7AEF\u5206\u9875\u5360\u4F4D\u7B26 \${page_size}/\${offset}\u3002`);
|
|
5504
|
+
}
|
|
5505
|
+
}
|
|
5506
|
+
function lintConsoleTemplateWork(value, errors, warnings) {
|
|
5507
|
+
if (value.flow_type === "" || value.flow_key === "") {
|
|
5508
|
+
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.");
|
|
5509
|
+
}
|
|
5510
|
+
const content = parseTemplateContent(value, errors);
|
|
5511
|
+
if (!isRecord3(content)) {
|
|
5512
|
+
errors.push("console-template content must be an object.");
|
|
5513
|
+
return;
|
|
5514
|
+
}
|
|
5515
|
+
const layout = Array.isArray(content.layout) ? content.layout : Array.isArray(value.modules) ? value.modules : [];
|
|
5516
|
+
if (!Array.isArray(layout) || layout.length === 0) {
|
|
5517
|
+
errors.push("console-template content.layout must contain at least one module.");
|
|
5518
|
+
return;
|
|
5519
|
+
}
|
|
5520
|
+
layout.forEach((item, index) => {
|
|
5521
|
+
if (isRecord3(item)) {
|
|
5522
|
+
lintConsoleTemplateModule(item, index, errors, warnings);
|
|
5523
|
+
} else {
|
|
5524
|
+
errors.push(`console-template content.layout[${index}] must be an object.`);
|
|
4712
5525
|
}
|
|
4713
5526
|
});
|
|
4714
5527
|
}
|
|
@@ -4910,6 +5723,14 @@ function normalizePageTemplatePayload(domain, work) {
|
|
|
4910
5723
|
if (domain === "list-template") {
|
|
4911
5724
|
validateListTemplateActionGate(work);
|
|
4912
5725
|
}
|
|
5726
|
+
if (domain === "console-template") {
|
|
5727
|
+
const errors = [];
|
|
5728
|
+
const warnings = [];
|
|
5729
|
+
lintConsoleTemplateWork(work, errors, warnings);
|
|
5730
|
+
if (errors.length) {
|
|
5731
|
+
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
5732
|
+
}
|
|
5733
|
+
}
|
|
4913
5734
|
const basic = isRecord3(work.basic) ? work.basic : work;
|
|
4914
5735
|
const rawContent = work.content ?? basic.content;
|
|
4915
5736
|
const type = definition.expectedType;
|
|
@@ -5008,6 +5829,10 @@ function normalizeFlowTemplatePayload(work) {
|
|
|
5008
5829
|
validateFlowTemplateRemoteTemplateRefs({ ...work, data });
|
|
5009
5830
|
validateFlowTemplateProjectAfterCreatePath({ ...work, data });
|
|
5010
5831
|
validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
|
|
5832
|
+
validateFlowTemplateStartConditionalJump({ ...work, data });
|
|
5833
|
+
validateFlowTemplateApproveActionShape({ ...work, data });
|
|
5834
|
+
validateFlowTemplatePluginRejectionControl({ ...work, data });
|
|
5835
|
+
validateFlowTemplateStandardConditionEditorRules({ ...work, data });
|
|
5011
5836
|
validateFlowTemplateCodeModeMessages({ ...work, data });
|
|
5012
5837
|
validateFlowTemplateRuntimeScripts({ ...work, data });
|
|
5013
5838
|
validateFlowTemplateFeishuChatPlugin({ ...work, data });
|
|
@@ -5037,18 +5862,60 @@ function normalizeFlowTemplatePayload(work) {
|
|
|
5037
5862
|
}
|
|
5038
5863
|
return payload;
|
|
5039
5864
|
}
|
|
5865
|
+
function validateNonEmptyFlowCreatePayload(payload) {
|
|
5866
|
+
const data = payload.data;
|
|
5867
|
+
if (!isRecord3(data) || !Array.isArray(data.nodes) || data.nodes.length === 0) {
|
|
5868
|
+
throw new Error("flow-template create refuses an empty flow; data.nodes must contain at least one node.");
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5871
|
+
function validateNonEmptyFormCreatePayload(payload) {
|
|
5872
|
+
if (!String(payload.name ?? "").trim()) {
|
|
5873
|
+
throw new Error("form-template create requires name.");
|
|
5874
|
+
}
|
|
5875
|
+
if (!Array.isArray(payload.rule) || payload.rule.flat().length === 0 || !Array.isArray(payload.value) || payload.value.length === 0) {
|
|
5876
|
+
throw new Error("form-template create refuses an empty form; rule and value must contain at least one field.");
|
|
5877
|
+
}
|
|
5878
|
+
}
|
|
5040
5879
|
function buildWorkspaceFlowBindingKey(flowType, flowKey) {
|
|
5041
5880
|
return `${String(flowType || "default")}:${String(flowKey || "")}`;
|
|
5042
5881
|
}
|
|
5043
5882
|
function normalizeWorkspaceFlowItems(value) {
|
|
5044
5883
|
if (!Array.isArray(value)) {
|
|
5045
|
-
|
|
5884
|
+
throw new Error("workspace_flow must be an array.");
|
|
5046
5885
|
}
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5886
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5887
|
+
return value.map((item, index) => {
|
|
5888
|
+
if (!isRecord3(item)) {
|
|
5889
|
+
throw new Error(`workspace_flow[${index}] must be an object.`);
|
|
5890
|
+
}
|
|
5891
|
+
if (typeof item.flow_type !== "string" || !item.flow_type.trim()) {
|
|
5892
|
+
throw new Error(`workspace_flow[${index}].flow_type must be a non-empty string.`);
|
|
5893
|
+
}
|
|
5894
|
+
if (item.flow_key !== void 0 && typeof item.flow_key !== "string") {
|
|
5895
|
+
throw new Error(`workspace_flow[${index}].flow_key must be a string when provided.`);
|
|
5896
|
+
}
|
|
5897
|
+
if (item.only_in_workspace !== void 0 && item.only_in_workspace !== 0 && item.only_in_workspace !== 1 && item.only_in_workspace !== "0" && item.only_in_workspace !== "1") {
|
|
5898
|
+
throw new Error(`workspace_flow[${index}].only_in_workspace must be 0 or 1.`);
|
|
5899
|
+
}
|
|
5900
|
+
const normalized = {
|
|
5901
|
+
flow_type: item.flow_type.trim(),
|
|
5902
|
+
flow_key: typeof item.flow_key === "string" ? item.flow_key.trim() : "",
|
|
5903
|
+
only_in_workspace: normalizeInt(item.only_in_workspace ?? 0)
|
|
5904
|
+
};
|
|
5905
|
+
const key = buildWorkspaceFlowBindingKey(normalized.flow_type, normalized.flow_key);
|
|
5906
|
+
if (seen.has(key)) {
|
|
5907
|
+
throw new Error(`workspace_flow contains duplicate binding ${key}.`);
|
|
5908
|
+
}
|
|
5909
|
+
seen.add(key);
|
|
5910
|
+
return normalized;
|
|
5911
|
+
});
|
|
5912
|
+
}
|
|
5913
|
+
function workspaceFlowClearIntent(work) {
|
|
5914
|
+
const intent = work.destructive_intent;
|
|
5915
|
+
return work.clear_workspace_flow === true || work.allow_empty_workspace_flow === true || intent === "clear_workspace_flow" || isRecord3(intent) && (intent.clear_workspace_flow === true || intent.clear === true);
|
|
5916
|
+
}
|
|
5917
|
+
function canonicalWorkspaceFlowItems(value) {
|
|
5918
|
+
return normalizeWorkspaceFlowItems(value).sort((left, right) => buildWorkspaceFlowBindingKey(left.flow_type, left.flow_key).localeCompare(buildWorkspaceFlowBindingKey(right.flow_type, right.flow_key)) || Number(left.only_in_workspace) - Number(right.only_in_workspace));
|
|
5052
5919
|
}
|
|
5053
5920
|
function buildWorkspaceFlowSubmitPayload(work) {
|
|
5054
5921
|
const workspace = normalizeWorkspaceKey(String(work.workspace || work.key || ""));
|
|
@@ -5056,6 +5923,9 @@ function buildWorkspaceFlowSubmitPayload(work) {
|
|
|
5056
5923
|
throw new Error("workspace-flow work requires workspace.");
|
|
5057
5924
|
}
|
|
5058
5925
|
const workspaceFlow = normalizeWorkspaceFlowItems(work.workspace_flow ?? work.flows);
|
|
5926
|
+
if (workspaceFlow.length === 0 && !workspaceFlowClearIntent(work)) {
|
|
5927
|
+
throw new Error("workspace-flow refuses to clear all bindings without destructive_intent.clear_workspace_flow=true.");
|
|
5928
|
+
}
|
|
5059
5929
|
return {
|
|
5060
5930
|
workspace,
|
|
5061
5931
|
workspace_flow: workspaceFlow
|
|
@@ -5094,8 +5964,26 @@ function normalizeDatasetPayload(work) {
|
|
|
5094
5964
|
if (id !== void 0 && id !== null && id !== "") {
|
|
5095
5965
|
payload.id = id;
|
|
5096
5966
|
}
|
|
5967
|
+
validateDatasetPayload(payload, mode === "create" ? "create" : "edit");
|
|
5097
5968
|
return payload;
|
|
5098
5969
|
}
|
|
5970
|
+
function validateDatasetPayload(payload, mode) {
|
|
5971
|
+
const required = [
|
|
5972
|
+
["payload.name", payload.name],
|
|
5973
|
+
["payload.basic_table", payload.basic_table],
|
|
5974
|
+
["payload.custom_key", payload.custom_key],
|
|
5975
|
+
["payload.flow_type", payload.flow_type]
|
|
5976
|
+
].filter(([, value]) => typeof value !== "string" || value.trim() === "");
|
|
5977
|
+
if (required.length) {
|
|
5978
|
+
throw new Error(`dataset ${mode} requires identity fields: ${required.map(([key]) => key).join(", ")}.`);
|
|
5979
|
+
}
|
|
5980
|
+
if (mode === "edit" && (payload.id === void 0 || payload.id === null || String(payload.id).trim() === "")) {
|
|
5981
|
+
throw new Error("dataset edit requires payload.id to preserve dataset identity.");
|
|
5982
|
+
}
|
|
5983
|
+
if (!Array.isArray(payload.fields) || payload.fields.length === 0) {
|
|
5984
|
+
throw new Error(`dataset ${mode} requires at least one relationFields field key.`);
|
|
5985
|
+
}
|
|
5986
|
+
}
|
|
5099
5987
|
function firstNonEmpty(...values) {
|
|
5100
5988
|
for (const value of values) {
|
|
5101
5989
|
if (value === null || value === void 0) {
|
|
@@ -5118,6 +6006,62 @@ function exactConfirmOrDryRun(confirm3, expectedConfirm, options = {}) {
|
|
|
5118
6006
|
}
|
|
5119
6007
|
throw new Error(`confirmation text mismatch. expected: ${expectedConfirm}. actual: ${confirm3}.`);
|
|
5120
6008
|
}
|
|
6009
|
+
function configReadbackHint(domain, id) {
|
|
6010
|
+
if (id === void 0 || id === null || id === "") {
|
|
6011
|
+
return null;
|
|
6012
|
+
}
|
|
6013
|
+
const value = String(id);
|
|
6014
|
+
return {
|
|
6015
|
+
command: `bpmax-cli config ${domain} export --id ${value} --inline --format json`,
|
|
6016
|
+
unified_command: `bpmax-cli config readback ${domain} --id ${value} --format json`
|
|
6017
|
+
};
|
|
6018
|
+
}
|
|
6019
|
+
function configResponseKey(domain, payload, response, readback) {
|
|
6020
|
+
if (isRecord3(response)) {
|
|
6021
|
+
const key = response.key ?? response.field ?? response.custom_key;
|
|
6022
|
+
if (key !== void 0) return key;
|
|
6023
|
+
if (isRecord3(response.data)) {
|
|
6024
|
+
const nested = response.data.key ?? response.data.field ?? response.data.custom_key;
|
|
6025
|
+
if (nested !== void 0) return nested;
|
|
6026
|
+
}
|
|
6027
|
+
}
|
|
6028
|
+
if (isRecord3(readback)) {
|
|
6029
|
+
const key = readback.key ?? readback.field ?? readback.custom_key;
|
|
6030
|
+
if (key !== void 0) return key;
|
|
6031
|
+
}
|
|
6032
|
+
if (isRecord3(payload)) {
|
|
6033
|
+
if (domain === "dataset") return payload.custom_key ?? payload.customKey ?? null;
|
|
6034
|
+
return payload.key ?? payload.field ?? null;
|
|
6035
|
+
}
|
|
6036
|
+
return null;
|
|
6037
|
+
}
|
|
6038
|
+
function standardConfigWriteResponse(input) {
|
|
6039
|
+
const resolvedId = input.executedId ?? input.id;
|
|
6040
|
+
return {
|
|
6041
|
+
id: resolvedId,
|
|
6042
|
+
request_id: input.id,
|
|
6043
|
+
key: configResponseKey(input.domain, input.payload, input.response, input.readback),
|
|
6044
|
+
readback_hint: configReadbackHint(input.domain, resolvedId)
|
|
6045
|
+
};
|
|
6046
|
+
}
|
|
6047
|
+
function dryRunFields(expectedConfirm) {
|
|
6048
|
+
return {
|
|
6049
|
+
ok: true,
|
|
6050
|
+
dry_run: true,
|
|
6051
|
+
operation_executed: false,
|
|
6052
|
+
confirm_required: true,
|
|
6053
|
+
required_confirm: expectedConfirm,
|
|
6054
|
+
expected_confirm: expectedConfirm
|
|
6055
|
+
};
|
|
6056
|
+
}
|
|
6057
|
+
function executedFields() {
|
|
6058
|
+
return {
|
|
6059
|
+
ok: true,
|
|
6060
|
+
dry_run: false,
|
|
6061
|
+
operation_executed: true,
|
|
6062
|
+
confirm_required: false
|
|
6063
|
+
};
|
|
6064
|
+
}
|
|
5121
6065
|
function validateDatasetFieldCreatePayload(payload) {
|
|
5122
6066
|
if (!isRecord3(payload)) {
|
|
5123
6067
|
throw new Error("dataset-field create requires an object payload.");
|
|
@@ -5132,13 +6076,33 @@ function validateDatasetFieldCreatePayload(payload) {
|
|
|
5132
6076
|
if (missingSource.length > 0) {
|
|
5133
6077
|
throw new Error(`dataset-field create requires dataset and source mapping fields: ${missingSource.map(([key]) => key).join(", ")}.`);
|
|
5134
6078
|
}
|
|
6079
|
+
validateDatasetFieldRelationMapping(payload);
|
|
6080
|
+
}
|
|
6081
|
+
function validateDatasetFieldRelationMapping(payload) {
|
|
6082
|
+
const relationValues = [payload.source_relation_table, payload.source_relation_field, payload.source_relation_fk];
|
|
6083
|
+
const populated = relationValues.filter((value) => typeof value === "string" && value.trim() !== "").length;
|
|
6084
|
+
if (populated !== 0 && populated !== relationValues.length) {
|
|
6085
|
+
throw new Error("dataset-field relation source mapping requires source_relation_table, source_relation_field, and source_relation_fk together.");
|
|
6086
|
+
}
|
|
6087
|
+
}
|
|
6088
|
+
function assertNoConflictingSourceAliases(source, aliases, label) {
|
|
6089
|
+
const values = aliases.filter((key) => source[key] !== void 0 && source[key] !== null && String(source[key]).trim() !== "").map((key) => String(source[key]).trim());
|
|
6090
|
+
if (new Set(values).size > 1) {
|
|
6091
|
+
throw new Error(`dataset-field ${label} aliases disagree; provide one consistent source mapping value.`);
|
|
6092
|
+
}
|
|
5135
6093
|
}
|
|
5136
6094
|
function normalizeDatasetFieldPayload(work) {
|
|
5137
6095
|
const mode = work.mode;
|
|
5138
6096
|
if (mode !== void 0 && mode !== "edit" && mode !== "create") {
|
|
5139
6097
|
throw new Error("dataset-field typed adapter supports mode edit or create. Delete requires a dedicated adapter.");
|
|
5140
6098
|
}
|
|
5141
|
-
const
|
|
6099
|
+
const hasSourceObject = isRecord3(work.source);
|
|
6100
|
+
const source = hasSourceObject ? work.source : work;
|
|
6101
|
+
if (mode === "create") {
|
|
6102
|
+
assertNoConflictingSourceAliases(source, ["table", "sourceTable", "source_table"], "source table");
|
|
6103
|
+
assertNoConflictingSourceAliases(source, ["field", "sourceField", "source_field"], "source field");
|
|
6104
|
+
assertNoConflictingSourceAliases(source, ["fk", "sourceFk", "source_fk"], "source fk");
|
|
6105
|
+
}
|
|
5142
6106
|
const sourcePayload = isRecord3(work.x_wewf_source_payload) ? work.x_wewf_source_payload : {};
|
|
5143
6107
|
const payload = {
|
|
5144
6108
|
data_set_id: firstNonEmpty(work.data_set_id, work.dataSetId, work.dataset_id, sourcePayload.data_set_id, sourcePayload.dataSetId, sourcePayload.dataset_id),
|
|
@@ -5162,7 +6126,7 @@ function normalizeDatasetFieldPayload(work) {
|
|
|
5162
6126
|
payload.source_fk = virtual.joinField || "";
|
|
5163
6127
|
} else {
|
|
5164
6128
|
payload.source_table = source.table ?? source.sourceTable ?? source.source_table ?? "";
|
|
5165
|
-
payload.source_field = source.field ?? source.sourceField ?? source.source_field ?? "";
|
|
6129
|
+
payload.source_field = hasSourceObject ? source.field ?? source.sourceField ?? source.source_field ?? "" : source.source_field ?? source.sourceField ?? "";
|
|
5166
6130
|
payload.source_fk = source.fk ?? source.sourceFk ?? source.source_fk ?? "";
|
|
5167
6131
|
}
|
|
5168
6132
|
payload.sourceTable = payload.source_table;
|
|
@@ -5170,6 +6134,8 @@ function normalizeDatasetFieldPayload(work) {
|
|
|
5170
6134
|
payload.sourceFk = payload.source_fk;
|
|
5171
6135
|
if (mode === "create") {
|
|
5172
6136
|
validateDatasetFieldCreatePayload(payload);
|
|
6137
|
+
} else {
|
|
6138
|
+
validateDatasetFieldRelationMapping(payload);
|
|
5173
6139
|
}
|
|
5174
6140
|
const advanced = isRecord3(work.advanced) ? work.advanced : {};
|
|
5175
6141
|
if (Object.prototype.hasOwnProperty.call(advanced, "sourceComputed")) {
|
|
@@ -5544,6 +6510,216 @@ function validateFormTemplateValueValidateMaps(payload, errors) {
|
|
|
5544
6510
|
}
|
|
5545
6511
|
}
|
|
5546
6512
|
}
|
|
6513
|
+
function formTemplateControlOptions(rule, value) {
|
|
6514
|
+
const candidates = [
|
|
6515
|
+
rule?.options,
|
|
6516
|
+
isRecord3(rule?.props) ? rule.props.options : void 0,
|
|
6517
|
+
value?.options,
|
|
6518
|
+
isRecord3(value?.value) ? value.value.options : void 0,
|
|
6519
|
+
isRecord3(value?.props) ? value.props.options : void 0
|
|
6520
|
+
];
|
|
6521
|
+
for (const candidate of candidates) {
|
|
6522
|
+
if (Array.isArray(candidate)) {
|
|
6523
|
+
return candidate;
|
|
6524
|
+
}
|
|
6525
|
+
}
|
|
6526
|
+
return [];
|
|
6527
|
+
}
|
|
6528
|
+
function formTemplateControlValueType(rule, value) {
|
|
6529
|
+
if (value && Object.prototype.hasOwnProperty.call(value, "value_type")) {
|
|
6530
|
+
return value.value_type;
|
|
6531
|
+
}
|
|
6532
|
+
if (rule && Object.prototype.hasOwnProperty.call(rule, "value_type")) {
|
|
6533
|
+
return rule.value_type;
|
|
6534
|
+
}
|
|
6535
|
+
if (value && isRecord3(value.value) && Object.prototype.hasOwnProperty.call(value.value, "value_type")) {
|
|
6536
|
+
return value.value.value_type;
|
|
6537
|
+
}
|
|
6538
|
+
return void 0;
|
|
6539
|
+
}
|
|
6540
|
+
function validateRadioFormTemplateControl(field, rule, value, errors) {
|
|
6541
|
+
const options = formTemplateControlOptions(rule, value);
|
|
6542
|
+
if (!options.length) {
|
|
6543
|
+
errors.push(`form-template radio field ${field} must include non-empty options on rule/value before build/submit.`);
|
|
6544
|
+
}
|
|
6545
|
+
for (const [index, option] of options.entries()) {
|
|
6546
|
+
if (!isRecord3(option)) {
|
|
6547
|
+
errors.push(`form-template radio field ${field} options[${index}] must be an object with label/value.`);
|
|
6548
|
+
continue;
|
|
6549
|
+
}
|
|
6550
|
+
const hasLabel = typeof option.label === "string" && option.label.length > 0 || typeof option.title === "string" && option.title.length > 0;
|
|
6551
|
+
const hasValue = Object.prototype.hasOwnProperty.call(option, "value") || Object.prototype.hasOwnProperty.call(option, "key");
|
|
6552
|
+
if (!hasLabel || !hasValue) {
|
|
6553
|
+
errors.push(`form-template radio field ${field} options[${index}] must include label and value.`);
|
|
6554
|
+
}
|
|
6555
|
+
}
|
|
6556
|
+
const valueType = formTemplateControlValueType(rule, value);
|
|
6557
|
+
if (valueType === void 0) {
|
|
6558
|
+
errors.push(`form-template radio field ${field} must include value_type=string.`);
|
|
6559
|
+
} else if (valueType !== "string") {
|
|
6560
|
+
errors.push(`form-template radio field ${field} value_type must be string.`);
|
|
6561
|
+
}
|
|
6562
|
+
const validateMap = value?.validateMap;
|
|
6563
|
+
if (!isRecord3(validateMap) || !Object.prototype.hasOwnProperty.call(validateMap, "required")) {
|
|
6564
|
+
errors.push(`form-template radio field ${field} must include value.validateMap.required.`);
|
|
6565
|
+
}
|
|
6566
|
+
}
|
|
6567
|
+
function validateFormTemplateControlContracts(payload, errors) {
|
|
6568
|
+
const validatePair = (field, rule, value) => {
|
|
6569
|
+
const type = typeof rule?.type === "string" ? rule.type : typeof value?.field_type === "string" ? value.field_type : "";
|
|
6570
|
+
if (type === "serial_number") {
|
|
6571
|
+
errors.push(`form-template field ${field} uses legacy serial_number; use BPMAX frontend control type sn_number.`);
|
|
6572
|
+
}
|
|
6573
|
+
if (type === "sn_number") {
|
|
6574
|
+
return;
|
|
6575
|
+
}
|
|
6576
|
+
if (type === "radio") {
|
|
6577
|
+
validateRadioFormTemplateControl(field, rule, value, errors);
|
|
6578
|
+
}
|
|
6579
|
+
};
|
|
6580
|
+
if (isRecord3(payload.fields)) {
|
|
6581
|
+
for (const [field, bundle] of Object.entries(payload.fields)) {
|
|
6582
|
+
if (!isRecord3(bundle)) {
|
|
6583
|
+
continue;
|
|
6584
|
+
}
|
|
6585
|
+
validatePair(field, isRecord3(bundle.rule) ? bundle.rule : void 0, isRecord3(bundle.value) ? bundle.value : void 0);
|
|
6586
|
+
}
|
|
6587
|
+
}
|
|
6588
|
+
const rawValueByField = /* @__PURE__ */ new Map();
|
|
6589
|
+
if (Array.isArray(payload.value)) {
|
|
6590
|
+
for (const item of payload.value) {
|
|
6591
|
+
if (isRecord3(item) && typeof item.field === "string" && item.field) {
|
|
6592
|
+
rawValueByField.set(item.field, item);
|
|
6593
|
+
}
|
|
6594
|
+
}
|
|
6595
|
+
}
|
|
6596
|
+
if (Array.isArray(payload.rule)) {
|
|
6597
|
+
for (const row of payload.rule) {
|
|
6598
|
+
if (!Array.isArray(row)) {
|
|
6599
|
+
continue;
|
|
6600
|
+
}
|
|
6601
|
+
for (const item of row) {
|
|
6602
|
+
if (!isRecord3(item) || typeof item.field !== "string" || !item.field) {
|
|
6603
|
+
continue;
|
|
6604
|
+
}
|
|
6605
|
+
validatePair(item.field, item, rawValueByField.get(item.field));
|
|
6606
|
+
}
|
|
6607
|
+
}
|
|
6608
|
+
}
|
|
6609
|
+
}
|
|
6610
|
+
var FORM_TEMPLATE_VISUAL_WIDE_TYPES = /* @__PURE__ */ new Set([
|
|
6611
|
+
"sub_form",
|
|
6612
|
+
"i_textarea",
|
|
6613
|
+
"textarea",
|
|
6614
|
+
"rich_text",
|
|
6615
|
+
"editor",
|
|
6616
|
+
"upload",
|
|
6617
|
+
"file",
|
|
6618
|
+
"image",
|
|
6619
|
+
"images",
|
|
6620
|
+
"raw"
|
|
6621
|
+
]);
|
|
6622
|
+
function shouldRunFormTemplateVisualLint(payload) {
|
|
6623
|
+
const lintHints = isRecord3(payload.lintHints) ? payload.lintHints : {};
|
|
6624
|
+
const visualReview = isRecord3(lintHints.visualReview) ? lintHints.visualReview : {};
|
|
6625
|
+
return visualReview.enabled === true || visualReview.required === true || payload.mode === "visual_review";
|
|
6626
|
+
}
|
|
6627
|
+
function formTemplateVisualReviewHints(payload) {
|
|
6628
|
+
const lintHints = isRecord3(payload.lintHints) ? payload.lintHints : {};
|
|
6629
|
+
return isRecord3(lintHints.visualReview) ? lintHints.visualReview : {};
|
|
6630
|
+
}
|
|
6631
|
+
function numericHint(value, fallback) {
|
|
6632
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
6633
|
+
}
|
|
6634
|
+
function formTemplateRuleTitle(rule, value) {
|
|
6635
|
+
const title = rule.title ?? value?.title ?? rule.label ?? value?.label;
|
|
6636
|
+
return typeof title === "string" ? title.trim() : "";
|
|
6637
|
+
}
|
|
6638
|
+
function formTemplateRuleWidth(rule) {
|
|
6639
|
+
const props = isRecord3(rule.props) ? rule.props : {};
|
|
6640
|
+
const candidates = [
|
|
6641
|
+
rule.span,
|
|
6642
|
+
rule.colSpan,
|
|
6643
|
+
rule.width,
|
|
6644
|
+
props.span,
|
|
6645
|
+
props.colSpan,
|
|
6646
|
+
props.width
|
|
6647
|
+
];
|
|
6648
|
+
for (const candidate of candidates) {
|
|
6649
|
+
if (typeof candidate === "number" && Number.isFinite(candidate) && candidate > 0) {
|
|
6650
|
+
return candidate;
|
|
6651
|
+
}
|
|
6652
|
+
if (typeof candidate === "string" && /^\d+$/.test(candidate.trim())) {
|
|
6653
|
+
return Number(candidate.trim());
|
|
6654
|
+
}
|
|
6655
|
+
}
|
|
6656
|
+
return void 0;
|
|
6657
|
+
}
|
|
6658
|
+
function validateStructuredFormTemplateVisualReview(payload, errors) {
|
|
6659
|
+
if (!shouldRunFormTemplateVisualLint(payload)) {
|
|
6660
|
+
return;
|
|
6661
|
+
}
|
|
6662
|
+
const hints = formTemplateVisualReviewHints(payload);
|
|
6663
|
+
if (hints.confirmedNonBehavioralProps !== true) {
|
|
6664
|
+
errors.push(
|
|
6665
|
+
"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."
|
|
6666
|
+
);
|
|
6667
|
+
}
|
|
6668
|
+
if (!Array.isArray(payload.layout) || !isRecord3(payload.fields)) {
|
|
6669
|
+
errors.push("form-template visual lint requires structured work with layout and fields.");
|
|
6670
|
+
return;
|
|
6671
|
+
}
|
|
6672
|
+
const maxColumnsPerRow = Math.floor(numericHint(hints.maxColumnsPerRow, 2));
|
|
6673
|
+
const maxRowTitleChars = Math.floor(numericHint(hints.maxRowTitleChars, 24));
|
|
6674
|
+
const maxTitleCharsInMultiColumn = Math.floor(numericHint(hints.maxTitleCharsInMultiColumn, 12));
|
|
6675
|
+
for (const [rowIndex, row] of payload.layout.entries()) {
|
|
6676
|
+
if (!Array.isArray(row)) {
|
|
6677
|
+
errors.push(`form-template visual lint layout row ${rowIndex} must be an array.`);
|
|
6678
|
+
continue;
|
|
6679
|
+
}
|
|
6680
|
+
if (!row.length) {
|
|
6681
|
+
errors.push(`form-template visual lint layout row ${rowIndex} is empty; remove empty visual rows before submit.`);
|
|
6682
|
+
continue;
|
|
6683
|
+
}
|
|
6684
|
+
if (row.length > maxColumnsPerRow) {
|
|
6685
|
+
errors.push(`form-template visual lint layout row ${rowIndex} has ${row.length} fields; maxColumnsPerRow=${maxColumnsPerRow} for readable desktop data entry.`);
|
|
6686
|
+
}
|
|
6687
|
+
let rowTitleChars = 0;
|
|
6688
|
+
for (const ref of row) {
|
|
6689
|
+
if (typeof ref !== "string" || !ref) {
|
|
6690
|
+
continue;
|
|
6691
|
+
}
|
|
6692
|
+
const bundle = payload.fields[ref];
|
|
6693
|
+
if (!isRecord3(bundle) || !isRecord3(bundle.rule)) {
|
|
6694
|
+
continue;
|
|
6695
|
+
}
|
|
6696
|
+
const value = isRecord3(bundle.value) ? bundle.value : void 0;
|
|
6697
|
+
const rule = bundle.rule;
|
|
6698
|
+
const title = formTemplateRuleTitle(rule, value);
|
|
6699
|
+
rowTitleChars += title.length;
|
|
6700
|
+
const type = typeof rule.type === "string" ? rule.type : typeof value?.field_type === "string" ? value.field_type : "";
|
|
6701
|
+
if (row.length > 1 && FORM_TEMPLATE_VISUAL_WIDE_TYPES.has(type)) {
|
|
6702
|
+
errors.push(`form-template visual lint field ${ref} (${title || type}) type=${type} must be in a single-field row for readable editing.`);
|
|
6703
|
+
}
|
|
6704
|
+
if (row.length > 1 && title.length > maxTitleCharsInMultiColumn) {
|
|
6705
|
+
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.`);
|
|
6706
|
+
}
|
|
6707
|
+
const width = formTemplateRuleWidth(rule);
|
|
6708
|
+
if (row.length > 1 && typeof width === "number" && width > 12) {
|
|
6709
|
+
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.`);
|
|
6710
|
+
}
|
|
6711
|
+
}
|
|
6712
|
+
if (row.length > 1 && rowTitleChars > maxRowTitleChars) {
|
|
6713
|
+
errors.push(`form-template visual lint layout row ${rowIndex} title length total is ${rowTitleChars}; maxRowTitleChars=${maxRowTitleChars}. Split the row for readability.`);
|
|
6714
|
+
}
|
|
6715
|
+
}
|
|
6716
|
+
}
|
|
6717
|
+
function validateFormTemplateWorkLint(payload, errors) {
|
|
6718
|
+
validateFormTemplateNameLength(payload, errors);
|
|
6719
|
+
validateFormTemplateValueValidateMaps(payload, errors);
|
|
6720
|
+
validateFormTemplateControlContracts(payload, errors);
|
|
6721
|
+
validateStructuredFormTemplateVisualReview(payload, errors);
|
|
6722
|
+
}
|
|
5547
6723
|
function stripFormTemplateCreateIds(payload) {
|
|
5548
6724
|
const next = { ...payload };
|
|
5549
6725
|
if (Array.isArray(next.rule)) {
|
|
@@ -5847,23 +7023,42 @@ function validateWorkspacePayload(payload) {
|
|
|
5847
7023
|
throw new Error("workspace entry_path is required.");
|
|
5848
7024
|
}
|
|
5849
7025
|
}
|
|
5850
|
-
|
|
7026
|
+
var WORKSPACE_EDITABLE_FIELDS = [
|
|
7027
|
+
"id",
|
|
7028
|
+
"name",
|
|
7029
|
+
"key",
|
|
7030
|
+
"logo",
|
|
7031
|
+
"bg_img",
|
|
7032
|
+
"icon",
|
|
7033
|
+
"description",
|
|
7034
|
+
"is_system_admin",
|
|
7035
|
+
"admin_ids",
|
|
7036
|
+
"entry_path",
|
|
7037
|
+
"m_entry_path",
|
|
7038
|
+
"origin",
|
|
7039
|
+
"white_list"
|
|
7040
|
+
];
|
|
7041
|
+
function isEmptyConfigValue(value) {
|
|
7042
|
+
return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0 || isRecord3(value) && Object.keys(value).length === 0;
|
|
7043
|
+
}
|
|
7044
|
+
function workspaceClearFields(work) {
|
|
7045
|
+
const intent = isRecord3(work.destructive_intent) ? work.destructive_intent : {};
|
|
7046
|
+
const values = Array.isArray(intent.clear_fields) ? intent.clear_fields : Array.isArray(work.clear_fields) ? work.clear_fields : [];
|
|
7047
|
+
return new Set(values.filter((value) => typeof value === "string"));
|
|
7048
|
+
}
|
|
7049
|
+
function normalizeWorkspacePayload(work, raw) {
|
|
5851
7050
|
const source = isRecord3(work.basic) ? { ...work, ...work.basic } : work;
|
|
5852
|
-
const
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
"m_entry_path",
|
|
5864
|
-
"origin",
|
|
5865
|
-
"white_list"
|
|
5866
|
-
]);
|
|
7051
|
+
const editMode = work.mode !== "create" && raw !== void 0;
|
|
7052
|
+
const baseline = editMode ? pickDefined(raw, WORKSPACE_EDITABLE_FIELDS) : {};
|
|
7053
|
+
const payload = { ...baseline, ...pickDefined(source, WORKSPACE_EDITABLE_FIELDS) };
|
|
7054
|
+
const clearFields = workspaceClearFields(work);
|
|
7055
|
+
if (editMode) {
|
|
7056
|
+
for (const field of WORKSPACE_EDITABLE_FIELDS) {
|
|
7057
|
+
if (Object.prototype.hasOwnProperty.call(source, field) && isEmptyConfigValue(source[field]) && !isEmptyConfigValue(raw?.[field]) && !clearFields.has(field)) {
|
|
7058
|
+
throw new Error(`workspace edit refuses to clear ${field} without destructive_intent.clear_fields including ${field}.`);
|
|
7059
|
+
}
|
|
7060
|
+
}
|
|
7061
|
+
}
|
|
5867
7062
|
payload.name = String(payload.name ?? "").trim();
|
|
5868
7063
|
payload.key = normalizeWorkspaceConfigKey(payload.key);
|
|
5869
7064
|
payload.entry_path = String(payload.entry_path ?? "/myProject").trim() || "/myProject";
|
|
@@ -6405,11 +7600,17 @@ function buildDomainSubmitPayload(domain, work, options = {}, raw) {
|
|
|
6405
7600
|
if (domain === "form-template") {
|
|
6406
7601
|
validateFormTemplateNameLength(work);
|
|
6407
7602
|
if (isRecord3(work.basic) && Array.isArray(work.layout) && isRecord3(work.fields)) {
|
|
6408
|
-
|
|
7603
|
+
const payload2 = buildStructuredFormTemplatePayload(work);
|
|
7604
|
+
if (work.mode === "create") {
|
|
7605
|
+
validateNonEmptyFormCreatePayload(payload2);
|
|
7606
|
+
}
|
|
7607
|
+
return payload2;
|
|
6409
7608
|
}
|
|
6410
7609
|
const payload = pickDefined(work, ["name", "desc", "category", "option", "rule", "value"]);
|
|
6411
7610
|
if (work.mode === "create") {
|
|
6412
|
-
|
|
7611
|
+
const createPayload = stripFormTemplateCreateIds(payload);
|
|
7612
|
+
validateNonEmptyFormCreatePayload(createPayload);
|
|
7613
|
+
return createPayload;
|
|
6413
7614
|
}
|
|
6414
7615
|
if (Array.isArray(payload.value)) {
|
|
6415
7616
|
payload.value = normalizeFormTemplateValueItems(payload.value);
|
|
@@ -6417,13 +7618,17 @@ function buildDomainSubmitPayload(domain, work, options = {}, raw) {
|
|
|
6417
7618
|
return payload;
|
|
6418
7619
|
}
|
|
6419
7620
|
if (domain === "flow-template") {
|
|
6420
|
-
|
|
7621
|
+
const payload = normalizeFlowTemplatePayload(work);
|
|
7622
|
+
if (work.mode === "create") {
|
|
7623
|
+
validateNonEmptyFlowCreatePayload(payload);
|
|
7624
|
+
}
|
|
7625
|
+
return payload;
|
|
6421
7626
|
}
|
|
6422
7627
|
if (domain === "workspace-flow") {
|
|
6423
7628
|
return buildWorkspaceFlowSubmitPayload(work);
|
|
6424
7629
|
}
|
|
6425
7630
|
if (domain === "workspace") {
|
|
6426
|
-
return normalizeWorkspacePayload(work);
|
|
7631
|
+
return normalizeWorkspacePayload(work, isRecord3(raw) ? raw : void 0);
|
|
6427
7632
|
}
|
|
6428
7633
|
if (domain === "dataset") {
|
|
6429
7634
|
return normalizeDatasetPayload(work);
|
|
@@ -6715,10 +7920,15 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
6715
7920
|
validateFlowTemplateRemoteTemplateRefs(work);
|
|
6716
7921
|
validateFlowTemplateProjectAfterCreatePath(work);
|
|
6717
7922
|
validateFlowTemplateStandardPageCreateFormTemplate(work);
|
|
7923
|
+
validateFlowTemplateStartConditionalJump(work);
|
|
7924
|
+
validateFlowTemplateApproveActionShape(work);
|
|
7925
|
+
validateFlowTemplatePluginRejectionControl(work);
|
|
7926
|
+
validateFlowTemplateStandardConditionEditorRules(work);
|
|
6718
7927
|
validateFlowTemplateCodeModeMessages(work);
|
|
6719
7928
|
validateFlowTemplateRuntimeScripts(work);
|
|
6720
7929
|
validateFlowTemplateFeishuChatPlugin(work);
|
|
6721
7930
|
validateFlowTemplateFormDrivenCreateBaseline(work, void 0, { context: "flow-template create" });
|
|
7931
|
+
validateNonEmptyFlowCreatePayload(work);
|
|
6722
7932
|
const createShell = {
|
|
6723
7933
|
name: String(work.name || ""),
|
|
6724
7934
|
category: work.category || "system",
|
|
@@ -6730,6 +7940,14 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
6730
7940
|
if (!createShell.name) {
|
|
6731
7941
|
throw new Error("flow-template create requires name.");
|
|
6732
7942
|
}
|
|
7943
|
+
const pluginLint = await runFlowTemplatePluginLint(work, {
|
|
7944
|
+
profile,
|
|
7945
|
+
agent: options.agent || "codex",
|
|
7946
|
+
requireInstalled: true
|
|
7947
|
+
});
|
|
7948
|
+
if (pluginLint?.errors.length) {
|
|
7949
|
+
throw new Error(`flow-template plugin lint failed: ${pluginLint.errors.join("; ")}`);
|
|
7950
|
+
}
|
|
6733
7951
|
const expectedConfirm = `create flow-template ${createShell.name}`;
|
|
6734
7952
|
if (confirm3 !== expectedConfirm) {
|
|
6735
7953
|
return {
|
|
@@ -6742,14 +7960,6 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
6742
7960
|
next: `Run again with --confirm "${expectedConfirm}" to create.`
|
|
6743
7961
|
};
|
|
6744
7962
|
}
|
|
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
7963
|
const client = createApiClient(profile);
|
|
6754
7964
|
const createResponse = await apiRequest(
|
|
6755
7965
|
client,
|
|
@@ -6835,13 +8045,31 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
|
|
|
6835
8045
|
if (!isRecord3(formWork) || formWork.mode !== "create") {
|
|
6836
8046
|
throw new Error("flow-app create requires form work with mode=create.");
|
|
6837
8047
|
}
|
|
8048
|
+
const preflight = await lintFlowAppWorkFiles(formWorkFile, flowWorkFile, {
|
|
8049
|
+
workspace,
|
|
8050
|
+
name,
|
|
8051
|
+
pluginLint: {
|
|
8052
|
+
profile,
|
|
8053
|
+
agent: options.agent || "codex",
|
|
8054
|
+
requireInstalled: true
|
|
8055
|
+
}
|
|
8056
|
+
});
|
|
8057
|
+
const preflightErrors = Array.isArray(preflight.errors) ? preflight.errors.map(String) : [];
|
|
8058
|
+
if (preflightErrors.length) {
|
|
8059
|
+
const errorGroups = isRecord3(preflight.error_groups) ? preflight.error_groups : {};
|
|
8060
|
+
const formErrors = Array.isArray(errorGroups.form_template) ? errorGroups.form_template.map(String) : [];
|
|
8061
|
+
const flowErrors = Array.isArray(errorGroups.flow_template) ? errorGroups.flow_template.map(String) : [];
|
|
8062
|
+
if (formErrors.length) {
|
|
8063
|
+
throw new Error(`form-template lint failed: ${formErrors.join("; ")}`);
|
|
8064
|
+
}
|
|
8065
|
+
if (flowErrors.length && flowErrors.every((error) => error.includes("current-environment remote numeric id"))) {
|
|
8066
|
+
throw new Error(`flow-template online template reference gate failed: ${flowErrors.join("; ")}`);
|
|
8067
|
+
}
|
|
8068
|
+
throw new Error(`flow-app create lint failed: ${preflightErrors.join("; ")}`);
|
|
8069
|
+
}
|
|
6838
8070
|
const formPayload = buildDomainSubmitPayload("form-template", formWork);
|
|
6839
8071
|
const flowWorkRecord = isRecord3(flowWork) ? flowWork : {};
|
|
6840
|
-
|
|
6841
|
-
validateFlowTemplateFormDrivenCreateBaseline(flowWorkRecord, void 0, {
|
|
6842
|
-
force: true,
|
|
6843
|
-
context: "flow-app create"
|
|
6844
|
-
});
|
|
8072
|
+
validateNonEmptyFlowCreatePayload(flowWorkRecord);
|
|
6845
8073
|
const flowShell = {
|
|
6846
8074
|
name: String(flowWorkRecord.name || name),
|
|
6847
8075
|
category: flowWorkRecord.category || "system",
|
|
@@ -6857,25 +8085,43 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
|
|
|
6857
8085
|
{ step: "create_form_template", method: "POST", path: "/form_template", payload: formPayload },
|
|
6858
8086
|
{ step: "publish_form_template", method: "POST", path: "/form_template/publish", payload: { id: "<draft-form-id>" } },
|
|
6859
8087
|
{ step: "create_flow_template", method: "POST", path: "/flow/flow_type", payload: flowShell },
|
|
6860
|
-
{
|
|
6861
|
-
|
|
6862
|
-
|
|
8088
|
+
{
|
|
8089
|
+
step: "save_flow_draft",
|
|
8090
|
+
method: "PUT",
|
|
8091
|
+
path: "/flow?flow_type=<platform-flow-type>&publish=2",
|
|
8092
|
+
payload_summary: flowAppDraftPayloadSummary(flowWorkRecord)
|
|
8093
|
+
},
|
|
8094
|
+
...options.publishLive !== false ? [{
|
|
8095
|
+
step: "publish_flow_live",
|
|
8096
|
+
method: "PUT",
|
|
8097
|
+
path: "/flow?flow_type=<platform-flow-type>&publish=1",
|
|
8098
|
+
payload_summary: flowAppDraftPayloadSummary(flowWorkRecord)
|
|
8099
|
+
}] : [],
|
|
8100
|
+
{
|
|
8101
|
+
step: "bind_workspace_flow",
|
|
8102
|
+
method: "PUT",
|
|
8103
|
+
path: "/workspace/workspace_flow",
|
|
8104
|
+
params: { workspace },
|
|
8105
|
+
payload_summary: {
|
|
8106
|
+
append_binding: { flow_type: "<platform-flow-type>", flow_key: "", only_in_workspace: 0 },
|
|
8107
|
+
replacement_mode: "full workspace_flow replacement guarded by latest readback hash"
|
|
8108
|
+
}
|
|
8109
|
+
},
|
|
6863
8110
|
{ step: "verify_workspace_binding", method: "GET", path: "/workspace/by_key", params: { key: workspace } }
|
|
6864
8111
|
]
|
|
6865
8112
|
};
|
|
6866
8113
|
if (!exactConfirmOrDryRun(confirm3, expectedConfirm, { equivalentConfirms: [acceptedConfirmWithWorkspacePrefix] })) {
|
|
6867
8114
|
return {
|
|
6868
|
-
|
|
6869
|
-
dry_run: true,
|
|
6870
|
-
operation_executed: false,
|
|
6871
|
-
confirm_required: true,
|
|
6872
|
-
expected_confirm: expectedConfirm,
|
|
8115
|
+
...dryRunFields(expectedConfirm),
|
|
6873
8116
|
accepted_confirms: [expectedConfirm, acceptedConfirmWithWorkspacePrefix],
|
|
6874
8117
|
domain: "flow-app",
|
|
6875
8118
|
workspace,
|
|
6876
8119
|
name,
|
|
8120
|
+
preflight,
|
|
6877
8121
|
operation_plan: dryRunPlan,
|
|
6878
8122
|
post_create_checklist: [
|
|
8123
|
+
"Save this dry-run response; operation_plan.save_flow_draft.payload_summary must show data.meta.form_template=<published-form-id> before confirm.",
|
|
8124
|
+
"If project_after_create_path redirects to /project, verify list discoverability after create or add list/default-list configuration.",
|
|
6879
8125
|
"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
8126
|
"Verify matrix rule records contain real approver user values before connecting business flow matrix_owner or cc_matrix.",
|
|
6881
8127
|
"Use bpmax-project safe project create/handoff for matrix rule records; do not treat local seed-rules.json as online data."
|
|
@@ -6990,9 +8236,9 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
|
|
|
6990
8236
|
"/workspace/by_key",
|
|
6991
8237
|
{ params: { key: workspace }, capability: `${workspaceDefinition.capability}.export` }
|
|
6992
8238
|
);
|
|
6993
|
-
const readbackBindings = isRecord3(workspaceReadback) ?
|
|
6994
|
-
if (
|
|
6995
|
-
throw new Error(`flow-app create workspace binding verification failed for ${workspace}
|
|
8239
|
+
const readbackBindings = isRecord3(workspaceReadback) ? canonicalWorkspaceFlowItems(workspaceReadback.workspace_flow) : [];
|
|
8240
|
+
if (JSON.stringify(readbackBindings) !== JSON.stringify(canonicalWorkspaceFlowItems(nextBindings))) {
|
|
8241
|
+
throw new Error(`flow-app create workspace binding verification failed for ${workspace}; exact workspace_flow collection mismatch.`);
|
|
6996
8242
|
}
|
|
6997
8243
|
const flowTemplateId = isRecord3(flowCreateResponse) ? isRecord3(flowCreateResponse.data) ? flowCreateResponse.data.id : flowCreateResponse.id : null;
|
|
6998
8244
|
const evidence = {
|
|
@@ -7008,10 +8254,7 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
|
|
|
7008
8254
|
verified_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7009
8255
|
};
|
|
7010
8256
|
return {
|
|
7011
|
-
|
|
7012
|
-
dry_run: false,
|
|
7013
|
-
operation_executed: true,
|
|
7014
|
-
confirm_required: false,
|
|
8257
|
+
...executedFields(),
|
|
7015
8258
|
domain: "flow-app",
|
|
7016
8259
|
workspace,
|
|
7017
8260
|
name,
|
|
@@ -7525,11 +8768,19 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
7525
8768
|
}
|
|
7526
8769
|
if (domain === "form-template" && isRecord3(work)) {
|
|
7527
8770
|
const errors = [];
|
|
7528
|
-
|
|
8771
|
+
validateFormTemplateWorkLint(work, errors);
|
|
7529
8772
|
if (errors.length) {
|
|
7530
8773
|
throw new Error(`form-template lint failed: ${errors.join("; ")}`);
|
|
7531
8774
|
}
|
|
7532
8775
|
}
|
|
8776
|
+
if (domain === "console-template" && isRecord3(work)) {
|
|
8777
|
+
const errors = [];
|
|
8778
|
+
const warnings = [];
|
|
8779
|
+
lintConsoleTemplateWork(work, errors, warnings);
|
|
8780
|
+
if (errors.length) {
|
|
8781
|
+
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
8782
|
+
}
|
|
8783
|
+
}
|
|
7533
8784
|
const payload = buildDomainSubmitPayload(domain, work, options, raw);
|
|
7534
8785
|
if (domain === "flow-template" && options.publishLive) {
|
|
7535
8786
|
payload.publish_live = true;
|
|
@@ -7561,14 +8812,24 @@ async function runFlowTemplatePluginLint(flowWork, options = {}) {
|
|
|
7561
8812
|
}
|
|
7562
8813
|
const agent = options.agent || "codex";
|
|
7563
8814
|
const client = createApiClient(options.profile);
|
|
7564
|
-
|
|
7565
|
-
|
|
8815
|
+
let platformSkills = [];
|
|
8816
|
+
let discoveryWarning = "";
|
|
8817
|
+
try {
|
|
8818
|
+
platformSkills = await listPluginSkills(client);
|
|
8819
|
+
} catch (error) {
|
|
8820
|
+
discoveryWarning = `Remote plugin lint discovery unavailable; used installed local lint declarations only: ${error instanceof Error ? error.message : String(error)}`;
|
|
8821
|
+
}
|
|
8822
|
+
const result = await lintFlowTemplatePluginExtensions({
|
|
7566
8823
|
profile: options.profile,
|
|
7567
8824
|
agent,
|
|
7568
8825
|
flowWork,
|
|
7569
8826
|
platformSkills,
|
|
7570
8827
|
requireInstalled: Boolean(options.requireInstalled)
|
|
7571
8828
|
});
|
|
8829
|
+
if (discoveryWarning) {
|
|
8830
|
+
result.warnings.push(discoveryWarning);
|
|
8831
|
+
}
|
|
8832
|
+
return result;
|
|
7572
8833
|
}
|
|
7573
8834
|
function hasPotentialFlowTemplatePluginExtension(flowWork) {
|
|
7574
8835
|
if (collectFlowTemplatePluginKeys(flowWork).length) {
|
|
@@ -7604,12 +8865,14 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
7604
8865
|
}
|
|
7605
8866
|
const shouldLintFormTemplate = options.domain ? options.domain === "form-template" : looksLikeFormTemplateWork(value);
|
|
7606
8867
|
if (shouldLintFormTemplate) {
|
|
7607
|
-
|
|
7608
|
-
validateFormTemplateValueValidateMaps(value, errors);
|
|
8868
|
+
validateFormTemplateWorkLint(value, errors);
|
|
7609
8869
|
}
|
|
7610
8870
|
if ((Object.prototype.hasOwnProperty.call(value, "content") || isRecord3(value.basic)) && pageTemplateType(value) === 1) {
|
|
7611
8871
|
validateListTemplateActionGate(value, errors);
|
|
7612
8872
|
}
|
|
8873
|
+
if (options.domain === "console-template" || (Object.prototype.hasOwnProperty.call(value, "content") || isRecord3(value.basic)) && pageTemplateType(value) === 4) {
|
|
8874
|
+
lintConsoleTemplateWork(value, errors, warnings);
|
|
8875
|
+
}
|
|
7613
8876
|
if (value.domain === "nav-config" || Object.prototype.hasOwnProperty.call(value, "configs")) {
|
|
7614
8877
|
lintNavConfigWork(value, errors);
|
|
7615
8878
|
}
|
|
@@ -7618,6 +8881,10 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
7618
8881
|
validateFlowTemplateRemoteTemplateRefs(flowWork, errors);
|
|
7619
8882
|
validateFlowTemplateProjectAfterCreatePath(flowWork, errors);
|
|
7620
8883
|
validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
|
|
8884
|
+
validateFlowTemplateStartConditionalJump(flowWork, errors);
|
|
8885
|
+
validateFlowTemplateApproveActionShape(flowWork, errors);
|
|
8886
|
+
validateFlowTemplatePluginRejectionControl(flowWork, errors);
|
|
8887
|
+
validateFlowTemplateStandardConditionEditorRules(flowWork, errors);
|
|
7621
8888
|
validateFlowTemplateCodeModeMessages(flowWork, errors);
|
|
7622
8889
|
validateFlowTemplateRuntimeScripts(flowWork, errors);
|
|
7623
8890
|
validateFlowTemplateFeishuChatPlugin(flowWork, errors);
|
|
@@ -7689,7 +8956,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7689
8956
|
const expectedConfirm2 = `submit ${domain} ${id}`;
|
|
7690
8957
|
if (confirm3 !== expectedConfirm2) {
|
|
7691
8958
|
return {
|
|
7692
|
-
|
|
8959
|
+
...dryRunFields(expectedConfirm2),
|
|
7693
8960
|
domain,
|
|
7694
8961
|
id,
|
|
7695
8962
|
endpoint: endpoint2,
|
|
@@ -7708,18 +8975,13 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7708
8975
|
{ data: submitPayload2, params: { workspace }, capability: `${definition.capability}.${createMode ? "create" : "submit"}` }
|
|
7709
8976
|
);
|
|
7710
8977
|
const readback2 = await readRemoteConfigDomain(profile, domain, workspace, definition);
|
|
7711
|
-
const bindings = isRecord3(readback2) ?
|
|
7712
|
-
const expectedBindings =
|
|
7713
|
-
|
|
7714
|
-
(expected)
|
|
7715
|
-
(actual) => buildWorkspaceFlowBindingKey(actual.flow_type, actual.flow_key) === buildWorkspaceFlowBindingKey(expected.flow_type, expected.flow_key)
|
|
7716
|
-
)
|
|
7717
|
-
);
|
|
7718
|
-
if (missingBindings.length) {
|
|
7719
|
-
throw new Error(`workspace-flow submit verification failed; missing bindings: ${missingBindings.map((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key)).join(", ")}`);
|
|
8978
|
+
const bindings = isRecord3(readback2) ? canonicalWorkspaceFlowItems(readback2.workspace_flow) : [];
|
|
8979
|
+
const expectedBindings = canonicalWorkspaceFlowItems(submitPayload2.workspace_flow);
|
|
8980
|
+
if (JSON.stringify(bindings) !== JSON.stringify(expectedBindings)) {
|
|
8981
|
+
throw new Error(`workspace-flow submit verification failed; exact collection mismatch. expected=${JSON.stringify(expectedBindings)} actual=${JSON.stringify(bindings)}`);
|
|
7720
8982
|
}
|
|
7721
8983
|
return {
|
|
7722
|
-
|
|
8984
|
+
...executedFields(),
|
|
7723
8985
|
domain,
|
|
7724
8986
|
id,
|
|
7725
8987
|
endpoint: endpoint2,
|
|
@@ -7757,7 +9019,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7757
9019
|
await ensureConfigCapability(profile, `${definition.capability}.export`);
|
|
7758
9020
|
if (confirm3 !== expectedConfirm2) {
|
|
7759
9021
|
return {
|
|
7760
|
-
|
|
9022
|
+
...dryRunFields(expectedConfirm2),
|
|
7761
9023
|
domain,
|
|
7762
9024
|
id,
|
|
7763
9025
|
endpoint: "/workspace",
|
|
@@ -7773,14 +9035,15 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7773
9035
|
{ data: submit2.payload, capability: `${definition.capability}.create` }
|
|
7774
9036
|
);
|
|
7775
9037
|
const readback3 = await readRemoteConfigDomain(profile, domain, `key:${workspaceKey}`, definition);
|
|
9038
|
+
const createdId = responseDataId(response3) ?? (isRecord3(readback3) ? readback3.id ?? null : null);
|
|
7776
9039
|
return {
|
|
7777
|
-
|
|
9040
|
+
...executedFields(),
|
|
7778
9041
|
domain,
|
|
7779
|
-
id,
|
|
9042
|
+
...standardConfigWriteResponse({ domain, id, executedId: createdId, payload: submit2.payload, response: response3, readback: readback3 }),
|
|
7780
9043
|
endpoint: "/workspace",
|
|
7781
9044
|
method: "POST",
|
|
7782
9045
|
response: response3,
|
|
7783
|
-
created_id:
|
|
9046
|
+
created_id: createdId,
|
|
7784
9047
|
readback_hash: hashJson(readback3)
|
|
7785
9048
|
};
|
|
7786
9049
|
}
|
|
@@ -7801,7 +9064,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7801
9064
|
const endpoint2 = `/workspace/${encodeURIComponent(workspaceId)}`;
|
|
7802
9065
|
if (confirm3 !== expectedConfirm2) {
|
|
7803
9066
|
return {
|
|
7804
|
-
|
|
9067
|
+
...dryRunFields(expectedConfirm2),
|
|
7805
9068
|
domain,
|
|
7806
9069
|
id,
|
|
7807
9070
|
endpoint: endpoint2,
|
|
@@ -7820,9 +9083,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7820
9083
|
);
|
|
7821
9084
|
const readback2 = await readRemoteConfigDomain(profile, domain, workspaceKey ? `key:${workspaceKey}` : workspaceId, definition);
|
|
7822
9085
|
return {
|
|
7823
|
-
|
|
9086
|
+
...executedFields(),
|
|
7824
9087
|
domain,
|
|
7825
|
-
id,
|
|
9088
|
+
...standardConfigWriteResponse({ domain, id, payload: submit2.payload, response: response2, readback: readback2 }),
|
|
7826
9089
|
endpoint: endpoint2,
|
|
7827
9090
|
method: "PUT",
|
|
7828
9091
|
response: response2,
|
|
@@ -7872,7 +9135,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7872
9135
|
}
|
|
7873
9136
|
if (confirm3 !== expectedConfirm2) {
|
|
7874
9137
|
return {
|
|
7875
|
-
|
|
9138
|
+
...dryRunFields(expectedConfirm2),
|
|
7876
9139
|
domain,
|
|
7877
9140
|
id,
|
|
7878
9141
|
operation_plan: submit2.payload,
|
|
@@ -7882,7 +9145,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7882
9145
|
};
|
|
7883
9146
|
}
|
|
7884
9147
|
return {
|
|
7885
|
-
|
|
9148
|
+
...executedFields(),
|
|
7886
9149
|
domain,
|
|
7887
9150
|
id,
|
|
7888
9151
|
...domain === "role" ? await submitRoleOperations(profile, id, submit2) : await submitAggregateConfigDomain(profile, domain, id, submit2)
|
|
@@ -7919,14 +9182,25 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7919
9182
|
if (domain === "list-template") {
|
|
7920
9183
|
validateListTemplateActionGate(submit.payload);
|
|
7921
9184
|
}
|
|
9185
|
+
if (domain === "console-template") {
|
|
9186
|
+
const errors = [];
|
|
9187
|
+
const warnings = [];
|
|
9188
|
+
lintConsoleTemplateWork(submit.payload, errors, warnings);
|
|
9189
|
+
if (errors.length) {
|
|
9190
|
+
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
9191
|
+
}
|
|
9192
|
+
}
|
|
7922
9193
|
if (domain === "dataset-field") {
|
|
7923
9194
|
validateDatasetFieldCreatePayload(submit.payload);
|
|
7924
9195
|
}
|
|
9196
|
+
if (domain === "dataset") {
|
|
9197
|
+
validateDatasetPayload(submit.payload, "create");
|
|
9198
|
+
}
|
|
7925
9199
|
await ensureConfigCapability(profile, `${definition.capability}.create`);
|
|
7926
9200
|
const expectedConfirm2 = `submit ${domain} ${id}`;
|
|
7927
9201
|
if (confirm3 !== expectedConfirm2) {
|
|
7928
9202
|
return {
|
|
7929
|
-
|
|
9203
|
+
...dryRunFields(expectedConfirm2),
|
|
7930
9204
|
domain,
|
|
7931
9205
|
id,
|
|
7932
9206
|
endpoint: definition.createPath,
|
|
@@ -7953,9 +9227,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7953
9227
|
}
|
|
7954
9228
|
}
|
|
7955
9229
|
return {
|
|
7956
|
-
|
|
9230
|
+
...executedFields(),
|
|
7957
9231
|
domain,
|
|
7958
|
-
id,
|
|
9232
|
+
...standardConfigWriteResponse({ domain, id, executedId: createdId ?? null, payload: submit.payload, response: response2 }),
|
|
7959
9233
|
created_id: createdId ?? null,
|
|
7960
9234
|
endpoint: definition.createPath,
|
|
7961
9235
|
method: definition.createMethod,
|
|
@@ -7969,6 +9243,10 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7969
9243
|
validateFlowTemplateRemoteTemplateRefs(submit.payload);
|
|
7970
9244
|
validateFlowTemplateProjectAfterCreatePath(submit.payload);
|
|
7971
9245
|
validateFlowTemplateStandardPageCreateFormTemplate(submit.payload);
|
|
9246
|
+
validateFlowTemplateStartConditionalJump(submit.payload);
|
|
9247
|
+
validateFlowTemplateApproveActionShape(submit.payload);
|
|
9248
|
+
validateFlowTemplatePluginRejectionControl(submit.payload);
|
|
9249
|
+
validateFlowTemplateStandardConditionEditorRules(submit.payload);
|
|
7972
9250
|
validateFlowTemplateCodeModeMessages(submit.payload);
|
|
7973
9251
|
validateFlowTemplateRuntimeScripts(submit.payload);
|
|
7974
9252
|
validateFlowTemplateFeishuChatPlugin(submit.payload);
|
|
@@ -7986,13 +9264,22 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
7986
9264
|
if (domain === "list-template") {
|
|
7987
9265
|
validateListTemplateActionGate(submit.payload);
|
|
7988
9266
|
}
|
|
9267
|
+
if (domain === "console-template") {
|
|
9268
|
+
const errors = [];
|
|
9269
|
+
const warnings = [];
|
|
9270
|
+
lintConsoleTemplateWork(submit.payload, errors, warnings);
|
|
9271
|
+
if (errors.length) {
|
|
9272
|
+
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
9273
|
+
}
|
|
9274
|
+
}
|
|
7989
9275
|
if (domain === "form-template" && submitMode === "create") {
|
|
9276
|
+
validateNonEmptyFormCreatePayload(submit.payload);
|
|
7990
9277
|
await ensureConfigCapability(profile, `${definition.capability}.create`);
|
|
7991
9278
|
const expectedConfirm2 = `submit ${domain} ${id}`;
|
|
7992
9279
|
const endpoint2 = "/form_template";
|
|
7993
9280
|
if (confirm3 !== expectedConfirm2) {
|
|
7994
9281
|
return {
|
|
7995
|
-
|
|
9282
|
+
...dryRunFields(expectedConfirm2),
|
|
7996
9283
|
domain,
|
|
7997
9284
|
id,
|
|
7998
9285
|
endpoint: endpoint2,
|
|
@@ -8033,9 +9320,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
8033
9320
|
{ capability: `${definition.capability}.export` }
|
|
8034
9321
|
);
|
|
8035
9322
|
return {
|
|
8036
|
-
|
|
9323
|
+
...executedFields(),
|
|
8037
9324
|
domain,
|
|
8038
|
-
id,
|
|
9325
|
+
...standardConfigWriteResponse({ domain, id, executedId: publishedId, payload: submit.payload, response: publishResponse2, readback: publishedReadback }),
|
|
8039
9326
|
endpoint: endpoint2,
|
|
8040
9327
|
method: "POST",
|
|
8041
9328
|
response: response2,
|
|
@@ -8051,6 +9338,15 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
8051
9338
|
if (domain === "form-template") {
|
|
8052
9339
|
assertFormTemplateDraftId(id, current, "submit");
|
|
8053
9340
|
}
|
|
9341
|
+
if (domain === "dataset") {
|
|
9342
|
+
validateDatasetPayload(submit.payload, "edit");
|
|
9343
|
+
if (String(submit.payload.id) !== id || isRecord3(current) && String(current.id) !== id) {
|
|
9344
|
+
throw new Error(`dataset edit identity mismatch; request id, payload.id, and readback id must all equal ${id}.`);
|
|
9345
|
+
}
|
|
9346
|
+
if (isRecord3(current) && String(current.custom_key ?? "") !== String(submit.payload.custom_key ?? "")) {
|
|
9347
|
+
throw new Error("dataset edit refuses to change custom_key identity through relationFields.");
|
|
9348
|
+
}
|
|
9349
|
+
}
|
|
8054
9350
|
validateExpectedType(domain, definition, current);
|
|
8055
9351
|
const currentHash = hashJson(current);
|
|
8056
9352
|
if (currentHash !== submit.base_hash) {
|
|
@@ -8077,7 +9373,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
8077
9373
|
}
|
|
8078
9374
|
if (confirm3 !== expectedConfirm) {
|
|
8079
9375
|
return {
|
|
8080
|
-
|
|
9376
|
+
...dryRunFields(expectedConfirm),
|
|
8081
9377
|
domain,
|
|
8082
9378
|
id,
|
|
8083
9379
|
endpoint,
|
|
@@ -8107,9 +9403,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
8107
9403
|
}
|
|
8108
9404
|
const readback = await readBackConfigDomain(profile, domain, id, definition);
|
|
8109
9405
|
return {
|
|
8110
|
-
|
|
9406
|
+
...executedFields(),
|
|
8111
9407
|
domain,
|
|
8112
|
-
id,
|
|
9408
|
+
...standardConfigWriteResponse({ domain, id, payload: submitPayload, response }),
|
|
8113
9409
|
endpoint,
|
|
8114
9410
|
method: definition.submitMethod,
|
|
8115
9411
|
...publishMode ? { publish_mode: publishMode } : {},
|
|
@@ -8203,7 +9499,7 @@ async function runDatasetLifecycleAction(config, profile, action, id, confirm3)
|
|
|
8203
9499
|
];
|
|
8204
9500
|
if (confirm3 !== expectedConfirm) {
|
|
8205
9501
|
return {
|
|
8206
|
-
|
|
9502
|
+
...dryRunFields(expectedConfirm),
|
|
8207
9503
|
domain: "dataset",
|
|
8208
9504
|
id,
|
|
8209
9505
|
action: commandAction,
|
|
@@ -8229,15 +9525,186 @@ async function runDatasetLifecycleAction(config, profile, action, id, confirm3)
|
|
|
8229
9525
|
}
|
|
8230
9526
|
const readback = await readRemoteConfigDomain(profile, "dataset", id, definition);
|
|
8231
9527
|
return {
|
|
8232
|
-
|
|
9528
|
+
...executedFields(),
|
|
8233
9529
|
domain: "dataset",
|
|
8234
9530
|
id,
|
|
8235
9531
|
action: commandAction,
|
|
8236
9532
|
operations: executableOperations,
|
|
8237
9533
|
operation_responses: responses,
|
|
9534
|
+
readback_hash: hashJson(readback),
|
|
9535
|
+
readback_hint: configReadbackHint("dataset", id),
|
|
8238
9536
|
readback
|
|
8239
9537
|
};
|
|
8240
9538
|
}
|
|
9539
|
+
function normalizeConfigBatchItems(manifest) {
|
|
9540
|
+
if (Array.isArray(manifest)) {
|
|
9541
|
+
return manifest.map((raw) => ({ raw, item: isRecord3(raw) ? raw : null }));
|
|
9542
|
+
}
|
|
9543
|
+
if (!isRecord3(manifest)) {
|
|
9544
|
+
throw new Error("config batch manifest must be a JSON object or array.");
|
|
9545
|
+
}
|
|
9546
|
+
const items = manifest.operations ?? manifest.items ?? manifest.rows;
|
|
9547
|
+
if (!Array.isArray(items)) {
|
|
9548
|
+
throw new Error("config batch manifest requires operations, items, or rows array.");
|
|
9549
|
+
}
|
|
9550
|
+
return items.map((raw) => ({ raw, item: isRecord3(raw) ? raw : null }));
|
|
9551
|
+
}
|
|
9552
|
+
function assertBatchItemDomain(domain) {
|
|
9553
|
+
if (typeof domain !== "string" || !Object.prototype.hasOwnProperty.call(CONFIG_DOMAINS, domain)) {
|
|
9554
|
+
throw new Error(`config batch item requires a supported domain, got ${String(domain)}.`);
|
|
9555
|
+
}
|
|
9556
|
+
return domain;
|
|
9557
|
+
}
|
|
9558
|
+
async function writeOptionalBatchResponse(file, value) {
|
|
9559
|
+
if (typeof file !== "string" || !file.trim()) {
|
|
9560
|
+
return null;
|
|
9561
|
+
}
|
|
9562
|
+
await writeJsonFile(file, value);
|
|
9563
|
+
return file;
|
|
9564
|
+
}
|
|
9565
|
+
async function runConfigBatchSubmit(config, profile, manifestFile, options = {}) {
|
|
9566
|
+
const manifest = await readJsonFile(manifestFile);
|
|
9567
|
+
const items = normalizeConfigBatchItems(manifest);
|
|
9568
|
+
const results = [];
|
|
9569
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
9570
|
+
const batchItem = items[index];
|
|
9571
|
+
const item = batchItem.item;
|
|
9572
|
+
if (!item) {
|
|
9573
|
+
const result = {
|
|
9574
|
+
ok: false,
|
|
9575
|
+
index,
|
|
9576
|
+
domain: null,
|
|
9577
|
+
id: "",
|
|
9578
|
+
action: "submit",
|
|
9579
|
+
error: "config batch submit item must be a JSON object."
|
|
9580
|
+
};
|
|
9581
|
+
results.push(result);
|
|
9582
|
+
if (!options.continueOnError) break;
|
|
9583
|
+
continue;
|
|
9584
|
+
}
|
|
9585
|
+
let domain = null;
|
|
9586
|
+
let id = "";
|
|
9587
|
+
try {
|
|
9588
|
+
domain = assertBatchItemDomain(item.domain);
|
|
9589
|
+
id = typeof item.id === "string" ? item.id : "";
|
|
9590
|
+
const payload = typeof item.payload === "string" ? item.payload : "";
|
|
9591
|
+
if (!id || !payload) {
|
|
9592
|
+
throw new Error("config batch submit item requires id and payload.");
|
|
9593
|
+
}
|
|
9594
|
+
const response = await submitConfigDomain(config, profile, domain, id, payload, item.confirm);
|
|
9595
|
+
const executed = !isRecord3(response) || response.operation_executed !== false && response.dry_run !== true;
|
|
9596
|
+
const result = executed ? {
|
|
9597
|
+
ok: true,
|
|
9598
|
+
index,
|
|
9599
|
+
domain,
|
|
9600
|
+
id,
|
|
9601
|
+
action: "submit",
|
|
9602
|
+
response
|
|
9603
|
+
} : {
|
|
9604
|
+
ok: false,
|
|
9605
|
+
index,
|
|
9606
|
+
domain,
|
|
9607
|
+
id,
|
|
9608
|
+
action: "submit",
|
|
9609
|
+
error: `config batch submit item did not execute; confirm_required=${String(isRecord3(response) ? response.required_confirm ?? response.expected_confirm ?? "" : "")}`,
|
|
9610
|
+
response
|
|
9611
|
+
};
|
|
9612
|
+
results.push(result);
|
|
9613
|
+
await writeOptionalBatchResponse(item.response_out, result);
|
|
9614
|
+
if (!result.ok && !options.continueOnError) break;
|
|
9615
|
+
} catch (error) {
|
|
9616
|
+
const result = {
|
|
9617
|
+
ok: false,
|
|
9618
|
+
index,
|
|
9619
|
+
domain,
|
|
9620
|
+
id,
|
|
9621
|
+
action: "submit",
|
|
9622
|
+
error: error instanceof Error ? error.message : String(error || "")
|
|
9623
|
+
};
|
|
9624
|
+
results.push(result);
|
|
9625
|
+
await writeOptionalBatchResponse(item.response_out, result);
|
|
9626
|
+
if (!options.continueOnError) break;
|
|
9627
|
+
}
|
|
9628
|
+
}
|
|
9629
|
+
const failures = results.filter((item) => item.ok === false);
|
|
9630
|
+
return {
|
|
9631
|
+
ok: failures.length === 0,
|
|
9632
|
+
manifest_file: manifestFile,
|
|
9633
|
+
action: "submit",
|
|
9634
|
+
continue_on_error: Boolean(options.continueOnError),
|
|
9635
|
+
total: items.length,
|
|
9636
|
+
completed: results.length,
|
|
9637
|
+
succeeded: results.length - failures.length,
|
|
9638
|
+
failed: failures.length,
|
|
9639
|
+
results
|
|
9640
|
+
};
|
|
9641
|
+
}
|
|
9642
|
+
async function runConfigBatchReadback(config, profile, manifestFile, options = {}) {
|
|
9643
|
+
const manifest = await readJsonFile(manifestFile);
|
|
9644
|
+
const items = normalizeConfigBatchItems(manifest);
|
|
9645
|
+
const results = [];
|
|
9646
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
9647
|
+
const batchItem = items[index];
|
|
9648
|
+
const item = batchItem.item;
|
|
9649
|
+
if (!item) {
|
|
9650
|
+
const result = {
|
|
9651
|
+
ok: false,
|
|
9652
|
+
index,
|
|
9653
|
+
domain: null,
|
|
9654
|
+
id: "",
|
|
9655
|
+
action: "readback",
|
|
9656
|
+
error: "config batch readback item must be a JSON object."
|
|
9657
|
+
};
|
|
9658
|
+
results.push(result);
|
|
9659
|
+
if (!options.continueOnError) break;
|
|
9660
|
+
continue;
|
|
9661
|
+
}
|
|
9662
|
+
let domain = null;
|
|
9663
|
+
let id = "";
|
|
9664
|
+
try {
|
|
9665
|
+
domain = assertBatchItemDomain(item.domain);
|
|
9666
|
+
id = typeof item.id === "string" ? item.id : "";
|
|
9667
|
+
if (!id) {
|
|
9668
|
+
throw new Error("config batch readback item requires id.");
|
|
9669
|
+
}
|
|
9670
|
+
const response = await readbackConfigDomain(config, profile, domain, id);
|
|
9671
|
+
const result = {
|
|
9672
|
+
ok: true,
|
|
9673
|
+
index,
|
|
9674
|
+
domain,
|
|
9675
|
+
id,
|
|
9676
|
+
action: "readback",
|
|
9677
|
+
response
|
|
9678
|
+
};
|
|
9679
|
+
results.push(result);
|
|
9680
|
+
await writeOptionalBatchResponse(item.response_out, result);
|
|
9681
|
+
} catch (error) {
|
|
9682
|
+
const result = {
|
|
9683
|
+
ok: false,
|
|
9684
|
+
index,
|
|
9685
|
+
domain,
|
|
9686
|
+
id,
|
|
9687
|
+
action: "readback",
|
|
9688
|
+
error: error instanceof Error ? error.message : String(error || "")
|
|
9689
|
+
};
|
|
9690
|
+
results.push(result);
|
|
9691
|
+
await writeOptionalBatchResponse(item.response_out, result);
|
|
9692
|
+
if (!options.continueOnError) break;
|
|
9693
|
+
}
|
|
9694
|
+
}
|
|
9695
|
+
const failures = results.filter((item) => item.ok === false);
|
|
9696
|
+
return {
|
|
9697
|
+
ok: failures.length === 0,
|
|
9698
|
+
manifest_file: manifestFile,
|
|
9699
|
+
action: "readback",
|
|
9700
|
+
continue_on_error: Boolean(options.continueOnError),
|
|
9701
|
+
total: items.length,
|
|
9702
|
+
completed: results.length,
|
|
9703
|
+
succeeded: results.length - failures.length,
|
|
9704
|
+
failed: failures.length,
|
|
9705
|
+
results
|
|
9706
|
+
};
|
|
9707
|
+
}
|
|
8241
9708
|
|
|
8242
9709
|
// src/core/config-workspace.ts
|
|
8243
9710
|
import { mkdir as mkdir6, readFile as readFile9, writeFile as writeFile6 } from "fs/promises";
|
|
@@ -8316,13 +9783,12 @@ function renderConfigWorkspaceGuide(options) {
|
|
|
8316
9783
|
([directory, purpose]) => `| \`${directory}\` | ${purpose} |`
|
|
8317
9784
|
).join("\n");
|
|
8318
9785
|
return `${start}
|
|
8319
|
-
# BPMAX \u914D\u7F6E\
|
|
9786
|
+
# BPMAX \u914D\u7F6E\u76EE\u5F55\uFF1A${display(options.env)}
|
|
8320
9787
|
|
|
8321
9788
|
## \u73AF\u5883
|
|
8322
9789
|
- Profile: \`${display(options.profileName)}\`
|
|
8323
9790
|
- Env: \`${display(options.env)}\`
|
|
8324
9791
|
- BPMAX: \`${display(options.environment.bpmax_base_url || options.profile.origin)}\`
|
|
8325
|
-
- Workspace: \`${display(options.environment.workspace || options.profile.workspace)}\`
|
|
8326
9792
|
- sysconfigdiff: \`${display(options.environment.sysconfigdiff_base_url)}\`
|
|
8327
9793
|
- sysconfig user: \`${display(options.environment.username)}\`
|
|
8328
9794
|
- secrets: \`[REDACTED]\`
|
|
@@ -8333,8 +9799,20 @@ ${configEnabled ? "" : "> \u5F53\u524D profile \u7684 API Key \u5C1A\u672A\u5F00
|
|
|
8333
9799
|
| --- | --- |
|
|
8334
9800
|
${directoryRows}
|
|
8335
9801
|
|
|
9802
|
+
## \u672C\u5730\u6587\u4EF6\u7EA6\u5B9A
|
|
9803
|
+
- \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
|
|
9804
|
+
- \`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
|
|
9805
|
+
- \u5E38\u89C1\u6587\u4EF6\u5F62\u6001\uFF1A
|
|
9806
|
+
- \`configuration\` \u662F\u914D\u7F6E\u5143\u6570\u636E\uFF0C\`configuration.content\` \u662F\u5B9E\u9645\u914D\u7F6E\u5185\u5BB9\u3002
|
|
9807
|
+
- \`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
|
|
9808
|
+
- \`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
|
|
9809
|
+
- \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
|
|
9810
|
+
|
|
8336
9811
|
## \u5F3A\u5236\u89C4\u5219
|
|
9812
|
+
- \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
|
|
9813
|
+
- \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
9814
|
- \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
|
|
9815
|
+
- \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
9816
|
- \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
9817
|
- \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
9818
|
- \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 +9824,17 @@ ${directoryRows}
|
|
|
8346
9824
|
${rows}
|
|
8347
9825
|
| \u63D2\u4EF6 typed config | \u63D2\u4EF6\u4E13\u9879 skill | \`${commandPrefix3} config plugin <domain> ...\` |
|
|
8348
9826
|
| \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 "<
|
|
9827
|
+
| \u957F\u671F\u8BB0\u5FC6 | \`bpmax-memory-protocol\` | \`${commandPrefix3} memory search --scope all --query "<env> <flow_type> <task>"\` |
|
|
8350
9828
|
| \u5B8C\u6574\u914D\u7F6E\u7F16\u6392 | \`bpmax-e2e-flow-config-orchestrator\` | \u6309\u7F16\u6392 Skill \u6267\u884C |
|
|
8351
9829
|
| \u7AEF\u5230\u7AEF\u56DE\u5F52 | \`bpmax-e2e-flow-test-operator\` | \u6309\u56DE\u5F52 Skill \u6267\u884C |
|
|
8352
9830
|
|
|
8353
9831
|
## \u6807\u51C6\u95ED\u73AF
|
|
8354
9832
|
\`\`\`bash
|
|
8355
9833
|
${commandPrefix3} config <domain> export --id <id> --profile ${profileArg}
|
|
8356
|
-
${commandPrefix3} config <domain> lint --work <work-file>
|
|
9834
|
+
${commandPrefix3} config <domain> lint --work <work-file> --profile ${profileArg}
|
|
8357
9835
|
# build/submit must use typed CLI and an enabled config capability.
|
|
8358
9836
|
# 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>
|
|
9837
|
+
${commandPrefix3} config <domain> build --work <work-file> --meta <meta-file> --out <submit-file> --profile ${profileArg}
|
|
8360
9838
|
${commandPrefix3} config <domain> submit --id <id> --payload <submit-file> --profile ${profileArg}
|
|
8361
9839
|
${commandPrefix3} config <domain> submit --id <id> --payload <submit-file> --profile ${profileArg} --confirm "submit <domain> <id>"
|
|
8362
9840
|
${commandPrefix3} config <domain> verify --id <id> --expect <work-file> --profile ${profileArg}
|
|
@@ -8386,17 +9864,19 @@ ${commandPrefix3} config latest pull ${envArg} --profile ${profileArg} --format
|
|
|
8386
9864
|
\`\`\`
|
|
8387
9865
|
|
|
8388
9866
|
## Memory \u4F7F\u7528\u89C4\u5219
|
|
8389
|
-
\u5F00\u59CB\u914D\u7F6E\u3001\u6392\u67E5\u6216\u6D4B\u8BD5\u524D\uFF0C\
|
|
9867
|
+
\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
|
|
9868
|
+
|
|
9869
|
+
\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
9870
|
|
|
8391
9871
|
\`\`\`bash
|
|
8392
9872
|
${commandPrefix3} memory status --profile ${profileArg} --format json
|
|
8393
|
-
${commandPrefix3} memory search --profile ${profileArg} --scope all --query "${display(options.
|
|
9873
|
+
${commandPrefix3} memory search --profile ${profileArg} --scope all --query "${display(options.env)} <flow_type> <task>" --format json
|
|
8394
9874
|
\`\`\`
|
|
8395
9875
|
|
|
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
|
|
9876
|
+
\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
9877
|
|
|
8398
9878
|
\`\`\`bash
|
|
8399
|
-
${commandPrefix3} memory add --profile ${profileArg} --scope user --text "<learning>" --metadata '{"type":"task_learning","project_id":"bpmax","
|
|
9879
|
+
${commandPrefix3} memory add --profile ${profileArg} --scope user --text "<learning>" --metadata '{"type":"task_learning","project_id":"bpmax","env":"${display(options.env)}"}' --format json
|
|
8400
9880
|
\`\`\`
|
|
8401
9881
|
${end}
|
|
8402
9882
|
`;
|
|
@@ -9872,7 +11352,24 @@ function registerConfigCommands(program2) {
|
|
|
9872
11352
|
};
|
|
9873
11353
|
registerFlowAppContextCommand("context");
|
|
9874
11354
|
registerFlowAppContextCommand("inspect");
|
|
9875
|
-
flowApp.command("
|
|
11355
|
+
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) => {
|
|
11356
|
+
const pluginLint = await resolveFlowTemplatePluginLintOptions({
|
|
11357
|
+
profile: options.profile,
|
|
11358
|
+
agent: options.agent,
|
|
11359
|
+
requireInstalled: true
|
|
11360
|
+
});
|
|
11361
|
+
const result = await lintFlowAppWorkFiles(options.formWork, options.flowWork, {
|
|
11362
|
+
workspace: options.workspace,
|
|
11363
|
+
name: options.name,
|
|
11364
|
+
pluginLint
|
|
11365
|
+
});
|
|
11366
|
+
if (!result.ok) {
|
|
11367
|
+
printResult(options.format, result);
|
|
11368
|
+
throw new Error(`Flow-app lint failed for ${options.formWork} + ${options.flowWork}`);
|
|
11369
|
+
}
|
|
11370
|
+
printResult(options.format, result);
|
|
11371
|
+
});
|
|
11372
|
+
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
11373
|
const configData = await loadConfig();
|
|
9877
11374
|
const resolved = resolveProfile(configData, options.profile);
|
|
9878
11375
|
const result = await createFlowAppFromWork(
|
|
@@ -9884,7 +11381,8 @@ function registerConfigCommands(program2) {
|
|
|
9884
11381
|
{
|
|
9885
11382
|
workspace: options.workspace,
|
|
9886
11383
|
name: options.name,
|
|
9887
|
-
publishLive: !options.draftOnly
|
|
11384
|
+
publishLive: !options.draftOnly,
|
|
11385
|
+
agent: options.agent
|
|
9888
11386
|
}
|
|
9889
11387
|
);
|
|
9890
11388
|
await writeResponseOut(options.responseOut, result);
|
|
@@ -9932,6 +11430,25 @@ function registerConfigCommands(program2) {
|
|
|
9932
11430
|
await saveConfig(configData);
|
|
9933
11431
|
printResult(options.format, result);
|
|
9934
11432
|
});
|
|
11433
|
+
const batch = config.command("batch").description("Run guarded typed config operations from a manifest");
|
|
11434
|
+
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) => {
|
|
11435
|
+
const configData = await loadConfig();
|
|
11436
|
+
const resolved = resolveProfile(configData, options.profile);
|
|
11437
|
+
const result = await runConfigBatchSubmit(configData, resolved, options.manifest, {
|
|
11438
|
+
continueOnError: Boolean(options.continueOnError)
|
|
11439
|
+
});
|
|
11440
|
+
await saveConfig(configData);
|
|
11441
|
+
printResult(options.format, result);
|
|
11442
|
+
});
|
|
11443
|
+
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) => {
|
|
11444
|
+
const configData = await loadConfig();
|
|
11445
|
+
const resolved = resolveProfile(configData, options.profile);
|
|
11446
|
+
const result = await runConfigBatchReadback(configData, resolved, options.manifest, {
|
|
11447
|
+
continueOnError: Boolean(options.continueOnError)
|
|
11448
|
+
});
|
|
11449
|
+
await saveConfig(configData);
|
|
11450
|
+
printResult(options.format, result);
|
|
11451
|
+
});
|
|
9935
11452
|
Object.keys(CONFIG_DOMAINS).forEach((domain) => {
|
|
9936
11453
|
const domainCommand = domain === "workspace" ? workspace.description("Initialize local sysconfig workspaces and manage BPMAX workspace configuration") : config.command(domain).description(`Manage BPMAX ${domain} configuration`);
|
|
9937
11454
|
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 +11494,13 @@ function registerConfigCommands(program2) {
|
|
|
9977
11494
|
const resolved = resolveProfile(configData, options.profile);
|
|
9978
11495
|
const workFormat = options.workFormat === "structured" ? "structured" : "raw";
|
|
9979
11496
|
const result = await exportConfigDomain(configData, resolved, domain, options.id, options.out, { workFormat });
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
result.work = work;
|
|
9988
|
-
}
|
|
11497
|
+
const workFile = typeof result.work_file === "string" ? result.work_file : void 0;
|
|
11498
|
+
const work = (options.inline || domain === "flow-template" && options.summary) && workFile ? await readJsonFile(workFile) : void 0;
|
|
11499
|
+
if (domain === "flow-template" && options.summary) {
|
|
11500
|
+
result.summary = summarizeFlowTemplateWork(work);
|
|
11501
|
+
}
|
|
11502
|
+
if (options.inline) {
|
|
11503
|
+
result.work = work;
|
|
9989
11504
|
}
|
|
9990
11505
|
await saveConfig(configData);
|
|
9991
11506
|
printResult(options.format, result);
|
|
@@ -10066,6 +11581,29 @@ function registerConfigCommands(program2) {
|
|
|
10066
11581
|
printResult(options.format, result);
|
|
10067
11582
|
});
|
|
10068
11583
|
if (domain === "dataset") {
|
|
11584
|
+
const relationFields = domainCommand.command("relation-fields").description("Manage dataset relationFields through the typed dataset adapter");
|
|
11585
|
+
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) => {
|
|
11586
|
+
const configData = await loadConfig();
|
|
11587
|
+
const resolved = resolveProfile(configData, options.profile);
|
|
11588
|
+
const result = await submitConfigDomain(
|
|
11589
|
+
configData,
|
|
11590
|
+
resolved,
|
|
11591
|
+
"dataset",
|
|
11592
|
+
options.id,
|
|
11593
|
+
options.payload,
|
|
11594
|
+
options.confirm
|
|
11595
|
+
);
|
|
11596
|
+
await saveConfig(configData);
|
|
11597
|
+
await writeResponseOut(options.responseOut, result);
|
|
11598
|
+
printResult(options.format, result);
|
|
11599
|
+
});
|
|
11600
|
+
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) => {
|
|
11601
|
+
const configData = await loadConfig();
|
|
11602
|
+
const resolved = resolveProfile(configData, options.profile);
|
|
11603
|
+
const result = await readbackConfigDomain(configData, resolved, "dataset", options.id);
|
|
11604
|
+
await saveConfig(configData);
|
|
11605
|
+
printResult(options.format, result);
|
|
11606
|
+
});
|
|
10069
11607
|
[
|
|
10070
11608
|
["publish", "Publish/start a dataset and trigger ES batch generation"],
|
|
10071
11609
|
["pause", "Pause a published or pending dataset"],
|
|
@@ -12133,6 +13671,156 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
12133
13671
|
});
|
|
12134
13672
|
}
|
|
12135
13673
|
|
|
13674
|
+
// src/commands/issue.ts
|
|
13675
|
+
import { readFile as readFile12 } from "fs/promises";
|
|
13676
|
+
|
|
13677
|
+
// src/core/issues.ts
|
|
13678
|
+
import axios7, { AxiosHeaders as AxiosHeaders3 } from "axios";
|
|
13679
|
+
var DEFAULT_GITLAB_URL = "https://gitlab.yitaiyitai.com";
|
|
13680
|
+
var DEFAULT_GITLAB_PROJECT = "bpmax/bpmax-cli";
|
|
13681
|
+
function normalizeBaseUrl2(baseUrl = DEFAULT_GITLAB_URL) {
|
|
13682
|
+
const normalized = baseUrl.trim().replace(/\/+$/g, "");
|
|
13683
|
+
if (!normalized) {
|
|
13684
|
+
throw new Error("GitLab base URL is required.");
|
|
13685
|
+
}
|
|
13686
|
+
return normalized;
|
|
13687
|
+
}
|
|
13688
|
+
function normalizeGitLabProject(project = DEFAULT_GITLAB_PROJECT) {
|
|
13689
|
+
const normalized = project.trim().replace(/^\/+|\/+$/g, "");
|
|
13690
|
+
if (!normalized) {
|
|
13691
|
+
throw new Error("GitLab project is required.");
|
|
13692
|
+
}
|
|
13693
|
+
return normalized;
|
|
13694
|
+
}
|
|
13695
|
+
function gitLabProjectApiPath(project = DEFAULT_GITLAB_PROJECT) {
|
|
13696
|
+
return encodeURIComponent(normalizeGitLabProject(project));
|
|
13697
|
+
}
|
|
13698
|
+
function buildGitLabIssuePayload(input) {
|
|
13699
|
+
const title = input.title.trim();
|
|
13700
|
+
if (!title) {
|
|
13701
|
+
throw new Error("Issue title is required.");
|
|
13702
|
+
}
|
|
13703
|
+
const description = input.description?.trim();
|
|
13704
|
+
const labels = (input.labels || []).map((label) => label.trim()).filter(Boolean);
|
|
13705
|
+
const assigneeIds = (input.assigneeIds || []).filter((id) => Number.isInteger(id) && id > 0);
|
|
13706
|
+
return {
|
|
13707
|
+
title,
|
|
13708
|
+
...description ? { description } : {},
|
|
13709
|
+
...labels.length > 0 ? { labels: labels.join(",") } : {},
|
|
13710
|
+
...assigneeIds.length > 0 ? { assignee_ids: assigneeIds } : {},
|
|
13711
|
+
...input.confidential !== void 0 ? { confidential: input.confidential } : {}
|
|
13712
|
+
};
|
|
13713
|
+
}
|
|
13714
|
+
function resolveGitLabToken(options) {
|
|
13715
|
+
const env = options.env || process.env;
|
|
13716
|
+
const candidates = [
|
|
13717
|
+
options.tokenEnv ? env[options.tokenEnv] : void 0,
|
|
13718
|
+
env.GITLAB_TOKEN,
|
|
13719
|
+
env.GL_TOKEN,
|
|
13720
|
+
env.PRIVATE_TOKEN,
|
|
13721
|
+
"-1pFevGtvjq4fXSxzZJQ"
|
|
13722
|
+
];
|
|
13723
|
+
const token = candidates.find((candidate) => candidate?.trim());
|
|
13724
|
+
if (!token) {
|
|
13725
|
+
const envHint = options.tokenEnv ? options.tokenEnv : "GITLAB_TOKEN";
|
|
13726
|
+
throw new Error(`GitLab token is required. Set ${envHint}.`);
|
|
13727
|
+
}
|
|
13728
|
+
return token.trim();
|
|
13729
|
+
}
|
|
13730
|
+
async function createGitLabIssue(input, options) {
|
|
13731
|
+
const token = options.token.trim();
|
|
13732
|
+
if (!token) {
|
|
13733
|
+
throw new Error("GitLab token is required.");
|
|
13734
|
+
}
|
|
13735
|
+
const baseUrl = normalizeBaseUrl2(options.baseUrl);
|
|
13736
|
+
const projectPath = gitLabProjectApiPath(options.project);
|
|
13737
|
+
const client = options.client || axios7.create({ baseURL: baseUrl });
|
|
13738
|
+
const headers = AxiosHeaders3.from();
|
|
13739
|
+
headers.set("PRIVATE-TOKEN", token);
|
|
13740
|
+
const response = await client.request({
|
|
13741
|
+
method: "POST",
|
|
13742
|
+
url: `/api/v4/projects/${projectPath}/issues`,
|
|
13743
|
+
headers,
|
|
13744
|
+
data: buildGitLabIssuePayload(input)
|
|
13745
|
+
});
|
|
13746
|
+
return response.data;
|
|
13747
|
+
}
|
|
13748
|
+
|
|
13749
|
+
// src/commands/issue.ts
|
|
13750
|
+
async function readDescription(options) {
|
|
13751
|
+
if (options.descriptionFile && options.description) {
|
|
13752
|
+
throw new Error("Use either --description or --description-file, not both.");
|
|
13753
|
+
}
|
|
13754
|
+
if (!options.descriptionFile) {
|
|
13755
|
+
return options.description;
|
|
13756
|
+
}
|
|
13757
|
+
return readFile12(options.descriptionFile, "utf8");
|
|
13758
|
+
}
|
|
13759
|
+
function parseAssigneeIds(values) {
|
|
13760
|
+
return (values || []).flatMap(
|
|
13761
|
+
(value) => value.split(",").map((part) => {
|
|
13762
|
+
const parsed = Number(part.trim());
|
|
13763
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
13764
|
+
throw new Error(`Invalid assignee id: ${part}`);
|
|
13765
|
+
}
|
|
13766
|
+
return parsed;
|
|
13767
|
+
})
|
|
13768
|
+
);
|
|
13769
|
+
}
|
|
13770
|
+
async function buildIssueInput(options) {
|
|
13771
|
+
return {
|
|
13772
|
+
title: options.title,
|
|
13773
|
+
description: await readDescription(options),
|
|
13774
|
+
labels: options.label || [],
|
|
13775
|
+
assigneeIds: parseAssigneeIds(options.assigneeId),
|
|
13776
|
+
confidential: options.confidential
|
|
13777
|
+
};
|
|
13778
|
+
}
|
|
13779
|
+
function prettyCreatedIssue(issue3) {
|
|
13780
|
+
return issue3.web_url;
|
|
13781
|
+
}
|
|
13782
|
+
function registerIssueCommands(program2, deps = {}) {
|
|
13783
|
+
const createIssue = deps.createIssue || createGitLabIssue;
|
|
13784
|
+
const issue3 = program2.command("issue").description("Report bugs and create GitLab issues for bpmax-cli");
|
|
13785
|
+
const registerCreateLike = (name) => {
|
|
13786
|
+
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) => {
|
|
13787
|
+
const input = await buildIssueInput(options);
|
|
13788
|
+
const payload = buildGitLabIssuePayload(input);
|
|
13789
|
+
const project = options.project || DEFAULT_GITLAB_PROJECT;
|
|
13790
|
+
const gitlabUrl = options.gitlabUrl || DEFAULT_GITLAB_URL;
|
|
13791
|
+
if (options.dryRun) {
|
|
13792
|
+
printResult(options.format, {
|
|
13793
|
+
ok: true,
|
|
13794
|
+
dry_run: true,
|
|
13795
|
+
gitlab_url: gitlabUrl,
|
|
13796
|
+
project,
|
|
13797
|
+
payload
|
|
13798
|
+
});
|
|
13799
|
+
return;
|
|
13800
|
+
}
|
|
13801
|
+
const token = resolveGitLabToken({
|
|
13802
|
+
tokenEnv: options.tokenEnv,
|
|
13803
|
+
env: deps.env
|
|
13804
|
+
});
|
|
13805
|
+
const created = await createIssue(input, {
|
|
13806
|
+
baseUrl: gitlabUrl,
|
|
13807
|
+
project,
|
|
13808
|
+
token
|
|
13809
|
+
});
|
|
13810
|
+
if (options.format === "pretty") {
|
|
13811
|
+
printResult("pretty", prettyCreatedIssue(created));
|
|
13812
|
+
return;
|
|
13813
|
+
}
|
|
13814
|
+
printResult(options.format, {
|
|
13815
|
+
ok: true,
|
|
13816
|
+
issue: created
|
|
13817
|
+
});
|
|
13818
|
+
});
|
|
13819
|
+
};
|
|
13820
|
+
registerCreateLike("create");
|
|
13821
|
+
registerCreateLike("report");
|
|
13822
|
+
}
|
|
13823
|
+
|
|
12136
13824
|
// src/commands/memory.ts
|
|
12137
13825
|
function parseLimit(input, fallback) {
|
|
12138
13826
|
const value = Number(input ?? fallback);
|
|
@@ -12213,7 +13901,7 @@ function registerMemoryCommands(program2) {
|
|
|
12213
13901
|
}
|
|
12214
13902
|
|
|
12215
13903
|
// src/commands/matrix.ts
|
|
12216
|
-
import { readFile as
|
|
13904
|
+
import { readFile as readFile13 } from "fs/promises";
|
|
12217
13905
|
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
13906
|
var UUID_PATH_PATTERN = /uuid'[^'"\s/]+/i;
|
|
12219
13907
|
async function parseSeedRules(input) {
|
|
@@ -12221,7 +13909,7 @@ async function parseSeedRules(input) {
|
|
|
12221
13909
|
if (source === "") {
|
|
12222
13910
|
throw new Error("--rules file path is empty.");
|
|
12223
13911
|
}
|
|
12224
|
-
const raw = source ? await
|
|
13912
|
+
const raw = source ? await readFile13(source, "utf8") : input;
|
|
12225
13913
|
let parsed;
|
|
12226
13914
|
try {
|
|
12227
13915
|
parsed = JSON.parse(raw);
|
|
@@ -12951,7 +14639,8 @@ async function printCreateFormHandoff(client, format, profile, flowIdentifiers,
|
|
|
12951
14639
|
const agentWarning = [
|
|
12952
14640
|
"Agent must reply with the full create form URL exactly as provided.",
|
|
12953
14641
|
'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."
|
|
14642
|
+
"Do not shorten, truncate, rebuild, or replace the URL with a bare flow_type link.",
|
|
14643
|
+
"prefill_context only describes the generated payload; browser_prefill_verified=false until a real page check confirms visible controls are populated."
|
|
12955
14644
|
].join(" ");
|
|
12956
14645
|
printResult(format, {
|
|
12957
14646
|
handoff: true,
|
|
@@ -12965,11 +14654,16 @@ async function printCreateFormHandoff(client, format, profile, flowIdentifiers,
|
|
|
12965
14654
|
...prefill ? {
|
|
12966
14655
|
prefill_token: prefill.token,
|
|
12967
14656
|
prefill_expires_in: prefill.expires_in,
|
|
12968
|
-
prefill_expires_at: prefill.expires_at
|
|
14657
|
+
prefill_expires_at: prefill.expires_at,
|
|
14658
|
+
prefill_status: "token_generated"
|
|
12969
14659
|
} : {
|
|
14660
|
+
prefill_status: "fallback_init_value",
|
|
12970
14661
|
prefill_fallback: "init_value",
|
|
12971
14662
|
...prefillError ? { prefill_error: prefillError } : {}
|
|
12972
14663
|
},
|
|
14664
|
+
browser_prefill_verified: false,
|
|
14665
|
+
prefill_verification_required: true,
|
|
14666
|
+
next_verification: "Open url in a real browser and confirm visible controls contain the expected values before treating prefill as successful.",
|
|
12973
14667
|
init_value: initValue,
|
|
12974
14668
|
init_value_keys: Object.keys(options.form),
|
|
12975
14669
|
prefill_context: prefillContext,
|
|
@@ -13066,7 +14760,7 @@ function isRiskyFormField(field) {
|
|
|
13066
14760
|
const type = field.type?.toLowerCase() ?? "";
|
|
13067
14761
|
const label = field.label?.toLowerCase() ?? "";
|
|
13068
14762
|
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);
|
|
14763
|
+
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
14764
|
}
|
|
13071
14765
|
function collectHandoffReasons(fields, template) {
|
|
13072
14766
|
const reasons = /* @__PURE__ */ new Set();
|
|
@@ -13534,7 +15228,7 @@ import { spawn as spawn2 } from "child_process";
|
|
|
13534
15228
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
13535
15229
|
|
|
13536
15230
|
// src/core/recipes.ts
|
|
13537
|
-
import { access, mkdir as mkdir10, readdir as readdir4, readFile as
|
|
15231
|
+
import { access, mkdir as mkdir10, readdir as readdir4, readFile as readFile14, writeFile as writeFile10 } from "fs/promises";
|
|
13538
15232
|
import path11 from "path";
|
|
13539
15233
|
var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
13540
15234
|
var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
|
|
@@ -13616,7 +15310,7 @@ function parseRecipeDefinition(input) {
|
|
|
13616
15310
|
};
|
|
13617
15311
|
}
|
|
13618
15312
|
async function loadRecipe(recipeDir) {
|
|
13619
|
-
const raw = await
|
|
15313
|
+
const raw = await readFile14(path11.join(recipeDir, "recipe.json"), "utf8");
|
|
13620
15314
|
return parseRecipeDefinition(JSON.parse(raw));
|
|
13621
15315
|
}
|
|
13622
15316
|
async function listRecipes(recipesDir) {
|
|
@@ -13715,7 +15409,7 @@ async function renderArgv(options) {
|
|
|
13715
15409
|
const rendered = [];
|
|
13716
15410
|
for (const token of options.recipe.command.argv) {
|
|
13717
15411
|
if (token.startsWith("@")) {
|
|
13718
|
-
const raw = await
|
|
15412
|
+
const raw = await readFile14(resolveRecipeFile(options.recipeDir, token), "utf8");
|
|
13719
15413
|
rendered.push(renderTemplate(raw, options.variables));
|
|
13720
15414
|
} else {
|
|
13721
15415
|
rendered.push(renderTemplate(token, options.variables));
|
|
@@ -14173,7 +15867,7 @@ function registerSetupCommand(program2, deps = {}) {
|
|
|
14173
15867
|
}
|
|
14174
15868
|
|
|
14175
15869
|
// src/core/taskbook.ts
|
|
14176
|
-
import { mkdir as mkdir11, readFile as
|
|
15870
|
+
import { mkdir as mkdir11, readFile as readFile15, writeFile as writeFile11 } from "fs/promises";
|
|
14177
15871
|
import path12 from "path";
|
|
14178
15872
|
var TaskbookError = class extends Error {
|
|
14179
15873
|
};
|
|
@@ -14381,7 +16075,7 @@ function addUuidIssues(text5, issues, path15) {
|
|
|
14381
16075
|
}
|
|
14382
16076
|
}
|
|
14383
16077
|
async function readTaskbookText(file) {
|
|
14384
|
-
const raw = await
|
|
16078
|
+
const raw = await readFile15(file, "utf8");
|
|
14385
16079
|
try {
|
|
14386
16080
|
const parsed = JSON.parse(raw);
|
|
14387
16081
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -15031,12 +16725,13 @@ import {
|
|
|
15031
16725
|
cp as cp3,
|
|
15032
16726
|
mkdir as mkdir12,
|
|
15033
16727
|
readdir as readdir5,
|
|
15034
|
-
readFile as
|
|
16728
|
+
readFile as readFile16,
|
|
15035
16729
|
rm as rm4,
|
|
15036
16730
|
stat as stat6,
|
|
15037
16731
|
writeFile as writeFile12
|
|
15038
16732
|
} from "fs/promises";
|
|
15039
16733
|
import path13 from "path";
|
|
16734
|
+
import { inflateSync } from "zlib";
|
|
15040
16735
|
var DEFAULT_SUITE_ROOT = ".ai_test/suite";
|
|
15041
16736
|
var DEFAULT_DRAFT_ROOT = ".ai_test/suite_draft";
|
|
15042
16737
|
var DEFAULT_REPORT_ROOT = ".ai_test/report";
|
|
@@ -15089,6 +16784,7 @@ var CONFIG_BASIS_ALLOWED_PREFIXES = [
|
|
|
15089
16784
|
".codex/skills/"
|
|
15090
16785
|
];
|
|
15091
16786
|
var REPORT_REQUIRED_KEYS = ["run_id:", "scenario_id:", "source_suite:", "result:"];
|
|
16787
|
+
var REPORT_EXECUTION_KEYS = ["planned_cases:", "executed_cases:", "precondition_check:", "state_file:", "report_run:", "browser_tool:", "rerun_policy:"];
|
|
15092
16788
|
var REPORT_REQUIRED_HEADINGS = [
|
|
15093
16789
|
"## 1. \u6D4B\u8BD5\u8303\u56F4",
|
|
15094
16790
|
"## 2. \u6267\u884C\u73AF\u5883",
|
|
@@ -15106,18 +16802,38 @@ var ID_AS_ENTRY_RE = /(发起表单|处理表单|表单模板|数据集|列表
|
|
|
15106
16802
|
var URL_RE = /https?:\/\/|\/w:[^\s,,;;]+|\/project\?|\/project_detail\/|\/projectContinue\?/;
|
|
15107
16803
|
var SHA_RE = /^[0-9a-f]{40}$/;
|
|
15108
16804
|
var CONFIG_BASIS_REASON_RE = /(依据|覆盖|校验|验证|对应|因为|reason=|why=|=>|->)/;
|
|
15109
|
-
var PREP_TOKEN_RE = /(
|
|
16805
|
+
var PREP_TOKEN_RE = /(账号|入口|样本|准备操作|预期|主数据|权限|自动化|依赖流程|清理策略|绑定解析|定位规则|模拟用户|precondition_check|browser_tool|live_draft|state_file|report_run|login_profile|mock_user|unmock_done|resume_policy)=/g;
|
|
15110
16806
|
var TEST_DATA_TOKEN_RE = /(业务场景|业务逻辑|样本数据|合理性|客户口径|数据约束)=/g;
|
|
15111
16807
|
var GENERIC_SAMPLE_VALUE_RE = /(^|[=,;,\s])(sample|test|mock|demo|xxx|todo|tbd|placeholder|随便|假数据|占位|待补)(?=$|[,;,\s])/i;
|
|
15112
16808
|
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
16809
|
var RAW_PAYLOAD_TEST_DATA_RE = /(^|[;;]\s*)(payload|完整payload|request|请求体|headers?)\s*=/i;
|
|
15114
16810
|
var PLACEHOLDER_RE = /<[^>]+>/;
|
|
16811
|
+
var CASE_CONTENT_GARBLED_RE = /\uFFFD|�|Ã.|Â.|â[€\u0080-\u00BF]|锛|鈥|乱码|���|\?\?\?/i;
|
|
16812
|
+
var HOLLOW_CASE_TEXT_RE = /(^|[=,;,\s])(todo|tbd|xxx|placeholder|占位|待补|随便写|后补|暂无|无具体步骤|略)(?=$|[,;,\s])/i;
|
|
15115
16813
|
var IMAGE_RE = /!\[[^\]]*]\(([^)]+)\)/g;
|
|
15116
16814
|
var YBS_NONZERO_DETAIL_RE = /https:\/\/yaditest\.yitaiyitai\.com\/w:ybs\/project_detail\/(?!0\/)\d+\//;
|
|
15117
16815
|
var YBS_PC_CREATE_WRONG_RE = /https:\/\/yaditest\.yitaiyitai\.com\/w:ybs\/pages\/projectCreate\/projectCreate\?flow_type=/;
|
|
15118
16816
|
var IDENTITY_MOCK_CASE_RE = /(非处理人|越权|只读|多角色|角色隔离|无权限|低权限|unauthorized|limited|readonly|permission)/;
|
|
15119
16817
|
var IDENTITY_MOCK_VALUE_RE = /(mock|模拟).*(unmock|退出模拟|恢复)|bpmax-user-mock-operator/;
|
|
15120
16818
|
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|复用模板|可复用|首次运行沉淀|沉淀模板/;
|
|
16819
|
+
var ERROR_CAPTURE_CASE_RE = /(negative|boundary|异常|错误|失败|报错|重复|无效|非法|invalid|error|扫码.*(异常|错误|无效)|错误\s*SN|异常\s*SN|无效\s*SN)/i;
|
|
16820
|
+
var ERROR_CAPTURE_EVIDENCE_RE = /(expected_error_text|error_capture_required|错误提示|提示文案|报错文案|toast|校验文案).*(screenshot|截图)|截图.*(错误提示|提示文案|报错文案|toast|校验文案)/i;
|
|
16821
|
+
var BROWSER_TOOL_RE = /(Chrome DevTools|DevTools|Playwright|AppleScript)/i;
|
|
16822
|
+
var REPORT_EVIDENCE_PLACEHOLDER_RE = /^(?:n\/?a|none|null|todo|tbd|xxx|unknown|pending|待补|暂无|无|未执行|跳过|-+)$/i;
|
|
16823
|
+
var LIVE_DRAFT_RE = /(live|draft|已发布|草稿|发布态|live_draft=)/i;
|
|
16824
|
+
var MULTI_ROLE_VALUE_RE = /[,、/]\s*[^,、/\s]+|多角色|跨角色/;
|
|
16825
|
+
var RESUME_POLICY_VALUE_RE = /(full_rerun|checkpoint|evidence_only|从头重跑|检查点|仅补证据)/i;
|
|
16826
|
+
var FULL_RERUN_RE = /(full_rerun|重新运行|全量重跑|从头重跑)/i;
|
|
16827
|
+
var PARTIAL_RERUN_RE = /(checkpoint|evidence_only|检查点|仅补证据)/i;
|
|
16828
|
+
var RUN_MARKER_RE = /\b\d{8}(?:-\d{3})?\b/g;
|
|
16829
|
+
var COMPLETE_RESULT_RE = /^(pass|passed|complete|success|通过|完整)$/i;
|
|
16830
|
+
var REPORT_RESULT_ALLOWED_RE = /^(?:pass|passed|complete|success|通过|完整|pass[-_]with[-_](?:warnings|evidence)|partial|stage|blocked|diagnostic|fail|failed|error|阶段|局部|不完整|阻塞|诊断|失败)$/i;
|
|
16831
|
+
var NOT_RUN_RE = /(not[_ -]?run|未执行|未跑|跳过)/i;
|
|
16832
|
+
var BLOCKED_RE = /(blocked|阻塞|卡住|无法继续)/i;
|
|
16833
|
+
var PASS_CASE_RE = /\b(pass|passed|success|通过)\b|(^|[||,,;;\s])通过($|[||,,;;\s])/i;
|
|
16834
|
+
var HISTORICAL_EVIDENCE_RE = /(历史|旧报告|旧截图|旧结果|旧状态|复用.*(报告|截图|结果|状态)|historical|old report|old screenshot|old result|reused)/i;
|
|
16835
|
+
var PAGE_CONCLUSION_RE = /(页面.*(通过|已验证|真实|可见|不可见)|浏览器回归.*(通过|完成)|完整链路.*通过|真实页面.*通过)/;
|
|
16836
|
+
var API_ONLY_PASS_EVIDENCE_RE = /(接口回读|readback|缓存命中|cache hit|status matrix|状态矩阵|接口一致|API\s*(验证|通过|evidence))/i;
|
|
15121
16837
|
var TestSuiteError = class extends Error {
|
|
15122
16838
|
code;
|
|
15123
16839
|
rule_id;
|
|
@@ -15140,7 +16856,7 @@ async function exists3(filePath) {
|
|
|
15140
16856
|
}
|
|
15141
16857
|
}
|
|
15142
16858
|
async function readText(filePath) {
|
|
15143
|
-
return
|
|
16859
|
+
return readFile16(filePath, "utf8");
|
|
15144
16860
|
}
|
|
15145
16861
|
function fail(message, options = {}) {
|
|
15146
16862
|
throw new TestSuiteError(message, options);
|
|
@@ -15390,6 +17106,87 @@ function hasE2eReusableAsset(row) {
|
|
|
15390
17106
|
const evidencePlan = [row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
|
|
15391
17107
|
return E2E_REUSABLE_ASSET_RE.test(evidencePlan);
|
|
15392
17108
|
}
|
|
17109
|
+
function validateReadableCaseContent(filePath, caseId, row) {
|
|
17110
|
+
for (const field of ["title", "preconditions", "config_basis", "prep_data", "steps", "expected_result", "test_data"]) {
|
|
17111
|
+
const value = row[field].trim();
|
|
17112
|
+
if (!value) continue;
|
|
17113
|
+
if (CASE_CONTENT_GARBLED_RE.test(value)) {
|
|
17114
|
+
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" });
|
|
17115
|
+
}
|
|
17116
|
+
if (HOLLOW_CASE_TEXT_RE.test(value)) {
|
|
17117
|
+
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" });
|
|
17118
|
+
}
|
|
17119
|
+
}
|
|
17120
|
+
if (row.steps.trim().length < 12 || !/[>;;。]|打开|点击|填写|选择|提交|等待|截图|校验|验证/.test(row.steps)) {
|
|
17121
|
+
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" });
|
|
17122
|
+
}
|
|
17123
|
+
}
|
|
17124
|
+
function validatePreflightEvidence(filePath, caseId, row, prepTokens) {
|
|
17125
|
+
if (!prepTokens.precondition_check) {
|
|
17126
|
+
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" });
|
|
17127
|
+
}
|
|
17128
|
+
if (!prepTokens.browser_tool || !BROWSER_TOOL_RE.test(prepTokens.browser_tool)) {
|
|
17129
|
+
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" });
|
|
17130
|
+
}
|
|
17131
|
+
if (!prepTokens.live_draft || !LIVE_DRAFT_RE.test(prepTokens.live_draft)) {
|
|
17132
|
+
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" });
|
|
17133
|
+
}
|
|
17134
|
+
if (!prepTokens.state_file && !prepTokens.report_run) {
|
|
17135
|
+
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" });
|
|
17136
|
+
}
|
|
17137
|
+
const policy = prepTokens.resume_policy;
|
|
17138
|
+
if (!policy || !RESUME_POLICY_VALUE_RE.test(policy)) {
|
|
17139
|
+
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" });
|
|
17140
|
+
}
|
|
17141
|
+
if (policy && PARTIAL_RERUN_RE.test(policy) && !/(边界|范围|局部|检查点|仅补证据|用户确认|只验证|scope|boundary|confirmed)/i.test([row.prep_data, row.steps, row.expected_result, row.evidence_required].join(" "))) {
|
|
17142
|
+
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" });
|
|
17143
|
+
}
|
|
17144
|
+
for (const [token, value] of Object.entries({ state_file: prepTokens.state_file, report_run: prepTokens.report_run })) {
|
|
17145
|
+
if (!value) continue;
|
|
17146
|
+
const markers = reportRunMarkers(value).filter((marker) => !/<run_id>|<date>|\{run_id\}|\{date\}|\$RUN_ID|\$RUN_DATE/i.test(value));
|
|
17147
|
+
if (markers.length > 0 && !value.includes("<run_id>") && !value.includes("<date>")) {
|
|
17148
|
+
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" });
|
|
17149
|
+
}
|
|
17150
|
+
}
|
|
17151
|
+
}
|
|
17152
|
+
function validateErrorCaptureEvidence(filePath, caseId, row) {
|
|
17153
|
+
const caseText = [row.type, row.title, row.preconditions, row.steps, row.expected_result, row.tags].join(" ");
|
|
17154
|
+
if (!ERROR_CAPTURE_CASE_RE.test(caseText)) return;
|
|
17155
|
+
const evidenceText = [row.prep_data, row.steps, row.expected_result, row.evidence_required].join(" ");
|
|
17156
|
+
if (!ERROR_CAPTURE_EVIDENCE_RE.test(evidenceText)) {
|
|
17157
|
+
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" });
|
|
17158
|
+
}
|
|
17159
|
+
}
|
|
17160
|
+
function validateResumePolicy(filePath, caseId, row, prepTokens) {
|
|
17161
|
+
const manualText = [row.preconditions, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
|
|
17162
|
+
if (!/(人工介入|手工|补救|续跑|dirty_resumed|局部复核|partial rerun)/i.test(manualText)) return;
|
|
17163
|
+
const text5 = [row.preconditions, row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
|
|
17164
|
+
const policy = prepTokens.resume_policy || text5;
|
|
17165
|
+
if (!RESUME_POLICY_VALUE_RE.test(policy)) {
|
|
17166
|
+
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" });
|
|
17167
|
+
}
|
|
17168
|
+
if (!/dirty_resumed|局部复核|partial|从头重跑|检查点/.test(text5)) {
|
|
17169
|
+
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" });
|
|
17170
|
+
}
|
|
17171
|
+
}
|
|
17172
|
+
function validateMultiRoleEvidence(filePath, caseId, row, prepTokens) {
|
|
17173
|
+
const text5 = [row.roles, row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
|
|
17174
|
+
if (!MULTI_ROLE_VALUE_RE.test(row.roles) && !/多角色|跨角色/.test(text5)) return;
|
|
17175
|
+
if (!prepTokens.login_profile) {
|
|
17176
|
+
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" });
|
|
17177
|
+
}
|
|
17178
|
+
const hasMockUser = Boolean(prepTokens.mock_user) || /bpmax-user-mock-operator|mock_user|模拟用户.*[=,,]/i.test(text5);
|
|
17179
|
+
if (!hasMockUser) {
|
|
17180
|
+
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" });
|
|
17181
|
+
}
|
|
17182
|
+
const hasUnmock = Boolean(prepTokens.unmock_done) || /unmock|退出模拟|恢复身份|恢复管理员/i.test(text5);
|
|
17183
|
+
if (!hasUnmock) {
|
|
17184
|
+
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" });
|
|
17185
|
+
}
|
|
17186
|
+
if (!/(分别截图|独立截图|每个角色|separate evidence|per-role|角色证据)/i.test(text5)) {
|
|
17187
|
+
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" });
|
|
17188
|
+
}
|
|
17189
|
+
}
|
|
15393
17190
|
function bootstrapActionForCase(row) {
|
|
15394
17191
|
const rawText = [row.title, row.prep_data, row.steps, row.evidence_required, row.tags].join(" ");
|
|
15395
17192
|
const text5 = rawText.toLowerCase();
|
|
@@ -15409,6 +17206,7 @@ async function validateCase(filePath, row, seen) {
|
|
|
15409
17206
|
if (!caseId) fail(`${filePath}: case_id is required`);
|
|
15410
17207
|
if (seen.has(caseId)) fail(`${filePath}: duplicate case_id \`${caseId}\``);
|
|
15411
17208
|
seen.add(caseId);
|
|
17209
|
+
validateReadableCaseContent(filePath, caseId, row);
|
|
15412
17210
|
for (const field of ["title", "config_basis", "steps", "expected_result", "status", "updated_at"]) {
|
|
15413
17211
|
if (!row[field].trim()) fail(`${filePath}:${caseId}: \`${field}\` is required`);
|
|
15414
17212
|
}
|
|
@@ -15452,6 +17250,10 @@ async function validateCase(filePath, row, seen) {
|
|
|
15452
17250
|
if (UUID_RE2.test(browserText)) fail(`${filePath}:${caseId}: browser-executed cases must not use UUID as the execution entrypoint`);
|
|
15453
17251
|
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
17252
|
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>`);
|
|
17253
|
+
validatePreflightEvidence(filePath, caseId, row, prepTokens);
|
|
17254
|
+
validateErrorCaptureEvidence(filePath, caseId, row);
|
|
17255
|
+
validateResumePolicy(filePath, caseId, row, prepTokens);
|
|
17256
|
+
validateMultiRoleEvidence(filePath, caseId, row, prepTokens);
|
|
15455
17257
|
validateBusinessTestData(filePath, caseId, row);
|
|
15456
17258
|
}
|
|
15457
17259
|
async function collectE2eAccelerationGaps(root) {
|
|
@@ -15595,10 +17397,10 @@ async function fileMap(root) {
|
|
|
15595
17397
|
return result;
|
|
15596
17398
|
}
|
|
15597
17399
|
async function sha256(filePath) {
|
|
15598
|
-
return createHash6("sha256").update(await
|
|
17400
|
+
return createHash6("sha256").update(await readFile16(filePath)).digest("hex");
|
|
15599
17401
|
}
|
|
15600
17402
|
async function readForDiff(filePath) {
|
|
15601
|
-
const buffer = await
|
|
17403
|
+
const buffer = await readFile16(filePath);
|
|
15602
17404
|
if (buffer.includes(0)) return [`<binary sha256=${createHash6("sha256").update(buffer).digest("hex")}>
|
|
15603
17405
|
`];
|
|
15604
17406
|
return buffer.toString("utf8").split(/(?<=\n)/);
|
|
@@ -15900,12 +17702,269 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
|
|
|
15900
17702
|
await mkdir12(path13.join(reportDir, "screenshots"), { recursive: true });
|
|
15901
17703
|
await writeFile12(
|
|
15902
17704
|
path13.join(reportDir, "summary.md"),
|
|
15903
|
-
[
|
|
17705
|
+
[
|
|
17706
|
+
"# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B",
|
|
17707
|
+
"",
|
|
17708
|
+
`run_id: ${path13.basename(reportDir)}`,
|
|
17709
|
+
"rerun_policy: full_rerun",
|
|
17710
|
+
"status: draft",
|
|
17711
|
+
"",
|
|
17712
|
+
"## \u573A\u666F\u62A5\u544A",
|
|
17713
|
+
"",
|
|
17714
|
+
"## \u622A\u56FE\u76EE\u5F55",
|
|
17715
|
+
"",
|
|
17716
|
+
`screenshots: ${path13.join(path13.basename(reportDir), "screenshots")}`,
|
|
17717
|
+
"",
|
|
17718
|
+
"## \u603B\u7ED3",
|
|
17719
|
+
""
|
|
17720
|
+
].join("\n"),
|
|
15904
17721
|
"utf8"
|
|
15905
17722
|
);
|
|
15906
17723
|
}
|
|
15907
17724
|
return reportDir;
|
|
15908
17725
|
}
|
|
17726
|
+
function reportKeyValue(text5, key) {
|
|
17727
|
+
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17728
|
+
const match = new RegExp(`^${escaped}[ \\t]*(.+)$`, "im").exec(text5);
|
|
17729
|
+
return match?.[1]?.trim() ?? "";
|
|
17730
|
+
}
|
|
17731
|
+
function reportHasAnyKeyValue(text5, keys) {
|
|
17732
|
+
return keys.some((key) => Boolean(reportKeyValue(text5, key)));
|
|
17733
|
+
}
|
|
17734
|
+
function reportClaimsCompleteResult(value) {
|
|
17735
|
+
if (!value || /(partial|stage|blocked|diagnostic|fail|error|阶段|局部|不完整|阻塞|失败|诊断)/i.test(value)) {
|
|
17736
|
+
return false;
|
|
17737
|
+
}
|
|
17738
|
+
return COMPLETE_RESULT_RE.test(value) || /(?:^|[_\s-])(pass(?:ed)?|complete|success)(?:$|[_\s-])/i.test(value) || /(通过|完整)/.test(value);
|
|
17739
|
+
}
|
|
17740
|
+
function crc32(value) {
|
|
17741
|
+
let crc = 4294967295;
|
|
17742
|
+
for (const byte of value) {
|
|
17743
|
+
crc ^= byte;
|
|
17744
|
+
for (let bit = 0; bit < 8; bit += 1) {
|
|
17745
|
+
crc = crc >>> 1 ^ (crc & 1 ? 3988292384 : 0);
|
|
17746
|
+
}
|
|
17747
|
+
}
|
|
17748
|
+
return (crc ^ 4294967295) >>> 0;
|
|
17749
|
+
}
|
|
17750
|
+
async function isValidCurrentRunScreenshot(filePath) {
|
|
17751
|
+
const buffer = await readFile16(filePath);
|
|
17752
|
+
const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
17753
|
+
if (buffer.length < 33 || !buffer.subarray(0, 8).equals(signature)) return false;
|
|
17754
|
+
let offset = 8;
|
|
17755
|
+
let width = 0;
|
|
17756
|
+
let height = 0;
|
|
17757
|
+
let bitDepth = 0;
|
|
17758
|
+
let colorType = -1;
|
|
17759
|
+
let interlace = -1;
|
|
17760
|
+
const idat = [];
|
|
17761
|
+
let hasIend = false;
|
|
17762
|
+
while (offset + 12 <= buffer.length) {
|
|
17763
|
+
const length = buffer.readUInt32BE(offset);
|
|
17764
|
+
const chunkEnd = offset + 12 + length;
|
|
17765
|
+
if (chunkEnd > buffer.length) return false;
|
|
17766
|
+
const type = buffer.subarray(offset + 4, offset + 8);
|
|
17767
|
+
const data = buffer.subarray(offset + 8, offset + 8 + length);
|
|
17768
|
+
const expectedCrc = buffer.readUInt32BE(offset + 8 + length);
|
|
17769
|
+
if (crc32(Buffer.concat([type, data])) !== expectedCrc) return false;
|
|
17770
|
+
const typeName = type.toString("ascii");
|
|
17771
|
+
if (typeName === "IHDR") {
|
|
17772
|
+
if (length !== 13) return false;
|
|
17773
|
+
width = data.readUInt32BE(0);
|
|
17774
|
+
height = data.readUInt32BE(4);
|
|
17775
|
+
bitDepth = data[8];
|
|
17776
|
+
colorType = data[9];
|
|
17777
|
+
interlace = data[12];
|
|
17778
|
+
} else if (typeName === "IDAT") {
|
|
17779
|
+
idat.push(data);
|
|
17780
|
+
} else if (typeName === "IEND") {
|
|
17781
|
+
hasIend = true;
|
|
17782
|
+
break;
|
|
17783
|
+
}
|
|
17784
|
+
offset = chunkEnd;
|
|
17785
|
+
}
|
|
17786
|
+
if (width < 100 || height < 80 || !idat.length || !hasIend || interlace !== 0) return false;
|
|
17787
|
+
const channels = { 2: 3, 6: 4 }[colorType];
|
|
17788
|
+
if (!channels || bitDepth !== 8) return false;
|
|
17789
|
+
try {
|
|
17790
|
+
const pixels = inflateSync(Buffer.concat(idat));
|
|
17791
|
+
const rowBytes = Math.ceil(width * channels * bitDepth / 8);
|
|
17792
|
+
const stride = rowBytes + 1;
|
|
17793
|
+
if (pixels.length !== stride * height) return false;
|
|
17794
|
+
const decoded = Buffer.alloc(rowBytes * height);
|
|
17795
|
+
const bytesPerPixel = Math.max(1, Math.ceil(channels * bitDepth / 8));
|
|
17796
|
+
const paeth = (left, up, upperLeft) => {
|
|
17797
|
+
const estimate = left + up - upperLeft;
|
|
17798
|
+
const leftDistance = Math.abs(estimate - left);
|
|
17799
|
+
const upDistance = Math.abs(estimate - up);
|
|
17800
|
+
const upperLeftDistance = Math.abs(estimate - upperLeft);
|
|
17801
|
+
return leftDistance <= upDistance && leftDistance <= upperLeftDistance ? left : upDistance <= upperLeftDistance ? up : upperLeft;
|
|
17802
|
+
};
|
|
17803
|
+
for (let row = 0; row < height; row += 1) {
|
|
17804
|
+
const filter = pixels[row * stride];
|
|
17805
|
+
if (filter > 4) return false;
|
|
17806
|
+
for (let column = 0; column < rowBytes; column += 1) {
|
|
17807
|
+
const source = pixels[row * stride + 1 + column];
|
|
17808
|
+
const targetIndex = row * rowBytes + column;
|
|
17809
|
+
const left = column >= bytesPerPixel ? decoded[targetIndex - bytesPerPixel] : 0;
|
|
17810
|
+
const up = row > 0 ? decoded[targetIndex - rowBytes] : 0;
|
|
17811
|
+
const upperLeft = row > 0 && column >= bytesPerPixel ? decoded[targetIndex - rowBytes - bytesPerPixel] : 0;
|
|
17812
|
+
const predictor = filter === 1 ? left : filter === 2 ? up : filter === 3 ? Math.floor((left + up) / 2) : filter === 4 ? paeth(left, up, upperLeft) : 0;
|
|
17813
|
+
decoded[targetIndex] = source + predictor & 255;
|
|
17814
|
+
}
|
|
17815
|
+
}
|
|
17816
|
+
const visiblePixels = /* @__PURE__ */ new Set();
|
|
17817
|
+
for (let index = 0; index < decoded.length; index += channels) {
|
|
17818
|
+
visiblePixels.add(decoded.subarray(index, index + channels).toString("hex"));
|
|
17819
|
+
if (visiblePixels.size >= 2) break;
|
|
17820
|
+
}
|
|
17821
|
+
if (visiblePixels.size < 2) return false;
|
|
17822
|
+
if (bitDepth === 8 && (colorType === 6 || colorType === 4)) {
|
|
17823
|
+
const alphaOffset = colorType === 6 ? 3 : 1;
|
|
17824
|
+
const pixelStride = colorType === 6 ? 4 : 2;
|
|
17825
|
+
let hasVisiblePixel = false;
|
|
17826
|
+
for (let index = alphaOffset; index < decoded.length; index += pixelStride) {
|
|
17827
|
+
if (decoded[index] > 0) {
|
|
17828
|
+
hasVisiblePixel = true;
|
|
17829
|
+
break;
|
|
17830
|
+
}
|
|
17831
|
+
}
|
|
17832
|
+
if (!hasVisiblePixel) return false;
|
|
17833
|
+
}
|
|
17834
|
+
return true;
|
|
17835
|
+
} catch {
|
|
17836
|
+
return false;
|
|
17837
|
+
}
|
|
17838
|
+
}
|
|
17839
|
+
function reportHasSupportedBrowserTool(value) {
|
|
17840
|
+
if (!value || /(^|\s)not\s+|unavailable|not available|disabled|blocked|missing|不可用|未启用|阻塞|缺失|无可用|^非/i.test(value)) {
|
|
17841
|
+
return false;
|
|
17842
|
+
}
|
|
17843
|
+
const tools = value.split(/\s*(?:\+|,|,|、|\/|;|;)\s*/).map((item) => item.trim()).filter(Boolean);
|
|
17844
|
+
return tools.length > 0 && tools.every((item) => /^(?:Chrome DevTools(?: MCP)?|DevTools|Playwright|AppleScript)$/i.test(item));
|
|
17845
|
+
}
|
|
17846
|
+
function reportRuntimeEvidenceMissing(text5) {
|
|
17847
|
+
const missing = [];
|
|
17848
|
+
if (!reportHasAnyKeyValue(text5, ["runtime_url:", "browser_runtime_url:"])) {
|
|
17849
|
+
missing.push("runtime_url");
|
|
17850
|
+
}
|
|
17851
|
+
if (!reportHasAnyKeyValue(text5, ["runtime_user:", "runtime_profile:", "browser_user:"])) {
|
|
17852
|
+
missing.push("runtime_user/runtime_profile");
|
|
17853
|
+
}
|
|
17854
|
+
if (!reportHasAnyKeyValue(text5, ["browser_action_log:", "browser_actions:"])) {
|
|
17855
|
+
missing.push("browser_action_log");
|
|
17856
|
+
}
|
|
17857
|
+
if (!reportHasAnyKeyValue(text5, ["visible_assertions:", "visible_assertion:"])) {
|
|
17858
|
+
missing.push("visible_assertions");
|
|
17859
|
+
}
|
|
17860
|
+
if (!reportHasAnyKeyValue(text5, ["project_id:", "step_id:"])) {
|
|
17861
|
+
missing.push("project_id/step_id");
|
|
17862
|
+
}
|
|
17863
|
+
return missing;
|
|
17864
|
+
}
|
|
17865
|
+
function reportRuntimeEvidenceInvalid(text5) {
|
|
17866
|
+
const invalid = [];
|
|
17867
|
+
const browserTool = reportKeyValue(text5, "browser_tool:");
|
|
17868
|
+
const runtimeUrl = reportKeyValue(text5, "runtime_url:") || reportKeyValue(text5, "browser_runtime_url:");
|
|
17869
|
+
const runtimeUser = reportKeyValue(text5, "runtime_user:") || reportKeyValue(text5, "runtime_profile:") || reportKeyValue(text5, "browser_user:");
|
|
17870
|
+
const actionLog = reportKeyValue(text5, "browser_action_log:") || reportKeyValue(text5, "browser_actions:");
|
|
17871
|
+
const assertions = reportKeyValue(text5, "visible_assertions:") || reportKeyValue(text5, "visible_assertion:");
|
|
17872
|
+
const projectId = reportKeyValue(text5, "project_id:");
|
|
17873
|
+
const stepId = reportKeyValue(text5, "step_id:");
|
|
17874
|
+
if (!reportHasSupportedBrowserTool(browserTool) || REPORT_EVIDENCE_PLACEHOLDER_RE.test(browserTool)) {
|
|
17875
|
+
invalid.push("browser_tool");
|
|
17876
|
+
}
|
|
17877
|
+
try {
|
|
17878
|
+
const url = new URL(runtimeUrl);
|
|
17879
|
+
if (!["http:", "https:"].includes(url.protocol) || !url.hostname) invalid.push("runtime_url");
|
|
17880
|
+
const hashRoute = url.hash.startsWith("#/") ? new URL(url.hash.slice(1), url.origin) : null;
|
|
17881
|
+
const runtimePath = hashRoute?.pathname || url.pathname;
|
|
17882
|
+
const runtimeParams = hashRoute?.searchParams || url.searchParams;
|
|
17883
|
+
if (/(^|\.)example\.(?:com|org|net)$/i.test(url.hostname) || /\/(?:api|bpmax)(?:\/|$)/i.test(runtimePath) || !/(?:\/project(?:$|\/|\?|_detail)|\/myProject|\/projectContinue|\/pages\/)/i.test(runtimePath)) {
|
|
17884
|
+
invalid.push("runtime_url/ui_route");
|
|
17885
|
+
}
|
|
17886
|
+
const pathProjectId = /\/project_detail\/\d+\/(\d+)/.exec(runtimePath)?.[1];
|
|
17887
|
+
const queryProjectId = runtimeParams.get("project_id") || runtimeParams.get("id");
|
|
17888
|
+
const urlProjectId = pathProjectId || queryProjectId;
|
|
17889
|
+
if (projectId && urlProjectId && projectId !== urlProjectId) invalid.push("runtime_url/project_id");
|
|
17890
|
+
const urlStepId = runtimeParams.get("step_id");
|
|
17891
|
+
if (stepId && urlStepId && stepId !== urlStepId) invalid.push("runtime_url/step_id");
|
|
17892
|
+
} catch {
|
|
17893
|
+
invalid.push("runtime_url");
|
|
17894
|
+
}
|
|
17895
|
+
if (REPORT_EVIDENCE_PLACEHOLDER_RE.test(runtimeUser) || /(todo|tbd|pending|later|待补|稍后)/i.test(runtimeUser)) invalid.push("runtime_user/runtime_profile");
|
|
17896
|
+
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)) {
|
|
17897
|
+
invalid.push("browser_action_log");
|
|
17898
|
+
}
|
|
17899
|
+
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)) {
|
|
17900
|
+
invalid.push("visible_assertions");
|
|
17901
|
+
}
|
|
17902
|
+
if (!/^\d+$/.test(projectId) && !/^\d+$/.test(stepId)) invalid.push("project_id/step_id");
|
|
17903
|
+
return [...new Set(invalid)];
|
|
17904
|
+
}
|
|
17905
|
+
function reportCaseList(text5, key) {
|
|
17906
|
+
const value = reportKeyValue(text5, key);
|
|
17907
|
+
return value.split(/[,\s,、;;]+/).map((item) => item.trim()).filter((item) => /^[A-Za-z0-9_-]+$/.test(item));
|
|
17908
|
+
}
|
|
17909
|
+
function reportRunDate(runName) {
|
|
17910
|
+
return runName.slice(0, 8);
|
|
17911
|
+
}
|
|
17912
|
+
function reportKeyValues(text5, key) {
|
|
17913
|
+
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17914
|
+
return [...text5.matchAll(new RegExp(`^${escaped}[ \\t]*(.+)$`, "gim"))].map((match) => match[1]?.trim() ?? "").filter(Boolean);
|
|
17915
|
+
}
|
|
17916
|
+
function reportRunMarkers(value) {
|
|
17917
|
+
return [...value.matchAll(RUN_MARKER_RE)].map((match) => match[0]);
|
|
17918
|
+
}
|
|
17919
|
+
function reportContainsHistoricalRun(value, runName) {
|
|
17920
|
+
const runDate = reportRunDate(runName);
|
|
17921
|
+
return reportRunMarkers(value).some((marker) => marker !== runName && marker !== runDate);
|
|
17922
|
+
}
|
|
17923
|
+
function parseReportTime(value) {
|
|
17924
|
+
if (!value.trim()) return null;
|
|
17925
|
+
const date = new Date(value.trim());
|
|
17926
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
17927
|
+
return date;
|
|
17928
|
+
}
|
|
17929
|
+
function reportDayWindow(runName) {
|
|
17930
|
+
const date = reportRunDate(runName);
|
|
17931
|
+
const start = /* @__PURE__ */ new Date(`${date.slice(0, 4)}-${date.slice(4, 6)}-${date.slice(6, 8)}T00:00:00+08:00`);
|
|
17932
|
+
const end = new Date(start.getTime() + 24 * 60 * 60 * 1e3);
|
|
17933
|
+
return { start, end };
|
|
17934
|
+
}
|
|
17935
|
+
function reportExecutionWindow(runName, text5) {
|
|
17936
|
+
const fallback = reportDayWindow(runName);
|
|
17937
|
+
const startedAt = parseReportTime(reportKeyValue(text5, "started_at:"));
|
|
17938
|
+
const finishedAt = parseReportTime(reportKeyValue(text5, "finished_at:"));
|
|
17939
|
+
if (!startedAt || !finishedAt || finishedAt < startedAt) return fallback;
|
|
17940
|
+
return { start: startedAt, end: finishedAt };
|
|
17941
|
+
}
|
|
17942
|
+
function isWithinWindow(date, window) {
|
|
17943
|
+
return date >= window.start && date <= window.end;
|
|
17944
|
+
}
|
|
17945
|
+
function caseEvidencePattern(caseId) {
|
|
17946
|
+
const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17947
|
+
return new RegExp(`\\b${escaped}\\b.*?(screenshots/|\\.ai_test/report/|\\.codex/tmp/e2e|evidence|\u622A\u56FE|\u8BC1\u636E|\u9879\u76EE|project|step)`, "i");
|
|
17948
|
+
}
|
|
17949
|
+
function caseResultPattern(caseId) {
|
|
17950
|
+
const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17951
|
+
return new RegExp(`\\b${escaped}\\b[^\\n]*(pass|passed|success|\u901A\u8FC7)`, "i");
|
|
17952
|
+
}
|
|
17953
|
+
function caseHasFailedResult(text5, caseId) {
|
|
17954
|
+
return linesForCase(text5, caseId).some((line) => {
|
|
17955
|
+
if (!line.includes("|")) return false;
|
|
17956
|
+
const cells = line.split("|").map((cell) => cell.trim());
|
|
17957
|
+
const caseIndex = cells.findIndex((cell) => cell === caseId);
|
|
17958
|
+
if (caseIndex < 0 || caseIndex + 2 >= cells.length) return false;
|
|
17959
|
+
const resultCell = cells[caseIndex + 2].replace(/[*_`~]/g, "").trim();
|
|
17960
|
+
return /\b(?:fail(?:ed)?|error|blocked)\b|失败|不通过/i.test(resultCell);
|
|
17961
|
+
});
|
|
17962
|
+
}
|
|
17963
|
+
function linesForCase(text5, caseId) {
|
|
17964
|
+
const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17965
|
+
const pattern = new RegExp(`\\b${escaped}\\b`);
|
|
17966
|
+
return text5.split(/\r?\n/).filter((line) => pattern.test(line));
|
|
17967
|
+
}
|
|
15909
17968
|
async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
15910
17969
|
if (!await exists3(root)) return [`report root not found: ${root}`];
|
|
15911
17970
|
const errors = [];
|
|
@@ -15922,12 +17981,87 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
|
15922
17981
|
for (const reportName of scenarioReports) {
|
|
15923
17982
|
const reportPath = path13.join(runDir, reportName);
|
|
15924
17983
|
const text5 = await readText(reportPath);
|
|
15925
|
-
for (const key of REPORT_REQUIRED_KEYS) if (!text5
|
|
17984
|
+
for (const key of REPORT_REQUIRED_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
|
|
17985
|
+
for (const key of REPORT_EXECUTION_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
|
|
15926
17986
|
for (const heading of REPORT_REQUIRED_HEADINGS) if (!text5.includes(heading)) errors.push(`${reportPath}: missing \`${heading}\``);
|
|
15927
|
-
const
|
|
15928
|
-
if (
|
|
17987
|
+
const runId = reportKeyValue(text5, "run_id:");
|
|
17988
|
+
if (runId && runId !== runName) {
|
|
17989
|
+
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`);
|
|
17990
|
+
}
|
|
17991
|
+
const rerunPolicy = reportKeyValue(text5, "rerun_policy:") || reportKeyValue(text5, "resume_policy:");
|
|
17992
|
+
const isFullRerun = FULL_RERUN_RE.test(rerunPolicy) || /重新运行|全量重跑|从头重跑/.test(text5);
|
|
17993
|
+
const isPartialRerun = PARTIAL_RERUN_RE.test(rerunPolicy);
|
|
17994
|
+
const resultValue = reportKeyValue(text5, "result:").toLowerCase();
|
|
17995
|
+
if (!REPORT_RESULT_ALLOWED_RE.test(resultValue)) {
|
|
17996
|
+
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>"}`);
|
|
17997
|
+
}
|
|
17998
|
+
if (isPartialRerun && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|对照/.test(resultValue)) {
|
|
17999
|
+
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`);
|
|
18000
|
+
}
|
|
18001
|
+
const plannedCases = reportCaseList(text5, "planned_cases:");
|
|
18002
|
+
const executedCases = reportCaseList(text5, "executed_cases:");
|
|
18003
|
+
const missingExecuted = plannedCases.filter((caseId) => !executedCases.includes(caseId));
|
|
18004
|
+
const unexpectedExecuted = executedCases.filter((caseId) => !plannedCases.includes(caseId));
|
|
18005
|
+
if (plannedCases.length > 0 && missingExecuted.length > 0) {
|
|
18006
|
+
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`);
|
|
18007
|
+
}
|
|
18008
|
+
if (unexpectedExecuted.length > 0) {
|
|
18009
|
+
errors.push(`[test_suite.report.case_reconciliation] ${reportPath}: executed_cases \u5305\u542B\u4E0D\u5728 planned_cases \u4E2D\u7684\u7528\u4F8B: ${unexpectedExecuted.join(", ")}`);
|
|
18010
|
+
}
|
|
18011
|
+
if ((NOT_RUN_RE.test(text5) || BLOCKED_RE.test(text5)) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
|
|
18012
|
+
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`);
|
|
18013
|
+
}
|
|
18014
|
+
if (reportClaimsCompleteResult(resultValue)) {
|
|
18015
|
+
const failedCases = executedCases.filter((caseId) => caseHasFailedResult(text5, caseId));
|
|
18016
|
+
if (failedCases.length) {
|
|
18017
|
+
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`);
|
|
18018
|
+
}
|
|
18019
|
+
}
|
|
18020
|
+
const browserToolValue = reportKeyValue(text5, "browser_tool:");
|
|
18021
|
+
if (PAGE_CONCLUSION_RE.test(text5) && !reportHasSupportedBrowserTool(browserToolValue)) {
|
|
18022
|
+
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`);
|
|
18023
|
+
}
|
|
18024
|
+
const claimsCompletePagePass = PAGE_CONCLUSION_RE.test(text5) || reportClaimsCompleteResult(resultValue);
|
|
18025
|
+
if (claimsCompletePagePass) {
|
|
18026
|
+
const missingRuntimeEvidence = reportRuntimeEvidenceMissing(text5);
|
|
18027
|
+
if (missingRuntimeEvidence.length) {
|
|
18028
|
+
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`);
|
|
18029
|
+
}
|
|
18030
|
+
const invalidRuntimeEvidence = reportRuntimeEvidenceInvalid(text5);
|
|
18031
|
+
if (invalidRuntimeEvidence.length) {
|
|
18032
|
+
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`);
|
|
18033
|
+
}
|
|
18034
|
+
}
|
|
18035
|
+
if (claimsCompletePagePass && API_ONLY_PASS_EVIDENCE_RE.test(text5)) {
|
|
18036
|
+
const missingRuntimeEvidence = reportRuntimeEvidenceMissing(text5);
|
|
18037
|
+
if (missingRuntimeEvidence.length) {
|
|
18038
|
+
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`);
|
|
18039
|
+
}
|
|
18040
|
+
}
|
|
18041
|
+
if (/browser[_ -]?blocked|浏览器阻塞|无可用浏览器工具/i.test(text5) && !/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5)) {
|
|
18042
|
+
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`);
|
|
18043
|
+
}
|
|
18044
|
+
if (/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|诊断/.test(resultValue)) {
|
|
18045
|
+
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`);
|
|
18046
|
+
}
|
|
15929
18047
|
const screenshotsDir = path13.join(runDir, "screenshots");
|
|
15930
18048
|
if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
|
|
18049
|
+
if (isFullRerun) {
|
|
18050
|
+
for (const key of ["state_file:", "precondition_check:", "report_run:"]) {
|
|
18051
|
+
for (const value of reportKeyValues(text5, key)) {
|
|
18052
|
+
const markers = reportRunMarkers(value);
|
|
18053
|
+
const hasCurrentMarker = markers.some((marker) => marker === runName || marker === reportRunDate(runName));
|
|
18054
|
+
if (!hasCurrentMarker || reportContainsHistoricalRun(value, runName)) {
|
|
18055
|
+
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}`);
|
|
18056
|
+
}
|
|
18057
|
+
}
|
|
18058
|
+
}
|
|
18059
|
+
}
|
|
18060
|
+
const imageMatches = [...text5.matchAll(IMAGE_RE)];
|
|
18061
|
+
const imageRefs = imageMatches.map((match) => match[1]);
|
|
18062
|
+
if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
|
|
18063
|
+
const validCurrentRunImages = [];
|
|
18064
|
+
const window = reportExecutionWindow(runName, text5);
|
|
15931
18065
|
for (const imageRef of imageRefs) {
|
|
15932
18066
|
if (imageRef.includes("://")) {
|
|
15933
18067
|
errors.push(`${reportPath}: screenshot must be a local file under this run's screenshots directory`);
|
|
@@ -15939,7 +18073,34 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
|
15939
18073
|
errors.push(`${reportPath}: image reference must stay under this run's screenshots directory: ${imageRef}`);
|
|
15940
18074
|
continue;
|
|
15941
18075
|
}
|
|
15942
|
-
if (!await exists3(imagePath))
|
|
18076
|
+
if (!await exists3(imagePath)) {
|
|
18077
|
+
errors.push(`${reportPath}: missing image file: ${imageRef}`);
|
|
18078
|
+
continue;
|
|
18079
|
+
}
|
|
18080
|
+
if (!await isValidCurrentRunScreenshot(imagePath)) {
|
|
18081
|
+
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}`);
|
|
18082
|
+
continue;
|
|
18083
|
+
}
|
|
18084
|
+
validCurrentRunImages.push(imageRef);
|
|
18085
|
+
if (isFullRerun) {
|
|
18086
|
+
const imageStat = await stat6(imagePath);
|
|
18087
|
+
if (!isWithinWindow(imageStat.mtime, window)) {
|
|
18088
|
+
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}`);
|
|
18089
|
+
}
|
|
18090
|
+
}
|
|
18091
|
+
}
|
|
18092
|
+
if (isFullRerun) {
|
|
18093
|
+
for (const caseId of executedCases) {
|
|
18094
|
+
const caseLines = linesForCase(text5, caseId);
|
|
18095
|
+
const hasPassResult = caseResultPattern(caseId).test(text5) || caseLines.some((line) => PASS_CASE_RE.test(line));
|
|
18096
|
+
const hasCurrentEvidence = caseEvidencePattern(caseId).test(text5) || validCurrentRunImages.some((imageRef) => imageRef.includes(caseId));
|
|
18097
|
+
if (hasPassResult && caseLines.some((line) => HISTORICAL_EVIDENCE_RE.test(line))) {
|
|
18098
|
+
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`);
|
|
18099
|
+
}
|
|
18100
|
+
if (hasPassResult && !hasCurrentEvidence) {
|
|
18101
|
+
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`);
|
|
18102
|
+
}
|
|
18103
|
+
}
|
|
15943
18104
|
}
|
|
15944
18105
|
}
|
|
15945
18106
|
}
|
|
@@ -16009,7 +18170,7 @@ function registerTestSuiteCommands(program2) {
|
|
|
16009
18170
|
}
|
|
16010
18171
|
|
|
16011
18172
|
// src/core/update.ts
|
|
16012
|
-
import { access as access2, mkdir as mkdir13, readFile as
|
|
18173
|
+
import { access as access2, mkdir as mkdir13, readFile as readFile17, realpath, writeFile as writeFile13 } from "fs/promises";
|
|
16013
18174
|
import path14 from "path";
|
|
16014
18175
|
var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
16015
18176
|
var UPDATE_STATE_FILE = "update-state.json";
|
|
@@ -16126,7 +18287,7 @@ function updateStatePath(configDir = getConfigDir()) {
|
|
|
16126
18287
|
}
|
|
16127
18288
|
async function readUpdateState(configDir) {
|
|
16128
18289
|
try {
|
|
16129
|
-
const raw = await
|
|
18290
|
+
const raw = await readFile17(updateStatePath(configDir), "utf8");
|
|
16130
18291
|
const parsed = JSON.parse(raw);
|
|
16131
18292
|
if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
|
|
16132
18293
|
return null;
|
|
@@ -16665,6 +18826,7 @@ registerSchemaCommands(program);
|
|
|
16665
18826
|
registerUserCommands(program);
|
|
16666
18827
|
registerEsCommands(program);
|
|
16667
18828
|
registerFlowCommands(program);
|
|
18829
|
+
registerIssueCommands(program);
|
|
16668
18830
|
registerMemoryCommands(program);
|
|
16669
18831
|
registerMatrixCommands(program);
|
|
16670
18832
|
registerPluginCommands(program);
|