fix(knowledge): 优化quiet和format参数的输出逻辑

- 在file-get命令中,quiet模式下仅输出fileId,避免了多余的结果格式化
- 在kb-info命令中,quiet模式仅输出id,格式化输出逻辑得到简化
- 在kb-stats命令中,去除了quiet判断,确保非"text"格式下正确输出结果
- 在service-get命令中,quiet模式下只输出agent_id,格式化部分调整为独立判断
- 统一了各命令中针对quiet和format参数的处理流程,提升代码一致性和可读性
This commit is contained in:
zeyu.fz
2026-08-11 20:05:44 +08:00
parent 9bd8b60c22
commit 2d5c49b02e
4 changed files with 20 additions and 8 deletions
@@ -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 ?? "-"}`);
@@ -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;
}
@@ -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) {
@@ -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:");