bpmax-cli 0.2.1-beta.37 → 0.2.1-beta.38
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 +1059 -503
- 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-filter-template-editor/SKILL.md +4 -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.38",
|
|
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
|
}
|
|
@@ -7855,6 +7890,7 @@ function normalizeFlowTemplatePayload(work) {
|
|
|
7855
7890
|
validateFlowTemplateProjectAfterCreatePath({ ...work, data });
|
|
7856
7891
|
validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
|
|
7857
7892
|
validateFlowTemplateStartConditionalJump({ ...work, data });
|
|
7893
|
+
validateFlowTemplatePostCreateInitiatorStep({ ...work, data });
|
|
7858
7894
|
validateFlowTemplateApproveActionShape({ ...work, data });
|
|
7859
7895
|
validateFlowTemplatePluginRejectionControl({ ...work, data });
|
|
7860
7896
|
validateFlowTemplateStandardConditionEditorRules({ ...work, data });
|
|
@@ -11767,24 +11803,24 @@ function normalizeTypedReadbackComparable(domain, value) {
|
|
|
11767
11803
|
}
|
|
11768
11804
|
function jsonSubsetMismatches(expected, actual) {
|
|
11769
11805
|
const mismatches = [];
|
|
11770
|
-
const compare = (left, right,
|
|
11806
|
+
const compare = (left, right, path17 = "") => {
|
|
11771
11807
|
if (Array.isArray(left)) {
|
|
11772
11808
|
if (!Array.isArray(right) || left.length !== right.length) {
|
|
11773
|
-
mismatches.push(
|
|
11809
|
+
mismatches.push(path17 || "/");
|
|
11774
11810
|
return;
|
|
11775
11811
|
}
|
|
11776
|
-
left.forEach((item, index) => compare(item, right[index], `${
|
|
11812
|
+
left.forEach((item, index) => compare(item, right[index], `${path17}/${index}`));
|
|
11777
11813
|
return;
|
|
11778
11814
|
}
|
|
11779
11815
|
if (isRecord3(left)) {
|
|
11780
11816
|
if (!isRecord3(right)) {
|
|
11781
|
-
mismatches.push(
|
|
11817
|
+
mismatches.push(path17 || "/");
|
|
11782
11818
|
return;
|
|
11783
11819
|
}
|
|
11784
|
-
for (const [key, item] of Object.entries(left)) compare(item, right[key], `${
|
|
11820
|
+
for (const [key, item] of Object.entries(left)) compare(item, right[key], `${path17}/${key}`);
|
|
11785
11821
|
return;
|
|
11786
11822
|
}
|
|
11787
|
-
if (JSON.stringify(left) !== JSON.stringify(right)) mismatches.push(
|
|
11823
|
+
if (JSON.stringify(left) !== JSON.stringify(right)) mismatches.push(path17 || "/");
|
|
11788
11824
|
};
|
|
11789
11825
|
compare(expected, actual);
|
|
11790
11826
|
return mismatches;
|
|
@@ -12702,6 +12738,7 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
12702
12738
|
validateFlowTemplateProjectAfterCreatePath(flowWork, errors);
|
|
12703
12739
|
validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
|
|
12704
12740
|
validateFlowTemplateStartConditionalJump(flowWork, errors);
|
|
12741
|
+
validateFlowTemplatePostCreateInitiatorStep(flowWork, errors);
|
|
12705
12742
|
validateFlowTemplateApproveActionShape(flowWork, errors);
|
|
12706
12743
|
validateFlowTemplatePluginRejectionControl(flowWork, errors);
|
|
12707
12744
|
validateFlowTemplateStandardConditionEditorRules(flowWork, errors);
|
|
@@ -13822,9 +13859,504 @@ async function runConfigBatchReadback(config, profile, manifestFile, options = {
|
|
|
13822
13859
|
};
|
|
13823
13860
|
}
|
|
13824
13861
|
|
|
13825
|
-
// src/core/config-
|
|
13826
|
-
import {
|
|
13862
|
+
// src/core/config-impact.ts
|
|
13863
|
+
import { readdir as readdir3, readFile as readFile9, stat as stat4 } from "fs/promises";
|
|
13827
13864
|
import path6 from "path";
|
|
13865
|
+
var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13866
|
+
var HIGH_RISK_CHANGES = /* @__PURE__ */ new Set([
|
|
13867
|
+
"removed",
|
|
13868
|
+
"renamed",
|
|
13869
|
+
"type_changed",
|
|
13870
|
+
"behavior_changed"
|
|
13871
|
+
]);
|
|
13872
|
+
var GENERIC_IDENTIFIERS = /* @__PURE__ */ new Set([
|
|
13873
|
+
"id",
|
|
13874
|
+
"key",
|
|
13875
|
+
"name",
|
|
13876
|
+
"title",
|
|
13877
|
+
"value",
|
|
13878
|
+
"field",
|
|
13879
|
+
"data",
|
|
13880
|
+
"status",
|
|
13881
|
+
"type",
|
|
13882
|
+
"project"
|
|
13883
|
+
]);
|
|
13884
|
+
var RECOMMENDED_SURFACES = {
|
|
13885
|
+
"form-template": [
|
|
13886
|
+
"dataset-field",
|
|
13887
|
+
"dataset",
|
|
13888
|
+
"list-template",
|
|
13889
|
+
"filter-template",
|
|
13890
|
+
"project-detail-template",
|
|
13891
|
+
"step-detail-template",
|
|
13892
|
+
"flow-template",
|
|
13893
|
+
"console-template",
|
|
13894
|
+
"runtime-script",
|
|
13895
|
+
"e2e"
|
|
13896
|
+
],
|
|
13897
|
+
"dataset-field": [
|
|
13898
|
+
"dataset",
|
|
13899
|
+
"list-template",
|
|
13900
|
+
"filter-template",
|
|
13901
|
+
"project-detail-template",
|
|
13902
|
+
"step-detail-template",
|
|
13903
|
+
"console-template",
|
|
13904
|
+
"runtime-script",
|
|
13905
|
+
"e2e"
|
|
13906
|
+
],
|
|
13907
|
+
dataset: [
|
|
13908
|
+
"list-template",
|
|
13909
|
+
"filter-template",
|
|
13910
|
+
"project-detail-template",
|
|
13911
|
+
"step-detail-template",
|
|
13912
|
+
"console-template",
|
|
13913
|
+
"nav-config",
|
|
13914
|
+
"runtime-script",
|
|
13915
|
+
"e2e"
|
|
13916
|
+
],
|
|
13917
|
+
"list-template": ["filter-template", "nav-config", "runtime-script", "e2e"],
|
|
13918
|
+
"filter-template": ["list-template", "nav-config", "runtime-script", "e2e"],
|
|
13919
|
+
"project-detail-template": ["flow-template", "runtime-script", "e2e"],
|
|
13920
|
+
"step-detail-template": ["flow-template", "runtime-script", "e2e"],
|
|
13921
|
+
"flow-detail-template": ["flow-template", "runtime-script", "e2e"],
|
|
13922
|
+
"console-template": ["dataset", "filter-template", "nav-config", "runtime-script", "e2e"],
|
|
13923
|
+
"flow-template": [
|
|
13924
|
+
"form-template",
|
|
13925
|
+
"dataset-field",
|
|
13926
|
+
"dataset",
|
|
13927
|
+
"list-template",
|
|
13928
|
+
"filter-template",
|
|
13929
|
+
"project-detail-template",
|
|
13930
|
+
"step-detail-template",
|
|
13931
|
+
"nav-config",
|
|
13932
|
+
"runtime-script",
|
|
13933
|
+
"e2e"
|
|
13934
|
+
],
|
|
13935
|
+
"nav-config": ["flow-template", "list-template", "filter-template", "console-template", "e2e"]
|
|
13936
|
+
};
|
|
13937
|
+
var BEHAVIOR_KEYS = /* @__PURE__ */ new Set([
|
|
13938
|
+
"hidden",
|
|
13939
|
+
"display",
|
|
13940
|
+
"disabled",
|
|
13941
|
+
"readonly",
|
|
13942
|
+
"required",
|
|
13943
|
+
"validate",
|
|
13944
|
+
"validatemap",
|
|
13945
|
+
"lambda",
|
|
13946
|
+
"customevalidate",
|
|
13947
|
+
"visibilitycondition",
|
|
13948
|
+
"disabledcondition",
|
|
13949
|
+
"requiredcondition",
|
|
13950
|
+
"defaultvalue"
|
|
13951
|
+
]);
|
|
13952
|
+
function stableString(value) {
|
|
13953
|
+
if (typeof value === "string") {
|
|
13954
|
+
return value.trim();
|
|
13955
|
+
}
|
|
13956
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
13957
|
+
return String(value);
|
|
13958
|
+
}
|
|
13959
|
+
return "";
|
|
13960
|
+
}
|
|
13961
|
+
function normalizeComparable(value) {
|
|
13962
|
+
if (Array.isArray(value)) {
|
|
13963
|
+
return `[${value.map(normalizeComparable).join(",")}]`;
|
|
13964
|
+
}
|
|
13965
|
+
if (isRecord4(value)) {
|
|
13966
|
+
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${normalizeComparable(value[key])}`).join(",")}}`;
|
|
13967
|
+
}
|
|
13968
|
+
return JSON.stringify(value);
|
|
13969
|
+
}
|
|
13970
|
+
function collectFieldIdentities(value) {
|
|
13971
|
+
const entries = [];
|
|
13972
|
+
const visited = /* @__PURE__ */ new Set();
|
|
13973
|
+
const visit = (current, currentPath) => {
|
|
13974
|
+
if (Array.isArray(current)) {
|
|
13975
|
+
current.forEach((item, index) => visit(item, `${currentPath}[${index}]`));
|
|
13976
|
+
return;
|
|
13977
|
+
}
|
|
13978
|
+
if (!isRecord4(current) || visited.has(current)) {
|
|
13979
|
+
return;
|
|
13980
|
+
}
|
|
13981
|
+
visited.add(current);
|
|
13982
|
+
const field = stableString(current.field);
|
|
13983
|
+
const key = stableString(current.key);
|
|
13984
|
+
if (field || key) {
|
|
13985
|
+
const type = stableString(current.type) || stableString(current.field_type);
|
|
13986
|
+
entries.push({
|
|
13987
|
+
identity: field || key,
|
|
13988
|
+
field,
|
|
13989
|
+
key,
|
|
13990
|
+
type,
|
|
13991
|
+
path: currentPath,
|
|
13992
|
+
value: current
|
|
13993
|
+
});
|
|
13994
|
+
}
|
|
13995
|
+
for (const [keyName, child] of Object.entries(current)) {
|
|
13996
|
+
if (Array.isArray(child) || isRecord4(child)) {
|
|
13997
|
+
visit(child, currentPath ? `${currentPath}.${keyName}` : keyName);
|
|
13998
|
+
}
|
|
13999
|
+
}
|
|
14000
|
+
};
|
|
14001
|
+
visit(value, "");
|
|
14002
|
+
return entries;
|
|
14003
|
+
}
|
|
14004
|
+
function hasBehaviorChange(before, after) {
|
|
14005
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)]);
|
|
14006
|
+
for (const key of keys) {
|
|
14007
|
+
if (!BEHAVIOR_KEYS.has(key.toLowerCase())) {
|
|
14008
|
+
continue;
|
|
14009
|
+
}
|
|
14010
|
+
if (JSON.stringify(before[key]) !== JSON.stringify(after[key])) {
|
|
14011
|
+
return true;
|
|
14012
|
+
}
|
|
14013
|
+
}
|
|
14014
|
+
return false;
|
|
14015
|
+
}
|
|
14016
|
+
function addIdentifier(target, item) {
|
|
14017
|
+
const value = item.identifier.trim();
|
|
14018
|
+
if (value.length < 3 || GENERIC_IDENTIFIERS.has(value.toLowerCase())) {
|
|
14019
|
+
return;
|
|
14020
|
+
}
|
|
14021
|
+
const key = `${value}\0${item.change}\0${item.previous || ""}\0${item.current || ""}`;
|
|
14022
|
+
if (!target.has(key)) {
|
|
14023
|
+
target.set(key, { ...item, identifier: value });
|
|
14024
|
+
}
|
|
14025
|
+
}
|
|
14026
|
+
function collectChangedIdentifiers(raw, work) {
|
|
14027
|
+
const result = /* @__PURE__ */ new Map();
|
|
14028
|
+
const beforeEntries = collectFieldIdentities(raw);
|
|
14029
|
+
const afterEntries = collectFieldIdentities(work);
|
|
14030
|
+
const beforeByIdentity = new Map(beforeEntries.map((item) => [item.identity, item]));
|
|
14031
|
+
const afterByIdentity = new Map(afterEntries.map((item) => [item.identity, item]));
|
|
14032
|
+
for (const before of beforeEntries) {
|
|
14033
|
+
const after = afterByIdentity.get(before.identity);
|
|
14034
|
+
if (!after) {
|
|
14035
|
+
for (const identifier of [before.field, before.key]) {
|
|
14036
|
+
addIdentifier(result, { identifier, change: "removed", path: before.path, previous: identifier });
|
|
14037
|
+
}
|
|
14038
|
+
continue;
|
|
14039
|
+
}
|
|
14040
|
+
if (before.key && after.key && before.key !== after.key) {
|
|
14041
|
+
addIdentifier(result, {
|
|
14042
|
+
identifier: before.key,
|
|
14043
|
+
change: "renamed",
|
|
14044
|
+
path: after.path,
|
|
14045
|
+
previous: before.key,
|
|
14046
|
+
current: after.key
|
|
14047
|
+
});
|
|
14048
|
+
addIdentifier(result, {
|
|
14049
|
+
identifier: after.key,
|
|
14050
|
+
change: "renamed",
|
|
14051
|
+
path: after.path,
|
|
14052
|
+
previous: before.key,
|
|
14053
|
+
current: after.key
|
|
14054
|
+
});
|
|
14055
|
+
}
|
|
14056
|
+
if (before.type !== after.type) {
|
|
14057
|
+
for (const identifier of [after.field, after.key, before.field, before.key]) {
|
|
14058
|
+
addIdentifier(result, {
|
|
14059
|
+
identifier,
|
|
14060
|
+
change: "type_changed",
|
|
14061
|
+
path: after.path,
|
|
14062
|
+
previous: before.type,
|
|
14063
|
+
current: after.type
|
|
14064
|
+
});
|
|
14065
|
+
}
|
|
14066
|
+
} else if (hasBehaviorChange(before.value, after.value)) {
|
|
14067
|
+
for (const identifier of [after.field, after.key]) {
|
|
14068
|
+
addIdentifier(result, { identifier, change: "behavior_changed", path: after.path });
|
|
14069
|
+
}
|
|
14070
|
+
} else if (normalizeComparable(before.value) !== normalizeComparable(after.value)) {
|
|
14071
|
+
for (const identifier of [after.field, after.key]) {
|
|
14072
|
+
addIdentifier(result, { identifier, change: "modified", path: after.path });
|
|
14073
|
+
}
|
|
14074
|
+
}
|
|
14075
|
+
}
|
|
14076
|
+
for (const after of afterEntries) {
|
|
14077
|
+
if (beforeByIdentity.has(after.identity)) {
|
|
14078
|
+
continue;
|
|
14079
|
+
}
|
|
14080
|
+
for (const identifier of [after.field, after.key]) {
|
|
14081
|
+
addIdentifier(result, { identifier, change: "added", path: after.path, current: identifier });
|
|
14082
|
+
}
|
|
14083
|
+
}
|
|
14084
|
+
const identifierKeys = /* @__PURE__ */ new Set([
|
|
14085
|
+
"field",
|
|
14086
|
+
"key",
|
|
14087
|
+
"id",
|
|
14088
|
+
"flow_type",
|
|
14089
|
+
"flow_key",
|
|
14090
|
+
"custom_key",
|
|
14091
|
+
"data_set_key",
|
|
14092
|
+
"data_set_id",
|
|
14093
|
+
"dataset_id",
|
|
14094
|
+
"source_field",
|
|
14095
|
+
"source_table",
|
|
14096
|
+
"form_template",
|
|
14097
|
+
"form_template_id",
|
|
14098
|
+
"table_list_template",
|
|
14099
|
+
"table_filter_template",
|
|
14100
|
+
"step_detail_id",
|
|
14101
|
+
"search_temp_id"
|
|
14102
|
+
]);
|
|
14103
|
+
const recordIdentifiers = (record) => [...new Set(
|
|
14104
|
+
Object.entries(record).filter(([key]) => identifierKeys.has(key.toLowerCase())).map(([, value]) => stableString(value)).filter(Boolean)
|
|
14105
|
+
)];
|
|
14106
|
+
const visitDifference = (before, after, currentPath) => {
|
|
14107
|
+
if (normalizeComparable(before) === normalizeComparable(after)) {
|
|
14108
|
+
return;
|
|
14109
|
+
}
|
|
14110
|
+
if (Array.isArray(before) || Array.isArray(after)) {
|
|
14111
|
+
const beforeArray = Array.isArray(before) ? before : [];
|
|
14112
|
+
const afterArray = Array.isArray(after) ? after : [];
|
|
14113
|
+
const length = Math.max(beforeArray.length, afterArray.length);
|
|
14114
|
+
for (let index = 0; index < length; index += 1) {
|
|
14115
|
+
visitDifference(beforeArray[index], afterArray[index], `${currentPath}[${index}]`);
|
|
14116
|
+
}
|
|
14117
|
+
return;
|
|
14118
|
+
}
|
|
14119
|
+
if (isRecord4(before) || isRecord4(after)) {
|
|
14120
|
+
const beforeRecord = isRecord4(before) ? before : {};
|
|
14121
|
+
const afterRecord = isRecord4(after) ? after : {};
|
|
14122
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(beforeRecord), ...Object.keys(afterRecord)]);
|
|
14123
|
+
for (const key of keys) {
|
|
14124
|
+
const beforeValue = beforeRecord[key];
|
|
14125
|
+
const afterValue = afterRecord[key];
|
|
14126
|
+
if (normalizeComparable(beforeValue) === normalizeComparable(afterValue)) {
|
|
14127
|
+
continue;
|
|
14128
|
+
}
|
|
14129
|
+
const changePath = currentPath ? `${currentPath}.${key}` : key;
|
|
14130
|
+
if (identifierKeys.has(key.toLowerCase())) {
|
|
14131
|
+
const previous = stableString(beforeValue);
|
|
14132
|
+
const current = stableString(afterValue);
|
|
14133
|
+
const change = previous && current && previous !== current ? "renamed" : previous ? "removed" : "added";
|
|
14134
|
+
for (const identifier of [previous, current]) {
|
|
14135
|
+
addIdentifier(result, { identifier, change, path: changePath, previous, current });
|
|
14136
|
+
}
|
|
14137
|
+
} else if (!Array.isArray(beforeValue) && !Array.isArray(afterValue) && !isRecord4(beforeValue) && !isRecord4(afterValue)) {
|
|
14138
|
+
const lowerKey = key.toLowerCase();
|
|
14139
|
+
const change = lowerKey === "type" || lowerKey === "field_type" ? "type_changed" : BEHAVIOR_KEYS.has(lowerKey) || /script|condition|owner|permission|template|mapping/.test(lowerKey) ? "behavior_changed" : "modified";
|
|
14140
|
+
for (const identifier of [...recordIdentifiers(beforeRecord), ...recordIdentifiers(afterRecord)]) {
|
|
14141
|
+
addIdentifier(result, { identifier, change, path: changePath });
|
|
14142
|
+
}
|
|
14143
|
+
}
|
|
14144
|
+
visitDifference(beforeValue, afterValue, changePath);
|
|
14145
|
+
}
|
|
14146
|
+
}
|
|
14147
|
+
};
|
|
14148
|
+
visitDifference(raw, work, "");
|
|
14149
|
+
const highRiskIdentifiers = new Set(
|
|
14150
|
+
[...result.values()].filter((item) => HIGH_RISK_CHANGES.has(item.change)).map((item) => item.identifier)
|
|
14151
|
+
);
|
|
14152
|
+
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));
|
|
14153
|
+
}
|
|
14154
|
+
function pageTemplateDomain(content) {
|
|
14155
|
+
try {
|
|
14156
|
+
const parsed = JSON.parse(content);
|
|
14157
|
+
if (!isRecord4(parsed)) {
|
|
14158
|
+
return void 0;
|
|
14159
|
+
}
|
|
14160
|
+
const basic = isRecord4(parsed.basic) ? parsed.basic : {};
|
|
14161
|
+
const rawType = parsed.type ?? basic.type;
|
|
14162
|
+
const templateType = typeof rawType === "number" ? rawType : Number(String(rawType || ""));
|
|
14163
|
+
const domains = {
|
|
14164
|
+
1: "list-template",
|
|
14165
|
+
2: "project-detail-template",
|
|
14166
|
+
3: "filter-template",
|
|
14167
|
+
4: "console-template",
|
|
14168
|
+
5: "flow-detail-template",
|
|
14169
|
+
6: "step-detail-template"
|
|
14170
|
+
};
|
|
14171
|
+
return domains[templateType];
|
|
14172
|
+
} catch {
|
|
14173
|
+
return void 0;
|
|
14174
|
+
}
|
|
14175
|
+
}
|
|
14176
|
+
async function configDomainForPath(relativeFile, absoluteFile, content, pageTemplateDomainCache) {
|
|
14177
|
+
const directory = relativeFile.split(path6.sep)[0];
|
|
14178
|
+
if (directory === "think_flow_page_template") {
|
|
14179
|
+
const inlineDomain = pageTemplateDomain(content);
|
|
14180
|
+
if (inlineDomain) {
|
|
14181
|
+
return inlineDomain;
|
|
14182
|
+
}
|
|
14183
|
+
const templateDirectory = path6.dirname(absoluteFile);
|
|
14184
|
+
const cached = pageTemplateDomainCache.get(templateDirectory);
|
|
14185
|
+
if (cached) {
|
|
14186
|
+
return cached;
|
|
14187
|
+
}
|
|
14188
|
+
try {
|
|
14189
|
+
const mainContent = await readFile9(path6.join(templateDirectory, "flow_page_template"), "utf8");
|
|
14190
|
+
const siblingDomain = pageTemplateDomain(mainContent) || "page-template";
|
|
14191
|
+
pageTemplateDomainCache.set(templateDirectory, siblingDomain);
|
|
14192
|
+
return siblingDomain;
|
|
14193
|
+
} catch {
|
|
14194
|
+
return "page-template";
|
|
14195
|
+
}
|
|
14196
|
+
}
|
|
14197
|
+
const mapping = {
|
|
14198
|
+
think_form_template: "form-template",
|
|
14199
|
+
think_data_set_field: "dataset-field",
|
|
14200
|
+
think_data_set: "dataset",
|
|
14201
|
+
think_flow: "flow-template",
|
|
14202
|
+
think_configuration: "configuration",
|
|
14203
|
+
think_role: "role",
|
|
14204
|
+
think_workspace: "workspace",
|
|
14205
|
+
think_api_platform: "api-platform",
|
|
14206
|
+
think_api_proxy: "api-proxy"
|
|
14207
|
+
};
|
|
14208
|
+
return mapping[directory] || directory.replace(/^think_/, "").replaceAll("_", "-");
|
|
14209
|
+
}
|
|
14210
|
+
async function collectConfigFiles(root) {
|
|
14211
|
+
const entries = await readdir3(root, { withFileTypes: true });
|
|
14212
|
+
const directories = entries.filter((entry) => entry.isDirectory() && entry.name.startsWith("think_")).map((entry) => entry.name).sort();
|
|
14213
|
+
const files = [];
|
|
14214
|
+
const walk = async (directory) => {
|
|
14215
|
+
const children = await readdir3(directory, { withFileTypes: true });
|
|
14216
|
+
for (const child of children) {
|
|
14217
|
+
const absolute = path6.join(directory, child.name);
|
|
14218
|
+
if (child.isDirectory()) {
|
|
14219
|
+
await walk(absolute);
|
|
14220
|
+
} else if (child.isFile()) {
|
|
14221
|
+
files.push(absolute);
|
|
14222
|
+
}
|
|
14223
|
+
}
|
|
14224
|
+
};
|
|
14225
|
+
for (const directory of directories) {
|
|
14226
|
+
await walk(path6.join(root, directory));
|
|
14227
|
+
}
|
|
14228
|
+
return { directories, files };
|
|
14229
|
+
}
|
|
14230
|
+
function lineContainsIdentifier(line, identifier) {
|
|
14231
|
+
const escaped = identifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
14232
|
+
if (/^\d+$/.test(identifier)) {
|
|
14233
|
+
return new RegExp(`(^|\\D)${escaped}(?=\\D|$)`).test(line);
|
|
14234
|
+
}
|
|
14235
|
+
return new RegExp(`(^|[^A-Za-z0-9_])${escaped}(?=[^A-Za-z0-9_]|$)`).test(line);
|
|
14236
|
+
}
|
|
14237
|
+
function nextStepForDomain(domain) {
|
|
14238
|
+
const labels = {
|
|
14239
|
+
"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",
|
|
14240
|
+
dataset: "\u6838\u5BF9\u5B57\u6BB5\u5173\u8054\u3001\u5904\u7406\u811A\u672C\u3001ES mapping\u3001\u53D1\u5E03\u548C\u5237\u65B0\u72B6\u6001\u3002",
|
|
14241
|
+
"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",
|
|
14242
|
+
"filter-template": "\u6838\u5BF9\u7B5B\u9009\u5B57\u6BB5\u3001\u67E5\u8BE2\u503C\u5F62\u6001\u548C\u6837\u672C\u547D\u4E2D\u7ED3\u679C\u3002",
|
|
14243
|
+
"project-detail-template": "\u6838\u5BF9\u8BE6\u60C5\u6A21\u5757\u3001\u5B57\u6BB5\u5C55\u793A\u548C\u771F\u5B9E\u8BE6\u60C5\u9875\u3002",
|
|
14244
|
+
"step-detail-template": "\u6838\u5BF9\u73AF\u8282\u8BE6\u60C5\u6A21\u5757\u3001\u5B57\u6BB5\u5C55\u793A\u4EE5\u53CA\u8282\u70B9\u7ED1\u5B9A\u3002",
|
|
14245
|
+
"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",
|
|
14246
|
+
"console-template": "\u6838\u5BF9\u770B\u677F\u6A21\u5757\u3001\u6307\u6807\u811A\u672C\u548C\u6570\u636E\u96C6\u5B57\u6BB5\u7ED1\u5B9A\u3002",
|
|
14247
|
+
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",
|
|
14248
|
+
"nav-config": "\u6838\u5BF9\u5BFC\u822A\u5165\u53E3\u53C2\u6570\u548C\u76EE\u6807\u9875\u9762\u7ED1\u5B9A\u3002",
|
|
14249
|
+
"runtime-script": "\u6838\u5BF9\u811A\u672C\u4E2D\u7684\u5B57\u6BB5 key\u3001\u503C\u7C7B\u578B\u548C\u7A7A\u503C\u5904\u7406\u3002",
|
|
14250
|
+
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"
|
|
14251
|
+
};
|
|
14252
|
+
return labels[domain] || `\u6838\u5BF9 ${domain} \u4E2D\u7684\u5F15\u7528\u548C\u8FD0\u884C\u65F6\u884C\u4E3A\u3002`;
|
|
14253
|
+
}
|
|
14254
|
+
async function analyzeConfigImpact(options) {
|
|
14255
|
+
const workspaceRoot = path6.resolve(options.workspaceRoot);
|
|
14256
|
+
const changedIdentifiers = collectChangedIdentifiers(options.raw, options.work);
|
|
14257
|
+
const { directories, files } = await collectConfigFiles(workspaceRoot);
|
|
14258
|
+
const references = [];
|
|
14259
|
+
const referenceLimit = options.referenceLimit ?? 500;
|
|
14260
|
+
const maxFileBytes = options.maxFileBytes ?? 5 * 1024 * 1024;
|
|
14261
|
+
let scannedFiles = 0;
|
|
14262
|
+
let skippedLargeFiles = 0;
|
|
14263
|
+
let referenceLimitReached = false;
|
|
14264
|
+
const pageTemplateDomainCache = /* @__PURE__ */ new Map();
|
|
14265
|
+
for (const file of files) {
|
|
14266
|
+
if (!changedIdentifiers.length || references.length >= referenceLimit) {
|
|
14267
|
+
referenceLimitReached = references.length >= referenceLimit;
|
|
14268
|
+
break;
|
|
14269
|
+
}
|
|
14270
|
+
const fileStat = await stat4(file);
|
|
14271
|
+
if (fileStat.size > maxFileBytes) {
|
|
14272
|
+
skippedLargeFiles += 1;
|
|
14273
|
+
continue;
|
|
14274
|
+
}
|
|
14275
|
+
const content = await readFile9(file, "utf8");
|
|
14276
|
+
scannedFiles += 1;
|
|
14277
|
+
if (content.includes("\0")) {
|
|
14278
|
+
continue;
|
|
14279
|
+
}
|
|
14280
|
+
const lines = content.split(/\r?\n/);
|
|
14281
|
+
for (const changed of changedIdentifiers) {
|
|
14282
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
14283
|
+
if (!lineContainsIdentifier(lines[index], changed.identifier)) {
|
|
14284
|
+
continue;
|
|
14285
|
+
}
|
|
14286
|
+
const relativeFile = path6.relative(workspaceRoot, file);
|
|
14287
|
+
references.push({
|
|
14288
|
+
identifier: changed.identifier,
|
|
14289
|
+
config_domain: await configDomainForPath(relativeFile, file, content, pageTemplateDomainCache),
|
|
14290
|
+
file: relativeFile,
|
|
14291
|
+
line: index + 1
|
|
14292
|
+
});
|
|
14293
|
+
if (references.length >= referenceLimit) {
|
|
14294
|
+
referenceLimitReached = true;
|
|
14295
|
+
break;
|
|
14296
|
+
}
|
|
14297
|
+
}
|
|
14298
|
+
if (referenceLimitReached) {
|
|
14299
|
+
break;
|
|
14300
|
+
}
|
|
14301
|
+
}
|
|
14302
|
+
}
|
|
14303
|
+
const impactedDomains = [...new Set(references.map((item) => item.config_domain))].sort();
|
|
14304
|
+
const highRiskIdentifiers = changedIdentifiers.filter((item) => HIGH_RISK_CHANGES.has(item.change));
|
|
14305
|
+
const renameTargets = new Set(changedIdentifiers.filter((item) => item.change === "renamed" && item.current === item.identifier && item.previous !== item.identifier).map((item) => item.identifier));
|
|
14306
|
+
const candidateMap = /* @__PURE__ */ new Map();
|
|
14307
|
+
for (const changed of highRiskIdentifiers) {
|
|
14308
|
+
const domains = new Set(references.filter((reference) => reference.identifier === changed.identifier).map((reference) => reference.config_domain));
|
|
14309
|
+
if (renameTargets.has(changed.identifier) && domains.size === 0) {
|
|
14310
|
+
continue;
|
|
14311
|
+
}
|
|
14312
|
+
const key = `${changed.identifier}\0${changed.change}`;
|
|
14313
|
+
const candidate = candidateMap.get(key) || {
|
|
14314
|
+
identifier: changed.identifier,
|
|
14315
|
+
change: changed.change,
|
|
14316
|
+
config_domains: /* @__PURE__ */ new Set()
|
|
14317
|
+
};
|
|
14318
|
+
domains.forEach((domain) => candidate.config_domains.add(domain));
|
|
14319
|
+
candidateMap.set(key, candidate);
|
|
14320
|
+
}
|
|
14321
|
+
const requiredCollateralCandidates = [...candidateMap.values()].map((candidate) => {
|
|
14322
|
+
const domains = [...candidate.config_domains].sort();
|
|
14323
|
+
return {
|
|
14324
|
+
identifier: candidate.identifier,
|
|
14325
|
+
change: candidate.change,
|
|
14326
|
+
config_domains: domains,
|
|
14327
|
+
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`
|
|
14328
|
+
};
|
|
14329
|
+
});
|
|
14330
|
+
const recommendedSurfaces = RECOMMENDED_SURFACES[options.domain] || ["runtime-script", "e2e"];
|
|
14331
|
+
const recommendedNextSteps = [
|
|
14332
|
+
...impactedDomains.map(nextStepForDomain),
|
|
14333
|
+
...recommendedSurfaces.filter((surface) => !impactedDomains.includes(surface)).map(nextStepForDomain)
|
|
14334
|
+
].filter((item, index, all) => all.indexOf(item) === index);
|
|
14335
|
+
const unverifiedSurfaces = recommendedSurfaces.filter((surface) => !impactedDomains.includes(surface));
|
|
14336
|
+
const impactStatus = !changedIdentifiers.length ? "no_identifier_changes" : requiredCollateralCandidates.length ? "required_collateral_review" : "review_recommended";
|
|
14337
|
+
return {
|
|
14338
|
+
ok: true,
|
|
14339
|
+
domain: options.domain,
|
|
14340
|
+
impact_status: impactStatus,
|
|
14341
|
+
changed_identifiers: changedIdentifiers,
|
|
14342
|
+
references_found: references,
|
|
14343
|
+
impacted_config_domains: impactedDomains,
|
|
14344
|
+
required_collateral_candidates: requiredCollateralCandidates,
|
|
14345
|
+
recommended_next_steps: recommendedNextSteps,
|
|
14346
|
+
unverified_surfaces: unverifiedSurfaces,
|
|
14347
|
+
scan: {
|
|
14348
|
+
workspace_root: workspaceRoot,
|
|
14349
|
+
scanned_directories: directories,
|
|
14350
|
+
scanned_files: scannedFiles,
|
|
14351
|
+
skipped_large_files: skippedLargeFiles,
|
|
14352
|
+
reference_limit_reached: referenceLimitReached
|
|
14353
|
+
}
|
|
14354
|
+
};
|
|
14355
|
+
}
|
|
14356
|
+
|
|
14357
|
+
// src/core/config-workspace.ts
|
|
14358
|
+
import { mkdir as mkdir6, readFile as readFile10, realpath, stat as stat5, writeFile as writeFile6 } from "fs/promises";
|
|
14359
|
+
import path7 from "path";
|
|
13828
14360
|
var DEFAULT_AGENT_GUIDE_FILE = "AGENTS.md";
|
|
13829
14361
|
var CONFIG_WORKSPACE_REQUIRED_ENTRIES = [
|
|
13830
14362
|
"AGENTS.md",
|
|
@@ -13889,11 +14421,11 @@ var CONFIG_DIRECTORY_PURPOSES = [
|
|
|
13889
14421
|
];
|
|
13890
14422
|
async function hasExpectedWorkspaceEntry(root, entry) {
|
|
13891
14423
|
try {
|
|
13892
|
-
const entryPath =
|
|
13893
|
-
const value = await
|
|
14424
|
+
const entryPath = path7.join(root, entry);
|
|
14425
|
+
const value = await stat5(entryPath);
|
|
13894
14426
|
const canonicalEntry = await realpath(entryPath);
|
|
13895
|
-
const relative =
|
|
13896
|
-
const staysInsideRoot = relative !== ".." && !relative.startsWith(`..${
|
|
14427
|
+
const relative = path7.relative(root, canonicalEntry);
|
|
14428
|
+
const staysInsideRoot = relative !== ".." && !relative.startsWith(`..${path7.sep}`) && !path7.isAbsolute(relative);
|
|
13897
14429
|
return staysInsideRoot && (entry === DEFAULT_AGENT_GUIDE_FILE ? value.isFile() : value.isDirectory());
|
|
13898
14430
|
} catch (error) {
|
|
13899
14431
|
if (error.code === "ENOENT") {
|
|
@@ -13920,7 +14452,7 @@ async function findConfigWorkspaceRoot(cwd = process.cwd()) {
|
|
|
13920
14452
|
current = await realpath(cwd);
|
|
13921
14453
|
} catch (error) {
|
|
13922
14454
|
throw new ConfigWorkspaceError(`\u5F53\u524D\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u8BBF\u95EE\uFF1A${cwd}`, {
|
|
13923
|
-
path:
|
|
14455
|
+
path: path7.resolve(cwd),
|
|
13924
14456
|
code: "config_workspace_invalid_cwd",
|
|
13925
14457
|
rule_id: "config.workspace.cwd_invalid"
|
|
13926
14458
|
});
|
|
@@ -13934,7 +14466,7 @@ async function findConfigWorkspaceRoot(cwd = process.cwd()) {
|
|
|
13934
14466
|
if (entries.present.length > 0 && (!closestPartial || entries.present.length > closestPartial.present.length)) {
|
|
13935
14467
|
closestPartial = { root: current, ...entries };
|
|
13936
14468
|
}
|
|
13937
|
-
const parent =
|
|
14469
|
+
const parent = path7.dirname(current);
|
|
13938
14470
|
if (parent === current) {
|
|
13939
14471
|
break;
|
|
13940
14472
|
}
|
|
@@ -13949,7 +14481,7 @@ async function findConfigWorkspaceRoot(cwd = process.cwd()) {
|
|
|
13949
14481
|
}
|
|
13950
14482
|
async function canonicalConfiguredPath(value) {
|
|
13951
14483
|
const configuredPath = value.trim();
|
|
13952
|
-
if (!configuredPath || !
|
|
14484
|
+
if (!configuredPath || !path7.isAbsolute(configuredPath)) {
|
|
13953
14485
|
return void 0;
|
|
13954
14486
|
}
|
|
13955
14487
|
try {
|
|
@@ -13964,8 +14496,8 @@ async function canonicalConfiguredPath(value) {
|
|
|
13964
14496
|
async function assertConfigWorkspace(options) {
|
|
13965
14497
|
const currentDirectory = await realpath(options.cwd || process.cwd());
|
|
13966
14498
|
const root = options.root ? await realpath(options.root) : await findConfigWorkspaceRoot(currentDirectory);
|
|
13967
|
-
const relative =
|
|
13968
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
14499
|
+
const relative = path7.relative(root, currentDirectory);
|
|
14500
|
+
if (relative === ".." || relative.startsWith(`..${path7.sep}`) || path7.isAbsolute(relative)) {
|
|
13969
14501
|
throw new ConfigWorkspaceError("\u5F53\u524D\u76EE\u5F55\u4E0D\u5728\u8BC6\u522B\u51FA\u7684 BPMAX \u914D\u7F6E\u76EE\u5F55\u5185\u3002", {
|
|
13970
14502
|
path: currentDirectory,
|
|
13971
14503
|
profile: options.profile.name,
|
|
@@ -14174,10 +14706,10 @@ async function initConfigWorkspaceGuide(options) {
|
|
|
14174
14706
|
);
|
|
14175
14707
|
}
|
|
14176
14708
|
const file = options.file || DEFAULT_AGENT_GUIDE_FILE;
|
|
14177
|
-
if (
|
|
14709
|
+
if (path7.isAbsolute(file) || file.split(/[\\/]+/).includes("..")) {
|
|
14178
14710
|
throw new Error("Agent guide file must be a relative file name inside the target workspace.");
|
|
14179
14711
|
}
|
|
14180
|
-
const targetFile =
|
|
14712
|
+
const targetFile = path7.resolve(options.cwd, file);
|
|
14181
14713
|
const block = renderConfigWorkspaceGuide({
|
|
14182
14714
|
profileName: options.profile.name,
|
|
14183
14715
|
profile: options.profile.config,
|
|
@@ -14187,7 +14719,7 @@ async function initConfigWorkspaceGuide(options) {
|
|
|
14187
14719
|
});
|
|
14188
14720
|
let existing = "";
|
|
14189
14721
|
try {
|
|
14190
|
-
existing = await
|
|
14722
|
+
existing = await readFile10(targetFile, "utf8");
|
|
14191
14723
|
} catch (error) {
|
|
14192
14724
|
if (error.code !== "ENOENT") {
|
|
14193
14725
|
throw error;
|
|
@@ -14195,7 +14727,7 @@ async function initConfigWorkspaceGuide(options) {
|
|
|
14195
14727
|
}
|
|
14196
14728
|
const content = upsertConfigWorkspaceBlock(existing, options.env, block);
|
|
14197
14729
|
if (!options.dryRun) {
|
|
14198
|
-
await mkdir6(
|
|
14730
|
+
await mkdir6(path7.dirname(targetFile), { recursive: true });
|
|
14199
14731
|
await writeFile6(targetFile, content, "utf8");
|
|
14200
14732
|
}
|
|
14201
14733
|
return {
|
|
@@ -14209,14 +14741,14 @@ async function initConfigWorkspaceGuide(options) {
|
|
|
14209
14741
|
}
|
|
14210
14742
|
|
|
14211
14743
|
// src/core/plugin-config-adapters.ts
|
|
14212
|
-
import { readFile as
|
|
14213
|
-
import
|
|
14214
|
-
function
|
|
14744
|
+
import { readFile as readFile11 } from "fs/promises";
|
|
14745
|
+
import path8 from "path";
|
|
14746
|
+
function isRecord5(value) {
|
|
14215
14747
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
14216
14748
|
}
|
|
14217
14749
|
function unwrapRecord(value) {
|
|
14218
|
-
if (
|
|
14219
|
-
return
|
|
14750
|
+
if (isRecord5(value) && isRecord5(value.data)) return value.data;
|
|
14751
|
+
return isRecord5(value) ? value : {};
|
|
14220
14752
|
}
|
|
14221
14753
|
function endpointPath(endpoint, id, pluginKey, operation = "request") {
|
|
14222
14754
|
const template = endpoint?.path || "";
|
|
@@ -14289,13 +14821,13 @@ function assertSafeDomain(domain) {
|
|
|
14289
14821
|
function assertSafeAdapterPath(adapterPath) {
|
|
14290
14822
|
const normalized = adapterPath.replace(/\\/g, "/");
|
|
14291
14823
|
const parts = normalized.split("/");
|
|
14292
|
-
if (!normalized.startsWith("config/") || !normalized.endsWith(".json") || normalized.startsWith("/") ||
|
|
14824
|
+
if (!normalized.startsWith("config/") || !normalized.endsWith(".json") || normalized.startsWith("/") || path8.isAbsolute(normalized) || parts.some((part) => part === "" || part === "." || part === "..")) {
|
|
14293
14825
|
throw new Error(`Invalid plugin config adapter path: ${adapterPath}`);
|
|
14294
14826
|
}
|
|
14295
14827
|
}
|
|
14296
14828
|
function normalizeAdapterManifest(value) {
|
|
14297
14829
|
if (!Array.isArray(value)) return [];
|
|
14298
|
-
return value.filter(
|
|
14830
|
+
return value.filter(isRecord5).map((item) => ({
|
|
14299
14831
|
domain: typeof item.domain === "string" ? item.domain : "",
|
|
14300
14832
|
plugin_key: typeof item.plugin_key === "string" ? item.plugin_key : "",
|
|
14301
14833
|
capability_prefix: typeof item.capability_prefix === "string" ? item.capability_prefix : "",
|
|
@@ -14311,9 +14843,9 @@ async function installedAdapterManifests(profile, agent) {
|
|
|
14311
14843
|
for (const manifest of normalizeAdapterManifest(skill.config_adapters)) {
|
|
14312
14844
|
assertSafeDomain(manifest.domain);
|
|
14313
14845
|
assertSafeAdapterPath(manifest.adapter);
|
|
14314
|
-
const adapterPath =
|
|
14315
|
-
const adapter = JSON.parse(await
|
|
14316
|
-
if (!
|
|
14846
|
+
const adapterPath = path8.join(skill.install_path, manifest.adapter);
|
|
14847
|
+
const adapter = JSON.parse(await readFile11(adapterPath, "utf8"));
|
|
14848
|
+
if (!isRecord5(adapter) || adapter.domain !== manifest.domain || adapter.plugin_key !== manifest.plugin_key) {
|
|
14317
14849
|
throw new Error(`Plugin config adapter manifest mismatch: ${plugin}/${skill.name}/${manifest.domain}`);
|
|
14318
14850
|
}
|
|
14319
14851
|
assertAdapterEndpoints(adapter);
|
|
@@ -14405,7 +14937,7 @@ function getPathValues(value, selector) {
|
|
|
14405
14937
|
const key = arrayMode ? rawPart.slice(0, -2) : rawPart;
|
|
14406
14938
|
const next = [];
|
|
14407
14939
|
for (const item of current) {
|
|
14408
|
-
if (!
|
|
14940
|
+
if (!isRecord5(item)) continue;
|
|
14409
14941
|
const child = item[key];
|
|
14410
14942
|
if (arrayMode) {
|
|
14411
14943
|
if (Array.isArray(child)) next.push(...child);
|
|
@@ -14440,7 +14972,7 @@ function lintPluginWork(work, rules, base) {
|
|
|
14440
14972
|
const message = rule.message || `${pathSelector || "<root>"} failed ${rule.type || "validation"}`;
|
|
14441
14973
|
if (rule.type === "object") {
|
|
14442
14974
|
const value = pathSelector ? firstPathValue(work, pathSelector) : work;
|
|
14443
|
-
if (!
|
|
14975
|
+
if (!isRecord5(value)) errors.push(message);
|
|
14444
14976
|
} else if (rule.type === "nonEmptyString") {
|
|
14445
14977
|
if (!values.length || values.some((value) => typeof value !== "string" || !value.trim())) errors.push(message);
|
|
14446
14978
|
} else if (rule.type === "nonEmptyArray") {
|
|
@@ -14504,9 +15036,9 @@ async function exportPluginConfigDomain(profile, domain, id, outDir, agent = "co
|
|
|
14504
15036
|
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
15037
|
capability: capabilityFor(resolved.adapter, "list")
|
|
14506
15038
|
}) : await readPluginConfigRecord(profile, resolved.adapter, id);
|
|
14507
|
-
const rawFile =
|
|
14508
|
-
const workFile =
|
|
14509
|
-
const metaFile =
|
|
15039
|
+
const rawFile = path8.join(outDir, `${domain}-${id}-raw.json`);
|
|
15040
|
+
const workFile = path8.join(outDir, `${domain}-${id}-work.json`);
|
|
15041
|
+
const metaFile = path8.join(outDir, `${domain}-${id}-meta.json`);
|
|
14510
15042
|
const rawForHash = raw;
|
|
14511
15043
|
const work = Array.isArray(raw) ? raw : normalizeWorkFromRaw(unwrapRecord(raw), resolved.adapter);
|
|
14512
15044
|
await writeJsonFile(rawFile, raw);
|
|
@@ -14517,7 +15049,7 @@ async function exportPluginConfigDomain(profile, domain, id, outDir, agent = "co
|
|
|
14517
15049
|
profile: profile.name,
|
|
14518
15050
|
workspace: profile.config.workspace,
|
|
14519
15051
|
id,
|
|
14520
|
-
mode:
|
|
15052
|
+
mode: isRecord5(work) ? work.mode || "edit" : "list",
|
|
14521
15053
|
raw_file: rawFile,
|
|
14522
15054
|
base_hash: hashJson(rawForHash),
|
|
14523
15055
|
exported_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -14531,8 +15063,8 @@ async function readAdapterLintRules(resolved) {
|
|
|
14531
15063
|
if (!normalized.startsWith("lint/") || !normalized.endsWith(".json") || normalized.includes("..")) {
|
|
14532
15064
|
throw new Error(`Invalid plugin config lint path: ${lintPath}`);
|
|
14533
15065
|
}
|
|
14534
|
-
const lint = JSON.parse(await
|
|
14535
|
-
if (!
|
|
15066
|
+
const lint = JSON.parse(await readFile11(path8.join(resolved.install_path, normalized), "utf8"));
|
|
15067
|
+
if (!isRecord5(lint) || lint.domain !== resolved.manifest.domain || lint.plugin_key !== resolved.manifest.plugin_key) {
|
|
14536
15068
|
throw new Error(`Plugin config lint manifest mismatch: ${resolved.manifest.domain}`);
|
|
14537
15069
|
}
|
|
14538
15070
|
return Array.isArray(lint.rules) ? lint.rules : [];
|
|
@@ -14542,10 +15074,10 @@ async function lintPluginConfigWorkFile(profile, domain, workFile, agent = "code
|
|
|
14542
15074
|
const work = await readJsonFile(workFile);
|
|
14543
15075
|
const base = baseFile ? await readJsonFile(baseFile) : void 0;
|
|
14544
15076
|
const errors = [];
|
|
14545
|
-
if (!
|
|
15077
|
+
if (!isRecord5(work)) {
|
|
14546
15078
|
errors.push("Plugin config work file must be a JSON object.");
|
|
14547
15079
|
} else {
|
|
14548
|
-
errors.push(...lintPluginWork(work, await readAdapterLintRules(resolved),
|
|
15080
|
+
errors.push(...lintPluginWork(work, await readAdapterLintRules(resolved), isRecord5(base) ? normalizeWorkFromRaw(base, resolved.adapter) : void 0));
|
|
14549
15081
|
}
|
|
14550
15082
|
return {
|
|
14551
15083
|
domain,
|
|
@@ -14559,21 +15091,21 @@ async function lintPluginConfigWorkFile(profile, domain, workFile, agent = "code
|
|
|
14559
15091
|
async function buildPluginConfigSubmitPayload(profile, domain, workFile, outFile, metaFile, agent = "codex") {
|
|
14560
15092
|
const resolved = await resolvePluginConfigAdapter(profile, agent, domain);
|
|
14561
15093
|
const work = await readJsonFile(workFile);
|
|
14562
|
-
if (!
|
|
15094
|
+
if (!isRecord5(work)) throw new Error("Plugin config work file must be a JSON object.");
|
|
14563
15095
|
const meta = metaFile ? await readJsonFile(metaFile) : {};
|
|
14564
|
-
const mode = String(work.mode || (
|
|
14565
|
-
const base =
|
|
14566
|
-
const lintErrors = lintPluginWork(work, await readAdapterLintRules(resolved),
|
|
15096
|
+
const mode = String(work.mode || (isRecord5(meta) ? meta.mode || "" : "") || "edit");
|
|
15097
|
+
const base = isRecord5(meta) && typeof meta.raw_file === "string" ? await readJsonFile(meta.raw_file) : void 0;
|
|
15098
|
+
const lintErrors = lintPluginWork(work, await readAdapterLintRules(resolved), isRecord5(base) ? normalizeWorkFromRaw(base, resolved.adapter) : void 0);
|
|
14567
15099
|
if (lintErrors.length) throw new Error(`Plugin config lint failed: ${lintErrors.join("; ")}`);
|
|
14568
15100
|
const payload = fieldsRecord(work, resolved.adapter.work?.fields);
|
|
14569
15101
|
delete payload.mode;
|
|
14570
15102
|
const submitMeta = {
|
|
14571
|
-
...
|
|
15103
|
+
...isRecord5(meta) ? meta : {},
|
|
14572
15104
|
domain,
|
|
14573
15105
|
plugin: resolved.plugin,
|
|
14574
15106
|
profile: profile.name,
|
|
14575
15107
|
workspace: profile.config.workspace,
|
|
14576
|
-
id:
|
|
15108
|
+
id: isRecord5(meta) && typeof meta.id === "string" ? meta.id : "",
|
|
14577
15109
|
mode
|
|
14578
15110
|
};
|
|
14579
15111
|
const result = {
|
|
@@ -14581,7 +15113,7 @@ async function buildPluginConfigSubmitPayload(profile, domain, workFile, outFile
|
|
|
14581
15113
|
plugin: resolved.plugin,
|
|
14582
15114
|
built_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14583
15115
|
meta: submitMeta,
|
|
14584
|
-
base_hash: mode === "create" ? null :
|
|
15116
|
+
base_hash: mode === "create" ? null : isRecord5(meta) && typeof meta.base_hash === "string" ? meta.base_hash : null,
|
|
14585
15117
|
payload
|
|
14586
15118
|
};
|
|
14587
15119
|
await writeJsonFile(outFile, result);
|
|
@@ -14598,7 +15130,7 @@ async function diffPluginConfigPayload(workFile, submitFile) {
|
|
|
14598
15130
|
async function submitPluginConfigDomain(profile, domain, id, submitFile, confirm3, agent = "codex") {
|
|
14599
15131
|
const resolved = await resolvePluginConfigAdapter(profile, agent, domain);
|
|
14600
15132
|
const submit = await readJsonFile(submitFile);
|
|
14601
|
-
if (!
|
|
15133
|
+
if (!isRecord5(submit) || submit.domain !== domain || !isRecord5(submit.payload) || !isRecord5(submit.meta)) {
|
|
14602
15134
|
throw new Error("Plugin config submit requires a payload produced by `bpmax-cli config plugin <domain> build`.");
|
|
14603
15135
|
}
|
|
14604
15136
|
if (submit.meta.profile !== profile.name) {
|
|
@@ -14667,7 +15199,7 @@ async function verifyPluginConfigDomain(profile, domain, id, expectFile, agent =
|
|
|
14667
15199
|
const actual = await readPluginConfigRecord(profile, resolved.adapter, id);
|
|
14668
15200
|
const expected = expectFile ? await readJsonFile(expectFile) : void 0;
|
|
14669
15201
|
const actualComparable = comparableRecord(normalizeWorkFromRaw(actual, resolved.adapter), resolved.adapter.work?.compare_fields || resolved.adapter.work?.fields);
|
|
14670
|
-
const expectedComparable =
|
|
15202
|
+
const expectedComparable = isRecord5(expected) ? comparableRecord(expected, resolved.adapter.work?.compare_fields || resolved.adapter.work?.fields) : void 0;
|
|
14671
15203
|
const ok = expectedComparable ? hashJson(actualComparable) === hashJson(expectedComparable) : true;
|
|
14672
15204
|
return {
|
|
14673
15205
|
domain,
|
|
@@ -14693,10 +15225,10 @@ async function testPluginConfigDomain(profile, domain, id, message, agent = "cod
|
|
|
14693
15225
|
|
|
14694
15226
|
// src/commands/config-env.ts
|
|
14695
15227
|
import { execFile } from "child_process";
|
|
14696
|
-
import { mkdir as mkdir7, rm as rm3, stat as
|
|
15228
|
+
import { mkdir as mkdir7, rm as rm3, stat as stat6, writeFile as writeFile7 } from "fs/promises";
|
|
14697
15229
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
14698
15230
|
import { tmpdir as tmpdir2 } from "os";
|
|
14699
|
-
import
|
|
15231
|
+
import path9 from "path";
|
|
14700
15232
|
import { promisify } from "util";
|
|
14701
15233
|
import { password, text } from "@clack/prompts";
|
|
14702
15234
|
import axios6 from "axios";
|
|
@@ -14835,11 +15367,11 @@ async function gitCloneWithTransientCredentials(gitUrl, workspaceDir, credential
|
|
|
14835
15367
|
const sanitizedGitUrl = stripGitUrlCredentials(gitUrl);
|
|
14836
15368
|
if (!credentials) {
|
|
14837
15369
|
await execFileAsync("git", ["clone", sanitizedGitUrl, workspaceDir], {
|
|
14838
|
-
cwd:
|
|
15370
|
+
cwd: path9.dirname(workspaceDir)
|
|
14839
15371
|
});
|
|
14840
15372
|
return;
|
|
14841
15373
|
}
|
|
14842
|
-
const askpassPath =
|
|
15374
|
+
const askpassPath = path9.join(tmpdir2(), `bpmax-cli-git-askpass-${randomUUID3()}.sh`);
|
|
14843
15375
|
await writeFile7(
|
|
14844
15376
|
askpassPath,
|
|
14845
15377
|
[
|
|
@@ -14855,7 +15387,7 @@ async function gitCloneWithTransientCredentials(gitUrl, workspaceDir, credential
|
|
|
14855
15387
|
);
|
|
14856
15388
|
try {
|
|
14857
15389
|
await execFileAsync("git", ["clone", sanitizedGitUrl, workspaceDir], {
|
|
14858
|
-
cwd:
|
|
15390
|
+
cwd: path9.dirname(workspaceDir),
|
|
14859
15391
|
env: {
|
|
14860
15392
|
...process.env,
|
|
14861
15393
|
GIT_ASKPASS: askpassPath,
|
|
@@ -14873,7 +15405,7 @@ async function withTransientGitCredentials(credentials, operation) {
|
|
|
14873
15405
|
if (!credentials) {
|
|
14874
15406
|
return operation(void 0);
|
|
14875
15407
|
}
|
|
14876
|
-
const askpassPath =
|
|
15408
|
+
const askpassPath = path9.join(tmpdir2(), `bpmax-cli-git-askpass-${randomUUID3()}.sh`);
|
|
14877
15409
|
await writeFile7(
|
|
14878
15410
|
askpassPath,
|
|
14879
15411
|
[
|
|
@@ -14988,7 +15520,7 @@ function hasBlockingDirtyStatus(status, allowedPaths = /* @__PURE__ */ new Set([
|
|
|
14988
15520
|
}
|
|
14989
15521
|
async function pathExists(targetPath) {
|
|
14990
15522
|
try {
|
|
14991
|
-
await
|
|
15523
|
+
await stat6(targetPath);
|
|
14992
15524
|
return true;
|
|
14993
15525
|
} catch (error) {
|
|
14994
15526
|
if (error.code === "ENOENT") {
|
|
@@ -15213,10 +15745,10 @@ async function initConfigWorkspaceFromPlatform(env, options) {
|
|
|
15213
15745
|
requiredPlatformField(platformEnv, "pull_url");
|
|
15214
15746
|
requiredPlatformField(platformEnv, "extract_url");
|
|
15215
15747
|
requiredPlatformField(platformEnv, "push_url");
|
|
15216
|
-
const workspaceDir =
|
|
15748
|
+
const workspaceDir = path9.resolve(options.workspaceDir);
|
|
15217
15749
|
const existed = await pathExists(workspaceDir);
|
|
15218
15750
|
if (!existed) {
|
|
15219
|
-
await mkdir7(
|
|
15751
|
+
await mkdir7(path9.dirname(workspaceDir), { recursive: true });
|
|
15220
15752
|
await gitCloneWithTransientCredentials(gitUrl, workspaceDir, credentials);
|
|
15221
15753
|
} else {
|
|
15222
15754
|
await assertExistingGitWorkspace(workspaceDir, gitUrl, options.force);
|
|
@@ -15320,17 +15852,17 @@ async function pullLatestConfigEnvironment(env, options) {
|
|
|
15320
15852
|
}
|
|
15321
15853
|
|
|
15322
15854
|
// src/commands/config.ts
|
|
15323
|
-
var
|
|
15855
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15324
15856
|
function csvCell(value) {
|
|
15325
|
-
const text5 = value === null || value === void 0 ? "" : Array.isArray(value) ||
|
|
15857
|
+
const text5 = value === null || value === void 0 ? "" : Array.isArray(value) || isRecord6(value) ? JSON.stringify(value) : String(value);
|
|
15326
15858
|
return /[",\n\r]/.test(text5) ? `"${text5.replace(/"/g, '""')}"` : text5;
|
|
15327
15859
|
}
|
|
15328
15860
|
async function writeEvidenceOut(file, value) {
|
|
15329
15861
|
if (!file) {
|
|
15330
15862
|
return;
|
|
15331
15863
|
}
|
|
15332
|
-
await mkdir8(
|
|
15333
|
-
const evidence =
|
|
15864
|
+
await mkdir8(path10.dirname(path10.resolve(file)), { recursive: true });
|
|
15865
|
+
const evidence = isRecord6(value.evidence) ? value.evidence : value;
|
|
15334
15866
|
if (file.endsWith(".csv")) {
|
|
15335
15867
|
const keys = [
|
|
15336
15868
|
"flow_type",
|
|
@@ -15356,7 +15888,7 @@ async function writeResponseOut(file, value) {
|
|
|
15356
15888
|
if (!file) {
|
|
15357
15889
|
return;
|
|
15358
15890
|
}
|
|
15359
|
-
await mkdir8(
|
|
15891
|
+
await mkdir8(path10.dirname(path10.resolve(file)), { recursive: true });
|
|
15360
15892
|
await writeFile8(file, `${JSON.stringify(value, null, 2)}
|
|
15361
15893
|
`, "utf8");
|
|
15362
15894
|
}
|
|
@@ -15380,15 +15912,15 @@ function arrayValue(value) {
|
|
|
15380
15912
|
return Array.isArray(value) ? value : [];
|
|
15381
15913
|
}
|
|
15382
15914
|
function flowTemplateNodes(work) {
|
|
15383
|
-
const data =
|
|
15384
|
-
return arrayValue(data?.nodes).filter(
|
|
15915
|
+
const data = isRecord6(work.data) ? work.data : void 0;
|
|
15916
|
+
return arrayValue(data?.nodes).filter(isRecord6);
|
|
15385
15917
|
}
|
|
15386
15918
|
function summarizeFlowTemplateWork(work) {
|
|
15387
|
-
if (!
|
|
15919
|
+
if (!isRecord6(work)) {
|
|
15388
15920
|
return { available: false, reason: "flow-template work file is not a JSON object" };
|
|
15389
15921
|
}
|
|
15390
|
-
const data =
|
|
15391
|
-
const meta =
|
|
15922
|
+
const data = isRecord6(work.data) ? work.data : {};
|
|
15923
|
+
const meta = isRecord6(data.meta) ? data.meta : {};
|
|
15392
15924
|
const nodes = flowTemplateNodes(work);
|
|
15393
15925
|
const matrixOwnerNodes = nodes.filter((node) => JSON.stringify(node).includes("matrix_owner")).map((node) => ({
|
|
15394
15926
|
id: stringValue(node.id),
|
|
@@ -15400,7 +15932,7 @@ function summarizeFlowTemplateWork(work) {
|
|
|
15400
15932
|
name: stringValue(node.name),
|
|
15401
15933
|
type: stringValue(node.type)
|
|
15402
15934
|
}));
|
|
15403
|
-
const publish =
|
|
15935
|
+
const publish = isRecord6(work.publish) ? work.publish : void 0;
|
|
15404
15936
|
return {
|
|
15405
15937
|
available: true,
|
|
15406
15938
|
name: stringValue(work.name),
|
|
@@ -15909,7 +16441,7 @@ function registerConfigCommands(program2) {
|
|
|
15909
16441
|
printResult(options.format, result);
|
|
15910
16442
|
});
|
|
15911
16443
|
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 &&
|
|
16444
|
+
if (options.submit && options.payload && path10.resolve(options.submit) !== path10.resolve(options.payload)) {
|
|
15913
16445
|
throw new Error(`config ${domain} diff received different --submit and --payload files; provide only one artifact.`);
|
|
15914
16446
|
}
|
|
15915
16447
|
const submitFile = options.submit ?? options.payload;
|
|
@@ -15927,6 +16459,29 @@ function registerConfigCommands(program2) {
|
|
|
15927
16459
|
submit_preview: submit || null
|
|
15928
16460
|
});
|
|
15929
16461
|
});
|
|
16462
|
+
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) => {
|
|
16463
|
+
const workspaceRoot = await findConfigWorkspaceRoot();
|
|
16464
|
+
if (!workspaceRoot) {
|
|
16465
|
+
throw new Error("Config impact analysis requires a recognized BPMAX configuration workspace.");
|
|
16466
|
+
}
|
|
16467
|
+
const configData = await loadConfig();
|
|
16468
|
+
const resolved = resolveProfile(configData, options.profile);
|
|
16469
|
+
const result = await analyzeConfigImpact({
|
|
16470
|
+
domain,
|
|
16471
|
+
raw: options.raw ? await readJsonFile(options.raw) : {},
|
|
16472
|
+
work: await readJsonFile(options.work),
|
|
16473
|
+
workspaceRoot
|
|
16474
|
+
});
|
|
16475
|
+
const output = {
|
|
16476
|
+
...result,
|
|
16477
|
+
profile: resolved.name,
|
|
16478
|
+
raw_file: options.raw ?? null,
|
|
16479
|
+
work_file: options.work,
|
|
16480
|
+
report_file: options.out ?? null
|
|
16481
|
+
};
|
|
16482
|
+
await writeResponseOut(options.out, output);
|
|
16483
|
+
printResult(options.format, output);
|
|
16484
|
+
});
|
|
15930
16485
|
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
16486
|
const configData = await loadConfig();
|
|
15932
16487
|
const resolved = resolveProfile(configData, options.profile);
|
|
@@ -16044,8 +16599,8 @@ function registerConfigCommands(program2) {
|
|
|
16044
16599
|
|
|
16045
16600
|
// src/commands/e2e.ts
|
|
16046
16601
|
import { createHash as createHash6 } from "crypto";
|
|
16047
|
-
import { mkdir as mkdir10, readFile as
|
|
16048
|
-
import
|
|
16602
|
+
import { mkdir as mkdir10, readFile as readFile13, readdir as readdir5, stat as stat8, writeFile as writeFile10 } from "fs/promises";
|
|
16603
|
+
import path12 from "path";
|
|
16049
16604
|
import axios7 from "axios";
|
|
16050
16605
|
|
|
16051
16606
|
// src/core/test-suite.ts
|
|
@@ -16055,16 +16610,16 @@ import {
|
|
|
16055
16610
|
cp as cp3,
|
|
16056
16611
|
mkdir as mkdir9,
|
|
16057
16612
|
open as open2,
|
|
16058
|
-
readdir as
|
|
16059
|
-
readFile as
|
|
16613
|
+
readdir as readdir4,
|
|
16614
|
+
readFile as readFile12,
|
|
16060
16615
|
realpath as realpath2,
|
|
16061
16616
|
rename,
|
|
16062
16617
|
rm as rm4,
|
|
16063
|
-
stat as
|
|
16618
|
+
stat as stat7,
|
|
16064
16619
|
unlink,
|
|
16065
16620
|
writeFile as writeFile9
|
|
16066
16621
|
} from "fs/promises";
|
|
16067
|
-
import
|
|
16622
|
+
import path11 from "path";
|
|
16068
16623
|
import { inflateSync } from "zlib";
|
|
16069
16624
|
var DEFAULT_SUITE_ROOT = ".ai_test/suite";
|
|
16070
16625
|
var DEFAULT_DRAFT_ROOT = ".ai_test/suite_draft";
|
|
@@ -16263,14 +16818,14 @@ function runtimeRoute(runtimeUrl) {
|
|
|
16263
16818
|
}
|
|
16264
16819
|
async function exists3(filePath) {
|
|
16265
16820
|
try {
|
|
16266
|
-
await
|
|
16821
|
+
await stat7(filePath);
|
|
16267
16822
|
return true;
|
|
16268
16823
|
} catch {
|
|
16269
16824
|
return false;
|
|
16270
16825
|
}
|
|
16271
16826
|
}
|
|
16272
16827
|
async function readText(filePath) {
|
|
16273
|
-
return
|
|
16828
|
+
return readFile12(filePath, "utf8");
|
|
16274
16829
|
}
|
|
16275
16830
|
function fail(message, options = {}) {
|
|
16276
16831
|
throw new TestSuiteError(message, options);
|
|
@@ -16331,12 +16886,12 @@ function reviewSchemaExplanation() {
|
|
|
16331
16886
|
};
|
|
16332
16887
|
}
|
|
16333
16888
|
function reviewFail(reviewPath, message) {
|
|
16334
|
-
const scenarioId =
|
|
16889
|
+
const scenarioId = path11.basename(path11.dirname(reviewPath));
|
|
16335
16890
|
fail(
|
|
16336
16891
|
[
|
|
16337
16892
|
message,
|
|
16338
16893
|
"\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 ${
|
|
16894
|
+
`\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
16895
|
`\u6700\u5C0F review.json \u793A\u4F8B\uFF1A${JSON.stringify(reviewSchemaExample(scenarioId))}`
|
|
16341
16896
|
].join("\n"),
|
|
16342
16897
|
{
|
|
@@ -16391,7 +16946,7 @@ async function readCases(filePath) {
|
|
|
16391
16946
|
code: "legacy_case_steps_format",
|
|
16392
16947
|
rule_id: "test_suite.case_steps.legacy_aggregated",
|
|
16393
16948
|
path: filePath,
|
|
16394
|
-
suggestion: `\u8FD0\u884C \`bpmax-cli test-suite steps migrate --scenario ${
|
|
16949
|
+
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
16950
|
});
|
|
16396
16951
|
}
|
|
16397
16952
|
if (JSON.stringify(fields) !== JSON.stringify(CASE_FIELDS)) {
|
|
@@ -16491,14 +17046,14 @@ function parseReadmeText(filePath, text5) {
|
|
|
16491
17046
|
return metadata;
|
|
16492
17047
|
}
|
|
16493
17048
|
async function validateReadme(scenarioDir) {
|
|
16494
|
-
const readmePath =
|
|
17049
|
+
const readmePath = path11.join(scenarioDir, "README.md");
|
|
16495
17050
|
if (!await exists3(readmePath)) fail(`missing README.md: ${readmePath}`);
|
|
16496
17051
|
const text5 = await readText(readmePath);
|
|
16497
17052
|
const metadata = parseReadmeText(readmePath, text5);
|
|
16498
17053
|
for (const key of REQUIRED_README_KEYS) {
|
|
16499
17054
|
if (!metadata[key]) fail(`${scenarioDir}: README.md missing \`${key}\``);
|
|
16500
17055
|
}
|
|
16501
|
-
if (metadata.scenario_id !==
|
|
17056
|
+
if (metadata.scenario_id !== path11.basename(scenarioDir)) fail(`${scenarioDir}: scenario_id must match directory name`);
|
|
16502
17057
|
if (!["true", "false"].includes(metadata.core.toLowerCase())) fail(`${scenarioDir}: core must be true or false`);
|
|
16503
17058
|
if (!STATUSES.has(metadata.status)) fail(`${scenarioDir}: status must be one of ${JSON.stringify([...STATUSES].sort())}`);
|
|
16504
17059
|
if (UUID_RE2.test(text5) || ID_AS_ENTRY_RE.test(text5)) {
|
|
@@ -16816,14 +17371,14 @@ async function collectE2eAccelerationGaps(root) {
|
|
|
16816
17371
|
const dirs = await scenarioDirs(root);
|
|
16817
17372
|
const gaps = [];
|
|
16818
17373
|
for (const dir of dirs) {
|
|
16819
|
-
const scenarioId =
|
|
16820
|
-
const casesPath =
|
|
17374
|
+
const scenarioId = path11.basename(dir);
|
|
17375
|
+
const casesPath = path11.join(dir, "cases.csv");
|
|
16821
17376
|
if (!await exists3(casesPath)) {
|
|
16822
17377
|
continue;
|
|
16823
17378
|
}
|
|
16824
17379
|
const rows2 = await readCases(casesPath);
|
|
16825
|
-
const steps = await readCaseSteps(
|
|
16826
|
-
const stepsByCase = validateCaseSteps(
|
|
17380
|
+
const steps = await readCaseSteps(path11.join(dir, "case_steps.csv"));
|
|
17381
|
+
const stepsByCase = validateCaseSteps(path11.join(dir, "case_steps.csv"), rows2, steps);
|
|
16827
17382
|
for (const row of rows2) {
|
|
16828
17383
|
const caseSteps = stepsByCase.get(row.case_id.trim()) ?? [];
|
|
16829
17384
|
if (row.status === "deprecated" || hasE2eReusableAsset(row, caseSteps)) {
|
|
@@ -16842,14 +17397,14 @@ async function collectE2eAccelerationGaps(root) {
|
|
|
16842
17397
|
}
|
|
16843
17398
|
async function scenarioDirs(root) {
|
|
16844
17399
|
if (!await exists3(root)) return [];
|
|
16845
|
-
const items = await
|
|
16846
|
-
return items.filter((item) => item.isDirectory()).map((item) =>
|
|
17400
|
+
const items = await readdir4(root, { withFileTypes: true });
|
|
17401
|
+
return items.filter((item) => item.isDirectory()).map((item) => path11.join(root, item.name)).sort();
|
|
16847
17402
|
}
|
|
16848
17403
|
async function validateScenario(scenarioDir) {
|
|
16849
17404
|
const metadata = await validateReadme(scenarioDir);
|
|
16850
|
-
const casesPath =
|
|
17405
|
+
const casesPath = path11.join(scenarioDir, "cases.csv");
|
|
16851
17406
|
const rows2 = await readCases(casesPath);
|
|
16852
|
-
const caseStepsPath =
|
|
17407
|
+
const caseStepsPath = path11.join(scenarioDir, "case_steps.csv");
|
|
16853
17408
|
const caseSteps = await readCaseSteps(caseStepsPath);
|
|
16854
17409
|
const stepsByCase = validateCaseSteps(caseStepsPath, rows2, caseSteps);
|
|
16855
17410
|
if (rows2.length === 0) fail(`${casesPath}: at least one case is required`);
|
|
@@ -16911,7 +17466,7 @@ function migratedStepActions(value) {
|
|
|
16911
17466
|
async function migrateScenarioSteps(options) {
|
|
16912
17467
|
const scenarioDir = scenarioPath(options.draftRoot ?? DEFAULT_DRAFT_ROOT, options.scenario);
|
|
16913
17468
|
await validateReadme(scenarioDir);
|
|
16914
|
-
const casesPath =
|
|
17469
|
+
const casesPath = path11.join(scenarioDir, "cases.csv");
|
|
16915
17470
|
const legacyRows = await readLegacyCases(casesPath);
|
|
16916
17471
|
const nextCases = legacyRows.map(({ steps: _steps, ...row }) => row);
|
|
16917
17472
|
const stepRows = [];
|
|
@@ -16941,7 +17496,7 @@ async function migrateScenarioSteps(options) {
|
|
|
16941
17496
|
});
|
|
16942
17497
|
}
|
|
16943
17498
|
await writeFile9(casesPath, csvText(CASE_FIELDS, nextCases), "utf8");
|
|
16944
|
-
const stepsPath =
|
|
17499
|
+
const stepsPath = path11.join(scenarioDir, "case_steps.csv");
|
|
16945
17500
|
await writeFile9(stepsPath, csvText(CASE_STEP_FIELDS, stepRows), "utf8");
|
|
16946
17501
|
return {
|
|
16947
17502
|
ok: false,
|
|
@@ -16956,9 +17511,9 @@ async function migrateScenarioSteps(options) {
|
|
|
16956
17511
|
}
|
|
16957
17512
|
async function suiteHash(scenarioDir) {
|
|
16958
17513
|
const hash = createHash5("sha256");
|
|
16959
|
-
hash.update(await readText(
|
|
16960
|
-
hash.update(await readText(
|
|
16961
|
-
hash.update(await readText(
|
|
17514
|
+
hash.update(await readText(path11.join(scenarioDir, "README.md")));
|
|
17515
|
+
hash.update(await readText(path11.join(scenarioDir, "cases.csv")));
|
|
17516
|
+
hash.update(await readText(path11.join(scenarioDir, "case_steps.csv")));
|
|
16962
17517
|
return hash.digest("hex");
|
|
16963
17518
|
}
|
|
16964
17519
|
function executionManifestHash(manifest) {
|
|
@@ -16967,7 +17522,7 @@ function executionManifestHash(manifest) {
|
|
|
16967
17522
|
async function readExecutionManifest(manifestPath) {
|
|
16968
17523
|
let value;
|
|
16969
17524
|
try {
|
|
16970
|
-
value = JSON.parse(await readText(
|
|
17525
|
+
value = JSON.parse(await readText(path11.resolve(manifestPath)));
|
|
16971
17526
|
} catch {
|
|
16972
17527
|
fail(`invalid execution manifest: ${manifestPath}`, { rule_id: "test_suite.execution_manifest.invalid", path: manifestPath });
|
|
16973
17528
|
}
|
|
@@ -16978,10 +17533,10 @@ async function readExecutionManifest(manifestPath) {
|
|
|
16978
17533
|
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
17534
|
fail(`invalid execution manifest shape: ${manifestPath}`, { rule_id: "test_suite.execution_manifest.invalid", path: manifestPath });
|
|
16980
17535
|
}
|
|
16981
|
-
if (
|
|
17536
|
+
if (path11.basename(path11.dirname(path11.resolve(manifestPath))) !== manifest.run_id) {
|
|
16982
17537
|
fail("execution manifest run_id must match its report directory", { rule_id: "test_suite.execution_manifest.run_scope", path: manifestPath });
|
|
16983
17538
|
}
|
|
16984
|
-
const statePath = `${
|
|
17539
|
+
const statePath = `${path11.resolve(manifestPath)}.state.json`;
|
|
16985
17540
|
if (await exists3(statePath)) {
|
|
16986
17541
|
try {
|
|
16987
17542
|
const state = JSON.parse(await readText(statePath));
|
|
@@ -16999,14 +17554,14 @@ async function readExecutionManifest(manifestPath) {
|
|
|
16999
17554
|
return manifest;
|
|
17000
17555
|
}
|
|
17001
17556
|
async function writeAtomicJson(filePath, value) {
|
|
17002
|
-
const resolved =
|
|
17557
|
+
const resolved = path11.resolve(filePath);
|
|
17003
17558
|
const tempPath = `${resolved}.tmp-${process.pid}-${Date.now()}`;
|
|
17004
17559
|
await writeFile9(tempPath, `${JSON.stringify(value, null, 2)}
|
|
17005
17560
|
`, "utf8");
|
|
17006
17561
|
await rename(tempPath, resolved);
|
|
17007
17562
|
}
|
|
17008
17563
|
async function withExecutionManifestLock(manifestPath, action) {
|
|
17009
|
-
const resolved =
|
|
17564
|
+
const resolved = path11.resolve(manifestPath);
|
|
17010
17565
|
const lockPath = `${resolved}.lock`;
|
|
17011
17566
|
let handle;
|
|
17012
17567
|
try {
|
|
@@ -17033,27 +17588,27 @@ async function assertExecutionManifestFresh(manifest, manifestPath) {
|
|
|
17033
17588
|
}
|
|
17034
17589
|
}
|
|
17035
17590
|
async function evidenceContainsDiagnostic(evidencePath) {
|
|
17036
|
-
const info = await
|
|
17591
|
+
const info = await stat7(evidencePath);
|
|
17037
17592
|
if (info.isDirectory()) {
|
|
17038
|
-
const entries = await
|
|
17593
|
+
const entries = await readdir4(evidencePath, { withFileTypes: true });
|
|
17039
17594
|
for (const entry of entries) {
|
|
17040
17595
|
if (!entry.isFile()) continue;
|
|
17041
17596
|
if (/diagnostic/i.test(entry.name)) return true;
|
|
17042
17597
|
if (!/\.(json|txt|md)$/i.test(entry.name)) continue;
|
|
17043
|
-
const value2 = await readText(
|
|
17598
|
+
const value2 = await readText(path11.join(evidencePath, entry.name)).catch(() => "");
|
|
17044
17599
|
if (/"?diagnostic"?\s*[:=]\s*(?:true|"diagnostic")|result\s*[:=]\s*diagnostic/i.test(value2)) return true;
|
|
17045
17600
|
}
|
|
17046
17601
|
return false;
|
|
17047
17602
|
}
|
|
17048
|
-
if (/diagnostic/i.test(
|
|
17603
|
+
if (/diagnostic/i.test(path11.basename(evidencePath))) return true;
|
|
17049
17604
|
if (!/\.(json|txt|md)$/i.test(evidencePath)) return false;
|
|
17050
17605
|
const value = await readText(evidencePath).catch(() => "");
|
|
17051
17606
|
return /"?diagnostic"?\s*[:=]\s*(?:true|"diagnostic")|result\s*[:=]\s*diagnostic/i.test(value);
|
|
17052
17607
|
}
|
|
17053
17608
|
function pathInside(root, candidate) {
|
|
17054
|
-
const resolvedRoot =
|
|
17055
|
-
const resolvedCandidate =
|
|
17056
|
-
return resolvedCandidate === resolvedRoot || resolvedCandidate.startsWith(`${resolvedRoot}${
|
|
17609
|
+
const resolvedRoot = path11.resolve(root);
|
|
17610
|
+
const resolvedCandidate = path11.resolve(candidate);
|
|
17611
|
+
return resolvedCandidate === resolvedRoot || resolvedCandidate.startsWith(`${resolvedRoot}${path11.sep}`);
|
|
17057
17612
|
}
|
|
17058
17613
|
async function pathInsideReal(root, candidate) {
|
|
17059
17614
|
if (!pathInside(root, candidate)) return false;
|
|
@@ -17077,16 +17632,16 @@ async function assertCurrentRunArtifact(manifest, artifactPath) {
|
|
|
17077
17632
|
if (!await exists3(artifactPath)) {
|
|
17078
17633
|
fail(`execution evidence artifact not found: ${artifactPath}`, { rule_id: "test_suite.run.evidence_missing", path: artifactPath });
|
|
17079
17634
|
}
|
|
17080
|
-
const info = await
|
|
17635
|
+
const info = await stat7(artifactPath);
|
|
17081
17636
|
if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
|
|
17082
17637
|
fail("execution evidence artifact predates the current run", { rule_id: "test_suite.run.evidence_stale", path: artifactPath });
|
|
17083
17638
|
}
|
|
17084
17639
|
}
|
|
17085
17640
|
async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
|
|
17086
17641
|
if (!await exists3(evidencePath)) fail(`execution evidence not found: ${evidencePath}`, { rule_id: "test_suite.run.evidence_missing", path: evidencePath });
|
|
17087
|
-
const runDir =
|
|
17642
|
+
const runDir = path11.dirname(path11.resolve(manifestPath));
|
|
17088
17643
|
await assertCurrentRunPathScope(runDir, evidencePath, "formal execution evidence must stay inside the current report run directory");
|
|
17089
|
-
const info = await
|
|
17644
|
+
const info = await stat7(evidencePath);
|
|
17090
17645
|
if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
|
|
17091
17646
|
fail("execution evidence predates the current run", { rule_id: "test_suite.run.evidence_stale", path: evidencePath });
|
|
17092
17647
|
}
|
|
@@ -17095,19 +17650,19 @@ async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
|
|
|
17095
17650
|
}
|
|
17096
17651
|
}
|
|
17097
17652
|
async function evidenceTexts(evidencePath) {
|
|
17098
|
-
const info = await
|
|
17653
|
+
const info = await stat7(evidencePath);
|
|
17099
17654
|
if (!info.isDirectory()) return [await readText(evidencePath).catch(() => "")];
|
|
17100
|
-
const entries = await
|
|
17655
|
+
const entries = await readdir4(evidencePath, { withFileTypes: true });
|
|
17101
17656
|
const texts = [];
|
|
17102
17657
|
for (const entry of entries) {
|
|
17103
17658
|
if (!entry.isFile() || !/\.(json|txt|md)$/i.test(entry.name)) continue;
|
|
17104
|
-
texts.push(await readText(
|
|
17659
|
+
texts.push(await readText(path11.join(evidencePath, entry.name)).catch(() => ""));
|
|
17105
17660
|
}
|
|
17106
17661
|
return texts;
|
|
17107
17662
|
}
|
|
17108
17663
|
async function evidenceJsonRecords(evidencePath) {
|
|
17109
|
-
const info = await
|
|
17110
|
-
const paths = info.isDirectory() ? (await
|
|
17664
|
+
const info = await stat7(evidencePath);
|
|
17665
|
+
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
17666
|
const records = [];
|
|
17112
17667
|
for (const source of paths) {
|
|
17113
17668
|
try {
|
|
@@ -17152,9 +17707,9 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
|
|
|
17152
17707
|
if (expectedResult !== "pass" && !assertions.some((assertion) => assertion.passed === false)) continue;
|
|
17153
17708
|
const screenshot = typeof value.screenshot === "string" ? value.screenshot.trim() : "";
|
|
17154
17709
|
if (!screenshot) continue;
|
|
17155
|
-
const screenshotPath =
|
|
17710
|
+
const screenshotPath = path11.resolve(path11.dirname(source), screenshot);
|
|
17156
17711
|
await assertCurrentRunArtifact(manifest, source);
|
|
17157
|
-
await assertCurrentRunPathScope(
|
|
17712
|
+
await assertCurrentRunPathScope(path11.dirname(manifestPath), screenshotPath, "browser screenshot must stay inside the current report run directory");
|
|
17158
17713
|
await assertCurrentRunArtifact(manifest, screenshotPath);
|
|
17159
17714
|
if (!await isValidCurrentRunScreenshot(screenshotPath)) {
|
|
17160
17715
|
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 +17717,8 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
|
|
|
17162
17717
|
if (/\bdom\b/i.test(step.evidence_required)) {
|
|
17163
17718
|
const domSnapshot = typeof value.dom_snapshot === "string" ? value.dom_snapshot.trim() : "";
|
|
17164
17719
|
if (!domSnapshot) continue;
|
|
17165
|
-
const domPath =
|
|
17166
|
-
await assertCurrentRunPathScope(
|
|
17720
|
+
const domPath = path11.resolve(path11.dirname(source), domSnapshot);
|
|
17721
|
+
await assertCurrentRunPathScope(path11.dirname(manifestPath), domPath, "browser DOM evidence must stay inside the current report run directory");
|
|
17167
17722
|
await assertCurrentRunArtifact(manifest, domPath);
|
|
17168
17723
|
}
|
|
17169
17724
|
matchedRecord = true;
|
|
@@ -17269,7 +17824,7 @@ async function browserReportEvidence(manifest) {
|
|
|
17269
17824
|
if (label) result.assertions.push(assertion.passed === false ? `\u5931\u8D25\u65AD\u8A00\uFF1A${label}` : label);
|
|
17270
17825
|
}
|
|
17271
17826
|
const screenshot = String(value.screenshot || "").trim();
|
|
17272
|
-
if (screenshot) result.screenshots.push({ stepId: step.step_id, path:
|
|
17827
|
+
if (screenshot) result.screenshots.push({ stepId: step.step_id, path: path11.resolve(path11.dirname(source), screenshot) });
|
|
17273
17828
|
}
|
|
17274
17829
|
}
|
|
17275
17830
|
}
|
|
@@ -17277,11 +17832,11 @@ async function browserReportEvidence(manifest) {
|
|
|
17277
17832
|
return result;
|
|
17278
17833
|
}
|
|
17279
17834
|
async function syncTestSuiteRunReportUnlocked(manifestFile) {
|
|
17280
|
-
const manifestPath =
|
|
17835
|
+
const manifestPath = path11.resolve(manifestFile);
|
|
17281
17836
|
const manifest = await readExecutionManifest(manifestPath);
|
|
17282
17837
|
await assertExecutionManifestFresh(manifest, manifestPath);
|
|
17283
|
-
const runDir =
|
|
17284
|
-
const reportPath =
|
|
17838
|
+
const runDir = path11.dirname(manifestPath);
|
|
17839
|
+
const reportPath = path11.join(runDir, `${manifest.scenario_id}.md`);
|
|
17285
17840
|
if (!await exists3(reportPath)) {
|
|
17286
17841
|
fail("scenario report scaffold is missing; restart the run or restore the generated report", { rule_id: "test_suite.run.report_missing", path: reportPath });
|
|
17287
17842
|
}
|
|
@@ -17309,7 +17864,7 @@ async function syncTestSuiteRunReportUnlocked(manifestFile) {
|
|
|
17309
17864
|
}
|
|
17310
17865
|
}
|
|
17311
17866
|
report = replaceReportMetadata(report, "browser_status", blockerEvidence ? "blocked" : null);
|
|
17312
|
-
report = replaceReportMetadata(report, "blocker_evidence", blockerEvidence ?
|
|
17867
|
+
report = replaceReportMetadata(report, "blocker_evidence", blockerEvidence ? path11.relative(runDir, blockerEvidence) : null);
|
|
17313
17868
|
report = replaceReportMetadata(report, "runtime_profile", manifest.profile);
|
|
17314
17869
|
report = replaceReportMetadata(report, "profile_origin", manifest.profile_origin || null);
|
|
17315
17870
|
report = replaceReportMetadata(report, "runtime_workspace", manifest.workspace || null);
|
|
@@ -17328,11 +17883,11 @@ async function syncTestSuiteRunReportUnlocked(manifestFile) {
|
|
|
17328
17883
|
`| ${manifest.case_id}`,
|
|
17329
17884
|
`${step.step_id} ${step.action}`,
|
|
17330
17885
|
step.status,
|
|
17331
|
-
step.evidence.length ? step.evidence.map((item) => `\`${
|
|
17886
|
+
step.evidence.length ? step.evidence.map((item) => `\`${path11.relative(runDir, item)}\``).join("<br>") : "pending"
|
|
17332
17887
|
].join(" | ") + " |")
|
|
17333
17888
|
].join("\n");
|
|
17334
17889
|
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
17891
|
report = replaceReportSection(report, "## 4. \u622A\u56FE\u8BC1\u636E", "## 5. \u63A5\u53E3 / \u6570\u636E\u56DE\u8BFB\u8BC1\u636E", screenshotBody);
|
|
17337
17892
|
const tempPath = `${reportPath}.tmp-${process.pid}`;
|
|
17338
17893
|
await writeFile9(tempPath, report, "utf8");
|
|
@@ -17351,7 +17906,7 @@ async function previousBrowserScreenshotHashes(manifest, step) {
|
|
|
17351
17906
|
for (const { value, source } of await evidenceJsonRecords(previousEvidence)) {
|
|
17352
17907
|
const screenshot = typeof value.screenshot === "string" ? value.screenshot.trim() : "";
|
|
17353
17908
|
if (!screenshot) continue;
|
|
17354
|
-
const screenshotPath =
|
|
17909
|
+
const screenshotPath = path11.resolve(path11.dirname(source), screenshot);
|
|
17355
17910
|
if (await exists3(screenshotPath)) hashes.add(await sha256(screenshotPath));
|
|
17356
17911
|
}
|
|
17357
17912
|
}
|
|
@@ -17385,12 +17940,12 @@ async function assertFormalExecutionEvidence(manifest, manifestPath, step, evide
|
|
|
17385
17940
|
const sourceEvidence = typeof value.source_evidence === "string" ? value.source_evidence : "";
|
|
17386
17941
|
if (!observed || assertions.length === 0 || !assertions.every((assertion) => assertion.passed === true) || !sourceEvidence) continue;
|
|
17387
17942
|
await assertCurrentRunArtifact(manifest, source);
|
|
17388
|
-
const sourcePath =
|
|
17389
|
-
const runDir =
|
|
17943
|
+
const sourcePath = path11.resolve(path11.dirname(source), sourceEvidence);
|
|
17944
|
+
const runDir = path11.dirname(path11.resolve(manifestPath));
|
|
17390
17945
|
if (!pathInside(runDir, sourcePath)) {
|
|
17391
17946
|
fail("observe source_evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: sourcePath });
|
|
17392
17947
|
}
|
|
17393
|
-
if (!await exists3(sourcePath) || !(await
|
|
17948
|
+
if (!await exists3(sourcePath) || !(await stat7(sourcePath)).isFile()) continue;
|
|
17394
17949
|
const [realRunDir, realSourcePath] = await Promise.all([realpath2(runDir), realpath2(sourcePath)]);
|
|
17395
17950
|
if (!pathInside(realRunDir, realSourcePath)) {
|
|
17396
17951
|
fail("observe source_evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: sourcePath });
|
|
@@ -17406,7 +17961,7 @@ async function writeExecutionManifest(manifestPath, manifest, incrementRevision
|
|
|
17406
17961
|
if (incrementRevision) manifest.revision = (manifest.revision ?? 0) + 1;
|
|
17407
17962
|
else manifest.revision ??= 0;
|
|
17408
17963
|
await writeAtomicJson(manifestPath, manifest);
|
|
17409
|
-
await writeAtomicJson(`${
|
|
17964
|
+
await writeAtomicJson(`${path11.resolve(manifestPath)}.state.json`, {
|
|
17410
17965
|
revision: manifest.revision,
|
|
17411
17966
|
hash: executionManifestHash(manifest),
|
|
17412
17967
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -17418,15 +17973,15 @@ function currentManifestStep(manifest) {
|
|
|
17418
17973
|
async function startTestSuiteRun(options) {
|
|
17419
17974
|
const scenarioDir = scenarioPath(options.suiteRoot ?? DEFAULT_SUITE_ROOT, options.scenario);
|
|
17420
17975
|
const scenario = await validateScenario(scenarioDir);
|
|
17421
|
-
const rows2 = await readCases(
|
|
17976
|
+
const rows2 = await readCases(path11.join(scenarioDir, "cases.csv"));
|
|
17422
17977
|
const row = rows2.find((item) => item.case_id === options.caseId && item.status !== "deprecated");
|
|
17423
17978
|
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(
|
|
17979
|
+
const allSteps = await readCaseSteps(path11.join(scenarioDir, "case_steps.csv"));
|
|
17980
|
+
const grouped = validateCaseSteps(path11.join(scenarioDir, "case_steps.csv"), rows2, allSteps);
|
|
17426
17981
|
const selectedSteps = grouped.get(options.caseId) ?? [];
|
|
17427
17982
|
const reportDir = await nextReportDir(options.reportRoot ?? DEFAULT_REPORT_ROOT, true);
|
|
17428
|
-
const runId =
|
|
17429
|
-
const manifestPath =
|
|
17983
|
+
const runId = path11.basename(reportDir);
|
|
17984
|
+
const manifestPath = path11.join(reportDir, "execution-manifest.json");
|
|
17430
17985
|
const manifest = {
|
|
17431
17986
|
version: 1,
|
|
17432
17987
|
run_id: runId,
|
|
@@ -17438,7 +17993,7 @@ async function startTestSuiteRun(options) {
|
|
|
17438
17993
|
revision: 0,
|
|
17439
17994
|
...options.skillSource ? { skill_source: options.skillSource } : {},
|
|
17440
17995
|
...options.skillVersion ? { skill_version: options.skillVersion } : {},
|
|
17441
|
-
source_suite:
|
|
17996
|
+
source_suite: path11.resolve(scenarioDir),
|
|
17442
17997
|
suite_hash: await suiteHash(scenarioDir),
|
|
17443
17998
|
rerun_policy: "full_rerun",
|
|
17444
17999
|
started_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -17448,7 +18003,7 @@ async function startTestSuiteRun(options) {
|
|
|
17448
18003
|
};
|
|
17449
18004
|
await writeExecutionManifest(manifestPath, manifest);
|
|
17450
18005
|
await writeFile9(
|
|
17451
|
-
|
|
18006
|
+
path11.join(reportDir, "ux-findings.json"),
|
|
17452
18007
|
`${JSON.stringify({
|
|
17453
18008
|
version: 1,
|
|
17454
18009
|
run_id: runId,
|
|
@@ -17460,14 +18015,14 @@ async function startTestSuiteRun(options) {
|
|
|
17460
18015
|
`,
|
|
17461
18016
|
"utf8"
|
|
17462
18017
|
);
|
|
17463
|
-
const scenarioReport =
|
|
18018
|
+
const scenarioReport = path11.join(reportDir, `${options.scenario}.md`);
|
|
17464
18019
|
const plannedSteps = selectedSteps.map((step) => `${options.caseId}/${step.step_id}`).join(", ");
|
|
17465
18020
|
await writeFile9(
|
|
17466
18021
|
scenarioReport,
|
|
17467
18022
|
[
|
|
17468
18023
|
`run_id: ${runId}`,
|
|
17469
18024
|
`scenario_id: ${options.scenario}`,
|
|
17470
|
-
`source_suite: ${
|
|
18025
|
+
`source_suite: ${path11.resolve(scenarioDir)}`,
|
|
17471
18026
|
"result: partial",
|
|
17472
18027
|
"test_design_skill: bpmax-functional-test-design",
|
|
17473
18028
|
"ux_audit_skill: bpmax-ui-ux-audit",
|
|
@@ -17482,7 +18037,7 @@ async function startTestSuiteRun(options) {
|
|
|
17482
18037
|
`planned_steps: ${plannedSteps}`,
|
|
17483
18038
|
"executed_steps: pending",
|
|
17484
18039
|
"execution_manifest: execution-manifest.json",
|
|
17485
|
-
`precondition_check: ${
|
|
18040
|
+
`precondition_check: ${path11.join(reportDir, `precondition-${runId}.json`)}`,
|
|
17486
18041
|
`state_file: ${manifestPath}`,
|
|
17487
18042
|
`report_run: ${reportDir}`,
|
|
17488
18043
|
"browser_tool: Chrome DevTools",
|
|
@@ -17524,7 +18079,7 @@ async function startTestSuiteRun(options) {
|
|
|
17524
18079
|
};
|
|
17525
18080
|
}
|
|
17526
18081
|
async function validateExecutionManifestStep(options) {
|
|
17527
|
-
const manifestPath =
|
|
18082
|
+
const manifestPath = path11.resolve(options.manifest);
|
|
17528
18083
|
const manifest = await readExecutionManifest(manifestPath);
|
|
17529
18084
|
if (manifest.case_id !== options.caseId || manifest.current_step_id !== options.caseStepId) {
|
|
17530
18085
|
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 +18099,11 @@ async function validateExecutionManifestStep(options) {
|
|
|
17544
18099
|
return { manifestPath, manifest, step };
|
|
17545
18100
|
}
|
|
17546
18101
|
async function preflightExecutionEvidenceDirectory(options) {
|
|
17547
|
-
const manifestPath =
|
|
18102
|
+
const manifestPath = path11.resolve(options.manifest);
|
|
17548
18103
|
const manifest = await readExecutionManifest(manifestPath);
|
|
17549
18104
|
await assertExecutionManifestFresh(manifest, manifestPath);
|
|
17550
|
-
const runDir =
|
|
17551
|
-
const evidenceDir =
|
|
18105
|
+
const runDir = path11.dirname(manifestPath);
|
|
18106
|
+
const evidenceDir = path11.resolve(options.evidenceDir);
|
|
17552
18107
|
if (!pathInside(runDir, evidenceDir)) {
|
|
17553
18108
|
fail("formal execution evidence must stay inside the current report run directory", {
|
|
17554
18109
|
rule_id: "test_suite.run.evidence_scope",
|
|
@@ -17572,10 +18127,10 @@ async function preflightExecutionEvidenceDirectory(options) {
|
|
|
17572
18127
|
suggestion: `Remove the symlink and use a real directory under ${runDir}.`
|
|
17573
18128
|
});
|
|
17574
18129
|
}
|
|
17575
|
-
const probe =
|
|
18130
|
+
const probe = path11.join(evidenceDir, `.bpmax-write-probe-${process.pid}-${Date.now()}`);
|
|
17576
18131
|
try {
|
|
17577
18132
|
await writeFile9(probe, "ok", "utf8");
|
|
17578
|
-
await
|
|
18133
|
+
await readFile12(probe, "utf8");
|
|
17579
18134
|
} catch (error) {
|
|
17580
18135
|
fail(`formal execution evidence directory is not writable: ${error instanceof Error ? error.message : String(error)}`, {
|
|
17581
18136
|
rule_id: "test_suite.run.evidence_unwritable",
|
|
@@ -17589,7 +18144,7 @@ async function preflightExecutionEvidenceDirectory(options) {
|
|
|
17589
18144
|
async function appendExecutionManifestEvidence(options) {
|
|
17590
18145
|
await withExecutionManifestLock(options.manifest, async () => {
|
|
17591
18146
|
const validated = await validateExecutionManifestStep(options);
|
|
17592
|
-
const evidencePath =
|
|
18147
|
+
const evidencePath = path11.resolve(options.evidence);
|
|
17593
18148
|
await assertCurrentRunEvidence(validated.manifest, validated.manifestPath, evidencePath);
|
|
17594
18149
|
validated.step.evidence = [.../* @__PURE__ */ new Set([...validated.step.evidence, evidencePath])];
|
|
17595
18150
|
await writeExecutionManifest(validated.manifestPath, validated.manifest, true);
|
|
@@ -17597,7 +18152,7 @@ async function appendExecutionManifestEvidence(options) {
|
|
|
17597
18152
|
}
|
|
17598
18153
|
async function nextTestSuiteRunStep(manifestPath, profile) {
|
|
17599
18154
|
const manifest = await readExecutionManifest(manifestPath);
|
|
17600
|
-
await assertExecutionManifestFresh(manifest,
|
|
18155
|
+
await assertExecutionManifestFresh(manifest, path11.resolve(manifestPath));
|
|
17601
18156
|
if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
|
|
17602
18157
|
const step = currentManifestStep(manifest);
|
|
17603
18158
|
if (!step) return { ok: true, complete: true, result: manifest.result, execution: manifest };
|
|
@@ -17608,7 +18163,7 @@ async function recordTestSuiteRunStep(options) {
|
|
|
17608
18163
|
if (!["pass", "fail", "blocked"].includes(options.result)) fail("run record result must be pass, fail, or blocked", { rule_id: "test_suite.run.result" });
|
|
17609
18164
|
return withExecutionManifestLock(options.manifest, async () => {
|
|
17610
18165
|
const validated = await validateExecutionManifestStep(options);
|
|
17611
|
-
const evidencePath =
|
|
18166
|
+
const evidencePath = path11.resolve(options.evidence);
|
|
17612
18167
|
await assertCurrentRunEvidence(validated.manifest, validated.manifestPath, evidencePath);
|
|
17613
18168
|
if (options.result === "pass") await assertFormalExecutionEvidence(validated.manifest, validated.manifestPath, validated.step, evidencePath);
|
|
17614
18169
|
if (options.result !== "pass" && !["browser", "e2e_create_page"].includes(validated.step.runner)) {
|
|
@@ -17661,7 +18216,7 @@ async function recordTestSuiteRunStep(options) {
|
|
|
17661
18216
|
}
|
|
17662
18217
|
async function testSuiteRunStatus(manifestPath, profile) {
|
|
17663
18218
|
const manifest = await readExecutionManifest(manifestPath);
|
|
17664
|
-
await assertExecutionManifestFresh(manifest,
|
|
18219
|
+
await assertExecutionManifestFresh(manifest, path11.resolve(manifestPath));
|
|
17665
18220
|
if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
|
|
17666
18221
|
return { ok: true, execution: manifest };
|
|
17667
18222
|
}
|
|
@@ -17694,9 +18249,9 @@ function validateLatestProofObject(proofPath, proof) {
|
|
|
17694
18249
|
}
|
|
17695
18250
|
function scenarioPath(root, scenario) {
|
|
17696
18251
|
if (!SCENARIO_ID_RE.test(scenario)) fail(`invalid scenario id: ${scenario}`);
|
|
17697
|
-
const rootResolved =
|
|
17698
|
-
const candidate =
|
|
17699
|
-
if (!candidate.startsWith(`${rootResolved}${
|
|
18252
|
+
const rootResolved = path11.resolve(root);
|
|
18253
|
+
const candidate = path11.resolve(root, scenario);
|
|
18254
|
+
if (!candidate.startsWith(`${rootResolved}${path11.sep}`) && candidate !== rootResolved) {
|
|
17700
18255
|
fail(`scenario path escapes root: ${candidate}`);
|
|
17701
18256
|
}
|
|
17702
18257
|
return candidate;
|
|
@@ -17704,14 +18259,14 @@ function scenarioPath(root, scenario) {
|
|
|
17704
18259
|
async function fileMap(root) {
|
|
17705
18260
|
const result = /* @__PURE__ */ new Map();
|
|
17706
18261
|
async function walk(dir) {
|
|
17707
|
-
for (const item of await
|
|
17708
|
-
const itemPath =
|
|
17709
|
-
const rel =
|
|
17710
|
-
if (rel.split(
|
|
18262
|
+
for (const item of await readdir4(dir, { withFileTypes: true })) {
|
|
18263
|
+
const itemPath = path11.join(dir, item.name);
|
|
18264
|
+
const rel = path11.relative(root, itemPath);
|
|
18265
|
+
if (rel.split(path11.sep)[0] === COPY_DIFF_DIR) continue;
|
|
17711
18266
|
if (item.isDirectory()) {
|
|
17712
18267
|
await walk(itemPath);
|
|
17713
18268
|
} else if (item.isFile()) {
|
|
17714
|
-
result.set(rel.split(
|
|
18269
|
+
result.set(rel.split(path11.sep).join("/"), itemPath);
|
|
17715
18270
|
}
|
|
17716
18271
|
}
|
|
17717
18272
|
}
|
|
@@ -17719,10 +18274,10 @@ async function fileMap(root) {
|
|
|
17719
18274
|
return result;
|
|
17720
18275
|
}
|
|
17721
18276
|
async function sha256(filePath) {
|
|
17722
|
-
return createHash5("sha256").update(await
|
|
18277
|
+
return createHash5("sha256").update(await readFile12(filePath)).digest("hex");
|
|
17723
18278
|
}
|
|
17724
18279
|
async function readForDiff(filePath) {
|
|
17725
|
-
const buffer = await
|
|
18280
|
+
const buffer = await readFile12(filePath);
|
|
17726
18281
|
if (buffer.includes(0)) return [`<binary sha256=${createHash5("sha256").update(buffer).digest("hex")}>
|
|
17727
18282
|
`];
|
|
17728
18283
|
return buffer.toString("utf8").split(/(?<=\n)/);
|
|
@@ -17782,7 +18337,7 @@ async function buildCopyDiff(src, dst, operation) {
|
|
|
17782
18337
|
return {
|
|
17783
18338
|
manifest: {
|
|
17784
18339
|
operation,
|
|
17785
|
-
scenario_id:
|
|
18340
|
+
scenario_id: path11.basename(src),
|
|
17786
18341
|
source: src,
|
|
17787
18342
|
destination: dst,
|
|
17788
18343
|
generated_at: (/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "+00:00"),
|
|
@@ -17795,12 +18350,12 @@ async function buildCopyDiff(src, dst, operation) {
|
|
|
17795
18350
|
};
|
|
17796
18351
|
}
|
|
17797
18352
|
async function writeCopyDiffArtifacts(dst, artifacts) {
|
|
17798
|
-
const diffDir =
|
|
18353
|
+
const diffDir = path11.join(dst, COPY_DIFF_DIR);
|
|
17799
18354
|
await mkdir9(diffDir, { recursive: true });
|
|
17800
|
-
await writeFile9(
|
|
17801
|
-
await writeFile9(
|
|
18355
|
+
await writeFile9(path11.join(diffDir, "last.diff"), artifacts.diff, "utf8");
|
|
18356
|
+
await writeFile9(path11.join(diffDir, "last.json"), `${JSON.stringify(artifacts.manifest, null, 2)}
|
|
17802
18357
|
`, "utf8");
|
|
17803
|
-
return
|
|
18358
|
+
return path11.join(diffDir, "last.diff");
|
|
17804
18359
|
}
|
|
17805
18360
|
function summarizeCopyDiff(artifacts) {
|
|
17806
18361
|
const files = Array.isArray(artifacts.manifest.files) ? artifacts.manifest.files : [];
|
|
@@ -17826,12 +18381,12 @@ async function copyScenarioTree(src, dst, replace, operation) {
|
|
|
17826
18381
|
artifacts = await buildCopyDiff(src, dst, operation);
|
|
17827
18382
|
await rm4(dst, { recursive: true, force: true });
|
|
17828
18383
|
}
|
|
17829
|
-
await mkdir9(
|
|
18384
|
+
await mkdir9(path11.dirname(dst), { recursive: true });
|
|
17830
18385
|
await cp3(src, dst, { recursive: true });
|
|
17831
18386
|
return artifacts ? { path: await writeCopyDiffArtifacts(dst, artifacts), summary: summarizeCopyDiff(artifacts) } : {};
|
|
17832
18387
|
}
|
|
17833
18388
|
async function copyDiffPreview(src, dst, operation) {
|
|
17834
|
-
const previewDir =
|
|
18389
|
+
const previewDir = path11.join(DEFAULT_TMP_ROOT, `${operation}-${path11.basename(src)}-copy-diff`);
|
|
17835
18390
|
await rm4(previewDir, { recursive: true, force: true });
|
|
17836
18391
|
await mkdir9(previewDir, { recursive: true });
|
|
17837
18392
|
const artifacts = await buildCopyDiff(src, dst, operation);
|
|
@@ -17853,7 +18408,7 @@ async function draftUpdate(options) {
|
|
|
17853
18408
|
return { destination: dst, copy_diff: copyDiff.path, copy_diff_summary: copyDiff.summary };
|
|
17854
18409
|
}
|
|
17855
18410
|
async function validateReviewGate(scenarioDir) {
|
|
17856
|
-
const reviewPath =
|
|
18411
|
+
const reviewPath = path11.join(scenarioDir, "review.json");
|
|
17857
18412
|
if (!await exists3(reviewPath)) reviewFail(reviewPath, `${scenarioDir}: missing review.json; run multi-subagent SKILL review before promote`);
|
|
17858
18413
|
let review;
|
|
17859
18414
|
try {
|
|
@@ -17861,7 +18416,7 @@ async function validateReviewGate(scenarioDir) {
|
|
|
17861
18416
|
} catch (error) {
|
|
17862
18417
|
reviewFail(reviewPath, `${reviewPath}: invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
17863
18418
|
}
|
|
17864
|
-
if (review.scenario_id !==
|
|
18419
|
+
if (review.scenario_id !== path11.basename(scenarioDir)) reviewFail(reviewPath, `${reviewPath}: scenario_id must match directory name`);
|
|
17865
18420
|
if (!review.latest_proof || typeof review.latest_proof !== "object" || Array.isArray(review.latest_proof)) reviewFail(reviewPath, `${reviewPath}: latest_proof is required`);
|
|
17866
18421
|
validateLatestProofObject(reviewPath, review.latest_proof);
|
|
17867
18422
|
if (!REVIEW_STATUSES.has(String(review.status))) reviewFail(reviewPath, `${reviewPath}: status must be one of ${JSON.stringify([...REVIEW_STATUSES].sort())}`);
|
|
@@ -17886,8 +18441,8 @@ async function validateReviewGate(scenarioDir) {
|
|
|
17886
18441
|
if (!Array.isArray(review.fixes) || review.fixes.length === 0) reviewFail(reviewPath, `${reviewPath}: fixes must be a non-empty list`);
|
|
17887
18442
|
}
|
|
17888
18443
|
async function validateExecutionOperabilityReview(reviewPath, scenarioDir, item) {
|
|
17889
|
-
const rows2 = await readCases(
|
|
17890
|
-
const steps = await readCaseSteps(
|
|
18444
|
+
const rows2 = await readCases(path11.join(scenarioDir, "cases.csv"));
|
|
18445
|
+
const steps = await readCaseSteps(path11.join(scenarioDir, "case_steps.csv"));
|
|
17891
18446
|
const activeCases = new Set(rows2.filter((row) => row.status !== "deprecated").map((row) => row.case_id));
|
|
17892
18447
|
const required = steps.filter((step) => activeCases.has(step.case_id)).map((step) => `${step.case_id}/${step.step_id}`);
|
|
17893
18448
|
const judgments = item.step_judgments;
|
|
@@ -18011,10 +18566,10 @@ async function initOrRepairReview(options) {
|
|
|
18011
18566
|
const scenarioDir = scenarioPath(options.draftRoot ?? DEFAULT_DRAFT_ROOT, options.scenario);
|
|
18012
18567
|
if (!await exists3(scenarioDir)) fail(`draft scenario not found: ${scenarioDir}`);
|
|
18013
18568
|
await validateReadme(scenarioDir);
|
|
18014
|
-
const rows2 = await readCases(
|
|
18015
|
-
const steps = await readCaseSteps(
|
|
18569
|
+
const rows2 = await readCases(path11.join(scenarioDir, "cases.csv"));
|
|
18570
|
+
const steps = await readCaseSteps(path11.join(scenarioDir, "case_steps.csv"));
|
|
18016
18571
|
const proof = await readLatestProof(options.latestProof);
|
|
18017
|
-
const reviewPath =
|
|
18572
|
+
const reviewPath = path11.join(scenarioDir, "review.json");
|
|
18018
18573
|
let existing;
|
|
18019
18574
|
const existed = await exists3(reviewPath);
|
|
18020
18575
|
if (existed) {
|
|
@@ -18025,7 +18580,7 @@ async function initOrRepairReview(options) {
|
|
|
18025
18580
|
existing = {};
|
|
18026
18581
|
}
|
|
18027
18582
|
}
|
|
18028
|
-
const review = mergeReviewDraft(
|
|
18583
|
+
const review = mergeReviewDraft(path11.basename(scenarioDir), proof, rows2, steps, existing);
|
|
18029
18584
|
await writeFile9(reviewPath, `${JSON.stringify(review, null, 2)}
|
|
18030
18585
|
`, "utf8");
|
|
18031
18586
|
return {
|
|
@@ -18060,16 +18615,16 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
|
|
|
18060
18615
|
String(today.getDate()).padStart(2, "0")
|
|
18061
18616
|
].join("");
|
|
18062
18617
|
const dirs = await scenarioDirs(root);
|
|
18063
|
-
const nums = dirs.map((dir) =>
|
|
18064
|
-
const reportDir =
|
|
18618
|
+
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));
|
|
18619
|
+
const reportDir = path11.join(root, `${prefix}-${String(Math.max(0, ...nums) + 1).padStart(3, "0")}`);
|
|
18065
18620
|
if (create) {
|
|
18066
|
-
await mkdir9(
|
|
18621
|
+
await mkdir9(path11.join(reportDir, "screenshots"), { recursive: true });
|
|
18067
18622
|
await writeFile9(
|
|
18068
|
-
|
|
18623
|
+
path11.join(reportDir, "summary.md"),
|
|
18069
18624
|
[
|
|
18070
18625
|
"# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B",
|
|
18071
18626
|
"",
|
|
18072
|
-
`run_id: ${
|
|
18627
|
+
`run_id: ${path11.basename(reportDir)}`,
|
|
18073
18628
|
"rerun_policy: full_rerun",
|
|
18074
18629
|
"status: draft",
|
|
18075
18630
|
"",
|
|
@@ -18077,7 +18632,7 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
|
|
|
18077
18632
|
"",
|
|
18078
18633
|
"## \u622A\u56FE\u76EE\u5F55",
|
|
18079
18634
|
"",
|
|
18080
|
-
`screenshots: ${
|
|
18635
|
+
`screenshots: ${path11.join(path11.basename(reportDir), "screenshots")}`,
|
|
18081
18636
|
"",
|
|
18082
18637
|
"## \u603B\u7ED3",
|
|
18083
18638
|
""
|
|
@@ -18112,7 +18667,7 @@ function crc32(value) {
|
|
|
18112
18667
|
return (crc ^ 4294967295) >>> 0;
|
|
18113
18668
|
}
|
|
18114
18669
|
async function isValidCurrentRunScreenshot(filePath) {
|
|
18115
|
-
const buffer = await
|
|
18670
|
+
const buffer = await readFile12(filePath);
|
|
18116
18671
|
const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
18117
18672
|
if (buffer.length < 33 || !buffer.subarray(0, 8).equals(signature)) return false;
|
|
18118
18673
|
let offset = 8;
|
|
@@ -18370,8 +18925,8 @@ async function reportHasValidBlockedEvidence(text5, reportPath, runDir, manifest
|
|
|
18370
18925
|
if (reportKeyValue(text5, "browser_status:").toLowerCase() !== "blocked") return false;
|
|
18371
18926
|
const evidenceValue = reportKeyValue(text5, "blocker_evidence:");
|
|
18372
18927
|
if (!evidenceValue) return false;
|
|
18373
|
-
const evidencePath =
|
|
18374
|
-
if (!await exists3(evidencePath) || !(await
|
|
18928
|
+
const evidencePath = path11.resolve(path11.dirname(reportPath), evidenceValue);
|
|
18929
|
+
if (!await exists3(evidencePath) || !(await stat7(evidencePath)).isFile() || !await pathInsideReal(runDir, evidencePath)) return false;
|
|
18375
18930
|
await assertCurrentRunArtifact(manifest, evidencePath);
|
|
18376
18931
|
const blockedStep = manifest.steps.find((step) => step.status === "blocked");
|
|
18377
18932
|
return Boolean(
|
|
@@ -18398,7 +18953,7 @@ async function uxManifestArtifacts(text5, reportPath, runDir) {
|
|
|
18398
18953
|
const artifacts = /* @__PURE__ */ new Set();
|
|
18399
18954
|
const manifestValue = reportKeyValue(text5, "execution_manifest:");
|
|
18400
18955
|
if (!manifestValue) return artifacts;
|
|
18401
|
-
const manifestPath =
|
|
18956
|
+
const manifestPath = path11.resolve(path11.dirname(reportPath), manifestValue);
|
|
18402
18957
|
if (!pathInside(runDir, manifestPath) || !await exists3(manifestPath) || !await pathInsideReal(runDir, manifestPath)) {
|
|
18403
18958
|
return artifacts;
|
|
18404
18959
|
}
|
|
@@ -18406,15 +18961,15 @@ async function uxManifestArtifacts(text5, reportPath, runDir) {
|
|
|
18406
18961
|
const manifest = JSON.parse(await readText(manifestPath));
|
|
18407
18962
|
for (const step of manifest.steps ?? []) {
|
|
18408
18963
|
for (const item of step.evidence ?? []) {
|
|
18409
|
-
const evidencePath =
|
|
18964
|
+
const evidencePath = path11.isAbsolute(item) ? path11.resolve(item) : path11.resolve(path11.dirname(manifestPath), item);
|
|
18410
18965
|
if (!pathInside(runDir, evidencePath) || !await exists3(evidencePath) || !await pathInsideReal(runDir, evidencePath)) continue;
|
|
18411
18966
|
artifacts.add(evidencePath);
|
|
18412
18967
|
for (const { value, source } of await evidenceJsonRecords(evidencePath)) {
|
|
18413
|
-
artifacts.add(
|
|
18968
|
+
artifacts.add(path11.resolve(source));
|
|
18414
18969
|
for (const key of ["screenshot", "dom_snapshot", "source_evidence"]) {
|
|
18415
18970
|
const referenced = typeof value[key] === "string" ? value[key].trim() : "";
|
|
18416
18971
|
if (!referenced) continue;
|
|
18417
|
-
const referencedPath =
|
|
18972
|
+
const referencedPath = path11.resolve(path11.dirname(source), referenced);
|
|
18418
18973
|
if (pathInside(runDir, referencedPath) && await exists3(referencedPath) && await pathInsideReal(runDir, referencedPath)) {
|
|
18419
18974
|
artifacts.add(referencedPath);
|
|
18420
18975
|
}
|
|
@@ -18430,12 +18985,12 @@ async function validateUxEvidence(values, options) {
|
|
|
18430
18985
|
const errors = [];
|
|
18431
18986
|
const mtimes = [];
|
|
18432
18987
|
for (const evidenceValue of values) {
|
|
18433
|
-
const evidencePath =
|
|
18988
|
+
const evidencePath = path11.resolve(options.runDir, evidenceValue);
|
|
18434
18989
|
if (!pathInside(options.runDir, evidencePath) || !await exists3(evidencePath) || !await pathInsideReal(options.runDir, evidencePath) || evidencePath === options.findingsPath) {
|
|
18435
18990
|
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
18991
|
continue;
|
|
18437
18992
|
}
|
|
18438
|
-
const info = await
|
|
18993
|
+
const info = await stat7(evidencePath);
|
|
18439
18994
|
if (!info.isFile()) {
|
|
18440
18995
|
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
18996
|
continue;
|
|
@@ -18446,7 +19001,7 @@ async function validateUxEvidence(values, options) {
|
|
|
18446
19001
|
if (!isWithinWindow(info.mtime, options.window)) {
|
|
18447
19002
|
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
19003
|
}
|
|
18449
|
-
const extension =
|
|
19004
|
+
const extension = path11.extname(evidencePath).toLowerCase();
|
|
18450
19005
|
if (extension === ".png") {
|
|
18451
19006
|
if (!await isValidCurrentRunScreenshot(evidencePath)) {
|
|
18452
19007
|
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 +19049,7 @@ async function lintUxAudit(text5, reportPath, runDir, runName) {
|
|
|
18494
19049
|
if (!findingsValue) {
|
|
18495
19050
|
errors.push(`[test_suite.report.ux_findings_missing] ${reportPath}: missing \`ux_findings:\``);
|
|
18496
19051
|
} else {
|
|
18497
|
-
const findingsPath =
|
|
19052
|
+
const findingsPath = path11.resolve(path11.dirname(reportPath), findingsValue);
|
|
18498
19053
|
if (!pathInside(runDir, findingsPath)) {
|
|
18499
19054
|
errors.push(`[test_suite.report.ux_findings_scope] ${reportPath}: ux_findings \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
|
|
18500
19055
|
} else if (!await exists3(findingsPath)) {
|
|
@@ -18548,8 +19103,8 @@ async function lintUxAudit(text5, reportPath, runDir, runName) {
|
|
|
18548
19103
|
window
|
|
18549
19104
|
});
|
|
18550
19105
|
errors.push(...retestCheck.errors);
|
|
18551
|
-
const initialPaths = new Set(finding.evidence.map((item) =>
|
|
18552
|
-
if (finding.retest_evidence.some((item) => initialPaths.has(
|
|
19106
|
+
const initialPaths = new Set(finding.evidence.map((item) => path11.resolve(runDir, item)));
|
|
19107
|
+
if (finding.retest_evidence.some((item) => initialPaths.has(path11.resolve(runDir, item)))) {
|
|
18553
19108
|
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
19109
|
}
|
|
18555
19110
|
const latestInitial = Math.max(...evidenceCheck.mtimes.map((item) => item.getTime()));
|
|
@@ -18601,22 +19156,22 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18601
19156
|
if (!await exists3(root)) return { errors: [`report root not found: ${root}`], reports: [] };
|
|
18602
19157
|
const errors = [];
|
|
18603
19158
|
const reports = [];
|
|
18604
|
-
const resolvedRoot =
|
|
18605
|
-
const candidateDirs = RUN_RE.test(
|
|
19159
|
+
const resolvedRoot = path11.resolve(root);
|
|
19160
|
+
const candidateDirs = RUN_RE.test(path11.basename(resolvedRoot)) ? [resolvedRoot] : (await scenarioDirs(resolvedRoot)).filter((dir) => RUN_RE.test(path11.basename(dir)));
|
|
18606
19161
|
if (candidateDirs.length === 0) return { errors: [`report run not found under: ${resolvedRoot}`], reports };
|
|
18607
19162
|
const runDirs = options.allRuns ? candidateDirs : candidateDirs.slice(-1);
|
|
18608
19163
|
for (const runDir of runDirs) {
|
|
18609
|
-
const runName =
|
|
19164
|
+
const runName = path11.basename(runDir);
|
|
18610
19165
|
if (!RUN_RE.test(runName)) {
|
|
18611
19166
|
errors.push(`${runDir}: run directory name must be YYYYMMDD-NNN`);
|
|
18612
19167
|
continue;
|
|
18613
19168
|
}
|
|
18614
|
-
if (!await exists3(
|
|
18615
|
-
const files = await
|
|
19169
|
+
if (!await exists3(path11.join(runDir, "summary.md"))) errors.push(`${runDir}: missing summary.md`);
|
|
19170
|
+
const files = await readdir4(runDir);
|
|
18616
19171
|
const scenarioReports = files.filter((file) => file.endsWith(".md") && file !== "summary.md");
|
|
18617
19172
|
if (scenarioReports.length === 0) errors.push(`${runDir}: missing scenario report markdown`);
|
|
18618
19173
|
for (const reportName of scenarioReports) {
|
|
18619
|
-
const reportPath =
|
|
19174
|
+
const reportPath = path11.join(runDir, reportName);
|
|
18620
19175
|
const text5 = await readText(reportPath);
|
|
18621
19176
|
const uxAudit = await lintUxAudit(text5, reportPath, runDir, runName);
|
|
18622
19177
|
errors.push(...uxAudit.errors);
|
|
@@ -18661,8 +19216,8 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18661
19216
|
}
|
|
18662
19217
|
const manifestValue = reportKeyValue(text5, "execution_manifest:");
|
|
18663
19218
|
if (manifestValue) {
|
|
18664
|
-
const manifestPath =
|
|
18665
|
-
const runRoot =
|
|
19219
|
+
const manifestPath = path11.resolve(path11.dirname(reportPath), manifestValue);
|
|
19220
|
+
const runRoot = path11.resolve(runDir);
|
|
18666
19221
|
if (!pathInside(runRoot, manifestPath)) {
|
|
18667
19222
|
errors.push(`[test_suite.report.execution_manifest_scope] ${reportPath}: execution_manifest \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
|
|
18668
19223
|
} else if (!await exists3(manifestPath)) {
|
|
@@ -18694,7 +19249,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18694
19249
|
if (validTerminalStop && !["browser", "e2e_create_page"].includes(manifest.steps[terminalIndex].runner)) {
|
|
18695
19250
|
const terminalStep = manifest.steps[terminalIndex];
|
|
18696
19251
|
for (const evidencePath of terminalStep.evidence) {
|
|
18697
|
-
const resolvedEvidencePath =
|
|
19252
|
+
const resolvedEvidencePath = path11.isAbsolute(evidencePath) ? path11.resolve(evidencePath) : path11.resolve(path11.dirname(manifestPath), evidencePath);
|
|
18698
19253
|
if (!pathInside(runRoot, resolvedEvidencePath) || !await pathInsideReal(runRoot, resolvedEvidencePath)) {
|
|
18699
19254
|
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
19255
|
continue;
|
|
@@ -18771,7 +19326,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18771
19326
|
if (/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|诊断/.test(resultValue)) {
|
|
18772
19327
|
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
19328
|
}
|
|
18774
|
-
const screenshotsDir =
|
|
19329
|
+
const screenshotsDir = path11.join(runDir, "screenshots");
|
|
18775
19330
|
if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
|
|
18776
19331
|
if (isFullRerun) {
|
|
18777
19332
|
for (const key of ["state_file:", "precondition_check:", "report_run:"]) {
|
|
@@ -18796,9 +19351,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18796
19351
|
errors.push(`${reportPath}: screenshot must be a local file under this run's screenshots directory`);
|
|
18797
19352
|
continue;
|
|
18798
19353
|
}
|
|
18799
|
-
const imagePath =
|
|
18800
|
-
const screenshotsResolved =
|
|
18801
|
-
if (!imagePath.startsWith(`${screenshotsResolved}${
|
|
19354
|
+
const imagePath = path11.resolve(path11.dirname(reportPath), imageRef);
|
|
19355
|
+
const screenshotsResolved = path11.resolve(screenshotsDir);
|
|
19356
|
+
if (!imagePath.startsWith(`${screenshotsResolved}${path11.sep}`)) {
|
|
18802
19357
|
errors.push(`${reportPath}: image reference must stay under this run's screenshots directory: ${imageRef}`);
|
|
18803
19358
|
continue;
|
|
18804
19359
|
}
|
|
@@ -18812,7 +19367,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18812
19367
|
}
|
|
18813
19368
|
validCurrentRunImages.push(imageRef);
|
|
18814
19369
|
if (isFullRerun) {
|
|
18815
|
-
const imageStat = await
|
|
19370
|
+
const imageStat = await stat7(imagePath);
|
|
18816
19371
|
if (!isWithinWindow(imageStat.mtime, window)) {
|
|
18817
19372
|
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
19373
|
}
|
|
@@ -18836,10 +19391,10 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
18836
19391
|
return { errors, reports };
|
|
18837
19392
|
}
|
|
18838
19393
|
async function validateCopyDiffArtifacts(scenarioDir) {
|
|
18839
|
-
const diffDir =
|
|
19394
|
+
const diffDir = path11.join(scenarioDir, COPY_DIFF_DIR);
|
|
18840
19395
|
if (!await exists3(diffDir)) return;
|
|
18841
|
-
const manifestPath =
|
|
18842
|
-
const diffPath =
|
|
19396
|
+
const manifestPath = path11.join(diffDir, "last.json");
|
|
19397
|
+
const diffPath = path11.join(diffDir, "last.diff");
|
|
18843
19398
|
if (!await exists3(manifestPath)) fail(`${scenarioDir}: ${COPY_DIFF_DIR}/last.json is required when copy diff artifacts exist`);
|
|
18844
19399
|
if (!await exists3(diffPath)) fail(`${scenarioDir}: ${COPY_DIFF_DIR}/last.diff is required when copy diff artifacts exist`);
|
|
18845
19400
|
let manifest;
|
|
@@ -18851,7 +19406,7 @@ async function validateCopyDiffArtifacts(scenarioDir) {
|
|
|
18851
19406
|
for (const key of ["operation", "scenario_id", "source", "destination", "generated_at", "summary", "diff_file", "files"]) {
|
|
18852
19407
|
if (!(key in manifest)) fail(`${manifestPath}: missing \`${key}\``);
|
|
18853
19408
|
}
|
|
18854
|
-
if (manifest.scenario_id !==
|
|
19409
|
+
if (manifest.scenario_id !== path11.basename(scenarioDir)) fail(`${manifestPath}: scenario_id must match directory name`);
|
|
18855
19410
|
if (manifest.diff_file !== "last.diff") fail(`${manifestPath}: diff_file must be last.diff`);
|
|
18856
19411
|
if (!(await readText(diffPath)).trim()) fail(`${diffPath}: copy diff must not be empty`);
|
|
18857
19412
|
}
|
|
@@ -18875,7 +19430,7 @@ var OPTION_NAMES = ["options", "items", "choices", "values"];
|
|
|
18875
19430
|
var REQUIRED_NAMES = ["required", "is_required", "isRequired", "require", "must", "validateRequired"];
|
|
18876
19431
|
var HIDDEN_NAMES = ["hidden", "is_hidden", "isHidden", "hide", "hideInForm"];
|
|
18877
19432
|
var VISIBLE_NAMES = ["visible", "display", "show"];
|
|
18878
|
-
function
|
|
19433
|
+
function isRecord7(value) {
|
|
18879
19434
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18880
19435
|
}
|
|
18881
19436
|
function pickString(source, keys) {
|
|
@@ -18902,10 +19457,10 @@ function pickBoolean(source, keys) {
|
|
|
18902
19457
|
}
|
|
18903
19458
|
const rules = source.rules;
|
|
18904
19459
|
if (Array.isArray(rules)) {
|
|
18905
|
-
return rules.some((rule) =>
|
|
19460
|
+
return rules.some((rule) => isRecord7(rule) && pickBoolean(rule, REQUIRED_NAMES));
|
|
18906
19461
|
}
|
|
18907
19462
|
const validateMap = source.validateMap;
|
|
18908
|
-
if (
|
|
19463
|
+
if (isRecord7(validateMap) && pickBoolean(validateMap, REQUIRED_NAMES)) {
|
|
18909
19464
|
return true;
|
|
18910
19465
|
}
|
|
18911
19466
|
return false;
|
|
@@ -18929,7 +19484,7 @@ function optionValue(option) {
|
|
|
18929
19484
|
if (typeof option === "string" || typeof option === "number") {
|
|
18930
19485
|
return String(option);
|
|
18931
19486
|
}
|
|
18932
|
-
if (!
|
|
19487
|
+
if (!isRecord7(option)) {
|
|
18933
19488
|
return null;
|
|
18934
19489
|
}
|
|
18935
19490
|
return pickString(option, ["value", "key", "id", "name", "label", "title"]) ?? null;
|
|
@@ -18947,7 +19502,7 @@ function pickOptions(source) {
|
|
|
18947
19502
|
}
|
|
18948
19503
|
for (const containerKey of ["props", "config", "setting", "value"]) {
|
|
18949
19504
|
const container = source[containerKey];
|
|
18950
|
-
if (
|
|
19505
|
+
if (isRecord7(container)) {
|
|
18951
19506
|
const nested = pickOptions(container);
|
|
18952
19507
|
if (nested?.length) {
|
|
18953
19508
|
return nested;
|
|
@@ -19003,7 +19558,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
19003
19558
|
}
|
|
19004
19559
|
return;
|
|
19005
19560
|
}
|
|
19006
|
-
if (!
|
|
19561
|
+
if (!isRecord7(value)) {
|
|
19007
19562
|
return;
|
|
19008
19563
|
}
|
|
19009
19564
|
const field = fieldFromRecord(value);
|
|
@@ -19011,7 +19566,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
19011
19566
|
if (isSubFormField(field)) {
|
|
19012
19567
|
const childFields = /* @__PURE__ */ new Map();
|
|
19013
19568
|
for (const child of Object.values(value)) {
|
|
19014
|
-
if (
|
|
19569
|
+
if (isRecord7(child) || Array.isArray(child)) {
|
|
19015
19570
|
collectFieldCandidates(child, childFields, depth + 1);
|
|
19016
19571
|
}
|
|
19017
19572
|
}
|
|
@@ -19025,7 +19580,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
|
|
|
19025
19580
|
fields.set(field.key, mergeField(fields.get(field.key), field));
|
|
19026
19581
|
}
|
|
19027
19582
|
for (const child of Object.values(value)) {
|
|
19028
|
-
if (
|
|
19583
|
+
if (isRecord7(child) || Array.isArray(child)) {
|
|
19029
19584
|
collectFieldCandidates(child, fields, depth + 1);
|
|
19030
19585
|
}
|
|
19031
19586
|
}
|
|
@@ -19043,7 +19598,7 @@ function validateComplexSelector(field, value) {
|
|
|
19043
19598
|
if (!isComplexSelectorType(type)) {
|
|
19044
19599
|
return null;
|
|
19045
19600
|
}
|
|
19046
|
-
const validObject = (item) =>
|
|
19601
|
+
const validObject = (item) => isRecord7(item);
|
|
19047
19602
|
const hint = complexSelectorHint(field);
|
|
19048
19603
|
if (Array.isArray(value)) {
|
|
19049
19604
|
return value.every(validObject) ? null : `${field.key} must contain selector option object(s), not scalar values. ${hint}`;
|
|
@@ -19060,7 +19615,7 @@ function isEnumSelectType(type) {
|
|
|
19060
19615
|
return /enum_select/.test(type);
|
|
19061
19616
|
}
|
|
19062
19617
|
function optionComparableValue(value) {
|
|
19063
|
-
if (
|
|
19618
|
+
if (isRecord7(value) && ("value" in value || "label" in value)) {
|
|
19064
19619
|
return value.value ?? value.label;
|
|
19065
19620
|
}
|
|
19066
19621
|
return value;
|
|
@@ -19074,7 +19629,7 @@ function validateType(field, value) {
|
|
|
19074
19629
|
if (!Array.isArray(value)) {
|
|
19075
19630
|
return `${field.key} must be a JSON array of row objects`;
|
|
19076
19631
|
}
|
|
19077
|
-
const invalidRowIndex = value.findIndex((row) => !
|
|
19632
|
+
const invalidRowIndex = value.findIndex((row) => !isRecord7(row));
|
|
19078
19633
|
return invalidRowIndex >= 0 ? `${field.key}[${invalidRowIndex}] must be a row object` : null;
|
|
19079
19634
|
}
|
|
19080
19635
|
const selectorError = validateComplexSelector(field, value);
|
|
@@ -19100,7 +19655,7 @@ function validateType(field, value) {
|
|
|
19100
19655
|
if (/(array|multi|multiple)/.test(type) && !Array.isArray(value)) {
|
|
19101
19656
|
return `${field.key} must be an array`;
|
|
19102
19657
|
}
|
|
19103
|
-
if (isEnumSelectType(type) &&
|
|
19658
|
+
if (isEnumSelectType(type) && isRecord7(value)) {
|
|
19104
19659
|
const optionValue2 = value.value ?? value.label;
|
|
19105
19660
|
return typeof optionValue2 === "string" || typeof optionValue2 === "number" ? null : `${field.key} must be an enum option object with a scalar value`;
|
|
19106
19661
|
}
|
|
@@ -19130,7 +19685,7 @@ function validateFormEntries(form, fields, prefix = "") {
|
|
|
19130
19685
|
}
|
|
19131
19686
|
if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
|
|
19132
19687
|
for (const [index, row] of value.entries()) {
|
|
19133
|
-
if (
|
|
19688
|
+
if (isRecord7(row)) {
|
|
19134
19689
|
errors.push(...validateFormEntries(row, field.children, `${prefix}${field.key}[${index}].`));
|
|
19135
19690
|
}
|
|
19136
19691
|
}
|
|
@@ -19208,7 +19763,7 @@ function explainFormValidationSchema(fields) {
|
|
|
19208
19763
|
}
|
|
19209
19764
|
|
|
19210
19765
|
// src/commands/step.ts
|
|
19211
|
-
function
|
|
19766
|
+
function isRecord8(value) {
|
|
19212
19767
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19213
19768
|
}
|
|
19214
19769
|
function stringValue2(value) {
|
|
@@ -19235,7 +19790,7 @@ function hasMeaningfulValue(value) {
|
|
|
19235
19790
|
if (Array.isArray(value)) {
|
|
19236
19791
|
return value.some(hasMeaningfulValue);
|
|
19237
19792
|
}
|
|
19238
|
-
if (
|
|
19793
|
+
if (isRecord8(value)) {
|
|
19239
19794
|
return Object.values(value).some(hasMeaningfulValue);
|
|
19240
19795
|
}
|
|
19241
19796
|
return false;
|
|
@@ -19244,7 +19799,7 @@ function isEmptyValue(value) {
|
|
|
19244
19799
|
return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
19245
19800
|
}
|
|
19246
19801
|
function projectIdOfStep(step) {
|
|
19247
|
-
const nestedProjectId =
|
|
19802
|
+
const nestedProjectId = isRecord8(step.project) ? step.project.id : void 0;
|
|
19248
19803
|
return idValue(step.project_id ?? step.projectId ?? nestedProjectId);
|
|
19249
19804
|
}
|
|
19250
19805
|
function stepFlowNodeId(step) {
|
|
@@ -19272,12 +19827,12 @@ function collectRecords(value, output = [], seen = /* @__PURE__ */ new Set()) {
|
|
|
19272
19827
|
value.forEach((item) => collectRecords(item, output, seen));
|
|
19273
19828
|
return output;
|
|
19274
19829
|
}
|
|
19275
|
-
if (!
|
|
19830
|
+
if (!isRecord8(value)) {
|
|
19276
19831
|
return output;
|
|
19277
19832
|
}
|
|
19278
19833
|
output.push(value);
|
|
19279
19834
|
for (const child of Object.values(value)) {
|
|
19280
|
-
if (Array.isArray(child) ||
|
|
19835
|
+
if (Array.isArray(child) || isRecord8(child)) {
|
|
19281
19836
|
collectRecords(child, output, seen);
|
|
19282
19837
|
}
|
|
19283
19838
|
}
|
|
@@ -19361,7 +19916,7 @@ function formListOfStep(step) {
|
|
|
19361
19916
|
return values.filter(hasMeaningfulValue);
|
|
19362
19917
|
}
|
|
19363
19918
|
function unwrapFormValue(value) {
|
|
19364
|
-
if (!
|
|
19919
|
+
if (!isRecord8(value)) {
|
|
19365
19920
|
return value;
|
|
19366
19921
|
}
|
|
19367
19922
|
if ("value" in value && Object.keys(value).length <= 3) {
|
|
@@ -19378,7 +19933,7 @@ function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set())
|
|
|
19378
19933
|
value.forEach((item) => collectFormValues(item, output, seen));
|
|
19379
19934
|
return output;
|
|
19380
19935
|
}
|
|
19381
|
-
if (!
|
|
19936
|
+
if (!isRecord8(value)) {
|
|
19382
19937
|
return output;
|
|
19383
19938
|
}
|
|
19384
19939
|
const key = stringValue2(value.key ?? value.field_key ?? value.fieldKey ?? value.name);
|
|
@@ -19389,7 +19944,7 @@ function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set())
|
|
|
19389
19944
|
}
|
|
19390
19945
|
}
|
|
19391
19946
|
for (const child of Object.values(value)) {
|
|
19392
|
-
if (Array.isArray(child) ||
|
|
19947
|
+
if (Array.isArray(child) || isRecord8(child)) {
|
|
19393
19948
|
collectFormValues(child, output, seen);
|
|
19394
19949
|
}
|
|
19395
19950
|
}
|
|
@@ -19436,7 +19991,7 @@ function collectMissingRequiredInputs(fields, values) {
|
|
|
19436
19991
|
continue;
|
|
19437
19992
|
}
|
|
19438
19993
|
value.forEach((row, index) => {
|
|
19439
|
-
if (!
|
|
19994
|
+
if (!isRecord8(row)) {
|
|
19440
19995
|
return;
|
|
19441
19996
|
}
|
|
19442
19997
|
for (const child of field.children ?? []) {
|
|
@@ -19491,7 +20046,7 @@ function ownerIdsFromStep(step) {
|
|
|
19491
20046
|
];
|
|
19492
20047
|
const ids = /* @__PURE__ */ new Set();
|
|
19493
20048
|
for (const owner of owners) {
|
|
19494
|
-
if (
|
|
20049
|
+
if (isRecord8(owner)) {
|
|
19495
20050
|
const id = idValue(owner.owner_id ?? owner.user_id ?? owner.id);
|
|
19496
20051
|
if (id) {
|
|
19497
20052
|
ids.add(id);
|
|
@@ -19525,7 +20080,7 @@ function ownerDiagnosticsFromStep(step, currentUser) {
|
|
|
19525
20080
|
const values = Array.isArray(value) ? value : [value];
|
|
19526
20081
|
for (const item of values) {
|
|
19527
20082
|
let id;
|
|
19528
|
-
if (
|
|
20083
|
+
if (isRecord8(item)) {
|
|
19529
20084
|
id = idValue(item.owner_id ?? item.user_id ?? item.id);
|
|
19530
20085
|
} else {
|
|
19531
20086
|
id = idValue(item);
|
|
@@ -19637,12 +20192,12 @@ function extractSubmitInputValues(data) {
|
|
|
19637
20192
|
const candidates = [data.form, data.form_data, data.formData, data.fields, data.values];
|
|
19638
20193
|
const values = {};
|
|
19639
20194
|
for (const candidate of candidates) {
|
|
19640
|
-
if (
|
|
20195
|
+
if (isRecord8(candidate)) {
|
|
19641
20196
|
Object.assign(values, candidate);
|
|
19642
20197
|
}
|
|
19643
20198
|
}
|
|
19644
20199
|
for (const [key, value] of Object.entries(data)) {
|
|
19645
|
-
if (!SUBMIT_NON_FORM_KEYS.has(key) && !
|
|
20200
|
+
if (!SUBMIT_NON_FORM_KEYS.has(key) && !isRecord8(value) && !Array.isArray(value)) {
|
|
19646
20201
|
values[key] = value;
|
|
19647
20202
|
}
|
|
19648
20203
|
}
|
|
@@ -19804,7 +20359,7 @@ async function appendE2eExecutionEvidence(options, evidence, runners) {
|
|
|
19804
20359
|
runners
|
|
19805
20360
|
});
|
|
19806
20361
|
}
|
|
19807
|
-
function
|
|
20362
|
+
function isRecord9(value) {
|
|
19808
20363
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19809
20364
|
}
|
|
19810
20365
|
function stringValue3(value) {
|
|
@@ -19825,18 +20380,18 @@ function timestampSlug() {
|
|
|
19825
20380
|
return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
19826
20381
|
}
|
|
19827
20382
|
async function ensureDir(dir) {
|
|
19828
|
-
const resolved =
|
|
20383
|
+
const resolved = path12.resolve(dir);
|
|
19829
20384
|
await mkdir10(resolved, { recursive: true });
|
|
19830
20385
|
return resolved;
|
|
19831
20386
|
}
|
|
19832
20387
|
async function writeEvidence(dir, name, value) {
|
|
19833
|
-
const file =
|
|
20388
|
+
const file = path12.join(await ensureDir(dir), name);
|
|
19834
20389
|
await writeFile10(file, `${JSON.stringify(redactAuditValue(value), null, 2)}
|
|
19835
20390
|
`, "utf8");
|
|
19836
20391
|
return file;
|
|
19837
20392
|
}
|
|
19838
20393
|
function summarizeRemoteResult(value) {
|
|
19839
|
-
if (!
|
|
20394
|
+
if (!isRecord9(value)) return value;
|
|
19840
20395
|
const summary = {};
|
|
19841
20396
|
for (const key of ["id", "project_id", "step_id", "status", "state", "code", "msg", "message", "next", "action"]) {
|
|
19842
20397
|
if (value[key] !== void 0) summary[key] = value[key];
|
|
@@ -19844,29 +20399,29 @@ function summarizeRemoteResult(value) {
|
|
|
19844
20399
|
return Object.keys(summary).length > 0 ? redactAuditValue(summary) : { received: true };
|
|
19845
20400
|
}
|
|
19846
20401
|
function stepReadbackConfirmed(before, after) {
|
|
19847
|
-
const beforeStatus =
|
|
19848
|
-
const afterStatus =
|
|
19849
|
-
const beforeProjectStep =
|
|
19850
|
-
const afterProjectStep =
|
|
20402
|
+
const beforeStatus = isRecord9(before.step) ? before.step.status : void 0;
|
|
20403
|
+
const afterStatus = isRecord9(after.step) ? after.step.status : void 0;
|
|
20404
|
+
const beforeProjectStep = isRecord9(before.project) ? before.project.current_flow_step_id : void 0;
|
|
20405
|
+
const afterProjectStep = isRecord9(after.project) ? after.project.current_flow_step_id : void 0;
|
|
19851
20406
|
return after.step_finished === true || beforeStatus !== afterStatus || beforeProjectStep !== afterProjectStep;
|
|
19852
20407
|
}
|
|
19853
20408
|
function evidenceMime(buffer, file) {
|
|
19854
20409
|
if (buffer.length >= 8 && buffer.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) return "image/png";
|
|
19855
20410
|
if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) return "image/jpeg";
|
|
19856
20411
|
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(
|
|
20412
|
+
if (path12.extname(file).toLowerCase() === ".json") return "application/json";
|
|
20413
|
+
if ([".txt", ".md", ".log"].includes(path12.extname(file).toLowerCase())) return "text/plain";
|
|
19859
20414
|
return "application/octet-stream";
|
|
19860
20415
|
}
|
|
19861
20416
|
async function writeEvidenceManifest(evidenceDir, details) {
|
|
19862
|
-
const files = await
|
|
20417
|
+
const files = await readdir5(evidenceDir, { withFileTypes: true });
|
|
19863
20418
|
const artifacts = [];
|
|
19864
20419
|
for (const entry of files) {
|
|
19865
20420
|
if (!entry.isFile() || entry.name === "evidence-manifest.json") continue;
|
|
19866
|
-
const file =
|
|
19867
|
-
const buffer = await
|
|
20421
|
+
const file = path12.join(evidenceDir, entry.name);
|
|
20422
|
+
const buffer = await readFile13(file);
|
|
19868
20423
|
const mimeType = evidenceMime(buffer, entry.name);
|
|
19869
|
-
const extension =
|
|
20424
|
+
const extension = path12.extname(entry.name).toLowerCase();
|
|
19870
20425
|
const expectedMime = extension === ".png" ? "image/png" : [".jpg", ".jpeg"].includes(extension) ? "image/jpeg" : extension === ".webp" ? "image/webp" : void 0;
|
|
19871
20426
|
artifacts.push({
|
|
19872
20427
|
path: entry.name,
|
|
@@ -19879,19 +20434,19 @@ async function writeEvidenceManifest(evidenceDir, details) {
|
|
|
19879
20434
|
return writeEvidence(evidenceDir, "evidence-manifest.json", {
|
|
19880
20435
|
schema_version: 1,
|
|
19881
20436
|
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
19882
|
-
evidence_dir:
|
|
20437
|
+
evidence_dir: path12.resolve(evidenceDir),
|
|
19883
20438
|
...details,
|
|
19884
20439
|
artifacts
|
|
19885
20440
|
});
|
|
19886
20441
|
}
|
|
19887
20442
|
function cacheRoot() {
|
|
19888
|
-
return
|
|
20443
|
+
return path12.resolve(".codex/cache/bpmax-e2e");
|
|
19889
20444
|
}
|
|
19890
20445
|
function safeSegment(value) {
|
|
19891
20446
|
return value.trim().replace(/[^a-zA-Z0-9._:-]+/g, "_") || "default";
|
|
19892
20447
|
}
|
|
19893
20448
|
function safeIdentity(value) {
|
|
19894
|
-
if (!
|
|
20449
|
+
if (!isRecord9(value)) return null;
|
|
19895
20450
|
return {
|
|
19896
20451
|
id: value.id,
|
|
19897
20452
|
name: value.name,
|
|
@@ -19932,14 +20487,14 @@ async function browserSessionRequest(profile, cookie, method, apiPath2, data, hr
|
|
|
19932
20487
|
response.status
|
|
19933
20488
|
);
|
|
19934
20489
|
}
|
|
19935
|
-
if (
|
|
20490
|
+
if (isRecord9(body) && typeof body.code === "number" && body.code !== 0) {
|
|
19936
20491
|
throw new BrowserSessionRejectedError(
|
|
19937
20492
|
`e2e.identity.api_error: ${String(body.msg ?? body.message ?? body.code)}`,
|
|
19938
20493
|
response.status,
|
|
19939
20494
|
body.code
|
|
19940
20495
|
);
|
|
19941
20496
|
}
|
|
19942
|
-
return
|
|
20497
|
+
return isRecord9(body) && Object.prototype.hasOwnProperty.call(body, "data") ? body.data : body;
|
|
19943
20498
|
}
|
|
19944
20499
|
function identityCookie(cookieEnv) {
|
|
19945
20500
|
const cookie = process.env[cookieEnv]?.trim();
|
|
@@ -19972,7 +20527,7 @@ function valuesEqual(left, right) {
|
|
|
19972
20527
|
}
|
|
19973
20528
|
function pathValue(source, dottedPath) {
|
|
19974
20529
|
return dottedPath.split(".").reduce((current, segment) => {
|
|
19975
|
-
if (!
|
|
20530
|
+
if (!isRecord9(current)) {
|
|
19976
20531
|
return void 0;
|
|
19977
20532
|
}
|
|
19978
20533
|
return current[segment];
|
|
@@ -19982,7 +20537,7 @@ function normalizeExpectedChecks(value) {
|
|
|
19982
20537
|
if (!Array.isArray(value)) {
|
|
19983
20538
|
return [];
|
|
19984
20539
|
}
|
|
19985
|
-
return value.filter(
|
|
20540
|
+
return value.filter(isRecord9).map((item) => ({
|
|
19986
20541
|
...stringValue3(item.name) ? { name: stringValue3(item.name) } : {},
|
|
19987
20542
|
path: stringValue3(item.path) ?? "",
|
|
19988
20543
|
op: stringValue3(item.op) ?? "equals",
|
|
@@ -20055,13 +20610,13 @@ function buildExpectedChecks(options) {
|
|
|
20055
20610
|
];
|
|
20056
20611
|
}
|
|
20057
20612
|
function flowCachePath(profileName, flowId) {
|
|
20058
|
-
return
|
|
20613
|
+
return path12.join(cacheRoot(), "profiles", safeSegment(profileName), "flows", `${safeSegment(flowId)}.json`);
|
|
20059
20614
|
}
|
|
20060
20615
|
async function readOptionalJson(file) {
|
|
20061
20616
|
try {
|
|
20062
|
-
const raw = await
|
|
20617
|
+
const raw = await readFile13(file, "utf8");
|
|
20063
20618
|
const parsed = JSON.parse(raw);
|
|
20064
|
-
return
|
|
20619
|
+
return isRecord9(parsed) ? parsed : null;
|
|
20065
20620
|
} catch (error) {
|
|
20066
20621
|
if (error.code === "ENOENT") {
|
|
20067
20622
|
return null;
|
|
@@ -20088,11 +20643,11 @@ function stepsFromProfile(profile) {
|
|
|
20088
20643
|
}
|
|
20089
20644
|
const steps = profile.steps;
|
|
20090
20645
|
if (Array.isArray(steps)) {
|
|
20091
|
-
return steps.filter(
|
|
20646
|
+
return steps.filter(isRecord9);
|
|
20092
20647
|
}
|
|
20093
|
-
if (
|
|
20648
|
+
if (isRecord9(steps)) {
|
|
20094
20649
|
return Object.entries(steps).map(([stepId, value]) => ({
|
|
20095
|
-
...
|
|
20650
|
+
...isRecord9(value) ? value : { data: value },
|
|
20096
20651
|
step_id: stepId
|
|
20097
20652
|
}));
|
|
20098
20653
|
}
|
|
@@ -20104,7 +20659,7 @@ function normalizeStepPlan(input, defaults) {
|
|
|
20104
20659
|
throw new Error("e2e step-run requires --step-id or data-profile steps[].step_id.");
|
|
20105
20660
|
}
|
|
20106
20661
|
const rawData = input.data ?? input.payload_template ?? input.payloadTemplate ?? input.form ?? input.values ?? {};
|
|
20107
|
-
const data =
|
|
20662
|
+
const data = isRecord9(rawData) ? rawData : {};
|
|
20108
20663
|
return {
|
|
20109
20664
|
step_id: stepId,
|
|
20110
20665
|
action: stringValue3(input.action) ?? defaults.action,
|
|
@@ -20144,7 +20699,7 @@ function dataProfilePath(input) {
|
|
|
20144
20699
|
if (!input?.startsWith("@")) {
|
|
20145
20700
|
return void 0;
|
|
20146
20701
|
}
|
|
20147
|
-
return
|
|
20702
|
+
return path12.resolve(input.slice(1));
|
|
20148
20703
|
}
|
|
20149
20704
|
function refreshedStepTemplate(options) {
|
|
20150
20705
|
return {
|
|
@@ -20168,14 +20723,14 @@ function refreshedStepTemplate(options) {
|
|
|
20168
20723
|
variables: Object.keys(options.plan.data).filter((key) => !["project_id", "action", "urgency"].includes(key)),
|
|
20169
20724
|
payload_template: options.plan.data,
|
|
20170
20725
|
source_evidence: {
|
|
20171
|
-
evidence_dir:
|
|
20172
|
-
context:
|
|
20726
|
+
evidence_dir: path12.resolve(options.evidenceDir),
|
|
20727
|
+
context: path12.basename(options.contextFile)
|
|
20173
20728
|
}
|
|
20174
20729
|
};
|
|
20175
20730
|
}
|
|
20176
20731
|
async function writeRefreshedCache(file, template) {
|
|
20177
|
-
const out =
|
|
20178
|
-
await mkdir10(
|
|
20732
|
+
const out = path12.resolve(file);
|
|
20733
|
+
await mkdir10(path12.dirname(out), { recursive: true });
|
|
20179
20734
|
await writeFile10(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
|
|
20180
20735
|
`, "utf8");
|
|
20181
20736
|
return out;
|
|
@@ -20253,13 +20808,13 @@ test(${JSON.stringify(options.title)}, async ({ page }) => {
|
|
|
20253
20808
|
async function writeBrowserTemplate(options) {
|
|
20254
20809
|
const handoffUrl = handoffUrlFromInput(options.handoff);
|
|
20255
20810
|
const assertFields = (options.assertFields ?? "").split(",").map((item) => item.trim()).filter(Boolean);
|
|
20256
|
-
const out =
|
|
20257
|
-
await mkdir10(
|
|
20811
|
+
const out = path12.resolve(options.out);
|
|
20812
|
+
await mkdir10(path12.dirname(out), { recursive: true });
|
|
20258
20813
|
await writeFile10(out, playwrightTemplate({
|
|
20259
20814
|
title: options.title ?? "BPMAX create page handoff submit",
|
|
20260
20815
|
handoffUrl,
|
|
20261
20816
|
assertFields,
|
|
20262
|
-
evidenceDir:
|
|
20817
|
+
evidenceDir: path12.resolve(options.evidenceDir)
|
|
20263
20818
|
}), "utf8");
|
|
20264
20819
|
return { out, handoff_url: handoffUrl, assert_fields: assertFields };
|
|
20265
20820
|
}
|
|
@@ -20268,7 +20823,7 @@ function scenarioRecords(plan) {
|
|
|
20268
20823
|
if (!Array.isArray(records)) {
|
|
20269
20824
|
return [];
|
|
20270
20825
|
}
|
|
20271
|
-
return records.filter(
|
|
20826
|
+
return records.filter(isRecord9);
|
|
20272
20827
|
}
|
|
20273
20828
|
function recordKey(record, index) {
|
|
20274
20829
|
return stringValue3(record.demo_no ?? record.id ?? record.case_id ?? record.subject) ?? `record-${index + 1}`;
|
|
@@ -20630,7 +21185,7 @@ function registerE2eCommands(program2) {
|
|
|
20630
21185
|
mode: "handoff_command_hint",
|
|
20631
21186
|
browser: options.browser,
|
|
20632
21187
|
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 ${
|
|
21188
|
+
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
21189
|
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
21190
|
});
|
|
20636
21191
|
return;
|
|
@@ -20652,7 +21207,7 @@ function registerE2eCommands(program2) {
|
|
|
20652
21207
|
browser_verified: false,
|
|
20653
21208
|
browser: options.browser,
|
|
20654
21209
|
...generated,
|
|
20655
|
-
evidence_dir:
|
|
21210
|
+
evidence_dir: path12.resolve(options.evidenceDir),
|
|
20656
21211
|
next_command: `npx playwright test ${generated.out}`,
|
|
20657
21212
|
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
21213
|
});
|
|
@@ -20662,7 +21217,7 @@ function registerE2eCommands(program2) {
|
|
|
20662
21217
|
const profile = resolveProfile(await loadConfig(), options.profile);
|
|
20663
21218
|
const file = flowCachePath(profile.name, options.flowId);
|
|
20664
21219
|
const cached = await readOptionalJson(file);
|
|
20665
|
-
const fileStat = await
|
|
21220
|
+
const fileStat = await stat8(file).catch(() => null);
|
|
20666
21221
|
printResult(options.format, {
|
|
20667
21222
|
ok: true,
|
|
20668
21223
|
profile: profile.name,
|
|
@@ -20703,7 +21258,7 @@ function registerE2eCommands(program2) {
|
|
|
20703
21258
|
template_id: result.template_id ?? result.templateId
|
|
20704
21259
|
})).digest("hex").slice(0, 16);
|
|
20705
21260
|
const file = flowCachePath(profile.name, options.flowId);
|
|
20706
|
-
await mkdir10(
|
|
21261
|
+
await mkdir10(path12.dirname(file), { recursive: true });
|
|
20707
21262
|
await writeFile10(file, `${JSON.stringify(redactAuditValue({
|
|
20708
21263
|
cache_key: cacheKey,
|
|
20709
21264
|
cached_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -20734,25 +21289,25 @@ function registerE2eCommands(program2) {
|
|
|
20734
21289
|
printResult(options.format, {
|
|
20735
21290
|
ok: true,
|
|
20736
21291
|
...generated,
|
|
20737
|
-
evidence_dir:
|
|
21292
|
+
evidence_dir: path12.resolve(options.evidenceDir),
|
|
20738
21293
|
next_command: `npx playwright test ${generated.out}`
|
|
20739
21294
|
});
|
|
20740
21295
|
});
|
|
20741
21296
|
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
21297
|
await requireE2eExecutionBinding(options, ["browser", "e2e_create_page", "e2e_step_run", "observe"]);
|
|
20743
|
-
const files = await
|
|
21298
|
+
const files = await readdir5(options.evidenceDir).catch(() => []);
|
|
20744
21299
|
const inferredStepId = options.stepId ?? files.map(inferStepIdFromEvidenceFile).find(Boolean);
|
|
20745
21300
|
const contextFile = inferredStepId ? stepEvidenceFile(files, inferredStepId, "context") : void 0;
|
|
20746
21301
|
const submitFile = inferredStepId ? stepEvidenceFile(files, inferredStepId, "submit") : void 0;
|
|
20747
21302
|
if (inferredStepId && !contextFile && !submitFile) {
|
|
20748
21303
|
throw new Error(`No step evidence files found for step ${inferredStepId} in ${options.evidenceDir}.`);
|
|
20749
21304
|
}
|
|
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 =
|
|
21305
|
+
const context2 = contextFile ? await readOptionalJson(path12.join(options.evidenceDir, contextFile)) : null;
|
|
21306
|
+
const submit = submitFile ? await readOptionalJson(path12.join(options.evidenceDir, submitFile)) : null;
|
|
21307
|
+
const requirements = isRecord9(context2?.requirements) ? context2.requirements : {};
|
|
21308
|
+
const requiredInputs = Array.isArray(requirements.required_inputs) ? requirements.required_inputs.filter(isRecord9) : [];
|
|
21309
|
+
const missingInputs = Array.isArray(requirements.missing_required_inputs) ? requirements.missing_required_inputs.filter(isRecord9) : [];
|
|
21310
|
+
const requestData = isRecord9(submit?.request) && isRecord9(submit.request.data) ? submit.request.data : {};
|
|
20756
21311
|
const recordedAction = stringValue3(requestData.action);
|
|
20757
21312
|
const expectedChecks = buildExpectedChecks({
|
|
20758
21313
|
context: context2,
|
|
@@ -20791,16 +21346,16 @@ function registerE2eCommands(program2) {
|
|
|
20791
21346
|
variables: Object.keys(requestData).filter((key) => !["project_id", "action", "urgency"].includes(key)),
|
|
20792
21347
|
payload_template: requestData,
|
|
20793
21348
|
source_evidence: {
|
|
20794
|
-
evidence_dir:
|
|
21349
|
+
evidence_dir: path12.resolve(options.evidenceDir),
|
|
20795
21350
|
...contextFile ? { context: contextFile } : {},
|
|
20796
21351
|
...submitFile ? { submit: submitFile } : {}
|
|
20797
21352
|
}
|
|
20798
21353
|
} : {
|
|
20799
|
-
name: options.name ??
|
|
21354
|
+
name: options.name ?? path12.basename(path12.resolve(options.evidenceDir)),
|
|
20800
21355
|
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20801
21356
|
submit_mode: "browser_evidence_bootstrap",
|
|
20802
21357
|
source_evidence: {
|
|
20803
|
-
evidence_dir:
|
|
21358
|
+
evidence_dir: path12.resolve(options.evidenceDir),
|
|
20804
21359
|
files: evidenceFiles
|
|
20805
21360
|
},
|
|
20806
21361
|
reuse_requirements: [
|
|
@@ -20813,8 +21368,8 @@ function registerE2eCommands(program2) {
|
|
|
20813
21368
|
template.result = "diagnostic";
|
|
20814
21369
|
template.diagnostic = true;
|
|
20815
21370
|
}
|
|
20816
|
-
const out =
|
|
20817
|
-
await mkdir10(
|
|
21371
|
+
const out = path12.resolve(options.out);
|
|
21372
|
+
await mkdir10(path12.dirname(out), { recursive: true });
|
|
20818
21373
|
await writeFile10(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
|
|
20819
21374
|
`, "utf8");
|
|
20820
21375
|
await appendE2eExecutionEvidence(options, out, ["browser", "e2e_create_page", "e2e_step_run", "observe"]);
|
|
@@ -20872,11 +21427,11 @@ function registerE2eCommands(program2) {
|
|
|
20872
21427
|
}
|
|
20873
21428
|
|
|
20874
21429
|
// src/core/project-search.ts
|
|
20875
|
-
function
|
|
21430
|
+
function isRecord10(value) {
|
|
20876
21431
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20877
21432
|
}
|
|
20878
21433
|
function hasRawProjectSearchBody(value) {
|
|
20879
|
-
return
|
|
21434
|
+
return isRecord10(value) && Object.prototype.hasOwnProperty.call(value, "body");
|
|
20880
21435
|
}
|
|
20881
21436
|
function assertProjectSearchBody(value) {
|
|
20882
21437
|
if (hasRawProjectSearchBody(value)) {
|
|
@@ -20890,13 +21445,13 @@ function isProjectListEsQuery(value) {
|
|
|
20890
21445
|
}
|
|
20891
21446
|
function splitProjectListPagination(body, options) {
|
|
20892
21447
|
const data = { ...body };
|
|
20893
|
-
const normalizePositiveInteger = (value,
|
|
21448
|
+
const normalizePositiveInteger = (value, path17) => {
|
|
20894
21449
|
if (typeof value === "string" && value.trim() === "") {
|
|
20895
|
-
throw new Error(`project search ${
|
|
21450
|
+
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
21451
|
}
|
|
20897
21452
|
const number = typeof value === "number" ? value : Number(value);
|
|
20898
21453
|
if (!Number.isSafeInteger(number) || number < 1) {
|
|
20899
|
-
throw new Error(`project search ${
|
|
21454
|
+
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
21455
|
}
|
|
20901
21456
|
return number;
|
|
20902
21457
|
};
|
|
@@ -21027,7 +21582,7 @@ function registerFlowCommands(program2) {
|
|
|
21027
21582
|
const client = createApiClient(profile);
|
|
21028
21583
|
if (options.flowType) {
|
|
21029
21584
|
const bindings = await getWorkspaceFlowBindings(client, profile, options);
|
|
21030
|
-
const
|
|
21585
|
+
const path17 = options.flowKey ? "/flow/options" : "/flow/flow_type";
|
|
21031
21586
|
const params = options.flowKey ? {
|
|
21032
21587
|
detail: "1"
|
|
21033
21588
|
} : {
|
|
@@ -21037,7 +21592,7 @@ function registerFlowCommands(program2) {
|
|
|
21037
21592
|
const result2 = await apiRequest(
|
|
21038
21593
|
client,
|
|
21039
21594
|
"GET",
|
|
21040
|
-
|
|
21595
|
+
path17,
|
|
21041
21596
|
{
|
|
21042
21597
|
params
|
|
21043
21598
|
}
|
|
@@ -21273,7 +21828,7 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
21273
21828
|
}
|
|
21274
21829
|
|
|
21275
21830
|
// src/commands/issue.ts
|
|
21276
|
-
import { readFile as
|
|
21831
|
+
import { readFile as readFile14 } from "fs/promises";
|
|
21277
21832
|
|
|
21278
21833
|
// src/core/issues.ts
|
|
21279
21834
|
import axios8, { AxiosHeaders as AxiosHeaders3 } from "axios";
|
|
@@ -21449,7 +22004,7 @@ async function readDescription(options) {
|
|
|
21449
22004
|
if (!options.descriptionFile) {
|
|
21450
22005
|
return options.description;
|
|
21451
22006
|
}
|
|
21452
|
-
return
|
|
22007
|
+
return readFile14(options.descriptionFile, "utf8");
|
|
21453
22008
|
}
|
|
21454
22009
|
function parseAssigneeIds(values) {
|
|
21455
22010
|
return (values || []).flatMap(
|
|
@@ -21548,10 +22103,10 @@ async function parseOptionalJson(input, label) {
|
|
|
21548
22103
|
}
|
|
21549
22104
|
return parseJsonInput(input, label);
|
|
21550
22105
|
}
|
|
21551
|
-
async function memoryRequest(options, method,
|
|
22106
|
+
async function memoryRequest(options, method, path17, capability, data, params) {
|
|
21552
22107
|
const profile = resolveProfile(await loadConfig(), options.profile);
|
|
21553
22108
|
const client = createApiClient(profile);
|
|
21554
|
-
return apiRequest(client, method,
|
|
22109
|
+
return apiRequest(client, method, path17, {
|
|
21555
22110
|
capability,
|
|
21556
22111
|
data: redactAuditValue(data),
|
|
21557
22112
|
params: params ? redactAuditValue(params) : void 0
|
|
@@ -21606,7 +22161,7 @@ function registerMemoryCommands(program2) {
|
|
|
21606
22161
|
}
|
|
21607
22162
|
|
|
21608
22163
|
// src/commands/matrix.ts
|
|
21609
|
-
import { readFile as
|
|
22164
|
+
import { readFile as readFile15 } from "fs/promises";
|
|
21610
22165
|
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
22166
|
var UUID_PATH_PATTERN = /uuid'[^'"\s/]+/i;
|
|
21612
22167
|
async function parseSeedRules(input) {
|
|
@@ -21614,7 +22169,7 @@ async function parseSeedRules(input) {
|
|
|
21614
22169
|
if (source === "") {
|
|
21615
22170
|
throw new Error("--rules file path is empty.");
|
|
21616
22171
|
}
|
|
21617
|
-
const raw = source ? await
|
|
22172
|
+
const raw = source ? await readFile15(source, "utf8") : input;
|
|
21618
22173
|
let parsed;
|
|
21619
22174
|
try {
|
|
21620
22175
|
parsed = JSON.parse(raw);
|
|
@@ -21633,15 +22188,15 @@ async function parseSeedRules(input) {
|
|
|
21633
22188
|
});
|
|
21634
22189
|
return rules;
|
|
21635
22190
|
}
|
|
21636
|
-
function collectUuidPaths(value,
|
|
22191
|
+
function collectUuidPaths(value, path17 = "$") {
|
|
21637
22192
|
if (typeof value === "string") {
|
|
21638
|
-
return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [
|
|
22193
|
+
return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [path17] : [];
|
|
21639
22194
|
}
|
|
21640
22195
|
if (Array.isArray(value)) {
|
|
21641
|
-
return value.flatMap((item, index) => collectUuidPaths(item, `${
|
|
22196
|
+
return value.flatMap((item, index) => collectUuidPaths(item, `${path17}[${index}]`));
|
|
21642
22197
|
}
|
|
21643
22198
|
if (typeof value === "object" && value !== null) {
|
|
21644
|
-
return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${
|
|
22199
|
+
return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${path17}.${key}`));
|
|
21645
22200
|
}
|
|
21646
22201
|
return [];
|
|
21647
22202
|
}
|
|
@@ -21664,20 +22219,20 @@ function isEmptyApproverValue(value) {
|
|
|
21664
22219
|
function shellQuote7(value) {
|
|
21665
22220
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
21666
22221
|
}
|
|
21667
|
-
var
|
|
22222
|
+
var isRecord11 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21668
22223
|
function dataArray(value) {
|
|
21669
22224
|
if (Array.isArray(value)) return value;
|
|
21670
|
-
if (
|
|
21671
|
-
if (
|
|
21672
|
-
if (
|
|
22225
|
+
if (isRecord11(value) && Array.isArray(value.data)) return value.data;
|
|
22226
|
+
if (isRecord11(value) && Array.isArray(value.list)) return value.list;
|
|
22227
|
+
if (isRecord11(value) && Array.isArray(value.rows)) return value.rows;
|
|
21673
22228
|
return [];
|
|
21674
22229
|
}
|
|
21675
22230
|
function predictedNodes(value) {
|
|
21676
|
-
if (!
|
|
21677
|
-
return dataArray(value.predicted_nodes).filter(
|
|
22231
|
+
if (!isRecord11(value)) return [];
|
|
22232
|
+
return dataArray(value.predicted_nodes).filter(isRecord11);
|
|
21678
22233
|
}
|
|
21679
22234
|
function safePredictedOwners(value) {
|
|
21680
|
-
return (Array.isArray(value) ? value : []).filter(
|
|
22235
|
+
return (Array.isArray(value) ? value : []).filter(isRecord11).map((owner) => ({
|
|
21681
22236
|
id: owner.id ?? owner.user_id ?? owner.owner_id,
|
|
21682
22237
|
name: owner.name ?? null
|
|
21683
22238
|
}));
|
|
@@ -21692,7 +22247,7 @@ async function fetchAllMatrixRuleRecords(client, flowType) {
|
|
|
21692
22247
|
data: { flow_type: flowType, page, page_size: pageSize },
|
|
21693
22248
|
capability: "project.list"
|
|
21694
22249
|
});
|
|
21695
|
-
const rows2 = dataArray(result).filter(
|
|
22250
|
+
const rows2 = dataArray(result).filter(isRecord11);
|
|
21696
22251
|
records.push(...rows2);
|
|
21697
22252
|
const total = Number(result.count ?? result.total ?? records.length);
|
|
21698
22253
|
if (rows2.length < pageSize || records.length >= total) break;
|
|
@@ -21711,23 +22266,23 @@ async function hydrateMatrixRuleRecords(client, records) {
|
|
|
21711
22266
|
for (let index = 0; index < records.length; index += 10) {
|
|
21712
22267
|
const chunk = records.slice(index, index + 10);
|
|
21713
22268
|
hydrated.push(...await Promise.all(chunk.map(async (record) => {
|
|
21714
|
-
if (
|
|
22269
|
+
if (isRecord11(record.metaForm) || Array.isArray(record.formList)) return record;
|
|
21715
22270
|
const id = Number(record.id ?? record.project_id);
|
|
21716
22271
|
return Number.isSafeInteger(id) && id > 0 ? apiRequest(client, "GET", `/project/${id}`) : record;
|
|
21717
22272
|
})));
|
|
21718
22273
|
}
|
|
21719
22274
|
return hydrated;
|
|
21720
22275
|
}
|
|
21721
|
-
function collectMatrixOwnerPaths(value,
|
|
22276
|
+
function collectMatrixOwnerPaths(value, path17 = "$") {
|
|
21722
22277
|
if (Array.isArray(value)) {
|
|
21723
|
-
return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${
|
|
22278
|
+
return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${path17}[${index}]`));
|
|
21724
22279
|
}
|
|
21725
|
-
if (!
|
|
22280
|
+
if (!isRecord11(value)) {
|
|
21726
22281
|
return [];
|
|
21727
22282
|
}
|
|
21728
22283
|
const matches = [];
|
|
21729
22284
|
Object.entries(value).forEach(([key, child]) => {
|
|
21730
|
-
const childPath = `${
|
|
22285
|
+
const childPath = `${path17}.${key}`;
|
|
21731
22286
|
if (key.includes("matrix_owner") || typeof child === "string" && child.includes("matrix_owner")) {
|
|
21732
22287
|
matches.push({ path: childPath, value: child });
|
|
21733
22288
|
}
|
|
@@ -21736,25 +22291,25 @@ function collectMatrixOwnerPaths(value, path16 = "$") {
|
|
|
21736
22291
|
return matches;
|
|
21737
22292
|
}
|
|
21738
22293
|
function projectFormKeys(project) {
|
|
21739
|
-
const metaForm =
|
|
22294
|
+
const metaForm = isRecord11(project.metaForm) ? project.metaForm : {};
|
|
21740
22295
|
const values = dataArray(metaForm.value ?? project.formList);
|
|
21741
|
-
return values.filter(
|
|
22296
|
+
return values.filter(isRecord11).map((item) => String(item.key ?? item.field_key ?? "")).filter(Boolean);
|
|
21742
22297
|
}
|
|
21743
22298
|
function findFlowNode2(flow, nodeId) {
|
|
21744
|
-
const data =
|
|
21745
|
-
return dataArray(data.nodes).filter(
|
|
22299
|
+
const data = isRecord11(flow.data) ? flow.data : {};
|
|
22300
|
+
return dataArray(data.nodes).filter(isRecord11).find((node) => String(node.id ?? node.key ?? node.flow_step_id ?? "") === nodeId);
|
|
21746
22301
|
}
|
|
21747
22302
|
function flowCategory(flow) {
|
|
21748
|
-
const data =
|
|
21749
|
-
const meta =
|
|
22303
|
+
const data = isRecord11(flow.data) ? flow.data : {};
|
|
22304
|
+
const meta = isRecord11(data.meta) ? data.meta : {};
|
|
21750
22305
|
return String(flow.category ?? data.category ?? meta.category ?? "");
|
|
21751
22306
|
}
|
|
21752
22307
|
function hasIdentifier(value) {
|
|
21753
22308
|
return value !== void 0 && value !== null && String(value).trim() !== "" && String(value) !== "0";
|
|
21754
22309
|
}
|
|
21755
22310
|
function matrixAppSummary(flow, listTemplates = [], filterTemplates = [], datasets = [], workspaceBound = false) {
|
|
21756
|
-
const data =
|
|
21757
|
-
const meta =
|
|
22311
|
+
const data = isRecord11(flow.data) ? flow.data : {};
|
|
22312
|
+
const meta = isRecord11(data.meta) ? data.meta : {};
|
|
21758
22313
|
const refs = {
|
|
21759
22314
|
form_template_id: meta.form_template ?? flow.form_template_id,
|
|
21760
22315
|
list_template_ids: listTemplates.map((item) => item.id ?? item.flow_page_template_id).filter(hasIdentifier),
|
|
@@ -21795,7 +22350,7 @@ function matrixAppSummary(flow, listTemplates = [], filterTemplates = [], datase
|
|
|
21795
22350
|
suggestion: "\u4ECE\u6700\u65B0 workspace-flow \u56DE\u8BFB merge \u540E\u901A\u8FC7 typed CLI \u63D0\u4EA4\u7ED1\u5B9A\u3002"
|
|
21796
22351
|
});
|
|
21797
22352
|
}
|
|
21798
|
-
const nodes = dataArray(data.nodes).filter(
|
|
22353
|
+
const nodes = dataArray(data.nodes).filter(isRecord11);
|
|
21799
22354
|
const activeNodes = nodes.filter((node) => {
|
|
21800
22355
|
const name = String(node.name ?? "").trim();
|
|
21801
22356
|
return name === "\u751F\u6548\u4E2D" || name === "\u8FDB\u884C\u4E2D" || Number(node.status) === 1;
|
|
@@ -21844,10 +22399,10 @@ async function inspectMatrixAppDefinition(profile, flowType, workspace, includeR
|
|
|
21844
22399
|
apiRequest(client, "GET", "/flow_page_template", { params: { type: 3, flow_type: flowType, flow_key: "", skip_i18n: true }, capability: "config.filter_template.export" }),
|
|
21845
22400
|
apiRequest(client, "GET", "/workspace/by_key", { params: { key: workspace }, capability: "config.workspace_flow.export" })
|
|
21846
22401
|
]);
|
|
21847
|
-
const flowData =
|
|
21848
|
-
const meta =
|
|
21849
|
-
const listRows = dataArray(listResult).filter(
|
|
21850
|
-
const filterRows = dataArray(filterResult).filter(
|
|
22402
|
+
const flowData = isRecord11(flow.data) ? flow.data : {};
|
|
22403
|
+
const meta = isRecord11(flowData.meta) ? flowData.meta : {};
|
|
22404
|
+
const listRows = dataArray(listResult).filter(isRecord11);
|
|
22405
|
+
const filterRows = dataArray(filterResult).filter(isRecord11);
|
|
21851
22406
|
const listIds = uniqueIds([meta.table_list_template, ...listRows.map((item) => item.id ?? item.flow_page_template_id)]);
|
|
21852
22407
|
const filterIds = uniqueIds([meta.table_filter_template, ...filterRows.map((item) => item.id ?? item.flow_page_template_id)]);
|
|
21853
22408
|
const formId = String(meta.form_template ?? flow.form_template_id ?? "");
|
|
@@ -21865,7 +22420,7 @@ async function inspectMatrixAppDefinition(profile, flowType, workspace, includeR
|
|
|
21865
22420
|
if (strict) {
|
|
21866
22421
|
assertNoMatrixErrors(summary.errors);
|
|
21867
22422
|
}
|
|
21868
|
-
const formRecord =
|
|
22423
|
+
const formRecord = isRecord11(form) ? form : {};
|
|
21869
22424
|
const exactReadback = {
|
|
21870
22425
|
flow: { id: flowType, readback_hash: matrixHash(flow), ...includeRaw ? { readback: flow } : {} },
|
|
21871
22426
|
form_template: { id: formId, draft_id: formRecord.origin_template_id ?? formRecord.id ?? null, readback_hash: matrixHash(formRecord), ...includeRaw ? { readback: formRecord } : {} },
|
|
@@ -21877,8 +22432,8 @@ async function inspectMatrixAppDefinition(profile, flowType, workspace, includeR
|
|
|
21877
22432
|
return { ok: summary.errors.length === 0, domain: "approval-matrix", action: "app.inspect", flow_type: flowType, workspace, ...summary, exact_readback: exactReadback };
|
|
21878
22433
|
}
|
|
21879
22434
|
function workspaceHasFlow(value, flowType) {
|
|
21880
|
-
if (!
|
|
21881
|
-
const rows2 = Array.isArray(value.workspace_flow) ? value.workspace_flow.filter(
|
|
22435
|
+
if (!isRecord11(value)) return false;
|
|
22436
|
+
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
22437
|
return rows2.some((item) => String(item.flow_type ?? "") === flowType && Number(item.is_del ?? 0) === 0);
|
|
21883
22438
|
}
|
|
21884
22439
|
function matrixConsumerSummary(node, expectedMatrixFlowType) {
|
|
@@ -21894,8 +22449,8 @@ function matrixConsumerSummary(node, expectedMatrixFlowType) {
|
|
|
21894
22449
|
});
|
|
21895
22450
|
return { errors, owner: null, cc: null };
|
|
21896
22451
|
}
|
|
21897
|
-
const owner =
|
|
21898
|
-
const cc =
|
|
22452
|
+
const owner = isRecord11(node.matrix_owner) ? node.matrix_owner : null;
|
|
22453
|
+
const cc = isRecord11(node.cc_matrix) ? node.cc_matrix : null;
|
|
21899
22454
|
const normalizeFlowRef = (value) => String(value ?? "").trim().replace(/:$/, "");
|
|
21900
22455
|
if (node.auto_range_type === "matrix") {
|
|
21901
22456
|
if (!owner || !String(owner.flow ?? owner.matrix_flow_type ?? "").trim()) {
|
|
@@ -21926,16 +22481,16 @@ function matrixConsumerSummary(node, expectedMatrixFlowType) {
|
|
|
21926
22481
|
return { errors, owner, cc };
|
|
21927
22482
|
}
|
|
21928
22483
|
function projectField(project, key) {
|
|
21929
|
-
const metaForm =
|
|
21930
|
-
const values = dataArray(metaForm.value ?? project.formList).filter(
|
|
22484
|
+
const metaForm = isRecord11(project.metaForm) ? project.metaForm : {};
|
|
22485
|
+
const values = dataArray(metaForm.value ?? project.formList).filter(isRecord11);
|
|
21931
22486
|
const row = values.find((item) => String(item.key ?? item.field_key ?? "") === key);
|
|
21932
22487
|
if (!row) return void 0;
|
|
21933
22488
|
const value = row.value;
|
|
21934
|
-
return
|
|
22489
|
+
return isRecord11(value) && Object.prototype.hasOwnProperty.call(value, "value") ? value.value : value;
|
|
21935
22490
|
}
|
|
21936
22491
|
function collectUserIds(value) {
|
|
21937
22492
|
if (Array.isArray(value)) return [...new Set(value.flatMap(collectUserIds))];
|
|
21938
|
-
if (
|
|
22493
|
+
if (isRecord11(value)) {
|
|
21939
22494
|
const direct2 = Number(value.id ?? value.user_id ?? value.value);
|
|
21940
22495
|
if (Number.isSafeInteger(direct2) && direct2 > 0) return [direct2];
|
|
21941
22496
|
return [...new Set(Object.values(value).flatMap(collectUserIds))];
|
|
@@ -21956,7 +22511,7 @@ async function readMatrixApprovers(client, ids) {
|
|
|
21956
22511
|
},
|
|
21957
22512
|
capability: "user.readback"
|
|
21958
22513
|
});
|
|
21959
|
-
users.push(...dataArray(result).filter(
|
|
22514
|
+
users.push(...dataArray(result).filter(isRecord11));
|
|
21960
22515
|
}
|
|
21961
22516
|
return users;
|
|
21962
22517
|
}
|
|
@@ -22040,7 +22595,7 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
22040
22595
|
const matrixOwnerConfig = node ? collectMatrixOwnerPaths(node) : [];
|
|
22041
22596
|
const predictedNode = predictedNodes(prediction).find((item) => String(item.node_id ?? item.id ?? "") === options.node);
|
|
22042
22597
|
const owners = safePredictedOwners(predictedNode?.owners);
|
|
22043
|
-
const ownerResolution = predictedNode &&
|
|
22598
|
+
const ownerResolution = predictedNode && isRecord11(predictedNode.owner_resolution) ? predictedNode.owner_resolution : { status: predictedNode ? "resolved" : "missing" };
|
|
22044
22599
|
const projectFlowType = String(project.flow_type ?? "");
|
|
22045
22600
|
const flowMatchesProject = !projectFlowType || projectFlowType === options.flowType;
|
|
22046
22601
|
printResult(options.format, {
|
|
@@ -22131,14 +22686,14 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
22131
22686
|
if (!workspace) throw new Error("matrix.app.workspace_required: \u8BF7\u63D0\u4F9B --workspace \u4EE5\u5220\u9664\u77E9\u9635\u5E94\u7528\u3002");
|
|
22132
22687
|
const definition = await inspectMatrixAppDefinition(profile, options.flowType, workspace, true, false);
|
|
22133
22688
|
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(
|
|
22689
|
+
const listItems = Array.isArray(exact.list_templates) ? exact.list_templates.filter(isRecord11) : [];
|
|
22690
|
+
const filterItems = Array.isArray(exact.filter_templates) ? exact.filter_templates.filter(isRecord11) : [];
|
|
22691
|
+
const datasetItems = Array.isArray(exact.datasets) ? exact.datasets.filter(isRecord11) : [];
|
|
22137
22692
|
const datasetFieldIds = uniqueIds(datasetItems.flatMap((item) => {
|
|
22138
|
-
const readback =
|
|
22139
|
-
return Array.isArray(readback.dataSetFields) ? readback.dataSetFields.filter(
|
|
22693
|
+
const readback = isRecord11(item.readback) ? item.readback : {};
|
|
22694
|
+
return Array.isArray(readback.dataSetFields) ? readback.dataSetFields.filter(isRecord11).map((field) => field.id) : [];
|
|
22140
22695
|
}));
|
|
22141
|
-
const formItem =
|
|
22696
|
+
const formItem = isRecord11(exact.form_template) ? exact.form_template : {};
|
|
22142
22697
|
const formDraftId = String(formItem.draft_id ?? formItem.id ?? "");
|
|
22143
22698
|
const expectedConfirm = `delete matrix app ${options.flowType} from ${workspace}`;
|
|
22144
22699
|
const plan = [
|
|
@@ -22200,8 +22755,8 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
22200
22755
|
apiRequest(client, "GET", "/flow_page_template", { params: { type: 3, flow_type: options.matrixFlowType, flow_key: "", skip_i18n: true }, capability: "config.filter_template.export" }),
|
|
22201
22756
|
apiRequest(client, "GET", "/workspace/by_key", { params: { key: workspace }, capability: "config.workspace_flow.export" })
|
|
22202
22757
|
]);
|
|
22203
|
-
const listRows = dataArray(listResult).filter(
|
|
22204
|
-
const filterRows = dataArray(filterResult).filter(
|
|
22758
|
+
const listRows = dataArray(listResult).filter(isRecord11);
|
|
22759
|
+
const filterRows = dataArray(filterResult).filter(isRecord11);
|
|
22205
22760
|
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
22761
|
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
22762
|
const datasetIds = uniqueIds([...listTemplates.map((item) => item.data_set_id), ...filterTemplates.map((item) => item.data_set_id)]);
|
|
@@ -22235,7 +22790,7 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
22235
22790
|
}
|
|
22236
22791
|
const predictedNode = predictedNodes(prediction).find((item) => String(item.node_id ?? item.id ?? "") === options.node);
|
|
22237
22792
|
const predictedOwners = safePredictedOwners(predictedNode?.owners);
|
|
22238
|
-
const ownerResolution = predictedNode &&
|
|
22793
|
+
const ownerResolution = predictedNode && isRecord11(predictedNode.owner_resolution) ? predictedNode.owner_resolution : { status: predictedNode ? "resolved" : "missing" };
|
|
22239
22794
|
if (ownerResolution.status === "error") {
|
|
22240
22795
|
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
22796
|
} else if (!predictedNode || predictedOwners.length === 0) {
|
|
@@ -22259,13 +22814,13 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
|
|
|
22259
22814
|
}
|
|
22260
22815
|
|
|
22261
22816
|
// src/commands/organization.ts
|
|
22262
|
-
function
|
|
22817
|
+
function isRecord12(value) {
|
|
22263
22818
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22264
22819
|
}
|
|
22265
22820
|
function rows(value) {
|
|
22266
|
-
if (Array.isArray(value)) return value.filter(
|
|
22267
|
-
if (!
|
|
22268
|
-
if (Array.isArray(value.data)) return value.data.filter(
|
|
22821
|
+
if (Array.isArray(value)) return value.filter(isRecord12);
|
|
22822
|
+
if (!isRecord12(value)) return [];
|
|
22823
|
+
if (Array.isArray(value.data)) return value.data.filter(isRecord12);
|
|
22269
22824
|
return value.id ? [value] : [];
|
|
22270
22825
|
}
|
|
22271
22826
|
function positiveId(value, errorCode) {
|
|
@@ -22289,7 +22844,7 @@ function safeDepartment(group) {
|
|
|
22289
22844
|
function departmentRows(value) {
|
|
22290
22845
|
const result = [];
|
|
22291
22846
|
const visit = (item) => {
|
|
22292
|
-
if (!
|
|
22847
|
+
if (!isRecord12(item)) return;
|
|
22293
22848
|
if (item.id !== void 0) result.push(safeDepartment(item));
|
|
22294
22849
|
if (Array.isArray(item.children)) item.children.forEach(visit);
|
|
22295
22850
|
};
|
|
@@ -22298,7 +22853,7 @@ function departmentRows(value) {
|
|
|
22298
22853
|
}
|
|
22299
22854
|
function relationDepartments(value) {
|
|
22300
22855
|
if (!Array.isArray(value)) return [];
|
|
22301
|
-
return value.filter(
|
|
22856
|
+
return value.filter(isRecord12).map(safeDepartment);
|
|
22302
22857
|
}
|
|
22303
22858
|
function safeUser(user) {
|
|
22304
22859
|
const status = user.status === void 0 ? null : Number(user.status);
|
|
@@ -22345,8 +22900,8 @@ async function readDepartments(client, ids) {
|
|
|
22345
22900
|
function pathIds(departments) {
|
|
22346
22901
|
const ids = /* @__PURE__ */ new Set();
|
|
22347
22902
|
for (const department of departments) {
|
|
22348
|
-
const
|
|
22349
|
-
for (const part of
|
|
22903
|
+
const path17 = String(department.path ?? "");
|
|
22904
|
+
for (const part of path17.split(/[|,]/)) {
|
|
22350
22905
|
const id = Number(part);
|
|
22351
22906
|
if (Number.isSafeInteger(id) && id > 0) ids.add(id);
|
|
22352
22907
|
}
|
|
@@ -22356,7 +22911,7 @@ function pathIds(departments) {
|
|
|
22356
22911
|
function mainDepartmentId(raw) {
|
|
22357
22912
|
for (const key of ["main_department_id", "main_group_id", "main_department"]) {
|
|
22358
22913
|
const value = raw[key];
|
|
22359
|
-
if (
|
|
22914
|
+
if (isRecord12(value)) {
|
|
22360
22915
|
const id2 = Number(value.id);
|
|
22361
22916
|
if (Number.isSafeInteger(id2) && id2 > 0) return id2;
|
|
22362
22917
|
}
|
|
@@ -22368,7 +22923,7 @@ function mainDepartmentId(raw) {
|
|
|
22368
22923
|
function branchId(raw) {
|
|
22369
22924
|
for (const key of ["branch_id", "branch_group_id", "branch"]) {
|
|
22370
22925
|
const value = raw[key];
|
|
22371
|
-
if (
|
|
22926
|
+
if (isRecord12(value)) {
|
|
22372
22927
|
const id2 = Number(value.id);
|
|
22373
22928
|
if (Number.isSafeInteger(id2) && id2 > 0) return id2;
|
|
22374
22929
|
}
|
|
@@ -22886,15 +23441,15 @@ async function promptProjectCreateForm(input) {
|
|
|
22886
23441
|
}
|
|
22887
23442
|
|
|
22888
23443
|
// src/core/project-form.ts
|
|
22889
|
-
function
|
|
23444
|
+
function isRecord13(value) {
|
|
22890
23445
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22891
23446
|
}
|
|
22892
23447
|
function clone(value) {
|
|
22893
23448
|
return JSON.parse(JSON.stringify(value));
|
|
22894
23449
|
}
|
|
22895
23450
|
function getFlowFormTemplateId(flowDetail) {
|
|
22896
|
-
const data =
|
|
22897
|
-
const meta =
|
|
23451
|
+
const data = isRecord13(flowDetail?.data) ? flowDetail.data : void 0;
|
|
23452
|
+
const meta = isRecord13(data?.meta) ? data.meta : void 0;
|
|
22898
23453
|
const templateId = meta?.form_template;
|
|
22899
23454
|
if (typeof templateId === "number" && Number.isFinite(templateId)) {
|
|
22900
23455
|
return templateId;
|
|
@@ -22919,7 +23474,7 @@ function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
22919
23474
|
if (Array.isArray(value)) {
|
|
22920
23475
|
return value.some((item) => hasAutoInitLambda(item, seen));
|
|
22921
23476
|
}
|
|
22922
|
-
if (!
|
|
23477
|
+
if (!isRecord13(value)) {
|
|
22923
23478
|
return false;
|
|
22924
23479
|
}
|
|
22925
23480
|
if (seen.has(value)) {
|
|
@@ -22934,14 +23489,14 @@ function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
22934
23489
|
function setControlValue(control, value) {
|
|
22935
23490
|
const next = clone(control);
|
|
22936
23491
|
next.value = {
|
|
22937
|
-
...
|
|
23492
|
+
...isRecord13(next.value) ? next.value : {},
|
|
22938
23493
|
type: next.value?.type ?? next.field_type,
|
|
22939
23494
|
value
|
|
22940
23495
|
};
|
|
22941
23496
|
return next;
|
|
22942
23497
|
}
|
|
22943
23498
|
function applyRowValues(rowTemplate, rowValue) {
|
|
22944
|
-
const source =
|
|
23499
|
+
const source = isRecord13(rowValue) ? rowValue : {};
|
|
22945
23500
|
return rowTemplate.map((control) => {
|
|
22946
23501
|
if (control.key && Object.prototype.hasOwnProperty.call(source, control.key)) {
|
|
22947
23502
|
return setControlValue(control, source[control.key]);
|
|
@@ -23227,17 +23782,17 @@ function assertStepProjectFormWritable(fields, form, prefix = "") {
|
|
|
23227
23782
|
for (const [key, value] of Object.entries(form)) {
|
|
23228
23783
|
const field = fieldsByKey.get(key);
|
|
23229
23784
|
if (!field) continue;
|
|
23230
|
-
const
|
|
23785
|
+
const path17 = `${prefix}${key}`;
|
|
23231
23786
|
if (field.hidden) {
|
|
23232
|
-
throw new Error(`Step project form handoff cannot write hidden field ${
|
|
23787
|
+
throw new Error(`Step project form handoff cannot write hidden field ${path17}.`);
|
|
23233
23788
|
}
|
|
23234
23789
|
if (isUnsupportedStepPrefillField(field)) {
|
|
23235
|
-
throw new Error(`Step project form handoff cannot write system or manual field ${
|
|
23790
|
+
throw new Error(`Step project form handoff cannot write system or manual field ${path17} (${field.type || "unknown"}).`);
|
|
23236
23791
|
}
|
|
23237
23792
|
if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
|
|
23238
23793
|
value.forEach((row, index) => {
|
|
23239
23794
|
if (isRecordValue(row)) {
|
|
23240
|
-
assertStepProjectFormWritable(field.children ?? [], row, `${
|
|
23795
|
+
assertStepProjectFormWritable(field.children ?? [], row, `${path17}[${index}].`);
|
|
23241
23796
|
}
|
|
23242
23797
|
});
|
|
23243
23798
|
}
|
|
@@ -23499,8 +24054,8 @@ function fieldsForValidation(flowDetail, projectFormTemplate) {
|
|
|
23499
24054
|
}));
|
|
23500
24055
|
}
|
|
23501
24056
|
function metaUsesTemplateProjectName(flowDetail) {
|
|
23502
|
-
const data =
|
|
23503
|
-
const meta =
|
|
24057
|
+
const data = isRecord14(flowDetail?.data) ? flowDetail.data : void 0;
|
|
24058
|
+
const meta = isRecord14(data?.meta) ? data.meta : void 0;
|
|
23504
24059
|
const hideFields = Array.isArray(meta?.hide_fields) ? meta.hide_fields.map(String) : [];
|
|
23505
24060
|
return meta?.use_template_project_name === true || hideFields.includes("project.name");
|
|
23506
24061
|
}
|
|
@@ -23594,9 +24149,9 @@ function contextField(field, reason, options = {}) {
|
|
|
23594
24149
|
function collectPrefillContextForFields(fields, form, result, options = {}) {
|
|
23595
24150
|
for (const field of fields) {
|
|
23596
24151
|
const value = form[field.key];
|
|
23597
|
-
const
|
|
24152
|
+
const path17 = options.prefix ? `${options.prefix}.${field.key}` : field.key;
|
|
23598
24153
|
const fieldOptions = {
|
|
23599
|
-
path:
|
|
24154
|
+
path: path17,
|
|
23600
24155
|
rootKey: options.rootKey ?? field.key,
|
|
23601
24156
|
parentKey: options.parentKey
|
|
23602
24157
|
};
|
|
@@ -23609,7 +24164,7 @@ function collectPrefillContextForFields(fields, form, result, options = {}) {
|
|
|
23609
24164
|
result.filled_fields.push(contextField(field, "prefilled", fieldOptions));
|
|
23610
24165
|
if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
|
|
23611
24166
|
value.forEach((row, index) => {
|
|
23612
|
-
if (
|
|
24167
|
+
if (isRecord14(row)) {
|
|
23613
24168
|
collectPrefillContextForFields(field.children ?? [], row, result, {
|
|
23614
24169
|
prefix: `${field.key}[${index}]`,
|
|
23615
24170
|
rootKey: field.key,
|
|
@@ -23636,7 +24191,7 @@ function buildPrefillContext(fields, form) {
|
|
|
23636
24191
|
}
|
|
23637
24192
|
};
|
|
23638
24193
|
}
|
|
23639
|
-
function
|
|
24194
|
+
function isRecord14(value) {
|
|
23640
24195
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23641
24196
|
}
|
|
23642
24197
|
function isEndedStep(step) {
|
|
@@ -23659,7 +24214,7 @@ function stepIdOf(step) {
|
|
|
23659
24214
|
function pickStepFormPayload(step) {
|
|
23660
24215
|
const formList = Array.isArray(step.formList) ? step.formList : [];
|
|
23661
24216
|
const forms = Array.isArray(step.forms) ? step.forms : [];
|
|
23662
|
-
const metaForm =
|
|
24217
|
+
const metaForm = isRecord14(step.metaForm) ? step.metaForm : void 0;
|
|
23663
24218
|
return {
|
|
23664
24219
|
step_id: step.id,
|
|
23665
24220
|
flow_step_id: step.flow_step_id,
|
|
@@ -23676,7 +24231,7 @@ function pickStepFormPayload(step) {
|
|
|
23676
24231
|
}
|
|
23677
24232
|
async function buildApprovalContext(client, projectId, options) {
|
|
23678
24233
|
const projectDetail = await apiRequest(client, "GET", `/project/${projectId}`);
|
|
23679
|
-
const steps = Array.isArray(projectDetail.steps) ? projectDetail.steps.filter(
|
|
24234
|
+
const steps = Array.isArray(projectDetail.steps) ? projectDetail.steps.filter(isRecord14) : [];
|
|
23680
24235
|
const targetStepIds = /* @__PURE__ */ new Set();
|
|
23681
24236
|
for (const step of steps) {
|
|
23682
24237
|
const id = stepIdOf(step);
|
|
@@ -23702,7 +24257,7 @@ async function buildApprovalContext(client, projectId, options) {
|
|
|
23702
24257
|
}
|
|
23703
24258
|
return {
|
|
23704
24259
|
project: projectDetail,
|
|
23705
|
-
project_form:
|
|
24260
|
+
project_form: isRecord14(projectDetail.metaForm) ? projectDetail.metaForm : null,
|
|
23706
24261
|
inspected_step_count: stepForms.length,
|
|
23707
24262
|
step_forms: stepForms,
|
|
23708
24263
|
failed_steps: failedSteps
|
|
@@ -24040,8 +24595,8 @@ import { spawn as spawn2 } from "child_process";
|
|
|
24040
24595
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
24041
24596
|
|
|
24042
24597
|
// src/core/recipes.ts
|
|
24043
|
-
import { access, mkdir as mkdir11, readdir as
|
|
24044
|
-
import
|
|
24598
|
+
import { access, mkdir as mkdir11, readdir as readdir6, readFile as readFile16, writeFile as writeFile11 } from "fs/promises";
|
|
24599
|
+
import path13 from "path";
|
|
24045
24600
|
var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
24046
24601
|
var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
|
|
24047
24602
|
function assertSafeName(kind, value) {
|
|
@@ -24065,14 +24620,14 @@ function resolveRecipeLocation(options) {
|
|
|
24065
24620
|
workspace,
|
|
24066
24621
|
workspaceDirName,
|
|
24067
24622
|
recipeName: options.recipeName,
|
|
24068
|
-
recipeDir:
|
|
24623
|
+
recipeDir: path13.join(profileDir, "recipes", workspaceDirName, options.recipeName)
|
|
24069
24624
|
};
|
|
24070
24625
|
}
|
|
24071
24626
|
function getRecipesDir(options) {
|
|
24072
24627
|
const workspaceDirName = normalizeWorkspaceForPath(options.workspace || DEFAULT_WORKSPACE);
|
|
24073
|
-
return
|
|
24628
|
+
return path13.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
|
|
24074
24629
|
}
|
|
24075
|
-
function
|
|
24630
|
+
function isRecord15(value) {
|
|
24076
24631
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24077
24632
|
}
|
|
24078
24633
|
function asString(value, fieldName) {
|
|
@@ -24082,7 +24637,7 @@ function asString(value, fieldName) {
|
|
|
24082
24637
|
return value;
|
|
24083
24638
|
}
|
|
24084
24639
|
function parseRecipeDefinition(input) {
|
|
24085
|
-
if (!
|
|
24640
|
+
if (!isRecord15(input)) {
|
|
24086
24641
|
throw new Error("recipe.json must be a JSON object.");
|
|
24087
24642
|
}
|
|
24088
24643
|
if (input.version !== 1) {
|
|
@@ -24090,7 +24645,7 @@ function parseRecipeDefinition(input) {
|
|
|
24090
24645
|
}
|
|
24091
24646
|
const name = asString(input.name, "recipe.name");
|
|
24092
24647
|
assertSafeName("Recipe name", name);
|
|
24093
|
-
if (!
|
|
24648
|
+
if (!isRecord15(input.command)) {
|
|
24094
24649
|
throw new Error("recipe.command must be an object.");
|
|
24095
24650
|
}
|
|
24096
24651
|
const argv = input.command.argv;
|
|
@@ -24098,7 +24653,7 @@ function parseRecipeDefinition(input) {
|
|
|
24098
24653
|
throw new Error("recipe.command.argv must be a non-empty string array.");
|
|
24099
24654
|
}
|
|
24100
24655
|
const variables = Array.isArray(input.variables) ? input.variables.map((item, index) => {
|
|
24101
|
-
if (!
|
|
24656
|
+
if (!isRecord15(item)) {
|
|
24102
24657
|
throw new Error(`recipe.variables[${index}] must be an object.`);
|
|
24103
24658
|
}
|
|
24104
24659
|
const variableName = asString(item.name, `recipe.variables[${index}].name`);
|
|
@@ -24122,13 +24677,13 @@ function parseRecipeDefinition(input) {
|
|
|
24122
24677
|
};
|
|
24123
24678
|
}
|
|
24124
24679
|
async function loadRecipe(recipeDir) {
|
|
24125
|
-
const raw = await
|
|
24680
|
+
const raw = await readFile16(path13.join(recipeDir, "recipe.json"), "utf8");
|
|
24126
24681
|
return parseRecipeDefinition(JSON.parse(raw));
|
|
24127
24682
|
}
|
|
24128
24683
|
async function listRecipes(recipesDir) {
|
|
24129
24684
|
let entries;
|
|
24130
24685
|
try {
|
|
24131
|
-
entries = await
|
|
24686
|
+
entries = await readdir6(recipesDir);
|
|
24132
24687
|
} catch (error) {
|
|
24133
24688
|
if (error.code === "ENOENT") {
|
|
24134
24689
|
return [];
|
|
@@ -24140,7 +24695,7 @@ async function listRecipes(recipesDir) {
|
|
|
24140
24695
|
if (!RECIPE_NAME_PATTERN.test(entry)) {
|
|
24141
24696
|
continue;
|
|
24142
24697
|
}
|
|
24143
|
-
const recipeDir =
|
|
24698
|
+
const recipeDir = path13.join(recipesDir, entry);
|
|
24144
24699
|
try {
|
|
24145
24700
|
const recipe = await loadRecipe(recipeDir);
|
|
24146
24701
|
summaries.push({
|
|
@@ -24174,7 +24729,7 @@ function parseVarsJson(input) {
|
|
|
24174
24729
|
return {};
|
|
24175
24730
|
}
|
|
24176
24731
|
const parsed = JSON.parse(input);
|
|
24177
|
-
if (!
|
|
24732
|
+
if (!isRecord15(parsed)) {
|
|
24178
24733
|
throw new Error("--vars must be a JSON object.");
|
|
24179
24734
|
}
|
|
24180
24735
|
const variables = {};
|
|
@@ -24206,12 +24761,12 @@ function renderTemplate(template, variables) {
|
|
|
24206
24761
|
}
|
|
24207
24762
|
function resolveRecipeFile(recipeDir, token) {
|
|
24208
24763
|
const relative = token.slice(1);
|
|
24209
|
-
if (!relative || relative.includes("..") ||
|
|
24764
|
+
if (!relative || relative.includes("..") || path13.isAbsolute(relative)) {
|
|
24210
24765
|
throw new Error(`Unsafe recipe file reference: ${token}`);
|
|
24211
24766
|
}
|
|
24212
|
-
const resolved =
|
|
24213
|
-
const root =
|
|
24214
|
-
if (resolved !== root && !resolved.startsWith(`${root}${
|
|
24767
|
+
const resolved = path13.resolve(recipeDir, relative);
|
|
24768
|
+
const root = path13.resolve(recipeDir);
|
|
24769
|
+
if (resolved !== root && !resolved.startsWith(`${root}${path13.sep}`)) {
|
|
24215
24770
|
throw new Error(`Recipe file reference escapes recipe directory: ${token}`);
|
|
24216
24771
|
}
|
|
24217
24772
|
return resolved;
|
|
@@ -24221,7 +24776,7 @@ async function renderArgv(options) {
|
|
|
24221
24776
|
const rendered = [];
|
|
24222
24777
|
for (const token of options.recipe.command.argv) {
|
|
24223
24778
|
if (token.startsWith("@")) {
|
|
24224
|
-
const raw = await
|
|
24779
|
+
const raw = await readFile16(resolveRecipeFile(options.recipeDir, token), "utf8");
|
|
24225
24780
|
rendered.push(renderTemplate(raw, options.variables));
|
|
24226
24781
|
} else {
|
|
24227
24782
|
rendered.push(renderTemplate(token, options.variables));
|
|
@@ -24264,16 +24819,16 @@ async function writeRecipeScaffold(options) {
|
|
|
24264
24819
|
mutating: true
|
|
24265
24820
|
}
|
|
24266
24821
|
};
|
|
24267
|
-
await writeFile11(
|
|
24822
|
+
await writeFile11(path13.join(options.location.recipeDir, "recipe.json"), `${JSON.stringify(recipe, null, 2)}
|
|
24268
24823
|
`, "utf8");
|
|
24269
24824
|
await writeFile11(
|
|
24270
|
-
|
|
24825
|
+
path13.join(options.location.recipeDir, "payload.json"),
|
|
24271
24826
|
`${JSON.stringify({ form: {} }, null, 2)}
|
|
24272
24827
|
`,
|
|
24273
24828
|
"utf8"
|
|
24274
24829
|
);
|
|
24275
24830
|
await writeFile11(
|
|
24276
|
-
|
|
24831
|
+
path13.join(options.location.recipeDir, "README.md"),
|
|
24277
24832
|
[`# ${title}`, "", "Describe the BPMAX flow, field mapping, prerequisites, and verification steps for this recipe.", ""].join("\n"),
|
|
24278
24833
|
"utf8"
|
|
24279
24834
|
);
|
|
@@ -24707,8 +25262,8 @@ function registerSetupCommand(program2, deps = {}) {
|
|
|
24707
25262
|
}
|
|
24708
25263
|
|
|
24709
25264
|
// src/core/taskbook.ts
|
|
24710
|
-
import { mkdir as mkdir12, readFile as
|
|
24711
|
-
import
|
|
25265
|
+
import { mkdir as mkdir12, readFile as readFile17, writeFile as writeFile12 } from "fs/promises";
|
|
25266
|
+
import path14 from "path";
|
|
24712
25267
|
var TaskbookError = class extends Error {
|
|
24713
25268
|
};
|
|
24714
25269
|
var REQUIRED_TASKBOOK_TERMS = [
|
|
@@ -24924,19 +25479,19 @@ function hasDomainWriteEvidence(domain, evidenceText, patterns) {
|
|
|
24924
25479
|
function uuidValues(text5) {
|
|
24925
25480
|
return [...new Set([...text5.matchAll(UUID_PATTERN)].map((match) => match[0]))];
|
|
24926
25481
|
}
|
|
24927
|
-
function addUuidIssues(text5, issues,
|
|
25482
|
+
function addUuidIssues(text5, issues, path17) {
|
|
24928
25483
|
for (const value of uuidValues(text5)) {
|
|
24929
25484
|
addTaskbookIssue(
|
|
24930
25485
|
issues,
|
|
24931
25486
|
"uuid_not_allowed",
|
|
24932
25487
|
"taskbook.config.no_uuid",
|
|
24933
25488
|
`BPMAX \u914D\u7F6E\u4EFB\u52A1\u4E0D\u80FD\u4F7F\u7528 UUID\uFF1A${value}\u3002`,
|
|
24934
|
-
{ path:
|
|
25489
|
+
{ 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
25490
|
);
|
|
24936
25491
|
}
|
|
24937
25492
|
}
|
|
24938
25493
|
async function readTaskbookText(file) {
|
|
24939
|
-
const raw = await
|
|
25494
|
+
const raw = await readFile17(file, "utf8");
|
|
24940
25495
|
try {
|
|
24941
25496
|
const parsed = JSON.parse(raw);
|
|
24942
25497
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -24963,7 +25518,7 @@ function findNavigationStrategy(text5) {
|
|
|
24963
25518
|
const matches = [...text5.matchAll(/导航入口策略\s*[::]\s*(nav-config:(?:included|skipped:[^\s|,。]+|deferred:[^\s|,。]+))/gi)];
|
|
24964
25519
|
return matches.at(-1)?.[1] || null;
|
|
24965
25520
|
}
|
|
24966
|
-
function validateNavigationStrategy(text5, issues,
|
|
25521
|
+
function validateNavigationStrategy(text5, issues, path17, subject) {
|
|
24967
25522
|
const strategy = findNavigationStrategy(text5);
|
|
24968
25523
|
if (!strategy) {
|
|
24969
25524
|
addTaskbookIssue(
|
|
@@ -24971,7 +25526,7 @@ function validateNavigationStrategy(text5, issues, path16, subject) {
|
|
|
24971
25526
|
"missing_navigation_strategy",
|
|
24972
25527
|
"taskbook.nav.strategy",
|
|
24973
25528
|
`${subject}\u7F3A\u5C11\u660E\u786E\u7684\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u3002`,
|
|
24974
|
-
{ path:
|
|
25529
|
+
{ 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
25530
|
);
|
|
24976
25531
|
return null;
|
|
24977
25532
|
}
|
|
@@ -24981,7 +25536,7 @@ function validateNavigationStrategy(text5, issues, path16, subject) {
|
|
|
24981
25536
|
"empty_navigation_strategy_reason",
|
|
24982
25537
|
"taskbook.nav.strategy_reason",
|
|
24983
25538
|
`${subject}\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u8DF3\u8FC7\u6216\u5EF6\u540E\u65F6\u5FC5\u987B\u5199\u660E\u539F\u56E0\u3002`,
|
|
24984
|
-
{ path:
|
|
25539
|
+
{ path: path17, suggestion: "\u4F7F\u7528 nav-config:skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 nav-config:deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
|
|
24985
25540
|
);
|
|
24986
25541
|
}
|
|
24987
25542
|
if (/(待完成范围确认后回填|待确认|TODO|TBD|占位)/i.test(strategy)) {
|
|
@@ -24990,7 +25545,7 @@ function validateNavigationStrategy(text5, issues, path16, subject) {
|
|
|
24990
25545
|
"placeholder_navigation_strategy",
|
|
24991
25546
|
"taskbook.nav.strategy_placeholder",
|
|
24992
25547
|
`${subject}\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u4ECD\u662F\u5360\u4F4D\u5185\u5BB9\u3002`,
|
|
24993
|
-
{ path:
|
|
25548
|
+
{ path: path17, suggestion: "\u66FF\u6362\u4E3A included\u3001skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
|
|
24994
25549
|
);
|
|
24995
25550
|
}
|
|
24996
25551
|
return strategy;
|
|
@@ -25467,6 +26022,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
|
|
|
25467
26022
|
"- \u6BCF\u4E2A\u4EFB\u52A1\u7684 `business_goal` \u90FD\u5FC5\u987B\u5199\u6E05\u695A\u4E1A\u52A1\u76EE\u6807\u573A\u666F\u3002",
|
|
25468
26023
|
"- \u6BCF\u4E2A\u4EFB\u52A1\u7684 `required_skills` \u90FD\u5FC5\u987B\u5217\u51FA\u5B9E\u9645\u8981\u4F7F\u7528\u7684 BPMAX skill\u3002",
|
|
25469
26024
|
"- \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",
|
|
26025
|
+
"- \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
26026
|
"",
|
|
25471
26027
|
"## \u8FDB\u5EA6 CSV",
|
|
25472
26028
|
"",
|
|
@@ -25508,7 +26064,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
|
|
|
25508
26064
|
}
|
|
25509
26065
|
async function initTaskbook(outFile, title) {
|
|
25510
26066
|
const content = taskbookTemplate(title);
|
|
25511
|
-
await mkdir12(
|
|
26067
|
+
await mkdir12(path14.dirname(outFile), { recursive: true });
|
|
25512
26068
|
await writeFile12(outFile, content, "utf8");
|
|
25513
26069
|
return { out: outFile, bytes: Buffer.byteLength(content) };
|
|
25514
26070
|
}
|
|
@@ -25598,7 +26154,7 @@ async function initTaskbookProgress(source, outFile) {
|
|
|
25598
26154
|
fields.join(","),
|
|
25599
26155
|
...rows2.map((row) => fields.map((field) => csvEscape(field === "status" ? "\u672A\u5F00\u59CB" : row[field] || "")).join(","))
|
|
25600
26156
|
].join("\n") + "\n";
|
|
25601
|
-
await mkdir12(
|
|
26157
|
+
await mkdir12(path14.dirname(outFile), { recursive: true });
|
|
25602
26158
|
await writeFile12(outFile, csv, "utf8");
|
|
25603
26159
|
return { source, out: outFile, task_count: rows2.length };
|
|
25604
26160
|
}
|
|
@@ -25641,12 +26197,12 @@ function registerTaskbookCommands(program2) {
|
|
|
25641
26197
|
}
|
|
25642
26198
|
|
|
25643
26199
|
// src/commands/test-suite.ts
|
|
25644
|
-
import { readFile as
|
|
25645
|
-
import
|
|
26200
|
+
import { readFile as readFile18 } from "fs/promises";
|
|
26201
|
+
import path15 from "path";
|
|
25646
26202
|
async function resolveE2eSkillSource(sourceSkill) {
|
|
25647
26203
|
if (sourceSkill) {
|
|
25648
|
-
const resolved =
|
|
25649
|
-
const content = await
|
|
26204
|
+
const resolved = path15.resolve(sourceSkill);
|
|
26205
|
+
const content = await readFile18(resolved, "utf8").catch(() => "");
|
|
25650
26206
|
if (!content.includes('name: "bpmax-e2e-flow-test-operator"') && !content.includes("name: bpmax-e2e-flow-test-operator")) {
|
|
25651
26207
|
throw new TestSuiteError("source skill is not bpmax-e2e-flow-test-operator", {
|
|
25652
26208
|
rule_id: "test_suite.run.skill_source_invalid",
|
|
@@ -25737,8 +26293,8 @@ function registerTestSuiteCommands(program2) {
|
|
|
25737
26293
|
}
|
|
25738
26294
|
|
|
25739
26295
|
// src/core/update.ts
|
|
25740
|
-
import { access as access2, mkdir as mkdir13, readFile as
|
|
25741
|
-
import
|
|
26296
|
+
import { access as access2, mkdir as mkdir13, readFile as readFile19, realpath as realpath3, writeFile as writeFile13 } from "fs/promises";
|
|
26297
|
+
import path16 from "path";
|
|
25742
26298
|
var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
25743
26299
|
var UPDATE_STATE_FILE = "update-state.json";
|
|
25744
26300
|
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -25854,11 +26410,11 @@ async function fetchLatestVersion(options = {}) {
|
|
|
25854
26410
|
}
|
|
25855
26411
|
}
|
|
25856
26412
|
function updateStatePath(configDir = getConfigDir()) {
|
|
25857
|
-
return
|
|
26413
|
+
return path16.join(configDir, UPDATE_STATE_FILE);
|
|
25858
26414
|
}
|
|
25859
26415
|
async function readUpdateState(configDir) {
|
|
25860
26416
|
try {
|
|
25861
|
-
const raw = await
|
|
26417
|
+
const raw = await readFile19(updateStatePath(configDir), "utf8");
|
|
25862
26418
|
const parsed = JSON.parse(raw);
|
|
25863
26419
|
if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
|
|
25864
26420
|
return null;
|
|
@@ -25935,7 +26491,7 @@ async function findNpmPath() {
|
|
|
25935
26491
|
}
|
|
25936
26492
|
function detectInstallMethod(input) {
|
|
25937
26493
|
const resolvedPath = input.executablePath || "";
|
|
25938
|
-
const method = resolvedPath.includes(`node_modules${
|
|
26494
|
+
const method = resolvedPath.includes(`node_modules${path16.sep}`) || resolvedPath.includes("node_modules/") ? "npm" : "manual";
|
|
25939
26495
|
return {
|
|
25940
26496
|
method,
|
|
25941
26497
|
resolvedPath,
|
|
@@ -26176,17 +26732,17 @@ function registerUrlCommands(program2, deps = {}) {
|
|
|
26176
26732
|
}
|
|
26177
26733
|
|
|
26178
26734
|
// src/commands/user.ts
|
|
26179
|
-
function
|
|
26735
|
+
function isRecord16(value) {
|
|
26180
26736
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26181
26737
|
}
|
|
26182
26738
|
function userRows(value) {
|
|
26183
|
-
if (Array.isArray(value)) return value.filter(
|
|
26184
|
-
if (!
|
|
26185
|
-
if (Array.isArray(value.data)) return value.data.filter(
|
|
26739
|
+
if (Array.isArray(value)) return value.filter(isRecord16);
|
|
26740
|
+
if (!isRecord16(value)) return [];
|
|
26741
|
+
if (Array.isArray(value.data)) return value.data.filter(isRecord16);
|
|
26186
26742
|
return value.id ? [value] : [];
|
|
26187
26743
|
}
|
|
26188
26744
|
function safeUser2(user) {
|
|
26189
|
-
const roles = Array.isArray(user.role) ? user.role.filter(
|
|
26745
|
+
const roles = Array.isArray(user.role) ? user.role.filter(isRecord16).map((role) => ({
|
|
26190
26746
|
id: role.id,
|
|
26191
26747
|
key: role.key,
|
|
26192
26748
|
name: role.name
|