From 2d5c49b02ecbeb7306e5b77103da27ed241777e6 Mon Sep 17 00:00:00 2001 From: "zeyu.fz" Date: Tue, 11 Aug 2026 20:05:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(knowledge):=20=E4=BC=98=E5=8C=96quiet?= =?UTF-8?q?=E5=92=8Cformat=E5=8F=82=E6=95=B0=E7=9A=84=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在file-get命令中,quiet模式下仅输出fileId,避免了多余的结果格式化 - 在kb-info命令中,quiet模式仅输出id,格式化输出逻辑得到简化 - 在kb-stats命令中,去除了quiet判断,确保非"text"格式下正确输出结果 - 在service-get命令中,quiet模式下只输出agent_id,格式化部分调整为独立判断 - 统一了各命令中针对quiet和format参数的处理流程,提升代码一致性和可读性 --- packages/commands/src/commands/knowledge/file-get.ts | 8 ++++++-- packages/commands/src/commands/knowledge/kb-info.ts | 8 ++++++-- packages/commands/src/commands/knowledge/kb-stats.ts | 4 ++-- packages/commands/src/commands/knowledge/service-get.ts | 8 ++++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/commands/src/commands/knowledge/file-get.ts b/packages/commands/src/commands/knowledge/file-get.ts index d52a05f..3ff414f 100644 --- a/packages/commands/src/commands/knowledge/file-get.ts +++ b/packages/commands/src/commands/knowledge/file-get.ts @@ -45,8 +45,12 @@ export default defineCommand({ }); const file = response.data; - if (settings.quiet || format !== "text") { - emitResult(response, format === "text" ? "json" : format); + if (settings.quiet) { + emitBare(file?.fileId ?? ""); + return; + } + if (format !== "text") { + emitResult(response, format); return; } emitBare(`id: ${file?.fileId ?? "-"}`); diff --git a/packages/commands/src/commands/knowledge/kb-info.ts b/packages/commands/src/commands/knowledge/kb-info.ts index 81fc5c4..e7ae801 100644 --- a/packages/commands/src/commands/knowledge/kb-info.ts +++ b/packages/commands/src/commands/knowledge/kb-info.ts @@ -92,8 +92,12 @@ export default defineCommand({ const row = await fetchIndexDetail(ctx.client, workspaceId, flags.indexId); - if (settings.quiet || format !== "text") { - emitResult(row, format === "text" ? "json" : format); + if (settings.quiet) { + emitBare(row.id ?? ""); + return; + } + if (format !== "text") { + emitResult(row, format); return; } diff --git a/packages/commands/src/commands/knowledge/kb-stats.ts b/packages/commands/src/commands/knowledge/kb-stats.ts index 45f7a8f..aa238c6 100644 --- a/packages/commands/src/commands/knowledge/kb-stats.ts +++ b/packages/commands/src/commands/knowledge/kb-stats.ts @@ -102,8 +102,8 @@ export default defineCommand({ body, }); - if (settings.quiet || format !== "text") { - emitResult(response, format === "text" ? "json" : format); + if (format !== "text") { + emitResult(response, format); return; } if (clampedEnd) { diff --git a/packages/commands/src/commands/knowledge/service-get.ts b/packages/commands/src/commands/knowledge/service-get.ts index 93e8c52..f885424 100644 --- a/packages/commands/src/commands/knowledge/service-get.ts +++ b/packages/commands/src/commands/knowledge/service-get.ts @@ -77,8 +77,12 @@ export default defineCommand({ }); const data = response.data; - if (settings.quiet || format !== "text") { - emitResult(response, format === "text" ? "json" : format); + if (settings.quiet) { + emitBare(data?.agent_id ?? ""); + return; + } + if (format !== "text") { + emitResult(response, format); return; } emitBare("Basic:");