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 +21 -13
- package/dist/bin.js +138 -23
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install-skills.mjs +8 -5
- package/skills/bpmax-auth/SKILL.md +6 -4
- package/skills/bpmax-business-skill/SKILL.md +8 -7
- package/skills/bpmax-cli/SKILL.md +4 -4
- package/skills/bpmax-shared/SKILL.md +10 -4
package/package.json
CHANGED
|
@@ -13,18 +13,21 @@ const effectiveAgent = targetAgent || '<agent>';
|
|
|
13
13
|
const agentGuidance = {
|
|
14
14
|
initialization: [
|
|
15
15
|
'Agent action: ask the user to directly input a BPMAX workspace page URL, for example http://127.0.0.1:10018/w:store_mgr.',
|
|
16
|
-
`After the user replies with the URL, run: bpmax-cli init --agent ${effectiveAgent} --channel feishu --url "<USER_URL>" --name local --format json`,
|
|
16
|
+
`After the user replies with the URL, run: bpmax-cli init --agent ${effectiveAgent} --channel feishu --url "<USER_URL>" --name local --profile-scope "<TRUSTED_RUNTIME_SCOPE>" --format json`,
|
|
17
|
+
'For Agent multi-user deployments, TRUSTED_RUNTIME_SCOPE must come from trusted runtime metadata such as channel + peer/user, or at least a stable user id. Do not invent it from natural language.',
|
|
18
|
+
'The init result returns config_dir, profile, message_card.next_command, and next_commands. Treat those as authoritative.',
|
|
17
19
|
'For a local terminal/browser setup path, run instead: bpmax-cli setup "<USER_URL>" --name local',
|
|
18
20
|
],
|
|
19
21
|
core_usage: [
|
|
20
22
|
'Read JSON output first. Show message_card.authorization_url and message_card.user_code to the user.',
|
|
21
23
|
'After the user confirms the short code in BPMAX, run message_card.next_command exactly; do not guess commands from natural-language next_action text.',
|
|
22
|
-
'For later bpmax-cli decisions,
|
|
24
|
+
'For later bpmax-cli decisions, copy next_commands.profile_list/auth_status/bbs_list or keep the returned --config-dir and --profile values exactly.',
|
|
25
|
+
'Do not run bare config profile list, auth status, or bbs commands from a shared Agent runtime.',
|
|
23
26
|
],
|
|
24
27
|
bbs_policy: [
|
|
25
|
-
'For business requests, first look for BPMAX Business Skills (BBS)
|
|
26
|
-
`If no local/catalog match is available, sync BBS first and then decide again: bpmax-cli bbs sync --agent ${effectiveAgent} --profile <profile> --format json`,
|
|
27
|
-
`Before using a business skill, install or update it lazily: bpmax-cli bbs ensure <skill-key> --agent ${effectiveAgent} --profile <profile> --format json`,
|
|
28
|
+
'For business requests, first look for BPMAX Business Skills (BBS) by copying next_commands.bbs_list from init.',
|
|
29
|
+
`If no local/catalog match is available, sync BBS first and then decide again: bpmax-cli --config-dir <config_dir> bbs sync --agent ${effectiveAgent} --profile <profile> --format json`,
|
|
30
|
+
`Before using a business skill, install or update it lazily: bpmax-cli --config-dir <config_dir> bbs ensure <skill-key> --agent ${effectiveAgent} --profile <profile> --format json`,
|
|
28
31
|
],
|
|
29
32
|
};
|
|
30
33
|
const agentGuidanceLines = Object.values(agentGuidance).flat().map((line) => `[bpmax-cli] ${line}`);
|
|
@@ -24,8 +24,8 @@ metadata:
|
|
|
24
24
|
## 命令
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
bpmax-cli
|
|
28
|
-
bpmax-cli auth device complete --profile
|
|
27
|
+
bpmax-cli init --agent openclaw --channel feishu --url <BPMAX_URL> --name local --profile-scope <TRUSTED_RUNTIME_SCOPE> --format json
|
|
28
|
+
bpmax-cli --config-dir <config_dir_from_init> auth device complete --profile <profile_from_init> --session <device_code> --format json
|
|
29
29
|
bpmax-cli auth login --mode device --profile local
|
|
30
30
|
bpmax-cli auth login
|
|
31
31
|
bpmax-cli auth status
|
|
@@ -34,9 +34,11 @@ bpmax-cli auth logout
|
|
|
34
34
|
|
|
35
35
|
## 路由规则
|
|
36
36
|
|
|
37
|
-
- 首次接入某个环境且在 Agent/飞书中交互:优先用 `bpmax-cli init --agent openclaw|aily|generic --channel feishu --url <BPMAX_URL> --format json`
|
|
37
|
+
- 首次接入某个环境且在 Agent/飞书中交互:优先用 `bpmax-cli init --agent openclaw|aily|generic --channel feishu --url <BPMAX_URL> --profile-scope <TRUSTED_RUNTIME_SCOPE> --format json`
|
|
38
|
+
- Agent 多用户场景必须传 `--profile-scope <TRUSTED_RUNTIME_SCOPE>`;scope 来自可信 runtime metadata,不能由 LLM 猜测
|
|
38
39
|
- 只需要发起无浏览器授权:用 `auth device start`,把返回的 `message_card.authorization_url` 和 `message_card.user_code` 发给用户
|
|
39
40
|
- 用户确认短码后:优先执行返回的 `message_card.next_command`;不要从 `next_action` 自然语言里猜命令
|
|
41
|
+
- 后续授权状态只复制 `init` 返回的 `next_commands.auth_status`;不要自行把 profile 写成 `local`,也不要漏掉 `--config-dir`
|
|
40
42
|
- 本地终端可继续用 `auth login`
|
|
41
43
|
- 只想确认当前身份和连通性:`auth status`
|
|
42
44
|
- 只清空当前 profile 的本地 API Key:`auth logout`
|
|
@@ -49,7 +51,7 @@ bpmax-cli auth logout
|
|
|
49
51
|
2. CLI 调用 BPMAX `POST /api/cli/device_authorizations`
|
|
50
52
|
3. 服务端返回 `device_code`、`user_code`、`verification_uri_complete`、过期时间和轮询间隔
|
|
51
53
|
4. Agent 将 `message_card` 渲染给用户,用户在 BPMAX 页面确认短码
|
|
52
|
-
5. Agent 执行 `message_card.next_command
|
|
54
|
+
5. Agent 执行 `message_card.next_command`,等价于在隔离 `--config-dir` 内执行 `auth device complete --session <device_code>`
|
|
53
55
|
6. CLI 调用 BPMAX `POST /api/cli/device_token`,拿到 API Key 后落盘
|
|
54
56
|
|
|
55
57
|
规则:
|
|
@@ -15,18 +15,19 @@ BBS 是 BPMAX 远端托管的标准 agent skill 包。不要手动复制远端 B
|
|
|
15
15
|
## 常用命令
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
bpmax-cli bbs sync --agent openclaw --profile <profile> --format json
|
|
19
|
-
bpmax-cli bbs list --profile <profile> --format json
|
|
20
|
-
bpmax-cli bbs ensure <skill-key> --agent openclaw --profile <profile> --format json
|
|
21
|
-
bpmax-cli bbs gate <skill-key> --stage preflight --input @input.json --profile <profile> --format json
|
|
22
|
-
bpmax-cli bbs gate <skill-key> --stage verify --input @result.json --profile <profile> --format json
|
|
23
|
-
bpmax-cli bbs uninstall <skill-key> --agent openclaw --profile <profile> --format json
|
|
18
|
+
bpmax-cli --config-dir <config_dir> bbs sync --agent openclaw --profile <profile> --format json
|
|
19
|
+
bpmax-cli --config-dir <config_dir> bbs list --profile <profile> --format json
|
|
20
|
+
bpmax-cli --config-dir <config_dir> bbs ensure <skill-key> --agent openclaw --profile <profile> --format json
|
|
21
|
+
bpmax-cli --config-dir <config_dir> bbs gate <skill-key> --stage preflight --input @input.json --profile <profile> --format json
|
|
22
|
+
bpmax-cli --config-dir <config_dir> bbs gate <skill-key> --stage verify --input @result.json --profile <profile> --format json
|
|
23
|
+
bpmax-cli --config-dir <config_dir> bbs uninstall <skill-key> --agent openclaw --profile <profile> --format json
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## 规则
|
|
27
27
|
|
|
28
28
|
- 每次新会话、切换 profile/workspace,或用户需求看起来是业务流程、审批、门店、库存、项目处理时,先检查是否已有匹配 BBS。
|
|
29
|
-
-
|
|
29
|
+
- Agent 场景必须沿用 `init` 返回的 `config_dir`;优先复制 `next_commands.bbs_list`,不要裸跑共享 `bpmax-cli bbs list`。
|
|
30
|
+
- 若本地 catalog 或 `bbs list` 没有匹配业务 skill,先运行 `bpmax-cli --config-dir <config_dir> bbs sync --agent <agent> --profile <profile> --format json`,再重新判断是否有匹配 BBS。
|
|
30
31
|
- `bbs sync` 只安装 `bpmax-business-skill-catalog`,不安装所有业务 skill。
|
|
31
32
|
- 使用业务 skill 前先运行 `bbs ensure <skill-key>`。
|
|
32
33
|
- `bbs ensure` 会自动检测远端最新版本;本地缺失或版本落后时直接安装/更新。
|
|
@@ -15,20 +15,20 @@ metadata:
|
|
|
15
15
|
## Agent 基础行为
|
|
16
16
|
|
|
17
17
|
- 先应用 `../bpmax-shared/SKILL.md` 的命令发现、profile/auth 检查、全局参数、JSON 输出、URL 生成和原始 API 降级规则。
|
|
18
|
-
- 未初始化时,不要直接编造 profile 或 API Key;先要求用户提供 BPMAX workspace 页面 URL
|
|
18
|
+
- 未初始化时,不要直接编造 profile、config-dir 或 API Key;先要求用户提供 BPMAX workspace 页面 URL。Agent 多用户环境必须从可信 runtime metadata 读取稳定用户/会话 scope,优先使用 channel + peer/user,至少使用 user id,再运行:
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
bpmax-cli init --agent <agent> --channel feishu --url "<BPMAX_URL>" --name local --format json
|
|
21
|
+
bpmax-cli init --agent <agent> --channel feishu --url "<BPMAX_URL>" --name local --profile-scope "<TRUSTED_RUNTIME_SCOPE>" --format json
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
- `init` 返回后,Agent 必须展示 `message_card.authorization_url` 和 `message_card.user_code` 给用户;用户确认短码后,逐字执行 `message_card.next_command`,不要从 `message_card.next_action` 自然语言里猜命令。
|
|
25
|
-
-
|
|
25
|
+
- `profile`、`config_dir` 的最终值只以 `init` JSON 返回为准;不要自行拼接或复用 `local`/共享 `~/.bpmax`。后续检查优先复制 `next_commands.profile_list/auth_status/bbs_list`,不要裸跑 `config profile list`、`auth status` 或 `bbs list`。
|
|
26
26
|
|
|
27
27
|
## 业务需求优先 BBS
|
|
28
28
|
|
|
29
29
|
- 用户需求看起来是业务流程、审批、门店、库存、项目处理或环境强绑定操作时,先进入 `../bpmax-business-skill/SKILL.md`,不要直接从通用 flow/project/api 开始。
|
|
30
30
|
- 先查本地/远端 BBS 列表;没有匹配业务 skill 时先同步 BBS catalog,再重新判断。
|
|
31
|
-
- 找到匹配业务 skill
|
|
31
|
+
- 找到匹配业务 skill 后,先复制 `next_commands.bbs_list` 里的 `--config-dir` 前缀运行 `bpmax-cli --config-dir <config_dir> bbs ensure <skill-key> --agent <agent> --profile <profile> --format json`,再按该业务 skill 的规则执行。
|
|
32
32
|
- 只有没有匹配 BBS,或 BBS 不覆盖当前需求时,才回落到通用 `bpmax-flow`、`bpmax-project` 或 `bpmax-api` 路径。
|
|
33
33
|
|
|
34
34
|
## 路由规则
|
|
@@ -41,7 +41,7 @@ node "$BPMAX_CLI_HOME/dist/bin.js" ...
|
|
|
41
41
|
|
|
42
42
|
## 开始前检查
|
|
43
43
|
|
|
44
|
-
任何 BPMAX CLI
|
|
44
|
+
任何 BPMAX CLI 场景都先做两步。本地终端可直接运行;Agent/飞书/OpenClaw/Aily 等多用户运行时必须使用 `init` 返回的 `next_commands.profile_list` 和 `next_commands.auth_status`,不要裸跑共享配置命令:
|
|
45
45
|
|
|
46
46
|
```bash
|
|
47
47
|
bpmax-cli config profile show
|
|
@@ -52,7 +52,8 @@ bpmax-cli auth status
|
|
|
52
52
|
|
|
53
53
|
- 如果 profile 未配置,先走 `config profile add` 或 `config profile use`
|
|
54
54
|
- 如果当前 profile 没有可用 API Key:
|
|
55
|
-
- OpenClaw/Aily/飞书等无浏览器 Agent 场景,优先走 `bpmax-cli init --agent <agent> --channel feishu --url <BPMAX_URL> --format json`
|
|
55
|
+
- OpenClaw/Aily/飞书等无浏览器 Agent 场景,优先走 `bpmax-cli init --agent <agent> --channel feishu --url <BPMAX_URL> --profile-scope <TRUSTED_RUNTIME_SCOPE> --format json`
|
|
56
|
+
- Agent 多用户场景必须传 `--profile-scope <TRUSTED_RUNTIME_SCOPE>`;scope 必须来自可信 runtime metadata,不得由 LLM 猜测
|
|
56
57
|
- 本地终端场景才走 `auth login`
|
|
57
58
|
- 如果用户明确指定环境,始终显式加 `--profile <name>`
|
|
58
59
|
|
|
@@ -61,7 +62,7 @@ bpmax-cli auth status
|
|
|
61
62
|
无浏览器 Agent 推荐统一入口:
|
|
62
63
|
|
|
63
64
|
```bash
|
|
64
|
-
bpmax-cli init --agent openclaw --channel feishu --url "https://example.com/w:store_mgr" --name
|
|
65
|
+
bpmax-cli init --agent openclaw --channel feishu --url "https://example.com/w:store_mgr" --name local --profile-scope "<TRUSTED_RUNTIME_SCOPE>" --format json
|
|
65
66
|
```
|
|
66
67
|
|
|
67
68
|
规则:
|
|
@@ -69,8 +70,11 @@ bpmax-cli init --agent openclaw --channel feishu --url "https://example.com/w:st
|
|
|
69
70
|
- `--agent` 决定 skills adapter:`openclaw`、`aily`、`codex`、`claude`、`gemini`、`generic`
|
|
70
71
|
- `--channel` 只影响输出给 Agent/UI 的消息结构,飞书使用 `feishu`
|
|
71
72
|
- 返回中的 `message_card` 是通用抽象,不是飞书专属协议
|
|
73
|
+
- 返回中的 `config_dir` 是本次 Agent 用户上下文的唯一配置根目录,后续命令必须带 `--config-dir`
|
|
74
|
+
- 返回中的 `next_commands` 是后续检查命令的唯一可信来源
|
|
72
75
|
- Agent 应把 `message_card.authorization_url` 和 `message_card.user_code` 展示给用户
|
|
73
76
|
- 用户确认短码后,优先执行 `message_card.next_command`;不要从 `message_card.next_action` 自然语言里猜命令
|
|
77
|
+
- `profile` 最终值只以 `init` 返回为准;后续命令使用返回的 `profile`、`config_dir` 或完整 `next_command`,不要自行拼接 profile/config-dir
|
|
74
78
|
|
|
75
79
|
## Profile Recipes
|
|
76
80
|
|
|
@@ -83,7 +87,7 @@ bpmax-cli recipe show <name> --format json
|
|
|
83
87
|
|
|
84
88
|
规则:
|
|
85
89
|
|
|
86
|
-
- recipe 存储在
|
|
90
|
+
- recipe 存储在 `<config-dir>/profiles/<profile>/recipes/<workspace>/<recipe-name>/`
|
|
87
91
|
- 适合沉淀“创建店员”“发起某个固定业务流程”这类依赖具体环境 flow/template/key 的操作
|
|
88
92
|
- 执行 recipe 用 `bpmax-cli recipe run <name> --var key=value --vars '{...}' --yes`
|
|
89
93
|
- mutating recipe 必须显式 `--yes`
|
|
@@ -106,12 +110,14 @@ bpmax-cli config profile remove test
|
|
|
106
110
|
- `origin` 只填环境根地址,不带 `/api`
|
|
107
111
|
- 默认环境来自 `current_profile`
|
|
108
112
|
- 读到旧版 `~/.bpmax/config.json` 单环境格式时,CLI 会迁移为多 profile 结构
|
|
113
|
+
- Agent 场景必须复制 `init` 返回的 `next_commands.profile_list`;禁止裸跑 `bpmax-cli config profile list` 读取共享配置
|
|
109
114
|
|
|
110
115
|
## 全局参数
|
|
111
116
|
|
|
112
117
|
所有子命令都优先考虑这些参数:
|
|
113
118
|
|
|
114
119
|
- `--profile <name>`:覆盖默认 profile
|
|
120
|
+
- `--config-dir <dir>`:覆盖本地状态根目录;Agent 场景必须使用 `init` 返回的值
|
|
115
121
|
- `--format json|pretty|table|ndjson`:Agent 读取优先 `json`
|
|
116
122
|
- `--workspace <name>`:覆盖 profile 默认工作空间
|
|
117
123
|
- `--language <code>`:覆盖 profile 默认语言
|