bpmax-cli 0.2.1-beta.37 → 0.2.1-beta.39
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 +1101 -513
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-ai-taskbook/SKILL.md +1 -0
- package/skills/bpmax-builder-shared/SKILL.md +1 -0
- package/skills/bpmax-builder-shared/configuration-impact-review.md +76 -0
- package/skills/bpmax-cli/SKILL.md +1 -0
- package/skills/bpmax-console-template-editor/SKILL.md +4 -2
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +4 -2
- package/skills/bpmax-dataset-template-editor/SKILL.md +4 -1
- package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +1 -0
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +1 -0
- package/skills/bpmax-filter-template-editor/SKILL.md +7 -3
- package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +21 -0
- package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +19 -2
- package/skills/bpmax-filter-template-editor/references/full-detail-guide.md +2 -2
- package/skills/bpmax-flow-template-editor/SKILL.md +5 -1
- package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +17 -0
- package/skills/bpmax-form-template-editor/SKILL.md +5 -1
- package/skills/bpmax-list-template-editor/SKILL.md +5 -2
package/dist/bin.js
CHANGED
|
@@ -233,8 +233,8 @@ function throwCliGovernanceUnsupportedIfNeeded(error, fallbackPath) {
|
|
|
233
233
|
}
|
|
234
234
|
throw error;
|
|
235
235
|
}
|
|
236
|
-
function normalizePath(
|
|
237
|
-
let normalized =
|
|
236
|
+
function normalizePath(path17) {
|
|
237
|
+
let normalized = path17.split("?")[0] || "/";
|
|
238
238
|
if (!normalized.startsWith("/")) {
|
|
239
239
|
normalized = `/${normalized}`;
|
|
240
240
|
}
|
|
@@ -244,17 +244,17 @@ function normalizePath(path16) {
|
|
|
244
244
|
}
|
|
245
245
|
return normalized.replace(/\/+$/g, "") || "/api";
|
|
246
246
|
}
|
|
247
|
-
function getNumber(value,
|
|
248
|
-
const result = getValue(value,
|
|
247
|
+
function getNumber(value, path17) {
|
|
248
|
+
const result = getValue(value, path17);
|
|
249
249
|
return typeof result === "number" ? result : void 0;
|
|
250
250
|
}
|
|
251
|
-
function getString(value,
|
|
252
|
-
const result = getValue(value,
|
|
251
|
+
function getString(value, path17) {
|
|
252
|
+
const result = getValue(value, path17);
|
|
253
253
|
return typeof result === "string" ? result : void 0;
|
|
254
254
|
}
|
|
255
|
-
function getValue(value,
|
|
255
|
+
function getValue(value, path17) {
|
|
256
256
|
let current = value;
|
|
257
|
-
for (const key of
|
|
257
|
+
for (const key of path17) {
|
|
258
258
|
if (!current || typeof current !== "object" || !(key in current)) {
|
|
259
259
|
return void 0;
|
|
260
260
|
}
|
|
@@ -264,10 +264,10 @@ function getValue(value, path16) {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
// src/core/capabilities.ts
|
|
267
|
-
function capabilityForRequest(method,
|
|
267
|
+
function capabilityForRequest(method, path17) {
|
|
268
268
|
const normalizedMethod = method.toUpperCase();
|
|
269
|
-
const normalizedPath = normalizePath2(
|
|
270
|
-
const pageTemplatePrefix = flowPageTemplateCapabilityPrefix(
|
|
269
|
+
const normalizedPath = normalizePath2(path17);
|
|
270
|
+
const pageTemplatePrefix = flowPageTemplateCapabilityPrefix(path17);
|
|
271
271
|
if (normalizedPath === "/cli/capabilities") {
|
|
272
272
|
return void 0;
|
|
273
273
|
}
|
|
@@ -444,8 +444,8 @@ async function updateProfileCapabilities(profileName, cache) {
|
|
|
444
444
|
};
|
|
445
445
|
await saveConfig(config);
|
|
446
446
|
}
|
|
447
|
-
function flowPageTemplateCapabilityPrefix(
|
|
448
|
-
const query =
|
|
447
|
+
function flowPageTemplateCapabilityPrefix(path17) {
|
|
448
|
+
const query = path17.includes("?") ? path17.slice(path17.indexOf("?") + 1) : "";
|
|
449
449
|
const type = new URLSearchParams(query).get("type");
|
|
450
450
|
if (type === "2") {
|
|
451
451
|
return "config.project_detail_template";
|
|
@@ -464,8 +464,8 @@ function flowPageTemplateCapabilityPrefix(path16) {
|
|
|
464
464
|
}
|
|
465
465
|
return "config.list_template";
|
|
466
466
|
}
|
|
467
|
-
function normalizePath2(
|
|
468
|
-
let normalized =
|
|
467
|
+
function normalizePath2(path17) {
|
|
468
|
+
let normalized = path17.split("?")[0] || "/";
|
|
469
469
|
if (!normalized.startsWith("/")) {
|
|
470
470
|
normalized = `/${normalized}`;
|
|
471
471
|
}
|
|
@@ -496,7 +496,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
|
|
|
496
496
|
// package.json
|
|
497
497
|
var package_default = {
|
|
498
498
|
name: "bpmax-cli",
|
|
499
|
-
version: "0.2.1-beta.
|
|
499
|
+
version: "0.2.1-beta.39",
|
|
500
500
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
501
501
|
type: "module",
|
|
502
502
|
bin: {
|
|
@@ -546,8 +546,8 @@ var NPM_PACKAGE = "bpmax-cli";
|
|
|
546
546
|
// src/core/terminal.ts
|
|
547
547
|
import { randomUUID } from "crypto";
|
|
548
548
|
import os from "os";
|
|
549
|
-
function isCliControlPath(
|
|
550
|
-
const normalized = normalizeApiPath(
|
|
549
|
+
function isCliControlPath(path17) {
|
|
550
|
+
const normalized = normalizeApiPath(path17);
|
|
551
551
|
return normalized === "/api/cli/capabilities" || normalized === "/api/cli/terminals/register" || normalized === "/api/cli/audit/start" || normalized === "/api/cli/audit/finish" || normalized === "/api/cli/bbs_invocations/start" || normalized === "/api/cli/bbs_invocations/finish";
|
|
552
552
|
}
|
|
553
553
|
function commandSummary(argv = process.argv) {
|
|
@@ -711,8 +711,8 @@ async function updateProfileTerminal(profile, terminalId, status) {
|
|
|
711
711
|
profile.config.terminal_status = status;
|
|
712
712
|
profile.config.terminal_registered_at = config.profiles[profile.name].terminal_registered_at;
|
|
713
713
|
}
|
|
714
|
-
function normalizeApiPath(
|
|
715
|
-
let normalized =
|
|
714
|
+
function normalizeApiPath(path17) {
|
|
715
|
+
let normalized = path17.split("?")[0] || "/";
|
|
716
716
|
if (!normalized.startsWith("/")) {
|
|
717
717
|
normalized = `/${normalized}`;
|
|
718
718
|
}
|
|
@@ -835,14 +835,14 @@ function recordCommandAuditResult(value) {
|
|
|
835
835
|
state.result_summary = redactAuditValue(value);
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
|
-
var ensureApiPath = (
|
|
839
|
-
if (!
|
|
840
|
-
|
|
838
|
+
var ensureApiPath = (path17) => {
|
|
839
|
+
if (!path17.startsWith("/")) {
|
|
840
|
+
path17 = `/${path17}`;
|
|
841
841
|
}
|
|
842
|
-
if (
|
|
843
|
-
return
|
|
842
|
+
if (path17.startsWith("/api/")) {
|
|
843
|
+
return path17;
|
|
844
844
|
}
|
|
845
|
-
return `/api${
|
|
845
|
+
return `/api${path17}`;
|
|
846
846
|
};
|
|
847
847
|
function normalizeWorkspaceForApi(workspace) {
|
|
848
848
|
const normalized = workspace?.trim();
|
|
@@ -888,10 +888,10 @@ function createApiClient(profile) {
|
|
|
888
888
|
});
|
|
889
889
|
return instance;
|
|
890
890
|
}
|
|
891
|
-
async function apiRequest(client, method,
|
|
891
|
+
async function apiRequest(client, method, path17, options = {}) {
|
|
892
892
|
const profile = clientProfiles.get(client);
|
|
893
|
-
const apiPath2 = ensureApiPath(
|
|
894
|
-
const capability = options.capability ?? capabilityForRequest(method,
|
|
893
|
+
const apiPath2 = ensureApiPath(path17);
|
|
894
|
+
const capability = options.capability ?? capabilityForRequest(method, path17);
|
|
895
895
|
const shouldControl = Boolean(profile?.config.api_key) && !isCliControlPath(apiPath2);
|
|
896
896
|
const reqId = requestId();
|
|
897
897
|
if (profile) {
|
|
@@ -1199,8 +1199,8 @@ async function parseJsonAny(input, label = "JSON input") {
|
|
|
1199
1199
|
function isMutatingMethod(method) {
|
|
1200
1200
|
return ["POST", "PUT", "PATCH", "DELETE"].includes(method.toUpperCase());
|
|
1201
1201
|
}
|
|
1202
|
-
function normalizeApiPath2(
|
|
1203
|
-
let normalized =
|
|
1202
|
+
function normalizeApiPath2(path17) {
|
|
1203
|
+
let normalized = path17.trim();
|
|
1204
1204
|
const queryIndex = normalized.indexOf("?");
|
|
1205
1205
|
if (queryIndex >= 0) {
|
|
1206
1206
|
normalized = normalized.slice(0, queryIndex);
|
|
@@ -1217,9 +1217,9 @@ function normalizeApiPath2(path16) {
|
|
|
1217
1217
|
}
|
|
1218
1218
|
return normalized;
|
|
1219
1219
|
}
|
|
1220
|
-
function pluginAgentCapabilityForRawApi(method,
|
|
1220
|
+
function pluginAgentCapabilityForRawApi(method, path17) {
|
|
1221
1221
|
const normalizedMethod = method.toUpperCase();
|
|
1222
|
-
const normalizedPath = normalizeApiPath2(
|
|
1222
|
+
const normalizedPath = normalizeApiPath2(path17);
|
|
1223
1223
|
const match = normalizedPath.match(/^\/(plugin_[A-Za-z0-9_]+)\/agents(?:\/|$)/);
|
|
1224
1224
|
if (!match) {
|
|
1225
1225
|
return void 0;
|
|
@@ -1233,19 +1233,19 @@ function pluginAgentCapabilityForRawApi(method, path16) {
|
|
|
1233
1233
|
}
|
|
1234
1234
|
return void 0;
|
|
1235
1235
|
}
|
|
1236
|
-
function parseQuery(
|
|
1237
|
-
const queryIndex =
|
|
1238
|
-
return new URLSearchParams(queryIndex >= 0 ?
|
|
1236
|
+
function parseQuery(path17) {
|
|
1237
|
+
const queryIndex = path17.indexOf("?");
|
|
1238
|
+
return new URLSearchParams(queryIndex >= 0 ? path17.slice(queryIndex + 1) : "");
|
|
1239
1239
|
}
|
|
1240
|
-
function isRawConfigPath(method,
|
|
1241
|
-
const normalizedPath = normalizeApiPath2(
|
|
1240
|
+
function isRawConfigPath(method, path17) {
|
|
1241
|
+
const normalizedPath = normalizeApiPath2(path17);
|
|
1242
1242
|
if (/^\/(configuration|form_template|flow_page_template|data_set|data_set_field|api_platform|api_platform_instance|api_proxy|api_proxy_entity_binding|entity|entity_field|role|point|user_role|workspace|group|config_repository)(\/|$)/.test(normalizedPath)) {
|
|
1243
1243
|
return true;
|
|
1244
1244
|
}
|
|
1245
1245
|
if (normalizedPath === "/flow/list/lightweight" || normalizedPath.startsWith("/flow/configuration/")) {
|
|
1246
1246
|
return true;
|
|
1247
1247
|
}
|
|
1248
|
-
if (normalizedPath === "/flow" && method === "GET" && parseQuery(
|
|
1248
|
+
if (normalizedPath === "/flow" && method === "GET" && parseQuery(path17).has("draft")) {
|
|
1249
1249
|
return true;
|
|
1250
1250
|
}
|
|
1251
1251
|
if (normalizedPath.startsWith("/flow/") && !["/flow/flow_type", "/flow/options", "/flow/batch_get"].includes(normalizedPath)) {
|
|
@@ -1256,35 +1256,35 @@ function isRawConfigPath(method, path16) {
|
|
|
1256
1256
|
}
|
|
1257
1257
|
return false;
|
|
1258
1258
|
}
|
|
1259
|
-
function assertRawApiPathAllowed(method,
|
|
1260
|
-
if (isRawConfigPath(method,
|
|
1259
|
+
function assertRawApiPathAllowed(method, path17) {
|
|
1260
|
+
if (isRawConfigPath(method, path17)) {
|
|
1261
1261
|
throw new Error(
|
|
1262
|
-
`Raw API ${method} ${
|
|
1262
|
+
`Raw API ${method} ${path17} is blocked because BPMAX configuration APIs must use typed bpmax-cli config commands. Run bpmax-cli config adapters --format json to check whether the target config domain is supported.`
|
|
1263
1263
|
);
|
|
1264
1264
|
}
|
|
1265
1265
|
if (!isMutatingMethod(method)) {
|
|
1266
1266
|
return;
|
|
1267
1267
|
}
|
|
1268
|
-
const normalizedPath = normalizeApiPath2(
|
|
1268
|
+
const normalizedPath = normalizeApiPath2(path17);
|
|
1269
1269
|
const isProjectPath = normalizedPath === "/project" || normalizedPath.startsWith("/project/");
|
|
1270
1270
|
const isAllowedProjectReadPost = method === "POST" && normalizedPath === "/project/list";
|
|
1271
1271
|
if (!isProjectPath || isAllowedProjectReadPost) {
|
|
1272
1272
|
return;
|
|
1273
1273
|
}
|
|
1274
1274
|
throw new Error(
|
|
1275
|
-
`Raw API ${method} ${
|
|
1275
|
+
`Raw API ${method} ${path17} is blocked because /api/project/<id> falls back to project creation in huanpingtong-server. Do not call /project/es-search or /project/raw-es-search; huanpingtong-server does not expose those as public ES APIs. Use bpmax-cli project create --flow-id <id> --json <json> for project creation, or bpmax-cli project search / project list for project reads.`
|
|
1276
1276
|
);
|
|
1277
1277
|
}
|
|
1278
1278
|
function registerApiCommands(program2) {
|
|
1279
|
-
program2.command("api <method> <path>").description("Call an arbitrary BPMAX /api endpoint").option("--profile <profile>", "Profile name").option("--params <json>", "Query params JSON or @file").option("--data <json>", "Request body JSON or @file").option("--confirm-mutating", "Allow mutating API calls").option("--format <format>", "Output format", "json").action(async (method,
|
|
1279
|
+
program2.command("api <method> <path>").description("Call an arbitrary BPMAX /api endpoint").option("--profile <profile>", "Profile name").option("--params <json>", "Query params JSON or @file").option("--data <json>", "Request body JSON or @file").option("--confirm-mutating", "Allow mutating API calls").option("--format <format>", "Output format", "json").action(async (method, path17, options) => {
|
|
1280
1280
|
const normalizedMethod = method.toUpperCase();
|
|
1281
|
-
assertRawApiPathAllowed(normalizedMethod,
|
|
1281
|
+
assertRawApiPathAllowed(normalizedMethod, path17);
|
|
1282
1282
|
if (isMutatingMethod(normalizedMethod) && options.confirmMutating !== true) {
|
|
1283
1283
|
printResult(options.format, {
|
|
1284
1284
|
ok: false,
|
|
1285
1285
|
dry_run: true,
|
|
1286
1286
|
method: normalizedMethod,
|
|
1287
|
-
path:
|
|
1287
|
+
path: path17,
|
|
1288
1288
|
warning: "Mutating raw API calls require --confirm-mutating. Prefer typed bpmax-cli commands such as step submit."
|
|
1289
1289
|
});
|
|
1290
1290
|
return;
|
|
@@ -1292,8 +1292,8 @@ function registerApiCommands(program2) {
|
|
|
1292
1292
|
const config = await loadConfig();
|
|
1293
1293
|
const profile = resolveProfile(config, options.profile);
|
|
1294
1294
|
const client = createApiClient(profile);
|
|
1295
|
-
const capability = pluginAgentCapabilityForRawApi(normalizedMethod,
|
|
1296
|
-
const result = await apiRequest(client, normalizedMethod,
|
|
1295
|
+
const capability = pluginAgentCapabilityForRawApi(normalizedMethod, path17) || "api.raw";
|
|
1296
|
+
const result = await apiRequest(client, normalizedMethod, path17, {
|
|
1297
1297
|
params: options.params ? await parseJsonInput(options.params, "--params") : void 0,
|
|
1298
1298
|
data: await parseJsonAny(options.data, "--data"),
|
|
1299
1299
|
capability
|
|
@@ -1380,18 +1380,18 @@ function lintDeviceAuthorizationUrl(urlValue, expectedOrigin, expectedWorkspace,
|
|
|
1380
1380
|
);
|
|
1381
1381
|
}
|
|
1382
1382
|
}
|
|
1383
|
-
function apiPath(
|
|
1384
|
-
if (
|
|
1385
|
-
return
|
|
1383
|
+
function apiPath(path17) {
|
|
1384
|
+
if (path17.startsWith("/api/")) {
|
|
1385
|
+
return path17;
|
|
1386
1386
|
}
|
|
1387
|
-
return `/api${
|
|
1387
|
+
return `/api${path17.startsWith("/") ? path17 : `/${path17}`}`;
|
|
1388
1388
|
}
|
|
1389
1389
|
function createDeviceRequest(origin) {
|
|
1390
1390
|
const client = axios2.create({ baseURL: origin, withCredentials: false });
|
|
1391
|
-
return async (method,
|
|
1391
|
+
return async (method, path17, options) => {
|
|
1392
1392
|
const response = await client.request({
|
|
1393
1393
|
method,
|
|
1394
|
-
url: apiPath(
|
|
1394
|
+
url: apiPath(path17),
|
|
1395
1395
|
data: options.data
|
|
1396
1396
|
});
|
|
1397
1397
|
const body = response.data;
|
|
@@ -3850,20 +3850,20 @@ function requireNumericId(value, name) {
|
|
|
3850
3850
|
}
|
|
3851
3851
|
return nextValue;
|
|
3852
3852
|
}
|
|
3853
|
-
function withQuery(
|
|
3853
|
+
function withQuery(path17, query) {
|
|
3854
3854
|
const params = new URLSearchParams();
|
|
3855
3855
|
for (const [key, value] of Object.entries(query)) {
|
|
3856
3856
|
if (value !== void 0) {
|
|
3857
3857
|
params.set(key, value);
|
|
3858
3858
|
}
|
|
3859
3859
|
}
|
|
3860
|
-
return `${
|
|
3860
|
+
return `${path17}?${params.toString()}`;
|
|
3861
3861
|
}
|
|
3862
3862
|
function buildBpmaxUrl(profile, kind, params = {}) {
|
|
3863
3863
|
const origin = normalizeOrigin2(profile.config.origin);
|
|
3864
3864
|
const workspace = normalizeWorkspaceForUrl(params.workspace || profile.config.workspace);
|
|
3865
3865
|
const basePath = `/${workspace}`;
|
|
3866
|
-
let
|
|
3866
|
+
let path17 = basePath;
|
|
3867
3867
|
const result = {
|
|
3868
3868
|
kind,
|
|
3869
3869
|
profile: profile.name,
|
|
@@ -3871,15 +3871,15 @@ function buildBpmaxUrl(profile, kind, params = {}) {
|
|
|
3871
3871
|
workspace
|
|
3872
3872
|
};
|
|
3873
3873
|
if (kind === "project-list") {
|
|
3874
|
-
|
|
3874
|
+
path17 = `${basePath}/project`;
|
|
3875
3875
|
} else if (kind === "project-detail") {
|
|
3876
3876
|
const projectId = requireNumericId(params.projectId, "projectId");
|
|
3877
|
-
|
|
3877
|
+
path17 = `${basePath}/project_detail/0/${projectId}`;
|
|
3878
3878
|
result.project_id = projectId;
|
|
3879
3879
|
} else if (kind === "project-step") {
|
|
3880
3880
|
const projectId = requireNumericId(params.projectId, "projectId");
|
|
3881
3881
|
const stepId = requireNumericId(params.stepId, "stepId");
|
|
3882
|
-
|
|
3882
|
+
path17 = withQuery(`${basePath}/projectContinue`, {
|
|
3883
3883
|
id: projectId,
|
|
3884
3884
|
step_id: stepId,
|
|
3885
3885
|
prefill_token: params.prefillToken
|
|
@@ -3897,15 +3897,15 @@ function buildBpmaxUrl(profile, kind, params = {}) {
|
|
|
3897
3897
|
...flowKey ? { key: flowKey } : {},
|
|
3898
3898
|
...prefillToken ? { prefill_token: prefillToken } : { init_value: initValue }
|
|
3899
3899
|
};
|
|
3900
|
-
|
|
3900
|
+
path17 = withQuery(`${basePath}/project/create`, query);
|
|
3901
3901
|
result.flow_type = flowType;
|
|
3902
3902
|
result.flow_key = flowKey;
|
|
3903
3903
|
result.mobile_path = withQuery("/pages/projectCreate/projectCreate", query);
|
|
3904
3904
|
}
|
|
3905
|
-
const url = `${origin}${
|
|
3905
|
+
const url = `${origin}${path17}`;
|
|
3906
3906
|
return {
|
|
3907
3907
|
...result,
|
|
3908
|
-
path:
|
|
3908
|
+
path: path17,
|
|
3909
3909
|
url,
|
|
3910
3910
|
...kind === "project-create" ? { pc_url: url } : {}
|
|
3911
3911
|
};
|
|
@@ -4243,7 +4243,7 @@ function registerCapabilitiesCommands(program2) {
|
|
|
4243
4243
|
// src/commands/config.ts
|
|
4244
4244
|
import { text as text2 } from "@clack/prompts";
|
|
4245
4245
|
import { mkdir as mkdir8, writeFile as writeFile8 } from "fs/promises";
|
|
4246
|
-
import
|
|
4246
|
+
import path10 from "path";
|
|
4247
4247
|
|
|
4248
4248
|
// src/core/config-workflow.ts
|
|
4249
4249
|
import { createHash as createHash4 } from "crypto";
|
|
@@ -4854,9 +4854,9 @@ function summarizeOperationPlan(payload) {
|
|
|
4854
4854
|
return "submit operation";
|
|
4855
4855
|
}
|
|
4856
4856
|
const method = typeof operation.method === "string" ? operation.method : "REQUEST";
|
|
4857
|
-
const
|
|
4857
|
+
const path17 = typeof operation.path === "string" ? operation.path : "";
|
|
4858
4858
|
const type = typeof operation.type === "string" ? ` ${operation.type}` : "";
|
|
4859
|
-
return `submit${type}: ${method}${
|
|
4859
|
+
return `submit${type}: ${method}${path17 ? ` ${path17}` : ""}`;
|
|
4860
4860
|
}),
|
|
4861
4861
|
...skipped.slice(0, Math.max(0, 20 - operations.length)).map((operation) => {
|
|
4862
4862
|
if (!isRecord3(operation)) {
|
|
@@ -5011,11 +5011,46 @@ function validateFlowTemplateFormDrivenCreateBaseline(value, errors, options = {
|
|
|
5011
5011
|
}
|
|
5012
5012
|
throw new Error(message);
|
|
5013
5013
|
}
|
|
5014
|
+
var POST_CREATE_INITIATOR_STEP_NAME = /(申请人|发起人|提交人|申请者|发起者|applicant|initiator|requester|submitter)/i;
|
|
5015
|
+
function validateFlowTemplatePostCreateInitiatorStep(value, errors) {
|
|
5016
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
5017
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
5018
|
+
if (!hasConfiguredFlowTemplateFormSource(value, meta)) {
|
|
5019
|
+
return;
|
|
5020
|
+
}
|
|
5021
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
|
|
5022
|
+
const firstNode = nodes[0];
|
|
5023
|
+
if (!firstNode) {
|
|
5024
|
+
return;
|
|
5025
|
+
}
|
|
5026
|
+
const firstNodeName = typeof firstNode.name === "string" ? firstNode.name.trim() : "";
|
|
5027
|
+
if (!POST_CREATE_INITIATOR_STEP_NAME.test(firstNodeName) || firstNode.owner_is_creater !== true) {
|
|
5028
|
+
return;
|
|
5029
|
+
}
|
|
5030
|
+
const lint = isRecord3(value.bpmax_lint) ? value.bpmax_lint : {};
|
|
5031
|
+
if (lint.allow_post_create_initiator_step === true) {
|
|
5032
|
+
return;
|
|
5033
|
+
}
|
|
5034
|
+
const firstNodeId = String(firstNode.id ?? "").trim();
|
|
5035
|
+
const jumps = meta.condational_jump;
|
|
5036
|
+
const routesBackToInitiator = Array.isArray(jumps) && jumps.some((jump) => isRecord3(jump) && String(jump.result ?? "").trim() === firstNodeId);
|
|
5037
|
+
if (Array.isArray(jumps) && jumps.length > 0 && !routesBackToInitiator) {
|
|
5038
|
+
return;
|
|
5039
|
+
}
|
|
5040
|
+
const jumpProblem = routesBackToInitiator ? `data.meta.condational_jump \u4ECD\u5305\u542B\u6307\u5411\u8BE5\u9996\u8282\u70B9 id\u201C${firstNodeId}\u201D\u7684\u89C4\u5219\uFF1B` : "data.meta.condational_jump \u4E3A\u7A7A\uFF1B";
|
|
5041
|
+
const message = `\u8868\u5355\u9A71\u52A8\u6D41\u7A0B\u7684\u9996\u8282\u70B9\u201C${firstNodeName || "\u672A\u547D\u540D"}\u201D\u7531\u521B\u5EFA\u4EBA\u529E\u7406\uFF0C\u4E14 ${jumpProblem}\u9879\u76EE\u521B\u5EFA\u540E\u540E\u7AEF\u4F1A\u76F4\u63A5\u751F\u6210\u8BE5\u7533\u8BF7\u4EBA\u5F85\u529E\uFF0C\u800C\u4E0D\u4F1A\u628A\u521B\u5EFA\u9875\u63D0\u4EA4\u89C6\u4E3A\u8BE5\u8282\u70B9\u5DF2\u5B8C\u6210\u3002\u8BF7\u628A\u521B\u5EFA\u540E\u7684\u9996\u4E2A\u5BA1\u6279/\u5206\u6D41\u8FC1\u79FB\u5230 data.meta.condational_jump\u3002\u5982\u679C\u4E1A\u52A1\u786E\u5B9E\u8981\u6C42\u7533\u8BF7\u4EBA\u521B\u5EFA\u540E\u518D\u6B21\u786E\u8BA4\uFF0C\u8BF7\u5728 work.bpmax_lint.allow_post_create_initiator_step \u4E2D\u663E\u5F0F\u8BBE\u7F6E true\uFF1B\u8BE5 lint-only \u5B57\u6BB5\u4E0D\u4F1A\u8FDB\u5165\u63D0\u4EA4 payload\u3002`;
|
|
5042
|
+
if (errors) {
|
|
5043
|
+
errors.push(message);
|
|
5044
|
+
return;
|
|
5045
|
+
}
|
|
5046
|
+
throw new Error(`flow-template post-create initiator step gate failed: ${message}`);
|
|
5047
|
+
}
|
|
5014
5048
|
function validateFlowAppFlowWork(value, errors, warnings) {
|
|
5015
5049
|
validateFlowTemplateRemoteTemplateRefs(value, errors);
|
|
5016
5050
|
validateFlowTemplateProjectAfterCreatePath(value, errors);
|
|
5017
5051
|
validateFlowTemplateStandardPageCreateFormTemplate(value, errors);
|
|
5018
5052
|
validateFlowTemplateStartConditionalJump(value, errors);
|
|
5053
|
+
validateFlowTemplatePostCreateInitiatorStep(value, errors);
|
|
5019
5054
|
validateFlowTemplateApproveActionShape(value, errors);
|
|
5020
5055
|
validateFlowTemplatePluginRejectionControl(value, errors);
|
|
5021
5056
|
validateFlowTemplateStandardConditionEditorRules(value, errors);
|
|
@@ -6621,23 +6656,23 @@ function lintConsoleTemplateDataSource(dataSource, moduleLabel, errors) {
|
|
|
6621
6656
|
errors.push(`${moduleLabel} \u4E0D\u80FD\u76F4\u63A5\u4F7F\u7528 /bpmax/project/list\u3001/api/project/list \u6216 ESProjectList\uFF1B\u5982\u786E\u9700\u7528\u6237\u8303\u56F4\u67E5\u8BE2\uFF0C\u811A\u672C\u4E2D\u5FC5\u987B\u5199\u660E bpmax-allow-user-scope-project-list: <reason>\u3002`);
|
|
6622
6657
|
}
|
|
6623
6658
|
}
|
|
6624
|
-
function lintConsoleTemplateWildcardFallback(value,
|
|
6659
|
+
function lintConsoleTemplateWildcardFallback(value, path17, errors) {
|
|
6625
6660
|
if (typeof value === "string") {
|
|
6626
6661
|
const scriptedWildcard = /(?:wildcard|value)\s*:\s*['\"](\*{1,2})['\"]/i.exec(value);
|
|
6627
6662
|
if (scriptedWildcard) {
|
|
6628
|
-
errors.push(`${
|
|
6663
|
+
errors.push(`${path17}.wildcard \u4E0D\u80FD\u7528 ${scriptedWildcard[1]} \u4F5C\u4E3A\u975E\u7A7A\u6216\u515C\u5E95\u7ED3\u679C\uFF1B\u8BF7\u5199\u660E\u786E\u7684\u7A7A\u6001\u3001\u6761\u4EF6\u6216\u805A\u5408\u7ED3\u679C\u3002`);
|
|
6629
6664
|
}
|
|
6630
6665
|
return;
|
|
6631
6666
|
}
|
|
6632
6667
|
if (Array.isArray(value)) {
|
|
6633
|
-
value.forEach((item, index) => lintConsoleTemplateWildcardFallback(item, `${
|
|
6668
|
+
value.forEach((item, index) => lintConsoleTemplateWildcardFallback(item, `${path17}[${index}]`, errors));
|
|
6634
6669
|
return;
|
|
6635
6670
|
}
|
|
6636
6671
|
if (!isRecord3(value)) {
|
|
6637
6672
|
return;
|
|
6638
6673
|
}
|
|
6639
6674
|
Object.entries(value).forEach(([key, item]) => {
|
|
6640
|
-
const nextPath = `${
|
|
6675
|
+
const nextPath = `${path17}.${key}`;
|
|
6641
6676
|
if ((key === "wildcard" || key === "value") && (item === "*" || item === "**")) {
|
|
6642
6677
|
errors.push(`${nextPath} \u4E0D\u80FD\u7528 ${String(item)} \u4F5C\u4E3A\u975E\u7A7A\u6216\u515C\u5E95\u7ED3\u679C\uFF1B\u8BF7\u5199\u660E\u786E\u7684\u7A7A\u6001\u3001\u6761\u4EF6\u6216\u805A\u5408\u7ED3\u679C\u3002`);
|
|
6643
6678
|
}
|
|
@@ -7000,9 +7035,35 @@ function lintFilterTemplateWork(value, errors) {
|
|
|
7000
7035
|
return;
|
|
7001
7036
|
}
|
|
7002
7037
|
content.config.forEach((item, index) => {
|
|
7003
|
-
if (isRecord3(item)
|
|
7038
|
+
if (!isRecord3(item)) {
|
|
7039
|
+
return;
|
|
7040
|
+
}
|
|
7041
|
+
const itemPath = `filter-template content.config[${index}]`;
|
|
7042
|
+
if (item.console === true) {
|
|
7004
7043
|
errors.push(`filter-template content.config[${index}].console=true is reserved for console/dashboard filters and is not allowed in ordinary filter templates.`);
|
|
7005
7044
|
}
|
|
7045
|
+
const componentType = textOf(item.is).trim();
|
|
7046
|
+
const queryType = textOf(item.type).trim();
|
|
7047
|
+
const timeType = textOf(item.time_type).trim();
|
|
7048
|
+
const props = isRecord3(item.props) ? item.props : {};
|
|
7049
|
+
const pickerType = textOf(props.type).trim();
|
|
7050
|
+
if (componentType === "date-picker") {
|
|
7051
|
+
const canonicalTimeType = pickerType === "datetimerange" ? "time_range" : pickerType === "monthrange" ? "month_range" : pickerType === "daterange" ? "date_range" : "d";
|
|
7052
|
+
errors.push(
|
|
7053
|
+
`[filter_date_range_component_invalid] ${itemPath} \u4F7F\u7528\u4E86\u5E73\u53F0\u7B5B\u9009\u5668\u4E0D\u652F\u6301\u7684 is=date-picker\uFF0C\u8FD0\u884C\u65F6\u4F1A\u964D\u7EA7\u4E3A\u666E\u901A\u8F93\u5165\u6846\u5E76\u4EA7\u751F\u5B57\u7B26\u4E32\u67E5\u8BE2\u3002\u8BF7\u6539\u7528 is=date-range\u3001type=range\u3001time_type=${canonicalTimeType}\uFF1B\u4E0D\u8981\u901A\u8FC7 props.type=${pickerType || "<empty>"} \u6539\u53D8\u7EC4\u4EF6\u7C7B\u578B\u3002`
|
|
7054
|
+
);
|
|
7055
|
+
}
|
|
7056
|
+
if (componentType === "date-range") {
|
|
7057
|
+
if (queryType !== "range") {
|
|
7058
|
+
errors.push(`[filter_date_range_query_invalid] ${itemPath} \u4F7F\u7528 is=date-range \u65F6 type \u5FC5\u987B\u4E3A range\uFF0C\u7EC4\u4EF6\u624D\u4F1A\u751F\u6210 raw ES range\u3002`);
|
|
7059
|
+
}
|
|
7060
|
+
const supportedTimeTypes = /* @__PURE__ */ new Set(["y", "m", "d", "time_range", "date_range", "month_range"]);
|
|
7061
|
+
if (!supportedTimeTypes.has(timeType)) {
|
|
7062
|
+
errors.push(
|
|
7063
|
+
`[filter_date_range_time_type_invalid] ${itemPath}.time_type \u5FC5\u987B\u662F y\u3001m\u3001d\u3001time_range\u3001date_range \u6216 month_range\uFF1B\u65E5\u671F\u533A\u95F4\u8BF7\u4F7F\u7528 time_type=date_range\u3002`
|
|
7064
|
+
);
|
|
7065
|
+
}
|
|
7066
|
+
}
|
|
7006
7067
|
});
|
|
7007
7068
|
}
|
|
7008
7069
|
function listTemplateNodeLabel(node) {
|
|
@@ -7855,6 +7916,7 @@ function normalizeFlowTemplatePayload(work) {
|
|
|
7855
7916
|
validateFlowTemplateProjectAfterCreatePath({ ...work, data });
|
|
7856
7917
|
validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
|
|
7857
7918
|
validateFlowTemplateStartConditionalJump({ ...work, data });
|
|
7919
|
+
validateFlowTemplatePostCreateInitiatorStep({ ...work, data });
|
|
7858
7920
|
validateFlowTemplateApproveActionShape({ ...work, data });
|
|
7859
7921
|
validateFlowTemplatePluginRejectionControl({ ...work, data });
|
|
7860
7922
|
validateFlowTemplateStandardConditionEditorRules({ ...work, data });
|
|
@@ -11767,24 +11829,24 @@ function normalizeTypedReadbackComparable(domain, value) {
|
|
|
11767
11829
|
}
|
|
11768
11830
|
function jsonSubsetMismatches(expected, actual) {
|
|
11769
11831
|
const mismatches = [];
|
|
11770
|
-
const compare = (left, right,
|
|
11832
|
+
const compare = (left, right, path17 = "") => {
|
|
11771
11833
|
if (Array.isArray(left)) {
|
|
11772
11834
|
if (!Array.isArray(right) || left.length !== right.length) {
|
|
11773
|
-
mismatches.push(
|
|
11835
|
+
mismatches.push(path17 || "/");
|
|
11774
11836
|
return;
|
|
11775
11837
|
}
|
|
11776
|
-
left.forEach((item, index) => compare(item, right[index], `${
|
|
11838
|
+
left.forEach((item, index) => compare(item, right[index], `${path17}/${index}`));
|
|
11777
11839
|
return;
|
|
11778
11840
|
}
|
|
11779
11841
|
if (isRecord3(left)) {
|
|
11780
11842
|
if (!isRecord3(right)) {
|
|
11781
|
-
mismatches.push(
|
|
11843
|
+
mismatches.push(path17 || "/");
|
|
11782
11844
|
return;
|
|
11783
11845
|
}
|
|
11784
|
-
for (const [key, item] of Object.entries(left)) compare(item, right[key], `${
|
|
11846
|
+
for (const [key, item] of Object.entries(left)) compare(item, right[key], `${path17}/${key}`);
|
|
11785
11847
|
return;
|
|
11786
11848
|
}
|
|
11787
|
-
if (JSON.stringify(left) !== JSON.stringify(right)) mismatches.push(
|
|
11849
|
+
if (JSON.stringify(left) !== JSON.stringify(right)) mismatches.push(path17 || "/");
|
|
11788
11850
|
};
|
|
11789
11851
|
compare(expected, actual);
|
|
11790
11852
|
return mismatches;
|
|
@@ -12702,6 +12764,7 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
12702
12764
|
validateFlowTemplateProjectAfterCreatePath(flowWork, errors);
|
|
12703
12765
|
validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
|
|
12704
12766
|
validateFlowTemplateStartConditionalJump(flowWork, errors);
|
|
12767
|
+
validateFlowTemplatePostCreateInitiatorStep(flowWork, errors);
|
|
12705
12768
|
validateFlowTemplateApproveActionShape(flowWork, errors);
|
|
12706
12769
|
validateFlowTemplatePluginRejectionControl(flowWork, errors);
|
|
12707
12770
|
validateFlowTemplateStandardConditionEditorRules(flowWork, errors);
|
|
@@ -13822,9 +13885,504 @@ async function runConfigBatchReadback(config, profile, manifestFile, options = {
|
|
|
13822
13885
|
};
|
|
13823
13886
|
}
|
|
13824
13887
|
|
|
13825
|
-
// src/core/config-
|
|
13826
|
-
import {
|
|
13888
|
+
// src/core/config-impact.ts
|
|
13889
|
+
import { readdir as readdir3, readFile as readFile9, stat as stat4 } from "fs/promises";
|
|
13827
13890
|
import path6 from "path";
|
|
13891
|
+
var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13892
|
+
var HIGH_RISK_CHANGES = /* @__PURE__ */ new Set([
|
|
13893
|
+
"removed",
|
|
13894
|
+
"renamed",
|
|
13895
|
+
"type_changed",
|
|
13896
|
+
"behavior_changed"
|
|
13897
|
+
]);
|
|
13898
|
+
var GENERIC_IDENTIFIERS = /* @__PURE__ */ new Set([
|
|
13899
|
+
"id",
|
|
13900
|
+
"key",
|
|
13901
|
+
"name",
|
|
13902
|
+
"title",
|
|
13903
|
+
"value",
|
|
13904
|
+
"field",
|
|
13905
|
+
"data",
|
|
13906
|
+
"status",
|
|
13907
|
+
"type",
|
|
13908
|
+
"project"
|
|
13909
|
+
]);
|
|
13910
|
+
var RECOMMENDED_SURFACES = {
|
|
13911
|
+
"form-template": [
|
|
13912
|
+
"dataset-field",
|
|
13913
|
+
"dataset",
|
|
13914
|
+
"list-template",
|
|
13915
|
+
"filter-template",
|
|
13916
|
+
"project-detail-template",
|
|
13917
|
+
"step-detail-template",
|
|
13918
|
+
"flow-template",
|
|
13919
|
+
"console-template",
|
|
13920
|
+
"runtime-script",
|
|
13921
|
+
"e2e"
|
|
13922
|
+
],
|
|
13923
|
+
"dataset-field": [
|
|
13924
|
+
"dataset",
|
|
13925
|
+
"list-template",
|
|
13926
|
+
"filter-template",
|
|
13927
|
+
"project-detail-template",
|
|
13928
|
+
"step-detail-template",
|
|
13929
|
+
"console-template",
|
|
13930
|
+
"runtime-script",
|
|
13931
|
+
"e2e"
|
|
13932
|
+
],
|
|
13933
|
+
dataset: [
|
|
13934
|
+
"list-template",
|
|
13935
|
+
"filter-template",
|
|
13936
|
+
"project-detail-template",
|
|
13937
|
+
"step-detail-template",
|
|
13938
|
+
"console-template",
|
|
13939
|
+
"nav-config",
|
|
13940
|
+
"runtime-script",
|
|
13941
|
+
"e2e"
|
|
13942
|
+
],
|
|
13943
|
+
"list-template": ["filter-template", "nav-config", "runtime-script", "e2e"],
|
|
13944
|
+
"filter-template": ["list-template", "nav-config", "runtime-script", "e2e"],
|
|
13945
|
+
"project-detail-template": ["flow-template", "runtime-script", "e2e"],
|
|
13946
|
+
"step-detail-template": ["flow-template", "runtime-script", "e2e"],
|
|
13947
|
+
"flow-detail-template": ["flow-template", "runtime-script", "e2e"],
|
|
13948
|
+
"console-template": ["dataset", "filter-template", "nav-config", "runtime-script", "e2e"],
|
|
13949
|
+
"flow-template": [
|
|
13950
|
+
"form-template",
|
|
13951
|
+
"dataset-field",
|
|
13952
|
+
"dataset",
|
|
13953
|
+
"list-template",
|
|
13954
|
+
"filter-template",
|
|
13955
|
+
"project-detail-template",
|
|
13956
|
+
"step-detail-template",
|
|
13957
|
+
"nav-config",
|
|
13958
|
+
"runtime-script",
|
|
13959
|
+
"e2e"
|
|
13960
|
+
],
|
|
13961
|
+
"nav-config": ["flow-template", "list-template", "filter-template", "console-template", "e2e"]
|
|
13962
|
+
};
|
|
13963
|
+
var BEHAVIOR_KEYS = /* @__PURE__ */ new Set([
|
|
13964
|
+
"hidden",
|
|
13965
|
+
"display",
|
|
13966
|
+
"disabled",
|
|
13967
|
+
"readonly",
|
|
13968
|
+
"required",
|
|
13969
|
+
"validate",
|
|
13970
|
+
"validatemap",
|
|
13971
|
+
"lambda",
|
|
13972
|
+
"customevalidate",
|
|
13973
|
+
"visibilitycondition",
|
|
13974
|
+
"disabledcondition",
|
|
13975
|
+
"requiredcondition",
|
|
13976
|
+
"defaultvalue"
|
|
13977
|
+
]);
|
|
13978
|
+
function stableString(value) {
|
|
13979
|
+
if (typeof value === "string") {
|
|
13980
|
+
return value.trim();
|
|
13981
|
+
}
|
|
13982
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
13983
|
+
return String(value);
|
|
13984
|
+
}
|
|
13985
|
+
return "";
|
|
13986
|
+
}
|
|
13987
|
+
function normalizeComparable(value) {
|
|
13988
|
+
if (Array.isArray(value)) {
|
|
13989
|
+
return `[${value.map(normalizeComparable).join(",")}]`;
|
|
13990
|
+
}
|
|
13991
|
+
if (isRecord4(value)) {
|
|
13992
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${normalizeComparable(value[key])}`).join(",")}}`;
|
|
13993
|
+
}
|
|
13994
|
+
return JSON.stringify(value);
|
|
13995
|
+
}
|
|
13996
|
+
function collectFieldIdentities(value) {
|
|
13997
|
+
const entries = [];
|
|
13998
|
+
const visited = /* @__PURE__ */ new Set();
|
|
13999
|
+
const visit = (current, currentPath) => {
|
|
14000
|
+
if (Array.isArray(current)) {
|
|
14001
|
+
current.forEach((item, index) => visit(item, `${currentPath}[${index}]`));
|
|
14002
|
+
return;
|
|
14003
|
+
}
|
|
14004
|
+
if (!isRecord4(current) || visited.has(current)) {
|
|
14005
|
+
return;
|
|
14006
|
+
}
|
|
14007
|
+
visited.add(current);
|
|
14008
|
+
const field = stableString(current.field);
|
|
14009
|
+
const key = stableString(current.key);
|
|
14010
|
+
if (field || key) {
|
|
14011
|
+
const type = stableString(current.type) || stableString(current.field_type);
|
|
14012
|
+
entries.push({
|
|
14013
|
+
identity: field || key,
|
|
14014
|
+
field,
|
|
14015
|
+
key,
|
|
14016
|
+
type,
|
|
14017
|
+
path: currentPath,
|
|
14018
|
+
value: current
|
|
14019
|
+
});
|
|
14020
|
+
}
|
|
14021
|
+
for (const [keyName, child] of Object.entries(current)) {
|
|
14022
|
+
if (Array.isArray(child) || isRecord4(child)) {
|
|
14023
|
+
visit(child, currentPath ? `${currentPath}.${keyName}` : keyName);
|
|
14024
|
+
}
|
|
14025
|
+
}
|
|
14026
|
+
};
|
|
14027
|
+
visit(value, "");
|
|
14028
|
+
return entries;
|
|
14029
|
+
}
|
|
14030
|
+
function hasBehaviorChange(before, after) {
|
|
14031
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)]);
|
|
14032
|
+
for (const key of keys) {
|
|
14033
|
+
if (!BEHAVIOR_KEYS.has(key.toLowerCase())) {
|
|
14034
|
+
continue;
|
|
14035
|
+
}
|
|
14036
|
+
if (JSON.stringify(before[key]) !== JSON.stringify(after[key])) {
|
|
14037
|
+
return true;
|
|
14038
|
+
}
|
|
14039
|
+
}
|
|
14040
|
+
return false;
|
|
14041
|
+
}
|
|
14042
|
+
function addIdentifier(target, item) {
|
|
14043
|
+
const value = item.identifier.trim();
|
|
14044
|
+
if (value.length < 3 || GENERIC_IDENTIFIERS.has(value.toLowerCase())) {
|
|
14045
|
+
return;
|
|
14046
|
+
}
|
|
14047
|
+
const key = `${value}\0${item.change}\0${item.previous || ""}\0${item.current || ""}`;
|
|
14048
|
+
if (!target.has(key)) {
|
|
14049
|
+
target.set(key, { ...item, identifier: value });
|
|
14050
|
+
}
|
|
14051
|
+
}
|
|
14052
|
+
function collectChangedIdentifiers(raw, work) {
|
|
14053
|
+
const result = /* @__PURE__ */ new Map();
|
|
14054
|
+
const beforeEntries = collectFieldIdentities(raw);
|
|
14055
|
+
const afterEntries = collectFieldIdentities(work);
|
|
14056
|
+
const beforeByIdentity = new Map(beforeEntries.map((item) => [item.identity, item]));
|
|
14057
|
+
const afterByIdentity = new Map(afterEntries.map((item) => [item.identity, item]));
|
|
14058
|
+
for (const before of beforeEntries) {
|
|
14059
|
+
const after = afterByIdentity.get(before.identity);
|
|
14060
|
+
if (!after) {
|
|
14061
|
+
for (const identifier of [before.field, before.key]) {
|
|
14062
|
+
addIdentifier(result, { identifier, change: "removed", path: before.path, previous: identifier });
|
|
14063
|
+
}
|
|
14064
|
+
continue;
|
|
14065
|
+
}
|
|
14066
|
+
if (before.key && after.key && before.key !== after.key) {
|
|
14067
|
+
addIdentifier(result, {
|
|
14068
|
+
identifier: before.key,
|
|
14069
|
+
change: "renamed",
|
|
14070
|
+
path: after.path,
|
|
14071
|
+
previous: before.key,
|
|
14072
|
+
current: after.key
|
|
14073
|
+
});
|
|
14074
|
+
addIdentifier(result, {
|
|
14075
|
+
identifier: after.key,
|
|
14076
|
+
change: "renamed",
|
|
14077
|
+
path: after.path,
|
|
14078
|
+
previous: before.key,
|
|
14079
|
+
current: after.key
|
|
14080
|
+
});
|
|
14081
|
+
}
|
|
14082
|
+
if (before.type !== after.type) {
|
|
14083
|
+
for (const identifier of [after.field, after.key, before.field, before.key]) {
|
|
14084
|
+
addIdentifier(result, {
|
|
14085
|
+
identifier,
|
|
14086
|
+
change: "type_changed",
|
|
14087
|
+
path: after.path,
|
|
14088
|
+
previous: before.type,
|
|
14089
|
+
current: after.type
|
|
14090
|
+
});
|
|
14091
|
+
}
|
|
14092
|
+
} else if (hasBehaviorChange(before.value, after.value)) {
|
|
14093
|
+
for (const identifier of [after.field, after.key]) {
|
|
14094
|
+
addIdentifier(result, { identifier, change: "behavior_changed", path: after.path });
|
|
14095
|
+
}
|
|
14096
|
+
} else if (normalizeComparable(before.value) !== normalizeComparable(after.value)) {
|
|
14097
|
+
for (const identifier of [after.field, after.key]) {
|
|
14098
|
+
addIdentifier(result, { identifier, change: "modified", path: after.path });
|
|
14099
|
+
}
|
|
14100
|
+
}
|
|
14101
|
+
}
|
|
14102
|
+
for (const after of afterEntries) {
|
|
14103
|
+
if (beforeByIdentity.has(after.identity)) {
|
|
14104
|
+
continue;
|
|
14105
|
+
}
|
|
14106
|
+
for (const identifier of [after.field, after.key]) {
|
|
14107
|
+
addIdentifier(result, { identifier, change: "added", path: after.path, current: identifier });
|
|
14108
|
+
}
|
|
14109
|
+
}
|
|
14110
|
+
const identifierKeys = /* @__PURE__ */ new Set([
|
|
14111
|
+
"field",
|
|
14112
|
+
"key",
|
|
14113
|
+
"id",
|
|
14114
|
+
"flow_type",
|
|
14115
|
+
"flow_key",
|
|
14116
|
+
"custom_key",
|
|
14117
|
+
"data_set_key",
|
|
14118
|
+
"data_set_id",
|
|
14119
|
+
"dataset_id",
|
|
14120
|
+
"source_field",
|
|
14121
|
+
"source_table",
|
|
14122
|
+
"form_template",
|
|
14123
|
+
"form_template_id",
|
|
14124
|
+
"table_list_template",
|
|
14125
|
+
"table_filter_template",
|
|
14126
|
+
"step_detail_id",
|
|
14127
|
+
"search_temp_id"
|
|
14128
|
+
]);
|
|
14129
|
+
const recordIdentifiers = (record) => [...new Set(
|
|
14130
|
+
Object.entries(record).filter(([key]) => identifierKeys.has(key.toLowerCase())).map(([, value]) => stableString(value)).filter(Boolean)
|
|
14131
|
+
)];
|
|
14132
|
+
const visitDifference = (before, after, currentPath) => {
|
|
14133
|
+
if (normalizeComparable(before) === normalizeComparable(after)) {
|
|
14134
|
+
return;
|
|
14135
|
+
}
|
|
14136
|
+
if (Array.isArray(before) || Array.isArray(after)) {
|
|
14137
|
+
const beforeArray = Array.isArray(before) ? before : [];
|
|
14138
|
+
const afterArray = Array.isArray(after) ? after : [];
|
|
14139
|
+
const length = Math.max(beforeArray.length, afterArray.length);
|
|
14140
|
+
for (let index = 0; index < length; index += 1) {
|
|
14141
|
+
visitDifference(beforeArray[index], afterArray[index], `${currentPath}[${index}]`);
|
|
14142
|
+
}
|
|
14143
|
+
return;
|
|
14144
|
+
}
|
|
14145
|
+
if (isRecord4(before) || isRecord4(after)) {
|
|
14146
|
+
const beforeRecord = isRecord4(before) ? before : {};
|
|
14147
|
+
const afterRecord = isRecord4(after) ? after : {};
|
|
14148
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(beforeRecord), ...Object.keys(afterRecord)]);
|
|
14149
|
+
for (const key of keys) {
|
|
14150
|
+
const beforeValue = beforeRecord[key];
|
|
14151
|
+
const afterValue = afterRecord[key];
|
|
14152
|
+
if (normalizeComparable(beforeValue) === normalizeComparable(afterValue)) {
|
|
14153
|
+
continue;
|
|
14154
|
+
}
|
|
14155
|
+
const changePath = currentPath ? `${currentPath}.${key}` : key;
|
|
14156
|
+
if (identifierKeys.has(key.toLowerCase())) {
|
|
14157
|
+
const previous = stableString(beforeValue);
|
|
14158
|
+
const current = stableString(afterValue);
|
|
14159
|
+
const change = previous && current && previous !== current ? "renamed" : previous ? "removed" : "added";
|
|
14160
|
+
for (const identifier of [previous, current]) {
|
|
14161
|
+
addIdentifier(result, { identifier, change, path: changePath, previous, current });
|
|
14162
|
+
}
|
|
14163
|
+
} else if (!Array.isArray(beforeValue) && !Array.isArray(afterValue) && !isRecord4(beforeValue) && !isRecord4(afterValue)) {
|
|
14164
|
+
const lowerKey = key.toLowerCase();
|
|
14165
|
+
const change = lowerKey === "type" || lowerKey === "field_type" ? "type_changed" : BEHAVIOR_KEYS.has(lowerKey) || /script|condition|owner|permission|template|mapping/.test(lowerKey) ? "behavior_changed" : "modified";
|
|
14166
|
+
for (const identifier of [...recordIdentifiers(beforeRecord), ...recordIdentifiers(afterRecord)]) {
|
|
14167
|
+
addIdentifier(result, { identifier, change, path: changePath });
|
|
14168
|
+
}
|
|
14169
|
+
}
|
|
14170
|
+
visitDifference(beforeValue, afterValue, changePath);
|
|
14171
|
+
}
|
|
14172
|
+
}
|
|
14173
|
+
};
|
|
14174
|
+
visitDifference(raw, work, "");
|
|
14175
|
+
const highRiskIdentifiers = new Set(
|
|
14176
|
+
[...result.values()].filter((item) => HIGH_RISK_CHANGES.has(item.change)).map((item) => item.identifier)
|
|
14177
|
+
);
|
|
14178
|
+
return [...result.values()].filter((item) => item.change !== "modified" || !highRiskIdentifiers.has(item.identifier)).sort((left, right) => left.identifier.localeCompare(right.identifier) || left.path.localeCompare(right.path));
|
|
14179
|
+
}
|
|
14180
|
+
function pageTemplateDomain(content) {
|
|
14181
|
+
try {
|
|
14182
|
+
const parsed = JSON.parse(content);
|
|
14183
|
+
if (!isRecord4(parsed)) {
|
|
14184
|
+
return void 0;
|
|
14185
|
+
}
|
|
14186
|
+
const basic = isRecord4(parsed.basic) ? parsed.basic : {};
|
|
14187
|
+
const rawType = parsed.type ?? basic.type;
|
|
14188
|
+
const templateType = typeof rawType === "number" ? rawType : Number(String(rawType || ""));
|
|
14189
|
+
const domains = {
|
|
14190
|
+
1: "list-template",
|
|
14191
|
+
2: "project-detail-template",
|
|
14192
|
+
3: "filter-template",
|
|
14193
|
+
4: "console-template",
|
|
14194
|
+
5: "flow-detail-template",
|
|
14195
|
+
6: "step-detail-template"
|
|
14196
|
+
};
|
|
14197
|
+
return domains[templateType];
|
|
14198
|
+
} catch {
|
|
14199
|
+
return void 0;
|
|
14200
|
+
}
|
|
14201
|
+
}
|
|
14202
|
+
async function configDomainForPath(relativeFile, absoluteFile, content, pageTemplateDomainCache) {
|
|
14203
|
+
const directory = relativeFile.split(path6.sep)[0];
|
|
14204
|
+
if (directory === "think_flow_page_template") {
|
|
14205
|
+
const inlineDomain = pageTemplateDomain(content);
|
|
14206
|
+
if (inlineDomain) {
|
|
14207
|
+
return inlineDomain;
|
|
14208
|
+
}
|
|
14209
|
+
const templateDirectory = path6.dirname(absoluteFile);
|
|
14210
|
+
const cached = pageTemplateDomainCache.get(templateDirectory);
|
|
14211
|
+
if (cached) {
|
|
14212
|
+
return cached;
|
|
14213
|
+
}
|
|
14214
|
+
try {
|
|
14215
|
+
const mainContent = await readFile9(path6.join(templateDirectory, "flow_page_template"), "utf8");
|
|
14216
|
+
const siblingDomain = pageTemplateDomain(mainContent) || "page-template";
|
|
14217
|
+
pageTemplateDomainCache.set(templateDirectory, siblingDomain);
|
|
14218
|
+
return siblingDomain;
|
|
14219
|
+
} catch {
|
|
14220
|
+
return "page-template";
|
|
14221
|
+
}
|
|
14222
|
+
}
|
|
14223
|
+
const mapping = {
|
|
14224
|
+
think_form_template: "form-template",
|
|
14225
|
+
think_data_set_field: "dataset-field",
|
|
14226
|
+
think_data_set: "dataset",
|
|
14227
|
+
think_flow: "flow-template",
|
|
14228
|
+
think_configuration: "configuration",
|
|
14229
|
+
think_role: "role",
|
|
14230
|
+
think_workspace: "workspace",
|
|
14231
|
+
think_api_platform: "api-platform",
|
|
14232
|
+
think_api_proxy: "api-proxy"
|
|
14233
|
+
};
|
|
14234
|
+
return mapping[directory] || directory.replace(/^think_/, "").replaceAll("_", "-");
|
|
14235
|
+
}
|
|
14236
|
+
async function collectConfigFiles(root) {
|
|
14237
|
+
const entries = await readdir3(root, { withFileTypes: true });
|
|
14238
|
+
const directories = entries.filter((entry) => entry.isDirectory() && entry.name.startsWith("think_")).map((entry) => entry.name).sort();
|
|
14239
|
+
const files = [];
|
|
14240
|
+
const walk = async (directory) => {
|
|
14241
|
+
const children = await readdir3(directory, { withFileTypes: true });
|
|
14242
|
+
for (const child of children) {
|
|
14243
|
+
const absolute = path6.join(directory, child.name);
|
|
14244
|
+
if (child.isDirectory()) {
|
|
14245
|
+
await walk(absolute);
|
|
14246
|
+
} else if (child.isFile()) {
|
|
14247
|
+
files.push(absolute);
|
|
14248
|
+
}
|
|
14249
|
+
}
|
|
14250
|
+
};
|
|
14251
|
+
for (const directory of directories) {
|
|
14252
|
+
await walk(path6.join(root, directory));
|
|
14253
|
+
}
|
|
14254
|
+
return { directories, files };
|
|
14255
|
+
}
|
|
14256
|
+
function lineContainsIdentifier(line, identifier) {
|
|
14257
|
+
const escaped = identifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
14258
|
+
if (/^\d+$/.test(identifier)) {
|
|
14259
|
+
return new RegExp(`(^|\\D)${escaped}(?=\\D|$)`).test(line);
|
|
14260
|
+
}
|
|
14261
|
+
return new RegExp(`(^|[^A-Za-z0-9_])${escaped}(?=[^A-Za-z0-9_]|$)`).test(line);
|
|
14262
|
+
}
|
|
14263
|
+
function nextStepForDomain(domain) {
|
|
14264
|
+
const labels = {
|
|
14265
|
+
"dataset-field": "\u6838\u5BF9\u6570\u636E\u96C6\u5B57\u6BB5\u6765\u6E90\u3001\u5B57\u6BB5\u7C7B\u578B\u548C\u503C\u7ED3\u6784\uFF0C\u5E76\u5728\u5FC5\u8981\u65F6\u4FEE\u6539\u540E\u91CD\u65B0 verify\u3002",
|
|
14266
|
+
dataset: "\u6838\u5BF9\u5B57\u6BB5\u5173\u8054\u3001\u5904\u7406\u811A\u672C\u3001ES mapping\u3001\u53D1\u5E03\u548C\u5237\u65B0\u72B6\u6001\u3002",
|
|
14267
|
+
"list-template": "\u6838\u5BF9\u5217\u8868\u5217\u3001\u683C\u5F0F\u5316\u811A\u672C\u3001\u64CD\u4F5C\u5217\u548C\u771F\u5B9E\u5217\u8868\u9875\u663E\u793A\u3002",
|
|
14268
|
+
"filter-template": "\u6838\u5BF9\u7B5B\u9009\u5B57\u6BB5\u3001\u67E5\u8BE2\u503C\u5F62\u6001\u548C\u6837\u672C\u547D\u4E2D\u7ED3\u679C\u3002",
|
|
14269
|
+
"project-detail-template": "\u6838\u5BF9\u8BE6\u60C5\u6A21\u5757\u3001\u5B57\u6BB5\u5C55\u793A\u548C\u771F\u5B9E\u8BE6\u60C5\u9875\u3002",
|
|
14270
|
+
"step-detail-template": "\u6838\u5BF9\u73AF\u8282\u8BE6\u60C5\u6A21\u5757\u3001\u5B57\u6BB5\u5C55\u793A\u4EE5\u53CA\u8282\u70B9\u7ED1\u5B9A\u3002",
|
|
14271
|
+
"flow-template": "\u6838\u5BF9\u6761\u4EF6\u3001owner\u3001\u8282\u70B9\u811A\u672C\u3001\u6D88\u606F\u6A21\u677F\u548C\u8868\u5355\u5B57\u6BB5\u53D6\u503C\u3002",
|
|
14272
|
+
"console-template": "\u6838\u5BF9\u770B\u677F\u6A21\u5757\u3001\u6307\u6807\u811A\u672C\u548C\u6570\u636E\u96C6\u5B57\u6BB5\u7ED1\u5B9A\u3002",
|
|
14273
|
+
configuration: "\u6838\u5BF9\u5BFC\u822A\u3001\u63D2\u4EF6\u8BBE\u7F6E\u3001\u6D88\u606F\u6A21\u677F\u6216\u5DE5\u4F5C\u533A\u7EA7\u811A\u672C\u4E2D\u7684\u5F15\u7528\u3002",
|
|
14274
|
+
"nav-config": "\u6838\u5BF9\u5BFC\u822A\u5165\u53E3\u53C2\u6570\u548C\u76EE\u6807\u9875\u9762\u7ED1\u5B9A\u3002",
|
|
14275
|
+
"runtime-script": "\u6838\u5BF9\u811A\u672C\u4E2D\u7684\u5B57\u6BB5 key\u3001\u503C\u7C7B\u578B\u548C\u7A7A\u503C\u5904\u7406\u3002",
|
|
14276
|
+
e2e: "\u66F4\u65B0\u76F8\u5173\u6B63\u5F0F\u7528\u4F8B\u548C\u6D4B\u8BD5\u6570\u636E\uFF0C\u5E76\u91CD\u65B0\u6267\u884C\u771F\u5B9E\u9875\u9762\u56DE\u5F52\u3002"
|
|
14277
|
+
};
|
|
14278
|
+
return labels[domain] || `\u6838\u5BF9 ${domain} \u4E2D\u7684\u5F15\u7528\u548C\u8FD0\u884C\u65F6\u884C\u4E3A\u3002`;
|
|
14279
|
+
}
|
|
14280
|
+
async function analyzeConfigImpact(options) {
|
|
14281
|
+
const workspaceRoot = path6.resolve(options.workspaceRoot);
|
|
14282
|
+
const changedIdentifiers = collectChangedIdentifiers(options.raw, options.work);
|
|
14283
|
+
const { directories, files } = await collectConfigFiles(workspaceRoot);
|
|
14284
|
+
const references = [];
|
|
14285
|
+
const referenceLimit = options.referenceLimit ?? 500;
|
|
14286
|
+
const maxFileBytes = options.maxFileBytes ?? 5 * 1024 * 1024;
|
|
14287
|
+
let scannedFiles = 0;
|
|
14288
|
+
let skippedLargeFiles = 0;
|
|
14289
|
+
let referenceLimitReached = false;
|
|
14290
|
+
const pageTemplateDomainCache = /* @__PURE__ */ new Map();
|
|
14291
|
+
for (const file of files) {
|
|
14292
|
+
if (!changedIdentifiers.length || references.length >= referenceLimit) {
|
|
14293
|
+
referenceLimitReached = references.length >= referenceLimit;
|
|
14294
|
+
break;
|
|
14295
|
+
}
|
|
14296
|
+
const fileStat = await stat4(file);
|
|
14297
|
+
if (fileStat.size > maxFileBytes) {
|
|
14298
|
+
skippedLargeFiles += 1;
|
|
14299
|
+
continue;
|
|
14300
|
+
}
|
|
14301
|
+
const content = await readFile9(file, "utf8");
|
|
14302
|
+
scannedFiles += 1;
|
|
14303
|
+
if (content.includes("\0")) {
|
|
14304
|
+
continue;
|
|
14305
|
+
}
|
|
14306
|
+
const lines = content.split(/\r?\n/);
|
|
14307
|
+
for (const changed of changedIdentifiers) {
|
|
14308
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
14309
|
+
if (!lineContainsIdentifier(lines[index], changed.identifier)) {
|
|
14310
|
+
continue;
|
|
14311
|
+
}
|
|
14312
|
+
const relativeFile = path6.relative(workspaceRoot, file);
|
|
14313
|
+
references.push({
|
|
14314
|
+
identifier: changed.identifier,
|
|
14315
|
+
config_domain: await configDomainForPath(relativeFile, file, content, pageTemplateDomainCache),
|
|
14316
|
+
file: relativeFile,
|
|
14317
|
+
line: index + 1
|
|
14318
|
+
});
|
|
14319
|
+
if (references.length >= referenceLimit) {
|
|
14320
|
+
referenceLimitReached = true;
|
|
14321
|
+
break;
|
|
14322
|
+
}
|
|
14323
|
+
}
|
|
14324
|
+
if (referenceLimitReached) {
|
|
14325
|
+
break;
|
|
14326
|
+
}
|
|
14327
|
+
}
|
|
14328
|
+
}
|
|
14329
|
+
const impactedDomains = [...new Set(references.map((item) => item.config_domain))].sort();
|
|
14330
|
+
const highRiskIdentifiers = changedIdentifiers.filter((item) => HIGH_RISK_CHANGES.has(item.change));
|
|
14331
|
+
const renameTargets = new Set(changedIdentifiers.filter((item) => item.change === "renamed" && item.current === item.identifier && item.previous !== item.identifier).map((item) => item.identifier));
|
|
14332
|
+
const candidateMap = /* @__PURE__ */ new Map();
|
|
14333
|
+
for (const changed of highRiskIdentifiers) {
|
|
14334
|
+
const domains = new Set(references.filter((reference) => reference.identifier === changed.identifier).map((reference) => reference.config_domain));
|
|
14335
|
+
if (renameTargets.has(changed.identifier) && domains.size === 0) {
|
|
14336
|
+
continue;
|
|
14337
|
+
}
|
|
14338
|
+
const key = `${changed.identifier}\0${changed.change}`;
|
|
14339
|
+
const candidate = candidateMap.get(key) || {
|
|
14340
|
+
identifier: changed.identifier,
|
|
14341
|
+
change: changed.change,
|
|
14342
|
+
config_domains: /* @__PURE__ */ new Set()
|
|
14343
|
+
};
|
|
14344
|
+
domains.forEach((domain) => candidate.config_domains.add(domain));
|
|
14345
|
+
candidateMap.set(key, candidate);
|
|
14346
|
+
}
|
|
14347
|
+
const requiredCollateralCandidates = [...candidateMap.values()].map((candidate) => {
|
|
14348
|
+
const domains = [...candidate.config_domains].sort();
|
|
14349
|
+
return {
|
|
14350
|
+
identifier: candidate.identifier,
|
|
14351
|
+
change: candidate.change,
|
|
14352
|
+
config_domains: domains,
|
|
14353
|
+
reason: domains.length ? `\u7A33\u5B9A\u6807\u8BC6\u53D1\u751F ${candidate.change}\uFF0C\u5E76\u5728 ${domains.join(", ")} \u4E2D\u53D1\u73B0\u5F15\u7528\uFF1B\u63D0\u4EA4\u524D\u5FC5\u987B\u786E\u8BA4\u8FD9\u4E9B\u5F15\u7528\u662F\u5426\u9700\u8981\u8054\u52A8\u4FEE\u6539\u3002` : `\u7A33\u5B9A\u6807\u8BC6\u53D1\u751F ${candidate.change}\uFF1B\u672C\u5730\u914D\u7F6E\u955C\u50CF\u672A\u53D1\u73B0\u5F15\u7528\uFF0C\u4F46\u4ECD\u9700\u6838\u5BF9\u7EBF\u4E0A\u811A\u672C\u3001\u63D2\u4EF6\u914D\u7F6E\u548C\u771F\u5B9E\u9875\u9762\u3002`
|
|
14354
|
+
};
|
|
14355
|
+
});
|
|
14356
|
+
const recommendedSurfaces = RECOMMENDED_SURFACES[options.domain] || ["runtime-script", "e2e"];
|
|
14357
|
+
const recommendedNextSteps = [
|
|
14358
|
+
...impactedDomains.map(nextStepForDomain),
|
|
14359
|
+
...recommendedSurfaces.filter((surface) => !impactedDomains.includes(surface)).map(nextStepForDomain)
|
|
14360
|
+
].filter((item, index, all) => all.indexOf(item) === index);
|
|
14361
|
+
const unverifiedSurfaces = recommendedSurfaces.filter((surface) => !impactedDomains.includes(surface));
|
|
14362
|
+
const impactStatus = !changedIdentifiers.length ? "no_identifier_changes" : requiredCollateralCandidates.length ? "required_collateral_review" : "review_recommended";
|
|
14363
|
+
return {
|
|
14364
|
+
ok: true,
|
|
14365
|
+
domain: options.domain,
|
|
14366
|
+
impact_status: impactStatus,
|
|
14367
|
+
changed_identifiers: changedIdentifiers,
|
|
14368
|
+
references_found: references,
|
|
14369
|
+
impacted_config_domains: impactedDomains,
|
|
14370
|
+
required_collateral_candidates: requiredCollateralCandidates,
|
|
14371
|
+
recommended_next_steps: recommendedNextSteps,
|
|
14372
|
+
unverified_surfaces: unverifiedSurfaces,
|
|
14373
|
+
scan: {
|
|
14374
|
+
workspace_root: workspaceRoot,
|
|
14375
|
+
scanned_directories: directories,
|
|
14376
|
+
scanned_files: scannedFiles,
|
|
14377
|
+
skipped_large_files: skippedLargeFiles,
|
|
14378
|
+
reference_limit_reached: referenceLimitReached
|
|
14379
|
+
}
|
|
14380
|
+
};
|
|
14381
|
+
}
|
|
14382
|
+
|
|
14383
|
+
// src/core/config-workspace.ts
|
|
14384
|
+
import { mkdir as mkdir6, readFile as readFile10, realpath, stat as stat5, writeFile as writeFile6 } from "fs/promises";
|
|
14385
|
+
import path7 from "path";
|
|
13828
14386
|
var DEFAULT_AGENT_GUIDE_FILE = "AGENTS.md";
|
|
13829
14387
|
var CONFIG_WORKSPACE_REQUIRED_ENTRIES = [
|
|
13830
14388
|
"AGENTS.md",
|
|
@@ -13889,11 +14447,11 @@ var CONFIG_DIRECTORY_PURPOSES = [
|
|
|
13889
14447
|
];
|
|
13890
14448
|
async function hasExpectedWorkspaceEntry(root, entry) {
|
|
13891
14449
|
try {
|
|
13892
|
-
const entryPath =
|
|
13893
|
-
const value = await
|
|
14450
|
+
const entryPath = path7.join(root, entry);
|
|
14451
|
+
const value = await stat5(entryPath);
|
|
13894
14452
|
const canonicalEntry = await realpath(entryPath);
|
|
13895
|
-
const relative =
|
|
13896
|
-
const staysInsideRoot = relative !== ".." && !relative.startsWith(`..${
|
|
14453
|
+
const relative = path7.relative(root, canonicalEntry);
|
|
14454
|
+
const staysInsideRoot = relative !== ".." && !relative.startsWith(`..${path7.sep}`) && !path7.isAbsolute(relative);
|
|
13897
14455
|
return staysInsideRoot && (entry === DEFAULT_AGENT_GUIDE_FILE ? value.isFile() : value.isDirectory());
|
|
13898
14456
|
} catch (error) {
|
|
13899
14457
|
if (error.code === "ENOENT") {
|
|
@@ -13920,7 +14478,7 @@ async function findConfigWorkspaceRoot(cwd = process.cwd()) {
|
|
|
13920
14478
|
current = await realpath(cwd);
|
|
13921
14479
|
} catch (error) {
|
|
13922
14480
|
throw new ConfigWorkspaceError(`\u5F53\u524D\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u8BBF\u95EE\uFF1A${cwd}`, {
|
|
13923
|
-
path:
|
|
14481
|
+
path: path7.resolve(cwd),
|
|
13924
14482
|
code: "config_workspace_invalid_cwd",
|
|
13925
14483
|
rule_id: "config.workspace.cwd_invalid"
|
|
13926
14484
|
});
|
|
@@ -13934,7 +14492,7 @@ async function findConfigWorkspaceRoot(cwd = process.cwd()) {
|
|
|
13934
14492
|
if (entries.present.length > 0 && (!closestPartial || entries.present.length > closestPartial.present.length)) {
|
|
13935
14493
|
closestPartial = { root: current, ...entries };
|
|
13936
14494
|
}
|
|
13937
|
-
const parent =
|
|
14495
|
+
const parent = path7.dirname(current);
|
|
13938
14496
|
if (parent === current) {
|
|
13939
14497
|
break;
|
|
13940
14498
|
}
|
|
@@ -13949,7 +14507,7 @@ async function findConfigWorkspaceRoot(cwd = process.cwd()) {
|
|
|
13949
14507
|
}
|
|
13950
14508
|
async function canonicalConfiguredPath(value) {
|
|
13951
14509
|
const configuredPath = value.trim();
|
|
13952
|
-
if (!configuredPath || !
|
|
14510
|
+
if (!configuredPath || !path7.isAbsolute(configuredPath)) {
|
|
13953
14511
|
return void 0;
|
|
13954
14512
|
}
|
|
13955
14513
|
try {
|
|
@@ -13964,8 +14522,8 @@ async function canonicalConfiguredPath(value) {
|
|
|
13964
14522
|
async function assertConfigWorkspace(options) {
|
|
13965
14523
|
const currentDirectory = await realpath(options.cwd || process.cwd());
|
|
13966
14524
|
const root = options.root ? await realpath(options.root) : await findConfigWorkspaceRoot(currentDirectory);
|
|
13967
|
-
const relative =
|
|
13968
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
14525
|
+
const relative = path7.relative(root, currentDirectory);
|
|
14526
|
+
if (relative === ".." || relative.startsWith(`..${path7.sep}`) || path7.isAbsolute(relative)) {
|
|
13969
14527
|
throw new ConfigWorkspaceError("\u5F53\u524D\u76EE\u5F55\u4E0D\u5728\u8BC6\u522B\u51FA\u7684 BPMAX \u914D\u7F6E\u76EE\u5F55\u5185\u3002", {
|
|
13970
14528
|
path: currentDirectory,
|
|
13971
14529
|
profile: options.profile.name,
|
|
@@ -14174,10 +14732,10 @@ async function initConfigWorkspaceGuide(options) {
|
|
|
14174
14732
|
);
|
|
14175
14733
|
}
|
|
14176
14734
|
const file = options.file || DEFAULT_AGENT_GUIDE_FILE;
|
|
14177
|
-
if (
|
|
14735
|
+
if (path7.isAbsolute(file) || file.split(/[\\/]+/).includes("..")) {
|
|
14178
14736
|
throw new Error("Agent guide file must be a relative file name inside the target workspace.");
|
|
14179
14737
|
}
|
|
14180
|
-
const targetFile =
|
|
14738
|
+
const targetFile = path7.resolve(options.cwd, file);
|
|
14181
14739
|
const block = renderConfigWorkspaceGuide({
|
|
14182
14740
|
profileName: options.profile.name,
|
|
14183
14741
|
profile: options.profile.config,
|
|
@@ -14187,7 +14745,7 @@ async function initConfigWorkspaceGuide(options) {
|
|
|
14187
14745
|
});
|
|
14188
14746
|
let existing = "";
|
|
14189
14747
|
try {
|
|
14190
|
-
existing = await
|
|
14748
|
+
existing = await readFile10(targetFile, "utf8");
|
|
14191
14749
|
} catch (error) {
|
|
14192
14750
|
if (error.code !== "ENOENT") {
|
|
14193
14751
|
throw error;
|
|
@@ -14195,7 +14753,7 @@ async function initConfigWorkspaceGuide(options) {
|
|
|
14195
14753
|
}
|
|
14196
14754
|
const content = upsertConfigWorkspaceBlock(existing, options.env, block);
|
|
14197
14755
|
if (!options.dryRun) {
|
|
14198
|
-
await mkdir6(
|
|
14756
|
+
await mkdir6(path7.dirname(targetFile), { recursive: true });
|
|
14199
14757
|
await writeFile6(targetFile, content, "utf8");
|
|
14200
14758
|
}
|
|
14201
14759
|
return {
|
|
@@ -14209,14 +14767,14 @@ async function initConfigWorkspaceGuide(options) {
|
|
|
14209
14767
|
}
|
|
14210
14768
|
|
|
14211
14769
|
// src/core/plugin-config-adapters.ts
|
|
14212
|
-
import { readFile as
|
|
14213
|
-
import
|
|
14214
|
-
function
|
|
14770
|
+
import { readFile as readFile11 } from "fs/promises";
|
|
14771
|
+
import path8 from "path";
|
|
14772
|
+
function isRecord5(value) {
|
|
14215
14773
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
14216
14774
|
}
|
|
14217
14775
|
function unwrapRecord(value) {
|
|
14218
|
-
if (
|
|
14219
|
-
return
|
|
14776
|
+
if (isRecord5(value) && isRecord5(value.data)) return value.data;
|
|
14777
|
+
return isRecord5(value) ? value : {};
|
|
14220
14778
|
}
|
|
14221
14779
|
function endpointPath(endpoint, id, pluginKey, operation = "request") {
|
|
14222
14780
|
const template = endpoint?.path || "";
|
|
@@ -14289,13 +14847,13 @@ function assertSafeDomain(domain) {
|
|
|
14289
14847
|
function assertSafeAdapterPath(adapterPath) {
|
|
14290
14848
|
const normalized = adapterPath.replace(/\\/g, "/");
|
|
14291
14849
|
const parts = normalized.split("/");
|
|
14292
|
-
if (!normalized.startsWith("config/") || !normalized.endsWith(".json") || normalized.startsWith("/") ||
|
|
14850
|
+
if (!normalized.startsWith("config/") || !normalized.endsWith(".json") || normalized.startsWith("/") || path8.isAbsolute(normalized) || parts.some((part) => part === "" || part === "." || part === "..")) {
|
|
14293
14851
|
throw new Error(`Invalid plugin config adapter path: ${adapterPath}`);
|
|
14294
14852
|
}
|
|
14295
14853
|
}
|
|
14296
14854
|
function normalizeAdapterManifest(value) {
|
|
14297
14855
|
if (!Array.isArray(value)) return [];
|
|
14298
|
-
return value.filter(
|
|
14856
|
+
return value.filter(isRecord5).map((item) => ({
|
|
14299
14857
|
domain: typeof item.domain === "string" ? item.domain : "",
|
|
14300
14858
|
plugin_key: typeof item.plugin_key === "string" ? item.plugin_key : "",
|
|
14301
14859
|
capability_prefix: typeof item.capability_prefix === "string" ? item.capability_prefix : "",
|
|
@@ -14311,9 +14869,9 @@ async function installedAdapterManifests(profile, agent) {
|
|
|
14311
14869
|
for (const manifest of normalizeAdapterManifest(skill.config_adapters)) {
|
|
14312
14870
|
assertSafeDomain(manifest.domain);
|
|
14313
14871
|
assertSafeAdapterPath(manifest.adapter);
|
|
14314
|
-
const adapterPath =
|
|
14315
|
-
const adapter = JSON.parse(await
|
|
14316
|
-
if (!
|
|
14872
|
+
const adapterPath = path8.join(skill.install_path, manifest.adapter);
|
|
14873
|
+
const adapter = JSON.parse(await readFile11(adapterPath, "utf8"));
|
|
14874
|
+
if (!isRecord5(adapter) || adapter.domain !== manifest.domain || adapter.plugin_key !== manifest.plugin_key) {
|
|
14317
14875
|
throw new Error(`Plugin config adapter manifest mismatch: ${plugin}/${skill.name}/${manifest.domain}`);
|
|
14318
14876
|
}
|
|
14319
14877
|
assertAdapterEndpoints(adapter);
|
|
@@ -14405,7 +14963,7 @@ function getPathValues(value, selector) {
|
|
|
14405
14963
|
const key = arrayMode ? rawPart.slice(0, -2) : rawPart;
|
|
14406
14964
|
const next = [];
|
|
14407
14965
|
for (const item of current) {
|
|
14408
|
-
if (!
|
|
14966
|
+
if (!isRecord5(item)) continue;
|
|
14409
14967
|
const child = item[key];
|
|
14410
14968
|
if (arrayMode) {
|
|
14411
14969
|
if (Array.isArray(child)) next.push(...child);
|
|
@@ -14440,7 +14998,7 @@ function lintPluginWork(work, rules, base) {
|
|
|
14440
14998
|
const message = rule.message || `${pathSelector || "<root>"} failed ${rule.type || "validation"}`;
|
|
14441
14999
|
if (rule.type === "object") {
|
|
14442
15000
|
const value = pathSelector ? firstPathValue(work, pathSelector) : work;
|
|
14443
|
-
if (!
|
|
15001
|
+
if (!isRecord5(value)) errors.push(message);
|
|
14444
15002
|
} else if (rule.type === "nonEmptyString") {
|
|
14445
15003
|
if (!values.length || values.some((value) => typeof value !== "string" || !value.trim())) errors.push(message);
|
|
14446
15004
|
} else if (rule.type === "nonEmptyArray") {
|
|
@@ -14504,9 +15062,9 @@ async function exportPluginConfigDomain(profile, domain, id, outDir, agent = "co
|
|
|
14504
15062
|
const raw = id === "list" || id === "all" ? await apiRequest(client, resolved.adapter.endpoints?.list?.method || "GET", endpointPath(resolved.adapter.endpoints?.list, void 0, resolved.adapter.plugin_key, "list"), {
|
|
14505
15063
|
capability: capabilityFor(resolved.adapter, "list")
|
|
14506
15064
|
}) : await readPluginConfigRecord(profile, resolved.adapter, id);
|
|
14507
|
-
const rawFile =
|
|
14508
|
-
const workFile =
|
|
14509
|
-
const metaFile =
|
|
15065
|
+
const rawFile = path8.join(outDir, `${domain}-${id}-raw.json`);
|
|
15066
|
+
const workFile = path8.join(outDir, `${domain}-${id}-work.json`);
|
|
15067
|
+
const metaFile = path8.join(outDir, `${domain}-${id}-meta.json`);
|
|
14510
15068
|
const rawForHash = raw;
|
|
14511
15069
|
const work = Array.isArray(raw) ? raw : normalizeWorkFromRaw(unwrapRecord(raw), resolved.adapter);
|
|
14512
15070
|
await writeJsonFile(rawFile, raw);
|
|
@@ -14517,7 +15075,7 @@ async function exportPluginConfigDomain(profile, domain, id, outDir, agent = "co
|
|
|
14517
15075
|
profile: profile.name,
|
|
14518
15076
|
workspace: profile.config.workspace,
|
|
14519
15077
|
id,
|
|
14520
|
-
mode:
|
|
15078
|
+
mode: isRecord5(work) ? work.mode || "edit" : "list",
|
|
14521
15079
|
raw_file: rawFile,
|
|
14522
15080
|
base_hash: hashJson(rawForHash),
|
|
14523
15081
|
exported_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -14531,8 +15089,8 @@ async function readAdapterLintRules(resolved) {
|
|
|
14531
15089
|
if (!normalized.startsWith("lint/") || !normalized.endsWith(".json") || normalized.includes("..")) {
|
|
14532
15090
|
throw new Error(`Invalid plugin config lint path: ${lintPath}`);
|
|
14533
15091
|
}
|
|
14534
|
-
const lint = JSON.parse(await
|
|
14535
|
-
if (!
|
|
15092
|
+
const lint = JSON.parse(await readFile11(path8.join(resolved.install_path, normalized), "utf8"));
|
|
15093
|
+
if (!isRecord5(lint) || lint.domain !== resolved.manifest.domain || lint.plugin_key !== resolved.manifest.plugin_key) {
|
|
14536
15094
|
throw new Error(`Plugin config lint manifest mismatch: ${resolved.manifest.domain}`);
|
|
14537
15095
|
}
|
|
14538
15096
|
return Array.isArray(lint.rules) ? lint.rules : [];
|
|
@@ -14542,10 +15100,10 @@ async function lintPluginConfigWorkFile(profile, domain, workFile, agent = "code
|
|
|
14542
15100
|
const work = await readJsonFile(workFile);
|
|
14543
15101
|
const base = baseFile ? await readJsonFile(baseFile) : void 0;
|
|
14544
15102
|
const errors = [];
|
|
14545
|
-
if (!
|
|
15103
|
+
if (!isRecord5(work)) {
|
|
14546
15104
|
errors.push("Plugin config work file must be a JSON object.");
|
|
14547
15105
|
} else {
|
|
14548
|
-
errors.push(...lintPluginWork(work, await readAdapterLintRules(resolved),
|
|
15106
|
+
errors.push(...lintPluginWork(work, await readAdapterLintRules(resolved), isRecord5(base) ? normalizeWorkFromRaw(base, resolved.adapter) : void 0));
|
|
14549
15107
|
}
|
|
14550
15108
|
return {
|
|
14551
15109
|
domain,
|
|
@@ -14559,21 +15117,21 @@ async function lintPluginConfigWorkFile(profile, domain, workFile, agent = "code
|
|
|
14559
15117
|
async function buildPluginConfigSubmitPayload(profile, domain, workFile, outFile, metaFile, agent = "codex") {
|
|
14560
15118
|
const resolved = await resolvePluginConfigAdapter(profile, agent, domain);
|
|
14561
15119
|
const work = await readJsonFile(workFile);
|
|
14562
|
-
if (!
|
|
15120
|
+
if (!isRecord5(work)) throw new Error("Plugin config work file must be a JSON object.");
|
|
14563
15121
|
const meta = metaFile ? await readJsonFile(metaFile) : {};
|
|
14564
|
-
const mode = String(work.mode || (
|
|
14565
|
-
const base =
|
|
14566
|
-
const lintErrors = lintPluginWork(work, await readAdapterLintRules(resolved),
|
|
15122
|
+
const mode = String(work.mode || (isRecord5(meta) ? meta.mode || "" : "") || "edit");
|
|
15123
|
+
const base = isRecord5(meta) && typeof meta.raw_file === "string" ? await readJsonFile(meta.raw_file) : void 0;
|
|
15124
|
+
const lintErrors = lintPluginWork(work, await readAdapterLintRules(resolved), isRecord5(base) ? normalizeWorkFromRaw(base, resolved.adapter) : void 0);
|
|
14567
15125
|
if (lintErrors.length) throw new Error(`Plugin config lint failed: ${lintErrors.join("; ")}`);
|
|
14568
15126
|
const payload = fieldsRecord(work, resolved.adapter.work?.fields);
|
|
14569
15127
|
delete payload.mode;
|
|
14570
15128
|
const submitMeta = {
|
|
14571
|
-
...
|
|
15129
|
+
...isRecord5(meta) ? meta : {},
|
|
14572
15130
|
domain,
|
|
14573
15131
|
plugin: resolved.plugin,
|
|
14574
15132
|
profile: profile.name,
|
|
14575
15133
|
workspace: profile.config.workspace,
|
|
14576
|
-
id:
|
|
15134
|
+
id: isRecord5(meta) && typeof meta.id === "string" ? meta.id : "",
|
|
14577
15135
|
mode
|
|
14578
15136
|
};
|
|
14579
15137
|
const result = {
|
|
@@ -14581,7 +15139,7 @@ async function buildPluginConfigSubmitPayload(profile, domain, workFile, outFile
|
|
|
14581
15139
|
plugin: resolved.plugin,
|
|
14582
15140
|
built_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14583
15141
|
meta: submitMeta,
|
|
14584
|
-
base_hash: mode === "create" ? null :
|
|
15142
|
+
base_hash: mode === "create" ? null : isRecord5(meta) && typeof meta.base_hash === "string" ? meta.base_hash : null,
|
|
14585
15143
|
payload
|
|
14586
15144
|
};
|
|
14587
15145
|
await writeJsonFile(outFile, result);
|
|
@@ -14598,7 +15156,7 @@ async function diffPluginConfigPayload(workFile, submitFile) {
|
|
|
14598
15156
|
async function submitPluginConfigDomain(profile, domain, id, submitFile, confirm3, agent = "codex") {
|
|
14599
15157
|
const resolved = await resolvePluginConfigAdapter(profile, agent, domain);
|
|
14600
15158
|
const submit = await readJsonFile(submitFile);
|
|
14601
|
-
if (!
|
|
15159
|
+
if (!isRecord5(submit) || submit.domain !== domain || !isRecord5(submit.payload) || !isRecord5(submit.meta)) {
|
|
14602
15160
|
throw new Error("Plugin config submit requires a payload produced by `bpmax-cli config plugin <domain> build`.");
|
|
14603
15161
|
}
|
|
14604
15162
|
if (submit.meta.profile !== profile.name) {
|
|
@@ -14667,7 +15225,7 @@ async function verifyPluginConfigDomain(profile, domain, id, expectFile, agent =
|
|
|
14667
15225
|
const actual = await readPluginConfigRecord(profile, resolved.adapter, id);
|
|
14668
15226
|
const expected = expectFile ? await readJsonFile(expectFile) : void 0;
|
|
14669
15227
|
const actualComparable = comparableRecord(normalizeWorkFromRaw(actual, resolved.adapter), resolved.adapter.work?.compare_fields || resolved.adapter.work?.fields);
|
|
14670
|
-
const expectedComparable =
|
|
15228
|
+
const expectedComparable = isRecord5(expected) ? comparableRecord(expected, resolved.adapter.work?.compare_fields || resolved.adapter.work?.fields) : void 0;
|
|
14671
15229
|
const ok = expectedComparable ? hashJson(actualComparable) === hashJson(expectedComparable) : true;
|
|
14672
15230
|
return {
|
|
14673
15231
|
domain,
|
|
@@ -14693,10 +15251,10 @@ async function testPluginConfigDomain(profile, domain, id, message, agent = "cod
|
|
|
14693
15251
|
|
|
14694
15252
|
// src/commands/config-env.ts
|
|
14695
15253
|
import { execFile } from "child_process";
|
|
14696
|
-
import { mkdir as mkdir7, rm as rm3, stat as
|
|
15254
|
+
import { mkdir as mkdir7, rm as rm3, stat as stat6, writeFile as writeFile7 } from "fs/promises";
|
|
14697
15255
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
14698
15256
|
import { tmpdir as tmpdir2 } from "os";
|
|
14699
|
-
import
|
|
15257
|
+
import path9 from "path";
|
|
14700
15258
|
import { promisify } from "util";
|
|
14701
15259
|
import { password, text } from "@clack/prompts";
|
|
14702
15260
|
import axios6 from "axios";
|
|
@@ -14835,11 +15393,11 @@ async function gitCloneWithTransientCredentials(gitUrl, workspaceDir, credential
|
|
|
14835
15393
|
const sanitizedGitUrl = stripGitUrlCredentials(gitUrl);
|
|
14836
15394
|
if (!credentials) {
|
|
14837
15395
|
await execFileAsync("git", ["clone", sanitizedGitUrl, workspaceDir], {
|
|
14838
|
-
cwd:
|
|
15396
|
+
cwd: path9.dirname(workspaceDir)
|
|
14839
15397
|
});
|
|
14840
15398
|
return;
|
|
14841
15399
|
}
|
|
14842
|
-
const askpassPath =
|
|
15400
|
+
const askpassPath = path9.join(tmpdir2(), `bpmax-cli-git-askpass-${randomUUID3()}.sh`);
|
|
14843
15401
|
await writeFile7(
|
|
14844
15402
|
askpassPath,
|
|
14845
15403
|
[
|
|
@@ -14855,7 +15413,7 @@ async function gitCloneWithTransientCredentials(gitUrl, workspaceDir, credential
|
|
|
14855
15413
|
);
|
|
14856
15414
|
try {
|
|
14857
15415
|
await execFileAsync("git", ["clone", sanitizedGitUrl, workspaceDir], {
|
|
14858
|
-
cwd:
|
|
15416
|
+
cwd: path9.dirname(workspaceDir),
|
|
14859
15417
|
env: {
|
|
14860
15418
|
...process.env,
|
|
14861
15419
|
GIT_ASKPASS: askpassPath,
|
|
@@ -14873,7 +15431,7 @@ async function withTransientGitCredentials(credentials, operation) {
|
|
|
14873
15431
|
if (!credentials) {
|
|
14874
15432
|
return operation(void 0);
|
|
14875
15433
|
}
|
|
14876
|
-
const askpassPath =
|
|
15434
|
+
const askpassPath = path9.join(tmpdir2(), `bpmax-cli-git-askpass-${randomUUID3()}.sh`);
|
|
14877
15435
|
await writeFile7(
|
|
14878
15436
|
askpassPath,
|
|
14879
15437
|
[
|
|
@@ -14988,7 +15546,7 @@ function hasBlockingDirtyStatus(status, allowedPaths = /* @__PURE__ */ new Set([
|
|
|
14988
15546
|
}
|
|
14989
15547
|
async function pathExists(targetPath) {
|
|
14990
15548
|
try {
|
|
14991
|
-
await
|
|
15549
|
+
await stat6(targetPath);
|
|
14992
15550
|
return true;
|
|
14993
15551
|
} catch (error) {
|
|
14994
15552
|
if (error.code === "ENOENT") {
|
|
@@ -15213,10 +15771,10 @@ async function initConfigWorkspaceFromPlatform(env, options) {
|
|
|
15213
15771
|
requiredPlatformField(platformEnv, "pull_url");
|
|
15214
15772
|
requiredPlatformField(platformEnv, "extract_url");
|
|
15215
15773
|
requiredPlatformField(platformEnv, "push_url");
|
|
15216
|
-
const workspaceDir =
|
|
15774
|
+
const workspaceDir = path9.resolve(options.workspaceDir);
|
|
15217
15775
|
const existed = await pathExists(workspaceDir);
|
|
15218
15776
|
if (!existed) {
|
|
15219
|
-
await mkdir7(
|
|
15777
|
+
await mkdir7(path9.dirname(workspaceDir), { recursive: true });
|
|
15220
15778
|
await gitCloneWithTransientCredentials(gitUrl, workspaceDir, credentials);
|
|
15221
15779
|
} else {
|
|
15222
15780
|
await assertExistingGitWorkspace(workspaceDir, gitUrl, options.force);
|
|
@@ -15320,17 +15878,17 @@ async function pullLatestConfigEnvironment(env, options) {
|
|
|
15320
15878
|
}
|
|
15321
15879
|
|
|
15322
15880
|
// src/commands/config.ts
|
|
15323
|
-
var
|
|
15881
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15324
15882
|
function csvCell(value) {
|
|
15325
|
-
const text5 = value === null || value === void 0 ? "" : Array.isArray(value) ||
|
|
15883
|
+
const text5 = value === null || value === void 0 ? "" : Array.isArray(value) || isRecord6(value) ? JSON.stringify(value) : String(value);
|
|
15326
15884
|
return /[",\n\r]/.test(text5) ? `"${text5.replace(/"/g, '""')}"` : text5;
|
|
15327
15885
|
}
|
|
15328
15886
|
async function writeEvidenceOut(file, value) {
|
|
15329
15887
|
if (!file) {
|
|
15330
15888
|
return;
|
|
15331
15889
|
}
|
|
15332
|
-
await mkdir8(
|
|
15333
|
-
const evidence =
|
|
15890
|
+
await mkdir8(path10.dirname(path10.resolve(file)), { recursive: true });
|
|
15891
|
+
const evidence = isRecord6(value.evidence) ? value.evidence : value;
|
|
15334
15892
|
if (file.endsWith(".csv")) {
|
|
15335
15893
|
const keys = [
|
|
15336
15894
|
"flow_type",
|
|
@@ -15356,7 +15914,7 @@ async function writeResponseOut(file, value) {
|
|
|
15356
15914
|
if (!file) {
|
|
15357
15915
|
return;
|
|
15358
15916
|
}
|
|
15359
|
-
await mkdir8(
|
|
15917
|
+
await mkdir8(path10.dirname(path10.resolve(file)), { recursive: true });
|
|
15360
15918
|
await writeFile8(file, `${JSON.stringify(value, null, 2)}
|
|
15361
15919
|
`, "utf8");
|
|
15362
15920
|
}
|
|
@@ -15380,15 +15938,15 @@ function arrayValue(value) {
|
|
|
15380
15938
|
return Array.isArray(value) ? value : [];
|
|
15381
15939
|
}
|
|
15382
15940
|
function flowTemplateNodes(work) {
|
|
15383
|
-
const data =
|
|
15384
|
-
return arrayValue(data?.nodes).filter(
|
|
15941
|
+
const data = isRecord6(work.data) ? work.data : void 0;
|
|
15942
|
+
return arrayValue(data?.nodes).filter(isRecord6);
|
|
15385
15943
|
}
|
|
15386
15944
|
function summarizeFlowTemplateWork(work) {
|
|
15387
|
-
if (!
|
|
15945
|
+
if (!isRecord6(work)) {
|
|
15388
15946
|
return { available: false, reason: "flow-template work file is not a JSON object" };
|
|
15389
15947
|
}
|
|
15390
|
-
const data =
|
|
15391
|
-
const meta =
|
|
15948
|
+
const data = isRecord6(work.data) ? work.data : {};
|
|
15949
|
+
const meta = isRecord6(data.meta) ? data.meta : {};
|
|
15392
15950
|
const nodes = flowTemplateNodes(work);
|
|
15393
15951
|
const matrixOwnerNodes = nodes.filter((node) => JSON.stringify(node).includes("matrix_owner")).map((node) => ({
|
|
15394
15952
|
id: stringValue(node.id),
|
|
@@ -15400,7 +15958,7 @@ function summarizeFlowTemplateWork(work) {
|
|
|
15400
15958
|
name: stringValue(node.name),
|
|
15401
15959
|
type: stringValue(node.type)
|
|
15402
15960
|
}));
|
|
15403
|
-
const publish =
|
|
15961
|
+
const publish = isRecord6(work.publish) ? work.publish : void 0;
|
|
15404
15962
|
return {
|
|
15405
15963
|
available: true,
|
|
15406
15964
|
name: stringValue(work.name),
|
|
@@ -15909,7 +16467,7 @@ function registerConfigCommands(program2) {
|
|
|
15909
16467
|
printResult(options.format, result);
|
|
15910
16468
|
});
|
|
15911
16469
|
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) => {
|
|
15912
|
-
if (options.submit && options.payload &&
|
|
16470
|
+
if (options.submit && options.payload && path10.resolve(options.submit) !== path10.resolve(options.payload)) {
|
|
15913
16471
|
throw new Error(`config ${domain} diff received different --submit and --payload files; provide only one artifact.`);
|
|
15914
16472
|
}
|
|
15915
16473
|
const submitFile = options.submit ?? options.payload;
|
|
@@ -15927,6 +16485,29 @@ function registerConfigCommands(program2) {
|
|
|
15927
16485
|
submit_preview: submit || null
|
|
15928
16486
|
});
|
|
15929
16487
|
});
|
|
16488
|
+
domainCommand.command("impact").description(`Analyze downstream configuration references affected by ${domain} work changes`).option("--raw <file>", "Exported raw baseline JSON file; omit for create mode").requiredOption("--work <file>", "Modified work JSON file").option("--out <file>", "Write the machine-readable impact report to a JSON file").option("--profile <profile>", "Profile name; accepted for command consistency").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
16489
|
+
const workspaceRoot = await findConfigWorkspaceRoot();
|
|
16490
|
+
if (!workspaceRoot) {
|
|
16491
|
+
throw new Error("Config impact analysis requires a recognized BPMAX configuration workspace.");
|
|
16492
|
+
}
|
|
16493
|
+
const configData = await loadConfig();
|
|
16494
|
+
const resolved = resolveProfile(configData, options.profile);
|
|
16495
|
+
const result = await analyzeConfigImpact({
|
|
16496
|
+
domain,
|
|
16497
|
+
raw: options.raw ? await readJsonFile(options.raw) : {},
|
|
16498
|
+
work: await readJsonFile(options.work),
|
|
16499
|
+
workspaceRoot
|
|
16500
|
+
});
|
|
16501
|
+
const output = {
|
|
16502
|
+
...result,
|
|
16503
|
+
profile: resolved.name,
|
|
16504
|
+
raw_file: options.raw ?? null,
|
|
16505
|
+
work_file: options.work,
|
|
16506
|
+
report_file: options.out ?? null
|
|
16507
|
+
};
|
|
16508
|
+
await writeResponseOut(options.out, output);
|
|
16509
|
+
printResult(options.format, output);
|
|
16510
|
+
});
|
|
15930
16511
|
domainCommand.command("submit").description(`Submit a ${domain} payload when a verified domain adapter is available; dry-run unless --confirm is exact`).requiredOption("--id <id>", "Remote config id").requiredOption("--payload <file>", "Submit payload JSON file produced by build").option("--profile <profile>", "Profile name").option("--agent <agent>", "Agent adapter for installed plugin lint discovery", "codex").option("--confirm <text>", "Exact confirmation text").option("--publish-live", "For flow-template, submit this payload as a live publish").option("--response-out <file>", "Write the full JSON response to a file").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
15931
16512
|
const configData = await loadConfig();
|
|
15932
16513
|
const resolved = resolveProfile(configData, options.profile);
|
|
@@ -16044,8 +16625,8 @@ function registerConfigCommands(program2) {
|
|
|
16044
16625
|
|
|
16045
16626
|
// src/commands/e2e.ts
|
|
16046
16627
|
import { createHash as createHash6 } from "crypto";
|
|
16047
|
-
import { mkdir as mkdir10, readFile as
|
|
16048
|
-
import
|
|
16628
|
+
import { mkdir as mkdir10, readFile as readFile13, readdir as readdir5, stat as stat8, writeFile as writeFile10 } from "fs/promises";
|
|
16629
|
+
import path12 from "path";
|
|
16049
16630
|
import axios7 from "axios";
|
|
16050
16631
|
|
|
16051
16632
|
// src/core/test-suite.ts
|
|
@@ -16055,16 +16636,16 @@ import {
|
|
|
16055
16636
|
cp as cp3,
|
|
16056
16637
|
mkdir as mkdir9,
|
|
16057
16638
|
open as open2,
|
|
16058
|
-
readdir as
|
|
16059
|
-
readFile as
|
|
16639
|
+
readdir as readdir4,
|
|
16640
|
+
readFile as readFile12,
|
|
16060
16641
|
realpath as realpath2,
|
|
16061
16642
|
rename,
|
|
16062
16643
|
rm as rm4,
|
|
16063
|
-
stat as
|
|
16644
|
+
stat as stat7,
|
|
16064
16645
|
unlink,
|
|
16065
16646
|
writeFile as writeFile9
|
|
16066
16647
|
} from "fs/promises";
|
|
16067
|
-
import
|
|
16648
|
+
import path11 from "path";
|
|
16068
16649
|
import { inflateSync } from "zlib";
|
|
16069
16650
|
var DEFAULT_SUITE_ROOT = ".ai_test/suite";
|
|
16070
16651
|
var DEFAULT_DRAFT_ROOT = ".ai_test/suite_draft";
|
|
@@ -16221,7 +16802,7 @@ var YBS_PC_CREATE_WRONG_RE = /https:\/\/yaditest\.yitaiyitai\.com\/w:ybs\/pages\
|
|
|
16221
16802
|
var IDENTITY_MOCK_CASE_RE = /(非处理人|越权|只读|多角色|角色隔离|无权限|低权限|unauthorized|limited|readonly|permission)/;
|
|
16222
16803
|
var IDENTITY_MOCK_VALUE_RE = /(mock|模拟).*(unmock|退出模拟|恢复)|bpmax-user-mock-operator/;
|
|
16223
16804
|
var E2E_REUSABLE_ASSET_RE = /bpmax-cli\s+e2e|record-from-evidence|create-page-submit|step-run|browser-template|scenario\s+plan|data\s+profile|reusable\s+step|复用模板|可复用|首次运行沉淀|沉淀模板/;
|
|
16224
|
-
var ERROR_CAPTURE_CASE_RE = /(negative|boundary
|
|
16805
|
+
var ERROR_CAPTURE_CASE_RE = /(negative|boundary|异常|错误|失败|报错|无效|非法|invalid|error|扫码.*(异常|错误|无效)|错误\s*SN|异常\s*SN|无效\s*SN)/i;
|
|
16225
16806
|
var ERROR_CAPTURE_EVIDENCE_RE = /(expected_error_text|error_capture_required|错误提示|提示文案|报错文案|toast|校验文案).*(screenshot|截图)|截图.*(错误提示|提示文案|报错文案|toast|校验文案)/i;
|
|
16226
16807
|
var BROWSER_TOOL_RE = /(Chrome DevTools|DevTools|Playwright|AppleScript)/i;
|
|
16227
16808
|
var REPORT_EVIDENCE_PLACEHOLDER_RE = /^(?:n\/?a|none|null|todo|tbd|xxx|unknown|pending|待补|暂无|无|未执行|跳过|-+)$/i;
|
|
@@ -16263,14 +16844,14 @@ function runtimeRoute(runtimeUrl) {
|
|
|
16263
16844
|
}
|
|
16264
16845
|
async function exists3(filePath) {
|
|
16265
16846
|
try {
|
|
16266
|
-
await
|
|
16847
|
+
await stat7(filePath);
|
|
16267
16848
|
return true;
|
|
16268
16849
|
} catch {
|
|
16269
16850
|
return false;
|
|
16270
16851
|
}
|
|
16271
16852
|
}
|
|
16272
16853
|
async function readText(filePath) {
|
|
16273
|
-
return
|
|
16854
|
+
return readFile12(filePath, "utf8");
|
|
16274
16855
|
}
|
|
16275
16856
|
function fail(message, options = {}) {
|
|
16276
16857
|
throw new TestSuiteError(message, options);
|
|
@@ -16331,12 +16912,12 @@ function reviewSchemaExplanation() {
|
|
|
16331
16912
|
};
|
|
16332
16913
|
}
|
|
16333
16914
|
function reviewFail(reviewPath, message) {
|
|
16334
|
-
const scenarioId =
|
|
16915
|
+
const scenarioId = path11.basename(path11.dirname(reviewPath));
|
|
16335
16916
|
fail(
|
|
16336
16917
|
[
|
|
16337
16918
|
message,
|
|
16338
16919
|
"\u8FD0\u884C `bpmax-cli test-suite review explain --format json` \u67E5\u770B\u5B8C\u6574 schema\u3002",
|
|
16339
|
-
`\u8FD0\u884C \`bpmax-cli test-suite review repair --scenario ${scenarioId} --draft-root ${
|
|
16920
|
+
`\u8FD0\u884C \`bpmax-cli test-suite review repair --scenario ${scenarioId} --draft-root ${path11.dirname(path11.dirname(reviewPath))} --latest-proof <proof.json> --format json\` \u4FEE\u8865\u7F3A\u5931\u5B57\u6BB5\u3002`,
|
|
16340
16921
|
`\u6700\u5C0F review.json \u793A\u4F8B\uFF1A${JSON.stringify(reviewSchemaExample(scenarioId))}`
|
|
16341
16922
|
].join("\n"),
|
|
16342
16923
|
{
|
|
@@ -16391,7 +16972,7 @@ async function readCases(filePath) {
|
|
|
16391
16972
|
code: "legacy_case_steps_format",
|
|
16392
16973
|
rule_id: "test_suite.case_steps.legacy_aggregated",
|
|
16393
16974
|
path: filePath,
|
|
16394
|
-
suggestion: `\u8FD0\u884C \`bpmax-cli test-suite steps migrate --scenario ${
|
|
16975
|
+
suggestion: `\u8FD0\u884C \`bpmax-cli test-suite steps migrate --scenario ${path11.basename(path11.dirname(filePath))} --draft-root ${path11.dirname(path11.dirname(filePath))} --latest-proof <proof.json> --format json\`\uFF0C\u518D\u8865\u9F50\u9010\u6B65\u9AA4\u5B57\u6BB5\u3002`
|
|
16395
16976
|
});
|
|
16396
16977
|
}
|
|
16397
16978
|
if (JSON.stringify(fields) !== JSON.stringify(CASE_FIELDS)) {
|
|
@@ -16491,14 +17072,14 @@ function parseReadmeText(filePath, text5) {
|
|
|
16491
17072
|
return metadata;
|
|
16492
17073
|
}
|
|
16493
17074
|
async function validateReadme(scenarioDir) {
|
|
16494
|
-
const readmePath =
|
|
17075
|
+
const readmePath = path11.join(scenarioDir, "README.md");
|
|
16495
17076
|
if (!await exists3(readmePath)) fail(`missing README.md: ${readmePath}`);
|
|
16496
17077
|
const text5 = await readText(readmePath);
|
|
16497
17078
|
const metadata = parseReadmeText(readmePath, text5);
|
|
16498
17079
|
for (const key of REQUIRED_README_KEYS) {
|
|
16499
17080
|
if (!metadata[key]) fail(`${scenarioDir}: README.md missing \`${key}\``);
|
|
16500
17081
|
}
|
|
16501
|
-
if (metadata.scenario_id !==
|
|
17082
|
+
if (metadata.scenario_id !== path11.basename(scenarioDir)) fail(`${scenarioDir}: scenario_id must match directory name`);
|
|
16502
17083
|
if (!["true", "false"].includes(metadata.core.toLowerCase())) fail(`${scenarioDir}: core must be true or false`);
|
|
16503
17084
|
if (!STATUSES.has(metadata.status)) fail(`${scenarioDir}: status must be one of ${JSON.stringify([...STATUSES].sort())}`);
|
|
16504
17085
|
if (UUID_RE2.test(text5) || ID_AS_ENTRY_RE.test(text5)) {
|
|
@@ -16816,14 +17397,14 @@ async function collectE2eAccelerationGaps(root) {
|
|
|
16816
17397
|
const dirs = await scenarioDirs(root);
|
|
16817
17398
|
const gaps = [];
|
|
16818
17399
|
for (const dir of dirs) {
|
|
16819
|
-
const scenarioId =
|
|
16820
|
-
const casesPath =
|
|
17400
|
+
const scenarioId = path11.basename(dir);
|
|
17401
|
+
const casesPath = path11.join(dir, "cases.csv");
|
|
16821
17402
|
if (!await exists3(casesPath)) {
|
|
16822
17403
|
continue;
|
|
16823
17404
|
}
|
|
16824
17405
|
const rows2 = await readCases(casesPath);
|
|
16825
|
-
const steps = await readCaseSteps(
|
|
16826
|
-
const stepsByCase = validateCaseSteps(
|
|
17406
|
+
const steps = await readCaseSteps(path11.join(dir, "case_steps.csv"));
|
|
17407
|
+
const stepsByCase = validateCaseSteps(path11.join(dir, "case_steps.csv"), rows2, steps);
|
|
16827
17408
|
for (const row of rows2) {
|
|
16828
17409
|
const caseSteps = stepsByCase.get(row.case_id.trim()) ?? [];
|
|
16829
17410
|
if (row.status === "deprecated" || hasE2eReusableAsset(row, caseSteps)) {
|
|
@@ -16842,14 +17423,14 @@ async function collectE2eAccelerationGaps(root) {
|
|
|
16842
17423
|
}
|
|
16843
17424
|
async function scenarioDirs(root) {
|
|
16844
17425
|
if (!await exists3(root)) return [];
|
|
16845
|
-
const items = await
|
|
16846
|
-
return items.filter((item) => item.isDirectory()).map((item) =>
|
|
17426
|
+
const items = await readdir4(root, { withFileTypes: true });
|
|
17427
|
+
return items.filter((item) => item.isDirectory()).map((item) => path11.join(root, item.name)).sort();
|
|
16847
17428
|
}
|
|
16848
17429
|
async function validateScenario(scenarioDir) {
|
|
16849
17430
|
const metadata = await validateReadme(scenarioDir);
|
|
16850
|
-
const casesPath =
|
|
17431
|
+
const casesPath = path11.join(scenarioDir, "cases.csv");
|
|
16851
17432
|
const rows2 = await readCases(casesPath);
|
|
16852
|
-
const caseStepsPath =
|
|
17433
|
+
const caseStepsPath = path11.join(scenarioDir, "case_steps.csv");
|
|
16853
17434
|
const caseSteps = await readCaseSteps(caseStepsPath);
|
|
16854
17435
|
const stepsByCase = validateCaseSteps(caseStepsPath, rows2, caseSteps);
|
|
16855
17436
|
if (rows2.length === 0) fail(`${casesPath}: at least one case is required`);
|
|
@@ -16911,7 +17492,7 @@ function migratedStepActions(value) {
|
|
|
16911
17492
|
async function migrateScenarioSteps(options) {
|
|
16912
17493
|
const scenarioDir = scenarioPath(options.draftRoot ?? DEFAULT_DRAFT_ROOT, options.scenario);
|
|
16913
17494
|
await validateReadme(scenarioDir);
|
|
16914
|
-
const casesPath =
|
|
17495
|
+
const casesPath = path11.join(scenarioDir, "cases.csv");
|
|
16915
17496
|
const legacyRows = await readLegacyCases(casesPath);
|
|
16916
17497
|
const nextCases = legacyRows.map(({ steps: _steps, ...row }) => row);
|
|
16917
17498
|
const stepRows = [];
|
|
@@ -16941,7 +17522,7 @@ async function migrateScenarioSteps(options) {
|
|
|
16941
17522
|
});
|
|
16942
17523
|
}
|
|
16943
17524
|
await writeFile9(casesPath, csvText(CASE_FIELDS, nextCases), "utf8");
|
|
16944
|
-
const stepsPath =
|
|
17525
|
+
const stepsPath = path11.join(scenarioDir, "case_steps.csv");
|
|
16945
17526
|
await writeFile9(stepsPath, csvText(CASE_STEP_FIELDS, stepRows), "utf8");
|
|
16946
17527
|
return {
|
|
16947
17528
|
ok: false,
|
|
@@ -16956,9 +17537,9 @@ async function migrateScenarioSteps(options) {
|
|
|
16956
17537
|
}
|
|
16957
17538
|
async function suiteHash(scenarioDir) {
|
|
16958
17539
|
const hash = createHash5("sha256");
|
|
16959
|
-
hash.update(await readText(
|
|
16960
|
-
hash.update(await readText(
|
|
16961
|
-
hash.update(await readText(
|
|
17540
|
+
hash.update(await readText(path11.join(scenarioDir, "README.md")));
|
|
17541
|
+
hash.update(await readText(path11.join(scenarioDir, "cases.csv")));
|
|
17542
|
+
hash.update(await readText(path11.join(scenarioDir, "case_steps.csv")));
|
|
16962
17543
|
return hash.digest("hex");
|
|
16963
17544
|
}
|
|
16964
17545
|
function executionManifestHash(manifest) {
|
|
@@ -16967,7 +17548,7 @@ function executionManifestHash(manifest) {
|
|
|
16967
17548
|
async function readExecutionManifest(manifestPath) {
|
|
16968
17549
|
let value;
|
|
16969
17550
|
try {
|
|
16970
|
-
value = JSON.parse(await readText(
|
|
17551
|
+
value = JSON.parse(await readText(path11.resolve(manifestPath)));
|
|
16971
17552
|
} catch {
|
|
16972
17553
|
fail(`invalid execution manifest: ${manifestPath}`, { rule_id: "test_suite.execution_manifest.invalid", path: manifestPath });
|
|
16973
17554
|
}
|
|
@@ -16978,10 +17559,10 @@ async function readExecutionManifest(manifestPath) {
|
|
|
16978
17559
|
if (!RUN_RE.test(String(manifest.run_id || "")) || !SCENARIO_ID_RE.test(String(manifest.scenario_id || "")) || !String(manifest.case_id || "").trim() || !String(manifest.source_suite || "").trim() || !/^[a-f0-9]{64}$/.test(String(manifest.suite_hash || "")) || !Array.isArray(manifest.steps) || !["running", "pass", "fail", "blocked"].includes(manifest.result)) {
|
|
16979
17560
|
fail(`invalid execution manifest shape: ${manifestPath}`, { rule_id: "test_suite.execution_manifest.invalid", path: manifestPath });
|
|
16980
17561
|
}
|
|
16981
|
-
if (
|
|
17562
|
+
if (path11.basename(path11.dirname(path11.resolve(manifestPath))) !== manifest.run_id) {
|
|
16982
17563
|
fail("execution manifest run_id must match its report directory", { rule_id: "test_suite.execution_manifest.run_scope", path: manifestPath });
|
|
16983
17564
|
}
|
|
16984
|
-
const statePath = `${
|
|
17565
|
+
const statePath = `${path11.resolve(manifestPath)}.state.json`;
|
|
16985
17566
|
if (await exists3(statePath)) {
|
|
16986
17567
|
try {
|
|
16987
17568
|
const state = JSON.parse(await readText(statePath));
|
|
@@ -16999,14 +17580,14 @@ async function readExecutionManifest(manifestPath) {
|
|
|
16999
17580
|
return manifest;
|
|
17000
17581
|
}
|
|
17001
17582
|
async function writeAtomicJson(filePath, value) {
|
|
17002
|
-
const resolved =
|
|
17583
|
+
const resolved = path11.resolve(filePath);
|
|
17003
17584
|
const tempPath = `${resolved}.tmp-${process.pid}-${Date.now()}`;
|
|
17004
17585
|
await writeFile9(tempPath, `${JSON.stringify(value, null, 2)}
|
|
17005
17586
|
`, "utf8");
|
|
17006
17587
|
await rename(tempPath, resolved);
|
|
17007
17588
|
}
|
|
17008
17589
|
async function withExecutionManifestLock(manifestPath, action) {
|
|
17009
|
-
const resolved =
|
|
17590
|
+
const resolved = path11.resolve(manifestPath);
|
|
17010
17591
|
const lockPath = `${resolved}.lock`;
|
|
17011
17592
|
let handle;
|
|
17012
17593
|
try {
|
|
@@ -17033,27 +17614,27 @@ async function assertExecutionManifestFresh(manifest, manifestPath) {
|
|
|
17033
17614
|
}
|
|
17034
17615
|
}
|
|
17035
17616
|
async function evidenceContainsDiagnostic(evidencePath) {
|
|
17036
|
-
const info = await
|
|
17617
|
+
const info = await stat7(evidencePath);
|
|
17037
17618
|
if (info.isDirectory()) {
|
|
17038
|
-
const entries = await
|
|
17619
|
+
const entries = await readdir4(evidencePath, { withFileTypes: true });
|
|
17039
17620
|
for (const entry of entries) {
|
|
17040
17621
|
if (!entry.isFile()) continue;
|
|
17041
17622
|
if (/diagnostic/i.test(entry.name)) return true;
|
|
17042
17623
|
if (!/\.(json|txt|md)$/i.test(entry.name)) continue;
|
|
17043
|
-
const value2 = await readText(
|
|
17624
|
+
const value2 = await readText(path11.join(evidencePath, entry.name)).catch(() => "");
|
|
17044
17625
|
if (/"?diagnostic"?\s*[:=]\s*(?:true|"diagnostic")|result\s*[:=]\s*diagnostic/i.test(value2)) return true;
|
|
17045
17626
|
}
|
|
17046
17627
|
return false;
|
|
17047
17628
|
}
|
|
17048
|
-
if (/diagnostic/i.test(
|
|
17629
|
+
if (/diagnostic/i.test(path11.basename(evidencePath))) return true;
|
|
17049
17630
|
if (!/\.(json|txt|md)$/i.test(evidencePath)) return false;
|
|
17050
17631
|
const value = await readText(evidencePath).catch(() => "");
|
|
17051
17632
|
return /"?diagnostic"?\s*[:=]\s*(?:true|"diagnostic")|result\s*[:=]\s*diagnostic/i.test(value);
|
|
17052
17633
|
}
|
|
17053
17634
|
function pathInside(root, candidate) {
|
|
17054
|
-
const resolvedRoot =
|
|
17055
|
-
const resolvedCandidate =
|
|
17056
|
-
return resolvedCandidate === resolvedRoot || resolvedCandidate.startsWith(`${resolvedRoot}${
|
|
17635
|
+
const resolvedRoot = path11.resolve(root);
|
|
17636
|
+
const resolvedCandidate = path11.resolve(candidate);
|
|
17637
|
+
return resolvedCandidate === resolvedRoot || resolvedCandidate.startsWith(`${resolvedRoot}${path11.sep}`);
|
|
17057
17638
|
}
|
|
17058
17639
|
async function pathInsideReal(root, candidate) {
|
|
17059
17640
|
if (!pathInside(root, candidate)) return false;
|
|
@@ -17077,16 +17658,16 @@ async function assertCurrentRunArtifact(manifest, artifactPath) {
|
|
|
17077
17658
|
if (!await exists3(artifactPath)) {
|
|
17078
17659
|
fail(`execution evidence artifact not found: ${artifactPath}`, { rule_id: "test_suite.run.evidence_missing", path: artifactPath });
|
|
17079
17660
|
}
|
|
17080
|
-
const info = await
|
|
17661
|
+
const info = await stat7(artifactPath);
|
|
17081
17662
|
if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
|
|
17082
17663
|
fail("execution evidence artifact predates the current run", { rule_id: "test_suite.run.evidence_stale", path: artifactPath });
|
|
17083
17664
|
}
|
|
17084
17665
|
}
|
|
17085
17666
|
async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
|
|
17086
17667
|
if (!await exists3(evidencePath)) fail(`execution evidence not found: ${evidencePath}`, { rule_id: "test_suite.run.evidence_missing", path: evidencePath });
|
|
17087
|
-
const runDir =
|
|
17668
|
+
const runDir = path11.dirname(path11.resolve(manifestPath));
|
|
17088
17669
|
await assertCurrentRunPathScope(runDir, evidencePath, "formal execution evidence must stay inside the current report run directory");
|
|
17089
|
-
const info = await
|
|
17670
|
+
const info = await stat7(evidencePath);
|
|
17090
17671
|
if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
|
|
17091
17672
|
fail("execution evidence predates the current run", { rule_id: "test_suite.run.evidence_stale", path: evidencePath });
|
|
17092
17673
|
}
|
|
@@ -17095,19 +17676,19 @@ async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
|
|
|
17095
17676
|
}
|
|
17096
17677
|
}
|
|
17097
17678
|
async function evidenceTexts(evidencePath) {
|
|
17098
|
-
const info = await
|
|
17679
|
+
const info = await stat7(evidencePath);
|
|
17099
17680
|
if (!info.isDirectory()) return [await readText(evidencePath).catch(() => "")];
|
|
17100
|
-
const entries = await
|
|
17681
|
+
const entries = await readdir4(evidencePath, { withFileTypes: true });
|
|
17101
17682
|
const texts = [];
|
|
17102
17683
|
for (const entry of entries) {
|
|
17103
17684
|
if (!entry.isFile() || !/\.(json|txt|md)$/i.test(entry.name)) continue;
|
|
17104
|
-
texts.push(await readText(
|
|
17685
|
+
texts.push(await readText(path11.join(evidencePath, entry.name)).catch(() => ""));
|
|
17105
17686
|
}
|
|
17106
17687
|
return texts;
|
|
17107
17688
|
}
|
|
17108
17689
|
async function evidenceJsonRecords(evidencePath) {
|
|
17109
|
-
const info = await
|
|
17110
|
-
const paths = info.isDirectory() ? (await
|
|
17690
|
+
const info = await stat7(evidencePath);
|
|
17691
|
+
const paths = info.isDirectory() ? (await readdir4(evidencePath, { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => path11.join(evidencePath, entry.name)) : [evidencePath];
|
|
17111
17692
|
const records = [];
|
|
17112
17693
|
for (const source of paths) {
|
|
17113
17694
|
try {
|
|
@@ -17152,9 +17733,9 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
|
|
|
17152
17733
|
if (expectedResult !== "pass" && !assertions.some((assertion) => assertion.passed === false)) continue;
|
|
17153
17734
|
const screenshot = typeof value.screenshot === "string" ? value.screenshot.trim() : "";
|
|
17154
17735
|
if (!screenshot) continue;
|
|
17155
|
-
const screenshotPath =
|
|
17736
|
+
const screenshotPath = path11.resolve(path11.dirname(source), screenshot);
|
|
17156
17737
|
await assertCurrentRunArtifact(manifest, source);
|
|
17157
|
-
await assertCurrentRunPathScope(
|
|
17738
|
+
await assertCurrentRunPathScope(path11.dirname(manifestPath), screenshotPath, "browser screenshot must stay inside the current report run directory");
|
|
17158
17739
|
await assertCurrentRunArtifact(manifest, screenshotPath);
|
|
17159
17740
|
if (!await isValidCurrentRunScreenshot(screenshotPath)) {
|
|
17160
17741
|
fail("browser pass evidence screenshot must be a valid visible PNG of at least 100x80", { rule_id: "test_suite.run.screenshot_invalid", path: screenshotPath });
|
|
@@ -17162,8 +17743,8 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
|
|
|
17162
17743
|
if (/\bdom\b/i.test(step.evidence_required)) {
|
|
17163
17744
|
const domSnapshot = typeof value.dom_snapshot === "string" ? value.dom_snapshot.trim() : "";
|
|
17164
17745
|
if (!domSnapshot) continue;
|
|
17165
|
-
const domPath =
|
|
17166
|
-
await assertCurrentRunPathScope(
|
|
17746
|
+
const domPath = path11.resolve(path11.dirname(source), domSnapshot);
|
|
17747
|
+
await assertCurrentRunPathScope(path11.dirname(manifestPath), domPath, "browser DOM evidence must stay inside the current report run directory");
|
|
17167
17748
|
await assertCurrentRunArtifact(manifest, domPath);
|
|
17168
17749
|
}
|
|
17169
17750
|
matchedRecord = true;
|
|
@@ -17269,7 +17850,7 @@ async function browserReportEvidence(manifest) {
|
|
|
17269
17850
|
if (label) result.assertions.push(assertion.passed === false ? `\u5931\u8D25\u65AD\u8A00\uFF1A${label}` : label);
|
|
17270
17851
|
}
|
|
17271
17852
|
const screenshot = String(value.screenshot || "").trim();
|
|
17272
|
-
if (screenshot) result.screenshots.push({ stepId: step.step_id, path:
|
|
17853
|
+
if (screenshot) result.screenshots.push({ stepId: step.step_id, path: path11.resolve(path11.dirname(source), screenshot) });
|
|
17273
17854
|
}
|
|
17274
17855
|
}
|
|
17275
17856
|
}
|
|
@@ -17277,11 +17858,11 @@ async function browserReportEvidence(manifest) {
|
|
|
17277
17858
|
return result;
|
|
17278
17859
|
}
|
|
17279
17860
|
async function syncTestSuiteRunReportUnlocked(manifestFile) {
|
|
17280
|
-
const manifestPath =
|
|
17861
|
+
const manifestPath = path11.resolve(manifestFile);
|
|
17281
17862
|
const manifest = await readExecutionManifest(manifestPath);
|
|
17282
17863
|
await assertExecutionManifestFresh(manifest, manifestPath);
|
|
17283
|
-
const runDir =
|
|
17284
|
-
const reportPath =
|
|
17864
|
+
const runDir = path11.dirname(manifestPath);
|
|
17865
|
+
const reportPath = path11.join(runDir, `${manifest.scenario_id}.md`);
|
|
17285
17866
|
if (!await exists3(reportPath)) {
|
|
17286
17867
|
fail("scenario report scaffold is missing; restart the run or restore the generated report", { rule_id: "test_suite.run.report_missing", path: reportPath });
|
|
17287
17868
|
}
|
|
@@ -17309,7 +17890,7 @@ async function syncTestSuiteRunReportUnlocked(manifestFile) {
|
|
|
17309
17890
|
}
|
|
17310
17891
|
}
|
|
17311
17892
|
report = replaceReportMetadata(report, "browser_status", blockerEvidence ? "blocked" : null);
|
|
17312
|
-
report = replaceReportMetadata(report, "blocker_evidence", blockerEvidence ?
|
|
17893
|
+
report = replaceReportMetadata(report, "blocker_evidence", blockerEvidence ? path11.relative(runDir, blockerEvidence) : null);
|
|
17313
17894
|
report = replaceReportMetadata(report, "runtime_profile", manifest.profile);
|
|
17314
17895
|
report = replaceReportMetadata(report, "profile_origin", manifest.profile_origin || null);
|
|
17315
17896
|
report = replaceReportMetadata(report, "runtime_workspace", manifest.workspace || null);
|
|
@@ -17328,11 +17909,11 @@ async function syncTestSuiteRunReportUnlocked(manifestFile) {
|
|
|
17328
17909
|
`| ${manifest.case_id}`,
|
|
17329
17910
|
`${step.step_id} ${step.action}`,
|
|
17330
17911
|
step.status,
|
|
17331
|
-
step.evidence.length ? step.evidence.map((item) => `\`${
|
|
17912
|
+
step.evidence.length ? step.evidence.map((item) => `\`${path11.relative(runDir, item)}\``).join("<br>") : "pending"
|
|
17332
17913
|
].join(" | ") + " |")
|
|
17333
17914
|
].join("\n");
|
|
17334
17915
|
report = replaceReportSection(report, "## 3. \u7528\u4F8B\u6267\u884C\u7ED3\u679C", "## 4. \u622A\u56FE\u8BC1\u636E", table);
|
|
17335
|
-
const screenshotBody = evidence.screenshots.length ? evidence.screenshots.map((item) => ` => `})`).join("\n\n") : "pending";
|
|
17336
17917
|
report = replaceReportSection(report, "## 4. \u622A\u56FE\u8BC1\u636E", "## 5. \u63A5\u53E3 / \u6570\u636E\u56DE\u8BFB\u8BC1\u636E", screenshotBody);
|
|
17337
17918
|
const tempPath = `${reportPath}.tmp-${process.pid}`;
|
|
17338
17919
|
await writeFile9(tempPath, report, "utf8");
|
|
@@ -17351,7 +17932,7 @@ async function previousBrowserScreenshotHashes(manifest, step) {
|
|
|
17351
17932
|
for (const { value, source } of await evidenceJsonRecords(previousEvidence)) {
|
|
17352
17933
|
const screenshot = typeof value.screenshot === "string" ? value.screenshot.trim() : "";
|
|
17353
17934
|
if (!screenshot) continue;
|
|
17354
|
-
const screenshotPath =
|
|
17935
|
+
const screenshotPath = path11.resolve(path11.dirname(source), screenshot);
|
|
17355
17936
|
if (await exists3(screenshotPath)) hashes.add(await sha256(screenshotPath));
|
|
17356
17937
|
}
|
|
17357
17938
|
}
|
|
@@ -17385,12 +17966,12 @@ async function assertFormalExecutionEvidence(manifest, manifestPath, step, evide
|
|
|
17385
17966
|
const sourceEvidence = typeof value.source_evidence === "string" ? value.source_evidence : "";
|
|
17386
17967
|
if (!observed || assertions.length === 0 || !assertions.every((assertion) => assertion.passed === true) || !sourceEvidence) continue;
|
|
17387
17968
|
await assertCurrentRunArtifact(manifest, source);
|
|
17388
|
-
const sourcePath =
|
|
17389
|
-
const runDir =
|
|
17969
|
+
const sourcePath = path11.resolve(path11.dirname(source), sourceEvidence);
|
|
17970
|
+
const runDir = path11.dirname(path11.resolve(manifestPath));
|
|
17390
17971
|
if (!pathInside(runDir, sourcePath)) {
|
|
17391
17972
|
fail("observe source_evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: sourcePath });
|
|
17392
17973
|
}
|
|
17393
|
-
if (!await exists3(sourcePath) || !(await
|
|
17974
|
+
if (!await exists3(sourcePath) || !(await stat7(sourcePath)).isFile()) continue;
|
|
17394
17975
|
const [realRunDir, realSourcePath] = await Promise.all([realpath2(runDir), realpath2(sourcePath)]);
|
|
17395
17976
|
if (!pathInside(realRunDir, realSourcePath)) {
|
|
17396
17977
|
fail("observe source_evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: sourcePath });
|
|
@@ -17406,7 +17987,7 @@ async function writeExecutionManifest(manifestPath, manifest, incrementRevision
|
|
|
17406
17987
|
if (incrementRevision) manifest.revision = (manifest.revision ?? 0) + 1;
|
|
17407
17988
|
else manifest.revision ??= 0;
|
|
17408
17989
|
await writeAtomicJson(manifestPath, manifest);
|
|
17409
|
-
await writeAtomicJson(`${
|
|
17990
|
+
await writeAtomicJson(`${path11.resolve(manifestPath)}.state.json`, {
|
|
17410
17991
|
revision: manifest.revision,
|
|
17411
17992
|
hash: executionManifestHash(manifest),
|
|
17412
17993
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -17418,15 +17999,15 @@ function currentManifestStep(manifest) {
|
|
|
17418
17999
|
async function startTestSuiteRun(options) {
|
|
17419
18000
|
const scenarioDir = scenarioPath(options.suiteRoot ?? DEFAULT_SUITE_ROOT, options.scenario);
|
|
17420
18001
|
const scenario = await validateScenario(scenarioDir);
|
|
17421
|
-
const rows2 = await readCases(
|
|
18002
|
+
const rows2 = await readCases(path11.join(scenarioDir, "cases.csv"));
|
|
17422
18003
|
const row = rows2.find((item) => item.case_id === options.caseId && item.status !== "deprecated");
|
|
17423
18004
|
if (!row) fail(`${scenarioDir}: active case not found: ${options.caseId}`, { rule_id: "test_suite.run.case_not_found" });
|
|
17424
|
-
const allSteps = await readCaseSteps(
|
|
17425
|
-
const grouped = validateCaseSteps(
|
|
18005
|
+
const allSteps = await readCaseSteps(path11.join(scenarioDir, "case_steps.csv"));
|
|
18006
|
+
const grouped = validateCaseSteps(path11.join(scenarioDir, "case_steps.csv"), rows2, allSteps);
|
|
17426
18007
|
const selectedSteps = grouped.get(options.caseId) ?? [];
|
|
17427
18008
|
const reportDir = await nextReportDir(options.reportRoot ?? DEFAULT_REPORT_ROOT, true);
|
|
17428
|
-
const runId =
|
|
17429
|
-
const manifestPath =
|
|
18009
|
+
const runId = path11.basename(reportDir);
|
|
18010
|
+
const manifestPath = path11.join(reportDir, "execution-manifest.json");
|
|
17430
18011
|
const manifest = {
|
|
17431
18012
|
version: 1,
|
|
17432
18013
|
run_id: runId,
|
|
@@ -17438,7 +18019,7 @@ async function startTestSuiteRun(options) {
|
|
|
17438
18019
|
revision: 0,
|
|
17439
18020
|
...options.skillSource ? { skill_source: options.skillSource } : {},
|
|
17440
18021
|
...options.skillVersion ? { skill_version: options.skillVersion } : {},
|
|
17441
|
-
source_suite:
|
|
18022
|
+
source_suite: path11.resolve(scenarioDir),
|
|
17442
18023
|
suite_hash: await suiteHash(scenarioDir),
|
|
17443
18024
|
rerun_policy: "full_rerun",
|
|
17444
18025
|
started_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17448,7 +18029,7 @@ async function startTestSuiteRun(options) {
|
|
|
17448
18029
|
};
|
|
17449
18030
|
await writeExecutionManifest(manifestPath, manifest);
|
|
17450
18031
|
await writeFile9(
|
|
17451
|
-
|
|
18032
|
+
path11.join(reportDir, "ux-findings.json"),
|
|
17452
18033
|
`${JSON.stringify({
|
|
17453
18034
|
version: 1,
|
|
17454
18035
|
run_id: runId,
|
|
@@ -17460,14 +18041,14 @@ async function startTestSuiteRun(options) {
|
|
|
17460
18041
|
`,
|
|
17461
18042
|
"utf8"
|
|
17462
18043
|
);
|
|
17463
|
-
const scenarioReport =
|
|
18044
|
+
const scenarioReport = path11.join(reportDir, `${options.scenario}.md`);
|
|
17464
18045
|
const plannedSteps = selectedSteps.map((step) => `${options.caseId}/${step.step_id}`).join(", ");
|
|
17465
18046
|
await writeFile9(
|
|
17466
18047
|
scenarioReport,
|
|
17467
18048
|
[
|
|
17468
18049
|
`run_id: ${runId}`,
|
|
17469
18050
|
`scenario_id: ${options.scenario}`,
|
|
17470
|
-
`source_suite: ${
|
|
18051
|
+
`source_suite: ${path11.resolve(scenarioDir)}`,
|
|
17471
18052
|
"result: partial",
|
|
17472
18053
|
"test_design_skill: bpmax-functional-test-design",
|
|
17473
18054
|
"ux_audit_skill: bpmax-ui-ux-audit",
|
|
@@ -17482,7 +18063,7 @@ async function startTestSuiteRun(options) {
|
|
|
17482
18063
|
`planned_steps: ${plannedSteps}`,
|
|
17483
18064
|
"executed_steps: pending",
|
|
17484
18065
|
"execution_manifest: execution-manifest.json",
|
|
17485
|
-
`precondition_check: ${
|
|
18066
|
+
`precondition_check: ${path11.join(reportDir, `precondition-${runId}.json`)}`,
|
|
17486
18067
|
`state_file: ${manifestPath}`,
|
|
17487
18068
|
`report_run: ${reportDir}`,
|
|
17488
18069
|
"browser_tool: Chrome DevTools",
|
|
@@ -17524,7 +18105,7 @@ async function startTestSuiteRun(options) {
|
|
|
17524
18105
|
};
|
|
17525
18106
|
}
|
|
17526
18107
|
async function validateExecutionManifestStep(options) {
|
|
17527
|
-
const manifestPath =
|
|
18108
|
+
const manifestPath = path11.resolve(options.manifest);
|
|
17528
18109
|
const manifest = await readExecutionManifest(manifestPath);
|
|
17529
18110
|
if (manifest.case_id !== options.caseId || manifest.current_step_id !== options.caseStepId) {
|
|
17530
18111
|
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 });
|
|
@@ -17544,11 +18125,11 @@ async function validateExecutionManifestStep(options) {
|
|
|
17544
18125
|
return { manifestPath, manifest, step };
|
|
17545
18126
|
}
|
|
17546
18127
|
async function preflightExecutionEvidenceDirectory(options) {
|
|
17547
|
-
const manifestPath =
|
|
18128
|
+
const manifestPath = path11.resolve(options.manifest);
|
|
17548
18129
|
const manifest = await readExecutionManifest(manifestPath);
|
|
17549
18130
|
await assertExecutionManifestFresh(manifest, manifestPath);
|
|
17550
|
-
const runDir =
|
|
17551
|
-
const evidenceDir =
|
|
18131
|
+
const runDir = path11.dirname(manifestPath);
|
|
18132
|
+
const evidenceDir = path11.resolve(options.evidenceDir);
|
|
17552
18133
|
if (!pathInside(runDir, evidenceDir)) {
|
|
17553
18134
|
fail("formal execution evidence must stay inside the current report run directory", {
|
|
17554
18135
|
rule_id: "test_suite.run.evidence_scope",
|
|
@@ -17572,10 +18153,10 @@ async function preflightExecutionEvidenceDirectory(options) {
|
|
|
17572
18153
|
suggestion: `Remove the symlink and use a real directory under ${runDir}.`
|
|
17573
18154
|
});
|
|
17574
18155
|
}
|
|
17575
|
-
const probe =
|
|
18156
|
+
const probe = path11.join(evidenceDir, `.bpmax-write-probe-${process.pid}-${Date.now()}`);
|
|
17576
18157
|
try {
|
|
17577
18158
|
await writeFile9(probe, "ok", "utf8");
|
|
17578
|
-
await
|
|
18159
|
+
await readFile12(probe, "utf8");
|
|
17579
18160
|
} catch (error) {
|
|
17580
18161
|
fail(`formal execution evidence directory is not writable: ${error instanceof Error ? error.message : String(error)}`, {
|
|
17581
18162
|
rule_id: "test_suite.run.evidence_unwritable",
|
|
@@ -17589,7 +18170,7 @@ async function preflightExecutionEvidenceDirectory(options) {
|
|
|
17589
18170
|
async function appendExecutionManifestEvidence(options) {
|
|
17590
18171
|
await withExecutionManifestLock(options.manifest, async () => {
|
|
17591
18172
|
const validated = await validateExecutionManifestStep(options);
|
|
17592
|
-
const evidencePath =
|
|
18173
|
+
const evidencePath = path11.resolve(options.evidence);
|
|
17593
18174
|
await assertCurrentRunEvidence(validated.manifest, validated.manifestPath, evidencePath);
|
|
17594
18175
|
validated.step.evidence = [.../* @__PURE__ */ new Set([...validated.step.evidence, evidencePath])];
|
|
17595
18176
|
await writeExecutionManifest(validated.manifestPath, validated.manifest, true);
|
|
@@ -17597,7 +18178,7 @@ async function appendExecutionManifestEvidence(options) {
|
|
|
17597
18178
|
}
|
|
17598
18179
|
async function nextTestSuiteRunStep(manifestPath, profile) {
|
|
17599
18180
|
const manifest = await readExecutionManifest(manifestPath);
|
|
17600
|
-
await assertExecutionManifestFresh(manifest,
|
|
18181
|
+
await assertExecutionManifestFresh(manifest, path11.resolve(manifestPath));
|
|
17601
18182
|
if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
|
|
17602
18183
|
const step = currentManifestStep(manifest);
|
|
17603
18184
|
if (!step) return { ok: true, complete: true, result: manifest.result, execution: manifest };
|
|
@@ -17608,7 +18189,7 @@ async function recordTestSuiteRunStep(options) {
|
|
|
17608
18189
|
if (!["pass", "fail", "blocked"].includes(options.result)) fail("run record result must be pass, fail, or blocked", { rule_id: "test_suite.run.result" });
|
|
17609
18190
|
return withExecutionManifestLock(options.manifest, async () => {
|
|
17610
18191
|
const validated = await validateExecutionManifestStep(options);
|
|
17611
|
-
const evidencePath =
|
|
18192
|
+
const evidencePath = path11.resolve(options.evidence);
|
|
17612
18193
|
await assertCurrentRunEvidence(validated.manifest, validated.manifestPath, evidencePath);
|
|
17613
18194
|
if (options.result === "pass") await assertFormalExecutionEvidence(validated.manifest, validated.manifestPath, validated.step, evidencePath);
|
|
17614
18195
|
if (options.result !== "pass" && !["browser", "e2e_create_page"].includes(validated.step.runner)) {
|
|
@@ -17661,7 +18242,7 @@ async function recordTestSuiteRunStep(options) {
|
|
|
17661
18242
|
}
|
|
17662
18243
|
async function testSuiteRunStatus(manifestPath, profile) {
|
|
17663
18244
|
const manifest = await readExecutionManifest(manifestPath);
|
|
17664
|
-
await assertExecutionManifestFresh(manifest,
|
|
18245
|
+
await assertExecutionManifestFresh(manifest, path11.resolve(manifestPath));
|
|
17665
18246
|
if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
|
|
17666
18247
|
return { ok: true, execution: manifest };
|
|
17667
18248
|
}
|
|
@@ -17694,9 +18275,9 @@ function validateLatestProofObject(proofPath, proof) {
|
|
|
17694
18275
|
}
|
|
17695
18276
|
function scenarioPath(root, scenario) {
|
|
17696
18277
|
if (!SCENARIO_ID_RE.test(scenario)) fail(`invalid scenario id: ${scenario}`);
|
|
17697
|
-
const rootResolved =
|
|
17698
|
-
const candidate =
|
|
17699
|
-
if (!candidate.startsWith(`${rootResolved}${
|
|
18278
|
+
const rootResolved = path11.resolve(root);
|
|
18279
|
+
const candidate = path11.resolve(root, scenario);
|
|
18280
|
+
if (!candidate.startsWith(`${rootResolved}${path11.sep}`) && candidate !== rootResolved) {
|
|
17700
18281
|
fail(`scenario path escapes root: ${candidate}`);
|
|
17701
18282
|
}
|
|
17702
18283
|
return candidate;
|
|
@@ -17704,14 +18285,14 @@ function scenarioPath(root, scenario) {
|
|
|
17704
18285
|
async function fileMap(root) {
|
|
17705
18286
|
const result = /* @__PURE__ */ new Map();
|
|
17706
18287
|
async function walk(dir) {
|
|
17707
|
-
for (const item of await
|
|
17708
|
-
const itemPath =
|
|
17709
|
-
const rel =
|
|
17710
|
-
if (rel.split(
|
|
18288
|
+
for (const item of await readdir4(dir, { withFileTypes: true })) {
|
|
18289
|
+
const itemPath = path11.join(dir, item.name);
|
|
18290
|
+
const rel = path11.relative(root, itemPath);
|
|
18291
|
+
if (rel.split(path11.sep)[0] === COPY_DIFF_DIR) continue;
|
|
17711
18292
|
if (item.isDirectory()) {
|
|
17712
18293
|
await walk(itemPath);
|
|
17713
18294
|
} else if (item.isFile()) {
|
|
17714
|
-
result.set(rel.split(
|
|
18295
|
+
result.set(rel.split(path11.sep).join("/"), itemPath);
|
|
17715
18296
|
}
|
|
17716
18297
|
}
|
|
17717
18298
|
}
|
|
@@ -17719,10 +18300,10 @@ async function fileMap(root) {
|
|
|
17719
18300
|
return result;
|
|
17720
18301
|
}
|
|
17721
18302
|
async function sha256(filePath) {
|
|
17722
|
-
return createHash5("sha256").update(await
|
|
18303
|
+
return createHash5("sha256").update(await readFile12(filePath)).digest("hex");
|
|
17723
18304
|
}
|
|
17724
18305
|
async function readForDiff(filePath) {
|
|
17725
|
-
const buffer = await
|
|
18306
|
+
const buffer = await readFile12(filePath);
|
|
17726
18307
|
if (buffer.includes(0)) return [`<binary sha256=${createHash5("sha256").update(buffer).digest("hex")}>
|
|
17727
18308
|
`];
|
|
17728
18309
|
return buffer.toString("utf8").split(/(?<=\n)/);
|
|
@@ -17782,7 +18363,7 @@ async function buildCopyDiff(src, dst, operation) {
|
|
|
17782
18363
|
return {
|
|
17783
18364
|
manifest: {
|
|
17784
18365
|
operation,
|
|
17785
|
-
scenario_id:
|
|
18366
|
+
scenario_id: path11.basename(src),
|
|
17786
18367
|
source: src,
|
|
17787
18368
|
destination: dst,
|
|
17788
18369
|
generated_at: (/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "+00:00"),
|
|
@@ -17795,12 +18376,12 @@ async function buildCopyDiff(src, dst, operation) {
|
|
|
17795
18376
|
};
|
|
17796
18377
|
}
|
|
17797
18378
|
async function writeCopyDiffArtifacts(dst, artifacts) {
|
|
17798
|
-
const diffDir =
|
|
18379
|
+
const diffDir = path11.join(dst, COPY_DIFF_DIR);
|
|
17799
18380
|
await mkdir9(diffDir, { recursive: true });
|
|
17800
|
-
await writeFile9(
|
|
17801
|
-
await writeFile9(
|
|
18381
|
+
await writeFile9(path11.join(diffDir, "last.diff"), artifacts.diff, "utf8");
|
|
18382
|
+
await writeFile9(path11.join(diffDir, "last.json"), `${JSON.stringify(artifacts.manifest, null, 2)}
|
|
17802
18383
|
`, "utf8");
|
|
17803
|
-
return
|
|
18384
|
+
return path11.join(diffDir, "last.diff");
|
|
17804
18385
|
}
|
|
17805
18386
|
function summarizeCopyDiff(artifacts) {
|
|
17806
18387
|
const files = Array.isArray(artifacts.manifest.files) ? artifacts.manifest.files : [];
|
|
@@ -17826,12 +18407,12 @@ async function copyScenarioTree(src, dst, replace, operation) {
|
|
|
17826
18407
|
artifacts = await buildCopyDiff(src, dst, operation);
|
|
17827
18408
|
await rm4(dst, { recursive: true, force: true });
|
|
17828
18409
|
}
|
|
17829
|
-
await mkdir9(
|
|
18410
|
+
await mkdir9(path11.dirname(dst), { recursive: true });
|
|
17830
18411
|
await cp3(src, dst, { recursive: true });
|
|
17831
18412
|
return artifacts ? { path: await writeCopyDiffArtifacts(dst, artifacts), summary: summarizeCopyDiff(artifacts) } : {};
|
|
17832
18413
|
}
|
|
17833
18414
|
async function copyDiffPreview(src, dst, operation) {
|
|
17834
|
-
const previewDir =
|
|
18415
|
+
const previewDir = path11.join(DEFAULT_TMP_ROOT, `${operation}-${path11.basename(src)}-copy-diff`);
|
|
17835
18416
|
await rm4(previewDir, { recursive: true, force: true });
|
|
17836
18417
|
await mkdir9(previewDir, { recursive: true });
|
|
17837
18418
|
const artifacts = await buildCopyDiff(src, dst, operation);
|
|
@@ -17853,7 +18434,7 @@ async function draftUpdate(options) {
|
|
|
17853
18434
|
return { destination: dst, copy_diff: copyDiff.path, copy_diff_summary: copyDiff.summary };
|
|
17854
18435
|
}
|
|
17855
18436
|
async function validateReviewGate(scenarioDir) {
|
|
17856
|
-
const reviewPath =
|
|
18437
|
+
const reviewPath = path11.join(scenarioDir, "review.json");
|
|
17857
18438
|
if (!await exists3(reviewPath)) reviewFail(reviewPath, `${scenarioDir}: missing review.json; run multi-subagent SKILL review before promote`);
|
|
17858
18439
|
let review;
|
|
17859
18440
|
try {
|
|
@@ -17861,7 +18442,7 @@ async function validateReviewGate(scenarioDir) {
|
|
|
17861
18442
|
} catch (error) {
|
|
17862
18443
|
reviewFail(reviewPath, `${reviewPath}: invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
17863
18444
|
}
|
|
17864
|
-
if (review.scenario_id !==
|
|
18445
|
+
if (review.scenario_id !== path11.basename(scenarioDir)) reviewFail(reviewPath, `${reviewPath}: scenario_id must match directory name`);
|
|
17865
18446
|
if (!review.latest_proof || typeof review.latest_proof !== "object" || Array.isArray(review.latest_proof)) reviewFail(reviewPath, `${reviewPath}: latest_proof is required`);
|
|
17866
18447
|
validateLatestProofObject(reviewPath, review.latest_proof);
|
|
17867
18448
|
if (!REVIEW_STATUSES.has(String(review.status))) reviewFail(reviewPath, `${reviewPath}: status must be one of ${JSON.stringify([...REVIEW_STATUSES].sort())}`);
|
|
@@ -17886,8 +18467,8 @@ async function validateReviewGate(scenarioDir) {
|
|
|
17886
18467
|
if (!Array.isArray(review.fixes) || review.fixes.length === 0) reviewFail(reviewPath, `${reviewPath}: fixes must be a non-empty list`);
|
|
17887
18468
|
}
|
|
17888
18469
|
async function validateExecutionOperabilityReview(reviewPath, scenarioDir, item) {
|
|
17889
|
-
const rows2 = await readCases(
|
|
17890
|
-
const steps = await readCaseSteps(
|
|
18470
|
+
const rows2 = await readCases(path11.join(scenarioDir, "cases.csv"));
|
|
18471
|
+
const steps = await readCaseSteps(path11.join(scenarioDir, "case_steps.csv"));
|
|
17891
18472
|
const activeCases = new Set(rows2.filter((row) => row.status !== "deprecated").map((row) => row.case_id));
|
|
17892
18473
|
const required = steps.filter((step) => activeCases.has(step.case_id)).map((step) => `${step.case_id}/${step.step_id}`);
|
|
17893
18474
|
const judgments = item.step_judgments;
|
|
@@ -18011,10 +18592,10 @@ async function initOrRepairReview(options) {
|
|
|
18011
18592
|
const scenarioDir = scenarioPath(options.draftRoot ?? DEFAULT_DRAFT_ROOT, options.scenario);
|
|
18012
18593
|
if (!await exists3(scenarioDir)) fail(`draft scenario not found: ${scenarioDir}`);
|
|
18013
18594
|
await validateReadme(scenarioDir);
|
|
18014
|
-
const rows2 = await readCases(
|
|
18015
|
-
const steps = await readCaseSteps(
|
|
18595
|
+
const rows2 = await readCases(path11.join(scenarioDir, "cases.csv"));
|
|
18596
|
+
const steps = await readCaseSteps(path11.join(scenarioDir, "case_steps.csv"));
|
|
18016
18597
|
const proof = await readLatestProof(options.latestProof);
|
|
18017
|
-
const reviewPath =
|
|
18598
|
+
const reviewPath = path11.join(scenarioDir, "review.json");
|
|
18018
18599
|
let existing;
|
|
18019
18600
|
const existed = await exists3(reviewPath);
|
|
18020
18601
|
if (existed) {
|
|
@@ -18025,7 +18606,7 @@ async function initOrRepairReview(options) {
|
|
|
18025
18606
|
existing = {};
|
|
18026
18607
|
}
|
|
18027
18608
|
}
|
|
18028
|
-
const review = mergeReviewDraft(
|
|
18609
|
+
const review = mergeReviewDraft(path11.basename(scenarioDir), proof, rows2, steps, existing);
|
|
18029
18610
|
await writeFile9(reviewPath, `${JSON.stringify(review, null, 2)}
|
|
18030
18611
|
`, "utf8");
|
|
18031
18612
|
return {
|
|
@@ -18060,16 +18641,16 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
|
|
|
18060
18641
|
String(today.getDate()).padStart(2, "0")
|
|
18061
18642
|
].join("");
|
|
18062
18643
|
const dirs = await scenarioDirs(root);
|
|
18063
|
-
const nums = dirs.map((dir) =>
|
|
18064
|
-
const reportDir =
|
|
18644
|
+
const nums = dirs.map((dir) => path11.basename(dir)).filter((name) => name.startsWith(prefix)).map((name) => RUN_RE.exec(name)?.[1]).filter((value) => Boolean(value)).map((value) => Number(value));
|
|
18645
|
+
const reportDir = path11.join(root, `${prefix}-${String(Math.max(0, ...nums) + 1).padStart(3, "0")}`);
|
|
18065
18646
|
if (create) {
|
|
18066
|
-
await mkdir9(
|
|
18647
|
+
await mkdir9(path11.join(reportDir, "screenshots"), { recursive: true });
|
|
18067
18648
|
await writeFile9(
|
|
18068
|
-
|
|
18649
|
+
path11.join(reportDir, "summary.md"),
|
|
18069
18650
|
[
|
|
18070
18651
|
"# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B",
|
|
18071
18652
|
"",
|
|
18072
|
-
`run_id: ${
|
|
18653
|
+
`run_id: ${path11.basename(reportDir)}`,
|
|
18073
18654
|
"rerun_policy: full_rerun",
|
|
18074
18655
|
"status: draft",
|
|
18075
18656
|
"",
|
|
@@ -18077,7 +18658,7 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
|
|
|
18077
18658
|
"",
|
|
18078
18659
|
"## \u622A\u56FE\u76EE\u5F55",
|
|
18079
18660
|
"",
|
|
18080
|
-
`screenshots: ${
|
|
18661
|
+
`screenshots: ${path11.join(path11.basename(reportDir), "screenshots")}`,
|
|
18081
18662
|
"",
|
|
18082
18663
|
"## \u603B\u7ED3",
|
|
18083
18664
|
""
|
|
@@ -18112,7 +18693,7 @@ function crc32(value) {
|
|
|
18112
18693
|
return (crc ^ 4294967295) >>> 0;
|
|
18113
18694
|
}
|
|
18114
18695
|
async function isValidCurrentRunScreenshot(filePath) {
|
|
18115
|
-
const buffer = await
|
|
18696
|
+
const buffer = await readFile12(filePath);
|
|
18116
18697
|
const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
18117
18698
|
if (buffer.length < 33 || !buffer.subarray(0, 8).equals(signature)) return false;
|
|
18118
18699
|
let offset = 8;
|
|
@@ -18370,8 +18951,8 @@ async function reportHasValidBlockedEvidence(text5, reportPath, runDir, manifest
|
|
|
18370
18951
|
if (reportKeyValue(text5, "browser_status:").toLowerCase() !== "blocked") return false;
|
|
18371
18952
|
const evidenceValue = reportKeyValue(text5, "blocker_evidence:");
|
|
18372
18953
|
if (!evidenceValue) return false;
|
|
18373
|
-
const evidencePath =
|
|
18374
|
-
if (!await exists3(evidencePath) || !(await
|
|
18954
|
+
const evidencePath = path11.resolve(path11.dirname(reportPath), evidenceValue);
|
|
18955
|
+
if (!await exists3(evidencePath) || !(await stat7(evidencePath)).isFile() || !await pathInsideReal(runDir, evidencePath)) return false;
|
|
18375
18956
|
await assertCurrentRunArtifact(manifest, evidencePath);
|
|
18376
18957
|
const blockedStep = manifest.steps.find((step) => step.status === "blocked");
|
|
18377
18958
|
return Boolean(
|
|
@@ -18398,7 +18979,7 @@ async function uxManifestArtifacts(text5, reportPath, runDir) {
|
|
|
18398
18979
|
const artifacts = /* @__PURE__ */ new Set();
|
|
18399
18980
|
const manifestValue = reportKeyValue(text5, "execution_manifest:");
|
|
18400
18981
|
if (!manifestValue) return artifacts;
|
|
18401
|
-
const manifestPath =
|
|
18982
|
+
const manifestPath = path11.resolve(path11.dirname(reportPath), manifestValue);
|
|
18402
18983
|
if (!pathInside(runDir, manifestPath) || !await exists3(manifestPath) || !await pathInsideReal(runDir, manifestPath)) {
|
|
18403
18984
|
return artifacts;
|
|
18404
18985
|
}
|
|
@@ -18406,15 +18987,15 @@ async function uxManifestArtifacts(text5, reportPath, runDir) {
|
|
|
18406
18987
|
const manifest = JSON.parse(await readText(manifestPath));
|
|
18407
18988
|
for (const step of manifest.steps ?? []) {
|
|
18408
18989
|
for (const item of step.evidence ?? []) {
|
|
18409
|
-
const evidencePath =
|
|
18990
|
+
const evidencePath = path11.isAbsolute(item) ? path11.resolve(item) : path11.resolve(path11.dirname(manifestPath), item);
|
|
18410
18991
|
if (!pathInside(runDir, evidencePath) || !await exists3(evidencePath) || !await pathInsideReal(runDir, evidencePath)) continue;
|
|
18411
18992
|
artifacts.add(evidencePath);
|
|
18412
18993
|
for (const { value, source } of await evidenceJsonRecords(evidencePath)) {
|
|
18413
|
-
artifacts.add(
|
|
18994
|
+
artifacts.add(path11.resolve(source));
|
|
18414
18995
|
for (const key of ["screenshot", "dom_snapshot", "source_evidence"]) {
|
|
18415
18996
|
const referenced = typeof value[key] === "string" ? value[key].trim() : "";
|
|
18416
18997
|
if (!referenced) continue;
|
|
18417
|
-
const referencedPath =
|
|
18998
|
+
const referencedPath = path11.resolve(path11.dirname(source), referenced);
|
|
18418
18999
|
if (pathInside(runDir, referencedPath) && await exists3(referencedPath) && await pathInsideReal(runDir, referencedPath)) {
|
|
18419
19000
|
artifacts.add(referencedPath);
|
|
18420
19001
|
}
|
|
@@ -18430,12 +19011,12 @@ async function validateUxEvidence(values, options) {
|
|
|
18430
19011
|
const errors = [];
|
|
18431
19012
|
const mtimes = [];
|
|
18432
19013
|
for (const evidenceValue of values) {
|
|
18433
|
-
const evidencePath =
|
|
19014
|
+
const evidencePath = path11.resolve(options.runDir, evidenceValue);
|
|
18434
19015
|
if (!pathInside(options.runDir, evidencePath) || !await exists3(evidencePath) || !await pathInsideReal(options.runDir, evidencePath) || evidencePath === options.findingsPath) {
|
|
18435
19016
|
errors.push(`[test_suite.report.ux_evidence] ${options.prefix}: UX BUG \u8BC1\u636E\u5FC5\u987B\u662F\u672C\u8F6E\u76EE\u5F55\u5185\u5B58\u5728\u7684\u72EC\u7ACB\u6587\u4EF6: ${evidenceValue}`);
|
|
18436
19017
|
continue;
|
|
18437
19018
|
}
|
|
18438
|
-
const info = await
|
|
19019
|
+
const info = await stat7(evidencePath);
|
|
18439
19020
|
if (!info.isFile()) {
|
|
18440
19021
|
errors.push(`[test_suite.report.ux_evidence] ${options.prefix}: UX BUG \u8BC1\u636E\u5FC5\u987B\u662F\u666E\u901A\u6587\u4EF6\uFF0C\u4E0D\u80FD\u662F\u76EE\u5F55: ${evidenceValue}`);
|
|
18441
19022
|
continue;
|
|
@@ -18446,7 +19027,7 @@ async function validateUxEvidence(values, options) {
|
|
|
18446
19027
|
if (!isWithinWindow(info.mtime, options.window)) {
|
|
18447
19028
|
errors.push(`[test_suite.report.ux_evidence_current_run] ${options.prefix}: UX BUG \u8BC1\u636E\u5FC5\u987B\u5728\u672C\u8F6E\u6267\u884C\u7A97\u53E3\u5185\u751F\u6210: ${evidenceValue}`);
|
|
18448
19029
|
}
|
|
18449
|
-
const extension =
|
|
19030
|
+
const extension = path11.extname(evidencePath).toLowerCase();
|
|
18450
19031
|
if (extension === ".png") {
|
|
18451
19032
|
if (!await isValidCurrentRunScreenshot(evidencePath)) {
|
|
18452
19033
|
errors.push(`[test_suite.report.ux_evidence_invalid] ${options.prefix}: UX \u622A\u56FE\u8BC1\u636E\u5FC5\u987B\u662F\u53EF\u89E3\u6790\u3001\u5C3A\u5BF8\u81F3\u5C11 100x80 \u7684\u771F\u5B9E PNG: ${evidenceValue}`);
|
|
@@ -18494,7 +19075,7 @@ async function lintUxAudit(text5, reportPath, runDir, runName) {
|
|
|
18494
19075
|
if (!findingsValue) {
|
|
18495
19076
|
errors.push(`[test_suite.report.ux_findings_missing] ${reportPath}: missing \`ux_findings:\``);
|
|
18496
19077
|
} else {
|
|
18497
|
-
const findingsPath =
|
|
19078
|
+
const findingsPath = path11.resolve(path11.dirname(reportPath), findingsValue);
|
|
18498
19079
|
if (!pathInside(runDir, findingsPath)) {
|
|
18499
19080
|
errors.push(`[test_suite.report.ux_findings_scope] ${reportPath}: ux_findings \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
|
|
18500
19081
|
} else if (!await exists3(findingsPath)) {
|
|
@@ -18548,8 +19129,8 @@ async function lintUxAudit(text5, reportPath, runDir, runName) {
|
|
|
18548
19129
|
window
|
|
18549
19130
|
});
|
|
18550
19131
|
errors.push(...retestCheck.errors);
|
|
18551
|
-
const initialPaths = new Set(finding.evidence.map((item) =>
|
|
18552
|
-
if (finding.retest_evidence.some((item) => initialPaths.has(
|
|
19132
|
+
const initialPaths = new Set(finding.evidence.map((item) => path11.resolve(runDir, item)));
|
|
19133
|
+
if (finding.retest_evidence.some((item) => initialPaths.has(path11.resolve(runDir, item)))) {
|
|
18553
19134
|
errors.push(`[test_suite.report.ux_verified_evidence] ${prefix}: retest_evidence \u5FC5\u987B\u4F7F\u7528\u4FEE\u590D\u540E\u7684\u65B0\u8BC1\u636E\uFF0C\u4E0D\u80FD\u590D\u7528\u539F\u59CB evidence`);
|
|
18554
19135
|
}
|
|
18555
19136
|
const latestInitial = Math.max(...evidenceCheck.mtimes.map((item) => item.getTime()));
|
|
@@ -18601,22 +19182,22 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18601
19182
|
if (!await exists3(root)) return { errors: [`report root not found: ${root}`], reports: [] };
|
|
18602
19183
|
const errors = [];
|
|
18603
19184
|
const reports = [];
|
|
18604
|
-
const resolvedRoot =
|
|
18605
|
-
const candidateDirs = RUN_RE.test(
|
|
19185
|
+
const resolvedRoot = path11.resolve(root);
|
|
19186
|
+
const candidateDirs = RUN_RE.test(path11.basename(resolvedRoot)) ? [resolvedRoot] : (await scenarioDirs(resolvedRoot)).filter((dir) => RUN_RE.test(path11.basename(dir)));
|
|
18606
19187
|
if (candidateDirs.length === 0) return { errors: [`report run not found under: ${resolvedRoot}`], reports };
|
|
18607
19188
|
const runDirs = options.allRuns ? candidateDirs : candidateDirs.slice(-1);
|
|
18608
19189
|
for (const runDir of runDirs) {
|
|
18609
|
-
const runName =
|
|
19190
|
+
const runName = path11.basename(runDir);
|
|
18610
19191
|
if (!RUN_RE.test(runName)) {
|
|
18611
19192
|
errors.push(`${runDir}: run directory name must be YYYYMMDD-NNN`);
|
|
18612
19193
|
continue;
|
|
18613
19194
|
}
|
|
18614
|
-
if (!await exists3(
|
|
18615
|
-
const files = await
|
|
19195
|
+
if (!await exists3(path11.join(runDir, "summary.md"))) errors.push(`${runDir}: missing summary.md`);
|
|
19196
|
+
const files = await readdir4(runDir);
|
|
18616
19197
|
const scenarioReports = files.filter((file) => file.endsWith(".md") && file !== "summary.md");
|
|
18617
19198
|
if (scenarioReports.length === 0) errors.push(`${runDir}: missing scenario report markdown`);
|
|
18618
19199
|
for (const reportName of scenarioReports) {
|
|
18619
|
-
const reportPath =
|
|
19200
|
+
const reportPath = path11.join(runDir, reportName);
|
|
18620
19201
|
const text5 = await readText(reportPath);
|
|
18621
19202
|
const uxAudit = await lintUxAudit(text5, reportPath, runDir, runName);
|
|
18622
19203
|
errors.push(...uxAudit.errors);
|
|
@@ -18661,8 +19242,8 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18661
19242
|
}
|
|
18662
19243
|
const manifestValue = reportKeyValue(text5, "execution_manifest:");
|
|
18663
19244
|
if (manifestValue) {
|
|
18664
|
-
const manifestPath =
|
|
18665
|
-
const runRoot =
|
|
19245
|
+
const manifestPath = path11.resolve(path11.dirname(reportPath), manifestValue);
|
|
19246
|
+
const runRoot = path11.resolve(runDir);
|
|
18666
19247
|
if (!pathInside(runRoot, manifestPath)) {
|
|
18667
19248
|
errors.push(`[test_suite.report.execution_manifest_scope] ${reportPath}: execution_manifest \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
|
|
18668
19249
|
} else if (!await exists3(manifestPath)) {
|
|
@@ -18694,7 +19275,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18694
19275
|
if (validTerminalStop && !["browser", "e2e_create_page"].includes(manifest.steps[terminalIndex].runner)) {
|
|
18695
19276
|
const terminalStep = manifest.steps[terminalIndex];
|
|
18696
19277
|
for (const evidencePath of terminalStep.evidence) {
|
|
18697
|
-
const resolvedEvidencePath =
|
|
19278
|
+
const resolvedEvidencePath = path11.isAbsolute(evidencePath) ? path11.resolve(evidencePath) : path11.resolve(path11.dirname(manifestPath), evidencePath);
|
|
18698
19279
|
if (!pathInside(runRoot, resolvedEvidencePath) || !await pathInsideReal(runRoot, resolvedEvidencePath)) {
|
|
18699
19280
|
errors.push(`[test_suite.report.terminal_evidence_scope] ${reportPath}: \u975E\u6D4F\u89C8\u5668 terminal evidence \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185: ${evidencePath}`);
|
|
18700
19281
|
continue;
|
|
@@ -18771,7 +19352,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18771
19352
|
if (/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|诊断/.test(resultValue)) {
|
|
18772
19353
|
errors.push(`[test_suite.report.page_conclusion_browser] ${reportPath}: browser_status: blocked \u65F6\u4E0D\u80FD\u58F0\u660E\u5B8C\u6574\u9875\u9762\u901A\u8FC7\uFF1B\u5FC5\u987B\u964D\u7EA7\u4E3A partial/stage/blocked/diagnostic`);
|
|
18773
19354
|
}
|
|
18774
|
-
const screenshotsDir =
|
|
19355
|
+
const screenshotsDir = path11.join(runDir, "screenshots");
|
|
18775
19356
|
if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
|
|
18776
19357
|
if (isFullRerun) {
|
|
18777
19358
|
for (const key of ["state_file:", "precondition_check:", "report_run:"]) {
|
|
@@ -18796,9 +19377,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18796
19377
|
errors.push(`${reportPath}: screenshot must be a local file under this run's screenshots directory`);
|
|
18797
19378
|
continue;
|
|
18798
19379
|
}
|
|
18799
|
-
const imagePath =
|
|
18800
|
-
const screenshotsResolved =
|
|
18801
|
-
if (!imagePath.startsWith(`${screenshotsResolved}${
|
|
19380
|
+
const imagePath = path11.resolve(path11.dirname(reportPath), imageRef);
|
|
19381
|
+
const screenshotsResolved = path11.resolve(screenshotsDir);
|
|
19382
|
+
if (!imagePath.startsWith(`${screenshotsResolved}${path11.sep}`)) {
|
|
18802
19383
|
errors.push(`${reportPath}: image reference must stay under this run's screenshots directory: ${imageRef}`);
|
|
18803
19384
|
continue;
|
|
18804
19385
|
}
|
|
@@ -18812,7 +19393,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18812
19393
|
}
|
|
18813
19394
|
validCurrentRunImages.push(imageRef);
|
|
18814
19395
|
if (isFullRerun) {
|
|
18815
|
-
const imageStat = await
|
|
19396
|
+
const imageStat = await stat7(imagePath);
|
|
18816
19397
|
if (!isWithinWindow(imageStat.mtime, window)) {
|
|
18817
19398
|
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}`);
|
|
18818
19399
|
}
|
|
@@ -18836,10 +19417,10 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18836
19417
|
return { errors, reports };
|
|
18837
19418
|
}
|
|
18838
19419
|
async function validateCopyDiffArtifacts(scenarioDir) {
|
|
18839
|
-
const diffDir =
|
|
19420
|
+
const diffDir = path11.join(scenarioDir, COPY_DIFF_DIR);
|
|
18840
19421
|
if (!await exists3(diffDir)) return;
|
|
18841
|
-
const manifestPath =
|
|
18842
|
-
const diffPath =
|
|
19422
|
+
const manifestPath = path11.join(diffDir, "last.json");
|
|
19423
|
+
const diffPath = path11.join(diffDir, "last.diff");
|
|
18843
19424
|
if (!await exists3(manifestPath)) fail(`${scenarioDir}: ${COPY_DIFF_DIR}/last.json is required when copy diff artifacts exist`);
|
|
18844
19425
|
if (!await exists3(diffPath)) fail(`${scenarioDir}: ${COPY_DIFF_DIR}/last.diff is required when copy diff artifacts exist`);
|
|
18845
19426
|
let manifest;
|
|
@@ -18851,7 +19432,7 @@ async function validateCopyDiffArtifacts(scenarioDir) {
|
|
|
18851
19432
|
for (const key of ["operation", "scenario_id", "source", "destination", "generated_at", "summary", "diff_file", "files"]) {
|
|
18852
19433
|
if (!(key in manifest)) fail(`${manifestPath}: missing \`${key}\``);
|
|
18853
19434
|
}
|
|
18854
|
-
if (manifest.scenario_id !==
|
|
19435
|
+
if (manifest.scenario_id !== path11.basename(scenarioDir)) fail(`${manifestPath}: scenario_id must match directory name`);
|
|
18855
19436
|
if (manifest.diff_file !== "last.diff") fail(`${manifestPath}: diff_file must be last.diff`);
|
|
18856
19437
|
if (!(await readText(diffPath)).trim()) fail(`${diffPath}: copy diff must not be empty`);
|
|
18857
19438
|
}
|
|
@@ -18875,7 +19456,7 @@ var OPTION_NAMES = ["options", "items", "choices", "values"];
|
|
|
18875
19456
|
var REQUIRED_NAMES = ["required", "is_required", "isRequired", "require", "must", "validateRequired"];
|
|
18876
19457
|
var HIDDEN_NAMES = ["hidden", "is_hidden", "isHidden", "hide", "hideInForm"];
|
|
18877
19458
|
var VISIBLE_NAMES = ["visible", "display", "show"];
|
|
18878
|
-
function
|
|
19459
|
+
function isRecord7(value) {
|
|
18879
19460
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18880
19461
|
}
|
|
18881
19462
|
function pickString(source, keys) {
|
|
@@ -18902,10 +19483,10 @@ function pickBoolean(source, keys) {
|
|
|
18902
19483
|
}
|
|
18903
19484
|
const rules = source.rules;
|
|
18904
19485
|
if (Array.isArray(rules)) {
|
|
18905
|
-
return rules.some((rule) =>
|
|
19486
|
+
return rules.some((rule) => isRecord7(rule) && pickBoolean(rule, REQUIRED_NAMES));
|
|
18906
19487
|
}
|
|
18907
19488
|
const validateMap = source.validateMap;
|
|
18908
|
-
if (
|
|
19489
|
+
if (isRecord7(validateMap) && pickBoolean(validateMap, REQUIRED_NAMES)) {
|
|
18909
19490
|
return true;
|
|
18910
19491
|
}
|
|
18911
19492
|
return false;
|
|
@@ -18929,7 +19510,7 @@ function optionValue(option) {
|
|
|
18929
19510
|
if (typeof option === "string" || typeof option === "number") {
|
|
18930
19511
|
return String(option);
|
|
18931
19512
|
}
|
|
18932
|
-
if (!
|
|
19513
|
+
if (!isRecord7(option)) {
|
|
18933
19514
|
return null;
|
|
18934
19515
|
}
|
|
18935
19516
|
return pickString(option, ["value", "key", "id", "name", "label", "title"]) ?? null;
|
|
@@ -18947,7 +19528,7 @@ function pickOptions(source) {
|
|
|
18947
19528
|
}
|
|
18948
19529
|
for (const containerKey of ["props", "config", "setting", "value"]) {
|
|
18949
19530
|
const container = source[containerKey];
|
|
18950
|
-
if (
|
|
19531
|
+
if (isRecord7(container)) {
|
|
18951
19532
|
const nested = pickOptions(container);
|
|
18952
19533
|
if (nested?.length) {
|
|
18953
19534
|
return nested;
|
|
@@ -19003,7 +19584,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
19003
19584
|
}
|
|
19004
19585
|
return;
|
|
19005
19586
|
}
|
|
19006
|
-
if (!
|
|
19587
|
+
if (!isRecord7(value)) {
|
|
19007
19588
|
return;
|
|
19008
19589
|
}
|
|
19009
19590
|
const field = fieldFromRecord(value);
|
|
@@ -19011,7 +19592,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
19011
19592
|
if (isSubFormField(field)) {
|
|
19012
19593
|
const childFields = /* @__PURE__ */ new Map();
|
|
19013
19594
|
for (const child of Object.values(value)) {
|
|
19014
|
-
if (
|
|
19595
|
+
if (isRecord7(child) || Array.isArray(child)) {
|
|
19015
19596
|
collectFieldCandidates(child, childFields, depth + 1);
|
|
19016
19597
|
}
|
|
19017
19598
|
}
|
|
@@ -19025,7 +19606,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
19025
19606
|
fields.set(field.key, mergeField(fields.get(field.key), field));
|
|
19026
19607
|
}
|
|
19027
19608
|
for (const child of Object.values(value)) {
|
|
19028
|
-
if (
|
|
19609
|
+
if (isRecord7(child) || Array.isArray(child)) {
|
|
19029
19610
|
collectFieldCandidates(child, fields, depth + 1);
|
|
19030
19611
|
}
|
|
19031
19612
|
}
|
|
@@ -19043,7 +19624,7 @@ function validateComplexSelector(field, value) {
|
|
|
19043
19624
|
if (!isComplexSelectorType(type)) {
|
|
19044
19625
|
return null;
|
|
19045
19626
|
}
|
|
19046
|
-
const validObject = (item) =>
|
|
19627
|
+
const validObject = (item) => isRecord7(item);
|
|
19047
19628
|
const hint = complexSelectorHint(field);
|
|
19048
19629
|
if (Array.isArray(value)) {
|
|
19049
19630
|
return value.every(validObject) ? null : `${field.key} must contain selector option object(s), not scalar values. ${hint}`;
|
|
@@ -19060,7 +19641,7 @@ function isEnumSelectType(type) {
|
|
|
19060
19641
|
return /enum_select/.test(type);
|
|
19061
19642
|
}
|
|
19062
19643
|
function optionComparableValue(value) {
|
|
19063
|
-
if (
|
|
19644
|
+
if (isRecord7(value) && ("value" in value || "label" in value)) {
|
|
19064
19645
|
return value.value ?? value.label;
|
|
19065
19646
|
}
|
|
19066
19647
|
return value;
|
|
@@ -19074,7 +19655,7 @@ function validateType(field, value) {
|
|
|
19074
19655
|
if (!Array.isArray(value)) {
|
|
19075
19656
|
return `${field.key} must be a JSON array of row objects`;
|
|
19076
19657
|
}
|
|
19077
|
-
const invalidRowIndex = value.findIndex((row) => !
|
|
19658
|
+
const invalidRowIndex = value.findIndex((row) => !isRecord7(row));
|
|
19078
19659
|
return invalidRowIndex >= 0 ? `${field.key}[${invalidRowIndex}] must be a row object` : null;
|
|
19079
19660
|
}
|
|
19080
19661
|
const selectorError = validateComplexSelector(field, value);
|
|
@@ -19100,7 +19681,7 @@ function validateType(field, value) {
|
|
|
19100
19681
|
if (/(array|multi|multiple)/.test(type) && !Array.isArray(value)) {
|
|
19101
19682
|
return `${field.key} must be an array`;
|
|
19102
19683
|
}
|
|
19103
|
-
if (isEnumSelectType(type) &&
|
|
19684
|
+
if (isEnumSelectType(type) && isRecord7(value)) {
|
|
19104
19685
|
const optionValue2 = value.value ?? value.label;
|
|
19105
19686
|
return typeof optionValue2 === "string" || typeof optionValue2 === "number" ? null : `${field.key} must be an enum option object with a scalar value`;
|
|
19106
19687
|
}
|
|
@@ -19130,7 +19711,7 @@ function validateFormEntries(form, fields, prefix = "") {
|
|
|
19130
19711
|
}
|
|
19131
19712
|
if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
|
|
19132
19713
|
for (const [index, row] of value.entries()) {
|
|
19133
|
-
if (
|
|
19714
|
+
if (isRecord7(row)) {
|
|
19134
19715
|
errors.push(...validateFormEntries(row, field.children, `${prefix}${field.key}[${index}].`));
|
|
19135
19716
|
}
|
|
19136
19717
|
}
|
|
@@ -19208,7 +19789,7 @@ function explainFormValidationSchema(fields) {
|
|
|
19208
19789
|
}
|
|
19209
19790
|
|
|
19210
19791
|
// src/commands/step.ts
|
|
19211
|
-
function
|
|
19792
|
+
function isRecord8(value) {
|
|
19212
19793
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19213
19794
|
}
|
|
19214
19795
|
function stringValue2(value) {
|
|
@@ -19235,7 +19816,7 @@ function hasMeaningfulValue(value) {
|
|
|
19235
19816
|
if (Array.isArray(value)) {
|
|
19236
19817
|
return value.some(hasMeaningfulValue);
|
|
19237
19818
|
}
|
|
19238
|
-
if (
|
|
19819
|
+
if (isRecord8(value)) {
|
|
19239
19820
|
return Object.values(value).some(hasMeaningfulValue);
|
|
19240
19821
|
}
|
|
19241
19822
|
return false;
|
|
@@ -19244,7 +19825,7 @@ function isEmptyValue(value) {
|
|
|
19244
19825
|
return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
19245
19826
|
}
|
|
19246
19827
|
function projectIdOfStep(step) {
|
|
19247
|
-
const nestedProjectId =
|
|
19828
|
+
const nestedProjectId = isRecord8(step.project) ? step.project.id : void 0;
|
|
19248
19829
|
return idValue(step.project_id ?? step.projectId ?? nestedProjectId);
|
|
19249
19830
|
}
|
|
19250
19831
|
function stepFlowNodeId(step) {
|
|
@@ -19272,12 +19853,12 @@ function collectRecords(value, output = [], seen = /* @__PURE__ */ new Set()) {
|
|
|
19272
19853
|
value.forEach((item) => collectRecords(item, output, seen));
|
|
19273
19854
|
return output;
|
|
19274
19855
|
}
|
|
19275
|
-
if (!
|
|
19856
|
+
if (!isRecord8(value)) {
|
|
19276
19857
|
return output;
|
|
19277
19858
|
}
|
|
19278
19859
|
output.push(value);
|
|
19279
19860
|
for (const child of Object.values(value)) {
|
|
19280
|
-
if (Array.isArray(child) ||
|
|
19861
|
+
if (Array.isArray(child) || isRecord8(child)) {
|
|
19281
19862
|
collectRecords(child, output, seen);
|
|
19282
19863
|
}
|
|
19283
19864
|
}
|
|
@@ -19361,7 +19942,7 @@ function formListOfStep(step) {
|
|
|
19361
19942
|
return values.filter(hasMeaningfulValue);
|
|
19362
19943
|
}
|
|
19363
19944
|
function unwrapFormValue(value) {
|
|
19364
|
-
if (!
|
|
19945
|
+
if (!isRecord8(value)) {
|
|
19365
19946
|
return value;
|
|
19366
19947
|
}
|
|
19367
19948
|
if ("value" in value && Object.keys(value).length <= 3) {
|
|
@@ -19378,7 +19959,7 @@ function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set())
|
|
|
19378
19959
|
value.forEach((item) => collectFormValues(item, output, seen));
|
|
19379
19960
|
return output;
|
|
19380
19961
|
}
|
|
19381
|
-
if (!
|
|
19962
|
+
if (!isRecord8(value)) {
|
|
19382
19963
|
return output;
|
|
19383
19964
|
}
|
|
19384
19965
|
const key = stringValue2(value.key ?? value.field_key ?? value.fieldKey ?? value.name);
|
|
@@ -19389,7 +19970,7 @@ function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set())
|
|
|
19389
19970
|
}
|
|
19390
19971
|
}
|
|
19391
19972
|
for (const child of Object.values(value)) {
|
|
19392
|
-
if (Array.isArray(child) ||
|
|
19973
|
+
if (Array.isArray(child) || isRecord8(child)) {
|
|
19393
19974
|
collectFormValues(child, output, seen);
|
|
19394
19975
|
}
|
|
19395
19976
|
}
|
|
@@ -19436,7 +20017,7 @@ function collectMissingRequiredInputs(fields, values) {
|
|
|
19436
20017
|
continue;
|
|
19437
20018
|
}
|
|
19438
20019
|
value.forEach((row, index) => {
|
|
19439
|
-
if (!
|
|
20020
|
+
if (!isRecord8(row)) {
|
|
19440
20021
|
return;
|
|
19441
20022
|
}
|
|
19442
20023
|
for (const child of field.children ?? []) {
|
|
@@ -19491,7 +20072,7 @@ function ownerIdsFromStep(step) {
|
|
|
19491
20072
|
];
|
|
19492
20073
|
const ids = /* @__PURE__ */ new Set();
|
|
19493
20074
|
for (const owner of owners) {
|
|
19494
|
-
if (
|
|
20075
|
+
if (isRecord8(owner)) {
|
|
19495
20076
|
const id = idValue(owner.owner_id ?? owner.user_id ?? owner.id);
|
|
19496
20077
|
if (id) {
|
|
19497
20078
|
ids.add(id);
|
|
@@ -19525,7 +20106,7 @@ function ownerDiagnosticsFromStep(step, currentUser) {
|
|
|
19525
20106
|
const values = Array.isArray(value) ? value : [value];
|
|
19526
20107
|
for (const item of values) {
|
|
19527
20108
|
let id;
|
|
19528
|
-
if (
|
|
20109
|
+
if (isRecord8(item)) {
|
|
19529
20110
|
id = idValue(item.owner_id ?? item.user_id ?? item.id);
|
|
19530
20111
|
} else {
|
|
19531
20112
|
id = idValue(item);
|
|
@@ -19637,12 +20218,12 @@ function extractSubmitInputValues(data) {
|
|
|
19637
20218
|
const candidates = [data.form, data.form_data, data.formData, data.fields, data.values];
|
|
19638
20219
|
const values = {};
|
|
19639
20220
|
for (const candidate of candidates) {
|
|
19640
|
-
if (
|
|
20221
|
+
if (isRecord8(candidate)) {
|
|
19641
20222
|
Object.assign(values, candidate);
|
|
19642
20223
|
}
|
|
19643
20224
|
}
|
|
19644
20225
|
for (const [key, value] of Object.entries(data)) {
|
|
19645
|
-
if (!SUBMIT_NON_FORM_KEYS.has(key) && !
|
|
20226
|
+
if (!SUBMIT_NON_FORM_KEYS.has(key) && !isRecord8(value) && !Array.isArray(value)) {
|
|
19646
20227
|
values[key] = value;
|
|
19647
20228
|
}
|
|
19648
20229
|
}
|
|
@@ -19804,7 +20385,7 @@ async function appendE2eExecutionEvidence(options, evidence, runners) {
|
|
|
19804
20385
|
runners
|
|
19805
20386
|
});
|
|
19806
20387
|
}
|
|
19807
|
-
function
|
|
20388
|
+
function isRecord9(value) {
|
|
19808
20389
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19809
20390
|
}
|
|
19810
20391
|
function stringValue3(value) {
|
|
@@ -19825,18 +20406,18 @@ function timestampSlug() {
|
|
|
19825
20406
|
return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
19826
20407
|
}
|
|
19827
20408
|
async function ensureDir(dir) {
|
|
19828
|
-
const resolved =
|
|
20409
|
+
const resolved = path12.resolve(dir);
|
|
19829
20410
|
await mkdir10(resolved, { recursive: true });
|
|
19830
20411
|
return resolved;
|
|
19831
20412
|
}
|
|
19832
20413
|
async function writeEvidence(dir, name, value) {
|
|
19833
|
-
const file =
|
|
20414
|
+
const file = path12.join(await ensureDir(dir), name);
|
|
19834
20415
|
await writeFile10(file, `${JSON.stringify(redactAuditValue(value), null, 2)}
|
|
19835
20416
|
`, "utf8");
|
|
19836
20417
|
return file;
|
|
19837
20418
|
}
|
|
19838
20419
|
function summarizeRemoteResult(value) {
|
|
19839
|
-
if (!
|
|
20420
|
+
if (!isRecord9(value)) return value;
|
|
19840
20421
|
const summary = {};
|
|
19841
20422
|
for (const key of ["id", "project_id", "step_id", "status", "state", "code", "msg", "message", "next", "action"]) {
|
|
19842
20423
|
if (value[key] !== void 0) summary[key] = value[key];
|
|
@@ -19844,29 +20425,29 @@ function summarizeRemoteResult(value) {
|
|
|
19844
20425
|
return Object.keys(summary).length > 0 ? redactAuditValue(summary) : { received: true };
|
|
19845
20426
|
}
|
|
19846
20427
|
function stepReadbackConfirmed(before, after) {
|
|
19847
|
-
const beforeStatus =
|
|
19848
|
-
const afterStatus =
|
|
19849
|
-
const beforeProjectStep =
|
|
19850
|
-
const afterProjectStep =
|
|
20428
|
+
const beforeStatus = isRecord9(before.step) ? before.step.status : void 0;
|
|
20429
|
+
const afterStatus = isRecord9(after.step) ? after.step.status : void 0;
|
|
20430
|
+
const beforeProjectStep = isRecord9(before.project) ? before.project.current_flow_step_id : void 0;
|
|
20431
|
+
const afterProjectStep = isRecord9(after.project) ? after.project.current_flow_step_id : void 0;
|
|
19851
20432
|
return after.step_finished === true || beforeStatus !== afterStatus || beforeProjectStep !== afterProjectStep;
|
|
19852
20433
|
}
|
|
19853
20434
|
function evidenceMime(buffer, file) {
|
|
19854
20435
|
if (buffer.length >= 8 && buffer.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) return "image/png";
|
|
19855
20436
|
if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) return "image/jpeg";
|
|
19856
20437
|
if (buffer.length >= 12 && buffer.subarray(0, 4).toString("ascii") === "RIFF" && buffer.subarray(8, 12).toString("ascii") === "WEBP") return "image/webp";
|
|
19857
|
-
if (
|
|
19858
|
-
if ([".txt", ".md", ".log"].includes(
|
|
20438
|
+
if (path12.extname(file).toLowerCase() === ".json") return "application/json";
|
|
20439
|
+
if ([".txt", ".md", ".log"].includes(path12.extname(file).toLowerCase())) return "text/plain";
|
|
19859
20440
|
return "application/octet-stream";
|
|
19860
20441
|
}
|
|
19861
20442
|
async function writeEvidenceManifest(evidenceDir, details) {
|
|
19862
|
-
const files = await
|
|
20443
|
+
const files = await readdir5(evidenceDir, { withFileTypes: true });
|
|
19863
20444
|
const artifacts = [];
|
|
19864
20445
|
for (const entry of files) {
|
|
19865
20446
|
if (!entry.isFile() || entry.name === "evidence-manifest.json") continue;
|
|
19866
|
-
const file =
|
|
19867
|
-
const buffer = await
|
|
20447
|
+
const file = path12.join(evidenceDir, entry.name);
|
|
20448
|
+
const buffer = await readFile13(file);
|
|
19868
20449
|
const mimeType = evidenceMime(buffer, entry.name);
|
|
19869
|
-
const extension =
|
|
20450
|
+
const extension = path12.extname(entry.name).toLowerCase();
|
|
19870
20451
|
const expectedMime = extension === ".png" ? "image/png" : [".jpg", ".jpeg"].includes(extension) ? "image/jpeg" : extension === ".webp" ? "image/webp" : void 0;
|
|
19871
20452
|
artifacts.push({
|
|
19872
20453
|
path: entry.name,
|
|
@@ -19879,19 +20460,19 @@ async function writeEvidenceManifest(evidenceDir, details) {
|
|
|
19879
20460
|
return writeEvidence(evidenceDir, "evidence-manifest.json", {
|
|
19880
20461
|
schema_version: 1,
|
|
19881
20462
|
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
19882
|
-
evidence_dir:
|
|
20463
|
+
evidence_dir: path12.resolve(evidenceDir),
|
|
19883
20464
|
...details,
|
|
19884
20465
|
artifacts
|
|
19885
20466
|
});
|
|
19886
20467
|
}
|
|
19887
20468
|
function cacheRoot() {
|
|
19888
|
-
return
|
|
20469
|
+
return path12.resolve(".codex/cache/bpmax-e2e");
|
|
19889
20470
|
}
|
|
19890
20471
|
function safeSegment(value) {
|
|
19891
20472
|
return value.trim().replace(/[^a-zA-Z0-9._:-]+/g, "_") || "default";
|
|
19892
20473
|
}
|
|
19893
20474
|
function safeIdentity(value) {
|
|
19894
|
-
if (!
|
|
20475
|
+
if (!isRecord9(value)) return null;
|
|
19895
20476
|
return {
|
|
19896
20477
|
id: value.id,
|
|
19897
20478
|
name: value.name,
|
|
@@ -19932,14 +20513,14 @@ async function browserSessionRequest(profile, cookie, method, apiPath2, data, hr
|
|
|
19932
20513
|
response.status
|
|
19933
20514
|
);
|
|
19934
20515
|
}
|
|
19935
|
-
if (
|
|
20516
|
+
if (isRecord9(body) && typeof body.code === "number" && body.code !== 0) {
|
|
19936
20517
|
throw new BrowserSessionRejectedError(
|
|
19937
20518
|
`e2e.identity.api_error: ${String(body.msg ?? body.message ?? body.code)}`,
|
|
19938
20519
|
response.status,
|
|
19939
20520
|
body.code
|
|
19940
20521
|
);
|
|
19941
20522
|
}
|
|
19942
|
-
return
|
|
20523
|
+
return isRecord9(body) && Object.prototype.hasOwnProperty.call(body, "data") ? body.data : body;
|
|
19943
20524
|
}
|
|
19944
20525
|
function identityCookie(cookieEnv) {
|
|
19945
20526
|
const cookie = process.env[cookieEnv]?.trim();
|
|
@@ -19972,7 +20553,7 @@ function valuesEqual(left, right) {
|
|
|
19972
20553
|
}
|
|
19973
20554
|
function pathValue(source, dottedPath) {
|
|
19974
20555
|
return dottedPath.split(".").reduce((current, segment) => {
|
|
19975
|
-
if (!
|
|
20556
|
+
if (!isRecord9(current)) {
|
|
19976
20557
|
return void 0;
|
|
19977
20558
|
}
|
|
19978
20559
|
return current[segment];
|
|
@@ -19982,7 +20563,7 @@ function normalizeExpectedChecks(value) {
|
|
|
19982
20563
|
if (!Array.isArray(value)) {
|
|
19983
20564
|
return [];
|
|
19984
20565
|
}
|
|
19985
|
-
return value.filter(
|
|
20566
|
+
return value.filter(isRecord9).map((item) => ({
|
|
19986
20567
|
...stringValue3(item.name) ? { name: stringValue3(item.name) } : {},
|
|
19987
20568
|
path: stringValue3(item.path) ?? "",
|
|
19988
20569
|
op: stringValue3(item.op) ?? "equals",
|
|
@@ -20055,13 +20636,13 @@ function buildExpectedChecks(options) {
|
|
|
20055
20636
|
];
|
|
20056
20637
|
}
|
|
20057
20638
|
function flowCachePath(profileName, flowId) {
|
|
20058
|
-
return
|
|
20639
|
+
return path12.join(cacheRoot(), "profiles", safeSegment(profileName), "flows", `${safeSegment(flowId)}.json`);
|
|
20059
20640
|
}
|
|
20060
20641
|
async function readOptionalJson(file) {
|
|
20061
20642
|
try {
|
|
20062
|
-
const raw = await
|
|
20643
|
+
const raw = await readFile13(file, "utf8");
|
|
20063
20644
|
const parsed = JSON.parse(raw);
|
|
20064
|
-
return
|
|
20645
|
+
return isRecord9(parsed) ? parsed : null;
|
|
20065
20646
|
} catch (error) {
|
|
20066
20647
|
if (error.code === "ENOENT") {
|
|
20067
20648
|
return null;
|
|
@@ -20088,11 +20669,11 @@ function stepsFromProfile(profile) {
|
|
|
20088
20669
|
}
|
|
20089
20670
|
const steps = profile.steps;
|
|
20090
20671
|
if (Array.isArray(steps)) {
|
|
20091
|
-
return steps.filter(
|
|
20672
|
+
return steps.filter(isRecord9);
|
|
20092
20673
|
}
|
|
20093
|
-
if (
|
|
20674
|
+
if (isRecord9(steps)) {
|
|
20094
20675
|
return Object.entries(steps).map(([stepId, value]) => ({
|
|
20095
|
-
...
|
|
20676
|
+
...isRecord9(value) ? value : { data: value },
|
|
20096
20677
|
step_id: stepId
|
|
20097
20678
|
}));
|
|
20098
20679
|
}
|
|
@@ -20104,7 +20685,7 @@ function normalizeStepPlan(input, defaults) {
|
|
|
20104
20685
|
throw new Error("e2e step-run requires --step-id or data-profile steps[].step_id.");
|
|
20105
20686
|
}
|
|
20106
20687
|
const rawData = input.data ?? input.payload_template ?? input.payloadTemplate ?? input.form ?? input.values ?? {};
|
|
20107
|
-
const data =
|
|
20688
|
+
const data = isRecord9(rawData) ? rawData : {};
|
|
20108
20689
|
return {
|
|
20109
20690
|
step_id: stepId,
|
|
20110
20691
|
action: stringValue3(input.action) ?? defaults.action,
|
|
@@ -20144,7 +20725,7 @@ function dataProfilePath(input) {
|
|
|
20144
20725
|
if (!input?.startsWith("@")) {
|
|
20145
20726
|
return void 0;
|
|
20146
20727
|
}
|
|
20147
|
-
return
|
|
20728
|
+
return path12.resolve(input.slice(1));
|
|
20148
20729
|
}
|
|
20149
20730
|
function refreshedStepTemplate(options) {
|
|
20150
20731
|
return {
|
|
@@ -20168,14 +20749,14 @@ function refreshedStepTemplate(options) {
|
|
|
20168
20749
|
variables: Object.keys(options.plan.data).filter((key) => !["project_id", "action", "urgency"].includes(key)),
|
|
20169
20750
|
payload_template: options.plan.data,
|
|
20170
20751
|
source_evidence: {
|
|
20171
|
-
evidence_dir:
|
|
20172
|
-
context:
|
|
20752
|
+
evidence_dir: path12.resolve(options.evidenceDir),
|
|
20753
|
+
context: path12.basename(options.contextFile)
|
|
20173
20754
|
}
|
|
20174
20755
|
};
|
|
20175
20756
|
}
|
|
20176
20757
|
async function writeRefreshedCache(file, template) {
|
|
20177
|
-
const out =
|
|
20178
|
-
await mkdir10(
|
|
20758
|
+
const out = path12.resolve(file);
|
|
20759
|
+
await mkdir10(path12.dirname(out), { recursive: true });
|
|
20179
20760
|
await writeFile10(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
|
|
20180
20761
|
`, "utf8");
|
|
20181
20762
|
return out;
|
|
@@ -20253,13 +20834,13 @@ test(${JSON.stringify(options.title)}, async ({ page }) => {
|
|
|
20253
20834
|
async function writeBrowserTemplate(options) {
|
|
20254
20835
|
const handoffUrl = handoffUrlFromInput(options.handoff);
|
|
20255
20836
|
const assertFields = (options.assertFields ?? "").split(",").map((item) => item.trim()).filter(Boolean);
|
|
20256
|
-
const out =
|
|
20257
|
-
await mkdir10(
|
|
20837
|
+
const out = path12.resolve(options.out);
|
|
20838
|
+
await mkdir10(path12.dirname(out), { recursive: true });
|
|
20258
20839
|
await writeFile10(out, playwrightTemplate({
|
|
20259
20840
|
title: options.title ?? "BPMAX create page handoff submit",
|
|
20260
20841
|
handoffUrl,
|
|
20261
20842
|
assertFields,
|
|
20262
|
-
evidenceDir:
|
|
20843
|
+
evidenceDir: path12.resolve(options.evidenceDir)
|
|
20263
20844
|
}), "utf8");
|
|
20264
20845
|
return { out, handoff_url: handoffUrl, assert_fields: assertFields };
|
|
20265
20846
|
}
|
|
@@ -20268,7 +20849,7 @@ function scenarioRecords(plan) {
|
|
|
20268
20849
|
if (!Array.isArray(records)) {
|
|
20269
20850
|
return [];
|
|
20270
20851
|
}
|
|
20271
|
-
return records.filter(
|
|
20852
|
+
return records.filter(isRecord9);
|
|
20272
20853
|
}
|
|
20273
20854
|
function recordKey(record, index) {
|
|
20274
20855
|
return stringValue3(record.demo_no ?? record.id ?? record.case_id ?? record.subject) ?? `record-${index + 1}`;
|
|
@@ -20630,7 +21211,7 @@ function registerE2eCommands(program2) {
|
|
|
20630
21211
|
mode: "handoff_command_hint",
|
|
20631
21212
|
browser: options.browser,
|
|
20632
21213
|
next_command: `bpmax-cli project create ${flowFlag}${jsonFlag}${profileFlag} --handoff-only --format json > handoff.json`,
|
|
20633
|
-
next_after_handoff: `bpmax-cli e2e create-page-submit --handoff-json @handoff.json --browser ${options.browser} --evidence-dir ${
|
|
21214
|
+
next_after_handoff: `bpmax-cli e2e create-page-submit --handoff-json @handoff.json --browser ${options.browser} --evidence-dir ${path12.resolve(options.evidenceDir)} --format json`,
|
|
20634
21215
|
note: "create-page-submit does not raw-create a project. First generate a handoff URL, then execute the generated browser template and keep screenshots/result JSON as evidence."
|
|
20635
21216
|
});
|
|
20636
21217
|
return;
|
|
@@ -20652,7 +21233,7 @@ function registerE2eCommands(program2) {
|
|
|
20652
21233
|
browser_verified: false,
|
|
20653
21234
|
browser: options.browser,
|
|
20654
21235
|
...generated,
|
|
20655
|
-
evidence_dir:
|
|
21236
|
+
evidence_dir: path12.resolve(options.evidenceDir),
|
|
20656
21237
|
next_command: `npx playwright test ${generated.out}`,
|
|
20657
21238
|
note: "This command does not raw-create a project. Run the generated Playwright script against a logged-in browser context and keep its screenshots/result JSON as browser evidence."
|
|
20658
21239
|
});
|
|
@@ -20662,7 +21243,7 @@ function registerE2eCommands(program2) {
|
|
|
20662
21243
|
const profile = resolveProfile(await loadConfig(), options.profile);
|
|
20663
21244
|
const file = flowCachePath(profile.name, options.flowId);
|
|
20664
21245
|
const cached = await readOptionalJson(file);
|
|
20665
|
-
const fileStat = await
|
|
21246
|
+
const fileStat = await stat8(file).catch(() => null);
|
|
20666
21247
|
printResult(options.format, {
|
|
20667
21248
|
ok: true,
|
|
20668
21249
|
profile: profile.name,
|
|
@@ -20703,7 +21284,7 @@ function registerE2eCommands(program2) {
|
|
|
20703
21284
|
template_id: result.template_id ?? result.templateId
|
|
20704
21285
|
})).digest("hex").slice(0, 16);
|
|
20705
21286
|
const file = flowCachePath(profile.name, options.flowId);
|
|
20706
|
-
await mkdir10(
|
|
21287
|
+
await mkdir10(path12.dirname(file), { recursive: true });
|
|
20707
21288
|
await writeFile10(file, `${JSON.stringify(redactAuditValue({
|
|
20708
21289
|
cache_key: cacheKey,
|
|
20709
21290
|
cached_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -20734,25 +21315,25 @@ function registerE2eCommands(program2) {
|
|
|
20734
21315
|
printResult(options.format, {
|
|
20735
21316
|
ok: true,
|
|
20736
21317
|
...generated,
|
|
20737
|
-
evidence_dir:
|
|
21318
|
+
evidence_dir: path12.resolve(options.evidenceDir),
|
|
20738
21319
|
next_command: `npx playwright test ${generated.out}`
|
|
20739
21320
|
});
|
|
20740
21321
|
});
|
|
20741
21322
|
e2e.command("record-from-evidence").description("Create a reusable E2E template from an evidence directory").option("--project-id <projectId>", "Project id for step evidence").option("--step-id <stepId>", "Step id for step evidence").requiredOption("--evidence-dir <dir>", "Evidence directory").requiredOption("--out <file>", "Template output JSON").option("--name <name>", "Template 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("--format <format>", "Output format", "json").action(async (options) => {
|
|
20742
21323
|
await requireE2eExecutionBinding(options, ["browser", "e2e_create_page", "e2e_step_run", "observe"]);
|
|
20743
|
-
const files = await
|
|
21324
|
+
const files = await readdir5(options.evidenceDir).catch(() => []);
|
|
20744
21325
|
const inferredStepId = options.stepId ?? files.map(inferStepIdFromEvidenceFile).find(Boolean);
|
|
20745
21326
|
const contextFile = inferredStepId ? stepEvidenceFile(files, inferredStepId, "context") : void 0;
|
|
20746
21327
|
const submitFile = inferredStepId ? stepEvidenceFile(files, inferredStepId, "submit") : void 0;
|
|
20747
21328
|
if (inferredStepId && !contextFile && !submitFile) {
|
|
20748
21329
|
throw new Error(`No step evidence files found for step ${inferredStepId} in ${options.evidenceDir}.`);
|
|
20749
21330
|
}
|
|
20750
|
-
const context2 = contextFile ? await readOptionalJson(
|
|
20751
|
-
const submit = submitFile ? await readOptionalJson(
|
|
20752
|
-
const requirements =
|
|
20753
|
-
const requiredInputs = Array.isArray(requirements.required_inputs) ? requirements.required_inputs.filter(
|
|
20754
|
-
const missingInputs = Array.isArray(requirements.missing_required_inputs) ? requirements.missing_required_inputs.filter(
|
|
20755
|
-
const requestData =
|
|
21331
|
+
const context2 = contextFile ? await readOptionalJson(path12.join(options.evidenceDir, contextFile)) : null;
|
|
21332
|
+
const submit = submitFile ? await readOptionalJson(path12.join(options.evidenceDir, submitFile)) : null;
|
|
21333
|
+
const requirements = isRecord9(context2?.requirements) ? context2.requirements : {};
|
|
21334
|
+
const requiredInputs = Array.isArray(requirements.required_inputs) ? requirements.required_inputs.filter(isRecord9) : [];
|
|
21335
|
+
const missingInputs = Array.isArray(requirements.missing_required_inputs) ? requirements.missing_required_inputs.filter(isRecord9) : [];
|
|
21336
|
+
const requestData = isRecord9(submit?.request) && isRecord9(submit.request.data) ? submit.request.data : {};
|
|
20756
21337
|
const recordedAction = stringValue3(requestData.action);
|
|
20757
21338
|
const expectedChecks = buildExpectedChecks({
|
|
20758
21339
|
context: context2,
|
|
@@ -20791,16 +21372,16 @@ function registerE2eCommands(program2) {
|
|
|
20791
21372
|
variables: Object.keys(requestData).filter((key) => !["project_id", "action", "urgency"].includes(key)),
|
|
20792
21373
|
payload_template: requestData,
|
|
20793
21374
|
source_evidence: {
|
|
20794
|
-
evidence_dir:
|
|
21375
|
+
evidence_dir: path12.resolve(options.evidenceDir),
|
|
20795
21376
|
...contextFile ? { context: contextFile } : {},
|
|
20796
21377
|
...submitFile ? { submit: submitFile } : {}
|
|
20797
21378
|
}
|
|
20798
21379
|
} : {
|
|
20799
|
-
name: options.name ??
|
|
21380
|
+
name: options.name ?? path12.basename(path12.resolve(options.evidenceDir)),
|
|
20800
21381
|
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20801
21382
|
submit_mode: "browser_evidence_bootstrap",
|
|
20802
21383
|
source_evidence: {
|
|
20803
|
-
evidence_dir:
|
|
21384
|
+
evidence_dir: path12.resolve(options.evidenceDir),
|
|
20804
21385
|
files: evidenceFiles
|
|
20805
21386
|
},
|
|
20806
21387
|
reuse_requirements: [
|
|
@@ -20813,8 +21394,8 @@ function registerE2eCommands(program2) {
|
|
|
20813
21394
|
template.result = "diagnostic";
|
|
20814
21395
|
template.diagnostic = true;
|
|
20815
21396
|
}
|
|
20816
|
-
const out =
|
|
20817
|
-
await mkdir10(
|
|
21397
|
+
const out = path12.resolve(options.out);
|
|
21398
|
+
await mkdir10(path12.dirname(out), { recursive: true });
|
|
20818
21399
|
await writeFile10(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
|
|
20819
21400
|
`, "utf8");
|
|
20820
21401
|
await appendE2eExecutionEvidence(options, out, ["browser", "e2e_create_page", "e2e_step_run", "observe"]);
|
|
@@ -20872,11 +21453,11 @@ function registerE2eCommands(program2) {
|
|
|
20872
21453
|
}
|
|
20873
21454
|
|
|
20874
21455
|
// src/core/project-search.ts
|
|
20875
|
-
function
|
|
21456
|
+
function isRecord10(value) {
|
|
20876
21457
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20877
21458
|
}
|
|
20878
21459
|
function hasRawProjectSearchBody(value) {
|
|
20879
|
-
return
|
|
21460
|
+
return isRecord10(value) && Object.prototype.hasOwnProperty.call(value, "body");
|
|
20880
21461
|
}
|
|
20881
21462
|
function assertProjectSearchBody(value) {
|
|
20882
21463
|
if (hasRawProjectSearchBody(value)) {
|
|
@@ -20890,13 +21471,13 @@ function isProjectListEsQuery(value) {
|
|
|
20890
21471
|
}
|
|
20891
21472
|
function splitProjectListPagination(body, options) {
|
|
20892
21473
|
const data = { ...body };
|
|
20893
|
-
const normalizePositiveInteger = (value,
|
|
21474
|
+
const normalizePositiveInteger = (value, path17) => {
|
|
20894
21475
|
if (typeof value === "string" && value.trim() === "") {
|
|
20895
|
-
throw new Error(`project search ${
|
|
21476
|
+
throw new Error(`project search ${path17} \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u4E0D\u80FD\u662F\u7A7A\u5B57\u7B26\u4E32\u3002`);
|
|
20896
21477
|
}
|
|
20897
21478
|
const number = typeof value === "number" ? value : Number(value);
|
|
20898
21479
|
if (!Number.isSafeInteger(number) || number < 1) {
|
|
20899
|
-
throw new Error(`project search ${
|
|
21480
|
+
throw new Error(`project search ${path17} \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u5F53\u524D\u503C\u4E3A ${String(value)}\u3002`);
|
|
20900
21481
|
}
|
|
20901
21482
|
return number;
|
|
20902
21483
|
};
|
|
@@ -21027,7 +21608,7 @@ function registerFlowCommands(program2) {
|
|
|
21027
21608
|
const client = createApiClient(profile);
|
|
21028
21609
|
if (options.flowType) {
|
|
21029
21610
|
const bindings = await getWorkspaceFlowBindings(client, profile, options);
|
|
21030
|
-
const
|
|
21611
|
+
const path17 = options.flowKey ? "/flow/options" : "/flow/flow_type";
|
|
21031
21612
|
const params = options.flowKey ? {
|
|
21032
21613
|
detail: "1"
|
|
21033
21614
|
} : {
|
|
@@ -21037,7 +21618,7 @@ function registerFlowCommands(program2) {
|
|
|
21037
21618
|
const result2 = await apiRequest(
|
|
21038
21619
|
client,
|
|
21039
21620
|
"GET",
|
|
21040
|
-
|
|
21621
|
+
path17,
|
|
21041
21622
|
{
|
|
21042
21623
|
params
|
|
21043
21624
|
}
|
|
@@ -21273,7 +21854,7 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
21273
21854
|
}
|
|
21274
21855
|
|
|
21275
21856
|
// src/commands/issue.ts
|
|
21276
|
-
import { readFile as
|
|
21857
|
+
import { readFile as readFile14 } from "fs/promises";
|
|
21277
21858
|
|
|
21278
21859
|
// src/core/issues.ts
|
|
21279
21860
|
import axios8, { AxiosHeaders as AxiosHeaders3 } from "axios";
|
|
@@ -21449,7 +22030,7 @@ async function readDescription(options) {
|
|
|
21449
22030
|
if (!options.descriptionFile) {
|
|
21450
22031
|
return options.description;
|
|
21451
22032
|
}
|
|
21452
|
-
return
|
|
22033
|
+
return readFile14(options.descriptionFile, "utf8");
|
|
21453
22034
|
}
|
|
21454
22035
|
function parseAssigneeIds(values) {
|
|
21455
22036
|
return (values || []).flatMap(
|
|
@@ -21548,10 +22129,10 @@ async function parseOptionalJson(input, label) {
|
|
|
21548
22129
|
}
|
|
21549
22130
|
return parseJsonInput(input, label);
|
|
21550
22131
|
}
|
|
21551
|
-
async function memoryRequest(options, method,
|
|
22132
|
+
async function memoryRequest(options, method, path17, capability, data, params) {
|
|
21552
22133
|
const profile = resolveProfile(await loadConfig(), options.profile);
|
|
21553
22134
|
const client = createApiClient(profile);
|
|
21554
|
-
return apiRequest(client, method,
|
|
22135
|
+
return apiRequest(client, method, path17, {
|
|
21555
22136
|
capability,
|
|
21556
22137
|
data: redactAuditValue(data),
|
|
21557
22138
|
params: params ? redactAuditValue(params) : void 0
|
|
@@ -21606,7 +22187,7 @@ function registerMemoryCommands(program2) {
|
|
|
21606
22187
|
}
|
|
21607
22188
|
|
|
21608
22189
|
// src/commands/matrix.ts
|
|
21609
|
-
import { readFile as
|
|
22190
|
+
import { readFile as readFile15 } from "fs/promises";
|
|
21610
22191
|
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;
|
|
21611
22192
|
var UUID_PATH_PATTERN = /uuid'[^'"\s/]+/i;
|
|
21612
22193
|
async function parseSeedRules(input) {
|
|
@@ -21614,7 +22195,7 @@ async function parseSeedRules(input) {
|
|
|
21614
22195
|
if (source === "") {
|
|
21615
22196
|
throw new Error("--rules file path is empty.");
|
|
21616
22197
|
}
|
|
21617
|
-
const raw = source ? await
|
|
22198
|
+
const raw = source ? await readFile15(source, "utf8") : input;
|
|
21618
22199
|
let parsed;
|
|
21619
22200
|
try {
|
|
21620
22201
|
parsed = JSON.parse(raw);
|
|
@@ -21633,15 +22214,15 @@ async function parseSeedRules(input) {
|
|
|
21633
22214
|
});
|
|
21634
22215
|
return rules;
|
|
21635
22216
|
}
|
|
21636
|
-
function collectUuidPaths(value,
|
|
22217
|
+
function collectUuidPaths(value, path17 = "$") {
|
|
21637
22218
|
if (typeof value === "string") {
|
|
21638
|
-
return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [
|
|
22219
|
+
return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [path17] : [];
|
|
21639
22220
|
}
|
|
21640
22221
|
if (Array.isArray(value)) {
|
|
21641
|
-
return value.flatMap((item, index) => collectUuidPaths(item, `${
|
|
22222
|
+
return value.flatMap((item, index) => collectUuidPaths(item, `${path17}[${index}]`));
|
|
21642
22223
|
}
|
|
21643
22224
|
if (typeof value === "object" && value !== null) {
|
|
21644
|
-
return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${
|
|
22225
|
+
return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${path17}.${key}`));
|
|
21645
22226
|
}
|
|
21646
22227
|
return [];
|
|
21647
22228
|
}
|
|
@@ -21664,20 +22245,20 @@ function isEmptyApproverValue(value) {
|
|
|
21664
22245
|
function shellQuote7(value) {
|
|
21665
22246
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
21666
22247
|
}
|
|
21667
|
-
var
|
|
22248
|
+
var isRecord11 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21668
22249
|
function dataArray(value) {
|
|
21669
22250
|
if (Array.isArray(value)) return value;
|
|
21670
|
-
if (
|
|
21671
|
-
if (
|
|
21672
|
-
if (
|
|
22251
|
+
if (isRecord11(value) && Array.isArray(value.data)) return value.data;
|
|
22252
|
+
if (isRecord11(value) && Array.isArray(value.list)) return value.list;
|
|
22253
|
+
if (isRecord11(value) && Array.isArray(value.rows)) return value.rows;
|
|
21673
22254
|
return [];
|
|
21674
22255
|
}
|
|
21675
22256
|
function predictedNodes(value) {
|
|
21676
|
-
if (!
|
|
21677
|
-
return dataArray(value.predicted_nodes).filter(
|
|
22257
|
+
if (!isRecord11(value)) return [];
|
|
22258
|
+
return dataArray(value.predicted_nodes).filter(isRecord11);
|
|
21678
22259
|
}
|
|
21679
22260
|
function safePredictedOwners(value) {
|
|
21680
|
-
return (Array.isArray(value) ? value : []).filter(
|
|
22261
|
+
return (Array.isArray(value) ? value : []).filter(isRecord11).map((owner) => ({
|
|
21681
22262
|
id: owner.id ?? owner.user_id ?? owner.owner_id,
|
|
21682
22263
|
name: owner.name ?? null
|
|
21683
22264
|
}));
|
|
@@ -21692,7 +22273,7 @@ async function fetchAllMatrixRuleRecords(client, flowType) {
|
|
|
21692
22273
|
data: { flow_type: flowType, page, page_size: pageSize },
|
|
21693
22274
|
capability: "project.list"
|
|
21694
22275
|
});
|
|
21695
|
-
const rows2 = dataArray(result).filter(
|
|
22276
|
+
const rows2 = dataArray(result).filter(isRecord11);
|
|
21696
22277
|
records.push(...rows2);
|
|
21697
22278
|
const total = Number(result.count ?? result.total ?? records.length);
|
|
21698
22279
|
if (rows2.length < pageSize || records.length >= total) break;
|
|
@@ -21711,23 +22292,23 @@ async function hydrateMatrixRuleRecords(client, records) {
|
|
|
21711
22292
|
for (let index = 0; index < records.length; index += 10) {
|
|
21712
22293
|
const chunk = records.slice(index, index + 10);
|
|
21713
22294
|
hydrated.push(...await Promise.all(chunk.map(async (record) => {
|
|
21714
|
-
if (
|
|
22295
|
+
if (isRecord11(record.metaForm) || Array.isArray(record.formList)) return record;
|
|
21715
22296
|
const id = Number(record.id ?? record.project_id);
|
|
21716
22297
|
return Number.isSafeInteger(id) && id > 0 ? apiRequest(client, "GET", `/project/${id}`) : record;
|
|
21717
22298
|
})));
|
|
21718
22299
|
}
|
|
21719
22300
|
return hydrated;
|
|
21720
22301
|
}
|
|
21721
|
-
function collectMatrixOwnerPaths(value,
|
|
22302
|
+
function collectMatrixOwnerPaths(value, path17 = "$") {
|
|
21722
22303
|
if (Array.isArray(value)) {
|
|
21723
|
-
return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${
|
|
22304
|
+
return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${path17}[${index}]`));
|
|
21724
22305
|
}
|
|
21725
|
-
if (!
|
|
22306
|
+
if (!isRecord11(value)) {
|
|
21726
22307
|
return [];
|
|
21727
22308
|
}
|
|
21728
22309
|
const matches = [];
|
|
21729
22310
|
Object.entries(value).forEach(([key, child]) => {
|
|
21730
|
-
const childPath = `${
|
|
22311
|
+
const childPath = `${path17}.${key}`;
|
|
21731
22312
|
if (key.includes("matrix_owner") || typeof child === "string" && child.includes("matrix_owner")) {
|
|
21732
22313
|
matches.push({ path: childPath, value: child });
|
|
21733
22314
|
}
|
|
@@ -21736,25 +22317,25 @@ function collectMatrixOwnerPaths(value, path16 = "$") {
|
|
|
21736
22317
|
return matches;
|
|
21737
22318
|
}
|
|
21738
22319
|
function projectFormKeys(project) {
|
|
21739
|
-
const metaForm =
|
|
22320
|
+
const metaForm = isRecord11(project.metaForm) ? project.metaForm : {};
|
|
21740
22321
|
const values = dataArray(metaForm.value ?? project.formList);
|
|
21741
|
-
return values.filter(
|
|
22322
|
+
return values.filter(isRecord11).map((item) => String(item.key ?? item.field_key ?? "")).filter(Boolean);
|
|
21742
22323
|
}
|
|
21743
22324
|
function findFlowNode2(flow, nodeId) {
|
|
21744
|
-
const data =
|
|
21745
|
-
return dataArray(data.nodes).filter(
|
|
22325
|
+
const data = isRecord11(flow.data) ? flow.data : {};
|
|
22326
|
+
return dataArray(data.nodes).filter(isRecord11).find((node) => String(node.id ?? node.key ?? node.flow_step_id ?? "") === nodeId);
|
|
21746
22327
|
}
|
|
21747
22328
|
function flowCategory(flow) {
|
|
21748
|
-
const data =
|
|
21749
|
-
const meta =
|
|
22329
|
+
const data = isRecord11(flow.data) ? flow.data : {};
|
|
22330
|
+
const meta = isRecord11(data.meta) ? data.meta : {};
|
|
21750
22331
|
return String(flow.category ?? data.category ?? meta.category ?? "");
|
|
21751
22332
|
}
|
|
21752
22333
|
function hasIdentifier(value) {
|
|
21753
22334
|
return value !== void 0 && value !== null && String(value).trim() !== "" && String(value) !== "0";
|
|
21754
22335
|
}
|
|
21755
22336
|
function matrixAppSummary(flow, listTemplates = [], filterTemplates = [], datasets = [], workspaceBound = false) {
|
|
21756
|
-
const data =
|
|
21757
|
-
const meta =
|
|
22337
|
+
const data = isRecord11(flow.data) ? flow.data : {};
|
|
22338
|
+
const meta = isRecord11(data.meta) ? data.meta : {};
|
|
21758
22339
|
const refs = {
|
|
21759
22340
|
form_template_id: meta.form_template ?? flow.form_template_id,
|
|
21760
22341
|
list_template_ids: listTemplates.map((item) => item.id ?? item.flow_page_template_id).filter(hasIdentifier),
|
|
@@ -21795,7 +22376,7 @@ function matrixAppSummary(flow, listTemplates = [], filterTemplates = [], datase
|
|
|
21795
22376
|
suggestion: "\u4ECE\u6700\u65B0 workspace-flow \u56DE\u8BFB merge \u540E\u901A\u8FC7 typed CLI \u63D0\u4EA4\u7ED1\u5B9A\u3002"
|
|
21796
22377
|
});
|
|
21797
22378
|
}
|
|
21798
|
-
const nodes = dataArray(data.nodes).filter(
|
|
22379
|
+
const nodes = dataArray(data.nodes).filter(isRecord11);
|
|
21799
22380
|
const activeNodes = nodes.filter((node) => {
|
|
21800
22381
|
const name = String(node.name ?? "").trim();
|
|
21801
22382
|
return name === "\u751F\u6548\u4E2D" || name === "\u8FDB\u884C\u4E2D" || Number(node.status) === 1;
|
|
@@ -21844,10 +22425,10 @@ async function inspectMatrixAppDefinition(profile, flowType, workspace, includeR
|
|
|
21844
22425
|
apiRequest(client, "GET", "/flow_page_template", { params: { type: 3, flow_type: flowType, flow_key: "", skip_i18n: true }, capability: "config.filter_template.export" }),
|
|
21845
22426
|
apiRequest(client, "GET", "/workspace/by_key", { params: { key: workspace }, capability: "config.workspace_flow.export" })
|
|
21846
22427
|
]);
|
|
21847
|
-
const flowData =
|
|
21848
|
-
const meta =
|
|
21849
|
-
const listRows = dataArray(listResult).filter(
|
|
21850
|
-
const filterRows = dataArray(filterResult).filter(
|
|
22428
|
+
const flowData = isRecord11(flow.data) ? flow.data : {};
|
|
22429
|
+
const meta = isRecord11(flowData.meta) ? flowData.meta : {};
|
|
22430
|
+
const listRows = dataArray(listResult).filter(isRecord11);
|
|
22431
|
+
const filterRows = dataArray(filterResult).filter(isRecord11);
|
|
21851
22432
|
const listIds = uniqueIds([meta.table_list_template, ...listRows.map((item) => item.id ?? item.flow_page_template_id)]);
|
|
21852
22433
|
const filterIds = uniqueIds([meta.table_filter_template, ...filterRows.map((item) => item.id ?? item.flow_page_template_id)]);
|
|
21853
22434
|
const formId = String(meta.form_template ?? flow.form_template_id ?? "");
|
|
@@ -21865,7 +22446,7 @@ async function inspectMatrixAppDefinition(profile, flowType, workspace, includeR
|
|
|
21865
22446
|
if (strict) {
|
|
21866
22447
|
assertNoMatrixErrors(summary.errors);
|
|
21867
22448
|
}
|
|
21868
|
-
const formRecord =
|
|
22449
|
+
const formRecord = isRecord11(form) ? form : {};
|
|
21869
22450
|
const exactReadback = {
|
|
21870
22451
|
flow: { id: flowType, readback_hash: matrixHash(flow), ...includeRaw ? { readback: flow } : {} },
|
|
21871
22452
|
form_template: { id: formId, draft_id: formRecord.origin_template_id ?? formRecord.id ?? null, readback_hash: matrixHash(formRecord), ...includeRaw ? { readback: formRecord } : {} },
|
|
@@ -21877,8 +22458,8 @@ async function inspectMatrixAppDefinition(profile, flowType, workspace, includeR
|
|
|
21877
22458
|
return { ok: summary.errors.length === 0, domain: "approval-matrix", action: "app.inspect", flow_type: flowType, workspace, ...summary, exact_readback: exactReadback };
|
|
21878
22459
|
}
|
|
21879
22460
|
function workspaceHasFlow(value, flowType) {
|
|
21880
|
-
if (!
|
|
21881
|
-
const rows2 = Array.isArray(value.workspace_flow) ? value.workspace_flow.filter(
|
|
22461
|
+
if (!isRecord11(value)) return false;
|
|
22462
|
+
const rows2 = Array.isArray(value.workspace_flow) ? value.workspace_flow.filter(isRecord11) : isRecord11(value.data) && Array.isArray(value.data.workspace_flow) ? value.data.workspace_flow.filter(isRecord11) : [];
|
|
21882
22463
|
return rows2.some((item) => String(item.flow_type ?? "") === flowType && Number(item.is_del ?? 0) === 0);
|
|
21883
22464
|
}
|
|
21884
22465
|
function matrixConsumerSummary(node, expectedMatrixFlowType) {
|
|
@@ -21894,8 +22475,8 @@ function matrixConsumerSummary(node, expectedMatrixFlowType) {
|
|
|
21894
22475
|
});
|
|
21895
22476
|
return { errors, owner: null, cc: null };
|
|
21896
22477
|
}
|
|
21897
|
-
const owner =
|
|
21898
|
-
const cc =
|
|
22478
|
+
const owner = isRecord11(node.matrix_owner) ? node.matrix_owner : null;
|
|
22479
|
+
const cc = isRecord11(node.cc_matrix) ? node.cc_matrix : null;
|
|
21899
22480
|
const normalizeFlowRef = (value) => String(value ?? "").trim().replace(/:$/, "");
|
|
21900
22481
|
if (node.auto_range_type === "matrix") {
|
|
21901
22482
|
if (!owner || !String(owner.flow ?? owner.matrix_flow_type ?? "").trim()) {
|
|
@@ -21926,16 +22507,16 @@ function matrixConsumerSummary(node, expectedMatrixFlowType) {
|
|
|
21926
22507
|
return { errors, owner, cc };
|
|
21927
22508
|
}
|
|
21928
22509
|
function projectField(project, key) {
|
|
21929
|
-
const metaForm =
|
|
21930
|
-
const values = dataArray(metaForm.value ?? project.formList).filter(
|
|
22510
|
+
const metaForm = isRecord11(project.metaForm) ? project.metaForm : {};
|
|
22511
|
+
const values = dataArray(metaForm.value ?? project.formList).filter(isRecord11);
|
|
21931
22512
|
const row = values.find((item) => String(item.key ?? item.field_key ?? "") === key);
|
|
21932
22513
|
if (!row) return void 0;
|
|
21933
22514
|
const value = row.value;
|
|
21934
|
-
return
|
|
22515
|
+
return isRecord11(value) && Object.prototype.hasOwnProperty.call(value, "value") ? value.value : value;
|
|
21935
22516
|
}
|
|
21936
22517
|
function collectUserIds(value) {
|
|
21937
22518
|
if (Array.isArray(value)) return [...new Set(value.flatMap(collectUserIds))];
|
|
21938
|
-
if (
|
|
22519
|
+
if (isRecord11(value)) {
|
|
21939
22520
|
const direct2 = Number(value.id ?? value.user_id ?? value.value);
|
|
21940
22521
|
if (Number.isSafeInteger(direct2) && direct2 > 0) return [direct2];
|
|
21941
22522
|
return [...new Set(Object.values(value).flatMap(collectUserIds))];
|
|
@@ -21956,7 +22537,7 @@ async function readMatrixApprovers(client, ids) {
|
|
|
21956
22537
|
},
|
|
21957
22538
|
capability: "user.readback"
|
|
21958
22539
|
});
|
|
21959
|
-
users.push(...dataArray(result).filter(
|
|
22540
|
+
users.push(...dataArray(result).filter(isRecord11));
|
|
21960
22541
|
}
|
|
21961
22542
|
return users;
|
|
21962
22543
|
}
|
|
@@ -22040,7 +22621,7 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
22040
22621
|
const matrixOwnerConfig = node ? collectMatrixOwnerPaths(node) : [];
|
|
22041
22622
|
const predictedNode = predictedNodes(prediction).find((item) => String(item.node_id ?? item.id ?? "") === options.node);
|
|
22042
22623
|
const owners = safePredictedOwners(predictedNode?.owners);
|
|
22043
|
-
const ownerResolution = predictedNode &&
|
|
22624
|
+
const ownerResolution = predictedNode && isRecord11(predictedNode.owner_resolution) ? predictedNode.owner_resolution : { status: predictedNode ? "resolved" : "missing" };
|
|
22044
22625
|
const projectFlowType = String(project.flow_type ?? "");
|
|
22045
22626
|
const flowMatchesProject = !projectFlowType || projectFlowType === options.flowType;
|
|
22046
22627
|
printResult(options.format, {
|
|
@@ -22131,14 +22712,14 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
22131
22712
|
if (!workspace) throw new Error("matrix.app.workspace_required: \u8BF7\u63D0\u4F9B --workspace \u4EE5\u5220\u9664\u77E9\u9635\u5E94\u7528\u3002");
|
|
22132
22713
|
const definition = await inspectMatrixAppDefinition(profile, options.flowType, workspace, true, false);
|
|
22133
22714
|
const exact = definition.exact_readback;
|
|
22134
|
-
const listItems = Array.isArray(exact.list_templates) ? exact.list_templates.filter(
|
|
22135
|
-
const filterItems = Array.isArray(exact.filter_templates) ? exact.filter_templates.filter(
|
|
22136
|
-
const datasetItems = Array.isArray(exact.datasets) ? exact.datasets.filter(
|
|
22715
|
+
const listItems = Array.isArray(exact.list_templates) ? exact.list_templates.filter(isRecord11) : [];
|
|
22716
|
+
const filterItems = Array.isArray(exact.filter_templates) ? exact.filter_templates.filter(isRecord11) : [];
|
|
22717
|
+
const datasetItems = Array.isArray(exact.datasets) ? exact.datasets.filter(isRecord11) : [];
|
|
22137
22718
|
const datasetFieldIds = uniqueIds(datasetItems.flatMap((item) => {
|
|
22138
|
-
const readback =
|
|
22139
|
-
return Array.isArray(readback.dataSetFields) ? readback.dataSetFields.filter(
|
|
22719
|
+
const readback = isRecord11(item.readback) ? item.readback : {};
|
|
22720
|
+
return Array.isArray(readback.dataSetFields) ? readback.dataSetFields.filter(isRecord11).map((field) => field.id) : [];
|
|
22140
22721
|
}));
|
|
22141
|
-
const formItem =
|
|
22722
|
+
const formItem = isRecord11(exact.form_template) ? exact.form_template : {};
|
|
22142
22723
|
const formDraftId = String(formItem.draft_id ?? formItem.id ?? "");
|
|
22143
22724
|
const expectedConfirm = `delete matrix app ${options.flowType} from ${workspace}`;
|
|
22144
22725
|
const plan = [
|
|
@@ -22200,8 +22781,8 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
22200
22781
|
apiRequest(client, "GET", "/flow_page_template", { params: { type: 3, flow_type: options.matrixFlowType, flow_key: "", skip_i18n: true }, capability: "config.filter_template.export" }),
|
|
22201
22782
|
apiRequest(client, "GET", "/workspace/by_key", { params: { key: workspace }, capability: "config.workspace_flow.export" })
|
|
22202
22783
|
]);
|
|
22203
|
-
const listRows = dataArray(listResult).filter(
|
|
22204
|
-
const filterRows = dataArray(filterResult).filter(
|
|
22784
|
+
const listRows = dataArray(listResult).filter(isRecord11);
|
|
22785
|
+
const filterRows = dataArray(filterResult).filter(isRecord11);
|
|
22205
22786
|
const listTemplates = await Promise.all(uniqueIds(listRows.map((item) => item.id ?? item.flow_page_template_id)).map((id) => apiRequest(client, "GET", `/flow_page_template/${encodeURIComponent(id)}?skip_i18n=true`, { capability: "config.list_template.export" })));
|
|
22206
22787
|
const filterTemplates = await Promise.all(uniqueIds(filterRows.map((item) => item.id ?? item.flow_page_template_id)).map((id) => apiRequest(client, "GET", `/flow_page_template/${encodeURIComponent(id)}?skip_i18n=true`, { capability: "config.filter_template.export" })));
|
|
22207
22788
|
const datasetIds = uniqueIds([...listTemplates.map((item) => item.data_set_id), ...filterTemplates.map((item) => item.data_set_id)]);
|
|
@@ -22235,7 +22816,7 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
22235
22816
|
}
|
|
22236
22817
|
const predictedNode = predictedNodes(prediction).find((item) => String(item.node_id ?? item.id ?? "") === options.node);
|
|
22237
22818
|
const predictedOwners = safePredictedOwners(predictedNode?.owners);
|
|
22238
|
-
const ownerResolution = predictedNode &&
|
|
22819
|
+
const ownerResolution = predictedNode && isRecord11(predictedNode.owner_resolution) ? predictedNode.owner_resolution : { status: predictedNode ? "resolved" : "missing" };
|
|
22239
22820
|
if (ownerResolution.status === "error") {
|
|
22240
22821
|
errors.push({ code: "matrix.consumer.owner_resolution_error", rule_id: "matrix.consumer.owner_resolution_error", domain: "approval-matrix", path: "$.predicted_nodes[].owner_resolution", message: `\u7EDF\u4E00 owner resolver \u6267\u884C\u5931\u8D25\uFF1A${String(ownerResolution.error_code ?? "unknown")}\u3002`, suggestion: "\u4FEE\u590D\u77E9\u9635/\u5B57\u6BB5/\u89D2\u8272 owner \u89E3\u6790\u9519\u8BEF\u540E\u91CD\u65B0 verify\uFF0C\u4E0D\u5F97\u5C06\u7A7A owners \u5F53\u6210\u6B63\u5E38\u65E0\u4EBA\u3002" });
|
|
22241
22822
|
} else if (!predictedNode || predictedOwners.length === 0) {
|
|
@@ -22259,13 +22840,13 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
22259
22840
|
}
|
|
22260
22841
|
|
|
22261
22842
|
// src/commands/organization.ts
|
|
22262
|
-
function
|
|
22843
|
+
function isRecord12(value) {
|
|
22263
22844
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22264
22845
|
}
|
|
22265
22846
|
function rows(value) {
|
|
22266
|
-
if (Array.isArray(value)) return value.filter(
|
|
22267
|
-
if (!
|
|
22268
|
-
if (Array.isArray(value.data)) return value.data.filter(
|
|
22847
|
+
if (Array.isArray(value)) return value.filter(isRecord12);
|
|
22848
|
+
if (!isRecord12(value)) return [];
|
|
22849
|
+
if (Array.isArray(value.data)) return value.data.filter(isRecord12);
|
|
22269
22850
|
return value.id ? [value] : [];
|
|
22270
22851
|
}
|
|
22271
22852
|
function positiveId(value, errorCode) {
|
|
@@ -22289,7 +22870,7 @@ function safeDepartment(group) {
|
|
|
22289
22870
|
function departmentRows(value) {
|
|
22290
22871
|
const result = [];
|
|
22291
22872
|
const visit = (item) => {
|
|
22292
|
-
if (!
|
|
22873
|
+
if (!isRecord12(item)) return;
|
|
22293
22874
|
if (item.id !== void 0) result.push(safeDepartment(item));
|
|
22294
22875
|
if (Array.isArray(item.children)) item.children.forEach(visit);
|
|
22295
22876
|
};
|
|
@@ -22298,7 +22879,7 @@ function departmentRows(value) {
|
|
|
22298
22879
|
}
|
|
22299
22880
|
function relationDepartments(value) {
|
|
22300
22881
|
if (!Array.isArray(value)) return [];
|
|
22301
|
-
return value.filter(
|
|
22882
|
+
return value.filter(isRecord12).map(safeDepartment);
|
|
22302
22883
|
}
|
|
22303
22884
|
function safeUser(user) {
|
|
22304
22885
|
const status = user.status === void 0 ? null : Number(user.status);
|
|
@@ -22345,8 +22926,8 @@ async function readDepartments(client, ids) {
|
|
|
22345
22926
|
function pathIds(departments) {
|
|
22346
22927
|
const ids = /* @__PURE__ */ new Set();
|
|
22347
22928
|
for (const department of departments) {
|
|
22348
|
-
const
|
|
22349
|
-
for (const part of
|
|
22929
|
+
const path17 = String(department.path ?? "");
|
|
22930
|
+
for (const part of path17.split(/[|,]/)) {
|
|
22350
22931
|
const id = Number(part);
|
|
22351
22932
|
if (Number.isSafeInteger(id) && id > 0) ids.add(id);
|
|
22352
22933
|
}
|
|
@@ -22356,7 +22937,7 @@ function pathIds(departments) {
|
|
|
22356
22937
|
function mainDepartmentId(raw) {
|
|
22357
22938
|
for (const key of ["main_department_id", "main_group_id", "main_department"]) {
|
|
22358
22939
|
const value = raw[key];
|
|
22359
|
-
if (
|
|
22940
|
+
if (isRecord12(value)) {
|
|
22360
22941
|
const id2 = Number(value.id);
|
|
22361
22942
|
if (Number.isSafeInteger(id2) && id2 > 0) return id2;
|
|
22362
22943
|
}
|
|
@@ -22368,7 +22949,7 @@ function mainDepartmentId(raw) {
|
|
|
22368
22949
|
function branchId(raw) {
|
|
22369
22950
|
for (const key of ["branch_id", "branch_group_id", "branch"]) {
|
|
22370
22951
|
const value = raw[key];
|
|
22371
|
-
if (
|
|
22952
|
+
if (isRecord12(value)) {
|
|
22372
22953
|
const id2 = Number(value.id);
|
|
22373
22954
|
if (Number.isSafeInteger(id2) && id2 > 0) return id2;
|
|
22374
22955
|
}
|
|
@@ -22886,15 +23467,15 @@ async function promptProjectCreateForm(input) {
|
|
|
22886
23467
|
}
|
|
22887
23468
|
|
|
22888
23469
|
// src/core/project-form.ts
|
|
22889
|
-
function
|
|
23470
|
+
function isRecord13(value) {
|
|
22890
23471
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22891
23472
|
}
|
|
22892
23473
|
function clone(value) {
|
|
22893
23474
|
return JSON.parse(JSON.stringify(value));
|
|
22894
23475
|
}
|
|
22895
23476
|
function getFlowFormTemplateId(flowDetail) {
|
|
22896
|
-
const data =
|
|
22897
|
-
const meta =
|
|
23477
|
+
const data = isRecord13(flowDetail?.data) ? flowDetail.data : void 0;
|
|
23478
|
+
const meta = isRecord13(data?.meta) ? data.meta : void 0;
|
|
22898
23479
|
const templateId = meta?.form_template;
|
|
22899
23480
|
if (typeof templateId === "number" && Number.isFinite(templateId)) {
|
|
22900
23481
|
return templateId;
|
|
@@ -22919,7 +23500,7 @@ function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
22919
23500
|
if (Array.isArray(value)) {
|
|
22920
23501
|
return value.some((item) => hasAutoInitLambda(item, seen));
|
|
22921
23502
|
}
|
|
22922
|
-
if (!
|
|
23503
|
+
if (!isRecord13(value)) {
|
|
22923
23504
|
return false;
|
|
22924
23505
|
}
|
|
22925
23506
|
if (seen.has(value)) {
|
|
@@ -22934,14 +23515,14 @@ function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
22934
23515
|
function setControlValue(control, value) {
|
|
22935
23516
|
const next = clone(control);
|
|
22936
23517
|
next.value = {
|
|
22937
|
-
...
|
|
23518
|
+
...isRecord13(next.value) ? next.value : {},
|
|
22938
23519
|
type: next.value?.type ?? next.field_type,
|
|
22939
23520
|
value
|
|
22940
23521
|
};
|
|
22941
23522
|
return next;
|
|
22942
23523
|
}
|
|
22943
23524
|
function applyRowValues(rowTemplate, rowValue) {
|
|
22944
|
-
const source =
|
|
23525
|
+
const source = isRecord13(rowValue) ? rowValue : {};
|
|
22945
23526
|
return rowTemplate.map((control) => {
|
|
22946
23527
|
if (control.key && Object.prototype.hasOwnProperty.call(source, control.key)) {
|
|
22947
23528
|
return setControlValue(control, source[control.key]);
|
|
@@ -23227,17 +23808,17 @@ function assertStepProjectFormWritable(fields, form, prefix = "") {
|
|
|
23227
23808
|
for (const [key, value] of Object.entries(form)) {
|
|
23228
23809
|
const field = fieldsByKey.get(key);
|
|
23229
23810
|
if (!field) continue;
|
|
23230
|
-
const
|
|
23811
|
+
const path17 = `${prefix}${key}`;
|
|
23231
23812
|
if (field.hidden) {
|
|
23232
|
-
throw new Error(`Step project form handoff cannot write hidden field ${
|
|
23813
|
+
throw new Error(`Step project form handoff cannot write hidden field ${path17}.`);
|
|
23233
23814
|
}
|
|
23234
23815
|
if (isUnsupportedStepPrefillField(field)) {
|
|
23235
|
-
throw new Error(`Step project form handoff cannot write system or manual field ${
|
|
23816
|
+
throw new Error(`Step project form handoff cannot write system or manual field ${path17} (${field.type || "unknown"}).`);
|
|
23236
23817
|
}
|
|
23237
23818
|
if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
|
|
23238
23819
|
value.forEach((row, index) => {
|
|
23239
23820
|
if (isRecordValue(row)) {
|
|
23240
|
-
assertStepProjectFormWritable(field.children ?? [], row, `${
|
|
23821
|
+
assertStepProjectFormWritable(field.children ?? [], row, `${path17}[${index}].`);
|
|
23241
23822
|
}
|
|
23242
23823
|
});
|
|
23243
23824
|
}
|
|
@@ -23499,8 +24080,8 @@ function fieldsForValidation(flowDetail, projectFormTemplate) {
|
|
|
23499
24080
|
}));
|
|
23500
24081
|
}
|
|
23501
24082
|
function metaUsesTemplateProjectName(flowDetail) {
|
|
23502
|
-
const data =
|
|
23503
|
-
const meta =
|
|
24083
|
+
const data = isRecord14(flowDetail?.data) ? flowDetail.data : void 0;
|
|
24084
|
+
const meta = isRecord14(data?.meta) ? data.meta : void 0;
|
|
23504
24085
|
const hideFields = Array.isArray(meta?.hide_fields) ? meta.hide_fields.map(String) : [];
|
|
23505
24086
|
return meta?.use_template_project_name === true || hideFields.includes("project.name");
|
|
23506
24087
|
}
|
|
@@ -23594,9 +24175,9 @@ function contextField(field, reason, options = {}) {
|
|
|
23594
24175
|
function collectPrefillContextForFields(fields, form, result, options = {}) {
|
|
23595
24176
|
for (const field of fields) {
|
|
23596
24177
|
const value = form[field.key];
|
|
23597
|
-
const
|
|
24178
|
+
const path17 = options.prefix ? `${options.prefix}.${field.key}` : field.key;
|
|
23598
24179
|
const fieldOptions = {
|
|
23599
|
-
path:
|
|
24180
|
+
path: path17,
|
|
23600
24181
|
rootKey: options.rootKey ?? field.key,
|
|
23601
24182
|
parentKey: options.parentKey
|
|
23602
24183
|
};
|
|
@@ -23609,7 +24190,7 @@ function collectPrefillContextForFields(fields, form, result, options = {}) {
|
|
|
23609
24190
|
result.filled_fields.push(contextField(field, "prefilled", fieldOptions));
|
|
23610
24191
|
if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
|
|
23611
24192
|
value.forEach((row, index) => {
|
|
23612
|
-
if (
|
|
24193
|
+
if (isRecord14(row)) {
|
|
23613
24194
|
collectPrefillContextForFields(field.children ?? [], row, result, {
|
|
23614
24195
|
prefix: `${field.key}[${index}]`,
|
|
23615
24196
|
rootKey: field.key,
|
|
@@ -23636,7 +24217,7 @@ function buildPrefillContext(fields, form) {
|
|
|
23636
24217
|
}
|
|
23637
24218
|
};
|
|
23638
24219
|
}
|
|
23639
|
-
function
|
|
24220
|
+
function isRecord14(value) {
|
|
23640
24221
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23641
24222
|
}
|
|
23642
24223
|
function isEndedStep(step) {
|
|
@@ -23659,7 +24240,7 @@ function stepIdOf(step) {
|
|
|
23659
24240
|
function pickStepFormPayload(step) {
|
|
23660
24241
|
const formList = Array.isArray(step.formList) ? step.formList : [];
|
|
23661
24242
|
const forms = Array.isArray(step.forms) ? step.forms : [];
|
|
23662
|
-
const metaForm =
|
|
24243
|
+
const metaForm = isRecord14(step.metaForm) ? step.metaForm : void 0;
|
|
23663
24244
|
return {
|
|
23664
24245
|
step_id: step.id,
|
|
23665
24246
|
flow_step_id: step.flow_step_id,
|
|
@@ -23676,7 +24257,7 @@ function pickStepFormPayload(step) {
|
|
|
23676
24257
|
}
|
|
23677
24258
|
async function buildApprovalContext(client, projectId, options) {
|
|
23678
24259
|
const projectDetail = await apiRequest(client, "GET", `/project/${projectId}`);
|
|
23679
|
-
const steps = Array.isArray(projectDetail.steps) ? projectDetail.steps.filter(
|
|
24260
|
+
const steps = Array.isArray(projectDetail.steps) ? projectDetail.steps.filter(isRecord14) : [];
|
|
23680
24261
|
const targetStepIds = /* @__PURE__ */ new Set();
|
|
23681
24262
|
for (const step of steps) {
|
|
23682
24263
|
const id = stepIdOf(step);
|
|
@@ -23702,7 +24283,7 @@ async function buildApprovalContext(client, projectId, options) {
|
|
|
23702
24283
|
}
|
|
23703
24284
|
return {
|
|
23704
24285
|
project: projectDetail,
|
|
23705
|
-
project_form:
|
|
24286
|
+
project_form: isRecord14(projectDetail.metaForm) ? projectDetail.metaForm : null,
|
|
23706
24287
|
inspected_step_count: stepForms.length,
|
|
23707
24288
|
step_forms: stepForms,
|
|
23708
24289
|
failed_steps: failedSteps
|
|
@@ -24040,8 +24621,8 @@ import { spawn as spawn2 } from "child_process";
|
|
|
24040
24621
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
24041
24622
|
|
|
24042
24623
|
// src/core/recipes.ts
|
|
24043
|
-
import { access, mkdir as mkdir11, readdir as
|
|
24044
|
-
import
|
|
24624
|
+
import { access, mkdir as mkdir11, readdir as readdir6, readFile as readFile16, writeFile as writeFile11 } from "fs/promises";
|
|
24625
|
+
import path13 from "path";
|
|
24045
24626
|
var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
24046
24627
|
var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
|
|
24047
24628
|
function assertSafeName(kind, value) {
|
|
@@ -24065,14 +24646,14 @@ function resolveRecipeLocation(options) {
|
|
|
24065
24646
|
workspace,
|
|
24066
24647
|
workspaceDirName,
|
|
24067
24648
|
recipeName: options.recipeName,
|
|
24068
|
-
recipeDir:
|
|
24649
|
+
recipeDir: path13.join(profileDir, "recipes", workspaceDirName, options.recipeName)
|
|
24069
24650
|
};
|
|
24070
24651
|
}
|
|
24071
24652
|
function getRecipesDir(options) {
|
|
24072
24653
|
const workspaceDirName = normalizeWorkspaceForPath(options.workspace || DEFAULT_WORKSPACE);
|
|
24073
|
-
return
|
|
24654
|
+
return path13.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
|
|
24074
24655
|
}
|
|
24075
|
-
function
|
|
24656
|
+
function isRecord15(value) {
|
|
24076
24657
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24077
24658
|
}
|
|
24078
24659
|
function asString(value, fieldName) {
|
|
@@ -24082,7 +24663,7 @@ function asString(value, fieldName) {
|
|
|
24082
24663
|
return value;
|
|
24083
24664
|
}
|
|
24084
24665
|
function parseRecipeDefinition(input) {
|
|
24085
|
-
if (!
|
|
24666
|
+
if (!isRecord15(input)) {
|
|
24086
24667
|
throw new Error("recipe.json must be a JSON object.");
|
|
24087
24668
|
}
|
|
24088
24669
|
if (input.version !== 1) {
|
|
@@ -24090,7 +24671,7 @@ function parseRecipeDefinition(input) {
|
|
|
24090
24671
|
}
|
|
24091
24672
|
const name = asString(input.name, "recipe.name");
|
|
24092
24673
|
assertSafeName("Recipe name", name);
|
|
24093
|
-
if (!
|
|
24674
|
+
if (!isRecord15(input.command)) {
|
|
24094
24675
|
throw new Error("recipe.command must be an object.");
|
|
24095
24676
|
}
|
|
24096
24677
|
const argv = input.command.argv;
|
|
@@ -24098,7 +24679,7 @@ function parseRecipeDefinition(input) {
|
|
|
24098
24679
|
throw new Error("recipe.command.argv must be a non-empty string array.");
|
|
24099
24680
|
}
|
|
24100
24681
|
const variables = Array.isArray(input.variables) ? input.variables.map((item, index) => {
|
|
24101
|
-
if (!
|
|
24682
|
+
if (!isRecord15(item)) {
|
|
24102
24683
|
throw new Error(`recipe.variables[${index}] must be an object.`);
|
|
24103
24684
|
}
|
|
24104
24685
|
const variableName = asString(item.name, `recipe.variables[${index}].name`);
|
|
@@ -24122,13 +24703,13 @@ function parseRecipeDefinition(input) {
|
|
|
24122
24703
|
};
|
|
24123
24704
|
}
|
|
24124
24705
|
async function loadRecipe(recipeDir) {
|
|
24125
|
-
const raw = await
|
|
24706
|
+
const raw = await readFile16(path13.join(recipeDir, "recipe.json"), "utf8");
|
|
24126
24707
|
return parseRecipeDefinition(JSON.parse(raw));
|
|
24127
24708
|
}
|
|
24128
24709
|
async function listRecipes(recipesDir) {
|
|
24129
24710
|
let entries;
|
|
24130
24711
|
try {
|
|
24131
|
-
entries = await
|
|
24712
|
+
entries = await readdir6(recipesDir);
|
|
24132
24713
|
} catch (error) {
|
|
24133
24714
|
if (error.code === "ENOENT") {
|
|
24134
24715
|
return [];
|
|
@@ -24140,7 +24721,7 @@ async function listRecipes(recipesDir) {
|
|
|
24140
24721
|
if (!RECIPE_NAME_PATTERN.test(entry)) {
|
|
24141
24722
|
continue;
|
|
24142
24723
|
}
|
|
24143
|
-
const recipeDir =
|
|
24724
|
+
const recipeDir = path13.join(recipesDir, entry);
|
|
24144
24725
|
try {
|
|
24145
24726
|
const recipe = await loadRecipe(recipeDir);
|
|
24146
24727
|
summaries.push({
|
|
@@ -24174,7 +24755,7 @@ function parseVarsJson(input) {
|
|
|
24174
24755
|
return {};
|
|
24175
24756
|
}
|
|
24176
24757
|
const parsed = JSON.parse(input);
|
|
24177
|
-
if (!
|
|
24758
|
+
if (!isRecord15(parsed)) {
|
|
24178
24759
|
throw new Error("--vars must be a JSON object.");
|
|
24179
24760
|
}
|
|
24180
24761
|
const variables = {};
|
|
@@ -24206,12 +24787,12 @@ function renderTemplate(template, variables) {
|
|
|
24206
24787
|
}
|
|
24207
24788
|
function resolveRecipeFile(recipeDir, token) {
|
|
24208
24789
|
const relative = token.slice(1);
|
|
24209
|
-
if (!relative || relative.includes("..") ||
|
|
24790
|
+
if (!relative || relative.includes("..") || path13.isAbsolute(relative)) {
|
|
24210
24791
|
throw new Error(`Unsafe recipe file reference: ${token}`);
|
|
24211
24792
|
}
|
|
24212
|
-
const resolved =
|
|
24213
|
-
const root =
|
|
24214
|
-
if (resolved !== root && !resolved.startsWith(`${root}${
|
|
24793
|
+
const resolved = path13.resolve(recipeDir, relative);
|
|
24794
|
+
const root = path13.resolve(recipeDir);
|
|
24795
|
+
if (resolved !== root && !resolved.startsWith(`${root}${path13.sep}`)) {
|
|
24215
24796
|
throw new Error(`Recipe file reference escapes recipe directory: ${token}`);
|
|
24216
24797
|
}
|
|
24217
24798
|
return resolved;
|
|
@@ -24221,7 +24802,7 @@ async function renderArgv(options) {
|
|
|
24221
24802
|
const rendered = [];
|
|
24222
24803
|
for (const token of options.recipe.command.argv) {
|
|
24223
24804
|
if (token.startsWith("@")) {
|
|
24224
|
-
const raw = await
|
|
24805
|
+
const raw = await readFile16(resolveRecipeFile(options.recipeDir, token), "utf8");
|
|
24225
24806
|
rendered.push(renderTemplate(raw, options.variables));
|
|
24226
24807
|
} else {
|
|
24227
24808
|
rendered.push(renderTemplate(token, options.variables));
|
|
@@ -24264,16 +24845,16 @@ async function writeRecipeScaffold(options) {
|
|
|
24264
24845
|
mutating: true
|
|
24265
24846
|
}
|
|
24266
24847
|
};
|
|
24267
|
-
await writeFile11(
|
|
24848
|
+
await writeFile11(path13.join(options.location.recipeDir, "recipe.json"), `${JSON.stringify(recipe, null, 2)}
|
|
24268
24849
|
`, "utf8");
|
|
24269
24850
|
await writeFile11(
|
|
24270
|
-
|
|
24851
|
+
path13.join(options.location.recipeDir, "payload.json"),
|
|
24271
24852
|
`${JSON.stringify({ form: {} }, null, 2)}
|
|
24272
24853
|
`,
|
|
24273
24854
|
"utf8"
|
|
24274
24855
|
);
|
|
24275
24856
|
await writeFile11(
|
|
24276
|
-
|
|
24857
|
+
path13.join(options.location.recipeDir, "README.md"),
|
|
24277
24858
|
[`# ${title}`, "", "Describe the BPMAX flow, field mapping, prerequisites, and verification steps for this recipe.", ""].join("\n"),
|
|
24278
24859
|
"utf8"
|
|
24279
24860
|
);
|
|
@@ -24707,8 +25288,8 @@ function registerSetupCommand(program2, deps = {}) {
|
|
|
24707
25288
|
}
|
|
24708
25289
|
|
|
24709
25290
|
// src/core/taskbook.ts
|
|
24710
|
-
import { mkdir as mkdir12, readFile as
|
|
24711
|
-
import
|
|
25291
|
+
import { mkdir as mkdir12, readFile as readFile17, writeFile as writeFile12 } from "fs/promises";
|
|
25292
|
+
import path14 from "path";
|
|
24712
25293
|
var TaskbookError = class extends Error {
|
|
24713
25294
|
};
|
|
24714
25295
|
var REQUIRED_TASKBOOK_TERMS = [
|
|
@@ -24924,19 +25505,19 @@ function hasDomainWriteEvidence(domain, evidenceText, patterns) {
|
|
|
24924
25505
|
function uuidValues(text5) {
|
|
24925
25506
|
return [...new Set([...text5.matchAll(UUID_PATTERN)].map((match) => match[0]))];
|
|
24926
25507
|
}
|
|
24927
|
-
function addUuidIssues(text5, issues,
|
|
25508
|
+
function addUuidIssues(text5, issues, path17) {
|
|
24928
25509
|
for (const value of uuidValues(text5)) {
|
|
24929
25510
|
addTaskbookIssue(
|
|
24930
25511
|
issues,
|
|
24931
25512
|
"uuid_not_allowed",
|
|
24932
25513
|
"taskbook.config.no_uuid",
|
|
24933
25514
|
`BPMAX \u914D\u7F6E\u4EFB\u52A1\u4E0D\u80FD\u4F7F\u7528 UUID\uFF1A${value}\u3002`,
|
|
24934
|
-
{ path:
|
|
25515
|
+
{ path: path17, suggestion: "\u4F7F\u7528\u5E73\u53F0\u8FD4\u56DE\u7684\u6570\u5B57 ID \u6216 flow<number>\uFF1B\u521B\u5EFA\u524D\u4F7F\u7528 new-flow:<name>\uFF0C\u521B\u5EFA\u540E\u56DE\u586B\u771F\u5B9E flow_type\u3002" }
|
|
24935
25516
|
);
|
|
24936
25517
|
}
|
|
24937
25518
|
}
|
|
24938
25519
|
async function readTaskbookText(file) {
|
|
24939
|
-
const raw = await
|
|
25520
|
+
const raw = await readFile17(file, "utf8");
|
|
24940
25521
|
try {
|
|
24941
25522
|
const parsed = JSON.parse(raw);
|
|
24942
25523
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -24963,7 +25544,7 @@ function findNavigationStrategy(text5) {
|
|
|
24963
25544
|
const matches = [...text5.matchAll(/导航入口策略\s*[::]\s*(nav-config:(?:included|skipped:[^\s|,。]+|deferred:[^\s|,。]+))/gi)];
|
|
24964
25545
|
return matches.at(-1)?.[1] || null;
|
|
24965
25546
|
}
|
|
24966
|
-
function validateNavigationStrategy(text5, issues,
|
|
25547
|
+
function validateNavigationStrategy(text5, issues, path17, subject) {
|
|
24967
25548
|
const strategy = findNavigationStrategy(text5);
|
|
24968
25549
|
if (!strategy) {
|
|
24969
25550
|
addTaskbookIssue(
|
|
@@ -24971,7 +25552,7 @@ function validateNavigationStrategy(text5, issues, path16, subject) {
|
|
|
24971
25552
|
"missing_navigation_strategy",
|
|
24972
25553
|
"taskbook.nav.strategy",
|
|
24973
25554
|
`${subject}\u7F3A\u5C11\u660E\u786E\u7684\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u3002`,
|
|
24974
|
-
{ path:
|
|
25555
|
+
{ path: path17, suggestion: "\u5199\u660E \u5BFC\u822A\u5165\u53E3\u7B56\u7565\uFF1Anav-config:included\u3001nav-config:skipped:<reason> \u6216 nav-config:deferred:<reason>\u3002" }
|
|
24975
25556
|
);
|
|
24976
25557
|
return null;
|
|
24977
25558
|
}
|
|
@@ -24981,7 +25562,7 @@ function validateNavigationStrategy(text5, issues, path16, subject) {
|
|
|
24981
25562
|
"empty_navigation_strategy_reason",
|
|
24982
25563
|
"taskbook.nav.strategy_reason",
|
|
24983
25564
|
`${subject}\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u8DF3\u8FC7\u6216\u5EF6\u540E\u65F6\u5FC5\u987B\u5199\u660E\u539F\u56E0\u3002`,
|
|
24984
|
-
{ path:
|
|
25565
|
+
{ path: path17, suggestion: "\u4F7F\u7528 nav-config:skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 nav-config:deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
|
|
24985
25566
|
);
|
|
24986
25567
|
}
|
|
24987
25568
|
if (/(待完成范围确认后回填|待确认|TODO|TBD|占位)/i.test(strategy)) {
|
|
@@ -24990,7 +25571,7 @@ function validateNavigationStrategy(text5, issues, path16, subject) {
|
|
|
24990
25571
|
"placeholder_navigation_strategy",
|
|
24991
25572
|
"taskbook.nav.strategy_placeholder",
|
|
24992
25573
|
`${subject}\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u4ECD\u662F\u5360\u4F4D\u5185\u5BB9\u3002`,
|
|
24993
|
-
{ path:
|
|
25574
|
+
{ path: path17, suggestion: "\u66FF\u6362\u4E3A included\u3001skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
|
|
24994
25575
|
);
|
|
24995
25576
|
}
|
|
24996
25577
|
return strategy;
|
|
@@ -25467,6 +26048,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
|
|
|
25467
26048
|
"- \u6BCF\u4E2A\u4EFB\u52A1\u7684 `business_goal` \u90FD\u5FC5\u987B\u5199\u6E05\u695A\u4E1A\u52A1\u76EE\u6807\u573A\u666F\u3002",
|
|
25468
26049
|
"- \u6BCF\u4E2A\u4EFB\u52A1\u7684 `required_skills` \u90FD\u5FC5\u987B\u5217\u51FA\u5B9E\u9645\u8981\u4F7F\u7528\u7684 BPMAX skill\u3002",
|
|
25469
26050
|
"- \u6BCF\u4E2A\u5199\u4EFB\u52A1\u7684 `evidence` \u6216 `notes` \u5FC5\u987B\u5305\u542B `bpmax-cli config adapters --format json` \u7684 capability/adapter \u68C0\u67E5\uFF0C\u4EE5\u53CA\u5BF9\u5E94 typed CLI lint/build/submit/verify\u3002",
|
|
26051
|
+
"- \u5B57\u6BB5\u3001\u7A33\u5B9A key\u3001\u503C\u7C7B\u578B\u3001\u6743\u9650\u3001\u811A\u672C\u3001\u6570\u636E\u6765\u6E90\u6216\u6A21\u677F\u7ED1\u5B9A\u53D1\u751F\u53D8\u5316\u65F6\uFF0C\u5199\u4EFB\u52A1\u8FD8\u5FC5\u987B\u5305\u542B `bpmax-cli config <domain> impact --raw <raw> --work <work>`\uFF0C\u5E76\u5206\u7C7B\u8BB0\u5F55 checked-and-compatible\u3001required-collateral\u3001recommended-next-step \u548C unverified\u3002",
|
|
25470
26052
|
"",
|
|
25471
26053
|
"## \u8FDB\u5EA6 CSV",
|
|
25472
26054
|
"",
|
|
@@ -25508,7 +26090,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
|
|
|
25508
26090
|
}
|
|
25509
26091
|
async function initTaskbook(outFile, title) {
|
|
25510
26092
|
const content = taskbookTemplate(title);
|
|
25511
|
-
await mkdir12(
|
|
26093
|
+
await mkdir12(path14.dirname(outFile), { recursive: true });
|
|
25512
26094
|
await writeFile12(outFile, content, "utf8");
|
|
25513
26095
|
return { out: outFile, bytes: Buffer.byteLength(content) };
|
|
25514
26096
|
}
|
|
@@ -25598,7 +26180,7 @@ async function initTaskbookProgress(source, outFile) {
|
|
|
25598
26180
|
fields.join(","),
|
|
25599
26181
|
...rows2.map((row) => fields.map((field) => csvEscape(field === "status" ? "\u672A\u5F00\u59CB" : row[field] || "")).join(","))
|
|
25600
26182
|
].join("\n") + "\n";
|
|
25601
|
-
await mkdir12(
|
|
26183
|
+
await mkdir12(path14.dirname(outFile), { recursive: true });
|
|
25602
26184
|
await writeFile12(outFile, csv, "utf8");
|
|
25603
26185
|
return { source, out: outFile, task_count: rows2.length };
|
|
25604
26186
|
}
|
|
@@ -25641,12 +26223,15 @@ function registerTaskbookCommands(program2) {
|
|
|
25641
26223
|
}
|
|
25642
26224
|
|
|
25643
26225
|
// src/commands/test-suite.ts
|
|
25644
|
-
import { readFile as
|
|
25645
|
-
import
|
|
26226
|
+
import { readFile as readFile18 } from "fs/promises";
|
|
26227
|
+
import path15 from "path";
|
|
26228
|
+
function effectiveProfileOption(options, command) {
|
|
26229
|
+
return options.profile || command.optsWithGlobals().profile;
|
|
26230
|
+
}
|
|
25646
26231
|
async function resolveE2eSkillSource(sourceSkill) {
|
|
25647
26232
|
if (sourceSkill) {
|
|
25648
|
-
const resolved =
|
|
25649
|
-
const content = await
|
|
26233
|
+
const resolved = path15.resolve(sourceSkill);
|
|
26234
|
+
const content = await readFile18(resolved, "utf8").catch(() => "");
|
|
25650
26235
|
if (!content.includes('name: "bpmax-e2e-flow-test-operator"') && !content.includes("name: bpmax-e2e-flow-test-operator")) {
|
|
25651
26236
|
throw new TestSuiteError("source skill is not bpmax-e2e-flow-test-operator", {
|
|
25652
26237
|
rule_id: "test_suite.run.skill_source_invalid",
|
|
@@ -25684,9 +26269,9 @@ function registerTestSuiteCommands(program2) {
|
|
|
25684
26269
|
printResult(options.format, await migrateScenarioSteps(options));
|
|
25685
26270
|
});
|
|
25686
26271
|
const run = suite.command("run").description("Run formal E2E cases through an execution manifest");
|
|
25687
|
-
run.command("start").description("Start one formal suite case and create its report execution manifest").requiredOption("--scenario <id>", "Scenario id").requiredOption("--case-id <id>", "Case id").option("--suite-root <path>", "Formal suite root directory", DEFAULT_SUITE_ROOT).option("--report-root <path>", "Report root directory", DEFAULT_REPORT_ROOT).option("--profile <profile>", "Profile name").option("--source-skill <path>", "Explicit source bpmax-e2e-flow-test-operator SKILL.md for source validation").requiredOption("--latest-proof <path>", "latest-* proof JSON written after syncing the sysconfig repo").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
26272
|
+
run.command("start").description("Start one formal suite case and create its report execution manifest").requiredOption("--scenario <id>", "Scenario id").requiredOption("--case-id <id>", "Case id").option("--suite-root <path>", "Formal suite root directory", DEFAULT_SUITE_ROOT).option("--report-root <path>", "Report root directory", DEFAULT_REPORT_ROOT).option("--profile <profile>", "Profile name").option("--source-skill <path>", "Explicit source bpmax-e2e-flow-test-operator SKILL.md for source validation").requiredOption("--latest-proof <path>", "latest-* proof JSON written after syncing the sysconfig repo").option("--format <format>", "Output format", "json").action(async (options, command) => {
|
|
25688
26273
|
await requireLatestProof(options.latestProof);
|
|
25689
|
-
const profile = resolveProfile(await loadConfig(), options
|
|
26274
|
+
const profile = resolveProfile(await loadConfig(), effectiveProfileOption(options, command));
|
|
25690
26275
|
const skill = await resolveE2eSkillSource(options.sourceSkill);
|
|
25691
26276
|
printResult(options.format, await startTestSuiteRun({
|
|
25692
26277
|
...options,
|
|
@@ -25696,17 +26281,20 @@ function registerTestSuiteCommands(program2) {
|
|
|
25696
26281
|
skillVersion: skill.version
|
|
25697
26282
|
}));
|
|
25698
26283
|
});
|
|
25699
|
-
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) => {
|
|
25700
|
-
printResult(options.format, await nextTestSuiteRunStep(options.manifest, options
|
|
26284
|
+
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, command) => {
|
|
26285
|
+
printResult(options.format, await nextTestSuiteRunStep(options.manifest, effectiveProfileOption(options, command)));
|
|
25701
26286
|
});
|
|
25702
|
-
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) => {
|
|
25703
|
-
printResult(options.format, await recordTestSuiteRunStep(
|
|
26287
|
+
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, command) => {
|
|
26288
|
+
printResult(options.format, await recordTestSuiteRunStep({
|
|
26289
|
+
...options,
|
|
26290
|
+
profile: effectiveProfileOption(options, command)
|
|
26291
|
+
}));
|
|
25704
26292
|
});
|
|
25705
26293
|
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) => {
|
|
25706
26294
|
printResult(options.format, await syncTestSuiteRunReport(options.manifest));
|
|
25707
26295
|
});
|
|
25708
|
-
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) => {
|
|
25709
|
-
printResult(options.format, await testSuiteRunStatus(options.manifest, options
|
|
26296
|
+
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, command) => {
|
|
26297
|
+
printResult(options.format, await testSuiteRunStatus(options.manifest, effectiveProfileOption(options, command)));
|
|
25710
26298
|
});
|
|
25711
26299
|
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) => {
|
|
25712
26300
|
printResult(options.format, await initOrRepairReview({ ...options, repair: true }));
|
|
@@ -25737,8 +26325,8 @@ function registerTestSuiteCommands(program2) {
|
|
|
25737
26325
|
}
|
|
25738
26326
|
|
|
25739
26327
|
// src/core/update.ts
|
|
25740
|
-
import { access as access2, mkdir as mkdir13, readFile as
|
|
25741
|
-
import
|
|
26328
|
+
import { access as access2, mkdir as mkdir13, readFile as readFile19, realpath as realpath3, writeFile as writeFile13 } from "fs/promises";
|
|
26329
|
+
import path16 from "path";
|
|
25742
26330
|
var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
25743
26331
|
var UPDATE_STATE_FILE = "update-state.json";
|
|
25744
26332
|
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -25854,11 +26442,11 @@ async function fetchLatestVersion(options = {}) {
|
|
|
25854
26442
|
}
|
|
25855
26443
|
}
|
|
25856
26444
|
function updateStatePath(configDir = getConfigDir()) {
|
|
25857
|
-
return
|
|
26445
|
+
return path16.join(configDir, UPDATE_STATE_FILE);
|
|
25858
26446
|
}
|
|
25859
26447
|
async function readUpdateState(configDir) {
|
|
25860
26448
|
try {
|
|
25861
|
-
const raw = await
|
|
26449
|
+
const raw = await readFile19(updateStatePath(configDir), "utf8");
|
|
25862
26450
|
const parsed = JSON.parse(raw);
|
|
25863
26451
|
if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
|
|
25864
26452
|
return null;
|
|
@@ -25935,7 +26523,7 @@ async function findNpmPath() {
|
|
|
25935
26523
|
}
|
|
25936
26524
|
function detectInstallMethod(input) {
|
|
25937
26525
|
const resolvedPath = input.executablePath || "";
|
|
25938
|
-
const method = resolvedPath.includes(`node_modules${
|
|
26526
|
+
const method = resolvedPath.includes(`node_modules${path16.sep}`) || resolvedPath.includes("node_modules/") ? "npm" : "manual";
|
|
25939
26527
|
return {
|
|
25940
26528
|
method,
|
|
25941
26529
|
resolvedPath,
|
|
@@ -26176,17 +26764,17 @@ function registerUrlCommands(program2, deps = {}) {
|
|
|
26176
26764
|
}
|
|
26177
26765
|
|
|
26178
26766
|
// src/commands/user.ts
|
|
26179
|
-
function
|
|
26767
|
+
function isRecord16(value) {
|
|
26180
26768
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26181
26769
|
}
|
|
26182
26770
|
function userRows(value) {
|
|
26183
|
-
if (Array.isArray(value)) return value.filter(
|
|
26184
|
-
if (!
|
|
26185
|
-
if (Array.isArray(value.data)) return value.data.filter(
|
|
26771
|
+
if (Array.isArray(value)) return value.filter(isRecord16);
|
|
26772
|
+
if (!isRecord16(value)) return [];
|
|
26773
|
+
if (Array.isArray(value.data)) return value.data.filter(isRecord16);
|
|
26186
26774
|
return value.id ? [value] : [];
|
|
26187
26775
|
}
|
|
26188
26776
|
function safeUser2(user) {
|
|
26189
|
-
const roles = Array.isArray(user.role) ? user.role.filter(
|
|
26777
|
+
const roles = Array.isArray(user.role) ? user.role.filter(isRecord16).map((role) => ({
|
|
26190
26778
|
id: role.id,
|
|
26191
26779
|
key: role.key,
|
|
26192
26780
|
name: role.name
|