feat: 完善工作流工具链与大结果保护

- 工作流节点描述增加服务端托管黑名单,仅代码节点保留自定义 desc
- 工作流保存新增 --in-place,并改进版本冲突提示
- platform records 新增 --page 分页,--all 强制走 ndjson 文件流
- platform schema 展示 ownerId/submitterId 等系统字段
- 更新 Agent Skill 的代码节点 agent use 标记规范
- 补充对应测试与文档
This commit is contained in:
gitea committed 2026-10-28 13:01:11 +08:00
1 parent 37643da254
commit 7423e166a1
10 files changed
+123 -20

No files matched your search

+15 -2
View File
@@ -11,6 +11,14 @@ import { printJson, printTable } from "../../printer.js";
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
import { cell, resolveAppAndEntity } from "./shared.js";
const SYSTEM_FIELD_INFO = [
{ fieldKey: "ownerId", label: "负责人", type: "staff", role: "system" },
{ fieldKey: "submitterId", label: "提交人", type: "staff", role: "system" },
{ fieldKey: "createTime", label: "创建时间", type: "date", role: "system" },
{ fieldKey: "updateTime", label: "更新时间", type: "date", role: "system" },
{ fieldKey: "active", label: "启停状态", type: "boolean", role: "system" },
];
export async function handleList(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
const clients = await createClientsForCorp(runtime.selectedCorp!);
const isAll = booleanOption(parsed.options, ["all", "a"], false);
@@ -60,7 +68,7 @@ export async function handleSchema(parsed: CliParsedArgs, runtime: CliRuntime):
)
: entity.fields,
}));
if (runtime.jsonMode) return { stdout: printJson({ platform: resolved.platform, count: output.length, entities: output }, runtime.outputOptions), stderr: "", exitCode: 0 };
if (runtime.jsonMode) return { stdout: printJson({ platform: resolved.platform, count: output.length, systemFields: SYSTEM_FIELD_INFO, entities: output }, runtime.outputOptions), stderr: "", exitCode: 0 };
const rows = output.flatMap((entity) =>
entity.fields.map((field): Array<string | number | boolean | null | undefined> => {
const roleTag =
@@ -86,16 +94,21 @@ export async function handleSchema(parsed: CliParsedArgs, runtime: CliRuntime):
["业务对象", "物理字段键 (fieldKey / 接口参数名)", "界面名称 (label)", "类型", "角色说明", "必填性", "引用对象"],
rows
);
const systemTable = printTable(
["系统字段键", "界面名称", "类型", "说明"],
SYSTEM_FIELD_INFO.map((field) => [field.fieldKey, field.label, field.type, "系统字段,不在业务 fields 列表中"])
);
const tips = [
"",
"💡 字段命名与工作流配置避坑提示:",
" 1. 物理字段键 (fieldKey / 接口参数名): 在工作流节点映射 (如 ekuaibao-datalink-create) 和 API 请求中,必须使用此键 (例如 E_..._费用金额),切勿使用中文显示名。",
" 2. 结尾 _name: 代表实体的业务主名称/标题 (界面通常显示为单据/计划名称);",
" 3. 结尾 _code: 代表业务编号/单号 (界面通常显示为单据/计划编码);若设置了 autoNumber 规则,创建时会自动生成流水号。",
" 4. 系统字段不在业务字段列表中:ownerId = 负责人/记录所有者,submitterId = 提交人;工作流创建/修改节点的字段映射可直接使用 ownerId,不能把自定义「人员」当作负责人。",
"",
].join("\n");
return {
stdout: `====== 应用 [${resolved.platform.name}] 字段定义 (共 ${rows.length} 个字段) ======\n${table}\n${tips}`,
stdout: `====== 应用 [${resolved.platform.name}] 字段定义 (共 ${rows.length} 个业务字段) ======\n${table}\n\n── 系统字段(不在业务 fields 中) ──\n${systemTable}\n${tips}`,
stderr: "",
exitCode: 0,
};
+13 -3
View File
@@ -54,11 +54,21 @@ export async function handleRecords(parsed: CliParsedArgs, runtime: CliRuntime):
const isAll = booleanOption(parsed.options, ["all", "a"], false);
const groupBy = stringOption(parsed.options, ["group-by", "groupBy"]);
const fetchAll = isAll || Boolean(sumOption || isProfileStats);
const start = numberOption(parsed.options, ["start", "offset"], 0);
const count = numberOption(parsed.options, ["count", "limit"], 20);
const pageSize = numberOption(parsed.options, ["page-size", "pageSize"], 500);
const count = numberOption(parsed.options, ["count", "limit"], 20) ?? 20;
const page = Math.max(1, numberOption(parsed.options, ["page"], 1) ?? 1);
const start = numberOption(parsed.options, ["start", "offset"], (page - 1) * count) ?? 0;
const pageSize = numberOption(parsed.options, ["page-size", "pageSize"], 500) ?? 500;
const fields = splitFields(stringOption(parsed.options, ["fields", "select"]));
// 全量 JSON/表格很容易把几十万条记录倒进 stdout 或内存;全量导出必须显式走文件流。
if (isAll && !isProfileStats && !sumOption) {
if (!isStream || !runtime.outputOptions?.outputFile) {
throw usageError(
"--all 不再直接返回全量 JSON/表格。请使用 --page/--count 分页查询,或使用 --ndjson --output-file <path> 流式导出;大范围检索建议交给脚本处理。"
);
}
}
// 1. 高性能流式下发模式 (--ndjson / --stream,内存开销 O(pageSize),专为海量数据外部脚本管道设计)
if (isStream) {
let streamCount = 0;