bpmax-cli 0.2.1-beta.10 → 0.2.1-beta.12
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.
|
|
472
|
+
version: "0.2.1-beta.12",
|
|
473
473
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
474
474
|
type: "module",
|
|
475
475
|
bin: {
|
|
@@ -4610,6 +4610,178 @@ function validateFlowTemplateApproveActionShape(value, errors) {
|
|
|
4610
4610
|
}
|
|
4611
4611
|
throw new Error(`flow-template approve action gate failed: ${nextErrors.join("; ")}`);
|
|
4612
4612
|
}
|
|
4613
|
+
function validateOptionalBoolean(errors, value, fieldName, pathName) {
|
|
4614
|
+
if (value[fieldName] !== void 0 && typeof value[fieldName] !== "boolean") {
|
|
4615
|
+
errors.push(`${pathName}.${fieldName} must be a boolean when provided.`);
|
|
4616
|
+
}
|
|
4617
|
+
}
|
|
4618
|
+
function flowTemplateNodeRequiresApproval(node) {
|
|
4619
|
+
if (node.approve_count_required === "all") {
|
|
4620
|
+
return true;
|
|
4621
|
+
}
|
|
4622
|
+
const approveCount = Number(node.approve_count_required ?? 0);
|
|
4623
|
+
return Number.isFinite(approveCount) && approveCount > 0;
|
|
4624
|
+
}
|
|
4625
|
+
function validateFlowTemplatePluginRejectionControl(value, errors) {
|
|
4626
|
+
const nextErrors = [];
|
|
4627
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
4628
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
4629
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
|
|
4630
|
+
nodes.forEach((node, nodeIndex) => {
|
|
4631
|
+
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
|
|
4632
|
+
const config = node.plugin_rejection_control;
|
|
4633
|
+
const pathName = `${nodeName}.plugin_rejection_control`;
|
|
4634
|
+
if (config === void 0 || config === null || config === "") {
|
|
4635
|
+
return;
|
|
4636
|
+
}
|
|
4637
|
+
if (!isRecord3(config)) {
|
|
4638
|
+
nextErrors.push(`${pathName} must be an object when configured.`);
|
|
4639
|
+
return;
|
|
4640
|
+
}
|
|
4641
|
+
validateOptionalBoolean(nextErrors, config, "enabled", pathName);
|
|
4642
|
+
validateOptionalBoolean(nextErrors, config, "disabled_form_validate", pathName);
|
|
4643
|
+
[
|
|
4644
|
+
"reject_to_pre",
|
|
4645
|
+
"reject_to_owner",
|
|
4646
|
+
"reject_to_specific_step",
|
|
4647
|
+
"reject_to_end",
|
|
4648
|
+
"review_default",
|
|
4649
|
+
"review_to_me",
|
|
4650
|
+
"review_to_all",
|
|
4651
|
+
"review_to_any_node"
|
|
4652
|
+
].forEach((fieldName) => validateOptionalBoolean(nextErrors, config, fieldName, pathName));
|
|
4653
|
+
if (config.enabled !== true) {
|
|
4654
|
+
return;
|
|
4655
|
+
}
|
|
4656
|
+
if (typeof config.button_text !== "string" || !config.button_text.trim()) {
|
|
4657
|
+
nextErrors.push(`${pathName}.button_text is required when plugin rejection control is enabled.`);
|
|
4658
|
+
}
|
|
4659
|
+
if (!flowTemplateNodeRequiresApproval(node)) {
|
|
4660
|
+
nextErrors.push(`${pathName}.enabled requires an approval step with approve_count_required > 0 or "all"; the plugin replaces reject buttons on approval steps only.`);
|
|
4661
|
+
}
|
|
4662
|
+
const hasNativeRejectTarget = typeof node.approve_fail === "string" && node.approve_fail.trim() || Array.isArray(node.approve_fail_actions) && node.approve_fail_actions.length > 0;
|
|
4663
|
+
const hasPluginRejectMethod = config.reject_to_pre === true || config.reject_to_owner === true || config.reject_to_specific_step === true || config.reject_to_end === true;
|
|
4664
|
+
if (!hasNativeRejectTarget && !hasPluginRejectMethod) {
|
|
4665
|
+
nextErrors.push(
|
|
4666
|
+
`${pathName} must enable at least one reject method (reject_to_pre, reject_to_owner, reject_to_specific_step, reject_to_end) or keep a native approve_fail/approve_fail_actions target.`
|
|
4667
|
+
);
|
|
4668
|
+
}
|
|
4669
|
+
if (config.reject_to_owner === true && meta.allow_jump_start !== true && !hasNativeRejectTarget && config.reject_to_pre !== true && config.reject_to_specific_step !== true && config.reject_to_end !== true) {
|
|
4670
|
+
nextErrors.push(
|
|
4671
|
+
`${pathName}.reject_to_owner is the only configured reject method but requires data.meta.allow_jump_start = true; otherwise the runtime will not offer any usable plugin reject method.`
|
|
4672
|
+
);
|
|
4673
|
+
}
|
|
4674
|
+
});
|
|
4675
|
+
if (!nextErrors.length) {
|
|
4676
|
+
return;
|
|
4677
|
+
}
|
|
4678
|
+
if (errors) {
|
|
4679
|
+
errors.push(...nextErrors);
|
|
4680
|
+
return;
|
|
4681
|
+
}
|
|
4682
|
+
throw new Error(`flow-template plugin rejection control gate failed: ${nextErrors.join("; ")}`);
|
|
4683
|
+
}
|
|
4684
|
+
var FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS = /* @__PURE__ */ new Set([
|
|
4685
|
+
"eq",
|
|
4686
|
+
"ne",
|
|
4687
|
+
"gt",
|
|
4688
|
+
"gte",
|
|
4689
|
+
"lt",
|
|
4690
|
+
"lte",
|
|
4691
|
+
"contains",
|
|
4692
|
+
"isEmpty",
|
|
4693
|
+
"isNotEmpty"
|
|
4694
|
+
]);
|
|
4695
|
+
function validateFlowTemplateStandardConditionEditorRules(value, errors) {
|
|
4696
|
+
const nextErrors = [];
|
|
4697
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
4698
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
|
|
4699
|
+
const visitConditionGroup = (group, pathName) => {
|
|
4700
|
+
if (!isRecord3(group)) {
|
|
4701
|
+
nextErrors.push(`${pathName} must be a condition group object with logic and conditions.`);
|
|
4702
|
+
return;
|
|
4703
|
+
}
|
|
4704
|
+
const logic = typeof group.logic === "string" ? group.logic.trim() : "AND";
|
|
4705
|
+
if (logic !== "AND" && logic !== "OR") {
|
|
4706
|
+
nextErrors.push(`${pathName}.logic must be AND or OR.`);
|
|
4707
|
+
}
|
|
4708
|
+
if (!Array.isArray(group.conditions)) {
|
|
4709
|
+
nextErrors.push(`${pathName}.conditions must be an array.`);
|
|
4710
|
+
return;
|
|
4711
|
+
}
|
|
4712
|
+
group.conditions.forEach((condition, conditionIndex) => {
|
|
4713
|
+
const conditionPath = `${pathName}.conditions[${conditionIndex}]`;
|
|
4714
|
+
if (!isRecord3(condition)) {
|
|
4715
|
+
nextErrors.push(`${conditionPath} must be a condition object or nested condition group.`);
|
|
4716
|
+
return;
|
|
4717
|
+
}
|
|
4718
|
+
if (Array.isArray(condition.conditions) || typeof condition.logic === "string") {
|
|
4719
|
+
visitConditionGroup(condition, conditionPath);
|
|
4720
|
+
return;
|
|
4721
|
+
}
|
|
4722
|
+
const leftValue = typeof condition.leftValue === "string" ? condition.leftValue.trim() : "";
|
|
4723
|
+
if (!leftValue) {
|
|
4724
|
+
nextErrors.push(`${conditionPath}.leftValue is required and must match a form_template rule.field value.`);
|
|
4725
|
+
}
|
|
4726
|
+
const leftValueType = typeof condition.leftValueType === "string" && condition.leftValueType.trim() ? condition.leftValueType.trim() : "field";
|
|
4727
|
+
if (leftValueType !== "field" && leftValueType !== "constant" && leftValueType !== "variable") {
|
|
4728
|
+
nextErrors.push(`${conditionPath}.leftValueType must be field, constant, or variable.`);
|
|
4729
|
+
}
|
|
4730
|
+
const operator = typeof condition.operator === "string" ? condition.operator.trim() : "";
|
|
4731
|
+
if (!operator || !FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS.has(operator)) {
|
|
4732
|
+
nextErrors.push(`${conditionPath}.operator must be one of ${Array.from(FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS).join(", ")}.`);
|
|
4733
|
+
}
|
|
4734
|
+
const rightValueType = typeof condition.rightValueType === "string" && condition.rightValueType.trim() ? condition.rightValueType.trim() : "constant";
|
|
4735
|
+
if (rightValueType !== "field" && rightValueType !== "constant" && rightValueType !== "variable") {
|
|
4736
|
+
nextErrors.push(`${conditionPath}.rightValueType must be field, constant, or variable.`);
|
|
4737
|
+
}
|
|
4738
|
+
const isWewfDerived = condition._wewf_operator !== void 0 || condition._wewf_source_rule_id !== void 0 || condition._wewf_field_key !== void 0;
|
|
4739
|
+
if (isWewfDerived && condition._bpmax_editor_field_resolved !== true) {
|
|
4740
|
+
nextErrors.push(
|
|
4741
|
+
`${conditionPath} is WEWF-derived but does not prove BPMAX editor field resolution; leftValue must be resolved from form_template rule.field (for example main.<field_key>) before using condition_mode=standard.`
|
|
4742
|
+
);
|
|
4743
|
+
}
|
|
4744
|
+
if (isWewfDerived && typeof condition._wewf_field_key === "string" && condition._wewf_field_key.trim() && condition._wewf_field_key.trim() === leftValue && !leftValue.includes(".")) {
|
|
4745
|
+
nextErrors.push(
|
|
4746
|
+
`${conditionPath}.leftValue (${leftValue}) still looks like a raw WEWF field key; standard condition editor values must use the BPMAX form_template rule.field value.`
|
|
4747
|
+
);
|
|
4748
|
+
}
|
|
4749
|
+
});
|
|
4750
|
+
};
|
|
4751
|
+
nodes.forEach((node, nodeIndex) => {
|
|
4752
|
+
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
|
|
4753
|
+
const conditionalNodes = Array.isArray(node.condational_nodes) ? node.condational_nodes : [];
|
|
4754
|
+
conditionalNodes.forEach((conditionNode, conditionIndex) => {
|
|
4755
|
+
if (!isRecord3(conditionNode)) {
|
|
4756
|
+
return;
|
|
4757
|
+
}
|
|
4758
|
+
const conditionMode = typeof conditionNode.condition_mode === "string" && conditionNode.condition_mode.trim() ? conditionNode.condition_mode.trim() : "code";
|
|
4759
|
+
if (conditionMode !== "standard") {
|
|
4760
|
+
return;
|
|
4761
|
+
}
|
|
4762
|
+
const conditionPath = `${nodeName}.condational_nodes[${conditionIndex}]`;
|
|
4763
|
+
if (!Array.isArray(conditionNode.condition_result_rules)) {
|
|
4764
|
+
nextErrors.push(`${conditionPath}.condition_result_rules must be an array when condition_mode is standard.`);
|
|
4765
|
+
return;
|
|
4766
|
+
}
|
|
4767
|
+
const resultLength = Array.isArray(conditionNode.result) ? conditionNode.result.length : 0;
|
|
4768
|
+
if (conditionNode.condition_result_rules.length !== resultLength) {
|
|
4769
|
+
nextErrors.push(`${conditionPath}.condition_result_rules length must equal result length (${resultLength}).`);
|
|
4770
|
+
}
|
|
4771
|
+
conditionNode.condition_result_rules.forEach((group, groupIndex) => {
|
|
4772
|
+
visitConditionGroup(group, `${conditionPath}.condition_result_rules[${groupIndex}]`);
|
|
4773
|
+
});
|
|
4774
|
+
});
|
|
4775
|
+
});
|
|
4776
|
+
if (!nextErrors.length) {
|
|
4777
|
+
return;
|
|
4778
|
+
}
|
|
4779
|
+
if (errors) {
|
|
4780
|
+
errors.push(...nextErrors);
|
|
4781
|
+
return;
|
|
4782
|
+
}
|
|
4783
|
+
throw new Error(`flow-template standard condition editor gate failed: ${nextErrors.join("; ")}`);
|
|
4784
|
+
}
|
|
4613
4785
|
function looksLikeParseEvalFunctionBody(script) {
|
|
4614
4786
|
const text5 = script.trim();
|
|
4615
4787
|
if (!text5) {
|
|
@@ -5286,6 +5458,8 @@ function normalizeFlowTemplatePayload(work) {
|
|
|
5286
5458
|
validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
|
|
5287
5459
|
validateFlowTemplateStartConditionalJump({ ...work, data });
|
|
5288
5460
|
validateFlowTemplateApproveActionShape({ ...work, data });
|
|
5461
|
+
validateFlowTemplatePluginRejectionControl({ ...work, data });
|
|
5462
|
+
validateFlowTemplateStandardConditionEditorRules({ ...work, data });
|
|
5289
5463
|
validateFlowTemplateCodeModeMessages({ ...work, data });
|
|
5290
5464
|
validateFlowTemplateRuntimeScripts({ ...work, data });
|
|
5291
5465
|
validateFlowTemplateFeishuChatPlugin({ ...work, data });
|
|
@@ -7163,6 +7337,8 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
7163
7337
|
validateFlowTemplateStandardPageCreateFormTemplate(work);
|
|
7164
7338
|
validateFlowTemplateStartConditionalJump(work);
|
|
7165
7339
|
validateFlowTemplateApproveActionShape(work);
|
|
7340
|
+
validateFlowTemplatePluginRejectionControl(work);
|
|
7341
|
+
validateFlowTemplateStandardConditionEditorRules(work);
|
|
7166
7342
|
validateFlowTemplateCodeModeMessages(work);
|
|
7167
7343
|
validateFlowTemplateRuntimeScripts(work);
|
|
7168
7344
|
validateFlowTemplateFeishuChatPlugin(work);
|
|
@@ -8060,6 +8236,8 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
8060
8236
|
validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
|
|
8061
8237
|
validateFlowTemplateStartConditionalJump(flowWork, errors);
|
|
8062
8238
|
validateFlowTemplateApproveActionShape(flowWork, errors);
|
|
8239
|
+
validateFlowTemplatePluginRejectionControl(flowWork, errors);
|
|
8240
|
+
validateFlowTemplateStandardConditionEditorRules(flowWork, errors);
|
|
8063
8241
|
validateFlowTemplateCodeModeMessages(flowWork, errors);
|
|
8064
8242
|
validateFlowTemplateRuntimeScripts(flowWork, errors);
|
|
8065
8243
|
validateFlowTemplateFeishuChatPlugin(flowWork, errors);
|
|
@@ -8414,6 +8592,8 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
8414
8592
|
validateFlowTemplateStandardPageCreateFormTemplate(submit.payload);
|
|
8415
8593
|
validateFlowTemplateStartConditionalJump(submit.payload);
|
|
8416
8594
|
validateFlowTemplateApproveActionShape(submit.payload);
|
|
8595
|
+
validateFlowTemplatePluginRejectionControl(submit.payload);
|
|
8596
|
+
validateFlowTemplateStandardConditionEditorRules(submit.payload);
|
|
8417
8597
|
validateFlowTemplateCodeModeMessages(submit.payload);
|
|
8418
8598
|
validateFlowTemplateRuntimeScripts(submit.payload);
|
|
8419
8599
|
validateFlowTemplateFeishuChatPlugin(submit.payload);
|
|
@@ -12790,6 +12970,155 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
12790
12970
|
});
|
|
12791
12971
|
}
|
|
12792
12972
|
|
|
12973
|
+
// src/commands/issue.ts
|
|
12974
|
+
import { readFile as readFile12 } from "fs/promises";
|
|
12975
|
+
|
|
12976
|
+
// src/core/issues.ts
|
|
12977
|
+
import axios7, { AxiosHeaders as AxiosHeaders3 } from "axios";
|
|
12978
|
+
var DEFAULT_GITLAB_URL = "https://gitlab.yitaiyitai.com";
|
|
12979
|
+
var DEFAULT_GITLAB_PROJECT = "bpmax/bpmax-cli";
|
|
12980
|
+
function normalizeBaseUrl2(baseUrl = DEFAULT_GITLAB_URL) {
|
|
12981
|
+
const normalized = baseUrl.trim().replace(/\/+$/g, "");
|
|
12982
|
+
if (!normalized) {
|
|
12983
|
+
throw new Error("GitLab base URL is required.");
|
|
12984
|
+
}
|
|
12985
|
+
return normalized;
|
|
12986
|
+
}
|
|
12987
|
+
function normalizeGitLabProject(project = DEFAULT_GITLAB_PROJECT) {
|
|
12988
|
+
const normalized = project.trim().replace(/^\/+|\/+$/g, "");
|
|
12989
|
+
if (!normalized) {
|
|
12990
|
+
throw new Error("GitLab project is required.");
|
|
12991
|
+
}
|
|
12992
|
+
return normalized;
|
|
12993
|
+
}
|
|
12994
|
+
function gitLabProjectApiPath(project = DEFAULT_GITLAB_PROJECT) {
|
|
12995
|
+
return encodeURIComponent(normalizeGitLabProject(project));
|
|
12996
|
+
}
|
|
12997
|
+
function buildGitLabIssuePayload(input) {
|
|
12998
|
+
const title = input.title.trim();
|
|
12999
|
+
if (!title) {
|
|
13000
|
+
throw new Error("Issue title is required.");
|
|
13001
|
+
}
|
|
13002
|
+
const description = input.description?.trim();
|
|
13003
|
+
const labels = (input.labels || []).map((label) => label.trim()).filter(Boolean);
|
|
13004
|
+
const assigneeIds = (input.assigneeIds || []).filter((id) => Number.isInteger(id) && id > 0);
|
|
13005
|
+
return {
|
|
13006
|
+
title,
|
|
13007
|
+
...description ? { description } : {},
|
|
13008
|
+
...labels.length > 0 ? { labels: labels.join(",") } : {},
|
|
13009
|
+
...assigneeIds.length > 0 ? { assignee_ids: assigneeIds } : {},
|
|
13010
|
+
...input.confidential !== void 0 ? { confidential: input.confidential } : {}
|
|
13011
|
+
};
|
|
13012
|
+
}
|
|
13013
|
+
function resolveGitLabToken(options) {
|
|
13014
|
+
const env = options.env || process.env;
|
|
13015
|
+
const candidates = [
|
|
13016
|
+
options.tokenEnv ? env[options.tokenEnv] : void 0,
|
|
13017
|
+
env.GITLAB_TOKEN,
|
|
13018
|
+
env.GL_TOKEN,
|
|
13019
|
+
env.PRIVATE_TOKEN
|
|
13020
|
+
];
|
|
13021
|
+
const token = candidates.find((candidate) => candidate?.trim());
|
|
13022
|
+
if (!token) {
|
|
13023
|
+
const envHint = options.tokenEnv ? options.tokenEnv : "GITLAB_TOKEN";
|
|
13024
|
+
throw new Error(`GitLab token is required. Set ${envHint}.`);
|
|
13025
|
+
}
|
|
13026
|
+
return token.trim();
|
|
13027
|
+
}
|
|
13028
|
+
async function createGitLabIssue(input, options) {
|
|
13029
|
+
const token = options.token.trim();
|
|
13030
|
+
if (!token) {
|
|
13031
|
+
throw new Error("GitLab token is required.");
|
|
13032
|
+
}
|
|
13033
|
+
const baseUrl = normalizeBaseUrl2(options.baseUrl);
|
|
13034
|
+
const projectPath = gitLabProjectApiPath(options.project);
|
|
13035
|
+
const client = options.client || axios7.create({ baseURL: baseUrl });
|
|
13036
|
+
const headers = AxiosHeaders3.from();
|
|
13037
|
+
headers.set("PRIVATE-TOKEN", token);
|
|
13038
|
+
const response = await client.request({
|
|
13039
|
+
method: "POST",
|
|
13040
|
+
url: `/api/v4/projects/${projectPath}/issues`,
|
|
13041
|
+
headers,
|
|
13042
|
+
data: buildGitLabIssuePayload(input)
|
|
13043
|
+
});
|
|
13044
|
+
return response.data;
|
|
13045
|
+
}
|
|
13046
|
+
|
|
13047
|
+
// src/commands/issue.ts
|
|
13048
|
+
async function readDescription(options) {
|
|
13049
|
+
if (options.descriptionFile && options.description) {
|
|
13050
|
+
throw new Error("Use either --description or --description-file, not both.");
|
|
13051
|
+
}
|
|
13052
|
+
if (!options.descriptionFile) {
|
|
13053
|
+
return options.description;
|
|
13054
|
+
}
|
|
13055
|
+
return readFile12(options.descriptionFile, "utf8");
|
|
13056
|
+
}
|
|
13057
|
+
function parseAssigneeIds(values) {
|
|
13058
|
+
return (values || []).flatMap(
|
|
13059
|
+
(value) => value.split(",").map((part) => {
|
|
13060
|
+
const parsed = Number(part.trim());
|
|
13061
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
13062
|
+
throw new Error(`Invalid assignee id: ${part}`);
|
|
13063
|
+
}
|
|
13064
|
+
return parsed;
|
|
13065
|
+
})
|
|
13066
|
+
);
|
|
13067
|
+
}
|
|
13068
|
+
async function buildIssueInput(options) {
|
|
13069
|
+
return {
|
|
13070
|
+
title: options.title,
|
|
13071
|
+
description: await readDescription(options),
|
|
13072
|
+
labels: options.label || [],
|
|
13073
|
+
assigneeIds: parseAssigneeIds(options.assigneeId),
|
|
13074
|
+
confidential: options.confidential
|
|
13075
|
+
};
|
|
13076
|
+
}
|
|
13077
|
+
function prettyCreatedIssue(issue3) {
|
|
13078
|
+
return issue3.web_url;
|
|
13079
|
+
}
|
|
13080
|
+
function registerIssueCommands(program2, deps = {}) {
|
|
13081
|
+
const createIssue = deps.createIssue || createGitLabIssue;
|
|
13082
|
+
const issue3 = program2.command("issue").description("Report bugs and create GitLab issues for bpmax-cli");
|
|
13083
|
+
const registerCreateLike = (name) => {
|
|
13084
|
+
issue3.command(name).description(name === "create" ? "Create a GitLab issue" : "Report a bug as a GitLab issue").requiredOption("--title <title>", "Issue title").option("--description <text>", "Issue description").option("--description-file <file>", "Read issue description from a file").option("--label <label>", "Issue label, repeatable", (value, previous = []) => [...previous, value], []).option("--assignee-id <id>", "GitLab assignee id, repeatable or comma-separated", (value, previous = []) => [...previous, value], []).option("--confidential", "Create a confidential issue").option("--gitlab-url <url>", "GitLab base URL", DEFAULT_GITLAB_URL).option("--project <path>", "GitLab project path or id", DEFAULT_GITLAB_PROJECT).option("--token-env <name>", "Environment variable name that contains the GitLab token").option("--dry-run", "Print the GitLab issue payload without submitting").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
13085
|
+
const input = await buildIssueInput(options);
|
|
13086
|
+
const payload = buildGitLabIssuePayload(input);
|
|
13087
|
+
const project = options.project || DEFAULT_GITLAB_PROJECT;
|
|
13088
|
+
const gitlabUrl = options.gitlabUrl || DEFAULT_GITLAB_URL;
|
|
13089
|
+
if (options.dryRun) {
|
|
13090
|
+
printResult(options.format, {
|
|
13091
|
+
ok: true,
|
|
13092
|
+
dry_run: true,
|
|
13093
|
+
gitlab_url: gitlabUrl,
|
|
13094
|
+
project,
|
|
13095
|
+
payload
|
|
13096
|
+
});
|
|
13097
|
+
return;
|
|
13098
|
+
}
|
|
13099
|
+
const token = resolveGitLabToken({
|
|
13100
|
+
tokenEnv: options.tokenEnv,
|
|
13101
|
+
env: deps.env
|
|
13102
|
+
});
|
|
13103
|
+
const created = await createIssue(input, {
|
|
13104
|
+
baseUrl: gitlabUrl,
|
|
13105
|
+
project,
|
|
13106
|
+
token
|
|
13107
|
+
});
|
|
13108
|
+
if (options.format === "pretty") {
|
|
13109
|
+
printResult("pretty", prettyCreatedIssue(created));
|
|
13110
|
+
return;
|
|
13111
|
+
}
|
|
13112
|
+
printResult(options.format, {
|
|
13113
|
+
ok: true,
|
|
13114
|
+
issue: created
|
|
13115
|
+
});
|
|
13116
|
+
});
|
|
13117
|
+
};
|
|
13118
|
+
registerCreateLike("create");
|
|
13119
|
+
registerCreateLike("report");
|
|
13120
|
+
}
|
|
13121
|
+
|
|
12793
13122
|
// src/commands/memory.ts
|
|
12794
13123
|
function parseLimit(input, fallback) {
|
|
12795
13124
|
const value = Number(input ?? fallback);
|
|
@@ -12870,7 +13199,7 @@ function registerMemoryCommands(program2) {
|
|
|
12870
13199
|
}
|
|
12871
13200
|
|
|
12872
13201
|
// src/commands/matrix.ts
|
|
12873
|
-
import { readFile as
|
|
13202
|
+
import { readFile as readFile13 } from "fs/promises";
|
|
12874
13203
|
var UUID_VALUE_PATTERN2 = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/i;
|
|
12875
13204
|
var UUID_PATH_PATTERN = /uuid'[^'"\s/]+/i;
|
|
12876
13205
|
async function parseSeedRules(input) {
|
|
@@ -12878,7 +13207,7 @@ async function parseSeedRules(input) {
|
|
|
12878
13207
|
if (source === "") {
|
|
12879
13208
|
throw new Error("--rules file path is empty.");
|
|
12880
13209
|
}
|
|
12881
|
-
const raw = source ? await
|
|
13210
|
+
const raw = source ? await readFile13(source, "utf8") : input;
|
|
12882
13211
|
let parsed;
|
|
12883
13212
|
try {
|
|
12884
13213
|
parsed = JSON.parse(raw);
|
|
@@ -14191,7 +14520,7 @@ import { spawn as spawn2 } from "child_process";
|
|
|
14191
14520
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
14192
14521
|
|
|
14193
14522
|
// src/core/recipes.ts
|
|
14194
|
-
import { access, mkdir as mkdir10, readdir as readdir4, readFile as
|
|
14523
|
+
import { access, mkdir as mkdir10, readdir as readdir4, readFile as readFile14, writeFile as writeFile10 } from "fs/promises";
|
|
14195
14524
|
import path11 from "path";
|
|
14196
14525
|
var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
14197
14526
|
var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
|
|
@@ -14273,7 +14602,7 @@ function parseRecipeDefinition(input) {
|
|
|
14273
14602
|
};
|
|
14274
14603
|
}
|
|
14275
14604
|
async function loadRecipe(recipeDir) {
|
|
14276
|
-
const raw = await
|
|
14605
|
+
const raw = await readFile14(path11.join(recipeDir, "recipe.json"), "utf8");
|
|
14277
14606
|
return parseRecipeDefinition(JSON.parse(raw));
|
|
14278
14607
|
}
|
|
14279
14608
|
async function listRecipes(recipesDir) {
|
|
@@ -14372,7 +14701,7 @@ async function renderArgv(options) {
|
|
|
14372
14701
|
const rendered = [];
|
|
14373
14702
|
for (const token of options.recipe.command.argv) {
|
|
14374
14703
|
if (token.startsWith("@")) {
|
|
14375
|
-
const raw = await
|
|
14704
|
+
const raw = await readFile14(resolveRecipeFile(options.recipeDir, token), "utf8");
|
|
14376
14705
|
rendered.push(renderTemplate(raw, options.variables));
|
|
14377
14706
|
} else {
|
|
14378
14707
|
rendered.push(renderTemplate(token, options.variables));
|
|
@@ -14830,7 +15159,7 @@ function registerSetupCommand(program2, deps = {}) {
|
|
|
14830
15159
|
}
|
|
14831
15160
|
|
|
14832
15161
|
// src/core/taskbook.ts
|
|
14833
|
-
import { mkdir as mkdir11, readFile as
|
|
15162
|
+
import { mkdir as mkdir11, readFile as readFile15, writeFile as writeFile11 } from "fs/promises";
|
|
14834
15163
|
import path12 from "path";
|
|
14835
15164
|
var TaskbookError = class extends Error {
|
|
14836
15165
|
};
|
|
@@ -15038,7 +15367,7 @@ function addUuidIssues(text5, issues, path15) {
|
|
|
15038
15367
|
}
|
|
15039
15368
|
}
|
|
15040
15369
|
async function readTaskbookText(file) {
|
|
15041
|
-
const raw = await
|
|
15370
|
+
const raw = await readFile15(file, "utf8");
|
|
15042
15371
|
try {
|
|
15043
15372
|
const parsed = JSON.parse(raw);
|
|
15044
15373
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -15688,7 +16017,7 @@ import {
|
|
|
15688
16017
|
cp as cp3,
|
|
15689
16018
|
mkdir as mkdir12,
|
|
15690
16019
|
readdir as readdir5,
|
|
15691
|
-
readFile as
|
|
16020
|
+
readFile as readFile16,
|
|
15692
16021
|
rm as rm4,
|
|
15693
16022
|
stat as stat6,
|
|
15694
16023
|
writeFile as writeFile12
|
|
@@ -15746,7 +16075,7 @@ var CONFIG_BASIS_ALLOWED_PREFIXES = [
|
|
|
15746
16075
|
".codex/skills/"
|
|
15747
16076
|
];
|
|
15748
16077
|
var REPORT_REQUIRED_KEYS = ["run_id:", "scenario_id:", "source_suite:", "result:"];
|
|
15749
|
-
var REPORT_EXECUTION_KEYS = ["planned_cases:", "executed_cases:", "precondition_check:", "state_file:", "browser_tool:"];
|
|
16078
|
+
var REPORT_EXECUTION_KEYS = ["planned_cases:", "executed_cases:", "precondition_check:", "state_file:", "report_run:", "browser_tool:", "rerun_policy:"];
|
|
15750
16079
|
var REPORT_REQUIRED_HEADINGS = [
|
|
15751
16080
|
"## 1. \u6D4B\u8BD5\u8303\u56F4",
|
|
15752
16081
|
"## 2. \u6267\u884C\u73AF\u5883",
|
|
@@ -15784,7 +16113,13 @@ var BROWSER_TOOL_RE = /(Chrome DevTools|DevTools|Playwright|AppleScript|browser_
|
|
|
15784
16113
|
var LIVE_DRAFT_RE = /(live|draft|已发布|草稿|发布态|live_draft=)/i;
|
|
15785
16114
|
var MULTI_ROLE_VALUE_RE = /[,、/]\s*[^,、/\s]+|多角色|跨角色/;
|
|
15786
16115
|
var RESUME_POLICY_VALUE_RE = /(full_rerun|checkpoint|evidence_only|从头重跑|检查点|仅补证据)/i;
|
|
16116
|
+
var FULL_RERUN_RE = /(full_rerun|重新运行|全量重跑|从头重跑)/i;
|
|
16117
|
+
var PARTIAL_RERUN_RE = /(checkpoint|evidence_only|检查点|仅补证据)/i;
|
|
16118
|
+
var RUN_MARKER_RE = /\b\d{8}(?:-\d{3})?\b/g;
|
|
15787
16119
|
var NOT_RUN_RE = /(not[_ -]?run|未执行|未跑|跳过)/i;
|
|
16120
|
+
var BLOCKED_RE = /(blocked|阻塞|卡住|无法继续)/i;
|
|
16121
|
+
var PASS_CASE_RE = /\b(pass|passed|success|通过)\b|(^|[||,,;;\s])通过($|[||,,;;\s])/i;
|
|
16122
|
+
var HISTORICAL_EVIDENCE_RE = /(历史|旧报告|旧截图|旧结果|旧状态|复用.*(报告|截图|结果|状态)|historical|old report|old screenshot|old result|reused)/i;
|
|
15788
16123
|
var PAGE_CONCLUSION_RE = /(页面.*(通过|已验证|真实|可见|不可见)|浏览器回归.*(通过|完成)|完整链路.*通过|真实页面.*通过)/;
|
|
15789
16124
|
var TestSuiteError = class extends Error {
|
|
15790
16125
|
code;
|
|
@@ -15808,7 +16143,7 @@ async function exists3(filePath) {
|
|
|
15808
16143
|
}
|
|
15809
16144
|
}
|
|
15810
16145
|
async function readText(filePath) {
|
|
15811
|
-
return
|
|
16146
|
+
return readFile16(filePath, "utf8");
|
|
15812
16147
|
}
|
|
15813
16148
|
function fail(message, options = {}) {
|
|
15814
16149
|
throw new TestSuiteError(message, options);
|
|
@@ -16086,6 +16421,20 @@ function validatePreflightEvidence(filePath, caseId, row, prepTokens) {
|
|
|
16086
16421
|
if (!prepTokens.state_file && !prepTokens.report_run) {
|
|
16087
16422
|
fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E .codex/tmp/e2e_states \u72B6\u6001\u6587\u4EF6\u6216 .ai_test/report/<run> \u62A5\u544A\u8BC1\u636E\u8DEF\u5F84`, { rule_id: "test_suite.case.state_file" });
|
|
16088
16423
|
}
|
|
16424
|
+
const policy = prepTokens.resume_policy;
|
|
16425
|
+
if (!policy || !RESUME_POLICY_VALUE_RE.test(policy)) {
|
|
16426
|
+
fail(`${filePath}:${caseId}: \u6B63\u5F0F E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E \`resume_policy=full_rerun|checkpoint|evidence_only\`\uFF1B\u9ED8\u8BA4\u91CD\u65B0\u8FD0\u884C\u5FC5\u987B\u4F7F\u7528 full_rerun`, { rule_id: "test_suite.case.resume_policy_required" });
|
|
16427
|
+
}
|
|
16428
|
+
if (policy && PARTIAL_RERUN_RE.test(policy) && !/(边界|范围|局部|检查点|仅补证据|用户确认|只验证|scope|boundary|confirmed)/i.test([row.prep_data, row.steps, row.expected_result, row.evidence_required].join(" "))) {
|
|
16429
|
+
fail(`${filePath}:${caseId}: checkpoint/evidence_only \u5FC5\u987B\u5199\u6E05\u5C40\u90E8\u8FB9\u754C\uFF0C\u5386\u53F2\u8BC1\u636E\u4E0D\u5F97\u4F5C\u4E3A\u672C\u8F6E\u901A\u8FC7\u7ED3\u8BBA`, { rule_id: "test_suite.case.resume_policy_boundary" });
|
|
16430
|
+
}
|
|
16431
|
+
for (const [token, value] of Object.entries({ state_file: prepTokens.state_file, report_run: prepTokens.report_run })) {
|
|
16432
|
+
if (!value) continue;
|
|
16433
|
+
const markers = reportRunMarkers(value).filter((marker) => !/<run_id>|<date>|\{run_id\}|\{date\}|\$RUN_ID|\$RUN_DATE/i.test(value));
|
|
16434
|
+
if (markers.length > 0 && !value.includes("<run_id>") && !value.includes("<date>")) {
|
|
16435
|
+
fail(`${filePath}:${caseId}: \`${token}=\` \u4E0D\u5F97\u5199\u6B7B\u5386\u53F2 run/date\uFF1B\u8BF7\u4F7F\u7528\u672C\u8F6E <run_id>/<date> \u6A21\u677F\u6216\u6267\u884C\u65F6\u751F\u6210\u7684\u65B0\u8DEF\u5F84`, { rule_id: "test_suite.case.current_run_template" });
|
|
16436
|
+
}
|
|
16437
|
+
}
|
|
16089
16438
|
}
|
|
16090
16439
|
function validateErrorCaptureEvidence(filePath, caseId, row) {
|
|
16091
16440
|
const caseText = [row.type, row.title, row.preconditions, row.steps, row.expected_result, row.tags].join(" ");
|
|
@@ -16096,8 +16445,9 @@ function validateErrorCaptureEvidence(filePath, caseId, row) {
|
|
|
16096
16445
|
}
|
|
16097
16446
|
}
|
|
16098
16447
|
function validateResumePolicy(filePath, caseId, row, prepTokens) {
|
|
16448
|
+
const manualText = [row.preconditions, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
|
|
16449
|
+
if (!/(人工介入|手工|补救|续跑|dirty_resumed|局部复核|partial rerun)/i.test(manualText)) return;
|
|
16099
16450
|
const text5 = [row.preconditions, row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
|
|
16100
|
-
if (!/(人工介入|手工|补救|续跑|dirty_resumed|resume|局部复核|partial rerun)/i.test(text5)) return;
|
|
16101
16451
|
const policy = prepTokens.resume_policy || text5;
|
|
16102
16452
|
if (!RESUME_POLICY_VALUE_RE.test(policy)) {
|
|
16103
16453
|
fail(`${filePath}:${caseId}: \u4EBA\u5DE5\u4ECB\u5165\u6216\u7EED\u8DD1\u7528\u4F8B\u5FC5\u987B\u58F0\u660E \`resume_policy=full_rerun|checkpoint|evidence_only\``, { rule_id: "test_suite.case.resume_policy" });
|
|
@@ -16334,10 +16684,10 @@ async function fileMap(root) {
|
|
|
16334
16684
|
return result;
|
|
16335
16685
|
}
|
|
16336
16686
|
async function sha256(filePath) {
|
|
16337
|
-
return createHash6("sha256").update(await
|
|
16687
|
+
return createHash6("sha256").update(await readFile16(filePath)).digest("hex");
|
|
16338
16688
|
}
|
|
16339
16689
|
async function readForDiff(filePath) {
|
|
16340
|
-
const buffer = await
|
|
16690
|
+
const buffer = await readFile16(filePath);
|
|
16341
16691
|
if (buffer.includes(0)) return [`<binary sha256=${createHash6("sha256").update(buffer).digest("hex")}>
|
|
16342
16692
|
`];
|
|
16343
16693
|
return buffer.toString("utf8").split(/(?<=\n)/);
|
|
@@ -16639,7 +16989,22 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
|
|
|
16639
16989
|
await mkdir12(path13.join(reportDir, "screenshots"), { recursive: true });
|
|
16640
16990
|
await writeFile12(
|
|
16641
16991
|
path13.join(reportDir, "summary.md"),
|
|
16642
|
-
[
|
|
16992
|
+
[
|
|
16993
|
+
"# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B",
|
|
16994
|
+
"",
|
|
16995
|
+
`run_id: ${path13.basename(reportDir)}`,
|
|
16996
|
+
"rerun_policy: full_rerun",
|
|
16997
|
+
"status: draft",
|
|
16998
|
+
"",
|
|
16999
|
+
"## \u573A\u666F\u62A5\u544A",
|
|
17000
|
+
"",
|
|
17001
|
+
"## \u622A\u56FE\u76EE\u5F55",
|
|
17002
|
+
"",
|
|
17003
|
+
`screenshots: ${path13.join(path13.basename(reportDir), "screenshots")}`,
|
|
17004
|
+
"",
|
|
17005
|
+
"## \u603B\u7ED3",
|
|
17006
|
+
""
|
|
17007
|
+
].join("\n"),
|
|
16643
17008
|
"utf8"
|
|
16644
17009
|
);
|
|
16645
17010
|
}
|
|
@@ -16654,6 +17019,55 @@ function reportCaseList(text5, key) {
|
|
|
16654
17019
|
const value = reportKeyValue(text5, key);
|
|
16655
17020
|
return value.split(/[,\s,、;;]+/).map((item) => item.trim()).filter((item) => /^[A-Za-z0-9_-]+$/.test(item));
|
|
16656
17021
|
}
|
|
17022
|
+
function reportRunDate(runName) {
|
|
17023
|
+
return runName.slice(0, 8);
|
|
17024
|
+
}
|
|
17025
|
+
function reportKeyValues(text5, key) {
|
|
17026
|
+
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17027
|
+
return [...text5.matchAll(new RegExp(`^${escaped}\\s*(.+)$`, "gim"))].map((match) => match[1]?.trim() ?? "").filter(Boolean);
|
|
17028
|
+
}
|
|
17029
|
+
function reportRunMarkers(value) {
|
|
17030
|
+
return [...value.matchAll(RUN_MARKER_RE)].map((match) => match[0]);
|
|
17031
|
+
}
|
|
17032
|
+
function reportContainsHistoricalRun(value, runName) {
|
|
17033
|
+
const runDate = reportRunDate(runName);
|
|
17034
|
+
return reportRunMarkers(value).some((marker) => marker !== runName && marker !== runDate);
|
|
17035
|
+
}
|
|
17036
|
+
function parseReportTime(value) {
|
|
17037
|
+
if (!value.trim()) return null;
|
|
17038
|
+
const date = new Date(value.trim());
|
|
17039
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
17040
|
+
return date;
|
|
17041
|
+
}
|
|
17042
|
+
function reportDayWindow(runName) {
|
|
17043
|
+
const date = reportRunDate(runName);
|
|
17044
|
+
const start = /* @__PURE__ */ new Date(`${date.slice(0, 4)}-${date.slice(4, 6)}-${date.slice(6, 8)}T00:00:00+08:00`);
|
|
17045
|
+
const end = new Date(start.getTime() + 24 * 60 * 60 * 1e3);
|
|
17046
|
+
return { start, end };
|
|
17047
|
+
}
|
|
17048
|
+
function reportExecutionWindow(runName, text5) {
|
|
17049
|
+
const fallback = reportDayWindow(runName);
|
|
17050
|
+
const startedAt = parseReportTime(reportKeyValue(text5, "started_at:"));
|
|
17051
|
+
const finishedAt = parseReportTime(reportKeyValue(text5, "finished_at:"));
|
|
17052
|
+
if (!startedAt || !finishedAt || finishedAt < startedAt) return fallback;
|
|
17053
|
+
return { start: startedAt, end: finishedAt };
|
|
17054
|
+
}
|
|
17055
|
+
function isWithinWindow(date, window) {
|
|
17056
|
+
return date >= window.start && date <= window.end;
|
|
17057
|
+
}
|
|
17058
|
+
function caseEvidencePattern(caseId) {
|
|
17059
|
+
const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17060
|
+
return new RegExp(`\\b${escaped}\\b.*?(screenshots/|\\.ai_test/report/|\\.codex/tmp/e2e|evidence|\u622A\u56FE|\u8BC1\u636E|\u9879\u76EE|project|step)`, "i");
|
|
17061
|
+
}
|
|
17062
|
+
function caseResultPattern(caseId) {
|
|
17063
|
+
const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17064
|
+
return new RegExp(`\\b${escaped}\\b[^\\n]*(pass|passed|success|\u901A\u8FC7)`, "i");
|
|
17065
|
+
}
|
|
17066
|
+
function linesForCase(text5, caseId) {
|
|
17067
|
+
const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17068
|
+
const pattern = new RegExp(`\\b${escaped}\\b`);
|
|
17069
|
+
return text5.split(/\r?\n/).filter((line) => pattern.test(line));
|
|
17070
|
+
}
|
|
16657
17071
|
async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
16658
17072
|
if (!await exists3(root)) return [`report root not found: ${root}`];
|
|
16659
17073
|
const errors = [];
|
|
@@ -16670,9 +17084,20 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
|
16670
17084
|
for (const reportName of scenarioReports) {
|
|
16671
17085
|
const reportPath = path13.join(runDir, reportName);
|
|
16672
17086
|
const text5 = await readText(reportPath);
|
|
16673
|
-
for (const key of REPORT_REQUIRED_KEYS) if (!text5
|
|
16674
|
-
for (const key of REPORT_EXECUTION_KEYS) if (!text5
|
|
17087
|
+
for (const key of REPORT_REQUIRED_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
|
|
17088
|
+
for (const key of REPORT_EXECUTION_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
|
|
16675
17089
|
for (const heading of REPORT_REQUIRED_HEADINGS) if (!text5.includes(heading)) errors.push(`${reportPath}: missing \`${heading}\``);
|
|
17090
|
+
const runId = reportKeyValue(text5, "run_id:");
|
|
17091
|
+
if (runId && runId !== runName) {
|
|
17092
|
+
errors.push(`[test_suite.report.run_id_current] ${reportPath}: run_id \u5FC5\u987B\u7B49\u4E8E\u62A5\u544A\u76EE\u5F55\u540D ${runName}\uFF0C\u4E0D\u80FD\u590D\u7528\u5176\u4ED6 run \u7684\u62A5\u544A\u5934`);
|
|
17093
|
+
}
|
|
17094
|
+
const rerunPolicy = reportKeyValue(text5, "rerun_policy:") || reportKeyValue(text5, "resume_policy:");
|
|
17095
|
+
const isFullRerun = FULL_RERUN_RE.test(rerunPolicy) || /重新运行|全量重跑|从头重跑/.test(text5);
|
|
17096
|
+
const isPartialRerun = PARTIAL_RERUN_RE.test(rerunPolicy);
|
|
17097
|
+
const resultValue = reportKeyValue(text5, "result:").toLowerCase();
|
|
17098
|
+
if (isPartialRerun && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|对照/.test(resultValue)) {
|
|
17099
|
+
errors.push(`[test_suite.report.partial_policy_result] ${reportPath}: checkpoint/evidence_only \u53EA\u80FD\u7ED9\u5C40\u90E8\u6216\u5BF9\u7167\u7ED3\u8BBA\uFF0C\u4E0D\u80FD\u58F0\u660E\u5B8C\u6574\u91CD\u65B0\u8FD0\u884C\u901A\u8FC7`);
|
|
17100
|
+
}
|
|
16676
17101
|
const plannedCases = reportCaseList(text5, "planned_cases:");
|
|
16677
17102
|
const executedCases = reportCaseList(text5, "executed_cases:");
|
|
16678
17103
|
const missingExecuted = plannedCases.filter((caseId) => !executedCases.includes(caseId));
|
|
@@ -16683,9 +17108,8 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
|
16683
17108
|
if (unexpectedExecuted.length > 0) {
|
|
16684
17109
|
errors.push(`[test_suite.report.case_reconciliation] ${reportPath}: executed_cases \u5305\u542B\u4E0D\u5728 planned_cases \u4E2D\u7684\u7528\u4F8B: ${unexpectedExecuted.join(", ")}`);
|
|
16685
17110
|
}
|
|
16686
|
-
|
|
16687
|
-
|
|
16688
|
-
errors.push(`[test_suite.report.not_run_downgrade] ${reportPath}: \u62A5\u544A\u5B58\u5728 not-run/\u672A\u6267\u884C\u7528\u4F8B\u4F46 result \u662F\u5B8C\u6574\u7ED3\u8BBA\uFF1B\u5FC5\u987B\u964D\u7EA7\u4E3A partial/stage \u6216\u8BF4\u660E\u7528\u6237\u786E\u8BA4\u7F29\u5C0F\u8303\u56F4`);
|
|
17111
|
+
if ((NOT_RUN_RE.test(text5) || BLOCKED_RE.test(text5)) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
|
|
17112
|
+
errors.push(`[test_suite.report.not_run_downgrade] ${reportPath}: \u62A5\u544A\u5B58\u5728 blocked/not-run/\u672A\u6267\u884C\u7528\u4F8B\u4F46 result \u662F\u5B8C\u6574\u7ED3\u8BBA\uFF1B\u5FC5\u987B\u964D\u7EA7\u4E3A partial/stage/blocked`);
|
|
16689
17113
|
}
|
|
16690
17114
|
if (PAGE_CONCLUSION_RE.test(text5) && !BROWSER_TOOL_RE.test(text5)) {
|
|
16691
17115
|
errors.push(`[test_suite.report.page_conclusion_browser] ${reportPath}: \u9875\u9762/\u6D4F\u89C8\u5668\u7ED3\u8BBA\u5FC5\u987B\u5305\u542B browser_tool \u8BC1\u636E\uFF1BAPI/readback \u4E0D\u80FD\u5192\u5145\u9875\u9762\u9A8C\u8BC1`);
|
|
@@ -16693,10 +17117,24 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
|
16693
17117
|
if (/browser[_ -]?blocked|浏览器阻塞|无可用浏览器工具/i.test(text5) && !/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5)) {
|
|
16694
17118
|
errors.push(`[test_suite.report.browser_blocked] ${reportPath}: \u6D4F\u89C8\u5668\u963B\u585E\u62A5\u544A\u5FC5\u987B\u4F7F\u7528 browser_status: blocked \u6A21\u677F\uFF0C\u5E76\u505C\u6B62\u9875\u9762\u7ED3\u8BBA`);
|
|
16695
17119
|
}
|
|
16696
|
-
const imageRefs = [...text5.matchAll(IMAGE_RE)].map((match) => match[1]);
|
|
16697
|
-
if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
|
|
16698
17120
|
const screenshotsDir = path13.join(runDir, "screenshots");
|
|
16699
17121
|
if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
|
|
17122
|
+
if (isFullRerun) {
|
|
17123
|
+
for (const key of ["state_file:", "precondition_check:", "report_run:"]) {
|
|
17124
|
+
for (const value of reportKeyValues(text5, key)) {
|
|
17125
|
+
const markers = reportRunMarkers(value);
|
|
17126
|
+
const hasCurrentMarker = markers.some((marker) => marker === runName || marker === reportRunDate(runName));
|
|
17127
|
+
if (!hasCurrentMarker || reportContainsHistoricalRun(value, runName)) {
|
|
17128
|
+
errors.push(`[test_suite.report.current_run_state] ${reportPath}: full_rerun \u7684 ${key} \u5FC5\u987B\u6307\u5411\u672C\u8F6E ${runName} \u6216\u672C\u8F6E\u65E5\u671F ${reportRunDate(runName)}\uFF0C\u4E0D\u80FD\u5F15\u7528\u5386\u53F2\u6216\u65E0 run \u6807\u8BB0\u7684\u72B6\u6001/\u62A5\u544A: ${value}`);
|
|
17129
|
+
}
|
|
17130
|
+
}
|
|
17131
|
+
}
|
|
17132
|
+
}
|
|
17133
|
+
const imageMatches = [...text5.matchAll(IMAGE_RE)];
|
|
17134
|
+
const imageRefs = imageMatches.map((match) => match[1]);
|
|
17135
|
+
if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
|
|
17136
|
+
const validCurrentRunImages = [];
|
|
17137
|
+
const window = reportExecutionWindow(runName, text5);
|
|
16700
17138
|
for (const imageRef of imageRefs) {
|
|
16701
17139
|
if (imageRef.includes("://")) {
|
|
16702
17140
|
errors.push(`${reportPath}: screenshot must be a local file under this run's screenshots directory`);
|
|
@@ -16708,7 +17146,30 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
|
16708
17146
|
errors.push(`${reportPath}: image reference must stay under this run's screenshots directory: ${imageRef}`);
|
|
16709
17147
|
continue;
|
|
16710
17148
|
}
|
|
16711
|
-
if (!await exists3(imagePath))
|
|
17149
|
+
if (!await exists3(imagePath)) {
|
|
17150
|
+
errors.push(`${reportPath}: missing image file: ${imageRef}`);
|
|
17151
|
+
continue;
|
|
17152
|
+
}
|
|
17153
|
+
validCurrentRunImages.push(imageRef);
|
|
17154
|
+
if (isFullRerun) {
|
|
17155
|
+
const imageStat = await stat6(imagePath);
|
|
17156
|
+
if (!isWithinWindow(imageStat.mtime, window)) {
|
|
17157
|
+
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}`);
|
|
17158
|
+
}
|
|
17159
|
+
}
|
|
17160
|
+
}
|
|
17161
|
+
if (isFullRerun) {
|
|
17162
|
+
for (const caseId of executedCases) {
|
|
17163
|
+
const caseLines = linesForCase(text5, caseId);
|
|
17164
|
+
const hasPassResult = caseResultPattern(caseId).test(text5) || caseLines.some((line) => PASS_CASE_RE.test(line));
|
|
17165
|
+
const hasCurrentEvidence = caseEvidencePattern(caseId).test(text5) || validCurrentRunImages.some((imageRef) => imageRef.includes(caseId));
|
|
17166
|
+
if (hasPassResult && caseLines.some((line) => HISTORICAL_EVIDENCE_RE.test(line))) {
|
|
17167
|
+
errors.push(`[test_suite.report.case_evidence_current_run] ${reportPath}: full_rerun \u4E2D ${caseId} \u7684\u901A\u8FC7\u7ED3\u8BBA\u4E0D\u80FD\u4F7F\u7528\u5386\u53F2/\u65E7\u62A5\u544A/\u65E7\u622A\u56FE\u4F5C\u4E3A\u672C\u8F6E\u8BC1\u636E`);
|
|
17168
|
+
}
|
|
17169
|
+
if (hasPassResult && !hasCurrentEvidence) {
|
|
17170
|
+
errors.push(`[test_suite.report.case_evidence_current_run] ${reportPath}: full_rerun \u4E2D ${caseId} \u7684\u901A\u8FC7\u7ED3\u8BBA\u5FC5\u987B\u6709\u672C\u8F6E\u622A\u56FE\u3001\u9879\u76EE/step \u6216\u8BC1\u636E\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u590D\u7528\u65E7\u7ED3\u679C`);
|
|
17171
|
+
}
|
|
17172
|
+
}
|
|
16712
17173
|
}
|
|
16713
17174
|
}
|
|
16714
17175
|
}
|
|
@@ -16778,7 +17239,7 @@ function registerTestSuiteCommands(program2) {
|
|
|
16778
17239
|
}
|
|
16779
17240
|
|
|
16780
17241
|
// src/core/update.ts
|
|
16781
|
-
import { access as access2, mkdir as mkdir13, readFile as
|
|
17242
|
+
import { access as access2, mkdir as mkdir13, readFile as readFile17, realpath, writeFile as writeFile13 } from "fs/promises";
|
|
16782
17243
|
import path14 from "path";
|
|
16783
17244
|
var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
16784
17245
|
var UPDATE_STATE_FILE = "update-state.json";
|
|
@@ -16895,7 +17356,7 @@ function updateStatePath(configDir = getConfigDir()) {
|
|
|
16895
17356
|
}
|
|
16896
17357
|
async function readUpdateState(configDir) {
|
|
16897
17358
|
try {
|
|
16898
|
-
const raw = await
|
|
17359
|
+
const raw = await readFile17(updateStatePath(configDir), "utf8");
|
|
16899
17360
|
const parsed = JSON.parse(raw);
|
|
16900
17361
|
if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
|
|
16901
17362
|
return null;
|
|
@@ -17434,6 +17895,7 @@ registerSchemaCommands(program);
|
|
|
17434
17895
|
registerUserCommands(program);
|
|
17435
17896
|
registerEsCommands(program);
|
|
17436
17897
|
registerFlowCommands(program);
|
|
17898
|
+
registerIssueCommands(program);
|
|
17437
17899
|
registerMemoryCommands(program);
|
|
17438
17900
|
registerMatrixCommands(program);
|
|
17439
17901
|
registerPluginCommands(program);
|