bpmax-cli 0.1.44-beta.13 → 0.1.44-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/dist/bin.js +286 -47
  2. package/dist/bin.js.map +1 -1
  3. package/package.json +1 -1
  4. package/skills/bpmax-ai-taskbook/SKILL.md +125 -0
  5. package/skills/bpmax-approval-matrix/SKILL.md +80 -0
  6. package/skills/bpmax-cli/SKILL.md +3 -0
  7. package/skills/bpmax-dataset-template-editor/references/pre-process-script-example-catalog.md +8 -8
  8. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +21 -0
  9. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +4 -3
  10. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale.json +4 -4
  11. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_final_v2.json +4 -4
  12. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_main.json +4 -4
  13. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_region.json +4 -4
  14. package/skills/bpmax-e2e-flow-test-operator/references/filter-field-discovery.md +2 -2
  15. package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +3 -3
  16. package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +6 -4
  17. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_test_profile.py +11 -11
  18. package/skills/bpmax-flow-template-editor/SKILL.md +1 -1
  19. package/skills/bpmax-flow-template-editor/references/lessons-from-price-plan-flow.md +3 -3
  20. package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +7 -4
  21. package/skills/bpmax-form-template-editor/SKILL.md +14 -9
  22. package/skills/bpmax-project/SKILL.md +4 -1
  23. package/skills/form-control-library/references/form-controls.md +37 -37
package/dist/bin.js CHANGED
@@ -448,7 +448,7 @@ function normalizePath2(path11) {
448
448
  // package.json
449
449
  var package_default = {
450
450
  name: "bpmax-cli",
451
- version: "0.1.44-beta.13",
451
+ version: "0.1.44-beta.15",
452
452
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
453
453
  type: "module",
454
454
  bin: {
@@ -2917,6 +2917,23 @@ function numericId(value) {
2917
2917
  }
2918
2918
  return void 0;
2919
2919
  }
2920
+ var UUID_VALUE_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
2921
+ function isUuidValue(value) {
2922
+ return UUID_VALUE_PATTERN.test(value.trim());
2923
+ }
2924
+ function assertNotLocalUuidConfigId(domain, id, action) {
2925
+ if (!isUuidValue(id)) {
2926
+ return;
2927
+ }
2928
+ if (domain === "form-template") {
2929
+ throw new Error(
2930
+ `Refusing to ${action} form-template local UUID ${id}. This is a local config mirror id, not an editable remote draft id; read the real published form id from flow meta.form_template, then export it so bpmax-cli can point you to the draft id.`
2931
+ );
2932
+ }
2933
+ throw new Error(
2934
+ `Refusing to ${action} ${domain} local UUID ${id}. BPMAX config writes must use platform-returned numeric ids or flow<number> ids.`
2935
+ );
2936
+ }
2920
2937
  function formTemplateDetail(value) {
2921
2938
  if (isRecord3(value) && isRecord3(value.data)) {
2922
2939
  return value.data;
@@ -3003,11 +3020,19 @@ function summarizeOperationPlan(payload) {
3003
3020
  ];
3004
3021
  }
3005
3022
  function diffJsonNormalized(domain, before, after) {
3023
+ return diffJsonComparable(
3024
+ domain,
3025
+ before,
3026
+ after,
3027
+ (value) => buildDomainSubmitPayload(domain, value)
3028
+ );
3029
+ }
3030
+ function diffJsonComparable(domain, before, after, normalize) {
3006
3031
  let beforeComparable;
3007
3032
  let afterComparable;
3008
3033
  try {
3009
- beforeComparable = buildDomainSubmitPayload(domain, before);
3010
- afterComparable = buildDomainSubmitPayload(domain, after);
3034
+ beforeComparable = normalize(before);
3035
+ afterComparable = normalize(after);
3011
3036
  } catch {
3012
3037
  beforeComparable = before;
3013
3038
  afterComparable = after;
@@ -4028,6 +4053,13 @@ function refreshSettingToSubmit(value) {
4028
4053
  }
4029
4054
  var FORM_RULE_ID_KEYS = /* @__PURE__ */ new Set(["form_rule_id", "form_template_id", "id"]);
4030
4055
  var FORM_VALUE_ID_KEYS = /* @__PURE__ */ new Set(["template_id", "id"]);
4056
+ var FORM_TEMPLATE_SERVER_FIELD_KEYS = /* @__PURE__ */ new Set([
4057
+ "form_rule_id",
4058
+ "form_template_id",
4059
+ "template_id",
4060
+ "visibility",
4061
+ "visibility_scope"
4062
+ ]);
4031
4063
  function stripKeys(source, keys) {
4032
4064
  const result = {};
4033
4065
  for (const [key, value] of Object.entries(source)) {
@@ -4037,6 +4069,21 @@ function stripKeys(source, keys) {
4037
4069
  }
4038
4070
  return result;
4039
4071
  }
4072
+ function stripServerFilledFields(value, keys) {
4073
+ if (Array.isArray(value)) {
4074
+ return value.map((item) => stripServerFilledFields(item, keys));
4075
+ }
4076
+ if (!isRecord3(value)) {
4077
+ return value;
4078
+ }
4079
+ const result = {};
4080
+ for (const [key, child] of Object.entries(value)) {
4081
+ if (!keys.has(key)) {
4082
+ result[key] = stripServerFilledFields(child, keys);
4083
+ }
4084
+ }
4085
+ return result;
4086
+ }
4040
4087
  function normalizeRemovedFields(value) {
4041
4088
  if (!Array.isArray(value)) {
4042
4089
  return /* @__PURE__ */ new Set();
@@ -5298,6 +5345,11 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
5298
5345
  workspace,
5299
5346
  name,
5300
5347
  operation_plan: dryRunPlan,
5348
+ post_create_checklist: [
5349
+ "If this flow-app is an approval matrix app, create online matrix rule records separately; flow-app create only creates the app/form/flow/workspace binding.",
5350
+ "Verify matrix rule records contain real approver user values before connecting business flow matrix_owner or cc_matrix.",
5351
+ "Use bpmax-project safe project create/handoff for matrix rule records; do not treat local seed-rules.json as online data."
5352
+ ],
5301
5353
  next: `Run again with --confirm "${expectedConfirm}" to create.`
5302
5354
  };
5303
5355
  }
@@ -5430,6 +5482,41 @@ async function readBackConfigDomain(profile, domain, id, definition) {
5430
5482
  readback_hash: hashJson(data)
5431
5483
  };
5432
5484
  }
5485
+ function comparableSubmitPayload(domain, value, options) {
5486
+ const comparable = domain === "form-template" && options.ignoreServerFields ? stripServerFilledFields(value, FORM_TEMPLATE_SERVER_FIELD_KEYS) : value;
5487
+ return buildDomainSubmitPayload(domain, comparable);
5488
+ }
5489
+ async function verifyConfigDomain(config, profile, domain, id, options = {}) {
5490
+ void config;
5491
+ assertNotLocalUuidConfigId(domain, id, "verify");
5492
+ const exported = await exportConfigDomain(
5493
+ config,
5494
+ profile,
5495
+ domain,
5496
+ id,
5497
+ options.outDir || `.codex/tmp/${domain}-verify`
5498
+ );
5499
+ const actual = await readJsonFile(String(exported.raw_file));
5500
+ const expected = options.expectFile ? await readJsonFile(options.expectFile) : void 0;
5501
+ const actualComparable = expected ? comparableSubmitPayload(domain, actual, options) : void 0;
5502
+ const expectedComparable = expected ? comparableSubmitPayload(domain, expected, options) : void 0;
5503
+ const ok = expected ? JSON.stringify(actualComparable) === JSON.stringify(expectedComparable) : true;
5504
+ const diff = expected ? diffJsonComparable(domain, expected, actual, (value) => comparableSubmitPayload(domain, value, options)) : void 0;
5505
+ return {
5506
+ domain,
5507
+ id,
5508
+ ok,
5509
+ compare: expected ? "normalized_submit_payload" : "readback_only",
5510
+ ...expected ? {
5511
+ expected_hash: expectedComparable ? hashJson(expectedComparable) : null,
5512
+ actual_hash: actualComparable ? hashJson(actualComparable) : null,
5513
+ actual_config_hash: exported.base_hash,
5514
+ ...domain === "form-template" && options.ignoreServerFields ? { ignored_server_fields: [...FORM_TEMPLATE_SERVER_FIELD_KEYS] } : {},
5515
+ diff
5516
+ } : {},
5517
+ exported
5518
+ };
5519
+ }
5433
5520
  async function readRemoteConfigDomain(profile, domain, id, definition) {
5434
5521
  if (!definition.exportPath) {
5435
5522
  throw new Error(`Config readback is not implemented for ${domain}.`);
@@ -5466,6 +5553,8 @@ async function writeJsonFile(file, value) {
5466
5553
  `, "utf8");
5467
5554
  }
5468
5555
  async function exportConfigDomain(config, profile, domain, id, outDir, options = {}) {
5556
+ void config;
5557
+ assertNotLocalUuidConfigId(domain, id, "export");
5469
5558
  if (domain === "api-platform") {
5470
5559
  const { raw, work: work2 } = await collectApiPlatformAggregate(profile, id);
5471
5560
  const baseHash2 = hashJson(raw);
@@ -5619,6 +5708,7 @@ async function lintConfigWorkFile(file) {
5619
5708
  async function submitConfigDomain(config, profile, domain, id, submitFile, confirm3, options = {}) {
5620
5709
  void config;
5621
5710
  const definition = CONFIG_DOMAINS[domain];
5711
+ assertNotLocalUuidConfigId(domain, id, "submit");
5622
5712
  if (domain === "workspace-flow") {
5623
5713
  if (definition.submitStatus !== "supported") {
5624
5714
  throw new Error(`${CONFIG_SUBMIT_UNSUPPORTED_MESSAGE} Domain: ${domain}.`);
@@ -5642,6 +5732,11 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
5642
5732
  throw new Error(`Config submit metadata profile mismatch. Expected ${profile.name}, got ${String(meta2.profile)}.`);
5643
5733
  }
5644
5734
  const createMode = meta2.mode === "create";
5735
+ if (typeof submit2.base_hash !== "string") {
5736
+ throw new Error(
5737
+ "workspace-flow submit requires a current base_hash from export/build because /workspace/workspace_flow is a full replacement API. Re-export current workspace-flow, merge new bindings, rebuild, then submit."
5738
+ );
5739
+ }
5645
5740
  await ensureConfigCapability(profile, `${definition.capability}.${createMode ? "create" : "submit"}`);
5646
5741
  const workspace = normalizeWorkspaceKey(String(submit2.payload.workspace || id));
5647
5742
  const metaWorkspace = normalizeWorkspaceKey(String(meta2.workspace || meta2.id || ""));
@@ -5651,7 +5746,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
5651
5746
  const endpoint2 = "/workspace/workspace_flow";
5652
5747
  const submitPayload2 = { workspace_flow: normalizeWorkspaceFlowItems(submit2.payload.workspace_flow) };
5653
5748
  const current2 = await readRemoteConfigDomain(profile, domain, workspace, definition);
5654
- if (typeof submit2.base_hash === "string" && hashJson(current2) !== submit2.base_hash) {
5749
+ if (hashJson(current2) !== submit2.base_hash) {
5655
5750
  throw new Error("Remote config changed after export. Re-export before submitting.");
5656
5751
  }
5657
5752
  const expectedConfirm2 = `submit ${domain} ${id}`;
@@ -6078,6 +6173,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
6078
6173
  async function deleteConfigDomain(config, profile, domain, id, confirm3) {
6079
6174
  void config;
6080
6175
  const definition = CONFIG_DOMAINS[domain];
6176
+ assertNotLocalUuidConfigId(domain, id, "delete");
6081
6177
  if (domain === "workspace-flow") {
6082
6178
  return deleteWorkspaceFlowBinding(profile, id, confirm3);
6083
6179
  }
@@ -7242,36 +7338,22 @@ function registerConfigCommands(program2) {
7242
7338
  });
7243
7339
  });
7244
7340
  }
7245
- domainCommand.command("verify").description(`Read back a ${domain} config and optionally compare with an expected JSON file`).requiredOption("--id <id>", "Remote config id").option("--expect <file>", "Expected JSON file").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
7341
+ domainCommand.command("verify").description(`Read back a ${domain} config and optionally compare with an expected JSON file`).requiredOption("--id <id>", "Remote config id").option("--expect <file>", "Expected JSON file").option("--ignore-server-fields", "For form-template verify, ignore platform-filled system fields such as form_rule_id/template_id/visibility").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
7246
7342
  const configData = await loadConfig();
7247
7343
  const resolved = resolveProfile(configData, options.profile);
7248
- const exported = await exportConfigDomain(
7344
+ const result = await verifyConfigDomain(
7249
7345
  configData,
7250
7346
  resolved,
7251
7347
  domain,
7252
7348
  options.id,
7253
- `.codex/tmp/${domain}-verify`
7349
+ {
7350
+ expectFile: options.expect,
7351
+ outDir: `.codex/tmp/${domain}-verify`,
7352
+ ignoreServerFields: Boolean(options.ignoreServerFields)
7353
+ }
7254
7354
  );
7255
- const actual = await readJsonFile(String(exported.raw_file));
7256
- const expected = options.expect ? await readJsonFile(options.expect) : void 0;
7257
- const actualComparable = expected ? buildDomainSubmitPayload(domain, actual) : void 0;
7258
- const expectedComparable = expected ? buildDomainSubmitPayload(domain, expected) : void 0;
7259
- const ok = expected ? JSON.stringify(actualComparable) === JSON.stringify(expectedComparable) : true;
7260
- const diff = expected ? diffJsonNormalized(domain, expected, actual) : void 0;
7261
7355
  await saveConfig(configData);
7262
- printResult(options.format, {
7263
- domain,
7264
- id: options.id,
7265
- ok,
7266
- compare: expected ? "normalized_submit_payload" : "readback_only",
7267
- ...expected ? {
7268
- expected_hash: expectedComparable ? hashJson(expectedComparable) : null,
7269
- actual_hash: actualComparable ? hashJson(actualComparable) : null,
7270
- actual_config_hash: exported.base_hash,
7271
- diff
7272
- } : {},
7273
- exported
7274
- });
7356
+ printResult(options.format, result);
7275
7357
  });
7276
7358
  });
7277
7359
  }
@@ -7782,6 +7864,119 @@ function registerMemoryCommands(program2) {
7782
7864
  });
7783
7865
  }
7784
7866
 
7867
+ // src/commands/matrix.ts
7868
+ import { readFile as readFile9 } from "fs/promises";
7869
+ var UUID_VALUE_PATTERN2 = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/i;
7870
+ var UUID_PATH_PATTERN = /uuid'[^'"\s/]+/i;
7871
+ async function parseSeedRules(input) {
7872
+ const source = input.startsWith("@") ? input.slice(1) : void 0;
7873
+ if (source === "") {
7874
+ throw new Error("--rules file path is empty.");
7875
+ }
7876
+ const raw = source ? await readFile9(source, "utf8") : input;
7877
+ let parsed;
7878
+ try {
7879
+ parsed = JSON.parse(raw);
7880
+ } catch (error) {
7881
+ const detail = error instanceof Error ? error.message : String(error);
7882
+ throw new Error(`--rules is not valid JSON: ${detail}`);
7883
+ }
7884
+ const rules = Array.isArray(parsed) ? parsed : [parsed];
7885
+ if (rules.length === 0) {
7886
+ throw new Error("--rules must contain at least one rule object.");
7887
+ }
7888
+ rules.forEach((rule, index) => {
7889
+ if (typeof rule !== "object" || rule === null || Array.isArray(rule)) {
7890
+ throw new Error(`--rules[${index}] must be a JSON object.`);
7891
+ }
7892
+ });
7893
+ return rules;
7894
+ }
7895
+ function collectUuidPaths(value, path11 = "$") {
7896
+ if (typeof value === "string") {
7897
+ return UUID_VALUE_PATTERN2.test(value) || UUID_PATH_PATTERN.test(value) ? [path11] : [];
7898
+ }
7899
+ if (Array.isArray(value)) {
7900
+ return value.flatMap((item, index) => collectUuidPaths(item, `${path11}[${index}]`));
7901
+ }
7902
+ if (typeof value === "object" && value !== null) {
7903
+ return Object.entries(value).flatMap(([key, child]) => collectUuidPaths(child, `${path11}.${key}`));
7904
+ }
7905
+ return [];
7906
+ }
7907
+ function ruleForm(rule) {
7908
+ const form = rule.form;
7909
+ if (typeof form === "object" && form !== null && !Array.isArray(form)) {
7910
+ return form;
7911
+ }
7912
+ return rule;
7913
+ }
7914
+ function isEmptyApproverValue(value) {
7915
+ if (value === null || value === void 0 || value === "") {
7916
+ return true;
7917
+ }
7918
+ if (Array.isArray(value)) {
7919
+ return value.length === 0;
7920
+ }
7921
+ return false;
7922
+ }
7923
+ function shellQuote6(value) {
7924
+ return `'${value.replace(/'/g, `'\\''`)}'`;
7925
+ }
7926
+ function registerMatrixCommands(program2) {
7927
+ const matrix = program2.command("matrix").description("Plan and validate BPMAX approval matrix operations");
7928
+ matrix.command("seed <flowType>").description("Validate approval matrix seed rule records and print safe project create commands").requiredOption("--rules <jsonOrFile>", "Seed rule object/array JSON or @file").option("--profile <profile>", "Profile name").option("--approver-field <field...>", "Required approver field key(s) inside each rule form").option("--format <format>", "Output format", "pretty").action(async (flowType, options) => {
7929
+ const rules = await parseSeedRules(options.rules);
7930
+ const approverFields = options.approverField || [];
7931
+ const errors = [];
7932
+ rules.forEach((rule, index) => {
7933
+ collectUuidPaths(rule).forEach((uuidPath) => {
7934
+ errors.push({
7935
+ rule_index: index,
7936
+ code: "uuid_not_allowed",
7937
+ path: uuidPath,
7938
+ message: "UUID values are not allowed in approval matrix rule seed data."
7939
+ });
7940
+ });
7941
+ const form = ruleForm(rule);
7942
+ approverFields.forEach((field) => {
7943
+ if (isEmptyApproverValue(form[field])) {
7944
+ errors.push({
7945
+ rule_index: index,
7946
+ code: "missing_approver",
7947
+ path: `$.form.${field}`,
7948
+ message: `Approver field "${field}" must contain a real BPMAX user value before seeding matrix rules.`
7949
+ });
7950
+ }
7951
+ });
7952
+ });
7953
+ if (errors.length > 0) {
7954
+ throw new Error(`Matrix seed validation failed:
7955
+ ${errors.map((error) => `- [${error.rule_index}] ${error.code}${error.path ? ` ${error.path}` : ""}: ${error.message}`).join("\n")}`);
7956
+ }
7957
+ const projectCreatePayloads = rules.map((rule) => ({ form: ruleForm(rule) }));
7958
+ const profileArgs = options.profile ? ` --profile ${shellQuote6(options.profile)}` : "";
7959
+ const nextCommands = projectCreatePayloads.map(
7960
+ (payload) => `bpmax-cli project create${profileArgs} --flow-type ${shellQuote6(flowType)} --json ${shellQuote6(JSON.stringify(payload))} --format json`
7961
+ );
7962
+ printResult(options.format, {
7963
+ domain: "approval-matrix",
7964
+ action: "seed",
7965
+ flow_type: flowType,
7966
+ dry_run: true,
7967
+ rule_count: rules.length,
7968
+ approver_fields: approverFields,
7969
+ project_create_payloads: projectCreatePayloads,
7970
+ next_commands: nextCommands,
7971
+ notes: [
7972
+ "This command does not write BPMAX project records.",
7973
+ "Run each project create command and follow handoff output when the form requires page runtime initialization.",
7974
+ "Do not use --no-interactive unless the matrix form is proven safe for direct create."
7975
+ ]
7976
+ });
7977
+ });
7978
+ }
7979
+
7785
7980
  // src/core/form-schema.ts
7786
7981
  var FIELD_KEY_NAMES = [
7787
7982
  "key",
@@ -8363,6 +8558,23 @@ async function buildProjectFormPayload(client, flowDetail, form, knownTemplate)
8363
8558
  }
8364
8559
 
8365
8560
  // src/commands/project.ts
8561
+ function projectCreateErrorDiagnostic(error, context) {
8562
+ const baseMessage = error instanceof Error ? error.message : String(error || "");
8563
+ const response = typeof error === "object" && error !== null && "response" in error ? error.response : void 0;
8564
+ const status = response?.status;
8565
+ const body = response?.data;
8566
+ const bodyText = body === void 0 ? "" : typeof body === "string" ? body : JSON.stringify(body);
8567
+ const summary = bodyText.length > 1e3 ? `${bodyText.slice(0, 1e3)}...` : bodyText;
8568
+ return new Error([
8569
+ `Project create failed${status ? ` with status ${String(status)}` : ""}: ${baseMessage}`,
8570
+ `local_form_validation=${context.localFormValidation}`,
8571
+ `direct_body=${context.usedBody ? "true" : "false"}`,
8572
+ `no_interactive=${context.noInteractive ? "true" : "false"}`,
8573
+ `handoff_available=${context.handoffAvailable ? "true" : "false"}`,
8574
+ summary ? `server_error_summary=${summary}` : "",
8575
+ context.handoffAvailable ? "next_action=Use the generated form handoff path unless the template is proven safe for direct create." : "next_action=Check field keys/types and server error body; do not bypass with raw API."
8576
+ ].filter(Boolean).join("\n"));
8577
+ }
8366
8578
  async function parseProjectJson(input, label = "--json") {
8367
8579
  if (!input) {
8368
8580
  return {};
@@ -8889,6 +9101,8 @@ function registerProjectCommands(program2) {
8889
9101
  const profile = resolveProfile(config, options.profile);
8890
9102
  const client = createApiClient(profile);
8891
9103
  const useInteractive = !options.body && options.interactive !== false;
9104
+ let localFormValidation = options.body ? "not_applicable" : "skipped";
9105
+ let handoffAvailable = false;
8892
9106
  let payload = await parseProjectJson(options.body, "--body");
8893
9107
  if (!options.body) {
8894
9108
  const flow = await resolveFlowIdentifiers(client, options, { loadDetail: true });
@@ -8928,6 +9142,7 @@ function registerProjectCommands(program2) {
8928
9142
  }
8929
9143
  const handoffReasons2 = collectHandoffReasons(fields, projectFormTemplate?.template);
8930
9144
  if (handoffReasons2.length > 0) {
9145
+ handoffAvailable = true;
8931
9146
  const handoffFields2 = fieldsForValidation(flowDetail, projectFormTemplate);
8932
9147
  assertHandoffFormCompatible(handoffFields2, form);
8933
9148
  await printCreateFormHandoff(client, options.format, profile, flowIdentifiers, {
@@ -8962,6 +9177,7 @@ function registerProjectCommands(program2) {
8962
9177
  const handoffFields = fieldsForValidation(flowDetail, projectFormTemplate);
8963
9178
  const handoffReasons = collectHandoffReasons(handoffFields, projectFormTemplate?.template);
8964
9179
  if (handoffReasons.length > 0) {
9180
+ handoffAvailable = true;
8965
9181
  assertHandoffFormCompatible(handoffFields, form);
8966
9182
  await printCreateFormHandoff(client, options.format, profile, flowIdentifiers, {
8967
9183
  name: name ?? "",
@@ -8985,16 +9201,29 @@ function registerProjectCommands(program2) {
8985
9201
  };
8986
9202
  if (!options.skipFormValidation) {
8987
9203
  await validateCreateForm(client, { flowId: options.flowId, flowDetail, form, projectFormTemplate });
9204
+ localFormValidation = "passed";
9205
+ } else {
9206
+ localFormValidation = "skipped";
8988
9207
  }
8989
9208
  }
8990
- const result = await apiRequest(
8991
- client,
8992
- "POST",
8993
- "/project",
8994
- {
8995
- data: payload
8996
- }
8997
- );
9209
+ let result;
9210
+ try {
9211
+ result = await apiRequest(
9212
+ client,
9213
+ "POST",
9214
+ "/project",
9215
+ {
9216
+ data: payload
9217
+ }
9218
+ );
9219
+ } catch (error) {
9220
+ throw projectCreateErrorDiagnostic(error, {
9221
+ localFormValidation,
9222
+ usedBody: Boolean(options.body),
9223
+ noInteractive: options.interactive === false,
9224
+ handoffAvailable
9225
+ });
9226
+ }
8998
9227
  printResult(options.format, attachProjectDetailUrl(profile, result));
8999
9228
  });
9000
9229
  }
@@ -9004,7 +9233,7 @@ import { spawn as spawn2 } from "child_process";
9004
9233
  import { fileURLToPath as fileURLToPath2 } from "url";
9005
9234
 
9006
9235
  // src/core/recipes.ts
9007
- import { access, mkdir as mkdir7, readdir, readFile as readFile9, writeFile as writeFile7 } from "fs/promises";
9236
+ import { access, mkdir as mkdir7, readdir, readFile as readFile10, writeFile as writeFile7 } from "fs/promises";
9008
9237
  import path7 from "path";
9009
9238
  var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
9010
9239
  var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
@@ -9086,7 +9315,7 @@ function parseRecipeDefinition(input) {
9086
9315
  };
9087
9316
  }
9088
9317
  async function loadRecipe(recipeDir) {
9089
- const raw = await readFile9(path7.join(recipeDir, "recipe.json"), "utf8");
9318
+ const raw = await readFile10(path7.join(recipeDir, "recipe.json"), "utf8");
9090
9319
  return parseRecipeDefinition(JSON.parse(raw));
9091
9320
  }
9092
9321
  async function listRecipes(recipesDir) {
@@ -9185,7 +9414,7 @@ async function renderArgv(options) {
9185
9414
  const rendered = [];
9186
9415
  for (const token of options.recipe.command.argv) {
9187
9416
  if (token.startsWith("@")) {
9188
- const raw = await readFile9(resolveRecipeFile(options.recipeDir, token), "utf8");
9417
+ const raw = await readFile10(resolveRecipeFile(options.recipeDir, token), "utf8");
9189
9418
  rendered.push(renderTemplate(raw, options.variables));
9190
9419
  } else {
9191
9420
  rendered.push(renderTemplate(token, options.variables));
@@ -9508,7 +9737,7 @@ async function promptConfirm(message) {
9508
9737
  const value = await confirm2({ message, initialValue: true });
9509
9738
  return value === true;
9510
9739
  }
9511
- function shellQuote6(value) {
9740
+ function shellQuote7(value) {
9512
9741
  if (/^[A-Za-z0-9_./:@=-]+$/.test(value)) {
9513
9742
  return value;
9514
9743
  }
@@ -9518,7 +9747,7 @@ function configWorkspaceNextCommands2(profileName, cache) {
9518
9747
  if (!capabilityEnabled(cache, "config.repository.view") || !capabilityEnabled(cache, "config.latest.pull")) {
9519
9748
  return void 0;
9520
9749
  }
9521
- const configDirPrefix = isConfigDirOverridden() ? ` --config-dir ${shellQuote6(getConfigDir())}` : "";
9750
+ const configDirPrefix = isConfigDirOverridden() ? ` --config-dir ${shellQuote7(getConfigDir())}` : "";
9522
9751
  return {
9523
9752
  config_workspace_init: `bpmax-cli${configDirPrefix} config workspace init <env> --profile ${profileName} --workspace-dir <dir> --format json`
9524
9753
  };
@@ -10152,7 +10381,7 @@ function registerStepCommands(program2) {
10152
10381
  }
10153
10382
 
10154
10383
  // src/core/taskbook.ts
10155
- import { mkdir as mkdir8, readFile as readFile10, writeFile as writeFile8 } from "fs/promises";
10384
+ import { mkdir as mkdir8, readFile as readFile11, writeFile as writeFile8 } from "fs/promises";
10156
10385
  import path8 from "path";
10157
10386
  var TaskbookError = class extends Error {
10158
10387
  };
@@ -10200,8 +10429,15 @@ var PROMPT_REQUIRED_TERMS = [
10200
10429
  ];
10201
10430
  var BPMAX_SKILL_PATTERN = /bpmax-[a-z0-9-]+|form-control-library|bpmax-memory-protocol/;
10202
10431
  var FLOW_LOCK_PATTERN = /\bflow:([A-Za-z0-9_-]+)/g;
10432
+ var UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/gi;
10433
+ function uuidErrors(text5, target) {
10434
+ const values = [...new Set([...text5.matchAll(UUID_PATTERN)].map((match) => match[0]))];
10435
+ return values.map(
10436
+ (value) => `UUID values are not allowed in BPMAX configuration ${target}: ${value}. Use platform-returned numeric ids or flow<number>; use new-flow:<name> before creation.`
10437
+ );
10438
+ }
10203
10439
  async function readTaskbookText(file) {
10204
- const raw = await readFile10(file, "utf8");
10440
+ const raw = await readFile11(file, "utf8");
10205
10441
  try {
10206
10442
  const parsed = JSON.parse(raw);
10207
10443
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
@@ -10238,6 +10474,7 @@ async function lintTaskbook(file, options = {}) {
10238
10474
  if (!options.allowGeneratedFlowTypeMissing) {
10239
10475
  errors.push(...missingTermErrors(text5, GENERATED_FLOW_TYPE_TERMS, "missing generated flow_type rule term"));
10240
10476
  }
10477
+ errors.push(...uuidErrors(text5, "taskbooks"));
10241
10478
  errors.push(...missingTermErrors(text5, SUBAGENT_TERMS, "missing subagent rule term"));
10242
10479
  for (const match of text5.matchAll(FLOW_LOCK_PATTERN)) {
10243
10480
  const value = match[1] || "";
@@ -10262,6 +10499,7 @@ async function lintTaskPrompt(file, options = {}) {
10262
10499
  if (!BPMAX_SKILL_PATTERN.test(text5)) {
10263
10500
  errors.push("prompt missing BPMAX related skill name in required_skills");
10264
10501
  }
10502
+ errors.push(...uuidErrors(text5, "task prompts"));
10265
10503
  for (const term of options.forbidTerms || []) {
10266
10504
  if (term && text5.includes(term)) {
10267
10505
  errors.push(`prompt forbidden term present: ${term}`);
@@ -10488,7 +10726,7 @@ import {
10488
10726
  cp as cp2,
10489
10727
  mkdir as mkdir9,
10490
10728
  readdir as readdir2,
10491
- readFile as readFile11,
10729
+ readFile as readFile12,
10492
10730
  rm as rm3,
10493
10731
  stat as stat4,
10494
10732
  writeFile as writeFile9
@@ -10580,7 +10818,7 @@ async function exists2(filePath) {
10580
10818
  }
10581
10819
  }
10582
10820
  async function readText(filePath) {
10583
- return readFile11(filePath, "utf8");
10821
+ return readFile12(filePath, "utf8");
10584
10822
  }
10585
10823
  function fail(message) {
10586
10824
  throw new TestSuiteError(message);
@@ -10843,10 +11081,10 @@ async function fileMap(root) {
10843
11081
  return result;
10844
11082
  }
10845
11083
  async function sha256(filePath) {
10846
- return createHash4("sha256").update(await readFile11(filePath)).digest("hex");
11084
+ return createHash4("sha256").update(await readFile12(filePath)).digest("hex");
10847
11085
  }
10848
11086
  async function readForDiff(filePath) {
10849
- const buffer = await readFile11(filePath);
11087
+ const buffer = await readFile12(filePath);
10850
11088
  if (buffer.includes(0)) return [`<binary sha256=${createHash4("sha256").update(buffer).digest("hex")}>
10851
11089
  `];
10852
11090
  return buffer.toString("utf8").split(/(?<=\n)/);
@@ -11121,7 +11359,7 @@ function registerTestSuiteCommands(program2) {
11121
11359
  }
11122
11360
 
11123
11361
  // src/core/update.ts
11124
- import { access as access2, mkdir as mkdir10, readFile as readFile12, realpath, writeFile as writeFile10 } from "fs/promises";
11362
+ import { access as access2, mkdir as mkdir10, readFile as readFile13, realpath, writeFile as writeFile10 } from "fs/promises";
11125
11363
  import path10 from "path";
11126
11364
  var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
11127
11365
  var UPDATE_STATE_FILE = "update-state.json";
@@ -11238,7 +11476,7 @@ function updateStatePath(configDir = getConfigDir()) {
11238
11476
  }
11239
11477
  async function readUpdateState(configDir) {
11240
11478
  try {
11241
- const raw = await readFile12(updateStatePath(configDir), "utf8");
11479
+ const raw = await readFile13(updateStatePath(configDir), "utf8");
11242
11480
  const parsed = JSON.parse(raw);
11243
11481
  if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
11244
11482
  return null;
@@ -11665,6 +11903,7 @@ registerUserCommands(program);
11665
11903
  registerEsCommands(program);
11666
11904
  registerFlowCommands(program);
11667
11905
  registerMemoryCommands(program);
11906
+ registerMatrixCommands(program);
11668
11907
  registerProjectCommands(program);
11669
11908
  registerStepCommands(program);
11670
11909
  registerTaskbookCommands(program);