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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js 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.2",
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";
@@ -3939,6 +3965,26 @@ function configAdapterMatrix() {
3939
3965
  delete_capability: supportsDelete ? `${definition.capability}.delete` : null,
3940
3966
  read_endpoints: definition.readEndpoints,
3941
3967
  write_endpoints: definition.writeEndpoints,
3968
+ actions: {
3969
+ export: definition.exportStatus === "supported",
3970
+ create: supportsCreate,
3971
+ build: definition.buildStatus === "supported",
3972
+ submit: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy",
3973
+ delete: supportsDelete,
3974
+ verify: definition.exportStatus === "supported",
3975
+ dry_run: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy"
3976
+ },
3977
+ requires: {
3978
+ work_file: definition.buildStatus === "supported",
3979
+ meta_file_for_build: definition.buildStatus === "supported",
3980
+ payload_file_for_submit: definition.submitStatus === "supported" || definition.submitStatus === "requires-platform-proxy",
3981
+ base_hash_for_submit: domain === "workspace-flow"
3982
+ },
3983
+ side_effects: {
3984
+ writes_workspace_binding: domain === "workspace-flow",
3985
+ full_replacement_submit: domain === "workspace-flow",
3986
+ publishes_on_submit: domain === "form-template"
3987
+ },
3942
3988
  notes: definition.notes
3943
3989
  };
3944
3990
  });
@@ -3946,6 +3992,34 @@ function configAdapterMatrix() {
3946
3992
  function hashJson(value) {
3947
3993
  return createHash4("sha256").update(JSON.stringify(value)).digest("hex");
3948
3994
  }
3995
+ function flowAppContextEvidence(input) {
3996
+ const flowData = isRecord3(input.flow.data) ? input.flow.data : {};
3997
+ const flowType = firstNonEmpty(input.flow.flow_type, flowData.flow_type, input.flowId);
3998
+ const flowKey = firstNonEmpty(input.flow.key);
3999
+ const flowTemplateId = input.flow.id ?? input.flow.flow_id ?? null;
4000
+ const missing = [
4001
+ ["flow_type", flowType],
4002
+ ["form_template_id", input.formTemplateId],
4003
+ ["form_template_draft_id", input.formTemplateDraftId],
4004
+ ["workspace_binding", input.bindingFound ? "ok" : ""]
4005
+ ].filter(([, value]) => value === null || value === void 0 || String(value).trim() === "").map(([key]) => key);
4006
+ return {
4007
+ flow_type: flowType || null,
4008
+ flow_key: flowKey,
4009
+ flow_template_id: flowTemplateId,
4010
+ form_template_id: input.formTemplateId ?? null,
4011
+ form_template_draft_id: input.formTemplateDraftId ?? null,
4012
+ workspace_key: input.workspace,
4013
+ workspace_binding_found: input.bindingFound,
4014
+ workspace_readback_hash: hashJson(input.workspaceReadback),
4015
+ flow_readback_hash: hashJson(input.flow),
4016
+ form_template_readback_hash: input.formReadback ? hashJson(input.formReadback) : null,
4017
+ evidence_status: missing.length === 0 ? "verified" : "incomplete",
4018
+ missing_context: missing,
4019
+ resolved_by: input.resolvedBy,
4020
+ verified_at: (/* @__PURE__ */ new Date()).toISOString()
4021
+ };
4022
+ }
3949
4023
  function isRecord3(value) {
3950
4024
  return value !== null && typeof value === "object" && !Array.isArray(value);
3951
4025
  }
@@ -4063,9 +4137,9 @@ function summarizeOperationPlan(payload) {
4063
4137
  return "submit operation";
4064
4138
  }
4065
4139
  const method = typeof operation.method === "string" ? operation.method : "REQUEST";
4066
- const path14 = typeof operation.path === "string" ? operation.path : "";
4140
+ const path15 = typeof operation.path === "string" ? operation.path : "";
4067
4141
  const type = typeof operation.type === "string" ? ` ${operation.type}` : "";
4068
- return `submit${type}: ${method}${path14 ? ` ${path14}` : ""}`;
4142
+ return `submit${type}: ${method}${path15 ? ` ${path15}` : ""}`;
4069
4143
  }),
4070
4144
  ...skipped.slice(0, Math.max(0, 20 - operations.length)).map((operation) => {
4071
4145
  if (!isRecord3(operation)) {
@@ -5022,13 +5096,52 @@ function normalizeDatasetPayload(work) {
5022
5096
  }
5023
5097
  return payload;
5024
5098
  }
5099
+ function firstNonEmpty(...values) {
5100
+ for (const value of values) {
5101
+ if (value === null || value === void 0) {
5102
+ continue;
5103
+ }
5104
+ const text5 = String(value).trim();
5105
+ if (text5 !== "") {
5106
+ return text5;
5107
+ }
5108
+ }
5109
+ return "";
5110
+ }
5111
+ function exactConfirmOrDryRun(confirm3, expectedConfirm, options = {}) {
5112
+ if (confirm3 === void 0 || confirm3 === "") {
5113
+ return false;
5114
+ }
5115
+ const accepted = [expectedConfirm, ...options.equivalentConfirms || []];
5116
+ if (accepted.includes(confirm3)) {
5117
+ return true;
5118
+ }
5119
+ throw new Error(`confirmation text mismatch. expected: ${expectedConfirm}. actual: ${confirm3}.`);
5120
+ }
5121
+ function validateDatasetFieldCreatePayload(payload) {
5122
+ if (!isRecord3(payload)) {
5123
+ throw new Error("dataset-field create requires an object payload.");
5124
+ }
5125
+ const missingSource = [
5126
+ ["payload.flow_type", payload.flow_type],
5127
+ ["payload.data_set_id", payload.data_set_id],
5128
+ ["payload.source_table", payload.source_table],
5129
+ ["payload.source_field", payload.source_field],
5130
+ ["payload.source_fk", payload.source_fk]
5131
+ ].filter(([, value]) => typeof value !== "string" || value.trim() === "");
5132
+ if (missingSource.length > 0) {
5133
+ throw new Error(`dataset-field create requires dataset and source mapping fields: ${missingSource.map(([key]) => key).join(", ")}.`);
5134
+ }
5135
+ }
5025
5136
  function normalizeDatasetFieldPayload(work) {
5026
5137
  const mode = work.mode;
5027
5138
  if (mode !== void 0 && mode !== "edit" && mode !== "create") {
5028
5139
  throw new Error("dataset-field typed adapter supports mode edit or create. Delete requires a dedicated adapter.");
5029
5140
  }
5030
5141
  const source = isRecord3(work.source) ? work.source : work;
5142
+ const sourcePayload = isRecord3(work.x_wewf_source_payload) ? work.x_wewf_source_payload : {};
5031
5143
  const payload = {
5144
+ data_set_id: firstNonEmpty(work.data_set_id, work.dataSetId, work.dataset_id, sourcePayload.data_set_id, sourcePayload.dataSetId, sourcePayload.dataset_id),
5032
5145
  name: work.name || "",
5033
5146
  key: work.key || work.field || "",
5034
5147
  type: work.type || "",
@@ -5056,14 +5169,7 @@ function normalizeDatasetFieldPayload(work) {
5056
5169
  payload.sourceField = payload.source_field;
5057
5170
  payload.sourceFk = payload.source_fk;
5058
5171
  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
- }
5172
+ validateDatasetFieldCreatePayload(payload);
5067
5173
  }
5068
5174
  const advanced = isRecord3(work.advanced) ? work.advanced : {};
5069
5175
  if (Object.prototype.hasOwnProperty.call(advanced, "sourceComputed")) {
@@ -6745,6 +6851,7 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
6745
6851
  }
6746
6852
  };
6747
6853
  const expectedConfirm = `create flow-app ${name} in ${workspace}`;
6854
+ const acceptedConfirmWithWorkspacePrefix = `create flow-app ${name} in w:${workspace}`;
6748
6855
  const dryRunPlan = {
6749
6856
  operations: [
6750
6857
  { step: "create_form_template", method: "POST", path: "/form_template", payload: formPayload },
@@ -6756,9 +6863,14 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
6756
6863
  { step: "verify_workspace_binding", method: "GET", path: "/workspace/by_key", params: { key: workspace } }
6757
6864
  ]
6758
6865
  };
6759
- if (confirm3 !== expectedConfirm) {
6866
+ if (!exactConfirmOrDryRun(confirm3, expectedConfirm, { equivalentConfirms: [acceptedConfirmWithWorkspacePrefix] })) {
6760
6867
  return {
6868
+ ok: true,
6761
6869
  dry_run: true,
6870
+ operation_executed: false,
6871
+ confirm_required: true,
6872
+ expected_confirm: expectedConfirm,
6873
+ accepted_confirms: [expectedConfirm, acceptedConfirmWithWorkspacePrefix],
6762
6874
  domain: "flow-app",
6763
6875
  workspace,
6764
6876
  name,
@@ -6849,9 +6961,22 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
6849
6961
  "/workspace/by_key",
6850
6962
  { params: { key: workspace }, capability: `${workspaceDefinition.capability}.export` }
6851
6963
  );
6964
+ const workspaceBaseHash = hashJson(workspaceInfo);
6852
6965
  const existingBindings = isRecord3(workspaceInfo) ? normalizeWorkspaceFlowItems(workspaceInfo.workspace_flow) : [];
6853
6966
  const bindingKey = buildWorkspaceFlowBindingKey(flowType, "");
6854
6967
  const nextBindings = existingBindings.some((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key) === bindingKey) ? existingBindings : [...existingBindings, { flow_type: flowType, flow_key: "", only_in_workspace: 0 }];
6968
+ const workspaceGuardReadback = await apiRequest(
6969
+ client,
6970
+ "GET",
6971
+ "/workspace/by_key",
6972
+ { params: { key: workspace }, capability: `${workspaceDefinition.capability}.export` }
6973
+ );
6974
+ const workspaceGuardHash = hashJson(workspaceGuardReadback);
6975
+ if (workspaceGuardHash !== workspaceBaseHash) {
6976
+ throw new Error(
6977
+ `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.`
6978
+ );
6979
+ }
6855
6980
  const workspaceBindResponse = await apiRequest(
6856
6981
  client,
6857
6982
  "PUT",
@@ -6869,21 +6994,51 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
6869
6994
  if (!readbackBindings.some((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key) === bindingKey)) {
6870
6995
  throw new Error(`flow-app create workspace binding verification failed for ${workspace} ${bindingKey}.`);
6871
6996
  }
6997
+ const flowTemplateId = isRecord3(flowCreateResponse) ? isRecord3(flowCreateResponse.data) ? flowCreateResponse.data.id : flowCreateResponse.id : null;
6998
+ const evidence = {
6999
+ flow_type: flowType,
7000
+ flow_key: "",
7001
+ flow_template_id: flowTemplateId ?? flowType,
7002
+ form_template_id: publishedFormId,
7003
+ form_template_draft_id: draftFormId,
7004
+ workspace_key: workspace,
7005
+ workspace_binding_found: true,
7006
+ workspace_readback_hash: hashJson(workspaceReadback),
7007
+ evidence_status: "verified",
7008
+ verified_at: (/* @__PURE__ */ new Date()).toISOString()
7009
+ };
6872
7010
  return {
7011
+ ok: true,
6873
7012
  dry_run: false,
7013
+ operation_executed: true,
7014
+ confirm_required: false,
6874
7015
  domain: "flow-app",
6875
7016
  workspace,
6876
7017
  name,
7018
+ created_ids: {
7019
+ draft_form_id: draftFormId,
7020
+ published_form_id: publishedFormId,
7021
+ form_template_id: publishedFormId,
7022
+ form_template_draft_id: draftFormId,
7023
+ flow_type: flowType,
7024
+ flow_template_id: flowTemplateId ?? flowType,
7025
+ workspace
7026
+ },
6877
7027
  draft_form_id: draftFormId,
6878
7028
  published_form_id: publishedFormId,
7029
+ form_template_id: publishedFormId,
7030
+ form_template_draft_id: draftFormId,
6879
7031
  flow_type: flowType,
7032
+ flow_key: "",
7033
+ flow_template_id: flowTemplateId ?? flowType,
6880
7034
  form_response: formResponse,
6881
7035
  form_publish_response: formPublishResponse,
6882
7036
  flow_create_response: flowCreateResponse,
6883
7037
  flow_draft_response: flowDraftResponse,
6884
7038
  ...liveEndpoint ? { flow_live_response: flowLiveResponse, live_endpoint: liveEndpoint } : {},
6885
7039
  workspace_bind_response: workspaceBindResponse,
6886
- workspace_readback_hash: hashJson(workspaceReadback)
7040
+ workspace_readback_hash: hashJson(workspaceReadback),
7041
+ evidence
6887
7042
  };
6888
7043
  } catch (error) {
6889
7044
  const message = error instanceof Error ? error.message : String(error || "");
@@ -6900,6 +7055,115 @@ async function readBackConfigDomain(profile, domain, id, definition) {
6900
7055
  readback_hash: hashJson(data)
6901
7056
  };
6902
7057
  }
7058
+ async function readbackConfigDomain(config, profile, domain, id) {
7059
+ void config;
7060
+ const definition = CONFIG_DOMAINS[domain];
7061
+ if (!definition) {
7062
+ throw new Error(`Unknown config domain: ${domain}`);
7063
+ }
7064
+ const data = await readRemoteConfigDomain(profile, domain, id, definition);
7065
+ validateExpectedType(domain, definition, data);
7066
+ return {
7067
+ domain,
7068
+ id,
7069
+ readback_hash: hashJson(data),
7070
+ source_api: definition.exportPath ? `GET /api${definition.exportPath(id)}` : null,
7071
+ verified_at: (/* @__PURE__ */ new Date()).toISOString(),
7072
+ readback: data
7073
+ };
7074
+ }
7075
+ async function resolveFlowAppContextFlowId(profile, flow) {
7076
+ const trimmed = flow.trim();
7077
+ if (!trimmed) {
7078
+ throw new Error("flow-app context requires --flow <flow_type|flow_type:key|key:<key>|name>.");
7079
+ }
7080
+ if (/^flow\d+$/.test(trimmed) || trimmed.startsWith("flow_type:") || trimmed.startsWith("key:") || trimmed.includes("|") || trimmed.includes(":")) {
7081
+ return { id: trimmed, resolvedBy: "flow_id" };
7082
+ }
7083
+ const client = createApiClient(profile);
7084
+ const options = await apiRequest(client, "GET", "/flow/options", { capability: "flow.options" });
7085
+ const rows = extractListData(options);
7086
+ const matches = rows.filter((item) => String(item.name || item.title || "").trim() === trimmed);
7087
+ if (matches.length !== 1) {
7088
+ throw new Error(
7089
+ `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.`
7090
+ );
7091
+ }
7092
+ const match = matches[0];
7093
+ const flowType = firstNonEmpty(match.flow_type, match.flowType);
7094
+ const flowKey = firstNonEmpty(match.key, match.flow_key, match.flowKey);
7095
+ if (flowKey && flowType) {
7096
+ return { id: `${flowType}:${flowKey}`, resolvedBy: "flow_options_name" };
7097
+ }
7098
+ if (flowKey) {
7099
+ return { id: `key:${flowKey}`, resolvedBy: "flow_options_name" };
7100
+ }
7101
+ if (flowType) {
7102
+ return { id: flowType, resolvedBy: "flow_options_name" };
7103
+ }
7104
+ throw new Error(`flow-app context resolved flow name "${trimmed}" but the option row did not include flow_type or key.`);
7105
+ }
7106
+ async function inspectFlowAppContext(config, profile, options) {
7107
+ void config;
7108
+ const flowDefinition = CONFIG_DOMAINS["flow-template"];
7109
+ const formDefinition = CONFIG_DOMAINS["form-template"];
7110
+ const workspaceDefinition = CONFIG_DOMAINS["workspace-flow"];
7111
+ await ensureConfigCapability(profile, `${flowDefinition.capability}.export`);
7112
+ await ensureConfigCapability(profile, `${formDefinition.capability}.export`);
7113
+ await ensureConfigCapability(profile, `${workspaceDefinition.capability}.export`);
7114
+ const workspace = normalizeWorkspaceKey(options.workspace || profile.config.workspace);
7115
+ if (!workspace) {
7116
+ throw new Error("flow-app context requires --workspace <workspace>.");
7117
+ }
7118
+ const resolvedFlow = await resolveFlowAppContextFlowId(profile, options.flow);
7119
+ const flowReadback = await readRemoteConfigDomain(profile, "flow-template", resolvedFlow.id, flowDefinition);
7120
+ const flow = isRecord3(flowReadback) ? flowReadback : {};
7121
+ const data = isRecord3(flow.data) ? flow.data : {};
7122
+ const meta = isRecord3(data.meta) ? data.meta : {};
7123
+ const formTemplateId = firstNonEmpty(meta.form_template, meta.formTemplate, flow.meta_form_id, flow.metaFormId);
7124
+ let formReadback = null;
7125
+ let formTemplateDraftId = null;
7126
+ if (formTemplateId) {
7127
+ formReadback = await readRemoteConfigDomain(profile, "form-template", String(formTemplateId), formDefinition);
7128
+ if (isRecord3(formReadback)) {
7129
+ const originTemplateId = formReadback.origin_template_id ?? formReadback.originTemplateId;
7130
+ formTemplateDraftId = originTemplateId && String(originTemplateId) !== "0" ? originTemplateId : formReadback.id ?? formTemplateId;
7131
+ }
7132
+ }
7133
+ const workspaceReadback = await readRemoteConfigDomain(profile, "workspace-flow", workspace, workspaceDefinition);
7134
+ const bindings = isRecord3(workspaceReadback) ? normalizeWorkspaceFlowItems(workspaceReadback.workspace_flow) : [];
7135
+ const parsedIdentity = parseFlowIdentity(resolvedFlow.id);
7136
+ const flowType = firstNonEmpty(flow.flow_type, parsedIdentity.flowType);
7137
+ const flowKey = firstNonEmpty(flow.key, parsedIdentity.flowKey);
7138
+ const bindingFound = bindings.some((item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key) === buildWorkspaceFlowBindingKey(flowType, flowKey));
7139
+ const evidence = flowAppContextEvidence({
7140
+ workspace,
7141
+ flow,
7142
+ flowId: resolvedFlow.id,
7143
+ formTemplateId: formTemplateId || null,
7144
+ formTemplateDraftId,
7145
+ formReadback,
7146
+ workspaceReadback,
7147
+ bindingFound,
7148
+ resolvedBy: resolvedFlow.resolvedBy
7149
+ });
7150
+ return {
7151
+ domain: "flow-app",
7152
+ workspace,
7153
+ flow: options.flow,
7154
+ target_context: evidence,
7155
+ evidence,
7156
+ source: {
7157
+ flow: flowExportPath(resolvedFlow.id),
7158
+ form_template: formTemplateId ? `/form_template/${formTemplateId}` : null,
7159
+ workspace: workspaceDefinition.exportPath ? workspaceDefinition.exportPath(workspace) : null
7160
+ },
7161
+ recommended_next_commands: evidence.missing_context.length ? [
7162
+ "If form_template_id is missing, inspect the flow data.meta.form_template and publish the form binding first.",
7163
+ "If workspace_binding is missing, rebuild workspace-flow from fresh export and submit the merged binding."
7164
+ ] : []
7165
+ };
7166
+ }
6903
7167
  function comparableSubmitPayload(domain, value, options) {
6904
7168
  const comparable2 = domain === "form-template" && options.ignoreServerFields ? stripServerFilledFields(value, FORM_TEMPLATE_SERVER_FIELD_KEYS) : value;
6905
7169
  return buildDomainSubmitPayload(domain, comparable2);
@@ -7655,6 +7919,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
7655
7919
  if (domain === "list-template") {
7656
7920
  validateListTemplateActionGate(submit.payload);
7657
7921
  }
7922
+ if (domain === "dataset-field") {
7923
+ validateDatasetFieldCreatePayload(submit.payload);
7924
+ }
7658
7925
  await ensureConfigCapability(profile, `${definition.capability}.create`);
7659
7926
  const expectedConfirm2 = `submit ${domain} ${id}`;
7660
7927
  if (confirm3 !== expectedConfirm2) {
@@ -9303,6 +9570,45 @@ async function pullLatestConfigEnvironment(env, options) {
9303
9570
 
9304
9571
  // src/commands/config.ts
9305
9572
  var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
9573
+ function csvCell(value) {
9574
+ const text5 = value === null || value === void 0 ? "" : Array.isArray(value) || isRecord5(value) ? JSON.stringify(value) : String(value);
9575
+ return /[",\n\r]/.test(text5) ? `"${text5.replace(/"/g, '""')}"` : text5;
9576
+ }
9577
+ async function writeEvidenceOut(file, value) {
9578
+ if (!file) {
9579
+ return;
9580
+ }
9581
+ await mkdir8(path9.dirname(path9.resolve(file)), { recursive: true });
9582
+ const evidence = isRecord5(value.evidence) ? value.evidence : value;
9583
+ if (file.endsWith(".csv")) {
9584
+ const keys = [
9585
+ "flow_type",
9586
+ "flow_key",
9587
+ "flow_template_id",
9588
+ "form_template_id",
9589
+ "form_template_draft_id",
9590
+ "workspace_key",
9591
+ "workspace_binding_found",
9592
+ "workspace_readback_hash",
9593
+ "evidence_status",
9594
+ "verified_at"
9595
+ ];
9596
+ await writeFile8(file, `${keys.join(",")}
9597
+ ${keys.map((key) => csvCell(evidence[key])).join(",")}
9598
+ `, "utf8");
9599
+ return;
9600
+ }
9601
+ await writeFile8(file, `${JSON.stringify(evidence, null, 2)}
9602
+ `, "utf8");
9603
+ }
9604
+ async function writeResponseOut(file, value) {
9605
+ if (!file) {
9606
+ return;
9607
+ }
9608
+ await mkdir8(path9.dirname(path9.resolve(file)), { recursive: true });
9609
+ await writeFile8(file, `${JSON.stringify(value, null, 2)}
9610
+ `, "utf8");
9611
+ }
9306
9612
  async function resolveFlowTemplatePluginLintOptions(options) {
9307
9613
  const configData = await loadConfig();
9308
9614
  const profileName = options.profile || configData.current_profile || "default";
@@ -9441,9 +9747,16 @@ function registerConfigCommands(program2) {
9441
9747
  user: target.user || null
9442
9748
  });
9443
9749
  });
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) => {
9750
+ 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
9751
  void options.profile;
9446
- printResult(options.format, configAdapterMatrix());
9752
+ const rows = configAdapterMatrix();
9753
+ const filtered = options.capability ? rows.filter((row) => Object.values(row).some((value) => {
9754
+ if (Array.isArray(value)) {
9755
+ return value.includes(options.capability);
9756
+ }
9757
+ return value === options.capability;
9758
+ })) : rows;
9759
+ printResult(options.format, filtered);
9447
9760
  });
9448
9761
  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
9762
  if (domain === "adapters" && !operation) {
@@ -9543,7 +9856,23 @@ function registerConfigCommands(program2) {
9543
9856
  next: `Run git -C ${environment.sysconfig_repo_path} status --short and git diff to inspect local changes.`
9544
9857
  });
9545
9858
  });
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) => {
9859
+ const flowApp = config.command("flow-app").description("Inspect or create an end-to-end BPMAX flow app");
9860
+ const registerFlowAppContextCommand = (name) => {
9861
+ 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) => {
9862
+ const configData = await loadConfig();
9863
+ const resolved = resolveProfile(configData, options.profile);
9864
+ const result = await inspectFlowAppContext(configData, resolved, {
9865
+ workspace: options.workspace,
9866
+ flow: options.flow
9867
+ });
9868
+ await writeEvidenceOut(options.evidenceOut, result);
9869
+ await saveConfig(configData);
9870
+ printResult(options.format, result);
9871
+ });
9872
+ };
9873
+ registerFlowAppContextCommand("context");
9874
+ registerFlowAppContextCommand("inspect");
9875
+ 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
9876
  const configData = await loadConfig();
9548
9877
  const resolved = resolveProfile(configData, options.profile);
9549
9878
  const result = await createFlowAppFromWork(
@@ -9558,6 +9887,8 @@ function registerConfigCommands(program2) {
9558
9887
  publishLive: !options.draftOnly
9559
9888
  }
9560
9889
  );
9890
+ await writeResponseOut(options.responseOut, result);
9891
+ await writeEvidenceOut(options.evidenceOut, result);
9561
9892
  await saveConfig(configData);
9562
9893
  printResult(options.format, result);
9563
9894
  });
@@ -9591,9 +9922,19 @@ function registerConfigCommands(program2) {
9591
9922
  profile: resolved
9592
9923
  }));
9593
9924
  });
9925
+ 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) => {
9926
+ if (!Object.prototype.hasOwnProperty.call(CONFIG_DOMAINS, domain)) {
9927
+ throw new Error(`Unknown config domain: ${domain}`);
9928
+ }
9929
+ const configData = await loadConfig();
9930
+ const resolved = resolveProfile(configData, options.profile);
9931
+ const result = await readbackConfigDomain(configData, resolved, domain, options.id);
9932
+ await saveConfig(configData);
9933
+ printResult(options.format, result);
9934
+ });
9594
9935
  Object.keys(CONFIG_DOMAINS).forEach((domain) => {
9595
9936
  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");
9937
+ 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
9938
  if (domain === "flow-template") {
9598
9939
  createCommand.requiredOption("--work <file>", "Flow-template work JSON file").option("--agent <agent>", "Agent adapter for installed plugin lint discovery", "codex");
9599
9940
  } else {
@@ -9618,6 +9959,7 @@ function registerConfigCommands(program2) {
9618
9959
  { publishLive: Boolean(options.publishLive) }
9619
9960
  );
9620
9961
  await saveConfig(configData);
9962
+ await writeResponseOut(options.responseOut, result);
9621
9963
  printResult(options.format, result);
9622
9964
  });
9623
9965
  if (domain === "project-detail-template") {
@@ -9694,7 +10036,7 @@ function registerConfigCommands(program2) {
9694
10036
  submit_preview: submit || null
9695
10037
  });
9696
10038
  });
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) => {
10039
+ 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
10040
  const configData = await loadConfig();
9699
10041
  const resolved = resolveProfile(configData, options.profile);
9700
10042
  const result = await submitConfigDomain(
@@ -9707,6 +10049,7 @@ function registerConfigCommands(program2) {
9707
10049
  { publishLive: Boolean(options.publishLive), agent: options.agent || "codex" }
9708
10050
  );
9709
10051
  await saveConfig(configData);
10052
+ await writeResponseOut(options.responseOut, result);
9710
10053
  printResult(options.format, result);
9711
10054
  });
9712
10055
  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) => {
@@ -9784,8 +10127,8 @@ function registerConfigCommands(program2) {
9784
10127
 
9785
10128
  // src/commands/e2e.ts
9786
10129
  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";
10130
+ import { mkdir as mkdir9, readFile as readFile11, readdir as readdir3, stat as stat5, writeFile as writeFile9 } from "fs/promises";
10131
+ import path10 from "path";
9789
10132
 
9790
10133
  // src/core/form-schema.ts
9791
10134
  var FIELD_KEY_NAMES = [
@@ -10718,18 +11061,18 @@ function timestampSlug() {
10718
11061
  return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
10719
11062
  }
10720
11063
  async function ensureDir(dir) {
10721
- const resolved = path9.resolve(dir);
10722
- await mkdir8(resolved, { recursive: true });
11064
+ const resolved = path10.resolve(dir);
11065
+ await mkdir9(resolved, { recursive: true });
10723
11066
  return resolved;
10724
11067
  }
10725
11068
  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)}
11069
+ const file = path10.join(await ensureDir(dir), name);
11070
+ await writeFile9(file, `${JSON.stringify(redactAuditValue(value), null, 2)}
10728
11071
  `, "utf8");
10729
11072
  return file;
10730
11073
  }
10731
11074
  function cacheRoot() {
10732
- return path9.resolve(".codex/cache/bpmax-e2e");
11075
+ return path10.resolve(".codex/cache/bpmax-e2e");
10733
11076
  }
10734
11077
  function safeSegment(value) {
10735
11078
  return value.trim().replace(/[^a-zA-Z0-9._:-]+/g, "_") || "default";
@@ -10841,7 +11184,7 @@ function buildExpectedChecks(options) {
10841
11184
  ];
10842
11185
  }
10843
11186
  function flowCachePath(profileName, flowId) {
10844
- return path9.join(cacheRoot(), "profiles", safeSegment(profileName), "flows", `${safeSegment(flowId)}.json`);
11187
+ return path10.join(cacheRoot(), "profiles", safeSegment(profileName), "flows", `${safeSegment(flowId)}.json`);
10845
11188
  }
10846
11189
  async function readOptionalJson(file) {
10847
11190
  try {
@@ -10930,7 +11273,7 @@ function dataProfilePath(input) {
10930
11273
  if (!input?.startsWith("@")) {
10931
11274
  return void 0;
10932
11275
  }
10933
- return path9.resolve(input.slice(1));
11276
+ return path10.resolve(input.slice(1));
10934
11277
  }
10935
11278
  function refreshedStepTemplate(options) {
10936
11279
  return {
@@ -10954,15 +11297,15 @@ function refreshedStepTemplate(options) {
10954
11297
  variables: Object.keys(options.plan.data).filter((key) => !["project_id", "action", "urgency"].includes(key)),
10955
11298
  payload_template: options.plan.data,
10956
11299
  source_evidence: {
10957
- evidence_dir: path9.resolve(options.evidenceDir),
10958
- context: path9.basename(options.contextFile)
11300
+ evidence_dir: path10.resolve(options.evidenceDir),
11301
+ context: path10.basename(options.contextFile)
10959
11302
  }
10960
11303
  };
10961
11304
  }
10962
11305
  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)}
11306
+ const out = path10.resolve(file);
11307
+ await mkdir9(path10.dirname(out), { recursive: true });
11308
+ await writeFile9(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
10966
11309
  `, "utf8");
10967
11310
  return out;
10968
11311
  }
@@ -11039,13 +11382,13 @@ test(${JSON.stringify(options.title)}, async ({ page }) => {
11039
11382
  async function writeBrowserTemplate(options) {
11040
11383
  const handoffUrl = handoffUrlFromInput(options.handoff);
11041
11384
  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({
11385
+ const out = path10.resolve(options.out);
11386
+ await mkdir9(path10.dirname(out), { recursive: true });
11387
+ await writeFile9(out, playwrightTemplate({
11045
11388
  title: options.title ?? "BPMAX create page handoff submit",
11046
11389
  handoffUrl,
11047
11390
  assertFields,
11048
- evidenceDir: path9.resolve(options.evidenceDir)
11391
+ evidenceDir: path10.resolve(options.evidenceDir)
11049
11392
  }), "utf8");
11050
11393
  return { out, handoff_url: handoffUrl, assert_fields: assertFields };
11051
11394
  }
@@ -11208,7 +11551,7 @@ function registerE2eCommands(program2) {
11208
11551
  mode: "handoff_command_hint",
11209
11552
  browser: options.browser,
11210
11553
  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`,
11554
+ 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
11555
  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
11556
  });
11214
11557
  return;
@@ -11227,7 +11570,7 @@ function registerE2eCommands(program2) {
11227
11570
  browser_verified: false,
11228
11571
  browser: options.browser,
11229
11572
  ...generated,
11230
- evidence_dir: path9.resolve(options.evidenceDir),
11573
+ evidence_dir: path10.resolve(options.evidenceDir),
11231
11574
  next_command: `npx playwright test ${generated.out}`,
11232
11575
  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
11576
  });
@@ -11278,8 +11621,8 @@ function registerE2eCommands(program2) {
11278
11621
  template_id: result.template_id ?? result.templateId
11279
11622
  })).digest("hex").slice(0, 16);
11280
11623
  const file = flowCachePath(profile.name, options.flowId);
11281
- await mkdir8(path9.dirname(file), { recursive: true });
11282
- await writeFile8(file, `${JSON.stringify(redactAuditValue({
11624
+ await mkdir9(path10.dirname(file), { recursive: true });
11625
+ await writeFile9(file, `${JSON.stringify(redactAuditValue({
11283
11626
  cache_key: cacheKey,
11284
11627
  cached_at: (/* @__PURE__ */ new Date()).toISOString(),
11285
11628
  profile: profile.name,
@@ -11309,7 +11652,7 @@ function registerE2eCommands(program2) {
11309
11652
  printResult(options.format, {
11310
11653
  ok: true,
11311
11654
  ...generated,
11312
- evidence_dir: path9.resolve(options.evidenceDir),
11655
+ evidence_dir: path10.resolve(options.evidenceDir),
11313
11656
  next_command: `npx playwright test ${generated.out}`
11314
11657
  });
11315
11658
  });
@@ -11321,8 +11664,8 @@ function registerE2eCommands(program2) {
11321
11664
  if (inferredStepId && !contextFile && !submitFile) {
11322
11665
  throw new Error(`No step evidence files found for step ${inferredStepId} in ${options.evidenceDir}.`);
11323
11666
  }
11324
- const context = contextFile ? await readOptionalJson(path9.join(options.evidenceDir, contextFile)) : null;
11325
- const submit = submitFile ? await readOptionalJson(path9.join(options.evidenceDir, submitFile)) : null;
11667
+ const context = contextFile ? await readOptionalJson(path10.join(options.evidenceDir, contextFile)) : null;
11668
+ const submit = submitFile ? await readOptionalJson(path10.join(options.evidenceDir, submitFile)) : null;
11326
11669
  const requirements = isRecord8(context?.requirements) ? context.requirements : {};
11327
11670
  const requiredInputs = Array.isArray(requirements.required_inputs) ? requirements.required_inputs.filter(isRecord8) : [];
11328
11671
  const missingInputs = Array.isArray(requirements.missing_required_inputs) ? requirements.missing_required_inputs.filter(isRecord8) : [];
@@ -11365,16 +11708,16 @@ function registerE2eCommands(program2) {
11365
11708
  variables: Object.keys(requestData).filter((key) => !["project_id", "action", "urgency"].includes(key)),
11366
11709
  payload_template: requestData,
11367
11710
  source_evidence: {
11368
- evidence_dir: path9.resolve(options.evidenceDir),
11711
+ evidence_dir: path10.resolve(options.evidenceDir),
11369
11712
  ...contextFile ? { context: contextFile } : {},
11370
11713
  ...submitFile ? { submit: submitFile } : {}
11371
11714
  }
11372
11715
  } : {
11373
- name: options.name ?? path9.basename(path9.resolve(options.evidenceDir)),
11716
+ name: options.name ?? path10.basename(path10.resolve(options.evidenceDir)),
11374
11717
  generated_at: (/* @__PURE__ */ new Date()).toISOString(),
11375
11718
  submit_mode: "browser_evidence_bootstrap",
11376
11719
  source_evidence: {
11377
- evidence_dir: path9.resolve(options.evidenceDir),
11720
+ evidence_dir: path10.resolve(options.evidenceDir),
11378
11721
  files: evidenceFiles
11379
11722
  },
11380
11723
  reuse_requirements: [
@@ -11383,9 +11726,9 @@ function registerE2eCommands(program2) {
11383
11726
  "Do not treat API-only evidence as browser E2E proof."
11384
11727
  ]
11385
11728
  };
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)}
11729
+ const out = path10.resolve(options.out);
11730
+ await mkdir9(path10.dirname(out), { recursive: true });
11731
+ await writeFile9(out, `${JSON.stringify(redactAuditValue(template), null, 2)}
11389
11732
  `, "utf8");
11390
11733
  printResult(options.format, {
11391
11734
  ok: true,
@@ -11545,7 +11888,7 @@ function registerFlowCommands(program2) {
11545
11888
  const client = createApiClient(profile);
11546
11889
  if (options.flowType) {
11547
11890
  const bindings = await getWorkspaceFlowBindings(client, profile, options);
11548
- const path14 = options.flowKey ? "/flow/options" : "/flow/flow_type";
11891
+ const path15 = options.flowKey ? "/flow/options" : "/flow/flow_type";
11549
11892
  const params = options.flowKey ? {
11550
11893
  detail: "1"
11551
11894
  } : {
@@ -11555,7 +11898,7 @@ function registerFlowCommands(program2) {
11555
11898
  const result2 = await apiRequest(
11556
11899
  client,
11557
11900
  "GET",
11558
- path14,
11901
+ path15,
11559
11902
  {
11560
11903
  params
11561
11904
  }
@@ -11812,10 +12155,10 @@ async function parseOptionalJson(input, label) {
11812
12155
  }
11813
12156
  return parseJsonInput(input, label);
11814
12157
  }
11815
- async function memoryRequest(options, method, path14, capability, data, params) {
12158
+ async function memoryRequest(options, method, path15, capability, data, params) {
11816
12159
  const profile = resolveProfile(await loadConfig(), options.profile);
11817
12160
  const client = createApiClient(profile);
11818
- return apiRequest(client, method, path14, {
12161
+ return apiRequest(client, method, path15, {
11819
12162
  capability,
11820
12163
  data: redactAuditValue(data),
11821
12164
  params: params ? redactAuditValue(params) : void 0
@@ -11897,15 +12240,15 @@ async function parseSeedRules(input) {
11897
12240
  });
11898
12241
  return rules;
11899
12242
  }
11900
- function collectUuidPaths(value, path14 = "$") {
12243
+ function collectUuidPaths(value, path15 = "$") {
11901
12244
  if (typeof value === "string") {
11902
- return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [path14] : [];
12245
+ return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [path15] : [];
11903
12246
  }
11904
12247
  if (Array.isArray(value)) {
11905
- return value.flatMap((item, index) => collectUuidPaths(item, `${path14}[${index}]`));
12248
+ return value.flatMap((item, index) => collectUuidPaths(item, `${path15}[${index}]`));
11906
12249
  }
11907
12250
  if (typeof value === "object" && value !== null) {
11908
- return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${path14}.${key}`));
12251
+ return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${path15}.${key}`));
11909
12252
  }
11910
12253
  return [];
11911
12254
  }
@@ -11934,16 +12277,16 @@ function dataArray(value) {
11934
12277
  if (isRecord10(value) && Array.isArray(value.data)) return value.data;
11935
12278
  return [];
11936
12279
  }
11937
- function collectMatrixOwnerPaths(value, path14 = "$") {
12280
+ function collectMatrixOwnerPaths(value, path15 = "$") {
11938
12281
  if (Array.isArray(value)) {
11939
- return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${path14}[${index}]`));
12282
+ return value.flatMap((item, index) => collectMatrixOwnerPaths(item, `${path15}[${index}]`));
11940
12283
  }
11941
12284
  if (!isRecord10(value)) {
11942
12285
  return [];
11943
12286
  }
11944
12287
  const matches = [];
11945
12288
  Object.entries(value).forEach(([key, child]) => {
11946
- const childPath = `${path14}.${key}`;
12289
+ const childPath = `${path15}.${key}`;
11947
12290
  if (key.includes("matrix_owner") || typeof child === "string" && child.includes("matrix_owner")) {
11948
12291
  matches.push({ path: childPath, value: child });
11949
12292
  }
@@ -12772,9 +13115,9 @@ function contextField(field, reason, options = {}) {
12772
13115
  function collectPrefillContextForFields(fields, form, result, options = {}) {
12773
13116
  for (const field of fields) {
12774
13117
  const value = form[field.key];
12775
- const path14 = options.prefix ? `${options.prefix}.${field.key}` : field.key;
13118
+ const path15 = options.prefix ? `${options.prefix}.${field.key}` : field.key;
12776
13119
  const fieldOptions = {
12777
- path: path14,
13120
+ path: path15,
12778
13121
  rootKey: options.rootKey ?? field.key,
12779
13122
  parentKey: options.parentKey
12780
13123
  };
@@ -13191,8 +13534,8 @@ import { spawn as spawn2 } from "child_process";
13191
13534
  import { fileURLToPath as fileURLToPath3 } from "url";
13192
13535
 
13193
13536
  // 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";
13537
+ import { access, mkdir as mkdir10, readdir as readdir4, readFile as readFile13, writeFile as writeFile10 } from "fs/promises";
13538
+ import path11 from "path";
13196
13539
  var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
13197
13540
  var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
13198
13541
  function assertSafeName(kind, value) {
@@ -13216,12 +13559,12 @@ function resolveRecipeLocation(options) {
13216
13559
  workspace,
13217
13560
  workspaceDirName,
13218
13561
  recipeName: options.recipeName,
13219
- recipeDir: path10.join(profileDir, "recipes", workspaceDirName, options.recipeName)
13562
+ recipeDir: path11.join(profileDir, "recipes", workspaceDirName, options.recipeName)
13220
13563
  };
13221
13564
  }
13222
13565
  function getRecipesDir(options) {
13223
13566
  const workspaceDirName = normalizeWorkspaceForPath(options.workspace || DEFAULT_WORKSPACE);
13224
- return path10.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
13567
+ return path11.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
13225
13568
  }
13226
13569
  function isRecord13(value) {
13227
13570
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -13273,7 +13616,7 @@ function parseRecipeDefinition(input) {
13273
13616
  };
13274
13617
  }
13275
13618
  async function loadRecipe(recipeDir) {
13276
- const raw = await readFile13(path10.join(recipeDir, "recipe.json"), "utf8");
13619
+ const raw = await readFile13(path11.join(recipeDir, "recipe.json"), "utf8");
13277
13620
  return parseRecipeDefinition(JSON.parse(raw));
13278
13621
  }
13279
13622
  async function listRecipes(recipesDir) {
@@ -13291,7 +13634,7 @@ async function listRecipes(recipesDir) {
13291
13634
  if (!RECIPE_NAME_PATTERN.test(entry)) {
13292
13635
  continue;
13293
13636
  }
13294
- const recipeDir = path10.join(recipesDir, entry);
13637
+ const recipeDir = path11.join(recipesDir, entry);
13295
13638
  try {
13296
13639
  const recipe = await loadRecipe(recipeDir);
13297
13640
  summaries.push({
@@ -13357,12 +13700,12 @@ function renderTemplate(template, variables) {
13357
13700
  }
13358
13701
  function resolveRecipeFile(recipeDir, token) {
13359
13702
  const relative = token.slice(1);
13360
- if (!relative || relative.includes("..") || path10.isAbsolute(relative)) {
13703
+ if (!relative || relative.includes("..") || path11.isAbsolute(relative)) {
13361
13704
  throw new Error(`Unsafe recipe file reference: ${token}`);
13362
13705
  }
13363
- const resolved = path10.resolve(recipeDir, relative);
13364
- const root = path10.resolve(recipeDir);
13365
- if (resolved !== root && !resolved.startsWith(`${root}${path10.sep}`)) {
13706
+ const resolved = path11.resolve(recipeDir, relative);
13707
+ const root = path11.resolve(recipeDir);
13708
+ if (resolved !== root && !resolved.startsWith(`${root}${path11.sep}`)) {
13366
13709
  throw new Error(`Recipe file reference escapes recipe directory: ${token}`);
13367
13710
  }
13368
13711
  return resolved;
@@ -13398,7 +13741,7 @@ async function ensureEmptyOrForce(targetDir, force = false) {
13398
13741
  }
13399
13742
  async function writeRecipeScaffold(options) {
13400
13743
  await ensureEmptyOrForce(options.location.recipeDir, options.force);
13401
- await mkdir9(options.location.recipeDir, { recursive: true });
13744
+ await mkdir10(options.location.recipeDir, { recursive: true });
13402
13745
  const title = options.title || options.location.recipeName;
13403
13746
  const recipe = {
13404
13747
  version: 1,
@@ -13415,16 +13758,16 @@ async function writeRecipeScaffold(options) {
13415
13758
  mutating: true
13416
13759
  }
13417
13760
  };
13418
- await writeFile9(path10.join(options.location.recipeDir, "recipe.json"), `${JSON.stringify(recipe, null, 2)}
13761
+ await writeFile10(path11.join(options.location.recipeDir, "recipe.json"), `${JSON.stringify(recipe, null, 2)}
13419
13762
  `, "utf8");
13420
- await writeFile9(
13421
- path10.join(options.location.recipeDir, "payload.json"),
13763
+ await writeFile10(
13764
+ path11.join(options.location.recipeDir, "payload.json"),
13422
13765
  `${JSON.stringify({ form: {} }, null, 2)}
13423
13766
  `,
13424
13767
  "utf8"
13425
13768
  );
13426
- await writeFile9(
13427
- path10.join(options.location.recipeDir, "README.md"),
13769
+ await writeFile10(
13770
+ path11.join(options.location.recipeDir, "README.md"),
13428
13771
  [`# ${title}`, "", "Describe the BPMAX flow, field mapping, prerequisites, and verification steps for this recipe.", ""].join("\n"),
13429
13772
  "utf8"
13430
13773
  );
@@ -13830,8 +14173,8 @@ function registerSetupCommand(program2, deps = {}) {
13830
14173
  }
13831
14174
 
13832
14175
  // src/core/taskbook.ts
13833
- import { mkdir as mkdir10, readFile as readFile14, writeFile as writeFile10 } from "fs/promises";
13834
- import path11 from "path";
14176
+ import { mkdir as mkdir11, readFile as readFile14, writeFile as writeFile11 } from "fs/promises";
14177
+ import path12 from "path";
13835
14178
  var TaskbookError = class extends Error {
13836
14179
  };
13837
14180
  var REQUIRED_TASKBOOK_TERMS = [
@@ -14026,14 +14369,14 @@ function hasDomainWriteEvidence(domain, evidenceText, patterns) {
14026
14369
  function uuidValues(text5) {
14027
14370
  return [...new Set([...text5.matchAll(UUID_PATTERN)].map((match) => match[0]))];
14028
14371
  }
14029
- function addUuidIssues(text5, issues, path14) {
14372
+ function addUuidIssues(text5, issues, path15) {
14030
14373
  for (const value of uuidValues(text5)) {
14031
14374
  addTaskbookIssue(
14032
14375
  issues,
14033
14376
  "uuid_not_allowed",
14034
14377
  "taskbook.config.no_uuid",
14035
14378
  `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" }
14379
+ { 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
14380
  );
14038
14381
  }
14039
14382
  }
@@ -14065,7 +14408,7 @@ function findNavigationStrategy(text5) {
14065
14408
  const matches = [...text5.matchAll(/导航入口策略\s*[::]\s*(nav-config:(?:included|skipped:[^\s|,。]+|deferred:[^\s|,。]+))/gi)];
14066
14409
  return matches.at(-1)?.[1] || null;
14067
14410
  }
14068
- function validateNavigationStrategy(text5, issues, path14, subject) {
14411
+ function validateNavigationStrategy(text5, issues, path15, subject) {
14069
14412
  const strategy = findNavigationStrategy(text5);
14070
14413
  if (!strategy) {
14071
14414
  addTaskbookIssue(
@@ -14073,7 +14416,7 @@ function validateNavigationStrategy(text5, issues, path14, subject) {
14073
14416
  "missing_navigation_strategy",
14074
14417
  "taskbook.nav.strategy",
14075
14418
  `${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" }
14419
+ { 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
14420
  );
14078
14421
  return null;
14079
14422
  }
@@ -14083,7 +14426,7 @@ function validateNavigationStrategy(text5, issues, path14, subject) {
14083
14426
  "empty_navigation_strategy_reason",
14084
14427
  "taskbook.nav.strategy_reason",
14085
14428
  `${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" }
14429
+ { path: path15, suggestion: "\u4F7F\u7528 nav-config:skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 nav-config:deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
14087
14430
  );
14088
14431
  }
14089
14432
  if (/(待完成范围确认后回填|待确认|TODO|TBD|占位)/i.test(strategy)) {
@@ -14092,7 +14435,7 @@ function validateNavigationStrategy(text5, issues, path14, subject) {
14092
14435
  "placeholder_navigation_strategy",
14093
14436
  "taskbook.nav.strategy_placeholder",
14094
14437
  `${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" }
14438
+ { path: path15, suggestion: "\u66FF\u6362\u4E3A included\u3001skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
14096
14439
  );
14097
14440
  }
14098
14441
  return strategy;
@@ -14549,8 +14892,8 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
14549
14892
  }
14550
14893
  async function initTaskbook(outFile, title) {
14551
14894
  const content = taskbookTemplate(title);
14552
- await mkdir10(path11.dirname(outFile), { recursive: true });
14553
- await writeFile10(outFile, content, "utf8");
14895
+ await mkdir11(path12.dirname(outFile), { recursive: true });
14896
+ await writeFile11(outFile, content, "utf8");
14554
14897
  return { out: outFile, bytes: Buffer.byteLength(content) };
14555
14898
  }
14556
14899
  function splitMarkdownRow(line) {
@@ -14639,8 +14982,8 @@ async function initTaskbookProgress(source, outFile) {
14639
14982
  fields.join(","),
14640
14983
  ...rows.map((row) => fields.map((field) => csvEscape(field === "status" ? "\u672A\u5F00\u59CB" : row[field] || "")).join(","))
14641
14984
  ].join("\n") + "\n";
14642
- await mkdir10(path11.dirname(outFile), { recursive: true });
14643
- await writeFile10(outFile, csv, "utf8");
14985
+ await mkdir11(path12.dirname(outFile), { recursive: true });
14986
+ await writeFile11(outFile, csv, "utf8");
14644
14987
  return { source, out: outFile, task_count: rows.length };
14645
14988
  }
14646
14989
 
@@ -14686,14 +15029,14 @@ import { createHash as createHash6 } from "crypto";
14686
15029
  import {
14687
15030
  copyFile,
14688
15031
  cp as cp3,
14689
- mkdir as mkdir11,
15032
+ mkdir as mkdir12,
14690
15033
  readdir as readdir5,
14691
15034
  readFile as readFile15,
14692
15035
  rm as rm4,
14693
15036
  stat as stat6,
14694
- writeFile as writeFile11
15037
+ writeFile as writeFile12
14695
15038
  } from "fs/promises";
14696
- import path12 from "path";
15039
+ import path13 from "path";
14697
15040
  var DEFAULT_SUITE_ROOT = ".ai_test/suite";
14698
15041
  var DEFAULT_DRAFT_ROOT = ".ai_test/suite_draft";
14699
15042
  var DEFAULT_REPORT_ROOT = ".ai_test/report";
@@ -14851,12 +15194,12 @@ function reviewSchemaExplanation() {
14851
15194
  };
14852
15195
  }
14853
15196
  function reviewFail(reviewPath, message) {
14854
- const scenarioId = path12.basename(path12.dirname(reviewPath));
15197
+ const scenarioId = path13.basename(path13.dirname(reviewPath));
14855
15198
  fail(
14856
15199
  [
14857
15200
  message,
14858
15201
  "\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`,
15202
+ `\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
15203
  `\u6700\u5C0F review.json \u793A\u4F8B\uFF1A${JSON.stringify(reviewSchemaExample(scenarioId))}`
14861
15204
  ].join("\n"),
14862
15205
  {
@@ -14945,14 +15288,14 @@ function parseReadmeText(filePath, text5) {
14945
15288
  return metadata;
14946
15289
  }
14947
15290
  async function validateReadme(scenarioDir) {
14948
- const readmePath = path12.join(scenarioDir, "README.md");
15291
+ const readmePath = path13.join(scenarioDir, "README.md");
14949
15292
  if (!await exists3(readmePath)) fail(`missing README.md: ${readmePath}`);
14950
15293
  const text5 = await readText(readmePath);
14951
15294
  const metadata = parseReadmeText(readmePath, text5);
14952
15295
  for (const key of REQUIRED_README_KEYS) {
14953
15296
  if (!metadata[key]) fail(`${scenarioDir}: README.md missing \`${key}\``);
14954
15297
  }
14955
- if (metadata.scenario_id !== path12.basename(scenarioDir)) fail(`${scenarioDir}: scenario_id must match directory name`);
15298
+ if (metadata.scenario_id !== path13.basename(scenarioDir)) fail(`${scenarioDir}: scenario_id must match directory name`);
14956
15299
  if (!["true", "false"].includes(metadata.core.toLowerCase())) fail(`${scenarioDir}: core must be true or false`);
14957
15300
  if (!STATUSES.has(metadata.status)) fail(`${scenarioDir}: status must be one of ${JSON.stringify([...STATUSES].sort())}`);
14958
15301
  if (UUID_RE2.test(text5) || ID_AS_ENTRY_RE.test(text5)) {
@@ -15115,8 +15458,8 @@ async function collectE2eAccelerationGaps(root) {
15115
15458
  const dirs = await scenarioDirs(root);
15116
15459
  const gaps = [];
15117
15460
  for (const dir of dirs) {
15118
- const scenarioId = path12.basename(dir);
15119
- const casesPath = path12.join(dir, "cases.csv");
15461
+ const scenarioId = path13.basename(dir);
15462
+ const casesPath = path13.join(dir, "cases.csv");
15120
15463
  if (!await exists3(casesPath)) {
15121
15464
  continue;
15122
15465
  }
@@ -15139,11 +15482,11 @@ async function collectE2eAccelerationGaps(root) {
15139
15482
  async function scenarioDirs(root) {
15140
15483
  if (!await exists3(root)) return [];
15141
15484
  const items = await readdir5(root, { withFileTypes: true });
15142
- return items.filter((item) => item.isDirectory()).map((item) => path12.join(root, item.name)).sort();
15485
+ return items.filter((item) => item.isDirectory()).map((item) => path13.join(root, item.name)).sort();
15143
15486
  }
15144
15487
  async function validateScenario(scenarioDir) {
15145
15488
  const metadata = await validateReadme(scenarioDir);
15146
- const casesPath = path12.join(scenarioDir, "cases.csv");
15489
+ const casesPath = path13.join(scenarioDir, "cases.csv");
15147
15490
  const rows = await readCases(casesPath);
15148
15491
  if (rows.length === 0) fail(`${casesPath}: at least one case is required`);
15149
15492
  const seen = /* @__PURE__ */ new Set();
@@ -15227,9 +15570,9 @@ function validateLatestProofObject(proofPath, proof) {
15227
15570
  }
15228
15571
  function scenarioPath(root, scenario) {
15229
15572
  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) {
15573
+ const rootResolved = path13.resolve(root);
15574
+ const candidate = path13.resolve(root, scenario);
15575
+ if (!candidate.startsWith(`${rootResolved}${path13.sep}`) && candidate !== rootResolved) {
15233
15576
  fail(`scenario path escapes root: ${candidate}`);
15234
15577
  }
15235
15578
  return candidate;
@@ -15238,13 +15581,13 @@ async function fileMap(root) {
15238
15581
  const result = /* @__PURE__ */ new Map();
15239
15582
  async function walk(dir) {
15240
15583
  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;
15584
+ const itemPath = path13.join(dir, item.name);
15585
+ const rel = path13.relative(root, itemPath);
15586
+ if (rel.split(path13.sep)[0] === COPY_DIFF_DIR) continue;
15244
15587
  if (item.isDirectory()) {
15245
15588
  await walk(itemPath);
15246
15589
  } else if (item.isFile()) {
15247
- result.set(rel.split(path12.sep).join("/"), itemPath);
15590
+ result.set(rel.split(path13.sep).join("/"), itemPath);
15248
15591
  }
15249
15592
  }
15250
15593
  }
@@ -15315,7 +15658,7 @@ async function buildCopyDiff(src, dst, operation) {
15315
15658
  return {
15316
15659
  manifest: {
15317
15660
  operation,
15318
- scenario_id: path12.basename(src),
15661
+ scenario_id: path13.basename(src),
15319
15662
  source: src,
15320
15663
  destination: dst,
15321
15664
  generated_at: (/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/, "+00:00"),
@@ -15328,12 +15671,12 @@ async function buildCopyDiff(src, dst, operation) {
15328
15671
  };
15329
15672
  }
15330
15673
  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)}
15674
+ const diffDir = path13.join(dst, COPY_DIFF_DIR);
15675
+ await mkdir12(diffDir, { recursive: true });
15676
+ await writeFile12(path13.join(diffDir, "last.diff"), artifacts.diff, "utf8");
15677
+ await writeFile12(path13.join(diffDir, "last.json"), `${JSON.stringify(artifacts.manifest, null, 2)}
15335
15678
  `, "utf8");
15336
- return path12.join(diffDir, "last.diff");
15679
+ return path13.join(diffDir, "last.diff");
15337
15680
  }
15338
15681
  function summarizeCopyDiff(artifacts) {
15339
15682
  const files = Array.isArray(artifacts.manifest.files) ? artifacts.manifest.files : [];
@@ -15359,14 +15702,14 @@ async function copyScenarioTree(src, dst, replace, operation) {
15359
15702
  artifacts = await buildCopyDiff(src, dst, operation);
15360
15703
  await rm4(dst, { recursive: true, force: true });
15361
15704
  }
15362
- await mkdir11(path12.dirname(dst), { recursive: true });
15705
+ await mkdir12(path13.dirname(dst), { recursive: true });
15363
15706
  await cp3(src, dst, { recursive: true });
15364
15707
  return artifacts ? { path: await writeCopyDiffArtifacts(dst, artifacts), summary: summarizeCopyDiff(artifacts) } : {};
15365
15708
  }
15366
15709
  async function copyDiffPreview(src, dst, operation) {
15367
- const previewDir = path12.join(DEFAULT_TMP_ROOT, `${operation}-${path12.basename(src)}-copy-diff`);
15710
+ const previewDir = path13.join(DEFAULT_TMP_ROOT, `${operation}-${path13.basename(src)}-copy-diff`);
15368
15711
  await rm4(previewDir, { recursive: true, force: true });
15369
- await mkdir11(previewDir, { recursive: true });
15712
+ await mkdir12(previewDir, { recursive: true });
15370
15713
  const artifacts = await buildCopyDiff(src, dst, operation);
15371
15714
  return { path: await writeCopyDiffArtifacts(previewDir, artifacts), summary: summarizeCopyDiff(artifacts) };
15372
15715
  }
@@ -15386,7 +15729,7 @@ async function draftUpdate(options) {
15386
15729
  return { destination: dst, copy_diff: copyDiff.path, copy_diff_summary: copyDiff.summary };
15387
15730
  }
15388
15731
  async function validateReviewGate(scenarioDir) {
15389
- const reviewPath = path12.join(scenarioDir, "review.json");
15732
+ const reviewPath = path13.join(scenarioDir, "review.json");
15390
15733
  if (!await exists3(reviewPath)) reviewFail(reviewPath, `${scenarioDir}: missing review.json; run multi-subagent SKILL review before promote`);
15391
15734
  let review;
15392
15735
  try {
@@ -15394,7 +15737,7 @@ async function validateReviewGate(scenarioDir) {
15394
15737
  } catch (error) {
15395
15738
  reviewFail(reviewPath, `${reviewPath}: invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
15396
15739
  }
15397
- if (review.scenario_id !== path12.basename(scenarioDir)) reviewFail(reviewPath, `${reviewPath}: scenario_id must match directory name`);
15740
+ if (review.scenario_id !== path13.basename(scenarioDir)) reviewFail(reviewPath, `${reviewPath}: scenario_id must match directory name`);
15398
15741
  if (!review.latest_proof || typeof review.latest_proof !== "object" || Array.isArray(review.latest_proof)) reviewFail(reviewPath, `${reviewPath}: latest_proof is required`);
15399
15742
  validateLatestProofObject(reviewPath, review.latest_proof);
15400
15743
  if (!REVIEW_STATUSES.has(String(review.status))) reviewFail(reviewPath, `${reviewPath}: status must be one of ${JSON.stringify([...REVIEW_STATUSES].sort())}`);
@@ -15503,9 +15846,9 @@ async function initOrRepairReview(options) {
15503
15846
  const scenarioDir = scenarioPath(options.draftRoot ?? DEFAULT_DRAFT_ROOT, options.scenario);
15504
15847
  if (!await exists3(scenarioDir)) fail(`draft scenario not found: ${scenarioDir}`);
15505
15848
  await validateReadme(scenarioDir);
15506
- const rows = await readCases(path12.join(scenarioDir, "cases.csv"));
15849
+ const rows = await readCases(path13.join(scenarioDir, "cases.csv"));
15507
15850
  const proof = await readLatestProof(options.latestProof);
15508
- const reviewPath = path12.join(scenarioDir, "review.json");
15851
+ const reviewPath = path13.join(scenarioDir, "review.json");
15509
15852
  let existing;
15510
15853
  const existed = await exists3(reviewPath);
15511
15854
  if (existed) {
@@ -15516,8 +15859,8 @@ async function initOrRepairReview(options) {
15516
15859
  existing = {};
15517
15860
  }
15518
15861
  }
15519
- const review = mergeReviewDraft(path12.basename(scenarioDir), proof, rows, existing);
15520
- await writeFile11(reviewPath, `${JSON.stringify(review, null, 2)}
15862
+ const review = mergeReviewDraft(path13.basename(scenarioDir), proof, rows, existing);
15863
+ await writeFile12(reviewPath, `${JSON.stringify(review, null, 2)}
15521
15864
  `, "utf8");
15522
15865
  return {
15523
15866
  ok: true,
@@ -15551,13 +15894,13 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
15551
15894
  String(today.getDate()).padStart(2, "0")
15552
15895
  ].join("");
15553
15896
  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")}`);
15897
+ 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));
15898
+ const reportDir = path13.join(root, `${prefix}-${String(Math.max(0, ...nums) + 1).padStart(3, "0")}`);
15556
15899
  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"),
15900
+ await mkdir12(path13.join(reportDir, "screenshots"), { recursive: true });
15901
+ await writeFile12(
15902
+ path13.join(reportDir, "summary.md"),
15903
+ ["# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B", "", `run_id: ${path13.basename(reportDir)}`, "status: draft", "", "## \u573A\u666F\u62A5\u544A", "", "## \u603B\u7ED3", ""].join("\n"),
15561
15904
  "utf8"
15562
15905
  );
15563
15906
  }
@@ -15567,32 +15910,32 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
15567
15910
  if (!await exists3(root)) return [`report root not found: ${root}`];
15568
15911
  const errors = [];
15569
15912
  for (const runDir of await scenarioDirs(root)) {
15570
- const runName = path12.basename(runDir);
15913
+ const runName = path13.basename(runDir);
15571
15914
  if (!RUN_RE.test(runName)) {
15572
15915
  errors.push(`${runDir}: run directory name must be YYYYMMDD-NNN`);
15573
15916
  continue;
15574
15917
  }
15575
- if (!await exists3(path12.join(runDir, "summary.md"))) errors.push(`${runDir}: missing summary.md`);
15918
+ if (!await exists3(path13.join(runDir, "summary.md"))) errors.push(`${runDir}: missing summary.md`);
15576
15919
  const files = await readdir5(runDir);
15577
15920
  const scenarioReports = files.filter((file) => file.endsWith(".md") && file !== "summary.md");
15578
15921
  if (scenarioReports.length === 0) errors.push(`${runDir}: missing scenario report markdown`);
15579
15922
  for (const reportName of scenarioReports) {
15580
- const reportPath = path12.join(runDir, reportName);
15923
+ const reportPath = path13.join(runDir, reportName);
15581
15924
  const text5 = await readText(reportPath);
15582
15925
  for (const key of REPORT_REQUIRED_KEYS) if (!text5.includes(key)) errors.push(`${reportPath}: missing \`${key}\``);
15583
15926
  for (const heading of REPORT_REQUIRED_HEADINGS) if (!text5.includes(heading)) errors.push(`${reportPath}: missing \`${heading}\``);
15584
15927
  const imageRefs = [...text5.matchAll(IMAGE_RE)].map((match) => match[1]);
15585
15928
  if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
15586
- const screenshotsDir = path12.join(runDir, "screenshots");
15929
+ const screenshotsDir = path13.join(runDir, "screenshots");
15587
15930
  if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
15588
15931
  for (const imageRef of imageRefs) {
15589
15932
  if (imageRef.includes("://")) {
15590
15933
  errors.push(`${reportPath}: screenshot must be a local file under this run's screenshots directory`);
15591
15934
  continue;
15592
15935
  }
15593
- const imagePath = path12.resolve(path12.dirname(reportPath), imageRef);
15594
- const screenshotsResolved = path12.resolve(screenshotsDir);
15595
- if (!imagePath.startsWith(`${screenshotsResolved}${path12.sep}`)) {
15936
+ const imagePath = path13.resolve(path13.dirname(reportPath), imageRef);
15937
+ const screenshotsResolved = path13.resolve(screenshotsDir);
15938
+ if (!imagePath.startsWith(`${screenshotsResolved}${path13.sep}`)) {
15596
15939
  errors.push(`${reportPath}: image reference must stay under this run's screenshots directory: ${imageRef}`);
15597
15940
  continue;
15598
15941
  }
@@ -15603,10 +15946,10 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
15603
15946
  return errors;
15604
15947
  }
15605
15948
  async function validateCopyDiffArtifacts(scenarioDir) {
15606
- const diffDir = path12.join(scenarioDir, COPY_DIFF_DIR);
15949
+ const diffDir = path13.join(scenarioDir, COPY_DIFF_DIR);
15607
15950
  if (!await exists3(diffDir)) return;
15608
- const manifestPath = path12.join(diffDir, "last.json");
15609
- const diffPath = path12.join(diffDir, "last.diff");
15951
+ const manifestPath = path13.join(diffDir, "last.json");
15952
+ const diffPath = path13.join(diffDir, "last.diff");
15610
15953
  if (!await exists3(manifestPath)) fail(`${scenarioDir}: ${COPY_DIFF_DIR}/last.json is required when copy diff artifacts exist`);
15611
15954
  if (!await exists3(diffPath)) fail(`${scenarioDir}: ${COPY_DIFF_DIR}/last.diff is required when copy diff artifacts exist`);
15612
15955
  let manifest;
@@ -15618,7 +15961,7 @@ async function validateCopyDiffArtifacts(scenarioDir) {
15618
15961
  for (const key of ["operation", "scenario_id", "source", "destination", "generated_at", "summary", "diff_file", "files"]) {
15619
15962
  if (!(key in manifest)) fail(`${manifestPath}: missing \`${key}\``);
15620
15963
  }
15621
- if (manifest.scenario_id !== path12.basename(scenarioDir)) fail(`${manifestPath}: scenario_id must match directory name`);
15964
+ if (manifest.scenario_id !== path13.basename(scenarioDir)) fail(`${manifestPath}: scenario_id must match directory name`);
15622
15965
  if (manifest.diff_file !== "last.diff") fail(`${manifestPath}: diff_file must be last.diff`);
15623
15966
  if (!(await readText(diffPath)).trim()) fail(`${diffPath}: copy diff must not be empty`);
15624
15967
  }
@@ -15666,8 +16009,8 @@ function registerTestSuiteCommands(program2) {
15666
16009
  }
15667
16010
 
15668
16011
  // 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";
16012
+ import { access as access2, mkdir as mkdir13, readFile as readFile16, realpath, writeFile as writeFile13 } from "fs/promises";
16013
+ import path14 from "path";
15671
16014
  var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
15672
16015
  var UPDATE_STATE_FILE = "update-state.json";
15673
16016
  var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -15779,7 +16122,7 @@ async function fetchLatestVersion(options = {}) {
15779
16122
  }
15780
16123
  }
15781
16124
  function updateStatePath(configDir = getConfigDir()) {
15782
- return path13.join(configDir, UPDATE_STATE_FILE);
16125
+ return path14.join(configDir, UPDATE_STATE_FILE);
15783
16126
  }
15784
16127
  async function readUpdateState(configDir) {
15785
16128
  try {
@@ -15794,8 +16137,8 @@ async function readUpdateState(configDir) {
15794
16137
  }
15795
16138
  }
15796
16139
  async function writeUpdateState(state, configDir = getConfigDir()) {
15797
- await mkdir12(configDir, { recursive: true });
15798
- await writeFile12(updateStatePath(configDir), JSON.stringify(state), "utf8");
16140
+ await mkdir13(configDir, { recursive: true });
16141
+ await writeFile13(updateStatePath(configDir), JSON.stringify(state), "utf8");
15799
16142
  }
15800
16143
  async function checkCachedUpdate(currentVersion, configDir = getConfigDir()) {
15801
16144
  if (process.env.BPMAX_CLI_NO_UPDATE_NOTIFIER) {
@@ -15847,7 +16190,7 @@ async function findNpmPath() {
15847
16190
  }
15848
16191
  function detectInstallMethod(input) {
15849
16192
  const resolvedPath = input.executablePath || "";
15850
- const method = resolvedPath.includes(`node_modules${path13.sep}`) || resolvedPath.includes("node_modules/") ? "npm" : "manual";
16193
+ const method = resolvedPath.includes(`node_modules${path14.sep}`) || resolvedPath.includes("node_modules/") ? "npm" : "manual";
15851
16194
  return {
15852
16195
  method,
15853
16196
  resolvedPath,