feat(aipro): add standalone document field translator and translate command
This commit is contained in:
1 parent
2afde446d2
commit
a16d429d44
4 files changed
+251
-1
No files matched your search
+25
-1
@@ -9,6 +9,8 @@ import {
|
||||
ApprovalGatewayBlockedError,
|
||||
FindingCheckStatus,
|
||||
} from "./domains/approval/index.js";
|
||||
import { getRawBillFlow } from "./domains/bill/api.js";
|
||||
import { translateBillFlowToMarkdown } from "./domains/bill/translator.js";
|
||||
import { VERSION } from "./version.js";
|
||||
|
||||
export async function runAiProCli(rawArgs: string[]): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||
@@ -163,7 +165,29 @@ export async function runAiProCli(rawArgs: string[]): Promise<{ stdout: string;
|
||||
};
|
||||
}
|
||||
|
||||
// ── 2. 查看审核要点清单(纯规则元数据,与具体单据无关)────────────────
|
||||
// ── 3. 单据字段转译器(转译为标准 LLM / 审核视图 Markdown)─────────────
|
||||
case "translate":
|
||||
case "doc":
|
||||
case "markdown":
|
||||
case "render": {
|
||||
const billSn = positional[1] || stringOption(parsed.options, ["code", "sn", "id", "target"]);
|
||||
if (!billSn) {
|
||||
throw new Error("请提供要转译的单号: hose-aipro translate <单号>");
|
||||
}
|
||||
const context = await getClient();
|
||||
const raw = await getRawBillFlow(context.client, context.corpId, billSn);
|
||||
if (!raw) {
|
||||
throw new Error(`在当前企业下未找到单号或 ID 为 [${billSn}] 的单据`);
|
||||
}
|
||||
const markdown = translateBillFlowToMarkdown(raw);
|
||||
return {
|
||||
stdout: markdown.endsWith("\n") ? markdown : markdown + "\n",
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
}
|
||||
|
||||
// ── 4. 查看审核要点清单(纯规则元数据,与具体单据无关)────────────────
|
||||
case "points":
|
||||
case "clauses": {
|
||||
const arg1 = positional[1] || stringOption(parsed.options, ["scope", "s", "index", "i"]);
|
||||
|
||||
Reference in new issue
Block a user