bpmax-cli 0.1.44-beta.1 → 0.1.44-beta.3

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.
Files changed (28) hide show
  1. package/dist/bin.js +114 -2
  2. package/dist/bin.js.map +1 -1
  3. package/package.json +1 -1
  4. package/scripts/install-skills.mjs +98 -0
  5. package/skills/bpmax-api-platform-editor/SKILL.md +1 -1
  6. package/skills/bpmax-console-template-editor/SKILL.md +1 -1
  7. package/skills/bpmax-dataset-field-template-editor/SKILL.md +1 -1
  8. package/skills/bpmax-dataset-template-editor/SKILL.md +1 -1
  9. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +1 -1
  10. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +25 -3
  11. package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +8 -0
  12. package/skills/bpmax-e2e-flow-test-operator/references/minimal-test-loop.md +9 -4
  13. package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +25 -0
  14. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +26 -0
  15. package/skills/bpmax-filter-template-editor/SKILL.md +1 -1
  16. package/skills/bpmax-flow-template-editor/SKILL.md +1 -1
  17. package/skills/bpmax-form-template-editor/SKILL.md +1 -1
  18. package/skills/bpmax-list-template-editor/SKILL.md +1 -1
  19. package/skills/bpmax-memory-protocol/SKILL.md +72 -0
  20. package/skills/bpmax-nav-config-editor/SKILL.md +1 -1
  21. package/skills/bpmax-project-detail-template-editor/SKILL.md +1 -1
  22. package/skills/bpmax-role-editor/SKILL.md +1 -1
  23. package/skills/bpmax-user-mock-operator/SKILL.md +106 -0
  24. package/skills/bpmax-user-mock-operator/agents/openai.yaml +4 -0
  25. package/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py +37 -0
  26. package/skills/bpmax-user-mock-operator/scripts/user_mock_operator_common.py +136 -0
  27. package/skills/bpmax-user-mock-operator/tests/test_user_mock_operator.py +138 -0
  28. package/skills/form-control-library/SKILL.md +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmax-cli",
3
- "version": "0.1.44-beta.1",
3
+ "version": "0.1.44-beta.3",
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,10 +19,11 @@ 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
  - 只有在用户明确确认接受“非页面路径”后,才可以用脚本代替真实页面操作;确认前,脚本最多只用于摸底、状态记录、接口回读、证据补充和首次抓请求骨架,不得直接当成线上链路测试结论。
26
+ - 浏览器 E2E 涉及多角色时,使用 [$bpmax-user-mock-operator](../bpmax-user-mock-operator/SKILL.md) 切换当前浏览器身份;该能力只用于浏览器页面测试,不用于 API Key 冒充或 CLI 业务命令身份切换。
26
27
  - 测试 H5 界面时,必须打开 `/m/#/...` H5 路由,并把页面可视区域(viewport)设置为 `412x844`;只允许调整页面 viewport,不要修改 Chrome/浏览器整个窗口的外层尺寸。
27
28
  - 默认按“线上完整链路页面优先 / 非完整链路接口优先”分层推进:
28
29
  - 线上完整链路:页面优先,必须走真实运行页真实操作;接口与脚本只做辅助,不替代用户路径
@@ -46,6 +47,7 @@ description: "用于在 BPMAX 中做全链路流程测试、场景回归、前
46
47
  - [$bpmax-filter-template-editor](../bpmax-filter-template-editor/SKILL.md)
47
48
  - [$bpmax-nav-config-editor](../bpmax-nav-config-editor/SKILL.md)
48
49
  - [$form-control-library](../form-control-library/SKILL.md)
50
+ - [$bpmax-user-mock-operator](../bpmax-user-mock-operator/SKILL.md)
49
51
  - [$feishu-doc-ops](/Users/yanghanwen/.codex/skills/feishu-doc-ops/SKILL.md)
50
52
  - 优先把测试过程写入本地状态文件,而不是在对话里反复长篇复述。
51
53
  - 每发现一个“可复现、可复用”的坑,优先更新对应来源 skill 的 `references/`,不要只记在当前会话里。
@@ -69,7 +71,7 @@ description: "用于在 BPMAX 中做全链路流程测试、场景回归、前
69
71
  ## 最小工作流
70
72
 
71
73
  ### 1. 先查记忆
72
- - 任务开始前,先用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md) 搜索:
74
+ - 任务开始前,先用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md) 搜索:
73
75
  - 业务名
74
76
  - `flow_type`
75
77
  - 关联 `form_template` / `data_set` / `flow_page_template`
@@ -98,6 +100,26 @@ description: "用于在 BPMAX 中做全链路流程测试、场景回归、前
98
100
  - 预期自动联动的项目类型
99
101
  - 若发现依赖数据不足,优先补数据或重造样本,再开始场景;不要把“缺前置数据”误判成流程故障。
100
102
 
103
+ ### 1.6 多角色浏览器身份切换
104
+ - 这一节只适用于浏览器 E2E 页面测试。不要把模拟用户身份用于 API Key、CLI 远端命令或非页面路径结论。
105
+ - 多角色场景必须先列出角色矩阵:
106
+ - 原始管理账号
107
+ - 目标角色
108
+ - 目标用户 id / 用户名
109
+ - 该角色要完成的浏览器动作
110
+ - 预期可见入口、按钮、表单或审批权限
111
+ - 切换角色时调用 [$bpmax-user-mock-operator](../bpmax-user-mock-operator/SKILL.md),然后必须验证当前身份:
112
+ - 优先调用 `/api/user/current` 或刷新页面确认当前用户名/头像/权限入口
113
+ - 验证失败时不得继续执行该角色的浏览器步骤
114
+ - 完成该角色动作后,记录:
115
+ - role
116
+ - target_user_id / target_user_name
117
+ - mocked 状态
118
+ - workspace
119
+ - 页面截图或关键 UI 证据
120
+ - project_id / step_id 等运行时样本
121
+ - 测试结束必须执行 unmock,并刷新页面验证恢复原始管理账号身份;没有完成恢复验证,不得结束多角色 E2E。
122
+
101
123
  ### 2. 初始化本地测试状态
102
124
  - 用脚本初始化或续写测试状态:
103
125
 
@@ -31,3 +31,11 @@
31
31
 
32
32
  原因:
33
33
  - skill 已明确:凡是报告写“页面真实结果”,都必须有截图证据
34
+
35
+ ## 5. 多角色身份切换与恢复
36
+ - 需要以发起人、审批人、查看人等不同用户身份验证页面行为时,必须在浏览器会话里完成 mock/unmock。
37
+ - mock 后必须刷新或调用 `/api/user/current` 验证当前身份。
38
+ - unmock 后必须验证已经恢复原始管理账号身份。
39
+
40
+ 原因:
41
+ - 多角色结论证明的是“真实用户在页面里能否看见并完成动作”,不能只用接口调用成功替代。
@@ -5,10 +5,12 @@
5
5
  1. 查记忆
6
6
  2. 读当前 live/draft 与浏览器页
7
7
  3. 确认前置数据
8
- 4. 执行场景
9
- 5. 记录样本 ID、关键接口、当前环节、业务字段
10
- 6. 判定 `pass / fail / blocked`
11
- 7. 如果失败,修最小问题后立刻复测当前场景
8
+ 4. 若场景涉及多角色,先完成浏览器身份切换并验证当前身份
9
+ 5. 执行场景
10
+ 6. 记录样本 ID、关键接口、当前环节、业务字段、当前角色
11
+ 7. 判定 `pass / fail / blocked`
12
+ 8. 多角色场景结束后执行 unmock 并验证恢复原始身份
13
+ 9. 如果失败,修最小问题后立刻复测当前场景
12
14
 
13
15
  判定优先级:
14
16
  - 运行时真实行为
@@ -17,3 +19,6 @@
17
19
  - 编辑器草稿
18
20
  - 本地镜像
19
21
 
22
+ 多角色场景额外要求:
23
+ - 未验证当前浏览器身份,不得判定该角色场景通过
24
+ - 未恢复原始身份,不得结束本轮浏览器 E2E
@@ -15,6 +15,9 @@
15
15
  - `endpoint_calls`
16
16
  - `browser_only_steps`
17
17
  - `runtime_bindings`
18
+ - `identity_steps`
19
+ - `role_contexts`
20
+ - `identity_cleanup`
18
21
  - `next_step`
19
22
  - `updated_at`
20
23
 
@@ -52,6 +55,28 @@
52
55
  - `title`
53
56
  - `reason`
54
57
 
58
+ `identity_steps` 每项建议包含:
59
+ - `role`
60
+ - `action`: `mock | verify | unmock`
61
+ - `target_user_id`
62
+ - `target_user_name`
63
+ - `workspace`
64
+ - `status`
65
+ - `evidence`
66
+
67
+ `role_contexts` 每项建议包含:
68
+ - `role`
69
+ - `user_id`
70
+ - `user_name`
71
+ - `expected_actions`
72
+ - `expected_visibility`
73
+
74
+ `identity_cleanup` 建议保存:
75
+ - `unmock_done`
76
+ - `restored_user`
77
+ - `verified_at`
78
+ - `evidence`
79
+
55
80
  `runtime_bindings` 建议保存:
56
81
  - 最近创建的项目 ID
57
82
  - 最近回读的项目 ID
@@ -65,6 +65,32 @@ def main():
65
65
  lines.append(f"- {item.get('title', '')}")
66
66
  if item.get("reason"):
67
67
  lines.append(f" - {item['reason']}")
68
+ if state.get("identity_steps") or state.get("role_contexts"):
69
+ lines.append("")
70
+ lines.append("### 2.5 多角色浏览器身份")
71
+ if state.get("role_contexts"):
72
+ lines.append("- 角色矩阵:")
73
+ for item in state.get("role_contexts", []):
74
+ lines.append(
75
+ f" - `{item.get('role', '')}`: `{item.get('user_name', '')}` / `{item.get('user_id', '')}`"
76
+ )
77
+ if item.get("expected_actions"):
78
+ lines.append(f" - 动作:{item['expected_actions']}")
79
+ if state.get("identity_steps"):
80
+ lines.append("- 身份切换记录:")
81
+ for item in state.get("identity_steps", []):
82
+ lines.append(
83
+ f" - `{item.get('action', '')}` `{item.get('role', '')}` "
84
+ f"`{item.get('target_user_id', '')}`: `{item.get('status', '')}`"
85
+ )
86
+ if item.get("evidence"):
87
+ lines.append(f" - 证据:{item['evidence']}")
88
+ if state.get("identity_cleanup"):
89
+ cleanup = state["identity_cleanup"]
90
+ lines.append(
91
+ f"- 恢复原始身份:`{cleanup.get('unmock_done', False)}`,"
92
+ f"当前账号:`{cleanup.get('restored_user', '')}`"
93
+ )
68
94
  lines.append("")
69
95
  lines.append("## 3. 给测试人员的操作手册")
70
96
  lines.append("### 3.1 前置数据")
@@ -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`
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: "bpmax-user-mock-operator"
3
+ description: "用于 BPMAX 浏览器 E2E 测试中的用户身份切换。只要用户提到“浏览器 E2E 切换用户”“模拟审批人测试”“多角色页面回归”“mock 用户做页面测试”“退出模拟用户”或等价表达,就应使用这个 skill。它只复用当前浏览器登录态调用既有 `PUT /api/user/:id` mock/unmock 接口,不提供 API Key 冒充、不修改平台权限、不修改本地配置镜像。"
4
+ ---
5
+
6
+ # BPMAX User Mock Operator
7
+
8
+ ## 使用范围
9
+ - 本 skill 只用于“浏览器 E2E 测试中的用户身份切换”。
10
+ - 目标是让同一浏览器会话在完整页面链路中切到发起人、审批人、查看人等角色,验证真实 UI 可见性、按钮、表单和流转。
11
+ - 不用于普通 CLI API 调用身份切换,不用于 API Key impersonation,不新增 `bpmax-cli user mock` typed command。
12
+ - 不修改 BPMAX 平台权限、角色配置、本地 `think_*` 镜像或配置提交体。
13
+
14
+ ## 何时使用
15
+ - E2E 场景需要用不同用户在浏览器里发起、审批、驳回、查看或验证权限。
16
+ - 当前浏览器已登录一个具备模拟用户权限的管理账号,需要临时 mock 到目标用户。
17
+ - 测试结束后需要 unmock,恢复原管理账号身份。
18
+ - 用户只给了姓名但没有给 `user_id` 时,先通过用户管理页或已有查询链路确认目标用户 id。
19
+
20
+ ## 前置条件
21
+ - 浏览器里已有可用 BPMAX 登录态。
22
+ - 当前账号具备平台已有的用户模拟权限。
23
+ - 已确认 workspace、目标用户 `user_id`、目标测试角色。
24
+ - 默认页面为 `.../w:<workspace>/userManagement`;如果测试页不是这个路由,可以传 `--href-path` 覆盖。
25
+
26
+ ## Memory 协议
27
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
28
+ - `浏览器 E2E`
29
+ - `模拟用户`
30
+ - `mock unmock`
31
+ - `workspace`
32
+ - 只有遇到稳定经验时才写回 memory,例如:
33
+ - 某工作区用户管理路由不是默认 `/w:<workspace>/userManagement`
34
+ - 某环境对 `x-href` 或 `referer` 有额外要求
35
+ - 某类角色切换后的页面权限验证方式
36
+ - 不要写入 Cookie、Authorization、API Key、手机号、验证码、密码或完整接口响应。
37
+
38
+ ## 核心接口
39
+ - 进入模拟:`PUT /api/user/<user_id>`,body `{"mock": 1}`
40
+ - 退出模拟:`PUT /api/user/<user_id>`,body `{"unmock": 1}`
41
+ - query 需要带 `$workspace=<workspace>&$language=<language>`
42
+ - 请求头复用当前浏览器登录态:
43
+ - `Cookie`
44
+ - `Origin`
45
+ - `Referer`
46
+ - `x-href`
47
+ - `Content-Type: application/json`
48
+
49
+ ## 操作命令
50
+
51
+ ### 进入目标用户身份
52
+
53
+ ```bash
54
+ PYTHON_BIN=./venv/bin/python
55
+ [[ -x "$PYTHON_BIN" ]] || PYTHON_BIN=./.venv/bin/python
56
+ [[ -x "$PYTHON_BIN" ]] || PYTHON_BIN=python3
57
+
58
+ "$PYTHON_BIN" .codex/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py \
59
+ --action mock \
60
+ --user-id <target_user_id> \
61
+ --workspace <workspace> \
62
+ --base-url <bpmax_origin> \
63
+ --cookie-header "$BPMAX_COOKIE_HEADER"
64
+ ```
65
+
66
+ ### 退出模拟身份
67
+
68
+ ```bash
69
+ "$PYTHON_BIN" .codex/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py \
70
+ --action unmock \
71
+ --user-id <target_user_id> \
72
+ --workspace <workspace> \
73
+ --base-url <bpmax_origin> \
74
+ --cookie-header "$BPMAX_COOKIE_HEADER"
75
+ ```
76
+
77
+ ## 参数说明
78
+ - `--action`:只能是 `mock` 或 `unmock`。
79
+ - `--user-id`:目标用户 id,必须是正整数。
80
+ - `--workspace`:工作区 key;也可用 `BPMAX_WORKSPACE` 环境变量。
81
+ - `--base-url`:BPMAX 页面 origin;也可用 `BPMAX_BASE_URL` 环境变量。
82
+ - `--cookie-header`:当前浏览器页面有效 Cookie 串;也可用 `BPMAX_COOKIE_HEADER` 环境变量。
83
+ - `--href-path`:覆盖默认 `/w:<workspace>/userManagement` 的 `x-href` / `Referer` 口径。
84
+ - `--language`:默认 `zhCN`。
85
+ - `--insecure`:仅用于证书异常的临时排障。
86
+
87
+ ## 浏览器 E2E 工作流
88
+ 1. 记录原始管理账号、workspace、当前页面和目标测试角色。
89
+ 2. 从当前浏览器页面提取 Cookie,设置 `BPMAX_COOKIE_HEADER`。
90
+ 3. 用本 skill 执行 `mock`。
91
+ 4. 刷新或打开待测页面,通过 `/api/user/current` 或页面头像/用户名/权限入口确认当前身份已经切到目标用户。
92
+ 5. 在浏览器中执行该角色的真实动作:发起、填写、提交、审批、驳回、查看或权限验证。
93
+ 6. 记录截图、项目 ID、step ID、当前角色、目标用户 id 和结论。
94
+ 7. 执行 `unmock`,刷新页面并确认已恢复原管理账号身份。
95
+
96
+ ## 硬门禁
97
+ - 没有确认当前浏览器身份前,不得声称该角色浏览器 E2E 已通过。
98
+ - 没有执行 unmock 和恢复验证前,不得结束多角色测试。
99
+ - 不得把 mock 后的 Cookie/API 响应用作普通 API Key 或 CLI 业务命令身份。
100
+ - 不得把浏览器抓包中的 Cookie 或 Authorization 写入报告、memory、AGENTS.md 或 git。
101
+
102
+ ## 常见问题
103
+ - 401/403:先确认 Cookie 是否过期,再确认原始管理账号是否具备模拟用户权限。
104
+ - HTTP 200 但业务 `code` 非 0:以后端返回的 JSON 错误为准,不要继续执行页面测试。
105
+ - 页面身份未变化:刷新页面,或调用 `/api/user/current` 验证;仍未变化则先 unmock 再重试。
106
+ - 目标用户 id 不确定:先在用户管理页定位用户,不要凭姓名猜 id。
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "BPMAX User Mock Operator"
3
+ short_description: "在 BPMAX 浏览器 E2E 测试中切换或退出模拟用户身份"
4
+ default_prompt: "使用 $bpmax-user-mock-operator 根据当前 BPMAX 浏览器登录态,为 E2E 测试切换或退出模拟用户身份。"