import type { CorpConfig } from "../../core/config/types.js"; import type { createSealClient } from "../../core/http/factory.js"; import { runCapability } from "../helpers.js"; import { numberOption, stringOption } from "../parser.js"; import { outputOptions, printJson } from "../printer.js"; import { loadReviews, reviewFilePath, writeReview } from "../../domains/seal/reports/review-store.js"; import type { ParsedArgs } from "../types.js"; /** `seal-use report monthly` — 月度 AI 审核准确率报告(Markdown 填充)。 */ export async function handleReportCommand( action: string | undefined, client: Awaited>, corp: CorpConfig, args: ParsedArgs ) { if (action === "monthly" || action === "month") { const month = stringOption(args.options.month); if (!month) { throw new Error("Usage: seal-use report monthly --month [--template ] [--report-id ] [--corp ]"); } await runCapability( "sealReportMonthlyGet", client, corp, { month, templatePath: stringOption(args.options.template), reportId: stringOption(args.options["report-id"]) ?? stringOption(args.options.reportId), maxRuns: numberOption(args.options["max-runs"]) ?? numberOption(args.options.maxRuns) }, outputOptions(args.options) ); return; } if (action === "review") { const sub = args.command[2]; // set | list const month = stringOption(args.options.month); if (!month) { throw new Error("Usage: seal-use report review --month [--sn --verdict ] [--corp ]"); } if (sub === "list") { const reviews = loadReviews(corp.id, month); printJson({ corpId: corp.id, month, file: reviewFilePath(corp.id, month), count: reviews.size, reviews: [...reviews.values()] }); return; } if (sub === "set") { const sn = stringOption(args.options.sn) ?? stringOption(args.options["document-sn"]); const verdict = stringOption(args.options.verdict); if (!sn || !verdict) { throw new Error( "Usage: seal-use report review set --month --sn --verdict [--note ] [--reviewed-by ] [--corp ]" ); } const record = writeReview(corp.id, { sn, month, verdict, note: stringOption(args.options.note), reviewedBy: stringOption(args.options["reviewed-by"]) ?? stringOption(args.options.reviewedBy) }); printJson({ corpId: corp.id, file: reviewFilePath(corp.id, month), record }); return; } throw new Error(`Unknown report review subcommand: ${sub ?? ""}. Use 'set' or 'list'.`); } throw new Error(`Unknown report command: ${action ?? ""}. Run 'seal-use report --help' for available commands.`); }