bpmax-cli 0.2.1-beta.23 → 0.2.1-beta.24

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
@@ -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.23",
472
+ version: "0.2.1-beta.24",
473
473
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
474
474
  type: "module",
475
475
  bin: {
@@ -479,6 +479,8 @@ var package_default = {
479
479
  "dist",
480
480
  "scripts/install-skills.mjs",
481
481
  "skills",
482
+ "!skills/**/__pycache__/**",
483
+ "!skills/**/*.py[cod]",
482
484
  "README.md"
483
485
  ],
484
486
  scripts: {
@@ -3881,7 +3883,7 @@ var CONFIG_DOMAINS = {
3881
3883
  expectedType: 1,
3882
3884
  readEndpoints: ["GET /api/flow_page_template/:id?skip_i18n=true"],
3883
3885
  writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
3884
- notes: ["type=1 list template. Create and edit both use the typed flow_page_template adapter."]
3886
+ notes: ["type=1 list template. Create and edit both use the typed flow_page_template adapter. Create automatically finalizes data_set_id/flow_type through PUT when the create endpoint leaves server defaults."]
3885
3887
  },
3886
3888
  "filter-template": {
3887
3889
  capability: "config.filter_template",
@@ -3898,7 +3900,7 @@ var CONFIG_DOMAINS = {
3898
3900
  expectedType: 3,
3899
3901
  readEndpoints: ["GET /api/flow_page_template/:id?skip_i18n=true"],
3900
3902
  writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
3901
- notes: ["type=3 filter template. Create and edit both use the typed flow_page_template adapter."]
3903
+ notes: ["type=3 filter template. Create and edit both use the typed flow_page_template adapter. Create automatically finalizes data_set_id/flow_type through PUT when the create endpoint leaves server defaults."]
3902
3904
  },
3903
3905
  "project-detail-template": {
3904
3906
  capability: "config.project_detail_template",
@@ -3915,7 +3917,7 @@ var CONFIG_DOMAINS = {
3915
3917
  expectedType: 2,
3916
3918
  readEndpoints: ["GET /api/flow_page_template/:id?type=2&create=&skip_i18n=true"],
3917
3919
  writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
3918
- notes: ["type=2 project detail template. Create and edit both use the typed flow_page_template adapter; activate/delete remain domain-specific operations."]
3920
+ notes: ["type=2 project detail template. Create and edit both use the typed flow_page_template adapter; create automatically finalizes data_set_id/flow_type through PUT when needed; activate/delete remain domain-specific operations."]
3919
3921
  },
3920
3922
  "console-template": {
3921
3923
  capability: "config.console_template",
@@ -5564,37 +5566,44 @@ function findInlineIconClass(value) {
5564
5566
  }
5565
5567
  return findInlineIconClass(value.children);
5566
5568
  }
5567
- function listTemplateNodeGuardText(node) {
5569
+ function listTemplateGuardExpression(value) {
5570
+ if (isRecord3(value) && typeof value.$template === "string") {
5571
+ return value.$template.trim();
5572
+ }
5573
+ return textOf(value).trim();
5574
+ }
5575
+ function listTemplateNodeGuards(node) {
5568
5576
  const attribute = isRecord3(node.attribute) ? node.attribute : {};
5569
5577
  const props = isRecord3(attribute.props) ? attribute.props : {};
5570
- return [
5571
- node.if,
5572
- node.show,
5573
- node.visible,
5574
- node.disabled,
5575
- props.disabled,
5576
- props.confirm,
5577
- props.confirmText,
5578
- props.beforeClick,
5579
- props.onClick,
5580
- node.on,
5581
- node.events
5582
- ].map(textOf).join(" ");
5578
+ const guards = [];
5579
+ [node.if, node.show, node.visible].forEach((value) => {
5580
+ const text5 = listTemplateGuardExpression(value);
5581
+ if (text5) guards.push({ kind: "visibility", text: text5 });
5582
+ });
5583
+ [node.disabled, props.disabled].forEach((value) => {
5584
+ const text5 = listTemplateGuardExpression(value);
5585
+ if (text5) guards.push({ kind: "disabled", text: text5 });
5586
+ });
5587
+ return guards;
5583
5588
  }
5584
- function collectListTemplateActionNodes(value, result = [], inheritedGuardText = "") {
5589
+ function collectListTemplateActionNodes(value, result = [], inheritedGuards = []) {
5585
5590
  if (Array.isArray(value)) {
5586
- value.forEach((item) => collectListTemplateActionNodes(item, result, inheritedGuardText));
5591
+ value.forEach((item) => collectListTemplateActionNodes(item, result, inheritedGuards));
5587
5592
  return result;
5588
5593
  }
5589
5594
  if (!isRecord3(value)) {
5590
5595
  return result;
5591
5596
  }
5592
5597
  const isValue = typeof value.is === "string" ? value.is.toLowerCase() : "";
5593
- const guardText = [inheritedGuardText, listTemplateNodeGuardText(value)].filter(Boolean).join(" ");
5598
+ const ownGuards = listTemplateNodeGuards(value);
5594
5599
  if (isValue.includes("button") || isValue.includes("dropdown-item")) {
5595
- result.push({ node: value, inheritedGuardText });
5600
+ result.push({ node: value, inheritedGuards });
5596
5601
  }
5597
- Object.values(value).forEach((item) => collectListTemplateActionNodes(item, result, guardText));
5602
+ const childGuards = [
5603
+ ...inheritedGuards,
5604
+ ...ownGuards.filter((guard) => guard.kind === "visibility")
5605
+ ];
5606
+ Object.values(value).forEach((item) => collectListTemplateActionNodes(item, result, childGuards));
5598
5607
  return result;
5599
5608
  }
5600
5609
  function isListTemplateOperationColumn(column) {
@@ -5637,14 +5646,349 @@ function iconMatchesAction(kind, icon) {
5637
5646
  }
5638
5647
  return true;
5639
5648
  }
5640
- function hasDeleteAvailabilityGuard(item) {
5641
- const guardText = [item.inheritedGuardText, listTemplateNodeGuardText(item.node)].filter(Boolean).join(" ");
5642
- if (!guardText.trim()) {
5649
+ function listTemplateDeleteGuards(item) {
5650
+ return [...item.inheritedGuards, ...listTemplateNodeGuards(item.node)];
5651
+ }
5652
+ function normalizeListTemplateGuardScript(text5) {
5653
+ return text5.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:])\/\/.*$/gm, "$1").trim();
5654
+ }
5655
+ function currentFlowStepReferencePattern() {
5656
+ return String.raw`(?:ctx(?:\.|\?\.)current_flow_step_(?:id|name)(?![\w$])|ctx\[\s*['"]current_flow_step_(?:id|name)['"]\s*\])`;
5657
+ }
5658
+ function currentFlowStepEmptyHelperPattern() {
5659
+ return String.raw`(?:(?:ctx\.)?(?:\$_?|\$lodash|lodash|_)(?:\.|\?\.))?(?:isEmpty|isNil)`;
5660
+ }
5661
+ function normalizeCurrentFlowStepGuardScript(text5) {
5662
+ const computedNormalized = normalizeListTemplateGuardScript(text5).replace(
5663
+ /ctx\[\s*(['"])(current_flow_step_(?:id|name))\1\s*\]/gi,
5664
+ "ctx.$2"
5665
+ );
5666
+ let result = "";
5667
+ let quote = "";
5668
+ for (let index = 0; index < computedNormalized.length; index += 1) {
5669
+ const char = computedNormalized[index];
5670
+ const previous = computedNormalized[index - 1];
5671
+ if (quote) {
5672
+ if (char === quote && previous !== "\\") {
5673
+ quote = "";
5674
+ result += char;
5675
+ } else {
5676
+ result += " ";
5677
+ }
5678
+ continue;
5679
+ }
5680
+ if (char === '"' || char === "'" || char === "`") {
5681
+ quote = char;
5682
+ }
5683
+ result += char;
5684
+ }
5685
+ return result;
5686
+ }
5687
+ function hasCurrentFlowStepAbsenceCheck(text5) {
5688
+ const normalized = normalizeCurrentFlowStepGuardScript(text5);
5689
+ const stepRef = currentFlowStepReferencePattern();
5690
+ const emptyHelper = currentFlowStepEmptyHelperPattern();
5691
+ const emptyValue = String.raw`(?:null|undefined|false|0|['"]{2})`;
5692
+ return new RegExp(String.raw`!\s*${stepRef}`, "i").test(normalized) || new RegExp(String.raw`${stepRef}\s*={2,3}\s*${emptyValue}`, "i").test(normalized) || new RegExp(String.raw`${emptyValue}\s*={2,3}\s*${stepRef}`, "i").test(normalized) || new RegExp(String.raw`${emptyHelper}\s*\(\s*${stepRef}\s*\)`, "i").test(normalized) || new RegExp(String.raw`!\s*(?:Boolean|String)\s*\(\s*${stepRef}\s*\)`, "i").test(normalized) || new RegExp(String.raw`${stepRef}(?:\.|\?\.)length\s*={2,3}\s*0`, "i").test(normalized);
5693
+ }
5694
+ function hasCurrentFlowStepPresenceCheck(text5) {
5695
+ const normalized = normalizeCurrentFlowStepGuardScript(text5);
5696
+ const stepRef = currentFlowStepReferencePattern();
5697
+ const emptyHelper = currentFlowStepEmptyHelperPattern();
5698
+ const emptyValue = String.raw`(?:null|undefined|false|0|['"]{2})`;
5699
+ return new RegExp(String.raw`!\s*!\s*${stepRef}`, "i").test(normalized) || new RegExp(String.raw`(?:Boolean|String)\s*\(\s*${stepRef}\s*\)`, "i").test(normalized) || new RegExp(String.raw`${stepRef}\s*!={1,2}\s*${emptyValue}`, "i").test(normalized) || new RegExp(String.raw`${emptyValue}\s*!={1,2}\s*${stepRef}`, "i").test(normalized) || new RegExp(String.raw`!\s*${emptyHelper}\s*\(\s*${stepRef}\s*\)`, "i").test(normalized) || new RegExp(String.raw`${stepRef}(?:\.|\?\.)length\s*(?:>=|>|!={1,2})\s*0`, "i").test(normalized);
5700
+ }
5701
+ function normalizeListTemplateGuardTerm(text5) {
5702
+ let normalized = normalizeListTemplateGuardScript(text5).replace(/^\s*return\b/i, "").replace(/^[\s{;]+|[\s};]+$/g, "").trim();
5703
+ const hasBalancedOuterParentheses = () => {
5704
+ if (!normalized.startsWith("(") || !normalized.endsWith(")")) {
5705
+ return false;
5706
+ }
5707
+ let depth = 0;
5708
+ let quote = "";
5709
+ for (let index = 0; index < normalized.length; index += 1) {
5710
+ const char = normalized[index];
5711
+ const previous = normalized[index - 1];
5712
+ if (quote) {
5713
+ if (char === quote && previous !== "\\") quote = "";
5714
+ continue;
5715
+ }
5716
+ if (char === '"' || char === "'" || char === "`") {
5717
+ quote = char;
5718
+ continue;
5719
+ }
5720
+ if (char === "(") depth += 1;
5721
+ if (char === ")") depth -= 1;
5722
+ if (depth === 0 && index < normalized.length - 1) return false;
5723
+ if (depth < 0) return false;
5724
+ }
5725
+ return depth === 0;
5726
+ };
5727
+ while (hasBalancedOuterParentheses()) {
5728
+ normalized = normalized.slice(1, -1).trim();
5729
+ }
5730
+ return normalized;
5731
+ }
5732
+ function normalizeListTemplateAtomicGuardTerm(text5) {
5733
+ let normalized = normalizeListTemplateGuardTerm(text5);
5734
+ const balance = () => {
5735
+ return [...normalized].reduce((result, char) => {
5736
+ if (char === "(") return result + 1;
5737
+ if (char === ")") return result - 1;
5738
+ return result;
5739
+ }, 0);
5740
+ };
5741
+ while (normalized.startsWith("(") && balance() > 0) {
5742
+ normalized = normalized.slice(1).trim();
5743
+ }
5744
+ while (normalized.endsWith(")") && balance() < 0) {
5745
+ normalized = normalized.slice(0, -1).trim();
5746
+ }
5747
+ return normalized;
5748
+ }
5749
+ function splitTopLevelListTemplateBoolean(text5, operator) {
5750
+ const normalized = normalizeListTemplateGuardTerm(text5);
5751
+ const result = [];
5752
+ let current = "";
5753
+ let depth = 0;
5754
+ let quote = "";
5755
+ for (let index = 0; index < normalized.length; index += 1) {
5756
+ const char = normalized[index];
5757
+ const previous = normalized[index - 1];
5758
+ if (quote) {
5759
+ current += char;
5760
+ if (char === quote && previous !== "\\") quote = "";
5761
+ continue;
5762
+ }
5763
+ if (char === '"' || char === "'" || char === "`") {
5764
+ quote = char;
5765
+ current += char;
5766
+ continue;
5767
+ }
5768
+ if (char === "(" || char === "[" || char === "{") depth += 1;
5769
+ if (char === ")" || char === "]" || char === "}") depth -= 1;
5770
+ if (depth === 0 && normalized.slice(index, index + operator.length) === operator) {
5771
+ if (current.trim()) result.push(current.trim());
5772
+ current = "";
5773
+ index += operator.length - 1;
5774
+ continue;
5775
+ }
5776
+ current += char;
5777
+ }
5778
+ if (current.trim()) result.push(current.trim());
5779
+ return result;
5780
+ }
5781
+ function hasTopLevelListTemplateCharacter(text5, target) {
5782
+ const normalized = normalizeListTemplateGuardTerm(text5);
5783
+ let depth = 0;
5784
+ let quote = "";
5785
+ for (let index = 0; index < normalized.length; index += 1) {
5786
+ const char = normalized[index];
5787
+ const previous = normalized[index - 1];
5788
+ if (quote) {
5789
+ if (char === quote && previous !== "\\") quote = "";
5790
+ continue;
5791
+ }
5792
+ if (char === '"' || char === "'" || char === "`") {
5793
+ quote = char;
5794
+ continue;
5795
+ }
5796
+ if (char === "(" || char === "[" || char === "{") depth += 1;
5797
+ if (char === ")" || char === "]" || char === "}") depth -= 1;
5798
+ if (depth === 0 && char === target) return true;
5799
+ }
5800
+ return false;
5801
+ }
5802
+ function singleListTemplateGuardExpression(text5) {
5803
+ const removeLeadingTrivia = (value) => {
5804
+ let result = value;
5805
+ let previous = "";
5806
+ while (result !== previous) {
5807
+ previous = result;
5808
+ result = result.replace(/^[\s\uFEFF]+/, "");
5809
+ if (result.startsWith("//")) {
5810
+ result = result.replace(/^\/\/[^\r\n\u2028\u2029]*(?:\r\n?|\n|\u2028|\u2029|$)/, "");
5811
+ } else if (result.startsWith("/*")) {
5812
+ result = result.replace(/^\/\*[\s\S]*?\*\//, "");
5813
+ }
5814
+ }
5815
+ return result;
5816
+ };
5817
+ const removeTrailingTrivia = (value) => {
5818
+ let index = 0;
5819
+ let lastSignificantEnd = 0;
5820
+ while (index < value.length) {
5821
+ const char = value[index];
5822
+ if (/^[\s\uFEFF]$/.test(char)) {
5823
+ index += 1;
5824
+ continue;
5825
+ }
5826
+ if (char === "/" && value[index + 1] === "/") {
5827
+ const lineEnd = value.slice(index + 2).search(/[\r\n\u2028\u2029]/);
5828
+ index = lineEnd < 0 ? value.length : index + 2 + lineEnd + 1;
5829
+ continue;
5830
+ }
5831
+ if (char === "/" && value[index + 1] === "*") {
5832
+ const commentEnd = value.indexOf("*/", index + 2);
5833
+ if (commentEnd < 0) {
5834
+ return value;
5835
+ }
5836
+ index = commentEnd + 2;
5837
+ continue;
5838
+ }
5839
+ if (char === '"' || char === "'" || char === "`") {
5840
+ const quote = char;
5841
+ index += 1;
5842
+ while (index < value.length) {
5843
+ if (value[index] === "\\") {
5844
+ index += 2;
5845
+ continue;
5846
+ }
5847
+ if (value[index] === quote) {
5848
+ index += 1;
5849
+ break;
5850
+ }
5851
+ index += 1;
5852
+ }
5853
+ lastSignificantEnd = index;
5854
+ continue;
5855
+ }
5856
+ index += 1;
5857
+ lastSignificantEnd = index;
5858
+ }
5859
+ return value.slice(0, lastSignificantEnd);
5860
+ };
5861
+ let rawScript = removeLeadingTrivia(removeTrailingTrivia(text5));
5862
+ if (rawScript.startsWith("{") && rawScript.endsWith("}")) {
5863
+ rawScript = removeLeadingTrivia(rawScript.slice(1, -1).trim());
5864
+ }
5865
+ const rawReturn = rawScript.match(/^return\b([\s\S]*)/i);
5866
+ if (rawReturn) {
5867
+ const trivia = rawReturn[1].match(/^(?:(?:[^\S\r\n\u2028\u2029]+)|(?:[\r\n\u2028\u2029]+)|(?:\/\*[\s\S]*?\*\/)|(?:\/\/[^\r\n\u2028\u2029]*(?:\r\n?|\n|\u2028|\u2029|$)))*/)?.[0] || "";
5868
+ if (/[\r\n\u2028\u2029]/.test(trivia)) return null;
5869
+ }
5870
+ let script = normalizeListTemplateGuardScript(text5).trim();
5871
+ if (script.startsWith("{") && script.endsWith("}")) {
5872
+ script = script.slice(1, -1).trim();
5873
+ }
5874
+ const returnCount = script.match(/\breturn\b/gi)?.length || 0;
5875
+ if (returnCount > 1) return null;
5876
+ if (returnCount === 1) {
5877
+ if (!/^return\b/i.test(script)) return null;
5878
+ script = script.replace(/^return\b/i, "").trim();
5879
+ }
5880
+ script = script.replace(/;\s*$/, "").trim();
5881
+ if (!script || /\breturn\b/i.test(script) || hasTopLevelListTemplateCharacter(script, ";")) {
5882
+ return null;
5883
+ }
5884
+ return script;
5885
+ }
5886
+ function isPositiveCanDeleteTerm(text5) {
5887
+ const term = normalizeListTemplateAtomicGuardTerm(text5);
5888
+ return /^(?:ctx\.)?\$CAN_DELETE(?:\s*={2,3}\s*true)?$/i.test(term) || /^true\s*={2,3}\s*(?:ctx\.)?\$CAN_DELETE$/i.test(term);
5889
+ }
5890
+ function isNegatedCanDeleteTerm(text5) {
5891
+ const term = normalizeListTemplateAtomicGuardTerm(text5);
5892
+ return /^!\s*(?:ctx\.)?\$CAN_DELETE$/i.test(term) || /^(?:ctx\.)?\$CAN_DELETE\s*={2,3}\s*false$/i.test(term) || /^false\s*={2,3}\s*(?:ctx\.)?\$CAN_DELETE$/i.test(term);
5893
+ }
5894
+ function flowPermissionCallPattern(permission) {
5895
+ const escapedPermission = permission.replace(".", String.raw`\.`);
5896
+ return String.raw`(?:ctx\.)?\$canInFlow\s*\(\s*['"]${escapedPermission}['"]\s*\)`;
5897
+ }
5898
+ function isPositiveFlowPermissionTerm(text5, permission) {
5899
+ const term = normalizeListTemplateAtomicGuardTerm(text5);
5900
+ const call = flowPermissionCallPattern(permission);
5901
+ return new RegExp(String.raw`^(?:${call})(?:\s*={2,3}\s*true)?$`, "i").test(term) || new RegExp(String.raw`^true\s*={2,3}\s*(?:${call})$`, "i").test(term);
5902
+ }
5903
+ function isNegatedFlowPermissionTerm(text5, permission) {
5904
+ const term = normalizeListTemplateAtomicGuardTerm(text5);
5905
+ const call = flowPermissionCallPattern(permission);
5906
+ return new RegExp(String.raw`^!\s*(?:${call})$`, "i").test(term) || new RegExp(String.raw`^(?:${call})\s*={2,3}\s*false$`, "i").test(term) || new RegExp(String.raw`^false\s*={2,3}\s*(?:${call})$`, "i").test(term);
5907
+ }
5908
+ function isOwnerIdentityEqualityTerm(text5) {
5909
+ const term = normalizeListTemplateAtomicGuardTerm(text5);
5910
+ const ownerRef = String.raw`(?:ctx\.)?__owner_id`;
5911
+ const userRef = String.raw`(?:ctx\.)?(?:\$USER_INFO|userInfo)(?:\?\.|\.)id`;
5912
+ return new RegExp(String.raw`^${ownerRef}\s*={2,3}\s*${userRef}$`, "i").test(term) || new RegExp(String.raw`^${userRef}\s*={2,3}\s*${ownerRef}$`, "i").test(term);
5913
+ }
5914
+ function hasPositiveDeletePermission(text5) {
5915
+ if (hasTopLevelListTemplateCharacter(text5, ",")) {
5643
5916
  return false;
5644
5917
  }
5645
- const hasInitialStatusCheck = /(status|project_status)[^;&|)]*(={2,3}|==)\s*['"]?0['"]?/i.test(guardText) || /['"]?0['"]?\s*(={2,3}|==)[^;&|)]*(status|project_status)/i.test(guardText) || /(draft|newly|created|unstarted|未开始|刚创建|新建)/i.test(guardText);
5646
- const hasNotAdvancedCheck = /!\s*[^&|;]*(current_flow_step|flow_step|step|node)/i.test(guardText) || /(current_flow_step|flow_step|step|node)[^&|;]*(={2,3}|==)\s*(null|undefined|false|['"]{2})/i.test(guardText) || /(first_node|before_first|未推进|第一个节点前)/i.test(guardText);
5647
- return hasInitialStatusCheck && hasNotAdvancedCheck;
5918
+ const terms = splitTopLevelListTemplateBoolean(text5, "&&");
5919
+ return terms.some(isPositiveCanDeleteTerm) || terms.some((term) => isPositiveFlowPermissionTerm(term, "project.delete")) || terms.some((term) => isPositiveFlowPermissionTerm(term, "project.delete.my")) && terms.some(isOwnerIdentityEqualityTerm);
5920
+ }
5921
+ function isNegatedMyOwnerExpression(text5) {
5922
+ const term = normalizeListTemplateGuardTerm(text5);
5923
+ if (!term.startsWith("!(") || !term.endsWith(")")) {
5924
+ return false;
5925
+ }
5926
+ const inner = term.slice(2, -1);
5927
+ const branches = splitTopLevelListTemplateBoolean(inner, "||");
5928
+ return branches.length > 0 && branches.every(hasPositiveDeletePermission);
5929
+ }
5930
+ function hasNegatedDeletePermission(text5) {
5931
+ const term = normalizeListTemplateGuardTerm(text5);
5932
+ return isNegatedCanDeleteTerm(term) || isNegatedFlowPermissionTerm(term, "project.delete") || isNegatedMyOwnerExpression(term);
5933
+ }
5934
+ function hasUnsupportedPermissionGuardShape(text5) {
5935
+ const expression = singleListTemplateGuardExpression(text5);
5936
+ if (!expression) return true;
5937
+ const normalized = normalizeListTemplateGuardScript(expression);
5938
+ return /(?:^|[;{}])\s*return\s*['"`]/i.test(normalized) || /\?/.test(normalized) && /:/.test(normalized);
5939
+ }
5940
+ function visibilityBranchHasConstantFalseTerm(branch) {
5941
+ return splitTopLevelListTemplateBoolean(branch, "&&").some((term) => {
5942
+ const normalizedTerm = term.replace(/\breturn\b/gi, "").replace(/[(){};\s]/g, "");
5943
+ return /^(?:false|null|undefined|0|!true)$/i.test(normalizedTerm);
5944
+ });
5945
+ }
5946
+ function isAlwaysFalseVisibilityGuard(text5) {
5947
+ const expression = singleListTemplateGuardExpression(text5);
5948
+ if (!expression) return false;
5949
+ const branches = splitTopLevelListTemplateBoolean(expression, "||");
5950
+ return branches.length > 0 && branches.every(visibilityBranchHasConstantFalseTerm);
5951
+ }
5952
+ function hasSafeVisibilityDeletePermission(text5) {
5953
+ const expression = singleListTemplateGuardExpression(text5);
5954
+ if (!expression || hasUnsupportedPermissionGuardShape(expression) || hasTopLevelListTemplateCharacter(expression, ",")) {
5955
+ return false;
5956
+ }
5957
+ const branches = splitTopLevelListTemplateBoolean(expression, "||");
5958
+ return branches.length > 0 && branches.every((branch) => {
5959
+ return !visibilityBranchHasConstantFalseTerm(branch) && hasPositiveDeletePermission(branch);
5960
+ });
5961
+ }
5962
+ function hasSafeDisabledDeletePermission(text5) {
5963
+ const expression = singleListTemplateGuardExpression(text5);
5964
+ if (!expression || hasUnsupportedPermissionGuardShape(expression) || hasTopLevelListTemplateCharacter(expression, ",")) {
5965
+ return false;
5966
+ }
5967
+ return splitTopLevelListTemplateBoolean(expression, "||").some((branch) => isNegatedMyOwnerExpression(branch) || !branch.includes("&&") && hasNegatedDeletePermission(branch));
5968
+ }
5969
+ function validateDeletePermissionGuard(item, errors) {
5970
+ const guards = listTemplateDeleteGuards(item);
5971
+ const visibilityGuards = guards.filter((guard) => guard.kind === "visibility");
5972
+ const disabledGuards = guards.filter((guard) => guard.kind === "disabled");
5973
+ if (visibilityGuards.some((guard) => hasCurrentFlowStepAbsenceCheck(guard.text)) || disabledGuards.some((guard) => hasCurrentFlowStepPresenceCheck(guard.text))) {
5974
+ errors.push("list-template delete action must not require current_flow_step_id/current_flow_step_name to be empty; immediate-active flows always have a current step. Use ctx.$CAN_DELETE instead.");
5975
+ }
5976
+ if (visibilityGuards.some((guard) => {
5977
+ return splitTopLevelListTemplateBoolean(guard.text, "||").some((branch) => hasNegatedDeletePermission(branch));
5978
+ })) {
5979
+ errors.push("list-template delete visibility guard must allow authorized users; do not negate ctx.$CAN_DELETE.");
5980
+ }
5981
+ if (visibilityGuards.some((guard) => isAlwaysFalseVisibilityGuard(guard.text))) {
5982
+ errors.push("list-template delete visibility guard must not be an always-false expression.");
5983
+ }
5984
+ if (disabledGuards.some((guard) => hasPositiveDeletePermission(guard.text) && !hasSafeDisabledDeletePermission(guard.text))) {
5985
+ errors.push("list-template delete disabled guard must negate the permission check, for example return !ctx.$CAN_DELETE.");
5986
+ }
5987
+ const hasVisibilityPermission = visibilityGuards.some((guard) => hasSafeVisibilityDeletePermission(guard.text));
5988
+ const hasDisabledPermission = disabledGuards.some((guard) => hasSafeDisabledDeletePermission(guard.text));
5989
+ if (!hasVisibilityPermission && !hasDisabledPermission) {
5990
+ errors.push("list-template delete action must include a permission guard using ctx.$CAN_DELETE or an equivalent project.delete/project.delete.my + owner check.");
5991
+ }
5648
5992
  }
5649
5993
  function validateListTemplateActionGate(value, errors) {
5650
5994
  const nextErrors = [];
@@ -5683,9 +6027,7 @@ function validateListTemplateActionGate(value, errors) {
5683
6027
  nextErrors.push("list-template operation column must include a delete/remove action.");
5684
6028
  } else {
5685
6029
  classified.filter((item) => item.kind === "delete").forEach((item) => {
5686
- if (!hasDeleteAvailabilityGuard(item)) {
5687
- nextErrors.push("list-template delete action must include an availability guard based on project status/current step so only newly created projects can be deleted.");
5688
- }
6030
+ validateDeletePermissionGuard(item, nextErrors);
5689
6031
  });
5690
6032
  }
5691
6033
  classified.filter((item) => item.kind !== "other").forEach((item) => {
@@ -8387,19 +8729,69 @@ async function readBackConfigDomain(profile, domain, id, definition) {
8387
8729
  readback_hash: hashJson(data)
8388
8730
  };
8389
8731
  }
8390
- function assertExactTypedReadback(domain, payload, readback) {
8391
- const expectedSource = domain === "form-template" ? stripServerFilledFields(payload, FORM_TEMPLATE_SERVER_FIELD_KEYS) : payload;
8392
- const actualSource = domain === "form-template" ? stripServerFilledFields(readback, FORM_TEMPLATE_SERVER_FIELD_KEYS) : readback;
8393
- let expected = expectedSource;
8394
- let actual = actualSource;
8732
+ function normalizeComparableId(value) {
8733
+ if (typeof value === "number" && Number.isFinite(value)) {
8734
+ return String(value);
8735
+ }
8736
+ if (typeof value === "string" && /^\d+$/.test(value.trim())) {
8737
+ return value.trim().replace(/^0+(?=\d)/, "");
8738
+ }
8739
+ return value;
8740
+ }
8741
+ function normalizeComparableFieldKeys(value) {
8742
+ if (!Array.isArray(value)) {
8743
+ return value;
8744
+ }
8745
+ const keys = value.flatMap((item) => {
8746
+ if (typeof item === "string" && item.trim()) {
8747
+ return [item.trim()];
8748
+ }
8749
+ if (isRecord3(item)) {
8750
+ const key = item.key ?? item.field;
8751
+ if (typeof key === "string" && key.trim()) {
8752
+ return [key.trim()];
8753
+ }
8754
+ }
8755
+ return [];
8756
+ });
8757
+ return [...new Set(keys)].sort();
8758
+ }
8759
+ function normalizeTypedReadbackComparable(domain, value) {
8760
+ let comparable2 = value;
8395
8761
  try {
8396
- expected = buildDomainSubmitPayload(domain, expectedSource);
8397
- actual = buildDomainSubmitPayload(domain, actualSource);
8762
+ comparable2 = buildDomainSubmitPayload(domain, value);
8398
8763
  } catch {
8399
8764
  }
8400
- assertJsonSubset(expected, actual, `${domain} submit`);
8765
+ if (!isRecord3(comparable2)) {
8766
+ return comparable2;
8767
+ }
8768
+ const normalized = { ...comparable2 };
8769
+ if (domain === "dataset") {
8770
+ normalized.refresh_setting = refreshSettingToSubmit(normalized.refresh_setting);
8771
+ const raw = isRecord3(value) ? value : {};
8772
+ normalized.fields = normalizeComparableFieldKeys(
8773
+ normalized.fields ?? raw.dataSetFields ?? raw.data_set_fields ?? raw.relationFields
8774
+ );
8775
+ }
8776
+ if (domain === "dataset-field") {
8777
+ normalized.data_set_id = normalizeComparableId(
8778
+ normalized.data_set_id ?? normalized.dataSetId ?? normalized.dataset_id
8779
+ );
8780
+ }
8781
+ if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "console-template") {
8782
+ if (Object.prototype.hasOwnProperty.call(normalized, "data_set_id")) {
8783
+ normalized.data_set_id = normalizeComparableId(normalized.data_set_id);
8784
+ }
8785
+ if (Object.prototype.hasOwnProperty.call(normalized, "flow_type")) {
8786
+ normalized.flow_type = normalized.flow_type ?? "";
8787
+ }
8788
+ if (Object.prototype.hasOwnProperty.call(normalized, "flow_key")) {
8789
+ normalized.flow_key = normalized.flow_key ?? "";
8790
+ }
8791
+ }
8792
+ return normalized;
8401
8793
  }
8402
- function assertJsonSubset(expected, actual, label) {
8794
+ function jsonSubsetMismatches(expected, actual) {
8403
8795
  const mismatches = [];
8404
8796
  const compare = (left, right, path16 = "") => {
8405
8797
  if (Array.isArray(left)) {
@@ -8407,7 +8799,7 @@ function assertJsonSubset(expected, actual, label) {
8407
8799
  mismatches.push(path16 || "/");
8408
8800
  return;
8409
8801
  }
8410
- left.forEach((value, index) => compare(value, right[index], `${path16}/${index}`));
8802
+ left.forEach((item, index) => compare(item, right[index], `${path16}/${index}`));
8411
8803
  return;
8412
8804
  }
8413
8805
  if (isRecord3(left)) {
@@ -8415,16 +8807,45 @@ function assertJsonSubset(expected, actual, label) {
8415
8807
  mismatches.push(path16 || "/");
8416
8808
  return;
8417
8809
  }
8418
- for (const [key, value] of Object.entries(left)) compare(value, right[key], `${path16}/${key}`);
8810
+ for (const [key, item] of Object.entries(left)) compare(item, right[key], `${path16}/${key}`);
8419
8811
  return;
8420
8812
  }
8421
8813
  if (JSON.stringify(left) !== JSON.stringify(right)) mismatches.push(path16 || "/");
8422
8814
  };
8423
8815
  compare(expected, actual);
8816
+ return mismatches;
8817
+ }
8818
+ function compareTypedReadback(domain, payload, readback) {
8819
+ const expectedSource = domain === "form-template" ? stripServerFilledFields(payload, FORM_TEMPLATE_SERVER_FIELD_KEYS) : payload;
8820
+ const actualSource = domain === "form-template" ? stripServerFilledFields(readback, FORM_TEMPLATE_SERVER_FIELD_KEYS) : readback;
8821
+ const expected = normalizeTypedReadbackComparable(domain, expectedSource);
8822
+ const actual = normalizeTypedReadbackComparable(domain, actualSource);
8823
+ const mismatches = jsonSubsetMismatches(expected, actual);
8824
+ return { ok: mismatches.length === 0, mismatches };
8825
+ }
8826
+ function assertExactTypedReadback(domain, payload, readback) {
8827
+ const comparison = compareTypedReadback(domain, payload, readback);
8828
+ if (!comparison.ok) {
8829
+ throw new Error(`${domain} submit readback mismatch: ${comparison.mismatches.slice(0, 10).join(", ")}.`);
8830
+ }
8831
+ }
8832
+ function assertJsonSubset(expected, actual, label) {
8833
+ const mismatches = jsonSubsetMismatches(expected, actual);
8424
8834
  if (mismatches.length > 0) {
8425
8835
  throw new Error(`${label} readback mismatch: ${mismatches.slice(0, 10).join(", ")}.`);
8426
8836
  }
8427
8837
  }
8838
+ function isPageTemplateCreateFinalizeDomain(domain) {
8839
+ return domain === "list-template" || domain === "filter-template" || domain === "project-detail-template";
8840
+ }
8841
+ function pageTemplateCreateNeedsFinalize(domain, payload, comparison) {
8842
+ if (!isPageTemplateCreateFinalizeDomain(domain)) {
8843
+ return false;
8844
+ }
8845
+ const expectsDataset = payload.data_set_id !== void 0 && payload.data_set_id !== null && String(payload.data_set_id).trim() !== "" && String(payload.data_set_id).trim() !== "0";
8846
+ const expectsFlowType = typeof payload.flow_type === "string" && payload.flow_type.trim() !== "";
8847
+ return expectsDataset && comparison.mismatches.includes("/data_set_id") || expectsFlowType && comparison.mismatches.includes("/flow_type");
8848
+ }
8428
8849
  async function readbackConfigDomain(config, profile, domain, id) {
8429
8850
  void config;
8430
8851
  const definition = CONFIG_DOMAINS[domain];
@@ -9357,24 +9778,76 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
9357
9778
  { data: submit.payload, capability: `${definition.capability}.create` }
9358
9779
  );
9359
9780
  const createdId = responseDataId(response2);
9360
- let readbackHash = null;
9361
- if (createdId !== void 0 && createdId !== null && createdId !== "" && definition.exportPath) {
9362
- await ensureConfigCapability(profile, `${definition.capability}.export`);
9363
- const createReadback = await readRemoteConfigDomain(profile, domain, String(createdId), definition);
9364
- assertExactTypedReadback(domain, submit.payload, createReadback);
9365
- readbackHash = hashJson(createReadback);
9366
- } else if (definition.exportPath) {
9781
+ if (createdId === void 0 || createdId === null || createdId === "") {
9367
9782
  throw new Error(`${domain} create did not return an id required for exact typed readback.`);
9368
9783
  }
9784
+ let readbackHash = null;
9785
+ let readbackStatus = definition.exportPath ? "unavailable" : "verified";
9786
+ let readbackMismatches = [];
9787
+ let readbackError = null;
9788
+ let finalizeResponse = null;
9789
+ let finalizeAttempted = false;
9790
+ let finalizeWriteCompleted = false;
9791
+ if (definition.exportPath) {
9792
+ try {
9793
+ await ensureConfigCapability(profile, `${definition.capability}.export`);
9794
+ let createReadback = await readRemoteConfigDomain(profile, domain, String(createdId), definition);
9795
+ let comparison = compareTypedReadback(domain, submit.payload, createReadback);
9796
+ readbackHash = hashJson(createReadback);
9797
+ readbackMismatches = comparison.mismatches;
9798
+ readbackStatus = comparison.ok ? "verified" : "mismatch";
9799
+ if (!comparison.ok && pageTemplateCreateNeedsFinalize(domain, submit.payload, comparison)) {
9800
+ finalizeAttempted = true;
9801
+ await ensureConfigCapability(profile, `${definition.capability}.submit`);
9802
+ const finalizeEndpoint = definition.submitPath?.(String(createdId));
9803
+ if (!finalizeEndpoint || !definition.submitMethod) {
9804
+ throw new Error(`${domain} create requires a typed finalize endpoint for data_set_id/flow_type persistence.`);
9805
+ }
9806
+ finalizeResponse = await apiRequest(
9807
+ client2,
9808
+ definition.submitMethod,
9809
+ finalizeEndpoint,
9810
+ { data: submit.payload, capability: `${definition.capability}.submit` }
9811
+ );
9812
+ finalizeWriteCompleted = true;
9813
+ readbackHash = null;
9814
+ readbackMismatches = [];
9815
+ readbackStatus = "unavailable";
9816
+ createReadback = await readRemoteConfigDomain(profile, domain, String(createdId), definition);
9817
+ comparison = compareTypedReadback(domain, submit.payload, createReadback);
9818
+ readbackHash = hashJson(createReadback);
9819
+ readbackMismatches = comparison.mismatches;
9820
+ readbackStatus = comparison.ok ? "verified" : "mismatch";
9821
+ }
9822
+ } catch (error) {
9823
+ if (finalizeWriteCompleted || readbackStatus !== "mismatch") {
9824
+ readbackStatus = "unavailable";
9825
+ }
9826
+ readbackError = error instanceof Error ? error.message : String(error || "");
9827
+ }
9828
+ }
9829
+ const partialSuccess = readbackStatus !== "verified";
9369
9830
  return {
9370
9831
  ...executedFields(),
9832
+ status: partialSuccess ? "partial_success" : "success",
9833
+ partial_success: partialSuccess,
9834
+ readback_status: readbackStatus,
9835
+ requires_follow_up: partialSuccess,
9371
9836
  domain,
9372
9837
  ...standardConfigWriteResponse({ domain, id, executedId: createdId ?? null, payload: submit.payload, response: response2 }),
9373
9838
  created_id: createdId ?? null,
9374
9839
  endpoint: definition.createPath,
9375
9840
  method: definition.createMethod,
9376
9841
  response: response2,
9377
- readback_hash: readbackHash
9842
+ readback_hash: readbackHash,
9843
+ ...readbackMismatches.length ? { readback_mismatches: readbackMismatches.slice(0, 10) } : {},
9844
+ ...readbackError ? { readback_error: readbackError } : {},
9845
+ ...finalizeAttempted ? {
9846
+ finalize_attempted: true,
9847
+ finalize_write_completed: finalizeWriteCompleted,
9848
+ finalize_endpoint: definition.submitPath?.(String(createdId)) ?? null,
9849
+ finalize_response: finalizeResponse
9850
+ } : {}
9378
9851
  };
9379
9852
  }
9380
9853
  await ensureConfigCapability(profile, `${definition.capability}.submit`);
@@ -9741,8 +10214,10 @@ async function runConfigBatchSubmit(config, profile, manifestFile, options = {})
9741
10214
  }
9742
10215
  const response = await submitConfigDomain(config, profile, domain, id, payload, item.confirm);
9743
10216
  const executed = !isRecord3(response) || response.operation_executed !== false && response.dry_run !== true;
10217
+ const partialSuccess = isRecord3(response) && response.status === "partial_success";
9744
10218
  const result = executed ? {
9745
10219
  ok: true,
10220
+ status: partialSuccess ? "partial_success" : "success",
9746
10221
  index,
9747
10222
  domain,
9748
10223
  id,
@@ -9775,14 +10250,17 @@ async function runConfigBatchSubmit(config, profile, manifestFile, options = {})
9775
10250
  }
9776
10251
  }
9777
10252
  const failures = results.filter((item) => item.ok === false);
10253
+ const partial = results.filter((item) => item.status === "partial_success").length;
9778
10254
  return {
9779
10255
  ok: failures.length === 0,
10256
+ status: failures.length > 0 ? "failed" : partial > 0 ? "partial_success" : "success",
9780
10257
  manifest_file: manifestFile,
9781
10258
  action: "submit",
9782
10259
  continue_on_error: Boolean(options.continueOnError),
9783
10260
  total: items.length,
9784
10261
  completed: results.length,
9785
10262
  succeeded: results.length - failures.length,
10263
+ partial,
9786
10264
  failed: failures.length,
9787
10265
  results
9788
10266
  };
@@ -16174,6 +16652,31 @@ import { readFile as readFile13 } from "fs/promises";
16174
16652
  import axios7, { AxiosHeaders as AxiosHeaders3 } from "axios";
16175
16653
  var DEFAULT_GITLAB_URL = "https://gitlab.yitaiyitai.com";
16176
16654
  var DEFAULT_GITLAB_PROJECT = "bpmax/bpmax-cli";
16655
+ var REQUIRED_ISSUE_SECTIONS = [
16656
+ "\u73B0\u8C61",
16657
+ "\u590D\u73B0",
16658
+ "\u671F\u671B\u884C\u4E3A",
16659
+ "\u5B9E\u9645\u884C\u4E3A",
16660
+ "\u5F71\u54CD\u8303\u56F4",
16661
+ "\u5DF2\u9A8C\u8BC1\u6392\u9664\u9879"
16662
+ ];
16663
+ var SECRET_PATTERNS = [
16664
+ {
16665
+ code: "secret.env_assignment",
16666
+ pattern: /\b(?:GITLAB_TOKEN|GL_TOKEN|PRIVATE_TOKEN|API_KEY|BPMAX_EXECUTION_TOKEN)\s*[:=]\s*['"]?[^'"\s]+/i,
16667
+ message: "Issue draft must not include token or API key environment variable values."
16668
+ },
16669
+ {
16670
+ code: "secret.header",
16671
+ pattern: /\b(?:authorization|private-token|cookie|set-cookie)\b\s*[:=]\s*[^,\n\r]+/i,
16672
+ message: "Issue draft must not include authorization, private token, or cookie headers."
16673
+ },
16674
+ {
16675
+ code: "secret.token_like",
16676
+ pattern: /(?<!-)-[A-Za-z0-9_][A-Za-z0-9_-]{15,}\b/,
16677
+ message: "Issue draft contains a token-like value; replace it with a redacted placeholder."
16678
+ }
16679
+ ];
16177
16680
  function normalizeBaseUrl2(baseUrl = DEFAULT_GITLAB_URL) {
16178
16681
  const normalized = baseUrl.trim().replace(/\/+$/g, "");
16179
16682
  if (!normalized) {
@@ -16209,8 +16712,14 @@ function buildGitLabIssuePayload(input) {
16209
16712
  }
16210
16713
  function resolveGitLabToken(options) {
16211
16714
  const env = options.env || process.env;
16715
+ if (options.tokenEnv) {
16716
+ const explicitToken = env[options.tokenEnv]?.trim();
16717
+ if (!explicitToken) {
16718
+ throw new Error(`GitLab token is required. Set ${options.tokenEnv}.`);
16719
+ }
16720
+ return explicitToken;
16721
+ }
16212
16722
  const candidates = [
16213
- options.tokenEnv ? env[options.tokenEnv] : void 0,
16214
16723
  env.GITLAB_TOKEN,
16215
16724
  env.GL_TOKEN,
16216
16725
  env.PRIVATE_TOKEN,
@@ -16218,8 +16727,7 @@ function resolveGitLabToken(options) {
16218
16727
  ];
16219
16728
  const token = candidates.find((candidate) => candidate?.trim());
16220
16729
  if (!token) {
16221
- const envHint = options.tokenEnv ? options.tokenEnv : "GITLAB_TOKEN";
16222
- throw new Error(`GitLab token is required. Set ${envHint}.`);
16730
+ throw new Error("GitLab token is required. Set GITLAB_TOKEN.");
16223
16731
  }
16224
16732
  return token.trim();
16225
16733
  }
@@ -16241,6 +16749,70 @@ async function createGitLabIssue(input, options) {
16241
16749
  });
16242
16750
  return response.data;
16243
16751
  }
16752
+ function lintIssueReportDraft(input) {
16753
+ const findings = [];
16754
+ const title = input.title?.trim() || "";
16755
+ const description = input.description?.trim() || "";
16756
+ if (!title) {
16757
+ findings.push({
16758
+ code: "issue.title.required",
16759
+ severity: "error",
16760
+ message: "Issue title is required."
16761
+ });
16762
+ } else if (title.length < 8) {
16763
+ findings.push({
16764
+ code: "issue.title.too_short",
16765
+ severity: "error",
16766
+ message: "Issue title must be specific enough to identify the bug."
16767
+ });
16768
+ }
16769
+ if (!description) {
16770
+ findings.push({
16771
+ code: "issue.description.required",
16772
+ severity: "error",
16773
+ message: "Issue description is required."
16774
+ });
16775
+ }
16776
+ for (const section of REQUIRED_ISSUE_SECTIONS) {
16777
+ const sectionPattern = new RegExp(`^#{2,3}\\s*${section}(?:\\s|$)`, "m");
16778
+ if (description && !sectionPattern.test(description)) {
16779
+ findings.push({
16780
+ code: "issue.description.missing_section",
16781
+ severity: "error",
16782
+ message: `Issue description must include section: ${section}.`
16783
+ });
16784
+ }
16785
+ }
16786
+ if (description && !/(bpmax-cli|node dist\/bin\.js|npm run|npx vitest|复现命令|最小步骤)/i.test(description)) {
16787
+ findings.push({
16788
+ code: "issue.description.missing_repro_evidence",
16789
+ severity: "error",
16790
+ message: "Issue description must include a reproduction command, minimal steps, or test evidence."
16791
+ });
16792
+ }
16793
+ if (description && /```(?:json)?\s*\{[\s\S]{1200,}\}\s*```/i.test(description)) {
16794
+ findings.push({
16795
+ code: "issue.description.large_raw_payload",
16796
+ severity: "error",
16797
+ message: "Issue description must summarize large raw payloads instead of pasting them."
16798
+ });
16799
+ }
16800
+ const combined = `${title}
16801
+ ${description}`;
16802
+ for (const secret of SECRET_PATTERNS) {
16803
+ if (secret.pattern.test(combined)) {
16804
+ findings.push({
16805
+ code: secret.code,
16806
+ severity: "error",
16807
+ message: secret.message
16808
+ });
16809
+ }
16810
+ }
16811
+ return {
16812
+ ok: findings.every((finding) => finding.severity !== "error"),
16813
+ findings
16814
+ };
16815
+ }
16244
16816
 
16245
16817
  // src/commands/issue.ts
16246
16818
  async function readDescription(options) {
@@ -16315,6 +16887,16 @@ function registerIssueCommands(program2, deps = {}) {
16315
16887
  };
16316
16888
  registerCreateLike("create");
16317
16889
  registerCreateLike("report");
16890
+ issue3.command("lint").description("Lint a bpmax-cli bug report draft before creating an issue").option("--title <title>", "Issue title").option("--description <text>", "Issue description").option("--description-file <file>", "Read issue description from a file").option("--format <format>", "Output format", "json").action(async (options) => {
16891
+ const result = lintIssueReportDraft({
16892
+ title: options.title,
16893
+ description: await readDescription(options)
16894
+ });
16895
+ printResult(options.format, result);
16896
+ if (!result.ok) {
16897
+ process.exitCode = 1;
16898
+ }
16899
+ });
16318
16900
  }
16319
16901
 
16320
16902
  // src/commands/memory.ts
@@ -18637,6 +19219,20 @@ function promptObjectLockText(text5) {
18637
19219
  function hasStrongListEvidence(value) {
18638
19220
  return /bpmax-cli config list-template lint/.test(value) && /(真实列表页|浏览器|runtime|E2E|渲染)/i.test(value);
18639
19221
  }
19222
+ function hasListDeletePermissionGuard(value) {
19223
+ const actionable = value.replace(/(?:禁止|不得|不要|避免)[^。;,\n|]*/gi, " ");
19224
+ if (/\$CAN_DELETE/i.test(actionable) || /project\.delete(?!\.my)/i.test(actionable)) {
19225
+ return true;
19226
+ }
19227
+ return /project\.delete\.my/i.test(actionable) && /__owner_id/i.test(actionable);
19228
+ }
19229
+ function hasForbiddenListDeleteStepGuard(value) {
19230
+ const actionable = value.replace(
19231
+ /(?:禁止|不得|不要|避免)[^。;\n|]{0,80}current_flow_step_(?:id|name)[^。;\n|]*/gi,
19232
+ " "
19233
+ );
19234
+ 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);
19235
+ }
18640
19236
  function validateTaskbookNavigationAndListGates(text5, issues) {
18641
19237
  const strategy = validateNavigationStrategy(text5, issues, "navigation_strategy", "\u4EFB\u52A1\u4E66");
18642
19238
  const rows = extractTaskRows(text5);
@@ -18674,6 +19270,8 @@ function validateTaskbookNavigationAndListGates(text5, issues) {
18674
19270
  });
18675
19271
  listRows.forEach((row) => {
18676
19272
  const taskId = row.task_id || "<unknown>";
19273
+ const evidenceText = `${row.evidence || ""} ${row.notes || ""}`;
19274
+ const writeMode = isWriteMode(row);
18677
19275
  if (!/list-template:(?:\d+|new-[A-Za-z0-9_-]+)/.test(row.object_lock || "")) {
18678
19276
  addTaskbookIssue(
18679
19277
  issues,
@@ -18692,6 +19290,24 @@ function validateTaskbookNavigationAndListGates(text5, issues) {
18692
19290
  { domain: "list-template", path: `tasks.${taskId}.evidence`, suggestion: "evidence \u5FC5\u987B\u5305\u542B bpmax-cli config list-template lint \u548C\u771F\u5B9E\u6D4F\u89C8\u5668\u5217\u8868\u9875 proof\u3002" }
18693
19291
  );
18694
19292
  }
19293
+ if (writeMode && !hasListDeletePermissionGuard(evidenceText)) {
19294
+ addTaskbookIssue(
19295
+ issues,
19296
+ "missing_list_delete_permission_guard",
19297
+ "taskbook.list.delete_permission_guard",
19298
+ `\u5217\u8868\u6A21\u677F\u4EFB\u52A1 ${taskId} \u7F3A\u5C11\u57FA\u4E8E ctx.$CAN_DELETE \u7684\u5220\u9664\u6743\u9650 guard \u8BF4\u660E\u3002`,
19299
+ { domain: "list-template", path: `tasks.${taskId}.notes`, suggestion: "\u5199\u660E\u5220\u9664\u6309\u94AE\u9996\u9009 ctx.$CAN_DELETE\uFF1B\u82E5\u663E\u5F0F\u5C55\u5F00 project.delete.my\uFF0C\u5FC5\u987B\u4F7F\u7528 ctx.__owner_id === ctx.$USER_INFO.id\uFF0C\u5E76\u9A8C\u8BC1\u5BF9\u5E94\u8EAB\u4EFD\u53EF\u5220\u9664\u3002" }
19300
+ );
19301
+ }
19302
+ if (writeMode && hasForbiddenListDeleteStepGuard(evidenceText)) {
19303
+ addTaskbookIssue(
19304
+ issues,
19305
+ "invalid_list_delete_step_guard",
19306
+ "taskbook.list.delete_step_guard",
19307
+ `\u5217\u8868\u6A21\u677F\u4EFB\u52A1 ${taskId} \u4E0D\u5F97\u8981\u6C42 current_flow_step_id/name \u4E3A\u7A7A\u540E\u624D\u5141\u8BB8\u5220\u9664\u3002`,
19308
+ { 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" }
19309
+ );
19310
+ }
18695
19311
  });
18696
19312
  }
18697
19313
  function rowText(row) {
@@ -18816,6 +19432,7 @@ function validatePromptNavigationAndListGates(text5, issues) {
18816
19432
  );
18817
19433
  }
18818
19434
  if (/bpmax-list-template-editor/.test(text5)) {
19435
+ const writeMode = isWriteMode(text5);
18819
19436
  if (!/list-template:(?:\d+|new-[A-Za-z0-9_-]+)/.test(objectLock)) {
18820
19437
  addTaskbookIssue(
18821
19438
  issues,
@@ -18834,6 +19451,24 @@ function validatePromptNavigationAndListGates(text5, issues) {
18834
19451
  { domain: "list-template", path: "prompt.evidence", suggestion: "\u5199\u660E bpmax-cli config list-template lint \u548C\u771F\u5B9E\u6D4F\u89C8\u5668\u5217\u8868\u9875 proof\u3002" }
18835
19452
  );
18836
19453
  }
19454
+ if (writeMode && !hasListDeletePermissionGuard(text5)) {
19455
+ addTaskbookIssue(
19456
+ issues,
19457
+ "missing_list_delete_permission_guard",
19458
+ "taskbook.list.delete_permission_guard",
19459
+ "Prompt \u4E2D\u7684\u5217\u8868\u6A21\u677F\u4EFB\u52A1\u5FC5\u987B\u8BF4\u660E\u57FA\u4E8E ctx.$CAN_DELETE \u7684\u5220\u9664\u6743\u9650 guard\u3002",
19460
+ { domain: "list-template", path: "prompt.constraints", suggestion: "\u5199\u660E ctx.$CAN_DELETE\uFF1B\u82E5\u663E\u5F0F\u5C55\u5F00 project.delete.my\uFF0C\u5FC5\u987B\u4F7F\u7528 ctx.__owner_id === ctx.$USER_INFO.id\uFF0C\u5E76\u8986\u76D6\u521B\u5EFA\u4EBA\u9A8C\u6536\u3002" }
19461
+ );
19462
+ }
19463
+ if (writeMode && hasForbiddenListDeleteStepGuard(text5)) {
19464
+ addTaskbookIssue(
19465
+ issues,
19466
+ "invalid_list_delete_step_guard",
19467
+ "taskbook.list.delete_step_guard",
19468
+ "Prompt \u4E2D\u7684\u5217\u8868\u6A21\u677F\u4EFB\u52A1\u4E0D\u5F97\u628A current_flow_step_id/name \u4E3A\u7A7A\u4F5C\u4E3A\u5220\u9664\u6761\u4EF6\u3002",
19469
+ { domain: "list-template", path: "prompt.constraints", suggestion: "\u6539\u7528 ctx.$CAN_DELETE\uFF0C\u72B6\u6001\u6761\u4EF6\u53EA\u80FD\u4F5C\u4E3A\u9644\u52A0\u9650\u5236\u3002" }
19470
+ );
19471
+ }
18837
19472
  }
18838
19473
  }
18839
19474
  function validatePromptConfigSkillGates(text5, issues) {
@@ -19028,7 +19663,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
19028
19663
  "|---|---|---|---|",
19029
19664
  "| \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 |",
19030
19665
  "| \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 |",
19031
- "| \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 guard\u3001icon\u3001\u67E5\u8BE2\u5B89\u5168\u3001\u771F\u5B9E\u5217\u8868\u9875 |",
19666
+ "| \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 |",
19032
19667
  "| \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 |",
19033
19668
  "",
19034
19669
  "## AI \u6700\u5C0F\u4EFB\u52A1\u5355\u5143",
@@ -19058,7 +19693,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
19058
19693
  "## \u9A8C\u6536\u95E8\u7981",
19059
19694
  "",
19060
19695
  "- \u914D\u7F6E\u5BF9\u8C61\u7EBF\u4E0A\u56DE\u8BFB\u901A\u8FC7\u3002",
19061
- "- \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\u5220\u9664\u53EF\u7528\u6027 guard\u3001icon \u5339\u914D\u548C\u67E5\u8BE2\u5B89\u5168\u3002",
19696
+ "- \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",
19062
19697
  "- \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",
19063
19698
  "- \u6D4F\u89C8\u5668 E2E \u9A8C\u8BC1\u901A\u8FC7\u3002",
19064
19699
  "- \u6D4B\u8BD5\u62A5\u544A\u548C\u622A\u56FE\u8BC1\u636E\u5B8C\u6574\u3002",