From 87b691bd4ef25f3002772913f2d1067fcd397f1c Mon Sep 17 00:00:00 2001 From: yunyingk Date: Mon, 12 Oct 2026 22:14:25 +0800 Subject: [PATCH] Organize reports domain into cohesive submodules --- src/cli/commands/report.ts | 13 +++- src/domains/seal/capabilities/reports.ts | 2 +- src/domains/seal/reports/README.md | 70 +++++++++---------- .../reports/charts/duration-histogram.test.ts | 2 +- .../seal/reports/charts/duration-histogram.ts | 2 +- src/domains/seal/reports/charts/venn.test.ts | 2 +- src/domains/seal/reports/charts/venn.ts | 2 +- .../seal/reports/{ => export}/files.test.ts | 6 +- .../seal/reports/{ => export}/files.ts | 11 ++- src/domains/seal/reports/export/index.ts | 1 + src/domains/seal/reports/index.ts | 6 ++ .../seal/reports/{ => pipeline}/collect.ts | 6 +- .../seal/reports/{ => pipeline}/describe.ts | 0 src/domains/seal/reports/pipeline/index.ts | 5 ++ .../seal/reports/{ => pipeline}/monthly.ts | 4 +- .../seal/reports/{ => pipeline}/render.ts | 2 +- .../reports/{ => pipeline}/reports.test.ts | 2 +- .../reports/{ => pipeline}/review-store.ts | 4 +- .../seal/reports/{ => render}/browser.ts | 2 +- .../seal/reports/{ => render}/html.test.ts | 0 src/domains/seal/reports/{ => render}/html.ts | 4 +- src/domains/seal/reports/render/index.ts | 3 + .../seal/reports/{ => render}/png.test.ts | 0 src/domains/seal/reports/{ => render}/png.ts | 2 +- .../seal/reports/{ => templates}/resources.ts | 10 +-- src/domains/seal/reports/validate/index.ts | 1 + .../reports/{ => validate}/validate.test.ts | 0 .../seal/reports/{ => validate}/validate.ts | 0 28 files changed, 92 insertions(+), 70 deletions(-) rename src/domains/seal/reports/{ => export}/files.test.ts (98%) rename src/domains/seal/reports/{ => export}/files.ts (96%) create mode 100644 src/domains/seal/reports/export/index.ts create mode 100644 src/domains/seal/reports/index.ts rename src/domains/seal/reports/{ => pipeline}/collect.ts (98%) rename src/domains/seal/reports/{ => pipeline}/describe.ts (100%) create mode 100644 src/domains/seal/reports/pipeline/index.ts rename src/domains/seal/reports/{ => pipeline}/monthly.ts (96%) rename src/domains/seal/reports/{ => pipeline}/render.ts (99%) rename src/domains/seal/reports/{ => pipeline}/reports.test.ts (99%) rename src/domains/seal/reports/{ => pipeline}/review-store.ts (97%) rename src/domains/seal/reports/{ => render}/browser.ts (99%) rename src/domains/seal/reports/{ => render}/html.test.ts (100%) rename src/domains/seal/reports/{ => render}/html.ts (98%) create mode 100644 src/domains/seal/reports/render/index.ts rename src/domains/seal/reports/{ => render}/png.test.ts (100%) rename src/domains/seal/reports/{ => render}/png.ts (96%) rename src/domains/seal/reports/{ => templates}/resources.ts (57%) create mode 100644 src/domains/seal/reports/validate/index.ts rename src/domains/seal/reports/{ => validate}/validate.test.ts (100%) rename src/domains/seal/reports/{ => validate}/validate.ts (100%) diff --git a/src/cli/commands/report.ts b/src/cli/commands/report.ts index 538534a..ada127b 100644 --- a/src/cli/commands/report.ts +++ b/src/cli/commands/report.ts @@ -4,9 +4,16 @@ import { runCapabilityResult } from "../helpers.js"; import { booleanOption, numberOption, stringOption } from "../parser.js"; import { outputOptions, printJson } from "../printer.js"; import { CliError, usageError } from "../../core/errors.js"; -import { exportReportPackage, renderReportFile, saveReportMarkdown, validateReportFile } from "../../domains/seal/reports/files.js"; -import type { MonthlyReportResult } from "../../domains/seal/reports/monthly.js"; -import { loadReviews, reviewFilePath, writeReview } from "../../domains/seal/reports/review-store.js"; +import { + exportReportPackage, + renderReportFile, + saveReportMarkdown, + validateReportFile, + loadReviews, + reviewFilePath, + writeReview, + type MonthlyReportResult +} from "../../domains/seal/reports/index.js"; import type { ParsedArgs } from "../types.js"; /** Tenant-free commands: dispatch these before resolving enterprise configuration or authentication. */ diff --git a/src/domains/seal/capabilities/reports.ts b/src/domains/seal/capabilities/reports.ts index 8fd2b65..a57a860 100644 --- a/src/domains/seal/capabilities/reports.ts +++ b/src/domains/seal/capabilities/reports.ts @@ -1,6 +1,6 @@ import { z } from "zod"; import type { KyInstance } from "ky"; -import { buildMonthlyReport } from "../reports/monthly.js"; +import { buildMonthlyReport } from "../reports/index.js"; import type { CapabilityContext } from "./helpers.js"; export const reportCapabilities = [ diff --git a/src/domains/seal/reports/README.md b/src/domains/seal/reports/README.md index b9ce93e..2ba3fa9 100644 --- a/src/domains/seal/reports/README.md +++ b/src/domains/seal/reports/README.md @@ -4,40 +4,40 @@ --- -## 模块分层与文件清单 +## 模块分层与目录结构 -### 1. 图表生成子模块 (`charts/`) -数据驱动的现代图表生成引擎,100% 纯 TypeScript 计算,支持输出内嵌 SVG 与通过 Headless Chrome 导出 4x 超高分屏/印刷级 PNG: -- [`charts/venn.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/charts/venn.ts):AI 与人工审核准确率对比维恩图(`` 透镜独立着色、严格水平中轴对称、AI 字符微调)。 -- [`charts/duration-histogram.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/charts/duration-histogram.ts):多模板单据审核耗时分布对比(自动分箱 Binning、7 系列马卡龙色堆叠直方图、总体平均耗时虚线标注)。 -- [`charts/index.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/charts/index.ts):图表模块统一出口。 +所有相关文件严格按职责收拢在对应的子目录中,根目录仅保留统一导出入口与本说明文档: -### 2. 模板与静态资源 (`templates/`) -- [`templates/monthly.md`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/templates/monthly.md):标准月度报告 Markdown 模板。 -- [`templates/report.css`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/templates/report.css):报告排版与 A4 打印样式表。 -- [`templates/assets/`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/templates/assets/):内置图表矢量资产(随二进制静态嵌入)。 -- [`templates/examples/`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/templates/examples/):真实企业脱敏报告实例文档。 -- [`resources.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/resources.ts):Bun 编译期静态资源嵌入定义。 - -### 3. 取数与组装流水线 (`collect.ts` / `describe.ts` / `monthly.ts` / `render.ts`) -- [`describe.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/describe.ts):解析 Markdown 章节标题并推断数据需求(数据与排版皮彻底解耦)。 -- [`collect.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/collect.ts):根据需求通过 Seal API 抓取单据指标,合并人工复核记录。 -- [`render.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/render.ts):将收集到的真实业务数据填入 Markdown 模板。 -- [`monthly.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/monthly.ts):月度报告构建顶层调度函数 (`buildMonthlyReport`)。 - -### 4. 人工审核复核存储 (`review-store.ts`) -- [`review-store.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/review-store.ts):管理本地人工复核判定记录(`~/.config/seal-use/reviews//.jsonl`),计算真实人工准确率基线。 - -### 5. 文档校验与质检门禁 (`validate.ts`) -- [`validate.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/validate.ts):全方位离线质量校验(信息表完整性、章节序号、表格表头加粗排查、数字统计勾稽、公式算术自洽、图片链接有效性)。 - -### 6. 文件系统与导出收拢 (`files.ts`) -- [`files.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/files.ts): - - `saveReportMarkdown`:导出 Markdown 并将本地配图拷贝至伴生专属目录 `<报告名>.md.assets/`。 - - `renderReportFile`:调度 HTML/PNG/PDF 渲染。 - - `exportReportPackage`:**整包收纳导出器**,在目标目录(如 `~/Downloads/赢家时尚-202608/`)下单层整齐打包全部交付物(MD、.md.assets、HTML、PDF),杜绝目录污染。 - -### 7. 渲染与排版底层 (`html.ts` / `browser.ts` / `png.ts`) -- [`html.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/html.ts):Markdown 转 HTML,将所有本地图片(PNG/SVG)与 KaTeX 字体无损转为 Base64 Data URI,编译为 100% 独立的单文件网页。 -- [`browser.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/browser.ts):跨平台自动发现 Chromium/Chrome/Edge 内核,驱动 `--headless` 截图超采样与 A4 打印。 -- [`png.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/png.ts):超长报告的多分带分块拼接,避免单次超大画布内存溢出。 +``` +src/domains/seal/reports/ +├── charts/ # 图表生成子模块(100% 纯 TS 数据驱动矢量计算) +│ ├── venn.ts # 图 1:AI 与人工审核准确率对比维恩图 +│ ├── duration-histogram.ts # 图 2:多模板单据审核耗时分布对比堆叠直方图 +│ └── index.ts # 图表模块出口 +├── pipeline/ # 取数、推断与组装流水线 +│ ├── describe.ts # 解析 Markdown 标题并反推各章节数据需求 +│ ├── collect.ts # 通过 Seal API 抓取单据指标,合并人工复核记录 +│ ├── render.ts # 模板占位填充与章节内容排版 +│ ├── monthly.ts # 月度报告顶层调度器 (buildMonthlyReport) +│ ├── review-store.ts # 人工复核判定本地存储(JSONL 租户分片) +│ └── index.ts # 流水线出口 +├── render/ # 渲染与排版引擎底层 +│ ├── html.ts # Markdown 转自包含 HTML(资源内嵌 Data URI) +│ ├── browser.ts # 跨平台 Headless Chrome 驱动(PDF 打印与长图截取) +│ ├── png.ts # 多分带分块拼接与超大图流式生成 +│ └── index.ts # 渲染引擎出口 +├── validate/ # 离线质量校验与勾稽门禁 +│ ├── validate.ts # 信息表完整性、章节序号、表格格式、公式算术核验 +│ └── index.ts # 校验门禁出口 +├── export/ # 文件系统整包导出与资产收拢 +│ ├── files.ts # 报告整包打包器 (exportReportPackage) 及文件保存 +│ └── index.ts # 导出器出口 +├── templates/ # 模板与静态资源 +│ ├── monthly.md # 标准月度报告 Markdown 模板 +│ ├── report.css # 报告排版与 A4 打印样式表 +│ ├── resources.ts # Bun 编译期静态资源嵌入定义 +│ ├── assets/ # 内置图表矢量资产 +│ └── examples/ # 真实脱敏报告示例 +├── index.ts # 报告域对外统一门面出口 (Barrel) +└── README.md # 架构与开发指南 +``` diff --git a/src/domains/seal/reports/charts/duration-histogram.test.ts b/src/domains/seal/reports/charts/duration-histogram.test.ts index 3f2d416..7141a93 100644 --- a/src/domains/seal/reports/charts/duration-histogram.test.ts +++ b/src/domains/seal/reports/charts/duration-histogram.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; import { renderDurationHistogramPng, renderDurationHistogramSvg, DEFAULT_EEKA_DURATION_SERIES } from "./duration-histogram.js"; -import { pngDimensions } from "../png.js"; +import { pngDimensions } from "../render/png.js"; import { writeFileSync, unlinkSync } from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; diff --git a/src/domains/seal/reports/charts/duration-histogram.ts b/src/domains/seal/reports/charts/duration-histogram.ts index 25eee5a..6c29528 100644 --- a/src/domains/seal/reports/charts/duration-histogram.ts +++ b/src/domains/seal/reports/charts/duration-histogram.ts @@ -1,4 +1,4 @@ -import { renderHtmlToImageBuffer } from "../browser.js"; +import { renderHtmlToImageBuffer } from "../render/browser.js"; export interface HistogramSeries { name: string; diff --git a/src/domains/seal/reports/charts/venn.test.ts b/src/domains/seal/reports/charts/venn.test.ts index 6c98f6a..5a54d68 100644 --- a/src/domains/seal/reports/charts/venn.test.ts +++ b/src/domains/seal/reports/charts/venn.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; import { renderVennAccuracyPng, renderVennAccuracySvg } from "./venn.js"; -import { pngDimensions } from "../png.js"; +import { pngDimensions } from "../render/png.js"; import { writeFileSync, unlinkSync } from "node:fs"; import { join } from "node:path"; import { tmpdir } from "node:os"; diff --git a/src/domains/seal/reports/charts/venn.ts b/src/domains/seal/reports/charts/venn.ts index e1cfbff..97997da 100644 --- a/src/domains/seal/reports/charts/venn.ts +++ b/src/domains/seal/reports/charts/venn.ts @@ -1,4 +1,4 @@ -import { renderHtmlToImageBuffer } from "../browser.js"; +import { renderHtmlToImageBuffer } from "../render/browser.js"; export interface VennAccuracyOptions { aiAccuracy: number; diff --git a/src/domains/seal/reports/files.test.ts b/src/domains/seal/reports/export/files.test.ts similarity index 98% rename from src/domains/seal/reports/files.test.ts rename to src/domains/seal/reports/export/files.test.ts index 4281636..3789782 100644 --- a/src/domains/seal/reports/files.test.ts +++ b/src/domains/seal/reports/export/files.test.ts @@ -3,10 +3,10 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync import { tmpdir } from "node:os"; import { join } from "node:path"; import { PNG } from "pngjs"; -import { runCli } from "../../../cli/runner.js"; -import { buildMonthlyReport } from "./monthly.js"; +import { runCli } from "../../../../cli/runner.js"; +import { buildMonthlyReport } from "../pipeline/index.js"; import { renderReportFile, saveReportMarkdown, validateReportFile } from "./files.js"; -import { BUILTIN_MONTHLY_TEMPLATE, BUILTIN_TEMPLATE_PATH } from "./resources.js"; +import { BUILTIN_MONTHLY_TEMPLATE, BUILTIN_TEMPLATE_PATH } from "../templates/resources.js"; const dirs: string[] = []; const originalCwd = process.cwd(); diff --git a/src/domains/seal/reports/files.ts b/src/domains/seal/reports/export/files.ts similarity index 96% rename from src/domains/seal/reports/files.ts rename to src/domains/seal/reports/export/files.ts index f38396d..6d4f6fd 100644 --- a/src/domains/seal/reports/files.ts +++ b/src/domains/seal/reports/export/files.ts @@ -1,13 +1,12 @@ import { constants, copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os" import { basename, dirname, extname, join, resolve } from "node:path" -import { CliError, usageError, validationError } from "../../../core/errors.js" -import { BUILTIN_TEMPLATE_PATH, REPORT_ASSETS } from "./resources.js" -import { validateReportDocument, type ReportValidation } from "./validate.js" -import { buildReportHtml } from "./html.js" -import { findReportChrome, renderBrowserArtifacts, renderHtmlToImageBuffer } from "./browser.js" +import { CliError, usageError, validationError } from "../../../../core/errors.js" +import { BUILTIN_TEMPLATE_PATH, REPORT_ASSETS } from "../templates/resources.js" +import { validateReportDocument, type ReportValidation } from "../validate/index.js" +import { buildReportHtml, findReportChrome, renderBrowserArtifacts, renderHtmlToImageBuffer } from "../render/index.js" -export type { ReportValidation } from "./validate.js" +export type { ReportValidation } from "../validate/index.js" export type ReportRenderOptions = { out: string; format?: string; diff --git a/src/domains/seal/reports/export/index.ts b/src/domains/seal/reports/export/index.ts new file mode 100644 index 0000000..1d92053 --- /dev/null +++ b/src/domains/seal/reports/export/index.ts @@ -0,0 +1 @@ +export * from "./files.js"; diff --git a/src/domains/seal/reports/index.ts b/src/domains/seal/reports/index.ts new file mode 100644 index 0000000..f1b1d43 --- /dev/null +++ b/src/domains/seal/reports/index.ts @@ -0,0 +1,6 @@ +export * from "./charts/index.js"; +export * from "./pipeline/index.js"; +export * from "./render/index.js"; +export * from "./validate/index.js"; +export * from "./export/index.js"; +export * from "./templates/resources.js"; diff --git a/src/domains/seal/reports/collect.ts b/src/domains/seal/reports/pipeline/collect.ts similarity index 98% rename from src/domains/seal/reports/collect.ts rename to src/domains/seal/reports/pipeline/collect.ts index e5753be..31523d1 100644 --- a/src/domains/seal/reports/collect.ts +++ b/src/domains/seal/reports/pipeline/collect.ts @@ -1,7 +1,7 @@ import type { KyInstance } from "ky"; -import * as api from "../api.js"; -import { formatBeijingIso } from "../../../core/config/timestamps.js"; -import type { ApprovalRun } from "../types.js"; +import * as api from "../../api.js"; +import { formatBeijingIso } from "../../../../core/config/timestamps.js"; +import type { ApprovalRun } from "../../types.js"; import type { ReportDemand } from "./describe.js"; import { loadReviews, type ReviewRecord } from "./review-store.js"; diff --git a/src/domains/seal/reports/describe.ts b/src/domains/seal/reports/pipeline/describe.ts similarity index 100% rename from src/domains/seal/reports/describe.ts rename to src/domains/seal/reports/pipeline/describe.ts diff --git a/src/domains/seal/reports/pipeline/index.ts b/src/domains/seal/reports/pipeline/index.ts new file mode 100644 index 0000000..973f253 --- /dev/null +++ b/src/domains/seal/reports/pipeline/index.ts @@ -0,0 +1,5 @@ +export * from "./describe.js"; +export * from "./collect.js"; +export * from "./render.js"; +export * from "./monthly.js"; +export * from "./review-store.js"; diff --git a/src/domains/seal/reports/monthly.ts b/src/domains/seal/reports/pipeline/monthly.ts similarity index 96% rename from src/domains/seal/reports/monthly.ts rename to src/domains/seal/reports/pipeline/monthly.ts index 4600ff0..0602415 100644 --- a/src/domains/seal/reports/monthly.ts +++ b/src/domains/seal/reports/pipeline/monthly.ts @@ -2,8 +2,8 @@ import type { KyInstance } from "ky"; import { existsSync, readFileSync } from "node:fs"; import { randomBytes } from "node:crypto"; import { resolve } from "node:path"; -import { validationError } from "../../../core/errors.js"; -import { BUILTIN_MONTHLY_TEMPLATE, BUILTIN_TEMPLATE_PATH } from "./resources.js"; +import { validationError } from "../../../../core/errors.js"; +import { BUILTIN_MONTHLY_TEMPLATE, BUILTIN_TEMPLATE_PATH } from "../templates/resources.js"; import { describeTemplate } from "./describe.js"; import { collectReportData, type ReportData } from "./collect.js"; import { renderMonthlyReport, type RenderOptions } from "./render.js"; diff --git a/src/domains/seal/reports/render.ts b/src/domains/seal/reports/pipeline/render.ts similarity index 99% rename from src/domains/seal/reports/render.ts rename to src/domains/seal/reports/pipeline/render.ts index 8c8d87c..d68975a 100644 --- a/src/domains/seal/reports/render.ts +++ b/src/domains/seal/reports/pipeline/render.ts @@ -1,4 +1,4 @@ -import { formatBeijingIso } from "../../../core/config/timestamps.js"; +import { formatBeijingIso } from "../../../../core/config/timestamps.js"; import type { ReportData, ReportBlock } from "./collect.js"; import type { SectionPlan } from "./describe.js"; diff --git a/src/domains/seal/reports/reports.test.ts b/src/domains/seal/reports/pipeline/reports.test.ts similarity index 99% rename from src/domains/seal/reports/reports.test.ts rename to src/domains/seal/reports/pipeline/reports.test.ts index f0be9fa..b79d079 100644 --- a/src/domains/seal/reports/reports.test.ts +++ b/src/domains/seal/reports/pipeline/reports.test.ts @@ -7,7 +7,7 @@ import { collectReportData, type ReportData } from "./collect.js"; import { renderMonthlyReport } from "./render.js"; import { loadReviews, writeReview, reviewFilePath } from "./review-store.js"; -const TEMPLATE = join(import.meta.dirname, "templates", "monthly.md"); +const TEMPLATE = join(import.meta.dirname, "..", "templates", "monthly.md"); function sampleData(overrides: Partial = {}): ReportData { return { diff --git a/src/domains/seal/reports/review-store.ts b/src/domains/seal/reports/pipeline/review-store.ts similarity index 97% rename from src/domains/seal/reports/review-store.ts rename to src/domains/seal/reports/pipeline/review-store.ts index 6eed47c..6ede791 100644 --- a/src/domains/seal/reports/review-store.ts +++ b/src/domains/seal/reports/pipeline/review-store.ts @@ -1,6 +1,6 @@ import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs"; import { dirname, join } from "node:path"; -import { validationError } from "../../../core/errors.js"; +import { validationError } from "../../../../core/errors.js"; /** * 人工裁决的本地持久化(JSONL,按 租户 × 月份 分片)。 @@ -43,7 +43,7 @@ const VERDICTS: ReadonlySet = new Set([ "undecided" ]); -import { SEAL_STATE_DIR } from "../../../core/paths.js"; +import { SEAL_STATE_DIR } from "../../../../core/paths.js"; const REVIEWS_DIR_ENV = "SEAL_USE_REVIEWS_DIR"; diff --git a/src/domains/seal/reports/browser.ts b/src/domains/seal/reports/render/browser.ts similarity index 99% rename from src/domains/seal/reports/browser.ts rename to src/domains/seal/reports/render/browser.ts index fd2f447..def1e4e 100644 --- a/src/domains/seal/reports/browser.ts +++ b/src/domains/seal/reports/render/browser.ts @@ -3,7 +3,7 @@ import { accessSync, constants, existsSync, mkdirSync, mkdtempSync, readdirSync, import { homedir, tmpdir } from "node:os" import { dirname, join } from "node:path" import { pathToFileURL } from "node:url" -import { CliError, validationError } from "../../../core/errors.js" +import { CliError, validationError } from "../../../../core/errors.js" import { pngDimensions, stitchPngBands, type PngBand } from "./png.js" export const PNG_BAND_HEIGHT = 14_000 diff --git a/src/domains/seal/reports/html.test.ts b/src/domains/seal/reports/render/html.test.ts similarity index 100% rename from src/domains/seal/reports/html.test.ts rename to src/domains/seal/reports/render/html.test.ts diff --git a/src/domains/seal/reports/html.ts b/src/domains/seal/reports/render/html.ts similarity index 98% rename from src/domains/seal/reports/html.ts rename to src/domains/seal/reports/render/html.ts index 2ce9377..88dcd2e 100644 --- a/src/domains/seal/reports/html.ts +++ b/src/domains/seal/reports/render/html.ts @@ -3,8 +3,8 @@ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writ import { homedir } from "node:os" import { basename, dirname, extname, join, resolve } from "node:path" import { Marked, type TokenizerExtension, type Tokens } from "marked" -import { CliError } from "../../../core/errors.js" -import { REPORT_CSS } from "./resources.js" +import { CliError } from "../../../../core/errors.js" +import { REPORT_CSS } from "../templates/resources.js" const katexBase = "https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/" const mimeTypes: Record = { diff --git a/src/domains/seal/reports/render/index.ts b/src/domains/seal/reports/render/index.ts new file mode 100644 index 0000000..17af9f7 --- /dev/null +++ b/src/domains/seal/reports/render/index.ts @@ -0,0 +1,3 @@ +export * from "./browser.js"; +export * from "./html.js"; +export * from "./png.js"; diff --git a/src/domains/seal/reports/png.test.ts b/src/domains/seal/reports/render/png.test.ts similarity index 100% rename from src/domains/seal/reports/png.test.ts rename to src/domains/seal/reports/render/png.test.ts diff --git a/src/domains/seal/reports/png.ts b/src/domains/seal/reports/render/png.ts similarity index 96% rename from src/domains/seal/reports/png.ts rename to src/domains/seal/reports/render/png.ts index 5b1a167..3feca67 100644 --- a/src/domains/seal/reports/png.ts +++ b/src/domains/seal/reports/render/png.ts @@ -1,6 +1,6 @@ import { closeSync, openSync, readFileSync, readSync, writeFileSync } from "node:fs" import { PNG } from "pngjs" -import { CliError } from "../../../core/errors.js" +import { CliError } from "../../../../core/errors.js" export type PngBand = { file: string; height: number } diff --git a/src/domains/seal/reports/resources.ts b/src/domains/seal/reports/templates/resources.ts similarity index 57% rename from src/domains/seal/reports/resources.ts rename to src/domains/seal/reports/templates/resources.ts index 392218a..6eb6397 100644 --- a/src/domains/seal/reports/resources.ts +++ b/src/domains/seal/reports/templates/resources.ts @@ -1,8 +1,8 @@ -import monthly from "./templates/monthly.md" with { type: "text" }; -import css from "./templates/report.css" with { type: "text" }; -import accuracy from "./templates/assets/图1-准确率对比.svg" with { type: "text" }; -import benefits from "./templates/assets/图2-综合效益.svg" with { type: "text" }; -import screenshot from "./templates/assets/图3-示例截图.svg" with { type: "text" }; +import monthly from "./monthly.md" with { type: "text" }; +import css from "./report.css" with { type: "text" }; +import accuracy from "./assets/图1-准确率对比.svg" with { type: "text" }; +import benefits from "./assets/图2-综合效益.svg" with { type: "text" }; +import screenshot from "./assets/图3-示例截图.svg" with { type: "text" }; // Git owns the source files; Bun embeds these imports in both developer and release binaries. // Loading the built-in template never depends on cwd, a checkout, or skill installation. diff --git a/src/domains/seal/reports/validate/index.ts b/src/domains/seal/reports/validate/index.ts new file mode 100644 index 0000000..fe4d5bc --- /dev/null +++ b/src/domains/seal/reports/validate/index.ts @@ -0,0 +1 @@ +export * from "./validate.js"; diff --git a/src/domains/seal/reports/validate.test.ts b/src/domains/seal/reports/validate/validate.test.ts similarity index 100% rename from src/domains/seal/reports/validate.test.ts rename to src/domains/seal/reports/validate/validate.test.ts diff --git a/src/domains/seal/reports/validate.ts b/src/domains/seal/reports/validate/validate.ts similarity index 100% rename from src/domains/seal/reports/validate.ts rename to src/domains/seal/reports/validate/validate.ts