bpmax-cli 0.1.44-beta.0 → 0.1.44-beta.2

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.44-beta.0",
3
+ "version": "0.1.44-beta.2",
4
4
  "description": "CLI for BPMAX environments with multi-profile config and local login callback flow",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,6 +33,10 @@ const agentGuidance = {
33
33
  const agentGuidanceLines = Object.values(agentGuidance).flat().map((line) => `[bpmax-cli] ${line}`);
34
34
  const stampPath = path.join(homedir(), '.bpmax', 'skills.stamp');
35
35
  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.';
36
+ const memoryGuidanceMarkers = {
37
+ start: '<!-- bpmax-cli:memory-guidance:start -->',
38
+ end: '<!-- bpmax-cli:memory-guidance:end -->',
39
+ };
36
40
 
37
41
  const directoryTargets = [
38
42
  { agent: 'codex', root: path.join(homedir(), '.codex', 'skills') },
@@ -41,6 +45,14 @@ const directoryTargets = [
41
45
  { agent: 'agents', root: path.join(homedir(), '.agents', 'skills') },
42
46
  { agent: 'gemini', root: path.join(homedir(), '.gemini', 'skills') },
43
47
  ];
48
+ const globalGuidanceTargets = [
49
+ { agent: 'codex', file: path.join(homedir(), '.codex', 'AGENTS.md') },
50
+ { agent: 'agents', file: path.join(homedir(), '.agents', 'AGENTS.md') },
51
+ { agent: 'claude', file: path.join(homedir(), '.claude', 'CLAUDE.md') },
52
+ { agent: 'cc-switch', file: path.join(homedir(), '.cc-switch', 'AGENTS.md') },
53
+ { agent: 'gemini', file: path.join(homedir(), '.gemini', 'GEMINI.md') },
54
+ { agent: 'openclaw', file: path.join(homedir(), '.openclaw', 'AGENTS.md') },
55
+ ];
44
56
 
45
57
  function shouldRunAdapter(adapter) {
46
58
  return !targetAgent || targetAgent === adapter;
@@ -105,6 +117,87 @@ async function installWithDirectoryTargets(skillNames) {
105
117
  };
106
118
  }
107
119
 
120
+ function renderMemoryGuidance(agent) {
121
+ const agentLabel = agent || '<agent>';
122
+ return `${memoryGuidanceMarkers.start}
123
+ # BPMAX Memory Guidance
124
+
125
+ - For non-trivial BPMAX configuration, flow, template, dataset, role, navigation, BBS, or e2e work, first use \`bpmax-memory-protocol\` or run \`bpmax-cli memory search --scope all --query "<workspace> <flow_type> <task>" --format json\`.
126
+ - Memory is isolated by the current API Key's bound agent. Do not pass or invent an agent id; for this runtime, treat the agent as \`${agentLabel}\`.
127
+ - After verified work, write only reusable \`decision\`, \`task_learning\`, \`anti_pattern\`, \`environmental\`, or \`convention\` memories. If work is incomplete, write only \`session_state\`.
128
+ - Never write API Key, Authorization, token, password, cookie, verification code, SMS code, phone number, full payloads, or large raw API responses to memory.
129
+ ${memoryGuidanceMarkers.end}
130
+ `;
131
+ }
132
+
133
+ function upsertMarkedBlock(existing, block) {
134
+ const pattern = new RegExp(`${escapeRegExp(memoryGuidanceMarkers.start)}[\\s\\S]*?${escapeRegExp(memoryGuidanceMarkers.end)}\\n?`);
135
+ if (pattern.test(existing)) {
136
+ return existing.replace(pattern, block.endsWith('\n') ? block : `${block}\n`);
137
+ }
138
+ const prefix = existing.trimEnd();
139
+ return `${prefix}${prefix ? '\n\n' : ''}${block.endsWith('\n') ? block : `${block}\n`}`;
140
+ }
141
+
142
+ function escapeRegExp(value) {
143
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
144
+ }
145
+
146
+ async function writeGlobalMemoryGuidance() {
147
+ const targets = globalGuidanceTargets.filter((target) => !targetAgent || target.agent === targetAgent);
148
+ const updated = [];
149
+ const skipped = [];
150
+ for (const target of targets) {
151
+ const parentExists = await exists(path.dirname(target.file));
152
+ const explicitlyRequested = targetAgent === target.agent;
153
+ if (!parentExists && !explicitlyRequested) {
154
+ skipped.push({
155
+ agent: target.agent,
156
+ path: target.file,
157
+ reason: 'agent home not found',
158
+ });
159
+ continue;
160
+ }
161
+ if (!parentExists && explicitlyRequested) {
162
+ skipped.push({
163
+ agent: target.agent,
164
+ path: target.file,
165
+ reason: 'agent home not found; create the directory or add the memory guidance manually',
166
+ });
167
+ continue;
168
+ }
169
+ let existing = '';
170
+ try {
171
+ existing = await readFile(target.file, 'utf8');
172
+ } catch (error) {
173
+ if (error.code !== 'ENOENT') {
174
+ skipped.push({ agent: target.agent, path: target.file, reason: error.message });
175
+ continue;
176
+ }
177
+ }
178
+ const content = upsertMarkedBlock(existing, renderMemoryGuidance(target.agent));
179
+ if (content !== existing) {
180
+ await writeFile(target.file, content, 'utf8');
181
+ }
182
+ updated.push({
183
+ agent: target.agent,
184
+ path: target.file,
185
+ updated: content !== existing,
186
+ });
187
+ }
188
+ if (targetAgent && !globalGuidanceTargets.some((target) => target.agent === targetAgent)) {
189
+ skipped.push({
190
+ agent: targetAgent,
191
+ reason: 'unknown agent; global memory guidance path was not guessed',
192
+ });
193
+ }
194
+ return {
195
+ marker: 'bpmax-cli:memory-guidance',
196
+ updated,
197
+ skipped,
198
+ };
199
+ }
200
+
108
201
  async function listSkillNames() {
109
202
  const entries = await readdir(sourceSkillsDir, { withFileTypes: true });
110
203
  const skillNames = [];
@@ -333,6 +426,7 @@ async function main() {
333
426
  await installWithOpenClawCli(skillNames),
334
427
  await installWithAilySkillhub(skillNames),
335
428
  ];
429
+ const globalGuidance = await writeGlobalMemoryGuidance();
336
430
  const installedCount = adapters.reduce((sum, item) => sum + item.installed.length + item.fallbacks.length, 0);
337
431
  const failedCount = adapters.reduce((sum, item) => sum + item.failed.length, 0);
338
432
 
@@ -345,6 +439,7 @@ async function main() {
345
439
  adapters,
346
440
  agent: targetAgent || 'auto',
347
441
  agent_guidance: agentGuidance,
442
+ global_guidance: globalGuidance,
348
443
  message: 'No compatible local agent skill directories detected.',
349
444
  next_action: adapters.map((item) => item.next_action).filter(Boolean).join(' '),
350
445
  };
@@ -370,6 +465,7 @@ async function main() {
370
465
  adapters,
371
466
  agent: targetAgent || 'auto',
372
467
  agent_guidance: agentGuidance,
468
+ global_guidance: globalGuidance,
373
469
  next_action: failedCount > 0 ? 'Review failed adapter items and retry.' : '',
374
470
  ...(targetAgent === 'openclaw' ? { reminder: openClawReminder } : {}),
375
471
  };
@@ -391,6 +487,8 @@ async function main() {
391
487
  console.log(`- ${item.adapter || 'adapter'} ${item.skill}: failed (${item.stderr || item.stdout || item.error || `exit ${item.exitCode}`})`);
392
488
  });
393
489
  agentGuidanceLines.forEach((line) => console.log(line));
490
+ result.global_guidance.updated.forEach((item) => console.log(`[bpmax-cli] Updated memory guidance: ${item.path}`));
491
+ result.global_guidance.skipped.forEach((item) => console.log(`[bpmax-cli] Skipped memory guidance for ${item.agent}: ${item.reason}`));
394
492
  }
395
493
  return result;
396
494
  }
@@ -62,7 +62,7 @@ description: "用于在 BPMAX 的系统集成页面中创建或编辑集成平
62
62
  - `doc-debug` 层只负责导出上下文和记录验收结果,不替代浏览器真实调试。
63
63
 
64
64
  ## Mem0 协议
65
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
65
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
66
66
  - `platform_key`
67
67
  - `instance_key`
68
68
  - `api_key`
@@ -27,7 +27,7 @@ description: "用于在 BPMAX 的数据看板模板页面中创建或编辑看
27
27
  - 如果需求涉及“按现有模板改一个版本”,应先识别当前模板或候选模板,而不是直接从零生成。
28
28
 
29
29
  ## Mem0 协议
30
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
30
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
31
31
  - `workspace`
32
32
  - 模板 `id` / 模板名
33
33
  - `data_set_id` / `search_temp_id`
@@ -30,7 +30,7 @@ description: "用于在 BPMAX 的数据集字段页面中创建、编辑、复
30
30
  - 当前已激活配置仓库可作为远端配置镜像参考;检索现有字段模板时,优先基于该仓库的 `think_data_set_field`,不要只依赖浏览器里人工翻列表。
31
31
 
32
32
  ## Mem0 协议
33
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
33
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
34
34
  - `flow_type`
35
35
  - `flow_key`
36
36
  - 字段 `key` / 字段名 / 业务关键词
@@ -29,7 +29,7 @@ description: "用于在 BPMAX 的数据集页面中创建、编辑、发布、
29
29
  - 当前已激活配置仓库可作为远端配置镜像参考;检索现有数据集模板时,优先基于该仓库的 `think_data_set` 和 `think_data_set_field`,不要只依赖浏览器里人工翻列表。
30
30
 
31
31
  ## Mem0 协议
32
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
32
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
33
33
  - `flow_type`
34
34
  - `flow_key`
35
35
  - 数据集名 / `custom_key`
@@ -45,7 +45,7 @@ description: "用于按 BPMAX 完整流程配置需求先调研、再出计划
45
45
  - 若首次同步因本地脏工作区失败,默认下一步尝试追加 `--allow-dirty` 重试;若重试任一步失败,立即停下并向用户说明冲突点,由用户决定是否继续。
46
46
 
47
47
  ## Mem0 协议
48
- - 编排开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
48
+ - 编排开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
49
49
  - 业务名 / 流程名
50
50
  - `flow_type`
51
51
  - `flow_key`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: "bpmax-e2e-flow-test-operator"
3
- description: "用于在 BPMAX 中做全链路流程测试、场景回归、前置数据准备、失败复测和测试文档沉淀。只要用户提到“全链路测试”“端到端回归”“跑场景”“准备测试数据”“继续上次测试”“验证流程是否真正生效”“回归某条 BPMAX 流程”或等价表达,就应使用这个 skill。它默认先查 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md) 和记忆状态,再最小化加载相关 BPMAX skill,优先复用 `.codex/skills/bpmax-e2e-flow-test-operator/scripts/` 里的状态脚本和文档脚本,尽量减少重复推理、重复试错和 token 消耗。"
3
+ description: "用于在 BPMAX 中做全链路流程测试、场景回归、前置数据准备、失败复测和测试文档沉淀。只要用户提到“全链路测试”“端到端回归”“跑场景”“准备测试数据”“继续上次测试”“验证流程是否真正生效”“回归某条 BPMAX 流程”或等价表达,就应使用这个 skill。它默认先查 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md) 和记忆状态,再最小化加载相关 BPMAX skill,优先复用 `.codex/skills/bpmax-e2e-flow-test-operator/scripts/` 里的状态脚本和文档脚本,尽量减少重复推理、重复试错和 token 消耗。"
4
4
  ---
5
5
 
6
6
  # BPMAX E2E Flow Test Operator
@@ -19,7 +19,7 @@ description: "用于在 BPMAX 中做全链路流程测试、场景回归、前
19
19
  - 用户要延续上一次 BPMAX 测试,而不希望重新解释全部上下文。
20
20
 
21
21
  ## 核心原则
22
- - 开始前先查 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),不要直接重复试错。
22
+ - 开始前先查 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),不要直接重复试错。
23
23
  - 浏览器实时页面、实时接口返回、最新 live/draft 配置优先于本地镜像。
24
24
  - 若用户要求“线上跑完整链路”“真实验证用户路径”或等价目标,必须在真实运行页面完成发起、填单、选择、提交、审批、驳回、回退等关键动作;不得用脚本、控制台、手改 request body 或接口直调绕过界面。
25
25
  - 只有在用户明确确认接受“非页面路径”后,才可以用脚本代替真实页面操作;确认前,脚本最多只用于摸底、状态记录、接口回读、证据补充和首次抓请求骨架,不得直接当成线上链路测试结论。
@@ -69,7 +69,7 @@ description: "用于在 BPMAX 中做全链路流程测试、场景回归、前
69
69
  ## 最小工作流
70
70
 
71
71
  ### 1. 先查记忆
72
- - 任务开始前,先用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md) 搜索:
72
+ - 任务开始前,先用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md) 搜索:
73
73
  - 业务名
74
74
  - `flow_type`
75
75
  - 关联 `form_template` / `data_set` / `flow_page_template`
@@ -36,7 +36,7 @@ description: "用于在 BPMAX 的筛选器模板页面中创建、编辑、切
36
36
  - 当前已激活配置仓库可作为远端配置镜像参考;检索现有筛选器模板时,优先基于该仓库的 `think_flow_page_template` 和 `think_flow`,不要只依赖浏览器里人工翻列表。
37
37
 
38
38
  ## Mem0 协议
39
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
39
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
40
40
  - `flow_type`
41
41
  - `flow_key`
42
42
  - 模板 `id` / 模板名
@@ -34,7 +34,7 @@ export BPMAX_BASE_URL='https://<your-bpmax-host>'
34
34
  - `BPMAX_BASE_URL` 只能取当前浏览器页面 origin,或最近一次同域请求的 origin;不要写死任何项目环境域名。
35
35
 
36
36
  ## Mem0 协议
37
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
37
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
38
38
  - 流程名 / 业务名
39
39
  - `flow_type`
40
40
  - `flow_key`
@@ -31,7 +31,7 @@ description: "用于在 BPMAX 的表单模板页面中创建或编辑表单。
31
31
  - 如果需求涉及控件选型、控件是否存在、某个 `field_type` 怎么配,必须联动 [$form-control-library](../form-control-library/SKILL.md)。
32
32
 
33
33
  ## Mem0 协议
34
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
34
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
35
35
  - 模板名 / 模板 `id`
36
36
  - `flow_type`
37
37
  - 关键控件 `field_type`
@@ -37,7 +37,7 @@ description: "用于在 BPMAX 的项目列表模板页面中创建或编辑列
37
37
  - 用户需要在请求里明确说明这次要做什么改动。
38
38
 
39
39
  ## Mem0 协议
40
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
40
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
41
41
  - `flow_type`
42
42
  - `flow_key`
43
43
  - 列表模板 `id` / 模板名
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: bpmax-memory-protocol
3
+ description: Use when a BPMAX task needs long-term memory, prior decisions, repeated configuration work, flow/template/data-set context, cross-session continuity, or the user mentions memory, Mem0, graph, history, or learned context.
4
+ ---
5
+
6
+ # BPMAX Memory Protocol
7
+
8
+ ## Overview
9
+
10
+ BPMAX memory is accessed through `bpmax-cli memory`, which calls the BPMAX platform proxy. Do not call Mem0 directly, do not pass an agent id manually, and do not store secrets.
11
+
12
+ Memory is isolated by the API Key's bound agent. The CLI only chooses scope:
13
+
14
+ - `user`: current BPMAX user + current agent
15
+ - `organization`: current organization + current agent
16
+ - `all`: search/list both user and organization scopes
17
+
18
+ ## Start Of Work
19
+
20
+ Before non-trivial BPMAX configuration, flow, template, dataset, role, navigation, BBS, or e2e work, search memory with a specific query.
21
+
22
+ ```bash
23
+ bpmax-cli memory status --profile <profile> --format json
24
+ bpmax-cli memory search --profile <profile> --scope all \
25
+ --query "<workspace> <flow_type> <business name> <target action>" \
26
+ --limit 8 --format json
27
+ ```
28
+
29
+ Good queries include the business name, workspace, `flow_type`, template/data-set/object id, and the current action such as edit, lint, submit, verify, or debug.
30
+
31
+ ## Write Back
32
+
33
+ Only write reusable conclusions. Prefer these metadata types:
34
+
35
+ - `decision`: durable design or implementation decision
36
+ - `task_learning`: verified method that should be reused
37
+ - `anti_pattern`: failed approach or known trap
38
+ - `session_state`: current state when stopping or context may be lost
39
+ - `environmental`: environment, endpoint, permission, branch, or deployment constraint
40
+ - `convention`: naming, directory, or repository convention
41
+
42
+ ```bash
43
+ bpmax-cli memory add --profile <profile> --scope user \
44
+ --text "<short reusable learning>" \
45
+ --metadata '{"type":"task_learning","domain":"flow-template","workspace":"store_mgr","flow_type":"flow_xxx","project_id":"bpmax"}' \
46
+ --format json
47
+ ```
48
+
49
+ Use `--scope organization` only for learning that should be shared across users of the same organization and agent. Organization-scope writes require organization admin permission.
50
+
51
+ ## Session State
52
+
53
+ When pausing, switching threads, or approaching context limits, write a short `session_state` memory:
54
+
55
+ ```bash
56
+ bpmax-cli memory add --profile <profile> --scope user \
57
+ --text "goal=<goal>; done=<done>; files=<key files>; next=<next step>" \
58
+ --metadata '{"type":"session_state","project_id":"bpmax","tags":["handoff"]}' \
59
+ --format json
60
+ ```
61
+
62
+ ## Safety Rules
63
+
64
+ - Never store API Key, Authorization, token, password, cookie, session, verification code, SMS code, phone number, complete raw payload, or large raw API response.
65
+ - Summarize evidence instead of copying full JSON.
66
+ - If memory is unavailable, continue the task and note that memory lookup/writeback failed.
67
+ - Do not use raw Mem0 URLs, curl, Python helper scripts, or environment variables from old per-environment skills.
68
+ - Do not pass `--agent`; `bpmax-cli memory` intentionally has no agent option.
69
+
70
+ ## Output
71
+
72
+ When using memory, report only the 2-5 relevant findings and how they change the current decision. Do not paste full memory JSON unless the user asks for raw output.
@@ -37,7 +37,7 @@ description: "用于在 BPMAX 的工作区导航配置页面中创建或编辑 P
37
37
  - H5快捷入口:移动最高频入口
38
38
 
39
39
  ## Mem0 协议
40
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
40
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
41
41
  - `workspace`
42
42
  - 导航业务名 / 页面入口名
43
43
  - `navmenu` / `shortcut` / `navmenu_mobile` / `shortcut_mobile`
@@ -36,7 +36,7 @@ description: "用于在 BPMAX 的项目详情模板页面中创建、编辑、
36
36
  - 具体要增删改哪些模块、在哪个区域、顺序如何变化
37
37
 
38
38
  ## Mem0 协议
39
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
39
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
40
40
  - `project_detail_template`
41
41
  - 模板 `id` / 模板名
42
42
  - `flow_type`
@@ -82,7 +82,7 @@ export BPMAX_WORKSPACE='store_mgr'
82
82
  - 不要在 skill 文档或脚本里再写死任何项目环境域名。
83
83
 
84
84
  ## Mem0 协议
85
- - 开始前先调用 `mem0-memory-protocol`,检索词至少包含:
85
+ - 开始前先调用 `bpmax-memory-protocol`,检索词至少包含:
86
86
  - `workspace`
87
87
  - 角色 `id` / `key` / `name`
88
88
  - `system/custom/flow/member`
@@ -29,7 +29,7 @@ description: "用于查询和分析当前已激活 BPMAX 配置仓库里的表
29
29
  - 模板出现次数:同一 `field_type` 在不同字段上的落地次数。
30
30
 
31
31
  ## Mem0 协议
32
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
32
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
33
33
  - `field_type`
34
34
  - 控件中文名 / 业务关键词
35
35
  - 模板名 / `flow_type`