bpmax-cli 0.1.33 → 0.1.35

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
@@ -29,10 +29,15 @@ bpmax-cli init \
29
29
  --agent openclaw \
30
30
  --channel feishu \
31
31
  --url https://example.com/w:store_mgr \
32
- --name retail \
32
+ --name local \
33
+ --profile-scope "<TRUSTED_RUNTIME_SCOPE>" \
33
34
  --format json
34
35
  ```
35
36
 
37
+ For Agent deployments, `TRUSTED_RUNTIME_SCOPE` must come from trusted runtime metadata such as channel + peer/user, or at least a stable user id. The LLM should not invent it. When `--profile-scope` is present, `init` creates an isolated context under `~/.bpmax/agent-contexts/<agent>/<scope_hash>/` and returns `config_dir`, `profile`, `message_card.next_command`, and `next_commands`.
38
+
39
+ Agent follow-up commands must copy the returned commands exactly, including `--config-dir`. Do not run bare `bpmax-cli config profile list`, `bpmax-cli auth status`, or `bpmax-cli bbs ...` from a shared Agent environment.
40
+
36
41
  The command saves the profile, syncs bundled skills for the selected agent adapter, and returns a `message_card` with:
37
42
 
38
43
  - `authorization_url`
@@ -41,10 +46,10 @@ The command saves the profile, syncs bundled skills for the selected agent adapt
41
46
  - `next_action`
42
47
  - `next_command`
43
48
 
44
- After the user confirms the code in BPMAX, complete authorization with:
49
+ After the user confirms the code in BPMAX, complete authorization by running `message_card.next_command` exactly. In an isolated Agent context it looks like:
45
50
 
46
51
  ```bash
47
- bpmax-cli auth device complete --profile retail --session <device_code> --format json
52
+ bpmax-cli --config-dir ~/.bpmax/agent-contexts/openclaw/<scope_hash> auth device complete --profile local__openclaw__<scope_hash> --session <device_code> --format json
48
53
  ```
49
54
 
50
55
  For agent-driven use, ask the user for any BPMAX page URL in the target workspace, then run setup with that URL. The CLI extracts the environment origin and workspace from the URL and opens browser authorization without terminal prompts:
@@ -78,8 +83,8 @@ bpmax-cli auth device start \
78
83
  --format json
79
84
  ```
80
85
 
81
- The result includes a short `user_code`, `authorization_url`, `session` (same as `device_code`), and a channel-neutral `message_card`. This is the recommended path for OpenClaw-style agents embedded in Feishu or other chat surfaces.
82
- Agents should execute `message_card.next_command` after the user confirms the code.
86
+ The result includes a short `user_code`, `authorization_url`, `session` (same as `device_code`), and a channel-neutral `message_card`. This is the recommended path for Agents embedded in Feishu or other chat surfaces.
87
+ Agents should execute `message_card.next_command` after the user confirms the code. If the command includes `--config-dir`, keep it unchanged.
83
88
 
84
89
  Complete after the user confirms the code:
85
90
 
@@ -169,10 +174,10 @@ The body is passed to `POST /api/project/raw-es-search` unchanged:
169
174
 
170
175
  ## Profile recipes
171
176
 
172
- Profile recipes are local, profile-scoped playbooks for environment-specific BPMAX operations. They live outside project repositories under:
177
+ Profile recipes are local, profile-scoped playbooks for environment-specific BPMAX operations. They live outside project repositories under the active config directory:
173
178
 
174
179
  ```text
175
- ~/.bpmax/profiles/<profile>/recipes/<workspace>/<recipe-name>/
180
+ <config-dir>/profiles/<profile>/recipes/<workspace>/<recipe-name>/
176
181
  ```
177
182
 
178
183
  Create a scaffold for the active profile and workspace:
@@ -242,19 +247,22 @@ After installation, the script prints an agent-oriented guide. The recommended a
242
247
  2. Initialize bpmax-cli for the current agent:
243
248
 
244
249
  ```bash
245
- bpmax-cli init --agent <agent> --channel feishu --url "<USER_URL>" --name local --format json
250
+ bpmax-cli init --agent <agent> --channel feishu --url "<USER_URL>" --name local --profile-scope "<TRUSTED_RUNTIME_SCOPE>" --format json
246
251
  ```
247
252
 
253
+ For Agent deployments, `TRUSTED_RUNTIME_SCOPE` must come from trusted runtime metadata such as channel + peer/user, or at least a stable user id. Do not ask the LLM to invent this value. The final profile name and config root are the `profile` and `config_dir` returned by `init`; do not reuse `local` or a shared `~/.bpmax/config.json` for follow-up commands.
254
+
248
255
  3. Show `message_card.authorization_url` and `message_card.user_code` to the user, then run `message_card.next_command` exactly after the user confirms the code.
256
+ 4. For later checks, copy `next_commands.profile_list`, `next_commands.auth_status`, and `next_commands.bbs_list` exactly. Do not reconstruct these commands from natural language.
249
257
 
250
258
  For local terminal/browser setup, `bpmax-cli setup "<USER_URL>" --name local` remains available.
251
259
 
252
260
  For business requests, first look for BPMAX Business Skills (BBS):
253
261
 
254
262
  ```bash
255
- bpmax-cli bbs list --profile <profile> --format json
256
- bpmax-cli bbs sync --agent <agent> --profile <profile> --format json
257
- bpmax-cli bbs ensure <skill-key> --agent <agent> --profile <profile> --format json
263
+ bpmax-cli --config-dir <config_dir> bbs list --profile <profile> --format json
264
+ bpmax-cli --config-dir <config_dir> bbs sync --agent <agent> --profile <profile> --format json
265
+ bpmax-cli --config-dir <config_dir> bbs ensure <skill-key> --agent <agent> --profile <profile> --format json
258
266
  ```
259
267
 
260
268
  Use `bbs sync` when there is no local/catalog match, then check again before falling back to generic flow/project/API commands. `bbs sync` installs only the catalog skill; individual business skills are installed lazily with `bbs ensure`.
@@ -289,13 +297,13 @@ BPMAX Business Skills (BBS) are standard skill zip packages hosted by a BPMAX en
289
297
  Sync only the lightweight catalog into an agent:
290
298
 
291
299
  ```bash
292
- bpmax-cli bbs sync --agent openclaw --profile yuanrong --format json
300
+ bpmax-cli --config-dir <config_dir> bbs sync --agent openclaw --profile yuanrong --format json
293
301
  ```
294
302
 
295
303
  Install or update a business skill only when it is needed:
296
304
 
297
305
  ```bash
298
- bpmax-cli bbs ensure <skill-key> --agent openclaw --profile yuanrong --format json
306
+ bpmax-cli --config-dir <config_dir> bbs ensure <skill-key> --agent openclaw --profile yuanrong --format json
299
307
  ```
300
308
 
301
309
  Publish a BBS:
package/dist/bin.js CHANGED
@@ -6,6 +6,7 @@ import { Command } from "commander";
6
6
  // src/core/config.ts
7
7
  import { homedir } from "os";
8
8
  import { mkdir, readFile, writeFile } from "fs/promises";
9
+ import { createHash } from "crypto";
9
10
  import path from "path";
10
11
 
11
12
  // src/core/setup-guide.ts
@@ -15,8 +16,8 @@ var SETUP_COMMAND_HINT = 'Do not show a command template yet. After the user rep
15
16
  // src/core/config.ts
16
17
  var DEFAULT_WORKSPACE = "default";
17
18
  var DEFAULT_LANGUAGE = "zhCN";
18
- var CONFIG_DIR = path.join(homedir(), ".bpmax");
19
- var CONFIG_PATH = path.join(CONFIG_DIR, "config.json");
19
+ var DEFAULT_CONFIG_DIR = path.join(homedir(), ".bpmax");
20
+ var configDirOverride;
20
21
  var defaultConfig = () => ({
21
22
  version: 2,
22
23
  current_profile: "default",
@@ -60,7 +61,7 @@ var toV2Config = (input) => {
60
61
  };
61
62
  async function loadConfig() {
62
63
  try {
63
- const raw = await readFile(CONFIG_PATH, "utf8");
64
+ const raw = await readFile(getConfigPath(), "utf8");
64
65
  const parsed = JSON.parse(raw);
65
66
  return toV2Config(parsed);
66
67
  } catch (error) {
@@ -71,18 +72,40 @@ async function loadConfig() {
71
72
  }
72
73
  }
73
74
  async function saveConfig(config) {
74
- await mkdir(CONFIG_DIR, { recursive: true });
75
- await writeFile(CONFIG_PATH, `${JSON.stringify(config, null, 2)}
75
+ const configDir = getConfigDir();
76
+ await mkdir(configDir, { recursive: true });
77
+ await writeFile(getConfigPath(), `${JSON.stringify(config, null, 2)}
76
78
  `, "utf8");
77
79
  }
78
80
  function getConfigPath() {
79
- return CONFIG_PATH;
81
+ return path.join(getConfigDir(), "config.json");
80
82
  }
81
83
  function getConfigDir() {
82
- return CONFIG_DIR;
84
+ return configDirOverride || DEFAULT_CONFIG_DIR;
85
+ }
86
+ function getDefaultConfigDir() {
87
+ return DEFAULT_CONFIG_DIR;
88
+ }
89
+ function setConfigDir(configDir) {
90
+ configDirOverride = configDir?.trim() ? path.resolve(configDir.trim()) : void 0;
91
+ }
92
+ function isConfigDirOverridden() {
93
+ return Boolean(configDirOverride);
83
94
  }
84
95
  function getProfileDataDir(profileName) {
85
- return path.join(CONFIG_DIR, "profiles", profileName);
96
+ return path.join(getConfigDir(), "profiles", profileName);
97
+ }
98
+ function hashProfileScope(scope) {
99
+ return createHash("sha256").update(scope.trim()).digest("hex").slice(0, 12);
100
+ }
101
+ function scopedProfileName(baseProfile, agent, scope) {
102
+ const safeBase = baseProfile.trim().replace(/[^a-zA-Z0-9._-]+/g, "_") || "default";
103
+ const safeAgent = agent.trim().replace(/[^a-zA-Z0-9._-]+/g, "_") || "generic";
104
+ return `${safeBase}__${safeAgent}__${hashProfileScope(scope)}`;
105
+ }
106
+ function agentContextConfigDir(agent, scope, rootDir = getDefaultConfigDir()) {
107
+ const safeAgent = agent.trim().replace(/[^a-zA-Z0-9._-]+/g, "_") || "generic";
108
+ return path.join(rootDir, "agent-contexts", safeAgent, hashProfileScope(scope));
86
109
  }
87
110
  function maskApiKey(apiKey) {
88
111
  if (!apiKey) {
@@ -275,6 +298,12 @@ import { createServer } from "http";
275
298
  import { randomBytes } from "crypto";
276
299
  import axios2 from "axios";
277
300
  import open from "open";
301
+ function shellQuote(value) {
302
+ if (/^[A-Za-z0-9_./:@=-]+$/.test(value)) {
303
+ return value;
304
+ }
305
+ return `'${value.replace(/'/g, `'\\''`)}'`;
306
+ }
278
307
  var DeviceAuthorizationError = class extends Error {
279
308
  code;
280
309
  interval;
@@ -482,6 +511,7 @@ async function pollDeviceLogin(options) {
482
511
  throw new DeviceAuthorizationError("expired_token", "Device authorization expired.");
483
512
  }
484
513
  function buildAuthorizationMessageCard(input) {
514
+ const configDirPrefix = input.config_dir ? ` --config-dir ${shellQuote(input.config_dir)}` : "";
485
515
  return {
486
516
  title: "Authorize BPMAX CLI",
487
517
  summary: `Open the authorization link and confirm code ${input.user_code} for profile "${input.profile}".`,
@@ -489,7 +519,7 @@ function buildAuthorizationMessageCard(input) {
489
519
  user_code: input.user_code,
490
520
  expires_at: input.expires_at,
491
521
  next_action: "Open the authorization URL, confirm the code, then run next_command.",
492
- next_command: `bpmax-cli auth device complete --profile ${input.profile} --session ${input.device_code} --format json`
522
+ next_command: `bpmax-cli${configDirPrefix} auth device complete --profile ${input.profile} --session ${input.device_code} --format json`
493
523
  };
494
524
  }
495
525
  function updateProfileAuth(profile, result) {
@@ -502,11 +532,16 @@ function updateProfileAuth(profile, result) {
502
532
 
503
533
  // src/commands/auth.ts
504
534
  function deviceStartBody(result) {
535
+ const configDir = isConfigDirOverridden() ? getConfigDir() : void 0;
505
536
  return {
506
537
  ok: true,
507
538
  ...result,
508
539
  session: result.device_code,
509
- message_card: buildAuthorizationMessageCard(result)
540
+ ...configDir ? { config_dir: configDir } : {},
541
+ message_card: buildAuthorizationMessageCard({
542
+ ...result,
543
+ ...configDir ? { config_dir: configDir } : {}
544
+ })
510
545
  };
511
546
  }
512
547
  function registerAuthCommands(program2, deps = {}) {
@@ -556,7 +591,13 @@ function registerAuthCommands(program2, deps = {}) {
556
591
  profile: profile.name,
557
592
  login: "authenticated",
558
593
  user: result.user,
559
- ...authorization ? { authorization, message_card: buildAuthorizationMessageCard(authorization) } : {}
594
+ ...authorization ? {
595
+ authorization,
596
+ message_card: buildAuthorizationMessageCard({
597
+ ...authorization,
598
+ ...isConfigDirOverridden() ? { config_dir: getConfigDir() } : {}
599
+ })
600
+ } : {}
560
601
  });
561
602
  } else {
562
603
  console.log(`Saved API key for profile "${profile.name}".`);
@@ -665,7 +706,7 @@ async function parseJsonInput(input, label = "JSON input") {
665
706
  // package.json
666
707
  var package_default = {
667
708
  name: "bpmax-cli",
668
- version: "0.1.33",
709
+ version: "0.1.35",
669
710
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
670
711
  type: "module",
671
712
  bin: {
@@ -827,7 +868,7 @@ function attachProjectDetailUrl(profile, value) {
827
868
 
828
869
  // src/core/business-skills.ts
829
870
  import { cp, mkdir as mkdir2, readFile as readFile3, rm, stat, writeFile as writeFile2 } from "fs/promises";
830
- import { createHash } from "crypto";
871
+ import { createHash as createHash2 } from "crypto";
831
872
  import { homedir as homedir2, tmpdir } from "os";
832
873
  import path2 from "path";
833
874
  import { setTimeout as delay } from "timers/promises";
@@ -1023,7 +1064,7 @@ async function exists(targetPath) {
1023
1064
  }
1024
1065
  }
1025
1066
  function businessSkillStatePath(profileName, agent) {
1026
- return path2.join(homedir2(), ".bpmax", "business-skills", profileName, agent, "state.json");
1067
+ return path2.join(getConfigDir(), "business-skills", profileName, agent, "state.json");
1027
1068
  }
1028
1069
  async function readBusinessSkillState(profileName, agent) {
1029
1070
  try {
@@ -1304,7 +1345,7 @@ async function downloadBusinessSkillPackage(profile, download) {
1304
1345
  responseType: "arraybuffer"
1305
1346
  })).data
1306
1347
  );
1307
- const checksum = createHash("sha256").update(buffer).digest("hex");
1348
+ const checksum = createHash2("sha256").update(buffer).digest("hex");
1308
1349
  if (download.checksum && checksum !== download.checksum) {
1309
1350
  throw new Error(`BBS checksum mismatch. expected ${download.checksum}, got ${checksum}`);
1310
1351
  }
@@ -1363,7 +1404,7 @@ async function buildCatalogSkill(skills) {
1363
1404
  await writeFile2(path2.join(dir, "SKILL.md"), body, "utf8");
1364
1405
  return {
1365
1406
  dir,
1366
- checksum: createHash("sha256").update(body).digest("hex")
1407
+ checksum: createHash2("sha256").update(body).digest("hex")
1367
1408
  };
1368
1409
  }
1369
1410
 
@@ -1903,6 +1944,12 @@ async function syncSkills(version, options = {}) {
1903
1944
  }
1904
1945
 
1905
1946
  // src/commands/init.ts
1947
+ function shellQuote2(value) {
1948
+ if (/^[A-Za-z0-9_./:@=-]+$/.test(value)) {
1949
+ return value;
1950
+ }
1951
+ return `'${value.replace(/'/g, `'\\''`)}'`;
1952
+ }
1906
1953
  function parseSkillsDetail(stdout) {
1907
1954
  if (!stdout?.trim()) {
1908
1955
  return void 0;
@@ -1913,14 +1960,43 @@ function parseSkillsDetail(stdout) {
1913
1960
  return void 0;
1914
1961
  }
1915
1962
  }
1963
+ var SHARED_OPENCLAW_PROFILES = /* @__PURE__ */ new Set(["default", "local"]);
1964
+ var OPENCLAW_SCOPE_REQUIRED_MESSAGE = 'OpenClaw multi-user initialization with shared profile names "local" or "default" requires --profile-scope from trusted runtime metadata.';
1965
+ function isSharedOpenClawProfile(agent, profileName) {
1966
+ return agent === "openclaw" && SHARED_OPENCLAW_PROFILES.has(profileName);
1967
+ }
1916
1968
  function registerInitCommand(program2, deps = {}) {
1917
1969
  const loadConfig2 = deps.loadConfig || loadConfig;
1918
1970
  const saveConfig2 = deps.saveConfig || saveConfig;
1919
1971
  const syncSkills2 = deps.syncSkills || syncSkills;
1920
1972
  const startDeviceLogin2 = deps.startDeviceLogin || startDeviceLogin;
1921
- program2.command("init").description("Initialize bpmax-cli for browserless agent environments").requiredOption("--url <url>", "Full BPMAX workspace URL, for example https://example.com/w:store_mgr").option("--name <name>", "Profile name", "default").option("--agent <agent>", "Agent adapter: openclaw | aily | codex | claude | gemini | generic", "generic").option("--channel <channel>", "Interaction channel: feishu | terminal | json", "json").option("--key-name <keyName>", "Target API key name", "bpmax-cli").option("--language <language>", "Default language", DEFAULT_LANGUAGE).option("--force-skills", "Force skills reinstall").option("--format <format>", "Output format", "pretty").action(async (options) => {
1973
+ program2.command("init").description("Initialize bpmax-cli for browserless agent environments").requiredOption("--url <url>", "Full BPMAX workspace URL, for example https://example.com/w:store_mgr").option("--name <name>", "Profile name", "default").option("--profile-scope <scope>", "Trusted runtime scope for agent-user profile isolation").option("--agent <agent>", "Agent adapter: openclaw | aily | codex | claude | gemini | generic", "generic").option("--channel <channel>", "Interaction channel: feishu | terminal | json", "json").option("--key-name <keyName>", "Target API key name", "bpmax-cli").option("--language <language>", "Default language", DEFAULT_LANGUAGE).option("--force-skills", "Force skills reinstall").option("--format <format>", "Output format", "pretty").action(async (options) => {
1922
1974
  const parsed = parseBpmUrl(options.url);
1923
- const profileName = options.name || "default";
1975
+ const baseProfileName = options.name || "default";
1976
+ if (isSharedOpenClawProfile(options.agent, baseProfileName) && !options.profileScope?.trim()) {
1977
+ if (options.format === "json") {
1978
+ printResult("json", {
1979
+ ok: false,
1980
+ error: {
1981
+ code: "profile_scope_required",
1982
+ message: OPENCLAW_SCOPE_REQUIRED_MESSAGE,
1983
+ agent: options.agent,
1984
+ base_profile: baseProfileName,
1985
+ requires: "--profile-scope"
1986
+ }
1987
+ });
1988
+ process.exitCode = 1;
1989
+ return;
1990
+ }
1991
+ throw new Error(OPENCLAW_SCOPE_REQUIRED_MESSAGE);
1992
+ }
1993
+ const profileScope = options.profileScope?.trim();
1994
+ const profileName = profileScope ? scopedProfileName(baseProfileName, options.agent, profileScope) : baseProfileName;
1995
+ const profileScopeHash = profileScope ? hashProfileScope(profileScope) : void 0;
1996
+ if (profileScope) {
1997
+ setConfigDir(agentContextConfigDir(options.agent, profileScope));
1998
+ }
1999
+ const configDir = getConfigDir();
1924
2000
  const config = await loadConfig2();
1925
2001
  const nextConfig = applySetupProfile(config, profileName, {
1926
2002
  origin: parsed.origin,
@@ -1930,7 +2006,8 @@ function registerInitCommand(program2, deps = {}) {
1930
2006
  await saveConfig2(nextConfig);
1931
2007
  const skills = await syncSkills2(VERSION, {
1932
2008
  force: Boolean(options.forceSkills),
1933
- agent: options.agent
2009
+ agent: options.agent,
2010
+ configDir
1934
2011
  });
1935
2012
  const authorization = await startDeviceLogin2({
1936
2013
  origin: parsed.origin,
@@ -1940,9 +2017,18 @@ function registerInitCommand(program2, deps = {}) {
1940
2017
  agent: options.agent,
1941
2018
  channel: options.channel
1942
2019
  });
2020
+ const commandPrefix2 = `bpmax-cli --config-dir ${shellQuote2(configDir)}`;
1943
2021
  printResult(options.format, {
1944
2022
  ok: true,
1945
2023
  profile: profileName,
2024
+ ...profileScope ? {
2025
+ base_profile: baseProfileName,
2026
+ profile_isolated: true,
2027
+ profile_scope_hash: profileScopeHash,
2028
+ config_dir: configDir,
2029
+ context_isolated: true,
2030
+ context_scope_hash: profileScopeHash
2031
+ } : {},
1946
2032
  origin: parsed.origin,
1947
2033
  workspace: parsed.workspace,
1948
2034
  agent: options.agent,
@@ -1953,7 +2039,17 @@ function registerInitCommand(program2, deps = {}) {
1953
2039
  ...skills.action === "failed" ? { error: skills.result?.stderr || skills.result?.stdout } : {}
1954
2040
  },
1955
2041
  authorization,
1956
- message_card: buildAuthorizationMessageCard(authorization)
2042
+ message_card: buildAuthorizationMessageCard({
2043
+ ...authorization,
2044
+ ...profileScope ? { config_dir: configDir } : {}
2045
+ }),
2046
+ ...profileScope ? {
2047
+ next_commands: {
2048
+ profile_list: `${commandPrefix2} config profile list --format json`,
2049
+ auth_status: `${commandPrefix2} auth status --profile ${profileName} --format json`,
2050
+ bbs_list: `${commandPrefix2} bbs list --profile ${profileName} --format json`
2051
+ }
2052
+ } : {}
1957
2053
  });
1958
2054
  });
1959
2055
  }
@@ -3458,12 +3554,13 @@ function registerRecipeCommands(program2, deps = {}) {
3458
3554
  variables,
3459
3555
  profileName: target.name
3460
3556
  });
3461
- const exitCode = await runRecipe(argv);
3557
+ const runnableArgv = isConfigDirOverridden() ? ["--config-dir", getConfigDir(), ...argv] : argv;
3558
+ const exitCode = await runRecipe(runnableArgv);
3462
3559
  if (exitCode !== 0) {
3463
3560
  throw new Error(`Recipe command failed with exit code ${exitCode}.`);
3464
3561
  }
3465
3562
  if (options.format === "json") {
3466
- printResult("json", { name, profile: target.name, workspace: location.workspaceDirName, argv, exitCode });
3563
+ printResult("json", { name, profile: target.name, workspace: location.workspaceDirName, argv: runnableArgv, exitCode });
3467
3564
  }
3468
3565
  });
3469
3566
  }
@@ -4103,7 +4200,24 @@ async function setupNotices(argv = process.argv) {
4103
4200
 
4104
4201
  // src/bin.ts
4105
4202
  var program = new Command();
4106
- program.name(CLI_NAME).description("BPMAX multi-environment CLI").version(VERSION);
4203
+ function configDirFromArgv(argv) {
4204
+ const option = "--config-dir";
4205
+ for (let index = 0; index < argv.length; index += 1) {
4206
+ const arg = argv[index];
4207
+ if (arg === option) {
4208
+ return argv[index + 1];
4209
+ }
4210
+ if (arg.startsWith(`${option}=`)) {
4211
+ return arg.slice(option.length + 1);
4212
+ }
4213
+ }
4214
+ return void 0;
4215
+ }
4216
+ program.name(CLI_NAME).description("BPMAX multi-environment CLI").version(VERSION).option("--config-dir <dir>", "Root directory for bpmax-cli local state");
4217
+ program.hook("preAction", (thisCommand) => {
4218
+ const options = thisCommand.optsWithGlobals();
4219
+ setConfigDir(options.configDir);
4220
+ });
4107
4221
  registerConfigCommands(program);
4108
4222
  registerAuthCommands(program);
4109
4223
  registerBbsCommands(program);
@@ -4120,6 +4234,7 @@ registerSetupCommand(program);
4120
4234
  registerInitCommand(program);
4121
4235
  registerUpdateCommands(program);
4122
4236
  var isCompletion = process.argv.includes("completion") || process.argv.includes("__complete");
4237
+ setConfigDir(configDirFromArgv(process.argv));
4123
4238
  (isCompletion ? Promise.resolve() : setupNotices()).then(() => program.parseAsync(process.argv)).catch((error) => {
4124
4239
  console.error(error instanceof Error ? error.message : String(error));
4125
4240
  process.exitCode = 1;