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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmax-cli",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "description": "CLI for BPMAX environments with multi-profile config and local login callback flow",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,18 +14,20 @@ 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
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 OpenClaw 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.',
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.',
18
19
  'For a local terminal/browser setup path, run instead: bpmax-cli setup "<USER_URL>" --name local',
19
20
  ],
20
21
  core_usage: [
21
22
  'Read JSON output first. Show message_card.authorization_url and message_card.user_code to the user.',
22
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.',
23
- 'For later bpmax-cli decisions, prefer --format json and pass the returned --profile <profile> when the target environment matters.',
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.',
24
26
  ],
25
27
  bbs_policy: [
26
- 'For business requests, first look for BPMAX Business Skills (BBS): bpmax-cli bbs list --profile <profile> --format json',
27
- `If no local/catalog match is available, sync BBS first and then decide again: bpmax-cli bbs sync --agent ${effectiveAgent} --profile <profile> --format json`,
28
- `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`,
29
31
  ],
30
32
  };
31
33
  const agentGuidanceLines = Object.values(agentGuidance).flat().map((line) => `[bpmax-cli] ${line}`);
@@ -25,7 +25,7 @@ metadata:
25
25
 
26
26
  ```bash
27
27
  bpmax-cli init --agent openclaw --channel feishu --url <BPMAX_URL> --name local --profile-scope <TRUSTED_RUNTIME_SCOPE> --format json
28
- bpmax-cli auth device complete --profile <profile_from_init> --session <device_code> --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,11 +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`
38
- - OpenClaw 多用户场景必须传 `--profile-scope <TRUSTED_RUNTIME_SCOPE>`;scope 来自可信 runtime metadata,不能由 LLM 猜测
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 猜测
39
39
  - 只需要发起无浏览器授权:用 `auth device start`,把返回的 `message_card.authorization_url` 和 `message_card.user_code` 发给用户
40
40
  - 用户确认短码后:优先执行返回的 `message_card.next_command`;不要从 `next_action` 自然语言里猜命令
41
- - 后续授权状态只使用 `init` 返回的 `profile`;不要自行把 profile 写成 `local`
41
+ - 后续授权状态只复制 `init` 返回的 `next_commands.auth_status`;不要自行把 profile 写成 `local`,也不要漏掉 `--config-dir`
42
42
  - 本地终端可继续用 `auth login`
43
43
  - 只想确认当前身份和连通性:`auth status`
44
44
  - 只清空当前 profile 的本地 API Key:`auth logout`
@@ -51,7 +51,7 @@ bpmax-cli auth logout
51
51
  2. CLI 调用 BPMAX `POST /api/cli/device_authorizations`
52
52
  3. 服务端返回 `device_code`、`user_code`、`verification_uri_complete`、过期时间和轮询间隔
53
53
  4. Agent 将 `message_card` 渲染给用户,用户在 BPMAX 页面确认短码
54
- 5. Agent 执行 `message_card.next_command`,等价于 `auth device complete --session <device_code>`
54
+ 5. Agent 执行 `message_card.next_command`,等价于在隔离 `--config-dir` 内执行 `auth device complete --session <device_code>`
55
55
  6. CLI 调用 BPMAX `POST /api/cli/device_token`,拿到 API Key 后落盘
56
56
 
57
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
- - 若本地 catalog 或 `bbs list` 没有匹配业务 skill,先运行 `bpmax-cli bbs sync --agent <agent> --profile <profile> --format json`,再重新判断是否有匹配 BBS。
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。OpenClaw 多用户环境必须从可信 runtime metadata 读取稳定用户/会话 scope,优先使用 channel + peer/user,至少使用 user id,再运行:
18
+ - 未初始化时,不要直接编造 profile、config-dir 或 API Key;先要求用户提供 BPMAX workspace 页面 URL。Agent 多用户环境必须从可信 runtime metadata 读取稳定用户/会话 scope,优先使用 channel + peer/user,至少使用 user id,再运行:
19
19
 
20
20
  ```bash
21
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
- - `profile` 的最终值只以 `init` JSON 返回为准;不要自行拼接或复用 `local`。后续需要 Agent 判断或串联操作时,优先使用 `--format json`;用户明确环境时显式加返回的 `--profile <name>`。
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 后,先 `bpmax-cli bbs ensure <skill-key> --agent <agent> --profile <profile> --format json`,再按该业务 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,8 +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` 或 `auth device start/complete`
56
- - OpenClaw 多用户场景必须额外传 `--profile-scope <TRUSTED_RUNTIME_SCOPE>`;scope 必须来自可信 runtime metadata,不得由 LLM 猜测
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 猜测
57
57
  - 本地终端场景才走 `auth login`
58
58
  - 如果用户明确指定环境,始终显式加 `--profile <name>`
59
59
 
@@ -70,9 +70,11 @@ bpmax-cli init --agent openclaw --channel feishu --url "https://example.com/w:st
70
70
  - `--agent` 决定 skills adapter:`openclaw`、`aily`、`codex`、`claude`、`gemini`、`generic`
71
71
  - `--channel` 只影响输出给 Agent/UI 的消息结构,飞书使用 `feishu`
72
72
  - 返回中的 `message_card` 是通用抽象,不是飞书专属协议
73
+ - 返回中的 `config_dir` 是本次 Agent 用户上下文的唯一配置根目录,后续命令必须带 `--config-dir`
74
+ - 返回中的 `next_commands` 是后续检查命令的唯一可信来源
73
75
  - Agent 应把 `message_card.authorization_url` 和 `message_card.user_code` 展示给用户
74
76
  - 用户确认短码后,优先执行 `message_card.next_command`;不要从 `message_card.next_action` 自然语言里猜命令
75
- - `profile` 最终值只以 `init` 返回为准;后续命令使用返回的 `profile` 或 `message_card.next_command`,不要自行拼接 profile
77
+ - `profile` 最终值只以 `init` 返回为准;后续命令使用返回的 `profile`、`config_dir` 或完整 `next_command`,不要自行拼接 profile/config-dir
76
78
 
77
79
  ## Profile Recipes
78
80
 
@@ -85,7 +87,7 @@ bpmax-cli recipe show <name> --format json
85
87
 
86
88
  规则:
87
89
 
88
- - recipe 存储在 `~/.bpmax/profiles/<profile>/recipes/<workspace>/<recipe-name>/`
90
+ - recipe 存储在 `<config-dir>/profiles/<profile>/recipes/<workspace>/<recipe-name>/`
89
91
  - 适合沉淀“创建店员”“发起某个固定业务流程”这类依赖具体环境 flow/template/key 的操作
90
92
  - 执行 recipe 用 `bpmax-cli recipe run <name> --var key=value --vars '{...}' --yes`
91
93
  - mutating recipe 必须显式 `--yes`
@@ -108,12 +110,14 @@ bpmax-cli config profile remove test
108
110
  - `origin` 只填环境根地址,不带 `/api`
109
111
  - 默认环境来自 `current_profile`
110
112
  - 读到旧版 `~/.bpmax/config.json` 单环境格式时,CLI 会迁移为多 profile 结构
113
+ - Agent 场景必须复制 `init` 返回的 `next_commands.profile_list`;禁止裸跑 `bpmax-cli config profile list` 读取共享配置
111
114
 
112
115
  ## 全局参数
113
116
 
114
117
  所有子命令都优先考虑这些参数:
115
118
 
116
119
  - `--profile <name>`:覆盖默认 profile
120
+ - `--config-dir <dir>`:覆盖本地状态根目录;Agent 场景必须使用 `init` 返回的值
117
121
  - `--format json|pretty|table|ndjson`:Agent 读取优先 `json`
118
122
  - `--workspace <name>`:覆盖 profile 默认工作空间
119
123
  - `--language <code>`:覆盖 profile 默认语言