From 8d203fc2303bc4a44593d35224618c092cd81b27 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Sun, 6 Sep 2026 22:39:45 +0800 Subject: [PATCH] feat(aipro): format scopes command output as pure json with index and scope --- src/aipro-cli.ts | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/src/aipro-cli.ts b/src/aipro-cli.ts index 5709458..3ecb9df 100644 --- a/src/aipro-cli.ts +++ b/src/aipro-cli.ts @@ -73,28 +73,11 @@ export async function runAiProCli(rawArgs: string[]): Promise<{ stdout: string; case "rule": case "index": case "indexes": { - const scopes = repo.listScopes(); - if (runtime.jsonMode) { - return { - stdout: printJson({ count: scopes.length, scopes }), - stderr: "", - exitCode: 0, - }; - } - const headers = ["索引号", "适用场景 (Scope)", "有效规则数", "包含规则编号"]; - const rows = scopes.map((s) => [ - s.index, - s.scope, - s.ruleCount, - s.ruleCodes.map((c) => `#${c}`).join(", "), - ]); - const table = printTable(headers, rows); - const title = `====== [AI PRO] 规约场景索引列表 (共 ${scopes.length} 个适用场景) ======\n`; - const tip = - `\n提示:\n` + - ` • 查看场景审核要点 (纯规则元数据,与单据无关): hose-aipro points <索引号|场景名称> (例如: hose-aipro points 1)\n` + - ` • 绑定单据发起审核: hose-aipro bind <单号> <索引号> (例如: hose-aipro bind S26000001 1)\n`; - return { stdout: title + table + tip, stderr: "", exitCode: 0 }; + const scopes = repo.listScopes().map((s) => ({ + index: s.index, + scope: s.scope, + })); + return { stdout: JSON.stringify(scopes, null, 2) + "\n", stderr: "", exitCode: 0 }; } // ── 2. 查看审核要点清单(纯规则元数据,与具体单据无关)──────────────── @@ -530,22 +513,6 @@ export async function runAiProCli(rawArgs: string[]): Promise<{ stdout: string; return { stdout: title + table, stderr: "", exitCode: 0 }; } - // ── 6. 规约快捷查看 ─────────────────────────────────────────────────── - case "rules": - case "rule": - case "scopes": { - const scopes = repo.listScopes(); - const headers = ["索引号", "适用场景 (Scope)", "有效规则数", "包含规则编号"]; - const rows = scopes.map((s) => [ - s.index, - s.scope, - s.ruleCount, - s.ruleCodes.map((c) => `#${c}`).join(", "), - ]); - const table = printTable(headers, rows); - const title = `====== [AI PRO] 规约场景索引库 (共 ${scopes.length} 个场景) ======\n`; - return { stdout: title + table, stderr: "", exitCode: 0 }; - } // ── 7. 帮助 ─────────────────────────────────────────────────────────── case "help":