docs(agent): 补齐 platform records --all 的流式导出约束与 JSON 错误测试
- platform records 的 JSON 结构化错误补充 exitCode 与 nextAction,与 runner 的统一错误形状对齐;非 JSON 路径同步携带 nextAction; - 新增 --json 模式下 DATASET_TOO_LARGE 单测,覆盖分页与流式导出建议; - Skill 与 workflow 参考文档中的 --all 示例统一改为 --ndjson -o,并补充 DATASET_TOO_LARGE 的恢复说明,修正 bbcf96c 声称完成但遗漏的 skill guidelines; - datalink README 补充 --all 的流式导出约束与结构化错误字段。 校验:bun test 1156 pass / 0 fail;bun run check 通过; check:readme 的 specs/ 与 src/core/db/ 缺失为仓库既有问题,与本次改动无关。
This commit is contained in:
1 parent
4ea73ef322
commit
235e4b806d
5 files changed
+40
-6
No files matched your search
@@ -528,6 +528,33 @@ describe("CLI - platform 命令与 record 动作", () => {
|
||||
).rejects.toThrow("--all 不再直接返回全量");
|
||||
});
|
||||
|
||||
it("platform records --all --json 返回 DATASET_TOO_LARGE 结构化错误", async () => {
|
||||
spies.push(spyOn(helpers, "createClientsForCorp").mockResolvedValue({ ekbClient: {} } as any));
|
||||
spies.push(spyOn(servicesApplications, "resolvePlatform").mockResolvedValue(mockPlatform as any));
|
||||
spies.push(spyOn(services, "resolveEntity").mockResolvedValue(mockEntity as any));
|
||||
const result = await handlePlatformCommand(
|
||||
{
|
||||
area: "platform",
|
||||
action: "records",
|
||||
args: ["platform-1", "entity-1"],
|
||||
options: { all: true, json: true },
|
||||
raw: ["platform", "records", "platform-1", "entity-1", "--all", "--json"],
|
||||
},
|
||||
{ ...dummyRuntime, jsonMode: true }
|
||||
);
|
||||
|
||||
expect(result.exitCode).toBe(2);
|
||||
const parsed = JSON.parse(result.stdout);
|
||||
expect(parsed.error).toBe(true);
|
||||
expect(parsed.code).toBe("DATASET_TOO_LARGE");
|
||||
expect(parsed.exitCode).toBe(2);
|
||||
expect(parsed.nextAction).toContain("--ndjson");
|
||||
expect(parsed.suggestions).toEqual([
|
||||
{ type: "paginate", command: "--page=1 --pageSize=500" },
|
||||
{ type: "stream_export", command: "--ndjson --output-file=<path>" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects malformed batch predicates before fetching all records or calling the writer", async () => {
|
||||
spies.push(spyOn(helpers, "createClientsForCorp").mockResolvedValue({ ekbClient: {} } as any));
|
||||
spies.push(spyOn(servicesApplications, "resolvePlatform").mockResolvedValue(mockPlatform as any));
|
||||
|
||||
@@ -65,12 +65,15 @@ export async function handleRecords(parsed: CliParsedArgs, runtime: CliRuntime):
|
||||
if (!isStream || !runtime.outputOptions?.outputFile) {
|
||||
const message =
|
||||
"--all 不再直接返回全量 JSON/表格。请使用 --page/--count 分页查询,或使用 --ndjson --output-file <path> 流式导出;大范围检索建议交给脚本处理。";
|
||||
const nextAction = "hose-use platform records <应用> <业务对象> --ndjson --output-file <path>";
|
||||
if (runtime.jsonMode) {
|
||||
return {
|
||||
stdout: JSON.stringify({
|
||||
error: true,
|
||||
code: "DATASET_TOO_LARGE",
|
||||
message: message,
|
||||
message,
|
||||
exitCode: 2,
|
||||
nextAction,
|
||||
suggestions: [
|
||||
{ type: "paginate", command: "--page=1 --pageSize=500" },
|
||||
{ type: "stream_export", command: "--ndjson --output-file=<path>" },
|
||||
@@ -80,7 +83,7 @@ export async function handleRecords(parsed: CliParsedArgs, runtime: CliRuntime):
|
||||
exitCode: 2,
|
||||
};
|
||||
}
|
||||
throw usageError(message);
|
||||
throw usageError(message, nextAction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user