bpmax-cli 0.1.7 → 0.1.8

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/README.md CHANGED
@@ -41,6 +41,61 @@ Interactive setup is still available when running the CLI directly:
41
41
  bpmax-cli setup
42
42
  ```
43
43
 
44
+ ## Profile recipes
45
+
46
+ Profile recipes are local, profile-scoped playbooks for environment-specific BPMAX operations. They live outside project repositories under:
47
+
48
+ ```text
49
+ ~/.bpmax/profiles/<profile>/recipes/<workspace>/<recipe-name>/
50
+ ```
51
+
52
+ Create a scaffold for the active profile and workspace:
53
+
54
+ ```bash
55
+ bpmax-cli recipe init create-store-staff --title "创建店员"
56
+ ```
57
+
58
+ List, inspect, or locate recipes:
59
+
60
+ ```bash
61
+ bpmax-cli recipe list --format table
62
+ bpmax-cli recipe show create-store-staff --format json
63
+ bpmax-cli recipe path create-store-staff
64
+ ```
65
+
66
+ Each recipe directory contains `recipe.json`, `README.md`, and `payload.json`. `recipe.json` is the machine-readable definition. `payload.json` can use `{{variable}}` placeholders, and `@payload.json` in `command.argv` means the file is read relative to the recipe directory, rendered, and passed as that argument value.
67
+
68
+ Example `recipe.json`:
69
+
70
+ ```json
71
+ {
72
+ "version": 1,
73
+ "name": "create-store-staff",
74
+ "title": "创建店员",
75
+ "description": "发起门店人员管理流程",
76
+ "workspace": "store_mgr",
77
+ "variables": [
78
+ { "name": "name", "required": true },
79
+ { "name": "phone", "required": true }
80
+ ],
81
+ "command": {
82
+ "argv": ["project", "create", "--body", "@payload.json", "--format", "json"],
83
+ "mutating": true
84
+ }
85
+ }
86
+ ```
87
+
88
+ Run a recipe with explicit variables. Mutating recipes require `--yes`:
89
+
90
+ ```bash
91
+ bpmax-cli recipe run create-store-staff \
92
+ --yes \
93
+ --var name=杨小小 \
94
+ --vars '{"phone":"18211223344","store_group_id":"817","store_name":"TMS测试门店"}'
95
+ ```
96
+
97
+ Recipe execution is intentionally limited to bpmax-cli subcommands. It does not run arbitrary shell commands. `--profile <profile>` is injected into the child command when the recipe did not already specify it.
98
+
44
99
  ## Skill distribution
45
100
 
46
101
  The project-owned skills live under `skills/`.
package/dist/bin.js CHANGED
@@ -81,6 +81,9 @@ function getConfigPath() {
81
81
  function getConfigDir() {
82
82
  return CONFIG_DIR;
83
83
  }
84
+ function getProfileDataDir(profileName) {
85
+ return path.join(CONFIG_DIR, "profiles", profileName);
86
+ }
84
87
  function maskApiKey(apiKey) {
85
88
  if (!apiKey) {
86
89
  return "(unset)";
@@ -138,14 +141,14 @@ async function upsertProfile(name, nextProfile) {
138
141
 
139
142
  // src/core/http.ts
140
143
  import axios, { AxiosHeaders } from "axios";
141
- var ensureApiPath = (path4) => {
142
- if (!path4.startsWith("/")) {
143
- path4 = `/${path4}`;
144
+ var ensureApiPath = (path5) => {
145
+ if (!path5.startsWith("/")) {
146
+ path5 = `/${path5}`;
144
147
  }
145
- if (path4.startsWith("/api/")) {
146
- return path4;
148
+ if (path5.startsWith("/api/")) {
149
+ return path5;
147
150
  }
148
- return `/api${path4}`;
151
+ return `/api${path5}`;
149
152
  };
150
153
  function createApiClient(profile) {
151
154
  const instance = axios.create({
@@ -167,10 +170,10 @@ function createApiClient(profile) {
167
170
  });
168
171
  return instance;
169
172
  }
170
- async function apiRequest(client, method, path4, options = {}) {
173
+ async function apiRequest(client, method, path5, options = {}) {
171
174
  const response = await client.request({
172
175
  method,
173
- url: ensureApiPath(path4),
176
+ url: ensureApiPath(path5),
174
177
  params: options.params,
175
178
  data: options.data
176
179
  });
@@ -253,10 +256,10 @@ function parseJson(input) {
253
256
  return JSON.parse(input);
254
257
  }
255
258
  function registerApiCommands(program2) {
256
- program2.command("api <method> <path>").description("Call an arbitrary BPMAX /api endpoint").option("--profile <profile>", "Profile name").option("--params <json>", "Query params JSON").option("--data <json>", "Request body JSON").option("--format <format>", "Output format", "json").action(async (method, path4, options) => {
259
+ program2.command("api <method> <path>").description("Call an arbitrary BPMAX /api endpoint").option("--profile <profile>", "Profile name").option("--params <json>", "Query params JSON").option("--data <json>", "Request body JSON").option("--format <format>", "Output format", "json").action(async (method, path5, options) => {
257
260
  const config = await loadConfig();
258
261
  const profile = resolveProfile(config, options.profile);
259
- const result = await apiRequest(createApiClient(profile), method, path4, {
262
+ const result = await apiRequest(createApiClient(profile), method, path5, {
260
263
  params: parseJson(options.params),
261
264
  data: parseJson(options.data)
262
265
  });
@@ -859,6 +862,365 @@ function registerProjectCommands(program2) {
859
862
  });
860
863
  }
861
864
 
865
+ // src/commands/recipe.ts
866
+ import { spawn } from "child_process";
867
+ import { fileURLToPath } from "url";
868
+
869
+ // src/core/recipes.ts
870
+ import { access, mkdir as mkdir2, readdir, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
871
+ import path2 from "path";
872
+ var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
873
+ var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
874
+ function assertSafeName(kind, value) {
875
+ if (!RECIPE_NAME_PATTERN.test(value) || value.includes("..") || value.includes("/") || value.includes("\\")) {
876
+ throw new Error(`${kind} must contain only letters, numbers, dots, underscores, and dashes.`);
877
+ }
878
+ }
879
+ function normalizeWorkspaceForPath(workspace) {
880
+ const normalized = (workspace || DEFAULT_WORKSPACE).trim() || DEFAULT_WORKSPACE;
881
+ const withoutPrefix = normalized.startsWith("w:") ? normalized.slice(2) : normalized;
882
+ assertSafeName("Workspace", withoutPrefix);
883
+ return withoutPrefix;
884
+ }
885
+ function resolveRecipeLocation(options) {
886
+ assertSafeName("Recipe name", options.recipeName);
887
+ const workspace = options.workspace || DEFAULT_WORKSPACE;
888
+ const workspaceDirName = normalizeWorkspaceForPath(workspace);
889
+ const profileDir = (options.getProfileDir || getProfileDataDir)(options.profileName);
890
+ return {
891
+ profileName: options.profileName,
892
+ workspace,
893
+ workspaceDirName,
894
+ recipeName: options.recipeName,
895
+ recipeDir: path2.join(profileDir, "recipes", workspaceDirName, options.recipeName)
896
+ };
897
+ }
898
+ function getRecipesDir(options) {
899
+ const workspaceDirName = normalizeWorkspaceForPath(options.workspace || DEFAULT_WORKSPACE);
900
+ return path2.join((options.getProfileDir || getProfileDataDir)(options.profileName), "recipes", workspaceDirName);
901
+ }
902
+ function isRecord3(value) {
903
+ return typeof value === "object" && value !== null && !Array.isArray(value);
904
+ }
905
+ function asString(value, fieldName) {
906
+ if (typeof value !== "string" || !value.trim()) {
907
+ throw new Error(`${fieldName} must be a non-empty string.`);
908
+ }
909
+ return value;
910
+ }
911
+ function parseRecipeDefinition(input) {
912
+ if (!isRecord3(input)) {
913
+ throw new Error("recipe.json must be a JSON object.");
914
+ }
915
+ if (input.version !== 1) {
916
+ throw new Error("recipe.json version must be 1.");
917
+ }
918
+ const name = asString(input.name, "recipe.name");
919
+ assertSafeName("Recipe name", name);
920
+ if (!isRecord3(input.command)) {
921
+ throw new Error("recipe.command must be an object.");
922
+ }
923
+ const argv = input.command.argv;
924
+ if (!Array.isArray(argv) || argv.some((item) => typeof item !== "string" || item.length === 0)) {
925
+ throw new Error("recipe.command.argv must be a non-empty string array.");
926
+ }
927
+ const variables = Array.isArray(input.variables) ? input.variables.map((item, index) => {
928
+ if (!isRecord3(item)) {
929
+ throw new Error(`recipe.variables[${index}] must be an object.`);
930
+ }
931
+ const variableName = asString(item.name, `recipe.variables[${index}].name`);
932
+ assertSafeName("Variable name", variableName);
933
+ return {
934
+ name: variableName,
935
+ required: item.required === void 0 ? void 0 : Boolean(item.required)
936
+ };
937
+ }) : void 0;
938
+ return {
939
+ version: 1,
940
+ name,
941
+ ...typeof input.title === "string" ? { title: input.title } : {},
942
+ ...typeof input.description === "string" ? { description: input.description } : {},
943
+ ...typeof input.workspace === "string" ? { workspace: input.workspace } : {},
944
+ ...variables ? { variables } : {},
945
+ command: {
946
+ argv,
947
+ mutating: Boolean(input.command.mutating)
948
+ }
949
+ };
950
+ }
951
+ async function loadRecipe(recipeDir) {
952
+ const raw = await readFile2(path2.join(recipeDir, "recipe.json"), "utf8");
953
+ return parseRecipeDefinition(JSON.parse(raw));
954
+ }
955
+ async function listRecipes(recipesDir) {
956
+ let entries;
957
+ try {
958
+ entries = await readdir(recipesDir);
959
+ } catch (error) {
960
+ if (error.code === "ENOENT") {
961
+ return [];
962
+ }
963
+ throw error;
964
+ }
965
+ const summaries = [];
966
+ for (const entry of entries.sort()) {
967
+ if (!RECIPE_NAME_PATTERN.test(entry)) {
968
+ continue;
969
+ }
970
+ const recipeDir = path2.join(recipesDir, entry);
971
+ try {
972
+ const recipe = await loadRecipe(recipeDir);
973
+ summaries.push({
974
+ name: recipe.name,
975
+ title: recipe.title,
976
+ description: recipe.description,
977
+ workspace: recipe.workspace,
978
+ path: recipeDir,
979
+ mutating: Boolean(recipe.command.mutating)
980
+ });
981
+ } catch {
982
+ }
983
+ }
984
+ return summaries;
985
+ }
986
+ function parseVarEntries(entries = []) {
987
+ const variables = {};
988
+ for (const entry of entries) {
989
+ const index = entry.indexOf("=");
990
+ if (index <= 0) {
991
+ throw new Error(`Invalid --var value "${entry}". Expected key=value.`);
992
+ }
993
+ const key = entry.slice(0, index);
994
+ assertSafeName("Variable name", key);
995
+ variables[key] = entry.slice(index + 1);
996
+ }
997
+ return variables;
998
+ }
999
+ function parseVarsJson(input) {
1000
+ if (!input) {
1001
+ return {};
1002
+ }
1003
+ const parsed = JSON.parse(input);
1004
+ if (!isRecord3(parsed)) {
1005
+ throw new Error("--vars must be a JSON object.");
1006
+ }
1007
+ const variables = {};
1008
+ for (const [key, value] of Object.entries(parsed)) {
1009
+ assertSafeName("Variable name", key);
1010
+ variables[key] = String(value);
1011
+ }
1012
+ return variables;
1013
+ }
1014
+ function mergeVariables(varsJson, varEntries = []) {
1015
+ return {
1016
+ ...parseVarsJson(varsJson),
1017
+ ...parseVarEntries(varEntries)
1018
+ };
1019
+ }
1020
+ function validateRequiredVariables(recipe, variables) {
1021
+ const missing = (recipe.variables || []).filter((variable) => variable.required && !Object.prototype.hasOwnProperty.call(variables, variable.name)).map((variable) => variable.name);
1022
+ if (missing.length > 0) {
1023
+ throw new Error(`Missing required recipe variable(s): ${missing.join(", ")}.`);
1024
+ }
1025
+ }
1026
+ function renderTemplate(template, variables) {
1027
+ return template.replace(TEMPLATE_PATTERN, (match, variableName) => {
1028
+ if (!Object.prototype.hasOwnProperty.call(variables, variableName)) {
1029
+ throw new Error(`Missing recipe variable: ${variableName}.`);
1030
+ }
1031
+ return variables[variableName];
1032
+ });
1033
+ }
1034
+ function resolveRecipeFile(recipeDir, token) {
1035
+ const relative = token.slice(1);
1036
+ if (!relative || relative.includes("..") || path2.isAbsolute(relative)) {
1037
+ throw new Error(`Unsafe recipe file reference: ${token}`);
1038
+ }
1039
+ const resolved = path2.resolve(recipeDir, relative);
1040
+ const root = path2.resolve(recipeDir);
1041
+ if (resolved !== root && !resolved.startsWith(`${root}${path2.sep}`)) {
1042
+ throw new Error(`Recipe file reference escapes recipe directory: ${token}`);
1043
+ }
1044
+ return resolved;
1045
+ }
1046
+ async function renderArgv(options) {
1047
+ validateRequiredVariables(options.recipe, options.variables);
1048
+ const rendered = [];
1049
+ for (const token of options.recipe.command.argv) {
1050
+ if (token.startsWith("@")) {
1051
+ const raw = await readFile2(resolveRecipeFile(options.recipeDir, token), "utf8");
1052
+ rendered.push(renderTemplate(raw, options.variables));
1053
+ } else {
1054
+ rendered.push(renderTemplate(token, options.variables));
1055
+ }
1056
+ }
1057
+ if (!rendered.includes("--profile")) {
1058
+ rendered.push("--profile", options.profileName);
1059
+ }
1060
+ return rendered;
1061
+ }
1062
+ async function ensureEmptyOrForce(targetDir, force = false) {
1063
+ try {
1064
+ await access(targetDir);
1065
+ if (!force) {
1066
+ throw new Error(`Recipe already exists at ${targetDir}. Re-run with --force to overwrite scaffold files.`);
1067
+ }
1068
+ } catch (error) {
1069
+ if (error.code === "ENOENT") {
1070
+ return;
1071
+ }
1072
+ throw error;
1073
+ }
1074
+ }
1075
+ async function writeRecipeScaffold(options) {
1076
+ await ensureEmptyOrForce(options.location.recipeDir, options.force);
1077
+ await mkdir2(options.location.recipeDir, { recursive: true });
1078
+ const title = options.title || options.location.recipeName;
1079
+ const recipe = {
1080
+ version: 1,
1081
+ name: options.location.recipeName,
1082
+ title,
1083
+ description: "Describe what this BPMAX environment recipe does.",
1084
+ workspace: options.location.workspaceDirName,
1085
+ variables: [{ name: "name", required: true }],
1086
+ command: {
1087
+ argv: ["project", "create", "--body", "@payload.json", "--format", "json"],
1088
+ mutating: true
1089
+ }
1090
+ };
1091
+ await writeFile2(path2.join(options.location.recipeDir, "recipe.json"), `${JSON.stringify(recipe, null, 2)}
1092
+ `, "utf8");
1093
+ await writeFile2(
1094
+ path2.join(options.location.recipeDir, "payload.json"),
1095
+ `${JSON.stringify({ name: "{{name}}" }, null, 2)}
1096
+ `,
1097
+ "utf8"
1098
+ );
1099
+ await writeFile2(
1100
+ path2.join(options.location.recipeDir, "README.md"),
1101
+ [`# ${title}`, "", "Describe the BPMAX flow, field mapping, prerequisites, and verification steps for this recipe.", ""].join("\n"),
1102
+ "utf8"
1103
+ );
1104
+ }
1105
+
1106
+ // src/commands/recipe.ts
1107
+ function currentCliInvocation() {
1108
+ const entry = process.argv[1] || fileURLToPath(import.meta.url);
1109
+ return {
1110
+ command: process.execPath,
1111
+ argsPrefix: [entry]
1112
+ };
1113
+ }
1114
+ function defaultRunRecipe(argv) {
1115
+ const invocation = currentCliInvocation();
1116
+ return new Promise((resolve, reject) => {
1117
+ const child = spawn(invocation.command, [...invocation.argsPrefix, ...argv], {
1118
+ stdio: "inherit",
1119
+ shell: false
1120
+ });
1121
+ child.on("error", reject);
1122
+ child.on("close", (code) => resolve(code ?? 1));
1123
+ });
1124
+ }
1125
+ function resolveTargetProfile(configData, profileName) {
1126
+ const resolved = resolveProfile(configData, profileName);
1127
+ return {
1128
+ name: resolved.name,
1129
+ workspace: resolved.config.workspace || DEFAULT_WORKSPACE
1130
+ };
1131
+ }
1132
+ function collectVarEntries(value) {
1133
+ if (!value) {
1134
+ return [];
1135
+ }
1136
+ return Array.isArray(value) ? value : [value];
1137
+ }
1138
+ function registerRecipeCommands(program2, deps = {}) {
1139
+ const load = deps.loadConfig || loadConfig;
1140
+ const getProfileDir = deps.getProfileDataDir;
1141
+ const runRecipe = deps.runRecipe || defaultRunRecipe;
1142
+ const recipe = program2.command("recipe").description("Manage profile-scoped BPMAX recipes");
1143
+ recipe.command("init <name>").description("Create a scaffold for a profile/workspace recipe").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--title <title>", "Recipe title").option("--force", "Overwrite existing scaffold files").option("--format <format>", "Output format", "pretty").action(async (name, options) => {
1144
+ const configData = await load();
1145
+ const target = resolveTargetProfile(configData, options.profile);
1146
+ const location = resolveRecipeLocation({
1147
+ profileName: target.name,
1148
+ workspace: options.workspace || target.workspace,
1149
+ recipeName: name,
1150
+ getProfileDir
1151
+ });
1152
+ await writeRecipeScaffold({ location, title: options.title, force: options.force });
1153
+ printResult(options.format, {
1154
+ name,
1155
+ profile: target.name,
1156
+ workspace: location.workspaceDirName,
1157
+ path: location.recipeDir
1158
+ });
1159
+ });
1160
+ recipe.command("list").description("List recipes for a profile/workspace").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--format <format>", "Output format", "table").action(async (options) => {
1161
+ const configData = await load();
1162
+ const target = resolveTargetProfile(configData, options.profile);
1163
+ const workspace = options.workspace || target.workspace;
1164
+ const rows = await listRecipes(getRecipesDir({ profileName: target.name, workspace, getProfileDir }));
1165
+ printResult(options.format, rows);
1166
+ });
1167
+ recipe.command("show <name>").description("Show a recipe definition").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--format <format>", "Output format", "pretty").action(async (name, options) => {
1168
+ const configData = await load();
1169
+ const target = resolveTargetProfile(configData, options.profile);
1170
+ const location = resolveRecipeLocation({
1171
+ profileName: target.name,
1172
+ workspace: options.workspace || target.workspace,
1173
+ recipeName: name,
1174
+ getProfileDir
1175
+ });
1176
+ const definition = await loadRecipe(location.recipeDir);
1177
+ printResult(options.format, {
1178
+ ...definition,
1179
+ profile: target.name,
1180
+ path: location.recipeDir
1181
+ });
1182
+ });
1183
+ recipe.command("path <name>").description("Print a recipe directory path").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").action(async (name, options) => {
1184
+ const configData = await load();
1185
+ const target = resolveTargetProfile(configData, options.profile);
1186
+ const location = resolveRecipeLocation({
1187
+ profileName: target.name,
1188
+ workspace: options.workspace || target.workspace,
1189
+ recipeName: name,
1190
+ getProfileDir
1191
+ });
1192
+ console.log(location.recipeDir);
1193
+ });
1194
+ recipe.command("run <name>").description("Render and run a profile/workspace recipe through bpmax-cli").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--var <entry>", "Recipe variable as key=value", (value, previous = []) => [...previous, value], []).option("--vars <json>", "Recipe variables JSON object").option("--yes", "Confirm running a mutating recipe").option("--format <format>", "Output format", "pretty").action(async (name, options) => {
1195
+ const configData = await load();
1196
+ const target = resolveTargetProfile(configData, options.profile);
1197
+ const location = resolveRecipeLocation({
1198
+ profileName: target.name,
1199
+ workspace: options.workspace || target.workspace,
1200
+ recipeName: name,
1201
+ getProfileDir
1202
+ });
1203
+ const definition = await loadRecipe(location.recipeDir);
1204
+ if (definition.command.mutating && !options.yes) {
1205
+ throw new Error("Recipe is marked as mutating. Re-run with --yes to execute it.");
1206
+ }
1207
+ const variables = mergeVariables(options.vars, collectVarEntries(options.var));
1208
+ const argv = await renderArgv({
1209
+ recipe: definition,
1210
+ recipeDir: location.recipeDir,
1211
+ variables,
1212
+ profileName: target.name
1213
+ });
1214
+ const exitCode = await runRecipe(argv);
1215
+ if (exitCode !== 0) {
1216
+ throw new Error(`Recipe command failed with exit code ${exitCode}.`);
1217
+ }
1218
+ if (options.format === "json") {
1219
+ printResult("json", { name, profile: target.name, workspace: location.workspaceDirName, argv, exitCode });
1220
+ }
1221
+ });
1222
+ }
1223
+
862
1224
  // src/core/manifest.ts
863
1225
  var schemaEntries = [
864
1226
  { name: "auth.login", description: "Open hpt-frontend bridge page and persist API key locally." },
@@ -1052,7 +1414,7 @@ function registerSetupCommand(program2, deps = {}) {
1052
1414
  // package.json
1053
1415
  var package_default = {
1054
1416
  name: "bpmax-cli",
1055
- version: "0.1.7",
1417
+ version: "0.1.8",
1056
1418
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
1057
1419
  type: "module",
1058
1420
  bin: {
@@ -1096,14 +1458,14 @@ var VERSION = package_default.version;
1096
1458
  var NPM_PACKAGE = "bpmax-cli";
1097
1459
 
1098
1460
  // src/core/skills.ts
1099
- import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
1100
- import path2 from "path";
1101
- import { fileURLToPath } from "url";
1461
+ import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
1462
+ import path3 from "path";
1463
+ import { fileURLToPath as fileURLToPath2 } from "url";
1102
1464
 
1103
1465
  // src/core/process.ts
1104
- import { spawn } from "child_process";
1466
+ import { spawn as spawn2 } from "child_process";
1105
1467
  var runCommand = (command, args, options = {}) => new Promise((resolve) => {
1106
- const child = spawn(command, args, {
1468
+ const child = spawn2(command, args, {
1107
1469
  cwd: options.cwd,
1108
1470
  env: options.env,
1109
1471
  stdio: ["ignore", "pipe", "pipe"]
@@ -1155,18 +1517,18 @@ var runCommand = (command, args, options = {}) => new Promise((resolve) => {
1155
1517
  var SKILLS_STAMP_FILE = "skills.stamp";
1156
1518
  var SKILLS_INSTALL_TIMEOUT_MS = 2 * 60 * 1e3;
1157
1519
  function stampPath(configDir = getConfigDir()) {
1158
- return path2.join(configDir, SKILLS_STAMP_FILE);
1520
+ return path3.join(configDir, SKILLS_STAMP_FILE);
1159
1521
  }
1160
1522
  async function readSkillsStamp(configDir = getConfigDir()) {
1161
1523
  try {
1162
- return (await readFile2(stampPath(configDir), "utf8")).trim();
1524
+ return (await readFile3(stampPath(configDir), "utf8")).trim();
1163
1525
  } catch {
1164
1526
  return "";
1165
1527
  }
1166
1528
  }
1167
1529
  async function writeSkillsStamp(version, configDir = getConfigDir()) {
1168
- await mkdir2(configDir, { recursive: true });
1169
- await writeFile2(stampPath(configDir), version, "utf8");
1530
+ await mkdir3(configDir, { recursive: true });
1531
+ await writeFile3(stampPath(configDir), version, "utf8");
1170
1532
  }
1171
1533
  async function checkSkillsSync(currentVersion, configDir = getConfigDir()) {
1172
1534
  if (process.env.BPMAX_CLI_NO_SKILLS_NOTIFIER) {
@@ -1176,11 +1538,11 @@ async function checkSkillsSync(currentVersion, configDir = getConfigDir()) {
1176
1538
  return { current, target: currentVersion, inSync: current === currentVersion };
1177
1539
  }
1178
1540
  function defaultPackageRoot() {
1179
- return path2.resolve(path2.dirname(fileURLToPath(import.meta.url)), "..", "..");
1541
+ return path3.resolve(path3.dirname(fileURLToPath2(import.meta.url)), "..", "..");
1180
1542
  }
1181
1543
  async function runSkillsInstall(options = {}) {
1182
1544
  const runner = options.runner || runCommand;
1183
- return runner(process.execPath, [path2.join(options.packageRoot || defaultPackageRoot(), "scripts", "install-skills.mjs")], {
1545
+ return runner(process.execPath, [path3.join(options.packageRoot || defaultPackageRoot(), "scripts", "install-skills.mjs")], {
1184
1546
  timeoutMs: SKILLS_INSTALL_TIMEOUT_MS
1185
1547
  });
1186
1548
  }
@@ -1200,8 +1562,8 @@ async function syncSkills(version, options = {}) {
1200
1562
  }
1201
1563
 
1202
1564
  // src/core/update.ts
1203
- import { access, mkdir as mkdir3, readFile as readFile3, realpath, writeFile as writeFile3 } from "fs/promises";
1204
- import path3 from "path";
1565
+ import { access as access2, mkdir as mkdir4, readFile as readFile4, realpath, writeFile as writeFile4 } from "fs/promises";
1566
+ import path4 from "path";
1205
1567
  var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
1206
1568
  var UPDATE_STATE_FILE = "update-state.json";
1207
1569
  var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -1313,11 +1675,11 @@ async function fetchLatestVersion(options = {}) {
1313
1675
  }
1314
1676
  }
1315
1677
  function updateStatePath(configDir = getConfigDir()) {
1316
- return path3.join(configDir, UPDATE_STATE_FILE);
1678
+ return path4.join(configDir, UPDATE_STATE_FILE);
1317
1679
  }
1318
1680
  async function readUpdateState(configDir) {
1319
1681
  try {
1320
- const raw = await readFile3(updateStatePath(configDir), "utf8");
1682
+ const raw = await readFile4(updateStatePath(configDir), "utf8");
1321
1683
  const parsed = JSON.parse(raw);
1322
1684
  if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
1323
1685
  return null;
@@ -1328,8 +1690,8 @@ async function readUpdateState(configDir) {
1328
1690
  }
1329
1691
  }
1330
1692
  async function writeUpdateState(state, configDir = getConfigDir()) {
1331
- await mkdir3(configDir, { recursive: true });
1332
- await writeFile3(updateStatePath(configDir), JSON.stringify(state), "utf8");
1693
+ await mkdir4(configDir, { recursive: true });
1694
+ await writeFile4(updateStatePath(configDir), JSON.stringify(state), "utf8");
1333
1695
  }
1334
1696
  async function checkCachedUpdate(currentVersion, configDir = getConfigDir()) {
1335
1697
  if (process.env.BPMAX_CLI_NO_UPDATE_NOTIFIER) {
@@ -1381,7 +1743,7 @@ async function findNpmPath() {
1381
1743
  }
1382
1744
  function detectInstallMethod(input) {
1383
1745
  const resolvedPath = input.executablePath || "";
1384
- const method = resolvedPath.includes(`node_modules${path3.sep}`) || resolvedPath.includes("node_modules/") ? "npm" : "manual";
1746
+ const method = resolvedPath.includes(`node_modules${path4.sep}`) || resolvedPath.includes("node_modules/") ? "npm" : "manual";
1385
1747
  return {
1386
1748
  method,
1387
1749
  resolvedPath,
@@ -1654,6 +2016,7 @@ registerSchemaCommands(program);
1654
2016
  registerUserCommands(program);
1655
2017
  registerFlowCommands(program);
1656
2018
  registerProjectCommands(program);
2019
+ registerRecipeCommands(program);
1657
2020
  registerSetupCommand(program);
1658
2021
  registerUpdateCommands(program);
1659
2022
  var isCompletion = process.argv.includes("completion") || process.argv.includes("__complete");