bpmax-cli 0.2.1-beta.27 → 0.2.1-beta.28
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 +408 -52
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +1 -0
- package/skills/bpmax-dataset-template-editor/SKILL.md +1 -0
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +3 -0
- package/skills/bpmax-flow-template-editor/SKILL.md +1 -0
- package/skills/bpmax-form-template-editor/SKILL.md +1 -0
- package/skills/bpmax-project/SKILL.md +1 -0
package/dist/bin.js
CHANGED
|
@@ -437,6 +437,9 @@ function flowPageTemplateCapabilityPrefix(path16) {
|
|
|
437
437
|
if (type === "4") {
|
|
438
438
|
return "config.console_template";
|
|
439
439
|
}
|
|
440
|
+
if (type === "6") {
|
|
441
|
+
return "config.step_detail_template";
|
|
442
|
+
}
|
|
440
443
|
return "config.list_template";
|
|
441
444
|
}
|
|
442
445
|
function normalizePath2(path16) {
|
|
@@ -471,7 +474,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
|
|
|
471
474
|
// package.json
|
|
472
475
|
var package_default = {
|
|
473
476
|
name: "bpmax-cli",
|
|
474
|
-
version: "0.2.1-beta.
|
|
477
|
+
version: "0.2.1-beta.28",
|
|
475
478
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
476
479
|
type: "module",
|
|
477
480
|
bin: {
|
|
@@ -4215,6 +4218,18 @@ import path9 from "path";
|
|
|
4215
4218
|
import { createHash as createHash4 } from "crypto";
|
|
4216
4219
|
import { mkdir as mkdir5, readdir as readdir2, readFile as readFile8, writeFile as writeFile5 } from "fs/promises";
|
|
4217
4220
|
import path5 from "path";
|
|
4221
|
+
function configWorkflowError(message, details) {
|
|
4222
|
+
return Object.assign(new Error(message), details);
|
|
4223
|
+
}
|
|
4224
|
+
function errorStatus(error) {
|
|
4225
|
+
if (!isRecord3(error) || !isRecord3(error.response)) return void 0;
|
|
4226
|
+
const status = Number(error.response.status);
|
|
4227
|
+
return Number.isFinite(status) ? status : void 0;
|
|
4228
|
+
}
|
|
4229
|
+
function isJsonParseFailure(error) {
|
|
4230
|
+
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
4231
|
+
return error instanceof SyntaxError || /Unexpected end of JSON input|JSON.*(?:parse|position)|unterminated JSON/i.test(message);
|
|
4232
|
+
}
|
|
4218
4233
|
var NAV_CONFIG_TYPES = ["navmenu", "shortcut", "navmenu_mobile", "shortcut_mobile"];
|
|
4219
4234
|
var NAV_CONTENT_KEY_BY_TYPE = {
|
|
4220
4235
|
navmenu: "navConfig",
|
|
@@ -4246,6 +4261,7 @@ var LOCAL_UUID_DOMAIN_DIR = {
|
|
|
4246
4261
|
"list-template": "think_flow_page_template",
|
|
4247
4262
|
"filter-template": "think_flow_page_template",
|
|
4248
4263
|
"project-detail-template": "think_flow_page_template",
|
|
4264
|
+
"step-detail-template": "think_flow_page_template",
|
|
4249
4265
|
"console-template": "think_flow_page_template",
|
|
4250
4266
|
dataset: "think_data_set",
|
|
4251
4267
|
"dataset-field": "think_data_set_field",
|
|
@@ -4257,6 +4273,7 @@ var REMOTE_UUID_EXPORT_PATH = {
|
|
|
4257
4273
|
"list-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
|
|
4258
4274
|
"filter-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
|
|
4259
4275
|
"project-detail-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
|
|
4276
|
+
"step-detail-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
|
|
4260
4277
|
"console-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`
|
|
4261
4278
|
};
|
|
4262
4279
|
var CONFIG_DOMAINS = {
|
|
@@ -4371,6 +4388,23 @@ var CONFIG_DOMAINS = {
|
|
|
4371
4388
|
writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
|
|
4372
4389
|
notes: ["type=2 project detail template. Create and edit both use the typed flow_page_template adapter; create automatically finalizes data_set_id/flow_type through PUT when needed; activate/delete remain domain-specific operations."]
|
|
4373
4390
|
},
|
|
4391
|
+
"step-detail-template": {
|
|
4392
|
+
capability: "config.step_detail_template",
|
|
4393
|
+
exportPath: (id) => `/flow_page_template/${id}?type=6&skip_i18n=true`,
|
|
4394
|
+
exportStatus: "supported",
|
|
4395
|
+
buildStatus: "supported",
|
|
4396
|
+
submitStatus: "supported",
|
|
4397
|
+
createPath: "/flow_page_template?type=6",
|
|
4398
|
+
createMethod: "POST",
|
|
4399
|
+
deletePath: (id) => `/flow_page_template/${id}?type=6`,
|
|
4400
|
+
deleteMethod: "DELETE",
|
|
4401
|
+
submitPath: (id) => `/flow_page_template/${id}?type=6`,
|
|
4402
|
+
submitMethod: "PUT",
|
|
4403
|
+
expectedType: 6,
|
|
4404
|
+
readEndpoints: ["GET /api/flow_page_template/:id?type=6&skip_i18n=true"],
|
|
4405
|
+
writeEndpoints: ["POST /api/flow_page_template?type=6", "PUT /api/flow_page_template/:id?type=6", "DELETE /api/flow_page_template/:id?type=6"],
|
|
4406
|
+
notes: ["type=6 flow-step detail template referenced by flow node step_detail_id. This domain has its own typed capability and must not be submitted as another page-template type."]
|
|
4407
|
+
},
|
|
4374
4408
|
"console-template": {
|
|
4375
4409
|
capability: "config.console_template",
|
|
4376
4410
|
exportPath: (id) => `/flow_page_template/${id}?skip_i18n=true`,
|
|
@@ -4591,8 +4625,18 @@ function assertFormTemplateDraftId(id, data, action) {
|
|
|
4591
4625
|
const detail = formTemplateDetail(data);
|
|
4592
4626
|
const originTemplateId = numericId(detail.origin_template_id);
|
|
4593
4627
|
if (originTemplateId && originTemplateId > 0) {
|
|
4594
|
-
throw
|
|
4595
|
-
`Refusing to ${action} published form-template id ${id}. Use draft id ${originTemplateId}; published ids are readback-only and must not be used for export/submit/publish
|
|
4628
|
+
throw configWorkflowError(
|
|
4629
|
+
`Refusing to ${action} published form-template id ${id}. Use draft id ${originTemplateId}; published ids are readback-only and must not be used for export/submit/publish.`,
|
|
4630
|
+
{
|
|
4631
|
+
code: "config_form_template_published_readonly",
|
|
4632
|
+
rule_id: "config.form_template.draft_required",
|
|
4633
|
+
domain: "form-template",
|
|
4634
|
+
path: `/form_template/${id}`,
|
|
4635
|
+
published_id: id,
|
|
4636
|
+
draft_id: originTemplateId,
|
|
4637
|
+
request_phase: "readback",
|
|
4638
|
+
suggestion: `Use bpmax-cli config form-template ${action} --id ${originTemplateId} with the editable draft id.`
|
|
4639
|
+
}
|
|
4596
4640
|
);
|
|
4597
4641
|
}
|
|
4598
4642
|
}
|
|
@@ -7101,7 +7145,11 @@ function normalizeDatasetPayload(work) {
|
|
|
7101
7145
|
const basic = isRecord3(work.basic) ? work.basic : work;
|
|
7102
7146
|
const scripts = isRecord3(work.scripts) ? work.scripts : work;
|
|
7103
7147
|
const search = isRecord3(work.search) ? work.search : work;
|
|
7104
|
-
const
|
|
7148
|
+
const fieldCandidates = [work.fields, work.dataSetFields, work.data_set_fields, work.relationFields];
|
|
7149
|
+
const fieldSource = fieldCandidates.find(
|
|
7150
|
+
(candidate) => Array.isArray(candidate) && candidate.length > 0 || isRecord3(candidate) && Array.isArray(candidate.selected) && candidate.selected.length > 0
|
|
7151
|
+
) ?? fieldCandidates.find((candidate) => candidate !== void 0 && candidate !== null);
|
|
7152
|
+
const selectedFields = isRecord3(fieldSource) && Array.isArray(fieldSource.selected) ? fieldSource.selected : Array.isArray(fieldSource) ? fieldSource : [];
|
|
7105
7153
|
const payload = {
|
|
7106
7154
|
name: basic.name || "",
|
|
7107
7155
|
basic_table: basic.basicTable ?? basic.basic_table ?? "",
|
|
@@ -7271,7 +7319,6 @@ function normalizeDatasetFieldPayload(work) {
|
|
|
7271
7319
|
}
|
|
7272
7320
|
const sourcePayload = isRecord3(work.x_wewf_source_payload) ? work.x_wewf_source_payload : {};
|
|
7273
7321
|
const payload = {
|
|
7274
|
-
data_set_id: firstNonEmpty(work.data_set_id, work.dataSetId, work.dataset_id, sourcePayload.data_set_id, sourcePayload.dataSetId, sourcePayload.dataset_id),
|
|
7275
7322
|
name: work.name || "",
|
|
7276
7323
|
key: work.key || work.field || "",
|
|
7277
7324
|
type: work.type || "",
|
|
@@ -7285,6 +7332,16 @@ function normalizeDatasetFieldPayload(work) {
|
|
|
7285
7332
|
relation_flow: normalizeRelationFlow(source.relationFlow ?? source.relation_flow ?? {}),
|
|
7286
7333
|
post_script: normalizeOptionalText(work.postScript ?? work.post_script ?? "")
|
|
7287
7334
|
};
|
|
7335
|
+
if (mode === "create") {
|
|
7336
|
+
payload.data_set_id = firstNonEmpty(
|
|
7337
|
+
work.data_set_id,
|
|
7338
|
+
work.dataSetId,
|
|
7339
|
+
work.dataset_id,
|
|
7340
|
+
sourcePayload.data_set_id,
|
|
7341
|
+
sourcePayload.dataSetId,
|
|
7342
|
+
sourcePayload.dataset_id
|
|
7343
|
+
);
|
|
7344
|
+
}
|
|
7288
7345
|
if (work.classify === "virtual") {
|
|
7289
7346
|
const virtual = isRecord3(work.virtual) ? work.virtual : {};
|
|
7290
7347
|
payload.source_table = virtual.sql || "";
|
|
@@ -8879,7 +8936,7 @@ function buildDomainSubmitPayload(domain, work, options = {}, raw) {
|
|
|
8879
8936
|
if (domain === "nav-config") {
|
|
8880
8937
|
return buildNavConfigSubmitPayload(work, isRecord3(raw) ? raw : void 0, options);
|
|
8881
8938
|
}
|
|
8882
|
-
if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "console-template") {
|
|
8939
|
+
if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "step-detail-template" || domain === "console-template") {
|
|
8883
8940
|
return normalizePageTemplatePayload(domain, work);
|
|
8884
8941
|
}
|
|
8885
8942
|
throw new Error(`${CONFIG_SUBMIT_UNSUPPORTED_MESSAGE} Domain: ${domain}.`);
|
|
@@ -9605,6 +9662,24 @@ function normalizeComparableFieldKeys(value) {
|
|
|
9605
9662
|
});
|
|
9606
9663
|
return [...new Set(keys)].sort();
|
|
9607
9664
|
}
|
|
9665
|
+
function canonicalFormTemplateValues(value) {
|
|
9666
|
+
if (!Array.isArray(value)) {
|
|
9667
|
+
return value;
|
|
9668
|
+
}
|
|
9669
|
+
return [...value].sort((left, right) => {
|
|
9670
|
+
const identity = (item) => {
|
|
9671
|
+
if (!isRecord3(item)) return `~${JSON.stringify(item)}`;
|
|
9672
|
+
for (const key of ["field", "key", "id", "uuid", "guid", "name"]) {
|
|
9673
|
+
const candidate = item[key];
|
|
9674
|
+
if (candidate !== void 0 && candidate !== null && String(candidate).trim()) {
|
|
9675
|
+
return `${key}:${String(candidate).trim()}`;
|
|
9676
|
+
}
|
|
9677
|
+
}
|
|
9678
|
+
return `~${JSON.stringify(item)}`;
|
|
9679
|
+
};
|
|
9680
|
+
return identity(left).localeCompare(identity(right));
|
|
9681
|
+
});
|
|
9682
|
+
}
|
|
9608
9683
|
function normalizeTypedReadbackComparable(domain, value) {
|
|
9609
9684
|
let comparable2 = value;
|
|
9610
9685
|
try {
|
|
@@ -9615,6 +9690,9 @@ function normalizeTypedReadbackComparable(domain, value) {
|
|
|
9615
9690
|
return comparable2;
|
|
9616
9691
|
}
|
|
9617
9692
|
const normalized = { ...comparable2 };
|
|
9693
|
+
if (domain === "form-template") {
|
|
9694
|
+
normalized.value = canonicalFormTemplateValues(normalized.value);
|
|
9695
|
+
}
|
|
9618
9696
|
if (domain === "dataset") {
|
|
9619
9697
|
normalized.refresh_setting = refreshSettingToSubmit(normalized.refresh_setting);
|
|
9620
9698
|
const raw = isRecord3(value) ? value : {};
|
|
@@ -9627,7 +9705,7 @@ function normalizeTypedReadbackComparable(domain, value) {
|
|
|
9627
9705
|
normalized.data_set_id ?? normalized.dataSetId ?? normalized.dataset_id
|
|
9628
9706
|
);
|
|
9629
9707
|
}
|
|
9630
|
-
if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "console-template") {
|
|
9708
|
+
if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "step-detail-template" || domain === "console-template") {
|
|
9631
9709
|
if (Object.prototype.hasOwnProperty.call(normalized, "data_set_id")) {
|
|
9632
9710
|
normalized.data_set_id = normalizeComparableId(normalized.data_set_id);
|
|
9633
9711
|
}
|
|
@@ -9685,7 +9763,7 @@ function assertJsonSubset(expected, actual, label) {
|
|
|
9685
9763
|
}
|
|
9686
9764
|
}
|
|
9687
9765
|
function isPageTemplateCreateFinalizeDomain(domain) {
|
|
9688
|
-
return domain === "list-template" || domain === "filter-template" || domain === "project-detail-template";
|
|
9766
|
+
return domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "step-detail-template";
|
|
9689
9767
|
}
|
|
9690
9768
|
function pageTemplateCreateNeedsFinalize(domain, payload, comparison) {
|
|
9691
9769
|
if (!isPageTemplateCreateFinalizeDomain(domain)) {
|
|
@@ -9806,7 +9884,11 @@ async function inspectFlowAppContext(config, profile, options) {
|
|
|
9806
9884
|
}
|
|
9807
9885
|
function comparableSubmitPayload(domain, value, options) {
|
|
9808
9886
|
const comparable2 = domain === "form-template" && options.ignoreServerFields ? stripServerFilledFields(value, FORM_TEMPLATE_SERVER_FIELD_KEYS) : value;
|
|
9809
|
-
|
|
9887
|
+
const normalized = normalizeTypedReadbackComparable(domain, comparable2);
|
|
9888
|
+
if (!isRecord3(normalized)) {
|
|
9889
|
+
throw new Error(`${domain} verify comparable payload must be an object.`);
|
|
9890
|
+
}
|
|
9891
|
+
return normalized;
|
|
9810
9892
|
}
|
|
9811
9893
|
function diffMismatchCount(diff) {
|
|
9812
9894
|
const counts = isRecord3(diff?.counts) ? diff.counts : {};
|
|
@@ -10108,7 +10190,27 @@ async function exportConfigDomain(config, profile, domain, id, outDir, options =
|
|
|
10108
10190
|
throw new Error(definition.unsupportedExportReason || `Config export is not implemented for ${domain}.`);
|
|
10109
10191
|
}
|
|
10110
10192
|
await ensureConfigCapability(profile, `${definition.capability}.export`);
|
|
10111
|
-
|
|
10193
|
+
let data;
|
|
10194
|
+
try {
|
|
10195
|
+
data = await readRemoteConfigDomain(profile, domain, id, definition);
|
|
10196
|
+
} catch (error) {
|
|
10197
|
+
if (domain === "form-template" && options.workFormat === "structured" && isJsonParseFailure(error)) {
|
|
10198
|
+
throw configWorkflowError(
|
|
10199
|
+
`\u65E0\u6CD5\u89E3\u6790 form-template ${id} \u7684\u7ED3\u6784\u5316\u5BFC\u51FA\u54CD\u5E94\uFF1B\u8BE5 ID \u53EF\u80FD\u662F\u53EA\u8BFB\u53D1\u5E03\u6001\uFF0C\u6216\u5E73\u53F0\u8FD4\u56DE\u4E86\u622A\u65AD JSON\u3002`,
|
|
10200
|
+
{
|
|
10201
|
+
code: "config_form_template_structured_export_failed",
|
|
10202
|
+
rule_id: "config.form_template.structured_export_response",
|
|
10203
|
+
domain,
|
|
10204
|
+
path: `/form_template/${id}`,
|
|
10205
|
+
published_id: id,
|
|
10206
|
+
draft_id: null,
|
|
10207
|
+
request_phase: "readback",
|
|
10208
|
+
suggestion: "\u5148\u4ECE\u6D41\u7A0B meta.form_template \u786E\u8BA4\u53D1\u5E03\u6001 ID\uFF0C\u518D\u4F7F\u7528\u5E73\u53F0\u8FD4\u56DE\u7684 origin_template_id \u5BF9\u5E94\u8349\u7A3F ID\u6267\u884C structured export\u3002"
|
|
10209
|
+
}
|
|
10210
|
+
);
|
|
10211
|
+
}
|
|
10212
|
+
throw error;
|
|
10213
|
+
}
|
|
10112
10214
|
if (domain === "form-template") {
|
|
10113
10215
|
assertFormTemplateDraftId(id, data, "export");
|
|
10114
10216
|
}
|
|
@@ -10178,7 +10280,8 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
10178
10280
|
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
10179
10281
|
}
|
|
10180
10282
|
}
|
|
10181
|
-
const
|
|
10283
|
+
const payloadWork = domain === "dataset-field" && createMode && isRecord3(work) ? { ...work, mode: "create" } : work;
|
|
10284
|
+
const payload = buildDomainSubmitPayload(domain, payloadWork, options, raw);
|
|
10182
10285
|
if (domain === "flow-template" && options.publishLive) {
|
|
10183
10286
|
payload.publish_live = true;
|
|
10184
10287
|
}
|
|
@@ -10301,6 +10404,13 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
10301
10404
|
if (Object.prototype.hasOwnProperty.call(value, "classify") && Object.prototype.hasOwnProperty.call(value, "source_table")) {
|
|
10302
10405
|
lintDatasetFieldWork(value, errors);
|
|
10303
10406
|
}
|
|
10407
|
+
if (options.domain === "dataset") {
|
|
10408
|
+
try {
|
|
10409
|
+
normalizeDatasetPayload(value);
|
|
10410
|
+
} catch (error) {
|
|
10411
|
+
errors.push(error instanceof Error ? error.message : String(error));
|
|
10412
|
+
}
|
|
10413
|
+
}
|
|
10304
10414
|
if (Object.prototype.hasOwnProperty.call(value, "content")) {
|
|
10305
10415
|
lintTemplateFieldReferences(value, errors);
|
|
10306
10416
|
}
|
|
@@ -10868,6 +10978,13 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10868
10978
|
let endpoint = definition.submitPath(id);
|
|
10869
10979
|
let submitPayload = submit.payload;
|
|
10870
10980
|
let publishMode;
|
|
10981
|
+
if (domain === "dataset-field") {
|
|
10982
|
+
const datasetFieldPayload = { ...submit.payload };
|
|
10983
|
+
delete datasetFieldPayload.data_set_id;
|
|
10984
|
+
delete datasetFieldPayload.dataSetId;
|
|
10985
|
+
delete datasetFieldPayload.dataset_id;
|
|
10986
|
+
submitPayload = datasetFieldPayload;
|
|
10987
|
+
}
|
|
10871
10988
|
if (domain === "flow-template") {
|
|
10872
10989
|
const flowPayload = { ...submit.payload };
|
|
10873
10990
|
if (options.publishLive) {
|
|
@@ -10884,6 +11001,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10884
11001
|
})}`;
|
|
10885
11002
|
submitPayload = flowPayload;
|
|
10886
11003
|
}
|
|
11004
|
+
const mutationDiff = diffJsonNormalized(domain, current, submitPayload);
|
|
10887
11005
|
if (confirm3 !== expectedConfirm) {
|
|
10888
11006
|
return {
|
|
10889
11007
|
...dryRunFields(expectedConfirm),
|
|
@@ -10893,18 +11011,53 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10893
11011
|
method: definition.submitMethod,
|
|
10894
11012
|
payload: submitPayload,
|
|
10895
11013
|
...publishMode ? { publish_mode: publishMode } : {},
|
|
10896
|
-
diff:
|
|
11014
|
+
diff: mutationDiff,
|
|
10897
11015
|
current_hash: currentHash,
|
|
10898
11016
|
next: `Run again with --confirm "${expectedConfirm}" to submit.`
|
|
10899
11017
|
};
|
|
10900
11018
|
}
|
|
10901
11019
|
const client = createApiClient(profile);
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
11020
|
+
let response;
|
|
11021
|
+
try {
|
|
11022
|
+
response = await apiRequest(
|
|
11023
|
+
client,
|
|
11024
|
+
definition.submitMethod,
|
|
11025
|
+
endpoint,
|
|
11026
|
+
{ data: submitPayload, capability: `${definition.capability}.submit` }
|
|
11027
|
+
);
|
|
11028
|
+
} catch (error) {
|
|
11029
|
+
let remoteWriteState = "unknown";
|
|
11030
|
+
let readbackConfirmed = false;
|
|
11031
|
+
let readbackError;
|
|
11032
|
+
try {
|
|
11033
|
+
const safeReadback = await readRemoteConfigDomain(profile, domain, id, definition);
|
|
11034
|
+
readbackConfirmed = compareTypedReadback(domain, submitPayload, safeReadback).ok;
|
|
11035
|
+
remoteWriteState = readbackConfirmed ? "confirmed" : hashJson(safeReadback) === currentHash ? "not_started" : "unknown";
|
|
11036
|
+
} catch (readError) {
|
|
11037
|
+
readbackError = readError instanceof Error ? readError.message : String(readError ?? "");
|
|
11038
|
+
}
|
|
11039
|
+
const status = errorStatus(error);
|
|
11040
|
+
const remoteError = error instanceof Error ? error.message : String(error ?? "");
|
|
11041
|
+
const changedPaths = Array.isArray(mutationDiff.changed_paths) ? mutationDiff.changed_paths : [];
|
|
11042
|
+
throw configWorkflowError(
|
|
11043
|
+
`${domain} \u63D0\u4EA4\u5728\u8FDC\u7AEF\u5199\u5165\u9636\u6BB5\u5931\u8D25${status ? `\uFF08HTTP ${status}\uFF09` : ""}\uFF1B\u8FDC\u7AEF\u5199\u5165\u72B6\u6001\u4E3A ${remoteWriteState}\u3002${remoteWriteState === "unknown" ? " \u5728\u5B8C\u6210\u53EA\u8BFB\u56DE\u8BFB\u524D\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u3002" : ""}`,
|
|
11044
|
+
{
|
|
11045
|
+
code: "config_remote_mutation_failed",
|
|
11046
|
+
rule_id: "config.submit.remote_mutation",
|
|
11047
|
+
domain,
|
|
11048
|
+
path: endpoint,
|
|
11049
|
+
request_phase: "mutation",
|
|
11050
|
+
http_status: status ?? null,
|
|
11051
|
+
remote_error: remoteError,
|
|
11052
|
+
changed_paths: changedPaths,
|
|
11053
|
+
remote_write_state: remoteWriteState,
|
|
11054
|
+
remote_submitted: remoteWriteState === "confirmed",
|
|
11055
|
+
readback_confirmed: readbackConfirmed,
|
|
11056
|
+
...readbackError ? { readback_error: readbackError } : {},
|
|
11057
|
+
suggestion: `\u5148\u6267\u884C bpmax-cli config ${domain} verify --id ${id} --profile ${profile.name} --format json\uFF1B\u786E\u8BA4\u7EBF\u4E0A\u72B6\u6001\u540E\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u8BD5\u3002`
|
|
11058
|
+
}
|
|
11059
|
+
);
|
|
11060
|
+
}
|
|
10908
11061
|
let publishResponse = null;
|
|
10909
11062
|
if (domain === "form-template") {
|
|
10910
11063
|
publishResponse = await apiRequest(
|
|
@@ -13280,16 +13433,21 @@ function registerConfigCommands(program2) {
|
|
|
13280
13433
|
});
|
|
13281
13434
|
printResult(options.format, result);
|
|
13282
13435
|
});
|
|
13283
|
-
domainCommand.command("diff").description(`Compare raw/work or inspect a submit payload for ${domain}`).option("--raw <file>", "Raw baseline JSON file").option("--work <file>", "Work JSON file").option("--submit <file>", "Submit JSON file").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
13436
|
+
domainCommand.command("diff").description(`Compare raw/work or inspect a submit payload for ${domain}`).option("--raw <file>", "Raw baseline JSON file").option("--work <file>", "Work JSON file").option("--submit <file>", "Submit JSON file").option("--payload <file>", "Alias for --submit").option("--profile <profile>", "Profile name; accepted for command consistency").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
13437
|
+
if (options.submit && options.payload && path9.resolve(options.submit) !== path9.resolve(options.payload)) {
|
|
13438
|
+
throw new Error(`config ${domain} diff received different --submit and --payload files; provide only one artifact.`);
|
|
13439
|
+
}
|
|
13440
|
+
const submitFile = options.submit ?? options.payload;
|
|
13284
13441
|
const raw = options.raw ? await readJsonFile(options.raw) : void 0;
|
|
13285
13442
|
const work = options.work ? await readJsonFile(options.work) : void 0;
|
|
13286
|
-
const submit =
|
|
13443
|
+
const submit = submitFile ? await readJsonFile(submitFile) : void 0;
|
|
13287
13444
|
const diff = raw && work ? diffJsonNormalized(domain, raw, work) : void 0;
|
|
13288
13445
|
printResult(options.format, {
|
|
13289
13446
|
domain,
|
|
13447
|
+
profile: options.profile ?? null,
|
|
13290
13448
|
raw_file: options.raw || null,
|
|
13291
13449
|
work_file: options.work || null,
|
|
13292
|
-
submit_file:
|
|
13450
|
+
submit_file: submitFile || null,
|
|
13293
13451
|
...diff || {},
|
|
13294
13452
|
submit_preview: submit || null
|
|
13295
13453
|
});
|
|
@@ -13421,6 +13579,7 @@ import {
|
|
|
13421
13579
|
open as open2,
|
|
13422
13580
|
readdir as readdir3,
|
|
13423
13581
|
readFile as readFile11,
|
|
13582
|
+
realpath as realpath2,
|
|
13424
13583
|
rename,
|
|
13425
13584
|
rm as rm4,
|
|
13426
13585
|
stat as stat6,
|
|
@@ -14739,6 +14898,12 @@ async function validateExecutionManifestStep(options) {
|
|
|
14739
14898
|
fail(`execution manifest current step is ${manifest.case_id}/${manifest.current_step_id ?? "<complete>"}, not ${options.caseId}/${options.caseStepId}`, { rule_id: "test_suite.run.step_mismatch", path: manifestPath });
|
|
14740
14899
|
}
|
|
14741
14900
|
await assertExecutionManifestFresh(manifest, manifestPath);
|
|
14901
|
+
if (options.profile && manifest.profile !== options.profile) {
|
|
14902
|
+
fail(`execution manifest profile is ${manifest.profile}, not ${options.profile}`, {
|
|
14903
|
+
rule_id: "test_suite.run.profile_mismatch",
|
|
14904
|
+
path: manifestPath
|
|
14905
|
+
});
|
|
14906
|
+
}
|
|
14742
14907
|
const step = currentManifestStep(manifest);
|
|
14743
14908
|
if (!step || step.status !== "planned") fail("execution manifest has no runnable current step", { rule_id: "test_suite.run.no_current_step", path: manifestPath });
|
|
14744
14909
|
if (options.runners?.length && !options.runners.includes(step.runner)) {
|
|
@@ -14746,6 +14911,49 @@ async function validateExecutionManifestStep(options) {
|
|
|
14746
14911
|
}
|
|
14747
14912
|
return { manifestPath, manifest, step };
|
|
14748
14913
|
}
|
|
14914
|
+
async function preflightExecutionEvidenceDirectory(options) {
|
|
14915
|
+
const manifestPath = path10.resolve(options.manifest);
|
|
14916
|
+
const manifest = await readExecutionManifest(manifestPath);
|
|
14917
|
+
await assertExecutionManifestFresh(manifest, manifestPath);
|
|
14918
|
+
const runDir = path10.dirname(manifestPath);
|
|
14919
|
+
const evidenceDir = path10.resolve(options.evidenceDir);
|
|
14920
|
+
if (!pathInside(runDir, evidenceDir)) {
|
|
14921
|
+
fail("formal execution evidence must stay inside the current report run directory", {
|
|
14922
|
+
rule_id: "test_suite.run.evidence_scope",
|
|
14923
|
+
path: evidenceDir,
|
|
14924
|
+
suggestion: `Use an evidence directory under ${runDir}.`
|
|
14925
|
+
});
|
|
14926
|
+
}
|
|
14927
|
+
try {
|
|
14928
|
+
await mkdir9(evidenceDir, { recursive: true });
|
|
14929
|
+
} catch (error) {
|
|
14930
|
+
fail(`formal execution evidence directory cannot be created: ${error instanceof Error ? error.message : String(error)}`, {
|
|
14931
|
+
rule_id: "test_suite.run.evidence_unwritable",
|
|
14932
|
+
path: evidenceDir
|
|
14933
|
+
});
|
|
14934
|
+
}
|
|
14935
|
+
const [realRunDir, realEvidenceDir] = await Promise.all([realpath2(runDir), realpath2(evidenceDir)]);
|
|
14936
|
+
if (!pathInside(realRunDir, realEvidenceDir)) {
|
|
14937
|
+
fail("formal execution evidence directory resolves outside the current report run directory", {
|
|
14938
|
+
rule_id: "test_suite.run.evidence_scope",
|
|
14939
|
+
path: evidenceDir,
|
|
14940
|
+
suggestion: `Remove the symlink and use a real directory under ${runDir}.`
|
|
14941
|
+
});
|
|
14942
|
+
}
|
|
14943
|
+
const probe = path10.join(evidenceDir, `.bpmax-write-probe-${process.pid}-${Date.now()}`);
|
|
14944
|
+
try {
|
|
14945
|
+
await writeFile9(probe, "ok", "utf8");
|
|
14946
|
+
await readFile11(probe, "utf8");
|
|
14947
|
+
} catch (error) {
|
|
14948
|
+
fail(`formal execution evidence directory is not writable: ${error instanceof Error ? error.message : String(error)}`, {
|
|
14949
|
+
rule_id: "test_suite.run.evidence_unwritable",
|
|
14950
|
+
path: evidenceDir
|
|
14951
|
+
});
|
|
14952
|
+
} finally {
|
|
14953
|
+
await unlink(probe).catch(() => void 0);
|
|
14954
|
+
}
|
|
14955
|
+
return { manifest: manifestPath, evidence_dir: evidenceDir };
|
|
14956
|
+
}
|
|
14749
14957
|
async function appendExecutionManifestEvidence(options) {
|
|
14750
14958
|
await withExecutionManifestLock(options.manifest, async () => {
|
|
14751
14959
|
const validated = await validateExecutionManifestStep(options);
|
|
@@ -14755,9 +14963,10 @@ async function appendExecutionManifestEvidence(options) {
|
|
|
14755
14963
|
await writeExecutionManifest(validated.manifestPath, validated.manifest, true);
|
|
14756
14964
|
});
|
|
14757
14965
|
}
|
|
14758
|
-
async function nextTestSuiteRunStep(manifestPath) {
|
|
14966
|
+
async function nextTestSuiteRunStep(manifestPath, profile) {
|
|
14759
14967
|
const manifest = await readExecutionManifest(manifestPath);
|
|
14760
14968
|
await assertExecutionManifestFresh(manifest, path10.resolve(manifestPath));
|
|
14969
|
+
if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
|
|
14761
14970
|
const step = currentManifestStep(manifest);
|
|
14762
14971
|
if (!step) return { ok: true, complete: true, result: manifest.result, execution: manifest };
|
|
14763
14972
|
if (step.status !== "planned") fail("current execution step is not planned", { rule_id: "test_suite.run.no_current_step", path: manifestPath });
|
|
@@ -14804,9 +15013,10 @@ async function recordTestSuiteRunStep(options) {
|
|
|
14804
15013
|
};
|
|
14805
15014
|
});
|
|
14806
15015
|
}
|
|
14807
|
-
async function testSuiteRunStatus(manifestPath) {
|
|
15016
|
+
async function testSuiteRunStatus(manifestPath, profile) {
|
|
14808
15017
|
const manifest = await readExecutionManifest(manifestPath);
|
|
14809
15018
|
await assertExecutionManifestFresh(manifest, path10.resolve(manifestPath));
|
|
15019
|
+
if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
|
|
14810
15020
|
return { ok: true, execution: manifest };
|
|
14811
15021
|
}
|
|
14812
15022
|
async function indexSuite(root = DEFAULT_SUITE_ROOT, includeInactive = false) {
|
|
@@ -15502,10 +15712,14 @@ function linesForCase(text5, caseId) {
|
|
|
15502
15712
|
const pattern = new RegExp(`\\b${escaped}\\b`);
|
|
15503
15713
|
return text5.split(/\r?\n/).filter((line) => pattern.test(line));
|
|
15504
15714
|
}
|
|
15505
|
-
async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
15715
|
+
async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
15506
15716
|
if (!await exists3(root)) return [`report root not found: ${root}`];
|
|
15507
15717
|
const errors = [];
|
|
15508
|
-
|
|
15718
|
+
const resolvedRoot = path10.resolve(root);
|
|
15719
|
+
const candidateDirs = RUN_RE.test(path10.basename(resolvedRoot)) ? [resolvedRoot] : (await scenarioDirs(resolvedRoot)).filter((dir) => RUN_RE.test(path10.basename(dir)));
|
|
15720
|
+
if (candidateDirs.length === 0) return [`report run not found under: ${resolvedRoot}`];
|
|
15721
|
+
const runDirs = options.allRuns ? candidateDirs : candidateDirs.slice(-1);
|
|
15722
|
+
for (const runDir of runDirs) {
|
|
15509
15723
|
const runName = path10.basename(runDir);
|
|
15510
15724
|
if (!RUN_RE.test(runName)) {
|
|
15511
15725
|
errors.push(`${runDir}: run directory name must be YYYYMMDD-NNN`);
|
|
@@ -16620,7 +16834,7 @@ function registerStepCommands(program2) {
|
|
|
16620
16834
|
}
|
|
16621
16835
|
|
|
16622
16836
|
// src/commands/e2e.ts
|
|
16623
|
-
async function requireE2eExecutionBinding(options, runners) {
|
|
16837
|
+
async function requireE2eExecutionBinding(options, runners, evidenceDir) {
|
|
16624
16838
|
if (options.diagnostic) return;
|
|
16625
16839
|
if (!options.executionManifest || !options.caseId || !options.caseStepId) {
|
|
16626
16840
|
throw new Error("Formal E2E execution requires --execution-manifest, --case-id, and --case-step-id. Use --diagnostic only for non-pass troubleshooting.");
|
|
@@ -16631,6 +16845,12 @@ async function requireE2eExecutionBinding(options, runners) {
|
|
|
16631
16845
|
caseStepId: options.caseStepId,
|
|
16632
16846
|
runners
|
|
16633
16847
|
});
|
|
16848
|
+
if (evidenceDir) {
|
|
16849
|
+
await preflightExecutionEvidenceDirectory({
|
|
16850
|
+
manifest: options.executionManifest,
|
|
16851
|
+
evidenceDir
|
|
16852
|
+
});
|
|
16853
|
+
}
|
|
16634
16854
|
}
|
|
16635
16855
|
async function appendE2eExecutionEvidence(options, evidence, runners) {
|
|
16636
16856
|
if (options.diagnostic || !options.executionManifest || !options.caseId || !options.caseStepId) return;
|
|
@@ -16673,6 +16893,55 @@ async function writeEvidence(dir, name, value) {
|
|
|
16673
16893
|
`, "utf8");
|
|
16674
16894
|
return file;
|
|
16675
16895
|
}
|
|
16896
|
+
function summarizeRemoteResult(value) {
|
|
16897
|
+
if (!isRecord8(value)) return value;
|
|
16898
|
+
const summary = {};
|
|
16899
|
+
for (const key of ["id", "project_id", "step_id", "status", "state", "code", "msg", "message", "next", "action"]) {
|
|
16900
|
+
if (value[key] !== void 0) summary[key] = value[key];
|
|
16901
|
+
}
|
|
16902
|
+
return Object.keys(summary).length > 0 ? redactAuditValue(summary) : { received: true };
|
|
16903
|
+
}
|
|
16904
|
+
function stepReadbackConfirmed(before, after) {
|
|
16905
|
+
const beforeStatus = isRecord8(before.step) ? before.step.status : void 0;
|
|
16906
|
+
const afterStatus = isRecord8(after.step) ? after.step.status : void 0;
|
|
16907
|
+
const beforeProjectStep = isRecord8(before.project) ? before.project.current_flow_step_id : void 0;
|
|
16908
|
+
const afterProjectStep = isRecord8(after.project) ? after.project.current_flow_step_id : void 0;
|
|
16909
|
+
return after.step_finished === true || beforeStatus !== afterStatus || beforeProjectStep !== afterProjectStep;
|
|
16910
|
+
}
|
|
16911
|
+
function evidenceMime(buffer, file) {
|
|
16912
|
+
if (buffer.length >= 8 && buffer.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) return "image/png";
|
|
16913
|
+
if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) return "image/jpeg";
|
|
16914
|
+
if (buffer.length >= 12 && buffer.subarray(0, 4).toString("ascii") === "RIFF" && buffer.subarray(8, 12).toString("ascii") === "WEBP") return "image/webp";
|
|
16915
|
+
if (path11.extname(file).toLowerCase() === ".json") return "application/json";
|
|
16916
|
+
if ([".txt", ".md", ".log"].includes(path11.extname(file).toLowerCase())) return "text/plain";
|
|
16917
|
+
return "application/octet-stream";
|
|
16918
|
+
}
|
|
16919
|
+
async function writeEvidenceManifest(evidenceDir, details) {
|
|
16920
|
+
const files = await readdir4(evidenceDir, { withFileTypes: true });
|
|
16921
|
+
const artifacts = [];
|
|
16922
|
+
for (const entry of files) {
|
|
16923
|
+
if (!entry.isFile() || entry.name === "evidence-manifest.json") continue;
|
|
16924
|
+
const file = path11.join(evidenceDir, entry.name);
|
|
16925
|
+
const buffer = await readFile12(file);
|
|
16926
|
+
const mimeType = evidenceMime(buffer, entry.name);
|
|
16927
|
+
const extension = path11.extname(entry.name).toLowerCase();
|
|
16928
|
+
const expectedMime = extension === ".png" ? "image/png" : [".jpg", ".jpeg"].includes(extension) ? "image/jpeg" : extension === ".webp" ? "image/webp" : void 0;
|
|
16929
|
+
artifacts.push({
|
|
16930
|
+
path: entry.name,
|
|
16931
|
+
size: buffer.length,
|
|
16932
|
+
sha256: createHash6("sha256").update(buffer).digest("hex"),
|
|
16933
|
+
mime_type: mimeType,
|
|
16934
|
+
...expectedMime && expectedMime !== mimeType ? { extension_mismatch: true, expected_mime: expectedMime } : {}
|
|
16935
|
+
});
|
|
16936
|
+
}
|
|
16937
|
+
return writeEvidence(evidenceDir, "evidence-manifest.json", {
|
|
16938
|
+
schema_version: 1,
|
|
16939
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
16940
|
+
evidence_dir: path11.resolve(evidenceDir),
|
|
16941
|
+
...details,
|
|
16942
|
+
artifacts
|
|
16943
|
+
});
|
|
16944
|
+
}
|
|
16676
16945
|
function cacheRoot() {
|
|
16677
16946
|
return path11.resolve(".codex/cache/bpmax-e2e");
|
|
16678
16947
|
}
|
|
@@ -17007,7 +17276,7 @@ function recordKey(record, index) {
|
|
|
17007
17276
|
function registerE2eCommands(program2) {
|
|
17008
17277
|
const e2e = program2.command("e2e").description("BPMAX E2E acceleration helpers with evidence-first safety gates");
|
|
17009
17278
|
e2e.command("step-run").description("Run one or more BPMAX step safe-chain submissions with evidence files").requiredOption("--project-id <projectId>", "Project id").option("--step-id <stepId>", "Step id for single-step mode").option("--action <action>", "Step action", "approve").option("--data <json>", "Single-step submit data JSON or @file").option("--data-profile <json>", "Reusable step profile JSON or @file; supports steps[] or steps object").option("--auto-refresh-cache", "Write a refreshed cache template when expected checks are missing or stale").option("--cache-out <file>", "Refreshed cache template output; defaults to --data-profile @file when possible").option("--comments <comments>", "Step comments").option("--urgency <urgency>", "Urgency value", "1").option("--confirm <confirmation>", "Actually submit; otherwise dry-run only").option("--profile <profile>", "Profile name").option("--execution-manifest <file>", "Formal test-suite execution manifest").option("--case-id <id>", "Formal test-suite case id").option("--case-step-id <id>", "Formal test-suite case step id").option("--diagnostic", "Run without a formal manifest; result cannot be used as pass evidence").option("--evidence-dir <dir>", "Evidence directory", `.codex/tmp/e2e/${timestampSlug()}`).option("--format <format>", "Output format", "json").action(async (options) => {
|
|
17010
|
-
await requireE2eExecutionBinding(options, ["e2e_step_run"]);
|
|
17279
|
+
await requireE2eExecutionBinding(options, ["e2e_step_run"], options.evidenceDir);
|
|
17011
17280
|
const config = await loadConfig();
|
|
17012
17281
|
const profile = resolveProfile(config, options.profile);
|
|
17013
17282
|
const client = createApiClient(profile);
|
|
@@ -17120,29 +17389,89 @@ function registerE2eCommands(program2) {
|
|
|
17120
17389
|
params: { action: plan.action },
|
|
17121
17390
|
data: payload
|
|
17122
17391
|
});
|
|
17123
|
-
|
|
17124
|
-
|
|
17125
|
-
|
|
17126
|
-
|
|
17392
|
+
let readback = null;
|
|
17393
|
+
let readbackError = null;
|
|
17394
|
+
try {
|
|
17395
|
+
readback = await buildStepContext(profile, client, plan.step_id, options.projectId);
|
|
17396
|
+
} catch (error) {
|
|
17397
|
+
readbackError = error instanceof Error ? error.message : String(error);
|
|
17398
|
+
}
|
|
17399
|
+
const readbackConfirmed2 = Boolean(readback && stepReadbackConfirmed(context, readback));
|
|
17400
|
+
let submitFile;
|
|
17401
|
+
let evidenceError;
|
|
17402
|
+
try {
|
|
17403
|
+
submitFile = await writeEvidence(evidenceDir, `${prefix}-submit.json`, {
|
|
17404
|
+
status: "submitted",
|
|
17405
|
+
operation_executed: true,
|
|
17406
|
+
remote_submitted: true,
|
|
17407
|
+
evidence_failed: false,
|
|
17408
|
+
readback_confirmed: readbackConfirmed2,
|
|
17409
|
+
request,
|
|
17410
|
+
remote_response_summary: summarizeRemoteResult(result),
|
|
17411
|
+
readback,
|
|
17412
|
+
...readbackError ? { readback_error: readbackError } : {}
|
|
17413
|
+
});
|
|
17414
|
+
} catch (error) {
|
|
17415
|
+
evidenceError = error instanceof Error ? error.message : String(error);
|
|
17416
|
+
}
|
|
17417
|
+
if (evidenceError || !readbackConfirmed2) {
|
|
17418
|
+
stopped = true;
|
|
17419
|
+
}
|
|
17127
17420
|
steps.push({
|
|
17128
17421
|
step_id: plan.step_id,
|
|
17129
17422
|
action: plan.action,
|
|
17130
|
-
status: "submitted",
|
|
17131
|
-
|
|
17132
|
-
|
|
17423
|
+
status: evidenceError ? "evidence_failed" : readbackConfirmed2 ? "submitted" : "submitted_unconfirmed",
|
|
17424
|
+
operation_executed: true,
|
|
17425
|
+
remote_submitted: true,
|
|
17426
|
+
evidence_failed: Boolean(evidenceError),
|
|
17427
|
+
readback_confirmed: readbackConfirmed2,
|
|
17428
|
+
evidence: { context: contextFile, ...submitFile ? { submit: submitFile } : {} },
|
|
17429
|
+
remote_response_summary: summarizeRemoteResult(result),
|
|
17430
|
+
...readback ? { readback } : {},
|
|
17431
|
+
...readbackError ? { readback_error: readbackError } : {},
|
|
17432
|
+
...!evidenceError && !readbackConfirmed2 ? {
|
|
17433
|
+
requires_manual_reconciliation: true,
|
|
17434
|
+
next_action: "Do not continue to another step or resubmit. Confirm the current project/step state with readback first."
|
|
17435
|
+
} : {},
|
|
17436
|
+
...evidenceError ? {
|
|
17437
|
+
evidence_error: evidenceError,
|
|
17438
|
+
requires_manual_reconciliation: true,
|
|
17439
|
+
next_action: "Do not resubmit. Read back the project/step state and repair evidence for this already-submitted operation."
|
|
17440
|
+
} : {}
|
|
17133
17441
|
});
|
|
17134
17442
|
}
|
|
17135
|
-
|
|
17443
|
+
let evidenceManifest;
|
|
17444
|
+
let evidenceManifestError;
|
|
17445
|
+
try {
|
|
17446
|
+
evidenceManifest = await writeEvidenceManifest(evidenceDir, {
|
|
17447
|
+
command: "e2e step-run",
|
|
17448
|
+
project_id: options.projectId,
|
|
17449
|
+
profile: profile.name,
|
|
17450
|
+
steps
|
|
17451
|
+
});
|
|
17452
|
+
} catch (error) {
|
|
17453
|
+
evidenceManifestError = error instanceof Error ? error.message : String(error);
|
|
17454
|
+
}
|
|
17455
|
+
const remoteSubmitted = steps.some((step) => step.remote_submitted === true);
|
|
17456
|
+
const evidenceFailed = steps.some((step) => step.evidence_failed === true) || Boolean(evidenceManifestError);
|
|
17457
|
+
const readbackConfirmed = remoteSubmitted && steps.filter((step) => step.remote_submitted === true).every((step) => step.readback_confirmed === true);
|
|
17458
|
+
if (options.confirm && remoteSubmitted && readbackConfirmed && !evidenceFailed && evidenceManifest && steps.every((step) => step.status !== "blocked" && step.status !== "cache_stale")) {
|
|
17136
17459
|
await appendE2eExecutionEvidence(options, evidenceDir, ["e2e_step_run"]);
|
|
17137
17460
|
}
|
|
17138
17461
|
printResult(options.format, {
|
|
17139
|
-
ok: steps.every((step) => step.status !== "blocked" && step.status !== "cache_stale"),
|
|
17140
|
-
result: options.diagnostic ? "diagnostic" : options.confirm &&
|
|
17462
|
+
ok: !evidenceFailed && (!remoteSubmitted || readbackConfirmed) && steps.every((step) => step.status !== "blocked" && step.status !== "cache_stale"),
|
|
17463
|
+
result: options.diagnostic ? "diagnostic" : evidenceFailed && remoteSubmitted ? "remote_submitted_evidence_failed" : options.confirm && remoteSubmitted ? readbackConfirmed ? "execution_evidence_recorded" : "remote_submitted_readback_unconfirmed" : "execution_plan_generated",
|
|
17141
17464
|
diagnostic: Boolean(options.diagnostic),
|
|
17142
17465
|
dry_run: !options.confirm,
|
|
17466
|
+
operation_executed: remoteSubmitted,
|
|
17467
|
+
remote_submitted: remoteSubmitted,
|
|
17468
|
+
evidence_failed: evidenceFailed,
|
|
17469
|
+
readback_confirmed: readbackConfirmed,
|
|
17143
17470
|
project_id: options.projectId,
|
|
17144
17471
|
profile: profile.name,
|
|
17145
17472
|
evidence_dir: evidenceDir,
|
|
17473
|
+
evidence_manifest: evidenceManifest ?? null,
|
|
17474
|
+
...evidenceManifestError ? { evidence_manifest_error: evidenceManifestError } : {},
|
|
17146
17475
|
steps
|
|
17147
17476
|
});
|
|
17148
17477
|
});
|
|
@@ -17421,12 +17750,24 @@ function assertProjectSearchBody(value) {
|
|
|
17421
17750
|
}
|
|
17422
17751
|
function withProjectListPagination(body, options) {
|
|
17423
17752
|
const data = { ...body };
|
|
17424
|
-
|
|
17425
|
-
|
|
17426
|
-
|
|
17427
|
-
|
|
17428
|
-
|
|
17429
|
-
|
|
17753
|
+
const normalizePositiveInteger = (value, path16) => {
|
|
17754
|
+
if (typeof value === "string" && value.trim() === "") {
|
|
17755
|
+
throw new Error(`project search ${path16} \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u4E0D\u80FD\u662F\u7A7A\u5B57\u7B26\u4E32\u3002`);
|
|
17756
|
+
}
|
|
17757
|
+
const number = typeof value === "number" ? value : Number(value);
|
|
17758
|
+
if (!Number.isSafeInteger(number) || number < 1) {
|
|
17759
|
+
throw new Error(`project search ${path16} \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u5F53\u524D\u503C\u4E3A ${String(value)}\u3002`);
|
|
17760
|
+
}
|
|
17761
|
+
return number;
|
|
17762
|
+
};
|
|
17763
|
+
data.page = normalizePositiveInteger(
|
|
17764
|
+
options.pageExplicit || data.page === void 0 ? options.page : data.page,
|
|
17765
|
+
"page"
|
|
17766
|
+
);
|
|
17767
|
+
data.page_size = normalizePositiveInteger(
|
|
17768
|
+
options.pageSizeExplicit || data.page_size === void 0 ? options.pageSize : data.page_size,
|
|
17769
|
+
"page_size"
|
|
17770
|
+
);
|
|
17430
17771
|
return data;
|
|
17431
17772
|
}
|
|
17432
17773
|
|
|
@@ -19898,6 +20239,10 @@ var schemaEntries = [
|
|
|
19898
20239
|
{ name: "config.console_template.create", description: "Create console template config through a verified typed adapter.", method: "POST", path: "/api/flow_page_template" },
|
|
19899
20240
|
{ name: "config.console_template.delete", description: "Delete console template config through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id" },
|
|
19900
20241
|
{ name: "config.console_template.submit", description: "Submit console template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id" },
|
|
20242
|
+
{ name: "config.step_detail_template.export", description: "Export type=6 flow-step detail template config.", method: "GET", path: "/api/flow_page_template/:id?type=6&skip_i18n=true" },
|
|
20243
|
+
{ name: "config.step_detail_template.create", description: "Create a type=6 flow-step detail template through a verified typed adapter.", method: "POST", path: "/api/flow_page_template?type=6" },
|
|
20244
|
+
{ name: "config.step_detail_template.delete", description: "Delete a type=6 flow-step detail template through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id?type=6" },
|
|
20245
|
+
{ name: "config.step_detail_template.submit", description: "Submit type=6 flow-step detail template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id?type=6" },
|
|
19901
20246
|
{ name: "config.dataset.export", description: "Export dataset config through huanpingtong API-key proxy.", method: "GET/POST", path: "/api/data_set/:id + /api/data_set/list" },
|
|
19902
20247
|
{ name: "config.dataset.create", description: "Create dataset config through the huanpingtong API-key proxy.", method: "POST", path: "/api/data_set" },
|
|
19903
20248
|
{ name: "config.dataset.delete", description: "Delete dataset config through the huanpingtong API-key proxy.", method: "DELETE", path: "/api/data_set/:id" },
|
|
@@ -21068,17 +21413,17 @@ function registerTestSuiteCommands(program2) {
|
|
|
21068
21413
|
skillVersion: skill.version
|
|
21069
21414
|
}));
|
|
21070
21415
|
});
|
|
21071
|
-
run.command("next").description("Return only the current runnable case step from an execution manifest").requiredOption("--manifest <file>", "Execution manifest file").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21072
|
-
printResult(options.format, await nextTestSuiteRunStep(options.manifest));
|
|
21416
|
+
run.command("next").description("Return only the current runnable case step from an execution manifest").requiredOption("--manifest <file>", "Execution manifest file").option("--profile <profile>", "Profile name; must match the execution manifest").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21417
|
+
printResult(options.format, await nextTestSuiteRunStep(options.manifest, options.profile));
|
|
21073
21418
|
});
|
|
21074
|
-
run.command("record").description("Record pass/fail/blocked evidence for the current case step").requiredOption("--manifest <file>", "Execution manifest file").requiredOption("--case-id <id>", "Case id").requiredOption("--case-step-id <id>", "Case step id").requiredOption("--result <result>", "pass, fail, or blocked").requiredOption("--evidence <path>", "Current-run evidence file or directory").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21419
|
+
run.command("record").description("Record pass/fail/blocked evidence for the current case step").requiredOption("--manifest <file>", "Execution manifest file").requiredOption("--case-id <id>", "Case id").requiredOption("--case-step-id <id>", "Case step id").requiredOption("--result <result>", "pass, fail, or blocked").requiredOption("--evidence <path>", "Current-run evidence file or directory").option("--profile <profile>", "Profile name; must match the execution manifest").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21075
21420
|
printResult(options.format, await recordTestSuiteRunStep(options));
|
|
21076
21421
|
});
|
|
21077
21422
|
run.command("report-sync").description("Synchronize the generated scenario report from the execution manifest").requiredOption("--manifest <file>", "Execution manifest file").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21078
21423
|
printResult(options.format, await syncTestSuiteRunReport(options.manifest));
|
|
21079
21424
|
});
|
|
21080
|
-
run.command("status").description("Show execution manifest status").requiredOption("--manifest <file>", "Execution manifest file").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21081
|
-
printResult(options.format, await testSuiteRunStatus(options.manifest));
|
|
21425
|
+
run.command("status").description("Show execution manifest status").requiredOption("--manifest <file>", "Execution manifest file").option("--profile <profile>", "Profile name; must match the execution manifest").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21426
|
+
printResult(options.format, await testSuiteRunStatus(options.manifest, options.profile));
|
|
21082
21427
|
});
|
|
21083
21428
|
review.command("repair").description("Repair missing schema fields in an existing draft review.json").requiredOption("--scenario <id>", "Scenario id").option("--draft-root <path>", "Draft suite root directory", DEFAULT_DRAFT_ROOT).requiredOption("--latest-proof <path>", "latest-* proof JSON written after syncing the sysconfig repo").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21084
21429
|
printResult(options.format, await initOrRepairReview({ ...options, repair: true }));
|
|
@@ -21098,8 +21443,8 @@ function registerTestSuiteCommands(program2) {
|
|
|
21098
21443
|
const reportDir = await nextReportDir(options.root, Boolean(options.create));
|
|
21099
21444
|
printResult(options.format, { path: reportDir });
|
|
21100
21445
|
});
|
|
21101
|
-
suite.command("lint-report").description("Lint BPMAX E2E test report artifacts").option("--root <path>", "Report root directory", DEFAULT_REPORT_ROOT).option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21102
|
-
const errors = await lintReport(options.root);
|
|
21446
|
+
suite.command("lint-report").description("Lint BPMAX E2E test report artifacts").option("--root <path>", "Report root directory", DEFAULT_REPORT_ROOT).option("--all-runs", "Lint every historical run instead of only the latest/current run").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21447
|
+
const errors = await lintReport(options.root, { allRuns: Boolean(options.allRuns) });
|
|
21103
21448
|
if (errors.length > 0) {
|
|
21104
21449
|
throw new Error(errors.join("\n"));
|
|
21105
21450
|
}
|
|
@@ -21108,7 +21453,7 @@ function registerTestSuiteCommands(program2) {
|
|
|
21108
21453
|
}
|
|
21109
21454
|
|
|
21110
21455
|
// src/core/update.ts
|
|
21111
|
-
import { access as access2, mkdir as mkdir13, readFile as readFile18, realpath as
|
|
21456
|
+
import { access as access2, mkdir as mkdir13, readFile as readFile18, realpath as realpath3, writeFile as writeFile13 } from "fs/promises";
|
|
21112
21457
|
import path15 from "path";
|
|
21113
21458
|
var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
21114
21459
|
var UPDATE_STATE_FILE = "update-state.json";
|
|
@@ -21274,7 +21619,7 @@ async function executablePath() {
|
|
|
21274
21619
|
return "";
|
|
21275
21620
|
}
|
|
21276
21621
|
try {
|
|
21277
|
-
return await
|
|
21622
|
+
return await realpath3(candidate);
|
|
21278
21623
|
} catch {
|
|
21279
21624
|
return candidate;
|
|
21280
21625
|
}
|
|
@@ -21687,6 +22032,7 @@ function commandEndpointHint(argv) {
|
|
|
21687
22032
|
"list-template": "/flow_page_template",
|
|
21688
22033
|
"filter-template": "/flow_page_template",
|
|
21689
22034
|
"project-detail-template": "/flow_page_template",
|
|
22035
|
+
"step-detail-template": "/flow_page_template",
|
|
21690
22036
|
"console-template": "/flow_page_template"
|
|
21691
22037
|
};
|
|
21692
22038
|
return endpointByDomain[args[1]];
|
|
@@ -21704,6 +22050,16 @@ function printCommandError(error) {
|
|
|
21704
22050
|
...typeof structured.rule_id === "string" ? { rule_id: structured.rule_id } : {},
|
|
21705
22051
|
...typeof structured.path === "string" ? { path: structured.path } : {},
|
|
21706
22052
|
...typeof structured.suggestion === "string" ? { suggestion: structured.suggestion } : {},
|
|
22053
|
+
...typeof structured.request_phase === "string" ? { request_phase: structured.request_phase } : {},
|
|
22054
|
+
...typeof structured.http_status === "number" || structured.http_status === null ? { http_status: structured.http_status } : {},
|
|
22055
|
+
...Array.isArray(structured.changed_paths) ? { changed_paths: structured.changed_paths } : {},
|
|
22056
|
+
...typeof structured.remote_write_state === "string" ? { remote_write_state: structured.remote_write_state } : {},
|
|
22057
|
+
...typeof structured.remote_submitted === "boolean" ? { remote_submitted: structured.remote_submitted } : {},
|
|
22058
|
+
...typeof structured.readback_confirmed === "boolean" ? { readback_confirmed: structured.readback_confirmed } : {},
|
|
22059
|
+
...typeof structured.readback_error === "string" ? { readback_error: structured.readback_error } : {},
|
|
22060
|
+
...typeof structured.remote_error === "string" ? { remote_error: structured.remote_error } : {},
|
|
22061
|
+
...typeof structured.published_id === "string" || typeof structured.published_id === "number" ? { published_id: structured.published_id } : {},
|
|
22062
|
+
...typeof structured.draft_id === "string" || typeof structured.draft_id === "number" || structured.draft_id === null ? { draft_id: structured.draft_id } : {},
|
|
21707
22063
|
...Array.isArray(structured.missing) ? { missing: structured.missing } : {},
|
|
21708
22064
|
...typeof structured.profile === "string" ? { profile: structured.profile } : {},
|
|
21709
22065
|
...typeof structured.env === "string" ? { env: structured.env } : {},
|