bpmax-cli 0.2.1-beta.24 → 0.2.1-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/bin.js +560 -56
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-cli/SKILL.md +3 -0
- package/skills/bpmax-config-latest/SKILL.md +4 -0
- package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +0 -1
- package/skills/bpmax-project/SKILL.md +1 -0
- package/skills/form-control-library/references/form-template-submit-schema.md +1 -1
package/dist/bin.js
CHANGED
|
@@ -469,7 +469,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
|
|
|
469
469
|
// package.json
|
|
470
470
|
var package_default = {
|
|
471
471
|
name: "bpmax-cli",
|
|
472
|
-
version: "0.2.1-beta.
|
|
472
|
+
version: "0.2.1-beta.26",
|
|
473
473
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
474
474
|
type: "module",
|
|
475
475
|
bin: {
|
|
@@ -4654,42 +4654,277 @@ function validateFlowTemplateActionTarget(errors, pathName, target, nodeIds, con
|
|
|
4654
4654
|
}
|
|
4655
4655
|
}
|
|
4656
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
|
+
}
|
|
4657
4862
|
function validateFlowTemplateOwnerStrategyShape(node, nodeName, errors) {
|
|
4658
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
|
+
}
|
|
4659
4878
|
if (!rawType) return;
|
|
4660
4879
|
if (!FLOW_TEMPLATE_OWNER_AUTO_RANGE_TYPES.has(rawType)) {
|
|
4661
4880
|
errors.push(`${nodeName}.auto_range_type must be one of owner, role, user, leader, continuous_leader, group, fieldvalue, matrix.`);
|
|
4662
4881
|
return;
|
|
4663
4882
|
}
|
|
4664
|
-
if (rawType === "owner" &&
|
|
4665
|
-
errors.push(`${nodeName}.owner_is_creater must be
|
|
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.`);
|
|
4666
4885
|
}
|
|
4667
|
-
if (rawType === "role"
|
|
4668
|
-
|
|
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
|
+
}
|
|
4669
4905
|
}
|
|
4670
|
-
if (rawType === "user" && (!Array.isArray(node.auto_range_by_users) || !node.auto_range_by_users.length)) {
|
|
4671
|
-
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.`);
|
|
4672
4908
|
}
|
|
4673
|
-
if (rawType === "group"
|
|
4674
|
-
|
|
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
|
+
}
|
|
4675
4916
|
}
|
|
4676
|
-
if (rawType === "fieldvalue" && (
|
|
4677
|
-
errors.push(`${nodeName}.auto_range_by_script
|
|
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.`);
|
|
4678
4919
|
}
|
|
4679
|
-
if (rawType === "matrix"
|
|
4680
|
-
|
|
4920
|
+
if (rawType === "matrix") {
|
|
4921
|
+
validateFlowTemplateMatrixConfig(node.matrix_owner, `${nodeName}.matrix_owner`, errors);
|
|
4681
4922
|
}
|
|
4682
4923
|
if (rawType === "leader") {
|
|
4683
|
-
|
|
4684
|
-
if (!hasLegacyLeaderConfig) {
|
|
4685
|
-
errors.push(`${nodeName}.leader_rules or leader_* config is required when auto_range_type is leader.`);
|
|
4686
|
-
}
|
|
4924
|
+
validateFlowTemplateLeaderRules(node, nodeName, errors);
|
|
4687
4925
|
}
|
|
4688
4926
|
if (rawType === "continuous_leader") {
|
|
4689
|
-
|
|
4690
|
-
if (!hasContinuousConfig) {
|
|
4691
|
-
errors.push(`${nodeName}.continuous_* config is required when auto_range_type is continuous_leader.`);
|
|
4692
|
-
}
|
|
4927
|
+
validateFlowTemplateContinuousLeader(node, nodeName, errors);
|
|
4693
4928
|
}
|
|
4694
4929
|
}
|
|
4695
4930
|
function validateFlowTemplateApproveActionShape(value, errors) {
|
|
@@ -6943,6 +7178,24 @@ function validateFormTemplateControlContracts(payload, errors) {
|
|
|
6943
7178
|
if (type === "radio") {
|
|
6944
7179
|
validateRadioFormTemplateControl(field, rule, value, errors);
|
|
6945
7180
|
}
|
|
7181
|
+
if (rule?.lambda === "ctx.$PROJECT?.owner?.name || ''") {
|
|
7182
|
+
const props = isRecord3(rule.props) ? rule.props : {};
|
|
7183
|
+
if (type !== "i_input" || props.disabled !== true) {
|
|
7184
|
+
errors.push(`form-template applicant-name lambda field ${field} must use disabled i_input.`);
|
|
7185
|
+
}
|
|
7186
|
+
if (rule.lambda_version !== "1.0" || rule.lambdaInit !== true) {
|
|
7187
|
+
errors.push(`form-template applicant-name lambda field ${field} must use lambda_version=1.0 and lambdaInit=true.`);
|
|
7188
|
+
}
|
|
7189
|
+
}
|
|
7190
|
+
if (rule?.lambda === "ctx.$PROJECT?.owner?.id || null") {
|
|
7191
|
+
const props = isRecord3(rule.props) ? rule.props : {};
|
|
7192
|
+
if (type !== "i_input" || props.disabled !== true || rule.hidden !== true) {
|
|
7193
|
+
errors.push(`form-template applicant-id lambda field ${field} must use hidden disabled i_input.`);
|
|
7194
|
+
}
|
|
7195
|
+
if (rule.lambda_version !== "1.0" || rule.lambdaInit !== true) {
|
|
7196
|
+
errors.push(`form-template applicant-id lambda field ${field} must use lambda_version=1.0 and lambdaInit=true.`);
|
|
7197
|
+
}
|
|
7198
|
+
}
|
|
6946
7199
|
};
|
|
6947
7200
|
if (isRecord3(payload.fields)) {
|
|
6948
7201
|
for (const [field, bundle] of Object.entries(payload.fields)) {
|
|
@@ -6974,6 +7227,37 @@ function validateFormTemplateControlContracts(payload, errors) {
|
|
|
6974
7227
|
}
|
|
6975
7228
|
}
|
|
6976
7229
|
}
|
|
7230
|
+
function validateFormTemplateHeaderContract(payload, errors) {
|
|
7231
|
+
const basic = isRecord3(payload.basic) ? payload.basic : {};
|
|
7232
|
+
const option = isRecord3(basic.option) ? basic.option : isRecord3(payload.option) ? payload.option : {};
|
|
7233
|
+
const form = isRecord3(option.form) ? option.form : {};
|
|
7234
|
+
const headerBar = isRecord3(form.headerBar) ? form.headerBar : {};
|
|
7235
|
+
let headerFieldCount = 0;
|
|
7236
|
+
const countRule = (rule) => {
|
|
7237
|
+
if (rule.displayArea === "header") {
|
|
7238
|
+
headerFieldCount += 1;
|
|
7239
|
+
} else if (rule.displayArea !== void 0 && rule.displayArea !== "body") {
|
|
7240
|
+
errors.push(`form-template field ${String(rule.field || "")} displayArea must be header or body.`);
|
|
7241
|
+
}
|
|
7242
|
+
};
|
|
7243
|
+
if (isRecord3(payload.fields)) {
|
|
7244
|
+
for (const bundle of Object.values(payload.fields)) {
|
|
7245
|
+
if (isRecord3(bundle) && isRecord3(bundle.rule)) countRule(bundle.rule);
|
|
7246
|
+
}
|
|
7247
|
+
}
|
|
7248
|
+
if (Array.isArray(payload.rule)) {
|
|
7249
|
+
for (const row of payload.rule) {
|
|
7250
|
+
if (!Array.isArray(row)) continue;
|
|
7251
|
+
for (const rule of row) if (isRecord3(rule)) countRule(rule);
|
|
7252
|
+
}
|
|
7253
|
+
}
|
|
7254
|
+
if (headerFieldCount > 0 && headerBar.enabled !== true) {
|
|
7255
|
+
errors.push("form-template fields with displayArea=header require option.form.headerBar.enabled=true.");
|
|
7256
|
+
}
|
|
7257
|
+
if (headerBar.enabled === true && headerFieldCount === 0) {
|
|
7258
|
+
errors.push("form-template option.form.headerBar.enabled=true requires at least one displayArea=header field.");
|
|
7259
|
+
}
|
|
7260
|
+
}
|
|
6977
7261
|
var FORM_TEMPLATE_VISUAL_WIDE_TYPES = /* @__PURE__ */ new Set([
|
|
6978
7262
|
"sub_form",
|
|
6979
7263
|
"i_textarea",
|
|
@@ -7085,6 +7369,7 @@ function validateFormTemplateWorkLint(payload, errors) {
|
|
|
7085
7369
|
validateFormTemplateNameLength(payload, errors);
|
|
7086
7370
|
validateFormTemplateValueValidateMaps(payload, errors);
|
|
7087
7371
|
validateFormTemplateControlContracts(payload, errors);
|
|
7372
|
+
validateFormTemplateHeaderContract(payload, errors);
|
|
7088
7373
|
validateStructuredFormTemplateVisualReview(payload, errors);
|
|
7089
7374
|
}
|
|
7090
7375
|
function stripFormTemplateCreateIds(payload) {
|
|
@@ -10333,9 +10618,35 @@ async function runConfigBatchReadback(config, profile, manifestFile, options = {
|
|
|
10333
10618
|
}
|
|
10334
10619
|
|
|
10335
10620
|
// src/core/config-workspace.ts
|
|
10336
|
-
import { mkdir as mkdir6, readFile as readFile9, writeFile as writeFile6 } from "fs/promises";
|
|
10621
|
+
import { mkdir as mkdir6, readFile as readFile9, realpath, stat as stat4, writeFile as writeFile6 } from "fs/promises";
|
|
10337
10622
|
import path6 from "path";
|
|
10338
10623
|
var DEFAULT_AGENT_GUIDE_FILE = "AGENTS.md";
|
|
10624
|
+
var CONFIG_WORKSPACE_REQUIRED_ENTRIES = [
|
|
10625
|
+
"AGENTS.md",
|
|
10626
|
+
"think_configuration",
|
|
10627
|
+
"think_flow",
|
|
10628
|
+
"think_form_template"
|
|
10629
|
+
];
|
|
10630
|
+
var ConfigWorkspaceError = class extends Error {
|
|
10631
|
+
code;
|
|
10632
|
+
rule_id;
|
|
10633
|
+
path;
|
|
10634
|
+
suggestion;
|
|
10635
|
+
missing;
|
|
10636
|
+
profile;
|
|
10637
|
+
env;
|
|
10638
|
+
constructor(message, options) {
|
|
10639
|
+
super(message);
|
|
10640
|
+
this.name = "ConfigWorkspaceError";
|
|
10641
|
+
this.code = options.code || "config_workspace_required";
|
|
10642
|
+
this.rule_id = options.rule_id || "config.workspace.cwd";
|
|
10643
|
+
this.path = options.path;
|
|
10644
|
+
this.suggestion = options.suggestion || "\u8BF7\u6267\u884C bpmax-cli config workspace init \u4FEE\u590D\u672C\u5730\u914D\u7F6E\u76EE\u5F55\u53CA profile \u7ED1\u5B9A\uFF0C\u7136\u540E\u8FDB\u5165\u8BE5\u76EE\u5F55\u91CD\u8BD5\u3002";
|
|
10645
|
+
this.missing = options.missing;
|
|
10646
|
+
this.profile = options.profile;
|
|
10647
|
+
this.env = options.env;
|
|
10648
|
+
}
|
|
10649
|
+
};
|
|
10339
10650
|
var CONFIG_DOMAINS2 = [
|
|
10340
10651
|
["form-template", "bpmax-form-template-editor", "\u8868\u5355\u6A21\u677F"],
|
|
10341
10652
|
["flow-template", "bpmax-flow-template-editor", "\u6D41\u7A0B\u6A21\u677F"],
|
|
@@ -10362,6 +10673,126 @@ var CONFIG_DIRECTORY_PURPOSES = [
|
|
|
10362
10673
|
["think_role/", "Role definitions"],
|
|
10363
10674
|
["think_category/", "Category definitions"]
|
|
10364
10675
|
];
|
|
10676
|
+
async function hasExpectedWorkspaceEntry(root, entry) {
|
|
10677
|
+
try {
|
|
10678
|
+
const entryPath = path6.join(root, entry);
|
|
10679
|
+
const value = await stat4(entryPath);
|
|
10680
|
+
const canonicalEntry = await realpath(entryPath);
|
|
10681
|
+
const relative = path6.relative(root, canonicalEntry);
|
|
10682
|
+
const staysInsideRoot = relative !== ".." && !relative.startsWith(`..${path6.sep}`) && !path6.isAbsolute(relative);
|
|
10683
|
+
return staysInsideRoot && (entry === DEFAULT_AGENT_GUIDE_FILE ? value.isFile() : value.isDirectory());
|
|
10684
|
+
} catch (error) {
|
|
10685
|
+
if (error.code === "ENOENT") {
|
|
10686
|
+
return false;
|
|
10687
|
+
}
|
|
10688
|
+
throw error;
|
|
10689
|
+
}
|
|
10690
|
+
}
|
|
10691
|
+
async function inspectWorkspaceEntries(root) {
|
|
10692
|
+
const checks = await Promise.all(
|
|
10693
|
+
CONFIG_WORKSPACE_REQUIRED_ENTRIES.map(async (entry) => ({
|
|
10694
|
+
entry,
|
|
10695
|
+
present: await hasExpectedWorkspaceEntry(root, entry)
|
|
10696
|
+
}))
|
|
10697
|
+
);
|
|
10698
|
+
return {
|
|
10699
|
+
present: checks.filter((item) => item.present).map((item) => item.entry),
|
|
10700
|
+
missing: checks.filter((item) => !item.present).map((item) => item.entry)
|
|
10701
|
+
};
|
|
10702
|
+
}
|
|
10703
|
+
async function findConfigWorkspaceRoot(cwd = process.cwd()) {
|
|
10704
|
+
let current;
|
|
10705
|
+
try {
|
|
10706
|
+
current = await realpath(cwd);
|
|
10707
|
+
} catch (error) {
|
|
10708
|
+
throw new ConfigWorkspaceError(`\u5F53\u524D\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u8BBF\u95EE\uFF1A${cwd}`, {
|
|
10709
|
+
path: path6.resolve(cwd),
|
|
10710
|
+
code: "config_workspace_invalid_cwd",
|
|
10711
|
+
rule_id: "config.workspace.cwd_invalid"
|
|
10712
|
+
});
|
|
10713
|
+
}
|
|
10714
|
+
let closestPartial;
|
|
10715
|
+
while (true) {
|
|
10716
|
+
const entries = await inspectWorkspaceEntries(current);
|
|
10717
|
+
if (entries.missing.length === 0) {
|
|
10718
|
+
return current;
|
|
10719
|
+
}
|
|
10720
|
+
if (entries.present.length > 0 && (!closestPartial || entries.present.length > closestPartial.present.length)) {
|
|
10721
|
+
closestPartial = { root: current, ...entries };
|
|
10722
|
+
}
|
|
10723
|
+
const parent = path6.dirname(current);
|
|
10724
|
+
if (parent === current) {
|
|
10725
|
+
break;
|
|
10726
|
+
}
|
|
10727
|
+
current = parent;
|
|
10728
|
+
}
|
|
10729
|
+
const diagnosticRoot = closestPartial?.root || await realpath(cwd);
|
|
10730
|
+
const missing = closestPartial?.missing || [...CONFIG_WORKSPACE_REQUIRED_ENTRIES];
|
|
10731
|
+
throw new ConfigWorkspaceError(
|
|
10732
|
+
`\u5F53\u524D\u8DEF\u5F84\u4E0D\u5728\u6709\u6548\u7684 BPMAX \u672C\u5730\u914D\u7F6E\u76EE\u5F55\u4E2D\uFF1B\u7F3A\u5C11\uFF1A${missing.join("\u3001")}\u3002`,
|
|
10733
|
+
{ path: diagnosticRoot, missing }
|
|
10734
|
+
);
|
|
10735
|
+
}
|
|
10736
|
+
async function canonicalConfiguredPath(value) {
|
|
10737
|
+
const configuredPath = value.trim();
|
|
10738
|
+
if (!configuredPath || !path6.isAbsolute(configuredPath)) {
|
|
10739
|
+
return void 0;
|
|
10740
|
+
}
|
|
10741
|
+
try {
|
|
10742
|
+
return await realpath(configuredPath);
|
|
10743
|
+
} catch (error) {
|
|
10744
|
+
if (error.code === "ENOENT") {
|
|
10745
|
+
return void 0;
|
|
10746
|
+
}
|
|
10747
|
+
throw error;
|
|
10748
|
+
}
|
|
10749
|
+
}
|
|
10750
|
+
async function assertConfigWorkspace(options) {
|
|
10751
|
+
const currentDirectory = await realpath(options.cwd || process.cwd());
|
|
10752
|
+
const root = options.root ? await realpath(options.root) : await findConfigWorkspaceRoot(currentDirectory);
|
|
10753
|
+
const relative = path6.relative(root, currentDirectory);
|
|
10754
|
+
if (relative === ".." || relative.startsWith(`..${path6.sep}`) || path6.isAbsolute(relative)) {
|
|
10755
|
+
throw new ConfigWorkspaceError("\u5F53\u524D\u76EE\u5F55\u4E0D\u5728\u8BC6\u522B\u51FA\u7684 BPMAX \u914D\u7F6E\u76EE\u5F55\u5185\u3002", {
|
|
10756
|
+
path: currentDirectory,
|
|
10757
|
+
profile: options.profile.name,
|
|
10758
|
+
env: options.env
|
|
10759
|
+
});
|
|
10760
|
+
}
|
|
10761
|
+
const environments = options.profile.config.config_environments || {};
|
|
10762
|
+
const entries = options.env ? Object.entries(environments).filter(([env]) => env === options.env) : Object.entries(environments);
|
|
10763
|
+
if (options.env && entries.length === 0) {
|
|
10764
|
+
throw new ConfigWorkspaceError(`\u5F53\u524D profile \u672A\u521D\u59CB\u5316\u914D\u7F6E\u73AF\u5883 ${options.env}\u3002`, {
|
|
10765
|
+
path: root,
|
|
10766
|
+
profile: options.profile.name,
|
|
10767
|
+
env: options.env,
|
|
10768
|
+
code: "config_workspace_environment_unbound",
|
|
10769
|
+
rule_id: "config.workspace.environment_binding"
|
|
10770
|
+
});
|
|
10771
|
+
}
|
|
10772
|
+
for (const [env, environment] of entries) {
|
|
10773
|
+
const configuredRoot = await canonicalConfiguredPath(environment.sysconfig_repo_path || "");
|
|
10774
|
+
if (configuredRoot === root) {
|
|
10775
|
+
return {
|
|
10776
|
+
root,
|
|
10777
|
+
profile: options.profile.name,
|
|
10778
|
+
env,
|
|
10779
|
+
current_directory: currentDirectory
|
|
10780
|
+
};
|
|
10781
|
+
}
|
|
10782
|
+
}
|
|
10783
|
+
const expected = entries.map(([env, environment]) => `${env}=${environment.sysconfig_repo_path || "<\u672A\u8BBE\u7F6E>"}`).join("\uFF0C");
|
|
10784
|
+
throw new ConfigWorkspaceError(
|
|
10785
|
+
options.env ? `\u5F53\u524D\u76EE\u5F55\u4E0E profile ${options.profile.name} \u7684\u914D\u7F6E\u73AF\u5883 ${options.env} \u7ED1\u5B9A\u4E0D\u4E00\u81F4\u3002` : `\u5F53\u524D\u76EE\u5F55\u672A\u7ED1\u5B9A\u5230 profile ${options.profile.name} \u7684\u4EFB\u4F55\u914D\u7F6E\u73AF\u5883\u3002`,
|
|
10786
|
+
{
|
|
10787
|
+
path: root,
|
|
10788
|
+
profile: options.profile.name,
|
|
10789
|
+
env: options.env,
|
|
10790
|
+
code: "config_workspace_profile_mismatch",
|
|
10791
|
+
rule_id: options.env ? "config.workspace.environment_binding" : "config.workspace.profile_binding",
|
|
10792
|
+
suggestion: `\u5DF2\u914D\u7F6E\u8DEF\u5F84\uFF1A${expected || "<\u65E0>"}\u3002\u8BF7\u6267\u884C bpmax-cli config workspace init \u4FEE\u590D\u7ED1\u5B9A\uFF0C\u7136\u540E\u8FDB\u5165\u8BE5\u76EE\u5F55\u91CD\u8BD5\u3002`
|
|
10793
|
+
}
|
|
10794
|
+
);
|
|
10795
|
+
}
|
|
10365
10796
|
function escapeRegExp(value) {
|
|
10366
10797
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10367
10798
|
}
|
|
@@ -11048,7 +11479,7 @@ async function testPluginConfigDomain(profile, domain, id, message, agent = "cod
|
|
|
11048
11479
|
|
|
11049
11480
|
// src/commands/config-env.ts
|
|
11050
11481
|
import { execFile } from "child_process";
|
|
11051
|
-
import { mkdir as mkdir7, rm as rm3, stat as
|
|
11482
|
+
import { mkdir as mkdir7, rm as rm3, stat as stat5, writeFile as writeFile7 } from "fs/promises";
|
|
11052
11483
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
11053
11484
|
import { tmpdir as tmpdir2 } from "os";
|
|
11054
11485
|
import path8 from "path";
|
|
@@ -11343,7 +11774,7 @@ function hasBlockingDirtyStatus(status, allowedPaths = /* @__PURE__ */ new Set([
|
|
|
11343
11774
|
}
|
|
11344
11775
|
async function pathExists(targetPath) {
|
|
11345
11776
|
try {
|
|
11346
|
-
await
|
|
11777
|
+
await stat5(targetPath);
|
|
11347
11778
|
return true;
|
|
11348
11779
|
} catch (error) {
|
|
11349
11780
|
if (error.code === "ENOENT") {
|
|
@@ -11785,8 +12216,64 @@ async function ensureValue(current, label, placeholder) {
|
|
|
11785
12216
|
}
|
|
11786
12217
|
return result.trim();
|
|
11787
12218
|
}
|
|
12219
|
+
function configCommandPath(actionCommand) {
|
|
12220
|
+
const names = [];
|
|
12221
|
+
let current = actionCommand;
|
|
12222
|
+
while (current) {
|
|
12223
|
+
names.unshift(current.name());
|
|
12224
|
+
if (current.name() === "config") {
|
|
12225
|
+
break;
|
|
12226
|
+
}
|
|
12227
|
+
current = current.parent;
|
|
12228
|
+
}
|
|
12229
|
+
return names;
|
|
12230
|
+
}
|
|
12231
|
+
function configCommandGate(actionCommand) {
|
|
12232
|
+
const commandPath = configCommandPath(actionCommand);
|
|
12233
|
+
const [, group, operation] = commandPath;
|
|
12234
|
+
if (group === "profile") {
|
|
12235
|
+
return { required: false };
|
|
12236
|
+
}
|
|
12237
|
+
if (group === "adapters" && !operation) {
|
|
12238
|
+
return { required: false };
|
|
12239
|
+
}
|
|
12240
|
+
if (group === "repository" && ["list", "show", "sync"].includes(operation || "")) {
|
|
12241
|
+
return { required: false };
|
|
12242
|
+
}
|
|
12243
|
+
if (group === "workspace" && operation === "init") {
|
|
12244
|
+
return { required: false };
|
|
12245
|
+
}
|
|
12246
|
+
if (group === "init" && operation === "workspace") {
|
|
12247
|
+
return { required: false };
|
|
12248
|
+
}
|
|
12249
|
+
if (group === "plugin") {
|
|
12250
|
+
const [domain, pluginOperation] = actionCommand.processedArgs;
|
|
12251
|
+
if (!domain || !pluginOperation) {
|
|
12252
|
+
return { required: false };
|
|
12253
|
+
}
|
|
12254
|
+
}
|
|
12255
|
+
if (group === "latest" && (operation === "pull" || operation === "diff")) {
|
|
12256
|
+
const [env] = actionCommand.processedArgs;
|
|
12257
|
+
return { required: true, env: typeof env === "string" ? env : void 0 };
|
|
12258
|
+
}
|
|
12259
|
+
return { required: true };
|
|
12260
|
+
}
|
|
11788
12261
|
function registerConfigCommands(program2) {
|
|
11789
12262
|
const config = program2.command("config").description("Manage local bpmax-cli profiles");
|
|
12263
|
+
config.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
12264
|
+
const gate = configCommandGate(actionCommand);
|
|
12265
|
+
if (!gate.required) {
|
|
12266
|
+
return;
|
|
12267
|
+
}
|
|
12268
|
+
const root = await findConfigWorkspaceRoot();
|
|
12269
|
+
const options = actionCommand.optsWithGlobals();
|
|
12270
|
+
const configData = await loadConfig();
|
|
12271
|
+
await assertConfigWorkspace({
|
|
12272
|
+
profile: resolveProfile(configData, options.profile),
|
|
12273
|
+
env: gate.env,
|
|
12274
|
+
root
|
|
12275
|
+
});
|
|
12276
|
+
});
|
|
11790
12277
|
const profile = config.command("profile").description("Manage named environment profiles");
|
|
11791
12278
|
profile.command("add").description("Add or update a profile").option("--name <name>", "Profile name").option("--origin <origin>", "Profile origin").option("--api-key <apiKey>", "API key").option("--workspace <workspace>", "Default workspace", DEFAULT_WORKSPACE).option("--language <language>", "Default language", DEFAULT_LANGUAGE).action(async (options) => {
|
|
11792
12279
|
const name = await ensureValue(options.name, "Profile name", "default");
|
|
@@ -12291,7 +12778,7 @@ function registerConfigCommands(program2) {
|
|
|
12291
12778
|
|
|
12292
12779
|
// src/commands/e2e.ts
|
|
12293
12780
|
import { createHash as createHash6 } from "crypto";
|
|
12294
|
-
import { mkdir as mkdir10, readFile as readFile12, readdir as readdir4, stat as
|
|
12781
|
+
import { mkdir as mkdir10, readFile as readFile12, readdir as readdir4, stat as stat7, writeFile as writeFile10 } from "fs/promises";
|
|
12295
12782
|
import path11 from "path";
|
|
12296
12783
|
|
|
12297
12784
|
// src/core/test-suite.ts
|
|
@@ -12306,7 +12793,7 @@ import {
|
|
|
12306
12793
|
readFile as readFile11,
|
|
12307
12794
|
rename,
|
|
12308
12795
|
rm as rm4,
|
|
12309
|
-
stat as
|
|
12796
|
+
stat as stat6,
|
|
12310
12797
|
unlink,
|
|
12311
12798
|
writeFile as writeFile9
|
|
12312
12799
|
} from "fs/promises";
|
|
@@ -12469,7 +12956,7 @@ var TestSuiteError = class extends Error {
|
|
|
12469
12956
|
};
|
|
12470
12957
|
async function exists3(filePath) {
|
|
12471
12958
|
try {
|
|
12472
|
-
await
|
|
12959
|
+
await stat6(filePath);
|
|
12473
12960
|
return true;
|
|
12474
12961
|
} catch {
|
|
12475
12962
|
return false;
|
|
@@ -13236,7 +13723,7 @@ async function assertExecutionManifestFresh(manifest, manifestPath) {
|
|
|
13236
13723
|
}
|
|
13237
13724
|
}
|
|
13238
13725
|
async function evidenceContainsDiagnostic(evidencePath) {
|
|
13239
|
-
const info = await
|
|
13726
|
+
const info = await stat6(evidencePath);
|
|
13240
13727
|
if (info.isDirectory()) {
|
|
13241
13728
|
const entries = await readdir3(evidencePath, { withFileTypes: true });
|
|
13242
13729
|
for (const entry of entries) {
|
|
@@ -13262,7 +13749,7 @@ async function assertCurrentRunArtifact(manifest, artifactPath) {
|
|
|
13262
13749
|
if (!await exists3(artifactPath)) {
|
|
13263
13750
|
fail(`execution evidence artifact not found: ${artifactPath}`, { rule_id: "test_suite.run.evidence_missing", path: artifactPath });
|
|
13264
13751
|
}
|
|
13265
|
-
const info = await
|
|
13752
|
+
const info = await stat6(artifactPath);
|
|
13266
13753
|
if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
|
|
13267
13754
|
fail("execution evidence artifact predates the current run", { rule_id: "test_suite.run.evidence_stale", path: artifactPath });
|
|
13268
13755
|
}
|
|
@@ -13273,7 +13760,7 @@ async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
|
|
|
13273
13760
|
if (!pathInside(runDir, evidencePath)) {
|
|
13274
13761
|
fail("formal execution evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: evidencePath });
|
|
13275
13762
|
}
|
|
13276
|
-
const info = await
|
|
13763
|
+
const info = await stat6(evidencePath);
|
|
13277
13764
|
if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
|
|
13278
13765
|
fail("execution evidence predates the current run", { rule_id: "test_suite.run.evidence_stale", path: evidencePath });
|
|
13279
13766
|
}
|
|
@@ -13282,7 +13769,7 @@ async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
|
|
|
13282
13769
|
}
|
|
13283
13770
|
}
|
|
13284
13771
|
async function evidenceTexts(evidencePath) {
|
|
13285
|
-
const info = await
|
|
13772
|
+
const info = await stat6(evidencePath);
|
|
13286
13773
|
if (!info.isDirectory()) return [await readText(evidencePath).catch(() => "")];
|
|
13287
13774
|
const entries = await readdir3(evidencePath, { withFileTypes: true });
|
|
13288
13775
|
const texts = [];
|
|
@@ -13293,7 +13780,7 @@ async function evidenceTexts(evidencePath) {
|
|
|
13293
13780
|
return texts;
|
|
13294
13781
|
}
|
|
13295
13782
|
async function evidenceJsonRecords(evidencePath) {
|
|
13296
|
-
const info = await
|
|
13783
|
+
const info = await stat6(evidencePath);
|
|
13297
13784
|
const paths = info.isDirectory() ? (await readdir3(evidencePath, { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => path10.join(evidencePath, entry.name)) : [evidencePath];
|
|
13298
13785
|
const records = [];
|
|
13299
13786
|
for (const source of paths) {
|
|
@@ -14549,7 +15036,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
|
14549
15036
|
}
|
|
14550
15037
|
validCurrentRunImages.push(imageRef);
|
|
14551
15038
|
if (isFullRerun) {
|
|
14552
|
-
const imageStat = await
|
|
15039
|
+
const imageStat = await stat6(imagePath);
|
|
14553
15040
|
if (!isWithinWindow(imageStat.mtime, window)) {
|
|
14554
15041
|
errors.push(`[test_suite.report.current_run_screenshot] ${reportPath}: full_rerun \u622A\u56FE\u5FC5\u987B\u5728\u672C\u8F6E\u6267\u884C\u65F6\u95F4\u5185\u751F\u6210\uFF0C\u4E0D\u80FD\u590D\u7528\u5386\u53F2\u622A\u56FE: ${imageRef}`);
|
|
14555
15042
|
}
|
|
@@ -16079,7 +16566,7 @@ function registerE2eCommands(program2) {
|
|
|
16079
16566
|
const profile = resolveProfile(await loadConfig(), options.profile);
|
|
16080
16567
|
const file = flowCachePath(profile.name, options.flowId);
|
|
16081
16568
|
const cached = await readOptionalJson(file);
|
|
16082
|
-
const fileStat = await
|
|
16569
|
+
const fileStat = await stat7(file).catch(() => null);
|
|
16083
16570
|
printResult(options.format, {
|
|
16084
16571
|
ok: true,
|
|
16085
16572
|
profile: profile.name,
|
|
@@ -16302,13 +16789,29 @@ function assertProjectSearchBody(value) {
|
|
|
16302
16789
|
);
|
|
16303
16790
|
}
|
|
16304
16791
|
}
|
|
16792
|
+
function withProjectListPagination(body, options) {
|
|
16793
|
+
const data = { ...body };
|
|
16794
|
+
if (options.pageExplicit || data.page === void 0) {
|
|
16795
|
+
data.page = Number(options.page);
|
|
16796
|
+
}
|
|
16797
|
+
if (options.pageSizeExplicit || data.page_size === void 0) {
|
|
16798
|
+
data.page_size = Number(options.pageSize);
|
|
16799
|
+
}
|
|
16800
|
+
return data;
|
|
16801
|
+
}
|
|
16305
16802
|
|
|
16306
16803
|
// src/commands/es.ts
|
|
16307
16804
|
function registerEsCommands(program2) {
|
|
16308
16805
|
const es = program2.command("es").description("Fast ES-backed data queries");
|
|
16309
|
-
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) => {
|
|
16806
|
+
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) => {
|
|
16310
16807
|
const body = await parseJsonInput(options.body, "--body");
|
|
16311
16808
|
assertProjectSearchBody(body);
|
|
16809
|
+
const data = withProjectListPagination(body, {
|
|
16810
|
+
page: options.page,
|
|
16811
|
+
pageSize: options.pageSize,
|
|
16812
|
+
pageExplicit: command.getOptionValueSource("page") === "cli",
|
|
16813
|
+
pageSizeExplicit: command.getOptionValueSource("pageSize") === "cli"
|
|
16814
|
+
});
|
|
16312
16815
|
const config = await loadConfig();
|
|
16313
16816
|
const profile = resolveProfile(config, options.profile);
|
|
16314
16817
|
const client = createApiClient(profile);
|
|
@@ -16317,11 +16820,7 @@ function registerEsCommands(program2) {
|
|
|
16317
16820
|
"POST",
|
|
16318
16821
|
"/project/list",
|
|
16319
16822
|
{
|
|
16320
|
-
|
|
16321
|
-
page: Number(options.page),
|
|
16322
|
-
page_size: Number(options.pageSize)
|
|
16323
|
-
},
|
|
16324
|
-
data: body,
|
|
16823
|
+
data,
|
|
16325
16824
|
preserveErrorBody: true,
|
|
16326
16825
|
capability: "project.search"
|
|
16327
16826
|
}
|
|
@@ -18003,9 +18502,15 @@ async function buildApprovalContext(client, projectId, options) {
|
|
|
18003
18502
|
}
|
|
18004
18503
|
function registerProjectCommands(program2) {
|
|
18005
18504
|
const project = program2.command("project").description("Project commands");
|
|
18006
|
-
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) => {
|
|
18505
|
+
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) => {
|
|
18007
18506
|
const body = await parseJsonInput(options.body, "--body");
|
|
18008
18507
|
assertProjectSearchBody(body);
|
|
18508
|
+
const data = withProjectListPagination(body, {
|
|
18509
|
+
page: options.page,
|
|
18510
|
+
pageSize: options.pageSize,
|
|
18511
|
+
pageExplicit: command.getOptionValueSource("page") === "cli",
|
|
18512
|
+
pageSizeExplicit: command.getOptionValueSource("pageSize") === "cli"
|
|
18513
|
+
});
|
|
18009
18514
|
const config = await loadConfig();
|
|
18010
18515
|
const profile = resolveProfile(config, options.profile);
|
|
18011
18516
|
const result = await apiRequest(
|
|
@@ -18013,31 +18518,27 @@ function registerProjectCommands(program2) {
|
|
|
18013
18518
|
"POST",
|
|
18014
18519
|
"/project/list",
|
|
18015
18520
|
{
|
|
18016
|
-
|
|
18017
|
-
page: Number(options.page),
|
|
18018
|
-
page_size: Number(options.pageSize)
|
|
18019
|
-
},
|
|
18020
|
-
data: body,
|
|
18521
|
+
data,
|
|
18021
18522
|
preserveErrorBody: true,
|
|
18022
18523
|
capability: "project.search"
|
|
18023
18524
|
}
|
|
18024
18525
|
);
|
|
18025
18526
|
printResult(options.format, result);
|
|
18026
18527
|
});
|
|
18027
|
-
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) => {
|
|
18528
|
+
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) => {
|
|
18028
18529
|
const config = await loadConfig();
|
|
18029
18530
|
const profile = resolveProfile(config, options.profile);
|
|
18531
|
+
const data = withProjectListPagination(await parseProjectJson(options.body, "--body"), {
|
|
18532
|
+
page: options.page,
|
|
18533
|
+
pageSize: options.pageSize,
|
|
18534
|
+
pageExplicit: command.getOptionValueSource("page") === "cli",
|
|
18535
|
+
pageSizeExplicit: command.getOptionValueSource("pageSize") === "cli"
|
|
18536
|
+
});
|
|
18030
18537
|
const result = await apiRequest(
|
|
18031
18538
|
createApiClient(profile),
|
|
18032
18539
|
"POST",
|
|
18033
18540
|
"/project/list",
|
|
18034
|
-
{
|
|
18035
|
-
params: {
|
|
18036
|
-
page: Number(options.page),
|
|
18037
|
-
page_size: Number(options.pageSize)
|
|
18038
|
-
},
|
|
18039
|
-
data: await parseProjectJson(options.body, "--body")
|
|
18040
|
-
}
|
|
18541
|
+
{ data }
|
|
18041
18542
|
);
|
|
18042
18543
|
printResult(options.format, result);
|
|
18043
18544
|
});
|
|
@@ -19945,7 +20446,7 @@ function registerTestSuiteCommands(program2) {
|
|
|
19945
20446
|
}
|
|
19946
20447
|
|
|
19947
20448
|
// src/core/update.ts
|
|
19948
|
-
import { access as access2, mkdir as mkdir13, readFile as readFile18, realpath, writeFile as writeFile13 } from "fs/promises";
|
|
20449
|
+
import { access as access2, mkdir as mkdir13, readFile as readFile18, realpath as realpath2, writeFile as writeFile13 } from "fs/promises";
|
|
19949
20450
|
import path15 from "path";
|
|
19950
20451
|
var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
19951
20452
|
var UPDATE_STATE_FILE = "update-state.json";
|
|
@@ -20111,7 +20612,7 @@ async function executablePath() {
|
|
|
20111
20612
|
return "";
|
|
20112
20613
|
}
|
|
20113
20614
|
try {
|
|
20114
|
-
return await
|
|
20615
|
+
return await realpath2(candidate);
|
|
20115
20616
|
} catch {
|
|
20116
20617
|
return candidate;
|
|
20117
20618
|
}
|
|
@@ -20541,6 +21042,9 @@ function printCommandError(error) {
|
|
|
20541
21042
|
...typeof structured.rule_id === "string" ? { rule_id: structured.rule_id } : {},
|
|
20542
21043
|
...typeof structured.path === "string" ? { path: structured.path } : {},
|
|
20543
21044
|
...typeof structured.suggestion === "string" ? { suggestion: structured.suggestion } : {},
|
|
21045
|
+
...Array.isArray(structured.missing) ? { missing: structured.missing } : {},
|
|
21046
|
+
...typeof structured.profile === "string" ? { profile: structured.profile } : {},
|
|
21047
|
+
...typeof structured.env === "string" ? { env: structured.env } : {},
|
|
20544
21048
|
...commandDomainFromArgv(process.argv) ? { domain: commandDomainFromArgv(process.argv) } : {},
|
|
20545
21049
|
...commandEndpointHint(process.argv) ? { endpoint: commandEndpointHint(process.argv) } : {}
|
|
20546
21050
|
}, null, 2));
|