bpmax-cli 0.2.1-beta.36 → 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.
Files changed (28) hide show
  1. package/README.md +2 -0
  2. package/dist/bin.js +1303 -499
  3. package/dist/bin.js.map +1 -1
  4. package/package.json +1 -1
  5. package/skills/bpmax-ai-taskbook/SKILL.md +1 -0
  6. package/skills/bpmax-builder-shared/SKILL.md +1 -0
  7. package/skills/bpmax-builder-shared/configuration-impact-review.md +76 -0
  8. package/skills/bpmax-cli/SKILL.md +1 -0
  9. package/skills/bpmax-console-template-editor/SKILL.md +4 -2
  10. package/skills/bpmax-dataset-field-template-editor/SKILL.md +4 -2
  11. package/skills/bpmax-dataset-template-editor/SKILL.md +4 -1
  12. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +7 -0
  13. package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +2 -2
  14. package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +13 -9
  15. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +14 -6
  16. package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +2 -2
  17. package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +15 -0
  18. package/skills/bpmax-e2e-flow-test-operator/references/full-detail-guide.md +3 -1
  19. package/skills/bpmax-filter-template-editor/SKILL.md +4 -2
  20. package/skills/bpmax-flow-template-editor/SKILL.md +5 -1
  21. package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +17 -0
  22. package/skills/bpmax-form-template-editor/SKILL.md +5 -1
  23. package/skills/bpmax-list-template-editor/SKILL.md +5 -2
  24. package/skills/bpmax-ui-ux-audit/LICENSE.upstream +23 -0
  25. package/skills/bpmax-ui-ux-audit/SKILL.md +42 -0
  26. package/skills/bpmax-ui-ux-audit/agents/openai.yaml +4 -0
  27. package/skills/bpmax-ui-ux-audit/references/audit-framework.md +39 -0
  28. package/skills/bpmax-ui-ux-audit/references/bpmax-ux-findings.md +56 -0
package/dist/bin.js CHANGED
@@ -233,8 +233,8 @@ function throwCliGovernanceUnsupportedIfNeeded(error, fallbackPath) {
233
233
  }
234
234
  throw error;
235
235
  }
236
- function normalizePath(path16) {
237
- let normalized = path16.split("?")[0] || "/";
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, path16) {
248
- const result = getValue(value, path16);
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, path16) {
252
- const result = getValue(value, path16);
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, path16) {
255
+ function getValue(value, path17) {
256
256
  let current = value;
257
- for (const key of path16) {
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, path16) {
267
+ function capabilityForRequest(method, path17) {
268
268
  const normalizedMethod = method.toUpperCase();
269
- const normalizedPath = normalizePath2(path16);
270
- const pageTemplatePrefix = flowPageTemplateCapabilityPrefix(path16);
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(path16) {
448
- const query = path16.includes("?") ? path16.slice(path16.indexOf("?") + 1) : "";
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(path16) {
468
- let normalized = path16.split("?")[0] || "/";
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.36",
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(path16) {
550
- const normalized = normalizeApiPath(path16);
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(path16) {
715
- let normalized = path16.split("?")[0] || "/";
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 = (path16) => {
839
- if (!path16.startsWith("/")) {
840
- path16 = `/${path16}`;
838
+ var ensureApiPath = (path17) => {
839
+ if (!path17.startsWith("/")) {
840
+ path17 = `/${path17}`;
841
841
  }
842
- if (path16.startsWith("/api/")) {
843
- return path16;
842
+ if (path17.startsWith("/api/")) {
843
+ return path17;
844
844
  }
845
- return `/api${path16}`;
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, path16, options = {}) {
891
+ async function apiRequest(client, method, path17, options = {}) {
892
892
  const profile = clientProfiles.get(client);
893
- const apiPath2 = ensureApiPath(path16);
894
- const capability = options.capability ?? capabilityForRequest(method, path16);
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(path16) {
1203
- let normalized = path16.trim();
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, path16) {
1220
+ function pluginAgentCapabilityForRawApi(method, path17) {
1221
1221
  const normalizedMethod = method.toUpperCase();
1222
- const normalizedPath = normalizeApiPath2(path16);
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(path16) {
1237
- const queryIndex = path16.indexOf("?");
1238
- return new URLSearchParams(queryIndex >= 0 ? path16.slice(queryIndex + 1) : "");
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, path16) {
1241
- const normalizedPath = normalizeApiPath2(path16);
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(path16).has("draft")) {
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, path16) {
1260
- if (isRawConfigPath(method, path16)) {
1259
+ function assertRawApiPathAllowed(method, path17) {
1260
+ if (isRawConfigPath(method, path17)) {
1261
1261
  throw new Error(
1262
- `Raw API ${method} ${path16} 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.`
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(path16);
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} ${path16} 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.`
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, path16, options) => {
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, path16);
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: path16,
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, path16) || "api.raw";
1296
- const result = await apiRequest(client, normalizedMethod, path16, {
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(path16) {
1384
- if (path16.startsWith("/api/")) {
1385
- return path16;
1383
+ function apiPath(path17) {
1384
+ if (path17.startsWith("/api/")) {
1385
+ return path17;
1386
1386
  }
1387
- return `/api${path16.startsWith("/") ? path16 : `/${path16}`}`;
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, path16, options) => {
1391
+ return async (method, path17, options) => {
1392
1392
  const response = await client.request({
1393
1393
  method,
1394
- url: apiPath(path16),
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(path16, query) {
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 `${path16}?${params.toString()}`;
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 path16 = basePath;
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
- path16 = `${basePath}/project`;
3874
+ path17 = `${basePath}/project`;
3875
3875
  } else if (kind === "project-detail") {
3876
3876
  const projectId = requireNumericId(params.projectId, "projectId");
3877
- path16 = `${basePath}/project_detail/0/${projectId}`;
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
- path16 = withQuery(`${basePath}/projectContinue`, {
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
- path16 = withQuery(`${basePath}/project/create`, query);
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}${path16}`;
3905
+ const url = `${origin}${path17}`;
3906
3906
  return {
3907
3907
  ...result,
3908
- path: path16,
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 path9 from "path";
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 path16 = typeof operation.path === "string" ? operation.path : "";
4857
+ const path17 = typeof operation.path === "string" ? operation.path : "";
4858
4858
  const type = typeof operation.type === "string" ? ` ${operation.type}` : "";
4859
- return `submit${type}: ${method}${path16 ? ` ${path16}` : ""}`;
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, path16, errors) {
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(`${path16}.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`);
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, `${path16}[${index}]`, errors));
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 = `${path16}.${key}`;
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, path16 = "") => {
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(path16 || "/");
11809
+ mismatches.push(path17 || "/");
11774
11810
  return;
11775
11811
  }
11776
- left.forEach((item, index) => compare(item, right[index], `${path16}/${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(path16 || "/");
11817
+ mismatches.push(path17 || "/");
11782
11818
  return;
11783
11819
  }
11784
- for (const [key, item] of Object.entries(left)) compare(item, right[key], `${path16}/${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(path16 || "/");
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-workspace.ts
13826
- import { mkdir as mkdir6, readFile as readFile9, realpath, stat as stat4, writeFile as writeFile6 } from "fs/promises";
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 = path6.join(root, entry);
13893
- const value = await stat4(entryPath);
14424
+ const entryPath = path7.join(root, entry);
14425
+ const value = await stat5(entryPath);
13894
14426
  const canonicalEntry = await realpath(entryPath);
13895
- const relative = path6.relative(root, canonicalEntry);
13896
- const staysInsideRoot = relative !== ".." && !relative.startsWith(`..${path6.sep}`) && !path6.isAbsolute(relative);
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: path6.resolve(cwd),
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 = path6.dirname(current);
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 || !path6.isAbsolute(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 = path6.relative(root, currentDirectory);
13968
- if (relative === ".." || relative.startsWith(`..${path6.sep}`) || path6.isAbsolute(relative)) {
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 (path6.isAbsolute(file) || file.split(/[\\/]+/).includes("..")) {
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 = path6.resolve(options.cwd, file);
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 readFile9(targetFile, "utf8");
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(path6.dirname(targetFile), { recursive: true });
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 readFile10 } from "fs/promises";
14213
- import path7 from "path";
14214
- function isRecord4(value) {
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 (isRecord4(value) && isRecord4(value.data)) return value.data;
14219
- return isRecord4(value) ? value : {};
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("/") || path7.isAbsolute(normalized) || parts.some((part) => part === "" || part === "." || part === "..")) {
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(isRecord4).map((item) => ({
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 = path7.join(skill.install_path, manifest.adapter);
14315
- const adapter = JSON.parse(await readFile10(adapterPath, "utf8"));
14316
- if (!isRecord4(adapter) || adapter.domain !== manifest.domain || adapter.plugin_key !== manifest.plugin_key) {
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 (!isRecord4(item)) continue;
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 (!isRecord4(value)) errors.push(message);
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 = path7.join(outDir, `${domain}-${id}-raw.json`);
14508
- const workFile = path7.join(outDir, `${domain}-${id}-work.json`);
14509
- const metaFile = path7.join(outDir, `${domain}-${id}-meta.json`);
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: isRecord4(work) ? work.mode || "edit" : "list",
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 readFile10(path7.join(resolved.install_path, normalized), "utf8"));
14535
- if (!isRecord4(lint) || lint.domain !== resolved.manifest.domain || lint.plugin_key !== resolved.manifest.plugin_key) {
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 (!isRecord4(work)) {
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), isRecord4(base) ? normalizeWorkFromRaw(base, resolved.adapter) : void 0));
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 (!isRecord4(work)) throw new Error("Plugin config work file must be a JSON object.");
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 || (isRecord4(meta) ? meta.mode || "" : "") || "edit");
14565
- const base = isRecord4(meta) && typeof meta.raw_file === "string" ? await readJsonFile(meta.raw_file) : void 0;
14566
- const lintErrors = lintPluginWork(work, await readAdapterLintRules(resolved), isRecord4(base) ? normalizeWorkFromRaw(base, resolved.adapter) : void 0);
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
- ...isRecord4(meta) ? meta : {},
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: isRecord4(meta) && typeof meta.id === "string" ? meta.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 : isRecord4(meta) && typeof meta.base_hash === "string" ? meta.base_hash : 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 (!isRecord4(submit) || submit.domain !== domain || !isRecord4(submit.payload) || !isRecord4(submit.meta)) {
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 = isRecord4(expected) ? comparableRecord(expected, resolved.adapter.work?.compare_fields || resolved.adapter.work?.fields) : void 0;
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 stat5, writeFile as writeFile7 } from "fs/promises";
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 path8 from "path";
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: path8.dirname(workspaceDir)
15370
+ cwd: path9.dirname(workspaceDir)
14839
15371
  });
14840
15372
  return;
14841
15373
  }
14842
- const askpassPath = path8.join(tmpdir2(), `bpmax-cli-git-askpass-${randomUUID3()}.sh`);
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: path8.dirname(workspaceDir),
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 = path8.join(tmpdir2(), `bpmax-cli-git-askpass-${randomUUID3()}.sh`);
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 stat5(targetPath);
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 = path8.resolve(options.workspaceDir);
15748
+ const workspaceDir = path9.resolve(options.workspaceDir);
15217
15749
  const existed = await pathExists(workspaceDir);
15218
15750
  if (!existed) {
15219
- await mkdir7(path8.dirname(workspaceDir), { recursive: true });
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 isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
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) || isRecord5(value) ? JSON.stringify(value) : String(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(path9.dirname(path9.resolve(file)), { recursive: true });
15333
- const evidence = isRecord5(value.evidence) ? value.evidence : value;
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(path9.dirname(path9.resolve(file)), { recursive: true });
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 = isRecord5(work.data) ? work.data : void 0;
15384
- return arrayValue(data?.nodes).filter(isRecord5);
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 (!isRecord5(work)) {
15919
+ if (!isRecord6(work)) {
15388
15920
  return { available: false, reason: "flow-template work file is not a JSON object" };
15389
15921
  }
15390
- const data = isRecord5(work.data) ? work.data : {};
15391
- const meta = isRecord5(data.meta) ? data.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 = isRecord5(work.publish) ? work.publish : void 0;
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 && path9.resolve(options.submit) !== path9.resolve(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 readFile12, readdir as readdir4, stat as stat7, writeFile as writeFile10 } from "fs/promises";
16048
- import path11 from "path";
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 readdir3,
16059
- readFile as readFile11,
16613
+ readdir as readdir4,
16614
+ readFile as readFile12,
16060
16615
  realpath as realpath2,
16061
16616
  rename,
16062
16617
  rm as rm4,
16063
- stat as stat6,
16618
+ stat as stat7,
16064
16619
  unlink,
16065
16620
  writeFile as writeFile9
16066
16621
  } from "fs/promises";
16067
- import path10 from "path";
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";
@@ -16172,6 +16727,12 @@ var CONFIG_BASIS_ALLOWED_PREFIXES = [
16172
16727
  ".codex/skills/"
16173
16728
  ];
16174
16729
  var REPORT_REQUIRED_KEYS = ["run_id:", "scenario_id:", "source_suite:", "result:"];
16730
+ var REPORT_REQUIRED_SKILLS = {
16731
+ test_design_skill: "bpmax-functional-test-design",
16732
+ ux_audit_skill: "bpmax-ui-ux-audit"
16733
+ };
16734
+ var UX_SEVERITIES = ["P0", "P1", "P2", "P3"];
16735
+ var UX_FINDING_STATUSES = /* @__PURE__ */ new Set(["open", "fixed", "verified"]);
16175
16736
  var REPORT_EXECUTION_KEYS = [
16176
16737
  "planned_cases:",
16177
16738
  "executed_cases:",
@@ -16257,14 +16818,14 @@ function runtimeRoute(runtimeUrl) {
16257
16818
  }
16258
16819
  async function exists3(filePath) {
16259
16820
  try {
16260
- await stat6(filePath);
16821
+ await stat7(filePath);
16261
16822
  return true;
16262
16823
  } catch {
16263
16824
  return false;
16264
16825
  }
16265
16826
  }
16266
16827
  async function readText(filePath) {
16267
- return readFile11(filePath, "utf8");
16828
+ return readFile12(filePath, "utf8");
16268
16829
  }
16269
16830
  function fail(message, options = {}) {
16270
16831
  throw new TestSuiteError(message, options);
@@ -16325,12 +16886,12 @@ function reviewSchemaExplanation() {
16325
16886
  };
16326
16887
  }
16327
16888
  function reviewFail(reviewPath, message) {
16328
- const scenarioId = path10.basename(path10.dirname(reviewPath));
16889
+ const scenarioId = path11.basename(path11.dirname(reviewPath));
16329
16890
  fail(
16330
16891
  [
16331
16892
  message,
16332
16893
  "\u8FD0\u884C `bpmax-cli test-suite review explain --format json` \u67E5\u770B\u5B8C\u6574 schema\u3002",
16333
- `\u8FD0\u884C \`bpmax-cli test-suite review repair --scenario ${scenarioId} --draft-root ${path10.dirname(path10.dirname(reviewPath))} --latest-proof <proof.json> --format json\` \u4FEE\u8865\u7F3A\u5931\u5B57\u6BB5\u3002`,
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`,
16334
16895
  `\u6700\u5C0F review.json \u793A\u4F8B\uFF1A${JSON.stringify(reviewSchemaExample(scenarioId))}`
16335
16896
  ].join("\n"),
16336
16897
  {
@@ -16385,7 +16946,7 @@ async function readCases(filePath) {
16385
16946
  code: "legacy_case_steps_format",
16386
16947
  rule_id: "test_suite.case_steps.legacy_aggregated",
16387
16948
  path: filePath,
16388
- suggestion: `\u8FD0\u884C \`bpmax-cli test-suite steps migrate --scenario ${path10.basename(path10.dirname(filePath))} --draft-root ${path10.dirname(path10.dirname(filePath))} --latest-proof <proof.json> --format json\`\uFF0C\u518D\u8865\u9F50\u9010\u6B65\u9AA4\u5B57\u6BB5\u3002`
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`
16389
16950
  });
16390
16951
  }
16391
16952
  if (JSON.stringify(fields) !== JSON.stringify(CASE_FIELDS)) {
@@ -16485,14 +17046,14 @@ function parseReadmeText(filePath, text5) {
16485
17046
  return metadata;
16486
17047
  }
16487
17048
  async function validateReadme(scenarioDir) {
16488
- const readmePath = path10.join(scenarioDir, "README.md");
17049
+ const readmePath = path11.join(scenarioDir, "README.md");
16489
17050
  if (!await exists3(readmePath)) fail(`missing README.md: ${readmePath}`);
16490
17051
  const text5 = await readText(readmePath);
16491
17052
  const metadata = parseReadmeText(readmePath, text5);
16492
17053
  for (const key of REQUIRED_README_KEYS) {
16493
17054
  if (!metadata[key]) fail(`${scenarioDir}: README.md missing \`${key}\``);
16494
17055
  }
16495
- if (metadata.scenario_id !== path10.basename(scenarioDir)) fail(`${scenarioDir}: scenario_id must match directory name`);
17056
+ if (metadata.scenario_id !== path11.basename(scenarioDir)) fail(`${scenarioDir}: scenario_id must match directory name`);
16496
17057
  if (!["true", "false"].includes(metadata.core.toLowerCase())) fail(`${scenarioDir}: core must be true or false`);
16497
17058
  if (!STATUSES.has(metadata.status)) fail(`${scenarioDir}: status must be one of ${JSON.stringify([...STATUSES].sort())}`);
16498
17059
  if (UUID_RE2.test(text5) || ID_AS_ENTRY_RE.test(text5)) {
@@ -16810,14 +17371,14 @@ async function collectE2eAccelerationGaps(root) {
16810
17371
  const dirs = await scenarioDirs(root);
16811
17372
  const gaps = [];
16812
17373
  for (const dir of dirs) {
16813
- const scenarioId = path10.basename(dir);
16814
- const casesPath = path10.join(dir, "cases.csv");
17374
+ const scenarioId = path11.basename(dir);
17375
+ const casesPath = path11.join(dir, "cases.csv");
16815
17376
  if (!await exists3(casesPath)) {
16816
17377
  continue;
16817
17378
  }
16818
17379
  const rows2 = await readCases(casesPath);
16819
- const steps = await readCaseSteps(path10.join(dir, "case_steps.csv"));
16820
- const stepsByCase = validateCaseSteps(path10.join(dir, "case_steps.csv"), rows2, steps);
17380
+ const steps = await readCaseSteps(path11.join(dir, "case_steps.csv"));
17381
+ const stepsByCase = validateCaseSteps(path11.join(dir, "case_steps.csv"), rows2, steps);
16821
17382
  for (const row of rows2) {
16822
17383
  const caseSteps = stepsByCase.get(row.case_id.trim()) ?? [];
16823
17384
  if (row.status === "deprecated" || hasE2eReusableAsset(row, caseSteps)) {
@@ -16836,14 +17397,14 @@ async function collectE2eAccelerationGaps(root) {
16836
17397
  }
16837
17398
  async function scenarioDirs(root) {
16838
17399
  if (!await exists3(root)) return [];
16839
- const items = await readdir3(root, { withFileTypes: true });
16840
- return items.filter((item) => item.isDirectory()).map((item) => path10.join(root, item.name)).sort();
17400
+ const items = await readdir4(root, { withFileTypes: true });
17401
+ return items.filter((item) => item.isDirectory()).map((item) => path11.join(root, item.name)).sort();
16841
17402
  }
16842
17403
  async function validateScenario(scenarioDir) {
16843
17404
  const metadata = await validateReadme(scenarioDir);
16844
- const casesPath = path10.join(scenarioDir, "cases.csv");
17405
+ const casesPath = path11.join(scenarioDir, "cases.csv");
16845
17406
  const rows2 = await readCases(casesPath);
16846
- const caseStepsPath = path10.join(scenarioDir, "case_steps.csv");
17407
+ const caseStepsPath = path11.join(scenarioDir, "case_steps.csv");
16847
17408
  const caseSteps = await readCaseSteps(caseStepsPath);
16848
17409
  const stepsByCase = validateCaseSteps(caseStepsPath, rows2, caseSteps);
16849
17410
  if (rows2.length === 0) fail(`${casesPath}: at least one case is required`);
@@ -16905,7 +17466,7 @@ function migratedStepActions(value) {
16905
17466
  async function migrateScenarioSteps(options) {
16906
17467
  const scenarioDir = scenarioPath(options.draftRoot ?? DEFAULT_DRAFT_ROOT, options.scenario);
16907
17468
  await validateReadme(scenarioDir);
16908
- const casesPath = path10.join(scenarioDir, "cases.csv");
17469
+ const casesPath = path11.join(scenarioDir, "cases.csv");
16909
17470
  const legacyRows = await readLegacyCases(casesPath);
16910
17471
  const nextCases = legacyRows.map(({ steps: _steps, ...row }) => row);
16911
17472
  const stepRows = [];
@@ -16935,7 +17496,7 @@ async function migrateScenarioSteps(options) {
16935
17496
  });
16936
17497
  }
16937
17498
  await writeFile9(casesPath, csvText(CASE_FIELDS, nextCases), "utf8");
16938
- const stepsPath = path10.join(scenarioDir, "case_steps.csv");
17499
+ const stepsPath = path11.join(scenarioDir, "case_steps.csv");
16939
17500
  await writeFile9(stepsPath, csvText(CASE_STEP_FIELDS, stepRows), "utf8");
16940
17501
  return {
16941
17502
  ok: false,
@@ -16950,9 +17511,9 @@ async function migrateScenarioSteps(options) {
16950
17511
  }
16951
17512
  async function suiteHash(scenarioDir) {
16952
17513
  const hash = createHash5("sha256");
16953
- hash.update(await readText(path10.join(scenarioDir, "README.md")));
16954
- hash.update(await readText(path10.join(scenarioDir, "cases.csv")));
16955
- hash.update(await readText(path10.join(scenarioDir, "case_steps.csv")));
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")));
16956
17517
  return hash.digest("hex");
16957
17518
  }
16958
17519
  function executionManifestHash(manifest) {
@@ -16961,7 +17522,7 @@ function executionManifestHash(manifest) {
16961
17522
  async function readExecutionManifest(manifestPath) {
16962
17523
  let value;
16963
17524
  try {
16964
- value = JSON.parse(await readText(path10.resolve(manifestPath)));
17525
+ value = JSON.parse(await readText(path11.resolve(manifestPath)));
16965
17526
  } catch {
16966
17527
  fail(`invalid execution manifest: ${manifestPath}`, { rule_id: "test_suite.execution_manifest.invalid", path: manifestPath });
16967
17528
  }
@@ -16972,10 +17533,10 @@ async function readExecutionManifest(manifestPath) {
16972
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)) {
16973
17534
  fail(`invalid execution manifest shape: ${manifestPath}`, { rule_id: "test_suite.execution_manifest.invalid", path: manifestPath });
16974
17535
  }
16975
- if (path10.basename(path10.dirname(path10.resolve(manifestPath))) !== manifest.run_id) {
17536
+ if (path11.basename(path11.dirname(path11.resolve(manifestPath))) !== manifest.run_id) {
16976
17537
  fail("execution manifest run_id must match its report directory", { rule_id: "test_suite.execution_manifest.run_scope", path: manifestPath });
16977
17538
  }
16978
- const statePath = `${path10.resolve(manifestPath)}.state.json`;
17539
+ const statePath = `${path11.resolve(manifestPath)}.state.json`;
16979
17540
  if (await exists3(statePath)) {
16980
17541
  try {
16981
17542
  const state = JSON.parse(await readText(statePath));
@@ -16993,14 +17554,14 @@ async function readExecutionManifest(manifestPath) {
16993
17554
  return manifest;
16994
17555
  }
16995
17556
  async function writeAtomicJson(filePath, value) {
16996
- const resolved = path10.resolve(filePath);
17557
+ const resolved = path11.resolve(filePath);
16997
17558
  const tempPath = `${resolved}.tmp-${process.pid}-${Date.now()}`;
16998
17559
  await writeFile9(tempPath, `${JSON.stringify(value, null, 2)}
16999
17560
  `, "utf8");
17000
17561
  await rename(tempPath, resolved);
17001
17562
  }
17002
17563
  async function withExecutionManifestLock(manifestPath, action) {
17003
- const resolved = path10.resolve(manifestPath);
17564
+ const resolved = path11.resolve(manifestPath);
17004
17565
  const lockPath = `${resolved}.lock`;
17005
17566
  let handle;
17006
17567
  try {
@@ -17027,27 +17588,27 @@ async function assertExecutionManifestFresh(manifest, manifestPath) {
17027
17588
  }
17028
17589
  }
17029
17590
  async function evidenceContainsDiagnostic(evidencePath) {
17030
- const info = await stat6(evidencePath);
17591
+ const info = await stat7(evidencePath);
17031
17592
  if (info.isDirectory()) {
17032
- const entries = await readdir3(evidencePath, { withFileTypes: true });
17593
+ const entries = await readdir4(evidencePath, { withFileTypes: true });
17033
17594
  for (const entry of entries) {
17034
17595
  if (!entry.isFile()) continue;
17035
17596
  if (/diagnostic/i.test(entry.name)) return true;
17036
17597
  if (!/\.(json|txt|md)$/i.test(entry.name)) continue;
17037
- const value2 = await readText(path10.join(evidencePath, entry.name)).catch(() => "");
17598
+ const value2 = await readText(path11.join(evidencePath, entry.name)).catch(() => "");
17038
17599
  if (/"?diagnostic"?\s*[:=]\s*(?:true|"diagnostic")|result\s*[:=]\s*diagnostic/i.test(value2)) return true;
17039
17600
  }
17040
17601
  return false;
17041
17602
  }
17042
- if (/diagnostic/i.test(path10.basename(evidencePath))) return true;
17603
+ if (/diagnostic/i.test(path11.basename(evidencePath))) return true;
17043
17604
  if (!/\.(json|txt|md)$/i.test(evidencePath)) return false;
17044
17605
  const value = await readText(evidencePath).catch(() => "");
17045
17606
  return /"?diagnostic"?\s*[:=]\s*(?:true|"diagnostic")|result\s*[:=]\s*diagnostic/i.test(value);
17046
17607
  }
17047
17608
  function pathInside(root, candidate) {
17048
- const resolvedRoot = path10.resolve(root);
17049
- const resolvedCandidate = path10.resolve(candidate);
17050
- return resolvedCandidate === resolvedRoot || resolvedCandidate.startsWith(`${resolvedRoot}${path10.sep}`);
17609
+ const resolvedRoot = path11.resolve(root);
17610
+ const resolvedCandidate = path11.resolve(candidate);
17611
+ return resolvedCandidate === resolvedRoot || resolvedCandidate.startsWith(`${resolvedRoot}${path11.sep}`);
17051
17612
  }
17052
17613
  async function pathInsideReal(root, candidate) {
17053
17614
  if (!pathInside(root, candidate)) return false;
@@ -17071,16 +17632,16 @@ async function assertCurrentRunArtifact(manifest, artifactPath) {
17071
17632
  if (!await exists3(artifactPath)) {
17072
17633
  fail(`execution evidence artifact not found: ${artifactPath}`, { rule_id: "test_suite.run.evidence_missing", path: artifactPath });
17073
17634
  }
17074
- const info = await stat6(artifactPath);
17635
+ const info = await stat7(artifactPath);
17075
17636
  if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
17076
17637
  fail("execution evidence artifact predates the current run", { rule_id: "test_suite.run.evidence_stale", path: artifactPath });
17077
17638
  }
17078
17639
  }
17079
17640
  async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
17080
17641
  if (!await exists3(evidencePath)) fail(`execution evidence not found: ${evidencePath}`, { rule_id: "test_suite.run.evidence_missing", path: evidencePath });
17081
- const runDir = path10.dirname(path10.resolve(manifestPath));
17642
+ const runDir = path11.dirname(path11.resolve(manifestPath));
17082
17643
  await assertCurrentRunPathScope(runDir, evidencePath, "formal execution evidence must stay inside the current report run directory");
17083
- const info = await stat6(evidencePath);
17644
+ const info = await stat7(evidencePath);
17084
17645
  if (info.mtime.getTime() + 1e3 < new Date(manifest.started_at).getTime()) {
17085
17646
  fail("execution evidence predates the current run", { rule_id: "test_suite.run.evidence_stale", path: evidencePath });
17086
17647
  }
@@ -17089,19 +17650,19 @@ async function assertCurrentRunEvidence(manifest, manifestPath, evidencePath) {
17089
17650
  }
17090
17651
  }
17091
17652
  async function evidenceTexts(evidencePath) {
17092
- const info = await stat6(evidencePath);
17653
+ const info = await stat7(evidencePath);
17093
17654
  if (!info.isDirectory()) return [await readText(evidencePath).catch(() => "")];
17094
- const entries = await readdir3(evidencePath, { withFileTypes: true });
17655
+ const entries = await readdir4(evidencePath, { withFileTypes: true });
17095
17656
  const texts = [];
17096
17657
  for (const entry of entries) {
17097
17658
  if (!entry.isFile() || !/\.(json|txt|md)$/i.test(entry.name)) continue;
17098
- texts.push(await readText(path10.join(evidencePath, entry.name)).catch(() => ""));
17659
+ texts.push(await readText(path11.join(evidencePath, entry.name)).catch(() => ""));
17099
17660
  }
17100
17661
  return texts;
17101
17662
  }
17102
17663
  async function evidenceJsonRecords(evidencePath) {
17103
- const info = await stat6(evidencePath);
17104
- const paths = info.isDirectory() ? (await readdir3(evidencePath, { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => path10.join(evidencePath, entry.name)) : [evidencePath];
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];
17105
17666
  const records = [];
17106
17667
  for (const source of paths) {
17107
17668
  try {
@@ -17146,9 +17707,9 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
17146
17707
  if (expectedResult !== "pass" && !assertions.some((assertion) => assertion.passed === false)) continue;
17147
17708
  const screenshot = typeof value.screenshot === "string" ? value.screenshot.trim() : "";
17148
17709
  if (!screenshot) continue;
17149
- const screenshotPath = path10.resolve(path10.dirname(source), screenshot);
17710
+ const screenshotPath = path11.resolve(path11.dirname(source), screenshot);
17150
17711
  await assertCurrentRunArtifact(manifest, source);
17151
- await assertCurrentRunPathScope(path10.dirname(manifestPath), screenshotPath, "browser screenshot must stay inside the current report run directory");
17712
+ await assertCurrentRunPathScope(path11.dirname(manifestPath), screenshotPath, "browser screenshot must stay inside the current report run directory");
17152
17713
  await assertCurrentRunArtifact(manifest, screenshotPath);
17153
17714
  if (!await isValidCurrentRunScreenshot(screenshotPath)) {
17154
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 });
@@ -17156,8 +17717,8 @@ async function browserEvidenceScreenshots(manifest, manifestPath, step, evidence
17156
17717
  if (/\bdom\b/i.test(step.evidence_required)) {
17157
17718
  const domSnapshot = typeof value.dom_snapshot === "string" ? value.dom_snapshot.trim() : "";
17158
17719
  if (!domSnapshot) continue;
17159
- const domPath = path10.resolve(path10.dirname(source), domSnapshot);
17160
- await assertCurrentRunPathScope(path10.dirname(manifestPath), domPath, "browser DOM evidence must stay inside the current report run directory");
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");
17161
17722
  await assertCurrentRunArtifact(manifest, domPath);
17162
17723
  }
17163
17724
  matchedRecord = true;
@@ -17263,7 +17824,7 @@ async function browserReportEvidence(manifest) {
17263
17824
  if (label) result.assertions.push(assertion.passed === false ? `\u5931\u8D25\u65AD\u8A00\uFF1A${label}` : label);
17264
17825
  }
17265
17826
  const screenshot = String(value.screenshot || "").trim();
17266
- if (screenshot) result.screenshots.push({ stepId: step.step_id, path: path10.resolve(path10.dirname(source), screenshot) });
17827
+ if (screenshot) result.screenshots.push({ stepId: step.step_id, path: path11.resolve(path11.dirname(source), screenshot) });
17267
17828
  }
17268
17829
  }
17269
17830
  }
@@ -17271,11 +17832,11 @@ async function browserReportEvidence(manifest) {
17271
17832
  return result;
17272
17833
  }
17273
17834
  async function syncTestSuiteRunReportUnlocked(manifestFile) {
17274
- const manifestPath = path10.resolve(manifestFile);
17835
+ const manifestPath = path11.resolve(manifestFile);
17275
17836
  const manifest = await readExecutionManifest(manifestPath);
17276
17837
  await assertExecutionManifestFresh(manifest, manifestPath);
17277
- const runDir = path10.dirname(manifestPath);
17278
- const reportPath = path10.join(runDir, `${manifest.scenario_id}.md`);
17838
+ const runDir = path11.dirname(manifestPath);
17839
+ const reportPath = path11.join(runDir, `${manifest.scenario_id}.md`);
17279
17840
  if (!await exists3(reportPath)) {
17280
17841
  fail("scenario report scaffold is missing; restart the run or restore the generated report", { rule_id: "test_suite.run.report_missing", path: reportPath });
17281
17842
  }
@@ -17303,7 +17864,7 @@ async function syncTestSuiteRunReportUnlocked(manifestFile) {
17303
17864
  }
17304
17865
  }
17305
17866
  report = replaceReportMetadata(report, "browser_status", blockerEvidence ? "blocked" : null);
17306
- report = replaceReportMetadata(report, "blocker_evidence", blockerEvidence ? path10.relative(runDir, blockerEvidence) : null);
17867
+ report = replaceReportMetadata(report, "blocker_evidence", blockerEvidence ? path11.relative(runDir, blockerEvidence) : null);
17307
17868
  report = replaceReportMetadata(report, "runtime_profile", manifest.profile);
17308
17869
  report = replaceReportMetadata(report, "profile_origin", manifest.profile_origin || null);
17309
17870
  report = replaceReportMetadata(report, "runtime_workspace", manifest.workspace || null);
@@ -17322,11 +17883,11 @@ async function syncTestSuiteRunReportUnlocked(manifestFile) {
17322
17883
  `| ${manifest.case_id}`,
17323
17884
  `${step.step_id} ${step.action}`,
17324
17885
  step.status,
17325
- step.evidence.length ? step.evidence.map((item) => `\`${path10.relative(runDir, item)}\``).join("<br>") : "pending"
17886
+ step.evidence.length ? step.evidence.map((item) => `\`${path11.relative(runDir, item)}\``).join("<br>") : "pending"
17326
17887
  ].join(" | ") + " |")
17327
17888
  ].join("\n");
17328
17889
  report = replaceReportSection(report, "## 3. \u7528\u4F8B\u6267\u884C\u7ED3\u679C", "## 4. \u622A\u56FE\u8BC1\u636E", table);
17329
- const screenshotBody = evidence.screenshots.length ? evidence.screenshots.map((item) => `![${manifest.case_id} ${item.stepId} \u672C\u8F6E\u9875\u9762\u8BC1\u636E](${path10.relative(runDir, item.path)})`).join("\n\n") : "pending";
17890
+ const screenshotBody = evidence.screenshots.length ? evidence.screenshots.map((item) => `![${manifest.case_id} ${item.stepId} \u672C\u8F6E\u9875\u9762\u8BC1\u636E](${path11.relative(runDir, item.path)})`).join("\n\n") : "pending";
17330
17891
  report = replaceReportSection(report, "## 4. \u622A\u56FE\u8BC1\u636E", "## 5. \u63A5\u53E3 / \u6570\u636E\u56DE\u8BFB\u8BC1\u636E", screenshotBody);
17331
17892
  const tempPath = `${reportPath}.tmp-${process.pid}`;
17332
17893
  await writeFile9(tempPath, report, "utf8");
@@ -17345,7 +17906,7 @@ async function previousBrowserScreenshotHashes(manifest, step) {
17345
17906
  for (const { value, source } of await evidenceJsonRecords(previousEvidence)) {
17346
17907
  const screenshot = typeof value.screenshot === "string" ? value.screenshot.trim() : "";
17347
17908
  if (!screenshot) continue;
17348
- const screenshotPath = path10.resolve(path10.dirname(source), screenshot);
17909
+ const screenshotPath = path11.resolve(path11.dirname(source), screenshot);
17349
17910
  if (await exists3(screenshotPath)) hashes.add(await sha256(screenshotPath));
17350
17911
  }
17351
17912
  }
@@ -17379,12 +17940,12 @@ async function assertFormalExecutionEvidence(manifest, manifestPath, step, evide
17379
17940
  const sourceEvidence = typeof value.source_evidence === "string" ? value.source_evidence : "";
17380
17941
  if (!observed || assertions.length === 0 || !assertions.every((assertion) => assertion.passed === true) || !sourceEvidence) continue;
17381
17942
  await assertCurrentRunArtifact(manifest, source);
17382
- const sourcePath = path10.resolve(path10.dirname(source), sourceEvidence);
17383
- const runDir = path10.dirname(path10.resolve(manifestPath));
17943
+ const sourcePath = path11.resolve(path11.dirname(source), sourceEvidence);
17944
+ const runDir = path11.dirname(path11.resolve(manifestPath));
17384
17945
  if (!pathInside(runDir, sourcePath)) {
17385
17946
  fail("observe source_evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: sourcePath });
17386
17947
  }
17387
- if (!await exists3(sourcePath) || !(await stat6(sourcePath)).isFile()) continue;
17948
+ if (!await exists3(sourcePath) || !(await stat7(sourcePath)).isFile()) continue;
17388
17949
  const [realRunDir, realSourcePath] = await Promise.all([realpath2(runDir), realpath2(sourcePath)]);
17389
17950
  if (!pathInside(realRunDir, realSourcePath)) {
17390
17951
  fail("observe source_evidence must stay inside the current report run directory", { rule_id: "test_suite.run.evidence_scope", path: sourcePath });
@@ -17400,7 +17961,7 @@ async function writeExecutionManifest(manifestPath, manifest, incrementRevision
17400
17961
  if (incrementRevision) manifest.revision = (manifest.revision ?? 0) + 1;
17401
17962
  else manifest.revision ??= 0;
17402
17963
  await writeAtomicJson(manifestPath, manifest);
17403
- await writeAtomicJson(`${path10.resolve(manifestPath)}.state.json`, {
17964
+ await writeAtomicJson(`${path11.resolve(manifestPath)}.state.json`, {
17404
17965
  revision: manifest.revision,
17405
17966
  hash: executionManifestHash(manifest),
17406
17967
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -17412,15 +17973,15 @@ function currentManifestStep(manifest) {
17412
17973
  async function startTestSuiteRun(options) {
17413
17974
  const scenarioDir = scenarioPath(options.suiteRoot ?? DEFAULT_SUITE_ROOT, options.scenario);
17414
17975
  const scenario = await validateScenario(scenarioDir);
17415
- const rows2 = await readCases(path10.join(scenarioDir, "cases.csv"));
17976
+ const rows2 = await readCases(path11.join(scenarioDir, "cases.csv"));
17416
17977
  const row = rows2.find((item) => item.case_id === options.caseId && item.status !== "deprecated");
17417
17978
  if (!row) fail(`${scenarioDir}: active case not found: ${options.caseId}`, { rule_id: "test_suite.run.case_not_found" });
17418
- const allSteps = await readCaseSteps(path10.join(scenarioDir, "case_steps.csv"));
17419
- const grouped = validateCaseSteps(path10.join(scenarioDir, "case_steps.csv"), rows2, allSteps);
17979
+ const allSteps = await readCaseSteps(path11.join(scenarioDir, "case_steps.csv"));
17980
+ const grouped = validateCaseSteps(path11.join(scenarioDir, "case_steps.csv"), rows2, allSteps);
17420
17981
  const selectedSteps = grouped.get(options.caseId) ?? [];
17421
17982
  const reportDir = await nextReportDir(options.reportRoot ?? DEFAULT_REPORT_ROOT, true);
17422
- const runId = path10.basename(reportDir);
17423
- const manifestPath = path10.join(reportDir, "execution-manifest.json");
17983
+ const runId = path11.basename(reportDir);
17984
+ const manifestPath = path11.join(reportDir, "execution-manifest.json");
17424
17985
  const manifest = {
17425
17986
  version: 1,
17426
17987
  run_id: runId,
@@ -17432,7 +17993,7 @@ async function startTestSuiteRun(options) {
17432
17993
  revision: 0,
17433
17994
  ...options.skillSource ? { skill_source: options.skillSource } : {},
17434
17995
  ...options.skillVersion ? { skill_version: options.skillVersion } : {},
17435
- source_suite: path10.resolve(scenarioDir),
17996
+ source_suite: path11.resolve(scenarioDir),
17436
17997
  suite_hash: await suiteHash(scenarioDir),
17437
17998
  rerun_policy: "full_rerun",
17438
17999
  started_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -17441,15 +18002,33 @@ async function startTestSuiteRun(options) {
17441
18002
  steps: selectedSteps.map((step) => ({ ...step, status: "planned", evidence: [] }))
17442
18003
  };
17443
18004
  await writeExecutionManifest(manifestPath, manifest);
17444
- const scenarioReport = path10.join(reportDir, `${options.scenario}.md`);
18005
+ await writeFile9(
18006
+ path11.join(reportDir, "ux-findings.json"),
18007
+ `${JSON.stringify({
18008
+ version: 1,
18009
+ run_id: runId,
18010
+ scenario_id: options.scenario,
18011
+ audit_status: "blocked",
18012
+ evaluated_surfaces: [],
18013
+ findings: []
18014
+ }, null, 2)}
18015
+ `,
18016
+ "utf8"
18017
+ );
18018
+ const scenarioReport = path11.join(reportDir, `${options.scenario}.md`);
17445
18019
  const plannedSteps = selectedSteps.map((step) => `${options.caseId}/${step.step_id}`).join(", ");
17446
18020
  await writeFile9(
17447
18021
  scenarioReport,
17448
18022
  [
17449
18023
  `run_id: ${runId}`,
17450
18024
  `scenario_id: ${options.scenario}`,
17451
- `source_suite: ${path10.resolve(scenarioDir)}`,
18025
+ `source_suite: ${path11.resolve(scenarioDir)}`,
17452
18026
  "result: partial",
18027
+ "test_design_skill: bpmax-functional-test-design",
18028
+ "ux_audit_skill: bpmax-ui-ux-audit",
18029
+ "ux_audit_status: blocked",
18030
+ "ux_findings: ux-findings.json",
18031
+ "ux_bug_counts: P0=0,P1=0,P2=0,P3=0",
17453
18032
  "rerun_policy: full_rerun",
17454
18033
  `started_at: ${manifest.started_at}`,
17455
18034
  "finished_at: pending",
@@ -17458,7 +18037,7 @@ async function startTestSuiteRun(options) {
17458
18037
  `planned_steps: ${plannedSteps}`,
17459
18038
  "executed_steps: pending",
17460
18039
  "execution_manifest: execution-manifest.json",
17461
- `precondition_check: ${path10.join(reportDir, `precondition-${runId}.json`)}`,
18040
+ `precondition_check: ${path11.join(reportDir, `precondition-${runId}.json`)}`,
17462
18041
  `state_file: ${manifestPath}`,
17463
18042
  `report_run: ${reportDir}`,
17464
18043
  "browser_tool: Chrome DevTools",
@@ -17500,7 +18079,7 @@ async function startTestSuiteRun(options) {
17500
18079
  };
17501
18080
  }
17502
18081
  async function validateExecutionManifestStep(options) {
17503
- const manifestPath = path10.resolve(options.manifest);
18082
+ const manifestPath = path11.resolve(options.manifest);
17504
18083
  const manifest = await readExecutionManifest(manifestPath);
17505
18084
  if (manifest.case_id !== options.caseId || manifest.current_step_id !== options.caseStepId) {
17506
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 });
@@ -17520,11 +18099,11 @@ async function validateExecutionManifestStep(options) {
17520
18099
  return { manifestPath, manifest, step };
17521
18100
  }
17522
18101
  async function preflightExecutionEvidenceDirectory(options) {
17523
- const manifestPath = path10.resolve(options.manifest);
18102
+ const manifestPath = path11.resolve(options.manifest);
17524
18103
  const manifest = await readExecutionManifest(manifestPath);
17525
18104
  await assertExecutionManifestFresh(manifest, manifestPath);
17526
- const runDir = path10.dirname(manifestPath);
17527
- const evidenceDir = path10.resolve(options.evidenceDir);
18105
+ const runDir = path11.dirname(manifestPath);
18106
+ const evidenceDir = path11.resolve(options.evidenceDir);
17528
18107
  if (!pathInside(runDir, evidenceDir)) {
17529
18108
  fail("formal execution evidence must stay inside the current report run directory", {
17530
18109
  rule_id: "test_suite.run.evidence_scope",
@@ -17548,10 +18127,10 @@ async function preflightExecutionEvidenceDirectory(options) {
17548
18127
  suggestion: `Remove the symlink and use a real directory under ${runDir}.`
17549
18128
  });
17550
18129
  }
17551
- const probe = path10.join(evidenceDir, `.bpmax-write-probe-${process.pid}-${Date.now()}`);
18130
+ const probe = path11.join(evidenceDir, `.bpmax-write-probe-${process.pid}-${Date.now()}`);
17552
18131
  try {
17553
18132
  await writeFile9(probe, "ok", "utf8");
17554
- await readFile11(probe, "utf8");
18133
+ await readFile12(probe, "utf8");
17555
18134
  } catch (error) {
17556
18135
  fail(`formal execution evidence directory is not writable: ${error instanceof Error ? error.message : String(error)}`, {
17557
18136
  rule_id: "test_suite.run.evidence_unwritable",
@@ -17565,7 +18144,7 @@ async function preflightExecutionEvidenceDirectory(options) {
17565
18144
  async function appendExecutionManifestEvidence(options) {
17566
18145
  await withExecutionManifestLock(options.manifest, async () => {
17567
18146
  const validated = await validateExecutionManifestStep(options);
17568
- const evidencePath = path10.resolve(options.evidence);
18147
+ const evidencePath = path11.resolve(options.evidence);
17569
18148
  await assertCurrentRunEvidence(validated.manifest, validated.manifestPath, evidencePath);
17570
18149
  validated.step.evidence = [.../* @__PURE__ */ new Set([...validated.step.evidence, evidencePath])];
17571
18150
  await writeExecutionManifest(validated.manifestPath, validated.manifest, true);
@@ -17573,7 +18152,7 @@ async function appendExecutionManifestEvidence(options) {
17573
18152
  }
17574
18153
  async function nextTestSuiteRunStep(manifestPath, profile) {
17575
18154
  const manifest = await readExecutionManifest(manifestPath);
17576
- await assertExecutionManifestFresh(manifest, path10.resolve(manifestPath));
18155
+ await assertExecutionManifestFresh(manifest, path11.resolve(manifestPath));
17577
18156
  if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
17578
18157
  const step = currentManifestStep(manifest);
17579
18158
  if (!step) return { ok: true, complete: true, result: manifest.result, execution: manifest };
@@ -17584,7 +18163,7 @@ async function recordTestSuiteRunStep(options) {
17584
18163
  if (!["pass", "fail", "blocked"].includes(options.result)) fail("run record result must be pass, fail, or blocked", { rule_id: "test_suite.run.result" });
17585
18164
  return withExecutionManifestLock(options.manifest, async () => {
17586
18165
  const validated = await validateExecutionManifestStep(options);
17587
- const evidencePath = path10.resolve(options.evidence);
18166
+ const evidencePath = path11.resolve(options.evidence);
17588
18167
  await assertCurrentRunEvidence(validated.manifest, validated.manifestPath, evidencePath);
17589
18168
  if (options.result === "pass") await assertFormalExecutionEvidence(validated.manifest, validated.manifestPath, validated.step, evidencePath);
17590
18169
  if (options.result !== "pass" && !["browser", "e2e_create_page"].includes(validated.step.runner)) {
@@ -17637,7 +18216,7 @@ async function recordTestSuiteRunStep(options) {
17637
18216
  }
17638
18217
  async function testSuiteRunStatus(manifestPath, profile) {
17639
18218
  const manifest = await readExecutionManifest(manifestPath);
17640
- await assertExecutionManifestFresh(manifest, path10.resolve(manifestPath));
18219
+ await assertExecutionManifestFresh(manifest, path11.resolve(manifestPath));
17641
18220
  if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
17642
18221
  return { ok: true, execution: manifest };
17643
18222
  }
@@ -17670,9 +18249,9 @@ function validateLatestProofObject(proofPath, proof) {
17670
18249
  }
17671
18250
  function scenarioPath(root, scenario) {
17672
18251
  if (!SCENARIO_ID_RE.test(scenario)) fail(`invalid scenario id: ${scenario}`);
17673
- const rootResolved = path10.resolve(root);
17674
- const candidate = path10.resolve(root, scenario);
17675
- if (!candidate.startsWith(`${rootResolved}${path10.sep}`) && candidate !== rootResolved) {
18252
+ const rootResolved = path11.resolve(root);
18253
+ const candidate = path11.resolve(root, scenario);
18254
+ if (!candidate.startsWith(`${rootResolved}${path11.sep}`) && candidate !== rootResolved) {
17676
18255
  fail(`scenario path escapes root: ${candidate}`);
17677
18256
  }
17678
18257
  return candidate;
@@ -17680,14 +18259,14 @@ function scenarioPath(root, scenario) {
17680
18259
  async function fileMap(root) {
17681
18260
  const result = /* @__PURE__ */ new Map();
17682
18261
  async function walk(dir) {
17683
- for (const item of await readdir3(dir, { withFileTypes: true })) {
17684
- const itemPath = path10.join(dir, item.name);
17685
- const rel = path10.relative(root, itemPath);
17686
- if (rel.split(path10.sep)[0] === COPY_DIFF_DIR) continue;
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;
17687
18266
  if (item.isDirectory()) {
17688
18267
  await walk(itemPath);
17689
18268
  } else if (item.isFile()) {
17690
- result.set(rel.split(path10.sep).join("/"), itemPath);
18269
+ result.set(rel.split(path11.sep).join("/"), itemPath);
17691
18270
  }
17692
18271
  }
17693
18272
  }
@@ -17695,10 +18274,10 @@ async function fileMap(root) {
17695
18274
  return result;
17696
18275
  }
17697
18276
  async function sha256(filePath) {
17698
- return createHash5("sha256").update(await readFile11(filePath)).digest("hex");
18277
+ return createHash5("sha256").update(await readFile12(filePath)).digest("hex");
17699
18278
  }
17700
18279
  async function readForDiff(filePath) {
17701
- const buffer = await readFile11(filePath);
18280
+ const buffer = await readFile12(filePath);
17702
18281
  if (buffer.includes(0)) return [`<binary sha256=${createHash5("sha256").update(buffer).digest("hex")}>
17703
18282
  `];
17704
18283
  return buffer.toString("utf8").split(/(?<=\n)/);
@@ -17758,7 +18337,7 @@ async function buildCopyDiff(src, dst, operation) {
17758
18337
  return {
17759
18338
  manifest: {
17760
18339
  operation,
17761
- scenario_id: path10.basename(src),
18340
+ scenario_id: path11.basename(src),
17762
18341
  source: src,
17763
18342
  destination: dst,
17764
18343
  generated_at: (/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "+00:00"),
@@ -17771,12 +18350,12 @@ async function buildCopyDiff(src, dst, operation) {
17771
18350
  };
17772
18351
  }
17773
18352
  async function writeCopyDiffArtifacts(dst, artifacts) {
17774
- const diffDir = path10.join(dst, COPY_DIFF_DIR);
18353
+ const diffDir = path11.join(dst, COPY_DIFF_DIR);
17775
18354
  await mkdir9(diffDir, { recursive: true });
17776
- await writeFile9(path10.join(diffDir, "last.diff"), artifacts.diff, "utf8");
17777
- await writeFile9(path10.join(diffDir, "last.json"), `${JSON.stringify(artifacts.manifest, null, 2)}
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)}
17778
18357
  `, "utf8");
17779
- return path10.join(diffDir, "last.diff");
18358
+ return path11.join(diffDir, "last.diff");
17780
18359
  }
17781
18360
  function summarizeCopyDiff(artifacts) {
17782
18361
  const files = Array.isArray(artifacts.manifest.files) ? artifacts.manifest.files : [];
@@ -17802,12 +18381,12 @@ async function copyScenarioTree(src, dst, replace, operation) {
17802
18381
  artifacts = await buildCopyDiff(src, dst, operation);
17803
18382
  await rm4(dst, { recursive: true, force: true });
17804
18383
  }
17805
- await mkdir9(path10.dirname(dst), { recursive: true });
18384
+ await mkdir9(path11.dirname(dst), { recursive: true });
17806
18385
  await cp3(src, dst, { recursive: true });
17807
18386
  return artifacts ? { path: await writeCopyDiffArtifacts(dst, artifacts), summary: summarizeCopyDiff(artifacts) } : {};
17808
18387
  }
17809
18388
  async function copyDiffPreview(src, dst, operation) {
17810
- const previewDir = path10.join(DEFAULT_TMP_ROOT, `${operation}-${path10.basename(src)}-copy-diff`);
18389
+ const previewDir = path11.join(DEFAULT_TMP_ROOT, `${operation}-${path11.basename(src)}-copy-diff`);
17811
18390
  await rm4(previewDir, { recursive: true, force: true });
17812
18391
  await mkdir9(previewDir, { recursive: true });
17813
18392
  const artifacts = await buildCopyDiff(src, dst, operation);
@@ -17829,7 +18408,7 @@ async function draftUpdate(options) {
17829
18408
  return { destination: dst, copy_diff: copyDiff.path, copy_diff_summary: copyDiff.summary };
17830
18409
  }
17831
18410
  async function validateReviewGate(scenarioDir) {
17832
- const reviewPath = path10.join(scenarioDir, "review.json");
18411
+ const reviewPath = path11.join(scenarioDir, "review.json");
17833
18412
  if (!await exists3(reviewPath)) reviewFail(reviewPath, `${scenarioDir}: missing review.json; run multi-subagent SKILL review before promote`);
17834
18413
  let review;
17835
18414
  try {
@@ -17837,7 +18416,7 @@ async function validateReviewGate(scenarioDir) {
17837
18416
  } catch (error) {
17838
18417
  reviewFail(reviewPath, `${reviewPath}: invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
17839
18418
  }
17840
- if (review.scenario_id !== path10.basename(scenarioDir)) reviewFail(reviewPath, `${reviewPath}: scenario_id must match directory name`);
18419
+ if (review.scenario_id !== path11.basename(scenarioDir)) reviewFail(reviewPath, `${reviewPath}: scenario_id must match directory name`);
17841
18420
  if (!review.latest_proof || typeof review.latest_proof !== "object" || Array.isArray(review.latest_proof)) reviewFail(reviewPath, `${reviewPath}: latest_proof is required`);
17842
18421
  validateLatestProofObject(reviewPath, review.latest_proof);
17843
18422
  if (!REVIEW_STATUSES.has(String(review.status))) reviewFail(reviewPath, `${reviewPath}: status must be one of ${JSON.stringify([...REVIEW_STATUSES].sort())}`);
@@ -17862,8 +18441,8 @@ async function validateReviewGate(scenarioDir) {
17862
18441
  if (!Array.isArray(review.fixes) || review.fixes.length === 0) reviewFail(reviewPath, `${reviewPath}: fixes must be a non-empty list`);
17863
18442
  }
17864
18443
  async function validateExecutionOperabilityReview(reviewPath, scenarioDir, item) {
17865
- const rows2 = await readCases(path10.join(scenarioDir, "cases.csv"));
17866
- const steps = await readCaseSteps(path10.join(scenarioDir, "case_steps.csv"));
18444
+ const rows2 = await readCases(path11.join(scenarioDir, "cases.csv"));
18445
+ const steps = await readCaseSteps(path11.join(scenarioDir, "case_steps.csv"));
17867
18446
  const activeCases = new Set(rows2.filter((row) => row.status !== "deprecated").map((row) => row.case_id));
17868
18447
  const required = steps.filter((step) => activeCases.has(step.case_id)).map((step) => `${step.case_id}/${step.step_id}`);
17869
18448
  const judgments = item.step_judgments;
@@ -17987,10 +18566,10 @@ async function initOrRepairReview(options) {
17987
18566
  const scenarioDir = scenarioPath(options.draftRoot ?? DEFAULT_DRAFT_ROOT, options.scenario);
17988
18567
  if (!await exists3(scenarioDir)) fail(`draft scenario not found: ${scenarioDir}`);
17989
18568
  await validateReadme(scenarioDir);
17990
- const rows2 = await readCases(path10.join(scenarioDir, "cases.csv"));
17991
- const steps = await readCaseSteps(path10.join(scenarioDir, "case_steps.csv"));
18569
+ const rows2 = await readCases(path11.join(scenarioDir, "cases.csv"));
18570
+ const steps = await readCaseSteps(path11.join(scenarioDir, "case_steps.csv"));
17992
18571
  const proof = await readLatestProof(options.latestProof);
17993
- const reviewPath = path10.join(scenarioDir, "review.json");
18572
+ const reviewPath = path11.join(scenarioDir, "review.json");
17994
18573
  let existing;
17995
18574
  const existed = await exists3(reviewPath);
17996
18575
  if (existed) {
@@ -18001,7 +18580,7 @@ async function initOrRepairReview(options) {
18001
18580
  existing = {};
18002
18581
  }
18003
18582
  }
18004
- const review = mergeReviewDraft(path10.basename(scenarioDir), proof, rows2, steps, existing);
18583
+ const review = mergeReviewDraft(path11.basename(scenarioDir), proof, rows2, steps, existing);
18005
18584
  await writeFile9(reviewPath, `${JSON.stringify(review, null, 2)}
18006
18585
  `, "utf8");
18007
18586
  return {
@@ -18036,16 +18615,16 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
18036
18615
  String(today.getDate()).padStart(2, "0")
18037
18616
  ].join("");
18038
18617
  const dirs = await scenarioDirs(root);
18039
- const nums = dirs.map((dir) => path10.basename(dir)).filter((name) => name.startsWith(prefix)).map((name) => RUN_RE.exec(name)?.[1]).filter((value) => Boolean(value)).map((value) => Number(value));
18040
- const reportDir = path10.join(root, `${prefix}-${String(Math.max(0, ...nums) + 1).padStart(3, "0")}`);
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")}`);
18041
18620
  if (create) {
18042
- await mkdir9(path10.join(reportDir, "screenshots"), { recursive: true });
18621
+ await mkdir9(path11.join(reportDir, "screenshots"), { recursive: true });
18043
18622
  await writeFile9(
18044
- path10.join(reportDir, "summary.md"),
18623
+ path11.join(reportDir, "summary.md"),
18045
18624
  [
18046
18625
  "# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B",
18047
18626
  "",
18048
- `run_id: ${path10.basename(reportDir)}`,
18627
+ `run_id: ${path11.basename(reportDir)}`,
18049
18628
  "rerun_policy: full_rerun",
18050
18629
  "status: draft",
18051
18630
  "",
@@ -18053,7 +18632,7 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
18053
18632
  "",
18054
18633
  "## \u622A\u56FE\u76EE\u5F55",
18055
18634
  "",
18056
- `screenshots: ${path10.join(path10.basename(reportDir), "screenshots")}`,
18635
+ `screenshots: ${path11.join(path11.basename(reportDir), "screenshots")}`,
18057
18636
  "",
18058
18637
  "## \u603B\u7ED3",
18059
18638
  ""
@@ -18088,7 +18667,7 @@ function crc32(value) {
18088
18667
  return (crc ^ 4294967295) >>> 0;
18089
18668
  }
18090
18669
  async function isValidCurrentRunScreenshot(filePath) {
18091
- const buffer = await readFile11(filePath);
18670
+ const buffer = await readFile12(filePath);
18092
18671
  const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
18093
18672
  if (buffer.length < 33 || !buffer.subarray(0, 8).equals(signature)) return false;
18094
18673
  let offset = 8;
@@ -18346,34 +18925,257 @@ async function reportHasValidBlockedEvidence(text5, reportPath, runDir, manifest
18346
18925
  if (reportKeyValue(text5, "browser_status:").toLowerCase() !== "blocked") return false;
18347
18926
  const evidenceValue = reportKeyValue(text5, "blocker_evidence:");
18348
18927
  if (!evidenceValue) return false;
18349
- const evidencePath = path10.resolve(path10.dirname(reportPath), evidenceValue);
18350
- if (!await exists3(evidencePath) || !(await stat6(evidencePath)).isFile() || !await pathInsideReal(runDir, evidencePath)) return false;
18928
+ const evidencePath = path11.resolve(path11.dirname(reportPath), evidenceValue);
18929
+ if (!await exists3(evidencePath) || !(await stat7(evidencePath)).isFile() || !await pathInsideReal(runDir, evidencePath)) return false;
18351
18930
  await assertCurrentRunArtifact(manifest, evidencePath);
18352
18931
  const blockedStep = manifest.steps.find((step) => step.status === "blocked");
18353
18932
  return Boolean(
18354
18933
  blockedStep && ["browser", "e2e_create_page"].includes(blockedStep.runner) && await hasStructuredBlockedEvidence(manifest, blockedStep, evidencePath)
18355
18934
  );
18356
18935
  }
18936
+ function emptyUxBugCounts() {
18937
+ return { P0: 0, P1: 0, P2: 0, P3: 0 };
18938
+ }
18939
+ function parseUxBugCounts(value) {
18940
+ const counts = emptyUxBugCounts();
18941
+ const matches = [...value.matchAll(/(?:^|,)\s*(P[0-3])\s*=\s*(\d+)\s*(?=,|$)/g)];
18942
+ if (matches.length !== UX_SEVERITIES.length) return null;
18943
+ for (const match of matches) counts[match[1]] = Number(match[2]);
18944
+ return UX_SEVERITIES.every((severity) => matches.filter((match) => match[1] === severity).length === 1) ? counts : null;
18945
+ }
18946
+ function nonEmptyString(value) {
18947
+ return typeof value === "string" && value.trim().length > 0;
18948
+ }
18949
+ function nonEmptyStringArray(value) {
18950
+ return Array.isArray(value) && value.length > 0 && value.every(nonEmptyString);
18951
+ }
18952
+ async function uxManifestArtifacts(text5, reportPath, runDir) {
18953
+ const artifacts = /* @__PURE__ */ new Set();
18954
+ const manifestValue = reportKeyValue(text5, "execution_manifest:");
18955
+ if (!manifestValue) return artifacts;
18956
+ const manifestPath = path11.resolve(path11.dirname(reportPath), manifestValue);
18957
+ if (!pathInside(runDir, manifestPath) || !await exists3(manifestPath) || !await pathInsideReal(runDir, manifestPath)) {
18958
+ return artifacts;
18959
+ }
18960
+ try {
18961
+ const manifest = JSON.parse(await readText(manifestPath));
18962
+ for (const step of manifest.steps ?? []) {
18963
+ for (const item of step.evidence ?? []) {
18964
+ const evidencePath = path11.isAbsolute(item) ? path11.resolve(item) : path11.resolve(path11.dirname(manifestPath), item);
18965
+ if (!pathInside(runDir, evidencePath) || !await exists3(evidencePath) || !await pathInsideReal(runDir, evidencePath)) continue;
18966
+ artifacts.add(evidencePath);
18967
+ for (const { value, source } of await evidenceJsonRecords(evidencePath)) {
18968
+ artifacts.add(path11.resolve(source));
18969
+ for (const key of ["screenshot", "dom_snapshot", "source_evidence"]) {
18970
+ const referenced = typeof value[key] === "string" ? value[key].trim() : "";
18971
+ if (!referenced) continue;
18972
+ const referencedPath = path11.resolve(path11.dirname(source), referenced);
18973
+ if (pathInside(runDir, referencedPath) && await exists3(referencedPath) && await pathInsideReal(runDir, referencedPath)) {
18974
+ artifacts.add(referencedPath);
18975
+ }
18976
+ }
18977
+ }
18978
+ }
18979
+ }
18980
+ } catch {
18981
+ }
18982
+ return artifacts;
18983
+ }
18984
+ async function validateUxEvidence(values, options) {
18985
+ const errors = [];
18986
+ const mtimes = [];
18987
+ for (const evidenceValue of values) {
18988
+ const evidencePath = path11.resolve(options.runDir, evidenceValue);
18989
+ if (!pathInside(options.runDir, evidencePath) || !await exists3(evidencePath) || !await pathInsideReal(options.runDir, evidencePath) || evidencePath === options.findingsPath) {
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}`);
18991
+ continue;
18992
+ }
18993
+ const info = await stat7(evidencePath);
18994
+ if (!info.isFile()) {
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}`);
18996
+ continue;
18997
+ }
18998
+ if (!options.manifestArtifacts.has(evidencePath)) {
18999
+ errors.push(`[test_suite.report.ux_evidence_manifest] ${options.prefix}: UX BUG \u8BC1\u636E\u5FC5\u987B\u7531\u672C\u8F6E execution manifest \u767B\u8BB0\u6216\u5F15\u7528: ${evidenceValue}`);
19000
+ }
19001
+ if (!isWithinWindow(info.mtime, options.window)) {
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}`);
19003
+ }
19004
+ const extension = path11.extname(evidencePath).toLowerCase();
19005
+ if (extension === ".png") {
19006
+ if (!await isValidCurrentRunScreenshot(evidencePath)) {
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}`);
19008
+ }
19009
+ } else if (extension === ".json") {
19010
+ try {
19011
+ const parsed = JSON.parse(await readText(evidencePath));
19012
+ if (parsed === null || typeof parsed !== "object") throw new Error("expected object or array");
19013
+ } catch {
19014
+ errors.push(`[test_suite.report.ux_evidence_invalid] ${options.prefix}: UX \u7ED3\u6784\u5316\u8BC1\u636E\u5FC5\u987B\u662F\u6709\u6548 JSON: ${evidenceValue}`);
19015
+ }
19016
+ } else if ([".html", ".htm", ".txt", ".md"].includes(extension)) {
19017
+ if (!(await readText(evidencePath)).trim()) {
19018
+ errors.push(`[test_suite.report.ux_evidence_invalid] ${options.prefix}: UX \u6587\u672C\u6216 DOM \u8BC1\u636E\u4E0D\u80FD\u4E3A\u7A7A: ${evidenceValue}`);
19019
+ }
19020
+ } else {
19021
+ errors.push(`[test_suite.report.ux_evidence_invalid] ${options.prefix}: UX \u8BC1\u636E\u53EA\u63A5\u53D7 PNG\u3001JSON\u3001HTML\u3001TXT \u6216 Markdown \u6587\u4EF6: ${evidenceValue}`);
19022
+ }
19023
+ mtimes.push(info.mtime);
19024
+ }
19025
+ return { errors, mtimes };
19026
+ }
19027
+ async function lintUxAudit(text5, reportPath, runDir, runName) {
19028
+ const errors = [];
19029
+ const testDesignSkill = reportKeyValue(text5, "test_design_skill:");
19030
+ const uxAuditSkill = reportKeyValue(text5, "ux_audit_skill:");
19031
+ if (testDesignSkill !== REPORT_REQUIRED_SKILLS.test_design_skill || uxAuditSkill !== REPORT_REQUIRED_SKILLS.ux_audit_skill) {
19032
+ errors.push(`[test_suite.report.required_skills] ${reportPath}: test_design_skill \u5FC5\u987B\u4E3A ${REPORT_REQUIRED_SKILLS.test_design_skill}\uFF0Cux_audit_skill \u5FC5\u987B\u4E3A ${REPORT_REQUIRED_SKILLS.ux_audit_skill}`);
19033
+ }
19034
+ const reportAuditStatus = reportKeyValue(text5, "ux_audit_status:").toLowerCase();
19035
+ if (!["completed", "blocked"].includes(reportAuditStatus)) {
19036
+ errors.push(`[test_suite.report.ux_audit_status] ${reportPath}: ux_audit_status \u5FC5\u987B\u662F completed \u6216 blocked`);
19037
+ }
19038
+ const countsValue = reportKeyValue(text5, "ux_bug_counts:");
19039
+ const reportedCounts = parseUxBugCounts(countsValue);
19040
+ if (!reportedCounts) {
19041
+ errors.push(`[test_suite.report.ux_bug_counts] ${reportPath}: ux_bug_counts \u5FC5\u987B\u5B8C\u6574\u4F7F\u7528 P0=<n>,P1=<n>,P2=<n>,P3=<n>`);
19042
+ }
19043
+ const findingsValue = reportKeyValue(text5, "ux_findings:");
19044
+ const scenarioId = reportKeyValue(text5, "scenario_id:");
19045
+ const resultValue = reportKeyValue(text5, "result:").toLowerCase();
19046
+ const manifestArtifacts = await uxManifestArtifacts(text5, reportPath, runDir);
19047
+ const window = reportExecutionWindow(runName, text5);
19048
+ let actualCounts = emptyUxBugCounts();
19049
+ if (!findingsValue) {
19050
+ errors.push(`[test_suite.report.ux_findings_missing] ${reportPath}: missing \`ux_findings:\``);
19051
+ } else {
19052
+ const findingsPath = path11.resolve(path11.dirname(reportPath), findingsValue);
19053
+ if (!pathInside(runDir, findingsPath)) {
19054
+ errors.push(`[test_suite.report.ux_findings_scope] ${reportPath}: ux_findings \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
19055
+ } else if (!await exists3(findingsPath)) {
19056
+ errors.push(`[test_suite.report.ux_findings_missing] ${reportPath}: ux_findings \u4E0D\u5B58\u5728: ${findingsValue}`);
19057
+ } else if (!await pathInsideReal(runDir, findingsPath)) {
19058
+ errors.push(`[test_suite.report.ux_findings_scope] ${reportPath}: ux_findings \u5FC5\u987B\u771F\u5B9E\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
19059
+ } else {
19060
+ try {
19061
+ const raw = JSON.parse(await readText(findingsPath));
19062
+ if (raw.version !== 1 || raw.run_id !== runName || raw.scenario_id !== scenarioId) {
19063
+ errors.push(`[test_suite.report.ux_findings_identity] ${reportPath}: ux-findings.json \u7684 version/run_id/scenario_id \u5FC5\u987B\u4E0E\u672C\u8F6E\u62A5\u544A\u4E00\u81F4`);
19064
+ }
19065
+ const auditStatus = typeof raw.audit_status === "string" ? raw.audit_status.toLowerCase() : "";
19066
+ if (!["completed", "blocked"].includes(auditStatus) || auditStatus !== reportAuditStatus) {
19067
+ errors.push(`[test_suite.report.ux_audit_status] ${reportPath}: \u62A5\u544A\u4E0E ux-findings.json \u7684 audit_status \u5FC5\u987B\u4E00\u81F4\u4E14\u4E3A completed|blocked`);
19068
+ }
19069
+ if (auditStatus === "completed" && !nonEmptyStringArray(raw.evaluated_surfaces)) {
19070
+ errors.push(`[test_suite.report.ux_surfaces] ${reportPath}: completed UX audit \u5FC5\u987B\u5217\u51FA evaluated_surfaces`);
19071
+ }
19072
+ if (!Array.isArray(raw.findings)) {
19073
+ errors.push(`[test_suite.report.ux_findings_invalid] ${reportPath}: findings \u5FC5\u987B\u662F\u6570\u7EC4`);
19074
+ } else {
19075
+ for (const [index, unknownFinding] of raw.findings.entries()) {
19076
+ const finding = unknownFinding;
19077
+ const prefix = `${reportPath}: findings[${index}]`;
19078
+ const severity = nonEmptyString(finding.severity) && UX_SEVERITIES.includes(finding.severity) ? finding.severity : null;
19079
+ const valid = finding.classification === "BUG" && severity && nonEmptyString(finding.bug_id) && nonEmptyString(finding.title) && nonEmptyString(finding.surface) && nonEmptyString(finding.user_impact) && nonEmptyStringArray(finding.reproduction_steps) && nonEmptyStringArray(finding.heuristic_refs) && nonEmptyStringArray(finding.evidence) && nonEmptyString(finding.recommendation) && nonEmptyString(finding.status) && UX_FINDING_STATUSES.has(finding.status);
19080
+ if (!valid || !severity) {
19081
+ errors.push(`[test_suite.report.ux_finding_invalid] ${prefix}: \u6BCF\u4E2A\u4F53\u9A8C\u95EE\u9898\u90FD\u5FC5\u987B classification=BUG\uFF0C\u5E76\u5305\u542B\u5408\u6CD5\u4E25\u91CD\u5EA6\u3001\u5F71\u54CD\u3001\u590D\u73B0\u3001\u542F\u53D1\u5F0F\u3001\u8BC1\u636E\u3001\u5EFA\u8BAE\u548C\u72B6\u6001`);
19082
+ continue;
19083
+ }
19084
+ const evidenceCheck = await validateUxEvidence(finding.evidence, {
19085
+ findingsPath,
19086
+ manifestArtifacts,
19087
+ prefix,
19088
+ reportPath,
19089
+ runDir,
19090
+ window
19091
+ });
19092
+ errors.push(...evidenceCheck.errors);
19093
+ if (finding.status === "verified") {
19094
+ if (!nonEmptyStringArray(finding.retest_evidence)) {
19095
+ errors.push(`[test_suite.report.ux_verified_evidence] ${prefix}: verified UX BUG \u5FC5\u987B\u5305\u542B retest_evidence`);
19096
+ } else {
19097
+ const retestCheck = await validateUxEvidence(finding.retest_evidence, {
19098
+ findingsPath,
19099
+ manifestArtifacts,
19100
+ prefix,
19101
+ reportPath,
19102
+ runDir,
19103
+ window
19104
+ });
19105
+ errors.push(...retestCheck.errors);
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)))) {
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`);
19109
+ }
19110
+ const latestInitial = Math.max(...evidenceCheck.mtimes.map((item) => item.getTime()));
19111
+ if (retestCheck.mtimes.length === 0 || retestCheck.mtimes.some((item) => item.getTime() <= latestInitial)) {
19112
+ errors.push(`[test_suite.report.ux_verified_evidence] ${prefix}: retest_evidence \u5FC5\u987B\u665A\u4E8E\u539F\u59CB BUG \u8BC1\u636E`);
19113
+ }
19114
+ }
19115
+ } else {
19116
+ actualCounts[severity] += 1;
19117
+ }
19118
+ }
19119
+ }
19120
+ } catch (error) {
19121
+ errors.push(`[test_suite.report.ux_findings_invalid] ${reportPath}: ux_findings \u65E0\u6CD5\u89E3\u6790: ${error instanceof Error ? error.message : String(error)}`);
19122
+ }
19123
+ }
19124
+ }
19125
+ if (reportedCounts && UX_SEVERITIES.some((severity) => reportedCounts[severity] !== actualCounts[severity])) {
19126
+ errors.push(`[test_suite.report.ux_bug_counts] ${reportPath}: ux_bug_counts \u4E0E ux-findings.json \u4E0D\u4E00\u81F4`);
19127
+ }
19128
+ const counts = reportedCounts ?? actualCounts;
19129
+ if (reportAuditStatus === "blocked" && !["partial", "blocked"].includes(resultValue)) {
19130
+ errors.push(`[test_suite.report.ux_result] ${reportPath}: UX \u5BA1\u8BA1 blocked \u65F6 result \u53EA\u80FD\u662F partial \u6216 blocked`);
19131
+ } else if (counts.P0 > 0 || counts.P1 > 0) {
19132
+ if (resultValue !== "fail") errors.push(`[test_suite.report.ux_result] ${reportPath}: \u5B58\u5728 P0/P1 UX BUG \u65F6 result \u5FC5\u987B\u662F fail`);
19133
+ } else if (counts.P2 > 0 || counts.P3 > 0) {
19134
+ if (!["pass-with-warnings", "fail"].includes(resultValue)) errors.push(`[test_suite.report.ux_result] ${reportPath}: \u53EA\u6709 P2/P3 UX BUG \u65F6 result \u5FC5\u987B\u662F pass-with-warnings\uFF1B\u5B58\u5728\u5176\u4ED6\u5931\u8D25\u65F6\u53EF\u4E3A fail`);
19135
+ } else if (reportAuditStatus === "completed" && resultValue === "pass-with-warnings") {
19136
+ errors.push(`[test_suite.report.ux_result] ${reportPath}: \u65E0 UX BUG \u65F6\u4E0D\u80FD\u7528 pass-with-warnings \u89C4\u907F\u660E\u786E\u7ED3\u8BBA`);
19137
+ }
19138
+ if (reportedCounts && testDesignSkill && uxAuditSkill && reportAuditStatus && scenarioId) {
19139
+ return {
19140
+ errors,
19141
+ summary: {
19142
+ report: reportPath,
19143
+ run_id: runName,
19144
+ scenario_id: scenarioId,
19145
+ result: resultValue,
19146
+ test_design_skill: testDesignSkill,
19147
+ ux_audit_skill: uxAuditSkill,
19148
+ ux_audit_status: reportAuditStatus,
19149
+ ux_bug_counts: reportedCounts
19150
+ }
19151
+ };
19152
+ }
19153
+ return { errors };
19154
+ }
18357
19155
  async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18358
- if (!await exists3(root)) return [`report root not found: ${root}`];
19156
+ if (!await exists3(root)) return { errors: [`report root not found: ${root}`], reports: [] };
18359
19157
  const errors = [];
18360
- const resolvedRoot = path10.resolve(root);
18361
- const candidateDirs = RUN_RE.test(path10.basename(resolvedRoot)) ? [resolvedRoot] : (await scenarioDirs(resolvedRoot)).filter((dir) => RUN_RE.test(path10.basename(dir)));
18362
- if (candidateDirs.length === 0) return [`report run not found under: ${resolvedRoot}`];
19158
+ const reports = [];
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)));
19161
+ if (candidateDirs.length === 0) return { errors: [`report run not found under: ${resolvedRoot}`], reports };
18363
19162
  const runDirs = options.allRuns ? candidateDirs : candidateDirs.slice(-1);
18364
19163
  for (const runDir of runDirs) {
18365
- const runName = path10.basename(runDir);
19164
+ const runName = path11.basename(runDir);
18366
19165
  if (!RUN_RE.test(runName)) {
18367
19166
  errors.push(`${runDir}: run directory name must be YYYYMMDD-NNN`);
18368
19167
  continue;
18369
19168
  }
18370
- if (!await exists3(path10.join(runDir, "summary.md"))) errors.push(`${runDir}: missing summary.md`);
18371
- const files = await readdir3(runDir);
19169
+ if (!await exists3(path11.join(runDir, "summary.md"))) errors.push(`${runDir}: missing summary.md`);
19170
+ const files = await readdir4(runDir);
18372
19171
  const scenarioReports = files.filter((file) => file.endsWith(".md") && file !== "summary.md");
18373
19172
  if (scenarioReports.length === 0) errors.push(`${runDir}: missing scenario report markdown`);
18374
19173
  for (const reportName of scenarioReports) {
18375
- const reportPath = path10.join(runDir, reportName);
19174
+ const reportPath = path11.join(runDir, reportName);
18376
19175
  const text5 = await readText(reportPath);
19176
+ const uxAudit = await lintUxAudit(text5, reportPath, runDir, runName);
19177
+ errors.push(...uxAudit.errors);
19178
+ if (uxAudit.summary) reports.push(uxAudit.summary);
18377
19179
  for (const key of REPORT_REQUIRED_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
18378
19180
  for (const key of REPORT_EXECUTION_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
18379
19181
  for (const heading of REPORT_REQUIRED_HEADINGS) if (!text5.includes(heading)) errors.push(`${reportPath}: missing \`${heading}\``);
@@ -18414,8 +19216,8 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18414
19216
  }
18415
19217
  const manifestValue = reportKeyValue(text5, "execution_manifest:");
18416
19218
  if (manifestValue) {
18417
- const manifestPath = path10.resolve(path10.dirname(reportPath), manifestValue);
18418
- const runRoot = path10.resolve(runDir);
19219
+ const manifestPath = path11.resolve(path11.dirname(reportPath), manifestValue);
19220
+ const runRoot = path11.resolve(runDir);
18419
19221
  if (!pathInside(runRoot, manifestPath)) {
18420
19222
  errors.push(`[test_suite.report.execution_manifest_scope] ${reportPath}: execution_manifest \u5FC5\u987B\u4F4D\u4E8E\u672C\u8F6E\u62A5\u544A\u76EE\u5F55\u5185`);
18421
19223
  } else if (!await exists3(manifestPath)) {
@@ -18447,7 +19249,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18447
19249
  if (validTerminalStop && !["browser", "e2e_create_page"].includes(manifest.steps[terminalIndex].runner)) {
18448
19250
  const terminalStep = manifest.steps[terminalIndex];
18449
19251
  for (const evidencePath of terminalStep.evidence) {
18450
- const resolvedEvidencePath = path10.isAbsolute(evidencePath) ? path10.resolve(evidencePath) : path10.resolve(path10.dirname(manifestPath), evidencePath);
19252
+ const resolvedEvidencePath = path11.isAbsolute(evidencePath) ? path11.resolve(evidencePath) : path11.resolve(path11.dirname(manifestPath), evidencePath);
18451
19253
  if (!pathInside(runRoot, resolvedEvidencePath) || !await pathInsideReal(runRoot, resolvedEvidencePath)) {
18452
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}`);
18453
19255
  continue;
@@ -18524,7 +19326,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18524
19326
  if (/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|诊断/.test(resultValue)) {
18525
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`);
18526
19328
  }
18527
- const screenshotsDir = path10.join(runDir, "screenshots");
19329
+ const screenshotsDir = path11.join(runDir, "screenshots");
18528
19330
  if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
18529
19331
  if (isFullRerun) {
18530
19332
  for (const key of ["state_file:", "precondition_check:", "report_run:"]) {
@@ -18549,9 +19351,9 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18549
19351
  errors.push(`${reportPath}: screenshot must be a local file under this run's screenshots directory`);
18550
19352
  continue;
18551
19353
  }
18552
- const imagePath = path10.resolve(path10.dirname(reportPath), imageRef);
18553
- const screenshotsResolved = path10.resolve(screenshotsDir);
18554
- if (!imagePath.startsWith(`${screenshotsResolved}${path10.sep}`)) {
19354
+ const imagePath = path11.resolve(path11.dirname(reportPath), imageRef);
19355
+ const screenshotsResolved = path11.resolve(screenshotsDir);
19356
+ if (!imagePath.startsWith(`${screenshotsResolved}${path11.sep}`)) {
18555
19357
  errors.push(`${reportPath}: image reference must stay under this run's screenshots directory: ${imageRef}`);
18556
19358
  continue;
18557
19359
  }
@@ -18565,7 +19367,7 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18565
19367
  }
18566
19368
  validCurrentRunImages.push(imageRef);
18567
19369
  if (isFullRerun) {
18568
- const imageStat = await stat6(imagePath);
19370
+ const imageStat = await stat7(imagePath);
18569
19371
  if (!isWithinWindow(imageStat.mtime, window)) {
18570
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}`);
18571
19373
  }
@@ -18586,13 +19388,13 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
18586
19388
  }
18587
19389
  }
18588
19390
  }
18589
- return errors;
19391
+ return { errors, reports };
18590
19392
  }
18591
19393
  async function validateCopyDiffArtifacts(scenarioDir) {
18592
- const diffDir = path10.join(scenarioDir, COPY_DIFF_DIR);
19394
+ const diffDir = path11.join(scenarioDir, COPY_DIFF_DIR);
18593
19395
  if (!await exists3(diffDir)) return;
18594
- const manifestPath = path10.join(diffDir, "last.json");
18595
- const diffPath = path10.join(diffDir, "last.diff");
19396
+ const manifestPath = path11.join(diffDir, "last.json");
19397
+ const diffPath = path11.join(diffDir, "last.diff");
18596
19398
  if (!await exists3(manifestPath)) fail(`${scenarioDir}: ${COPY_DIFF_DIR}/last.json is required when copy diff artifacts exist`);
18597
19399
  if (!await exists3(diffPath)) fail(`${scenarioDir}: ${COPY_DIFF_DIR}/last.diff is required when copy diff artifacts exist`);
18598
19400
  let manifest;
@@ -18604,7 +19406,7 @@ async function validateCopyDiffArtifacts(scenarioDir) {
18604
19406
  for (const key of ["operation", "scenario_id", "source", "destination", "generated_at", "summary", "diff_file", "files"]) {
18605
19407
  if (!(key in manifest)) fail(`${manifestPath}: missing \`${key}\``);
18606
19408
  }
18607
- if (manifest.scenario_id !== path10.basename(scenarioDir)) fail(`${manifestPath}: scenario_id must match directory name`);
19409
+ if (manifest.scenario_id !== path11.basename(scenarioDir)) fail(`${manifestPath}: scenario_id must match directory name`);
18608
19410
  if (manifest.diff_file !== "last.diff") fail(`${manifestPath}: diff_file must be last.diff`);
18609
19411
  if (!(await readText(diffPath)).trim()) fail(`${diffPath}: copy diff must not be empty`);
18610
19412
  }
@@ -18628,7 +19430,7 @@ var OPTION_NAMES = ["options", "items", "choices", "values"];
18628
19430
  var REQUIRED_NAMES = ["required", "is_required", "isRequired", "require", "must", "validateRequired"];
18629
19431
  var HIDDEN_NAMES = ["hidden", "is_hidden", "isHidden", "hide", "hideInForm"];
18630
19432
  var VISIBLE_NAMES = ["visible", "display", "show"];
18631
- function isRecord6(value) {
19433
+ function isRecord7(value) {
18632
19434
  return typeof value === "object" && value !== null && !Array.isArray(value);
18633
19435
  }
18634
19436
  function pickString(source, keys) {
@@ -18655,10 +19457,10 @@ function pickBoolean(source, keys) {
18655
19457
  }
18656
19458
  const rules = source.rules;
18657
19459
  if (Array.isArray(rules)) {
18658
- return rules.some((rule) => isRecord6(rule) && pickBoolean(rule, REQUIRED_NAMES));
19460
+ return rules.some((rule) => isRecord7(rule) && pickBoolean(rule, REQUIRED_NAMES));
18659
19461
  }
18660
19462
  const validateMap = source.validateMap;
18661
- if (isRecord6(validateMap) && pickBoolean(validateMap, REQUIRED_NAMES)) {
19463
+ if (isRecord7(validateMap) && pickBoolean(validateMap, REQUIRED_NAMES)) {
18662
19464
  return true;
18663
19465
  }
18664
19466
  return false;
@@ -18682,7 +19484,7 @@ function optionValue(option) {
18682
19484
  if (typeof option === "string" || typeof option === "number") {
18683
19485
  return String(option);
18684
19486
  }
18685
- if (!isRecord6(option)) {
19487
+ if (!isRecord7(option)) {
18686
19488
  return null;
18687
19489
  }
18688
19490
  return pickString(option, ["value", "key", "id", "name", "label", "title"]) ?? null;
@@ -18700,7 +19502,7 @@ function pickOptions(source) {
18700
19502
  }
18701
19503
  for (const containerKey of ["props", "config", "setting", "value"]) {
18702
19504
  const container = source[containerKey];
18703
- if (isRecord6(container)) {
19505
+ if (isRecord7(container)) {
18704
19506
  const nested = pickOptions(container);
18705
19507
  if (nested?.length) {
18706
19508
  return nested;
@@ -18756,7 +19558,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
18756
19558
  }
18757
19559
  return;
18758
19560
  }
18759
- if (!isRecord6(value)) {
19561
+ if (!isRecord7(value)) {
18760
19562
  return;
18761
19563
  }
18762
19564
  const field = fieldFromRecord(value);
@@ -18764,7 +19566,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
18764
19566
  if (isSubFormField(field)) {
18765
19567
  const childFields = /* @__PURE__ */ new Map();
18766
19568
  for (const child of Object.values(value)) {
18767
- if (isRecord6(child) || Array.isArray(child)) {
19569
+ if (isRecord7(child) || Array.isArray(child)) {
18768
19570
  collectFieldCandidates(child, childFields, depth + 1);
18769
19571
  }
18770
19572
  }
@@ -18778,7 +19580,7 @@ function collectFieldCandidates(value, fields, depth = 0) {
18778
19580
  fields.set(field.key, mergeField(fields.get(field.key), field));
18779
19581
  }
18780
19582
  for (const child of Object.values(value)) {
18781
- if (isRecord6(child) || Array.isArray(child)) {
19583
+ if (isRecord7(child) || Array.isArray(child)) {
18782
19584
  collectFieldCandidates(child, fields, depth + 1);
18783
19585
  }
18784
19586
  }
@@ -18796,7 +19598,7 @@ function validateComplexSelector(field, value) {
18796
19598
  if (!isComplexSelectorType(type)) {
18797
19599
  return null;
18798
19600
  }
18799
- const validObject = (item) => isRecord6(item);
19601
+ const validObject = (item) => isRecord7(item);
18800
19602
  const hint = complexSelectorHint(field);
18801
19603
  if (Array.isArray(value)) {
18802
19604
  return value.every(validObject) ? null : `${field.key} must contain selector option object(s), not scalar values. ${hint}`;
@@ -18813,7 +19615,7 @@ function isEnumSelectType(type) {
18813
19615
  return /enum_select/.test(type);
18814
19616
  }
18815
19617
  function optionComparableValue(value) {
18816
- if (isRecord6(value) && ("value" in value || "label" in value)) {
19618
+ if (isRecord7(value) && ("value" in value || "label" in value)) {
18817
19619
  return value.value ?? value.label;
18818
19620
  }
18819
19621
  return value;
@@ -18827,7 +19629,7 @@ function validateType(field, value) {
18827
19629
  if (!Array.isArray(value)) {
18828
19630
  return `${field.key} must be a JSON array of row objects`;
18829
19631
  }
18830
- const invalidRowIndex = value.findIndex((row) => !isRecord6(row));
19632
+ const invalidRowIndex = value.findIndex((row) => !isRecord7(row));
18831
19633
  return invalidRowIndex >= 0 ? `${field.key}[${invalidRowIndex}] must be a row object` : null;
18832
19634
  }
18833
19635
  const selectorError = validateComplexSelector(field, value);
@@ -18853,7 +19655,7 @@ function validateType(field, value) {
18853
19655
  if (/(array|multi|multiple)/.test(type) && !Array.isArray(value)) {
18854
19656
  return `${field.key} must be an array`;
18855
19657
  }
18856
- if (isEnumSelectType(type) && isRecord6(value)) {
19658
+ if (isEnumSelectType(type) && isRecord7(value)) {
18857
19659
  const optionValue2 = value.value ?? value.label;
18858
19660
  return typeof optionValue2 === "string" || typeof optionValue2 === "number" ? null : `${field.key} must be an enum option object with a scalar value`;
18859
19661
  }
@@ -18883,7 +19685,7 @@ function validateFormEntries(form, fields, prefix = "") {
18883
19685
  }
18884
19686
  if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
18885
19687
  for (const [index, row] of value.entries()) {
18886
- if (isRecord6(row)) {
19688
+ if (isRecord7(row)) {
18887
19689
  errors.push(...validateFormEntries(row, field.children, `${prefix}${field.key}[${index}].`));
18888
19690
  }
18889
19691
  }
@@ -18961,7 +19763,7 @@ function explainFormValidationSchema(fields) {
18961
19763
  }
18962
19764
 
18963
19765
  // src/commands/step.ts
18964
- function isRecord7(value) {
19766
+ function isRecord8(value) {
18965
19767
  return typeof value === "object" && value !== null && !Array.isArray(value);
18966
19768
  }
18967
19769
  function stringValue2(value) {
@@ -18988,7 +19790,7 @@ function hasMeaningfulValue(value) {
18988
19790
  if (Array.isArray(value)) {
18989
19791
  return value.some(hasMeaningfulValue);
18990
19792
  }
18991
- if (isRecord7(value)) {
19793
+ if (isRecord8(value)) {
18992
19794
  return Object.values(value).some(hasMeaningfulValue);
18993
19795
  }
18994
19796
  return false;
@@ -18997,7 +19799,7 @@ function isEmptyValue(value) {
18997
19799
  return value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
18998
19800
  }
18999
19801
  function projectIdOfStep(step) {
19000
- const nestedProjectId = isRecord7(step.project) ? step.project.id : void 0;
19802
+ const nestedProjectId = isRecord8(step.project) ? step.project.id : void 0;
19001
19803
  return idValue(step.project_id ?? step.projectId ?? nestedProjectId);
19002
19804
  }
19003
19805
  function stepFlowNodeId(step) {
@@ -19025,12 +19827,12 @@ function collectRecords(value, output = [], seen = /* @__PURE__ */ new Set()) {
19025
19827
  value.forEach((item) => collectRecords(item, output, seen));
19026
19828
  return output;
19027
19829
  }
19028
- if (!isRecord7(value)) {
19830
+ if (!isRecord8(value)) {
19029
19831
  return output;
19030
19832
  }
19031
19833
  output.push(value);
19032
19834
  for (const child of Object.values(value)) {
19033
- if (Array.isArray(child) || isRecord7(child)) {
19835
+ if (Array.isArray(child) || isRecord8(child)) {
19034
19836
  collectRecords(child, output, seen);
19035
19837
  }
19036
19838
  }
@@ -19114,7 +19916,7 @@ function formListOfStep(step) {
19114
19916
  return values.filter(hasMeaningfulValue);
19115
19917
  }
19116
19918
  function unwrapFormValue(value) {
19117
- if (!isRecord7(value)) {
19919
+ if (!isRecord8(value)) {
19118
19920
  return value;
19119
19921
  }
19120
19922
  if ("value" in value && Object.keys(value).length <= 3) {
@@ -19131,7 +19933,7 @@ function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set())
19131
19933
  value.forEach((item) => collectFormValues(item, output, seen));
19132
19934
  return output;
19133
19935
  }
19134
- if (!isRecord7(value)) {
19936
+ if (!isRecord8(value)) {
19135
19937
  return output;
19136
19938
  }
19137
19939
  const key = stringValue2(value.key ?? value.field_key ?? value.fieldKey ?? value.name);
@@ -19142,7 +19944,7 @@ function collectFormValues(value, output = {}, seen = /* @__PURE__ */ new Set())
19142
19944
  }
19143
19945
  }
19144
19946
  for (const child of Object.values(value)) {
19145
- if (Array.isArray(child) || isRecord7(child)) {
19947
+ if (Array.isArray(child) || isRecord8(child)) {
19146
19948
  collectFormValues(child, output, seen);
19147
19949
  }
19148
19950
  }
@@ -19189,7 +19991,7 @@ function collectMissingRequiredInputs(fields, values) {
19189
19991
  continue;
19190
19992
  }
19191
19993
  value.forEach((row, index) => {
19192
- if (!isRecord7(row)) {
19994
+ if (!isRecord8(row)) {
19193
19995
  return;
19194
19996
  }
19195
19997
  for (const child of field.children ?? []) {
@@ -19244,7 +20046,7 @@ function ownerIdsFromStep(step) {
19244
20046
  ];
19245
20047
  const ids = /* @__PURE__ */ new Set();
19246
20048
  for (const owner of owners) {
19247
- if (isRecord7(owner)) {
20049
+ if (isRecord8(owner)) {
19248
20050
  const id = idValue(owner.owner_id ?? owner.user_id ?? owner.id);
19249
20051
  if (id) {
19250
20052
  ids.add(id);
@@ -19278,7 +20080,7 @@ function ownerDiagnosticsFromStep(step, currentUser) {
19278
20080
  const values = Array.isArray(value) ? value : [value];
19279
20081
  for (const item of values) {
19280
20082
  let id;
19281
- if (isRecord7(item)) {
20083
+ if (isRecord8(item)) {
19282
20084
  id = idValue(item.owner_id ?? item.user_id ?? item.id);
19283
20085
  } else {
19284
20086
  id = idValue(item);
@@ -19390,12 +20192,12 @@ function extractSubmitInputValues(data) {
19390
20192
  const candidates = [data.form, data.form_data, data.formData, data.fields, data.values];
19391
20193
  const values = {};
19392
20194
  for (const candidate of candidates) {
19393
- if (isRecord7(candidate)) {
20195
+ if (isRecord8(candidate)) {
19394
20196
  Object.assign(values, candidate);
19395
20197
  }
19396
20198
  }
19397
20199
  for (const [key, value] of Object.entries(data)) {
19398
- if (!SUBMIT_NON_FORM_KEYS.has(key) && !isRecord7(value) && !Array.isArray(value)) {
20200
+ if (!SUBMIT_NON_FORM_KEYS.has(key) && !isRecord8(value) && !Array.isArray(value)) {
19399
20201
  values[key] = value;
19400
20202
  }
19401
20203
  }
@@ -19557,7 +20359,7 @@ async function appendE2eExecutionEvidence(options, evidence, runners) {
19557
20359
  runners
19558
20360
  });
19559
20361
  }
19560
- function isRecord8(value) {
20362
+ function isRecord9(value) {
19561
20363
  return typeof value === "object" && value !== null && !Array.isArray(value);
19562
20364
  }
19563
20365
  function stringValue3(value) {
@@ -19578,18 +20380,18 @@ function timestampSlug() {
19578
20380
  return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
19579
20381
  }
19580
20382
  async function ensureDir(dir) {
19581
- const resolved = path11.resolve(dir);
20383
+ const resolved = path12.resolve(dir);
19582
20384
  await mkdir10(resolved, { recursive: true });
19583
20385
  return resolved;
19584
20386
  }
19585
20387
  async function writeEvidence(dir, name, value) {
19586
- const file = path11.join(await ensureDir(dir), name);
20388
+ const file = path12.join(await ensureDir(dir), name);
19587
20389
  await writeFile10(file, `${JSON.stringify(redactAuditValue(value), null, 2)}
19588
20390
  `, "utf8");
19589
20391
  return file;
19590
20392
  }
19591
20393
  function summarizeRemoteResult(value) {
19592
- if (!isRecord8(value)) return value;
20394
+ if (!isRecord9(value)) return value;
19593
20395
  const summary = {};
19594
20396
  for (const key of ["id", "project_id", "step_id", "status", "state", "code", "msg", "message", "next", "action"]) {
19595
20397
  if (value[key] !== void 0) summary[key] = value[key];
@@ -19597,29 +20399,29 @@ function summarizeRemoteResult(value) {
19597
20399
  return Object.keys(summary).length > 0 ? redactAuditValue(summary) : { received: true };
19598
20400
  }
19599
20401
  function stepReadbackConfirmed(before, after) {
19600
- const beforeStatus = isRecord8(before.step) ? before.step.status : void 0;
19601
- const afterStatus = isRecord8(after.step) ? after.step.status : void 0;
19602
- const beforeProjectStep = isRecord8(before.project) ? before.project.current_flow_step_id : void 0;
19603
- const afterProjectStep = isRecord8(after.project) ? after.project.current_flow_step_id : void 0;
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;
19604
20406
  return after.step_finished === true || beforeStatus !== afterStatus || beforeProjectStep !== afterProjectStep;
19605
20407
  }
19606
20408
  function evidenceMime(buffer, file) {
19607
20409
  if (buffer.length >= 8 && buffer.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) return "image/png";
19608
20410
  if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) return "image/jpeg";
19609
20411
  if (buffer.length >= 12 && buffer.subarray(0, 4).toString("ascii") === "RIFF" && buffer.subarray(8, 12).toString("ascii") === "WEBP") return "image/webp";
19610
- if (path11.extname(file).toLowerCase() === ".json") return "application/json";
19611
- if ([".txt", ".md", ".log"].includes(path11.extname(file).toLowerCase())) return "text/plain";
20412
+ if (path12.extname(file).toLowerCase() === ".json") return "application/json";
20413
+ if ([".txt", ".md", ".log"].includes(path12.extname(file).toLowerCase())) return "text/plain";
19612
20414
  return "application/octet-stream";
19613
20415
  }
19614
20416
  async function writeEvidenceManifest(evidenceDir, details) {
19615
- const files = await readdir4(evidenceDir, { withFileTypes: true });
20417
+ const files = await readdir5(evidenceDir, { withFileTypes: true });
19616
20418
  const artifacts = [];
19617
20419
  for (const entry of files) {
19618
20420
  if (!entry.isFile() || entry.name === "evidence-manifest.json") continue;
19619
- const file = path11.join(evidenceDir, entry.name);
19620
- const buffer = await readFile12(file);
20421
+ const file = path12.join(evidenceDir, entry.name);
20422
+ const buffer = await readFile13(file);
19621
20423
  const mimeType = evidenceMime(buffer, entry.name);
19622
- const extension = path11.extname(entry.name).toLowerCase();
20424
+ const extension = path12.extname(entry.name).toLowerCase();
19623
20425
  const expectedMime = extension === ".png" ? "image/png" : [".jpg", ".jpeg"].includes(extension) ? "image/jpeg" : extension === ".webp" ? "image/webp" : void 0;
19624
20426
  artifacts.push({
19625
20427
  path: entry.name,
@@ -19632,19 +20434,19 @@ async function writeEvidenceManifest(evidenceDir, details) {
19632
20434
  return writeEvidence(evidenceDir, "evidence-manifest.json", {
19633
20435
  schema_version: 1,
19634
20436
  generated_at: (/* @__PURE__ */ new Date()).toISOString(),
19635
- evidence_dir: path11.resolve(evidenceDir),
20437
+ evidence_dir: path12.resolve(evidenceDir),
19636
20438
  ...details,
19637
20439
  artifacts
19638
20440
  });
19639
20441
  }
19640
20442
  function cacheRoot() {
19641
- return path11.resolve(".codex/cache/bpmax-e2e");
20443
+ return path12.resolve(".codex/cache/bpmax-e2e");
19642
20444
  }
19643
20445
  function safeSegment(value) {
19644
20446
  return value.trim().replace(/[^a-zA-Z0-9._:-]+/g, "_") || "default";
19645
20447
  }
19646
20448
  function safeIdentity(value) {
19647
- if (!isRecord8(value)) return null;
20449
+ if (!isRecord9(value)) return null;
19648
20450
  return {
19649
20451
  id: value.id,
19650
20452
  name: value.name,
@@ -19685,14 +20487,14 @@ async function browserSessionRequest(profile, cookie, method, apiPath2, data, hr
19685
20487
  response.status
19686
20488
  );
19687
20489
  }
19688
- if (isRecord8(body) && typeof body.code === "number" && body.code !== 0) {
20490
+ if (isRecord9(body) && typeof body.code === "number" && body.code !== 0) {
19689
20491
  throw new BrowserSessionRejectedError(
19690
20492
  `e2e.identity.api_error: ${String(body.msg ?? body.message ?? body.code)}`,
19691
20493
  response.status,
19692
20494
  body.code
19693
20495
  );
19694
20496
  }
19695
- return isRecord8(body) && Object.prototype.hasOwnProperty.call(body, "data") ? body.data : body;
20497
+ return isRecord9(body) && Object.prototype.hasOwnProperty.call(body, "data") ? body.data : body;
19696
20498
  }
19697
20499
  function identityCookie(cookieEnv) {
19698
20500
  const cookie = process.env[cookieEnv]?.trim();
@@ -19725,7 +20527,7 @@ function valuesEqual(left, right) {
19725
20527
  }
19726
20528
  function pathValue(source, dottedPath) {
19727
20529
  return dottedPath.split(".").reduce((current, segment) => {
19728
- if (!isRecord8(current)) {
20530
+ if (!isRecord9(current)) {
19729
20531
  return void 0;
19730
20532
  }
19731
20533
  return current[segment];
@@ -19735,7 +20537,7 @@ function normalizeExpectedChecks(value) {
19735
20537
  if (!Array.isArray(value)) {
19736
20538
  return [];
19737
20539
  }
19738
- return value.filter(isRecord8).map((item) => ({
20540
+ return value.filter(isRecord9).map((item) => ({
19739
20541
  ...stringValue3(item.name) ? { name: stringValue3(item.name) } : {},
19740
20542
  path: stringValue3(item.path) ?? "",
19741
20543
  op: stringValue3(item.op) ?? "equals",
@@ -19808,13 +20610,13 @@ function buildExpectedChecks(options) {
19808
20610
  ];
19809
20611
  }
19810
20612
  function flowCachePath(profileName, flowId) {
19811
- return path11.join(cacheRoot(), "profiles", safeSegment(profileName), "flows", `${safeSegment(flowId)}.json`);
20613
+ return path12.join(cacheRoot(), "profiles", safeSegment(profileName), "flows", `${safeSegment(flowId)}.json`);
19812
20614
  }
19813
20615
  async function readOptionalJson(file) {
19814
20616
  try {
19815
- const raw = await readFile12(file, "utf8");
20617
+ const raw = await readFile13(file, "utf8");
19816
20618
  const parsed = JSON.parse(raw);
19817
- return isRecord8(parsed) ? parsed : null;
20619
+ return isRecord9(parsed) ? parsed : null;
19818
20620
  } catch (error) {
19819
20621
  if (error.code === "ENOENT") {
19820
20622
  return null;
@@ -19841,11 +20643,11 @@ function stepsFromProfile(profile) {
19841
20643
  }
19842
20644
  const steps = profile.steps;
19843
20645
  if (Array.isArray(steps)) {
19844
- return steps.filter(isRecord8);
20646
+ return steps.filter(isRecord9);
19845
20647
  }
19846
- if (isRecord8(steps)) {
20648
+ if (isRecord9(steps)) {
19847
20649
  return Object.entries(steps).map(([stepId, value]) => ({
19848
- ...isRecord8(value) ? value : { data: value },
20650
+ ...isRecord9(value) ? value : { data: value },
19849
20651
  step_id: stepId
19850
20652
  }));
19851
20653
  }
@@ -19857,7 +20659,7 @@ function normalizeStepPlan(input, defaults) {
19857
20659
  throw new Error("e2e step-run requires --step-id or data-profile steps[].step_id.");
19858
20660
  }
19859
20661
  const rawData = input.data ?? input.payload_template ?? input.payloadTemplate ?? input.form ?? input.values ?? {};
19860
- const data = isRecord8(rawData) ? rawData : {};
20662
+ const data = isRecord9(rawData) ? rawData : {};
19861
20663
  return {
19862
20664
  step_id: stepId,
19863
20665
  action: stringValue3(input.action) ?? defaults.action,
@@ -19897,7 +20699,7 @@ function dataProfilePath(input) {
19897
20699
  if (!input?.startsWith("@")) {
19898
20700
  return void 0;
19899
20701
  }
19900
- return path11.resolve(input.slice(1));
20702
+ return path12.resolve(input.slice(1));
19901
20703
  }
19902
20704
  function refreshedStepTemplate(options) {
19903
20705
  return {
@@ -19921,14 +20723,14 @@ function refreshedStepTemplate(options) {
19921
20723
  variables: Object.keys(options.plan.data).filter((key) => !["project_id", "action", "urgency"].includes(key)),
19922
20724
  payload_template: options.plan.data,
19923
20725
  source_evidence: {
19924
- evidence_dir: path11.resolve(options.evidenceDir),
19925
- context: path11.basename(options.contextFile)
20726
+ evidence_dir: path12.resolve(options.evidenceDir),
20727
+ context: path12.basename(options.contextFile)
19926
20728
  }
19927
20729
  };
19928
20730
  }
19929
20731
  async function writeRefreshedCache(file, template) {
19930
- const out = path11.resolve(file);
19931
- await mkdir10(path11.dirname(out), { recursive: true });
20732
+ const out = path12.resolve(file);
20733
+ await mkdir10(path12.dirname(out), { recursive: true });
19932
20734
  await writeFile10(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
19933
20735
  `, "utf8");
19934
20736
  return out;
@@ -20006,13 +20808,13 @@ test(${JSON.stringify(options.title)}, async ({ page }) => {
20006
20808
  async function writeBrowserTemplate(options) {
20007
20809
  const handoffUrl = handoffUrlFromInput(options.handoff);
20008
20810
  const assertFields = (options.assertFields ?? "").split(",").map((item) => item.trim()).filter(Boolean);
20009
- const out = path11.resolve(options.out);
20010
- await mkdir10(path11.dirname(out), { recursive: true });
20811
+ const out = path12.resolve(options.out);
20812
+ await mkdir10(path12.dirname(out), { recursive: true });
20011
20813
  await writeFile10(out, playwrightTemplate({
20012
20814
  title: options.title ?? "BPMAX create page handoff submit",
20013
20815
  handoffUrl,
20014
20816
  assertFields,
20015
- evidenceDir: path11.resolve(options.evidenceDir)
20817
+ evidenceDir: path12.resolve(options.evidenceDir)
20016
20818
  }), "utf8");
20017
20819
  return { out, handoff_url: handoffUrl, assert_fields: assertFields };
20018
20820
  }
@@ -20021,7 +20823,7 @@ function scenarioRecords(plan) {
20021
20823
  if (!Array.isArray(records)) {
20022
20824
  return [];
20023
20825
  }
20024
- return records.filter(isRecord8);
20826
+ return records.filter(isRecord9);
20025
20827
  }
20026
20828
  function recordKey(record, index) {
20027
20829
  return stringValue3(record.demo_no ?? record.id ?? record.case_id ?? record.subject) ?? `record-${index + 1}`;
@@ -20383,7 +21185,7 @@ function registerE2eCommands(program2) {
20383
21185
  mode: "handoff_command_hint",
20384
21186
  browser: options.browser,
20385
21187
  next_command: `bpmax-cli project create ${flowFlag}${jsonFlag}${profileFlag} --handoff-only --format json > handoff.json`,
20386
- next_after_handoff: `bpmax-cli e2e create-page-submit --handoff-json @handoff.json --browser ${options.browser} --evidence-dir ${path11.resolve(options.evidenceDir)} --format json`,
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`,
20387
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."
20388
21190
  });
20389
21191
  return;
@@ -20405,7 +21207,7 @@ function registerE2eCommands(program2) {
20405
21207
  browser_verified: false,
20406
21208
  browser: options.browser,
20407
21209
  ...generated,
20408
- evidence_dir: path11.resolve(options.evidenceDir),
21210
+ evidence_dir: path12.resolve(options.evidenceDir),
20409
21211
  next_command: `npx playwright test ${generated.out}`,
20410
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."
20411
21213
  });
@@ -20415,7 +21217,7 @@ function registerE2eCommands(program2) {
20415
21217
  const profile = resolveProfile(await loadConfig(), options.profile);
20416
21218
  const file = flowCachePath(profile.name, options.flowId);
20417
21219
  const cached = await readOptionalJson(file);
20418
- const fileStat = await stat7(file).catch(() => null);
21220
+ const fileStat = await stat8(file).catch(() => null);
20419
21221
  printResult(options.format, {
20420
21222
  ok: true,
20421
21223
  profile: profile.name,
@@ -20456,7 +21258,7 @@ function registerE2eCommands(program2) {
20456
21258
  template_id: result.template_id ?? result.templateId
20457
21259
  })).digest("hex").slice(0, 16);
20458
21260
  const file = flowCachePath(profile.name, options.flowId);
20459
- await mkdir10(path11.dirname(file), { recursive: true });
21261
+ await mkdir10(path12.dirname(file), { recursive: true });
20460
21262
  await writeFile10(file, `${JSON.stringify(redactAuditValue({
20461
21263
  cache_key: cacheKey,
20462
21264
  cached_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -20487,25 +21289,25 @@ function registerE2eCommands(program2) {
20487
21289
  printResult(options.format, {
20488
21290
  ok: true,
20489
21291
  ...generated,
20490
- evidence_dir: path11.resolve(options.evidenceDir),
21292
+ evidence_dir: path12.resolve(options.evidenceDir),
20491
21293
  next_command: `npx playwright test ${generated.out}`
20492
21294
  });
20493
21295
  });
20494
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) => {
20495
21297
  await requireE2eExecutionBinding(options, ["browser", "e2e_create_page", "e2e_step_run", "observe"]);
20496
- const files = await readdir4(options.evidenceDir).catch(() => []);
21298
+ const files = await readdir5(options.evidenceDir).catch(() => []);
20497
21299
  const inferredStepId = options.stepId ?? files.map(inferStepIdFromEvidenceFile).find(Boolean);
20498
21300
  const contextFile = inferredStepId ? stepEvidenceFile(files, inferredStepId, "context") : void 0;
20499
21301
  const submitFile = inferredStepId ? stepEvidenceFile(files, inferredStepId, "submit") : void 0;
20500
21302
  if (inferredStepId && !contextFile && !submitFile) {
20501
21303
  throw new Error(`No step evidence files found for step ${inferredStepId} in ${options.evidenceDir}.`);
20502
21304
  }
20503
- const context2 = contextFile ? await readOptionalJson(path11.join(options.evidenceDir, contextFile)) : null;
20504
- const submit = submitFile ? await readOptionalJson(path11.join(options.evidenceDir, submitFile)) : null;
20505
- const requirements = isRecord8(context2?.requirements) ? context2.requirements : {};
20506
- const requiredInputs = Array.isArray(requirements.required_inputs) ? requirements.required_inputs.filter(isRecord8) : [];
20507
- const missingInputs = Array.isArray(requirements.missing_required_inputs) ? requirements.missing_required_inputs.filter(isRecord8) : [];
20508
- const requestData = isRecord8(submit?.request) && isRecord8(submit.request.data) ? submit.request.data : {};
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 : {};
20509
21311
  const recordedAction = stringValue3(requestData.action);
20510
21312
  const expectedChecks = buildExpectedChecks({
20511
21313
  context: context2,
@@ -20544,16 +21346,16 @@ function registerE2eCommands(program2) {
20544
21346
  variables: Object.keys(requestData).filter((key) => !["project_id", "action", "urgency"].includes(key)),
20545
21347
  payload_template: requestData,
20546
21348
  source_evidence: {
20547
- evidence_dir: path11.resolve(options.evidenceDir),
21349
+ evidence_dir: path12.resolve(options.evidenceDir),
20548
21350
  ...contextFile ? { context: contextFile } : {},
20549
21351
  ...submitFile ? { submit: submitFile } : {}
20550
21352
  }
20551
21353
  } : {
20552
- name: options.name ?? path11.basename(path11.resolve(options.evidenceDir)),
21354
+ name: options.name ?? path12.basename(path12.resolve(options.evidenceDir)),
20553
21355
  generated_at: (/* @__PURE__ */ new Date()).toISOString(),
20554
21356
  submit_mode: "browser_evidence_bootstrap",
20555
21357
  source_evidence: {
20556
- evidence_dir: path11.resolve(options.evidenceDir),
21358
+ evidence_dir: path12.resolve(options.evidenceDir),
20557
21359
  files: evidenceFiles
20558
21360
  },
20559
21361
  reuse_requirements: [
@@ -20566,8 +21368,8 @@ function registerE2eCommands(program2) {
20566
21368
  template.result = "diagnostic";
20567
21369
  template.diagnostic = true;
20568
21370
  }
20569
- const out = path11.resolve(options.out);
20570
- await mkdir10(path11.dirname(out), { recursive: true });
21371
+ const out = path12.resolve(options.out);
21372
+ await mkdir10(path12.dirname(out), { recursive: true });
20571
21373
  await writeFile10(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
20572
21374
  `, "utf8");
20573
21375
  await appendE2eExecutionEvidence(options, out, ["browser", "e2e_create_page", "e2e_step_run", "observe"]);
@@ -20625,11 +21427,11 @@ function registerE2eCommands(program2) {
20625
21427
  }
20626
21428
 
20627
21429
  // src/core/project-search.ts
20628
- function isRecord9(value) {
21430
+ function isRecord10(value) {
20629
21431
  return typeof value === "object" && value !== null && !Array.isArray(value);
20630
21432
  }
20631
21433
  function hasRawProjectSearchBody(value) {
20632
- return isRecord9(value) && Object.prototype.hasOwnProperty.call(value, "body");
21434
+ return isRecord10(value) && Object.prototype.hasOwnProperty.call(value, "body");
20633
21435
  }
20634
21436
  function assertProjectSearchBody(value) {
20635
21437
  if (hasRawProjectSearchBody(value)) {
@@ -20643,13 +21445,13 @@ function isProjectListEsQuery(value) {
20643
21445
  }
20644
21446
  function splitProjectListPagination(body, options) {
20645
21447
  const data = { ...body };
20646
- const normalizePositiveInteger = (value, path16) => {
21448
+ const normalizePositiveInteger = (value, path17) => {
20647
21449
  if (typeof value === "string" && value.trim() === "") {
20648
- throw new Error(`project search ${path16} \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u4E0D\u80FD\u662F\u7A7A\u5B57\u7B26\u4E32\u3002`);
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`);
20649
21451
  }
20650
21452
  const number = typeof value === "number" ? value : Number(value);
20651
21453
  if (!Number.isSafeInteger(number) || number < 1) {
20652
- throw new Error(`project search ${path16} \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u5F53\u524D\u503C\u4E3A ${String(value)}\u3002`);
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`);
20653
21455
  }
20654
21456
  return number;
20655
21457
  };
@@ -20780,7 +21582,7 @@ function registerFlowCommands(program2) {
20780
21582
  const client = createApiClient(profile);
20781
21583
  if (options.flowType) {
20782
21584
  const bindings = await getWorkspaceFlowBindings(client, profile, options);
20783
- const path16 = options.flowKey ? "/flow/options" : "/flow/flow_type";
21585
+ const path17 = options.flowKey ? "/flow/options" : "/flow/flow_type";
20784
21586
  const params = options.flowKey ? {
20785
21587
  detail: "1"
20786
21588
  } : {
@@ -20790,7 +21592,7 @@ function registerFlowCommands(program2) {
20790
21592
  const result2 = await apiRequest(
20791
21593
  client,
20792
21594
  "GET",
20793
- path16,
21595
+ path17,
20794
21596
  {
20795
21597
  params
20796
21598
  }
@@ -21026,7 +21828,7 @@ function registerInitCommand(program2, deps = {}) {
21026
21828
  }
21027
21829
 
21028
21830
  // src/commands/issue.ts
21029
- import { readFile as readFile13 } from "fs/promises";
21831
+ import { readFile as readFile14 } from "fs/promises";
21030
21832
 
21031
21833
  // src/core/issues.ts
21032
21834
  import axios8, { AxiosHeaders as AxiosHeaders3 } from "axios";
@@ -21202,7 +22004,7 @@ async function readDescription(options) {
21202
22004
  if (!options.descriptionFile) {
21203
22005
  return options.description;
21204
22006
  }
21205
- return readFile13(options.descriptionFile, "utf8");
22007
+ return readFile14(options.descriptionFile, "utf8");
21206
22008
  }
21207
22009
  function parseAssigneeIds(values) {
21208
22010
  return (values || []).flatMap(
@@ -21301,10 +22103,10 @@ async function parseOptionalJson(input, label) {
21301
22103
  }
21302
22104
  return parseJsonInput(input, label);
21303
22105
  }
21304
- async function memoryRequest(options, method, path16, capability, data, params) {
22106
+ async function memoryRequest(options, method, path17, capability, data, params) {
21305
22107
  const profile = resolveProfile(await loadConfig(), options.profile);
21306
22108
  const client = createApiClient(profile);
21307
- return apiRequest(client, method, path16, {
22109
+ return apiRequest(client, method, path17, {
21308
22110
  capability,
21309
22111
  data: redactAuditValue(data),
21310
22112
  params: params ? redactAuditValue(params) : void 0
@@ -21359,7 +22161,7 @@ function registerMemoryCommands(program2) {
21359
22161
  }
21360
22162
 
21361
22163
  // src/commands/matrix.ts
21362
- import { readFile as readFile14 } from "fs/promises";
22164
+ import { readFile as readFile15 } from "fs/promises";
21363
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;
21364
22166
  var UUID_PATH_PATTERN = /uuid'[^'"\s/]+/i;
21365
22167
  async function parseSeedRules(input) {
@@ -21367,7 +22169,7 @@ async function parseSeedRules(input) {
21367
22169
  if (source === "") {
21368
22170
  throw new Error("--rules file path is empty.");
21369
22171
  }
21370
- const raw = source ? await readFile14(source, "utf8") : input;
22172
+ const raw = source ? await readFile15(source, "utf8") : input;
21371
22173
  let parsed;
21372
22174
  try {
21373
22175
  parsed = JSON.parse(raw);
@@ -21386,15 +22188,15 @@ async function parseSeedRules(input) {
21386
22188
  });
21387
22189
  return rules;
21388
22190
  }
21389
- function collectUuidPaths(value, path16 = "$") {
22191
+ function collectUuidPaths(value, path17 = "$") {
21390
22192
  if (typeof value === "string") {
21391
- return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [path16] : [];
22193
+ return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [path17] : [];
21392
22194
  }
21393
22195
  if (Array.isArray(value)) {
21394
- return value.flatMap((item, index) => collectUuidPaths(item, `${path16}[${index}]`));
22196
+ return value.flatMap((item, index) => collectUuidPaths(item, `${path17}[${index}]`));
21395
22197
  }
21396
22198
  if (typeof value === "object" && value !== null) {
21397
- return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${path16}.${key}`));
22199
+ return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${path17}.${key}`));
21398
22200
  }
21399
22201
  return [];
21400
22202
  }
@@ -21417,20 +22219,20 @@ function isEmptyApproverValue(value) {
21417
22219
  function shellQuote7(value) {
21418
22220
  return `'${value.replace(/'/g, `'\\''`)}'`;
21419
22221
  }
21420
- var isRecord10 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
22222
+ var isRecord11 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
21421
22223
  function dataArray(value) {
21422
22224
  if (Array.isArray(value)) return value;
21423
- if (isRecord10(value) && Array.isArray(value.data)) return value.data;
21424
- if (isRecord10(value) && Array.isArray(value.list)) return value.list;
21425
- if (isRecord10(value) && Array.isArray(value.rows)) return value.rows;
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;
21426
22228
  return [];
21427
22229
  }
21428
22230
  function predictedNodes(value) {
21429
- if (!isRecord10(value)) return [];
21430
- return dataArray(value.predicted_nodes).filter(isRecord10);
22231
+ if (!isRecord11(value)) return [];
22232
+ return dataArray(value.predicted_nodes).filter(isRecord11);
21431
22233
  }
21432
22234
  function safePredictedOwners(value) {
21433
- return (Array.isArray(value) ? value : []).filter(isRecord10).map((owner) => ({
22235
+ return (Array.isArray(value) ? value : []).filter(isRecord11).map((owner) => ({
21434
22236
  id: owner.id ?? owner.user_id ?? owner.owner_id,
21435
22237
  name: owner.name ?? null
21436
22238
  }));
@@ -21445,7 +22247,7 @@ async function fetchAllMatrixRuleRecords(client, flowType) {
21445
22247
  data: { flow_type: flowType, page, page_size: pageSize },
21446
22248
  capability: "project.list"
21447
22249
  });
21448
- const rows2 = dataArray(result).filter(isRecord10);
22250
+ const rows2 = dataArray(result).filter(isRecord11);
21449
22251
  records.push(...rows2);
21450
22252
  const total = Number(result.count ?? result.total ?? records.length);
21451
22253
  if (rows2.length < pageSize || records.length >= total) break;
@@ -21464,23 +22266,23 @@ async function hydrateMatrixRuleRecords(client, records) {
21464
22266
  for (let index = 0; index < records.length; index += 10) {
21465
22267
  const chunk = records.slice(index, index + 10);
21466
22268
  hydrated.push(...await Promise.all(chunk.map(async (record) => {
21467
- if (isRecord10(record.metaForm) || Array.isArray(record.formList)) return record;
22269
+ if (isRecord11(record.metaForm) || Array.isArray(record.formList)) return record;
21468
22270
  const id = Number(record.id ?? record.project_id);
21469
22271
  return Number.isSafeInteger(id) && id > 0 ? apiRequest(client, "GET", `/project/${id}`) : record;
21470
22272
  })));
21471
22273
  }
21472
22274
  return hydrated;
21473
22275
  }
21474
- function collectMatrixOwnerPaths(value, path16 = "$") {
22276
+ function collectMatrixOwnerPaths(value, path17 = "$") {
21475
22277
  if (Array.isArray(value)) {
21476
- return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${path16}[${index}]`));
22278
+ return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${path17}[${index}]`));
21477
22279
  }
21478
- if (!isRecord10(value)) {
22280
+ if (!isRecord11(value)) {
21479
22281
  return [];
21480
22282
  }
21481
22283
  const matches = [];
21482
22284
  Object.entries(value).forEach(([key, child]) => {
21483
- const childPath = `${path16}.${key}`;
22285
+ const childPath = `${path17}.${key}`;
21484
22286
  if (key.includes("matrix_owner") || typeof child === "string" && child.includes("matrix_owner")) {
21485
22287
  matches.push({ path: childPath, value: child });
21486
22288
  }
@@ -21489,25 +22291,25 @@ function collectMatrixOwnerPaths(value, path16 = "$") {
21489
22291
  return matches;
21490
22292
  }
21491
22293
  function projectFormKeys(project) {
21492
- const metaForm = isRecord10(project.metaForm) ? project.metaForm : {};
22294
+ const metaForm = isRecord11(project.metaForm) ? project.metaForm : {};
21493
22295
  const values = dataArray(metaForm.value ?? project.formList);
21494
- return values.filter(isRecord10).map((item) => String(item.key ?? item.field_key ?? "")).filter(Boolean);
22296
+ return values.filter(isRecord11).map((item) => String(item.key ?? item.field_key ?? "")).filter(Boolean);
21495
22297
  }
21496
22298
  function findFlowNode2(flow, nodeId) {
21497
- const data = isRecord10(flow.data) ? flow.data : {};
21498
- return dataArray(data.nodes).filter(isRecord10).find((node) => String(node.id ?? node.key ?? node.flow_step_id ?? "") === nodeId);
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);
21499
22301
  }
21500
22302
  function flowCategory(flow) {
21501
- const data = isRecord10(flow.data) ? flow.data : {};
21502
- const meta = isRecord10(data.meta) ? data.meta : {};
22303
+ const data = isRecord11(flow.data) ? flow.data : {};
22304
+ const meta = isRecord11(data.meta) ? data.meta : {};
21503
22305
  return String(flow.category ?? data.category ?? meta.category ?? "");
21504
22306
  }
21505
22307
  function hasIdentifier(value) {
21506
22308
  return value !== void 0 && value !== null && String(value).trim() !== "" && String(value) !== "0";
21507
22309
  }
21508
22310
  function matrixAppSummary(flow, listTemplates = [], filterTemplates = [], datasets = [], workspaceBound = false) {
21509
- const data = isRecord10(flow.data) ? flow.data : {};
21510
- const meta = isRecord10(data.meta) ? data.meta : {};
22311
+ const data = isRecord11(flow.data) ? flow.data : {};
22312
+ const meta = isRecord11(data.meta) ? data.meta : {};
21511
22313
  const refs = {
21512
22314
  form_template_id: meta.form_template ?? flow.form_template_id,
21513
22315
  list_template_ids: listTemplates.map((item) => item.id ?? item.flow_page_template_id).filter(hasIdentifier),
@@ -21548,7 +22350,7 @@ function matrixAppSummary(flow, listTemplates = [], filterTemplates = [], datase
21548
22350
  suggestion: "\u4ECE\u6700\u65B0 workspace-flow \u56DE\u8BFB merge \u540E\u901A\u8FC7 typed CLI \u63D0\u4EA4\u7ED1\u5B9A\u3002"
21549
22351
  });
21550
22352
  }
21551
- const nodes = dataArray(data.nodes).filter(isRecord10);
22353
+ const nodes = dataArray(data.nodes).filter(isRecord11);
21552
22354
  const activeNodes = nodes.filter((node) => {
21553
22355
  const name = String(node.name ?? "").trim();
21554
22356
  return name === "\u751F\u6548\u4E2D" || name === "\u8FDB\u884C\u4E2D" || Number(node.status) === 1;
@@ -21597,10 +22399,10 @@ async function inspectMatrixAppDefinition(profile, flowType, workspace, includeR
21597
22399
  apiRequest(client, "GET", "/flow_page_template", { params: { type: 3, flow_type: flowType, flow_key: "", skip_i18n: true }, capability: "config.filter_template.export" }),
21598
22400
  apiRequest(client, "GET", "/workspace/by_key", { params: { key: workspace }, capability: "config.workspace_flow.export" })
21599
22401
  ]);
21600
- const flowData = isRecord10(flow.data) ? flow.data : {};
21601
- const meta = isRecord10(flowData.meta) ? flowData.meta : {};
21602
- const listRows = dataArray(listResult).filter(isRecord10);
21603
- const filterRows = dataArray(filterResult).filter(isRecord10);
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);
21604
22406
  const listIds = uniqueIds([meta.table_list_template, ...listRows.map((item) => item.id ?? item.flow_page_template_id)]);
21605
22407
  const filterIds = uniqueIds([meta.table_filter_template, ...filterRows.map((item) => item.id ?? item.flow_page_template_id)]);
21606
22408
  const formId = String(meta.form_template ?? flow.form_template_id ?? "");
@@ -21618,7 +22420,7 @@ async function inspectMatrixAppDefinition(profile, flowType, workspace, includeR
21618
22420
  if (strict) {
21619
22421
  assertNoMatrixErrors(summary.errors);
21620
22422
  }
21621
- const formRecord = isRecord10(form) ? form : {};
22423
+ const formRecord = isRecord11(form) ? form : {};
21622
22424
  const exactReadback = {
21623
22425
  flow: { id: flowType, readback_hash: matrixHash(flow), ...includeRaw ? { readback: flow } : {} },
21624
22426
  form_template: { id: formId, draft_id: formRecord.origin_template_id ?? formRecord.id ?? null, readback_hash: matrixHash(formRecord), ...includeRaw ? { readback: formRecord } : {} },
@@ -21630,8 +22432,8 @@ async function inspectMatrixAppDefinition(profile, flowType, workspace, includeR
21630
22432
  return { ok: summary.errors.length === 0, domain: "approval-matrix", action: "app.inspect", flow_type: flowType, workspace, ...summary, exact_readback: exactReadback };
21631
22433
  }
21632
22434
  function workspaceHasFlow(value, flowType) {
21633
- if (!isRecord10(value)) return false;
21634
- const rows2 = Array.isArray(value.workspace_flow) ? value.workspace_flow.filter(isRecord10) : isRecord10(value.data) && Array.isArray(value.data.workspace_flow) ? value.data.workspace_flow.filter(isRecord10) : [];
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) : [];
21635
22437
  return rows2.some((item) => String(item.flow_type ?? "") === flowType && Number(item.is_del ?? 0) === 0);
21636
22438
  }
21637
22439
  function matrixConsumerSummary(node, expectedMatrixFlowType) {
@@ -21647,8 +22449,8 @@ function matrixConsumerSummary(node, expectedMatrixFlowType) {
21647
22449
  });
21648
22450
  return { errors, owner: null, cc: null };
21649
22451
  }
21650
- const owner = isRecord10(node.matrix_owner) ? node.matrix_owner : null;
21651
- const cc = isRecord10(node.cc_matrix) ? node.cc_matrix : null;
22452
+ const owner = isRecord11(node.matrix_owner) ? node.matrix_owner : null;
22453
+ const cc = isRecord11(node.cc_matrix) ? node.cc_matrix : null;
21652
22454
  const normalizeFlowRef = (value) => String(value ?? "").trim().replace(/:$/, "");
21653
22455
  if (node.auto_range_type === "matrix") {
21654
22456
  if (!owner || !String(owner.flow ?? owner.matrix_flow_type ?? "").trim()) {
@@ -21679,16 +22481,16 @@ function matrixConsumerSummary(node, expectedMatrixFlowType) {
21679
22481
  return { errors, owner, cc };
21680
22482
  }
21681
22483
  function projectField(project, key) {
21682
- const metaForm = isRecord10(project.metaForm) ? project.metaForm : {};
21683
- const values = dataArray(metaForm.value ?? project.formList).filter(isRecord10);
22484
+ const metaForm = isRecord11(project.metaForm) ? project.metaForm : {};
22485
+ const values = dataArray(metaForm.value ?? project.formList).filter(isRecord11);
21684
22486
  const row = values.find((item) => String(item.key ?? item.field_key ?? "") === key);
21685
22487
  if (!row) return void 0;
21686
22488
  const value = row.value;
21687
- return isRecord10(value) && Object.prototype.hasOwnProperty.call(value, "value") ? value.value : value;
22489
+ return isRecord11(value) && Object.prototype.hasOwnProperty.call(value, "value") ? value.value : value;
21688
22490
  }
21689
22491
  function collectUserIds(value) {
21690
22492
  if (Array.isArray(value)) return [...new Set(value.flatMap(collectUserIds))];
21691
- if (isRecord10(value)) {
22493
+ if (isRecord11(value)) {
21692
22494
  const direct2 = Number(value.id ?? value.user_id ?? value.value);
21693
22495
  if (Number.isSafeInteger(direct2) && direct2 > 0) return [direct2];
21694
22496
  return [...new Set(Object.values(value).flatMap(collectUserIds))];
@@ -21709,7 +22511,7 @@ async function readMatrixApprovers(client, ids) {
21709
22511
  },
21710
22512
  capability: "user.readback"
21711
22513
  });
21712
- users.push(...dataArray(result).filter(isRecord10));
22514
+ users.push(...dataArray(result).filter(isRecord11));
21713
22515
  }
21714
22516
  return users;
21715
22517
  }
@@ -21793,7 +22595,7 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
21793
22595
  const matrixOwnerConfig = node ? collectMatrixOwnerPaths(node) : [];
21794
22596
  const predictedNode = predictedNodes(prediction).find((item) => String(item.node_id ?? item.id ?? "") === options.node);
21795
22597
  const owners = safePredictedOwners(predictedNode?.owners);
21796
- const ownerResolution = predictedNode && isRecord10(predictedNode.owner_resolution) ? predictedNode.owner_resolution : { status: predictedNode ? "resolved" : "missing" };
22598
+ const ownerResolution = predictedNode && isRecord11(predictedNode.owner_resolution) ? predictedNode.owner_resolution : { status: predictedNode ? "resolved" : "missing" };
21797
22599
  const projectFlowType = String(project.flow_type ?? "");
21798
22600
  const flowMatchesProject = !projectFlowType || projectFlowType === options.flowType;
21799
22601
  printResult(options.format, {
@@ -21884,14 +22686,14 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
21884
22686
  if (!workspace) throw new Error("matrix.app.workspace_required: \u8BF7\u63D0\u4F9B --workspace \u4EE5\u5220\u9664\u77E9\u9635\u5E94\u7528\u3002");
21885
22687
  const definition = await inspectMatrixAppDefinition(profile, options.flowType, workspace, true, false);
21886
22688
  const exact = definition.exact_readback;
21887
- const listItems = Array.isArray(exact.list_templates) ? exact.list_templates.filter(isRecord10) : [];
21888
- const filterItems = Array.isArray(exact.filter_templates) ? exact.filter_templates.filter(isRecord10) : [];
21889
- const datasetItems = Array.isArray(exact.datasets) ? exact.datasets.filter(isRecord10) : [];
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) : [];
21890
22692
  const datasetFieldIds = uniqueIds(datasetItems.flatMap((item) => {
21891
- const readback = isRecord10(item.readback) ? item.readback : {};
21892
- return Array.isArray(readback.dataSetFields) ? readback.dataSetFields.filter(isRecord10).map((field) => field.id) : [];
22693
+ const readback = isRecord11(item.readback) ? item.readback : {};
22694
+ return Array.isArray(readback.dataSetFields) ? readback.dataSetFields.filter(isRecord11).map((field) => field.id) : [];
21893
22695
  }));
21894
- const formItem = isRecord10(exact.form_template) ? exact.form_template : {};
22696
+ const formItem = isRecord11(exact.form_template) ? exact.form_template : {};
21895
22697
  const formDraftId = String(formItem.draft_id ?? formItem.id ?? "");
21896
22698
  const expectedConfirm = `delete matrix app ${options.flowType} from ${workspace}`;
21897
22699
  const plan = [
@@ -21953,8 +22755,8 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
21953
22755
  apiRequest(client, "GET", "/flow_page_template", { params: { type: 3, flow_type: options.matrixFlowType, flow_key: "", skip_i18n: true }, capability: "config.filter_template.export" }),
21954
22756
  apiRequest(client, "GET", "/workspace/by_key", { params: { key: workspace }, capability: "config.workspace_flow.export" })
21955
22757
  ]);
21956
- const listRows = dataArray(listResult).filter(isRecord10);
21957
- const filterRows = dataArray(filterResult).filter(isRecord10);
22758
+ const listRows = dataArray(listResult).filter(isRecord11);
22759
+ const filterRows = dataArray(filterResult).filter(isRecord11);
21958
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" })));
21959
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" })));
21960
22762
  const datasetIds = uniqueIds([...listTemplates.map((item) => item.data_set_id), ...filterTemplates.map((item) => item.data_set_id)]);
@@ -21988,7 +22790,7 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
21988
22790
  }
21989
22791
  const predictedNode = predictedNodes(prediction).find((item) => String(item.node_id ?? item.id ?? "") === options.node);
21990
22792
  const predictedOwners = safePredictedOwners(predictedNode?.owners);
21991
- const ownerResolution = predictedNode && isRecord10(predictedNode.owner_resolution) ? predictedNode.owner_resolution : { status: predictedNode ? "resolved" : "missing" };
22793
+ const ownerResolution = predictedNode && isRecord11(predictedNode.owner_resolution) ? predictedNode.owner_resolution : { status: predictedNode ? "resolved" : "missing" };
21992
22794
  if (ownerResolution.status === "error") {
21993
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" });
21994
22796
  } else if (!predictedNode || predictedOwners.length === 0) {
@@ -22012,13 +22814,13 @@ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` $
22012
22814
  }
22013
22815
 
22014
22816
  // src/commands/organization.ts
22015
- function isRecord11(value) {
22817
+ function isRecord12(value) {
22016
22818
  return typeof value === "object" && value !== null && !Array.isArray(value);
22017
22819
  }
22018
22820
  function rows(value) {
22019
- if (Array.isArray(value)) return value.filter(isRecord11);
22020
- if (!isRecord11(value)) return [];
22021
- if (Array.isArray(value.data)) return value.data.filter(isRecord11);
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);
22022
22824
  return value.id ? [value] : [];
22023
22825
  }
22024
22826
  function positiveId(value, errorCode) {
@@ -22042,7 +22844,7 @@ function safeDepartment(group) {
22042
22844
  function departmentRows(value) {
22043
22845
  const result = [];
22044
22846
  const visit = (item) => {
22045
- if (!isRecord11(item)) return;
22847
+ if (!isRecord12(item)) return;
22046
22848
  if (item.id !== void 0) result.push(safeDepartment(item));
22047
22849
  if (Array.isArray(item.children)) item.children.forEach(visit);
22048
22850
  };
@@ -22051,7 +22853,7 @@ function departmentRows(value) {
22051
22853
  }
22052
22854
  function relationDepartments(value) {
22053
22855
  if (!Array.isArray(value)) return [];
22054
- return value.filter(isRecord11).map(safeDepartment);
22856
+ return value.filter(isRecord12).map(safeDepartment);
22055
22857
  }
22056
22858
  function safeUser(user) {
22057
22859
  const status = user.status === void 0 ? null : Number(user.status);
@@ -22098,8 +22900,8 @@ async function readDepartments(client, ids) {
22098
22900
  function pathIds(departments) {
22099
22901
  const ids = /* @__PURE__ */ new Set();
22100
22902
  for (const department of departments) {
22101
- const path16 = String(department.path ?? "");
22102
- for (const part of path16.split(/[|,]/)) {
22903
+ const path17 = String(department.path ?? "");
22904
+ for (const part of path17.split(/[|,]/)) {
22103
22905
  const id = Number(part);
22104
22906
  if (Number.isSafeInteger(id) && id > 0) ids.add(id);
22105
22907
  }
@@ -22109,7 +22911,7 @@ function pathIds(departments) {
22109
22911
  function mainDepartmentId(raw) {
22110
22912
  for (const key of ["main_department_id", "main_group_id", "main_department"]) {
22111
22913
  const value = raw[key];
22112
- if (isRecord11(value)) {
22914
+ if (isRecord12(value)) {
22113
22915
  const id2 = Number(value.id);
22114
22916
  if (Number.isSafeInteger(id2) && id2 > 0) return id2;
22115
22917
  }
@@ -22121,7 +22923,7 @@ function mainDepartmentId(raw) {
22121
22923
  function branchId(raw) {
22122
22924
  for (const key of ["branch_id", "branch_group_id", "branch"]) {
22123
22925
  const value = raw[key];
22124
- if (isRecord11(value)) {
22926
+ if (isRecord12(value)) {
22125
22927
  const id2 = Number(value.id);
22126
22928
  if (Number.isSafeInteger(id2) && id2 > 0) return id2;
22127
22929
  }
@@ -22639,15 +23441,15 @@ async function promptProjectCreateForm(input) {
22639
23441
  }
22640
23442
 
22641
23443
  // src/core/project-form.ts
22642
- function isRecord12(value) {
23444
+ function isRecord13(value) {
22643
23445
  return typeof value === "object" && value !== null && !Array.isArray(value);
22644
23446
  }
22645
23447
  function clone(value) {
22646
23448
  return JSON.parse(JSON.stringify(value));
22647
23449
  }
22648
23450
  function getFlowFormTemplateId(flowDetail) {
22649
- const data = isRecord12(flowDetail?.data) ? flowDetail.data : void 0;
22650
- const meta = isRecord12(data?.meta) ? data.meta : void 0;
23451
+ const data = isRecord13(flowDetail?.data) ? flowDetail.data : void 0;
23452
+ const meta = isRecord13(data?.meta) ? data.meta : void 0;
22651
23453
  const templateId = meta?.form_template;
22652
23454
  if (typeof templateId === "number" && Number.isFinite(templateId)) {
22653
23455
  return templateId;
@@ -22672,7 +23474,7 @@ function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
22672
23474
  if (Array.isArray(value)) {
22673
23475
  return value.some((item) => hasAutoInitLambda(item, seen));
22674
23476
  }
22675
- if (!isRecord12(value)) {
23477
+ if (!isRecord13(value)) {
22676
23478
  return false;
22677
23479
  }
22678
23480
  if (seen.has(value)) {
@@ -22687,14 +23489,14 @@ function hasAutoInitLambda(value, seen = /* @__PURE__ */ new WeakSet()) {
22687
23489
  function setControlValue(control, value) {
22688
23490
  const next = clone(control);
22689
23491
  next.value = {
22690
- ...isRecord12(next.value) ? next.value : {},
23492
+ ...isRecord13(next.value) ? next.value : {},
22691
23493
  type: next.value?.type ?? next.field_type,
22692
23494
  value
22693
23495
  };
22694
23496
  return next;
22695
23497
  }
22696
23498
  function applyRowValues(rowTemplate, rowValue) {
22697
- const source = isRecord12(rowValue) ? rowValue : {};
23499
+ const source = isRecord13(rowValue) ? rowValue : {};
22698
23500
  return rowTemplate.map((control) => {
22699
23501
  if (control.key && Object.prototype.hasOwnProperty.call(source, control.key)) {
22700
23502
  return setControlValue(control, source[control.key]);
@@ -22980,17 +23782,17 @@ function assertStepProjectFormWritable(fields, form, prefix = "") {
22980
23782
  for (const [key, value] of Object.entries(form)) {
22981
23783
  const field = fieldsByKey.get(key);
22982
23784
  if (!field) continue;
22983
- const path16 = `${prefix}${key}`;
23785
+ const path17 = `${prefix}${key}`;
22984
23786
  if (field.hidden) {
22985
- throw new Error(`Step project form handoff cannot write hidden field ${path16}.`);
23787
+ throw new Error(`Step project form handoff cannot write hidden field ${path17}.`);
22986
23788
  }
22987
23789
  if (isUnsupportedStepPrefillField(field)) {
22988
- throw new Error(`Step project form handoff cannot write system or manual field ${path16} (${field.type || "unknown"}).`);
23790
+ throw new Error(`Step project form handoff cannot write system or manual field ${path17} (${field.type || "unknown"}).`);
22989
23791
  }
22990
23792
  if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
22991
23793
  value.forEach((row, index) => {
22992
23794
  if (isRecordValue(row)) {
22993
- assertStepProjectFormWritable(field.children ?? [], row, `${path16}[${index}].`);
23795
+ assertStepProjectFormWritable(field.children ?? [], row, `${path17}[${index}].`);
22994
23796
  }
22995
23797
  });
22996
23798
  }
@@ -23252,8 +24054,8 @@ function fieldsForValidation(flowDetail, projectFormTemplate) {
23252
24054
  }));
23253
24055
  }
23254
24056
  function metaUsesTemplateProjectName(flowDetail) {
23255
- const data = isRecord13(flowDetail?.data) ? flowDetail.data : void 0;
23256
- const meta = isRecord13(data?.meta) ? data.meta : void 0;
24057
+ const data = isRecord14(flowDetail?.data) ? flowDetail.data : void 0;
24058
+ const meta = isRecord14(data?.meta) ? data.meta : void 0;
23257
24059
  const hideFields = Array.isArray(meta?.hide_fields) ? meta.hide_fields.map(String) : [];
23258
24060
  return meta?.use_template_project_name === true || hideFields.includes("project.name");
23259
24061
  }
@@ -23347,9 +24149,9 @@ function contextField(field, reason, options = {}) {
23347
24149
  function collectPrefillContextForFields(fields, form, result, options = {}) {
23348
24150
  for (const field of fields) {
23349
24151
  const value = form[field.key];
23350
- const path16 = options.prefix ? `${options.prefix}.${field.key}` : field.key;
24152
+ const path17 = options.prefix ? `${options.prefix}.${field.key}` : field.key;
23351
24153
  const fieldOptions = {
23352
- path: path16,
24154
+ path: path17,
23353
24155
  rootKey: options.rootKey ?? field.key,
23354
24156
  parentKey: options.parentKey
23355
24157
  };
@@ -23362,7 +24164,7 @@ function collectPrefillContextForFields(fields, form, result, options = {}) {
23362
24164
  result.filled_fields.push(contextField(field, "prefilled", fieldOptions));
23363
24165
  if (isSubFormField(field) && Array.isArray(value) && field.children?.length) {
23364
24166
  value.forEach((row, index) => {
23365
- if (isRecord13(row)) {
24167
+ if (isRecord14(row)) {
23366
24168
  collectPrefillContextForFields(field.children ?? [], row, result, {
23367
24169
  prefix: `${field.key}[${index}]`,
23368
24170
  rootKey: field.key,
@@ -23389,7 +24191,7 @@ function buildPrefillContext(fields, form) {
23389
24191
  }
23390
24192
  };
23391
24193
  }
23392
- function isRecord13(value) {
24194
+ function isRecord14(value) {
23393
24195
  return typeof value === "object" && value !== null && !Array.isArray(value);
23394
24196
  }
23395
24197
  function isEndedStep(step) {
@@ -23412,7 +24214,7 @@ function stepIdOf(step) {
23412
24214
  function pickStepFormPayload(step) {
23413
24215
  const formList = Array.isArray(step.formList) ? step.formList : [];
23414
24216
  const forms = Array.isArray(step.forms) ? step.forms : [];
23415
- const metaForm = isRecord13(step.metaForm) ? step.metaForm : void 0;
24217
+ const metaForm = isRecord14(step.metaForm) ? step.metaForm : void 0;
23416
24218
  return {
23417
24219
  step_id: step.id,
23418
24220
  flow_step_id: step.flow_step_id,
@@ -23429,7 +24231,7 @@ function pickStepFormPayload(step) {
23429
24231
  }
23430
24232
  async function buildApprovalContext(client, projectId, options) {
23431
24233
  const projectDetail = await apiRequest(client, "GET", `/project/${projectId}`);
23432
- const steps = Array.isArray(projectDetail.steps) ? projectDetail.steps.filter(isRecord13) : [];
24234
+ const steps = Array.isArray(projectDetail.steps) ? projectDetail.steps.filter(isRecord14) : [];
23433
24235
  const targetStepIds = /* @__PURE__ */ new Set();
23434
24236
  for (const step of steps) {
23435
24237
  const id = stepIdOf(step);
@@ -23455,7 +24257,7 @@ async function buildApprovalContext(client, projectId, options) {
23455
24257
  }
23456
24258
  return {
23457
24259
  project: projectDetail,
23458
- project_form: isRecord13(projectDetail.metaForm) ? projectDetail.metaForm : null,
24260
+ project_form: isRecord14(projectDetail.metaForm) ? projectDetail.metaForm : null,
23459
24261
  inspected_step_count: stepForms.length,
23460
24262
  step_forms: stepForms,
23461
24263
  failed_steps: failedSteps
@@ -23793,8 +24595,8 @@ import { spawn as spawn2 } from "child_process";
23793
24595
  import { fileURLToPath as fileURLToPath3 } from "url";
23794
24596
 
23795
24597
  // src/core/recipes.ts
23796
- import { access, mkdir as mkdir11, readdir as readdir5, readFile as readFile15, writeFile as writeFile11 } from "fs/promises";
23797
- import path12 from "path";
24598
+ import { access, mkdir as mkdir11, readdir as readdir6, readFile as readFile16, writeFile as writeFile11 } from "fs/promises";
24599
+ import path13 from "path";
23798
24600
  var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
23799
24601
  var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
23800
24602
  function assertSafeName(kind, value) {
@@ -23818,14 +24620,14 @@ function resolveRecipeLocation(options) {
23818
24620
  workspace,
23819
24621
  workspaceDirName,
23820
24622
  recipeName: options.recipeName,
23821
- recipeDir: path12.join(profileDir, "recipes", workspaceDirName, options.recipeName)
24623
+ recipeDir: path13.join(profileDir, "recipes", workspaceDirName, options.recipeName)
23822
24624
  };
23823
24625
  }
23824
24626
  function getRecipesDir(options) {
23825
24627
  const workspaceDirName = normalizeWorkspaceForPath(options.workspace || DEFAULT_WORKSPACE);
23826
- return path12.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
24628
+ return path13.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
23827
24629
  }
23828
- function isRecord14(value) {
24630
+ function isRecord15(value) {
23829
24631
  return typeof value === "object" && value !== null && !Array.isArray(value);
23830
24632
  }
23831
24633
  function asString(value, fieldName) {
@@ -23835,7 +24637,7 @@ function asString(value, fieldName) {
23835
24637
  return value;
23836
24638
  }
23837
24639
  function parseRecipeDefinition(input) {
23838
- if (!isRecord14(input)) {
24640
+ if (!isRecord15(input)) {
23839
24641
  throw new Error("recipe.json must be a JSON object.");
23840
24642
  }
23841
24643
  if (input.version !== 1) {
@@ -23843,7 +24645,7 @@ function parseRecipeDefinition(input) {
23843
24645
  }
23844
24646
  const name = asString(input.name, "recipe.name");
23845
24647
  assertSafeName("Recipe name", name);
23846
- if (!isRecord14(input.command)) {
24648
+ if (!isRecord15(input.command)) {
23847
24649
  throw new Error("recipe.command must be an object.");
23848
24650
  }
23849
24651
  const argv = input.command.argv;
@@ -23851,7 +24653,7 @@ function parseRecipeDefinition(input) {
23851
24653
  throw new Error("recipe.command.argv must be a non-empty string array.");
23852
24654
  }
23853
24655
  const variables = Array.isArray(input.variables) ? input.variables.map((item, index) => {
23854
- if (!isRecord14(item)) {
24656
+ if (!isRecord15(item)) {
23855
24657
  throw new Error(`recipe.variables[${index}] must be an object.`);
23856
24658
  }
23857
24659
  const variableName = asString(item.name, `recipe.variables[${index}].name`);
@@ -23875,13 +24677,13 @@ function parseRecipeDefinition(input) {
23875
24677
  };
23876
24678
  }
23877
24679
  async function loadRecipe(recipeDir) {
23878
- const raw = await readFile15(path12.join(recipeDir, "recipe.json"), "utf8");
24680
+ const raw = await readFile16(path13.join(recipeDir, "recipe.json"), "utf8");
23879
24681
  return parseRecipeDefinition(JSON.parse(raw));
23880
24682
  }
23881
24683
  async function listRecipes(recipesDir) {
23882
24684
  let entries;
23883
24685
  try {
23884
- entries = await readdir5(recipesDir);
24686
+ entries = await readdir6(recipesDir);
23885
24687
  } catch (error) {
23886
24688
  if (error.code === "ENOENT") {
23887
24689
  return [];
@@ -23893,7 +24695,7 @@ async function listRecipes(recipesDir) {
23893
24695
  if (!RECIPE_NAME_PATTERN.test(entry)) {
23894
24696
  continue;
23895
24697
  }
23896
- const recipeDir = path12.join(recipesDir, entry);
24698
+ const recipeDir = path13.join(recipesDir, entry);
23897
24699
  try {
23898
24700
  const recipe = await loadRecipe(recipeDir);
23899
24701
  summaries.push({
@@ -23927,7 +24729,7 @@ function parseVarsJson(input) {
23927
24729
  return {};
23928
24730
  }
23929
24731
  const parsed = JSON.parse(input);
23930
- if (!isRecord14(parsed)) {
24732
+ if (!isRecord15(parsed)) {
23931
24733
  throw new Error("--vars must be a JSON object.");
23932
24734
  }
23933
24735
  const variables = {};
@@ -23959,12 +24761,12 @@ function renderTemplate(template, variables) {
23959
24761
  }
23960
24762
  function resolveRecipeFile(recipeDir, token) {
23961
24763
  const relative = token.slice(1);
23962
- if (!relative || relative.includes("..") || path12.isAbsolute(relative)) {
24764
+ if (!relative || relative.includes("..") || path13.isAbsolute(relative)) {
23963
24765
  throw new Error(`Unsafe recipe file reference: ${token}`);
23964
24766
  }
23965
- const resolved = path12.resolve(recipeDir, relative);
23966
- const root = path12.resolve(recipeDir);
23967
- if (resolved !== root && !resolved.startsWith(`${root}${path12.sep}`)) {
24767
+ const resolved = path13.resolve(recipeDir, relative);
24768
+ const root = path13.resolve(recipeDir);
24769
+ if (resolved !== root && !resolved.startsWith(`${root}${path13.sep}`)) {
23968
24770
  throw new Error(`Recipe file reference escapes recipe directory: ${token}`);
23969
24771
  }
23970
24772
  return resolved;
@@ -23974,7 +24776,7 @@ async function renderArgv(options) {
23974
24776
  const rendered = [];
23975
24777
  for (const token of options.recipe.command.argv) {
23976
24778
  if (token.startsWith("@")) {
23977
- const raw = await readFile15(resolveRecipeFile(options.recipeDir, token), "utf8");
24779
+ const raw = await readFile16(resolveRecipeFile(options.recipeDir, token), "utf8");
23978
24780
  rendered.push(renderTemplate(raw, options.variables));
23979
24781
  } else {
23980
24782
  rendered.push(renderTemplate(token, options.variables));
@@ -24017,16 +24819,16 @@ async function writeRecipeScaffold(options) {
24017
24819
  mutating: true
24018
24820
  }
24019
24821
  };
24020
- await writeFile11(path12.join(options.location.recipeDir, "recipe.json"), `${JSON.stringify(recipe, null, 2)}
24822
+ await writeFile11(path13.join(options.location.recipeDir, "recipe.json"), `${JSON.stringify(recipe, null, 2)}
24021
24823
  `, "utf8");
24022
24824
  await writeFile11(
24023
- path12.join(options.location.recipeDir, "payload.json"),
24825
+ path13.join(options.location.recipeDir, "payload.json"),
24024
24826
  `${JSON.stringify({ form: {} }, null, 2)}
24025
24827
  `,
24026
24828
  "utf8"
24027
24829
  );
24028
24830
  await writeFile11(
24029
- path12.join(options.location.recipeDir, "README.md"),
24831
+ path13.join(options.location.recipeDir, "README.md"),
24030
24832
  [`# ${title}`, "", "Describe the BPMAX flow, field mapping, prerequisites, and verification steps for this recipe.", ""].join("\n"),
24031
24833
  "utf8"
24032
24834
  );
@@ -24460,8 +25262,8 @@ function registerSetupCommand(program2, deps = {}) {
24460
25262
  }
24461
25263
 
24462
25264
  // src/core/taskbook.ts
24463
- import { mkdir as mkdir12, readFile as readFile16, writeFile as writeFile12 } from "fs/promises";
24464
- import path13 from "path";
25265
+ import { mkdir as mkdir12, readFile as readFile17, writeFile as writeFile12 } from "fs/promises";
25266
+ import path14 from "path";
24465
25267
  var TaskbookError = class extends Error {
24466
25268
  };
24467
25269
  var REQUIRED_TASKBOOK_TERMS = [
@@ -24677,19 +25479,19 @@ function hasDomainWriteEvidence(domain, evidenceText, patterns) {
24677
25479
  function uuidValues(text5) {
24678
25480
  return [...new Set([...text5.matchAll(UUID_PATTERN)].map((match) => match[0]))];
24679
25481
  }
24680
- function addUuidIssues(text5, issues, path16) {
25482
+ function addUuidIssues(text5, issues, path17) {
24681
25483
  for (const value of uuidValues(text5)) {
24682
25484
  addTaskbookIssue(
24683
25485
  issues,
24684
25486
  "uuid_not_allowed",
24685
25487
  "taskbook.config.no_uuid",
24686
25488
  `BPMAX \u914D\u7F6E\u4EFB\u52A1\u4E0D\u80FD\u4F7F\u7528 UUID\uFF1A${value}\u3002`,
24687
- { path: path16, 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" }
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" }
24688
25490
  );
24689
25491
  }
24690
25492
  }
24691
25493
  async function readTaskbookText(file) {
24692
- const raw = await readFile16(file, "utf8");
25494
+ const raw = await readFile17(file, "utf8");
24693
25495
  try {
24694
25496
  const parsed = JSON.parse(raw);
24695
25497
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
@@ -24716,7 +25518,7 @@ function findNavigationStrategy(text5) {
24716
25518
  const matches = [...text5.matchAll(/导航入口策略\s*[::]\s*(nav-config:(?:included|skipped:[^\s|,。]+|deferred:[^\s|,。]+))/gi)];
24717
25519
  return matches.at(-1)?.[1] || null;
24718
25520
  }
24719
- function validateNavigationStrategy(text5, issues, path16, subject) {
25521
+ function validateNavigationStrategy(text5, issues, path17, subject) {
24720
25522
  const strategy = findNavigationStrategy(text5);
24721
25523
  if (!strategy) {
24722
25524
  addTaskbookIssue(
@@ -24724,7 +25526,7 @@ function validateNavigationStrategy(text5, issues, path16, subject) {
24724
25526
  "missing_navigation_strategy",
24725
25527
  "taskbook.nav.strategy",
24726
25528
  `${subject}\u7F3A\u5C11\u660E\u786E\u7684\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u3002`,
24727
- { path: path16, suggestion: "\u5199\u660E \u5BFC\u822A\u5165\u53E3\u7B56\u7565\uFF1Anav-config:included\u3001nav-config:skipped:<reason> \u6216 nav-config:deferred:<reason>\u3002" }
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" }
24728
25530
  );
24729
25531
  return null;
24730
25532
  }
@@ -24734,7 +25536,7 @@ function validateNavigationStrategy(text5, issues, path16, subject) {
24734
25536
  "empty_navigation_strategy_reason",
24735
25537
  "taskbook.nav.strategy_reason",
24736
25538
  `${subject}\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u8DF3\u8FC7\u6216\u5EF6\u540E\u65F6\u5FC5\u987B\u5199\u660E\u539F\u56E0\u3002`,
24737
- { path: path16, suggestion: "\u4F7F\u7528 nav-config:skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 nav-config:deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
25539
+ { path: path17, suggestion: "\u4F7F\u7528 nav-config:skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 nav-config:deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
24738
25540
  );
24739
25541
  }
24740
25542
  if (/(待完成范围确认后回填|待确认|TODO|TBD|占位)/i.test(strategy)) {
@@ -24743,7 +25545,7 @@ function validateNavigationStrategy(text5, issues, path16, subject) {
24743
25545
  "placeholder_navigation_strategy",
24744
25546
  "taskbook.nav.strategy_placeholder",
24745
25547
  `${subject}\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u4ECD\u662F\u5360\u4F4D\u5185\u5BB9\u3002`,
24746
- { path: path16, suggestion: "\u66FF\u6362\u4E3A included\u3001skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
25548
+ { path: path17, suggestion: "\u66FF\u6362\u4E3A included\u3001skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
24747
25549
  );
24748
25550
  }
24749
25551
  return strategy;
@@ -25220,6 +26022,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
25220
26022
  "- \u6BCF\u4E2A\u4EFB\u52A1\u7684 `business_goal` \u90FD\u5FC5\u987B\u5199\u6E05\u695A\u4E1A\u52A1\u76EE\u6807\u573A\u666F\u3002",
25221
26023
  "- \u6BCF\u4E2A\u4EFB\u52A1\u7684 `required_skills` \u90FD\u5FC5\u987B\u5217\u51FA\u5B9E\u9645\u8981\u4F7F\u7528\u7684 BPMAX skill\u3002",
25222
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",
25223
26026
  "",
25224
26027
  "## \u8FDB\u5EA6 CSV",
25225
26028
  "",
@@ -25261,7 +26064,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
25261
26064
  }
25262
26065
  async function initTaskbook(outFile, title) {
25263
26066
  const content = taskbookTemplate(title);
25264
- await mkdir12(path13.dirname(outFile), { recursive: true });
26067
+ await mkdir12(path14.dirname(outFile), { recursive: true });
25265
26068
  await writeFile12(outFile, content, "utf8");
25266
26069
  return { out: outFile, bytes: Buffer.byteLength(content) };
25267
26070
  }
@@ -25351,7 +26154,7 @@ async function initTaskbookProgress(source, outFile) {
25351
26154
  fields.join(","),
25352
26155
  ...rows2.map((row) => fields.map((field) => csvEscape(field === "status" ? "\u672A\u5F00\u59CB" : row[field] || "")).join(","))
25353
26156
  ].join("\n") + "\n";
25354
- await mkdir12(path13.dirname(outFile), { recursive: true });
26157
+ await mkdir12(path14.dirname(outFile), { recursive: true });
25355
26158
  await writeFile12(outFile, csv, "utf8");
25356
26159
  return { source, out: outFile, task_count: rows2.length };
25357
26160
  }
@@ -25394,12 +26197,12 @@ function registerTaskbookCommands(program2) {
25394
26197
  }
25395
26198
 
25396
26199
  // src/commands/test-suite.ts
25397
- import { readFile as readFile17 } from "fs/promises";
25398
- import path14 from "path";
26200
+ import { readFile as readFile18 } from "fs/promises";
26201
+ import path15 from "path";
25399
26202
  async function resolveE2eSkillSource(sourceSkill) {
25400
26203
  if (sourceSkill) {
25401
- const resolved = path14.resolve(sourceSkill);
25402
- const content = await readFile17(resolved, "utf8").catch(() => "");
26204
+ const resolved = path15.resolve(sourceSkill);
26205
+ const content = await readFile18(resolved, "utf8").catch(() => "");
25403
26206
  if (!content.includes('name: "bpmax-e2e-flow-test-operator"') && !content.includes("name: bpmax-e2e-flow-test-operator")) {
25404
26207
  throw new TestSuiteError("source skill is not bpmax-e2e-flow-test-operator", {
25405
26208
  rule_id: "test_suite.run.skill_source_invalid",
@@ -25480,17 +26283,18 @@ function registerTestSuiteCommands(program2) {
25480
26283
  printResult(options.format, { path: reportDir });
25481
26284
  });
25482
26285
  suite.command("lint-report").description("Lint BPMAX E2E test report artifacts").option("--root <path>", "Report root directory", DEFAULT_REPORT_ROOT).option("--all-runs", "Lint every historical run instead of only the latest/current run").option("--format <format>", "Output format", "json").action(async (options) => {
25483
- const errors = await lintReport(options.root, { allRuns: Boolean(options.allRuns) });
25484
- if (errors.length > 0) {
25485
- throw new Error(errors.join("\n"));
26286
+ const lint = await lintReport(options.root, { allRuns: Boolean(options.allRuns) });
26287
+ if (lint.errors.length > 0) {
26288
+ throw new Error(lint.errors.join("\n"));
25486
26289
  }
25487
- printResult(options.format, { ok: true });
26290
+ const summary = lint.reports.length === 1 ? lint.reports[0] : { reports: lint.reports };
26291
+ printResult(options.format, { ok: true, ...summary });
25488
26292
  });
25489
26293
  }
25490
26294
 
25491
26295
  // src/core/update.ts
25492
- import { access as access2, mkdir as mkdir13, readFile as readFile18, realpath as realpath3, writeFile as writeFile13 } from "fs/promises";
25493
- import path15 from "path";
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";
25494
26298
  var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
25495
26299
  var UPDATE_STATE_FILE = "update-state.json";
25496
26300
  var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -25606,11 +26410,11 @@ async function fetchLatestVersion(options = {}) {
25606
26410
  }
25607
26411
  }
25608
26412
  function updateStatePath(configDir = getConfigDir()) {
25609
- return path15.join(configDir, UPDATE_STATE_FILE);
26413
+ return path16.join(configDir, UPDATE_STATE_FILE);
25610
26414
  }
25611
26415
  async function readUpdateState(configDir) {
25612
26416
  try {
25613
- const raw = await readFile18(updateStatePath(configDir), "utf8");
26417
+ const raw = await readFile19(updateStatePath(configDir), "utf8");
25614
26418
  const parsed = JSON.parse(raw);
25615
26419
  if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
25616
26420
  return null;
@@ -25687,7 +26491,7 @@ async function findNpmPath() {
25687
26491
  }
25688
26492
  function detectInstallMethod(input) {
25689
26493
  const resolvedPath = input.executablePath || "";
25690
- const method = resolvedPath.includes(`node_modules${path15.sep}`) || resolvedPath.includes("node_modules/") ? "npm" : "manual";
26494
+ const method = resolvedPath.includes(`node_modules${path16.sep}`) || resolvedPath.includes("node_modules/") ? "npm" : "manual";
25691
26495
  return {
25692
26496
  method,
25693
26497
  resolvedPath,
@@ -25928,17 +26732,17 @@ function registerUrlCommands(program2, deps = {}) {
25928
26732
  }
25929
26733
 
25930
26734
  // src/commands/user.ts
25931
- function isRecord15(value) {
26735
+ function isRecord16(value) {
25932
26736
  return typeof value === "object" && value !== null && !Array.isArray(value);
25933
26737
  }
25934
26738
  function userRows(value) {
25935
- if (Array.isArray(value)) return value.filter(isRecord15);
25936
- if (!isRecord15(value)) return [];
25937
- if (Array.isArray(value.data)) return value.data.filter(isRecord15);
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);
25938
26742
  return value.id ? [value] : [];
25939
26743
  }
25940
26744
  function safeUser2(user) {
25941
- const roles = Array.isArray(user.role) ? user.role.filter(isRecord15).map((role) => ({
26745
+ const roles = Array.isArray(user.role) ? user.role.filter(isRecord16).map((role) => ({
25942
26746
  id: role.id,
25943
26747
  key: role.key,
25944
26748
  name: role.name