diff --git a/src/cli/commands/platform/records.ts b/src/cli/commands/platform/records.ts index 2c54251..54c1d94 100644 --- a/src/cli/commands/platform/records.ts +++ b/src/cli/commands/platform/records.ts @@ -63,9 +63,24 @@ export async function handleRecords(parsed: CliParsedArgs, runtime: CliRuntime): // 全量 JSON/表格很容易把几十万条记录倒进 stdout 或内存;全量导出必须显式走文件流。 if (isAll && !isProfileStats && !sumOption) { if (!isStream || !runtime.outputOptions?.outputFile) { - throw usageError( - "--all 不再直接返回全量 JSON/表格。请使用 --page/--count 分页查询,或使用 --ndjson --output-file 流式导出;大范围检索建议交给脚本处理。" - ); + const message = + "--all 不再直接返回全量 JSON/表格。请使用 --page/--count 分页查询,或使用 --ndjson --output-file 流式导出;大范围检索建议交给脚本处理。"; + if (runtime.jsonMode) { + return { + stdout: JSON.stringify({ + error: true, + code: "DATASET_TOO_LARGE", + message: message, + suggestions: [ + { type: "paginate", command: "--page=1 --pageSize=500" }, + { type: "stream_export", command: "--ndjson --output-file=" }, + ], + }), + stderr: "", + exitCode: 2, + }; + } + throw usageError(message); } }