bpmax-cli 0.2.1-beta.28 → 0.2.1-beta.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -474,7 +474,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
474
474
  // package.json
475
475
  var package_default = {
476
476
  name: "bpmax-cli",
477
- version: "0.2.1-beta.28",
477
+ version: "0.2.1-beta.29",
478
478
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
479
479
  type: "module",
480
480
  bin: {
@@ -4218,6 +4218,7 @@ import path9 from "path";
4218
4218
  import { createHash as createHash4 } from "crypto";
4219
4219
  import { mkdir as mkdir5, readdir as readdir2, readFile as readFile8, writeFile as writeFile5 } from "fs/promises";
4220
4220
  import path5 from "path";
4221
+ import { isDeepStrictEqual } from "util";
4221
4222
  function configWorkflowError(message, details) {
4222
4223
  return Object.assign(new Error(message), details);
4223
4224
  }
@@ -4909,6 +4910,7 @@ async function lintFlowAppWorkFiles(formWorkFile, flowWorkFile, options = {}) {
4909
4910
  const flowErrors = [];
4910
4911
  const warnings = [];
4911
4912
  let pluginLint;
4913
+ let stepDetailReferenceAudit;
4912
4914
  if (!isRecord3(formWork)) {
4913
4915
  formErrors.push("flow-app create requires form work to be a JSON object.");
4914
4916
  } else if (formWork.mode !== "create") {
@@ -4930,6 +4932,11 @@ async function lintFlowAppWorkFiles(formWorkFile, flowWorkFile, options = {}) {
4930
4932
  flowErrors.push(...pluginLint.errors);
4931
4933
  warnings.push(...pluginLint.warnings);
4932
4934
  }
4935
+ if (options.pluginLint?.profile) {
4936
+ stepDetailReferenceAudit = await auditFlowStepDetailReferences(flowWork, options.pluginLint.profile);
4937
+ flowErrors.push(...stepDetailReferenceAudit.errors.filter((error) => !flowErrors.includes(error)));
4938
+ warnings.push(...stepDetailReferenceAudit.warnings);
4939
+ }
4933
4940
  }
4934
4941
  errors.push(...formErrors, ...flowErrors);
4935
4942
  return {
@@ -4945,6 +4952,11 @@ async function lintFlowAppWorkFiles(formWorkFile, flowWorkFile, options = {}) {
4945
4952
  flow_template: flowErrors
4946
4953
  },
4947
4954
  ...pluginLint ? { plugin_lints: pluginLint.plugin_lints } : {},
4955
+ ...stepDetailReferenceAudit ? {
4956
+ step_detail_references: stepDetailReferenceAudit.references,
4957
+ step_detail_warnings: stepDetailReferenceAudit.warnings,
4958
+ runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
4959
+ } : {},
4948
4960
  warnings,
4949
4961
  flow_type_policy: "flow_type is allocated by the platform during config flow-app create; pre-create lint intentionally does not require flow_type.",
4950
4962
  evidence_requirements: [
@@ -6010,6 +6022,329 @@ function lintTemplateFieldReferences(value, errors) {
6010
6022
  }
6011
6023
  }
6012
6024
  }
6025
+ var STEP_DETAIL_CORE_MODULE_NAMES = /* @__PURE__ */ new Set([
6026
+ "\u4E0A\u4E00\u73AF\u8282",
6027
+ "\u73AF\u8282\u9644\u4EF6",
6028
+ "\u8BC4\u8BBA",
6029
+ "\u64CD\u4F5C\u65E5\u5FD7",
6030
+ "\u5F53\u524D\u73AF\u8282",
6031
+ "\u4EFB\u610F\u73AF\u8282\u8868\u5355",
6032
+ "\u5907\u6CE8",
6033
+ "\u73AF\u8282\u8868\u5355",
6034
+ "\u5F15\u7528\u9644\u4EF6",
6035
+ "\u590D\u6742\u8868\u5355",
6036
+ "\u6284\u9001\u4EBA",
6037
+ "\u73AF\u8282\u8017\u65F6",
6038
+ "\u7ED1\u5B9A\u5B50\u6D41\u7A0B",
6039
+ "\u4F20\u9605[\u4FA7\u8FB9\u680F]",
6040
+ "\u9879\u76EE\u4FE1\u606F",
6041
+ "\u540E\u7EED\u73AF\u8282\u8D1F\u8D23\u4EBA\u5206\u914D",
6042
+ "\u6D41\u7A0B\u65E5\u5FD7[\u4FA7\u8FB9\u680F]",
6043
+ "\u9879\u76EE\u4FE1\u606F[\u4FA7\u8FB9\u680F]",
6044
+ "\u8868\u5355[\u4FA7\u8FB9\u680F]",
6045
+ "\u4E0A\u4E00\u73AF\u8282\u8868\u5355",
6046
+ "\u5173\u8054\u9879\u76EE\u8868\u5355",
6047
+ "\u9644\u4EF6[\u4FA7\u8FB9\u680F]"
6048
+ ]);
6049
+ function stepDetailLintCustomModules(value) {
6050
+ const lint = isRecord3(value.bpmax_lint) ? value.bpmax_lint : {};
6051
+ const modules = Array.isArray(lint.step_detail_custom_modules) ? lint.step_detail_custom_modules : [];
6052
+ return new Set(
6053
+ modules.filter((item) => typeof item === "string" && Boolean(item.trim())).map((item) => item.trim())
6054
+ );
6055
+ }
6056
+ function parseStepDetailContent(value, errors) {
6057
+ const basic = isRecord3(value.basic) ? value.basic : value;
6058
+ const rawContent = value.content ?? basic.content;
6059
+ if (rawContent === void 0 || rawContent === null || rawContent === "") {
6060
+ errors.push("step-detail-template content \u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u4E14\u5FC5\u987B\u5305\u542B\u975E\u7A7A layout\u3002");
6061
+ return void 0;
6062
+ }
6063
+ if (typeof rawContent === "string") {
6064
+ try {
6065
+ const parsed = JSON.parse(rawContent);
6066
+ if (!isRecord3(parsed)) {
6067
+ errors.push("step-detail-template content \u5FC5\u987B\u89E3\u6790\u4E3A JSON \u5BF9\u8C61\u3002");
6068
+ return void 0;
6069
+ }
6070
+ return parsed;
6071
+ } catch {
6072
+ errors.push("step-detail-template content \u5FC5\u987B\u662F\u5408\u6CD5 JSON\u3002");
6073
+ return void 0;
6074
+ }
6075
+ }
6076
+ if (!isRecord3(rawContent)) {
6077
+ errors.push("step-detail-template content \u5FC5\u987B\u662F JSON \u5BF9\u8C61\u3002");
6078
+ return void 0;
6079
+ }
6080
+ return rawContent;
6081
+ }
6082
+ function analyzeStepDetailTemplate(value, options = {}) {
6083
+ const errors = [];
6084
+ const warnings = [];
6085
+ const basic = isRecord3(value.basic) ? value.basic : value;
6086
+ if (typeof basic.name !== "string" || !basic.name.trim()) {
6087
+ errors.push("step-detail-template name \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002");
6088
+ }
6089
+ if (basic.type !== void 0 && Number(basic.type) !== 6) {
6090
+ errors.push(`step-detail-template type \u5FC5\u987B\u4E3A 6\uFF0C\u5F53\u524D\u4E3A ${JSON.stringify(basic.type)}\u3002`);
6091
+ }
6092
+ const content = parseStepDetailContent(value, errors);
6093
+ const layout = content?.layout;
6094
+ if (!Array.isArray(layout) || layout.length === 0) {
6095
+ errors.push("step-detail-template content.layout \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4\u3002");
6096
+ return {
6097
+ errors,
6098
+ warnings,
6099
+ moduleNames: [],
6100
+ unknownModules: [],
6101
+ customModules: [],
6102
+ hasMainColumn: false,
6103
+ hasCurrentStepForm: false,
6104
+ hasRelatedProjectForm: false,
6105
+ requiresRuntimeProof: false
6106
+ };
6107
+ }
6108
+ const declaredCustomModules = stepDetailLintCustomModules(value);
6109
+ const moduleNames = [];
6110
+ const unknownModules = /* @__PURE__ */ new Set();
6111
+ const usedCustomModules = /* @__PURE__ */ new Set();
6112
+ const occupied = /* @__PURE__ */ new Set();
6113
+ let hasMainColumn = false;
6114
+ layout.forEach((item, index) => {
6115
+ const itemPath = `content.layout[${index}]`;
6116
+ if (!isRecord3(item)) {
6117
+ errors.push(`${itemPath} \u5FC5\u987B\u662F\u5BF9\u8C61\u3002`);
6118
+ return;
6119
+ }
6120
+ const name = typeof item.name === "string" ? item.name.trim() : "";
6121
+ if (!name) {
6122
+ errors.push(`${itemPath}.name \u5FC5\u987B\u662F\u975E\u7A7A\u6A21\u5757\u540D\u79F0\u3002`);
6123
+ } else {
6124
+ moduleNames.push(name);
6125
+ if (!STEP_DETAIL_CORE_MODULE_NAMES.has(name) && !declaredCustomModules.has(name)) {
6126
+ unknownModules.add(name);
6127
+ } else if (!STEP_DETAIL_CORE_MODULE_NAMES.has(name)) {
6128
+ usedCustomModules.add(name);
6129
+ }
6130
+ }
6131
+ const x = item.x;
6132
+ const y = item.y;
6133
+ if (x !== 0 && x !== 1) {
6134
+ errors.push(`${itemPath}.x \u53EA\u80FD\u4E3A 0\uFF08\u4E3B\u680F\uFF09\u6216 1\uFF08\u4FA7\u680F\uFF09\u3002`);
6135
+ } else if (x === 0) {
6136
+ hasMainColumn = true;
6137
+ }
6138
+ if (typeof y !== "number" || !Number.isInteger(y) || y < 0) {
6139
+ errors.push(`${itemPath}.y \u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570\u3002`);
6140
+ }
6141
+ if ((x === 0 || x === 1) && typeof y === "number" && Number.isInteger(y) && y >= 0) {
6142
+ const position = `${x}:${y}`;
6143
+ if (occupied.has(position)) {
6144
+ errors.push(`${itemPath} \u4E0E\u5176\u4ED6\u6A21\u5757\u5360\u7528\u4E86\u91CD\u590D\u4F4D\u7F6E x=${x}, y=${y}\u3002`);
6145
+ }
6146
+ occupied.add(position);
6147
+ }
6148
+ if (item.config !== void 0 && !isRecord3(item.config)) {
6149
+ errors.push(`${itemPath}.config \u5FC5\u987B\u662F\u5BF9\u8C61\u3002`);
6150
+ }
6151
+ if (item.detailFormConfig !== void 0 && (!Array.isArray(item.detailFormConfig) || item.detailFormConfig.some((entry) => !isRecord3(entry)))) {
6152
+ errors.push(`${itemPath}.detailFormConfig \u5FC5\u987B\u662F\u5BF9\u8C61\u6570\u7EC4\u3002`);
6153
+ }
6154
+ });
6155
+ if (!hasMainColumn) {
6156
+ errors.push("step-detail-template \u81F3\u5C11\u9700\u8981\u4E00\u4E2A x=0 \u7684\u4E3B\u680F\u6A21\u5757\u3002");
6157
+ }
6158
+ if (unknownModules.size) {
6159
+ const names = [...unknownModules].join(", ");
6160
+ const message = `step-detail-template \u5305\u542B\u672A\u58F0\u660E\u7684\u81EA\u5B9A\u4E49\u6A21\u5757\uFF1A${names}\u3002\u5E73\u53F0\u4F1A\u9759\u9ED8\u8FC7\u6EE4\u672A\u6CE8\u518C\u6A21\u5757\uFF1B\u8BF7\u786E\u8BA4\u63D2\u4EF6\u5DF2\u6CE8\u518C\uFF0C\u5E76\u5728 work.bpmax_lint.step_detail_custom_modules \u4E2D\u663E\u5F0F\u58F0\u660E\u3002`;
6161
+ if (options.allowUndeclaredCustomModules) {
6162
+ warnings.push(message);
6163
+ } else {
6164
+ errors.push(message);
6165
+ }
6166
+ }
6167
+ if (usedCustomModules.size) {
6168
+ warnings.push(
6169
+ `step-detail-template \u4F7F\u7528\u5DF2\u58F0\u660E\u7684\u63D2\u4EF6\u81EA\u5B9A\u4E49\u6A21\u5757\uFF1A${[...usedCustomModules].join(", ")}\u3002CLI \u53EA\u80FD\u786E\u8BA4\u58F0\u660E\u5B58\u5728\uFF0C\u4E0D\u80FD\u9759\u6001\u8BC1\u660E\u524D\u7AEF\u63D2\u4EF6\u5DF2\u6CE8\u518C\uFF1B\u5B8C\u6210\u7ED3\u8BBA\u5FC5\u987B\u5305\u542B\u771F\u5B9E\u73AF\u8282\u9875\u9762\u8BC1\u636E\u3002`
6170
+ );
6171
+ }
6172
+ return {
6173
+ errors,
6174
+ warnings,
6175
+ moduleNames,
6176
+ unknownModules: [...unknownModules],
6177
+ customModules: [...usedCustomModules],
6178
+ hasMainColumn,
6179
+ hasCurrentStepForm: moduleNames.some((name) => ["\u73AF\u8282\u8868\u5355", "\u4EFB\u610F\u73AF\u8282\u8868\u5355", "\u590D\u6742\u8868\u5355"].includes(name)),
6180
+ hasRelatedProjectForm: moduleNames.includes("\u5173\u8054\u9879\u76EE\u8868\u5355"),
6181
+ requiresRuntimeProof: unknownModules.size > 0 || usedCustomModules.size > 0
6182
+ };
6183
+ }
6184
+ function lintStepDetailTemplateWork(value, errors, warnings) {
6185
+ const analysis = analyzeStepDetailTemplate(value);
6186
+ errors.push(...analysis.errors);
6187
+ warnings.push(...analysis.warnings);
6188
+ return analysis;
6189
+ }
6190
+ function stepDetailAnalysisEvidence(analysis) {
6191
+ return {
6192
+ modules: analysis.moduleNames,
6193
+ unknown_modules: analysis.unknownModules,
6194
+ custom_modules: analysis.customModules,
6195
+ has_main_column: analysis.hasMainColumn,
6196
+ has_current_step_form: analysis.hasCurrentStepForm,
6197
+ has_related_project_form: analysis.hasRelatedProjectForm,
6198
+ runtime_proof_required: analysis.requiresRuntimeProof
6199
+ };
6200
+ }
6201
+ function stepDetailLintArtifact(value) {
6202
+ return {
6203
+ step_detail_custom_modules: [...stepDetailLintCustomModules(value)]
6204
+ };
6205
+ }
6206
+ function stepDetailPayloadWithLintArtifact(payload, submit) {
6207
+ const lint = isRecord3(submit.step_detail_lint) ? submit.step_detail_lint : {};
6208
+ return {
6209
+ ...payload,
6210
+ bpmax_lint: lint
6211
+ };
6212
+ }
6213
+ function numericTemplateId(value) {
6214
+ return isRemoteNumericTemplateId(value) ? String(value).trim() : null;
6215
+ }
6216
+ async function auditFlowStepDetailReferences(flowWork, profile) {
6217
+ const errors = [];
6218
+ const warnings = [];
6219
+ const references = [];
6220
+ const data = isRecord3(flowWork.data) ? flowWork.data : {};
6221
+ const meta = isRecord3(data.meta) ? data.meta : {};
6222
+ const metaConfigured = !isEmptyTemplateReference(meta.step_detail_id);
6223
+ const metaId = numericTemplateId(meta.step_detail_id);
6224
+ const nodes = Array.isArray(data.nodes) ? data.nodes.map((node, index) => ({ node, index })).filter((entry) => isRecord3(entry.node)) : [];
6225
+ const ids = /* @__PURE__ */ new Set();
6226
+ if (metaConfigured && !metaId) {
6227
+ addFlowTemplateRemoteIdError(errors, "data.meta.step_detail_id", meta.step_detail_id);
6228
+ }
6229
+ if (metaId) ids.add(metaId);
6230
+ nodes.forEach(({ node, index }) => {
6231
+ const directConfigured = !isEmptyTemplateReference(node.step_detail_id);
6232
+ const directId = numericTemplateId(node.step_detail_id);
6233
+ if (directConfigured && !directId) {
6234
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
6235
+ addFlowTemplateRemoteIdError(errors, `data.nodes[${index}].step_detail_id (${nodeName})`, node.step_detail_id);
6236
+ }
6237
+ if (directId) ids.add(directId);
6238
+ });
6239
+ const templates = /* @__PURE__ */ new Map();
6240
+ if (ids.size) {
6241
+ await ensureConfigCapability(profile, "config.step_detail_template.export");
6242
+ const definition = CONFIG_DOMAINS["step-detail-template"];
6243
+ const remoteResults = await Promise.all([...ids].map(async (id) => {
6244
+ try {
6245
+ const remote = await readRemoteConfigDomain(profile, "step-detail-template", id, definition);
6246
+ validateExpectedType("step-detail-template", definition, remote);
6247
+ if (!isRecord3(remote)) {
6248
+ throw new Error("\u8FDC\u7AEF\u54CD\u5E94\u4E0D\u662F\u6A21\u677F\u5BF9\u8C61");
6249
+ }
6250
+ const analysis = analyzeStepDetailTemplate(remote, { allowUndeclaredCustomModules: true });
6251
+ return { id, remote, analysis, error: null };
6252
+ } catch (error) {
6253
+ return {
6254
+ id,
6255
+ remote: null,
6256
+ analysis: null,
6257
+ error: error instanceof Error ? error.message : String(error)
6258
+ };
6259
+ }
6260
+ }));
6261
+ remoteResults.forEach((result) => {
6262
+ if (result.error || !result.remote || !result.analysis) {
6263
+ errors.push(`step_detail_id=${result.id} \u65E0\u6CD5\u5728\u5F53\u524D profile \u56DE\u8BFB\u4E3A type=6 \u73AF\u8282\u8BE6\u60C5\u6A21\u677F\uFF1A${result.error || "\u8FDC\u7AEF\u54CD\u5E94\u65E0\u6548"}\u3002`);
6264
+ return;
6265
+ }
6266
+ errors.push(...result.analysis.errors.map((message) => `step_detail_id=${result.id}: ${message}`));
6267
+ warnings.push(...result.analysis.warnings.map((message) => `step_detail_id=${result.id}: ${message}`));
6268
+ templates.set(result.id, {
6269
+ record: result.remote,
6270
+ analysis: result.analysis,
6271
+ structuralOk: result.analysis.errors.length === 0
6272
+ });
6273
+ });
6274
+ }
6275
+ if (metaConfigured) {
6276
+ const template = metaId ? templates.get(metaId) : void 0;
6277
+ references.push({
6278
+ path: "data.meta.step_detail_id",
6279
+ source: metaId ? "flow_default" : "invalid_flow_default",
6280
+ configured_value: meta.step_detail_id,
6281
+ effective_id: metaId,
6282
+ status: metaId && template?.structuralOk ? "verified" : "invalid",
6283
+ template_name: template?.record.name ?? null,
6284
+ template_type: template?.record.type ?? null,
6285
+ template_structural_ok: template ? template.structuralOk : null,
6286
+ template_errors: template?.analysis.errors ?? [],
6287
+ modules: template?.analysis.moduleNames ?? [],
6288
+ unknown_modules: template?.analysis.unknownModules ?? [],
6289
+ custom_modules: template?.analysis.customModules ?? [],
6290
+ runtime_proof_required: template?.analysis.requiresRuntimeProof ?? false
6291
+ });
6292
+ }
6293
+ nodes.forEach(({ node, index }) => {
6294
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
6295
+ const directConfigured = !isEmptyTemplateReference(node.step_detail_id);
6296
+ const directId = numericTemplateId(node.step_detail_id);
6297
+ const effectiveId = directConfigured ? directId : metaConfigured ? metaId : null;
6298
+ const template = effectiveId ? templates.get(effectiveId) : void 0;
6299
+ const source = directConfigured ? directId ? "node" : "invalid_node_reference" : metaConfigured ? metaId ? "flow_default" : "invalid_flow_default" : "platform_default_layout";
6300
+ const hideStepDetail = node.hide_step_detail === true;
6301
+ const hasStepForm = !isEmptyTemplateReference(node.form_template);
6302
+ const enableRelatedProjectForm = node.enable_relate_project_form === true;
6303
+ let suitability = hideStepDetail ? "hidden" : source === "invalid_node_reference" || source === "invalid_flow_default" ? "invalid" : effectiveId ? template?.structuralOk ? "verified" : "mismatch" : "platform_default_layout";
6304
+ if (hideStepDetail && effectiveId) {
6305
+ warnings.push(`${nodeName} \u5DF2\u8BBE\u7F6E hide_step_detail=true\uFF0C\u4F46\u4ECD\u7ED1\u5B9A step_detail_id=${effectiveId}\uFF1B\u8BE5\u6A21\u677F\u4E0D\u4F1A\u4F5C\u4E3A\u6B63\u5E38\u73AF\u8282\u8BE6\u60C5\u5165\u53E3\u5C55\u793A\u3002`);
6306
+ }
6307
+ if (!hideStepDetail && template && enableRelatedProjectForm && !template.analysis.hasRelatedProjectForm) {
6308
+ errors.push(`${nodeName} \u542F\u7528\u4E86 enable_relate_project_form\uFF0C\u4F46 step_detail_id=${effectiveId} \u4E0D\u5305\u542B\u201C\u5173\u8054\u9879\u76EE\u8868\u5355\u201D\u6A21\u5757\u3002`);
6309
+ suitability = "mismatch";
6310
+ }
6311
+ if (!hideStepDetail && template && hasStepForm && !template.analysis.hasCurrentStepForm) {
6312
+ if (template.analysis.unknownModules.length) {
6313
+ warnings.push(`${nodeName} \u914D\u7F6E\u4E86\u73AF\u8282 form_template\uFF0C\u4F46 step_detail_id=${effectiveId} \u4EC5\u80FD\u901A\u8FC7\u81EA\u5B9A\u4E49\u6A21\u5757\u63A8\u65AD\u586B\u5199\u80FD\u529B\uFF1B\u5FC5\u987B\u8865\u771F\u5B9E\u9875\u9762\u8BC1\u636E\u3002`);
6314
+ suitability = "runtime_proof_required";
6315
+ } else {
6316
+ errors.push(`${nodeName} \u914D\u7F6E\u4E86\u73AF\u8282 form_template\uFF0C\u4F46 step_detail_id=${effectiveId} \u4E0D\u5305\u542B\u201C\u73AF\u8282\u8868\u5355\u201D\u201C\u4EFB\u610F\u73AF\u8282\u8868\u5355\u201D\u6216\u201C\u590D\u6742\u8868\u5355\u201D\u6A21\u5757\u3002`);
6317
+ suitability = "mismatch";
6318
+ }
6319
+ }
6320
+ references.push({
6321
+ path: `data.nodes[${index}].step_detail_id`,
6322
+ node_id: node.id ?? null,
6323
+ node_name: nodeName,
6324
+ configured_value: directConfigured ? node.step_detail_id : null,
6325
+ direct_id: directId,
6326
+ effective_id: effectiveId,
6327
+ source,
6328
+ hide_step_detail: hideStepDetail,
6329
+ form_template: node.form_template ?? null,
6330
+ enable_relate_project_form: enableRelatedProjectForm,
6331
+ status: source === "invalid_node_reference" || source === "invalid_flow_default" ? "invalid" : effectiveId ? template?.structuralOk ? "verified" : "invalid" : "not_configured",
6332
+ suitability,
6333
+ template_name: template?.record.name ?? null,
6334
+ template_type: template?.record.type ?? null,
6335
+ template_structural_ok: template ? template.structuralOk : null,
6336
+ template_errors: template?.analysis.errors ?? [],
6337
+ modules: template?.analysis.moduleNames ?? [],
6338
+ unknown_modules: template?.analysis.unknownModules ?? [],
6339
+ custom_modules: template?.analysis.customModules ?? [],
6340
+ runtime_proof_required: template?.analysis.requiresRuntimeProof ?? false
6341
+ });
6342
+ });
6343
+ return { errors, warnings, references };
6344
+ }
6345
+ function flowStepDetailRuntimeProofRequired(audit) {
6346
+ return Boolean(audit?.references.some((reference) => reference.runtime_proof_required === true));
6347
+ }
6013
6348
  function parseTemplateContent(value, errors) {
6014
6349
  const basic = isRecord3(value.basic) ? value.basic : {};
6015
6350
  const rawContent = value.content ?? basic.content;
@@ -6917,6 +7252,14 @@ function normalizePageTemplatePayload(domain, work) {
6917
7252
  throw new Error(`console-template lint failed: ${errors.join("; ")}`);
6918
7253
  }
6919
7254
  }
7255
+ if (domain === "step-detail-template") {
7256
+ const errors = [];
7257
+ const warnings = [];
7258
+ lintStepDetailTemplateWork(work, errors, warnings);
7259
+ if (errors.length) {
7260
+ throw new Error(`step-detail-template lint failed: ${errors.join("; ")}`);
7261
+ }
7262
+ }
6920
7263
  const basic = isRecord3(work.basic) ? work.basic : work;
6921
7264
  const rawContent = work.content ?? basic.content;
6922
7265
  const type = definition.expectedType;
@@ -7575,6 +7918,21 @@ function normalizeRemovedFields(value) {
7575
7918
  }
7576
7919
  return new Set(value.filter((item) => typeof item === "string" && item.length > 0));
7577
7920
  }
7921
+ function formTemplateValueFieldType(value) {
7922
+ if (typeof value.field_type === "string" && value.field_type) {
7923
+ return value.field_type;
7924
+ }
7925
+ return typeof value.type === "string" ? value.type : "";
7926
+ }
7927
+ function normalizeStructuredFormTemplateValue(value, ruleType) {
7928
+ const fieldType = typeof value.field_type === "string" ? value.field_type : "";
7929
+ const typeAlias = typeof value.type === "string" ? value.type : "";
7930
+ if (fieldType && typeAlias && fieldType !== typeAlias) {
7931
+ throw new Error(`form-template value type aliases conflict: field_type=${fieldType}, type=${typeAlias}.`);
7932
+ }
7933
+ const resolvedType = fieldType || typeAlias || (typeof ruleType === "string" ? ruleType : "");
7934
+ return resolvedType ? { ...value, field_type: resolvedType } : { ...value };
7935
+ }
7578
7936
  function buildStructuredFormTemplatePayload(work) {
7579
7937
  const mode = work.mode;
7580
7938
  if (mode !== "edit" && mode !== "create") {
@@ -7616,12 +7974,13 @@ function buildStructuredFormTemplatePayload(work) {
7616
7974
  if (bundle.rule.field !== ref || bundle.value.field !== ref) {
7617
7975
  throw new Error(`form-template field mismatch for ${ref}.`);
7618
7976
  }
7619
- if (bundle.value.field_type !== bundle.rule.type) {
7977
+ const normalizedValue = normalizeStructuredFormTemplateValue(bundle.value, bundle.rule.type);
7978
+ if (formTemplateValueFieldType(normalizedValue) !== bundle.rule.type) {
7620
7979
  throw new Error(`form-template field_type mismatch for ${ref}.`);
7621
7980
  }
7622
7981
  const rule = mode === "create" ? stripKeys(bundle.rule, FORM_RULE_ID_KEYS) : { ...bundle.rule };
7623
7982
  const value = normalizeFormTemplateValueValidateMap(
7624
- mode === "create" ? stripKeys(bundle.value, FORM_VALUE_ID_KEYS) : { ...bundle.value }
7983
+ mode === "create" ? stripKeys(normalizedValue, FORM_VALUE_ID_KEYS) : normalizedValue
7625
7984
  );
7626
7985
  submitRow.push(rule);
7627
7986
  valueItems.push(value);
@@ -7638,7 +7997,7 @@ function buildStructuredFormTemplatePayload(work) {
7638
7997
  for (const value of preservedValues) {
7639
7998
  const field = typeof value.field === "string" ? value.field : "";
7640
7999
  if (field && !seen.has(field) && !removedFields.has(field)) {
7641
- valueItems.push(normalizeFormTemplateValueValidateMap(value));
8000
+ valueItems.push(normalizeFormTemplateValueValidateMap(normalizeStructuredFormTemplateValue(value)));
7642
8001
  }
7643
8002
  }
7644
8003
  return {
@@ -7733,6 +8092,37 @@ function validateFormTemplateValueValidateMaps(payload, errors) {
7733
8092
  }
7734
8093
  }
7735
8094
  }
8095
+ function validateStructuredFormTemplateFieldTypes(payload, errors) {
8096
+ if (isRecord3(payload.fields)) {
8097
+ for (const [field, bundle] of Object.entries(payload.fields)) {
8098
+ if (!isRecord3(bundle) || !isRecord3(bundle.rule) || !isRecord3(bundle.value)) {
8099
+ continue;
8100
+ }
8101
+ try {
8102
+ const value = normalizeStructuredFormTemplateValue(bundle.value, bundle.rule.type);
8103
+ const valueType = formTemplateValueFieldType(value);
8104
+ if (typeof bundle.rule.type === "string" && valueType !== bundle.rule.type) {
8105
+ errors.push(`form-template field_type mismatch for ${field}.`);
8106
+ }
8107
+ } catch (error) {
8108
+ errors.push(`form-template field ${field}: ${error instanceof Error ? error.message : String(error)}`);
8109
+ }
8110
+ }
8111
+ }
8112
+ if (isRecord3(payload.preserve) && Array.isArray(payload.preserve.value)) {
8113
+ payload.preserve.value.forEach((value, index) => {
8114
+ if (!isRecord3(value)) {
8115
+ return;
8116
+ }
8117
+ try {
8118
+ normalizeStructuredFormTemplateValue(value);
8119
+ } catch (error) {
8120
+ const field = typeof value.field === "string" && value.field ? value.field : `#${index}`;
8121
+ errors.push(`form-template preserved field ${field}: ${error instanceof Error ? error.message : String(error)}`);
8122
+ }
8123
+ });
8124
+ }
8125
+ }
7736
8126
  function formTemplateControlOptions(rule, value) {
7737
8127
  const candidates = [
7738
8128
  rule?.options,
@@ -7789,7 +8179,7 @@ function validateRadioFormTemplateControl(field, rule, value, errors) {
7789
8179
  }
7790
8180
  function validateFormTemplateControlContracts(payload, errors) {
7791
8181
  const validatePair = (field, rule, value) => {
7792
- const type = typeof rule?.type === "string" ? rule.type : typeof value?.field_type === "string" ? value.field_type : "";
8182
+ const type = typeof rule?.type === "string" ? rule.type : value ? formTemplateValueFieldType(value) : "";
7793
8183
  if (type === "serial_number") {
7794
8184
  errors.push(`form-template field ${field} uses legacy serial_number; use BPMAX frontend control type sn_number.`);
7795
8185
  }
@@ -7989,6 +8379,7 @@ function validateStructuredFormTemplateVisualReview(payload, errors) {
7989
8379
  function validateFormTemplateWorkLint(payload, errors) {
7990
8380
  validateFormTemplateNameLength(payload, errors);
7991
8381
  validateFormTemplateValueValidateMaps(payload, errors);
8382
+ validateStructuredFormTemplateFieldTypes(payload, errors);
7992
8383
  validateFormTemplateControlContracts(payload, errors);
7993
8384
  validateFormTemplateHeaderContract(payload, errors);
7994
8385
  validateStructuredFormTemplateVisualReview(payload, errors);
@@ -8027,12 +8418,12 @@ function formTemplateRawToStructured(raw) {
8027
8418
  continue;
8028
8419
  }
8029
8420
  const field = rule.field;
8030
- const value = valueByField.get(field) || {
8421
+ const value = normalizeStructuredFormTemplateValue(valueByField.get(field) || {
8031
8422
  field,
8032
8423
  title: rule.title,
8033
8424
  field_type: rule.type,
8034
8425
  value: { type: rule.type }
8035
- };
8426
+ }, rule.type);
8036
8427
  layoutRow.push(field);
8037
8428
  fields[field] = { rule, value };
8038
8429
  seenFields.add(field);
@@ -8041,7 +8432,7 @@ function formTemplateRawToStructured(raw) {
8041
8432
  layout.push(layoutRow);
8042
8433
  }
8043
8434
  }
8044
- const preservedValues = values.filter((item) => isRecord3(item) && typeof item.field === "string" && item.field && !seenFields.has(item.field));
8435
+ const preservedValues = values.filter((item) => isRecord3(item) && typeof item.field === "string" && item.field && !seenFields.has(item.field)).map((item) => normalizeStructuredFormTemplateValue(item));
8045
8436
  const preserve = pickDefined(raw, [
8046
8437
  "status",
8047
8438
  "meta_form_id",
@@ -9284,6 +9675,10 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
9284
9675
  if (pluginLint?.errors.length) {
9285
9676
  throw new Error(`flow-template plugin lint failed: ${pluginLint.errors.join("; ")}`);
9286
9677
  }
9678
+ const stepDetailReferenceAudit = await auditFlowStepDetailReferences(work, profile);
9679
+ if (stepDetailReferenceAudit.errors.length) {
9680
+ throw new Error(`flow-template step-detail reference gate failed: ${stepDetailReferenceAudit.errors.join("; ")}`);
9681
+ }
9287
9682
  const expectedConfirm = `create flow-template ${createShell.name}`;
9288
9683
  if (confirm3 !== expectedConfirm) {
9289
9684
  return {
@@ -9292,6 +9687,9 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
9292
9687
  create_endpoint: "/flow/flow_type",
9293
9688
  create_payload: createShell,
9294
9689
  draft_endpoint: "/flow?flow_type=<platform-flow-type>&publish=2",
9690
+ step_detail_references: stepDetailReferenceAudit.references,
9691
+ step_detail_warnings: stepDetailReferenceAudit.warnings,
9692
+ runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit),
9295
9693
  ...options.publishLive ? { live_endpoint: "/flow?flow_type=<platform-flow-type>&publish=1" } : {},
9296
9694
  next: `Run again with --confirm "${expectedConfirm}" to create.`
9297
9695
  };
@@ -9350,6 +9748,9 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
9350
9748
  create_response: createResponse,
9351
9749
  draft_endpoint: draftEndpoint,
9352
9750
  draft_response: draftResponse,
9751
+ step_detail_references: stepDetailReferenceAudit.references,
9752
+ step_detail_warnings: stepDetailReferenceAudit.warnings,
9753
+ runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit),
9353
9754
  ...liveEndpoint ? { live_endpoint: liveEndpoint, live_response: liveResponse } : {},
9354
9755
  readback_hash: hashJson(readback)
9355
9756
  };
@@ -9454,6 +9855,9 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
9454
9855
  workspace,
9455
9856
  name,
9456
9857
  preflight,
9858
+ step_detail_references: preflight.step_detail_references,
9859
+ step_detail_warnings: preflight.step_detail_warnings,
9860
+ runtime_proof_required: preflight.runtime_proof_required === true,
9457
9861
  operation_plan: dryRunPlan,
9458
9862
  post_create_checklist: [
9459
9863
  "Save this dry-run response; operation_plan.save_flow_draft.payload_summary must show data.meta.form_template=<published-form-id> before confirm.",
@@ -9617,6 +10021,9 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
9617
10021
  ...liveEndpoint ? { flow_live_response: flowLiveResponse, live_endpoint: liveEndpoint } : {},
9618
10022
  workspace_bind_response: workspaceBindResponse,
9619
10023
  workspace_readback_hash: hashJson(workspaceReadback),
10024
+ step_detail_references: preflight.step_detail_references,
10025
+ step_detail_warnings: preflight.step_detail_warnings,
10026
+ runtime_proof_required: preflight.runtime_proof_required === true,
9620
10027
  evidence
9621
10028
  };
9622
10029
  } catch (error) {
@@ -9666,7 +10073,21 @@ function canonicalFormTemplateValues(value) {
9666
10073
  if (!Array.isArray(value)) {
9667
10074
  return value;
9668
10075
  }
9669
- return [...value].sort((left, right) => {
10076
+ const canonical = value.map((item) => {
10077
+ if (!isRecord3(item)) {
10078
+ return item;
10079
+ }
10080
+ const fieldType = typeof item.field_type === "string" && item.field_type ? item.field_type : typeof item.type === "string" ? item.type : "";
10081
+ if (!fieldType) {
10082
+ return item;
10083
+ }
10084
+ const normalized = { ...item, field_type: fieldType };
10085
+ if (typeof normalized.type === "string" && normalized.type === fieldType) {
10086
+ delete normalized.type;
10087
+ }
10088
+ return normalized;
10089
+ });
10090
+ return canonical.sort((left, right) => {
9670
10091
  const identity = (item) => {
9671
10092
  if (!isRecord3(item)) return `~${JSON.stringify(item)}`;
9672
10093
  for (const key of ["field", "key", "id", "uuid", "guid", "name"]) {
@@ -9924,24 +10345,68 @@ async function verifyConfigDomain(config, profile, domain, id, options = {}) {
9924
10345
  const expected = options.expectFile ? await readJsonFile(options.expectFile) : void 0;
9925
10346
  const actualComparable = expected ? comparableSubmitPayload(domain, actual, options) : void 0;
9926
10347
  const expectedComparable = expected ? comparableSubmitPayload(domain, expected, options) : void 0;
9927
- const ok = expected ? JSON.stringify(actualComparable) === JSON.stringify(expectedComparable) : true;
10348
+ const comparisonOk = expected ? isDeepStrictEqual(actualComparable, expectedComparable) : true;
10349
+ const structuralErrors = [];
10350
+ const semanticErrors = [];
10351
+ const verificationWarnings = [];
10352
+ let stepDetailAnalysis;
10353
+ let stepDetailReferenceAudit;
10354
+ if (domain === "step-detail-template" && isRecord3(actual)) {
10355
+ stepDetailAnalysis = analyzeStepDetailTemplate(actual, { allowUndeclaredCustomModules: true });
10356
+ structuralErrors.push(...stepDetailAnalysis.errors);
10357
+ verificationWarnings.push(...stepDetailAnalysis.warnings);
10358
+ if (isRecord3(expected)) {
10359
+ const expectedAnalysis = analyzeStepDetailTemplate(expected);
10360
+ structuralErrors.push(...expectedAnalysis.errors.map((message) => `expect: ${message}`));
10361
+ verificationWarnings.push(...expectedAnalysis.warnings.map((message) => `expect: ${message}`));
10362
+ }
10363
+ }
10364
+ if (domain === "flow-template" && isRecord3(actual)) {
10365
+ stepDetailReferenceAudit = await auditFlowStepDetailReferences(actual, profile);
10366
+ semanticErrors.push(...stepDetailReferenceAudit.errors);
10367
+ verificationWarnings.push(...stepDetailReferenceAudit.warnings);
10368
+ }
10369
+ const ok = comparisonOk && structuralErrors.length === 0 && semanticErrors.length === 0;
10370
+ const runtimeProofRequired = Boolean(
10371
+ stepDetailAnalysis?.requiresRuntimeProof || stepDetailReferenceAudit?.references.some((reference) => reference.runtime_proof_required === true)
10372
+ );
9928
10373
  const diff = expected ? diffJsonComparable(domain, expected, actual, (value) => comparableSubmitPayload(domain, value, options)) : void 0;
9929
10374
  const rawDiff = expected && domain === "form-template" && options.ignoreServerFields ? diffJsonComparable(domain, expected, actual, (value) => buildDomainSubmitPayload(domain, value)) : void 0;
9930
10375
  const comparisonSkippedReason = expected ? null : "no --expect file provided; verify performed readback only";
9931
- const serverDefaultDrift = Boolean(ok && rawDiff?.changed === true);
9932
- const mismatchCount = diffMismatchCount(diff);
9933
- const reasons = verifyFailureReasons(ok, diff, comparisonSkippedReason);
10376
+ const serverDefaultDrift = Boolean(comparisonOk && rawDiff?.changed === true);
10377
+ const mismatchCount = diffMismatchCount(diff) + structuralErrors.length + semanticErrors.length;
10378
+ const reasons = [
10379
+ ...structuralErrors,
10380
+ ...semanticErrors,
10381
+ ...!comparisonOk ? verifyFailureReasons(false, diff, comparisonSkippedReason) : []
10382
+ ];
9934
10383
  return {
9935
10384
  domain,
9936
10385
  id,
9937
10386
  ok,
9938
- structural_ok: true,
9939
- semantic_ok: ok,
10387
+ structural_ok: structuralErrors.length === 0,
10388
+ semantic_ok: comparisonOk && semanticErrors.length === 0,
10389
+ structural_errors: structuralErrors,
10390
+ semantic_errors: semanticErrors,
10391
+ warnings: verificationWarnings,
10392
+ runtime_proof_required: runtimeProofRequired,
9940
10393
  server_default_drift: serverDefaultDrift,
9941
10394
  comparison_skipped_reason: comparisonSkippedReason,
9942
10395
  mismatch_count: mismatchCount,
9943
10396
  ...!ok ? { reason: reasons[0], reasons } : {},
9944
10397
  compare: expected ? "normalized_submit_payload" : "readback_only",
10398
+ ...stepDetailAnalysis ? {
10399
+ step_detail_template: {
10400
+ modules: stepDetailAnalysis.moduleNames,
10401
+ unknown_modules: stepDetailAnalysis.unknownModules,
10402
+ custom_modules: stepDetailAnalysis.customModules,
10403
+ has_main_column: stepDetailAnalysis.hasMainColumn,
10404
+ has_current_step_form: stepDetailAnalysis.hasCurrentStepForm,
10405
+ has_related_project_form: stepDetailAnalysis.hasRelatedProjectForm,
10406
+ runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
10407
+ }
10408
+ } : {},
10409
+ ...stepDetailReferenceAudit ? { step_detail_references: stepDetailReferenceAudit.references } : {},
9945
10410
  ...expected ? {
9946
10411
  expected_hash: expectedComparable ? hashJson(expectedComparable) : null,
9947
10412
  actual_hash: actualComparable ? hashJson(actualComparable) : null,
@@ -10259,11 +10724,19 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
10259
10724
  throw new Error("Config build requires a meta file produced by `bpmax-cli config <domain> export`.");
10260
10725
  }
10261
10726
  const raw = typeof meta.raw_file === "string" ? await readJsonFile(meta.raw_file) : void 0;
10727
+ let stepDetailReferenceAudit;
10728
+ let stepDetailAnalysis;
10262
10729
  if (domain === "flow-template" && isRecord3(work)) {
10263
10730
  const pluginLint = await runFlowTemplatePluginLint(work, options.pluginLint);
10264
10731
  if (pluginLint?.errors.length) {
10265
10732
  throw new Error(`flow-template plugin lint failed: ${pluginLint.errors.join("; ")}`);
10266
10733
  }
10734
+ if (options.pluginLint?.profile) {
10735
+ stepDetailReferenceAudit = await auditFlowStepDetailReferences(work, options.pluginLint.profile);
10736
+ if (stepDetailReferenceAudit.errors.length) {
10737
+ throw new Error(`flow-template step-detail reference gate failed: ${stepDetailReferenceAudit.errors.join("; ")}`);
10738
+ }
10739
+ }
10267
10740
  }
10268
10741
  if (domain === "form-template" && isRecord3(work)) {
10269
10742
  const errors = [];
@@ -10280,6 +10753,14 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
10280
10753
  throw new Error(`console-template lint failed: ${errors.join("; ")}`);
10281
10754
  }
10282
10755
  }
10756
+ if (domain === "step-detail-template" && isRecord3(work)) {
10757
+ const errors = [];
10758
+ const warnings = [];
10759
+ stepDetailAnalysis = lintStepDetailTemplateWork(work, errors, warnings);
10760
+ if (errors.length) {
10761
+ throw new Error(`step-detail-template lint failed: ${errors.join("; ")}`);
10762
+ }
10763
+ }
10283
10764
  const payloadWork = domain === "dataset-field" && createMode && isRecord3(work) ? { ...work, mode: "create" } : work;
10284
10765
  const payload = buildDomainSubmitPayload(domain, payloadWork, options, raw);
10285
10766
  if (domain === "flow-template" && options.publishLive) {
@@ -10298,10 +10779,36 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
10298
10779
  built_at: (/* @__PURE__ */ new Date()).toISOString(),
10299
10780
  meta: submitMeta,
10300
10781
  base_hash: createMode ? null : typeof meta.base_hash === "string" ? meta.base_hash : null,
10301
- payload
10782
+ payload,
10783
+ ...stepDetailReferenceAudit ? {
10784
+ step_detail_references: stepDetailReferenceAudit.references,
10785
+ step_detail_warnings: stepDetailReferenceAudit.warnings,
10786
+ runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
10787
+ } : {},
10788
+ ...stepDetailAnalysis ? {
10789
+ step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
10790
+ step_detail_lint: stepDetailLintArtifact(work),
10791
+ step_detail_warnings: stepDetailAnalysis.warnings,
10792
+ runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
10793
+ } : {}
10302
10794
  };
10303
10795
  await writeJsonFile(outFile, result);
10304
- return { domain, work_file: workFile, submit_file: outFile, payload_keys: Object.keys(payload) };
10796
+ return {
10797
+ domain,
10798
+ work_file: workFile,
10799
+ submit_file: outFile,
10800
+ payload_keys: Object.keys(payload),
10801
+ ...stepDetailReferenceAudit ? {
10802
+ step_detail_references: stepDetailReferenceAudit.references,
10803
+ warnings: stepDetailReferenceAudit.warnings,
10804
+ runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
10805
+ } : {},
10806
+ ...stepDetailAnalysis ? {
10807
+ step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
10808
+ warnings: stepDetailAnalysis.warnings,
10809
+ runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
10810
+ } : {}
10811
+ };
10305
10812
  }
10306
10813
  async function runFlowTemplatePluginLint(flowWork, options = {}) {
10307
10814
  if (!options.profile) {
@@ -10398,6 +10905,8 @@ async function lintConfigWorkFile(file, options = {}) {
10398
10905
  const errors = [];
10399
10906
  const warnings = [];
10400
10907
  let pluginLint;
10908
+ let stepDetailAnalysis;
10909
+ let stepDetailReferenceAudit;
10401
10910
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
10402
10911
  errors.push("Config work file must be a JSON object.");
10403
10912
  } else {
@@ -10418,6 +10927,9 @@ async function lintConfigWorkFile(file, options = {}) {
10418
10927
  if (shouldLintFormTemplate) {
10419
10928
  validateFormTemplateWorkLint(value, errors);
10420
10929
  }
10930
+ if (options.domain === "step-detail-template") {
10931
+ stepDetailAnalysis = lintStepDetailTemplateWork(value, errors, warnings);
10932
+ }
10421
10933
  if ((Object.prototype.hasOwnProperty.call(value, "content") || isRecord3(value.basic)) && pageTemplateType(value) === 1) {
10422
10934
  validateListTemplateActionGate(value, errors);
10423
10935
  }
@@ -10444,6 +10956,12 @@ async function lintConfigWorkFile(file, options = {}) {
10444
10956
  errors.push(...pluginLint.errors);
10445
10957
  warnings.push(...pluginLint.warnings);
10446
10958
  }
10959
+ const profile = options.pluginLint?.profile;
10960
+ if (profile) {
10961
+ stepDetailReferenceAudit = await auditFlowStepDetailReferences(flowWork, profile);
10962
+ errors.push(...stepDetailReferenceAudit.errors.filter((error) => !errors.includes(error)));
10963
+ warnings.push(...stepDetailReferenceAudit.warnings);
10964
+ }
10447
10965
  if (flowWork.mode === "create") {
10448
10966
  validateFlowTemplateFormDrivenCreateBaseline(flowWork, errors, { context: "flow-template create" });
10449
10967
  } else {
@@ -10456,6 +10974,21 @@ async function lintConfigWorkFile(file, options = {}) {
10456
10974
  ok: errors.length === 0,
10457
10975
  errors,
10458
10976
  warnings,
10977
+ ...stepDetailAnalysis ? {
10978
+ step_detail_template: {
10979
+ modules: stepDetailAnalysis.moduleNames,
10980
+ unknown_modules: stepDetailAnalysis.unknownModules,
10981
+ custom_modules: stepDetailAnalysis.customModules,
10982
+ has_main_column: stepDetailAnalysis.hasMainColumn,
10983
+ has_current_step_form: stepDetailAnalysis.hasCurrentStepForm,
10984
+ has_related_project_form: stepDetailAnalysis.hasRelatedProjectForm,
10985
+ runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
10986
+ }
10987
+ } : {},
10988
+ ...stepDetailReferenceAudit ? {
10989
+ step_detail_references: stepDetailReferenceAudit.references,
10990
+ runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
10991
+ } : {},
10459
10992
  ...pluginLint ? { plugin_lints: pluginLint.plugin_lints } : {},
10460
10993
  checked_at: (/* @__PURE__ */ new Date()).toISOString()
10461
10994
  };
@@ -10735,6 +11268,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
10735
11268
  if (meta.workspace !== profile.config.workspace) {
10736
11269
  throw new Error(`Config submit metadata workspace mismatch. Expected ${profile.config.workspace}, got ${String(meta.workspace)}.`);
10737
11270
  }
11271
+ let stepDetailAnalysis;
10738
11272
  const submitMode = isRecord3(meta) ? meta.mode : void 0;
10739
11273
  if (submitMode === "create" && domain !== "form-template") {
10740
11274
  if (!definition.createPath || !definition.createMethod) {
@@ -10754,6 +11288,12 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
10754
11288
  throw new Error(`console-template lint failed: ${errors.join("; ")}`);
10755
11289
  }
10756
11290
  }
11291
+ if (domain === "step-detail-template") {
11292
+ stepDetailAnalysis = analyzeStepDetailTemplate(stepDetailPayloadWithLintArtifact(submit.payload, submit));
11293
+ if (stepDetailAnalysis.errors.length) {
11294
+ throw new Error(`step-detail-template lint failed: ${stepDetailAnalysis.errors.join("; ")}`);
11295
+ }
11296
+ }
10757
11297
  if (domain === "dataset-field") {
10758
11298
  validateDatasetFieldCreatePayload(submit.payload);
10759
11299
  }
@@ -10770,6 +11310,11 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
10770
11310
  endpoint: definition.createPath,
10771
11311
  method: definition.createMethod,
10772
11312
  payload: submit.payload,
11313
+ ...stepDetailAnalysis ? {
11314
+ step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
11315
+ warnings: stepDetailAnalysis.warnings,
11316
+ runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
11317
+ } : {},
10773
11318
  next: `Run again with --confirm "${expectedConfirm2}" to submit.`
10774
11319
  };
10775
11320
  }
@@ -10843,6 +11388,11 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
10843
11388
  method: definition.createMethod,
10844
11389
  response: response2,
10845
11390
  readback_hash: readbackHash,
11391
+ ...stepDetailAnalysis ? {
11392
+ step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
11393
+ warnings: stepDetailAnalysis.warnings,
11394
+ runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
11395
+ } : {},
10846
11396
  ...readbackMismatches.length ? { readback_mismatches: readbackMismatches.slice(0, 10) } : {},
10847
11397
  ...readbackError ? { readback_error: readbackError } : {},
10848
11398
  ...finalizeAttempted ? {
@@ -10855,6 +11405,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
10855
11405
  }
10856
11406
  await ensureConfigCapability(profile, `${definition.capability}.submit`);
10857
11407
  await ensureConfigCapability(profile, `${definition.capability}.export`);
11408
+ let stepDetailReferenceAudit;
10858
11409
  if (domain === "flow-template") {
10859
11410
  validateFlowTemplateRemoteTemplateRefs(submit.payload);
10860
11411
  validateFlowTemplateProjectAfterCreatePath(submit.payload);
@@ -10876,6 +11427,10 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
10876
11427
  if (pluginLint?.errors.length) {
10877
11428
  throw new Error(`flow-template plugin lint failed: ${pluginLint.errors.join("; ")}`);
10878
11429
  }
11430
+ stepDetailReferenceAudit = await auditFlowStepDetailReferences(submit.payload, profile);
11431
+ if (stepDetailReferenceAudit.errors.length) {
11432
+ throw new Error(`flow-template step-detail reference gate failed: ${stepDetailReferenceAudit.errors.join("; ")}`);
11433
+ }
10879
11434
  }
10880
11435
  if (domain === "list-template") {
10881
11436
  validateListTemplateActionGate(submit.payload);
@@ -10888,6 +11443,12 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
10888
11443
  throw new Error(`console-template lint failed: ${errors.join("; ")}`);
10889
11444
  }
10890
11445
  }
11446
+ if (domain === "step-detail-template") {
11447
+ stepDetailAnalysis = analyzeStepDetailTemplate(stepDetailPayloadWithLintArtifact(submit.payload, submit));
11448
+ if (stepDetailAnalysis.errors.length) {
11449
+ throw new Error(`step-detail-template lint failed: ${stepDetailAnalysis.errors.join("; ")}`);
11450
+ }
11451
+ }
10891
11452
  if (domain === "form-template" && submitMode === "create") {
10892
11453
  validateNonEmptyFormCreatePayload(submit.payload);
10893
11454
  await ensureConfigCapability(profile, `${definition.capability}.create`);
@@ -11011,6 +11572,16 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
11011
11572
  method: definition.submitMethod,
11012
11573
  payload: submitPayload,
11013
11574
  ...publishMode ? { publish_mode: publishMode } : {},
11575
+ ...stepDetailReferenceAudit ? {
11576
+ step_detail_references: stepDetailReferenceAudit.references,
11577
+ step_detail_warnings: stepDetailReferenceAudit.warnings,
11578
+ runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
11579
+ } : {},
11580
+ ...stepDetailAnalysis ? {
11581
+ step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
11582
+ warnings: stepDetailAnalysis.warnings,
11583
+ runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
11584
+ } : {},
11014
11585
  diff: mutationDiff,
11015
11586
  current_hash: currentHash,
11016
11587
  next: `Run again with --confirm "${expectedConfirm}" to submit.`
@@ -11076,6 +11647,16 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
11076
11647
  endpoint,
11077
11648
  method: definition.submitMethod,
11078
11649
  ...publishMode ? { publish_mode: publishMode } : {},
11650
+ ...stepDetailReferenceAudit ? {
11651
+ step_detail_references: stepDetailReferenceAudit.references,
11652
+ step_detail_warnings: stepDetailReferenceAudit.warnings,
11653
+ runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
11654
+ } : {},
11655
+ ...stepDetailAnalysis ? {
11656
+ step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
11657
+ warnings: stepDetailAnalysis.warnings,
11658
+ runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
11659
+ } : {},
11079
11660
  response,
11080
11661
  publish_response: publishResponse,
11081
11662
  readback_hash: readback.readback_hash
@@ -20515,7 +21096,7 @@ var CONFIG_TASK_RULES = [
20515
21096
  writeEvidence: [/bpmax-cli config flow-template lint/, /bpmax-cli config flow-template build/, /bpmax-cli config flow-template submit/, /bpmax-cli config flow-template verify/],
20516
21097
  readonlyEvidence: [/bpmax-cli config flow-template export|流程.*回读|readback/i],
20517
21098
  constraintEvidence: /project_after_create_path|message_template|return ""|matrix_owner|cc_matrix|流程模板约束|flow-template lint/i,
20518
- mentionPattern: /流程模板|flow-template|flow_template|流程配置|创建流程|编辑流程/
21099
+ mentionPattern: /流程模板|flow-template|flow_template|流程配置|创建流程|编辑流程|step_detail_id/
20519
21100
  },
20520
21101
  {
20521
21102
  domain: "form-template",
@@ -20551,7 +21132,16 @@ var CONFIG_TASK_RULES = [
20551
21132
  writeEvidence: [/bpmax-cli config project-detail-template lint/, /bpmax-cli config project-detail-template build/, /bpmax-cli config project-detail-template submit/, /bpmax-cli config project-detail-template verify/],
20552
21133
  readonlyEvidence: [/bpmax-cli config project-detail-template export|详情.*回读|resolve-default|readback/i],
20553
21134
  constraintEvidence: /默认详情模板|resolve-default|详情页|project_detail|project-detail-template lint/i,
20554
- mentionPattern: /详情模板|项目详情|project-detail-template|project_detail/
21135
+ mentionPattern: /项目详情模板|项目详情页|project-detail-template|project_detail/
21136
+ },
21137
+ {
21138
+ domain: "step-detail-template",
21139
+ skill: "bpmax-flow-template-editor",
21140
+ lockPattern: /step-detail-template:(?:\d+|new-[A-Za-z0-9_-]+)/,
21141
+ writeEvidence: [/bpmax-cli config step-detail-template lint/, /bpmax-cli config step-detail-template build/, /bpmax-cli config step-detail-template submit/, /bpmax-cli config step-detail-template verify/],
21142
+ readonlyEvidence: [/bpmax-cli config step-detail-template export|环节详情.*回读|step_detail_id|readback/i],
21143
+ constraintEvidence: /type=6|content\.layout|step_detail_id|自定义模块|step-detail-template lint/i,
21144
+ mentionPattern: /(?:(?<!不)(?<!不得)(?<!禁止)(?:创建|编辑|修改|新增|删除|配置|优化|调整|调研|检查|回读)[^。\n]{0,16}(?:环节详情模板|环节处理模板)|(?:环节详情模板|环节处理模板)[^。\n]{0,16}(?<!不)(?<!不得)(?<!禁止)(?:创建|编辑|修改|新增|删除|配置|优化|调整|调研|检查|回读)|step-detail-template)/
20555
21145
  },
20556
21146
  {
20557
21147
  domain: "console-template",
@@ -20635,6 +21225,9 @@ var CONFIG_TASK_RULES = [
20635
21225
  mentionPattern: /E2E|端到端|浏览器测试|测试用例|回归测试/
20636
21226
  }
20637
21227
  ];
21228
+ function skillOwnsMultipleConfigDomains(skill) {
21229
+ return CONFIG_TASK_RULES.filter((rule) => rule.skill === skill).length > 1;
21230
+ }
20638
21231
  function isWriteMode(rowOrText) {
20639
21232
  const mode = typeof rowOrText === "string" ? rowOrText.match(/subagent_mode\s*[::]\s*([^\n]+)/)?.[1] || "" : rowOrText.subagent_mode || "";
20640
21233
  return !/\breadonly\b/i.test(mode);
@@ -20859,6 +21452,9 @@ function validateConfigRuleForTaskRow(row, rule, issues) {
20859
21452
  if (!hasSkill) {
20860
21453
  return;
20861
21454
  }
21455
+ if (!mentionsDomain && skillOwnsMultipleConfigDomains(rule.skill)) {
21456
+ return;
21457
+ }
20862
21458
  const writeMode = isWriteMode(row);
20863
21459
  if (writeMode && !rule.lockPattern.test(row.object_lock || "")) {
20864
21460
  addTaskbookIssue(
@@ -20999,6 +21595,9 @@ function validatePromptConfigSkillGates(text5, issues) {
20999
21595
  if (!hasSkill) {
21000
21596
  continue;
21001
21597
  }
21598
+ if (!mentionsDomain && skillOwnsMultipleConfigDomains(rule.skill)) {
21599
+ continue;
21600
+ }
21002
21601
  if (writeMode && !rule.lockPattern.test(objectLock)) {
21003
21602
  addTaskbookIssue(
21004
21603
  issues,
@@ -21172,6 +21771,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
21172
21771
  "| \u6D41\u7A0B\u6A21\u677F | bpmax-flow-template-editor | bpmax-cli config flow-template export/lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | project_after_create_path\u3001message_template\u3001matrix_owner\u3001\u6D41\u7A0B\u6A21\u677F\u7EA6\u675F |",
21173
21772
  "| \u8868\u5355\u6A21\u677F | bpmax-form-template-editor | bpmax-cli config form-template export/lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | \u5B57\u6BB5 schema\u3001\u8868\u5355\u987A\u5E8F\u3001raw.value\u3001layout\u3001sub_form\u3001form-template inspect |",
21174
21773
  "| \u5217\u8868\u6A21\u677F | bpmax-list-template-editor | bpmax-cli config list-template lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | \u64CD\u4F5C\u5217\u3001\u8BE6\u60C5\u52A8\u4F5C\u3001\u5220\u9664\u6743\u9650 guard\uFF08\u9996\u9009 ctx.$CAN_DELETE\uFF0C\u7981\u6B62\u5F53\u524D\u73AF\u8282\u4E3A\u7A7A\u6761\u4EF6\uFF09\u3001icon\u3001\u67E5\u8BE2\u5B89\u5168\u3001\u771F\u5B9E\u5217\u8868\u9875 |",
21774
+ "| \u73AF\u8282\u8BE6\u60C5\u6A21\u677F | bpmax-flow-template-editor | bpmax-cli config step-detail-template export/lint/build/submit/verify\uFF1B\u6D41\u7A0B\u7ED1\u5B9A\u8FD8\u9700 flow-template verify | type=6\u3001content.layout\u3001\u6A21\u5757\u58F0\u660E\u3001step_detail_id \u8FDC\u7AEF\u5B58\u5728\u6027\u4E0E\u8282\u70B9\u9002\u914D |",
21175
21775
  "| \u5BFC\u822A\u914D\u7F6E | bpmax-nav-config-editor | bpmax-cli config nav-config lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | PC/H5 \u5BFC\u822A\u3001\u5FEB\u6377\u5165\u53E3\u3001\u6D4F\u89C8\u5668\u6253\u5F00\u9A8C\u8BC1 |",
21176
21776
  "",
21177
21777
  "## AI \u6700\u5C0F\u4EFB\u52A1\u5355\u5143",