bpmax-cli 0.1.34 → 0.1.36
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 +16 -13
- package/dist/bin.js +145 -32
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install-skills.mjs +7 -5
- package/skills/bpmax-auth/SKILL.md +5 -5
- package/skills/bpmax-business-skill/SKILL.md +8 -7
- package/skills/bpmax-cli/SKILL.md +3 -3
- package/skills/bpmax-shared/SKILL.md +9 -5
package/README.md
CHANGED
|
@@ -34,7 +34,9 @@ bpmax-cli init \
|
|
|
34
34
|
--format json
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
For
|
|
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.
|
|
38
40
|
|
|
39
41
|
The command saves the profile, syncs bundled skills for the selected agent adapter, and returns a `message_card` with:
|
|
40
42
|
|
|
@@ -44,10 +46,10 @@ The command saves the profile, syncs bundled skills for the selected agent adapt
|
|
|
44
46
|
- `next_action`
|
|
45
47
|
- `next_command`
|
|
46
48
|
|
|
47
|
-
After the user confirms the code in BPMAX, complete authorization
|
|
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:
|
|
48
50
|
|
|
49
51
|
```bash
|
|
50
|
-
bpmax-cli auth device complete --profile
|
|
52
|
+
bpmax-cli --config-dir ~/.bpmax/agent-contexts/openclaw/<scope_hash> auth device complete --profile local__openclaw__<scope_hash> --session <device_code> --format json
|
|
51
53
|
```
|
|
52
54
|
|
|
53
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:
|
|
@@ -81,8 +83,8 @@ bpmax-cli auth device start \
|
|
|
81
83
|
--format json
|
|
82
84
|
```
|
|
83
85
|
|
|
84
|
-
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
|
|
85
|
-
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.
|
|
86
88
|
|
|
87
89
|
Complete after the user confirms the code:
|
|
88
90
|
|
|
@@ -172,10 +174,10 @@ The body is passed to `POST /api/project/raw-es-search` unchanged:
|
|
|
172
174
|
|
|
173
175
|
## Profile recipes
|
|
174
176
|
|
|
175
|
-
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:
|
|
176
178
|
|
|
177
179
|
```text
|
|
178
|
-
|
|
180
|
+
<config-dir>/profiles/<profile>/recipes/<workspace>/<recipe-name>/
|
|
179
181
|
```
|
|
180
182
|
|
|
181
183
|
Create a scaffold for the active profile and workspace:
|
|
@@ -248,18 +250,19 @@ After installation, the script prints an agent-oriented guide. The recommended a
|
|
|
248
250
|
bpmax-cli init --agent <agent> --channel feishu --url "<USER_URL>" --name local --profile-scope "<TRUSTED_RUNTIME_SCOPE>" --format json
|
|
249
251
|
```
|
|
250
252
|
|
|
251
|
-
For
|
|
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.
|
|
252
254
|
|
|
253
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.
|
|
254
257
|
|
|
255
258
|
For local terminal/browser setup, `bpmax-cli setup "<USER_URL>" --name local` remains available.
|
|
256
259
|
|
|
257
260
|
For business requests, first look for BPMAX Business Skills (BBS):
|
|
258
261
|
|
|
259
262
|
```bash
|
|
260
|
-
bpmax-cli bbs list --profile <profile> --format json
|
|
261
|
-
bpmax-cli bbs sync --agent <agent> --profile <profile> --format json
|
|
262
|
-
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
|
|
263
266
|
```
|
|
264
267
|
|
|
265
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`.
|
|
@@ -294,13 +297,13 @@ BPMAX Business Skills (BBS) are standard skill zip packages hosted by a BPMAX en
|
|
|
294
297
|
Sync only the lightweight catalog into an agent:
|
|
295
298
|
|
|
296
299
|
```bash
|
|
297
|
-
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
|
|
298
301
|
```
|
|
299
302
|
|
|
300
303
|
Install or update a business skill only when it is needed:
|
|
301
304
|
|
|
302
305
|
```bash
|
|
303
|
-
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
|
|
304
307
|
```
|
|
305
308
|
|
|
306
309
|
Publish a BBS:
|
package/dist/bin.js
CHANGED
|
@@ -16,8 +16,8 @@ var SETUP_COMMAND_HINT = 'Do not show a command template yet. After the user rep
|
|
|
16
16
|
// src/core/config.ts
|
|
17
17
|
var DEFAULT_WORKSPACE = "default";
|
|
18
18
|
var DEFAULT_LANGUAGE = "zhCN";
|
|
19
|
-
var
|
|
20
|
-
var
|
|
19
|
+
var DEFAULT_CONFIG_DIR = path.join(homedir(), ".bpmax");
|
|
20
|
+
var configDirOverride;
|
|
21
21
|
var defaultConfig = () => ({
|
|
22
22
|
version: 2,
|
|
23
23
|
current_profile: "default",
|
|
@@ -61,7 +61,7 @@ var toV2Config = (input) => {
|
|
|
61
61
|
};
|
|
62
62
|
async function loadConfig() {
|
|
63
63
|
try {
|
|
64
|
-
const raw = await readFile(
|
|
64
|
+
const raw = await readFile(getConfigPath(), "utf8");
|
|
65
65
|
const parsed = JSON.parse(raw);
|
|
66
66
|
return toV2Config(parsed);
|
|
67
67
|
} catch (error) {
|
|
@@ -72,18 +72,28 @@ async function loadConfig() {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
async function saveConfig(config) {
|
|
75
|
-
|
|
76
|
-
await
|
|
75
|
+
const configDir = getConfigDir();
|
|
76
|
+
await mkdir(configDir, { recursive: true });
|
|
77
|
+
await writeFile(getConfigPath(), `${JSON.stringify(config, null, 2)}
|
|
77
78
|
`, "utf8");
|
|
78
79
|
}
|
|
79
80
|
function getConfigPath() {
|
|
80
|
-
return
|
|
81
|
+
return path.join(getConfigDir(), "config.json");
|
|
81
82
|
}
|
|
82
83
|
function getConfigDir() {
|
|
83
|
-
return
|
|
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);
|
|
84
94
|
}
|
|
85
95
|
function getProfileDataDir(profileName) {
|
|
86
|
-
return path.join(
|
|
96
|
+
return path.join(getConfigDir(), "profiles", profileName);
|
|
87
97
|
}
|
|
88
98
|
function hashProfileScope(scope) {
|
|
89
99
|
return createHash("sha256").update(scope.trim()).digest("hex").slice(0, 12);
|
|
@@ -93,6 +103,10 @@ function scopedProfileName(baseProfile, agent, scope) {
|
|
|
93
103
|
const safeAgent = agent.trim().replace(/[^a-zA-Z0-9._-]+/g, "_") || "generic";
|
|
94
104
|
return `${safeBase}__${safeAgent}__${hashProfileScope(scope)}`;
|
|
95
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));
|
|
109
|
+
}
|
|
96
110
|
function maskApiKey(apiKey) {
|
|
97
111
|
if (!apiKey) {
|
|
98
112
|
return "(unset)";
|
|
@@ -284,6 +298,12 @@ import { createServer } from "http";
|
|
|
284
298
|
import { randomBytes } from "crypto";
|
|
285
299
|
import axios2 from "axios";
|
|
286
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
|
+
}
|
|
287
307
|
var DeviceAuthorizationError = class extends Error {
|
|
288
308
|
code;
|
|
289
309
|
interval;
|
|
@@ -491,6 +511,7 @@ async function pollDeviceLogin(options) {
|
|
|
491
511
|
throw new DeviceAuthorizationError("expired_token", "Device authorization expired.");
|
|
492
512
|
}
|
|
493
513
|
function buildAuthorizationMessageCard(input) {
|
|
514
|
+
const configDirPrefix = input.config_dir ? ` --config-dir ${shellQuote(input.config_dir)}` : "";
|
|
494
515
|
return {
|
|
495
516
|
title: "Authorize BPMAX CLI",
|
|
496
517
|
summary: `Open the authorization link and confirm code ${input.user_code} for profile "${input.profile}".`,
|
|
@@ -498,7 +519,7 @@ function buildAuthorizationMessageCard(input) {
|
|
|
498
519
|
user_code: input.user_code,
|
|
499
520
|
expires_at: input.expires_at,
|
|
500
521
|
next_action: "Open the authorization URL, confirm the code, then run next_command.",
|
|
501
|
-
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`
|
|
502
523
|
};
|
|
503
524
|
}
|
|
504
525
|
function updateProfileAuth(profile, result) {
|
|
@@ -511,11 +532,16 @@ function updateProfileAuth(profile, result) {
|
|
|
511
532
|
|
|
512
533
|
// src/commands/auth.ts
|
|
513
534
|
function deviceStartBody(result) {
|
|
535
|
+
const configDir = isConfigDirOverridden() ? getConfigDir() : void 0;
|
|
514
536
|
return {
|
|
515
537
|
ok: true,
|
|
516
538
|
...result,
|
|
517
539
|
session: result.device_code,
|
|
518
|
-
|
|
540
|
+
...configDir ? { config_dir: configDir } : {},
|
|
541
|
+
message_card: buildAuthorizationMessageCard({
|
|
542
|
+
...result,
|
|
543
|
+
...configDir ? { config_dir: configDir } : {}
|
|
544
|
+
})
|
|
519
545
|
};
|
|
520
546
|
}
|
|
521
547
|
function registerAuthCommands(program2, deps = {}) {
|
|
@@ -565,7 +591,13 @@ function registerAuthCommands(program2, deps = {}) {
|
|
|
565
591
|
profile: profile.name,
|
|
566
592
|
login: "authenticated",
|
|
567
593
|
user: result.user,
|
|
568
|
-
...authorization ? {
|
|
594
|
+
...authorization ? {
|
|
595
|
+
authorization,
|
|
596
|
+
message_card: buildAuthorizationMessageCard({
|
|
597
|
+
...authorization,
|
|
598
|
+
...isConfigDirOverridden() ? { config_dir: getConfigDir() } : {}
|
|
599
|
+
})
|
|
600
|
+
} : {}
|
|
569
601
|
});
|
|
570
602
|
} else {
|
|
571
603
|
console.log(`Saved API key for profile "${profile.name}".`);
|
|
@@ -674,7 +706,7 @@ async function parseJsonInput(input, label = "JSON input") {
|
|
|
674
706
|
// package.json
|
|
675
707
|
var package_default = {
|
|
676
708
|
name: "bpmax-cli",
|
|
677
|
-
version: "0.1.
|
|
709
|
+
version: "0.1.36",
|
|
678
710
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
679
711
|
type: "module",
|
|
680
712
|
bin: {
|
|
@@ -1032,7 +1064,7 @@ async function exists(targetPath) {
|
|
|
1032
1064
|
}
|
|
1033
1065
|
}
|
|
1034
1066
|
function businessSkillStatePath(profileName, agent) {
|
|
1035
|
-
return path2.join(
|
|
1067
|
+
return path2.join(getConfigDir(), "business-skills", profileName, agent, "state.json");
|
|
1036
1068
|
}
|
|
1037
1069
|
async function readBusinessSkillState(profileName, agent) {
|
|
1038
1070
|
try {
|
|
@@ -1691,13 +1723,42 @@ function registerEsCommands(program2) {
|
|
|
1691
1723
|
}
|
|
1692
1724
|
|
|
1693
1725
|
// src/commands/flow.ts
|
|
1726
|
+
function normalizeWorkspaceKey(workspace) {
|
|
1727
|
+
const nextWorkspace = workspace.trim().replace(/^\/+|\/+$/g, "");
|
|
1728
|
+
return nextWorkspace.startsWith("w:") ? nextWorkspace.slice(2) : nextWorkspace;
|
|
1729
|
+
}
|
|
1730
|
+
function flowBindingKey(flowType, flowKey) {
|
|
1731
|
+
return `${String(flowType || "default")}:${String(flowKey || "")}`;
|
|
1732
|
+
}
|
|
1733
|
+
async function getWorkspaceFlowBindings(client, profile, options) {
|
|
1734
|
+
if (options.all) {
|
|
1735
|
+
return void 0;
|
|
1736
|
+
}
|
|
1737
|
+
const workspace = normalizeWorkspaceKey(options.workspace || profile.config.workspace);
|
|
1738
|
+
const workspaceInfo = await apiRequest(client, "GET", "/workspace/by_key", {
|
|
1739
|
+
params: {
|
|
1740
|
+
key: workspace
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
return new Set(
|
|
1744
|
+
(workspaceInfo.workspace_flow || []).map((item) => flowBindingKey(item.flow_type, item.flow_key))
|
|
1745
|
+
);
|
|
1746
|
+
}
|
|
1747
|
+
function filterFlowsByBindings(flows, bindings) {
|
|
1748
|
+
if (!bindings) {
|
|
1749
|
+
return flows;
|
|
1750
|
+
}
|
|
1751
|
+
return flows.filter((flow) => bindings.has(flowBindingKey(flow.flow_type, flow.key)));
|
|
1752
|
+
}
|
|
1694
1753
|
function registerFlowCommands(program2) {
|
|
1695
1754
|
const flow = program2.command("flow").description("Flow commands");
|
|
1696
|
-
flow.command("list").description("List flows").option("--profile <profile>", "Profile name").option("--draft <draft>", "Draft flag", "1").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
1755
|
+
flow.command("list").description("List flows").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--all", "List all flows without workspace binding filtering").option("--draft <draft>", "Draft flag", "1").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
1697
1756
|
const config = await loadConfig();
|
|
1698
1757
|
const profile = resolveProfile(config, options.profile);
|
|
1758
|
+
const client = createApiClient(profile);
|
|
1759
|
+
const bindings = await getWorkspaceFlowBindings(client, profile, options);
|
|
1699
1760
|
const result = await apiRequest(
|
|
1700
|
-
|
|
1761
|
+
client,
|
|
1701
1762
|
"GET",
|
|
1702
1763
|
"/flow/flow_type",
|
|
1703
1764
|
{
|
|
@@ -1707,40 +1768,48 @@ function registerFlowCommands(program2) {
|
|
|
1707
1768
|
}
|
|
1708
1769
|
}
|
|
1709
1770
|
);
|
|
1710
|
-
printResult(options.format, result);
|
|
1771
|
+
printResult(options.format, filterFlowsByBindings(result, bindings));
|
|
1711
1772
|
});
|
|
1712
|
-
flow.command("options").description("List flow options").option("--profile <profile>", "Profile name").option("--name <name>", "Flow name filter").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
1773
|
+
flow.command("options").description("List flow options").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--all", "List all flow options without workspace binding filtering").option("--name <name>", "Flow name filter").option("--format <format>", "Output format", "table").action(async (options) => {
|
|
1713
1774
|
const config = await loadConfig();
|
|
1714
1775
|
const profile = resolveProfile(config, options.profile);
|
|
1776
|
+
const client = createApiClient(profile);
|
|
1777
|
+
const bindings = await getWorkspaceFlowBindings(client, profile, options);
|
|
1715
1778
|
const result = await apiRequest(
|
|
1716
|
-
|
|
1779
|
+
client,
|
|
1717
1780
|
"GET",
|
|
1718
1781
|
"/flow/options",
|
|
1719
1782
|
{
|
|
1720
1783
|
params: options.name ? { name: options.name } : void 0
|
|
1721
1784
|
}
|
|
1722
1785
|
);
|
|
1723
|
-
printResult(options.format, result);
|
|
1786
|
+
printResult(options.format, filterFlowsByBindings(result, bindings));
|
|
1724
1787
|
});
|
|
1725
|
-
flow.command("get").description("Get flow detail by id or flow_type/flow_key").option("--id <id>", "Flow id").option("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key", "").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
1788
|
+
flow.command("get").description("Get flow detail by id or flow_type/flow_key").option("--id <id>", "Flow id").option("--flow-type <flowType>", "Flow type").option("--flow-key <flowKey>", "Flow key", "").option("--profile <profile>", "Profile name").option("--workspace <workspace>", "Workspace override").option("--all", "Get flow by flow_type without workspace binding filtering").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
1726
1789
|
const config = await loadConfig();
|
|
1727
1790
|
const profile = resolveProfile(config, options.profile);
|
|
1728
1791
|
const client = createApiClient(profile);
|
|
1729
1792
|
if (options.flowType) {
|
|
1793
|
+
const bindings = await getWorkspaceFlowBindings(client, profile, options);
|
|
1794
|
+
const path6 = options.flowKey ? "/flow/options" : "/flow/flow_type";
|
|
1795
|
+
const params = options.flowKey ? {
|
|
1796
|
+
detail: "1"
|
|
1797
|
+
} : {
|
|
1798
|
+
draft: "1",
|
|
1799
|
+
skip_i18n: "true"
|
|
1800
|
+
};
|
|
1730
1801
|
const result2 = await apiRequest(
|
|
1731
1802
|
client,
|
|
1732
1803
|
"GET",
|
|
1733
|
-
|
|
1804
|
+
path6,
|
|
1734
1805
|
{
|
|
1735
|
-
params
|
|
1736
|
-
draft: "1",
|
|
1737
|
-
skip_i18n: "true"
|
|
1738
|
-
}
|
|
1806
|
+
params
|
|
1739
1807
|
}
|
|
1740
1808
|
);
|
|
1809
|
+
const filteredResult = filterFlowsByBindings(result2, bindings);
|
|
1741
1810
|
printResult(
|
|
1742
1811
|
options.format,
|
|
1743
|
-
|
|
1812
|
+
filteredResult.find((item) => item.flow_type === options.flowType && String(item.key || "") === options.flowKey) ?? null
|
|
1744
1813
|
);
|
|
1745
1814
|
return;
|
|
1746
1815
|
}
|
|
@@ -1912,6 +1981,12 @@ async function syncSkills(version, options = {}) {
|
|
|
1912
1981
|
}
|
|
1913
1982
|
|
|
1914
1983
|
// src/commands/init.ts
|
|
1984
|
+
function shellQuote2(value) {
|
|
1985
|
+
if (/^[A-Za-z0-9_./:@=-]+$/.test(value)) {
|
|
1986
|
+
return value;
|
|
1987
|
+
}
|
|
1988
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
1989
|
+
}
|
|
1915
1990
|
function parseSkillsDetail(stdout) {
|
|
1916
1991
|
if (!stdout?.trim()) {
|
|
1917
1992
|
return void 0;
|
|
@@ -1955,6 +2030,10 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
1955
2030
|
const profileScope = options.profileScope?.trim();
|
|
1956
2031
|
const profileName = profileScope ? scopedProfileName(baseProfileName, options.agent, profileScope) : baseProfileName;
|
|
1957
2032
|
const profileScopeHash = profileScope ? hashProfileScope(profileScope) : void 0;
|
|
2033
|
+
if (profileScope) {
|
|
2034
|
+
setConfigDir(agentContextConfigDir(options.agent, profileScope));
|
|
2035
|
+
}
|
|
2036
|
+
const configDir = getConfigDir();
|
|
1958
2037
|
const config = await loadConfig2();
|
|
1959
2038
|
const nextConfig = applySetupProfile(config, profileName, {
|
|
1960
2039
|
origin: parsed.origin,
|
|
@@ -1964,7 +2043,8 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
1964
2043
|
await saveConfig2(nextConfig);
|
|
1965
2044
|
const skills = await syncSkills2(VERSION, {
|
|
1966
2045
|
force: Boolean(options.forceSkills),
|
|
1967
|
-
agent: options.agent
|
|
2046
|
+
agent: options.agent,
|
|
2047
|
+
configDir
|
|
1968
2048
|
});
|
|
1969
2049
|
const authorization = await startDeviceLogin2({
|
|
1970
2050
|
origin: parsed.origin,
|
|
@@ -1974,13 +2054,17 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
1974
2054
|
agent: options.agent,
|
|
1975
2055
|
channel: options.channel
|
|
1976
2056
|
});
|
|
2057
|
+
const commandPrefix2 = `bpmax-cli --config-dir ${shellQuote2(configDir)}`;
|
|
1977
2058
|
printResult(options.format, {
|
|
1978
2059
|
ok: true,
|
|
1979
2060
|
profile: profileName,
|
|
1980
2061
|
...profileScope ? {
|
|
1981
2062
|
base_profile: baseProfileName,
|
|
1982
2063
|
profile_isolated: true,
|
|
1983
|
-
profile_scope_hash: profileScopeHash
|
|
2064
|
+
profile_scope_hash: profileScopeHash,
|
|
2065
|
+
config_dir: configDir,
|
|
2066
|
+
context_isolated: true,
|
|
2067
|
+
context_scope_hash: profileScopeHash
|
|
1984
2068
|
} : {},
|
|
1985
2069
|
origin: parsed.origin,
|
|
1986
2070
|
workspace: parsed.workspace,
|
|
@@ -1992,7 +2076,17 @@ function registerInitCommand(program2, deps = {}) {
|
|
|
1992
2076
|
...skills.action === "failed" ? { error: skills.result?.stderr || skills.result?.stdout } : {}
|
|
1993
2077
|
},
|
|
1994
2078
|
authorization,
|
|
1995
|
-
message_card: buildAuthorizationMessageCard(
|
|
2079
|
+
message_card: buildAuthorizationMessageCard({
|
|
2080
|
+
...authorization,
|
|
2081
|
+
...profileScope ? { config_dir: configDir } : {}
|
|
2082
|
+
}),
|
|
2083
|
+
...profileScope ? {
|
|
2084
|
+
next_commands: {
|
|
2085
|
+
profile_list: `${commandPrefix2} config profile list --format json`,
|
|
2086
|
+
auth_status: `${commandPrefix2} auth status --profile ${profileName} --format json`,
|
|
2087
|
+
bbs_list: `${commandPrefix2} bbs list --profile ${profileName} --format json`
|
|
2088
|
+
}
|
|
2089
|
+
} : {}
|
|
1996
2090
|
});
|
|
1997
2091
|
});
|
|
1998
2092
|
}
|
|
@@ -3497,12 +3591,13 @@ function registerRecipeCommands(program2, deps = {}) {
|
|
|
3497
3591
|
variables,
|
|
3498
3592
|
profileName: target.name
|
|
3499
3593
|
});
|
|
3500
|
-
const
|
|
3594
|
+
const runnableArgv = isConfigDirOverridden() ? ["--config-dir", getConfigDir(), ...argv] : argv;
|
|
3595
|
+
const exitCode = await runRecipe(runnableArgv);
|
|
3501
3596
|
if (exitCode !== 0) {
|
|
3502
3597
|
throw new Error(`Recipe command failed with exit code ${exitCode}.`);
|
|
3503
3598
|
}
|
|
3504
3599
|
if (options.format === "json") {
|
|
3505
|
-
printResult("json", { name, profile: target.name, workspace: location.workspaceDirName, argv, exitCode });
|
|
3600
|
+
printResult("json", { name, profile: target.name, workspace: location.workspaceDirName, argv: runnableArgv, exitCode });
|
|
3506
3601
|
}
|
|
3507
3602
|
});
|
|
3508
3603
|
}
|
|
@@ -4142,7 +4237,24 @@ async function setupNotices(argv = process.argv) {
|
|
|
4142
4237
|
|
|
4143
4238
|
// src/bin.ts
|
|
4144
4239
|
var program = new Command();
|
|
4145
|
-
|
|
4240
|
+
function configDirFromArgv(argv) {
|
|
4241
|
+
const option = "--config-dir";
|
|
4242
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
4243
|
+
const arg = argv[index];
|
|
4244
|
+
if (arg === option) {
|
|
4245
|
+
return argv[index + 1];
|
|
4246
|
+
}
|
|
4247
|
+
if (arg.startsWith(`${option}=`)) {
|
|
4248
|
+
return arg.slice(option.length + 1);
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
return void 0;
|
|
4252
|
+
}
|
|
4253
|
+
program.name(CLI_NAME).description("BPMAX multi-environment CLI").version(VERSION).option("--config-dir <dir>", "Root directory for bpmax-cli local state");
|
|
4254
|
+
program.hook("preAction", (thisCommand) => {
|
|
4255
|
+
const options = thisCommand.optsWithGlobals();
|
|
4256
|
+
setConfigDir(options.configDir);
|
|
4257
|
+
});
|
|
4146
4258
|
registerConfigCommands(program);
|
|
4147
4259
|
registerAuthCommands(program);
|
|
4148
4260
|
registerBbsCommands(program);
|
|
@@ -4159,6 +4271,7 @@ registerSetupCommand(program);
|
|
|
4159
4271
|
registerInitCommand(program);
|
|
4160
4272
|
registerUpdateCommands(program);
|
|
4161
4273
|
var isCompletion = process.argv.includes("completion") || process.argv.includes("__complete");
|
|
4274
|
+
setConfigDir(configDirFromArgv(process.argv));
|
|
4162
4275
|
(isCompletion ? Promise.resolve() : setupNotices()).then(() => program.parseAsync(process.argv)).catch((error) => {
|
|
4163
4276
|
console.error(error instanceof Error ? error.message : String(error));
|
|
4164
4277
|
process.exitCode = 1;
|