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

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 (39) hide show
  1. package/dist/bin.js +1584 -69
  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 +3 -3
  8. package/skills/bpmax-dataset-template-editor/SKILL.md +3 -3
  9. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +28 -2
  10. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +26 -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 +25 -10
  17. package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +17 -2
  18. package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +2 -0
  19. package/skills/bpmax-form-template-editor/SKILL.md +31 -6
  20. package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +15 -5
  21. package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +1 -1
  22. package/skills/bpmax-form-template-editor/scripts/export_form_template.py +2 -0
  23. package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +17 -0
  24. package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +6 -17
  25. package/skills/bpmax-list-template-editor/SKILL.md +5 -1
  26. package/skills/bpmax-list-template-editor/references/content-config-shape.md +17 -0
  27. package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +9 -4
  28. package/skills/bpmax-list-template-editor/references/runtime-verified-workflow.md +17 -10
  29. package/skills/bpmax-list-template-editor/references/special-formats.md +17 -0
  30. package/skills/bpmax-memory-protocol/SKILL.md +72 -0
  31. package/skills/bpmax-nav-config-editor/SKILL.md +1 -1
  32. package/skills/bpmax-project-detail-template-editor/SKILL.md +1 -1
  33. package/skills/bpmax-role-editor/SKILL.md +2 -2
  34. package/skills/bpmax-user-mock-operator/SKILL.md +106 -0
  35. package/skills/bpmax-user-mock-operator/agents/openai.yaml +4 -0
  36. package/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py +37 -0
  37. package/skills/bpmax-user-mock-operator/scripts/user_mock_operator_common.py +136 -0
  38. package/skills/bpmax-user-mock-operator/tests/test_user_mock_operator.py +138 -0
  39. package/skills/form-control-library/SKILL.md +1 -1
@@ -77,6 +77,19 @@
77
77
  3. 创建流程模板壳:
78
78
  - `POST flow/flow_type`
79
79
 
80
+ typed CLI 执行口径:
81
+
82
+ ```bash
83
+ bpmax-cli config flow-template create --work .codex/tmp/flow-template-editor/work/<create-file>.json
84
+ bpmax-cli config flow-template create --work .codex/tmp/flow-template-editor/work/<create-file>.json --confirm "create flow-template <name>"
85
+ ```
86
+
87
+ gate:
88
+ - work 文件不得手写语义化主流程 `flow_type`
89
+ - CLI 必须从平台响应中取得 `flow<number>`
90
+ - dry-run 必须展示 `POST /flow/flow_type` 与 `PUT /flow?flow_type=<platform-flow-type>&publish=2`
91
+ - 若需发布 live,显式加 `--publish-live`
92
+
80
93
  创建主流程请求体:
81
94
 
82
95
  ```json
@@ -101,6 +114,8 @@
101
114
  1. `POST /flow/sub`
102
115
  2. `PUT /flow?key=<subKey>&publish=2`
103
116
 
117
+ 当前 npm 分发版若没有 typed 子流程 create 命令,不得用 raw API 或页面 fetch 绕过;必须停止并说明缺少 typed 子流程 create 能力。
118
+
104
119
  ### 主流程保存草稿与发布
105
120
  文件:
106
121
  - `/Users/yanghanwen/Development/Cicada/bpmax-core/hpt-frontend/components/FlowEditorDark/index.vue`
@@ -120,8 +135,8 @@
120
135
  - 成功后调用 `getFlowData(this.flowTypeKey)`
121
136
 
122
137
  实操补充:
123
- - 在当前环境批量改 live 流程时,保存草稿后紧接着复用同一份 `{ name, data }` 请求体再调一次 `publish=1` 可正常发布。
124
- - 当前环境实测可继续沿用 live 读到的同一个 `update_time` 完成“先保存草稿,再正式发布”的串行闭环。
138
+ - 这是接口形态事实,不是执行许可。实际发布必须使用 typed CLI 的 `--publish-live` 路径,不能手动复用 `{ name, data }` 调 `PUT /api/flow?...publish=1`。
139
+ - 当前环境实测的 `update_time` 行为只能用于理解 typed CLI 构建出的 endpoint,不能作为 raw API 发布依据。
125
140
 
126
141
  ### 刷新流程
127
142
  文件:
@@ -121,6 +121,8 @@
121
121
  ## 4. 工作区与导航怎么协作
122
122
  - `workspace_flow` 决定一个流程属于哪个工作区的流程集合。
123
123
  - `navmenu` 决定用户有没有明确入口、入口叫什么、点进去走什么路径、哪些角色能看见。
124
+ - 工作区绑定写入必须走 typed adapter:`bpmax-cli config workspace-flow build/submit`,或在完整新建场景下由 `bpmax-cli config flow-app create` 内置执行。
125
+ - 写入后必须用 `/workspace/by_key?key=<workspace>` 回读确认 `(flow_type, flow_key)` 存在;缺失时不能宣布绑定成功。
124
126
  - 以 `flow511341945` 为例:
125
127
  - `workspace_flow` 已挂到 `project_management`
126
128
  - `navmenu` 已提供 `/project?flow_type=flow511341945` 入口
@@ -7,7 +7,9 @@ description: "用于在 BPMAX 的表单模板页面中创建或编辑表单。
7
7
 
8
8
  ## 写入路径硬约束
9
9
  - 执行前必须先运行 `bpmax-cli config adapters --format json` 核对 `form-template`;只有 `build_status` 和 `submit_status` 都是 `supported` 时才允许进入 build/submit。当前若显示 `blocked`,只能导出、编辑 work、lint 和形成变更建议,不得提交。
10
- - 在 bpmax-cli npm 分发包中,真实远端写操作只能走 `bpmax-cli config form-template submit`。
10
+ - 在 bpmax-cli npm 分发包中,真实远端写操作只能走 `bpmax-cli config form-template submit`;编辑态由 submit 执行 `PUT /form_template/:id`,新建态由 `mode=create` 的 submit 执行 `POST /form_template` 并发布。
11
+ - 新建表单模板时,必须确认当前 profile 具备 `config.form_template.create`,且 `config adapters` 的 `form-template.write_endpoints` 包含 `POST /api/form_template` 与 `POST /api/form_template/publish`。缺任一项就停止,不得改用 raw API 或页面 fetch。
12
+ - `bpmax-cli config form-template export/submit/verify` 和 `export_form_template.py --template-id` 必须硬阻断发布态模板 ID;若 `origin_template_id != 0`,只能改用该草稿 ID 后重试。
11
13
  - 旧来源脚本 `scripts/submit*.py` 只保留为结构参考,默认会硬失败;不得用它们直调 BPMAX API。
12
14
  - 不得用 `bpmax-cli api POST/PUT/DELETE /form_template*` 或其它 raw API 绕过 typed config submit。
13
15
 
@@ -31,7 +33,7 @@ description: "用于在 BPMAX 的表单模板页面中创建或编辑表单。
31
33
  - 如果需求涉及控件选型、控件是否存在、某个 `field_type` 怎么配,必须联动 [$form-control-library](../form-control-library/SKILL.md)。
32
34
 
33
35
  ## Mem0 协议
34
- - 开始前先调用 [$mem0-memory-protocol](../mem0-memory-protocol/SKILL.md),检索词至少包含:
36
+ - 开始前先调用 [$bpmax-memory-protocol](../bpmax-memory-protocol/SKILL.md),检索词至少包含:
35
37
  - 模板名 / 模板 `id`
36
38
  - `flow_type`
37
39
  - 关键控件 `field_type`
@@ -120,7 +122,7 @@ description: "用于在 BPMAX 的表单模板页面中创建或编辑表单。
120
122
  - 对仅承担内部传值职责的自动带出字段:应做成数据字段语义,优先隐藏(例如 `hidden = true` 且 `display = false`,或明确采用 `raw` / 非用户输入字段承载)
121
123
  - 表单 lint 必须把“脚本自动回填目标字段但字段仍可编辑”视为错误,并同时覆盖“按字段 key 回填”和“按 field id 回填”两类写法;触发联动的源字段不在这条只读规则内。
122
124
  - 新建与编辑要严格区分:
123
- - 新建:`POST /api/form_template`
125
+ - 新建:`bpmax-cli config form-template submit --id create ... --confirm "submit form-template create"`,由 typed adapter 内部执行 `POST /api/form_template`
124
126
  - 编辑:`PUT /api/form_template/:id`
125
127
  - 成功提交后,必须打开最新的表单编辑页,展示当前结果,而不是只口头说明成功。
126
128
  - 范围门禁是硬规则:只有用户明确要求的改动,或为满足该需求而不可避免的联动改动,才允许进入 `work` / `submit` / 最终提交。
@@ -157,7 +159,7 @@ description: "用于在 BPMAX 的表单模板页面中创建或编辑表单。
157
159
  - `required-collateral`:为闭合需求不得不连带修改的项
158
160
  - `out-of-scope`:当前发现但不应在本次提交里的项
159
161
  - 只要 `out-of-scope` 非空,或 `required-collateral` 还没拿到逐项确认,就不得构建 `submit`,也不得执行线上提交、发布或运行态验收结论。
160
- - 如果使用 `submit_form_template.py --allow-semantic-lint-errors`,它只表示本次允许带着已解释的语义 lint 错误继续提交;它不得绕过需求范围 gate、双确认、文件 hash、发布一致性门禁、回读验证和运行态验收。
162
+ - 如果 typed CLI 后续提供 `--allow-semantic-lint-errors`,它也只表示本次允许带着已解释的语义 lint 错误继续提交;旧 `submit_form_template.py` 不得用于真实远端写入,也不得绕过需求范围 gate、双确认、文件 hash、发布一致性门禁、回读验证和运行态验收。
161
163
 
162
164
  ### 1. 识别当前模式
163
165
  - 读取当前页 URL。
@@ -186,7 +188,7 @@ export BPMAX_WORKSPACE='store_mgr'
186
188
 
187
189
  - `BPMAX_BASE_URL` 必须来自当前浏览器页面 origin,或当前页面最近一次同域请求的 origin;不要写死某个项目环境域名。
188
190
 
189
- - 只有在终端脚本口径失败且确认是鉴权/环境问题时,才回退到页面内 `fetch(..., { credentials: "include" })` 兜底。
191
+ - 页面内 `fetch(..., { credentials: "include" })` 只允许用于只读探测或排查鉴权问题;任何表单模板写入、发布、删除都不得用页面 fetch 兜底,必须回到 typed CLI。
190
192
 
191
193
  ### 3. 读取当前表单结构
192
194
  - 开发前必须先通过真实线上接口确认当前环境的表单详情结构,而不是只看仓库镜像或旧请求样例。
@@ -196,6 +198,13 @@ export BPMAX_WORKSPACE='store_mgr'
196
198
  - 新建模板时,必须先找到一个可复用模板或已验证样例,再用:
197
199
  - `GET /api/form_template/:sampleId`
198
200
  - 把它当作 create skeleton 的真实格式样本
201
+ - 新建模板的 work/meta gate:
202
+ - `work.mode` 必须是 `create`
203
+ - `meta.mode` 必须是 `create`
204
+ - `meta.id` 固定用 `create` 或本轮约定的 create 占位,不得填未来猜测出来的模板 ID
205
+ - build 后 `submit.base_hash` 应为 `null`
206
+ - submit payload 里不得保留字段级后端持久化 ID,例如 `form_rule_id`、`form_template_id`、`template_id`、字段 `id`
207
+ - 如果 build 输出仍带这些 ID,立即停止并修正 work/build,不得提交
199
208
  - 当前环境已确认:
200
209
  - 顶层对象直接包含 `name`、`desc`、`option`、`rule`、`value`
201
210
  - `rule` 是二维数组
@@ -785,6 +794,9 @@ bpmax-cli config form-template submit \
785
794
  - `submit` 没有比已确认的 `work` 多出新的基础信息、布局、控件、字段属性、脚本、校验或子表单引用变化
786
795
  - 语义 lint 不得存在 blocker
787
796
  - 编辑场景下,发布一致性门禁不得发现“草稿将覆盖已发布关键字段”的风险
797
+ - 新建场景下,dry-run 必须先展示 `POST /form_template` 与 `POST /form_template/publish`,且未确认时不得出现任何 `POST` 请求
798
+ - 新建确认文本固定为 `submit form-template create`;不能把平台尚未返回的 draft id 或 published id 写进确认文本
799
+ - 新建成功后必须回读 draft id 与 published id;缺少任一回读 hash 或回读失败都不能宣布完成
788
800
  - 本地一致性检查结论必须可口头复述,至少包括:
789
801
  - 哪些是用户明确要求改的
790
802
  - 哪些是为闭合需求而额外联动、且已获用户逐项确认的
@@ -807,6 +819,10 @@ bpmax-cli config form-template submit \
807
819
  - 提交成功后,必须打开:
808
820
  - 新建:新模板的编辑页 `/w:<workspace>/form_template/<newId>`
809
821
  - 编辑:当前模板编辑页
822
+ - 如果新建后浏览器中的表单打不开、空白或控件缺失,必须优先检查浏览器 Console 和 Network:
823
+ - 先记录第一条阻断性 JS error 或接口 4xx/5xx
824
+ - 若错误指向 `form_template`、控件 `lambda`、`customeValidate`、控件 props/schema,优先修表单模板配置本身
825
+ - 只有确认表单模板无报错后,才继续排查流程绑定、导航入口或权限
810
826
  - 接口层至少要验证:
811
827
  - 草稿态 `GET /api/form_template/<draftId>`
812
828
  - 发布态 `GET /api/form_template/<publishedId>`
@@ -862,6 +878,7 @@ bpmax-cli config form-template submit \
862
878
  - 这类场景里 `actualRuntimeFormTemplateId = <publishedId>` 就是主证据
863
879
  - 不要求再额外补一个 `flow_live_form_template_id` 才算通过
864
880
  - 典型场景:纯文案、小字段显示、提示语、非流程绑定结构的小改动
881
+ - 如果运行态发起页、审批页或详情页表单打不开、白屏、字段不渲染或提交控件不可用,不得先跳到接口结论;必须先检查浏览器 Console 和 Network 报错,并优先处理 `form_template` 加载、控件渲染、`lambda`、`customeValidate`、`sub_form` 绑定等表单模板相关错误。
865
882
  - 推荐命令:
866
883
 
867
884
  ```bash
@@ -1067,8 +1084,16 @@ bpmax-cli config form-template submit --id <id> --payload .codex/tmp/form-templa
1067
1084
  bpmax-cli config form-template verify --id <id> --expect .codex/tmp/form-template-editor/work/<file>.json
1068
1085
  ```
1069
1086
 
1087
+ 新建表单模板时,`work` 与 `meta` 都必须声明 `mode=create`,再走同一 submit 入口:
1088
+
1089
+ ```bash
1090
+ bpmax-cli config form-template build --work .codex/tmp/form-template-editor/work/<create-file>.json --meta .codex/tmp/form-template-editor/meta/<create-file>.meta.json --out .codex/tmp/form-template-editor/submit/<create-file>.json
1091
+ bpmax-cli config form-template submit --id create --payload .codex/tmp/form-template-editor/submit/<create-file>.json
1092
+ bpmax-cli config form-template submit --id create --payload .codex/tmp/form-template-editor/submit/<create-file>.json --confirm "submit form-template create"
1093
+ ```
1094
+
1070
1095
  授权前置:当前 profile 必须通过校对码授权,并在授权页开启“配置能力”。如果 CLI 返回 capability 缺失,停止并让用户使用有管理权限的账号重新授权。
1071
1096
 
1072
1097
  默认使用 `--work-format structured`,直接编辑 `basic/layout/fields/removedFields` 后再 build;只有兼容旧脚本时才导出 raw。
1073
1098
 
1074
- 旧来源中的 `scripts/` 和 `references/` 只作为字段结构、lint 规则和验收规则参考;真实远端写操作必须走 `bpmax-cli config form-template submit`,保留 dry-run、二次确认、审计和回读验证。
1099
+ 旧来源中的 `scripts/` 和 `references/` 只作为字段结构、lint 规则和验收规则参考;真实远端写操作必须走 `bpmax-cli config form-template submit`,保留 dry-run、二次确认、审计和回读验证。create 能力缺失时不得退回旧脚本、raw API 或浏览器页面内 fetch。
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## 鉴权与执行环境
8
8
  - 浏览器用于确认登录态、提取 Cookie / 请求头、最终刷新编辑页
9
- - 正式提交默认由终端脚本完成
9
+ - 正式提交必须由 `bpmax-cli config form-template submit` typed adapter 完成;下面的旧脚本命令只用于理解历史临时文件结构,不得用于真实远端写入
10
10
  - 推荐环境变量:
11
11
 
12
12
  ```bash
@@ -97,10 +97,8 @@ PYTHON_BIN=./venv/bin/python
97
97
  ### 提交与回读
98
98
 
99
99
  ```bash
100
- "$PYTHON_BIN" .codex/skills/bpmax-form-template-editor/scripts/submit_form_template.py \
101
- --stem 990702153 \
102
- --workspace store_mgr \
103
- --cookie-header "$BPMAX_COOKIE_HEADER"
100
+ bpmax-cli config form-template submit --id 990702153 --payload .codex/tmp/form-template-editor/submit/form-template-990702153.json
101
+ bpmax-cli config form-template submit --id 990702153 --payload .codex/tmp/form-template-editor/submit/form-template-990702153.json --confirm "submit form-template 990702153"
104
102
  ```
105
103
 
106
104
  ## 正式接口
@@ -111,6 +109,13 @@ PYTHON_BIN=./venv/bin/python
111
109
  ### 新建
112
110
  - `POST /api/form_template?$workspace=<workspace>&$language=zhCN`
113
111
  - `POST /api/form_template/publish?$workspace=<workspace>&$language=zhCN`
112
+ - typed CLI 口径:
113
+
114
+ ```bash
115
+ bpmax-cli config form-template build --work .codex/tmp/form-template-editor/work/<create-file>.json --meta .codex/tmp/form-template-editor/meta/<create-file>.meta.json --out .codex/tmp/form-template-editor/submit/<create-file>.json
116
+ bpmax-cli config form-template submit --id create --payload .codex/tmp/form-template-editor/submit/<create-file>.json
117
+ bpmax-cli config form-template submit --id create --payload .codex/tmp/form-template-editor/submit/<create-file>.json --confirm "submit form-template create"
118
+ ```
114
119
 
115
120
  ### 发布请求体
116
121
 
@@ -160,6 +165,11 @@ PYTHON_BIN=./venv/bin/python
160
165
  - `modelingGatePassed = true`
161
166
  - 语义 lint 无 blocker
162
167
  - 编辑态发布一致性检查无 blocker
168
+ - 新建态 `work.mode = create` 且 `meta.mode = create`
169
+ - 新建态 `submit.base_hash = null`
170
+ - 新建态 submit payload 不得包含字段级持久化 ID
171
+ - 新建 dry-run 未确认时不得发起 `POST`
172
+ - 新建 confirmed 后必须回读 draft 与 published 两个 ID
163
173
  - 编辑态发布一致性检查默认要做,但它只是一道辅助门禁:
164
174
  - 如果本地已发布镜像、历史目录或基于 `origin_template_id != 0` 的本地比对结果,与线上草稿/发布态 readback 和浏览器编辑页渲染冲突,必须优先认定为镜像漂移
165
175
  - 遇到镜像漂移时,不得为了通过本地 gate 把旧字段、旧 `lambda`、旧 `customeValidate` 机械补回去
@@ -120,6 +120,6 @@
120
120
  - `submit` 文件一旦变化,必须重新确认 submit
121
121
  - `work diff`、`submit diff`、`verify.json`、`drift.json`、`runtime-acceptance.json` 都必须映射到 `requested` 或已确认的 `required-collateral`
122
122
  - `out-of-scope` 非空,或 `required-collateral` 未逐项确认时,不得构建 submit、提交、发布或给出运行态已验收结论
123
- - `submit_form_template.py --allow-semantic-lint-errors` 只允许绕过已解释的语义 lint 错误,不得绕过需求范围 gate、双确认、hash、发布一致性和回读验收
123
+ - 旧 `submit_form_template.py` 不得用于真实远端写入;若 typed CLI 后续提供语义 lint 例外参数,也只能绕过已解释的语义 lint 错误,不得绕过需求范围 gate、双确认、hash、发布一致性和回读验收
124
124
  - 编辑场景下,如发布一致性门禁发现 submit 会覆盖已发布关键能力,必须先修正再提
125
125
  - 涉及 flow 绑定、发起页、运行页、审批页行为验证时,默认优先用 fresh instance 复测,不要拿旧项目做最终验收
@@ -7,6 +7,7 @@ from form_template_editor_common import (
7
7
  build_client,
8
8
  build_create_raw_payload,
9
9
  create_stem,
10
+ assert_form_template_draft_id,
10
11
  detail_to_work_payload,
11
12
  dump_json,
12
13
  paths_for,
@@ -36,6 +37,7 @@ def main() -> int:
36
37
  if args.template_id:
37
38
  response = client.get_form_template(args.template_id)
38
39
  detail = response.get("data") or {}
40
+ assert_form_template_draft_id(args.template_id, detail, "export")
39
41
  stem = str(args.template_id)
40
42
  mode = "edit"
41
43
  raw = detail
@@ -133,6 +133,23 @@ def extract_api_data(payload: Dict[str, Any]) -> Any:
133
133
  return payload
134
134
 
135
135
 
136
+ def normalize_numeric_id(value: Any) -> int | None:
137
+ if isinstance(value, int):
138
+ return value
139
+ if isinstance(value, str) and value.isdigit():
140
+ return int(value)
141
+ return None
142
+
143
+
144
+ def assert_form_template_draft_id(template_id: Any, detail: Dict[str, Any], action: str) -> None:
145
+ origin_template_id = normalize_numeric_id(detail.get("origin_template_id"))
146
+ if origin_template_id and origin_template_id > 0:
147
+ raise SystemExit(
148
+ f"refusing to {action} published form-template id {template_id}; "
149
+ f"use draft id {origin_template_id}. Published ids are readback-only."
150
+ )
151
+
152
+
136
153
  def _extract_field_pairs(rule_rows: Any, value_items: Any) -> tuple[Dict[str, Dict[str, Any]], list[str]]:
137
154
  value_by_field: Dict[str, Dict[str, Any]] = {}
138
155
  if isinstance(value_items, list):
@@ -12,8 +12,8 @@ if str(SCRIPT_DIR) not in sys.path:
12
12
  sys.path.insert(0, str(SCRIPT_DIR))
13
13
 
14
14
  import form_template_editor_common as common
15
- import submit_form_template as submit_script
16
15
  from form_template_editor_common import (
16
+ assert_form_template_draft_id,
17
17
  build_drift_report,
18
18
  build_publish_safety_report,
19
19
  build_runtime_acceptance_payload,
@@ -1223,23 +1223,12 @@ class FormTemplateEditorCommonTests(unittest.TestCase):
1223
1223
  self.assertEqual(payload["flowDraftFormTemplateId"], 990702161)
1224
1224
  self.assertEqual(payload["runtimeReferenceSource"], "flow_live_api")
1225
1225
 
1226
- def test_submit_script_resolves_origin_template_as_edit_target_when_present(self) -> None:
1227
- class FakeClient:
1228
- def get_form_template(self, template_id):
1229
- return {"data": {"id": template_id, "origin_template_id": 990702142}}
1226
+ def test_form_template_draft_id_gate_blocks_published_template_id(self) -> None:
1227
+ with self.assertRaisesRegex(SystemExit, "published form-template id 990702161.*draft id 990702142"):
1228
+ assert_form_template_draft_id(990702161, {"id": 990702161, "origin_template_id": 990702142}, "export")
1230
1229
 
1231
- draft_id, detail = submit_script.resolve_edit_target_ids(FakeClient(), 990702161)
1232
- self.assertEqual(draft_id, 990702142)
1233
- self.assertEqual(detail["id"], 990702161)
1234
-
1235
- def test_submit_script_uses_requested_id_as_edit_target_when_origin_missing(self) -> None:
1236
- class FakeClient:
1237
- def get_form_template(self, template_id):
1238
- return {"data": {"id": template_id, "origin_template_id": 0}}
1239
-
1240
- draft_id, detail = submit_script.resolve_edit_target_ids(FakeClient(), 990702161)
1241
- self.assertEqual(draft_id, 990702161)
1242
- self.assertEqual(detail["id"], 990702161)
1230
+ def test_form_template_draft_id_gate_allows_draft_template_id(self) -> None:
1231
+ assert_form_template_draft_id(990702142, {"id": 990702142, "origin_template_id": 0}, "export")
1243
1232
 
1244
1233
  def test_runtime_acceptance_payload_accepts_browser_runtime_without_flow_live_reference(self) -> None:
1245
1234
  payload = build_runtime_acceptance_payload(
@@ -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` / 模板名
@@ -285,6 +285,8 @@ export BPMAX_BASE_URL='https://<your-bpmax-host>'
285
285
  - `createElement.children.$template` / `eval` 结构非法
286
286
  - 操作列在列根配置了 `icon` / `iconColor`
287
287
  - 操作列任一按钮未配置按钮级 icon
288
+ - 操作列缺少“详情/查看”或“删除/移除”动作
289
+ - 删除/移除动作没有基于项目状态、当前环节或步骤状态的可用性 guard;默认只允许刚创建、未推进到第一个节点后的项目删除,过了第一个节点就不能删除
288
290
  - `icon` 不是完整 `ri ri_*`
289
291
  - 普通数据列带 `icon` 的列数少于 1 列或多于 3 列
290
292
  - `iconColor` 不符合规范
@@ -393,6 +395,8 @@ bpmax-cli config list-template submit \
393
395
  - 图标规则:
394
396
  - 操作列列根不要配置 `icon` / `iconColor`
395
397
  - 操作列的每个操作按钮前面都要带 icon
398
+ - 操作列必须包含详情/查看动作和删除/移除动作
399
+ - 删除/移除动作必须有条件 guard,依据项目状态、当前环节或步骤状态控制是否可用;默认语义是“刚创建/未推进可以删除,过了第一个节点不可删除”
396
400
  - 普通数据列至少 1 列带 icon,最多 3 列带 icon
397
401
  - 列表列 icon 和操作按钮 icon 都必须写完整 class:`ri ri_*`
398
402
  - 默认优先统一浅灰色:`#D6DCE5`
@@ -110,6 +110,21 @@
110
110
  },
111
111
  "children": "详情"
112
112
  }
113
+ },
114
+ {
115
+ "is": "el-button",
116
+ "if": {
117
+ "$template": "{return ctx.status === 0 && !ctx.current_flow_step_name}",
118
+ "eval": true
119
+ },
120
+ "attribute": {
121
+ "props": {
122
+ "size": "small",
123
+ "type": "text",
124
+ "icon": "ri ri_delete-bin-line"
125
+ }
126
+ },
127
+ "children": "删除"
113
128
  }
114
129
  ]
115
130
  },
@@ -120,6 +135,8 @@
120
135
 
121
136
  - 操作列的 `icon` / `iconColor` 不放在列根,默认留空或不写。
122
137
  - icon 放到每个操作按钮自身,优先用 `attribute.props.icon`,或显式渲染 `i.ri ri_*` 在按钮文本前。
138
+ - 操作列必须包含详情/查看和删除/移除动作。
139
+ - 删除/移除动作必须带条件 guard,依据项目状态、当前环节或步骤状态控制是否可用;默认只允许刚创建、未推进的项目删除,过了第一个节点后不能删除。
123
140
 
124
141
  ## 图标列
125
142
  - 渲染层会把 `icon` / `iconColor` 作为列外层配置传入
@@ -1,12 +1,14 @@
1
1
  # BPMAX 项目列表模板创建与编辑接口工作流
2
2
 
3
+ > 当前约束:本文记录页面接口结构和历史请求骨架,只用于导出、比对、浏览器验收和调试。真实远端写入必须走 `bpmax-cli config list-template build/submit`,不得用页面 `fetch`、`vm.$axios`、raw `POST/PUT /api/flow_page_template` 或旧脚本替代 typed CLI。
4
+
3
5
  ## 适用页面
4
6
  - 新建页:`/w:<workspace>/project_detail_table/create`
5
7
  - 编辑页:`/w:<workspace>/project_detail_table/<id>`
6
8
 
7
9
  ## 鉴权与执行环境
8
10
  - 优先依赖浏览器当前登录态。
9
- - 优先在页面上下文内执行同域请求,复用已有 Cookie。
11
+ - 优先在页面上下文内观察同域请求,复用已有 Cookie 做只读诊断。
10
12
  - 可读取的上下文包括:
11
13
  - `document.cookie`
12
14
  - `localStorage`
@@ -14,7 +16,8 @@
14
16
  - 当前页最近一次提交流量
15
17
 
16
18
  实践建议:
17
- - 如果只是为了提交接口,优先直接复用页面里的 `fetch(..., { credentials: 'include' })`。
19
+ - 如果只是为了确认接口结构,可以观察页面里的 `fetch(..., { credentials: 'include' })`。
20
+ - 如果需要提交,必须把结构写入本地 work 文件并通过 `bpmax-cli config list-template submit`。
18
21
  - Cookie 信息用于确认和诊断,不应成为唯一提交手段。
19
22
 
20
23
  ## 已确认的接口
@@ -36,7 +39,8 @@
36
39
  - 当前数据集字段列表
37
40
 
38
41
  ### 新建
39
- - `POST /api/flow_page_template?$workspace=<workspace>&$language=zhCN`
42
+ - 历史页面接口:`POST /api/flow_page_template?$workspace=<workspace>&$language=zhCN`
43
+ - typed CLI 写入:`bpmax-cli config list-template submit --id create:list-template ...`
40
44
 
41
45
  请求体结构:
42
46
 
@@ -60,7 +64,8 @@
60
64
 
61
65
  ### 编辑
62
66
  - `GET /api/flow_page_template/<id>?$workspace=<workspace>&$language=zhCN`
63
- - `PUT /api/flow_page_template/<id>?$workspace=<workspace>&$language=zhCN`
67
+ - 历史页面接口:`PUT /api/flow_page_template/<id>?$workspace=<workspace>&$language=zhCN`
68
+ - typed CLI 写入:`bpmax-cli config list-template submit --id <id> ...`
64
69
 
65
70
  编辑返回体重点字段:
66
71
  - `id`
@@ -2,6 +2,8 @@
2
2
 
3
3
  这份文档记录的是在真实 `project_detail_table` 页面上验证通过的操作方式,优先级高于纯推断。
4
4
 
5
+ > 当前约束:本文只作为浏览器验收、页面状态诊断和历史结构参考。真实远端写入必须走 `bpmax-cli config list-template build/submit`,不得再用 `vm.save()`、`vm.$axios` 或裸 `fetch` 作为提交路径。
6
+
5
7
  ## 页面实例定位
6
8
 
7
9
  在当前 Nuxt 页面中,列表模板编辑页的核心实例可通过递归 Vue 树定位。
@@ -22,18 +24,18 @@ typeof vm.save === 'function'
22
24
  - `vm.$axios`
23
25
  - `vm.$router`
24
26
 
25
- ## 运行时操作优先级
27
+ ## 运行时诊断优先级
26
28
 
27
- 推荐顺序:
29
+ 只读诊断推荐顺序:
28
30
 
29
31
  1. 先找页面 Vue 实例
30
- 2. 优先使用 `vm.$axios`
31
- 3. 能直接调用 `vm.save()` 时,优先复用页面保存逻辑
32
- 4. 最后才考虑在浏览器里裸调 `fetch`
32
+ 2. 读取 `vm.form` / `vm.content` / `vm.dataSetList` / `vm.flow`
33
+ 3. 观察页面保存前后的请求结构
34
+ 4. 把确认后的结构落到本地 work 文件,再通过 typed CLI build/submit 写入
33
35
 
34
36
  原因:
35
37
  - 这次实测中,当前页直接裸 `fetch('/api/bpmax/data-set')` 返回了 `403`
36
- - 但通过页面实例的 `vm.$axios.$post('/flow_page_template', payload)` 创建模板成功
38
+ - 历史上通过页面实例的 `vm.$axios.$post('/flow_page_template', payload)` 创建模板成功,但该路径现在只可作为请求结构参考,不能作为实际提交路径
37
39
 
38
40
  ## 推荐操作模式
39
41
 
@@ -44,8 +46,8 @@ typeof vm.save === 'function'
44
46
  - `vm.dataSetList`
45
47
  - `vm.flow.data.meta.table_list_template`
46
48
 
47
- ### 修改模板
48
- 优先直接改:
49
+ ### 查看待修改结构
50
+ 可以临时在页面实例中观察结构,但不要调用保存:
49
51
 
50
52
  ```js
51
53
  vm.form.name = '...';
@@ -55,7 +57,7 @@ vm.content = { level: 0, config: [...] };
55
57
  ```
56
58
 
57
59
  ### 提交
58
- 若需要自定义创建:
60
+ 不要使用页面实例提交。以下旧写法只保留为历史请求骨架参考:
59
61
 
60
62
  ```js
61
63
  const payload = {
@@ -69,7 +71,12 @@ const payload = {
69
71
  const res = await vm.$axios.$post('/flow_page_template', payload);
70
72
  ```
71
73
 
72
- 若只是编辑已有模板,优先考虑直接调用页面的 `save()`。
74
+ 实际提交必须改为:
75
+
76
+ ```bash
77
+ bpmax-cli config list-template build --work <work-file> --meta <meta-file> --out <submit-file>
78
+ bpmax-cli config list-template submit --id <template-id> --payload <submit-file> --confirm "submit list-template <template-id>"
79
+ ```
73
80
 
74
81
  ## 创建页默认模板与线上默认模板
75
82
  - `create` 页默认骨架不一定等于当前流程线上已挂的默认列表模板
@@ -224,6 +224,21 @@
224
224
  },
225
225
  "children": "详情"
226
226
  }
227
+ },
228
+ {
229
+ "is": "el-button",
230
+ "if": {
231
+ "$template": "{return ctx.status === 0 && !ctx.current_flow_step_name}",
232
+ "eval": true
233
+ },
234
+ "attribute": {
235
+ "props": {
236
+ "size": "small",
237
+ "type": "text",
238
+ "icon": "ri ri_delete-bin-line"
239
+ }
240
+ },
241
+ "children": "删除"
227
242
  }
228
243
  ]
229
244
  },
@@ -234,6 +249,8 @@
234
249
 
235
250
  - 操作列不要在列根写 `icon` / `iconColor`。
236
251
  - 每个操作按钮都要自己带 icon,推荐直接写在 `attribute.props.icon`。
252
+ - 操作列必须保留“详情/查看”和“删除/移除”动作;缺删除动作时 CLI gate 会阻断。
253
+ - 删除/移除动作必须带可用性 guard,例如 `if` 或 `disabled`,并引用项目状态、当前环节或步骤状态。默认语义是:刚创建、未推进到第一个节点后的项目可以删除;过了第一个节点后不能删除。
237
254
 
238
255
  ## 5. 条件显示
239
256
 
@@ -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`
@@ -41,7 +41,7 @@ description: "用于在 BPMAX 的角色配置页面创建或编辑角色。只
41
41
  - 提交
42
42
  - 接口回读
43
43
  - 浏览器刷新角色页验收
44
- - v1 不做角色删除。
44
+ - 支持通过 `bpmax-cli config role delete --id <role_id>` 删除角色;必须先 dry-run,确认无成员、权限点和业务流程引用风险后,再使用精确 `--confirm` 执行并回读角色列表验收。
45
45
  - 只允许人工修改 `work/<stem>.json`,不要直接改 `raw`、`submit` 或仓库镜像。
46
46
  - `permissions` 必须始终保持四段结构:
47
47
  - `system`
@@ -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`