@qingflow-tech/qingflow-cli 1.1.59 → 1.1.61-beta.1
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 +4 -4
- package/npm/lib/runtime.mjs +29 -13
- package/package.json +1 -1
- package/pyproject.toml +3 -1
- package/skills/qingflow-cli/SKILL.md +92 -318
- package/skills/qingflow-cli/manifest.yaml +1 -1
- package/skills/qingflow-cli/reference/00-INDEX.md +4 -4
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_ADMIN_CHEATSHEET.md +1 -1
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_DATA_RETRIEVAL_WORKFLOW.md +3 -137
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_EXPLORATION_REPORT.md +6 -4
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_FIELD_DATA_TYPES.md +14 -14
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_MEMBER_CHEATSHEET.md +20 -19
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_ONE_SHOT_CHEATSHEET.md +18 -14
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_RECORD_CREATE_WORKFLOW.md +7 -12
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md +2 -1
- package/skills/qingflow-cli/reference/builder/20-build-complete-system.md +2 -2
- package/skills/qingflow-cli/reference/builder/30-schema-fields.md +9 -5
- package/skills/qingflow-cli/reference/builder/reference/app-delivery-sop.md +3 -3
- package/skills/qingflow-cli/reference/core/QINGFLOW_CLI_ADMIN_CHEATSHEET.md +1 -1
- package/skills/qingflow-cli/reference/core/QINGFLOW_CLI_DATA_RETRIEVAL_WORKFLOW.md +76 -95
- package/skills/qingflow-cli/reference/core/QINGFLOW_CLI_EXPLORATION_REPORT.md +6 -4
- package/skills/qingflow-cli/reference/core/QINGFLOW_CLI_FIELD_DATA_TYPES.md +13 -13
- package/skills/qingflow-cli/reference/core/QINGFLOW_CLI_MEMBER_CHEATSHEET.md +20 -19
- package/skills/qingflow-cli/reference/core/QINGFLOW_CLI_ONE_SHOT_CHEATSHEET.md +18 -14
- package/skills/qingflow-cli/reference/data/README.md +52 -0
- package/skills/qingflow-cli/reference/record/QINGFLOW_CLI_RECORD_SPECIALIZED_WORKFLOW.md +56 -0
- package/skills/qingflow-cli/reference/record/QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md +2 -1
- package/skills/qingflow-cli/reference/record/analysis/README.md +21 -113
- package/skills/qingflow-cli/reference/record/analysis/analysis-gotchas.md +10 -10
- package/skills/qingflow-cli/reference/record/analysis/analysis-patterns.md +9 -9
- package/skills/qingflow-cli/reference/record/analysis/business-context.md +1 -1
- package/skills/qingflow-cli/reference/record/analysis/confidence-reporting.md +10 -10
- package/skills/qingflow-cli/reference/record/analysis/data-access-playbook.md +52 -80
- package/skills/qingflow-cli/reference/record/analysis/pandas-recipes.md +2 -2
- package/skills/qingflow-common/SKILL.md +10 -4
- package/src/qingflow_mcp/app_form_compat.py +3 -0
- package/src/qingflow_mcp/app_form_validator.py +69 -17
- package/src/qingflow_mcp/backend_client.py +33 -8
- package/src/qingflow_mcp/builder_facade/app_form.py +497 -100
- package/src/qingflow_mcp/builder_facade/schemas/app_form/manifest.json +1 -0
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/complete.json +64 -30
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/address.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/amount.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/attachment.json +6 -10
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/code_block.json +6 -10
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/data_relation.json +11 -18
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/date.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/datetime.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/department.json +6 -10
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/email.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/link.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/long_text.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/member.json +6 -10
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/multi_select.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/number.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/phone.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/q_linker.json +6 -10
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/relation.json +46 -15
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/rich_text.json +146 -0
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/single_choice.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/single_select.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/subtable.json +61 -27
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/fields/text.json +4 -8
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/formula.json +43 -0
- package/src/qingflow_mcp/builder_facade/schemas/app_form/v1alpha1/summary.json +7 -12
- package/src/qingflow_mcp/builder_facade/service.py +39 -1
- package/src/qingflow_mcp/cli/commands/__init__.py +2 -1
- package/src/qingflow_mcp/cli/commands/data.py +144 -0
- package/src/qingflow_mcp/cli/commands/record.py +1 -1
- package/src/qingflow_mcp/cli/context.py +3 -0
- package/src/qingflow_mcp/cli/formatters.py +104 -1
- package/src/qingflow_mcp/public_surface.py +5 -0
- package/src/qingflow_mcp/response_trim.py +2 -1
- package/src/qingflow_mcp/server.py +3 -1
- package/src/qingflow_mcp/server_app_user.py +5 -1
- package/src/qingflow_mcp/tools/csv_export.py +168 -0
- package/src/qingflow_mcp/tools/data_files.py +174 -0
- package/src/qingflow_mcp/tools/data_tools.py +313 -0
- package/src/qingflow_mcp/tools/record_tools.py +25 -118
- package/src/qingflow_mcp/tools/storage_download.py +89 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Qingflow CLI:record 日志与附件参考
|
|
2
|
+
|
|
3
|
+
> **适用范围**:任务需要完整数据/流程日志、详情页引用和关联资源上下文,或用户指定 record 兼容入口时使用。普通应用数据查询使用 [`data query/get`](../core/QINGFLOW_CLI_DATA_RETRIEVAL_WORKFLOW.md),附件下载使用 [data 附件下载](../data/README.md#附件下载与读取)。
|
|
4
|
+
|
|
5
|
+
## record 查询链
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
app get(解析 accessible_views,选定 VIEW_ID)
|
|
9
|
+
→ record schema browse(读取该视图字段口径)
|
|
10
|
+
→ record list(样本浏览或模糊定位候选)
|
|
11
|
+
→ record get(可选:详情页首屏、附件与图片上下文)
|
|
12
|
+
→ record logs(可选:完整数据日志与流程日志)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 命令形状
|
|
16
|
+
|
|
17
|
+
普通记录附件下载使用 `data get --download-attachments`。以下 record 命令只用于详情页专项上下文或用户明确指定的兼容入口;不要把它们当作 data 权限错误的回退。
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
qingflow --json app get --app-key APP_KEY > tmp/qingflow_app_get.json
|
|
21
|
+
|
|
22
|
+
qingflow --json record schema browse \
|
|
23
|
+
--app-key APP_KEY --view-id VIEW_ID \
|
|
24
|
+
> tmp/qingflow_record_schema.json
|
|
25
|
+
|
|
26
|
+
qingflow --json record list \
|
|
27
|
+
--app-key APP_KEY --view-id VIEW_ID \
|
|
28
|
+
> tmp/qingflow_record_list.json
|
|
29
|
+
|
|
30
|
+
qingflow --json record get \
|
|
31
|
+
--app-key APP_KEY --record-id RECORD_ID --view-id VIEW_ID \
|
|
32
|
+
> tmp/qingflow_record_get.json
|
|
33
|
+
|
|
34
|
+
qingflow --json record logs \
|
|
35
|
+
--app-key APP_KEY --record-id RECORD_ID --view-id VIEW_ID \
|
|
36
|
+
> tmp/qingflow_record_logs.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`VIEW_ID` 只能来自 `app get.accessible_views`、已经确认的前端 URL 或用户明确提供的上下文。显式视图失败时不要自动换成另一系统视图。
|
|
40
|
+
|
|
41
|
+
## 专有结果
|
|
42
|
+
|
|
43
|
+
- `record get`:用于详情页字段、首屏日志、引用、关联资源、`media_assets` 和 `file_assets`。附件与图片优先使用返回的本地路径,不直接访问远端附件 URL。
|
|
44
|
+
- `record logs`:用于完整可见数据日志和流程日志。响应只读取摘要与 JSONL 文件路径,按需筛选本地文件,不把全文放入上下文。
|
|
45
|
+
- `record list`:只在用户明确指定该命令时用于样本浏览/模糊定位,不用于完整统计结论。
|
|
46
|
+
|
|
47
|
+
## 附件下载与读取
|
|
48
|
+
|
|
49
|
+
普通附件下载在 `data get --download-attachments` 中完成,参数、状态与预算见 [data 附件下载](../data/README.md#附件下载与读取)。如果用户明确使用 record 详情页兼容入口,继续使用其返回的本地资产;`extraction.status=unsupported` 不代表下载失败。
|
|
50
|
+
|
|
51
|
+
## 边界
|
|
52
|
+
|
|
53
|
+
- 统计分析仍转 `data query --all --output csv -> Python/pandas`。
|
|
54
|
+
- `CUSTOM_VIEW_LIST_UNAVAILABLE` 只说明自定义视图列表读取受限;不要据此断言应用整体不可读。
|
|
55
|
+
- 待办、已办和抄送属于 `task list --task-box ...`,不使用 `record list --view-id system:todo/done/cc`。
|
|
56
|
+
- 所有大 JSON、附件清单和日志摘要必须落盘。
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Qingflow CLI:更新记录工作流(详情后直接写入)
|
|
2
2
|
|
|
3
|
+
> **兼容范围**:本文仅限用户明确要求旧 CLI `record` 兼容入口时使用。默认更新必须切换到 [data 操作说明](../data/README.md) 的 `data get` → `data update`;禁止在 data update 失败后自动回退本文链路。
|
|
3
4
|
> **用途**:使用当前 CLI 会话读取目标记录详情后,用 **`record update`** 直接提交差异字段。主链路是 `record get -> record update`;字段范围不清、候选歧义或失败排查时,才追加 **`record schema update`**。
|
|
4
|
-
>
|
|
5
|
+
> **关联**:直接数据操作统一使用 [data 操作说明](../data/README.md);最终统计结论统一使用 **[record/analysis](./analysis/README.md) 的 `data query --all --output csv -> Python/pandas`**;主技能 **[../SKILL.md](../../SKILL.md)**。
|
|
5
6
|
|
|
6
7
|
---
|
|
7
8
|
|
|
@@ -1,130 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 轻流记录数据分析
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Default path, every time:
|
|
3
|
+
最终统计结论、分析报告、趋势、排名、比例和分布统一使用以下路径:
|
|
6
4
|
|
|
7
5
|
```text
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Use the CLI entry:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
qingflow record --help
|
|
15
|
-
qingflow record access --help
|
|
16
|
-
qingflow record access --app-key APP_KEY --view-id VIEW_ID --columns-file columns.json --where-file where.json --order-by-file order_by.json --json
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
The CLI command is under the `record` command group, so the discovery path is: first inspect `qingflow record --help`, then inspect `qingflow record access --help`.
|
|
20
|
-
|
|
21
|
-
## Hard Rules
|
|
22
|
-
|
|
23
|
-
- Never start analysis from `record_list`, export, QingBI, or guessed field ids.
|
|
24
|
-
- Never conclude `record_access` is unavailable just because it is not visible as a top-level MCP tool; check the CLI path `qingflow record access`.
|
|
25
|
-
- Never call `record access` before `record schema browse`.
|
|
26
|
-
- Use only field ids returned by `record schema browse`.
|
|
27
|
-
- If `app_get.accessible_views[].analysis_supported=false`, do not use that view for `record_access`.
|
|
28
|
-
- Prefer an explicit time range or business filter. If the user gives none and the table may be large, ask for scope or use a clearly provided month/quarter/year.
|
|
29
|
-
- Read every CSV shard in `record_access.files[].local_path` with Python. Do not print raw CSV or load raw rows into model context.
|
|
30
|
-
- Before final analysis, run a field-quality profile in pandas: row count, null rate, distinct count, and period coverage for candidate grouping fields.
|
|
31
|
-
- Do not use a high-missing field as the main conclusion dimension. If a candidate dimension is sparse, downgrade it to an `已填写样本观察` and choose a cleaner semantic fallback when available.
|
|
32
|
-
- Full final conclusions require `record_access.complete=true` and `record_access.safe_for_final_conclusion=true`.
|
|
33
|
-
- `record_list` is only for sample inspection after the aggregate result is understood.
|
|
34
|
-
- `record_get` is only for single-record detail verification, logs, references, images, or readable attachments. Read images from `media_assets.items[].local_path`; read documents/tables from `file_assets.items[].local_path` and `extraction.text_path`.
|
|
35
|
-
- `record_export_direct` is only for explicit export/download/Excel requests.
|
|
36
|
-
- `chart_get` / QingBI is only for user-provided report URLs or chart ids.
|
|
37
|
-
|
|
38
|
-
## Tool Selection
|
|
39
|
-
|
|
40
|
-
| Need | Tool |
|
|
41
|
-
|---|---|
|
|
42
|
-
| Batch analysis, statistics, comparison, report | `record access -> Python` |
|
|
43
|
-
| Browse a few example rows | `record_list` |
|
|
44
|
-
| Inspect one record, logs, references, images, attachments | `record_get` |
|
|
45
|
-
| User asks to export/download/Excel | `record_export_direct` |
|
|
46
|
-
| User gives report URL or chart id | `chart_get` |
|
|
47
|
-
| Todo/workflow task actions | `reference/task/QINGFLOW_CLI_TASK_CONTEXT_WORKFLOW.md` |
|
|
48
|
-
|
|
49
|
-
## Standard Procedure
|
|
50
|
-
|
|
51
|
-
1. Run `app get` and choose a table-style `view_id` from `accessible_views`.
|
|
52
|
-
2. Run `record schema browse --app-key APP_KEY --view-id VIEW_ID`.
|
|
53
|
-
3. Decide metric intent before fetching data: `count`, `sum`, `avg`, `distinct_count`, ratio, ranking, trend, or comparison.
|
|
54
|
-
4. Choose minimal `record_access.columns`, plus `where` and `order_by`.
|
|
55
|
-
5. Run `qingflow record access`.
|
|
56
|
-
6. Read all returned CSV files in Python; use `fields[]` only when field-id metadata is needed.
|
|
57
|
-
7. Run field-quality checks for all candidate dimensions.
|
|
58
|
-
8. Compute results in pandas.
|
|
59
|
-
9. Report numbers with scope, field choices, field-quality caveats, completeness, and business assumptions.
|
|
60
|
-
|
|
61
|
-
Use field-id DSLs only:
|
|
62
|
-
|
|
63
|
-
```json
|
|
64
|
-
{
|
|
65
|
-
"app_key": "APP_KEY",
|
|
66
|
-
"view_id": "system:all",
|
|
67
|
-
"columns": [{ "field_id": 2 }, { "field_id": 18 }],
|
|
68
|
-
"where": [{ "field_id": 2, "op": "between", "value": ["2026-05-01", "2026-05-31"] }],
|
|
69
|
-
"order_by": [{ "field_id": 2, "direction": "asc" }]
|
|
70
|
-
}
|
|
6
|
+
qingflow data query --all --output csv -> 读取全部 CSV 分片 -> Python/pandas
|
|
71
7
|
```
|
|
72
8
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
CSV columns are already readable and field-id anchored, for example `项目状态__field_343283094`. Do not expect separate `schema.json` or `README.md` files.
|
|
76
|
-
|
|
77
|
-
For CLI use, write JSON argument files instead of embedding large JSON in shell text:
|
|
9
|
+
先用当前 CLI 帮助确认参数:
|
|
78
10
|
|
|
79
11
|
```bash
|
|
80
|
-
qingflow
|
|
12
|
+
qingflow data --help
|
|
13
|
+
qingflow data query --help
|
|
14
|
+
qingflow --json data query \
|
|
81
15
|
--app-key APP_KEY \
|
|
82
|
-
--view-id system:all \
|
|
83
16
|
--columns-file columns.json \
|
|
84
17
|
--where-file where.json \
|
|
85
|
-
--
|
|
86
|
-
--
|
|
18
|
+
--sort-file sort.json \
|
|
19
|
+
--all --output csv
|
|
87
20
|
```
|
|
88
21
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Read `record_access.status` before reading files or writing conclusions.
|
|
92
|
-
|
|
93
|
-
- `status=success`, `complete=true`, `safe_for_final_conclusion=true`: full-scope answer is allowed.
|
|
94
|
-
- `status=needs_scope`: no CSV was written. Ask for a time/business range or retry with a user-provided period using `scope.suggested_time_fields`.
|
|
95
|
-
- `status=partial`: read returned files only as a subset. Do not give a full-population conclusion.
|
|
96
|
-
- `complete=false`, `truncated=true`, or `safe_for_final_conclusion=false`: answer as `初步观察` or ask for a narrower scope.
|
|
97
|
-
|
|
98
|
-
## Business Context
|
|
99
|
-
|
|
100
|
-
If the question mentions department, team, region, owner group, stage, product line, or a named business scope, check whether aliases or child scopes matter before concluding. Use explicit mappings provided by the user or local context; otherwise ask a short clarification.
|
|
101
|
-
|
|
102
|
-
Example: if `烈焰组` and `飓风组` are sub-departments of `北斗部门`, apply that mapping in Python and state it in the answer.
|
|
103
|
-
|
|
104
|
-
## Output Shape
|
|
105
|
-
|
|
106
|
-
Default to:
|
|
107
|
-
|
|
108
|
-
1. `结论`
|
|
109
|
-
2. `关键数据`
|
|
110
|
-
3. `口径与范围`
|
|
111
|
-
4. `可信度 / 限制`
|
|
112
|
-
|
|
113
|
-
Concrete numbers are mandatory. Ratios require both numerator and denominator. Trends require a time field and explicit date range. Rankings must come from a sorted pandas result.
|
|
114
|
-
If a requested dimension has poor quality, say so explicitly and provide the nearest reliable fallback dimension, for example platform or product instead of a mostly empty module field.
|
|
22
|
+
`--all` 与 `--output csv` 必须同时使用。columns 使用字段 id 数组;where 与 sort 使用包含 `field_id` 的对象数组。字段 id 来自当前 data schema 或已确认上下文,不得猜测。
|
|
115
23
|
|
|
116
|
-
##
|
|
24
|
+
## 分析门禁
|
|
117
25
|
|
|
118
|
-
|
|
26
|
+
- 读取返回摘要的 `status`、`row_count`、`complete`、`truncated`、`safe_for_final_conclusion`、`files` 和 `stopped_reason`。
|
|
27
|
+
- 用 Python/pandas 读取全部 `files[].local_path`,不要把原始 CSV 行打印到模型上下文。
|
|
28
|
+
- 完整总体结论必须同时满足 `complete=true`、`truncated=false`、`safe_for_final_conclusion=true`。
|
|
29
|
+
- `status=needs_scope` 时 `files` 为空;读取 `scope.reported_total` 与 `scope.row_threshold`,请求时间或业务范围后重试。
|
|
30
|
+
- `status=partial` 或任一完整性条件不满足时,只能给出局部观察,或收窄范围后重试。
|
|
31
|
+
- 最终分组前检查行数、空值率、唯一值数量与时间覆盖;高缺失维度只能作为“已填写样本观察”。
|
|
32
|
+
- `record list` 仅用于样本核查,不能代替全量 CSV;导出工具只用于用户明确要求下载文件的场景。
|
|
119
33
|
|
|
120
|
-
|
|
121
|
-
- Python/pandas templates: [references/pandas-recipes.md](./pandas-recipes.md)
|
|
122
|
-
- Analysis patterns: [references/analysis-patterns.md](./analysis-patterns.md)
|
|
123
|
-
- Business mappings and scope: [references/business-context.md](./business-context.md)
|
|
124
|
-
- Confidence and final wording: [references/confidence-reporting.md](./confidence-reporting.md)
|
|
125
|
-
- Common mistakes: [references/analysis-gotchas.md](./analysis-gotchas.md)
|
|
126
|
-
- Report templates: [references/report-format.md](./report-format.md)
|
|
34
|
+
## 输出要求
|
|
127
35
|
|
|
128
|
-
|
|
36
|
+
默认输出结论、关键数据、口径与范围、可信度/限制。比例必须包含分子与分母,趋势必须说明时间字段与日期范围,排名必须来自 pandas 显式排序。
|
|
129
37
|
|
|
130
|
-
|
|
38
|
+
进一步细节见同目录的取数状态机、pandas 模板、分析模式、业务上下文、可信度和报告模板。
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# Analysis Gotchas
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 不要猜字段 schema
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
正确路径:
|
|
6
6
|
|
|
7
|
-
1.
|
|
8
|
-
2. `
|
|
9
|
-
3. `
|
|
10
|
-
4. Python
|
|
7
|
+
1. 从当前 data schema 或已确认上下文选择字段 id
|
|
8
|
+
2. `data query --all --output csv`
|
|
9
|
+
3. 读取全部 `files[].local_path`
|
|
10
|
+
4. Python/pandas
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
data 工具返回的 schema、字段错误与访问范围是事实源;缺失字段不是猜测隐藏 id 的理由。
|
|
13
13
|
|
|
14
14
|
## Do Not Use Export For Analysis
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
导出工具只用于用户明确要求下载文件。分析使用 `data query --all --output csv`,因为它返回本地 CSV 分片与结构化完整性字段。
|
|
17
17
|
|
|
18
18
|
## Do Not Treat `record_list` As Full Data
|
|
19
19
|
|
|
@@ -28,7 +28,7 @@ Export tools are for user-requested files. Analysis uses `record_access` because
|
|
|
28
28
|
|
|
29
29
|
## Do Not Control Paging
|
|
30
30
|
|
|
31
|
-
`
|
|
31
|
+
`data query --all --output csv` 内部处理分页。
|
|
32
32
|
|
|
33
33
|
Do not invent:
|
|
34
34
|
|
|
@@ -84,7 +84,7 @@ For penetration, conversion, or share:
|
|
|
84
84
|
|
|
85
85
|
## Normalize Relative Dates
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
在 data query 前把相对日期转换为精确范围。
|
|
88
88
|
|
|
89
89
|
- `今年5月` -> exact May 1 to May 31 in the current year
|
|
90
90
|
- `去年同期` -> same date range in previous year
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Canonical Sequence
|
|
4
4
|
|
|
5
|
-
1. `
|
|
6
|
-
2.
|
|
7
|
-
3.
|
|
8
|
-
4.
|
|
9
|
-
5. `
|
|
10
|
-
6. Python
|
|
5
|
+
1. 明确 `app_key`
|
|
6
|
+
2. 从当前 data schema 或已确认上下文选择字段 id
|
|
7
|
+
3. 决定指标意图
|
|
8
|
+
4. 选择 data query 的 columns / where / sort
|
|
9
|
+
5. `data query --all --output csv`
|
|
10
|
+
6. Python 读取每个 `files[].local_path`
|
|
11
11
|
7. optional `record_list` or `record_get` only for sample/detail verification
|
|
12
12
|
|
|
13
13
|
Metric intent must be one of:
|
|
@@ -74,7 +74,7 @@ If denominator is missing or scope differs, do not call the result a rate.
|
|
|
74
74
|
|
|
75
75
|
## Trend
|
|
76
76
|
|
|
77
|
-
1.
|
|
77
|
+
1. 从 data schema 或查询响应的 `fields` 中选择日期/时间字段,并核对其 id、标题与类型。
|
|
78
78
|
2. Convert relative phrases into exact date ranges.
|
|
79
79
|
3. Fetch the date field and metrics.
|
|
80
80
|
4. Bucket in pandas by day/week/month/quarter/year.
|
|
@@ -104,8 +104,8 @@ Never use `record_list` alone for final averages, shares, rankings, trends, or d
|
|
|
104
104
|
|
|
105
105
|
If the exact field is unclear:
|
|
106
106
|
|
|
107
|
-
1.
|
|
108
|
-
2.
|
|
107
|
+
1. 检查 data schema 或返回的 `fields`
|
|
108
|
+
2. 按 `fields` 中的标题、字段 id 与类型筛选候选字段
|
|
109
109
|
3. if one candidate is clearly dominant, proceed
|
|
110
110
|
4. otherwise ask the user to confirm
|
|
111
111
|
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
Use `全量可信结论` only when:
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- data
|
|
7
|
+
- 字段 id 来自当前 data schema 或已确认上下文
|
|
8
|
+
- 数据来自 `data query --all --output csv`
|
|
9
9
|
- all returned CSV shards were read in Python
|
|
10
|
-
- `
|
|
11
|
-
- `
|
|
12
|
-
- `
|
|
10
|
+
- `complete=true`
|
|
11
|
+
- `truncated=false`
|
|
12
|
+
- `safe_for_final_conclusion=true`
|
|
13
13
|
- metric definitions are complete
|
|
14
14
|
- denominator exists for every ratio
|
|
15
15
|
- time fields and date ranges are explicit
|
|
@@ -19,11 +19,11 @@ Use `全量可信结论` only when:
|
|
|
19
19
|
|
|
20
20
|
Use `初步观察` when:
|
|
21
21
|
|
|
22
|
-
- `
|
|
23
|
-
- `
|
|
24
|
-
- `
|
|
25
|
-
- `
|
|
26
|
-
- `
|
|
22
|
+
- `status=needs_scope`
|
|
23
|
+
- `status=partial`
|
|
24
|
+
- `complete=false`
|
|
25
|
+
- `truncated=true`
|
|
26
|
+
- `safe_for_final_conclusion=false`
|
|
27
27
|
- evidence came from `record_list`
|
|
28
28
|
- scope or saved view filter is unverified
|
|
29
29
|
|
|
@@ -1,106 +1,78 @@
|
|
|
1
|
-
#
|
|
1
|
+
# data CSV 取数状态机
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 必须路径
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
1. 明确 `app_key` 与指标意图。
|
|
6
|
+
2. 从当前 data schema 或已确认上下文选择字段 id。
|
|
7
|
+
3. 构造 columns、where、sort JSON 文件。
|
|
8
|
+
4. 执行 `data query --all --output csv`。
|
|
9
|
+
5. 读取全部 `files[].local_path` 并在 Python/pandas 中合并。
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
2. choose `view_id` from `accessible_views`
|
|
9
|
-
3. `record_browse_schema_get(app_key, view_id)`
|
|
10
|
-
4. build `record_access.columns / where / order_by` from field ids
|
|
11
|
-
5. run `record_access`
|
|
12
|
-
6. read every CSV shard with Python
|
|
13
|
-
|
|
14
|
-
Do not call `record_access` with field titles, guessed ids, page controls, row limits, or profile.
|
|
15
|
-
CSV columns are readable and field-id anchored, for example `项目状态__field_343283094`; do not look for extra `schema.json` or README files.
|
|
16
|
-
|
|
17
|
-
## Finding `record_access`
|
|
18
|
-
|
|
19
|
-
`record_access` can be available as an MCP tool or as a CLI subcommand. If the MCP surface does not show a top-level `record_access` tool, look under the Qingflow CLI record group before choosing any other path:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
qingflow record --help
|
|
23
|
-
qingflow record access --help
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
The CLI call is:
|
|
11
|
+
CLI 发现与调用:
|
|
27
12
|
|
|
28
13
|
```bash
|
|
29
|
-
qingflow
|
|
14
|
+
qingflow data --help
|
|
15
|
+
qingflow data query --help
|
|
16
|
+
qingflow --json data query \
|
|
30
17
|
--app-key APP_KEY \
|
|
31
|
-
--view-id VIEW_ID \
|
|
32
18
|
--columns-file columns.json \
|
|
33
19
|
--where-file where.json \
|
|
34
|
-
--
|
|
35
|
-
--
|
|
20
|
+
--sort-file sort.json \
|
|
21
|
+
--all --output csv
|
|
36
22
|
```
|
|
37
23
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## Request Patterns
|
|
24
|
+
columns 是字段 id 数组,例如 `[2, 18]`;where 和 sort 是带 `field_id` 的对象数组。`--all` 与 `--output csv` 必须同时出现。
|
|
41
25
|
|
|
42
|
-
|
|
26
|
+
## 真实输出字段
|
|
43
27
|
|
|
44
|
-
|
|
28
|
+
分析前先读取:
|
|
45
29
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
30
|
+
- `status`
|
|
31
|
+
- `files[].local_path`、`files[].row_count`、`files[].part`
|
|
32
|
+
- `row_count`
|
|
33
|
+
- `complete`
|
|
34
|
+
- `truncated`
|
|
35
|
+
- `safe_for_final_conclusion`
|
|
36
|
+
- `fetched_pages`
|
|
37
|
+
- `stopped_reason`
|
|
38
|
+
- `fields`
|
|
55
39
|
|
|
56
|
-
|
|
40
|
+
输出还可能包含 `local_dir`、访问上下文和动态提示;这些内容保持原样解释,不在本地补造。
|
|
57
41
|
|
|
58
|
-
|
|
42
|
+
## 状态决策
|
|
59
43
|
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
"app_key": "APP_KEY",
|
|
63
|
-
"view_id": "system:all",
|
|
64
|
-
"columns": [{ "field_id": 2 }, { "field_id": 18 }],
|
|
65
|
-
"where": [{ "field_id": 2, "op": "between", "value": ["2026-01-01", "2026-12-31"] }],
|
|
66
|
-
"order_by": [{ "field_id": 2, "direction": "asc" }]
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Ratio
|
|
71
|
-
|
|
72
|
-
If numerator and denominator use different filters, run separate `record_access` calls. Only compute the ratio after both source datasets are complete and compatible.
|
|
73
|
-
|
|
74
|
-
## Status Decisions
|
|
75
|
-
|
|
76
|
-
| Status | Meaning | Agent action |
|
|
44
|
+
| 状态 | 含义 | 动作 |
|
|
77
45
|
|---|---|---|
|
|
78
|
-
| `success`
|
|
79
|
-
| `needs_scope` |
|
|
80
|
-
| `partial` |
|
|
81
|
-
| `complete=false` |
|
|
82
|
-
| `truncated=true` |
|
|
83
|
-
|
|
84
|
-
## `needs_scope` Recovery
|
|
46
|
+
| `success` 且完整性三项满足 | 请求范围完整可用 | 读取所有分片后形成总体结论 |
|
|
47
|
+
| `needs_scope` | 无范围大查询被拒绝,未写 CSV | 读取 `scope.reported_total` 与 `scope.row_threshold`,请求时间或业务范围 |
|
|
48
|
+
| `partial` | 已写部分 CSV,但未完成 | 只给局部观察,说明 `row_count` 与 `stopped_reason` |
|
|
49
|
+
| `complete=false` | 未取完请求范围 | 不给总体结论 |
|
|
50
|
+
| `truncated=true` | 提前停止 | 收窄范围后重试 |
|
|
51
|
+
| `safe_for_final_conclusion=false` | 不适合最终总体结论 | 降级或重试 |
|
|
85
52
|
|
|
86
|
-
|
|
53
|
+
`needs_scope` 时 `files=[]`、`row_count=0`;不要寻找不存在的 CSV。partial 时保留的文件可用于局部观察,但不能使用“全部”“整体”“全量”等措辞。
|
|
87
54
|
|
|
88
|
-
|
|
89
|
-
- `suggested_time_fields`: choose likely date fields
|
|
90
|
-
- `recommended_where_examples`: reuse if they match the user request
|
|
55
|
+
## 请求示例
|
|
91
56
|
|
|
92
|
-
|
|
57
|
+
`columns.json`:
|
|
93
58
|
|
|
94
|
-
|
|
59
|
+
```json
|
|
60
|
+
[2, 18]
|
|
61
|
+
```
|
|
95
62
|
|
|
96
|
-
|
|
63
|
+
`where.json`(同一字段的范围使用两个公开操作符并按 AND 组合):
|
|
97
64
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
65
|
+
```json
|
|
66
|
+
[
|
|
67
|
+
{"field_id": 2, "op": "gte", "value": "2026-05-01"},
|
|
68
|
+
{"field_id": 2, "op": "lte", "value": "2026-05-31"}
|
|
69
|
+
]
|
|
70
|
+
```
|
|
101
71
|
|
|
102
|
-
|
|
72
|
+
`sort.json`:
|
|
103
73
|
|
|
104
|
-
|
|
74
|
+
```json
|
|
75
|
+
[{"field_id": 2, "direction": "asc"}]
|
|
76
|
+
```
|
|
105
77
|
|
|
106
|
-
|
|
78
|
+
若分子和分母使用不同筛选,分别执行兼容范围的 data query;两侧都满足完整性门禁后再计算比例。
|
|
@@ -9,14 +9,14 @@ import pandas as pd
|
|
|
9
9
|
|
|
10
10
|
files = [
|
|
11
11
|
"/absolute/path/records-0001.csv",
|
|
12
|
-
#
|
|
12
|
+
# 包含 data query 返回的每个 files[].local_path
|
|
13
13
|
]
|
|
14
14
|
|
|
15
15
|
frames = [pd.read_csv(path, dtype=str, keep_default_na=False) for path in files]
|
|
16
16
|
df = pd.concat(frames, ignore_index=True) if frames else pd.DataFrame()
|
|
17
17
|
|
|
18
18
|
# Columns are readable and field-id anchored, e.g. 项目状态__field_343283094.
|
|
19
|
-
fields = [] #
|
|
19
|
+
fields = [] # 需要字段 id 元数据时使用 data query 返回的 fields
|
|
20
20
|
field_by_id = {int(item["field_id"]): item for item in fields if "field_id" in item}
|
|
21
21
|
title_by_col = {item["column_name"]: item["title"] for item in fields if item.get("column_name")}
|
|
22
22
|
```
|
|
@@ -19,7 +19,8 @@ Do not require both surfaces. If only one is installed, complete the workflow on
|
|
|
19
19
|
## Shared Concepts
|
|
20
20
|
|
|
21
21
|
- **AppForm** is the versioned declarative definition for an application form: app metadata, fields, sections, layout, settings, and field configuration. The same JSON declaration is used by CLI and Qingflow MCP.
|
|
22
|
-
- **
|
|
22
|
+
- **Data** 是既有应用中的普通业务数据。查询、单条读取和直接增删改默认使用视图无关的 data 入口,并以当次 schema、字段能力和访问范围为准。
|
|
23
|
+
- **Record** 用于详情页专项上下文、完整日志、导入、代码块,以及用户明确指定的 record 命令;普通应用数据与记录附件下载使用 data。
|
|
23
24
|
- **Task** is a workflow work item. Prefer task operations for approval, transfer, rollback, and assignee actions.
|
|
24
25
|
- **Builder resource** is package, app, view, chart, portal, navigation, or workflow configuration. It is separate from record data.
|
|
25
26
|
- **Schema version** is part of the public contract. Pin it for one AppForm or workflow operation and do not combine values from different versions.
|
|
@@ -30,11 +31,16 @@ Do not require both surfaces. If only one is installed, complete the workflow on
|
|
|
30
31
|
| --- | --- | --- |
|
|
31
32
|
| Form schema/read/apply/delete | `qingflow --json builder app-form ...` / `builder app delete` | `app_form_schema`, `app_form_get`, `app_form_apply`, `app_delete` |
|
|
32
33
|
| AppForm static validation | `qingflow --json builder app-form validate --file ...` | Performed inside `app_form_apply`; no separate tool |
|
|
33
|
-
|
|
|
34
|
-
|
|
|
34
|
+
| 普通应用数据查询与直接增删改 | `qingflow --json data ...` | Qingflow MCP `data_query/get/insert/update/delete` |
|
|
35
|
+
| 记录附件下载 | `qingflow --json data get --download-attachments` | `data_get(download_attachments=true)` |
|
|
36
|
+
| 日志、详情页专项上下文、导入、代码块或用户指定的 record 命令 | `qingflow --json record ...` / `import ...` | Qingflow MCP 对应 record/import 专项工具 |
|
|
37
|
+
| 待办与流程动作 | `qingflow --json task ...` | Qingflow MCP task tools |
|
|
38
|
+
| 免登录打开网页或指定业务页面 | `qingflow --json auth login-link [--redirect-path PATH]` | `get_login_link` |
|
|
35
39
|
| Package, view, portal, chart, workflow | `qingflow --json builder ...` | Qingflow MCP configuration tools |
|
|
36
40
|
|
|
37
|
-
The operation names and payload schemas are defined by the public surface. Use the current Schema or tool input schema as the source of truth, not
|
|
41
|
+
The operation names and payload schemas are defined by the public surface. Use the current Schema or tool input schema as the source of truth, not another command's shape or a backend payload.
|
|
42
|
+
|
|
43
|
+
用户需要下载或读取附件时,先用 data 定位记录,保持相同身份与工作区,对同一 `app_key`、`record_id` 调用 CLI `data get --download-attachments` 或 MCP `data_get(download_attachments=true)`,保留 schema,使用 `file_assets.items[].local_path`。附件图片与视频同样适用;新入口只下载原文件,不做文本提取。以 `access_status=downloaded` 和非空本地路径判断成功,部分失败看 `file_assets.warnings`。无需 view_id 或 record_get,也不要为下载而读取认证配置、打印 token 或用 Python/curl 直接请求远端 URL。
|
|
38
44
|
|
|
39
45
|
## Package Boundaries
|
|
40
46
|
|
|
@@ -10,6 +10,9 @@ from .json_types import JSONObject
|
|
|
10
10
|
TYPE_ALIASES = {
|
|
11
11
|
"multiline": "long_text",
|
|
12
12
|
"textarea": "long_text",
|
|
13
|
+
"richtext": "rich_text",
|
|
14
|
+
"rich-text": "rich_text",
|
|
15
|
+
"rich_text": "rich_text",
|
|
13
16
|
"radio": "single_choice",
|
|
14
17
|
"boolean": "single_choice",
|
|
15
18
|
"select": "single_select",
|