Add one-shot monthly audit report command (report monthly)

Eats in the ai-audit-report-template as a module. The template is the mutable
skin: describeTemplate() infers per-section data demands from ##/### headings
(keyword rules), so editing/renaming/reordering sections does not require
touching collect or render code.

- src/domains/seal/reports/: describe (heading to demand), collect (performance/
  risk blocks/template groups, fetched only for declared demands), render (fills
  tables by section+column signature, rewrites narrative by structure not line
  number), monthly (orchestrator returning content + per-section completeness +
  notes).
- report-templates/: the template body, assets, example, and downstream
  validate.py/render.py (not bundled; next.validate/render in the result point
  at them).
- Capability sealReportMonthlyGet (read-only, allow-listed) + CLI
  "seal-use report monthly --month <YYYY-MM>" + help + KNOWN_FLAGS month +
  read-only report:monthly.
- SKILL.md: routing row + a section stating the two hard rules: the template is
  swappable, and metrics with no upstream source keep template sample values
  with a warning note instead of fabricated numbers.

Template-path resolution branches on isCompiledBinary() (dev: module-relative to
repo root; compiled: cwd), matching how rules lint --file resolves paths, since
templates are not embedded.

Verified: bun test 633 pass (6 new reports tests), tsc clean, oxlint 0 warnings.
Live smoke: 2026-08 report for a real corp fills real accuracy/counts/distribution
and marks human-accuracy + mismatch-classification + section-6 sample rows with
gap notes.
This commit is contained in:
gitea committed 2026-09-30 17:55:37 +08:00
1 parent a37cac2679
commit 2ee15bb0d6
21 files changed
+2281 -1

No files matched your search

+4 -1
View File
@@ -8,6 +8,7 @@ import { approvalRunsCapabilities } from "./approval-runs.js";
import { simulationCapabilities } from "./simulation.js";
import { deployCapabilities } from "./deploy.js";
import { preferenceCapabilities } from "./preference.js";
import { reportCapabilities } from "./reports.js";
export * from "./helpers.js";
export * from "./validate.js";
@@ -22,7 +23,8 @@ export const sealCapabilities = [
...approvalRunsCapabilities,
...simulationCapabilities,
...deployCapabilities,
...preferenceCapabilities
...preferenceCapabilities,
...reportCapabilities
];
export type SealCapability = (typeof sealCapabilities)[number];
@@ -99,6 +101,7 @@ export const SEAL_READ_ONLY_CAPABILITIES: ReadonlySet<string> = new Set([
"sealPermissionsConfigsList",
"sealPreferenceGet",
"sealPreferenceThinkingDepthPoliciesList",
"sealReportMonthlyGet",
"sealSessionGet",
"sealSimulationBatchGet",
"sealSimulationBatchRecordsGet",
+42
View File
@@ -0,0 +1,42 @@
import { z } from "zod";
import type { KyInstance } from "ky";
import { buildMonthlyReport } from "../reports/monthly.js";
import type { CapabilityContext } from "./helpers.js";
export const reportCapabilities = [
{
name: "sealReportMonthlyGet",
description:
"生成月度 AI 审核准确率报告(Markdown)。按模板结构从效能/风险/审批运行接口取数填充,返回填充后的内容与各章节数据完备度;无法从上游取得的口径(人工准确率、失准原因分类)如实标注而非编造",
parameters: z.object({
month: z
.string()
.regex(/^\d{4}-\d{2}$/)
.describe("统计月份,YYYY-MM"),
templatePath: z
.string()
.optional()
.describe("自定义模板 Markdown 路径;缺省用 report-templates/monthly.md"),
reportId: z.string().optional().describe("自定义报告编号(RPT-YYYYMM-XXXXXX)"),
maxRuns: z
.number()
.int()
.positive()
.max(500)
.optional()
.describe("拉取审批运行明细分块的上限,默认 500")
}),
handler: async (
client: KyInstance,
params: { month: string; templatePath?: string; reportId?: string; maxRuns?: number },
context: CapabilityContext
) =>
buildMonthlyReport(client, {
month: params.month,
corp: { id: context.corp.id, name: context.corp.name },
templatePath: params.templatePath,
reportId: params.reportId,
maxRuns: params.maxRuns
})
}
];