bpmax-cli 0.2.1-beta.71 → 0.2.1-beta.72

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
@@ -501,7 +501,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
501
501
  // package.json
502
502
  var package_default = {
503
503
  name: "bpmax-cli",
504
- version: "0.2.1-beta.71",
504
+ version: "0.2.1-beta.72",
505
505
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
506
506
  type: "module",
507
507
  bin: {
@@ -4979,6 +4979,55 @@ function validateListTemplateRuntimeSmoke(value) {
4979
4979
  if (errors.length) throw new Error(`[list_template_runtime_smoke_failed] ${errors.join("; ")}`);
4980
4980
  return { ok: true, scenario_count: value.scenarios.length, scenarios: value.scenarios };
4981
4981
  }
4982
+ function validateListTemplateRuntimeCheck(value) {
4983
+ if (!isRecord4(value) || value.schema_version !== 1 || !Array.isArray(value.template_fields) && !Array.isArray(value.field_contracts)) {
4984
+ throw new Error("[list_template_runtime_check_invalid] Expected schema_version=1 with template_fields or field_contracts.");
4985
+ }
4986
+ const datasetFields = new Set(Array.isArray(value.dataset_fields) ? value.dataset_fields.map(String) : []);
4987
+ const row = isRecord4(value.list_row) ? value.list_row : {};
4988
+ const detail = isRecord4(value.detail_values) ? value.detail_values : {};
4989
+ const index = isRecord4(value.index_document) ? value.index_document : {};
4990
+ const actualIconTokens = isRecord4(value.icon_tokens) ? value.icon_tokens : {};
4991
+ const strictContracts = Array.isArray(value.field_contracts);
4992
+ const contracts = strictContracts ? value.field_contracts : value.template_fields;
4993
+ const diagnostics = contracts.map((item) => {
4994
+ const contract = isRecord4(item) ? item : { field: String(item) };
4995
+ const field = String(contract.field ?? "");
4996
+ const sourceField = String(contract.source_dataset_field ?? field);
4997
+ const contractMissing = strictContracts ? ["required_nonempty", "allowed_empty_reason", "source_dataset_field", "detail_consistency", "runtime_evidence", "icon_token"].filter((key) => !(key in contract)) : [];
4998
+ const inDataset = datasetFields.has(sourceField);
4999
+ const rowValue = row[field];
5000
+ const detailValue = detail[sourceField];
5001
+ const indexValue = index[sourceField];
5002
+ const sourceEmpty = rowValue === void 0 || rowValue === null || rowValue === "";
5003
+ const mappingMissing = !inDataset;
5004
+ const indexStale = !sourceEmpty && (indexValue === void 0 || JSON.stringify(indexValue) !== JSON.stringify(rowValue));
5005
+ const templateUnresolved = !sourceEmpty && contract.detail_consistency === true && (detailValue === void 0 || JSON.stringify(detailValue) !== JSON.stringify(rowValue));
5006
+ const requiredNonempty = contract.required_nonempty === true;
5007
+ const allowedEmptyReason = typeof contract.allowed_empty_reason === "string" && Boolean(contract.allowed_empty_reason.trim());
5008
+ const contractPolicyInvalid = strictContracts && (typeof contract.required_nonempty !== "boolean" || typeof contract.source_dataset_field !== "string" || !contract.source_dataset_field.trim() || typeof contract.detail_consistency !== "boolean" || contract.required_nonempty === false && !allowedEmptyReason);
5009
+ const runtimeEvidenceMissing = strictContracts && (contract.runtime_evidence === null || contract.runtime_evidence === void 0 || contract.runtime_evidence === "" || isRecord4(contract.runtime_evidence) && Object.keys(contract.runtime_evidence).length === 0);
5010
+ const expectedIconToken = contract.icon_token;
5011
+ const actualIconToken = actualIconTokens[field];
5012
+ const iconTokenMismatch = expectedIconToken !== null && expectedIconToken !== void 0 && JSON.stringify(expectedIconToken) !== JSON.stringify(actualIconToken);
5013
+ const status = contractMissing.length || contractPolicyInvalid || runtimeEvidenceMissing ? "contract_invalid" : mappingMissing ? "mapping_missing" : sourceEmpty && requiredNonempty ? "source_empty" : indexStale ? "index_stale" : templateUnresolved ? "template_unresolved" : iconTokenMismatch ? "icon_token_mismatch" : "ok";
5014
+ return {
5015
+ field,
5016
+ source_dataset_field: sourceField,
5017
+ source_empty: sourceEmpty,
5018
+ mapping_missing: mappingMissing,
5019
+ index_stale: indexStale,
5020
+ template_unresolved: templateUnresolved,
5021
+ icon_token_mismatch: iconTokenMismatch,
5022
+ contract_missing: contractMissing,
5023
+ contract_policy_invalid: contractPolicyInvalid,
5024
+ runtime_evidence_missing: runtimeEvidenceMissing,
5025
+ status
5026
+ };
5027
+ });
5028
+ const errors = diagnostics.filter((item) => item.status !== "ok");
5029
+ return { ok: errors.length === 0, schema_version: 1, diagnostics, error_count: errors.length };
5030
+ }
4982
5031
  function missingCoverage(scenarios, field, required) {
4983
5032
  const actual = new Set(scenarios.map((item) => String(item[field] ?? "")));
4984
5033
  return required.filter((item) => !actual.has(item));
@@ -7794,6 +7843,7 @@ var STEP_DETAIL_CORE_MODULE_NAMES = /* @__PURE__ */ new Set([
7794
7843
  "\u5173\u8054\u9879\u76EE\u8868\u5355",
7795
7844
  "\u9644\u4EF6[\u4FA7\u8FB9\u680F]"
7796
7845
  ]);
7846
+ var STEP_DETAIL_REQUIRED_LAYOUT_FIELDS = ["i", "w", "h", "moved", "_h"];
7797
7847
  function stepDetailLintCustomModules(value) {
7798
7848
  const lint = isRecord5(value.bpmax_lint) ? value.bpmax_lint : {};
7799
7849
  const modules = Array.isArray(lint.step_detail_custom_modules) ? lint.step_detail_custom_modules : [];
@@ -7878,6 +7928,22 @@ function analyzeStepDetailTemplate(value, options = {}) {
7878
7928
  }
7879
7929
  const x = item.x;
7880
7930
  const y = item.y;
7931
+ for (const field of STEP_DETAIL_REQUIRED_LAYOUT_FIELDS) {
7932
+ if (!(field in item)) {
7933
+ errors.push(`${itemPath}.${field} is required by the step-detail editor grid layout.`);
7934
+ }
7935
+ }
7936
+ if ("i" in item && (typeof item.i !== "string" || !item.i.trim())) {
7937
+ errors.push(`${itemPath}.i must be a non-empty string grid item id.`);
7938
+ }
7939
+ for (const field of ["w", "h", "_h"]) {
7940
+ if (field in item && (typeof item[field] !== "number" || !Number.isInteger(item[field]) || item[field] <= 0)) {
7941
+ errors.push(`${itemPath}.${field} must be a positive integer.`);
7942
+ }
7943
+ }
7944
+ if ("moved" in item && typeof item.moved !== "boolean") {
7945
+ errors.push(`${itemPath}.moved must be boolean.`);
7946
+ }
7881
7947
  if (x !== 0 && x !== 1) {
7882
7948
  errors.push(`${itemPath}.x \u53EA\u80FD\u4E3A 0\uFF08\u4E3B\u680F\uFF09\u6216 1\uFF08\u4FA7\u680F\uFF09\u3002`);
7883
7949
  } else if (x === 0) {
@@ -8439,6 +8505,25 @@ function lintListTemplateRuntimeStateConflicts(content, errors) {
8439
8505
  }
8440
8506
  });
8441
8507
  }
8508
+ function lintListTemplateDatasetFieldReferences(value, content, errors) {
8509
+ const lint = isRecord5(value.bpmax_lint) ? value.bpmax_lint : {};
8510
+ const declared = Array.isArray(lint.dataset_fields) ? lint.dataset_fields.flatMap((item) => {
8511
+ if (typeof item === "string") return [item.trim()];
8512
+ if (!isRecord5(item)) return [];
8513
+ return [item.key, item.field, item.name].filter((field) => typeof field === "string" && Boolean(field.trim()));
8514
+ }) : [];
8515
+ if (!declared.length) return;
8516
+ const allowed = /* @__PURE__ */ new Set([...declared, "id", "_id", "__id", "status", "created_at", "updated_at", "userInfo", "project"]);
8517
+ const refs = /* @__PURE__ */ new Set();
8518
+ for (const text5 of collectTextAtKeys(content, /* @__PURE__ */ new Set(["$template", "createElement", "onClick", "onChange", "render", "title", "label"]))) {
8519
+ for (const match of text5.matchAll(/\bctx\.([A-Za-z_$][\w$]*)/g)) refs.add(match[1]);
8520
+ }
8521
+ for (const field of refs) {
8522
+ if (!allowed.has(field) && !field.startsWith("$")) {
8523
+ errors.push(`[list_template.dataset_field.unmapped] ctx.${field} is not declared in bpmax_lint.dataset_fields or a supported system field.`);
8524
+ }
8525
+ }
8526
+ }
8442
8527
  var CONSOLE_TEMPLATE_SUPPORTED_DATA_SOURCE_DRIVERS = /* @__PURE__ */ new Set(["es", "mysql", "customer", "custom_bpmax", "service"]);
8443
8528
  var CONSOLE_TEMPLATE_OVERVIEW_SUPPORTED_ICONS = /* @__PURE__ */ new Set(["total", "finished", "delay_warning", "delay"]);
8444
8529
  function consoleTemplateModuleLabel(module, index) {
@@ -9684,6 +9769,7 @@ function validateListTemplateActionGate(value, errors, warnings) {
9684
9769
  return;
9685
9770
  }
9686
9771
  lintListTemplateQuerySafety(content, nextErrors);
9772
+ lintListTemplateDatasetFieldReferences(value, content, nextErrors);
9687
9773
  lintListTemplateNullableDomCoercion(content, nextErrors);
9688
9774
  lintListTemplateRuntimeStateConflicts(content, nextErrors);
9689
9775
  if (warnings) lintListTemplateRowRendererSideEffects(columns, warnings);
@@ -20127,6 +20213,11 @@ function registerConfigCommands(program2) {
20127
20213
  domainCommand.command("smoke").description("Validate list runtime row counts, permission buttons, column samples, and loading/table/empty states").requiredOption("--evidence <file>", "Runtime smoke evidence JSON").option("--format <format>", "Output format", "json").action(async (options) => {
20128
20214
  printResult(options.format, validateListTemplateRuntimeSmoke(await readJsonFile(options.evidence)));
20129
20215
  });
20216
+ domainCommand.command("runtime-check").description("Compare list row, dataset/index document, and detail values field by field").requiredOption("--evidence <file>", "Runtime check evidence JSON").option("--profile <profile>", "Profile name for workspace binding").option("--format <format>", "Output format", "json").action(async (options) => {
20217
+ const result = validateListTemplateRuntimeCheck(await readJsonFile(options.evidence));
20218
+ printResult(options.format, result);
20219
+ if (!result.ok) throw new Error("list-template runtime check found unresolved fields.");
20220
+ });
20130
20221
  }
20131
20222
  if (domain === "form-template") {
20132
20223
  domainCommand.command("restore-baseline").description("Restore an unreadable draft from an exact verified export baseline; dry-run unless --confirm is exact").requiredOption("--id <id>", "Remote draft form-template id").requiredOption("--raw <file>", "Raw JSON artifact produced by form-template export").requiredOption("--meta <file>", "Meta JSON artifact produced by the same export").option("--profile <profile>", "Profile name").option("--confirm <text>", "Exact confirmation text including the full baseline hash").option("--response-out <file>", "Write the full JSON response to a file").option("--format <format>", "Output format", "pretty").action(async (options) => {
@@ -37686,15 +37777,23 @@ function resolveGitLabToken(options) {
37686
37777
  env.GITLAB_TOKEN,
37687
37778
  env.GL_TOKEN,
37688
37779
  env.PRIVATE_TOKEN,
37780
+ // important: 不要删除这个 token
37689
37781
  "-1pFevGtvjq4fXSxzZJQ"
37690
37782
  ];
37691
37783
  const token = candidates.find((candidate) => candidate?.trim());
37692
37784
  return token?.trim() || void 0;
37693
37785
  }
37694
37786
  function gitLabIssueAuthError(status, tokenConfigured) {
37695
- return new Error(
37787
+ const error = new Error(
37696
37788
  `GitLab issue submission failed with HTTP ${status}. ` + (tokenConfigured ? "The configured GitLab token was rejected. Replace GITLAB_TOKEN, GL_TOKEN, PRIVATE_TOKEN, or --token-env, then retry." : "No GitLab token was configured. Set GITLAB_TOKEN, GL_TOKEN, PRIVATE_TOKEN, or --token-env, then retry.") + " Browser login is not used for issue submission."
37697
37789
  );
37790
+ Object.assign(error, {
37791
+ code: tokenConfigured ? "gitlab_token_rejected" : "auth_required",
37792
+ rule_id: tokenConfigured ? "issue.auth.token_rejected" : "issue.auth.token_required",
37793
+ http_status: status,
37794
+ suggestion: tokenConfigured ? "Replace the configured token and retry." : "Set GITLAB_TOKEN, GL_TOKEN, PRIVATE_TOKEN, or pass --token-env <ENV_NAME>, then retry."
37795
+ });
37796
+ return error;
37698
37797
  }
37699
37798
  async function createGitLabIssue(input, options) {
37700
37799
  const baseUrl = normalizeBaseUrl2(options.baseUrl);
@@ -41634,6 +41733,10 @@ function hasForbiddenListDeleteStepGuard(value) {
41634
41733
  );
41635
41734
  return /!\s*(?:ctx(?:\.|\?\.))?current_flow_step_(?:id|name)/i.test(actionable) || /current_flow_step_(?:id|name)\s*={2,3}\s*(?:null|undefined|false|0|['"]{2})/i.test(actionable) || /(?:要求|仅当|只有|必须).{0,24}current_flow_step_(?:id|name).{0,16}(?:为空|不存在|empty|null|undefined)/i.test(actionable) || /current_flow_step_(?:id|name).{0,16}(?:为空|不存在|empty|null|undefined).{0,16}(?:才|时).{0,16}(?:删除|允许)/i.test(actionable);
41636
41735
  }
41736
+ var LIST_FIELD_CONTRACT_TERMS = ["required_nonempty", "allowed_empty_reason", "source_dataset_field", "detail_consistency", "runtime_evidence", "icon_token"];
41737
+ function hasListFieldContract(value) {
41738
+ return LIST_FIELD_CONTRACT_TERMS.every((term) => value.includes(term));
41739
+ }
41637
41740
  function validateTaskbookNavigationAndListGates(text5, issues) {
41638
41741
  const strategy = validateNavigationStrategy(text5, issues, "navigation_strategy", "\u4EFB\u52A1\u4E66");
41639
41742
  const rows2 = extractTaskRows(text5);
@@ -41709,6 +41812,18 @@ function validateTaskbookNavigationAndListGates(text5, issues) {
41709
41812
  { domain: "list-template", path: `tasks.${taskId}.notes`, suggestion: "\u5220\u9664\u5F53\u524D\u73AF\u8282\u4E3A\u7A7A\u6761\u4EF6\uFF0C\u6539\u7528 ctx.$CAN_DELETE\uFF1B\u4E1A\u52A1\u72B6\u6001\u53EA\u80FD\u4F5C\u4E3A\u9644\u52A0\u9650\u5236\u3002" }
41710
41813
  );
41711
41814
  }
41815
+ if (hasListFieldContract(text5)) {
41816
+ const missing = LIST_FIELD_CONTRACT_TERMS.filter((term) => !evidenceText.includes(term));
41817
+ if (missing.length) {
41818
+ addTaskbookIssue(
41819
+ issues,
41820
+ "missing_list_field_contract",
41821
+ "taskbook.list.field_contract",
41822
+ `\u5217\u8868\u6A21\u677F\u4EFB\u52A1 ${taskId} \u7F3A\u5C11\u5B57\u6BB5\u8FD0\u884C\u6001\u5951\u7EA6\uFF1A${missing.join(", ")}\u3002`,
41823
+ { domain: "list-template", path: `tasks.${taskId}.evidence`, suggestion: `\u8865\u9F50 ${LIST_FIELD_CONTRACT_TERMS.join("\u3001")}\uFF0C\u5E76\u4E3A\u5173\u952E\u5B57\u6BB5\u63D0\u4F9B\u771F\u5B9E\u9875\u9762\u8BC1\u636E\u3002` }
41824
+ );
41825
+ }
41826
+ }
41712
41827
  });
41713
41828
  }
41714
41829
  function rowText(row) {
@@ -42583,6 +42698,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
42583
42698
  "",
42584
42699
  "- \u914D\u7F6E\u5BF9\u8C61\u7EBF\u4E0A\u56DE\u8BFB\u901A\u8FC7\u3002",
42585
42700
  "- \u5217\u8868\u6A21\u677F\u5FC5\u987B\u901A\u8FC7 `bpmax-cli config list-template lint`\uFF0C\u5E76\u8986\u76D6\u64CD\u4F5C\u5217\u3001\u8BE6\u60C5\u52A8\u4F5C\u3001\u5220\u9664\u52A8\u4F5C\u3001`ctx.$CAN_DELETE` \u5220\u9664\u6743\u9650 guard\u3001\u7981\u6B62\u5F53\u524D\u73AF\u8282\u4E3A\u7A7A\u6761\u4EF6\u3001icon \u5339\u914D\u548C\u67E5\u8BE2\u5B89\u5168\u3002",
42701
+ "- \u5217\u8868\u5B57\u6BB5\u8FD0\u884C\u6001\u5951\u7EA6\u5FC5\u987B\u9010\u9879\u8BB0\u5F55 `required_nonempty`\u3001`allowed_empty_reason`\u3001`source_dataset_field`\u3001`detail_consistency`\u3001`runtime_evidence`\u3001`icon_token`\uFF1B\u7F3A\u5931\u65F6\u53EA\u80FD\u4FDD\u6301 partial/blocked\u3002",
42586
42702
  "- \u5982\u679C\u914D\u7F6E\u6216\u53D8\u66F4\u4E86\u5BFC\u822A\u5165\u53E3\uFF0C\u5FC5\u987B\u901A\u8FC7 `bpmax-cli config nav-config lint/build/submit` \u95ED\u73AF\uFF0C\u5E76\u5728\u6D4F\u89C8\u5668\u786E\u8BA4\u5165\u53E3\u53EF\u89C1\u4E14\u80FD\u8FDB\u5165\u76EE\u6807\u9875\u9762\u3002",
42587
42703
  "- \u6D4F\u89C8\u5668 E2E \u9A8C\u8BC1\u901A\u8FC7\u3002",
42588
42704
  "- \u6D4B\u8BD5\u62A5\u544A\u548C\u622A\u56FE\u8BC1\u636E\u5B8C\u6574\u3002",