bpmax-cli 0.1.29 → 0.1.31

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.29",
3
+ "version": "0.1.31",
4
4
  "description": "CLI for BPMAX environments with multi-profile config and local login callback flow",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,11 +9,25 @@ const sourceSkillsDir = path.join(projectRoot, 'skills');
9
9
  const jsonOutput = process.argv.includes('--json');
10
10
  const agentArgIndex = process.argv.indexOf('--agent');
11
11
  const targetAgent = agentArgIndex >= 0 ? process.argv[agentArgIndex + 1] : '';
12
- const setupHint = [
13
- '[bpmax-cli] Agent action: ask the user to directly input a BPMAX workspace page URL, for example http://127.0.0.1:10018/w:store_mgr',
14
- '[bpmax-cli] Do not show a command template yet. After the user replies with the URL, run: bpmax-cli setup "<USER_URL>" --name local',
15
- '[bpmax-cli] To save the profile without browser authorization, add: --skip-login',
16
- ];
12
+ const effectiveAgent = targetAgent || '<agent>';
13
+ const agentGuidance = {
14
+ initialization: [
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`,
17
+ 'For a local terminal/browser setup path, run instead: bpmax-cli setup "<USER_URL>" --name local',
18
+ ],
19
+ core_usage: [
20
+ 'Read JSON output first. Show message_card.authorization_url and message_card.user_code to the user.',
21
+ '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, prefer --format json and pass --profile <profile> when the target environment matters.',
23
+ ],
24
+ bbs_policy: [
25
+ 'For business requests, first look for BPMAX Business Skills (BBS): bpmax-cli bbs list --profile <profile> --format json',
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
+ ],
29
+ };
30
+ const agentGuidanceLines = Object.values(agentGuidance).flat().map((line) => `[bpmax-cli] ${line}`);
17
31
  const stampPath = path.join(homedir(), '.bpmax', 'skills.stamp');
18
32
  const openClawReminder = 'OpenClaw install already tries `openclaw skills install` and falls back to copying into ~/.openclaw/skills when needed. Do not manually copy skills unless this result reports a failure.';
19
33
 
@@ -327,6 +341,7 @@ async function main() {
327
341
  source_skills: sourceSkillDirs,
328
342
  adapters,
329
343
  agent: targetAgent || 'auto',
344
+ agent_guidance: agentGuidance,
330
345
  message: 'No compatible local agent skill directories detected.',
331
346
  next_action: adapters.map((item) => item.next_action).filter(Boolean).join(' '),
332
347
  };
@@ -337,7 +352,7 @@ async function main() {
337
352
  adapters.flatMap((adapter) => adapter.failed).forEach((item) => {
338
353
  console.log(`- ${item.adapter || 'adapter'} ${item.skill}: ${item.stderr || item.stdout || item.error || `exit ${item.exitCode}`}`);
339
354
  });
340
- setupHint.forEach((line) => console.log(line));
355
+ agentGuidanceLines.forEach((line) => console.log(line));
341
356
  }
342
357
  return result;
343
358
  }
@@ -351,6 +366,7 @@ async function main() {
351
366
  source_skills: sourceSkillDirs,
352
367
  adapters,
353
368
  agent: targetAgent || 'auto',
369
+ agent_guidance: agentGuidance,
354
370
  next_action: failedCount > 0 ? 'Review failed adapter items and retry.' : '',
355
371
  ...(targetAgent === 'openclaw' ? { reminder: openClawReminder } : {}),
356
372
  };
@@ -371,7 +387,7 @@ async function main() {
371
387
  result.failed.forEach((item) => {
372
388
  console.log(`- ${item.adapter || 'adapter'} ${item.skill}: failed (${item.stderr || item.stdout || item.error || `exit ${item.exitCode}`})`);
373
389
  });
374
- setupHint.forEach((line) => console.log(line));
390
+ agentGuidanceLines.forEach((line) => console.log(line));
375
391
  }
376
392
  return result;
377
393
  }
@@ -25,6 +25,8 @@ bpmax-cli bbs uninstall <skill-key> --agent openclaw --profile <profile> --forma
25
25
 
26
26
  ## 规则
27
27
 
28
+ - 每次新会话、切换 profile/workspace,或用户需求看起来是业务流程、审批、门店、库存、项目处理时,先检查是否已有匹配 BBS。
29
+ - 若本地 catalog 或 `bbs list` 没有匹配业务 skill,先运行 `bpmax-cli bbs sync --agent <agent> --profile <profile> --format json`,再重新判断是否有匹配 BBS。
28
30
  - `bbs sync` 只安装 `bpmax-business-skill-catalog`,不安装所有业务 skill。
29
31
  - 使用业务 skill 前先运行 `bbs ensure <skill-key>`。
30
32
  - `bbs ensure` 会自动检测远端最新版本;本地缺失或版本落后时直接安装/更新。
@@ -10,7 +10,26 @@ metadata:
10
10
 
11
11
  # bpmax-cli
12
12
 
13
- 这是总入口 skill,只负责分流,不承载具体业务规则。
13
+ 这是总入口 skill,负责建立 Agent 使用 bpmax-cli 的基础行为,再按场景分流到更具体的 `bpmax-*` skill。
14
+
15
+ ## Agent 基础行为
16
+
17
+ - 先应用 `../bpmax-shared/SKILL.md` 的命令发现、profile/auth 检查、全局参数、JSON 输出、URL 生成和原始 API 降级规则。
18
+ - 未初始化时,不要直接编造 profile 或 API Key;先要求用户提供 BPMAX workspace 页面 URL,再优先运行:
19
+
20
+ ```bash
21
+ bpmax-cli init --agent <agent> --channel feishu --url "<BPMAX_URL>" --name local --format json
22
+ ```
23
+
24
+ - `init` 返回后,Agent 必须展示 `message_card.authorization_url` 和 `message_card.user_code` 给用户;用户确认短码后,逐字执行 `message_card.next_command`,不要从 `message_card.next_action` 自然语言里猜命令。
25
+ - 后续需要 Agent 判断或串联操作时,优先使用 `--format json`;用户明确环境时显式加 `--profile <name>`。
26
+
27
+ ## 业务需求优先 BBS
28
+
29
+ - 用户需求看起来是业务流程、审批、门店、库存、项目处理或环境强绑定操作时,先进入 `../bpmax-business-skill/SKILL.md`,不要直接从通用 flow/project/api 开始。
30
+ - 先查本地/远端 BBS 列表;没有匹配业务 skill 时先同步 BBS catalog,再重新判断。
31
+ - 找到匹配业务 skill 后,先 `bpmax-cli bbs ensure <skill-key> --agent <agent> --profile <profile> --format json`,再按该业务 skill 的规则执行。
32
+ - 只有没有匹配 BBS,或 BBS 不覆盖当前需求时,才回落到通用 `bpmax-flow`、`bpmax-project` 或 `bpmax-api` 路径。
14
33
 
15
34
  ## 路由规则
16
35
 
@@ -21,6 +40,7 @@ metadata:
21
40
  - 项目列表、项目详情、我的待办、最小创建:读 `../bpmax-project/SKILL.md`
22
41
  - 系统内页面 URL 生成:先读 `../bpmax-shared/SKILL.md` 的“系统内 URL 生成”
23
42
  - 本地 schema manifest:读 `../bpmax-schema/SKILL.md`
43
+ - BPMAX Business Skills 查询、同步、安装、更新、卸载:读 `../bpmax-business-skill/SKILL.md`
24
44
 
25
45
  ## 规则
26
46
 
@@ -36,7 +36,7 @@ metadata:
36
36
  - 不得从 `flow_type`、`flow_key`、host、workspace、路由片段重新拼接链接
37
37
  - 不得把 CLI 输出的 URL 截断成 `.../project/create?flow_type=...`
38
38
  - 如果最终要发送的链接与 CLI JSON 的 `url`/`pc_url` 不完全一致,停止回复链接并报告“无法生成带预填参数的创建页链接”
39
- - 典型错误链接:`https://yuanrongtest.yitaiyitai.com/w:oa/project/create?flow_type=flow322497069`。这种只有 `flow_type`、没有 `init_value` 的链接永远不能发给用户
39
+ - 典型错误链接:`https://yuanrongtest.yitaiyitai.com/w:oa/project/create?flow_type=flow322497069`。这种只有 `flow_type`、没有 `prefill_token` 或 `init_value` 的链接永远不能发给用户
40
40
 
41
41
  ## 安全创建流程
42
42
 
@@ -58,11 +58,11 @@ bpmax-cli project create --flow-id 123 --json '{"form":{"priority":"P1"}}' --for
58
58
  CLI 返回 `handoff: true` 时,回复用户前必须全部满足:
59
59
 
60
60
  - 优先使用 CLI 输出的 `reply_markdown` 原样回复;否则只使用 CLI 输出的 `url` 或 `pc_url` 生成 `[填写表单](完整URL)`
61
- - 链接必须包含 `init_value=`
61
+ - 链接必须优先包含 `prefill_token=`;旧版 CLI 兼容 `init_value=`
62
62
  - `init_value_keys` 必须覆盖本轮已收集字段
63
- - `init_value` 必须包含本轮已收集字段;如果用户已提供行程、事由、金额等信息,不能发送没有这些字段的链接
63
+ - CLI JSON 输出的 `init_value` 必须包含本轮已收集字段;如果用户已提供行程、事由、金额等信息,不能发送没有这些字段的链接
64
64
  - `reason: "form_template_auto_init_lambda"` 只说明需要页面执行初始化,不代表可以简化链接
65
- - 如果链接只有 `flow_type` 或没有 `init_value`,不得发给用户;重新运行默认 `project create` 或报告无法生成预填链接
65
+ - 如果链接只有 `flow_type`,或既没有 `prefill_token` 也没有 `init_value`,不得发给用户;重新运行默认 `project create` 或报告无法生成预填链接
66
66
  - 如果 CLI 没有返回 URL,不要自己拼 URL
67
67
 
68
68
  ### 禁止/例外