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

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.25",
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",
@@ -4652,42 +4654,277 @@ function validateFlowTemplateActionTarget(errors, pathName, target, nodeIds, con
4652
4654
  }
4653
4655
  }
4654
4656
  var FLOW_TEMPLATE_OWNER_AUTO_RANGE_TYPES = /* @__PURE__ */ new Set(["owner", "role", "user", "leader", "continuous_leader", "group", "fieldvalue", "matrix"]);
4657
+ var FLOW_TEMPLATE_LEADER_MATCH_METHODS = /* @__PURE__ */ new Set(["owner", "form"]);
4658
+ var FLOW_TEMPLATE_LEADER_SUPERIOR_TYPES = /* @__PURE__ */ new Set(["org", "direct"]);
4659
+ var FLOW_TEMPLATE_CONTINUOUS_DIRECTIONS = /* @__PURE__ */ new Set(["up", "down"]);
4660
+ var FLOW_TEMPLATE_RUNTIME_CC_TYPES = /* @__PURE__ */ new Set(["fieldvalue", "matrix"]);
4661
+ var FLOW_TEMPLATE_CC_TRIGGER_MODES = /* @__PURE__ */ new Set(["all", "approve", "refuse"]);
4662
+ var FLOW_TEMPLATE_CC_TRIGGER_TIMINGS = /* @__PURE__ */ new Set(["step_active", "step_finish"]);
4663
+ var FLOW_TEMPLATE_MATRIX_FLOW_PATTERN = /^[^:\s]+:[^:\s]*$/;
4664
+ function isPositiveIntegerLike(value) {
4665
+ if (typeof value !== "number" && typeof value !== "string") {
4666
+ return false;
4667
+ }
4668
+ if (typeof value === "string" && !value.trim()) {
4669
+ return false;
4670
+ }
4671
+ const numericValue = Number(value);
4672
+ return Number.isInteger(numericValue) && numericValue > 0;
4673
+ }
4674
+ function isNonEmptyFlowTemplateIdentifier(value) {
4675
+ if (typeof value === "number") {
4676
+ return Number.isFinite(value) && value > 0;
4677
+ }
4678
+ return typeof value === "string" && Boolean(value.trim());
4679
+ }
4680
+ function isValidFlowTemplateRoleCount(value) {
4681
+ return value === void 0 || value === null || value === "" || value === false || value === true || value === 0 || value === "all" || isPositiveIntegerLike(value);
4682
+ }
4683
+ function isUsableFlowTemplateScript(value) {
4684
+ if (typeof value !== "string" || !value.trim()) {
4685
+ return false;
4686
+ }
4687
+ const withoutComments = value.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/\/\/[^\r\n]*/g, " ").trim();
4688
+ if (!withoutComments) {
4689
+ return false;
4690
+ }
4691
+ const normalized = withoutComments.replace(/\s+/g, " ").replace(/^(?:debugger\s*;\s*)+/i, "").replace(/;+\s*$/, "").trim();
4692
+ return !(/^(?:todo|tbd|placeholder|not implemented)$/i.test(normalized) || /^return\s+(?:(?:await\s+)?Promise\.resolve\s*\(\s*)?(?:\[\]|\{\}|null|undefined)(?:\s*\))?$/i.test(normalized) || /^return\s+(?:new\s+)?Array\s*\(\s*\)$/i.test(normalized) || /^throw\s+new\s+error\s*\(\s*['"`](?:todo|tbd|placeholder|not implemented)[^'"`]*['"`]\s*\)$/i.test(normalized));
4693
+ }
4694
+ function validateFlowTemplateMatrixConfig(value, pathName, errors) {
4695
+ if (!isRecord3(value)) {
4696
+ errors.push(`${pathName} is required and must be an object.`);
4697
+ return;
4698
+ }
4699
+ const flow = typeof value.flow === "string" ? value.flow.trim() : "";
4700
+ if (!FLOW_TEMPLATE_MATRIX_FLOW_PATTERN.test(flow)) {
4701
+ errors.push(`${pathName}.flow must use "flow_type:flow_key" format.`);
4702
+ }
4703
+ if (!isUsableFlowTemplateScript(value.script)) {
4704
+ errors.push(`${pathName}.script must be a non-placeholder script.`);
4705
+ }
4706
+ }
4707
+ function validateFlowTemplateLeaderRule(rawRule, pathName, errors) {
4708
+ if (!isRecord3(rawRule)) {
4709
+ errors.push(`${pathName} must be an object.`);
4710
+ return;
4711
+ }
4712
+ const matchMethod = typeof rawRule.match_method === "string" ? rawRule.match_method.trim() : "";
4713
+ if (!FLOW_TEMPLATE_LEADER_MATCH_METHODS.has(matchMethod)) {
4714
+ errors.push(`${pathName}.match_method must be owner or form.`);
4715
+ } else if (matchMethod === "owner" && (typeof rawRule.step_id !== "string" || !rawRule.step_id.trim())) {
4716
+ errors.push(`${pathName}.step_id is required when match_method is owner.`);
4717
+ } else if (matchMethod === "form") {
4718
+ if (typeof rawRule.form_source_type !== "string" || !rawRule.form_source_type.trim()) {
4719
+ errors.push(`${pathName}.form_source_type is required when match_method is form.`);
4720
+ }
4721
+ if (typeof rawRule.form_field_key !== "string" || !rawRule.form_field_key.trim()) {
4722
+ errors.push(`${pathName}.form_field_key is required when match_method is form.`);
4723
+ }
4724
+ }
4725
+ const superiorType = typeof rawRule.superior_type === "string" ? rawRule.superior_type.trim() : "";
4726
+ if (!FLOW_TEMPLATE_LEADER_SUPERIOR_TYPES.has(superiorType)) {
4727
+ errors.push(`${pathName}.superior_type must be org or direct.`);
4728
+ }
4729
+ const levelsUp = Number(rawRule.levels_up);
4730
+ if (!isPositiveIntegerLike(rawRule.levels_up) || levelsUp > 20) {
4731
+ errors.push(`${pathName}.levels_up must be an integer from 1 to 20.`);
4732
+ }
4733
+ if (rawRule.max_levels_up !== void 0) {
4734
+ const maxLevelsUp = Number(rawRule.max_levels_up);
4735
+ if (!isPositiveIntegerLike(rawRule.max_levels_up) || maxLevelsUp > 20) {
4736
+ errors.push(`${pathName}.max_levels_up must be an integer from 1 to 20 when provided.`);
4737
+ } else if (Number.isFinite(levelsUp) && maxLevelsUp < levelsUp) {
4738
+ errors.push(`${pathName}.max_levels_up must be greater than or equal to levels_up.`);
4739
+ }
4740
+ }
4741
+ }
4742
+ function validateFlowTemplateLeaderRules(node, nodeName, errors) {
4743
+ if (Array.isArray(node.leader_rules) && node.leader_rules.length) {
4744
+ node.leader_rules.forEach((rawRule, ruleIndex) => {
4745
+ validateFlowTemplateLeaderRule(rawRule, `${nodeName}.leader_rules[${ruleIndex}]`, errors);
4746
+ });
4747
+ return;
4748
+ }
4749
+ const hasLegacyLeaderConfig = Boolean(
4750
+ node.leader_match_method || node.auto_range_by_step_owner_group_leader || node.leader_form_source_type || node.leader_form_field_key || node.leader_superior_type || node.leader_levels_up || node.leader_max_levels_up
4751
+ );
4752
+ if (!hasLegacyLeaderConfig) {
4753
+ errors.push(`${nodeName}.leader_rules or legacy leader_* config is required when auto_range_type is leader.`);
4754
+ return;
4755
+ }
4756
+ validateFlowTemplateLeaderRule(
4757
+ {
4758
+ match_method: node.leader_match_method || "owner",
4759
+ step_id: node.auto_range_by_step_owner_group_leader,
4760
+ form_source_type: node.leader_form_source_type,
4761
+ form_field_key: node.leader_form_field_key,
4762
+ superior_type: node.leader_superior_type || "org",
4763
+ levels_up: node.leader_levels_up || 1,
4764
+ max_levels_up: node.leader_max_levels_up
4765
+ },
4766
+ `${nodeName}.legacy_leader_config`,
4767
+ errors
4768
+ );
4769
+ }
4770
+ function validateFlowTemplateContinuousLeader(node, nodeName, errors) {
4771
+ const matchMethod = typeof node.continuous_match_method === "string" ? node.continuous_match_method.trim() : "";
4772
+ if (!FLOW_TEMPLATE_LEADER_MATCH_METHODS.has(matchMethod)) {
4773
+ errors.push(`${nodeName}.continuous_match_method must be owner or form when auto_range_type is continuous_leader.`);
4774
+ } else if (matchMethod === "owner" && (typeof node.continuous_step_id !== "string" || !node.continuous_step_id.trim())) {
4775
+ errors.push(`${nodeName}.continuous_step_id is required when continuous_match_method is owner.`);
4776
+ } else if (matchMethod === "form") {
4777
+ if (typeof node.continuous_form_source_type !== "string" || !node.continuous_form_source_type.trim()) {
4778
+ errors.push(`${nodeName}.continuous_form_source_type is required when continuous_match_method is form.`);
4779
+ }
4780
+ if (typeof node.continuous_form_field_key !== "string" || !node.continuous_form_field_key.trim()) {
4781
+ errors.push(`${nodeName}.continuous_form_field_key is required when continuous_match_method is form.`);
4782
+ }
4783
+ }
4784
+ const superiorType = typeof node.continuous_superior_type === "string" ? node.continuous_superior_type.trim() : "";
4785
+ if (!FLOW_TEMPLATE_LEADER_SUPERIOR_TYPES.has(superiorType)) {
4786
+ errors.push(`${nodeName}.continuous_superior_type must be org or direct.`);
4787
+ }
4788
+ const matchDirection = typeof node.continuous_match_direction === "string" ? node.continuous_match_direction.trim() : "";
4789
+ if (!FLOW_TEMPLATE_CONTINUOUS_DIRECTIONS.has(matchDirection)) {
4790
+ errors.push(`${nodeName}.continuous_match_direction must be up or down.`);
4791
+ }
4792
+ const terminationType = typeof node.continuous_termination_type === "string" ? node.continuous_termination_type.trim() : "";
4793
+ const allowedTerminationTypes = matchDirection === "up" ? /* @__PURE__ */ new Set(["direct", "level"]) : matchDirection === "down" ? /* @__PURE__ */ new Set(["top", "level"]) : /* @__PURE__ */ new Set();
4794
+ if (!allowedTerminationTypes.has(terminationType)) {
4795
+ errors.push(
4796
+ `${nodeName}.continuous_termination_type must be ${matchDirection === "down" ? "top or level" : "direct or level"} for the configured continuous_match_direction.`
4797
+ );
4798
+ }
4799
+ if (terminationType === "level") {
4800
+ const levelCount = Number(node.continuous_termination_level_count);
4801
+ if (!isPositiveIntegerLike(node.continuous_termination_level_count) || levelCount > 20) {
4802
+ errors.push(`${nodeName}.continuous_termination_level_count must be an integer from 1 to 20 when termination type is level.`);
4803
+ }
4804
+ }
4805
+ }
4806
+ function validateFlowTemplateCcShape(node, nodeName, errors) {
4807
+ if (node.cc_type !== void 0 && typeof node.cc_type !== "string") {
4808
+ errors.push(`${nodeName}.cc_type must be a string when provided.`);
4809
+ }
4810
+ const ccType = typeof node.cc_type === "string" ? node.cc_type.trim() : "";
4811
+ if (ccType && !FLOW_TEMPLATE_RUNTIME_CC_TYPES.has(ccType)) {
4812
+ errors.push(
4813
+ `${nodeName}.cc_type must be fieldvalue or matrix; the server CC runtime does not execute role or user configurations.`
4814
+ );
4815
+ }
4816
+ if (ccType === "fieldvalue" && !isUsableFlowTemplateScript(node.cc_user_by_script)) {
4817
+ errors.push(`${nodeName}.cc_user_by_script must be a non-placeholder script when cc_type is fieldvalue.`);
4818
+ }
4819
+ if (ccType === "matrix") {
4820
+ validateFlowTemplateMatrixConfig(node.cc_matrix, `${nodeName}.cc_matrix`, errors);
4821
+ }
4822
+ const triggerMode = typeof node.cc_trigger_mode === "string" ? node.cc_trigger_mode.trim() : "";
4823
+ if (ccType && node.cc_trigger_mode !== void 0) {
4824
+ if (!FLOW_TEMPLATE_CC_TRIGGER_MODES.has(triggerMode)) {
4825
+ errors.push(`${nodeName}.cc_trigger_mode must be all, approve, or refuse when provided.`);
4826
+ }
4827
+ }
4828
+ let normalizedTimings;
4829
+ if (node.cc_trigger_timing !== void 0) {
4830
+ if (!Array.isArray(node.cc_trigger_timing)) {
4831
+ errors.push(`${nodeName}.cc_trigger_timing must be an array containing only step_active or step_finish.`);
4832
+ } else {
4833
+ normalizedTimings = [];
4834
+ node.cc_trigger_timing.forEach((timing, timingIndex) => {
4835
+ if (typeof timing !== "string" || !FLOW_TEMPLATE_CC_TRIGGER_TIMINGS.has(timing.trim())) {
4836
+ errors.push(`${nodeName}.cc_trigger_timing[${timingIndex}] must be step_active or step_finish.`);
4837
+ } else {
4838
+ normalizedTimings?.push(timing.trim());
4839
+ }
4840
+ });
4841
+ if (ccType && !node.cc_trigger_timing.length) {
4842
+ errors.push(`${nodeName}.cc_trigger_timing must not be empty when cc_type is configured.`);
4843
+ }
4844
+ }
4845
+ }
4846
+ if (ccType && normalizedTimings?.includes("step_active") && (triggerMode === "approve" || triggerMode === "refuse")) {
4847
+ errors.push(
4848
+ `${nodeName}.cc_trigger_mode must be all when cc_trigger_timing includes step_active because no approval outcome exists at activation time.`
4849
+ );
4850
+ }
4851
+ }
4852
+ function validateFlowTemplateCompletionThreshold(value, pathName, errors) {
4853
+ if (value === void 0 || value === 0) {
4854
+ return false;
4855
+ }
4856
+ if (value === "all" || isPositiveIntegerLike(value)) {
4857
+ return true;
4858
+ }
4859
+ errors.push(`${pathName} must be 0, all, or a positive integer when provided.`);
4860
+ return false;
4861
+ }
4655
4862
  function validateFlowTemplateOwnerStrategyShape(node, nodeName, errors) {
4656
4863
  const rawType = typeof node.auto_range_type === "string" ? node.auto_range_type.trim() : "";
4864
+ validateFlowTemplateCcShape(node, nodeName, errors);
4865
+ const hasApproveThreshold = validateFlowTemplateCompletionThreshold(
4866
+ node.approve_count_required,
4867
+ `${nodeName}.approve_count_required`,
4868
+ errors
4869
+ );
4870
+ const hasDoneThreshold = validateFlowTemplateCompletionThreshold(
4871
+ node.done_count_required,
4872
+ `${nodeName}.done_count_required`,
4873
+ errors
4874
+ );
4875
+ if (hasApproveThreshold && hasDoneThreshold) {
4876
+ errors.push(`${nodeName}.approve_count_required and done_count_required cannot both define an effective completion threshold.`);
4877
+ }
4657
4878
  if (!rawType) return;
4658
4879
  if (!FLOW_TEMPLATE_OWNER_AUTO_RANGE_TYPES.has(rawType)) {
4659
4880
  errors.push(`${nodeName}.auto_range_type must be one of owner, role, user, leader, continuous_leader, group, fieldvalue, matrix.`);
4660
4881
  return;
4661
4882
  }
4662
- if (rawType === "owner" && typeof node.owner_is_creater !== "boolean") {
4663
- errors.push(`${nodeName}.owner_is_creater must be a boolean when auto_range_type is owner.`);
4883
+ if (rawType === "owner" && node.owner_is_creater !== true) {
4884
+ errors.push(`${nodeName}.owner_is_creater must be true when auto_range_type is owner.`);
4664
4885
  }
4665
- if (rawType === "role" && (!Array.isArray(node.owner_roles) || !node.owner_roles.length) && !node.auto_range_by_role) {
4666
- errors.push(`${nodeName}.owner_roles or auto_range_by_role is required when auto_range_type is role.`);
4886
+ if (rawType === "role") {
4887
+ if (!Array.isArray(node.owner_roles) || !node.owner_roles.length || node.owner_roles.some((role) => typeof role !== "string" || !role.trim())) {
4888
+ errors.push(`${nodeName}.owner_roles must be a non-empty array of role keys when auto_range_type is role.`);
4889
+ }
4890
+ if (!isValidFlowTemplateRoleCount(node.auto_range_by_role)) {
4891
+ errors.push(
4892
+ `${nodeName}.auto_range_by_role must be 0, false, true, all, or a positive integer when provided.`
4893
+ );
4894
+ }
4895
+ if (node.role_logic !== void 0 && node.role_logic !== "or" && node.role_logic !== "and") {
4896
+ errors.push(`${nodeName}.role_logic must be or or and when provided.`);
4897
+ }
4898
+ if (node.auto_range_by_role_range !== void 0) {
4899
+ if (typeof node.auto_range_by_role_range !== "string") {
4900
+ errors.push(`${nodeName}.auto_range_by_role_range must be a script string when provided.`);
4901
+ } else if (node.auto_range_by_role_range.trim() && !isUsableFlowTemplateScript(node.auto_range_by_role_range)) {
4902
+ errors.push(`${nodeName}.auto_range_by_role_range must be a non-placeholder script when provided.`);
4903
+ }
4904
+ }
4667
4905
  }
4668
- if (rawType === "user" && (!Array.isArray(node.auto_range_by_users) || !node.auto_range_by_users.length)) {
4669
- errors.push(`${nodeName}.auto_range_by_users must be a non-empty array when auto_range_type is user.`);
4906
+ if (rawType === "user" && (!Array.isArray(node.auto_range_by_users) || !node.auto_range_by_users.length || node.auto_range_by_users.some((user) => !isNonEmptyFlowTemplateIdentifier(user)))) {
4907
+ errors.push(`${nodeName}.auto_range_by_users must be a non-empty array of user ids when auto_range_type is user.`);
4670
4908
  }
4671
- if (rawType === "group" && (!Array.isArray(node.auto_range_by_groups) || !node.auto_range_by_groups.length)) {
4672
- errors.push(`${nodeName}.auto_range_by_groups must be a non-empty array when auto_range_type is group.`);
4909
+ if (rawType === "group") {
4910
+ if (!Array.isArray(node.auto_range_by_group) || !node.auto_range_by_group.length || node.auto_range_by_group.some((group) => !isNonEmptyFlowTemplateIdentifier(group))) {
4911
+ errors.push(`${nodeName}.auto_range_by_group must be a non-empty array of group ids when auto_range_type is group.`);
4912
+ }
4913
+ if (!isPositiveIntegerLike(node.auto_range_by_group_count)) {
4914
+ errors.push(`${nodeName}.auto_range_by_group_count must be a positive integer when auto_range_type is group.`);
4915
+ }
4673
4916
  }
4674
- if (rawType === "fieldvalue" && (typeof node.auto_range_by_script !== "string" || !node.auto_range_by_script.trim())) {
4675
- errors.push(`${nodeName}.auto_range_by_script is required when auto_range_type is fieldvalue.`);
4917
+ if (rawType === "fieldvalue" && !isUsableFlowTemplateScript(node.auto_range_by_script)) {
4918
+ errors.push(`${nodeName}.auto_range_by_script must be a non-placeholder script when auto_range_type is fieldvalue.`);
4676
4919
  }
4677
- if (rawType === "matrix" && !isRecord3(node.matrix_owner)) {
4678
- errors.push(`${nodeName}.matrix_owner is required when auto_range_type is matrix.`);
4920
+ if (rawType === "matrix") {
4921
+ validateFlowTemplateMatrixConfig(node.matrix_owner, `${nodeName}.matrix_owner`, errors);
4679
4922
  }
4680
4923
  if (rawType === "leader") {
4681
- const hasLegacyLeaderConfig = Boolean(node.leader_match_method || node.auto_range_by_step_owner_group_leader || node.leader_form_field_key || node.leader_rules);
4682
- if (!hasLegacyLeaderConfig) {
4683
- errors.push(`${nodeName}.leader_rules or leader_* config is required when auto_range_type is leader.`);
4684
- }
4924
+ validateFlowTemplateLeaderRules(node, nodeName, errors);
4685
4925
  }
4686
4926
  if (rawType === "continuous_leader") {
4687
- const hasContinuousConfig = Boolean(node.continuous_match_method || node.continuous_step_id || node.continuous_form_field_key);
4688
- if (!hasContinuousConfig) {
4689
- errors.push(`${nodeName}.continuous_* config is required when auto_range_type is continuous_leader.`);
4690
- }
4927
+ validateFlowTemplateContinuousLeader(node, nodeName, errors);
4691
4928
  }
4692
4929
  }
4693
4930
  function validateFlowTemplateApproveActionShape(value, errors) {
@@ -5564,37 +5801,44 @@ function findInlineIconClass(value) {
5564
5801
  }
5565
5802
  return findInlineIconClass(value.children);
5566
5803
  }
5567
- function listTemplateNodeGuardText(node) {
5804
+ function listTemplateGuardExpression(value) {
5805
+ if (isRecord3(value) && typeof value.$template === "string") {
5806
+ return value.$template.trim();
5807
+ }
5808
+ return textOf(value).trim();
5809
+ }
5810
+ function listTemplateNodeGuards(node) {
5568
5811
  const attribute = isRecord3(node.attribute) ? node.attribute : {};
5569
5812
  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(" ");
5813
+ const guards = [];
5814
+ [node.if, node.show, node.visible].forEach((value) => {
5815
+ const text5 = listTemplateGuardExpression(value);
5816
+ if (text5) guards.push({ kind: "visibility", text: text5 });
5817
+ });
5818
+ [node.disabled, props.disabled].forEach((value) => {
5819
+ const text5 = listTemplateGuardExpression(value);
5820
+ if (text5) guards.push({ kind: "disabled", text: text5 });
5821
+ });
5822
+ return guards;
5583
5823
  }
5584
- function collectListTemplateActionNodes(value, result = [], inheritedGuardText = "") {
5824
+ function collectListTemplateActionNodes(value, result = [], inheritedGuards = []) {
5585
5825
  if (Array.isArray(value)) {
5586
- value.forEach((item) => collectListTemplateActionNodes(item, result, inheritedGuardText));
5826
+ value.forEach((item) => collectListTemplateActionNodes(item, result, inheritedGuards));
5587
5827
  return result;
5588
5828
  }
5589
5829
  if (!isRecord3(value)) {
5590
5830
  return result;
5591
5831
  }
5592
5832
  const isValue = typeof value.is === "string" ? value.is.toLowerCase() : "";
5593
- const guardText = [inheritedGuardText, listTemplateNodeGuardText(value)].filter(Boolean).join(" ");
5833
+ const ownGuards = listTemplateNodeGuards(value);
5594
5834
  if (isValue.includes("button") || isValue.includes("dropdown-item")) {
5595
- result.push({ node: value, inheritedGuardText });
5835
+ result.push({ node: value, inheritedGuards });
5596
5836
  }
5597
- Object.values(value).forEach((item) => collectListTemplateActionNodes(item, result, guardText));
5837
+ const childGuards = [
5838
+ ...inheritedGuards,
5839
+ ...ownGuards.filter((guard) => guard.kind === "visibility")
5840
+ ];
5841
+ Object.values(value).forEach((item) => collectListTemplateActionNodes(item, result, childGuards));
5598
5842
  return result;
5599
5843
  }
5600
5844
  function isListTemplateOperationColumn(column) {
@@ -5637,14 +5881,349 @@ function iconMatchesAction(kind, icon) {
5637
5881
  }
5638
5882
  return true;
5639
5883
  }
5640
- function hasDeleteAvailabilityGuard(item) {
5641
- const guardText = [item.inheritedGuardText, listTemplateNodeGuardText(item.node)].filter(Boolean).join(" ");
5642
- if (!guardText.trim()) {
5884
+ function listTemplateDeleteGuards(item) {
5885
+ return [...item.inheritedGuards, ...listTemplateNodeGuards(item.node)];
5886
+ }
5887
+ function normalizeListTemplateGuardScript(text5) {
5888
+ return text5.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:])\/\/.*$/gm, "$1").trim();
5889
+ }
5890
+ function currentFlowStepReferencePattern() {
5891
+ return String.raw`(?:ctx(?:\.|\?\.)current_flow_step_(?:id|name)(?![\w$])|ctx\[\s*['"]current_flow_step_(?:id|name)['"]\s*\])`;
5892
+ }
5893
+ function currentFlowStepEmptyHelperPattern() {
5894
+ return String.raw`(?:(?:ctx\.)?(?:\$_?|\$lodash|lodash|_)(?:\.|\?\.))?(?:isEmpty|isNil)`;
5895
+ }
5896
+ function normalizeCurrentFlowStepGuardScript(text5) {
5897
+ const computedNormalized = normalizeListTemplateGuardScript(text5).replace(
5898
+ /ctx\[\s*(['"])(current_flow_step_(?:id|name))\1\s*\]/gi,
5899
+ "ctx.$2"
5900
+ );
5901
+ let result = "";
5902
+ let quote = "";
5903
+ for (let index = 0; index < computedNormalized.length; index += 1) {
5904
+ const char = computedNormalized[index];
5905
+ const previous = computedNormalized[index - 1];
5906
+ if (quote) {
5907
+ if (char === quote && previous !== "\\") {
5908
+ quote = "";
5909
+ result += char;
5910
+ } else {
5911
+ result += " ";
5912
+ }
5913
+ continue;
5914
+ }
5915
+ if (char === '"' || char === "'" || char === "`") {
5916
+ quote = char;
5917
+ }
5918
+ result += char;
5919
+ }
5920
+ return result;
5921
+ }
5922
+ function hasCurrentFlowStepAbsenceCheck(text5) {
5923
+ const normalized = normalizeCurrentFlowStepGuardScript(text5);
5924
+ const stepRef = currentFlowStepReferencePattern();
5925
+ const emptyHelper = currentFlowStepEmptyHelperPattern();
5926
+ const emptyValue = String.raw`(?:null|undefined|false|0|['"]{2})`;
5927
+ 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);
5928
+ }
5929
+ function hasCurrentFlowStepPresenceCheck(text5) {
5930
+ const normalized = normalizeCurrentFlowStepGuardScript(text5);
5931
+ const stepRef = currentFlowStepReferencePattern();
5932
+ const emptyHelper = currentFlowStepEmptyHelperPattern();
5933
+ const emptyValue = String.raw`(?:null|undefined|false|0|['"]{2})`;
5934
+ 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);
5935
+ }
5936
+ function normalizeListTemplateGuardTerm(text5) {
5937
+ let normalized = normalizeListTemplateGuardScript(text5).replace(/^\s*return\b/i, "").replace(/^[\s{;]+|[\s};]+$/g, "").trim();
5938
+ const hasBalancedOuterParentheses = () => {
5939
+ if (!normalized.startsWith("(") || !normalized.endsWith(")")) {
5940
+ return false;
5941
+ }
5942
+ let depth = 0;
5943
+ let quote = "";
5944
+ for (let index = 0; index < normalized.length; index += 1) {
5945
+ const char = normalized[index];
5946
+ const previous = normalized[index - 1];
5947
+ if (quote) {
5948
+ if (char === quote && previous !== "\\") quote = "";
5949
+ continue;
5950
+ }
5951
+ if (char === '"' || char === "'" || char === "`") {
5952
+ quote = char;
5953
+ continue;
5954
+ }
5955
+ if (char === "(") depth += 1;
5956
+ if (char === ")") depth -= 1;
5957
+ if (depth === 0 && index < normalized.length - 1) return false;
5958
+ if (depth < 0) return false;
5959
+ }
5960
+ return depth === 0;
5961
+ };
5962
+ while (hasBalancedOuterParentheses()) {
5963
+ normalized = normalized.slice(1, -1).trim();
5964
+ }
5965
+ return normalized;
5966
+ }
5967
+ function normalizeListTemplateAtomicGuardTerm(text5) {
5968
+ let normalized = normalizeListTemplateGuardTerm(text5);
5969
+ const balance = () => {
5970
+ return [...normalized].reduce((result, char) => {
5971
+ if (char === "(") return result + 1;
5972
+ if (char === ")") return result - 1;
5973
+ return result;
5974
+ }, 0);
5975
+ };
5976
+ while (normalized.startsWith("(") && balance() > 0) {
5977
+ normalized = normalized.slice(1).trim();
5978
+ }
5979
+ while (normalized.endsWith(")") && balance() < 0) {
5980
+ normalized = normalized.slice(0, -1).trim();
5981
+ }
5982
+ return normalized;
5983
+ }
5984
+ function splitTopLevelListTemplateBoolean(text5, operator) {
5985
+ const normalized = normalizeListTemplateGuardTerm(text5);
5986
+ const result = [];
5987
+ let current = "";
5988
+ let depth = 0;
5989
+ let quote = "";
5990
+ for (let index = 0; index < normalized.length; index += 1) {
5991
+ const char = normalized[index];
5992
+ const previous = normalized[index - 1];
5993
+ if (quote) {
5994
+ current += char;
5995
+ if (char === quote && previous !== "\\") quote = "";
5996
+ continue;
5997
+ }
5998
+ if (char === '"' || char === "'" || char === "`") {
5999
+ quote = char;
6000
+ current += char;
6001
+ continue;
6002
+ }
6003
+ if (char === "(" || char === "[" || char === "{") depth += 1;
6004
+ if (char === ")" || char === "]" || char === "}") depth -= 1;
6005
+ if (depth === 0 && normalized.slice(index, index + operator.length) === operator) {
6006
+ if (current.trim()) result.push(current.trim());
6007
+ current = "";
6008
+ index += operator.length - 1;
6009
+ continue;
6010
+ }
6011
+ current += char;
6012
+ }
6013
+ if (current.trim()) result.push(current.trim());
6014
+ return result;
6015
+ }
6016
+ function hasTopLevelListTemplateCharacter(text5, target) {
6017
+ const normalized = normalizeListTemplateGuardTerm(text5);
6018
+ let depth = 0;
6019
+ let quote = "";
6020
+ for (let index = 0; index < normalized.length; index += 1) {
6021
+ const char = normalized[index];
6022
+ const previous = normalized[index - 1];
6023
+ if (quote) {
6024
+ if (char === quote && previous !== "\\") quote = "";
6025
+ continue;
6026
+ }
6027
+ if (char === '"' || char === "'" || char === "`") {
6028
+ quote = char;
6029
+ continue;
6030
+ }
6031
+ if (char === "(" || char === "[" || char === "{") depth += 1;
6032
+ if (char === ")" || char === "]" || char === "}") depth -= 1;
6033
+ if (depth === 0 && char === target) return true;
6034
+ }
6035
+ return false;
6036
+ }
6037
+ function singleListTemplateGuardExpression(text5) {
6038
+ const removeLeadingTrivia = (value) => {
6039
+ let result = value;
6040
+ let previous = "";
6041
+ while (result !== previous) {
6042
+ previous = result;
6043
+ result = result.replace(/^[\s\uFEFF]+/, "");
6044
+ if (result.startsWith("//")) {
6045
+ result = result.replace(/^\/\/[^\r\n\u2028\u2029]*(?:\r\n?|\n|\u2028|\u2029|$)/, "");
6046
+ } else if (result.startsWith("/*")) {
6047
+ result = result.replace(/^\/\*[\s\S]*?\*\//, "");
6048
+ }
6049
+ }
6050
+ return result;
6051
+ };
6052
+ const removeTrailingTrivia = (value) => {
6053
+ let index = 0;
6054
+ let lastSignificantEnd = 0;
6055
+ while (index < value.length) {
6056
+ const char = value[index];
6057
+ if (/^[\s\uFEFF]$/.test(char)) {
6058
+ index += 1;
6059
+ continue;
6060
+ }
6061
+ if (char === "/" && value[index + 1] === "/") {
6062
+ const lineEnd = value.slice(index + 2).search(/[\r\n\u2028\u2029]/);
6063
+ index = lineEnd < 0 ? value.length : index + 2 + lineEnd + 1;
6064
+ continue;
6065
+ }
6066
+ if (char === "/" && value[index + 1] === "*") {
6067
+ const commentEnd = value.indexOf("*/", index + 2);
6068
+ if (commentEnd < 0) {
6069
+ return value;
6070
+ }
6071
+ index = commentEnd + 2;
6072
+ continue;
6073
+ }
6074
+ if (char === '"' || char === "'" || char === "`") {
6075
+ const quote = char;
6076
+ index += 1;
6077
+ while (index < value.length) {
6078
+ if (value[index] === "\\") {
6079
+ index += 2;
6080
+ continue;
6081
+ }
6082
+ if (value[index] === quote) {
6083
+ index += 1;
6084
+ break;
6085
+ }
6086
+ index += 1;
6087
+ }
6088
+ lastSignificantEnd = index;
6089
+ continue;
6090
+ }
6091
+ index += 1;
6092
+ lastSignificantEnd = index;
6093
+ }
6094
+ return value.slice(0, lastSignificantEnd);
6095
+ };
6096
+ let rawScript = removeLeadingTrivia(removeTrailingTrivia(text5));
6097
+ if (rawScript.startsWith("{") && rawScript.endsWith("}")) {
6098
+ rawScript = removeLeadingTrivia(rawScript.slice(1, -1).trim());
6099
+ }
6100
+ const rawReturn = rawScript.match(/^return\b([\s\S]*)/i);
6101
+ if (rawReturn) {
6102
+ 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] || "";
6103
+ if (/[\r\n\u2028\u2029]/.test(trivia)) return null;
6104
+ }
6105
+ let script = normalizeListTemplateGuardScript(text5).trim();
6106
+ if (script.startsWith("{") && script.endsWith("}")) {
6107
+ script = script.slice(1, -1).trim();
6108
+ }
6109
+ const returnCount = script.match(/\breturn\b/gi)?.length || 0;
6110
+ if (returnCount > 1) return null;
6111
+ if (returnCount === 1) {
6112
+ if (!/^return\b/i.test(script)) return null;
6113
+ script = script.replace(/^return\b/i, "").trim();
6114
+ }
6115
+ script = script.replace(/;\s*$/, "").trim();
6116
+ if (!script || /\breturn\b/i.test(script) || hasTopLevelListTemplateCharacter(script, ";")) {
6117
+ return null;
6118
+ }
6119
+ return script;
6120
+ }
6121
+ function isPositiveCanDeleteTerm(text5) {
6122
+ const term = normalizeListTemplateAtomicGuardTerm(text5);
6123
+ return /^(?:ctx\.)?\$CAN_DELETE(?:\s*={2,3}\s*true)?$/i.test(term) || /^true\s*={2,3}\s*(?:ctx\.)?\$CAN_DELETE$/i.test(term);
6124
+ }
6125
+ function isNegatedCanDeleteTerm(text5) {
6126
+ const term = normalizeListTemplateAtomicGuardTerm(text5);
6127
+ 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);
6128
+ }
6129
+ function flowPermissionCallPattern(permission) {
6130
+ const escapedPermission = permission.replace(".", String.raw`\.`);
6131
+ return String.raw`(?:ctx\.)?\$canInFlow\s*\(\s*['"]${escapedPermission}['"]\s*\)`;
6132
+ }
6133
+ function isPositiveFlowPermissionTerm(text5, permission) {
6134
+ const term = normalizeListTemplateAtomicGuardTerm(text5);
6135
+ const call = flowPermissionCallPattern(permission);
6136
+ 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);
6137
+ }
6138
+ function isNegatedFlowPermissionTerm(text5, permission) {
6139
+ const term = normalizeListTemplateAtomicGuardTerm(text5);
6140
+ const call = flowPermissionCallPattern(permission);
6141
+ 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);
6142
+ }
6143
+ function isOwnerIdentityEqualityTerm(text5) {
6144
+ const term = normalizeListTemplateAtomicGuardTerm(text5);
6145
+ const ownerRef = String.raw`(?:ctx\.)?__owner_id`;
6146
+ const userRef = String.raw`(?:ctx\.)?(?:\$USER_INFO|userInfo)(?:\?\.|\.)id`;
6147
+ 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);
6148
+ }
6149
+ function hasPositiveDeletePermission(text5) {
6150
+ if (hasTopLevelListTemplateCharacter(text5, ",")) {
6151
+ return false;
6152
+ }
6153
+ const terms = splitTopLevelListTemplateBoolean(text5, "&&");
6154
+ return terms.some(isPositiveCanDeleteTerm) || terms.some((term) => isPositiveFlowPermissionTerm(term, "project.delete")) || terms.some((term) => isPositiveFlowPermissionTerm(term, "project.delete.my")) && terms.some(isOwnerIdentityEqualityTerm);
6155
+ }
6156
+ function isNegatedMyOwnerExpression(text5) {
6157
+ const term = normalizeListTemplateGuardTerm(text5);
6158
+ if (!term.startsWith("!(") || !term.endsWith(")")) {
5643
6159
  return false;
5644
6160
  }
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;
6161
+ const inner = term.slice(2, -1);
6162
+ const branches = splitTopLevelListTemplateBoolean(inner, "||");
6163
+ return branches.length > 0 && branches.every(hasPositiveDeletePermission);
6164
+ }
6165
+ function hasNegatedDeletePermission(text5) {
6166
+ const term = normalizeListTemplateGuardTerm(text5);
6167
+ return isNegatedCanDeleteTerm(term) || isNegatedFlowPermissionTerm(term, "project.delete") || isNegatedMyOwnerExpression(term);
6168
+ }
6169
+ function hasUnsupportedPermissionGuardShape(text5) {
6170
+ const expression = singleListTemplateGuardExpression(text5);
6171
+ if (!expression) return true;
6172
+ const normalized = normalizeListTemplateGuardScript(expression);
6173
+ return /(?:^|[;{}])\s*return\s*['"`]/i.test(normalized) || /\?/.test(normalized) && /:/.test(normalized);
6174
+ }
6175
+ function visibilityBranchHasConstantFalseTerm(branch) {
6176
+ return splitTopLevelListTemplateBoolean(branch, "&&").some((term) => {
6177
+ const normalizedTerm = term.replace(/\breturn\b/gi, "").replace(/[(){};\s]/g, "");
6178
+ return /^(?:false|null|undefined|0|!true)$/i.test(normalizedTerm);
6179
+ });
6180
+ }
6181
+ function isAlwaysFalseVisibilityGuard(text5) {
6182
+ const expression = singleListTemplateGuardExpression(text5);
6183
+ if (!expression) return false;
6184
+ const branches = splitTopLevelListTemplateBoolean(expression, "||");
6185
+ return branches.length > 0 && branches.every(visibilityBranchHasConstantFalseTerm);
6186
+ }
6187
+ function hasSafeVisibilityDeletePermission(text5) {
6188
+ const expression = singleListTemplateGuardExpression(text5);
6189
+ if (!expression || hasUnsupportedPermissionGuardShape(expression) || hasTopLevelListTemplateCharacter(expression, ",")) {
6190
+ return false;
6191
+ }
6192
+ const branches = splitTopLevelListTemplateBoolean(expression, "||");
6193
+ return branches.length > 0 && branches.every((branch) => {
6194
+ return !visibilityBranchHasConstantFalseTerm(branch) && hasPositiveDeletePermission(branch);
6195
+ });
6196
+ }
6197
+ function hasSafeDisabledDeletePermission(text5) {
6198
+ const expression = singleListTemplateGuardExpression(text5);
6199
+ if (!expression || hasUnsupportedPermissionGuardShape(expression) || hasTopLevelListTemplateCharacter(expression, ",")) {
6200
+ return false;
6201
+ }
6202
+ return splitTopLevelListTemplateBoolean(expression, "||").some((branch) => isNegatedMyOwnerExpression(branch) || !branch.includes("&&") && hasNegatedDeletePermission(branch));
6203
+ }
6204
+ function validateDeletePermissionGuard(item, errors) {
6205
+ const guards = listTemplateDeleteGuards(item);
6206
+ const visibilityGuards = guards.filter((guard) => guard.kind === "visibility");
6207
+ const disabledGuards = guards.filter((guard) => guard.kind === "disabled");
6208
+ if (visibilityGuards.some((guard) => hasCurrentFlowStepAbsenceCheck(guard.text)) || disabledGuards.some((guard) => hasCurrentFlowStepPresenceCheck(guard.text))) {
6209
+ 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.");
6210
+ }
6211
+ if (visibilityGuards.some((guard) => {
6212
+ return splitTopLevelListTemplateBoolean(guard.text, "||").some((branch) => hasNegatedDeletePermission(branch));
6213
+ })) {
6214
+ errors.push("list-template delete visibility guard must allow authorized users; do not negate ctx.$CAN_DELETE.");
6215
+ }
6216
+ if (visibilityGuards.some((guard) => isAlwaysFalseVisibilityGuard(guard.text))) {
6217
+ errors.push("list-template delete visibility guard must not be an always-false expression.");
6218
+ }
6219
+ if (disabledGuards.some((guard) => hasPositiveDeletePermission(guard.text) && !hasSafeDisabledDeletePermission(guard.text))) {
6220
+ errors.push("list-template delete disabled guard must negate the permission check, for example return !ctx.$CAN_DELETE.");
6221
+ }
6222
+ const hasVisibilityPermission = visibilityGuards.some((guard) => hasSafeVisibilityDeletePermission(guard.text));
6223
+ const hasDisabledPermission = disabledGuards.some((guard) => hasSafeDisabledDeletePermission(guard.text));
6224
+ if (!hasVisibilityPermission && !hasDisabledPermission) {
6225
+ 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.");
6226
+ }
5648
6227
  }
5649
6228
  function validateListTemplateActionGate(value, errors) {
5650
6229
  const nextErrors = [];
@@ -5683,9 +6262,7 @@ function validateListTemplateActionGate(value, errors) {
5683
6262
  nextErrors.push("list-template operation column must include a delete/remove action.");
5684
6263
  } else {
5685
6264
  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
- }
6265
+ validateDeletePermissionGuard(item, nextErrors);
5689
6266
  });
5690
6267
  }
5691
6268
  classified.filter((item) => item.kind !== "other").forEach((item) => {
@@ -8387,19 +8964,69 @@ async function readBackConfigDomain(profile, domain, id, definition) {
8387
8964
  readback_hash: hashJson(data)
8388
8965
  };
8389
8966
  }
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;
8967
+ function normalizeComparableId(value) {
8968
+ if (typeof value === "number" && Number.isFinite(value)) {
8969
+ return String(value);
8970
+ }
8971
+ if (typeof value === "string" && /^\d+$/.test(value.trim())) {
8972
+ return value.trim().replace(/^0+(?=\d)/, "");
8973
+ }
8974
+ return value;
8975
+ }
8976
+ function normalizeComparableFieldKeys(value) {
8977
+ if (!Array.isArray(value)) {
8978
+ return value;
8979
+ }
8980
+ const keys = value.flatMap((item) => {
8981
+ if (typeof item === "string" && item.trim()) {
8982
+ return [item.trim()];
8983
+ }
8984
+ if (isRecord3(item)) {
8985
+ const key = item.key ?? item.field;
8986
+ if (typeof key === "string" && key.trim()) {
8987
+ return [key.trim()];
8988
+ }
8989
+ }
8990
+ return [];
8991
+ });
8992
+ return [...new Set(keys)].sort();
8993
+ }
8994
+ function normalizeTypedReadbackComparable(domain, value) {
8995
+ let comparable2 = value;
8395
8996
  try {
8396
- expected = buildDomainSubmitPayload(domain, expectedSource);
8397
- actual = buildDomainSubmitPayload(domain, actualSource);
8997
+ comparable2 = buildDomainSubmitPayload(domain, value);
8398
8998
  } catch {
8399
8999
  }
8400
- assertJsonSubset(expected, actual, `${domain} submit`);
9000
+ if (!isRecord3(comparable2)) {
9001
+ return comparable2;
9002
+ }
9003
+ const normalized = { ...comparable2 };
9004
+ if (domain === "dataset") {
9005
+ normalized.refresh_setting = refreshSettingToSubmit(normalized.refresh_setting);
9006
+ const raw = isRecord3(value) ? value : {};
9007
+ normalized.fields = normalizeComparableFieldKeys(
9008
+ normalized.fields ?? raw.dataSetFields ?? raw.data_set_fields ?? raw.relationFields
9009
+ );
9010
+ }
9011
+ if (domain === "dataset-field") {
9012
+ normalized.data_set_id = normalizeComparableId(
9013
+ normalized.data_set_id ?? normalized.dataSetId ?? normalized.dataset_id
9014
+ );
9015
+ }
9016
+ if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "console-template") {
9017
+ if (Object.prototype.hasOwnProperty.call(normalized, "data_set_id")) {
9018
+ normalized.data_set_id = normalizeComparableId(normalized.data_set_id);
9019
+ }
9020
+ if (Object.prototype.hasOwnProperty.call(normalized, "flow_type")) {
9021
+ normalized.flow_type = normalized.flow_type ?? "";
9022
+ }
9023
+ if (Object.prototype.hasOwnProperty.call(normalized, "flow_key")) {
9024
+ normalized.flow_key = normalized.flow_key ?? "";
9025
+ }
9026
+ }
9027
+ return normalized;
8401
9028
  }
8402
- function assertJsonSubset(expected, actual, label) {
9029
+ function jsonSubsetMismatches(expected, actual) {
8403
9030
  const mismatches = [];
8404
9031
  const compare = (left, right, path16 = "") => {
8405
9032
  if (Array.isArray(left)) {
@@ -8407,7 +9034,7 @@ function assertJsonSubset(expected, actual, label) {
8407
9034
  mismatches.push(path16 || "/");
8408
9035
  return;
8409
9036
  }
8410
- left.forEach((value, index) => compare(value, right[index], `${path16}/${index}`));
9037
+ left.forEach((item, index) => compare(item, right[index], `${path16}/${index}`));
8411
9038
  return;
8412
9039
  }
8413
9040
  if (isRecord3(left)) {
@@ -8415,16 +9042,45 @@ function assertJsonSubset(expected, actual, label) {
8415
9042
  mismatches.push(path16 || "/");
8416
9043
  return;
8417
9044
  }
8418
- for (const [key, value] of Object.entries(left)) compare(value, right[key], `${path16}/${key}`);
9045
+ for (const [key, item] of Object.entries(left)) compare(item, right[key], `${path16}/${key}`);
8419
9046
  return;
8420
9047
  }
8421
9048
  if (JSON.stringify(left) !== JSON.stringify(right)) mismatches.push(path16 || "/");
8422
9049
  };
8423
9050
  compare(expected, actual);
9051
+ return mismatches;
9052
+ }
9053
+ function compareTypedReadback(domain, payload, readback) {
9054
+ const expectedSource = domain === "form-template" ? stripServerFilledFields(payload, FORM_TEMPLATE_SERVER_FIELD_KEYS) : payload;
9055
+ const actualSource = domain === "form-template" ? stripServerFilledFields(readback, FORM_TEMPLATE_SERVER_FIELD_KEYS) : readback;
9056
+ const expected = normalizeTypedReadbackComparable(domain, expectedSource);
9057
+ const actual = normalizeTypedReadbackComparable(domain, actualSource);
9058
+ const mismatches = jsonSubsetMismatches(expected, actual);
9059
+ return { ok: mismatches.length === 0, mismatches };
9060
+ }
9061
+ function assertExactTypedReadback(domain, payload, readback) {
9062
+ const comparison = compareTypedReadback(domain, payload, readback);
9063
+ if (!comparison.ok) {
9064
+ throw new Error(`${domain} submit readback mismatch: ${comparison.mismatches.slice(0, 10).join(", ")}.`);
9065
+ }
9066
+ }
9067
+ function assertJsonSubset(expected, actual, label) {
9068
+ const mismatches = jsonSubsetMismatches(expected, actual);
8424
9069
  if (mismatches.length > 0) {
8425
9070
  throw new Error(`${label} readback mismatch: ${mismatches.slice(0, 10).join(", ")}.`);
8426
9071
  }
8427
9072
  }
9073
+ function isPageTemplateCreateFinalizeDomain(domain) {
9074
+ return domain === "list-template" || domain === "filter-template" || domain === "project-detail-template";
9075
+ }
9076
+ function pageTemplateCreateNeedsFinalize(domain, payload, comparison) {
9077
+ if (!isPageTemplateCreateFinalizeDomain(domain)) {
9078
+ return false;
9079
+ }
9080
+ 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";
9081
+ const expectsFlowType = typeof payload.flow_type === "string" && payload.flow_type.trim() !== "";
9082
+ return expectsDataset && comparison.mismatches.includes("/data_set_id") || expectsFlowType && comparison.mismatches.includes("/flow_type");
9083
+ }
8428
9084
  async function readbackConfigDomain(config, profile, domain, id) {
8429
9085
  void config;
8430
9086
  const definition = CONFIG_DOMAINS[domain];
@@ -9357,24 +10013,76 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
9357
10013
  { data: submit.payload, capability: `${definition.capability}.create` }
9358
10014
  );
9359
10015
  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) {
10016
+ if (createdId === void 0 || createdId === null || createdId === "") {
9367
10017
  throw new Error(`${domain} create did not return an id required for exact typed readback.`);
9368
10018
  }
10019
+ let readbackHash = null;
10020
+ let readbackStatus = definition.exportPath ? "unavailable" : "verified";
10021
+ let readbackMismatches = [];
10022
+ let readbackError = null;
10023
+ let finalizeResponse = null;
10024
+ let finalizeAttempted = false;
10025
+ let finalizeWriteCompleted = false;
10026
+ if (definition.exportPath) {
10027
+ try {
10028
+ await ensureConfigCapability(profile, `${definition.capability}.export`);
10029
+ let createReadback = await readRemoteConfigDomain(profile, domain, String(createdId), definition);
10030
+ let comparison = compareTypedReadback(domain, submit.payload, createReadback);
10031
+ readbackHash = hashJson(createReadback);
10032
+ readbackMismatches = comparison.mismatches;
10033
+ readbackStatus = comparison.ok ? "verified" : "mismatch";
10034
+ if (!comparison.ok && pageTemplateCreateNeedsFinalize(domain, submit.payload, comparison)) {
10035
+ finalizeAttempted = true;
10036
+ await ensureConfigCapability(profile, `${definition.capability}.submit`);
10037
+ const finalizeEndpoint = definition.submitPath?.(String(createdId));
10038
+ if (!finalizeEndpoint || !definition.submitMethod) {
10039
+ throw new Error(`${domain} create requires a typed finalize endpoint for data_set_id/flow_type persistence.`);
10040
+ }
10041
+ finalizeResponse = await apiRequest(
10042
+ client2,
10043
+ definition.submitMethod,
10044
+ finalizeEndpoint,
10045
+ { data: submit.payload, capability: `${definition.capability}.submit` }
10046
+ );
10047
+ finalizeWriteCompleted = true;
10048
+ readbackHash = null;
10049
+ readbackMismatches = [];
10050
+ readbackStatus = "unavailable";
10051
+ createReadback = await readRemoteConfigDomain(profile, domain, String(createdId), definition);
10052
+ comparison = compareTypedReadback(domain, submit.payload, createReadback);
10053
+ readbackHash = hashJson(createReadback);
10054
+ readbackMismatches = comparison.mismatches;
10055
+ readbackStatus = comparison.ok ? "verified" : "mismatch";
10056
+ }
10057
+ } catch (error) {
10058
+ if (finalizeWriteCompleted || readbackStatus !== "mismatch") {
10059
+ readbackStatus = "unavailable";
10060
+ }
10061
+ readbackError = error instanceof Error ? error.message : String(error || "");
10062
+ }
10063
+ }
10064
+ const partialSuccess = readbackStatus !== "verified";
9369
10065
  return {
9370
10066
  ...executedFields(),
10067
+ status: partialSuccess ? "partial_success" : "success",
10068
+ partial_success: partialSuccess,
10069
+ readback_status: readbackStatus,
10070
+ requires_follow_up: partialSuccess,
9371
10071
  domain,
9372
10072
  ...standardConfigWriteResponse({ domain, id, executedId: createdId ?? null, payload: submit.payload, response: response2 }),
9373
10073
  created_id: createdId ?? null,
9374
10074
  endpoint: definition.createPath,
9375
10075
  method: definition.createMethod,
9376
10076
  response: response2,
9377
- readback_hash: readbackHash
10077
+ readback_hash: readbackHash,
10078
+ ...readbackMismatches.length ? { readback_mismatches: readbackMismatches.slice(0, 10) } : {},
10079
+ ...readbackError ? { readback_error: readbackError } : {},
10080
+ ...finalizeAttempted ? {
10081
+ finalize_attempted: true,
10082
+ finalize_write_completed: finalizeWriteCompleted,
10083
+ finalize_endpoint: definition.submitPath?.(String(createdId)) ?? null,
10084
+ finalize_response: finalizeResponse
10085
+ } : {}
9378
10086
  };
9379
10087
  }
9380
10088
  await ensureConfigCapability(profile, `${definition.capability}.submit`);
@@ -9741,8 +10449,10 @@ async function runConfigBatchSubmit(config, profile, manifestFile, options = {})
9741
10449
  }
9742
10450
  const response = await submitConfigDomain(config, profile, domain, id, payload, item.confirm);
9743
10451
  const executed = !isRecord3(response) || response.operation_executed !== false && response.dry_run !== true;
10452
+ const partialSuccess = isRecord3(response) && response.status === "partial_success";
9744
10453
  const result = executed ? {
9745
10454
  ok: true,
10455
+ status: partialSuccess ? "partial_success" : "success",
9746
10456
  index,
9747
10457
  domain,
9748
10458
  id,
@@ -9775,14 +10485,17 @@ async function runConfigBatchSubmit(config, profile, manifestFile, options = {})
9775
10485
  }
9776
10486
  }
9777
10487
  const failures = results.filter((item) => item.ok === false);
10488
+ const partial = results.filter((item) => item.status === "partial_success").length;
9778
10489
  return {
9779
10490
  ok: failures.length === 0,
10491
+ status: failures.length > 0 ? "failed" : partial > 0 ? "partial_success" : "success",
9780
10492
  manifest_file: manifestFile,
9781
10493
  action: "submit",
9782
10494
  continue_on_error: Boolean(options.continueOnError),
9783
10495
  total: items.length,
9784
10496
  completed: results.length,
9785
10497
  succeeded: results.length - failures.length,
10498
+ partial,
9786
10499
  failed: failures.length,
9787
10500
  results
9788
10501
  };
@@ -15824,13 +16537,29 @@ function assertProjectSearchBody(value) {
15824
16537
  );
15825
16538
  }
15826
16539
  }
16540
+ function withProjectListPagination(body, options) {
16541
+ const data = { ...body };
16542
+ if (options.pageExplicit || data.page === void 0) {
16543
+ data.page = Number(options.page);
16544
+ }
16545
+ if (options.pageSizeExplicit || data.page_size === void 0) {
16546
+ data.page_size = Number(options.pageSize);
16547
+ }
16548
+ return data;
16549
+ }
15827
16550
 
15828
16551
  // src/commands/es.ts
15829
16552
  function registerEsCommands(program2) {
15830
16553
  const es = program2.command("es").description("Fast ES-backed data queries");
15831
- es.command("project-search").description("Compatibility alias for project search through huanpingtong /api/project/list ES mode").option("--profile <profile>", "Profile name").option("--page <page>", "Page number for project-list payloads", "1").option("--page-size <pageSize>", "Page size for project-list payloads", "20").requiredOption("--body <json>", "Project list body JSON or @file").option("--format <format>", "Output format", "json").action(async (options) => {
16554
+ es.command("project-search").description("Compatibility alias for project search through huanpingtong /api/project/list ES mode").option("--profile <profile>", "Profile name").option("--page <page>", "Page number for project-list payloads", "1").option("--page-size <pageSize>", "Page size for project-list payloads", "20").requiredOption("--body <json>", "Project list body JSON or @file").option("--format <format>", "Output format", "json").action(async (options, command) => {
15832
16555
  const body = await parseJsonInput(options.body, "--body");
15833
16556
  assertProjectSearchBody(body);
16557
+ const data = withProjectListPagination(body, {
16558
+ page: options.page,
16559
+ pageSize: options.pageSize,
16560
+ pageExplicit: command.getOptionValueSource("page") === "cli",
16561
+ pageSizeExplicit: command.getOptionValueSource("pageSize") === "cli"
16562
+ });
15834
16563
  const config = await loadConfig();
15835
16564
  const profile = resolveProfile(config, options.profile);
15836
16565
  const client = createApiClient(profile);
@@ -15839,11 +16568,7 @@ function registerEsCommands(program2) {
15839
16568
  "POST",
15840
16569
  "/project/list",
15841
16570
  {
15842
- params: {
15843
- page: Number(options.page),
15844
- page_size: Number(options.pageSize)
15845
- },
15846
- data: body,
16571
+ data,
15847
16572
  preserveErrorBody: true,
15848
16573
  capability: "project.search"
15849
16574
  }
@@ -16174,6 +16899,31 @@ import { readFile as readFile13 } from "fs/promises";
16174
16899
  import axios7, { AxiosHeaders as AxiosHeaders3 } from "axios";
16175
16900
  var DEFAULT_GITLAB_URL = "https://gitlab.yitaiyitai.com";
16176
16901
  var DEFAULT_GITLAB_PROJECT = "bpmax/bpmax-cli";
16902
+ var REQUIRED_ISSUE_SECTIONS = [
16903
+ "\u73B0\u8C61",
16904
+ "\u590D\u73B0",
16905
+ "\u671F\u671B\u884C\u4E3A",
16906
+ "\u5B9E\u9645\u884C\u4E3A",
16907
+ "\u5F71\u54CD\u8303\u56F4",
16908
+ "\u5DF2\u9A8C\u8BC1\u6392\u9664\u9879"
16909
+ ];
16910
+ var SECRET_PATTERNS = [
16911
+ {
16912
+ code: "secret.env_assignment",
16913
+ pattern: /\b(?:GITLAB_TOKEN|GL_TOKEN|PRIVATE_TOKEN|API_KEY|BPMAX_EXECUTION_TOKEN)\s*[:=]\s*['"]?[^'"\s]+/i,
16914
+ message: "Issue draft must not include token or API key environment variable values."
16915
+ },
16916
+ {
16917
+ code: "secret.header",
16918
+ pattern: /\b(?:authorization|private-token|cookie|set-cookie)\b\s*[:=]\s*[^,\n\r]+/i,
16919
+ message: "Issue draft must not include authorization, private token, or cookie headers."
16920
+ },
16921
+ {
16922
+ code: "secret.token_like",
16923
+ pattern: /(?<!-)-[A-Za-z0-9_][A-Za-z0-9_-]{15,}\b/,
16924
+ message: "Issue draft contains a token-like value; replace it with a redacted placeholder."
16925
+ }
16926
+ ];
16177
16927
  function normalizeBaseUrl2(baseUrl = DEFAULT_GITLAB_URL) {
16178
16928
  const normalized = baseUrl.trim().replace(/\/+$/g, "");
16179
16929
  if (!normalized) {
@@ -16209,8 +16959,14 @@ function buildGitLabIssuePayload(input) {
16209
16959
  }
16210
16960
  function resolveGitLabToken(options) {
16211
16961
  const env = options.env || process.env;
16962
+ if (options.tokenEnv) {
16963
+ const explicitToken = env[options.tokenEnv]?.trim();
16964
+ if (!explicitToken) {
16965
+ throw new Error(`GitLab token is required. Set ${options.tokenEnv}.`);
16966
+ }
16967
+ return explicitToken;
16968
+ }
16212
16969
  const candidates = [
16213
- options.tokenEnv ? env[options.tokenEnv] : void 0,
16214
16970
  env.GITLAB_TOKEN,
16215
16971
  env.GL_TOKEN,
16216
16972
  env.PRIVATE_TOKEN,
@@ -16218,8 +16974,7 @@ function resolveGitLabToken(options) {
16218
16974
  ];
16219
16975
  const token = candidates.find((candidate) => candidate?.trim());
16220
16976
  if (!token) {
16221
- const envHint = options.tokenEnv ? options.tokenEnv : "GITLAB_TOKEN";
16222
- throw new Error(`GitLab token is required. Set ${envHint}.`);
16977
+ throw new Error("GitLab token is required. Set GITLAB_TOKEN.");
16223
16978
  }
16224
16979
  return token.trim();
16225
16980
  }
@@ -16241,6 +16996,70 @@ async function createGitLabIssue(input, options) {
16241
16996
  });
16242
16997
  return response.data;
16243
16998
  }
16999
+ function lintIssueReportDraft(input) {
17000
+ const findings = [];
17001
+ const title = input.title?.trim() || "";
17002
+ const description = input.description?.trim() || "";
17003
+ if (!title) {
17004
+ findings.push({
17005
+ code: "issue.title.required",
17006
+ severity: "error",
17007
+ message: "Issue title is required."
17008
+ });
17009
+ } else if (title.length < 8) {
17010
+ findings.push({
17011
+ code: "issue.title.too_short",
17012
+ severity: "error",
17013
+ message: "Issue title must be specific enough to identify the bug."
17014
+ });
17015
+ }
17016
+ if (!description) {
17017
+ findings.push({
17018
+ code: "issue.description.required",
17019
+ severity: "error",
17020
+ message: "Issue description is required."
17021
+ });
17022
+ }
17023
+ for (const section of REQUIRED_ISSUE_SECTIONS) {
17024
+ const sectionPattern = new RegExp(`^#{2,3}\\s*${section}(?:\\s|$)`, "m");
17025
+ if (description && !sectionPattern.test(description)) {
17026
+ findings.push({
17027
+ code: "issue.description.missing_section",
17028
+ severity: "error",
17029
+ message: `Issue description must include section: ${section}.`
17030
+ });
17031
+ }
17032
+ }
17033
+ if (description && !/(bpmax-cli|node dist\/bin\.js|npm run|npx vitest|复现命令|最小步骤)/i.test(description)) {
17034
+ findings.push({
17035
+ code: "issue.description.missing_repro_evidence",
17036
+ severity: "error",
17037
+ message: "Issue description must include a reproduction command, minimal steps, or test evidence."
17038
+ });
17039
+ }
17040
+ if (description && /```(?:json)?\s*\{[\s\S]{1200,}\}\s*```/i.test(description)) {
17041
+ findings.push({
17042
+ code: "issue.description.large_raw_payload",
17043
+ severity: "error",
17044
+ message: "Issue description must summarize large raw payloads instead of pasting them."
17045
+ });
17046
+ }
17047
+ const combined = `${title}
17048
+ ${description}`;
17049
+ for (const secret of SECRET_PATTERNS) {
17050
+ if (secret.pattern.test(combined)) {
17051
+ findings.push({
17052
+ code: secret.code,
17053
+ severity: "error",
17054
+ message: secret.message
17055
+ });
17056
+ }
17057
+ }
17058
+ return {
17059
+ ok: findings.every((finding) => finding.severity !== "error"),
17060
+ findings
17061
+ };
17062
+ }
16244
17063
 
16245
17064
  // src/commands/issue.ts
16246
17065
  async function readDescription(options) {
@@ -16315,6 +17134,16 @@ function registerIssueCommands(program2, deps = {}) {
16315
17134
  };
16316
17135
  registerCreateLike("create");
16317
17136
  registerCreateLike("report");
17137
+ 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) => {
17138
+ const result = lintIssueReportDraft({
17139
+ title: options.title,
17140
+ description: await readDescription(options)
17141
+ });
17142
+ printResult(options.format, result);
17143
+ if (!result.ok) {
17144
+ process.exitCode = 1;
17145
+ }
17146
+ });
16318
17147
  }
16319
17148
 
16320
17149
  // src/commands/memory.ts
@@ -17421,9 +18250,15 @@ async function buildApprovalContext(client, projectId, options) {
17421
18250
  }
17422
18251
  function registerProjectCommands(program2) {
17423
18252
  const project = program2.command("project").description("Project commands");
17424
- project.command("search").description("Search projects through huanpingtong /api/project/list ES mode").option("--profile <profile>", "Profile name").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").requiredOption("--body <json>", "Project search body JSON or @file").option("--format <format>", "Output format", "json").action(async (options) => {
18253
+ project.command("search").description("Search projects through huanpingtong /api/project/list ES mode").option("--profile <profile>", "Profile name").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").requiredOption("--body <json>", "Project search body JSON or @file").option("--format <format>", "Output format", "json").action(async (options, command) => {
17425
18254
  const body = await parseJsonInput(options.body, "--body");
17426
18255
  assertProjectSearchBody(body);
18256
+ const data = withProjectListPagination(body, {
18257
+ page: options.page,
18258
+ pageSize: options.pageSize,
18259
+ pageExplicit: command.getOptionValueSource("page") === "cli",
18260
+ pageSizeExplicit: command.getOptionValueSource("pageSize") === "cli"
18261
+ });
17427
18262
  const config = await loadConfig();
17428
18263
  const profile = resolveProfile(config, options.profile);
17429
18264
  const result = await apiRequest(
@@ -17431,31 +18266,27 @@ function registerProjectCommands(program2) {
17431
18266
  "POST",
17432
18267
  "/project/list",
17433
18268
  {
17434
- params: {
17435
- page: Number(options.page),
17436
- page_size: Number(options.pageSize)
17437
- },
17438
- data: body,
18269
+ data,
17439
18270
  preserveErrorBody: true,
17440
18271
  capability: "project.search"
17441
18272
  }
17442
18273
  );
17443
18274
  printResult(options.format, result);
17444
18275
  });
17445
- project.command("list").description("List projects").option("--profile <profile>", "Profile name").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").option("--body <json>", "Project list body JSON", "{}").option("--format <format>", "Output format", "table").action(async (options) => {
18276
+ project.command("list").description("List projects").option("--profile <profile>", "Profile name").option("--page <page>", "Page number", "1").option("--page-size <pageSize>", "Page size", "20").option("--body <json>", "Project list body JSON", "{}").option("--format <format>", "Output format", "table").action(async (options, command) => {
17446
18277
  const config = await loadConfig();
17447
18278
  const profile = resolveProfile(config, options.profile);
18279
+ const data = withProjectListPagination(await parseProjectJson(options.body, "--body"), {
18280
+ page: options.page,
18281
+ pageSize: options.pageSize,
18282
+ pageExplicit: command.getOptionValueSource("page") === "cli",
18283
+ pageSizeExplicit: command.getOptionValueSource("pageSize") === "cli"
18284
+ });
17448
18285
  const result = await apiRequest(
17449
18286
  createApiClient(profile),
17450
18287
  "POST",
17451
18288
  "/project/list",
17452
- {
17453
- params: {
17454
- page: Number(options.page),
17455
- page_size: Number(options.pageSize)
17456
- },
17457
- data: await parseProjectJson(options.body, "--body")
17458
- }
18289
+ { data }
17459
18290
  );
17460
18291
  printResult(options.format, result);
17461
18292
  });
@@ -18637,6 +19468,20 @@ function promptObjectLockText(text5) {
18637
19468
  function hasStrongListEvidence(value) {
18638
19469
  return /bpmax-cli config list-template lint/.test(value) && /(真实列表页|浏览器|runtime|E2E|渲染)/i.test(value);
18639
19470
  }
19471
+ function hasListDeletePermissionGuard(value) {
19472
+ const actionable = value.replace(/(?:禁止|不得|不要|避免)[^。;,\n|]*/gi, " ");
19473
+ if (/\$CAN_DELETE/i.test(actionable) || /project\.delete(?!\.my)/i.test(actionable)) {
19474
+ return true;
19475
+ }
19476
+ return /project\.delete\.my/i.test(actionable) && /__owner_id/i.test(actionable);
19477
+ }
19478
+ function hasForbiddenListDeleteStepGuard(value) {
19479
+ const actionable = value.replace(
19480
+ /(?:禁止|不得|不要|避免)[^。;\n|]{0,80}current_flow_step_(?:id|name)[^。;\n|]*/gi,
19481
+ " "
19482
+ );
19483
+ 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);
19484
+ }
18640
19485
  function validateTaskbookNavigationAndListGates(text5, issues) {
18641
19486
  const strategy = validateNavigationStrategy(text5, issues, "navigation_strategy", "\u4EFB\u52A1\u4E66");
18642
19487
  const rows = extractTaskRows(text5);
@@ -18674,6 +19519,8 @@ function validateTaskbookNavigationAndListGates(text5, issues) {
18674
19519
  });
18675
19520
  listRows.forEach((row) => {
18676
19521
  const taskId = row.task_id || "<unknown>";
19522
+ const evidenceText = `${row.evidence || ""} ${row.notes || ""}`;
19523
+ const writeMode = isWriteMode(row);
18677
19524
  if (!/list-template:(?:\d+|new-[A-Za-z0-9_-]+)/.test(row.object_lock || "")) {
18678
19525
  addTaskbookIssue(
18679
19526
  issues,
@@ -18692,6 +19539,24 @@ function validateTaskbookNavigationAndListGates(text5, issues) {
18692
19539
  { 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
19540
  );
18694
19541
  }
19542
+ if (writeMode && !hasListDeletePermissionGuard(evidenceText)) {
19543
+ addTaskbookIssue(
19544
+ issues,
19545
+ "missing_list_delete_permission_guard",
19546
+ "taskbook.list.delete_permission_guard",
19547
+ `\u5217\u8868\u6A21\u677F\u4EFB\u52A1 ${taskId} \u7F3A\u5C11\u57FA\u4E8E ctx.$CAN_DELETE \u7684\u5220\u9664\u6743\u9650 guard \u8BF4\u660E\u3002`,
19548
+ { 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" }
19549
+ );
19550
+ }
19551
+ if (writeMode && hasForbiddenListDeleteStepGuard(evidenceText)) {
19552
+ addTaskbookIssue(
19553
+ issues,
19554
+ "invalid_list_delete_step_guard",
19555
+ "taskbook.list.delete_step_guard",
19556
+ `\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`,
19557
+ { 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" }
19558
+ );
19559
+ }
18695
19560
  });
18696
19561
  }
18697
19562
  function rowText(row) {
@@ -18816,6 +19681,7 @@ function validatePromptNavigationAndListGates(text5, issues) {
18816
19681
  );
18817
19682
  }
18818
19683
  if (/bpmax-list-template-editor/.test(text5)) {
19684
+ const writeMode = isWriteMode(text5);
18819
19685
  if (!/list-template:(?:\d+|new-[A-Za-z0-9_-]+)/.test(objectLock)) {
18820
19686
  addTaskbookIssue(
18821
19687
  issues,
@@ -18834,6 +19700,24 @@ function validatePromptNavigationAndListGates(text5, issues) {
18834
19700
  { 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
19701
  );
18836
19702
  }
19703
+ if (writeMode && !hasListDeletePermissionGuard(text5)) {
19704
+ addTaskbookIssue(
19705
+ issues,
19706
+ "missing_list_delete_permission_guard",
19707
+ "taskbook.list.delete_permission_guard",
19708
+ "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",
19709
+ { 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" }
19710
+ );
19711
+ }
19712
+ if (writeMode && hasForbiddenListDeleteStepGuard(text5)) {
19713
+ addTaskbookIssue(
19714
+ issues,
19715
+ "invalid_list_delete_step_guard",
19716
+ "taskbook.list.delete_step_guard",
19717
+ "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",
19718
+ { 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" }
19719
+ );
19720
+ }
18837
19721
  }
18838
19722
  }
18839
19723
  function validatePromptConfigSkillGates(text5, issues) {
@@ -19028,7 +19912,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
19028
19912
  "|---|---|---|---|",
19029
19913
  "| \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
19914
  "| \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 |",
19915
+ "| \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
19916
  "| \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
19917
  "",
19034
19918
  "## AI \u6700\u5C0F\u4EFB\u52A1\u5355\u5143",
@@ -19058,7 +19942,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
19058
19942
  "## \u9A8C\u6536\u95E8\u7981",
19059
19943
  "",
19060
19944
  "- \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",
19945
+ "- \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
19946
  "- \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
19947
  "- \u6D4F\u89C8\u5668 E2E \u9A8C\u8BC1\u901A\u8FC7\u3002",
19064
19948
  "- \u6D4B\u8BD5\u62A5\u544A\u548C\u622A\u56FE\u8BC1\u636E\u5B8C\u6574\u3002",