bpmax-cli 0.2.1-beta.1 → 0.2.1-beta.10

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 (23) hide show
  1. package/README.md +28 -1
  2. package/dist/bin.js +1367 -255
  3. package/dist/bin.js.map +1 -1
  4. package/package.json +1 -1
  5. package/skills/bpmax-ai-taskbook/SKILL.md +5 -1
  6. package/skills/bpmax-approval-matrix/SKILL.md +4 -1
  7. package/skills/bpmax-blueprint-doc-workflow/SKILL.md +87 -0
  8. package/skills/bpmax-blueprint-doc-workflow/agents/openai.yaml +4 -0
  9. package/skills/bpmax-blueprint-doc-workflow/references/blueprint-structure.md +60 -0
  10. package/skills/bpmax-blueprint-doc-workflow/references/per-flow-required-structure.md +98 -0
  11. package/skills/bpmax-blueprint-doc-workflow/references/sample-forbidden-term.xml +12 -0
  12. package/skills/bpmax-blueprint-doc-workflow/references/sample-mermaid-codeblock.xml +12 -0
  13. package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-boundary.xml +10 -0
  14. package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-whiteboard.xml +10 -0
  15. package/skills/bpmax-blueprint-doc-workflow/references/sample-pass.xml +55 -0
  16. package/skills/bpmax-blueprint-doc-workflow/scripts/lint_blueprint_doc.py +257 -0
  17. package/skills/bpmax-dataset-field-template-editor/SKILL.md +6 -3
  18. package/skills/bpmax-dataset-template-editor/SKILL.md +12 -2
  19. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +25 -1
  20. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +13 -0
  21. package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +25 -3
  22. package/skills/bpmax-flow-template-editor/SKILL.md +67 -5
  23. package/skills/bpmax-form-template-editor/SKILL.md +47 -0
package/dist/bin.js CHANGED
@@ -138,8 +138,8 @@ function maskApiKey(apiKey) {
138
138
  if (!apiKey) {
139
139
  return "(unset)";
140
140
  }
141
- if (apiKey.length <= 10) {
142
- return apiKey;
141
+ if (apiKey.length <= 16) {
142
+ return "[REDACTED]";
143
143
  }
144
144
  return `${apiKey.slice(0, 8)}****${apiKey.slice(-4)}`;
145
145
  }
@@ -231,8 +231,8 @@ function throwCliGovernanceUnsupportedIfNeeded(error, fallbackPath) {
231
231
  }
232
232
  throw error;
233
233
  }
234
- function normalizePath(path14) {
235
- let normalized = path14.split("?")[0] || "/";
234
+ function normalizePath(path15) {
235
+ let normalized = path15.split("?")[0] || "/";
236
236
  if (!normalized.startsWith("/")) {
237
237
  normalized = `/${normalized}`;
238
238
  }
@@ -242,17 +242,17 @@ function normalizePath(path14) {
242
242
  }
243
243
  return normalized.replace(/\/+$/g, "") || "/api";
244
244
  }
245
- function getNumber(value, path14) {
246
- const result = getValue(value, path14);
245
+ function getNumber(value, path15) {
246
+ const result = getValue(value, path15);
247
247
  return typeof result === "number" ? result : void 0;
248
248
  }
249
- function getString(value, path14) {
250
- const result = getValue(value, path14);
249
+ function getString(value, path15) {
250
+ const result = getValue(value, path15);
251
251
  return typeof result === "string" ? result : void 0;
252
252
  }
253
- function getValue(value, path14) {
253
+ function getValue(value, path15) {
254
254
  let current = value;
255
- for (const key of path14) {
255
+ for (const key of path15) {
256
256
  if (!current || typeof current !== "object" || !(key in current)) {
257
257
  return void 0;
258
258
  }
@@ -262,10 +262,10 @@ function getValue(value, path14) {
262
262
  }
263
263
 
264
264
  // src/core/capabilities.ts
265
- function capabilityForRequest(method, path14) {
265
+ function capabilityForRequest(method, path15) {
266
266
  const normalizedMethod = method.toUpperCase();
267
- const normalizedPath = normalizePath2(path14);
268
- const pageTemplatePrefix = flowPageTemplateCapabilityPrefix(path14);
267
+ const normalizedPath = normalizePath2(path15);
268
+ const pageTemplatePrefix = flowPageTemplateCapabilityPrefix(path15);
269
269
  if (normalizedPath === "/cli/capabilities") {
270
270
  return void 0;
271
271
  }
@@ -423,8 +423,8 @@ async function updateProfileCapabilities(profileName, cache) {
423
423
  };
424
424
  await saveConfig(config);
425
425
  }
426
- function flowPageTemplateCapabilityPrefix(path14) {
427
- const query = path14.includes("?") ? path14.slice(path14.indexOf("?") + 1) : "";
426
+ function flowPageTemplateCapabilityPrefix(path15) {
427
+ const query = path15.includes("?") ? path15.slice(path15.indexOf("?") + 1) : "";
428
428
  const type = new URLSearchParams(query).get("type");
429
429
  if (type === "2") {
430
430
  return "config.project_detail_template";
@@ -437,8 +437,8 @@ function flowPageTemplateCapabilityPrefix(path14) {
437
437
  }
438
438
  return "config.list_template";
439
439
  }
440
- function normalizePath2(path14) {
441
- let normalized = path14.split("?")[0] || "/";
440
+ function normalizePath2(path15) {
441
+ let normalized = path15.split("?")[0] || "/";
442
442
  if (!normalized.startsWith("/")) {
443
443
  normalized = `/${normalized}`;
444
444
  }
@@ -469,7 +469,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
469
469
  // package.json
470
470
  var package_default = {
471
471
  name: "bpmax-cli",
472
- version: "0.2.1-beta.1",
472
+ version: "0.2.1-beta.10",
473
473
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
474
474
  type: "module",
475
475
  bin: {
@@ -516,8 +516,8 @@ var NPM_PACKAGE = "bpmax-cli";
516
516
  // src/core/terminal.ts
517
517
  import { randomUUID } from "crypto";
518
518
  import os from "os";
519
- function isCliControlPath(path14) {
520
- const normalized = normalizeApiPath(path14);
519
+ function isCliControlPath(path15) {
520
+ const normalized = normalizeApiPath(path15);
521
521
  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";
522
522
  }
523
523
  function commandSummary(argv = process.argv) {
@@ -681,8 +681,8 @@ async function updateProfileTerminal(profile, terminalId, status) {
681
681
  profile.config.terminal_status = status;
682
682
  profile.config.terminal_registered_at = config.profiles[profile.name].terminal_registered_at;
683
683
  }
684
- function normalizeApiPath(path14) {
685
- let normalized = path14.split("?")[0] || "/";
684
+ function normalizeApiPath(path15) {
685
+ let normalized = path15.split("?")[0] || "/";
686
686
  if (!normalized.startsWith("/")) {
687
687
  normalized = `/${normalized}`;
688
688
  }
@@ -800,14 +800,14 @@ function recordCommandAuditResult(value) {
800
800
  state.result_summary = redactAuditValue(value);
801
801
  }
802
802
  }
803
- var ensureApiPath = (path14) => {
804
- if (!path14.startsWith("/")) {
805
- path14 = `/${path14}`;
803
+ var ensureApiPath = (path15) => {
804
+ if (!path15.startsWith("/")) {
805
+ path15 = `/${path15}`;
806
806
  }
807
- if (path14.startsWith("/api/")) {
808
- return path14;
807
+ if (path15.startsWith("/api/")) {
808
+ return path15;
809
809
  }
810
- return `/api${path14}`;
810
+ return `/api${path15}`;
811
811
  };
812
812
  function normalizeWorkspaceForApi(workspace) {
813
813
  const normalized = workspace?.trim();
@@ -853,10 +853,10 @@ function createApiClient(profile) {
853
853
  });
854
854
  return instance;
855
855
  }
856
- async function apiRequest(client, method, path14, options = {}) {
856
+ async function apiRequest(client, method, path15, options = {}) {
857
857
  const profile = clientProfiles.get(client);
858
- const apiPath2 = ensureApiPath(path14);
859
- const capability = options.capability ?? capabilityForRequest(method, path14);
858
+ const apiPath2 = ensureApiPath(path15);
859
+ const capability = options.capability ?? capabilityForRequest(method, path15);
860
860
  const shouldControl = Boolean(profile?.config.api_key) && !isCliControlPath(apiPath2);
861
861
  const reqId = requestId();
862
862
  if (profile) {
@@ -1164,8 +1164,8 @@ async function parseJsonAny(input, label = "JSON input") {
1164
1164
  function isMutatingMethod(method) {
1165
1165
  return ["POST", "PUT", "PATCH", "DELETE"].includes(method.toUpperCase());
1166
1166
  }
1167
- function normalizeApiPath2(path14) {
1168
- let normalized = path14.trim();
1167
+ function normalizeApiPath2(path15) {
1168
+ let normalized = path15.trim();
1169
1169
  const queryIndex = normalized.indexOf("?");
1170
1170
  if (queryIndex >= 0) {
1171
1171
  normalized = normalized.slice(0, queryIndex);
@@ -1182,9 +1182,9 @@ function normalizeApiPath2(path14) {
1182
1182
  }
1183
1183
  return normalized;
1184
1184
  }
1185
- function pluginAgentCapabilityForRawApi(method, path14) {
1185
+ function pluginAgentCapabilityForRawApi(method, path15) {
1186
1186
  const normalizedMethod = method.toUpperCase();
1187
- const normalizedPath = normalizeApiPath2(path14);
1187
+ const normalizedPath = normalizeApiPath2(path15);
1188
1188
  const match = normalizedPath.match(/^\/(plugin_[A-Za-z0-9_]+)\/agents(?:\/|$)/);
1189
1189
  if (!match) {
1190
1190
  return void 0;
@@ -1198,19 +1198,19 @@ function pluginAgentCapabilityForRawApi(method, path14) {
1198
1198
  }
1199
1199
  return void 0;
1200
1200
  }
1201
- function parseQuery(path14) {
1202
- const queryIndex = path14.indexOf("?");
1203
- return new URLSearchParams(queryIndex >= 0 ? path14.slice(queryIndex + 1) : "");
1201
+ function parseQuery(path15) {
1202
+ const queryIndex = path15.indexOf("?");
1203
+ return new URLSearchParams(queryIndex >= 0 ? path15.slice(queryIndex + 1) : "");
1204
1204
  }
1205
- function isRawConfigPath(method, path14) {
1206
- const normalizedPath = normalizeApiPath2(path14);
1205
+ function isRawConfigPath(method, path15) {
1206
+ const normalizedPath = normalizeApiPath2(path15);
1207
1207
  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)) {
1208
1208
  return true;
1209
1209
  }
1210
1210
  if (normalizedPath === "/flow/list/lightweight" || normalizedPath.startsWith("/flow/configuration/")) {
1211
1211
  return true;
1212
1212
  }
1213
- if (normalizedPath === "/flow" && method === "GET" && parseQuery(path14).has("draft")) {
1213
+ if (normalizedPath === "/flow" && method === "GET" && parseQuery(path15).has("draft")) {
1214
1214
  return true;
1215
1215
  }
1216
1216
  if (normalizedPath.startsWith("/flow/") && !["/flow/flow_type", "/flow/options", "/flow/batch_get"].includes(normalizedPath)) {
@@ -1221,35 +1221,35 @@ function isRawConfigPath(method, path14) {
1221
1221
  }
1222
1222
  return false;
1223
1223
  }
1224
- function assertRawApiPathAllowed(method, path14) {
1225
- if (isRawConfigPath(method, path14)) {
1224
+ function assertRawApiPathAllowed(method, path15) {
1225
+ if (isRawConfigPath(method, path15)) {
1226
1226
  throw new Error(
1227
- `Raw API ${method} ${path14} 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.`
1227
+ `Raw API ${method} ${path15} 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.`
1228
1228
  );
1229
1229
  }
1230
1230
  if (!isMutatingMethod(method)) {
1231
1231
  return;
1232
1232
  }
1233
- const normalizedPath = normalizeApiPath2(path14);
1233
+ const normalizedPath = normalizeApiPath2(path15);
1234
1234
  const isProjectPath = normalizedPath === "/project" || normalizedPath.startsWith("/project/");
1235
1235
  const isAllowedProjectReadPost = method === "POST" && normalizedPath === "/project/list";
1236
1236
  if (!isProjectPath || isAllowedProjectReadPost) {
1237
1237
  return;
1238
1238
  }
1239
1239
  throw new Error(
1240
- `Raw API ${method} ${path14} 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.`
1240
+ `Raw API ${method} ${path15} 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.`
1241
1241
  );
1242
1242
  }
1243
1243
  function registerApiCommands(program2) {
1244
- 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, path14, options) => {
1244
+ 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, path15, options) => {
1245
1245
  const normalizedMethod = method.toUpperCase();
1246
- assertRawApiPathAllowed(normalizedMethod, path14);
1246
+ assertRawApiPathAllowed(normalizedMethod, path15);
1247
1247
  if (isMutatingMethod(normalizedMethod) && options.confirmMutating !== true) {
1248
1248
  printResult(options.format, {
1249
1249
  ok: false,
1250
1250
  dry_run: true,
1251
1251
  method: normalizedMethod,
1252
- path: path14,
1252
+ path: path15,
1253
1253
  warning: "Mutating raw API calls require --confirm-mutating. Prefer typed bpmax-cli commands such as step submit."
1254
1254
  });
1255
1255
  return;
@@ -1257,8 +1257,8 @@ function registerApiCommands(program2) {
1257
1257
  const config = await loadConfig();
1258
1258
  const profile = resolveProfile(config, options.profile);
1259
1259
  const client = createApiClient(profile);
1260
- const capability = pluginAgentCapabilityForRawApi(normalizedMethod, path14) || "api.raw";
1261
- const result = await apiRequest(client, normalizedMethod, path14, {
1260
+ const capability = pluginAgentCapabilityForRawApi(normalizedMethod, path15) || "api.raw";
1261
+ const result = await apiRequest(client, normalizedMethod, path15, {
1262
1262
  params: options.params ? await parseJsonInput(options.params, "--params") : void 0,
1263
1263
  data: await parseJsonAny(options.data, "--data"),
1264
1264
  capability
@@ -1281,6 +1281,18 @@ function shellQuote(value) {
1281
1281
  }
1282
1282
  return `'${value.replace(/'/g, `'\\''`)}'`;
1283
1283
  }
1284
+ function toUserSummary(user) {
1285
+ if (!user || typeof user !== "object" || Array.isArray(user)) {
1286
+ return void 0;
1287
+ }
1288
+ const record = user;
1289
+ const id = typeof record.id === "number" ? record.id : typeof record.user_id === "number" ? record.user_id : void 0;
1290
+ const name = typeof record.name === "string" ? record.name : typeof record.nickname === "string" ? record.nickname : typeof record.realname === "string" ? record.realname : "";
1291
+ if (id === void 0) {
1292
+ return void 0;
1293
+ }
1294
+ return { id, name };
1295
+ }
1284
1296
  var DeviceAuthorizationError = class extends Error {
1285
1297
  code;
1286
1298
  interval;
@@ -1333,18 +1345,18 @@ function lintDeviceAuthorizationUrl(urlValue, expectedOrigin, expectedWorkspace,
1333
1345
  );
1334
1346
  }
1335
1347
  }
1336
- function apiPath(path14) {
1337
- if (path14.startsWith("/api/")) {
1338
- return path14;
1348
+ function apiPath(path15) {
1349
+ if (path15.startsWith("/api/")) {
1350
+ return path15;
1339
1351
  }
1340
- return `/api${path14.startsWith("/") ? path14 : `/${path14}`}`;
1352
+ return `/api${path15.startsWith("/") ? path15 : `/${path15}`}`;
1341
1353
  }
1342
1354
  function createDeviceRequest(origin) {
1343
1355
  const client = axios2.create({ baseURL: origin, withCredentials: false });
1344
- return async (method, path14, options) => {
1356
+ return async (method, path15, options) => {
1345
1357
  const response = await client.request({
1346
1358
  method,
1347
- url: apiPath(path14),
1359
+ url: apiPath(path15),
1348
1360
  data: options.data
1349
1361
  });
1350
1362
  const body = response.data;
@@ -1427,7 +1439,7 @@ async function completeDeviceLogin(options) {
1427
1439
  }
1428
1440
  return {
1429
1441
  apiKey,
1430
- user: response.user,
1442
+ user: toUserSummary(response.user),
1431
1443
  apiKeyCapabilities: response.capabilities && typeof response.capabilities === "object" && !Array.isArray(response.capabilities) ? response.capabilities : void 0
1432
1444
  };
1433
1445
  }
@@ -1491,7 +1503,7 @@ function updateProfileAuth(profile, result) {
1491
1503
  ...rest,
1492
1504
  ...terminalFields,
1493
1505
  api_key: result.apiKey,
1494
- user: result.user,
1506
+ user: toUserSummary(result.user),
1495
1507
  api_key_capabilities: result.apiKeyCapabilities || {}
1496
1508
  };
1497
1509
  }
@@ -1544,6 +1556,15 @@ async function fetchCurrentUserForStatus(profile) {
1544
1556
  }
1545
1557
  return body.data ?? body;
1546
1558
  }
1559
+ function minimalStatusUser(user) {
1560
+ const safe = {};
1561
+ for (const key of ["id", "user_id", "uid", "name", "nickname", "realname"]) {
1562
+ if (user[key] !== void 0 && user[key] !== null && user[key] !== "") {
1563
+ safe[key] = user[key];
1564
+ }
1565
+ }
1566
+ return safe;
1567
+ }
1547
1568
  function registerAuthCommands(program2, deps = {}) {
1548
1569
  const load = deps.loadConfig || loadConfig;
1549
1570
  const save = deps.saveConfig || saveConfig;
@@ -1579,6 +1600,7 @@ function registerAuthCommands(program2, deps = {}) {
1579
1600
  expiresIn: authorization.expires_in
1580
1601
  });
1581
1602
  config.profiles[profile.name] = updateProfileAuth(config.profiles[profile.name], result);
1603
+ result = { ...result, user: config.profiles[profile.name].user };
1582
1604
  await save(config);
1583
1605
  let capabilitiesProbe;
1584
1606
  let capabilitiesCache = config.profiles[profile.name].capabilities_cache;
@@ -1643,6 +1665,7 @@ function registerAuthCommands(program2, deps = {}) {
1643
1665
  deviceCode
1644
1666
  });
1645
1667
  config.profiles[profile.name] = updateProfileAuth(config.profiles[profile.name], result);
1668
+ const safeUser = config.profiles[profile.name].user;
1646
1669
  await save(config);
1647
1670
  let capabilitiesProbe;
1648
1671
  let capabilitiesCache = config.profiles[profile.name].capabilities_cache;
@@ -1664,12 +1687,12 @@ function registerAuthCommands(program2, deps = {}) {
1664
1687
  ok: true,
1665
1688
  profile: profile.name,
1666
1689
  login: "authenticated",
1667
- user: result.user,
1690
+ user: safeUser,
1668
1691
  ...capabilitiesProbe ? { capabilities_probe: capabilitiesProbe } : {},
1669
1692
  ...nextCommands ? { next_commands: nextCommands } : {}
1670
1693
  });
1671
1694
  });
1672
- auth.command("status").description("Show saved auth state and validate /api/user/current").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
1695
+ auth.command("status").description("Show saved auth state and validate /api/user/current").option("--profile <profile>", "Profile name").option("--verbose", "Include the full /api/user/current response. Default output is minimized and redacted for logs.").option("--format <format>", "Output format", "pretty").action(async (options) => {
1673
1696
  const config = await load();
1674
1697
  const profile = resolveProfile(config, options.profile);
1675
1698
  const output = {
@@ -1682,7 +1705,8 @@ function registerAuthCommands(program2, deps = {}) {
1682
1705
  if (profile.config.api_key) {
1683
1706
  try {
1684
1707
  const currentUser = await fetchCurrentUserForStatus(profile);
1685
- output.user = currentUser;
1708
+ output.user = options.verbose ? currentUser : minimalStatusUser(currentUser);
1709
+ output.user_detail = options.verbose ? "full" : "minimal";
1686
1710
  output.authenticated = true;
1687
1711
  } catch (error) {
1688
1712
  const message = error instanceof Error ? error.message : String(error);
@@ -1753,20 +1777,20 @@ function requireNumericId(value, name) {
1753
1777
  }
1754
1778
  return nextValue;
1755
1779
  }
1756
- function withQuery(path14, query) {
1780
+ function withQuery(path15, query) {
1757
1781
  const params = new URLSearchParams();
1758
1782
  for (const [key, value] of Object.entries(query)) {
1759
1783
  if (value !== void 0) {
1760
1784
  params.set(key, value);
1761
1785
  }
1762
1786
  }
1763
- return `${path14}?${params.toString()}`;
1787
+ return `${path15}?${params.toString()}`;
1764
1788
  }
1765
1789
  function buildBpmaxUrl(profile, kind, params = {}) {
1766
1790
  const origin = normalizeOrigin2(profile.config.origin);
1767
1791
  const workspace = normalizeWorkspaceForUrl(params.workspace || profile.config.workspace);
1768
1792
  const basePath = `/${workspace}`;
1769
- let path14 = basePath;
1793
+ let path15 = basePath;
1770
1794
  const result = {
1771
1795
  kind,
1772
1796
  profile: profile.name,
@@ -1774,15 +1798,15 @@ function buildBpmaxUrl(profile, kind, params = {}) {
1774
1798
  workspace
1775
1799
  };
1776
1800
  if (kind === "project-list") {
1777
- path14 = `${basePath}/project`;
1801
+ path15 = `${basePath}/project`;
1778
1802
  } else if (kind === "project-detail") {
1779
1803
  const projectId = requireNumericId(params.projectId, "projectId");
1780
- path14 = `${basePath}/project_detail/0/${projectId}`;
1804
+ path15 = `${basePath}/project_detail/0/${projectId}`;
1781
1805
  result.project_id = projectId;
1782
1806
  } else if (kind === "project-step") {
1783
1807
  const projectId = requireNumericId(params.projectId, "projectId");
1784
1808
  const stepId = requireNumericId(params.stepId, "stepId");
1785
- path14 = withQuery(`${basePath}/projectContinue`, {
1809
+ path15 = withQuery(`${basePath}/projectContinue`, {
1786
1810
  id: projectId,
1787
1811
  step_id: stepId
1788
1812
  });
@@ -1799,15 +1823,15 @@ function buildBpmaxUrl(profile, kind, params = {}) {
1799
1823
  ...flowKey ? { key: flowKey } : {},
1800
1824
  ...prefillToken ? { prefill_token: prefillToken } : { init_value: initValue }
1801
1825
  };
1802
- path14 = withQuery(`${basePath}/project/create`, query);
1826
+ path15 = withQuery(`${basePath}/project/create`, query);
1803
1827
  result.flow_type = flowType;
1804
1828
  result.flow_key = flowKey;
1805
1829
  result.mobile_path = withQuery("/pages/projectCreate/projectCreate", query);
1806
1830
  }
1807
- const url = `${origin}${path14}`;
1831
+ const url = `${origin}${path15}`;
1808
1832
  return {
1809
1833
  ...result,
1810
- path: path14,
1834
+ path: path15,
1811
1835
  url,
1812
1836
  ...kind === "project-create" ? { pc_url: url } : {}
1813
1837
  };
@@ -2717,6 +2741,8 @@ function registerCapabilitiesCommands(program2) {
2717
2741
 
2718
2742
  // src/commands/config.ts
2719
2743
  import { text as text2 } from "@clack/prompts";
2744
+ import { mkdir as mkdir8, writeFile as writeFile8 } from "fs/promises";
2745
+ import path9 from "path";
2720
2746
 
2721
2747
  // src/core/config-workflow.ts
2722
2748
  import { createHash as createHash4 } from "crypto";
@@ -3927,6 +3953,8 @@ function configAdapterMatrix() {
3927
3953
  return Object.entries(CONFIG_DOMAINS).map(([domain, definition]) => {
3928
3954
  const supportsCreate = Boolean(definition.createPath) || ["flow-template", "api-platform", "role", "nav-config"].includes(domain);
3929
3955
  const supportsDelete = Boolean(definition.deletePath) || ["workspace-flow", "api-platform", "nav-config"].includes(domain);
3956
+ const supportsPublish = domain === "dataset";
3957
+ const supportsRelationFields = domain === "dataset";
3930
3958
  return {
3931
3959
  domain,
3932
3960
  capability_prefix: definition.capability,
@@ -3939,6 +3967,29 @@ function configAdapterMatrix() {
3939
3967
  delete_capability: supportsDelete ? `${definition.capability}.delete` : null,
3940
3968
  read_endpoints: definition.readEndpoints,
3941
3969
  write_endpoints: definition.writeEndpoints,
3970
+ actions: {
3971
+ export: definition.exportStatus === "supported",
3972
+ create: supportsCreate,
3973
+ build: definition.buildStatus === "supported",
3974
+ submit: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy",
3975
+ publish: supportsPublish,
3976
+ relationFields: supportsRelationFields,
3977
+ delete: supportsDelete,
3978
+ verify: definition.exportStatus === "supported",
3979
+ dry_run: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy"
3980
+ },
3981
+ requires: {
3982
+ work_file: definition.buildStatus === "supported",
3983
+ meta_file_for_build: definition.buildStatus === "supported",
3984
+ payload_file_for_submit: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy",
3985
+ base_hash_for_submit: domain === "workspace-flow" || domain === "dataset"
3986
+ },
3987
+ side_effects: {
3988
+ writes_workspace_binding: domain === "workspace-flow",
3989
+ full_replacement_submit: domain === "workspace-flow",
3990
+ publishes_on_submit: domain === "form-template",
3991
+ relation_fields_submit: domain === "dataset"
3992
+ },
3942
3993
  notes: definition.notes
3943
3994
  };
3944
3995
  });
@@ -3946,6 +3997,34 @@ function configAdapterMatrix() {
3946
3997
  function hashJson(value) {
3947
3998
  return createHash4("sha256").update(JSON.stringify(value)).digest("hex");
3948
3999
  }
4000
+ function flowAppContextEvidence(input) {
4001
+ const flowData = isRecord3(input.flow.data) ? input.flow.data : {};
4002
+ const flowType = firstNonEmpty(input.flow.flow_type, flowData.flow_type, input.flowId);
4003
+ const flowKey = firstNonEmpty(input.flow.key);
4004
+ const flowTemplateId = input.flow.id ?? input.flow.flow_id ?? null;
4005
+ const missing = [
4006
+ ["flow_type", flowType],
4007
+ ["form_template_id", input.formTemplateId],
4008
+ ["form_template_draft_id", input.formTemplateDraftId],
4009
+ ["workspace_binding", input.bindingFound ? "ok" : ""]
4010
+ ].filter(([, value]) => value === null || value === void 0 || String(value).trim() === "").map(([key]) => key);
4011
+ return {
4012
+ flow_type: flowType || null,
4013
+ flow_key: flowKey,
4014
+ flow_template_id: flowTemplateId,
4015
+ form_template_id: input.formTemplateId ?? null,
4016
+ form_template_draft_id: input.formTemplateDraftId ?? null,
4017
+ workspace_key: input.workspace,
4018
+ workspace_binding_found: input.bindingFound,
4019
+ workspace_readback_hash: hashJson(input.workspaceReadback),
4020
+ flow_readback_hash: hashJson(input.flow),
4021
+ form_template_readback_hash: input.formReadback ? hashJson(input.formReadback) : null,
4022
+ evidence_status: missing.length === 0 ? "verified" : "incomplete",
4023
+ missing_context: missing,
4024
+ resolved_by: input.resolvedBy,
4025
+ verified_at: (/* @__PURE__ */ new Date()).toISOString()
4026
+ };
4027
+ }
3949
4028
  function isRecord3(value) {
3950
4029
  return value !== null && typeof value === "object" && !Array.isArray(value);
3951
4030
  }
@@ -4063,9 +4142,9 @@ function summarizeOperationPlan(payload) {
4063
4142
  return "submit operation";
4064
4143
  }
4065
4144
  const method = typeof operation.method === "string" ? operation.method : "REQUEST";
4066
- const path14 = typeof operation.path === "string" ? operation.path : "";
4145
+ const path15 = typeof operation.path === "string" ? operation.path : "";
4067
4146
  const type = typeof operation.type === "string" ? ` ${operation.type}` : "";
4068
- return `submit${type}: ${method}${path14 ? ` ${path14}` : ""}`;
4147
+ return `submit${type}: ${method}${path15 ? ` ${path15}` : ""}`;
4069
4148
  }),
4070
4149
  ...skipped.slice(0, Math.max(0, 20 - operations.length)).map((operation) => {
4071
4150
  if (!isRecord3(operation)) {
@@ -4260,6 +4339,277 @@ function validateFlowTemplateStandardPageCreateFormTemplate(value, errors) {
4260
4339
  }
4261
4340
  throw new Error(message);
4262
4341
  }
4342
+ function startConditionalJumpScriptLooksLikeIndexReturn(script) {
4343
+ const text5 = script.trim();
4344
+ if (!text5) {
4345
+ return false;
4346
+ }
4347
+ const directReturns = Array.from(text5.matchAll(/\breturn\s+([^;]+)\s*;?/g));
4348
+ if (!directReturns.length) {
4349
+ return false;
4350
+ }
4351
+ return directReturns.some((match) => {
4352
+ const expression = match[1].trim();
4353
+ if (/[=!<>]=?|&&|\|\||\?/.test(expression)) {
4354
+ return false;
4355
+ }
4356
+ return /^-?\d+$/.test(expression) || /^(routeIndex|resultIndex|targetIndex|index)\b/.test(expression) || /\b(result|options)\.indexOf\s*\(/.test(expression) || /^Number(?:\.parseInt)?\s*\(/.test(expression);
4357
+ });
4358
+ }
4359
+ function startConditionalJumpScriptIsCatchAll(script) {
4360
+ const text5 = script.trim();
4361
+ return /^return\s+true\s*;?\s*$/.test(text5) || /^return\s+Boolean\s*\(\s*true\s*\)\s*;?\s*$/.test(text5);
4362
+ }
4363
+ function validateFlowTemplateStartConditionalJump(value, errors) {
4364
+ const nextErrors = [];
4365
+ const data = isRecord3(value.data) ? value.data : {};
4366
+ const meta = isRecord3(data.meta) ? data.meta : {};
4367
+ const jumps = meta.condational_jump;
4368
+ if (jumps === void 0 || jumps === null || jumps === "") {
4369
+ return;
4370
+ }
4371
+ if (!Array.isArray(jumps)) {
4372
+ nextErrors.push("data.meta.condational_jump must be an array when start conditional routing is configured.");
4373
+ } else if (jumps.length === 0) {
4374
+ return;
4375
+ }
4376
+ const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
4377
+ const firstNodeId = nodes.length ? String(nodes[0].id ?? "").trim() : "";
4378
+ const nodeIds = new Set(nodes.map((node) => String(node.id ?? "").trim()).filter(Boolean));
4379
+ if (Array.isArray(jumps) && jumps.length && !nodes.length) {
4380
+ nextErrors.push("data.meta.condational_jump is configured but data.nodes is empty; start jump targets must point to real nodes or -1.");
4381
+ }
4382
+ if (Array.isArray(jumps) && jumps.length) {
4383
+ nodes.forEach((node, index) => {
4384
+ const id = String(node.id ?? "").trim();
4385
+ if (!id) {
4386
+ nextErrors.push(`data.nodes[${index}].id is required when data.meta.condational_jump is configured.`);
4387
+ }
4388
+ });
4389
+ }
4390
+ let lastJumpScript = "";
4391
+ let lastJumpResult = "";
4392
+ if (Array.isArray(jumps)) {
4393
+ jumps.forEach((jump, index) => {
4394
+ const pathName = `data.meta.condational_jump[${index}]`;
4395
+ if (!isRecord3(jump)) {
4396
+ nextErrors.push(`${pathName} must be an object with name, result, condition_mode, and a boolean condition script.`);
4397
+ return;
4398
+ }
4399
+ const name = typeof jump.name === "string" ? jump.name.trim() : "";
4400
+ if (!name) {
4401
+ nextErrors.push(`${pathName}.name is required so every explicit start route can be audited.`);
4402
+ }
4403
+ const rawResult = jump.result;
4404
+ if (Array.isArray(rawResult) || isRecord3(rawResult) || rawResult === void 0 || rawResult === null || String(rawResult).trim() === "") {
4405
+ nextErrors.push(`${pathName}.result must be a target node id or -1; it must not be empty, an array, an object, or a node name.`);
4406
+ } else {
4407
+ const result = String(rawResult).trim();
4408
+ if (result !== "-1" && !nodeIds.has(result)) {
4409
+ nextErrors.push(`${pathName}.result (${result}) must point to an existing data.nodes[].id or -1 for success end.`);
4410
+ }
4411
+ lastJumpResult = result;
4412
+ }
4413
+ const mode = typeof jump.condition_mode === "string" && jump.condition_mode.trim() ? jump.condition_mode.trim() : "code";
4414
+ let script = "";
4415
+ if (mode === "standard") {
4416
+ if (typeof jump.standard_condition === "string" && jump.standard_condition.trim()) {
4417
+ script = jump.standard_condition.trim();
4418
+ } else {
4419
+ nextErrors.push(`${pathName}.standard_condition is required when condition_mode is standard; condition is ignored by the backend in this mode.`);
4420
+ }
4421
+ } else if (mode === "code") {
4422
+ if (typeof jump.condition === "string" && jump.condition.trim()) {
4423
+ script = jump.condition.trim();
4424
+ } else {
4425
+ nextErrors.push(`${pathName}.condition is required when condition_mode is code or omitted; standard_condition is ignored by the backend in code mode.`);
4426
+ }
4427
+ } else {
4428
+ nextErrors.push(`${pathName}.condition_mode must be code or standard.`);
4429
+ }
4430
+ if (script) {
4431
+ lastJumpScript = script;
4432
+ if (index < jumps.length - 1 && startConditionalJumpScriptIsCatchAll(script)) {
4433
+ nextErrors.push(
4434
+ `${pathName} is a catch-all start route but is not the final item; return true must only appear on the last explicit fallback route.`
4435
+ );
4436
+ }
4437
+ if (startConditionalJumpScriptLooksLikeIndexReturn(script)) {
4438
+ nextErrors.push(
4439
+ `${pathName} must return boolean/truthy for this explicit start edge, not a node-level result index; do not copy node.condational_nodes scripts such as return 0/1/-1 into data.meta.condational_jump.`
4440
+ );
4441
+ }
4442
+ }
4443
+ });
4444
+ }
4445
+ if (Array.isArray(jumps) && jumps.length && nodes.length) {
4446
+ if (!lastJumpResult || !startConditionalJumpScriptIsCatchAll(lastJumpScript)) {
4447
+ nextErrors.push(
4448
+ "data.meta.condational_jump must end with an explicit catch-all route using condition script return true; this documents the default start path instead of relying on implicit fallback."
4449
+ );
4450
+ }
4451
+ }
4452
+ if (!nextErrors.length) {
4453
+ return;
4454
+ }
4455
+ if (errors) {
4456
+ errors.push(...nextErrors);
4457
+ return;
4458
+ }
4459
+ throw new Error(`flow-template start conditional jump gate failed: ${nextErrors.join("; ")}`);
4460
+ }
4461
+ function isFlowTemplateEndpointTarget(value) {
4462
+ return /^-\d+$/.test(value.trim());
4463
+ }
4464
+ function isFlowTemplateSpecialStepTarget(value) {
4465
+ const normalized = value.trim();
4466
+ return normalized === "[source]" || normalized === "anyNode";
4467
+ }
4468
+ function isFlowTemplateBackSourceTarget(value) {
4469
+ return value.trim() === "[source]";
4470
+ }
4471
+ function isFlowTemplateConditionalTarget(value, conditionNames) {
4472
+ const match = value.trim().match(/^(.+)\[condition\]\d+$/);
4473
+ if (!match) {
4474
+ return false;
4475
+ }
4476
+ return conditionNames.has(match[1].trim());
4477
+ }
4478
+ function validateFlowTemplateActionTarget(errors, pathName, target, nodeIds, conditionNames, options = {}) {
4479
+ const normalizedTarget = target.trim();
4480
+ if (!normalizedTarget) {
4481
+ if (options.actionString) {
4482
+ errors.push(`${pathName} target step is required after "|"; use "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID" or "\u6309\u94AE\u6587\u6848|\u6761\u4EF6\u540D[condition]0".`);
4483
+ } else {
4484
+ errors.push(`${pathName} target step is required; use a node id, -1, [source], anyNode, or \u6761\u4EF6\u540D[condition]0.`);
4485
+ }
4486
+ return;
4487
+ }
4488
+ const conditionalTargetAllowed = options.allowConditionalTarget !== false;
4489
+ const specialTargetAllowed = options.allowAnyNode === false ? isFlowTemplateBackSourceTarget(normalizedTarget) : isFlowTemplateSpecialStepTarget(normalizedTarget);
4490
+ if (!nodeIds.has(normalizedTarget) && !isFlowTemplateEndpointTarget(normalizedTarget) && !specialTargetAllowed && !(conditionalTargetAllowed && isFlowTemplateConditionalTarget(normalizedTarget, conditionNames))) {
4491
+ const allowedTargets = conditionalTargetAllowed ? "an existing data.nodes[].id, an endpoint like -1, [source], anyNode, or a condational_nodes reference like \u6761\u4EF6\u540D[condition]0" : options.allowAnyNode === false ? "an existing data.nodes[].id, an endpoint like -1, or [source]" : "an existing data.nodes[].id, an endpoint like -1, [source], or anyNode";
4492
+ errors.push(`${pathName} target (${normalizedTarget}) must be ${allowedTargets}.`);
4493
+ }
4494
+ }
4495
+ function validateFlowTemplateApproveActionShape(value, errors) {
4496
+ const nextErrors = [];
4497
+ const data = isRecord3(value.data) ? value.data : {};
4498
+ const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
4499
+ const nodeIds = new Set(nodes.map((node) => String(node.id ?? "").trim()).filter(Boolean));
4500
+ nodes.forEach((node, nodeIndex) => {
4501
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
4502
+ const conditionNames = /* @__PURE__ */ new Set();
4503
+ if (node.condational_nodes !== void 0 && node.condational_nodes !== null && node.condational_nodes !== "" && !Array.isArray(node.condational_nodes)) {
4504
+ nextErrors.push(`${nodeName}.condational_nodes must be an array of condition route objects.`);
4505
+ }
4506
+ const conditionalNodes = Array.isArray(node.condational_nodes) ? node.condational_nodes : [];
4507
+ conditionalNodes.forEach((conditionNode, conditionIndex) => {
4508
+ const conditionPath = `${nodeName}.condational_nodes[${conditionIndex}]`;
4509
+ if (!isRecord3(conditionNode)) {
4510
+ nextErrors.push(`${conditionPath} must be an object with name, result, condition_mode, and an index-returning condition script.`);
4511
+ return;
4512
+ }
4513
+ const conditionName = typeof conditionNode.name === "string" ? conditionNode.name.trim() : "";
4514
+ if (conditionName) {
4515
+ conditionNames.add(conditionName);
4516
+ } else {
4517
+ nextErrors.push(`${conditionPath}.name is required so approve_to_step/approve_actions can reference this condational_nodes entry.`);
4518
+ }
4519
+ const conditionMode = typeof conditionNode.condition_mode === "string" && conditionNode.condition_mode.trim() ? conditionNode.condition_mode.trim() : "code";
4520
+ if (conditionMode === "standard") {
4521
+ if (typeof conditionNode.standard_condition !== "string" || !conditionNode.standard_condition.trim()) {
4522
+ nextErrors.push(`${conditionPath}.standard_condition is required when condition_mode is standard; condition is ignored by the backend in this mode.`);
4523
+ }
4524
+ } else if (conditionMode === "code") {
4525
+ if (typeof conditionNode.condition !== "string" || !conditionNode.condition.trim()) {
4526
+ nextErrors.push(`${conditionPath}.condition is required when condition_mode is code or omitted; standard_condition is ignored by the backend in code mode.`);
4527
+ }
4528
+ } else {
4529
+ nextErrors.push(`${conditionPath}.condition_mode must be code or standard.`);
4530
+ }
4531
+ const conditionResult = conditionNode.result;
4532
+ const resultPath = `${conditionPath}.result`;
4533
+ if (!Array.isArray(conditionResult) || !conditionResult.length) {
4534
+ nextErrors.push(`${resultPath} must be a non-empty array of target node ids.`);
4535
+ return;
4536
+ }
4537
+ conditionResult.forEach((target, targetIndex) => {
4538
+ const targetPath = `${resultPath}[${targetIndex}]`;
4539
+ if (Array.isArray(target) || isRecord3(target) || target === void 0 || target === null) {
4540
+ nextErrors.push(`${targetPath} must be a target node id, endpoint like -1, or [source].`);
4541
+ return;
4542
+ }
4543
+ validateFlowTemplateActionTarget(
4544
+ nextErrors,
4545
+ targetPath,
4546
+ String(target),
4547
+ nodeIds,
4548
+ conditionNames,
4549
+ { allowConditionalTarget: false, allowAnyNode: false }
4550
+ );
4551
+ });
4552
+ });
4553
+ [
4554
+ ["approve_to_step", node.approve_to_step],
4555
+ ["approve_fail", node.approve_fail]
4556
+ ].forEach(([fieldName, fieldValue]) => {
4557
+ if (fieldValue === void 0 || fieldValue === null || fieldValue === "") {
4558
+ return;
4559
+ }
4560
+ if (Array.isArray(fieldValue) || isRecord3(fieldValue)) {
4561
+ nextErrors.push(`${nodeName}.${fieldName} must be a target node id, endpoint like -1, [source], anyNode, or \u6761\u4EF6\u540D[condition]0.`);
4562
+ return;
4563
+ }
4564
+ validateFlowTemplateActionTarget(nextErrors, `${nodeName}.${fieldName}`, String(fieldValue), nodeIds, conditionNames);
4565
+ });
4566
+ const actionGroups = [
4567
+ ["approve_actions", node.approve_actions],
4568
+ ["approve_fail_actions", node.approve_fail_actions]
4569
+ ];
4570
+ actionGroups.forEach(([fieldName, fieldValue]) => {
4571
+ if (fieldValue === void 0 || fieldValue === null || fieldValue === "") {
4572
+ return;
4573
+ }
4574
+ const pathPrefix = `${nodeName}.${fieldName}`;
4575
+ if (!Array.isArray(fieldValue)) {
4576
+ nextErrors.push(`${pathPrefix} must be an array of action strings.`);
4577
+ return;
4578
+ }
4579
+ fieldValue.forEach((action, actionIndex) => {
4580
+ const pathName = `${pathPrefix}[${actionIndex}]`;
4581
+ if (typeof action !== "string") {
4582
+ nextErrors.push(`${pathName} must be a string action in "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID" format.`);
4583
+ return;
4584
+ }
4585
+ const parts = action.split("|");
4586
+ if (parts.length < 2) {
4587
+ const raw = action.trim();
4588
+ if (raw && (nodeIds.has(raw) || isFlowTemplateEndpointTarget(raw) || isFlowTemplateSpecialStepTarget(raw) || isFlowTemplateConditionalTarget(raw, conditionNames))) {
4589
+ nextErrors.push(`${pathName} is a bare target (${raw}); action strings must be "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID", not just a node id.`);
4590
+ } else {
4591
+ nextErrors.push(`${pathName} must contain "|" and use "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID" or "\u6309\u94AE\u6587\u6848|\u6761\u4EF6\u540D[condition]0".`);
4592
+ }
4593
+ return;
4594
+ }
4595
+ const label = parts[0].trim();
4596
+ const target = parts[1].trim();
4597
+ if (!label) {
4598
+ nextErrors.push(`${pathName} label is required before "|".`);
4599
+ }
4600
+ validateFlowTemplateActionTarget(nextErrors, pathName, target, nodeIds, conditionNames, { actionString: true });
4601
+ });
4602
+ });
4603
+ });
4604
+ if (!nextErrors.length) {
4605
+ return;
4606
+ }
4607
+ if (errors) {
4608
+ errors.push(...nextErrors);
4609
+ return;
4610
+ }
4611
+ throw new Error(`flow-template approve action gate failed: ${nextErrors.join("; ")}`);
4612
+ }
4263
4613
  function looksLikeParseEvalFunctionBody(script) {
4264
4614
  const text5 = script.trim();
4265
4615
  if (!text5) {
@@ -4934,6 +5284,8 @@ function normalizeFlowTemplatePayload(work) {
4934
5284
  validateFlowTemplateRemoteTemplateRefs({ ...work, data });
4935
5285
  validateFlowTemplateProjectAfterCreatePath({ ...work, data });
4936
5286
  validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
5287
+ validateFlowTemplateStartConditionalJump({ ...work, data });
5288
+ validateFlowTemplateApproveActionShape({ ...work, data });
4937
5289
  validateFlowTemplateCodeModeMessages({ ...work, data });
4938
5290
  validateFlowTemplateRuntimeScripts({ ...work, data });
4939
5291
  validateFlowTemplateFeishuChatPlugin({ ...work, data });
@@ -5022,13 +5374,108 @@ function normalizeDatasetPayload(work) {
5022
5374
  }
5023
5375
  return payload;
5024
5376
  }
5377
+ function firstNonEmpty(...values) {
5378
+ for (const value of values) {
5379
+ if (value === null || value === void 0) {
5380
+ continue;
5381
+ }
5382
+ const text5 = String(value).trim();
5383
+ if (text5 !== "") {
5384
+ return text5;
5385
+ }
5386
+ }
5387
+ return "";
5388
+ }
5389
+ function exactConfirmOrDryRun(confirm3, expectedConfirm, options = {}) {
5390
+ if (confirm3 === void 0 || confirm3 === "") {
5391
+ return false;
5392
+ }
5393
+ const accepted = [expectedConfirm, ...options.equivalentConfirms || []];
5394
+ if (accepted.includes(confirm3)) {
5395
+ return true;
5396
+ }
5397
+ throw new Error(`confirmation text mismatch. expected: ${expectedConfirm}. actual: ${confirm3}.`);
5398
+ }
5399
+ function configReadbackHint(domain, id) {
5400
+ if (id === void 0 || id === null || id === "") {
5401
+ return null;
5402
+ }
5403
+ const value = String(id);
5404
+ return {
5405
+ command: `bpmax-cli config ${domain} export --id ${value} --inline --format json`,
5406
+ unified_command: `bpmax-cli config readback ${domain} --id ${value} --format json`
5407
+ };
5408
+ }
5409
+ function configResponseKey(domain, payload, response, readback) {
5410
+ if (isRecord3(response)) {
5411
+ const key = response.key ?? response.field ?? response.custom_key;
5412
+ if (key !== void 0) return key;
5413
+ if (isRecord3(response.data)) {
5414
+ const nested = response.data.key ?? response.data.field ?? response.data.custom_key;
5415
+ if (nested !== void 0) return nested;
5416
+ }
5417
+ }
5418
+ if (isRecord3(readback)) {
5419
+ const key = readback.key ?? readback.field ?? readback.custom_key;
5420
+ if (key !== void 0) return key;
5421
+ }
5422
+ if (isRecord3(payload)) {
5423
+ if (domain === "dataset") return payload.custom_key ?? payload.customKey ?? null;
5424
+ return payload.key ?? payload.field ?? null;
5425
+ }
5426
+ return null;
5427
+ }
5428
+ function standardConfigWriteResponse(input) {
5429
+ const resolvedId = input.executedId ?? input.id;
5430
+ return {
5431
+ id: resolvedId,
5432
+ request_id: input.id,
5433
+ key: configResponseKey(input.domain, input.payload, input.response, input.readback),
5434
+ readback_hint: configReadbackHint(input.domain, resolvedId)
5435
+ };
5436
+ }
5437
+ function dryRunFields(expectedConfirm) {
5438
+ return {
5439
+ ok: true,
5440
+ dry_run: true,
5441
+ operation_executed: false,
5442
+ confirm_required: true,
5443
+ required_confirm: expectedConfirm,
5444
+ expected_confirm: expectedConfirm
5445
+ };
5446
+ }
5447
+ function executedFields() {
5448
+ return {
5449
+ ok: true,
5450
+ dry_run: false,
5451
+ operation_executed: true,
5452
+ confirm_required: false
5453
+ };
5454
+ }
5455
+ function validateDatasetFieldCreatePayload(payload) {
5456
+ if (!isRecord3(payload)) {
5457
+ throw new Error("dataset-field create requires an object payload.");
5458
+ }
5459
+ const missingSource = [
5460
+ ["payload.flow_type", payload.flow_type],
5461
+ ["payload.data_set_id", payload.data_set_id],
5462
+ ["payload.source_table", payload.source_table],
5463
+ ["payload.source_field", payload.source_field],
5464
+ ["payload.source_fk", payload.source_fk]
5465
+ ].filter(([, value]) => typeof value !== "string" || value.trim() === "");
5466
+ if (missingSource.length > 0) {
5467
+ throw new Error(`dataset-field create requires dataset and source mapping fields: ${missingSource.map(([key]) => key).join(", ")}.`);
5468
+ }
5469
+ }
5025
5470
  function normalizeDatasetFieldPayload(work) {
5026
5471
  const mode = work.mode;
5027
5472
  if (mode !== void 0 && mode !== "edit" && mode !== "create") {
5028
5473
  throw new Error("dataset-field typed adapter supports mode edit or create. Delete requires a dedicated adapter.");
5029
5474
  }
5030
5475
  const source = isRecord3(work.source) ? work.source : work;
5476
+ const sourcePayload = isRecord3(work.x_wewf_source_payload) ? work.x_wewf_source_payload : {};
5031
5477
  const payload = {
5478
+ data_set_id: firstNonEmpty(work.data_set_id, work.dataSetId, work.dataset_id, sourcePayload.data_set_id, sourcePayload.dataSetId, sourcePayload.dataset_id),
5032
5479
  name: work.name || "",
5033
5480
  key: work.key || work.field || "",
5034
5481
  type: work.type || "",
@@ -5056,14 +5503,7 @@ function normalizeDatasetFieldPayload(work) {
5056
5503
  payload.sourceField = payload.source_field;
5057
5504
  payload.sourceFk = payload.source_fk;
5058
5505
  if (mode === "create") {
5059
- const missingSource = [
5060
- ["source_table", payload.source_table],
5061
- ["source_field", payload.source_field],
5062
- ["source_fk", payload.source_fk]
5063
- ].filter(([, value]) => typeof value !== "string" || value.trim() === "");
5064
- if (missingSource.length > 0) {
5065
- throw new Error(`dataset-field create requires source mapping fields: ${missingSource.map(([key]) => key).join(", ")}.`);
5066
- }
5506
+ validateDatasetFieldCreatePayload(payload);
5067
5507
  }
5068
5508
  const advanced = isRecord3(work.advanced) ? work.advanced : {};
5069
5509
  if (Object.prototype.hasOwnProperty.call(advanced, "sourceComputed")) {
@@ -5438,6 +5878,118 @@ function validateFormTemplateValueValidateMaps(payload, errors) {
5438
5878
  }
5439
5879
  }
5440
5880
  }
5881
+ var FORM_TEMPLATE_VISUAL_WIDE_TYPES = /* @__PURE__ */ new Set([
5882
+ "sub_form",
5883
+ "i_textarea",
5884
+ "textarea",
5885
+ "rich_text",
5886
+ "editor",
5887
+ "upload",
5888
+ "file",
5889
+ "image",
5890
+ "images",
5891
+ "raw"
5892
+ ]);
5893
+ function shouldRunFormTemplateVisualLint(payload) {
5894
+ const lintHints = isRecord3(payload.lintHints) ? payload.lintHints : {};
5895
+ const visualReview = isRecord3(lintHints.visualReview) ? lintHints.visualReview : {};
5896
+ return visualReview.enabled === true || visualReview.required === true || payload.mode === "visual_review";
5897
+ }
5898
+ function formTemplateVisualReviewHints(payload) {
5899
+ const lintHints = isRecord3(payload.lintHints) ? payload.lintHints : {};
5900
+ return isRecord3(lintHints.visualReview) ? lintHints.visualReview : {};
5901
+ }
5902
+ function numericHint(value, fallback) {
5903
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
5904
+ }
5905
+ function formTemplateRuleTitle(rule, value) {
5906
+ const title = rule.title ?? value?.title ?? rule.label ?? value?.label;
5907
+ return typeof title === "string" ? title.trim() : "";
5908
+ }
5909
+ function formTemplateRuleWidth(rule) {
5910
+ const props = isRecord3(rule.props) ? rule.props : {};
5911
+ const candidates = [
5912
+ rule.span,
5913
+ rule.colSpan,
5914
+ rule.width,
5915
+ props.span,
5916
+ props.colSpan,
5917
+ props.width
5918
+ ];
5919
+ for (const candidate of candidates) {
5920
+ if (typeof candidate === "number" && Number.isFinite(candidate) && candidate > 0) {
5921
+ return candidate;
5922
+ }
5923
+ if (typeof candidate === "string" && /^\d+$/.test(candidate.trim())) {
5924
+ return Number(candidate.trim());
5925
+ }
5926
+ }
5927
+ return void 0;
5928
+ }
5929
+ function validateStructuredFormTemplateVisualReview(payload, errors) {
5930
+ if (!shouldRunFormTemplateVisualLint(payload)) {
5931
+ return;
5932
+ }
5933
+ const hints = formTemplateVisualReviewHints(payload);
5934
+ if (hints.confirmedNonBehavioralProps !== true) {
5935
+ errors.push(
5936
+ "form-template visual lint requires lintHints.visualReview.confirmedNonBehavioralProps=true after confirming the diff only changes layout, label/control width, spacing, or other non-behavioral display props."
5937
+ );
5938
+ }
5939
+ if (!Array.isArray(payload.layout) || !isRecord3(payload.fields)) {
5940
+ errors.push("form-template visual lint requires structured work with layout and fields.");
5941
+ return;
5942
+ }
5943
+ const maxColumnsPerRow = Math.floor(numericHint(hints.maxColumnsPerRow, 2));
5944
+ const maxRowTitleChars = Math.floor(numericHint(hints.maxRowTitleChars, 24));
5945
+ const maxTitleCharsInMultiColumn = Math.floor(numericHint(hints.maxTitleCharsInMultiColumn, 12));
5946
+ for (const [rowIndex, row] of payload.layout.entries()) {
5947
+ if (!Array.isArray(row)) {
5948
+ errors.push(`form-template visual lint layout row ${rowIndex} must be an array.`);
5949
+ continue;
5950
+ }
5951
+ if (!row.length) {
5952
+ errors.push(`form-template visual lint layout row ${rowIndex} is empty; remove empty visual rows before submit.`);
5953
+ continue;
5954
+ }
5955
+ if (row.length > maxColumnsPerRow) {
5956
+ errors.push(`form-template visual lint layout row ${rowIndex} has ${row.length} fields; maxColumnsPerRow=${maxColumnsPerRow} for readable desktop data entry.`);
5957
+ }
5958
+ let rowTitleChars = 0;
5959
+ for (const ref of row) {
5960
+ if (typeof ref !== "string" || !ref) {
5961
+ continue;
5962
+ }
5963
+ const bundle = payload.fields[ref];
5964
+ if (!isRecord3(bundle) || !isRecord3(bundle.rule)) {
5965
+ continue;
5966
+ }
5967
+ const value = isRecord3(bundle.value) ? bundle.value : void 0;
5968
+ const rule = bundle.rule;
5969
+ const title = formTemplateRuleTitle(rule, value);
5970
+ rowTitleChars += title.length;
5971
+ const type = typeof rule.type === "string" ? rule.type : typeof value?.field_type === "string" ? value.field_type : "";
5972
+ if (row.length > 1 && FORM_TEMPLATE_VISUAL_WIDE_TYPES.has(type)) {
5973
+ errors.push(`form-template visual lint field ${ref} (${title || type}) type=${type} must be in a single-field row for readable editing.`);
5974
+ }
5975
+ if (row.length > 1 && title.length > maxTitleCharsInMultiColumn) {
5976
+ errors.push(`form-template visual lint field ${ref} title is too long for a multi-column row (${title.length} > ${maxTitleCharsInMultiColumn}); move it to a single row or shorten the visible label.`);
5977
+ }
5978
+ const width = formTemplateRuleWidth(rule);
5979
+ if (row.length > 1 && typeof width === "number" && width > 12) {
5980
+ errors.push(`form-template visual lint field ${ref} declares width/span=${width} inside a multi-column row; wide controls must be single-row or use <=12 grid width.`);
5981
+ }
5982
+ }
5983
+ if (row.length > 1 && rowTitleChars > maxRowTitleChars) {
5984
+ errors.push(`form-template visual lint layout row ${rowIndex} title length total is ${rowTitleChars}; maxRowTitleChars=${maxRowTitleChars}. Split the row for readability.`);
5985
+ }
5986
+ }
5987
+ }
5988
+ function validateFormTemplateWorkLint(payload, errors) {
5989
+ validateFormTemplateNameLength(payload, errors);
5990
+ validateFormTemplateValueValidateMaps(payload, errors);
5991
+ validateStructuredFormTemplateVisualReview(payload, errors);
5992
+ }
5441
5993
  function stripFormTemplateCreateIds(payload) {
5442
5994
  const next = { ...payload };
5443
5995
  if (Array.isArray(next.rule)) {
@@ -6609,6 +7161,8 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
6609
7161
  validateFlowTemplateRemoteTemplateRefs(work);
6610
7162
  validateFlowTemplateProjectAfterCreatePath(work);
6611
7163
  validateFlowTemplateStandardPageCreateFormTemplate(work);
7164
+ validateFlowTemplateStartConditionalJump(work);
7165
+ validateFlowTemplateApproveActionShape(work);
6612
7166
  validateFlowTemplateCodeModeMessages(work);
6613
7167
  validateFlowTemplateRuntimeScripts(work);
6614
7168
  validateFlowTemplateFeishuChatPlugin(work);
@@ -6745,6 +7299,7 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
6745
7299
  }
6746
7300
  };
6747
7301
  const expectedConfirm = `create flow-app ${name} in ${workspace}`;
7302
+ const acceptedConfirmWithWorkspacePrefix = `create flow-app ${name} in w:${workspace}`;
6748
7303
  const dryRunPlan = {
6749
7304
  operations: [
6750
7305
  { step: "create_form_template", method: "POST", path: "/form_template", payload: formPayload },
@@ -6756,9 +7311,10 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
6756
7311
  { step: "verify_workspace_binding", method: "GET", path: "/workspace/by_key", params: { key: workspace } }
6757
7312
  ]
6758
7313
  };
6759
- if (confirm3 !== expectedConfirm) {
7314
+ if (!exactConfirmOrDryRun(confirm3, expectedConfirm, { equivalentConfirms: [acceptedConfirmWithWorkspacePrefix] })) {
6760
7315
  return {
6761
- dry_run: true,
7316
+ ...dryRunFields(expectedConfirm),
7317
+ accepted_confirms: [expectedConfirm, acceptedConfirmWithWorkspacePrefix],
6762
7318
  domain: "flow-app",
6763
7319
  workspace,
6764
7320
  name,
@@ -6849,9 +7405,22 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
6849
7405
  "/workspace/by_key",
6850
7406
  { params: { key: workspace }, capability: `${workspaceDefinition.capability}.export` }
6851
7407
  );
7408
+ const workspaceBaseHash = hashJson(workspaceInfo);
6852
7409
  const existingBindings = isRecord3(workspaceInfo) ? normalizeWorkspaceFlowItems(workspaceInfo.workspace_flow) : [];
6853
7410
  const bindingKey = buildWorkspaceFlowBindingKey(flowType, "");
6854
7411
  const nextBindings = existingBindings.some((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key) === bindingKey) ? existingBindings : [...existingBindings, { flow_type: flowType, flow_key: "", only_in_workspace: 0 }];
7412
+ const workspaceGuardReadback = await apiRequest(
7413
+ client,
7414
+ "GET",
7415
+ "/workspace/by_key",
7416
+ { params: { key: workspace }, capability: `${workspaceDefinition.capability}.export` }
7417
+ );
7418
+ const workspaceGuardHash = hashJson(workspaceGuardReadback);
7419
+ if (workspaceGuardHash !== workspaceBaseHash) {
7420
+ throw new Error(
7421
+ `flow-app create workspace-flow baseline changed for ${workspace}. Re-run flow-app context or workspace-flow export, merge the latest bindings, and retry to avoid dropping concurrent workspace bindings.`
7422
+ );
7423
+ }
6855
7424
  const workspaceBindResponse = await apiRequest(
6856
7425
  client,
6857
7426
  "PUT",
@@ -6869,21 +7438,48 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
6869
7438
  if (!readbackBindings.some((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key) === bindingKey)) {
6870
7439
  throw new Error(`flow-app create workspace binding verification failed for ${workspace} ${bindingKey}.`);
6871
7440
  }
7441
+ const flowTemplateId = isRecord3(flowCreateResponse) ? isRecord3(flowCreateResponse.data) ? flowCreateResponse.data.id : flowCreateResponse.id : null;
7442
+ const evidence = {
7443
+ flow_type: flowType,
7444
+ flow_key: "",
7445
+ flow_template_id: flowTemplateId ?? flowType,
7446
+ form_template_id: publishedFormId,
7447
+ form_template_draft_id: draftFormId,
7448
+ workspace_key: workspace,
7449
+ workspace_binding_found: true,
7450
+ workspace_readback_hash: hashJson(workspaceReadback),
7451
+ evidence_status: "verified",
7452
+ verified_at: (/* @__PURE__ */ new Date()).toISOString()
7453
+ };
6872
7454
  return {
6873
- dry_run: false,
7455
+ ...executedFields(),
6874
7456
  domain: "flow-app",
6875
7457
  workspace,
6876
7458
  name,
7459
+ created_ids: {
7460
+ draft_form_id: draftFormId,
7461
+ published_form_id: publishedFormId,
7462
+ form_template_id: publishedFormId,
7463
+ form_template_draft_id: draftFormId,
7464
+ flow_type: flowType,
7465
+ flow_template_id: flowTemplateId ?? flowType,
7466
+ workspace
7467
+ },
6877
7468
  draft_form_id: draftFormId,
6878
7469
  published_form_id: publishedFormId,
7470
+ form_template_id: publishedFormId,
7471
+ form_template_draft_id: draftFormId,
6879
7472
  flow_type: flowType,
7473
+ flow_key: "",
7474
+ flow_template_id: flowTemplateId ?? flowType,
6880
7475
  form_response: formResponse,
6881
7476
  form_publish_response: formPublishResponse,
6882
7477
  flow_create_response: flowCreateResponse,
6883
7478
  flow_draft_response: flowDraftResponse,
6884
7479
  ...liveEndpoint ? { flow_live_response: flowLiveResponse, live_endpoint: liveEndpoint } : {},
6885
7480
  workspace_bind_response: workspaceBindResponse,
6886
- workspace_readback_hash: hashJson(workspaceReadback)
7481
+ workspace_readback_hash: hashJson(workspaceReadback),
7482
+ evidence
6887
7483
  };
6888
7484
  } catch (error) {
6889
7485
  const message = error instanceof Error ? error.message : String(error || "");
@@ -6900,6 +7496,115 @@ async function readBackConfigDomain(profile, domain, id, definition) {
6900
7496
  readback_hash: hashJson(data)
6901
7497
  };
6902
7498
  }
7499
+ async function readbackConfigDomain(config, profile, domain, id) {
7500
+ void config;
7501
+ const definition = CONFIG_DOMAINS[domain];
7502
+ if (!definition) {
7503
+ throw new Error(`Unknown config domain: ${domain}`);
7504
+ }
7505
+ const data = await readRemoteConfigDomain(profile, domain, id, definition);
7506
+ validateExpectedType(domain, definition, data);
7507
+ return {
7508
+ domain,
7509
+ id,
7510
+ readback_hash: hashJson(data),
7511
+ source_api: definition.exportPath ? `GET /api${definition.exportPath(id)}` : null,
7512
+ verified_at: (/* @__PURE__ */ new Date()).toISOString(),
7513
+ readback: data
7514
+ };
7515
+ }
7516
+ async function resolveFlowAppContextFlowId(profile, flow) {
7517
+ const trimmed = flow.trim();
7518
+ if (!trimmed) {
7519
+ throw new Error("flow-app context requires --flow <flow_type|flow_type:key|key:<key>|name>.");
7520
+ }
7521
+ if (/^flow\d+$/.test(trimmed) || trimmed.startsWith("flow_type:") || trimmed.startsWith("key:") || trimmed.includes("|") || trimmed.includes(":")) {
7522
+ return { id: trimmed, resolvedBy: "flow_id" };
7523
+ }
7524
+ const client = createApiClient(profile);
7525
+ const options = await apiRequest(client, "GET", "/flow/options", { capability: "flow.options" });
7526
+ const rows = extractListData(options);
7527
+ const matches = rows.filter((item) => String(item.name || item.title || "").trim() === trimmed);
7528
+ if (matches.length !== 1) {
7529
+ throw new Error(
7530
+ `flow-app context could not resolve flow name "${trimmed}" (${matches.length} matches). Use --flow flow_type:<flow_type>, --flow key:<flow_key>, or run bpmax-cli flow options --name "<name>" --format json first.`
7531
+ );
7532
+ }
7533
+ const match = matches[0];
7534
+ const flowType = firstNonEmpty(match.flow_type, match.flowType);
7535
+ const flowKey = firstNonEmpty(match.key, match.flow_key, match.flowKey);
7536
+ if (flowKey && flowType) {
7537
+ return { id: `${flowType}:${flowKey}`, resolvedBy: "flow_options_name" };
7538
+ }
7539
+ if (flowKey) {
7540
+ return { id: `key:${flowKey}`, resolvedBy: "flow_options_name" };
7541
+ }
7542
+ if (flowType) {
7543
+ return { id: flowType, resolvedBy: "flow_options_name" };
7544
+ }
7545
+ throw new Error(`flow-app context resolved flow name "${trimmed}" but the option row did not include flow_type or key.`);
7546
+ }
7547
+ async function inspectFlowAppContext(config, profile, options) {
7548
+ void config;
7549
+ const flowDefinition = CONFIG_DOMAINS["flow-template"];
7550
+ const formDefinition = CONFIG_DOMAINS["form-template"];
7551
+ const workspaceDefinition = CONFIG_DOMAINS["workspace-flow"];
7552
+ await ensureConfigCapability(profile, `${flowDefinition.capability}.export`);
7553
+ await ensureConfigCapability(profile, `${formDefinition.capability}.export`);
7554
+ await ensureConfigCapability(profile, `${workspaceDefinition.capability}.export`);
7555
+ const workspace = normalizeWorkspaceKey(options.workspace || profile.config.workspace);
7556
+ if (!workspace) {
7557
+ throw new Error("flow-app context requires --workspace <workspace>.");
7558
+ }
7559
+ const resolvedFlow = await resolveFlowAppContextFlowId(profile, options.flow);
7560
+ const flowReadback = await readRemoteConfigDomain(profile, "flow-template", resolvedFlow.id, flowDefinition);
7561
+ const flow = isRecord3(flowReadback) ? flowReadback : {};
7562
+ const data = isRecord3(flow.data) ? flow.data : {};
7563
+ const meta = isRecord3(data.meta) ? data.meta : {};
7564
+ const formTemplateId = firstNonEmpty(meta.form_template, meta.formTemplate, flow.meta_form_id, flow.metaFormId);
7565
+ let formReadback = null;
7566
+ let formTemplateDraftId = null;
7567
+ if (formTemplateId) {
7568
+ formReadback = await readRemoteConfigDomain(profile, "form-template", String(formTemplateId), formDefinition);
7569
+ if (isRecord3(formReadback)) {
7570
+ const originTemplateId = formReadback.origin_template_id ?? formReadback.originTemplateId;
7571
+ formTemplateDraftId = originTemplateId && String(originTemplateId) !== "0" ? originTemplateId : formReadback.id ?? formTemplateId;
7572
+ }
7573
+ }
7574
+ const workspaceReadback = await readRemoteConfigDomain(profile, "workspace-flow", workspace, workspaceDefinition);
7575
+ const bindings = isRecord3(workspaceReadback) ? normalizeWorkspaceFlowItems(workspaceReadback.workspace_flow) : [];
7576
+ const parsedIdentity = parseFlowIdentity(resolvedFlow.id);
7577
+ const flowType = firstNonEmpty(flow.flow_type, parsedIdentity.flowType);
7578
+ const flowKey = firstNonEmpty(flow.key, parsedIdentity.flowKey);
7579
+ const bindingFound = bindings.some((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key) === buildWorkspaceFlowBindingKey(flowType, flowKey));
7580
+ const evidence = flowAppContextEvidence({
7581
+ workspace,
7582
+ flow,
7583
+ flowId: resolvedFlow.id,
7584
+ formTemplateId: formTemplateId || null,
7585
+ formTemplateDraftId,
7586
+ formReadback,
7587
+ workspaceReadback,
7588
+ bindingFound,
7589
+ resolvedBy: resolvedFlow.resolvedBy
7590
+ });
7591
+ return {
7592
+ domain: "flow-app",
7593
+ workspace,
7594
+ flow: options.flow,
7595
+ target_context: evidence,
7596
+ evidence,
7597
+ source: {
7598
+ flow: flowExportPath(resolvedFlow.id),
7599
+ form_template: formTemplateId ? `/form_template/${formTemplateId}` : null,
7600
+ workspace: workspaceDefinition.exportPath ? workspaceDefinition.exportPath(workspace) : null
7601
+ },
7602
+ recommended_next_commands: evidence.missing_context.length ? [
7603
+ "If form_template_id is missing, inspect the flow data.meta.form_template and publish the form binding first.",
7604
+ "If workspace_binding is missing, rebuild workspace-flow from fresh export and submit the merged binding."
7605
+ ] : []
7606
+ };
7607
+ }
6903
7608
  function comparableSubmitPayload(domain, value, options) {
6904
7609
  const comparable2 = domain === "form-template" && options.ignoreServerFields ? stripServerFilledFields(value, FORM_TEMPLATE_SERVER_FIELD_KEYS) : value;
6905
7610
  return buildDomainSubmitPayload(domain, comparable2);
@@ -7261,7 +7966,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
7261
7966
  }
7262
7967
  if (domain === "form-template" && isRecord3(work)) {
7263
7968
  const errors = [];
7264
- validateFormTemplateValueValidateMaps(work, errors);
7969
+ validateFormTemplateWorkLint(work, errors);
7265
7970
  if (errors.length) {
7266
7971
  throw new Error(`form-template lint failed: ${errors.join("; ")}`);
7267
7972
  }
@@ -7340,8 +8045,7 @@ async function lintConfigWorkFile(file, options = {}) {
7340
8045
  }
7341
8046
  const shouldLintFormTemplate = options.domain ? options.domain === "form-template" : looksLikeFormTemplateWork(value);
7342
8047
  if (shouldLintFormTemplate) {
7343
- validateFormTemplateNameLength(value, errors);
7344
- validateFormTemplateValueValidateMaps(value, errors);
8048
+ validateFormTemplateWorkLint(value, errors);
7345
8049
  }
7346
8050
  if ((Object.prototype.hasOwnProperty.call(value, "content") || isRecord3(value.basic)) && pageTemplateType(value) === 1) {
7347
8051
  validateListTemplateActionGate(value, errors);
@@ -7354,6 +8058,8 @@ async function lintConfigWorkFile(file, options = {}) {
7354
8058
  validateFlowTemplateRemoteTemplateRefs(flowWork, errors);
7355
8059
  validateFlowTemplateProjectAfterCreatePath(flowWork, errors);
7356
8060
  validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
8061
+ validateFlowTemplateStartConditionalJump(flowWork, errors);
8062
+ validateFlowTemplateApproveActionShape(flowWork, errors);
7357
8063
  validateFlowTemplateCodeModeMessages(flowWork, errors);
7358
8064
  validateFlowTemplateRuntimeScripts(flowWork, errors);
7359
8065
  validateFlowTemplateFeishuChatPlugin(flowWork, errors);
@@ -7425,7 +8131,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7425
8131
  const expectedConfirm2 = `submit ${domain} ${id}`;
7426
8132
  if (confirm3 !== expectedConfirm2) {
7427
8133
  return {
7428
- dry_run: true,
8134
+ ...dryRunFields(expectedConfirm2),
7429
8135
  domain,
7430
8136
  id,
7431
8137
  endpoint: endpoint2,
@@ -7455,7 +8161,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7455
8161
  throw new Error(`workspace-flow submit verification failed; missing bindings: ${missingBindings.map((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key)).join(", ")}`);
7456
8162
  }
7457
8163
  return {
7458
- dry_run: false,
8164
+ ...executedFields(),
7459
8165
  domain,
7460
8166
  id,
7461
8167
  endpoint: endpoint2,
@@ -7493,7 +8199,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7493
8199
  await ensureConfigCapability(profile, `${definition.capability}.export`);
7494
8200
  if (confirm3 !== expectedConfirm2) {
7495
8201
  return {
7496
- dry_run: true,
8202
+ ...dryRunFields(expectedConfirm2),
7497
8203
  domain,
7498
8204
  id,
7499
8205
  endpoint: "/workspace",
@@ -7509,14 +8215,15 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7509
8215
  { data: submit2.payload, capability: `${definition.capability}.create` }
7510
8216
  );
7511
8217
  const readback3 = await readRemoteConfigDomain(profile, domain, `key:${workspaceKey}`, definition);
8218
+ const createdId = responseDataId(response3) ?? (isRecord3(readback3) ? readback3.id ?? null : null);
7512
8219
  return {
7513
- dry_run: false,
8220
+ ...executedFields(),
7514
8221
  domain,
7515
- id,
8222
+ ...standardConfigWriteResponse({ domain, id, executedId: createdId, payload: submit2.payload, response: response3, readback: readback3 }),
7516
8223
  endpoint: "/workspace",
7517
8224
  method: "POST",
7518
8225
  response: response3,
7519
- created_id: responseDataId(response3) ?? (isRecord3(readback3) ? readback3.id ?? null : null),
8226
+ created_id: createdId,
7520
8227
  readback_hash: hashJson(readback3)
7521
8228
  };
7522
8229
  }
@@ -7537,7 +8244,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7537
8244
  const endpoint2 = `/workspace/${encodeURIComponent(workspaceId)}`;
7538
8245
  if (confirm3 !== expectedConfirm2) {
7539
8246
  return {
7540
- dry_run: true,
8247
+ ...dryRunFields(expectedConfirm2),
7541
8248
  domain,
7542
8249
  id,
7543
8250
  endpoint: endpoint2,
@@ -7556,9 +8263,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7556
8263
  );
7557
8264
  const readback2 = await readRemoteConfigDomain(profile, domain, workspaceKey ? `key:${workspaceKey}` : workspaceId, definition);
7558
8265
  return {
7559
- dry_run: false,
8266
+ ...executedFields(),
7560
8267
  domain,
7561
- id,
8268
+ ...standardConfigWriteResponse({ domain, id, payload: submit2.payload, response: response2, readback: readback2 }),
7562
8269
  endpoint: endpoint2,
7563
8270
  method: "PUT",
7564
8271
  response: response2,
@@ -7608,7 +8315,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7608
8315
  }
7609
8316
  if (confirm3 !== expectedConfirm2) {
7610
8317
  return {
7611
- dry_run: true,
8318
+ ...dryRunFields(expectedConfirm2),
7612
8319
  domain,
7613
8320
  id,
7614
8321
  operation_plan: submit2.payload,
@@ -7618,7 +8325,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7618
8325
  };
7619
8326
  }
7620
8327
  return {
7621
- dry_run: false,
8328
+ ...executedFields(),
7622
8329
  domain,
7623
8330
  id,
7624
8331
  ...domain === "role" ? await submitRoleOperations(profile, id, submit2) : await submitAggregateConfigDomain(profile, domain, id, submit2)
@@ -7655,11 +8362,14 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7655
8362
  if (domain === "list-template") {
7656
8363
  validateListTemplateActionGate(submit.payload);
7657
8364
  }
8365
+ if (domain === "dataset-field") {
8366
+ validateDatasetFieldCreatePayload(submit.payload);
8367
+ }
7658
8368
  await ensureConfigCapability(profile, `${definition.capability}.create`);
7659
8369
  const expectedConfirm2 = `submit ${domain} ${id}`;
7660
8370
  if (confirm3 !== expectedConfirm2) {
7661
8371
  return {
7662
- dry_run: true,
8372
+ ...dryRunFields(expectedConfirm2),
7663
8373
  domain,
7664
8374
  id,
7665
8375
  endpoint: definition.createPath,
@@ -7686,9 +8396,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7686
8396
  }
7687
8397
  }
7688
8398
  return {
7689
- dry_run: false,
8399
+ ...executedFields(),
7690
8400
  domain,
7691
- id,
8401
+ ...standardConfigWriteResponse({ domain, id, executedId: createdId ?? null, payload: submit.payload, response: response2 }),
7692
8402
  created_id: createdId ?? null,
7693
8403
  endpoint: definition.createPath,
7694
8404
  method: definition.createMethod,
@@ -7702,6 +8412,8 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7702
8412
  validateFlowTemplateRemoteTemplateRefs(submit.payload);
7703
8413
  validateFlowTemplateProjectAfterCreatePath(submit.payload);
7704
8414
  validateFlowTemplateStandardPageCreateFormTemplate(submit.payload);
8415
+ validateFlowTemplateStartConditionalJump(submit.payload);
8416
+ validateFlowTemplateApproveActionShape(submit.payload);
7705
8417
  validateFlowTemplateCodeModeMessages(submit.payload);
7706
8418
  validateFlowTemplateRuntimeScripts(submit.payload);
7707
8419
  validateFlowTemplateFeishuChatPlugin(submit.payload);
@@ -7725,7 +8437,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7725
8437
  const endpoint2 = "/form_template";
7726
8438
  if (confirm3 !== expectedConfirm2) {
7727
8439
  return {
7728
- dry_run: true,
8440
+ ...dryRunFields(expectedConfirm2),
7729
8441
  domain,
7730
8442
  id,
7731
8443
  endpoint: endpoint2,
@@ -7766,9 +8478,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7766
8478
  { capability: `${definition.capability}.export` }
7767
8479
  );
7768
8480
  return {
7769
- dry_run: false,
8481
+ ...executedFields(),
7770
8482
  domain,
7771
- id,
8483
+ ...standardConfigWriteResponse({ domain, id, executedId: publishedId, payload: submit.payload, response: publishResponse2, readback: publishedReadback }),
7772
8484
  endpoint: endpoint2,
7773
8485
  method: "POST",
7774
8486
  response: response2,
@@ -7810,7 +8522,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7810
8522
  }
7811
8523
  if (confirm3 !== expectedConfirm) {
7812
8524
  return {
7813
- dry_run: true,
8525
+ ...dryRunFields(expectedConfirm),
7814
8526
  domain,
7815
8527
  id,
7816
8528
  endpoint,
@@ -7840,9 +8552,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7840
8552
  }
7841
8553
  const readback = await readBackConfigDomain(profile, domain, id, definition);
7842
8554
  return {
7843
- dry_run: false,
8555
+ ...executedFields(),
7844
8556
  domain,
7845
- id,
8557
+ ...standardConfigWriteResponse({ domain, id, payload: submitPayload, response }),
7846
8558
  endpoint,
7847
8559
  method: definition.submitMethod,
7848
8560
  ...publishMode ? { publish_mode: publishMode } : {},
@@ -7936,7 +8648,7 @@ async function runDatasetLifecycleAction(config, profile, action, id, confirm3)
7936
8648
  ];
7937
8649
  if (confirm3 !== expectedConfirm) {
7938
8650
  return {
7939
- dry_run: true,
8651
+ ...dryRunFields(expectedConfirm),
7940
8652
  domain: "dataset",
7941
8653
  id,
7942
8654
  action: commandAction,
@@ -7962,15 +8674,186 @@ async function runDatasetLifecycleAction(config, profile, action, id, confirm3)
7962
8674
  }
7963
8675
  const readback = await readRemoteConfigDomain(profile, "dataset", id, definition);
7964
8676
  return {
7965
- dry_run: false,
8677
+ ...executedFields(),
7966
8678
  domain: "dataset",
7967
8679
  id,
7968
8680
  action: commandAction,
7969
8681
  operations: executableOperations,
7970
8682
  operation_responses: responses,
8683
+ readback_hash: hashJson(readback),
8684
+ readback_hint: configReadbackHint("dataset", id),
7971
8685
  readback
7972
8686
  };
7973
8687
  }
8688
+ function normalizeConfigBatchItems(manifest) {
8689
+ if (Array.isArray(manifest)) {
8690
+ return manifest.map((raw) => ({ raw, item: isRecord3(raw) ? raw : null }));
8691
+ }
8692
+ if (!isRecord3(manifest)) {
8693
+ throw new Error("config batch manifest must be a JSON object or array.");
8694
+ }
8695
+ const items = manifest.operations ?? manifest.items ?? manifest.rows;
8696
+ if (!Array.isArray(items)) {
8697
+ throw new Error("config batch manifest requires operations, items, or rows array.");
8698
+ }
8699
+ return items.map((raw) => ({ raw, item: isRecord3(raw) ? raw : null }));
8700
+ }
8701
+ function assertBatchItemDomain(domain) {
8702
+ if (typeof domain !== "string" || !Object.prototype.hasOwnProperty.call(CONFIG_DOMAINS, domain)) {
8703
+ throw new Error(`config batch item requires a supported domain, got ${String(domain)}.`);
8704
+ }
8705
+ return domain;
8706
+ }
8707
+ async function writeOptionalBatchResponse(file, value) {
8708
+ if (typeof file !== "string" || !file.trim()) {
8709
+ return null;
8710
+ }
8711
+ await writeJsonFile(file, value);
8712
+ return file;
8713
+ }
8714
+ async function runConfigBatchSubmit(config, profile, manifestFile, options = {}) {
8715
+ const manifest = await readJsonFile(manifestFile);
8716
+ const items = normalizeConfigBatchItems(manifest);
8717
+ const results = [];
8718
+ for (let index = 0; index < items.length; index += 1) {
8719
+ const batchItem = items[index];
8720
+ const item = batchItem.item;
8721
+ if (!item) {
8722
+ const result = {
8723
+ ok: false,
8724
+ index,
8725
+ domain: null,
8726
+ id: "",
8727
+ action: "submit",
8728
+ error: "config batch submit item must be a JSON object."
8729
+ };
8730
+ results.push(result);
8731
+ if (!options.continueOnError) break;
8732
+ continue;
8733
+ }
8734
+ let domain = null;
8735
+ let id = "";
8736
+ try {
8737
+ domain = assertBatchItemDomain(item.domain);
8738
+ id = typeof item.id === "string" ? item.id : "";
8739
+ const payload = typeof item.payload === "string" ? item.payload : "";
8740
+ if (!id || !payload) {
8741
+ throw new Error("config batch submit item requires id and payload.");
8742
+ }
8743
+ const response = await submitConfigDomain(config, profile, domain, id, payload, item.confirm);
8744
+ const executed = !isRecord3(response) || response.operation_executed !== false && response.dry_run !== true;
8745
+ const result = executed ? {
8746
+ ok: true,
8747
+ index,
8748
+ domain,
8749
+ id,
8750
+ action: "submit",
8751
+ response
8752
+ } : {
8753
+ ok: false,
8754
+ index,
8755
+ domain,
8756
+ id,
8757
+ action: "submit",
8758
+ error: `config batch submit item did not execute; confirm_required=${String(isRecord3(response) ? response.required_confirm ?? response.expected_confirm ?? "" : "")}`,
8759
+ response
8760
+ };
8761
+ results.push(result);
8762
+ await writeOptionalBatchResponse(item.response_out, result);
8763
+ if (!result.ok && !options.continueOnError) break;
8764
+ } catch (error) {
8765
+ const result = {
8766
+ ok: false,
8767
+ index,
8768
+ domain,
8769
+ id,
8770
+ action: "submit",
8771
+ error: error instanceof Error ? error.message : String(error || "")
8772
+ };
8773
+ results.push(result);
8774
+ await writeOptionalBatchResponse(item.response_out, result);
8775
+ if (!options.continueOnError) break;
8776
+ }
8777
+ }
8778
+ const failures = results.filter((item) => item.ok === false);
8779
+ return {
8780
+ ok: failures.length === 0,
8781
+ manifest_file: manifestFile,
8782
+ action: "submit",
8783
+ continue_on_error: Boolean(options.continueOnError),
8784
+ total: items.length,
8785
+ completed: results.length,
8786
+ succeeded: results.length - failures.length,
8787
+ failed: failures.length,
8788
+ results
8789
+ };
8790
+ }
8791
+ async function runConfigBatchReadback(config, profile, manifestFile, options = {}) {
8792
+ const manifest = await readJsonFile(manifestFile);
8793
+ const items = normalizeConfigBatchItems(manifest);
8794
+ const results = [];
8795
+ for (let index = 0; index < items.length; index += 1) {
8796
+ const batchItem = items[index];
8797
+ const item = batchItem.item;
8798
+ if (!item) {
8799
+ const result = {
8800
+ ok: false,
8801
+ index,
8802
+ domain: null,
8803
+ id: "",
8804
+ action: "readback",
8805
+ error: "config batch readback item must be a JSON object."
8806
+ };
8807
+ results.push(result);
8808
+ if (!options.continueOnError) break;
8809
+ continue;
8810
+ }
8811
+ let domain = null;
8812
+ let id = "";
8813
+ try {
8814
+ domain = assertBatchItemDomain(item.domain);
8815
+ id = typeof item.id === "string" ? item.id : "";
8816
+ if (!id) {
8817
+ throw new Error("config batch readback item requires id.");
8818
+ }
8819
+ const response = await readbackConfigDomain(config, profile, domain, id);
8820
+ const result = {
8821
+ ok: true,
8822
+ index,
8823
+ domain,
8824
+ id,
8825
+ action: "readback",
8826
+ response
8827
+ };
8828
+ results.push(result);
8829
+ await writeOptionalBatchResponse(item.response_out, result);
8830
+ } catch (error) {
8831
+ const result = {
8832
+ ok: false,
8833
+ index,
8834
+ domain,
8835
+ id,
8836
+ action: "readback",
8837
+ error: error instanceof Error ? error.message : String(error || "")
8838
+ };
8839
+ results.push(result);
8840
+ await writeOptionalBatchResponse(item.response_out, result);
8841
+ if (!options.continueOnError) break;
8842
+ }
8843
+ }
8844
+ const failures = results.filter((item) => item.ok === false);
8845
+ return {
8846
+ ok: failures.length === 0,
8847
+ manifest_file: manifestFile,
8848
+ action: "readback",
8849
+ continue_on_error: Boolean(options.continueOnError),
8850
+ total: items.length,
8851
+ completed: results.length,
8852
+ succeeded: results.length - failures.length,
8853
+ failed: failures.length,
8854
+ results
8855
+ };
8856
+ }
7974
8857
 
7975
8858
  // src/core/config-workspace.ts
7976
8859
  import { mkdir as mkdir6, readFile as readFile9, writeFile as writeFile6 } from "fs/promises";
@@ -8067,6 +8950,7 @@ ${configEnabled ? "" : "> \u5F53\u524D profile \u7684 API Key \u5C1A\u672A\u5F00
8067
8950
  ${directoryRows}
8068
8951
 
8069
8952
  ## \u5F3A\u5236\u89C4\u5219
8953
+ - \u5F53\u524D\u76EE\u5F55\u7ED1\u5B9A Profile\uFF1A\`${display(options.profileName)}\`\u3002\u5728\u5F53\u524D\u76EE\u5F55\u6267\u884C\u7684\u6240\u6709 \`bpmax-cli\` \u547D\u4EE4\u90FD\u5FC5\u987B\u663E\u5F0F\u4F7F\u7528 \`--profile ${profileArg}\`\uFF1B\u4E0D\u5F97\u7701\u7565 profile\u3001\u4E0D\u5F97\u4F9D\u8D56\u5168\u5C40 \`current_profile\`\uFF0C\u4E5F\u4E0D\u5F97\u5207\u6362\u5230\u5176\u5B83\u73AF\u5883/profile\u3002
8070
8954
  - \u914D\u7F6E\u5199\u64CD\u4F5C\u53EA\u80FD\u4F7F\u7528 typed CLI\uFF1A\`${commandPrefix3} config <domain> submit\`\uFF1B\u63D2\u4EF6\u914D\u7F6E\u53EA\u80FD\u4F7F\u7528 \`${commandPrefix3} config plugin <domain> submit\`\u3002
8071
8955
  - \u5982\u679C CLI \u63D0\u793A\u7F3A\u5C11 capability\u3001\u5F53\u524D profile \u672A\u5F00\u542F\u914D\u7F6E\u80FD\u529B\uFF0C\u6216\u672A\u6765\u65B0\u589E domain \u5C1A\u672A\u8FDB\u5165 adapter \u77E9\u9635 / \`config plugin adapters\`\uFF0C\u5FC5\u987B\u505C\u6B62\u8FDC\u7AEF\u5199\u5165\uFF1B\u4E0D\u5F97\u624B\u5199 raw API\u3002
8072
8956
  - \u7981\u6B62\u7528 \`bpmax-cli api\`\u3001curl\u3001\u9875\u9762 fetch\u3001\u9875\u9762 axios \u6216\u65E7 submit \u811A\u672C\u76F4\u63A5\u5199\u914D\u7F6E\u3002
@@ -8086,10 +8970,10 @@ ${rows}
8086
8970
  ## \u6807\u51C6\u95ED\u73AF
8087
8971
  \`\`\`bash
8088
8972
  ${commandPrefix3} config <domain> export --id <id> --profile ${profileArg}
8089
- ${commandPrefix3} config <domain> lint --work <work-file>
8973
+ ${commandPrefix3} config <domain> lint --work <work-file> --profile ${profileArg}
8090
8974
  # build/submit must use typed CLI and an enabled config capability.
8091
8975
  # If capability is missing or the domain is not listed by config adapters, stop before remote writes.
8092
- ${commandPrefix3} config <domain> build --work <work-file> --meta <meta-file> --out <submit-file>
8976
+ ${commandPrefix3} config <domain> build --work <work-file> --meta <meta-file> --out <submit-file> --profile ${profileArg}
8093
8977
  ${commandPrefix3} config <domain> submit --id <id> --payload <submit-file> --profile ${profileArg}
8094
8978
  ${commandPrefix3} config <domain> submit --id <id> --payload <submit-file> --profile ${profileArg} --confirm "submit <domain> <id>"
8095
8979
  ${commandPrefix3} config <domain> verify --id <id> --expect <work-file> --profile ${profileArg}
@@ -9303,6 +10187,45 @@ async function pullLatestConfigEnvironment(env, options) {
9303
10187
 
9304
10188
  // src/commands/config.ts
9305
10189
  var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
10190
+ function csvCell(value) {
10191
+ const text5 = value === null || value === void 0 ? "" : Array.isArray(value) || isRecord5(value) ? JSON.stringify(value) : String(value);
10192
+ return /[",\n\r]/.test(text5) ? `"${text5.replace(/"/g, '""')}"` : text5;
10193
+ }
10194
+ async function writeEvidenceOut(file, value) {
10195
+ if (!file) {
10196
+ return;
10197
+ }
10198
+ await mkdir8(path9.dirname(path9.resolve(file)), { recursive: true });
10199
+ const evidence = isRecord5(value.evidence) ? value.evidence : value;
10200
+ if (file.endsWith(".csv")) {
10201
+ const keys = [
10202
+ "flow_type",
10203
+ "flow_key",
10204
+ "flow_template_id",
10205
+ "form_template_id",
10206
+ "form_template_draft_id",
10207
+ "workspace_key",
10208
+ "workspace_binding_found",
10209
+ "workspace_readback_hash",
10210
+ "evidence_status",
10211
+ "verified_at"
10212
+ ];
10213
+ await writeFile8(file, `${keys.join(",")}
10214
+ ${keys.map((key) => csvCell(evidence[key])).join(",")}
10215
+ `, "utf8");
10216
+ return;
10217
+ }
10218
+ await writeFile8(file, `${JSON.stringify(evidence, null, 2)}
10219
+ `, "utf8");
10220
+ }
10221
+ async function writeResponseOut(file, value) {
10222
+ if (!file) {
10223
+ return;
10224
+ }
10225
+ await mkdir8(path9.dirname(path9.resolve(file)), { recursive: true });
10226
+ await writeFile8(file, `${JSON.stringify(value, null, 2)}
10227
+ `, "utf8");
10228
+ }
9306
10229
  async function resolveFlowTemplatePluginLintOptions(options) {
9307
10230
  const configData = await loadConfig();
9308
10231
  const profileName = options.profile || configData.current_profile || "default";
@@ -9441,9 +10364,16 @@ function registerConfigCommands(program2) {
9441
10364
  user: target.user || null
9442
10365
  });
9443
10366
  });
9444
- config.command("adapters").description("Show typed config domain adapter coverage and verified API surfaces").option("--profile <profile>", "Profile name (accepted for consistency; adapter coverage is local and profile-independent)").option("--format <format>", "Output format", "table").action(async (options) => {
10367
+ config.command("adapters").description("Show typed config domain adapter coverage and verified API surfaces").option("--profile <profile>", "Profile name (accepted for consistency; adapter coverage is local and profile-independent)").option("--capability <capability>", "Filter by capability name, e.g. config.dataset_field.create").option("--format <format>", "Output format", "table").action(async (options) => {
9445
10368
  void options.profile;
9446
- printResult(options.format, configAdapterMatrix());
10369
+ const rows = configAdapterMatrix();
10370
+ const filtered = options.capability ? rows.filter((row) => Object.values(row).some((value) => {
10371
+ if (Array.isArray(value)) {
10372
+ return value.includes(options.capability);
10373
+ }
10374
+ return value === options.capability;
10375
+ })) : rows;
10376
+ printResult(options.format, filtered);
9447
10377
  });
9448
10378
  config.command("plugin").description("Manage plugin-provided typed config adapters").argument("[domain]", "Plugin typed config domain, or adapters").argument("[operation]", "Operation: export, lint, build, diff, submit, verify, test").option("--id <id>", "Remote plugin config id, list/all, or create:<stable-key>").option("--work <file>", "Work JSON file").option("--base <file>", "Optional raw baseline JSON for lifecycle rules").option("--out <file>", "Output file or directory").option("--meta <file>", "Export meta JSON file").option("--submit <file>", "Submit JSON file for diff").option("--payload <file>", "Submit payload JSON file produced by build").option("--expect <file>", "Expected work JSON file").option("--message <message>", "Smoke test message").option("--profile <profile>", "Profile name").option("--agent <agent>", "Agent adapter for installed plugin adapter discovery", "codex").option("--confirm <text>", "Exact confirmation text").option("--format <format>", "Output format", "pretty").action(async (domain, operation, options) => {
9449
10379
  if (domain === "adapters" && !operation) {
@@ -9543,7 +10473,23 @@ function registerConfigCommands(program2) {
9543
10473
  next: `Run git -C ${environment.sysconfig_repo_path} status --short and git diff to inspect local changes.`
9544
10474
  });
9545
10475
  });
9546
- config.command("flow-app").description("Create an end-to-end BPMAX flow app from form and flow work files").command("create").description("Create a form template, create a main flow, bind the published form, and bind the flow to a workspace").requiredOption("--workspace <workspace>", "Target workspace key, e.g. oa or w:oa").requiredOption("--form-work <file>", "Form-template work JSON file").requiredOption("--flow-work <file>", "Flow-template work JSON file").requiredOption("--name <name>", "Flow app name used in the confirmation text").option("--profile <profile>", "Profile name").option("--draft-only", "Save the created flow as draft only instead of publishing live").option("--confirm <text>", "Exact confirmation text").option("--format <format>", "Output format", "pretty").action(async (options) => {
10476
+ const flowApp = config.command("flow-app").description("Inspect or create an end-to-end BPMAX flow app");
10477
+ const registerFlowAppContextCommand = (name) => {
10478
+ flowApp.command(name).description("Collect target flow-app context evidence for migration").requiredOption("--workspace <workspace>", "Target workspace key, e.g. oa or w:oa").requiredOption("--flow <flow>", "Flow identity: flow_type, flow_type:key, key:<key>, or exact flow name").option("--profile <profile>", "Profile name").option("--evidence-out <file>", "Write target context evidence as JSON or CSV").option("--format <format>", "Output format", "json").action(async (options) => {
10479
+ const configData = await loadConfig();
10480
+ const resolved = resolveProfile(configData, options.profile);
10481
+ const result = await inspectFlowAppContext(configData, resolved, {
10482
+ workspace: options.workspace,
10483
+ flow: options.flow
10484
+ });
10485
+ await writeEvidenceOut(options.evidenceOut, result);
10486
+ await saveConfig(configData);
10487
+ printResult(options.format, result);
10488
+ });
10489
+ };
10490
+ registerFlowAppContextCommand("context");
10491
+ registerFlowAppContextCommand("inspect");
10492
+ flowApp.command("create").description("Create a form template, create a main flow, bind the published form, and bind the flow to a workspace").requiredOption("--workspace <workspace>", "Target workspace key, e.g. oa or w:oa").requiredOption("--form-work <file>", "Form-template work JSON file").requiredOption("--flow-work <file>", "Flow-template work JSON file").requiredOption("--name <name>", "Flow app name used in the confirmation text").option("--profile <profile>", "Profile name").option("--draft-only", "Save the created flow as draft only instead of publishing live").option("--confirm <text>", "Exact confirmation text").option("--evidence-out <file>", "Write apply-ready target context evidence as JSON or CSV after create").option("--response-out <file>", "Write the full JSON response to a file").option("--format <format>", "Output format", "pretty").action(async (options) => {
9547
10493
  const configData = await loadConfig();
9548
10494
  const resolved = resolveProfile(configData, options.profile);
9549
10495
  const result = await createFlowAppFromWork(
@@ -9558,6 +10504,8 @@ function registerConfigCommands(program2) {
9558
10504
  publishLive: !options.draftOnly
9559
10505
  }
9560
10506
  );
10507
+ await writeResponseOut(options.responseOut, result);
10508
+ await writeEvidenceOut(options.evidenceOut, result);
9561
10509
  await saveConfig(configData);
9562
10510
  printResult(options.format, result);
9563
10511
  });
@@ -9591,9 +10539,38 @@ function registerConfigCommands(program2) {
9591
10539
  profile: resolved
9592
10540
  }));
9593
10541
  });
10542
+ config.command("readback <domain>").description("Read back one config object with a unified hash/evidence shape").requiredOption("--id <id>", "Remote config id").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (domain, options) => {
10543
+ if (!Object.prototype.hasOwnProperty.call(CONFIG_DOMAINS, domain)) {
10544
+ throw new Error(`Unknown config domain: ${domain}`);
10545
+ }
10546
+ const configData = await loadConfig();
10547
+ const resolved = resolveProfile(configData, options.profile);
10548
+ const result = await readbackConfigDomain(configData, resolved, domain, options.id);
10549
+ await saveConfig(configData);
10550
+ printResult(options.format, result);
10551
+ });
10552
+ const batch = config.command("batch").description("Run guarded typed config operations from a manifest");
10553
+ batch.command("submit").description("Submit typed config payloads from a batch manifest and keep per-row evidence").requiredOption("--manifest <file>", "Batch manifest JSON file").option("--profile <profile>", "Profile name").option("--continue-on-error", "Continue after a row fails and return a final failed summary").option("--format <format>", "Output format", "json").action(async (options) => {
10554
+ const configData = await loadConfig();
10555
+ const resolved = resolveProfile(configData, options.profile);
10556
+ const result = await runConfigBatchSubmit(configData, resolved, options.manifest, {
10557
+ continueOnError: Boolean(options.continueOnError)
10558
+ });
10559
+ await saveConfig(configData);
10560
+ printResult(options.format, result);
10561
+ });
10562
+ batch.command("readback").description("Read back typed config objects from a batch manifest and keep per-row evidence").requiredOption("--manifest <file>", "Batch manifest JSON file").option("--profile <profile>", "Profile name").option("--continue-on-error", "Continue after a row fails and return a final failed summary").option("--format <format>", "Output format", "json").action(async (options) => {
10563
+ const configData = await loadConfig();
10564
+ const resolved = resolveProfile(configData, options.profile);
10565
+ const result = await runConfigBatchReadback(configData, resolved, options.manifest, {
10566
+ continueOnError: Boolean(options.continueOnError)
10567
+ });
10568
+ await saveConfig(configData);
10569
+ printResult(options.format, result);
10570
+ });
9594
10571
  Object.keys(CONFIG_DOMAINS).forEach((domain) => {
9595
10572
  const domainCommand = domain === "workspace" ? workspace.description("Initialize local sysconfig workspaces and manage BPMAX workspace configuration") : config.command(domain).description(`Manage BPMAX ${domain} configuration`);
9596
- const createCommand = domainCommand.command("create").description(domain === "flow-template" ? "Create a new main flow template through the typed adapter" : `Create a ${domain} config object through a verified typed adapter; dry-run unless --confirm is exact`).option("--profile <profile>", "Profile name").option("--confirm <text>", "Exact confirmation text").option("--publish-live", "For flow-template, publish the created flow to live after saving draft").option("--format <format>", "Output format", "pretty");
10573
+ const createCommand = domainCommand.command("create").description(domain === "flow-template" ? "Create a new main flow template through the typed adapter" : `Create a ${domain} config object through a verified typed adapter; dry-run unless --confirm is exact`).option("--profile <profile>", "Profile name").option("--confirm <text>", "Exact confirmation text").option("--publish-live", "For flow-template, publish the created flow to live after saving draft").option("--response-out <file>", "Write the full JSON response to a file").option("--format <format>", "Output format", "pretty");
9597
10574
  if (domain === "flow-template") {
9598
10575
  createCommand.requiredOption("--work <file>", "Flow-template work JSON file").option("--agent <agent>", "Agent adapter for installed plugin lint discovery", "codex");
9599
10576
  } else {
@@ -9618,6 +10595,7 @@ function registerConfigCommands(program2) {
9618
10595
  { publishLive: Boolean(options.publishLive) }
9619
10596
  );
9620
10597
  await saveConfig(configData);
10598
+ await writeResponseOut(options.responseOut, result);
9621
10599
  printResult(options.format, result);
9622
10600
  });
9623
10601
  if (domain === "project-detail-template") {
@@ -9635,15 +10613,13 @@ function registerConfigCommands(program2) {
9635
10613
  const resolved = resolveProfile(configData, options.profile);
9636
10614
  const workFormat = options.workFormat === "structured" ? "structured" : "raw";
9637
10615
  const result = await exportConfigDomain(configData, resolved, domain, options.id, options.out, { workFormat });
9638
- if (domain === "flow-template" && (options.summary || options.inline)) {
9639
- const workFile = typeof result.work_file === "string" ? result.work_file : void 0;
9640
- const work = workFile ? await readJsonFile(workFile) : void 0;
9641
- if (options.summary) {
9642
- result.summary = summarizeFlowTemplateWork(work);
9643
- }
9644
- if (options.inline) {
9645
- result.work = work;
9646
- }
10616
+ const workFile = typeof result.work_file === "string" ? result.work_file : void 0;
10617
+ const work = (options.inline || domain === "flow-template" && options.summary) && workFile ? await readJsonFile(workFile) : void 0;
10618
+ if (domain === "flow-template" && options.summary) {
10619
+ result.summary = summarizeFlowTemplateWork(work);
10620
+ }
10621
+ if (options.inline) {
10622
+ result.work = work;
9647
10623
  }
9648
10624
  await saveConfig(configData);
9649
10625
  printResult(options.format, result);
@@ -9694,7 +10670,7 @@ function registerConfigCommands(program2) {
9694
10670
  submit_preview: submit || null
9695
10671
  });
9696
10672
  });
9697
- 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("--format <format>", "Output format", "pretty").action(async (options) => {
10673
+ 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) => {
9698
10674
  const configData = await loadConfig();
9699
10675
  const resolved = resolveProfile(configData, options.profile);
9700
10676
  const result = await submitConfigDomain(
@@ -9707,6 +10683,7 @@ function registerConfigCommands(program2) {
9707
10683
  { publishLive: Boolean(options.publishLive), agent: options.agent || "codex" }
9708
10684
  );
9709
10685
  await saveConfig(configData);
10686
+ await writeResponseOut(options.responseOut, result);
9710
10687
  printResult(options.format, result);
9711
10688
  });
9712
10689
  domainCommand.command("delete").description(`Delete a ${domain} config object through a verified typed adapter; dry-run unless --confirm is exact`).requiredOption("--id <id>", "Remote config id").option("--profile <profile>", "Profile name").option("--confirm <text>", "Exact confirmation text").option("--format <format>", "Output format", "pretty").action(async (options) => {
@@ -9723,6 +10700,29 @@ function registerConfigCommands(program2) {
9723
10700
  printResult(options.format, result);
9724
10701
  });
9725
10702
  if (domain === "dataset") {
10703
+ const relationFields = domainCommand.command("relation-fields").description("Manage dataset relationFields through the typed dataset adapter");
10704
+ relationFields.command("submit").description("Submit dataset relationFields payload with the standard dataset evidence response").requiredOption("--id <id>", "Remote dataset id").requiredOption("--payload <file>", "Submit payload JSON file produced by config dataset build").option("--profile <profile>", "Profile name").option("--confirm <text>", "Exact confirmation text").option("--response-out <file>", "Write the full JSON response to a file").option("--format <format>", "Output format", "pretty").action(async (options) => {
10705
+ const configData = await loadConfig();
10706
+ const resolved = resolveProfile(configData, options.profile);
10707
+ const result = await submitConfigDomain(
10708
+ configData,
10709
+ resolved,
10710
+ "dataset",
10711
+ options.id,
10712
+ options.payload,
10713
+ options.confirm
10714
+ );
10715
+ await saveConfig(configData);
10716
+ await writeResponseOut(options.responseOut, result);
10717
+ printResult(options.format, result);
10718
+ });
10719
+ relationFields.command("readback").description("Read back dataset relationFields evidence using the unified readback shape").requiredOption("--id <id>", "Remote dataset id").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (options) => {
10720
+ const configData = await loadConfig();
10721
+ const resolved = resolveProfile(configData, options.profile);
10722
+ const result = await readbackConfigDomain(configData, resolved, "dataset", options.id);
10723
+ await saveConfig(configData);
10724
+ printResult(options.format, result);
10725
+ });
9726
10726
  [
9727
10727
  ["publish", "Publish/start a dataset and trigger ES batch generation"],
9728
10728
  ["pause", "Pause a published or pending dataset"],
@@ -9784,8 +10784,8 @@ function registerConfigCommands(program2) {
9784
10784
 
9785
10785
  // src/commands/e2e.ts
9786
10786
  import { createHash as createHash5 } from "crypto";
9787
- import { mkdir as mkdir8, readFile as readFile11, readdir as readdir3, stat as stat5, writeFile as writeFile8 } from "fs/promises";
9788
- import path9 from "path";
10787
+ import { mkdir as mkdir9, readFile as readFile11, readdir as readdir3, stat as stat5, writeFile as writeFile9 } from "fs/promises";
10788
+ import path10 from "path";
9789
10789
 
9790
10790
  // src/core/form-schema.ts
9791
10791
  var FIELD_KEY_NAMES = [
@@ -10718,18 +11718,18 @@ function timestampSlug() {
10718
11718
  return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
10719
11719
  }
10720
11720
  async function ensureDir(dir) {
10721
- const resolved = path9.resolve(dir);
10722
- await mkdir8(resolved, { recursive: true });
11721
+ const resolved = path10.resolve(dir);
11722
+ await mkdir9(resolved, { recursive: true });
10723
11723
  return resolved;
10724
11724
  }
10725
11725
  async function writeEvidence(dir, name, value) {
10726
- const file = path9.join(await ensureDir(dir), name);
10727
- await writeFile8(file, `${JSON.stringify(redactAuditValue(value), null, 2)}
11726
+ const file = path10.join(await ensureDir(dir), name);
11727
+ await writeFile9(file, `${JSON.stringify(redactAuditValue(value), null, 2)}
10728
11728
  `, "utf8");
10729
11729
  return file;
10730
11730
  }
10731
11731
  function cacheRoot() {
10732
- return path9.resolve(".codex/cache/bpmax-e2e");
11732
+ return path10.resolve(".codex/cache/bpmax-e2e");
10733
11733
  }
10734
11734
  function safeSegment(value) {
10735
11735
  return value.trim().replace(/[^a-zA-Z0-9._:-]+/g, "_") || "default";
@@ -10841,7 +11841,7 @@ function buildExpectedChecks(options) {
10841
11841
  ];
10842
11842
  }
10843
11843
  function flowCachePath(profileName, flowId) {
10844
- return path9.join(cacheRoot(), "profiles", safeSegment(profileName), "flows", `${safeSegment(flowId)}.json`);
11844
+ return path10.join(cacheRoot(), "profiles", safeSegment(profileName), "flows", `${safeSegment(flowId)}.json`);
10845
11845
  }
10846
11846
  async function readOptionalJson(file) {
10847
11847
  try {
@@ -10930,7 +11930,7 @@ function dataProfilePath(input) {
10930
11930
  if (!input?.startsWith("@")) {
10931
11931
  return void 0;
10932
11932
  }
10933
- return path9.resolve(input.slice(1));
11933
+ return path10.resolve(input.slice(1));
10934
11934
  }
10935
11935
  function refreshedStepTemplate(options) {
10936
11936
  return {
@@ -10954,15 +11954,15 @@ function refreshedStepTemplate(options) {
10954
11954
  variables: Object.keys(options.plan.data).filter((key) => !["project_id", "action", "urgency"].includes(key)),
10955
11955
  payload_template: options.plan.data,
10956
11956
  source_evidence: {
10957
- evidence_dir: path9.resolve(options.evidenceDir),
10958
- context: path9.basename(options.contextFile)
11957
+ evidence_dir: path10.resolve(options.evidenceDir),
11958
+ context: path10.basename(options.contextFile)
10959
11959
  }
10960
11960
  };
10961
11961
  }
10962
11962
  async function writeRefreshedCache(file, template) {
10963
- const out = path9.resolve(file);
10964
- await mkdir8(path9.dirname(out), { recursive: true });
10965
- await writeFile8(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
11963
+ const out = path10.resolve(file);
11964
+ await mkdir9(path10.dirname(out), { recursive: true });
11965
+ await writeFile9(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
10966
11966
  `, "utf8");
10967
11967
  return out;
10968
11968
  }
@@ -11039,13 +12039,13 @@ test(${JSON.stringify(options.title)}, async ({ page }) => {
11039
12039
  async function writeBrowserTemplate(options) {
11040
12040
  const handoffUrl = handoffUrlFromInput(options.handoff);
11041
12041
  const assertFields = (options.assertFields ?? "").split(",").map((item) => item.trim()).filter(Boolean);
11042
- const out = path9.resolve(options.out);
11043
- await mkdir8(path9.dirname(out), { recursive: true });
11044
- await writeFile8(out, playwrightTemplate({
12042
+ const out = path10.resolve(options.out);
12043
+ await mkdir9(path10.dirname(out), { recursive: true });
12044
+ await writeFile9(out, playwrightTemplate({
11045
12045
  title: options.title ?? "BPMAX create page handoff submit",
11046
12046
  handoffUrl,
11047
12047
  assertFields,
11048
- evidenceDir: path9.resolve(options.evidenceDir)
12048
+ evidenceDir: path10.resolve(options.evidenceDir)
11049
12049
  }), "utf8");
11050
12050
  return { out, handoff_url: handoffUrl, assert_fields: assertFields };
11051
12051
  }
@@ -11208,7 +12208,7 @@ function registerE2eCommands(program2) {
11208
12208
  mode: "handoff_command_hint",
11209
12209
  browser: options.browser,
11210
12210
  next_command: `bpmax-cli project create ${flowFlag}${jsonFlag}${profileFlag} --handoff-only --format json > handoff.json`,
11211
- next_after_handoff: `bpmax-cli e2e create-page-submit --handoff-json @handoff.json --browser ${options.browser} --evidence-dir ${path9.resolve(options.evidenceDir)} --format json`,
12211
+ next_after_handoff: `bpmax-cli e2e create-page-submit --handoff-json @handoff.json --browser ${options.browser} --evidence-dir ${path10.resolve(options.evidenceDir)} --format json`,
11212
12212
  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."
11213
12213
  });
11214
12214
  return;
@@ -11227,7 +12227,7 @@ function registerE2eCommands(program2) {
11227
12227
  browser_verified: false,
11228
12228
  browser: options.browser,
11229
12229
  ...generated,
11230
- evidence_dir: path9.resolve(options.evidenceDir),
12230
+ evidence_dir: path10.resolve(options.evidenceDir),
11231
12231
  next_command: `npx playwright test ${generated.out}`,
11232
12232
  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."
11233
12233
  });
@@ -11278,8 +12278,8 @@ function registerE2eCommands(program2) {
11278
12278
  template_id: result.template_id ?? result.templateId
11279
12279
  })).digest("hex").slice(0, 16);
11280
12280
  const file = flowCachePath(profile.name, options.flowId);
11281
- await mkdir8(path9.dirname(file), { recursive: true });
11282
- await writeFile8(file, `${JSON.stringify(redactAuditValue({
12281
+ await mkdir9(path10.dirname(file), { recursive: true });
12282
+ await writeFile9(file, `${JSON.stringify(redactAuditValue({
11283
12283
  cache_key: cacheKey,
11284
12284
  cached_at: (/* @__PURE__ */ new Date()).toISOString(),
11285
12285
  profile: profile.name,
@@ -11309,7 +12309,7 @@ function registerE2eCommands(program2) {
11309
12309
  printResult(options.format, {
11310
12310
  ok: true,
11311
12311
  ...generated,
11312
- evidence_dir: path9.resolve(options.evidenceDir),
12312
+ evidence_dir: path10.resolve(options.evidenceDir),
11313
12313
  next_command: `npx playwright test ${generated.out}`
11314
12314
  });
11315
12315
  });
@@ -11321,8 +12321,8 @@ function registerE2eCommands(program2) {
11321
12321
  if (inferredStepId && !contextFile && !submitFile) {
11322
12322
  throw new Error(`No step evidence files found for step ${inferredStepId} in ${options.evidenceDir}.`);
11323
12323
  }
11324
- const context = contextFile ? await readOptionalJson(path9.join(options.evidenceDir, contextFile)) : null;
11325
- const submit = submitFile ? await readOptionalJson(path9.join(options.evidenceDir, submitFile)) : null;
12324
+ const context = contextFile ? await readOptionalJson(path10.join(options.evidenceDir, contextFile)) : null;
12325
+ const submit = submitFile ? await readOptionalJson(path10.join(options.evidenceDir, submitFile)) : null;
11326
12326
  const requirements = isRecord8(context?.requirements) ? context.requirements : {};
11327
12327
  const requiredInputs = Array.isArray(requirements.required_inputs) ? requirements.required_inputs.filter(isRecord8) : [];
11328
12328
  const missingInputs = Array.isArray(requirements.missing_required_inputs) ? requirements.missing_required_inputs.filter(isRecord8) : [];
@@ -11365,16 +12365,16 @@ function registerE2eCommands(program2) {
11365
12365
  variables: Object.keys(requestData).filter((key) => !["project_id", "action", "urgency"].includes(key)),
11366
12366
  payload_template: requestData,
11367
12367
  source_evidence: {
11368
- evidence_dir: path9.resolve(options.evidenceDir),
12368
+ evidence_dir: path10.resolve(options.evidenceDir),
11369
12369
  ...contextFile ? { context: contextFile } : {},
11370
12370
  ...submitFile ? { submit: submitFile } : {}
11371
12371
  }
11372
12372
  } : {
11373
- name: options.name ?? path9.basename(path9.resolve(options.evidenceDir)),
12373
+ name: options.name ?? path10.basename(path10.resolve(options.evidenceDir)),
11374
12374
  generated_at: (/* @__PURE__ */ new Date()).toISOString(),
11375
12375
  submit_mode: "browser_evidence_bootstrap",
11376
12376
  source_evidence: {
11377
- evidence_dir: path9.resolve(options.evidenceDir),
12377
+ evidence_dir: path10.resolve(options.evidenceDir),
11378
12378
  files: evidenceFiles
11379
12379
  },
11380
12380
  reuse_requirements: [
@@ -11383,9 +12383,9 @@ function registerE2eCommands(program2) {
11383
12383
  "Do not treat API-only evidence as browser E2E proof."
11384
12384
  ]
11385
12385
  };
11386
- const out = path9.resolve(options.out);
11387
- await mkdir8(path9.dirname(out), { recursive: true });
11388
- await writeFile8(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
12386
+ const out = path10.resolve(options.out);
12387
+ await mkdir9(path10.dirname(out), { recursive: true });
12388
+ await writeFile9(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
11389
12389
  `, "utf8");
11390
12390
  printResult(options.format, {
11391
12391
  ok: true,
@@ -11545,7 +12545,7 @@ function registerFlowCommands(program2) {
11545
12545
  const client = createApiClient(profile);
11546
12546
  if (options.flowType) {
11547
12547
  const bindings = await getWorkspaceFlowBindings(client, profile, options);
11548
- const path14 = options.flowKey ? "/flow/options" : "/flow/flow_type";
12548
+ const path15 = options.flowKey ? "/flow/options" : "/flow/flow_type";
11549
12549
  const params = options.flowKey ? {
11550
12550
  detail: "1"
11551
12551
  } : {
@@ -11555,7 +12555,7 @@ function registerFlowCommands(program2) {
11555
12555
  const result2 = await apiRequest(
11556
12556
  client,
11557
12557
  "GET",
11558
- path14,
12558
+ path15,
11559
12559
  {
11560
12560
  params
11561
12561
  }
@@ -11812,10 +12812,10 @@ async function parseOptionalJson(input, label) {
11812
12812
  }
11813
12813
  return parseJsonInput(input, label);
11814
12814
  }
11815
- async function memoryRequest(options, method, path14, capability, data, params) {
12815
+ async function memoryRequest(options, method, path15, capability, data, params) {
11816
12816
  const profile = resolveProfile(await loadConfig(), options.profile);
11817
12817
  const client = createApiClient(profile);
11818
- return apiRequest(client, method, path14, {
12818
+ return apiRequest(client, method, path15, {
11819
12819
  capability,
11820
12820
  data: redactAuditValue(data),
11821
12821
  params: params ? redactAuditValue(params) : void 0
@@ -11897,15 +12897,15 @@ async function parseSeedRules(input) {
11897
12897
  });
11898
12898
  return rules;
11899
12899
  }
11900
- function collectUuidPaths(value, path14 = "$") {
12900
+ function collectUuidPaths(value, path15 = "$") {
11901
12901
  if (typeof value === "string") {
11902
- return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [path14] : [];
12902
+ return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [path15] : [];
11903
12903
  }
11904
12904
  if (Array.isArray(value)) {
11905
- return value.flatMap((item, index) => collectUuidPaths(item, `${path14}[${index}]`));
12905
+ return value.flatMap((item, index) => collectUuidPaths(item, `${path15}[${index}]`));
11906
12906
  }
11907
12907
  if (typeof value === "object" && value !== null) {
11908
- return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${path14}.${key}`));
12908
+ return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${path15}.${key}`));
11909
12909
  }
11910
12910
  return [];
11911
12911
  }
@@ -11934,16 +12934,16 @@ function dataArray(value) {
11934
12934
  if (isRecord10(value) && Array.isArray(value.data)) return value.data;
11935
12935
  return [];
11936
12936
  }
11937
- function collectMatrixOwnerPaths(value, path14 = "$") {
12937
+ function collectMatrixOwnerPaths(value, path15 = "$") {
11938
12938
  if (Array.isArray(value)) {
11939
- return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${path14}[${index}]`));
12939
+ return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${path15}[${index}]`));
11940
12940
  }
11941
12941
  if (!isRecord10(value)) {
11942
12942
  return [];
11943
12943
  }
11944
12944
  const matches = [];
11945
12945
  Object.entries(value).forEach(([key, child]) => {
11946
- const childPath = `${path14}.${key}`;
12946
+ const childPath = `${path15}.${key}`;
11947
12947
  if (key.includes("matrix_owner") || typeof child === "string" && child.includes("matrix_owner")) {
11948
12948
  matches.push({ path: childPath, value: child });
11949
12949
  }
@@ -12772,9 +13772,9 @@ function contextField(field, reason, options = {}) {
12772
13772
  function collectPrefillContextForFields(fields, form, result, options = {}) {
12773
13773
  for (const field of fields) {
12774
13774
  const value = form[field.key];
12775
- const path14 = options.prefix ? `${options.prefix}.${field.key}` : field.key;
13775
+ const path15 = options.prefix ? `${options.prefix}.${field.key}` : field.key;
12776
13776
  const fieldOptions = {
12777
- path: path14,
13777
+ path: path15,
12778
13778
  rootKey: options.rootKey ?? field.key,
12779
13779
  parentKey: options.parentKey
12780
13780
  };
@@ -13191,8 +14191,8 @@ import { spawn as spawn2 } from "child_process";
13191
14191
  import { fileURLToPath as fileURLToPath3 } from "url";
13192
14192
 
13193
14193
  // src/core/recipes.ts
13194
- import { access, mkdir as mkdir9, readdir as readdir4, readFile as readFile13, writeFile as writeFile9 } from "fs/promises";
13195
- import path10 from "path";
14194
+ import { access, mkdir as mkdir10, readdir as readdir4, readFile as readFile13, writeFile as writeFile10 } from "fs/promises";
14195
+ import path11 from "path";
13196
14196
  var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
13197
14197
  var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
13198
14198
  function assertSafeName(kind, value) {
@@ -13216,12 +14216,12 @@ function resolveRecipeLocation(options) {
13216
14216
  workspace,
13217
14217
  workspaceDirName,
13218
14218
  recipeName: options.recipeName,
13219
- recipeDir: path10.join(profileDir, "recipes", workspaceDirName, options.recipeName)
14219
+ recipeDir: path11.join(profileDir, "recipes", workspaceDirName, options.recipeName)
13220
14220
  };
13221
14221
  }
13222
14222
  function getRecipesDir(options) {
13223
14223
  const workspaceDirName = normalizeWorkspaceForPath(options.workspace || DEFAULT_WORKSPACE);
13224
- return path10.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
14224
+ return path11.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
13225
14225
  }
13226
14226
  function isRecord13(value) {
13227
14227
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -13273,7 +14273,7 @@ function parseRecipeDefinition(input) {
13273
14273
  };
13274
14274
  }
13275
14275
  async function loadRecipe(recipeDir) {
13276
- const raw = await readFile13(path10.join(recipeDir, "recipe.json"), "utf8");
14276
+ const raw = await readFile13(path11.join(recipeDir, "recipe.json"), "utf8");
13277
14277
  return parseRecipeDefinition(JSON.parse(raw));
13278
14278
  }
13279
14279
  async function listRecipes(recipesDir) {
@@ -13291,7 +14291,7 @@ async function listRecipes(recipesDir) {
13291
14291
  if (!RECIPE_NAME_PATTERN.test(entry)) {
13292
14292
  continue;
13293
14293
  }
13294
- const recipeDir = path10.join(recipesDir, entry);
14294
+ const recipeDir = path11.join(recipesDir, entry);
13295
14295
  try {
13296
14296
  const recipe = await loadRecipe(recipeDir);
13297
14297
  summaries.push({
@@ -13357,12 +14357,12 @@ function renderTemplate(template, variables) {
13357
14357
  }
13358
14358
  function resolveRecipeFile(recipeDir, token) {
13359
14359
  const relative = token.slice(1);
13360
- if (!relative || relative.includes("..") || path10.isAbsolute(relative)) {
14360
+ if (!relative || relative.includes("..") || path11.isAbsolute(relative)) {
13361
14361
  throw new Error(`Unsafe recipe file reference: ${token}`);
13362
14362
  }
13363
- const resolved = path10.resolve(recipeDir, relative);
13364
- const root = path10.resolve(recipeDir);
13365
- if (resolved !== root && !resolved.startsWith(`${root}${path10.sep}`)) {
14363
+ const resolved = path11.resolve(recipeDir, relative);
14364
+ const root = path11.resolve(recipeDir);
14365
+ if (resolved !== root && !resolved.startsWith(`${root}${path11.sep}`)) {
13366
14366
  throw new Error(`Recipe file reference escapes recipe directory: ${token}`);
13367
14367
  }
13368
14368
  return resolved;
@@ -13398,7 +14398,7 @@ async function ensureEmptyOrForce(targetDir, force = false) {
13398
14398
  }
13399
14399
  async function writeRecipeScaffold(options) {
13400
14400
  await ensureEmptyOrForce(options.location.recipeDir, options.force);
13401
- await mkdir9(options.location.recipeDir, { recursive: true });
14401
+ await mkdir10(options.location.recipeDir, { recursive: true });
13402
14402
  const title = options.title || options.location.recipeName;
13403
14403
  const recipe = {
13404
14404
  version: 1,
@@ -13415,16 +14415,16 @@ async function writeRecipeScaffold(options) {
13415
14415
  mutating: true
13416
14416
  }
13417
14417
  };
13418
- await writeFile9(path10.join(options.location.recipeDir, "recipe.json"), `${JSON.stringify(recipe, null, 2)}
14418
+ await writeFile10(path11.join(options.location.recipeDir, "recipe.json"), `${JSON.stringify(recipe, null, 2)}
13419
14419
  `, "utf8");
13420
- await writeFile9(
13421
- path10.join(options.location.recipeDir, "payload.json"),
14420
+ await writeFile10(
14421
+ path11.join(options.location.recipeDir, "payload.json"),
13422
14422
  `${JSON.stringify({ form: {} }, null, 2)}
13423
14423
  `,
13424
14424
  "utf8"
13425
14425
  );
13426
- await writeFile9(
13427
- path10.join(options.location.recipeDir, "README.md"),
14426
+ await writeFile10(
14427
+ path11.join(options.location.recipeDir, "README.md"),
13428
14428
  [`# ${title}`, "", "Describe the BPMAX flow, field mapping, prerequisites, and verification steps for this recipe.", ""].join("\n"),
13429
14429
  "utf8"
13430
14430
  );
@@ -13830,8 +14830,8 @@ function registerSetupCommand(program2, deps = {}) {
13830
14830
  }
13831
14831
 
13832
14832
  // src/core/taskbook.ts
13833
- import { mkdir as mkdir10, readFile as readFile14, writeFile as writeFile10 } from "fs/promises";
13834
- import path11 from "path";
14833
+ import { mkdir as mkdir11, readFile as readFile14, writeFile as writeFile11 } from "fs/promises";
14834
+ import path12 from "path";
13835
14835
  var TaskbookError = class extends Error {
13836
14836
  };
13837
14837
  var REQUIRED_TASKBOOK_TERMS = [
@@ -14026,14 +15026,14 @@ function hasDomainWriteEvidence(domain, evidenceText, patterns) {
14026
15026
  function uuidValues(text5) {
14027
15027
  return [...new Set([...text5.matchAll(UUID_PATTERN)].map((match) => match[0]))];
14028
15028
  }
14029
- function addUuidIssues(text5, issues, path14) {
15029
+ function addUuidIssues(text5, issues, path15) {
14030
15030
  for (const value of uuidValues(text5)) {
14031
15031
  addTaskbookIssue(
14032
15032
  issues,
14033
15033
  "uuid_not_allowed",
14034
15034
  "taskbook.config.no_uuid",
14035
15035
  `BPMAX \u914D\u7F6E\u4EFB\u52A1\u4E0D\u80FD\u4F7F\u7528 UUID\uFF1A${value}\u3002`,
14036
- { path: path14, 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" }
15036
+ { path: path15, 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" }
14037
15037
  );
14038
15038
  }
14039
15039
  }
@@ -14065,7 +15065,7 @@ function findNavigationStrategy(text5) {
14065
15065
  const matches = [...text5.matchAll(/导航入口策略\s*[::]\s*(nav-config:(?:included|skipped:[^\s|,。]+|deferred:[^\s|,。]+))/gi)];
14066
15066
  return matches.at(-1)?.[1] || null;
14067
15067
  }
14068
- function validateNavigationStrategy(text5, issues, path14, subject) {
15068
+ function validateNavigationStrategy(text5, issues, path15, subject) {
14069
15069
  const strategy = findNavigationStrategy(text5);
14070
15070
  if (!strategy) {
14071
15071
  addTaskbookIssue(
@@ -14073,7 +15073,7 @@ function validateNavigationStrategy(text5, issues, path14, subject) {
14073
15073
  "missing_navigation_strategy",
14074
15074
  "taskbook.nav.strategy",
14075
15075
  `${subject}\u7F3A\u5C11\u660E\u786E\u7684\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u3002`,
14076
- { path: path14, suggestion: "\u5199\u660E \u5BFC\u822A\u5165\u53E3\u7B56\u7565\uFF1Anav-config:included\u3001nav-config:skipped:<reason> \u6216 nav-config:deferred:<reason>\u3002" }
15076
+ { path: path15, suggestion: "\u5199\u660E \u5BFC\u822A\u5165\u53E3\u7B56\u7565\uFF1Anav-config:included\u3001nav-config:skipped:<reason> \u6216 nav-config:deferred:<reason>\u3002" }
14077
15077
  );
14078
15078
  return null;
14079
15079
  }
@@ -14083,7 +15083,7 @@ function validateNavigationStrategy(text5, issues, path14, subject) {
14083
15083
  "empty_navigation_strategy_reason",
14084
15084
  "taskbook.nav.strategy_reason",
14085
15085
  `${subject}\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u8DF3\u8FC7\u6216\u5EF6\u540E\u65F6\u5FC5\u987B\u5199\u660E\u539F\u56E0\u3002`,
14086
- { path: path14, suggestion: "\u4F7F\u7528 nav-config:skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 nav-config:deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
15086
+ { path: path15, suggestion: "\u4F7F\u7528 nav-config:skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 nav-config:deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
14087
15087
  );
14088
15088
  }
14089
15089
  if (/(待完成范围确认后回填|待确认|TODO|TBD|占位)/i.test(strategy)) {
@@ -14092,7 +15092,7 @@ function validateNavigationStrategy(text5, issues, path14, subject) {
14092
15092
  "placeholder_navigation_strategy",
14093
15093
  "taskbook.nav.strategy_placeholder",
14094
15094
  `${subject}\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u4ECD\u662F\u5360\u4F4D\u5185\u5BB9\u3002`,
14095
- { path: path14, suggestion: "\u66FF\u6362\u4E3A included\u3001skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
15095
+ { path: path15, suggestion: "\u66FF\u6362\u4E3A included\u3001skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
14096
15096
  );
14097
15097
  }
14098
15098
  return strategy;
@@ -14549,8 +15549,8 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
14549
15549
  }
14550
15550
  async function initTaskbook(outFile, title) {
14551
15551
  const content = taskbookTemplate(title);
14552
- await mkdir10(path11.dirname(outFile), { recursive: true });
14553
- await writeFile10(outFile, content, "utf8");
15552
+ await mkdir11(path12.dirname(outFile), { recursive: true });
15553
+ await writeFile11(outFile, content, "utf8");
14554
15554
  return { out: outFile, bytes: Buffer.byteLength(content) };
14555
15555
  }
14556
15556
  function splitMarkdownRow(line) {
@@ -14639,8 +15639,8 @@ async function initTaskbookProgress(source, outFile) {
14639
15639
  fields.join(","),
14640
15640
  ...rows.map((row) => fields.map((field) => csvEscape(field === "status" ? "\u672A\u5F00\u59CB" : row[field] || "")).join(","))
14641
15641
  ].join("\n") + "\n";
14642
- await mkdir10(path11.dirname(outFile), { recursive: true });
14643
- await writeFile10(outFile, csv, "utf8");
15642
+ await mkdir11(path12.dirname(outFile), { recursive: true });
15643
+ await writeFile11(outFile, csv, "utf8");
14644
15644
  return { source, out: outFile, task_count: rows.length };
14645
15645
  }
14646
15646
 
@@ -14686,14 +15686,14 @@ import { createHash as createHash6 } from "crypto";
14686
15686
  import {
14687
15687
  copyFile,
14688
15688
  cp as cp3,
14689
- mkdir as mkdir11,
15689
+ mkdir as mkdir12,
14690
15690
  readdir as readdir5,
14691
15691
  readFile as readFile15,
14692
15692
  rm as rm4,
14693
15693
  stat as stat6,
14694
- writeFile as writeFile11
15694
+ writeFile as writeFile12
14695
15695
  } from "fs/promises";
14696
- import path12 from "path";
15696
+ import path13 from "path";
14697
15697
  var DEFAULT_SUITE_ROOT = ".ai_test/suite";
14698
15698
  var DEFAULT_DRAFT_ROOT = ".ai_test/suite_draft";
14699
15699
  var DEFAULT_REPORT_ROOT = ".ai_test/report";
@@ -14746,6 +15746,7 @@ var CONFIG_BASIS_ALLOWED_PREFIXES = [
14746
15746
  ".codex/skills/"
14747
15747
  ];
14748
15748
  var REPORT_REQUIRED_KEYS = ["run_id:", "scenario_id:", "source_suite:", "result:"];
15749
+ var REPORT_EXECUTION_KEYS = ["planned_cases:", "executed_cases:", "precondition_check:", "state_file:", "browser_tool:"];
14749
15750
  var REPORT_REQUIRED_HEADINGS = [
14750
15751
  "## 1. \u6D4B\u8BD5\u8303\u56F4",
14751
15752
  "## 2. \u6267\u884C\u73AF\u5883",
@@ -14763,18 +15764,28 @@ var ID_AS_ENTRY_RE = /(发起表单|处理表单|表单模板|数据集|列表
14763
15764
  var URL_RE = /https?:\/\/|\/w:[^\s,,;;]+|\/project\?|\/project_detail\/|\/projectContinue\?/;
14764
15765
  var SHA_RE = /^[0-9a-f]{40}$/;
14765
15766
  var CONFIG_BASIS_REASON_RE = /(依据|覆盖|校验|验证|对应|因为|reason=|why=|=>|->)/;
14766
- var PREP_TOKEN_RE = /(账号|入口|样本|准备操作|预期|主数据|权限|自动化|依赖流程|清理策略|绑定解析|定位规则|模拟用户)=/g;
15767
+ var PREP_TOKEN_RE = /(账号|入口|样本|准备操作|预期|主数据|权限|自动化|依赖流程|清理策略|绑定解析|定位规则|模拟用户|precondition_check|browser_tool|live_draft|state_file|report_run|login_profile|mock_user|unmock_done|resume_policy)=/g;
14767
15768
  var TEST_DATA_TOKEN_RE = /(业务场景|业务逻辑|样本数据|合理性|客户口径|数据约束)=/g;
14768
15769
  var GENERIC_SAMPLE_VALUE_RE = /(^|[=,;,\s])(sample|test|mock|demo|xxx|todo|tbd|placeholder|随便|假数据|占位|待补)(?=$|[,;,\s])/i;
14769
15770
  var SENSITIVE_TEST_DATA_RE = /authorization|bearer\s+[A-Za-z0-9._-]+|cookie|set-cookie|api[-_]?key|token|password|passwd|pwd|secret|session|验证码|手机号|\b1[3-9]\d{9}\b/i;
14770
15771
  var RAW_PAYLOAD_TEST_DATA_RE = /(^|[;;]\s*)(payload|完整payload|request|请求体|headers?)\s*=/i;
14771
15772
  var PLACEHOLDER_RE = /<[^>]+>/;
15773
+ var CASE_CONTENT_GARBLED_RE = /\uFFFD|�|Ã.|Â.|â[€\u0080-\u00BF]|锛|鈥|乱码|���|\?\?\?/i;
15774
+ var HOLLOW_CASE_TEXT_RE = /(^|[=,;,\s])(todo|tbd|xxx|placeholder|占位|待补|随便写|后补|暂无|无具体步骤|略)(?=$|[,;,\s])/i;
14772
15775
  var IMAGE_RE = /!\[[^\]]*]\(([^)]+)\)/g;
14773
15776
  var YBS_NONZERO_DETAIL_RE = /https:\/\/yaditest\.yitaiyitai\.com\/w:ybs\/project_detail\/(?!0\/)\d+\//;
14774
15777
  var YBS_PC_CREATE_WRONG_RE = /https:\/\/yaditest\.yitaiyitai\.com\/w:ybs\/pages\/projectCreate\/projectCreate\?flow_type=/;
14775
15778
  var IDENTITY_MOCK_CASE_RE = /(非处理人|越权|只读|多角色|角色隔离|无权限|低权限|unauthorized|limited|readonly|permission)/;
14776
15779
  var IDENTITY_MOCK_VALUE_RE = /(mock|模拟).*(unmock|退出模拟|恢复)|bpmax-user-mock-operator/;
14777
15780
  var E2E_REUSABLE_ASSET_RE = /bpmax-cli\s+e2e|record-from-evidence|create-page-submit|step-run|browser-template|scenario\s+plan|data\s+profile|reusable\s+step|复用模板|可复用|首次运行沉淀|沉淀模板/;
15781
+ var ERROR_CAPTURE_CASE_RE = /(negative|boundary|异常|错误|失败|报错|重复|无效|非法|invalid|error|扫码.*(异常|错误|无效)|错误\s*SN|异常\s*SN|无效\s*SN)/i;
15782
+ var ERROR_CAPTURE_EVIDENCE_RE = /(expected_error_text|error_capture_required|错误提示|提示文案|报错文案|toast|校验文案).*(screenshot|截图)|截图.*(错误提示|提示文案|报错文案|toast|校验文案)/i;
15783
+ var BROWSER_TOOL_RE = /(Chrome DevTools|DevTools|Playwright|AppleScript|browser_tool=|浏览器工具)/i;
15784
+ var LIVE_DRAFT_RE = /(live|draft|已发布|草稿|发布态|live_draft=)/i;
15785
+ var MULTI_ROLE_VALUE_RE = /[,、/]\s*[^,、/\s]+|多角色|跨角色/;
15786
+ var RESUME_POLICY_VALUE_RE = /(full_rerun|checkpoint|evidence_only|从头重跑|检查点|仅补证据)/i;
15787
+ var NOT_RUN_RE = /(not[_ -]?run|未执行|未跑|跳过)/i;
15788
+ var PAGE_CONCLUSION_RE = /(页面.*(通过|已验证|真实|可见|不可见)|浏览器回归.*(通过|完成)|完整链路.*通过|真实页面.*通过)/;
14778
15789
  var TestSuiteError = class extends Error {
14779
15790
  code;
14780
15791
  rule_id;
@@ -14851,12 +15862,12 @@ function reviewSchemaExplanation() {
14851
15862
  };
14852
15863
  }
14853
15864
  function reviewFail(reviewPath, message) {
14854
- const scenarioId = path12.basename(path12.dirname(reviewPath));
15865
+ const scenarioId = path13.basename(path13.dirname(reviewPath));
14855
15866
  fail(
14856
15867
  [
14857
15868
  message,
14858
15869
  "\u8FD0\u884C `bpmax-cli test-suite review explain --format json` \u67E5\u770B\u5B8C\u6574 schema\u3002",
14859
- `\u8FD0\u884C \`bpmax-cli test-suite review repair --scenario ${scenarioId} --draft-root ${path12.dirname(path12.dirname(reviewPath))} --latest-proof <proof.json> --format json\` \u4FEE\u8865\u7F3A\u5931\u5B57\u6BB5\u3002`,
15870
+ `\u8FD0\u884C \`bpmax-cli test-suite review repair --scenario ${scenarioId} --draft-root ${path13.dirname(path13.dirname(reviewPath))} --latest-proof <proof.json> --format json\` \u4FEE\u8865\u7F3A\u5931\u5B57\u6BB5\u3002`,
14860
15871
  `\u6700\u5C0F review.json \u793A\u4F8B\uFF1A${JSON.stringify(reviewSchemaExample(scenarioId))}`
14861
15872
  ].join("\n"),
14862
15873
  {
@@ -14945,14 +15956,14 @@ function parseReadmeText(filePath, text5) {
14945
15956
  return metadata;
14946
15957
  }
14947
15958
  async function validateReadme(scenarioDir) {
14948
- const readmePath = path12.join(scenarioDir, "README.md");
15959
+ const readmePath = path13.join(scenarioDir, "README.md");
14949
15960
  if (!await exists3(readmePath)) fail(`missing README.md: ${readmePath}`);
14950
15961
  const text5 = await readText(readmePath);
14951
15962
  const metadata = parseReadmeText(readmePath, text5);
14952
15963
  for (const key of REQUIRED_README_KEYS) {
14953
15964
  if (!metadata[key]) fail(`${scenarioDir}: README.md missing \`${key}\``);
14954
15965
  }
14955
- if (metadata.scenario_id !== path12.basename(scenarioDir)) fail(`${scenarioDir}: scenario_id must match directory name`);
15966
+ if (metadata.scenario_id !== path13.basename(scenarioDir)) fail(`${scenarioDir}: scenario_id must match directory name`);
14956
15967
  if (!["true", "false"].includes(metadata.core.toLowerCase())) fail(`${scenarioDir}: core must be true or false`);
14957
15968
  if (!STATUSES.has(metadata.status)) fail(`${scenarioDir}: status must be one of ${JSON.stringify([...STATUSES].sort())}`);
14958
15969
  if (UUID_RE2.test(text5) || ID_AS_ENTRY_RE.test(text5)) {
@@ -15047,6 +16058,72 @@ function hasE2eReusableAsset(row) {
15047
16058
  const evidencePlan = [row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
15048
16059
  return E2E_REUSABLE_ASSET_RE.test(evidencePlan);
15049
16060
  }
16061
+ function validateReadableCaseContent(filePath, caseId, row) {
16062
+ for (const field of ["title", "preconditions", "config_basis", "prep_data", "steps", "expected_result", "test_data"]) {
16063
+ const value = row[field].trim();
16064
+ if (!value) continue;
16065
+ if (CASE_CONTENT_GARBLED_RE.test(value)) {
16066
+ fail(`${filePath}:${caseId}: \`${field}\` \u5305\u542B\u4E71\u7801\u6216\u5F02\u5E38\u7F16\u7801\u7247\u6BB5\uFF1Bpromote \u524D\u5FC5\u987B\u4FEE\u590D\u6587\u672C\u7F16\u7801`, { rule_id: "test_suite.case.content_garbled" });
16067
+ }
16068
+ if (HOLLOW_CASE_TEXT_RE.test(value)) {
16069
+ fail(`${filePath}:${caseId}: \`${field}\` \u5305\u542B\u7A7A\u6D1E\u5360\u4F4D\u5185\u5BB9\uFF1B\u5FC5\u987B\u5199\u6E05\u53EF\u6267\u884C\u4E1A\u52A1\u6B65\u9AA4\u548C\u9884\u671F\u7ED3\u679C`, { rule_id: "test_suite.case.content_hollow" });
16070
+ }
16071
+ }
16072
+ if (row.steps.trim().length < 12 || !/[>;;。]|打开|点击|填写|选择|提交|等待|截图|校验|验证/.test(row.steps)) {
16073
+ fail(`${filePath}:${caseId}: \`steps\` \u5FC5\u987B\u662F\u53EF\u8BFB\u3001\u53EF\u6267\u884C\u7684\u6B65\u9AA4\uFF0C\u4E0D\u80FD\u662F\u4E00\u53E5\u6CDB\u6CDB\u5907\u6CE8`, { rule_id: "test_suite.case.content_steps" });
16074
+ }
16075
+ }
16076
+ function validatePreflightEvidence(filePath, caseId, row, prepTokens) {
16077
+ if (!prepTokens.precondition_check) {
16078
+ fail(`${filePath}:${caseId}: \`prep_data\` \u5FC5\u987B\u5305\u542B \`precondition_check=\`\uFF0C\u5426\u5219\u53EA\u80FD\u8FDB\u5165\u51C6\u5907\u9636\u6BB5\uFF0C\u4E0D\u80FD\u5F00\u59CB\u6B63\u5F0F E2E \u6267\u884C`, { rule_id: "test_suite.case.precondition_check" });
16079
+ }
16080
+ if (!prepTokens.browser_tool || !BROWSER_TOOL_RE.test(prepTokens.browser_tool)) {
16081
+ fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E\u6D4F\u89C8\u5668\u5DE5\u5177\u8BC1\u636E\uFF0C\u4F8B\u5982 \`browser_tool=Chrome DevTools\` \u6216 AppleScript fallback`, { rule_id: "test_suite.case.browser_tool" });
16082
+ }
16083
+ if (!prepTokens.live_draft || !LIVE_DRAFT_RE.test(prepTokens.live_draft)) {
16084
+ fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E\u672C\u8F6E\u76EE\u6807\u662F live \u53D1\u5E03\u6001\u8FD8\u662F draft \u8349\u7A3F\u6001`, { rule_id: "test_suite.case.live_draft" });
16085
+ }
16086
+ if (!prepTokens.state_file && !prepTokens.report_run) {
16087
+ fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E .codex/tmp/e2e_states \u72B6\u6001\u6587\u4EF6\u6216 .ai_test/report/<run> \u62A5\u544A\u8BC1\u636E\u8DEF\u5F84`, { rule_id: "test_suite.case.state_file" });
16088
+ }
16089
+ }
16090
+ function validateErrorCaptureEvidence(filePath, caseId, row) {
16091
+ const caseText = [row.type, row.title, row.preconditions, row.steps, row.expected_result, row.tags].join(" ");
16092
+ if (!ERROR_CAPTURE_CASE_RE.test(caseText)) return;
16093
+ const evidenceText = [row.prep_data, row.steps, row.expected_result, row.evidence_required].join(" ");
16094
+ if (!ERROR_CAPTURE_EVIDENCE_RE.test(evidenceText)) {
16095
+ fail(`${filePath}:${caseId}: \u8D1F\u5411/\u9519\u8BEF\u63D0\u793A\u7528\u4F8B\u5FC5\u987B\u5305\u542B expected_error_text \u6216 error_capture_required\uFF0C\u5E76\u8981\u6C42\u771F\u5B9E\u63D0\u793A\u6587\u6848\u622A\u56FE`, { rule_id: "test_suite.case.error_capture" });
16096
+ }
16097
+ }
16098
+ function validateResumePolicy(filePath, caseId, row, prepTokens) {
16099
+ const text5 = [row.preconditions, row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
16100
+ if (!/(人工介入|手工|补救|续跑|dirty_resumed|resume|局部复核|partial rerun)/i.test(text5)) return;
16101
+ const policy = prepTokens.resume_policy || text5;
16102
+ if (!RESUME_POLICY_VALUE_RE.test(policy)) {
16103
+ fail(`${filePath}:${caseId}: \u4EBA\u5DE5\u4ECB\u5165\u6216\u7EED\u8DD1\u7528\u4F8B\u5FC5\u987B\u58F0\u660E \`resume_policy=full_rerun|checkpoint|evidence_only\``, { rule_id: "test_suite.case.resume_policy" });
16104
+ }
16105
+ if (!/dirty_resumed|局部复核|partial|从头重跑|检查点/.test(text5)) {
16106
+ fail(`${filePath}:${caseId}: \u4EBA\u5DE5\u4ECB\u5165\u6216\u7EED\u8DD1\u7528\u4F8B\u5FC5\u987B\u6807\u8BB0 dirty_resumed\uFF0C\u6216\u660E\u786E\u8BF4\u660E\u5C40\u90E8/\u5B8C\u6574\u91CD\u8DD1\u8303\u56F4`, { rule_id: "test_suite.case.resume_scope" });
16107
+ }
16108
+ }
16109
+ function validateMultiRoleEvidence(filePath, caseId, row, prepTokens) {
16110
+ const text5 = [row.roles, row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
16111
+ if (!MULTI_ROLE_VALUE_RE.test(row.roles) && !/多角色|跨角色/.test(text5)) return;
16112
+ if (!prepTokens.login_profile) {
16113
+ fail(`${filePath}:${caseId}: \u591A\u89D2\u8272 E2E \u7528\u4F8B\u5FC5\u987B\u8BB0\u5F55\u6BCF\u4E2A\u89D2\u8272\u7684 login_profile`, { rule_id: "test_suite.case.multi_role_login_profile" });
16114
+ }
16115
+ const hasMockUser = Boolean(prepTokens.mock_user) || /bpmax-user-mock-operator|mock_user|模拟用户.*[=,,]/i.test(text5);
16116
+ if (!hasMockUser) {
16117
+ fail(`${filePath}:${caseId}: \u591A\u89D2\u8272 E2E \u7528\u4F8B\u5FC5\u987B\u8BB0\u5F55 mock_user \u6216 bpmax-user-mock-operator\uFF0C\u8BF4\u660E\u5982\u4F55\u5207\u6362\u8EAB\u4EFD`, { rule_id: "test_suite.case.multi_role_mock_user" });
16118
+ }
16119
+ const hasUnmock = Boolean(prepTokens.unmock_done) || /unmock|退出模拟|恢复身份|恢复管理员/i.test(text5);
16120
+ if (!hasUnmock) {
16121
+ fail(`${filePath}:${caseId}: \u591A\u89D2\u8272 E2E \u7528\u4F8B\u5FC5\u987B\u8BB0\u5F55 unmock_done\uFF0C\u8BF4\u660E\u6D4B\u8BD5\u7ED3\u675F\u540E\u5982\u4F55\u6062\u590D\u539F\u59CB\u8EAB\u4EFD`, { rule_id: "test_suite.case.multi_role_unmock" });
16122
+ }
16123
+ if (!/(分别截图|独立截图|每个角色|separate evidence|per-role|角色证据)/i.test(text5)) {
16124
+ fail(`${filePath}:${caseId}: \u591A\u89D2\u8272 E2E \u7528\u4F8B\u5FC5\u987B\u8981\u6C42\u6BCF\u4E2A\u89D2\u8272\u5355\u72EC\u6D4F\u89C8\u5668\u8BC1\u636E\uFF0C\u4E0D\u80FD\u590D\u7528\u622A\u56FE`, { rule_id: "test_suite.case.multi_role_screenshot" });
16125
+ }
16126
+ }
15050
16127
  function bootstrapActionForCase(row) {
15051
16128
  const rawText = [row.title, row.prep_data, row.steps, row.evidence_required, row.tags].join(" ");
15052
16129
  const text5 = rawText.toLowerCase();
@@ -15066,6 +16143,7 @@ async function validateCase(filePath, row, seen) {
15066
16143
  if (!caseId) fail(`${filePath}: case_id is required`);
15067
16144
  if (seen.has(caseId)) fail(`${filePath}: duplicate case_id \`${caseId}\``);
15068
16145
  seen.add(caseId);
16146
+ validateReadableCaseContent(filePath, caseId, row);
15069
16147
  for (const field of ["title", "config_basis", "steps", "expected_result", "status", "updated_at"]) {
15070
16148
  if (!row[field].trim()) fail(`${filePath}:${caseId}: \`${field}\` is required`);
15071
16149
  }
@@ -15109,14 +16187,18 @@ async function validateCase(filePath, row, seen) {
15109
16187
  if (UUID_RE2.test(browserText)) fail(`${filePath}:${caseId}: browser-executed cases must not use UUID as the execution entrypoint`);
15110
16188
  if (YBS_NONZERO_DETAIL_RE.test(browserText)) fail(`${filePath}:${caseId}: YBS detail URLs must use /w:ybs/project_detail/0/<project_id> unless verified otherwise`);
15111
16189
  if (YBS_PC_CREATE_WRONG_RE.test(browserText)) fail(`${filePath}:${caseId}: YBS PC create URLs must use /w:ybs/project/create?flow_type=<flow_type>`);
16190
+ validatePreflightEvidence(filePath, caseId, row, prepTokens);
16191
+ validateErrorCaptureEvidence(filePath, caseId, row);
16192
+ validateResumePolicy(filePath, caseId, row, prepTokens);
16193
+ validateMultiRoleEvidence(filePath, caseId, row, prepTokens);
15112
16194
  validateBusinessTestData(filePath, caseId, row);
15113
16195
  }
15114
16196
  async function collectE2eAccelerationGaps(root) {
15115
16197
  const dirs = await scenarioDirs(root);
15116
16198
  const gaps = [];
15117
16199
  for (const dir of dirs) {
15118
- const scenarioId = path12.basename(dir);
15119
- const casesPath = path12.join(dir, "cases.csv");
16200
+ const scenarioId = path13.basename(dir);
16201
+ const casesPath = path13.join(dir, "cases.csv");
15120
16202
  if (!await exists3(casesPath)) {
15121
16203
  continue;
15122
16204
  }
@@ -15139,11 +16221,11 @@ async function collectE2eAccelerationGaps(root) {
15139
16221
  async function scenarioDirs(root) {
15140
16222
  if (!await exists3(root)) return [];
15141
16223
  const items = await readdir5(root, { withFileTypes: true });
15142
- return items.filter((item) => item.isDirectory()).map((item) => path12.join(root, item.name)).sort();
16224
+ return items.filter((item) => item.isDirectory()).map((item) => path13.join(root, item.name)).sort();
15143
16225
  }
15144
16226
  async function validateScenario(scenarioDir) {
15145
16227
  const metadata = await validateReadme(scenarioDir);
15146
- const casesPath = path12.join(scenarioDir, "cases.csv");
16228
+ const casesPath = path13.join(scenarioDir, "cases.csv");
15147
16229
  const rows = await readCases(casesPath);
15148
16230
  if (rows.length === 0) fail(`${casesPath}: at least one case is required`);
15149
16231
  const seen = /* @__PURE__ */ new Set();
@@ -15227,9 +16309,9 @@ function validateLatestProofObject(proofPath, proof) {
15227
16309
  }
15228
16310
  function scenarioPath(root, scenario) {
15229
16311
  if (!SCENARIO_ID_RE.test(scenario)) fail(`invalid scenario id: ${scenario}`);
15230
- const rootResolved = path12.resolve(root);
15231
- const candidate = path12.resolve(root, scenario);
15232
- if (!candidate.startsWith(`${rootResolved}${path12.sep}`) && candidate !== rootResolved) {
16312
+ const rootResolved = path13.resolve(root);
16313
+ const candidate = path13.resolve(root, scenario);
16314
+ if (!candidate.startsWith(`${rootResolved}${path13.sep}`) && candidate !== rootResolved) {
15233
16315
  fail(`scenario path escapes root: ${candidate}`);
15234
16316
  }
15235
16317
  return candidate;
@@ -15238,13 +16320,13 @@ async function fileMap(root) {
15238
16320
  const result = /* @__PURE__ */ new Map();
15239
16321
  async function walk(dir) {
15240
16322
  for (const item of await readdir5(dir, { withFileTypes: true })) {
15241
- const itemPath = path12.join(dir, item.name);
15242
- const rel = path12.relative(root, itemPath);
15243
- if (rel.split(path12.sep)[0] === COPY_DIFF_DIR) continue;
16323
+ const itemPath = path13.join(dir, item.name);
16324
+ const rel = path13.relative(root, itemPath);
16325
+ if (rel.split(path13.sep)[0] === COPY_DIFF_DIR) continue;
15244
16326
  if (item.isDirectory()) {
15245
16327
  await walk(itemPath);
15246
16328
  } else if (item.isFile()) {
15247
- result.set(rel.split(path12.sep).join("/"), itemPath);
16329
+ result.set(rel.split(path13.sep).join("/"), itemPath);
15248
16330
  }
15249
16331
  }
15250
16332
  }
@@ -15315,7 +16397,7 @@ async function buildCopyDiff(src, dst, operation) {
15315
16397
  return {
15316
16398
  manifest: {
15317
16399
  operation,
15318
- scenario_id: path12.basename(src),
16400
+ scenario_id: path13.basename(src),
15319
16401
  source: src,
15320
16402
  destination: dst,
15321
16403
  generated_at: (/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "+00:00"),
@@ -15328,12 +16410,12 @@ async function buildCopyDiff(src, dst, operation) {
15328
16410
  };
15329
16411
  }
15330
16412
  async function writeCopyDiffArtifacts(dst, artifacts) {
15331
- const diffDir = path12.join(dst, COPY_DIFF_DIR);
15332
- await mkdir11(diffDir, { recursive: true });
15333
- await writeFile11(path12.join(diffDir, "last.diff"), artifacts.diff, "utf8");
15334
- await writeFile11(path12.join(diffDir, "last.json"), `${JSON.stringify(artifacts.manifest, null, 2)}
16413
+ const diffDir = path13.join(dst, COPY_DIFF_DIR);
16414
+ await mkdir12(diffDir, { recursive: true });
16415
+ await writeFile12(path13.join(diffDir, "last.diff"), artifacts.diff, "utf8");
16416
+ await writeFile12(path13.join(diffDir, "last.json"), `${JSON.stringify(artifacts.manifest, null, 2)}
15335
16417
  `, "utf8");
15336
- return path12.join(diffDir, "last.diff");
16418
+ return path13.join(diffDir, "last.diff");
15337
16419
  }
15338
16420
  function summarizeCopyDiff(artifacts) {
15339
16421
  const files = Array.isArray(artifacts.manifest.files) ? artifacts.manifest.files : [];
@@ -15359,14 +16441,14 @@ async function copyScenarioTree(src, dst, replace, operation) {
15359
16441
  artifacts = await buildCopyDiff(src, dst, operation);
15360
16442
  await rm4(dst, { recursive: true, force: true });
15361
16443
  }
15362
- await mkdir11(path12.dirname(dst), { recursive: true });
16444
+ await mkdir12(path13.dirname(dst), { recursive: true });
15363
16445
  await cp3(src, dst, { recursive: true });
15364
16446
  return artifacts ? { path: await writeCopyDiffArtifacts(dst, artifacts), summary: summarizeCopyDiff(artifacts) } : {};
15365
16447
  }
15366
16448
  async function copyDiffPreview(src, dst, operation) {
15367
- const previewDir = path12.join(DEFAULT_TMP_ROOT, `${operation}-${path12.basename(src)}-copy-diff`);
16449
+ const previewDir = path13.join(DEFAULT_TMP_ROOT, `${operation}-${path13.basename(src)}-copy-diff`);
15368
16450
  await rm4(previewDir, { recursive: true, force: true });
15369
- await mkdir11(previewDir, { recursive: true });
16451
+ await mkdir12(previewDir, { recursive: true });
15370
16452
  const artifacts = await buildCopyDiff(src, dst, operation);
15371
16453
  return { path: await writeCopyDiffArtifacts(previewDir, artifacts), summary: summarizeCopyDiff(artifacts) };
15372
16454
  }
@@ -15386,7 +16468,7 @@ async function draftUpdate(options) {
15386
16468
  return { destination: dst, copy_diff: copyDiff.path, copy_diff_summary: copyDiff.summary };
15387
16469
  }
15388
16470
  async function validateReviewGate(scenarioDir) {
15389
- const reviewPath = path12.join(scenarioDir, "review.json");
16471
+ const reviewPath = path13.join(scenarioDir, "review.json");
15390
16472
  if (!await exists3(reviewPath)) reviewFail(reviewPath, `${scenarioDir}: missing review.json; run multi-subagent SKILL review before promote`);
15391
16473
  let review;
15392
16474
  try {
@@ -15394,7 +16476,7 @@ async function validateReviewGate(scenarioDir) {
15394
16476
  } catch (error) {
15395
16477
  reviewFail(reviewPath, `${reviewPath}: invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
15396
16478
  }
15397
- if (review.scenario_id !== path12.basename(scenarioDir)) reviewFail(reviewPath, `${reviewPath}: scenario_id must match directory name`);
16479
+ if (review.scenario_id !== path13.basename(scenarioDir)) reviewFail(reviewPath, `${reviewPath}: scenario_id must match directory name`);
15398
16480
  if (!review.latest_proof || typeof review.latest_proof !== "object" || Array.isArray(review.latest_proof)) reviewFail(reviewPath, `${reviewPath}: latest_proof is required`);
15399
16481
  validateLatestProofObject(reviewPath, review.latest_proof);
15400
16482
  if (!REVIEW_STATUSES.has(String(review.status))) reviewFail(reviewPath, `${reviewPath}: status must be one of ${JSON.stringify([...REVIEW_STATUSES].sort())}`);
@@ -15503,9 +16585,9 @@ async function initOrRepairReview(options) {
15503
16585
  const scenarioDir = scenarioPath(options.draftRoot ?? DEFAULT_DRAFT_ROOT, options.scenario);
15504
16586
  if (!await exists3(scenarioDir)) fail(`draft scenario not found: ${scenarioDir}`);
15505
16587
  await validateReadme(scenarioDir);
15506
- const rows = await readCases(path12.join(scenarioDir, "cases.csv"));
16588
+ const rows = await readCases(path13.join(scenarioDir, "cases.csv"));
15507
16589
  const proof = await readLatestProof(options.latestProof);
15508
- const reviewPath = path12.join(scenarioDir, "review.json");
16590
+ const reviewPath = path13.join(scenarioDir, "review.json");
15509
16591
  let existing;
15510
16592
  const existed = await exists3(reviewPath);
15511
16593
  if (existed) {
@@ -15516,8 +16598,8 @@ async function initOrRepairReview(options) {
15516
16598
  existing = {};
15517
16599
  }
15518
16600
  }
15519
- const review = mergeReviewDraft(path12.basename(scenarioDir), proof, rows, existing);
15520
- await writeFile11(reviewPath, `${JSON.stringify(review, null, 2)}
16601
+ const review = mergeReviewDraft(path13.basename(scenarioDir), proof, rows, existing);
16602
+ await writeFile12(reviewPath, `${JSON.stringify(review, null, 2)}
15521
16603
  `, "utf8");
15522
16604
  return {
15523
16605
  ok: true,
@@ -15551,48 +16633,78 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
15551
16633
  String(today.getDate()).padStart(2, "0")
15552
16634
  ].join("");
15553
16635
  const dirs = await scenarioDirs(root);
15554
- const nums = dirs.map((dir) => path12.basename(dir)).filter((name) => name.startsWith(prefix)).map((name) => RUN_RE.exec(name)?.[1]).filter((value) => Boolean(value)).map((value) => Number(value));
15555
- const reportDir = path12.join(root, `${prefix}-${String(Math.max(0, ...nums) + 1).padStart(3, "0")}`);
16636
+ const nums = dirs.map((dir) => path13.basename(dir)).filter((name) => name.startsWith(prefix)).map((name) => RUN_RE.exec(name)?.[1]).filter((value) => Boolean(value)).map((value) => Number(value));
16637
+ const reportDir = path13.join(root, `${prefix}-${String(Math.max(0, ...nums) + 1).padStart(3, "0")}`);
15556
16638
  if (create) {
15557
- await mkdir11(path12.join(reportDir, "screenshots"), { recursive: true });
15558
- await writeFile11(
15559
- path12.join(reportDir, "summary.md"),
15560
- ["# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B", "", `run_id: ${path12.basename(reportDir)}`, "status: draft", "", "## \u573A\u666F\u62A5\u544A", "", "## \u603B\u7ED3", ""].join("\n"),
16639
+ await mkdir12(path13.join(reportDir, "screenshots"), { recursive: true });
16640
+ await writeFile12(
16641
+ path13.join(reportDir, "summary.md"),
16642
+ ["# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B", "", `run_id: ${path13.basename(reportDir)}`, "status: draft", "", "## \u573A\u666F\u62A5\u544A", "", "## \u603B\u7ED3", ""].join("\n"),
15561
16643
  "utf8"
15562
16644
  );
15563
16645
  }
15564
16646
  return reportDir;
15565
16647
  }
16648
+ function reportKeyValue(text5, key) {
16649
+ const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16650
+ const match = new RegExp(`^${escaped}\\s*(.+)$`, "im").exec(text5);
16651
+ return match?.[1]?.trim() ?? "";
16652
+ }
16653
+ function reportCaseList(text5, key) {
16654
+ const value = reportKeyValue(text5, key);
16655
+ return value.split(/[,\s,、;;]+/).map((item) => item.trim()).filter((item) => /^[A-Za-z0-9_-]+$/.test(item));
16656
+ }
15566
16657
  async function lintReport(root = DEFAULT_REPORT_ROOT) {
15567
16658
  if (!await exists3(root)) return [`report root not found: ${root}`];
15568
16659
  const errors = [];
15569
16660
  for (const runDir of await scenarioDirs(root)) {
15570
- const runName = path12.basename(runDir);
16661
+ const runName = path13.basename(runDir);
15571
16662
  if (!RUN_RE.test(runName)) {
15572
16663
  errors.push(`${runDir}: run directory name must be YYYYMMDD-NNN`);
15573
16664
  continue;
15574
16665
  }
15575
- if (!await exists3(path12.join(runDir, "summary.md"))) errors.push(`${runDir}: missing summary.md`);
16666
+ if (!await exists3(path13.join(runDir, "summary.md"))) errors.push(`${runDir}: missing summary.md`);
15576
16667
  const files = await readdir5(runDir);
15577
16668
  const scenarioReports = files.filter((file) => file.endsWith(".md") && file !== "summary.md");
15578
16669
  if (scenarioReports.length === 0) errors.push(`${runDir}: missing scenario report markdown`);
15579
16670
  for (const reportName of scenarioReports) {
15580
- const reportPath = path12.join(runDir, reportName);
16671
+ const reportPath = path13.join(runDir, reportName);
15581
16672
  const text5 = await readText(reportPath);
15582
16673
  for (const key of REPORT_REQUIRED_KEYS) if (!text5.includes(key)) errors.push(`${reportPath}: missing \`${key}\``);
16674
+ for (const key of REPORT_EXECUTION_KEYS) if (!text5.includes(key)) errors.push(`${reportPath}: missing \`${key}\``);
15583
16675
  for (const heading of REPORT_REQUIRED_HEADINGS) if (!text5.includes(heading)) errors.push(`${reportPath}: missing \`${heading}\``);
16676
+ const plannedCases = reportCaseList(text5, "planned_cases:");
16677
+ const executedCases = reportCaseList(text5, "executed_cases:");
16678
+ const missingExecuted = plannedCases.filter((caseId) => !executedCases.includes(caseId));
16679
+ const unexpectedExecuted = executedCases.filter((caseId) => !plannedCases.includes(caseId));
16680
+ if (plannedCases.length > 0 && missingExecuted.length > 0) {
16681
+ errors.push(`[test_suite.report.case_reconciliation] ${reportPath}: planned_cases \u4E2D\u5B58\u5728\u672A\u6267\u884C\u7528\u4F8B: ${missingExecuted.join(", ")}\uFF1B\u62A5\u544A\u5FC5\u987B\u5199\u660E blocked/not run \u539F\u56E0\u5E76\u964D\u7EA7\u7ED3\u8BBA`);
16682
+ }
16683
+ if (unexpectedExecuted.length > 0) {
16684
+ errors.push(`[test_suite.report.case_reconciliation] ${reportPath}: executed_cases \u5305\u542B\u4E0D\u5728 planned_cases \u4E2D\u7684\u7528\u4F8B: ${unexpectedExecuted.join(", ")}`);
16685
+ }
16686
+ const resultValue = reportKeyValue(text5, "result:").toLowerCase();
16687
+ if (NOT_RUN_RE.test(text5) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
16688
+ errors.push(`[test_suite.report.not_run_downgrade] ${reportPath}: \u62A5\u544A\u5B58\u5728 not-run/\u672A\u6267\u884C\u7528\u4F8B\u4F46 result \u662F\u5B8C\u6574\u7ED3\u8BBA\uFF1B\u5FC5\u987B\u964D\u7EA7\u4E3A partial/stage \u6216\u8BF4\u660E\u7528\u6237\u786E\u8BA4\u7F29\u5C0F\u8303\u56F4`);
16689
+ }
16690
+ if (PAGE_CONCLUSION_RE.test(text5) && !BROWSER_TOOL_RE.test(text5)) {
16691
+ errors.push(`[test_suite.report.page_conclusion_browser] ${reportPath}: \u9875\u9762/\u6D4F\u89C8\u5668\u7ED3\u8BBA\u5FC5\u987B\u5305\u542B browser_tool \u8BC1\u636E\uFF1BAPI/readback \u4E0D\u80FD\u5192\u5145\u9875\u9762\u9A8C\u8BC1`);
16692
+ }
16693
+ if (/browser[_ -]?blocked|浏览器阻塞|无可用浏览器工具/i.test(text5) && !/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5)) {
16694
+ errors.push(`[test_suite.report.browser_blocked] ${reportPath}: \u6D4F\u89C8\u5668\u963B\u585E\u62A5\u544A\u5FC5\u987B\u4F7F\u7528 browser_status: blocked \u6A21\u677F\uFF0C\u5E76\u505C\u6B62\u9875\u9762\u7ED3\u8BBA`);
16695
+ }
15584
16696
  const imageRefs = [...text5.matchAll(IMAGE_RE)].map((match) => match[1]);
15585
16697
  if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
15586
- const screenshotsDir = path12.join(runDir, "screenshots");
16698
+ const screenshotsDir = path13.join(runDir, "screenshots");
15587
16699
  if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
15588
16700
  for (const imageRef of imageRefs) {
15589
16701
  if (imageRef.includes("://")) {
15590
16702
  errors.push(`${reportPath}: screenshot must be a local file under this run's screenshots directory`);
15591
16703
  continue;
15592
16704
  }
15593
- const imagePath = path12.resolve(path12.dirname(reportPath), imageRef);
15594
- const screenshotsResolved = path12.resolve(screenshotsDir);
15595
- if (!imagePath.startsWith(`${screenshotsResolved}${path12.sep}`)) {
16705
+ const imagePath = path13.resolve(path13.dirname(reportPath), imageRef);
16706
+ const screenshotsResolved = path13.resolve(screenshotsDir);
16707
+ if (!imagePath.startsWith(`${screenshotsResolved}${path13.sep}`)) {
15596
16708
  errors.push(`${reportPath}: image reference must stay under this run's screenshots directory: ${imageRef}`);
15597
16709
  continue;
15598
16710
  }
@@ -15603,10 +16715,10 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
15603
16715
  return errors;
15604
16716
  }
15605
16717
  async function validateCopyDiffArtifacts(scenarioDir) {
15606
- const diffDir = path12.join(scenarioDir, COPY_DIFF_DIR);
16718
+ const diffDir = path13.join(scenarioDir, COPY_DIFF_DIR);
15607
16719
  if (!await exists3(diffDir)) return;
15608
- const manifestPath = path12.join(diffDir, "last.json");
15609
- const diffPath = path12.join(diffDir, "last.diff");
16720
+ const manifestPath = path13.join(diffDir, "last.json");
16721
+ const diffPath = path13.join(diffDir, "last.diff");
15610
16722
  if (!await exists3(manifestPath)) fail(`${scenarioDir}: ${COPY_DIFF_DIR}/last.json is required when copy diff artifacts exist`);
15611
16723
  if (!await exists3(diffPath)) fail(`${scenarioDir}: ${COPY_DIFF_DIR}/last.diff is required when copy diff artifacts exist`);
15612
16724
  let manifest;
@@ -15618,7 +16730,7 @@ async function validateCopyDiffArtifacts(scenarioDir) {
15618
16730
  for (const key of ["operation", "scenario_id", "source", "destination", "generated_at", "summary", "diff_file", "files"]) {
15619
16731
  if (!(key in manifest)) fail(`${manifestPath}: missing \`${key}\``);
15620
16732
  }
15621
- if (manifest.scenario_id !== path12.basename(scenarioDir)) fail(`${manifestPath}: scenario_id must match directory name`);
16733
+ if (manifest.scenario_id !== path13.basename(scenarioDir)) fail(`${manifestPath}: scenario_id must match directory name`);
15622
16734
  if (manifest.diff_file !== "last.diff") fail(`${manifestPath}: diff_file must be last.diff`);
15623
16735
  if (!(await readText(diffPath)).trim()) fail(`${diffPath}: copy diff must not be empty`);
15624
16736
  }
@@ -15666,8 +16778,8 @@ function registerTestSuiteCommands(program2) {
15666
16778
  }
15667
16779
 
15668
16780
  // src/core/update.ts
15669
- import { access as access2, mkdir as mkdir12, readFile as readFile16, realpath, writeFile as writeFile12 } from "fs/promises";
15670
- import path13 from "path";
16781
+ import { access as access2, mkdir as mkdir13, readFile as readFile16, realpath, writeFile as writeFile13 } from "fs/promises";
16782
+ import path14 from "path";
15671
16783
  var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
15672
16784
  var UPDATE_STATE_FILE = "update-state.json";
15673
16785
  var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -15779,7 +16891,7 @@ async function fetchLatestVersion(options = {}) {
15779
16891
  }
15780
16892
  }
15781
16893
  function updateStatePath(configDir = getConfigDir()) {
15782
- return path13.join(configDir, UPDATE_STATE_FILE);
16894
+ return path14.join(configDir, UPDATE_STATE_FILE);
15783
16895
  }
15784
16896
  async function readUpdateState(configDir) {
15785
16897
  try {
@@ -15794,8 +16906,8 @@ async function readUpdateState(configDir) {
15794
16906
  }
15795
16907
  }
15796
16908
  async function writeUpdateState(state, configDir = getConfigDir()) {
15797
- await mkdir12(configDir, { recursive: true });
15798
- await writeFile12(updateStatePath(configDir), JSON.stringify(state), "utf8");
16909
+ await mkdir13(configDir, { recursive: true });
16910
+ await writeFile13(updateStatePath(configDir), JSON.stringify(state), "utf8");
15799
16911
  }
15800
16912
  async function checkCachedUpdate(currentVersion, configDir = getConfigDir()) {
15801
16913
  if (process.env.BPMAX_CLI_NO_UPDATE_NOTIFIER) {
@@ -15847,7 +16959,7 @@ async function findNpmPath() {
15847
16959
  }
15848
16960
  function detectInstallMethod(input) {
15849
16961
  const resolvedPath = input.executablePath || "";
15850
- const method = resolvedPath.includes(`node_modules${path13.sep}`) || resolvedPath.includes("node_modules/") ? "npm" : "manual";
16962
+ const method = resolvedPath.includes(`node_modules${path14.sep}`) || resolvedPath.includes("node_modules/") ? "npm" : "manual";
15851
16963
  return {
15852
16964
  method,
15853
16965
  resolvedPath,