bpmax-cli 0.2.1-beta.5 → 0.2.1-beta.50
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 +13 -5
- package/dist/bin.js +25216 -12623
- package/dist/bin.js.map +1 -1
- package/package.json +10 -5
- package/scripts/run-source-cli.mjs +121 -0
- package/skills/bpmax-ai-taskbook/SKILL.md +2 -0
- package/skills/bpmax-api-platform-editor/SKILL.md +24 -31
- package/skills/bpmax-api-platform-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-api-platform-editor/references/platform-api-map.md +2 -2
- package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +3 -3
- package/skills/bpmax-approval-matrix/SKILL.md +54 -2
- package/skills/bpmax-blueprint-doc-workflow/SKILL.md +87 -0
- package/skills/bpmax-blueprint-doc-workflow/agents/openai.yaml +4 -0
- package/skills/bpmax-blueprint-doc-workflow/references/blueprint-structure.md +60 -0
- package/skills/bpmax-blueprint-doc-workflow/references/per-flow-required-structure.md +98 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-forbidden-term.xml +12 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-mermaid-codeblock.xml +12 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-boundary.xml +10 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-whiteboard.xml +10 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-pass.xml +55 -0
- package/skills/bpmax-blueprint-doc-workflow/scripts/lint_blueprint_doc.py +257 -0
- package/skills/bpmax-bug-reporting/SKILL.md +72 -0
- package/skills/bpmax-builder-shared/SKILL.md +1 -0
- package/skills/bpmax-builder-shared/configuration-impact-review.md +76 -0
- package/skills/bpmax-builder-shared/template_script_hard_rules.py +3 -1
- package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +16 -0
- package/skills/bpmax-cli/SKILL.md +43 -0
- package/skills/bpmax-config-latest/SKILL.md +4 -0
- package/skills/bpmax-console-template-editor/SKILL.md +112 -523
- package/skills/bpmax-console-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-console-template-editor/references/full-detail-guide.md +45 -0
- package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +13 -12
- package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +299 -78
- package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +344 -30
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +127 -594
- package/skills/bpmax-dataset-field-template-editor/references/full-detail-guide.md +570 -0
- package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +1 -1
- package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +11 -77
- package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +4 -57
- package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +2 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +4 -78
- package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +3 -89
- package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +14 -0
- package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +2 -0
- package/skills/bpmax-dataset-template-editor/SKILL.md +116 -778
- package/skills/bpmax-dataset-template-editor/references/full-detail-guide.md +753 -0
- package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +1 -0
- package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +2 -2
- package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +9 -90
- package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +1 -2
- package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +8 -1
- package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +6 -40
- package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +18 -4
- package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +2 -2
- package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +13 -9
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +150 -546
- package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +2 -3
- package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +136 -13
- package/skills/bpmax-e2e-flow-test-operator/references/browser-action-dsl.md +85 -0
- package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +6 -5
- package/skills/bpmax-e2e-flow-test-operator/references/full-detail-guide.md +576 -0
- package/skills/bpmax-e2e-flow-test-operator/references/minimal-test-loop.md +2 -0
- package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +4 -4
- package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +1 -1
- package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +3 -1
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +7 -5
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +2 -2
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +5 -1
- package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +71 -0
- package/skills/bpmax-filter-template-editor/SKILL.md +114 -551
- package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +18 -18
- package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +21 -0
- package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +29 -26
- package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +19 -2
- package/skills/bpmax-filter-template-editor/references/full-detail-guide.md +56 -0
- package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +10 -9
- package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +7 -57
- package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +4 -48
- package/skills/bpmax-flow/SKILL.md +2 -0
- package/skills/bpmax-flow-detail-template-editor/SKILL.md +53 -0
- package/skills/bpmax-flow-template-editor/SKILL.md +120 -1084
- package/skills/bpmax-flow-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-flow-template-editor/references/diff-strategy.md +3 -3
- package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +9 -9
- package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +2 -1
- package/skills/bpmax-flow-template-editor/references/full-detail-guide.md +1157 -0
- package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +1 -1
- package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +17 -0
- package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +8 -3
- package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +7 -7
- package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +2 -2
- package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +8 -2
- package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +7 -23
- package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +1 -1
- package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +19 -75
- package/skills/bpmax-form-template-editor/SKILL.md +133 -1104
- package/skills/bpmax-form-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-form-template-editor/references/dynamic-field-state.md +167 -0
- package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +51 -51
- package/skills/bpmax-form-template-editor/references/full-detail-guide.md +1115 -0
- package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +4 -4
- package/skills/bpmax-form-template-editor/references/payload-checklist.md +3 -1
- package/skills/bpmax-form-template-editor/references/sub-form-patterns.md +6 -0
- package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +8 -0
- package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +42 -19
- package/skills/bpmax-functional-test-design/LICENSE.upstream +24 -0
- package/skills/bpmax-functional-test-design/SKILL.md +80 -0
- package/skills/bpmax-functional-test-design/agents/openai.yaml +4 -0
- package/skills/bpmax-functional-test-design/references/bpmax-test-suite-output.md +95 -0
- package/skills/bpmax-functional-test-design/references/decision-table-testing.md +50 -0
- package/skills/bpmax-functional-test-design/references/domain-testing.md +43 -0
- package/skills/bpmax-functional-test-design/references/state-transition-testing.md +47 -0
- package/skills/bpmax-functional-test-design/references/technique-selection.md +38 -0
- package/skills/bpmax-functional-test-design/references/use-case-testing.md +55 -0
- package/skills/bpmax-group-model-editor/SKILL.md +24 -0
- package/skills/bpmax-list-template-editor/SKILL.md +119 -466
- package/skills/bpmax-list-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-list-template-editor/references/content-config-shape.md +16 -4
- package/skills/bpmax-list-template-editor/references/full-detail-guide.md +458 -0
- package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +6 -9
- package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +1 -1
- package/skills/bpmax-list-template-editor/references/special-formats.md +5 -2
- package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +9 -78
- package/skills/bpmax-memory-protocol/SKILL.md +7 -6
- package/skills/bpmax-nav-config-editor/SKILL.md +13 -17
- package/skills/bpmax-nav-config-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-nav-config-editor/references/api-workflow.md +2 -2
- package/skills/bpmax-nav-config-editor/references/runtime-probing.md +11 -12
- package/skills/bpmax-plugin-config/SKILL.md +20 -4
- package/skills/bpmax-project/SKILL.md +37 -1
- package/skills/bpmax-project-detail-template-editor/SKILL.md +13 -39
- package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-role-editor/SKILL.md +7 -30
- package/skills/bpmax-shared/SKILL.md +19 -9
- package/skills/bpmax-team-editor/SKILL.md +27 -0
- package/skills/bpmax-ui-ux-audit/LICENSE.upstream +23 -0
- package/skills/bpmax-ui-ux-audit/SKILL.md +42 -0
- package/skills/bpmax-ui-ux-audit/agents/openai.yaml +4 -0
- package/skills/bpmax-ui-ux-audit/references/audit-framework.md +39 -0
- package/skills/bpmax-ui-ux-audit/references/bpmax-ux-findings.md +56 -0
- package/skills/bpmax-user/SKILL.md +33 -1
- package/skills/bpmax-user-mock-operator/SKILL.md +20 -48
- package/skills/bpmax-user-mock-operator/agents/openai.yaml +2 -2
- package/skills/bpmax-user-model-editor/SKILL.md +24 -0
- package/skills/form-control-library/references/form-template-submit-schema.md +1 -1
- package/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py +0 -37
- package/skills/bpmax-user-mock-operator/scripts/user_mock_operator_common.py +0 -136
- package/skills/bpmax-user-mock-operator/tests/test_user_mock_operator.py +0 -138
|
@@ -14,31 +14,41 @@ metadata:
|
|
|
14
14
|
|
|
15
15
|
## 命令发现
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
若提供了 `BPMAX_CLI_HOME`,必须优先使用该源码 checkout,不能因为 PATH 中存在旧版全局命令而回退。源码入口会在需要时自动构建,并在执行命令前把 bundled Skills 同步到当前源码版本:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
|
|
20
|
+
node "$BPMAX_CLI_HOME/scripts/run-source-cli.mjs" --help
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
在 `bpmax-cli` 源码仓库内开发或联调时,先执行一次 `npm link`。之后 bare `bpmax-cli` 会链接到同一个源码入口,迁移脚本中的子进程也会自动使用当前源码:
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
|
|
26
|
+
npm link
|
|
27
|
+
bpmax-cli --version
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
若没有 `BPMAX_CLI_HOME`,才允许使用 PATH 中的已安装命令:
|
|
30
31
|
|
|
31
32
|
```bash
|
|
32
|
-
|
|
33
|
-
npm --prefix "$BPMAX_CLI_HOME" run build
|
|
33
|
+
bpmax-cli --help
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
后文默认直接写 `bpmax-cli
|
|
36
|
+
后文默认直接写 `bpmax-cli`。设置了 `BPMAX_CLI_HOME` 但没有执行 `npm link` 时,把所有命令前缀替换成:
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
node "$BPMAX_CLI_HOME/
|
|
39
|
+
node "$BPMAX_CLI_HOME/scripts/run-source-cli.mjs" ...
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
禁止在同一次迁移中混用源码 CLI、旧全局 CLI 和不同版本 Skills。开始迁移前必须确认 `--version` 与 `$BPMAX_CLI_HOME/package.json` 一致,且命令输出不再出现 Skills out-of-sync notice。
|
|
43
|
+
|
|
44
|
+
## Agent 更新通知
|
|
45
|
+
|
|
46
|
+
- 所有 Agent、OpenClaw、Aily、Codex 和自动化调用都必须读取 CLI 返回的 `_notice`,不能只读取业务字段。
|
|
47
|
+
- `_notice.update` 表示当前安装渠道存在更高版本;beta 安装跟踪 `beta`,稳定安装跟踪 `latest`。先展示 `current/latest/channel`,再执行返回的 `next_command`。
|
|
48
|
+
- `_notice.skills` 表示 bundled Skills 未安装或与 CLI 不匹配;必须先执行返回的 `next_command` 完成同步。
|
|
49
|
+
- JSON 对象中的通知位于 `_notice`;JSON 数组、NDJSON、table、pretty 和命令错误中的通知通过 stderr 输出。Agent 必须同时读取 stdout 和 stderr。
|
|
50
|
+
- 更新失败时停止后续配置提交和正式 E2E,并向用户展示结构化错误;不得静默忽略更新提示或继续使用旧 lint/Skill。
|
|
51
|
+
|
|
42
52
|
## 开始前检查
|
|
43
53
|
|
|
44
54
|
任何 BPMAX CLI 场景都先做两步。本地终端可直接运行;Agent/飞书/OpenClaw/Aily 等多用户运行时必须使用 `init` 返回的 `next_commands.profile_list` 和 `next_commands.auth_status`,不要裸跑共享配置命令:
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bpmax-team-editor
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
description: "Use when creating or editing BPMAX teams and organization hierarchy through the bpmax-cli typed team adapter."
|
|
5
|
+
metadata:
|
|
6
|
+
requires:
|
|
7
|
+
bins: ["bpmax-cli"]
|
|
8
|
+
cliHelp: "bpmax-cli config team --help"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# BPMAX Team Editor
|
|
12
|
+
|
|
13
|
+
先阅读 `../bpmax-shared/SKILL.md`。团队配置必须在已初始化的 BPMAX 配置目录中,通过 typed CLI 完成。
|
|
14
|
+
|
|
15
|
+
## 标准链路
|
|
16
|
+
|
|
17
|
+
1. `bpmax-cli config team export --id <id> --out <dir> --profile <profile> --format json`
|
|
18
|
+
2. 只修改 work 文件中的 `name`、`intro`、`parent_id`、`model_id`、`permission`、`admin_users` 或 `meta_form`;导出的 `platform_id` 必须原样保留。
|
|
19
|
+
3. 运行 `lint`、`build`,审阅 dry-run 后再 `submit --id <id> --confirm "submit team <id>"`。
|
|
20
|
+
4. 运行 `verify --id <id>`,确认父级、模型、权限和管理员回读一致。
|
|
21
|
+
|
|
22
|
+
## 硬门禁
|
|
23
|
+
|
|
24
|
+
- `parent_id` 不得指向自身;调整层级前必须确认目标父团队存在且不会形成环。
|
|
25
|
+
- 不得修改 `path`、`organization_id`、`platform_*`、`is_del`、时间戳等服务端或外部同步字段。已有 `platform_id` 是只读身份字段,删除或改变都会被 build/submit 硬阻断;create 也不得手工指定。
|
|
26
|
+
- 不得直接修改 `think_group` 文件代替 typed submit。
|
|
27
|
+
- 删除前必须确认没有子团队、成员或业务对象仍依赖该团队;平台拒绝时不得绕过。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Adapted from https://github.com/EliaAlberti/ux-audit-skill at commit 76eb1ab73560c90275823395fda52c3ca4ea8b2b.
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026 Elia Alberti
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bpmax-ui-ux-audit
|
|
3
|
+
description: Use when auditing BPMAX forms, lists, details, approval pages, responsive pages, or end-to-end journeys for usability, accessibility, error recovery, visual hierarchy, interaction clarity, or cross-page consistency; also use during BPMAX flow design and before reporting E2E completion.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BPMAX UI/UX Audit
|
|
7
|
+
|
|
8
|
+
Audit the user journey with current-run(本轮)page or screenshot evidence. Every confirmed experience issue is a product `classification: BUG`, not optional polish.
|
|
9
|
+
|
|
10
|
+
## Hard gates
|
|
11
|
+
|
|
12
|
+
- Use `bpmax-functional-test-design` first to establish user goals, actors, paths, states, boundaries, and expected outcomes. UX review supplements functional coverage; it does not replace it.
|
|
13
|
+
- Inspect every in-scope surface actually reached in this run. Record unvisited or unavailable surfaces as not evaluated.
|
|
14
|
+
- Base each finding on a named current-run page, screenshot, DOM snapshot, or interaction observation. 不得编造 DOM、键盘、焦点、读屏、动画、延迟或响应式事实。
|
|
15
|
+
- Keep evidence under `.ai_test/report/<run>/`. Historical evidence may inform investigation but cannot prove the current result.
|
|
16
|
+
- Classify every confirmed issue as `BUG` with `P0|P1|P2|P3`, user impact, reproduction steps, evidence, heuristic references, recommendation, and `open|fixed|verified` status.
|
|
17
|
+
- Do not automatically install Python or image packages. Use available image/view capabilities for annotations; if unavailable, keep the textual finding and state that annotation was not produced.
|
|
18
|
+
- Run `bpmax-cli test-suite lint-report --root .ai_test/report/<run> --format json` before any complete E2E conclusion.
|
|
19
|
+
|
|
20
|
+
## Audit workflow
|
|
21
|
+
|
|
22
|
+
1. Define the journey goal, actors, platform, current run, and evaluated surfaces from the functional cases.
|
|
23
|
+
2. Review each surface in four passes: goal completion, framework heuristics, recurring checks, and journey-level consistency.
|
|
24
|
+
3. Separate visible facts from unavailable interaction properties. Capture a new screenshot or structured browser evidence when a claim needs proof.
|
|
25
|
+
4. Merge duplicate symptoms into one BUG when they share a cause and recommendation; list every affected surface.
|
|
26
|
+
5. Write `ux-findings.json` using `references/bpmax-ux-findings.md`.
|
|
27
|
+
6. Update the scenario report metadata and findings section. Re-test fixed BUGs and change status to `verified` only with new current-run evidence.
|
|
28
|
+
7. Apply the result gate and run `lint-report`.
|
|
29
|
+
|
|
30
|
+
## Result gate
|
|
31
|
+
|
|
32
|
+
- Unresolved P0/P1 BUG present: `result: fail`.
|
|
33
|
+
- Only unresolved P2/P3 BUGs present: `result: pass-with-warnings`.
|
|
34
|
+
- No unresolved UX BUG and all other E2E gates pass: `result: pass`.
|
|
35
|
+
- Audit incomplete or blocked: only `partial` or `blocked`.
|
|
36
|
+
|
|
37
|
+
Never downgrade a BUG to “suggestion”, “observation”, or “polish” to obtain a passing result.
|
|
38
|
+
|
|
39
|
+
## References
|
|
40
|
+
|
|
41
|
+
- Read `references/audit-framework.md` for the review passes, named heuristics, and recurring checks.
|
|
42
|
+
- Read `references/bpmax-ux-findings.md` for the JSON contract, evidence rules, severity mapping, and report metadata.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# BPMAX UX audit framework
|
|
2
|
+
|
|
3
|
+
## Four review passes
|
|
4
|
+
|
|
5
|
+
1. **Goal walk:** follow the functional case as the stated actor. Identify friction, ambiguity, dead ends, lost work, and unclear completion.
|
|
6
|
+
2. **Framework sweep:** cite the smallest relevant named rule. Prefer Nielsen, Norman, WCAG, content design, and established behavioral laws over generic taste.
|
|
7
|
+
3. **Recurring checks:** use stable labels so repeated defects are classified consistently.
|
|
8
|
+
4. **Journey review:** compare pages for terminology, action placement, status visibility, progress, memory load, and recovery continuity.
|
|
9
|
+
|
|
10
|
+
## Core heuristics
|
|
11
|
+
|
|
12
|
+
- **Nielsen:** system status, real-world language, user control, consistency, error prevention, recognition over recall, efficiency, minimalism, error recovery(错误恢复), and contextual help.
|
|
13
|
+
- **Norman:** discoverability, signifiers, mapping, feedback, constraints, affordances, and a coherent conceptual model.
|
|
14
|
+
- **WCAG:** color is not the only signal; text and controls have sufficient contrast; headings and labels are descriptive; targets are usable; errors are identified with corrective guidance; navigation/components stay consistent.
|
|
15
|
+
- **Behavioral laws:** apply Hick's Law to ungrouped choices, Fitts's Law to target size and distance, Miller's Law to memory load, Jakob's Law to convention drift, and Peak-End to the worst moment and final confirmation.
|
|
16
|
+
- **Content design:** use plain language, one term per concept, verb-first actions, honest expectations, scannable structure, and errors that say what happened and how to recover.
|
|
17
|
+
|
|
18
|
+
## Recurring checks
|
|
19
|
+
|
|
20
|
+
| ID | Check |
|
|
21
|
+
|---|---|
|
|
22
|
+
| CTA-AMBIGUITY | The next action or its consequence is unclear. |
|
|
23
|
+
| DEAD-END | An empty, error, or terminal state has no recovery or exit. |
|
|
24
|
+
| ERROR-VAGUE | The error does not explain cause and recovery. |
|
|
25
|
+
| FORM-FRICTION | Labels, formats, defaults, validation, or field order add avoidable effort. |
|
|
26
|
+
| STATUS-BLIND | Current state, progress, save state, or completion is not visible. |
|
|
27
|
+
| PATTERN-DRIFT | The same concept or action changes wording, position, or behavior across pages. |
|
|
28
|
+
| ACCESS-FOCUS | 键盘焦点不可见、顺序异常或操作无法通过键盘完成;只有本轮交互证据才能确认。 |
|
|
29
|
+
| TARGET-SIZE | A control is too small or crowded for reliable activation. |
|
|
30
|
+
| HIERARCHY-FLAT | Primary, secondary, and dangerous actions lack visual priority. |
|
|
31
|
+
| RECALL-TAX | Users must remember data from an earlier surface to continue. |
|
|
32
|
+
|
|
33
|
+
## Evidence calibration
|
|
34
|
+
|
|
35
|
+
- Static screenshots can prove visible text, hierarchy, spacing, grouping, color-only signaling, and visible states.
|
|
36
|
+
- Live interaction evidence is required for keyboard focus, focus order, latency, loading behavior, preserved input, error recovery, and action consequences.
|
|
37
|
+
- Borderline contrast requires a measurement note; do not invent a ratio.
|
|
38
|
+
- Illegible text is evidence of illegibility, not permission to guess the wording.
|
|
39
|
+
- A positive observation may be documented separately, but it is not a finding and does not offset a BUG.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# BPMAX UX finding contract
|
|
2
|
+
|
|
3
|
+
Write one `ux-findings.json` in the current `.ai_test/report/<run>/` directory:
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"version": 1,
|
|
8
|
+
"run_id": "20260723-001",
|
|
9
|
+
"scenario_id": "expense-approval",
|
|
10
|
+
"audit_status": "completed",
|
|
11
|
+
"evaluated_surfaces": ["create form", "approval detail"],
|
|
12
|
+
"findings": [
|
|
13
|
+
{
|
|
14
|
+
"bug_id": "UX-BUG-001",
|
|
15
|
+
"classification": "BUG",
|
|
16
|
+
"severity": "P2",
|
|
17
|
+
"title": "错误提示没有恢复方法",
|
|
18
|
+
"surface": "create form",
|
|
19
|
+
"user_impact": "用户无法判断如何完成提交",
|
|
20
|
+
"reproduction_steps": ["打开创建页", "输入非法金额并提交"],
|
|
21
|
+
"heuristic_refs": ["Nielsen #9", "WCAG 3.3.3"],
|
|
22
|
+
"evidence": ["screenshots/C001-S002.png"],
|
|
23
|
+
"recommendation": "说明有效范围,并把焦点保留在错误字段",
|
|
24
|
+
"status": "open"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Required rules
|
|
31
|
+
|
|
32
|
+
- `version` is `1`; `audit_status` is `completed|blocked`.
|
|
33
|
+
- A completed audit has at least one `evaluated_surfaces` entry. An audit can complete with an empty `findings` array.
|
|
34
|
+
- Every finding has `classification: "BUG"`, severity `P0|P1|P2|P3`, non-empty reproduction steps, heuristic references, evidence, recommendation, and status `open|fixed|verified`.
|
|
35
|
+
- Evidence paths are relative to the current run, point to ordinary PNG/JSON/HTML/TXT/Markdown files, and must be registered or referenced by the current execution manifest. Directories, `ux-findings.json` self-references, stale files, and unregistered copied artifacts are invalid.
|
|
36
|
+
- `verified` requires a non-empty `retest_evidence` array whose registered current-run files are different from and newer than the original `evidence`. `fixed` without retest remains unresolved.
|
|
37
|
+
- `ux_bug_counts` counts unresolved `open|fixed` BUGs by severity. A correctly verified BUG remains in `findings` for traceability but is excluded from the active counts and outcome gate.
|
|
38
|
+
|
|
39
|
+
## Scenario report metadata
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
test_design_skill: bpmax-functional-test-design
|
|
43
|
+
ux_audit_skill: bpmax-ui-ux-audit
|
|
44
|
+
ux_audit_status: completed
|
|
45
|
+
ux_findings: ux-findings.json
|
|
46
|
+
ux_bug_counts: P0=0,P1=0,P2=1,P3=0
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Severity and outcome
|
|
50
|
+
|
|
51
|
+
- Unresolved P0/P1: blocks release or materially prevents/corrupts the journey; final result is `fail`.
|
|
52
|
+
- Unresolved P2/P3 only: result is `pass-with-warnings`; retain evidence, remediation, and retest status.
|
|
53
|
+
- Zero unresolved BUGs: result may be `pass` when functional and browser gates also pass.
|
|
54
|
+
- Audit unavailable or incomplete: result is `partial` or `blocked`.
|
|
55
|
+
|
|
56
|
+
Run `bpmax-cli test-suite lint-report` after updating both files. The lint result must agree with `ux-findings.json`; manually written prose is not a substitute.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bpmax-user
|
|
3
3
|
version: 1.0.0
|
|
4
|
-
description: Use when the user needs to
|
|
4
|
+
description: Use when the user needs to query, resolve, create, or safely edit BPMAX organization users and identity relations through typed bpmax-cli commands.
|
|
5
5
|
metadata:
|
|
6
6
|
requires:
|
|
7
7
|
bins: ["bpmax-cli"]
|
|
@@ -16,6 +16,24 @@ metadata:
|
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
bpmax-cli user current --format json
|
|
19
|
+
bpmax-cli user search --query "<姓名或工号>" --active-only --profile <profile> --format json
|
|
20
|
+
bpmax-cli user resolve --name "<姓名>" --employee-no "<工号>" --profile <profile> --format json
|
|
21
|
+
bpmax-cli user readback --id <user_id> --profile <profile> --format json
|
|
22
|
+
bpmax-cli organization department search --query "<部门名称>" --profile <profile> --format json
|
|
23
|
+
bpmax-cli organization department readback --id <group_id> --profile <profile> --format json
|
|
24
|
+
bpmax-cli organization department memberships --user-id <user_id> --profile <profile> --format json
|
|
25
|
+
bpmax-cli organization main-department --user-id <user_id> --profile <profile> --format json
|
|
26
|
+
bpmax-cli organization branch --user-id <user_id> --profile <profile> --format json
|
|
27
|
+
bpmax-cli organization position --user-id <user_id> --profile <profile> --format json
|
|
28
|
+
bpmax-cli organization direct-superior --user-id <user_id> --profile <profile> --format json
|
|
29
|
+
bpmax-cli organization superior-chain --user-id <user_id> --levels 20 --profile <profile> --format json
|
|
30
|
+
bpmax-cli organization readback --user-id <user_id> --profile <profile> --format json
|
|
31
|
+
bpmax-cli config user export --id <user_id> --out <dir> --profile <profile> --format json
|
|
32
|
+
bpmax-cli config user lint --work <work.json> --profile <profile> --format json
|
|
33
|
+
bpmax-cli config user build --work <work.json> --meta <meta.json> --out <submit.json> --profile <profile> --format json
|
|
34
|
+
bpmax-cli config user submit --id <user_id> --payload <submit.json> --profile <profile> --format json
|
|
35
|
+
bpmax-cli config user verify --id <user_id> --expect <work.json> --profile <profile> --format json
|
|
36
|
+
bpmax-cli config user delete --id <user_id> --profile <profile> --format json
|
|
19
37
|
```
|
|
20
38
|
|
|
21
39
|
## 何时使用
|
|
@@ -23,9 +41,23 @@ bpmax-cli user current --format json
|
|
|
23
41
|
- 用户想确认当前登录账号
|
|
24
42
|
- 要在执行其他 BPMAX 操作前验证身份
|
|
25
43
|
- 要检查某个 profile 实际连到哪个环境、哪个用户
|
|
44
|
+
- WEWF 迁移、固定审批人或矩阵规则需要将姓名/工号精确绑定到 BPMAX 用户 ID
|
|
45
|
+
- 需要确认用户未删除且处于有效在职状态
|
|
46
|
+
- 需要将申请人映射到所属部门、岗位、直属上级或连续上级
|
|
47
|
+
- 需要检查主部门、分部是否具备平台权威字段,而不是依赖数组顺序或名称猜测
|
|
26
48
|
|
|
27
49
|
## 规则
|
|
28
50
|
|
|
29
51
|
- 默认优先 `--format json`
|
|
30
52
|
- 若只是判断登录是否生效,`user current` 比原始 `api GET /user/current` 更优先
|
|
31
53
|
- 若用户明确指定环境,显式加 `--profile <name>`
|
|
54
|
+
- 固定人绑定优先同时提供姓名和工号。`user resolve` 匹配多人、未匹配或用户失效时必须停止,不得凭姓名选第一个。
|
|
55
|
+
- typed 输出只保留 ID、姓名、工号、组织、状态和角色摘要,不应默认输出手机号或头像 URL。
|
|
56
|
+
- `organization department memberships` 以平台 `user_group` 关系为权威;`position` 以 `user.title` 为权威;直属与连续直属上级以 `user.leader_id` 为权威。
|
|
57
|
+
- `main-department` 不得把第一个部门当主部门;平台未返回主部门字段时必须输出 `platform_authority_required`。
|
|
58
|
+
- `branch` 不得按部门名称或固定层级猜测分部;平台未提供分部类型/标识时只返回候选祖先并明确要求平台改造。
|
|
59
|
+
- 用户配置必须在已初始化的 BPMAX 配置目录中走 `config user` typed 链路;不得直接修改 `think_user`,也不得使用 raw API 写用户。
|
|
60
|
+
- 导出和普通输出不得包含手机号、头像、密码、Cookie、会话、IP 或登录时间。手机号只允许在 `mode=create` work 中显式提供,且 dry-run 输出必须脱敏。
|
|
61
|
+
- 创建用户至少需要姓名、手机号和一个角色 ID;编辑关系时 `group_ids`、`role_ids`、`modelList` 必须使用精确 typed readback 得到的 ID。
|
|
62
|
+
- `hide_in_contact` 当前平台接口未实现,不得写入 work 或 submit payload;CLI lint/build 会硬阻断。
|
|
63
|
+
- `leader_id` 不得指向用户自身;状态只允许 0、1、2。删除前必须确认没有进行中项目或待办依赖该用户。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: "bpmax-user-mock-operator"
|
|
3
|
-
description: "用于 BPMAX
|
|
3
|
+
description: "用于 BPMAX E2E 测试中的用户身份切换。只要用户提到“E2E 切换用户”“模拟审批人测试”“多角色页面回归”“mock 用户做真实页面测试”“退出模拟用户”或等价表达,就应使用这个 skill。它只复用当前 E2E 会话调用既有 `PUT /api/user/:id` mock/unmock 接口,不提供 API Key 冒充、不修改平台权限、不修改本地配置镜像。"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# BPMAX User Mock Operator
|
|
@@ -8,7 +8,7 @@ description: "用于 BPMAX 浏览器 E2E 测试中的用户身份切换。只要
|
|
|
8
8
|
## 使用范围
|
|
9
9
|
- 本 skill 只用于“浏览器 E2E 测试中的用户身份切换”。
|
|
10
10
|
- 目标是让同一浏览器会话在完整页面链路中切到发起人、审批人、查看人等角色,验证真实 UI 可见性、按钮、表单和流转。
|
|
11
|
-
- 不用于普通 CLI API 调用身份切换,不用于 API Key impersonation
|
|
11
|
+
- 不用于普通 CLI API 调用身份切换,不用于 API Key impersonation。只使用 `bpmax-cli e2e identity mock|unmock|status` 操作当前浏览器会话。
|
|
12
12
|
- 不修改 BPMAX 平台权限、角色配置、本地 `think_*` 镜像或配置提交体。
|
|
13
13
|
|
|
14
14
|
## 何时使用
|
|
@@ -19,7 +19,7 @@ description: "用于 BPMAX 浏览器 E2E 测试中的用户身份切换。只要
|
|
|
19
19
|
|
|
20
20
|
## 前置条件
|
|
21
21
|
- 浏览器里已有可用 BPMAX 登录态。
|
|
22
|
-
-
|
|
22
|
+
- 原始账号必须具备专用权限点 `user.mock`(超管兼容);普通 `organization.admin` 不再自动获得模拟身份权限。
|
|
23
23
|
- 已确认 workspace、目标用户 `user_id`、目标测试角色。
|
|
24
24
|
- 默认页面为 `.../w:<workspace>/userManagement`;如果测试页不是这个路由,可以传 `--href-path` 覆盖。
|
|
25
25
|
|
|
@@ -35,69 +35,41 @@ description: "用于 BPMAX 浏览器 E2E 测试中的用户身份切换。只要
|
|
|
35
35
|
- 某类角色切换后的页面权限验证方式
|
|
36
36
|
- 不要写入 Cookie、Authorization、API Key、手机号、验证码、密码或完整接口响应。
|
|
37
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`
|
|
38
|
+
## 受控命令
|
|
48
39
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
### 进入目标用户身份
|
|
40
|
+
浏览器 Cookie 只能通过环境变量 `BPMAX_COOKIE_HEADER` 传入,不得出现在命令行、报告或证据文件中。正式 E2E 必须带本轮 execution manifest 和当前 case step:
|
|
52
41
|
|
|
53
42
|
```bash
|
|
54
|
-
|
|
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 \
|
|
43
|
+
bpmax-cli e2e identity mock \
|
|
60
44
|
--user-id <target_user_id> \
|
|
61
|
-
--
|
|
62
|
-
--
|
|
63
|
-
--cookie-header "$BPMAX_COOKIE_HEADER"
|
|
64
|
-
```
|
|
45
|
+
--execution-manifest <file> --case-id <case_id> --case-step-id <step_id> \
|
|
46
|
+
--evidence-dir <current_run_dir> --profile <profile> --format json
|
|
65
47
|
|
|
66
|
-
|
|
48
|
+
bpmax-cli e2e identity status \
|
|
49
|
+
--execution-manifest <file> --case-id <case_id> --case-step-id <step_id> \
|
|
50
|
+
--evidence-dir <current_run_dir> --profile <profile> --format json
|
|
67
51
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
--
|
|
71
|
-
--user-id <target_user_id> \
|
|
72
|
-
--workspace <workspace> \
|
|
73
|
-
--base-url <bpmax_origin> \
|
|
74
|
-
--cookie-header "$BPMAX_COOKIE_HEADER"
|
|
52
|
+
bpmax-cli e2e identity unmock \
|
|
53
|
+
--execution-manifest <file> --case-id <case_id> --case-step-id <step_id> \
|
|
54
|
+
--evidence-dir <current_run_dir> --profile <profile> --format json
|
|
75
55
|
```
|
|
76
56
|
|
|
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
57
|
## 浏览器 E2E 工作流
|
|
88
58
|
1. 记录原始管理账号、workspace、当前页面和目标测试角色。
|
|
89
|
-
2.
|
|
90
|
-
3.
|
|
91
|
-
4.
|
|
59
|
+
2. 使用 `bpmax-cli user resolve` 精确解析目标用户,不得凭姓名猜 ID。
|
|
60
|
+
3. 将当前浏览器会话 Cookie 仅放入 `BPMAX_COOKIE_HEADER`,执行当前用例步骤对应的 `e2e identity mock`。
|
|
61
|
+
4. CLI 必须回读 `current_user.mock=true` 且 ID 与目标用户一致;然后刷新待测页面,再从可见用户名和权限入口确认身份。
|
|
92
62
|
5. 在浏览器中执行该角色的真实动作:发起、填写、提交、审批、驳回、查看或权限验证。
|
|
93
63
|
6. 记录截图、项目 ID、step ID、当前角色、目标用户 id 和结论。
|
|
94
|
-
7. 执行 `unmock
|
|
64
|
+
7. 执行 `e2e identity unmock`;只有 `readback_confirmed=true` 且页面刷新后恢复原账号,才能结束多角色测试。
|
|
95
65
|
|
|
96
66
|
## 硬门禁
|
|
97
67
|
- 没有确认当前浏览器身份前,不得声称该角色浏览器 E2E 已通过。
|
|
98
68
|
- 没有执行 unmock 和恢复验证前,不得结束多角色测试。
|
|
99
69
|
- 不得把 mock 后的 Cookie/API 响应用作普通 API Key 或 CLI 业务命令身份。
|
|
100
70
|
- 不得把浏览器抓包中的 Cookie 或 Authorization 写入报告、memory、AGENTS.md 或 git。
|
|
71
|
+
- 正式用例缺少 execution manifest/case step 时必须在远程 mock 前硬阻断。`--diagnostic` 只能排障,不能记为 pass evidence。
|
|
72
|
+
- 每次 mock/unmock 由平台写入审计日志;目标用户必须与原始操作人同组织。
|
|
101
73
|
|
|
102
74
|
## 常见问题
|
|
103
75
|
- 401/403:先确认 Cookie 是否过期,再确认原始管理账号是否具备模拟用户权限。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
interface:
|
|
2
2
|
display_name: "BPMAX User Mock Operator"
|
|
3
|
-
short_description: "在 BPMAX
|
|
4
|
-
default_prompt: "使用 $bpmax-user-mock-operator 根据当前 BPMAX
|
|
3
|
+
short_description: "在 BPMAX E2E 测试中切换或退出模拟用户身份"
|
|
4
|
+
default_prompt: "使用 $bpmax-user-mock-operator 根据当前 BPMAX E2E 会话,为测试切换或退出模拟用户身份。"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bpmax-user-model-editor
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
description: "Use when creating or editing BPMAX user models through the bpmax-cli typed user-model adapter."
|
|
5
|
+
metadata:
|
|
6
|
+
requires:
|
|
7
|
+
bins: ["bpmax-cli"]
|
|
8
|
+
cliHelp: "bpmax-cli config user-model --help"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# BPMAX User Model Editor
|
|
12
|
+
|
|
13
|
+
先阅读 `../bpmax-shared/SKILL.md`。使用 `config user-model export/lint/build/submit/verify` 完成配置。
|
|
14
|
+
|
|
15
|
+
标准命令必须显式使用 `--id`:`export --id <id>`、`submit --id <id>`、`verify --id <id>`、`delete --id <id>`。不得把 ID 当作位置参数。
|
|
16
|
+
|
|
17
|
+
## 规则
|
|
18
|
+
|
|
19
|
+
- `key` 必须稳定且可跨环境识别;不要用线上数字 ID 代替 key 或 UUID。
|
|
20
|
+
- `object_event` 必须是数组;`auto_trigger_flows`、`permission` 必须是对象。
|
|
21
|
+
- `form_template_id`、`role_id` 必须通过 typed readback 证明目标存在。
|
|
22
|
+
- 数字 ID 必须属于当前 profile 对应组织;平台返回不存在时不得切换 profile 或尝试跨组织 ID。
|
|
23
|
+
- 修改 `form_template_id` 不会自动补齐既有用户的模型表单;需要该行为时单独执行平台支持的初始化动作并保留证据。
|
|
24
|
+
- 删除前确认没有用户绑定该模型;平台阻断时不得清理关系绕过。
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
import argparse
|
|
5
|
-
import json
|
|
6
|
-
|
|
7
|
-
from user_mock_operator_common import build_client, default_href_path
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def build_parser() -> argparse.ArgumentParser:
|
|
11
|
-
parser = argparse.ArgumentParser(
|
|
12
|
-
description="Switch a BPMAX browser E2E session into or out of simulated identity mode via /api/user/:id."
|
|
13
|
-
)
|
|
14
|
-
parser.add_argument("--action", choices=("mock", "unmock"), required=True)
|
|
15
|
-
parser.add_argument("--user-id", type=int, required=True)
|
|
16
|
-
parser.add_argument("--workspace")
|
|
17
|
-
parser.add_argument("--base-url")
|
|
18
|
-
parser.add_argument("--language", default="zhCN")
|
|
19
|
-
parser.add_argument("--cookie-header")
|
|
20
|
-
parser.add_argument("--href-path")
|
|
21
|
-
parser.add_argument("--timeout", type=float, default=30)
|
|
22
|
-
parser.add_argument("--insecure", action="store_true")
|
|
23
|
-
return parser
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def main() -> int:
|
|
27
|
-
args = build_parser().parse_args()
|
|
28
|
-
client = build_client(args)
|
|
29
|
-
workspace = args.workspace or client.workspace
|
|
30
|
-
href_path = args.href_path or default_href_path(workspace)
|
|
31
|
-
payload = client.switch_user_identity(args.user_id, args.action, href_path)
|
|
32
|
-
print(json.dumps(payload, ensure_ascii=False))
|
|
33
|
-
return 0
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if __name__ == "__main__":
|
|
37
|
-
raise SystemExit(main())
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
import json
|
|
5
|
-
import os
|
|
6
|
-
import ssl
|
|
7
|
-
import sys
|
|
8
|
-
import urllib.error
|
|
9
|
-
import urllib.parse
|
|
10
|
-
import urllib.request
|
|
11
|
-
from dataclasses import dataclass
|
|
12
|
-
from pathlib import Path
|
|
13
|
-
from typing import Any, Optional
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
SHARED_SKILL_ROOT = Path(__file__).resolve().parents[2] / "bpmax-builder-shared"
|
|
17
|
-
if str(SHARED_SKILL_ROOT) not in sys.path:
|
|
18
|
-
sys.path.insert(0, str(SHARED_SKILL_ROOT))
|
|
19
|
-
|
|
20
|
-
from base_url import DEFAULT_BASE_URL, resolve_base_url
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
DEFAULT_LANGUAGE = "zhCN"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def resolve_cookie_header(value: Optional[str]) -> str:
|
|
27
|
-
cookie = value or os.environ.get("BPMAX_COOKIE_HEADER", "")
|
|
28
|
-
if not cookie:
|
|
29
|
-
raise SystemExit("missing cookie header: pass --cookie-header or set BPMAX_COOKIE_HEADER")
|
|
30
|
-
return cookie
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def resolve_workspace(value: Optional[str]) -> str:
|
|
34
|
-
workspace = value or os.environ.get("BPMAX_WORKSPACE", "")
|
|
35
|
-
if not workspace:
|
|
36
|
-
raise SystemExit("missing workspace: pass --workspace or set BPMAX_WORKSPACE")
|
|
37
|
-
return workspace
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def default_href_path(workspace: str) -> str:
|
|
41
|
-
return f"/w:{workspace}/userManagement"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def encode_x_href(href_path: str) -> str:
|
|
45
|
-
return urllib.parse.quote(href_path, safe="")
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def normalize_href_path(href_path: Optional[str], workspace: str) -> str:
|
|
49
|
-
candidate = (href_path or "").strip() or default_href_path(workspace)
|
|
50
|
-
if candidate.startswith("http://") or candidate.startswith("https://"):
|
|
51
|
-
parsed = urllib.parse.urlparse(candidate)
|
|
52
|
-
candidate = parsed.path or default_href_path(workspace)
|
|
53
|
-
if parsed.query:
|
|
54
|
-
candidate = f"{candidate}?{parsed.query}"
|
|
55
|
-
if not candidate.startswith("/"):
|
|
56
|
-
raise SystemExit("href path must start with '/' or be an absolute BPMAX page URL")
|
|
57
|
-
return candidate
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def build_action_body(action: str) -> dict:
|
|
61
|
-
if action == "mock":
|
|
62
|
-
return {"mock": 1}
|
|
63
|
-
if action == "unmock":
|
|
64
|
-
return {"unmock": 1}
|
|
65
|
-
raise SystemExit(f"unsupported action: {action}")
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
@dataclass
|
|
69
|
-
class ApiClient:
|
|
70
|
-
base_url: str
|
|
71
|
-
workspace: str
|
|
72
|
-
language: str
|
|
73
|
-
cookie_header: str
|
|
74
|
-
timeout: float
|
|
75
|
-
insecure: bool = False
|
|
76
|
-
|
|
77
|
-
def _build_url(self, path: str) -> str:
|
|
78
|
-
joiner = "&" if "?" in path else "?"
|
|
79
|
-
suffix = f"$workspace={urllib.parse.quote(self.workspace)}&$language={urllib.parse.quote(self.language)}"
|
|
80
|
-
return self.base_url.rstrip("/") + path + joiner + suffix
|
|
81
|
-
|
|
82
|
-
def _build_headers(self, href_path: str) -> dict[str, str]:
|
|
83
|
-
normalized_href = normalize_href_path(href_path, self.workspace)
|
|
84
|
-
return {
|
|
85
|
-
"accept": "application/json, text/plain, */*",
|
|
86
|
-
"accept-language": "zh-CN,zh;q=0.9",
|
|
87
|
-
"content-type": "application/json",
|
|
88
|
-
"cookie": self.cookie_header,
|
|
89
|
-
"origin": self.base_url.rstrip("/"),
|
|
90
|
-
"referer": f"{self.base_url.rstrip('/')}{normalized_href}",
|
|
91
|
-
"x-href": encode_x_href(normalized_href),
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
def request(self, method: str, path: str, body: Optional[dict] = None, *, href_path: Optional[str] = None) -> dict:
|
|
95
|
-
href = normalize_href_path(href_path, self.workspace)
|
|
96
|
-
headers = self._build_headers(href)
|
|
97
|
-
data = None if body is None else json.dumps(body, ensure_ascii=False).encode("utf-8")
|
|
98
|
-
request = urllib.request.Request(self._build_url(path), data=data, headers=headers, method=method.upper())
|
|
99
|
-
context = ssl._create_unverified_context() if self.insecure else None
|
|
100
|
-
try:
|
|
101
|
-
with urllib.request.urlopen(request, timeout=self.timeout, context=context) as response:
|
|
102
|
-
raw = response.read().decode("utf-8", "replace")
|
|
103
|
-
except urllib.error.HTTPError as err:
|
|
104
|
-
raw = err.read().decode("utf-8", "replace")
|
|
105
|
-
raise SystemExit(f"HTTP {err.code} {path}: {raw}") from err
|
|
106
|
-
except urllib.error.URLError as err:
|
|
107
|
-
raise SystemExit(f"Request failed {path}: {err}") from err
|
|
108
|
-
|
|
109
|
-
try:
|
|
110
|
-
payload = json.loads(raw)
|
|
111
|
-
except json.JSONDecodeError as err:
|
|
112
|
-
raise SystemExit(f"Non-JSON response from {path}: {raw}") from err
|
|
113
|
-
if isinstance(payload, dict) and payload.get("code") not in (None, 0):
|
|
114
|
-
raise SystemExit(f"API error {path}: {payload}")
|
|
115
|
-
return payload
|
|
116
|
-
|
|
117
|
-
def switch_user_identity(self, user_id: int, action: str, href_path: Optional[str] = None) -> dict:
|
|
118
|
-
if user_id <= 0:
|
|
119
|
-
raise SystemExit("user id must be positive")
|
|
120
|
-
return self.request(
|
|
121
|
-
"PUT",
|
|
122
|
-
f"/api/user/{user_id}",
|
|
123
|
-
build_action_body(action),
|
|
124
|
-
href_path=href_path,
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
def build_client(args: Any) -> ApiClient:
|
|
129
|
-
return ApiClient(
|
|
130
|
-
base_url=resolve_base_url(getattr(args, "base_url", None)),
|
|
131
|
-
workspace=resolve_workspace(getattr(args, "workspace", None)),
|
|
132
|
-
language=getattr(args, "language", DEFAULT_LANGUAGE),
|
|
133
|
-
cookie_header=resolve_cookie_header(getattr(args, "cookie_header", None)),
|
|
134
|
-
timeout=float(getattr(args, "timeout", 30)),
|
|
135
|
-
insecure=bool(getattr(args, "insecure", False)),
|
|
136
|
-
)
|