@qingflow-tech/qingflow-cli 1.1.61-beta.8 → 1.1.62
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 +3 -3
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/skills/qingflow-cli/SKILL.md +2 -104
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_BUILDER_PORTAL_WORKFLOW.md +1 -1
- package/skills/qingflow-cli/reference/builder/70-portal.md +10 -11
- package/src/qingflow_mcp/builder_facade/service.py +18 -10
- package/src/qingflow_mcp/cli/main.py +1 -34
- package/src/qingflow_mcp/cloud_context.py +1 -16
- package/src/qingflow_mcp/public_surface.py +8 -67
- package/src/qingflow_mcp/response_trim.py +1 -2
- package/src/qingflow_mcp/server.py +6 -12
- package/src/qingflow_mcp/server_app_builder.py +5 -9
- package/src/qingflow_mcp/server_app_user.py +5 -9
- package/src/qingflow_mcp/server_cloud.py +7 -43
- package/src/qingflow_mcp/session_store.py +14 -1
- package/src/qingflow_mcp/tool_catalog.py +0 -387
- package/src/qingflow_mcp/tool_catalog_i18n.py +0 -185
- package/src/qingflow_mcp/tool_policy.py +0 -197
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Qingflow CLI 是轻流面向开发者和 AI Agent 的命令行工具。它把轻
|
|
|
7
7
|
## 安装
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @qingflow-tech/qingflow-cli@1.1.
|
|
10
|
+
npm install @qingflow-tech/qingflow-cli@1.1.62
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
推荐从官网复制这一条一键安装 Qingflow CLI:
|
|
@@ -21,7 +21,7 @@ npx qingflow-cli@latest install
|
|
|
21
21
|
## 运行
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
npx -y -p @qingflow-tech/qingflow-cli@1.1.
|
|
24
|
+
npx -y -p @qingflow-tech/qingflow-cli@1.1.62 qingflow
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
全局安装后可以直接运行:
|
|
@@ -62,7 +62,7 @@ qingflow-skills install --agent codex --scope user
|
|
|
62
62
|
如果你通过一次性 `npx -p` 执行 skills 安装,建议加 `--copy`,避免 symlink 指向 npm 临时执行缓存:
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
npx -y -p @qingflow-tech/qingflow-cli@1.1.
|
|
65
|
+
npx -y -p @qingflow-tech/qingflow-cli@1.1.62 qingflow-skills install --agent codex --scope user --copy
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
`qingflow-skills install` 默认使用 symlink,且遇到同名 skill 不会覆盖;只有显式传入 `--force` 才会替换。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qingflow-tech/qingflow-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.62",
|
|
4
4
|
"description": "Human-friendly Qingflow command line interface for auth, record operations, import, tasks, and stable builder flows.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/pyproject.toml
CHANGED
|
@@ -3,9 +3,6 @@ name: qingflow-cli
|
|
|
3
3
|
description: |
|
|
4
4
|
【强制】在执行或编排任何 qingflow CLI 命令前必须优先加载本 Skill。
|
|
5
5
|
Qingflow CLI 主入口:规定命令执行与 JSON 落盘方式,并把普通应用数据默认路由到 data;task、builder、import、日志、附件和代码块按专项参考执行。
|
|
6
|
-
Qingflow CLI 包以本 Skill 作为 CLI 主入口;record/app-builder/task/workflow 等相关说明按场景组织在 reference 子目录。
|
|
7
|
-
指导安装、执行上下文失败恢复、查询与写入;规定 task/record/import/builder 查询落盘;覆盖普通成员读数、字段 kind 与数据形态、任务上下文、批量导入、record access/list/get/insert/update/delete 与管理端边界。
|
|
8
|
-
Builder SOP 按智能体任务路径组织:完整系统、单应用、AppForm、视图、报表、门户、关联资源、流程、发布校验;表单字段、分组、布局和应用设置统一使用 versioned AppForm;按钮随视图 action_buttons 声明;更新动作并入对应资源文档,批量读/批量写/局部改依各资源契约执行;视图 apply 每次仅处理一个视图的一种操作,不支持批量创建或混合操作;明细见「关联文件」表与文末命令索引。
|
|
9
6
|
---
|
|
10
7
|
|
|
11
8
|
# Qingflow CLI 使用技能
|
|
@@ -16,43 +13,8 @@ description: |
|
|
|
16
13
|
|
|
17
14
|
首次解析 `data query/get` 响应前,阅读 [data 响应结构与解析](./reference/data/README.md#响应结构与解析),按同次响应中的 schema 与记录结构读取目标字段。
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
| 文件 | 说明 |
|
|
23
|
-
| ------------------------------------------------------------------------------------------------ |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
24
|
-
| `manifest.yaml` | 技能清单 |
|
|
25
|
-
| [reference/00-INDEX.md](./reference/00-INDEX.md) | **总导航**:按用户目标选择 record / task / builder 文档;复杂任务先读 |
|
|
26
|
-
| [reference/QINGFLOW_CLI_MEMBER_CHEATSHEET.md](./reference/core/QINGFLOW_CLI_MEMBER_CHEATSHEET.md) | **普通成员**主线:最短路径、`view_id`、与管理命令的差异预期 |
|
|
27
|
-
| [reference/QINGFLOW_CLI_FIELD_DATA_TYPES.md](./reference/core/QINGFLOW_CLI_FIELD_DATA_TYPES.md) | **字段数据类型**:`record schema …` 的 `fields[]`(`field_id`、`title`、`kind`、`options`…);`record list/get/access` 与写入 payload 的形态对照 |
|
|
28
|
-
| [reference/QINGFLOW_CLI_DATA_RETRIEVAL_WORKFLOW.md](./reference/core/QINGFLOW_CLI_DATA_RETRIEVAL_WORKFLOW.md) | **普通应用数据读取**:`data query` 获取记录和 schema → 按需 `data get` 读取单条;附件下载见 [data 操作说明](./reference/data/README.md) |
|
|
29
|
-
| [reference/QINGFLOW_CLI_TASK_CONTEXT_WORKFLOW.md](./reference/task/QINGFLOW_CLI_TASK_CONTEXT_WORKFLOW.md) | **任务(待办已办)上下文 SOP**:`task list` → `task get` → `task log` → `task report` → `task action`;只把 `task_id` 作为主定位参数 |
|
|
30
|
-
| [reference/QINGFLOW_CLI_RECORD_IMPORT_WORKFLOW.md](./reference/record/QINGFLOW_CLI_RECORD_IMPORT_WORKFLOW.md) | **批量导入 SOP**:`app_get`(**`import_capability`**)→ `record_import_template_get` → `record_import_verify` →(可选)`record_import_repair_local` → `record_import_start` → `record_import_status_get`;CLI `import` / `record schema import` |
|
|
31
|
-
| [reference/builder/README.md](./reference/builder/README.md) | **Builder 总导航**:完整系统、单应用、字段、布局、视图、报表、门户、按钮/关联资源、流程、发布校验 |
|
|
32
|
-
| [reference/builder/10-build-single-app.md](./reference/builder/10-build-single-app.md) | **单应用搭建主入口**:一个应用端到端交付顺序 |
|
|
33
|
-
| [reference/builder/20-build-complete-system.md](./reference/builder/20-build-complete-system.md) | **完整系统/应用包主入口**:多应用、跨应用 relation、门户闭环 |
|
|
34
|
-
| [reference/builder/30-schema-fields.md](./reference/builder/30-schema-fields.md) | **字段 / schema**:字段类型、直觉别名、数据标题/封面、schema 创建与更新 |
|
|
35
|
-
| [reference/builder/40-layout.md](./reference/builder/40-layout.md) | **布局维护**:仅用于已有应用的分组、`rows` 矩阵、布局修复;新建应用布局写在 `form` 内 |
|
|
36
|
-
| [reference/builder/50-views.md](./reference/builder/50-views.md) | **视图**:先读 schema,一次写一个视图对象;查询面板和按钮约束见该文 |
|
|
37
|
-
| [reference/builder/60-charts.md](./reference/builder/60-charts.md) | **报表 / QingBI**:指标卡、图表、语义聚合、筛选、排序、更新 |
|
|
38
|
-
| [reference/builder/70-portal.md](./reference/builder/70-portal.md) | **门户**:标准工作台、业务入口、指标、图表、视图组件、发布 |
|
|
39
|
-
| [reference/builder/80-buttons-associated-resources.md](./reference/builder/80-buttons-associated-resources.md) | **关联资源 / 非主链路按钮维护**:关联视图/报表、`match_mappings`、上下文传参;按钮配置看视图文档 `action_buttons`;创建自定义按钮前先 `button get --button-text` 查重复用 |
|
|
40
|
-
| [reference/builder/90-workflow.md](./reference/builder/90-workflow.md) | **流程**:WorkflowSpec、`patch_nodes`、角色/成员、流程回读 |
|
|
41
|
-
| [reference/builder/99-publish-verify.md](./reference/builder/99-publish-verify.md) | **发布与回读**:`publish verify`、partial/readback 处理、最终汇报口径 |
|
|
42
|
-
| [reference/QINGFLOW_CLI_RECORD_CREATE_WORKFLOW.md](./reference/record/QINGFLOW_CLI_RECORD_CREATE_WORKFLOW.md) | **新建记录**:`record schema insert -> record insert --items-file`;成员/部门/关联优先自然语言输入;细节见 [record/insert](./reference/record/insert/README.md) |
|
|
43
|
-
| [reference/QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md](./reference/record/QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md) | **更新记录**:主链路是 `record get` → 智能体按 `fields[]` 组 key/value → **`record update`**;`record schema update` 仅用于失败后诊断可写字段/路径 |
|
|
44
|
-
| [reference/QINGFLOW_CLI_RECORD_DELETE_WORKFLOW.md](./reference/record/QINGFLOW_CLI_RECORD_DELETE_WORKFLOW.md) | **删除记录**:`record list/get` 精确定位 → `record delete --app-key --record-id --view-id system:*`;批量用 `--record-ids-file` |
|
|
45
|
-
| [reference/record/analysis/README.md](./reference/record/analysis/README.md) | **数据分析**:最终统计结论、分析报告、趋势/排名/比例/分布统一走 `data query --all --output csv -> Python/pandas` |
|
|
46
|
-
| [reference/builder/reference/app-delivery-sop.md](./reference/builder/reference/app-delivery-sop.md) | **底层交付参考**:历史完整 SOP、权限、系统列和工具细节;不是主入口 |
|
|
47
|
-
| [reference/builder/reference/workspace-icons.md](./reference/builder/reference/workspace-icons.md) | **图标参考**:`builder icon catalog`;新建应用包、应用、门户必须显式选择非 `template` 的 `icon + color` |
|
|
48
|
-
| [reference/builder/reference/match-rules.md](./reference/builder/reference/match-rules.md) | **统一筛选 / 条件写法**:`filters`、`visible_when`、QingBI 图表筛选、工作流条件、`match_mappings`、`field_mappings` 的 `operator/value` 规则 |
|
|
49
|
-
| [reference/builder/workflow/README.md](./reference/builder/workflow/README.md) | **工作流搭建**:已有应用的流程建模、节点配置、`builder flow apply` 与 `patch_nodes` |
|
|
50
|
-
| [reference/builder/code-integrations/README.md](./reference/builder/code-integrations/README.md) | **代码块 / Q-Linker 配置**:字段别名、绑定、输入字段插入和配置排障 |
|
|
51
|
-
| [reference/QINGFLOW_CLI_ADMIN_CHEATSHEET.md](./reference/core/QINGFLOW_CLI_ADMIN_CHEATSHEET.md) | **管理员**:检索、导入等与成员差异(主技能正文不展开) |
|
|
52
|
-
| [reference/QINGFLOW_CLI_EXPLORATION_REPORT.md](./reference/core/QINGFLOW_CLI_EXPLORATION_REPORT.md) | CLI 实测与 argparse/服务端对齐备忘 |
|
|
53
|
-
| [reference/QINGFLOW_CLI_ONE_SHOT_CHEATSHEET.md](./reference/core/QINGFLOW_CLI_ONE_SHOT_CHEATSHEET.md) | **可选**:全角色「一次可复制」分项模板;默认执行技能**不必**打开 |
|
|
54
|
-
| [scripts/find-app-by-keyword.py](./scripts/find-app-by-keyword.py) | **旧版 CLI 兼容脚本**:当 `app list --query` 不可用时,用 `app list` 本地解析;默认优先使用 `qingflow --json app list --query <关键词>` |
|
|
55
|
-
| [scripts/builder-package-from-app-list.py](./scripts/builder-package-from-app-list.py) | **旧版 CLI 兼容脚本**:当 `builder package list` 不可用时,才从 `app list` 曲线反查 **`package_name` / `resolve-id`**;新版默认直接用 `qingflow --json builder package list --query <关键词>` |
|
|
16
|
+
需要向用户交付业务页面入口时,遵循 [Qingflow Common](../qingflow-common/SKILL.md) 的链接规则。
|
|
17
|
+
|
|
56
18
|
## CLI 执行与 JSON 落盘
|
|
57
19
|
|
|
58
20
|
1. 已知业务目标时直接执行目标命令,不固定前置 `auth whoami`、`workspace get` 或 `workspace select`。只有业务命令明确返回未登录、会话失效或工作区错误后,才恢复上下文并重试原命令。
|
|
@@ -105,70 +67,6 @@ echo "$QINGFLOW_CREDENTIAL" | qingflow --profile default auth use-credential \
|
|
|
105
67
|
qingflow --json data query --app-key APP_KEY > tmp/qingflow_data_query.json
|
|
106
68
|
```
|
|
107
69
|
|
|
108
|
-
常用参数:`--credential-stdin`、`--password-stdin`、`--persist` / `--forget-persisted`;详见 `qingflow auth --help`。
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## 输出落盘规则(task / record / import / builder 查询类)
|
|
113
|
-
|
|
114
|
-
以下 **必须** 将标准输出重定向到文件(如 `tmp/qingflow_*.json`),**禁止**把终端大 JSON 直接交给 LLM;后续用读文件 / 脚本处理。
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
| 子系统 | 必须落盘的子命令 |
|
|
118
|
-
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
119
|
-
| **task** | `list`、`get`、`log`、`report` |
|
|
120
|
-
| **import** | `template`、`verify`、`repair`、`start`、`status`(**`verify` / `start` 链依赖本机 `~/.qingflow-mcp` 校验/任务落盘,自动化须开放写权限**) |
|
|
121
|
-
| **builder** | **`app get`(summary/app map、fields、layout、views、flow、charts;summary 含 `custom_buttons` / `associated_resources`)**、`contract`、`app-form schema/get/validate/apply`;以及 **`views schema/get/validate/apply` / `button apply` / `associated-resource apply` / `flow apply` / `charts apply` / `portal apply` / `portal delete` / `publish verify` / `package apply`** 等大 JSON 响应 |
|
|
122
|
-
| **record** | `list`、`get`、`logs`、`access`、`schema browse`;以及 `schema insert` / `schema update` / `schema import` / `schema code-block` 等大体积 schema 子命令(体量大时同上);**创建前列字段时用 `schema insert` / `record_insert_schema_get` 同上**;**写操作 `insert` / `update` 响应体大时同样建议落盘** |
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
**规则摘要**
|
|
126
|
-
|
|
127
|
-
- 重定向示例:`qingflow --json record list … > tmp/qingflow_records.json`
|
|
128
|
-
- 线上真实测试、子智能体并行任务、批量 `--*-file` 入参优先使用**绝对路径**,或在命令前固定确认 `pwd`;不要假设子智能体当前目录与主线程一致。
|
|
129
|
-
- `auth`、`workspace`、`app`、`portal`、`view`、**非上述列出的**等,可直接终端查看或按需落盘。
|
|
130
|
-
- 错误在使用 **`--json`** 时多在 **stdout** 的 JSON 信封里;stderr 多为 argparse usage。
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## 应用数据:查询与读取(默认路径)
|
|
135
|
-
|
|
136
|
-
已知 `app_key` 时直接执行 `qingflow --json data query --app-key <APP_KEY>`;首次查询保留默认 schema,根据响应中的 `field_capabilities` 和 `hints` 决定筛选、分页或停止。定位到 `record_id` 后,按需执行 `qingflow --json data get --app-key <APP_KEY> --record-id <RECORD_ID>`;下载附件时加 `--download-attachments`。
|
|
137
|
-
|
|
138
|
-
参数与附件处理见 [data 操作说明](./reference/data/README.md)。详情页引用、关联资源和完整日志见 [record 专项参考](./reference/record/QINGFLOW_CLI_RECORD_SPECIALIZED_WORKFLOW.md);最终统计结论按 [数据分析说明](./reference/record/analysis/README.md) 使用 `data query --all --output csv`。
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## 应用记录:创建记录工作流(申请节点 → 写入)
|
|
143
|
-
|
|
144
|
-
推荐顺序:
|
|
145
|
-
|
|
146
|
-
1. **`record schema insert`**:先读取 insert-ready schema、`required_fields`、`payload_template`、`format_hint`、`example_value`、联动与运行时必填提示。
|
|
147
|
-
2. **`record insert --items-file`**:单条也是 `items` 数组的一行;成员、部门、关联字段优先写自然语言(如 `"张三"`、`"直销部"`、`"海军军医大学"`),仅在返回 `needs_confirmation` 时再让用户确认候选。
|
|
148
|
-
3. **写后读回**:单条重要数据用 `record get`,批量样本用 `record list` 或业务视图校验;`partial_success` 只重试失败行,不重放全批。
|
|
149
|
-
|
|
150
|
-
**细则、字段 JSON 结构与排障**见 **[reference/QINGFLOW_CLI_RECORD_CREATE_WORKFLOW.md](./reference/record/QINGFLOW_CLI_RECORD_CREATE_WORKFLOW.md)**。
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
## 应用记录:更新记录工作流(详情 → 写入)
|
|
155
|
-
|
|
156
|
-
主链路是先读详情,再直接提交用户要求修改的 key/value。不要把 `record schema update` 当成更新前置步骤:
|
|
157
|
-
|
|
158
|
-
1. **`record get`** → 拿 **`record_id`、当前值、fields[].title / field_id / kind**;已知前端/自定义视图时必须带同一个 **`--view-id`**。未知时 CLI 会先试默认 `system:all`,权限拒绝后再尝试可访问视图,但智能体仍优先从 `app get.accessible_views` 取 view。
|
|
159
|
-
2. 智能体根据 `record get.fields[]` 和用户要求,组一个只包含待改字段的 JSON 对象(标题 → 值)。字段必须来自当前详情上下文的 `fields[]`;带 `--view-id` 时,视图隐藏的字段不要强写。若用户要求改的字段不在当前 `record get.fields[]`,先换到包含该字段的视图/详情上下文,或用 `record schema update` 做失败诊断。
|
|
160
|
-
3. **`record update`** → **`--record-id` + `--fields-file`**,已知前端视图时同样带 **`--view-id`** 让 CLI 优先走该 view;批量用 **`--items-file`**(**`--dry-run` 仅批量**)。
|
|
161
|
-
4. 只有字段范围不清、候选歧义、或 `record update` 失败时,才用 **`record schema update`** 诊断本条记录的 **`writable_fields / payload_template / available_update_routes`**;已知前端视图时同样带 **`--view-id`**,让诊断优先探测同一个详情页上下文。
|
|
162
|
-
|
|
163
|
-
**更新路径**:`record update` 会自动先尝试数据管理员直改,再 fallback 到前端同源的 custom view 详情编辑路径;如果当前用户存在这条记录的唯一待办且目标字段在当前节点可编辑,最后会尝试 workflow save-only。成功时只需要读 **`status / update_route / verification_status`**;失败时再读失败原因与路线诊断。不要把中间 route 或辅助 schema/readback 探测的 40002 / 40027 / 404 当作最终失败。
|
|
164
|
-
|
|
165
|
-
**大号 `record_id`(常见于 Snowflake 类 id)**:若干 CLI 版本在 **`record update` 写入路径**上对 `apply_id` 会做 **JavaScript 安全整数**相关校验,`list`/`get`/`schema update` 仍可能正常而 **更新落库报错**(常为 `apply_id must be positive`)。排障见 **[reference/QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md](./reference/record/QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md)**。业务统计与最终结论仍必须按 **[record/analysis](./reference/record/analysis/README.md)** 使用 `data query --all --output csv -> Python/pandas`。
|
|
166
|
-
|
|
167
|
-
**命令模板、批量 `items` 形态、与新建相同的写入值约定**(按 **`kind`** 分题型见 **[QINGFLOW_CLI_FIELD_DATA_TYPES.md](./reference/core/QINGFLOW_CLI_FIELD_DATA_TYPES.md)**)见 **[reference/QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md](./reference/record/QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md)**。
|
|
168
|
-
|
|
169
|
-
**成员 / 部门候选排障**:若成员、部门字段返回 `needs_confirmation` 或候选不清,使用 `qingflow record member-candidates` / `qingflow record department-candidates`;它们优先走表单字段候选范围接口(与前端选择器一致)。不要改用通讯录管理类查询去“补候选”,那会把普通成员误带到 ContactAuth 管理权限链路。
|
|
170
|
-
|
|
171
|
-
**部门名筛选 / 写入**:`record list/access/analyze/insert/update` 遇到部门字段时可直接传部门名或候选对象;CLI 会优先走成员可见的目录搜索解析部门。不要先用通讯录管理接口查询部门 id,否则普通成员容易被 ContactAuth 错误阻挡。
|
|
172
70
|
### 字段筛选
|
|
173
71
|
|
|
174
72
|
先运行一次不带 `columns` 的 query,从返回的 `schema` 与递归 `field_capabilities` 准确定位 `field_id`,并确认该字段暴露的 `filter_operators` 与 `value_shape`。再写筛选文件:
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
```bash
|
|
6
6
|
qingflow --json builder portal get --dash-key DASH_KEY --schema-kind complete > portal.json # 更新前先读
|
|
7
7
|
qingflow --json builder portal validate --file portal.json # 零后端离线校验
|
|
8
|
-
qingflow builder portal apply --file portal.json --schema-version v1alpha1 [--dash-key DASH_KEY]
|
|
8
|
+
qingflow builder portal apply --file portal.json --schema-version v1alpha1 [--dash-key DASH_KEY]
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
契约与九类组件专项 Schema:`qingflow --json builder portal schema --schema-kind complete|<类型>`。
|
|
@@ -24,7 +24,7 @@ portal list/get if updating -> verify apps/views and read chart lists only when
|
|
|
24
24
|
- Read the contract itself: `qingflow --json builder portal schema --schema-kind summary|complete|<component>`; every component type (`chart|view|grid|filter|text|link|carousel|task|favourite`) has a self-contained schema — fetch it before guessing config keys.
|
|
25
25
|
- `builder portal get` defaults to `--schema-kind summary` and returns a canonical `declaration` (the round-trip anchor for replay tooling). Use `--schema-kind raw` for the legacy normalized response and `--schema-kind complete` for the full declaration.
|
|
26
26
|
- Offline validation: `qingflow --json builder portal validate --file decl.json` (accepts `-` for stdin; zero backend calls). Fix issues before applying.
|
|
27
|
-
- Apply main form: `qingflow builder portal apply --file decl.json --schema-version v1alpha1
|
|
27
|
+
- Apply main form: `qingflow builder portal apply --file decl.json --schema-version v1alpha1` (apply always publishes automatically; there is no draft-only mode). Legacy patch parameters (`--sections-file`, `--visibility-file`, ...) still work in a compatibility window but emit a deprecation notice; do not use them in new automations. `--payload-file` (raw DTO passthrough) is legacy-only.
|
|
28
28
|
|
|
29
29
|
## Demo files
|
|
30
30
|
|
|
@@ -79,7 +79,7 @@ Recommended standard workbench skeleton:
|
|
|
79
79
|
|
|
80
80
|
## Update existing portal
|
|
81
81
|
|
|
82
|
-
- Prefer the declaration-file form: `builder portal apply --file decl.json --schema-version v1alpha1 --dash-key K
|
|
82
|
+
- Prefer the declaration-file form: `builder portal apply --file decl.json --schema-version v1alpha1 --dash-key K` (the file may omit `dash_key` and pass it via `--dash-key`; do not send `package_id` for updates; apply publishes automatically).
|
|
83
83
|
- Read the current declaration first with `builder portal get --dash-key K --schema-kind complete`, edit it, `builder portal validate --file`, then apply. `sections` is full-replace semantics.
|
|
84
84
|
- `patch_sections[]` (via `--patch-sections-file`, compatibility window) remains for targeted section changes when a full declaration round-trip is not practical.
|
|
85
85
|
- `patch_sections[]` selectors may use `order`, `chart_ref.chart_id`, `chart_ref.chart_key`, or `view_ref.view_key`; chart sections read back from portal often only include `chart_id`, so patching by `chart_id` is valid and does not require `app_key`.
|
|
@@ -90,7 +90,7 @@ Recommended standard workbench skeleton:
|
|
|
90
90
|
|
|
91
91
|
搭建侧稳定入口:**`qingflow builder portal`**:`list` / `get` / **`apply`** / **`delete`**(与根命令 **`qingflow portal`** 的「成员可读列表/详情」不同,见 **[QINGFLOW_CLI_EXPLORATION_REPORT.md](../core/QINGFLOW_CLI_EXPLORATION_REPORT.md) §4.6**)。
|
|
92
92
|
|
|
93
|
-
实现要点来自 CLI 打包内的 `builder_facade/models.py`(`PortalApplyRequest`、`PortalSectionPatch`)、`builder_facade/service.py`(`portal_apply` / `portal_delete`)、`cli/commands/builder.py`。已对 **`package_id=2030703`**、应用 **`ead8ims5i401`**
|
|
93
|
+
实现要点来自 CLI 打包内的 `builder_facade/models.py`(`PortalApplyRequest`、`PortalSectionPatch`)、`builder_facade/service.py`(`portal_apply` / `portal_delete`)、`cli/commands/builder.py`。已对 **`package_id=2030703`**、应用 **`ead8ims5i401`** **实跑**:**新建**、**更新**(网关 **503** 恢复后已重试成功;历史记录中的 `--publish/--no-publish` flag 已移除,apply 一律发布)、**五类区块可稳定落库**;**`filter` 声明式写入受控支持(rules 非空,历史「不落库」实测为空规则读面不可见,见 §3.4)**。另已对测试包 **`1414907`** 实跑 **`portal delete`**:临时门户 **`etcivtmv5402`** 删除后回读 **`readback_status=deleted`**。
|
|
94
94
|
|
|
95
95
|
> **权限**:**更新**需 **`edit_portal`**;**新建**按后端 `DashCtrl.createDash` 链路只预检目标包 **`add_app`**,不额外要求包 **`edit_app`**。失败时参见主技能与 **ADMIN** 速查。
|
|
96
96
|
|
|
@@ -123,7 +123,6 @@ qingflow --json builder portal get --dash-key "<DASH_KEY>" --no-being-draft
|
|
|
123
123
|
|
|
124
124
|
| 参数 | 说明 |
|
|
125
125
|
|------|------|
|
|
126
|
-
| **`--publish` / `--no-publish`** | 默认 **`--publish`**。仅 **`--no-publish`** 时不会调用发布接口;契约说明 **`publish=false` 不宣称线上已变**。 |
|
|
127
126
|
| **`--file`**(主形态) | 完整门户声明 JSON 对象(支持 **`-`** stdin);与 patch 参数互斥;声明内可带 **`schema_version`**。 |
|
|
128
127
|
| **`--schema-version`** | 固定声明契约版本(缺省读文件内 `schema_version`,再缺省 latest)。传入时声明先过 complete schema 离线校验,**`INVALID_SPEC` 不写**。 |
|
|
129
128
|
| **`--payload-file`**(旧) | 完整门户 JSON 对象透传(兼容窗口);新代码改用 **`--file`**。标准字段写 `dash_name`。 |
|
|
@@ -334,9 +333,9 @@ CLI 校验(`PortalSectionPatch`):**chart** 须 **`chart`** 或 **`chart_re
|
|
|
334
333
|
|
|
335
334
|
---
|
|
336
335
|
|
|
337
|
-
## 5.
|
|
336
|
+
## 5. 新建最小例
|
|
338
337
|
|
|
339
|
-
见上文 **§2** 与 **`visibility`** 最小对象;**`sections`** 可先用 **单块 `view
|
|
338
|
+
见上文 **§2** 与 **`visibility`** 最小对象;**`sections`** 可先用 **单块 `view`**。apply 一律自动发布,成功后拿 **`dash_key`** 直接迭代更新。
|
|
340
339
|
|
|
341
340
|
---
|
|
342
341
|
|
|
@@ -361,9 +360,9 @@ qingflow --json builder portal delete --dash-key "<DASH_KEY>" > tmp/builder_port
|
|
|
361
360
|
|
|
362
361
|
---
|
|
363
362
|
|
|
364
|
-
## 8.
|
|
363
|
+
## 8. **发布**(apply 一律发布)
|
|
365
364
|
|
|
366
|
-
-
|
|
365
|
+
- **不存在「不发布」场景**:`portal apply` 写后**总是自动发布**并回读线上态(`--publish/--no-publish` flag 与声明内 `publish` 字段均已移除;声明里写 `publish: false` 会被明确拒绝)。门户不会停留在草稿-only 状态,也不会出现「apply 成功但工作台导航看不到」的情况。
|
|
367
366
|
- **已发布线索**:成功路径上 **`published: true`**;**`live_result.publishStatus`** 常见 **`2`** 表示已发布(以你环境枚举为准)。
|
|
368
367
|
- **`partial_success` + `PORTAL_READBACK_PENDING`**:草稿/线上 **组件数量或元数据** 与「本次期望」不一致时会出现;**`PORTAL_*_VERIFICATION_INCOMPLETE`** 警告。应 **`builder portal get --dash-key …`**(草稿与 **`--no-being-draft` 线上**)**肉眼核对**区块是否齐全,而不是仅信 **`verified: true`**。
|
|
369
368
|
- **网关 503**:**与 CLI 无关**;环境恢复后重试 **`portal get` / `portal apply`**。(本轮在网关恢复后 **`portal apply` 已成功**。)
|
|
@@ -374,10 +373,10 @@ qingflow --json builder portal delete --dash-key "<DASH_KEY>" > tmp/builder_port
|
|
|
374
373
|
|
|
375
374
|
| 步骤 | 命令要点 | 结果 |
|
|
376
375
|
|------|-----------|------|
|
|
377
|
-
| 新建门户 | `--package-id 2030703`、`--dash-name "CLI门户探针_可删"
|
|
378
|
-
| 503 后重试 | **`--dash-key ecdcell64s02
|
|
376
|
+
| 新建门户 | `--package-id 2030703`、`--dash-name "CLI门户探针_可删"`、单 **view**(历史记录,当时带 `--no-publish`;该 flag 已移除) | **`dash_key`: `ecdcell64s02`** |
|
|
377
|
+
| 503 后重试 | **`--dash-key ecdcell64s02`** + 含 **filter** 的六类 **`sections-file`**(历史记录) | **`published: true`**;当时 filter 组合全部**空 rules** → 读面不可见(**§3.4** 机制,非后端拒绝;现空 rules 已被模型层阻断) |
|
|
379
378
|
| **filter 专项** | 仅 **chart + filter** 两块的多种 **`graphList`/`graphRef`/`dashChartId`/`filterGroupConfig`** 组合(历史记录,全部空 rules) | **回读恒为 1 块(仅 `type: 9`)**——空规则读面不可见;含 rules 的声明式写入已由 ws40013 基准验证 |
|
|
380
|
-
| **稳定可复现** |
|
|
379
|
+
| **稳定可复现** | **[portal_sections_five_types.example.json](../examples/portal/portal_sections_five_types.example.json)**(**grid / text / link / view / chart**) | **`status: success`**,**`types: [2,4,5,9,10]`**,**`published: true`** |
|
|
381
380
|
| 删除门户 | `builder portal delete --dash-key etcivtmv5402` | **`status: success`**,**`delete_executed: true`**,**`readback_status: deleted`**,**`summary.removed: 1`** |
|
|
382
381
|
|
|
383
382
|
**推荐工作台模板示例**:[portal_sections_standard_workbench.example.json](../examples/portal/portal_sections_standard_workbench.example.json)。正式业务门户优先复制这个文件的行布局。
|
|
@@ -15655,8 +15655,8 @@ class AiBuilderFacade:
|
|
|
15655
15655
|
draft_result = {}
|
|
15656
15656
|
else:
|
|
15657
15657
|
portal_draft_readback_ms = _duration_ms(portal_draft_readback_started_at)
|
|
15658
|
-
except
|
|
15659
|
-
api_error = _coerce_api_error(error) if
|
|
15658
|
+
except Exception as error: # noqa: BLE001 — 任何失败都必须走清壳路径,不允许异常击穿留下半成品
|
|
15659
|
+
api_error = _coerce_api_error(error) if isinstance(error, (QingflowApiError, RuntimeError)) else None
|
|
15660
15660
|
inline_chart_write_executed = any(bool(item.get("write_executed")) for item in inline_chart_results)
|
|
15661
15661
|
# 本次 apply 创建的空壳回收:创建成功但 sections 未写入且无内联图表写入时,
|
|
15662
15662
|
# 删除刚建的门户壳,阻断「失败重试 → 0 组件空门户堆积」(实测反馈 3 个空壳)。
|
|
@@ -16891,6 +16891,22 @@ class AiBuilderFacade:
|
|
|
16891
16891
|
},
|
|
16892
16892
|
)
|
|
16893
16893
|
)
|
|
16894
|
+
except Exception as error: # noqa: BLE001
|
|
16895
|
+
# 工作线程的任何未预期异常(含并发 session 刷新竞态的
|
|
16896
|
+
# KeyError)都不得击穿整个 portal apply——否则门户壳已创建
|
|
16897
|
+
# 而组件未写入,清理逻辑也无从执行(实测空壳残留路径)。
|
|
16898
|
+
inline_chart_job_results.append(
|
|
16899
|
+
(
|
|
16900
|
+
job,
|
|
16901
|
+
{
|
|
16902
|
+
"status": "failed",
|
|
16903
|
+
"error_code": "PORTAL_INLINE_CHART_APPLY_FAILED",
|
|
16904
|
+
"message": f"{type(error).__name__}: {error}",
|
|
16905
|
+
"write_executed": False,
|
|
16906
|
+
"details": {"unexpected_error": True},
|
|
16907
|
+
},
|
|
16908
|
+
)
|
|
16909
|
+
)
|
|
16894
16910
|
|
|
16895
16911
|
for job, chart_apply in sorted(inline_chart_job_results, key=lambda item: int(item[0].get("section_index") or 0)):
|
|
16896
16912
|
app_key = str(job["app_key"])
|
|
@@ -31178,14 +31194,6 @@ def _build_view_update_payload(
|
|
|
31178
31194
|
payload["viewgraphType"] = "calendarView"
|
|
31179
31195
|
payload["beingShowTitleQue"] = True
|
|
31180
31196
|
payload.pop("groupQueId", None)
|
|
31181
|
-
elif normalized_type == "hierarchy":
|
|
31182
|
-
payload["viewgraphType"] = "hierarchyView"
|
|
31183
|
-
payload["beingShowTitleQue"] = True
|
|
31184
|
-
payload.pop("groupQueId", None)
|
|
31185
|
-
elif normalized_type == "calendar":
|
|
31186
|
-
payload["viewgraphType"] = "calendarView"
|
|
31187
|
-
payload["beingShowTitleQue"] = True
|
|
31188
|
-
payload.pop("groupQueId", None)
|
|
31189
31197
|
return _hydrate_view_backend_payload(
|
|
31190
31198
|
payload=payload,
|
|
31191
31199
|
view_type=normalized_type,
|
|
@@ -7,22 +7,11 @@ import sys
|
|
|
7
7
|
from typing import Any, Callable, TextIO
|
|
8
8
|
|
|
9
9
|
from ..errors import QingflowApiError, backend_code_value_int, message_looks_like_invalid_token
|
|
10
|
-
from ..public_surface import
|
|
11
|
-
NON_TOOL_CLI_HANDLER_ROUTES,
|
|
12
|
-
cli_public_tool_spec_from_namespace,
|
|
13
|
-
cli_route_from_namespace,
|
|
14
|
-
cli_trim_key_from_namespace,
|
|
15
|
-
)
|
|
10
|
+
from ..public_surface import cli_public_tool_spec_from_namespace
|
|
16
11
|
from ..resource_uri import cli_resource_base_url
|
|
17
12
|
from ..response_trim import resolve_cli_tool_name, trim_error_response, trim_public_response
|
|
18
13
|
from ..tools.ai_builder_tools import _attach_builder_apply_envelope
|
|
19
14
|
from ..version import get_cli_version, get_cli_version_info
|
|
20
|
-
from ..tool_policy import (
|
|
21
|
-
TOOL_POLICY_ENV,
|
|
22
|
-
TOOL_POLICY_INVALID,
|
|
23
|
-
ToolPolicyViolation,
|
|
24
|
-
parse_tool_policy,
|
|
25
|
-
)
|
|
26
15
|
from .context import CliContext, build_cli_context
|
|
27
16
|
from .formatters import emit_json_result, emit_text_result
|
|
28
17
|
from .commands import register_all_commands
|
|
@@ -101,14 +90,6 @@ def run(
|
|
|
101
90
|
if handler is None:
|
|
102
91
|
parser.print_help(out)
|
|
103
92
|
return 2
|
|
104
|
-
violation = _cli_tool_policy_violation(args)
|
|
105
|
-
if violation is not None:
|
|
106
|
-
return _emit_error(
|
|
107
|
-
violation.payload(),
|
|
108
|
-
json_mode=bool(args.json),
|
|
109
|
-
stdout=out,
|
|
110
|
-
stderr=err,
|
|
111
|
-
)
|
|
112
93
|
try:
|
|
113
94
|
if _should_force_json_output(args):
|
|
114
95
|
setattr(args, "json", True)
|
|
@@ -141,20 +122,6 @@ def run(
|
|
|
141
122
|
return exit_code
|
|
142
123
|
|
|
143
124
|
|
|
144
|
-
def _cli_tool_policy_violation(args: argparse.Namespace) -> ToolPolicyViolation | None:
|
|
145
|
-
stable_id = cli_trim_key_from_namespace(args)
|
|
146
|
-
if stable_id is None:
|
|
147
|
-
# 仅显式登记的非业务分发器可跳过闸门;无子命令的新增 handler 也必须默认拒绝。
|
|
148
|
-
if cli_route_from_namespace(args) in NON_TOOL_CLI_HANDLER_ROUTES:
|
|
149
|
-
return None
|
|
150
|
-
return ToolPolicyViolation(
|
|
151
|
-
TOOL_POLICY_INVALID,
|
|
152
|
-
"user:unregistered",
|
|
153
|
-
"CLI 业务命令未登记稳定工具 ID",
|
|
154
|
-
)
|
|
155
|
-
return parse_tool_policy(os.getenv(TOOL_POLICY_ENV)).violation_for(stable_id)
|
|
156
|
-
|
|
157
|
-
|
|
158
125
|
def _handle_version(_args: argparse.Namespace, _context: CliContext) -> dict[str, Any]:
|
|
159
126
|
info = get_cli_version_info()
|
|
160
127
|
return {
|
|
@@ -2,14 +2,11 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from contextvars import ContextVar
|
|
4
4
|
from dataclasses import dataclass, field
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import Callable
|
|
6
6
|
|
|
7
7
|
from .backend_client import BackendRequestContext
|
|
8
8
|
from .session_store import BackendSession, SessionProfile
|
|
9
9
|
|
|
10
|
-
if TYPE_CHECKING:
|
|
11
|
-
from .tool_policy import ToolPolicySnapshot
|
|
12
|
-
|
|
13
10
|
|
|
14
11
|
CLOUD_PROFILE_NAME = "__cloud_mcp__"
|
|
15
12
|
|
|
@@ -76,15 +73,3 @@ current_call_platform: ContextVar[str] = ContextVar(
|
|
|
76
73
|
"qingflow_mcp_current_call_platform",
|
|
77
74
|
default="",
|
|
78
75
|
)
|
|
79
|
-
|
|
80
|
-
# 远端 MCP 每个 HTTP 请求独立绑定策略原文;缺头用 None 表示,不回退进程环境变量。
|
|
81
|
-
current_tool_policy_header: ContextVar[str | None] = ContextVar(
|
|
82
|
-
"qingflow_mcp_current_tool_policy_header",
|
|
83
|
-
default=None,
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
# 在 HTTP 入口合成一次快照,列表与调用共用,避免将 URL 选择保存到会话或共享环境。
|
|
87
|
-
current_http_tool_policy: ContextVar[ToolPolicySnapshot | None] = ContextVar(
|
|
88
|
-
"qingflow_mcp_current_http_tool_policy",
|
|
89
|
-
default=None,
|
|
90
|
-
)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import argparse
|
|
4
3
|
from argparse import Namespace
|
|
5
4
|
from dataclasses import dataclass
|
|
6
5
|
|
|
@@ -110,7 +109,6 @@ USER_PUBLIC_TOOL_SPECS: tuple[PublicToolSpec, ...] = (
|
|
|
110
109
|
PublicToolSpec(USER_DOMAIN, "record_export_direct", ("record_export_direct",), ("export", "direct"), cli_show_effective_context=True),
|
|
111
110
|
PublicToolSpec(USER_DOMAIN, "record_code_block_run", ("record_code_block_run",), ("record", "code-block-run"), cli_show_effective_context=True, cli_context_write=True),
|
|
112
111
|
PublicToolSpec(USER_DOMAIN, "task_list", ("task_list",), ("task", "list"), cli_show_effective_context=True),
|
|
113
|
-
PublicToolSpec(USER_DOMAIN, "task_workbench", cli_route=("task",), mcp_public=False),
|
|
114
112
|
PublicToolSpec(USER_DOMAIN, "task_get", ("task_get",), ("task", "get"), cli_show_effective_context=True),
|
|
115
113
|
PublicToolSpec(USER_DOMAIN, "task_action_execute", ("task_action_execute",), ("task", "action"), cli_show_effective_context=True, cli_context_write=True),
|
|
116
114
|
PublicToolSpec(
|
|
@@ -132,12 +130,12 @@ USER_PUBLIC_TOOL_SPECS: tuple[PublicToolSpec, ...] = (
|
|
|
132
130
|
|
|
133
131
|
|
|
134
132
|
BUILDER_PUBLIC_TOOL_SPECS: tuple[PublicToolSpec, ...] = (
|
|
135
|
-
PublicToolSpec(BUILDER_DOMAIN, "auth_use_credential", ("auth_use_credential",), cli_public=False),
|
|
136
|
-
PublicToolSpec(BUILDER_DOMAIN, "auth_whoami", ("auth_whoami",), cli_public=False),
|
|
137
|
-
PublicToolSpec(BUILDER_DOMAIN, "auth_logout", ("auth_logout",), cli_public=False),
|
|
133
|
+
PublicToolSpec(BUILDER_DOMAIN, "auth_use_credential", ("auth_use_credential",), ("builder", "auth", "use-credential"), cli_public=False),
|
|
134
|
+
PublicToolSpec(BUILDER_DOMAIN, "auth_whoami", ("auth_whoami",), ("builder", "auth", "whoami"), cli_public=False),
|
|
135
|
+
PublicToolSpec(BUILDER_DOMAIN, "auth_logout", ("auth_logout",), ("builder", "auth", "logout"), cli_public=False),
|
|
138
136
|
PublicToolSpec(BUILDER_DOMAIN, "get_login_link", ("get_login_link",), mcp_public=True, cli_public=False),
|
|
139
|
-
PublicToolSpec(BUILDER_DOMAIN, "workspace_list", ("workspace_list",), cli_public=False),
|
|
140
|
-
PublicToolSpec(BUILDER_DOMAIN, "workspace_get", ("workspace_get",), cli_public=False),
|
|
137
|
+
PublicToolSpec(BUILDER_DOMAIN, "workspace_list", ("workspace_list",), ("builder", "workspace", "list"), cli_public=False),
|
|
138
|
+
PublicToolSpec(BUILDER_DOMAIN, "workspace_get", ("workspace_get",), ("builder", "workspace", "get"), cli_public=False),
|
|
141
139
|
PublicToolSpec(BUILDER_DOMAIN, "file_upload_local", ("file_upload_local",), ("builder", "file", "upload-local"), has_contract=True, cli_show_effective_context=True, cli_context_write=True),
|
|
142
140
|
PublicToolSpec(BUILDER_DOMAIN, "feedback_submit", ("feedback_submit",), ("builder", "feedback", "submit"), has_contract=True),
|
|
143
141
|
PublicToolSpec(BUILDER_DOMAIN, "builder_tool_contract", ("builder_tool_contract",), ("builder", "contract"), has_contract=False),
|
|
@@ -198,8 +196,7 @@ PUBLIC_TOOL_BY_KEY: dict[str, PublicToolSpec] = {spec.trim_key: spec for spec in
|
|
|
198
196
|
PUBLIC_TOOL_BY_CLI_ROUTE: dict[tuple[str, ...], PublicToolSpec] = {
|
|
199
197
|
spec.cli_route: spec
|
|
200
198
|
for spec in ALL_PUBLIC_TOOL_SPECS
|
|
201
|
-
|
|
202
|
-
if spec.cli_route is not None
|
|
199
|
+
if spec.cli_public and spec.cli_route is not None
|
|
203
200
|
}
|
|
204
201
|
PUBLIC_TOOL_BY_CLI_ROUTE.update(
|
|
205
202
|
{
|
|
@@ -210,9 +207,6 @@ PUBLIC_TOOL_BY_CLI_ROUTE.update(
|
|
|
210
207
|
}
|
|
211
208
|
)
|
|
212
209
|
|
|
213
|
-
# 这些 handler 只负责版本输出或参数迁移提示,不会发起轻流业务请求。
|
|
214
|
-
NON_TOOL_CLI_HANDLER_ROUTES = frozenset({("version",), ("record", "schema")})
|
|
215
|
-
|
|
216
210
|
|
|
217
211
|
def public_tool_specs(domain: str | None = None) -> tuple[PublicToolSpec, ...]:
|
|
218
212
|
if domain is None:
|
|
@@ -266,13 +260,11 @@ def cli_route_from_namespace(args: Namespace) -> tuple[str, ...] | None:
|
|
|
266
260
|
record_command = getattr(args, "record_command", None)
|
|
267
261
|
if record_command == "schema":
|
|
268
262
|
schema_command = getattr(args, "record_schema_command", None)
|
|
269
|
-
if isinstance(schema_command, str) and schema_command
|
|
270
|
-
return (command, "schema", schema_command)
|
|
271
|
-
return (command, "schema")
|
|
263
|
+
return (command, "schema", schema_command) if isinstance(schema_command, str) and schema_command else None
|
|
272
264
|
return (command, record_command) if isinstance(record_command, str) and record_command else None
|
|
273
265
|
if command == "task":
|
|
274
266
|
task_command = getattr(args, "task_command", None)
|
|
275
|
-
return (command, task_command) if isinstance(task_command, str) and task_command else
|
|
267
|
+
return (command, task_command) if isinstance(task_command, str) and task_command else None
|
|
276
268
|
if command != "builder":
|
|
277
269
|
child_attr = f"{command}_command"
|
|
278
270
|
child = getattr(args, child_attr, None)
|
|
@@ -293,54 +285,3 @@ def cli_route_from_namespace(args: Namespace) -> tuple[str, ...] | None:
|
|
|
293
285
|
child_attr = f"builder_{builder_command.replace('-', '_')}_command"
|
|
294
286
|
child = getattr(args, child_attr, None)
|
|
295
287
|
return ("builder", builder_command, child) if isinstance(child, str) and child else None
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
def discover_cli_handler_routes(
|
|
299
|
-
parser: argparse.ArgumentParser,
|
|
300
|
-
) -> dict[tuple[str, ...], tuple[str, ...]]:
|
|
301
|
-
"""从 argparse 实际 handler 树枚举规范化路由及其实现,包含中间交互入口。"""
|
|
302
|
-
discovered: dict[tuple[str, ...], set[str]] = {}
|
|
303
|
-
|
|
304
|
-
def walk(current: argparse.ArgumentParser, path: tuple[str, ...], inherited: dict[str, object]) -> None:
|
|
305
|
-
attrs = dict(inherited)
|
|
306
|
-
for action in current._actions:
|
|
307
|
-
if isinstance(action, argparse._SubParsersAction):
|
|
308
|
-
continue
|
|
309
|
-
if action.dest != argparse.SUPPRESS and action.default != argparse.SUPPRESS:
|
|
310
|
-
attrs.setdefault(action.dest, action.default)
|
|
311
|
-
attrs.update(current._defaults)
|
|
312
|
-
|
|
313
|
-
handler = current._defaults.get("handler")
|
|
314
|
-
if callable(handler):
|
|
315
|
-
variants = [attrs]
|
|
316
|
-
for action in current._actions:
|
|
317
|
-
if isinstance(action, argparse._SubParsersAction) or action.choices is None:
|
|
318
|
-
continue
|
|
319
|
-
variants.extend({**attrs, action.dest: choice} for choice in action.choices)
|
|
320
|
-
for variant in variants:
|
|
321
|
-
route = cli_route_from_namespace(Namespace(**variant))
|
|
322
|
-
if route is None:
|
|
323
|
-
route = _normalize_cli_parser_path(path)
|
|
324
|
-
if route:
|
|
325
|
-
identity = f"{handler.__module__}:{handler.__qualname__}"
|
|
326
|
-
discovered.setdefault(route, set()).add(identity)
|
|
327
|
-
|
|
328
|
-
for action in current._actions:
|
|
329
|
-
if not isinstance(action, argparse._SubParsersAction):
|
|
330
|
-
continue
|
|
331
|
-
for name, child in action.choices.items():
|
|
332
|
-
next_attrs = dict(attrs)
|
|
333
|
-
next_attrs[action.dest] = name
|
|
334
|
-
walk(child, path + (name,), next_attrs)
|
|
335
|
-
|
|
336
|
-
walk(parser, (), {})
|
|
337
|
-
return {route: tuple(sorted(handlers)) for route, handlers in discovered.items()}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
def _normalize_cli_parser_path(path: tuple[str, ...]) -> tuple[str, ...]:
|
|
341
|
-
normalized = list(path)
|
|
342
|
-
if normalized and normalized[0] == "build":
|
|
343
|
-
normalized[0] = "builder"
|
|
344
|
-
if len(normalized) > 1 and normalized[0] == "builder" and normalized[1] == "associated-resources":
|
|
345
|
-
normalized[1] = "associated-resource"
|
|
346
|
-
return tuple(normalized)
|
|
@@ -51,9 +51,8 @@ COMMON_ERROR_DROP_TOP = {
|
|
|
51
51
|
|
|
52
52
|
SUCCESS_POLICY_BY_TOOL: dict[str, TransformFn] = {}
|
|
53
53
|
|
|
54
|
-
#:
|
|
54
|
+
#: 这两个校验命令的产出契约明确包含 ok 字段(供阶段 2 SKILL.md 引用),
|
|
55
55
|
#: 需在 success 裁剪时保留 ok(默认 COMMON_SUCCESS_DROP_TOP 会丢弃 ok)。
|
|
56
|
-
#: `builder:app_views_validate`(views 声明式校验)同属校验类工具,ok 同样进产出契约。
|
|
57
56
|
_KEEP_OK_TOOLS = {
|
|
58
57
|
"builder:app_form_validate_formula",
|
|
59
58
|
"builder:app_form_validate_code_block",
|
|
@@ -2,6 +2,8 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from datetime import date
|
|
4
4
|
|
|
5
|
+
from mcp.server.fastmcp import FastMCP
|
|
6
|
+
|
|
5
7
|
from .backend_client import BackendClient
|
|
6
8
|
from .session_store import SessionStore
|
|
7
9
|
from .tools.app_tools import AppTools
|
|
@@ -24,11 +26,9 @@ from .tools.task_context_tools import TaskContextTools
|
|
|
24
26
|
from .tools.view_tools import ViewTools
|
|
25
27
|
from .tools.workflow_tools import WorkflowTools
|
|
26
28
|
from .tools.workspace_tools import WorkspaceTools
|
|
27
|
-
from .tool_catalog import stdio_server_bindings
|
|
28
|
-
from .tool_policy import PolicyAwareFastMCP, configure_tool_policy
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def _register_missing_builder_tools(server:
|
|
31
|
+
def _register_missing_builder_tools(server: FastMCP) -> None:
|
|
32
32
|
"""Add current high-level builder tools to the unified MCP without duplicate names."""
|
|
33
33
|
from .server_app_builder import build_builder_server
|
|
34
34
|
|
|
@@ -48,10 +48,10 @@ def _register_missing_builder_tools(server: PolicyAwareFastMCP) -> None:
|
|
|
48
48
|
)
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
def build_server() ->
|
|
51
|
+
def build_server() -> FastMCP:
|
|
52
52
|
today = date.today()
|
|
53
53
|
current_year = today.year
|
|
54
|
-
server =
|
|
54
|
+
server = FastMCP(
|
|
55
55
|
"Qingflow MCP",
|
|
56
56
|
instructions=f"""Use this unified server for Qingflow operational and builder workflows. Current date: `{today.isoformat()}`.
|
|
57
57
|
|
|
@@ -259,14 +259,8 @@ If the current MCP capability is unsupported, the workflow is awkward, or the us
|
|
|
259
259
|
WorkflowTools(sessions, backend).register(server)
|
|
260
260
|
ViewTools(sessions, backend).register(server)
|
|
261
261
|
SolutionTools(sessions, backend).register(server)
|
|
262
|
-
# 保存补齐 Builder 前的真实注册来源,裸名冲突只能绑定最终保留 callable 的来源域。
|
|
263
|
-
legacy_tool_names = set(server._tool_manager._tools)
|
|
264
262
|
_register_missing_builder_tools(server)
|
|
265
|
-
return
|
|
266
|
-
server,
|
|
267
|
-
stdio_server_bindings(legacy_tool_names, server._tool_manager._tools),
|
|
268
|
-
source="environment",
|
|
269
|
-
)
|
|
263
|
+
return server
|
|
270
264
|
|
|
271
265
|
|
|
272
266
|
mcp = build_server()
|