diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3152b58..6ec24ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,9 @@ jobs: - name: Lint run: bun run lint + - name: Linter Plaintext Sync + run: bun run verify:linter-plaintext + - name: Colocated Unit Tests run: bun test diff --git a/.gitignore b/.gitignore index bb65593..46a2143 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,16 @@ node_modules/ .DS_Store -*.log -.cache/ -tmp/* -!tmp/.gitkeep + +# Build outputs dist/bin/ + +# Local runtime caches and system noise (regenerate at any time) +.cache/ .mimosa/ - -# Local enterprise configs can contain credentials. -enterprises/*.json -!enterprises/example.*.json - -# Local generated reports and exported deliverables. -.local/ .apifox/ -exports/ -scripts/export-*.ts -# Local custom linters. Loaded and executed from /linters at runtime, so a fresh -# clone has none — README.md is tracked to explain the convention, the linters stay private. -linters/* -!linters/README.md +# Local runtime state (rule snapshots, bridge, reports) — never committed +.local/ + +# One-off export harnesses dropped in scripts/ while exporting +scripts/export-*.ts diff --git a/AGENTS.md b/AGENTS.md index 51e1220..460177a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -6,7 +6,7 @@ This is a Bun + TypeScript toolkit for the `seal-use` CLI and a local stdio MCP The repository doubles as a ZCode plugin: `.zcode-plugin/plugin.json` declares a skills-only plugin manifest and the agent skill lives under `skills/seal-use/`. The plugin ships no MCP surface; the local MCP runs from the CLI (`seal-use mcp`, or the `mcp-config` snippet for Cursor/Claude Desktop). The in-repo `.agents/skills/seal-use` symlink has been dropped; workspace and Codex skill loading use the global `~/.agents/skills/seal-use` copy installed by `seal-use skill install`. -Tests are colocated as `*.test.ts` files in `src/`. Example enterprise configs are in `enterprises/example.*.json`; real configs must stay untracked. +Tests are colocated as `*.test.ts` files in `src/`. ## Build, Test, and Development Commands @@ -101,15 +101,15 @@ Recent commits use concise imperative subjects, often `Add ...` or `Refine ...`, git push origin refs/tags/vX.Y.Z ``` - GitHub Actions (`release.yml`) is responsible only for cross-compiling all 5 target binaries and publishing the GitHub Release. - - **Gitea & Homebrew Pull-Based Promotion**: Do not manually push branches or tags to `home` (Gitea). On WSL (`wsl-dev`), `seal-use-release-sync.timer` polls the latest GitHub Release every 15 minutes (or can be triggered immediately via `systemctl start seal-use-release-sync.service`), pulls the release and assets from GitHub into Gitea, and updates the Homebrew tap (`ops/README.md`). + - **Gitea & Homebrew Pull-Based Promotion**: Do not manually push branches or tags to `home` (Gitea). On WSL (`wsl-dev`), `seal-use-release-sync.timer` polls the latest GitHub Release every 15 minutes (or can be triggered immediately via `systemctl start seal-use-release-sync.service`), pulls the release and assets from GitHub into Gitea, and updates the Homebrew tap (`wsl-infra/systemd/`). - The workflow enforces the merge-before-tag rule rather than trusting the operator: `release.yml` refuses to publish unless the tagged commit is an ancestor of `origin/main`. Actions in both workflows are pinned to commit SHAs rather than moving tags for supply-chain integrity. ## Security & Configuration Tips -Never commit real enterprise credentials, Seal tokens, service logs, or local generated state. Use `enterprises/example.hose.json` or `enterprises/example.seal.json` as templates, then place real configs in `enterprises/local.json` or `~/.config/seal-use/enterprises` (with legacy fallback to `~/.config/seal-home/enterprises`). For auth or tenant changes, verify with `bun run probe` or `seal-use auth diagnose`. +Never commit real enterprise credentials, Seal tokens, service logs, or local generated state. Enterprise configs live only in `~/.config/seal-use/enterprises` (with legacy fallback to `~/.config/seal-home/enterprises`); the project tree carries none. For auth or tenant changes, verify with `bun run probe` or `seal-use auth diagnose`. Credential files are written `0600`; a config placed by hand keeps the `0o644` default, so run `seal-use doctor` and act on its `credential_permissions` check before sharing a machine or a backup. See `SECURITY.md` for the trust model (self-update, custom linters). ## Agent-Specific Instructions -Do not create `.codex/skills`; Codex is compatible with `.agents/skills`, and this project treats `.agents/` as authoritative. At project scope, prefer `AGENT.md` instructions when present. +Do not create `.codex/skills`; Codex is compatible with `.agents/skills`, and this project treats `.agents/` as authoritative. At project scope, prefer `AGENTS.md` instructions when present. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 120000 index 0000000..47dc3e3 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +AGENTS.md \ No newline at end of file diff --git a/README.md b/README.md index d8c2f83..a424e7c 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ seal-use update # Self-update (GitHub Releases binary, Homebrew, or so For local development from source with Bun: -For an already-authenticated Seal-native source, use `seal-use corps add-seal-bearer` or copy `enterprises/example.seal.json`. +For an already-authenticated Seal-native source, use `seal-use corps add-seal-bearer`. ## Public Usage @@ -133,12 +133,7 @@ seal-use update Because `npm link` makes the global command a symlink into your checkout, **updating the checkout is sufficient** — no reinstall step required. The symlink continues to point to the updated source. -Local enterprise config files are ignored by git: - -```text -enterprises/*.json -!enterprises/example.*.json -``` +Enterprise configs live only in the global directory `~/.config/seal-use/enterprises` (legacy fallback `~/.config/seal-home/enterprises`); the project tree carries none. The canonical plugin skill lives at `skills/seal-use`. There is no in-repo `.agents/skills/seal-use` symlink; run `seal-use skill install` (or copy that folder yourself) to place it in a Codex skills directory such as `~/.agents/skills/seal-use` when you want Codex to invoke the workflow as `$seal-use`. diff --git a/SECURITY.md b/SECURITY.md index 910f4a2..67a35a7 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -36,10 +36,10 @@ than described here. `checksums.txt` but only warns on a mismatch. Prefer the direct GitHub source (`SEAL_USE_MIRROR=github`, which skips the third-party mirrors) and pass an explicit `SEAL_USE_VERSION` when installing. -- **Custom rule linters are code that gets executed.** Files under `/linters/` and - `~/.config/seal-use/linters/` are imported into the CLI process by `seal-use rules lint`, with - that process's filesystem access and enterprise credentials. Treat those directories as trusted - code and do not run the CLI from an untrusted checkout. See `linters/README.md`. +- **Custom rule linters are code that gets executed.** Files under `~/.config/seal-use/linters/` + are imported into the CLI process by `seal-use rules lint`, with that process.s filesystem access + and enterprise credentials. Treat that directory as trusted code and do not hand it untrusted + scripts. ## Supported versions diff --git a/enterprises/example.hose.json b/enterprises/example.hose.json deleted file mode 100644 index 6de3399..0000000 --- a/enterprises/example.hose.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "id": "corp-id", - "name": "企业名称", - "seal": { - "url": "https://corp-id.sealai.cc", - "endpoints": { - "approvalStylePreferences": "api/v1/agent/ai-approval/config" - } - }, - "source": { - "type": "hose", - "domain": "https://app.ekuaibao.com", - "key": "hose-app-key", - "password": "hose-app-security", - "staffId": "hose-staff-id", - "corpId": "hose-corp-id" - }, - "auth": { - "refreshTtl": 300 - } -} diff --git a/enterprises/example.seal.json b/enterprises/example.seal.json deleted file mode 100644 index ea30e38..0000000 --- a/enterprises/example.seal.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "id": "tenant-slug", - "name": "Seal 原生企业", - "seal": { - "url": "https://tenant.sealai.cc", - "tenantSlug": "tenant-slug", - "endpoints": { - "approvalStylePreferences": "api/v1/agent/ai-approval/config" - } - }, - "source": { - "type": "seal", - "token": "seal-bearer-token", - "sealUrl": "https://tenant.sealai.cc", - "expiresIn": 2592000, - "expiresAt": "2026-10-22T00:00:00Z", - "staffId": "seal-user-id", - "corpId": "tenant-slug", - "tenantId": "seal-tenant-id", - "tenantSlug": "tenant-slug", - "tenantName": "Seal 原生企业", - "providerUserId": "provider-user-id" - }, - "auth": { - "refreshTtl": 300 - } -} diff --git a/linters/README.md b/linters/README.md deleted file mode 100644 index ee13cc8..0000000 --- a/linters/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# `linters/` — local custom rule linters (intentionally untracked) - -`seal-use rules lint` resolves custom linters from two directories, in this order -(`src/domains/seal/linter/loader.ts`): - -1. `/linters/` — **this directory**, relative to the working directory the CLI runs in -2. `~/.config/seal-use/linters/` - -`/linters/` is gitignored (all of it except this file), so a fresh clone has no custom -linters and `rules lint` silently falls back to the official ones. Only this README is tracked, -to record the convention. - -## Conventions - -- One linter per file, named `.ts`, `.js` or `.mjs`. The basename is the - linter name used by `seal-use rules lint --linter `. -- The official linters occupy `~/.config/seal-use/linters/official/`, which is **excluded** from - custom-linter discovery and rewritten on every load. Never put custom code there; put it - directly in `linters/` or in `~/.config/seal-use/linters/`. -- Prefer `~/.config/seal-use/linters/` for linters you want available from every directory: this - directory only applies when the CLI happens to be started from the repository root. - -## Module shape - -```ts -import type { RuleLintTarget, RuleLintResult } from "…"; - -export default function myLinter(rule: RuleLintTarget): RuleLintResult { - // … -} -``` - -`default`, `lintRule`, `linter` and `lint` are all accepted exports, and each is wrapped so a -throwing linter degrades to a reported error rather than aborting the run. - -## Trust boundary - -A custom linter is **imported and executed in the CLI process**, with the CLI's filesystem access -and the enterprise credentials it holds. Treat these files as code you trust: never drop an -unreviewed linter here, and never point the CLI's working directory at an untrusted checkout. diff --git a/package.json b/package.json index a7e2003..61bbe90 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,8 @@ "release": "bun run scripts/release.ts", "dev:override": "bun run scripts/dev-override.ts", "dev:link": "bun run scripts/dev-override.ts", + "generate:linter-plaintext": "bun run scripts/generate-linter-plaintext.mjs", + "verify:linter-plaintext": "bun run scripts/check-linter-plaintext.mjs", "test": "bun test", "prepare": "git config core.hooksPath .githooks" }, diff --git a/scripts/bump-version.ts b/scripts/bump-version.ts index 6a633b8..b17893c 100644 --- a/scripts/bump-version.ts +++ b/scripts/bump-version.ts @@ -99,6 +99,9 @@ if (existsSync(globalSkillDir)) { } // 6. Rebuild bundles + +// 同步官方校验器明文嵌入物(checkers/ 源码 -> plaintext.generated.ts) +execSync("bun run generate:linter-plaintext", { cwd: ROOT, stdio: "inherit" }); console.log("==> Rebuilding binary bundle..."); execSync("bun run build:binary", { cwd: ROOT, stdio: "inherit" }); diff --git a/scripts/check-linter-plaintext.mjs b/scripts/check-linter-plaintext.mjs new file mode 100644 index 0000000..70d207c --- /dev/null +++ b/scripts/check-linter-plaintext.mjs @@ -0,0 +1,16 @@ +#!/usr/bin/env bun +// CI/本地防漂移:checkers/ 源码改动后若忘记跑 generate:linter-plaintext,这里红。 +import { execSync } from "node:child_process"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; + +const ROOT = join(import.meta.dirname, ".."); +const generated = join(ROOT, "src/domains/seal/linter/plaintext.generated.ts"); +const before = readFileSync(generated, "utf8"); +execSync("bun run scripts/generate-linter-plaintext.mjs", { cwd: ROOT, stdio: "ignore" }); +const after = readFileSync(generated, "utf8"); +if (before !== after) { + console.error("❌ linter/checkers/ 与 plaintext.generated.ts 不同步;请运行 bun run generate:linter-plaintext 并提交"); + process.exit(1); +} +console.log("✓ linter plaintext 与 checkers 源码同步"); diff --git a/scripts/generate-linter-plaintext.mjs b/scripts/generate-linter-plaintext.mjs new file mode 100644 index 0000000..96ad32b --- /dev/null +++ b/scripts/generate-linter-plaintext.mjs @@ -0,0 +1,40 @@ +#!/usr/bin/env bun +// 生成 src/domains/seal/linter/plaintext.generated.ts: +// 把 manifest 中 plaintext: true 的官方校验器源码嵌入为字符串, +// 供 syncOfficialLinters 写入 ~/.config/seal-use/linters/official/。 +// 修改 checkers/ 下任一源码后运行 `bun run generate:linter-plaintext` 刷新。 +import { readFileSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; + +const ROOT = join(import.meta.dirname, ".."); +const manifestPath = join(ROOT, "src/domains/seal/linter/manifest.ts"); +const generatedPath = join(ROOT, "src/domains/seal/linter/plaintext.generated.ts"); + +// 从 manifest.ts 提取 (name, file, plaintext) —— 保持与运行时同一份清单 +const manifestSource = readFileSync(manifestPath, "utf8"); +const entries = [...manifestSource.matchAll( + /name: "([a-z0-9-]+)",\s*\n\s*file: "([a-z.]+)",\s*\n\s*plaintext: (true|false)/g +)].map((m) => ({ name: m[1], file: m[2], plaintext: m[3] === "true" })); + +if (entries.length === 0) { + console.error("❌ 未从 manifest.ts 解析到任何校验器条目"); + process.exit(1); +} + +const plaintext = {}; +for (const entry of entries) { + if (!entry.plaintext) continue; + const filePath = join(ROOT, "src/domains/seal/linter/checkers", entry.file); + plaintext[entry.file] = readFileSync(filePath, "utf8"); +} + +const banner = + "/**\n * 生成文件 —— 由 scripts/generate-linter-plaintext.mjs 从 linter/checkers/ 生成,勿手改。\n" + + ` * 明文下发的官方校验器源码(manifest.ts 中 plaintext: true 的条目)。\n */\n`; + +const content = + banner + + `export const OFFICIAL_LINTER_PLAINTEXT: Record = ${JSON.stringify(plaintext, null, 2)};\n`; + +writeFileSync(generatedPath, content); +console.log(`✓ 已生成 plaintext.generated.ts(${Object.keys(plaintext).length} 个明文校验器: ${Object.keys(plaintext).join(", ")})`); diff --git a/skills/seal-use/references/rule-lint.md b/skills/seal-use/references/rule-lint.md index 565dc22..782a111 100644 --- a/skills/seal-use/references/rule-lint.md +++ b/skills/seal-use/references/rule-lint.md @@ -53,6 +53,16 @@ seal-use config lint disable ## Official Linters +校验器分三层,加载顺序:CLI 内置 → 官方明文版 → 用户自定义。 + +| 层 | 位置 | 说明 | +| :--- | :--- | :--- | +| 内置引擎 | 编译进二进制 | 永远可用,`builtin` 即此层 | +| 官方明文版 | `~/.config/seal-use/linters/official/` | `syncOfficialLinters` 自动同步,改动会被覆盖;agent 可直接阅读源码理解校验逻辑 | +| 用户自定义 | `~/.config/seal-use/linters/.ts`(全局唯一位置) | 私有脚本,跨项目共用;不再从项目 cwd 读取 | + +哪些官方校验器明文下发由 `src/domains/seal/linter/manifest.ts` 的 `plaintext` 标记决定:`true` 的条目源码会被写入 `official/`(源码嵌入物 `plaintext.generated.ts` 由 `bun run generate:linter-plaintext` 从 `linter/checkers/` 生成,改动校验器后必须重跑并提交,CI 的 `verify:linter-plaintext` 会拦截漂移);`false` 的条目只以进程内函数存在、不下发明文。 + | Linter Name | Scope & Purpose | Aliases | | :--- | :--- | :--- | | `builtin` | Seal 官方标准校验器:拦截过短描述、主观模糊词与悬空例外条款。 | `default`, `official/builtin` | diff --git a/src/core/doctor/diagnose.ts b/src/core/doctor/diagnose.ts index 87da465..a58b214 100644 --- a/src/core/doctor/diagnose.ts +++ b/src/core/doctor/diagnose.ts @@ -92,7 +92,7 @@ function listCredentialFilePaths(dir: string): string[] { /** * The tool writes credential-bearing files 0o600 (`core/config/loader.ts`, * `cli/commands/corps.ts`, `core/auth/token-store.ts`), but a file placed by hand keeps the - * 0o644 default — and `enterprises/local.json` holds a plaintext Hose app key and password. + * 0o644 default — holds a plaintext Hose app key and password. * Report those rather than assuming the writers' mode. */ function findGroupOrWorldReadable(paths: string[]): string[] { diff --git a/src/domains/seal/linter/builtin.ts b/src/domains/seal/linter/checkers/builtin.ts similarity index 99% rename from src/domains/seal/linter/builtin.ts rename to src/domains/seal/linter/checkers/builtin.ts index 4872298..7485889 100644 --- a/src/domains/seal/linter/builtin.ts +++ b/src/domains/seal/linter/checkers/builtin.ts @@ -1,4 +1,4 @@ -import type { RuleLintIssue, RuleLintResult, RuleLintTarget } from "./types.js"; +import type { RuleLintIssue, RuleLintResult, RuleLintTarget } from "../types.js"; export const BUILTIN_VAGUE_WORDS = [ "原则上", diff --git a/src/domains/seal/linter/hlab.ts b/src/domains/seal/linter/checkers/hlab.ts similarity index 99% rename from src/domains/seal/linter/hlab.ts rename to src/domains/seal/linter/checkers/hlab.ts index 5aa6f48..ff5a8c4 100644 --- a/src/domains/seal/linter/hlab.ts +++ b/src/domains/seal/linter/checkers/hlab.ts @@ -1,4 +1,4 @@ -import type { RuleLintIssue, RuleLintResult, RuleLintTarget } from "./types.js"; +import type { RuleLintIssue, RuleLintResult, RuleLintTarget } from "../types.js"; export const HLAB_DISPOSAL_WORDS = [ "驳回单据", diff --git a/src/domains/seal/linter/strict.ts b/src/domains/seal/linter/checkers/strict.ts similarity index 99% rename from src/domains/seal/linter/strict.ts rename to src/domains/seal/linter/checkers/strict.ts index 77840f8..cebd84e 100644 --- a/src/domains/seal/linter/strict.ts +++ b/src/domains/seal/linter/checkers/strict.ts @@ -1,4 +1,4 @@ -import type { RuleLintIssue, RuleLintResult, RuleLintTarget } from "./types.js"; +import type { RuleLintIssue, RuleLintResult, RuleLintTarget } from "../types.js"; export const STRICT_VAGUE_WORDS = [ "原则上", diff --git a/src/domains/seal/linter/index.ts b/src/domains/seal/linter/index.ts index 0b0c868..8929bed 100644 --- a/src/domains/seal/linter/index.ts +++ b/src/domains/seal/linter/index.ts @@ -1,7 +1,7 @@ export * from "./types.js"; -export * from "./builtin.js"; -export * from "./strict.js"; -export * from "./hlab.js"; -export * from "./official-templates.js"; +export * from "./manifest.js"; +export * from "./checkers/builtin.js"; +export * from "./checkers/strict.js"; +export * from "./checkers/hlab.js"; export * from "./loader.js"; export * from "./service.js"; diff --git a/src/domains/seal/linter/linter.test.ts b/src/domains/seal/linter/linter.test.ts index 3ca9c15..d6743f9 100644 --- a/src/domains/seal/linter/linter.test.ts +++ b/src/domains/seal/linter/linter.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "bun:test"; -import { builtinRuleLinter } from "./builtin.js"; +import { builtinRuleLinter } from "./checkers/builtin.js"; import { loadRuleLinter } from "./loader.js"; import { lintRuleBatch } from "./service.js"; import { writeFileSync, unlinkSync, mkdirSync, existsSync } from "node:fs"; @@ -111,7 +111,7 @@ describe("Rule Linter", () => { }); test("strictRuleLinter enforces higher standards for quantitative constraints, approvers, and exceptions", async () => { - const { strictRuleLinter } = await import("./strict.js"); + const { strictRuleLinter } = await import("./checkers/strict.js"); // 1. 少于 10 字告警 const shortRes = strictRuleLinter({ description: "不能报销打车费" }); @@ -160,16 +160,16 @@ describe("Rule Linter", () => { expect(existsSync(join(testOfficialDir, "hlab.ts"))).toBe(true); const builtinPlaintext = readFileSync(join(testOfficialDir, "builtin.ts"), "utf8"); - expect(builtinPlaintext).toContain("Seal 官方标准规则校验器"); - expect(builtinPlaintext).toContain("export function lintRule"); + expect(builtinPlaintext).toContain("BUILTIN_VAGUE_WORDS"); + expect(builtinPlaintext).toContain("export function builtinRuleLinter"); const strictPlaintext = readFileSync(join(testOfficialDir, "strict.ts"), "utf8"); - expect(strictPlaintext).toContain("Seal 官方严格风控规则校验器"); expect(strictPlaintext).toContain("STRICT_QUANTITATIVE_INDICATORS"); + expect(strictPlaintext).toContain("export function strictRuleLinter"); const hlabPlaintext = readFileSync(join(testOfficialDir, "hlab.ts"), "utf8"); - expect(hlabPlaintext).toContain("合思实验室 (HLab) 结构化规则校验器"); expect(hlabPlaintext).toContain("HLAB_DISPOSAL_WORDS"); + expect(hlabPlaintext).toContain("export function hlabRuleLinter"); // 2. 模拟客户私自篡改 official/builtin.ts writeFileSync(join(testOfficialDir, "builtin.ts"), "// HACKED CONTENT", "utf8"); @@ -187,7 +187,7 @@ describe("Rule Linter", () => { // 验证官方文件已恢复明文 const restoredContent = readFileSync(join(testOfficialDir, "builtin.ts"), "utf8"); - expect(restoredContent).toContain("Seal 官方标准规则校验器"); + expect(restoredContent).toContain("export function builtinRuleLinter"); expect(restoredContent).not.toContain("// HACKED CONTENT"); // 验证多余文件已被清理干掉 @@ -211,7 +211,7 @@ describe("Rule Linter", () => { }); test("hlabRuleLinter enforces HLab SOP structure, ternary closure, action decoupling, and false-skip prevention", async () => { - const { hlabRuleLinter } = await import("./hlab.js"); + const { hlabRuleLinter } = await import("./checkers/hlab.js"); // 1. 标准 HLab 结构化规则:满分通过 const perfectRule = { diff --git a/src/domains/seal/linter/loader.ts b/src/domains/seal/linter/loader.ts index d68005a..5cf2e8a 100644 --- a/src/domains/seal/linter/loader.ts +++ b/src/domains/seal/linter/loader.ts @@ -2,15 +2,14 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, unlinkSync, w import { isAbsolute, join, resolve } from "node:path"; import { pathToFileURL } from "node:url"; import { PRIMARY_LINTERS_DIR, OFFICIAL_LINTERS_DIR } from "../../../core/paths.js"; -import { builtinRuleLinter } from "./builtin.js"; -import { hlabRuleLinter } from "./hlab.js"; -import { OFFICIAL_LINTER_TEMPLATES } from "./official-templates.js"; -import { strictRuleLinter } from "./strict.js"; +import { builtinRuleLinter } from "./checkers/builtin.js"; +import { OFFICIAL_LINTERS } from "./manifest.js"; +import { OFFICIAL_LINTER_PLAINTEXT } from "./plaintext.generated.js"; + +// 明文源码字符串由生成物提供(见 scripts/generate-linter-plaintext.mjs),勿手改 import type { RuleLintContext, RuleLintResult, RuleLintTarget, RuleLinterFn } from "./types.js"; export { PRIMARY_LINTERS_DIR, OFFICIAL_LINTERS_DIR }; -export const OFFICIAL_SUBDIR_NAME = "official"; -export const LOCAL_LINTERS_DIR = join(process.cwd(), "linters"); export interface LoadedLinter { name: string; @@ -27,8 +26,10 @@ export interface AvailableLinterItem { } /** - * 强制同步官方内置校验器明文文件,并清理 official 子目录下的任何非官方多余文件。 - * 用户 AI Agent 可直接阅读 official/ 下的源码;用户在 official/ 内所作的修改会被自动覆盖。 + * 强制同步"明文下发"的官方校验器到 ~/.config/seal-use/linters/official/, + * 并清理 official 目录下任何非清单内的多余文件。 + * 哪些校验器明文下发由 manifest.ts 的 plaintext 标记决定; + * 明文源码字符串由 plaintext.generated.ts 提供(生成物,勿手改)。 */ export function syncOfficialLinters(officialDir = OFFICIAL_LINTERS_DIR): { synced: string[]; @@ -42,33 +43,32 @@ export function syncOfficialLinters(officialDir = OFFICIAL_LINTERS_DIR): { mkdirSync(officialDir, { recursive: true }); } - const officialFiles = Object.keys(OFFICIAL_LINTER_TEMPLATES); + const exposed = OFFICIAL_LINTERS.filter((meta) => meta.plaintext); + const exposedFiles = exposed.map((meta) => meta.file); - // 1. 强制写入/覆盖官方校验器明文源码 - for (const [filename, templateContent] of Object.entries(OFFICIAL_LINTER_TEMPLATES)) { - const targetPath = join(officialDir, filename); + for (const meta of exposed) { + const targetPath = join(officialDir, meta.file); + const templateContent = OFFICIAL_LINTER_PLAINTEXT[meta.file]; + if (!templateContent) continue; let needsWrite = true; if (existsSync(targetPath)) { try { - const currentContent = readFileSync(targetPath, "utf8"); - if (currentContent === templateContent) { + if (readFileSync(targetPath, "utf8") === templateContent) { needsWrite = false; } } catch { needsWrite = true; } } - if (needsWrite) { writeFileSync(targetPath, templateContent, "utf8"); } - synced.push(filename); + synced.push(meta.file); } - // 2. 清理 official/ 目录下用户误建或第三方写入的多余文件/子目录 const existingEntries = readdirSync(officialDir, { withFileTypes: true }); for (const entry of existingEntries) { - if (!officialFiles.includes(entry.name)) { + if (!exposedFiles.includes(entry.name)) { const fullPath = join(officialDir, entry.name); try { if (entry.isDirectory()) { @@ -90,61 +90,41 @@ export function syncOfficialLinters(officialDir = OFFICIAL_LINTERS_DIR): { } /** - * 列出所有可用的规则校验器:包括 official/ 目录下的官方规则和外层目录下的用户自定义规则。 + * 列出所有可用的规则校验器:官方清单 + ~/.config/seal-use/linters/ 下的用户自定义脚本。 */ export function listAvailableLinters(options: { syncOfficial?: boolean } = { syncOfficial: true }): AvailableLinterItem[] { if (options.syncOfficial !== false) { syncOfficialLinters(); } - const list: AvailableLinterItem[] = [ - { - name: "builtin", - type: "builtin", - path: join(OFFICIAL_LINTERS_DIR, "builtin.ts"), - description: "Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)" - }, - { - name: "strict", - type: "official", - path: join(OFFICIAL_LINTERS_DIR, "strict.ts"), - description: "Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)" - }, - { - name: "hlab", - type: "official", - path: join(OFFICIAL_LINTERS_DIR, "hlab.ts"), - description: "合思实验室 (HLab) 结构化规则校验器 (SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判)" - } - ]; + const list: AvailableLinterItem[] = OFFICIAL_LINTERS.map((meta) => ({ + name: meta.name, + type: meta.name === "builtin" ? ("builtin" as const) : ("official" as const), + path: join(OFFICIAL_LINTERS_DIR, meta.file), + description: meta.description + })); - // 扫描用户自定义规则(仅扫描外层目录,忽略 official 子目录) - const searchDirs = [PRIMARY_LINTERS_DIR, LOCAL_LINTERS_DIR]; - for (const dir of searchDirs) { - if (existsSync(dir)) { - try { - const entries = readdirSync(dir, { withFileTypes: true }); - for (const entry of entries) { - if (entry.isDirectory()) { - // 排除 official 子目录及任何其他子目录 - continue; - } - const file = entry.name; - if (file.endsWith(".ts") || file.endsWith(".js") || file.endsWith(".mjs")) { - const baseName = file.replace(/\.(ts|js|mjs)$/, ""); - if (!list.some((item) => item.name === baseName)) { - list.push({ - name: baseName, - type: "custom", - path: join(dir, file), - description: `用户自定义规则校验器 (${file})` - }); - } + // 用户自定义:仅扫描全局私有目录(忽略 official 子目录) + if (existsSync(PRIMARY_LINTERS_DIR)) { + try { + const entries = readdirSync(PRIMARY_LINTERS_DIR, { withFileTypes: true }); + for (const entry of entries) { + if (entry.isDirectory()) continue; + const file = entry.name; + if (file.endsWith(".ts") || file.endsWith(".js") || file.endsWith(".mjs")) { + const baseName = file.replace(/\.(ts|js|mjs)$/, ""); + if (!list.some((item) => item.name === baseName)) { + list.push({ + name: baseName, + type: "custom", + path: join(PRIMARY_LINTERS_DIR, file), + description: `用户自定义规则校验器 (${file})` + }); } } - } catch { - // 忽略目录读取异常 } + } catch { + // 忽略目录读取异常 } } @@ -154,38 +134,15 @@ export function listAvailableLinters(options: { syncOfficial?: boolean } = { syn export function resolveLinterPath(nameOrPath: string): { path?: string; isOfficial?: boolean; - officialKind?: "builtin" | "strict" | "hlab"; + officialKind?: string; } { const norm = (nameOrPath || "").trim(); - if (!norm || norm === "builtin" || norm === "default" || norm === "official/builtin" || norm === "official/builtin.ts") { - return { - path: join(OFFICIAL_LINTERS_DIR, "builtin.ts"), - isOfficial: true, - officialKind: "builtin" - }; - } - if (norm === "strict" || norm === "official/strict" || norm === "official/strict.ts") { - return { - path: join(OFFICIAL_LINTERS_DIR, "strict.ts"), - isOfficial: true, - officialKind: "strict" - }; - } - - if ( - norm === "hlab" || - norm === "hlab-sop" || - norm === "hlab-rules" || - norm === "hlab-standard" || - norm === "official/hlab" || - norm === "official/hlab.ts" - ) { - return { - path: join(OFFICIAL_LINTERS_DIR, "hlab.ts"), - isOfficial: true, - officialKind: "hlab" - }; + const official = OFFICIAL_LINTERS.find( + (meta) => norm === meta.name || (meta.aliases ?? []).includes(norm) || norm === `official/${meta.name}` || norm === `official/${meta.file}` + ); + if (official) { + return { path: join(OFFICIAL_LINTERS_DIR, official.file), isOfficial: true, officialKind: official.name }; } // 显式相对或绝对路径 @@ -197,18 +154,10 @@ export function resolveLinterPath(nameOrPath: string): { } } - // 自定义规则名称:仅在外层目录中搜索,绝不在 official/ 子目录中搜索 - const candidates = [ - join(PRIMARY_LINTERS_DIR, `${norm}.ts`), - join(PRIMARY_LINTERS_DIR, `${norm}.js`), - join(PRIMARY_LINTERS_DIR, `${norm}.mjs`), - join(LOCAL_LINTERS_DIR, `${norm}.ts`), - join(LOCAL_LINTERS_DIR, `${norm}.js`), - join(LOCAL_LINTERS_DIR, `${norm}.mjs`) - ]; - - for (const cPath of candidates) { - if (existsSync(cPath)) return { path: cPath }; + // 自定义校验器:仅搜索全局私有目录 + for (const ext of [".ts", ".js", ".mjs"]) { + const candidate = join(PRIMARY_LINTERS_DIR, `${norm}${ext}`); + if (existsSync(candidate)) return { path: candidate }; } return {}; @@ -220,14 +169,10 @@ export async function loadRuleLinter(nameOrPath?: string): Promise const resolution = resolveLinterPath(nameOrPath ?? "builtin"); - // 1. 处理官方内置校验器 (builtin / strict / hlab) + // 1. 官方校验器(builtin / strict / hlab) if (resolution.isOfficial) { - const fallbackFn = - resolution.officialKind === "strict" - ? strictRuleLinter - : resolution.officialKind === "hlab" - ? hlabRuleLinter - : builtinRuleLinter; + const meta = OFFICIAL_LINTERS.find((item) => item.name === resolution.officialKind)!; + const fallbackFn = meta.fallback; const kind = resolution.officialKind === "builtin" ? "builtin" : "official"; const officialPath = resolution.path; @@ -238,7 +183,7 @@ export async function loadRuleLinter(nameOrPath?: string): Promise const candidateFn = mod.default ?? mod.lintRule ?? mod.linter ?? mod.lint; if (typeof candidateFn === "function") { return { - name: resolution.officialKind ?? "builtin", + name: meta.name, type: kind, filePath: officialPath, linter: wrapSafeLinter(candidateFn, fallbackFn) @@ -250,14 +195,14 @@ export async function loadRuleLinter(nameOrPath?: string): Promise } return { - name: resolution.officialKind ?? "builtin", + name: meta.name, type: kind, filePath: officialPath, linter: fallbackFn }; } - // 2. 处理用户自定义校验器 + // 2. 用户自定义校验器 const resolvedPath = resolution.path; if (!resolvedPath) { console.error(`⚠️ [linter] 未找到自定义校验器 "${nameOrPath}",已自动安全降级至内置标准校验器。`); diff --git a/src/domains/seal/linter/manifest.ts b/src/domains/seal/linter/manifest.ts new file mode 100644 index 0000000..fd2427e --- /dev/null +++ b/src/domains/seal/linter/manifest.ts @@ -0,0 +1,52 @@ +import type { RuleLinterFn } from "./types.js"; +import { builtinRuleLinter } from "./checkers/builtin.js"; +import { hlabRuleLinter } from "./checkers/hlab.js"; +import { strictRuleLinter } from "./checkers/strict.js"; + +/** + * 官方校验器清单 —— "存在哪些校验器、是否明文下发"的唯一事实源。 + * + * - `plaintext: true` 的条目,其源码会被 `syncOfficialLinters` 明文写入 + * `~/.config/seal-use/linters/official/`(源码字符串由 + * `plaintext.generated.ts` 提供,经 `bun run generate:linter-plaintext` 从本目录生成,勿手改)。 + * - `plaintext: false` 的条目只以进程内函数存在,不下发明文。 + */ +export interface OfficialLinterMeta { + /** 调用名(rules lint --linter ) */ + name: string; + /** linters/ 下的源码文件名 */ + file: string; + /** 是否明文下发到 ~/.config/seal-use/linters/official/ */ + plaintext: boolean; + description: string; + /** 兼容别名 */ + aliases?: string[]; + /** 明文文件缺失/损坏时的进程内回退实现 */ + fallback: RuleLinterFn; +} + +export const OFFICIAL_LINTERS: OfficialLinterMeta[] = [ + { + name: "builtin", + file: "builtin.ts", + plaintext: true, + description: "Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)", + aliases: ["default"], + fallback: builtinRuleLinter + }, + { + name: "strict", + file: "strict.ts", + plaintext: true, + description: "Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)", + fallback: strictRuleLinter + }, + { + name: "hlab", + file: "hlab.ts", + plaintext: true, + description: "合思实验室 (HLab) 结构化规则校验器 (SOP 四段论结构、三元闭环判定、剥离处置动作与防漏判)", + aliases: ["hlab-sop", "hlab-rules", "hlab-standard"], + fallback: hlabRuleLinter + } +]; diff --git a/src/domains/seal/linter/official-templates.ts b/src/domains/seal/linter/official-templates.ts deleted file mode 100644 index 66d95a7..0000000 --- a/src/domains/seal/linter/official-templates.ts +++ /dev/null @@ -1,580 +0,0 @@ -/** - * 官方内置规则校验器源码模板。 - * 这些文件以明文 TypeScript 格式写入 ~/.config/seal-use/linters/official/ 目录, - * 供用户和 AI Agent 直接阅读、学习和执行。 - */ - -export const OFFICIAL_BUILTIN_LINTER_SOURCE = `/** - * ============================================================================== - * Seal 官方标准规则校验器 (Official Standard Rule Linter) - * ============================================================================== - * - * 存放路径: ~/.config/seal-use/linters/official/builtin.ts - * 维护说明: 本文件由 seal-use 官方自动同步并保护。 - * 每次运行时系统会自动重写本文件并清理 official/ 目录下的非官方文件。 - * 若您需要编写企业私有规则校验器,请将自定义 .ts 文件放置在外层的用户目录: - * ~/.config/seal-use/linters/ 即可,系统将自动识别并加载。 - */ - -export interface RuleLintTarget { - id?: string; - code?: string; - name?: string; - description: string; - scope?: string; - strictness?: string; -} - -export interface RuleLintIssue { - level: "error" | "warning"; - code: string; - message: string; - snippet?: string; - suggestion?: string; -} - -export interface RuleLintResult { - score: number; - passed: boolean; - issues: RuleLintIssue[]; -} - -export const BUILTIN_VAGUE_WORDS = [ - "原则上", - "尽量", - "适当", - "酌情", - "一般情况下", - "尽可能", - "合理控制", - "视情况", - "视具体情况" -]; - -export const BUILTIN_EXCEPTION_TRIGGERS = [ - "除非", - "特殊情况", - "特殊原因", - "经批准", - "经审批", - "经领导同意", - "除外", - "例外" -]; - -export const BUILTIN_EVIDENCE_KEYWORDS = [ - "备注", - "说明", - "附件", - "证明", - "邮件", - "截图", - "凭证", - "审批", - "单据", - "发票" -]; - -export function lintRule(rule: RuleLintTarget): RuleLintResult { - const text = (rule.description || "").trim(); - const issues: RuleLintIssue[] = []; - - // 1. 规则过短检查 - if (text.length < 5) { - issues.push({ - level: "error", - code: "TOO_SHORT", - message: "规则描述过于简短(少于 5 个字),大模型难以形成明确的判定逻辑", - suggestion: "请补充具体的费用类型、核验条件与限制标准" - }); - } - - // 2. 主观模糊词拦截 - for (const word of BUILTIN_VAGUE_WORDS) { - if (text.includes(word)) { - issues.push({ - level: "error", - code: "VAGUE_WORD", - snippet: word, - message: \`包含主观模糊词 "\${word}",容易导致大模型判定标准产生波动与幻觉\`, - suggestion: \`建议移除 "\${word}",改为具体的金额上限、枚举范围或刚性判定条件\` - }); - } - } - - // 3. 悬空例外条款检测 - const matchedTrigger = BUILTIN_EXCEPTION_TRIGGERS.find((trigger) => text.includes(trigger)); - const hasEvidence = BUILTIN_EVIDENCE_KEYWORDS.some((kw) => text.includes(kw)); - - if (matchedTrigger && !hasEvidence) { - issues.push({ - level: "warning", - code: "HANGING_EXCEPTION", - snippet: matchedTrigger, - message: \`包含例外条款 "\${matchedTrigger}",但未指定 AI 从何处核验该例外成立的依据\`, - suggestion: "建议补充明确的凭据来源(例如:需在【单据备注】中说明原因,或在【附件】中上传审批截图)" - }); - } - - const errorCount = issues.filter((i) => i.level === "error").length; - const warningCount = issues.filter((i) => i.level === "warning").length; - const score = Math.max(0, 100 - errorCount * 25 - warningCount * 10); - - return { - score, - passed: errorCount === 0, - issues - }; -} - -export default lintRule; -`; - -export const OFFICIAL_STRICT_LINTER_SOURCE = `/** - * ============================================================================== - * Seal 官方严格风控规则校验器 (Official Strict Risk Rule Linter) - * ============================================================================== - * - * 存放路径: ~/.config/seal-use/linters/official/strict.ts - * 维护说明: 本文件由 seal-use 官方自动同步并保护。 - * 每次运行时系统会自动重写本文件并清理 official/ 目录下的非官方文件。 - * 若您需要编写企业私有规则校验器,请将自定义 .ts 文件放置在外层的用户目录: - * ~/.config/seal-use/linters/ 即可,系统将自动识别并加载。 - */ - -export interface RuleLintTarget { - id?: string; - code?: string; - name?: string; - description: string; - scope?: string; - strictness?: string; -} - -export interface RuleLintIssue { - level: "error" | "warning"; - code: string; - message: string; - snippet?: string; - suggestion?: string; -} - -export interface RuleLintResult { - score: number; - passed: boolean; - issues: RuleLintIssue[]; -} - -export const STRICT_VAGUE_WORDS = [ - "原则上", - "尽量", - "适当", - "酌情", - "一般情况下", - "尽可能", - "合理控制", - "视情况", - "视具体情况", - "必要时", - "及时", - "适量", - "差不多", - "相关部门" -]; - -export const STRICT_EXCEPTION_TRIGGERS = [ - "除非", - "特殊情况", - "特殊原因", - "经批准", - "经审批", - "经领导同意", - "除外", - "例外" -]; - -export const STRICT_EVIDENCE_KEYWORDS = [ - "备注", - "说明", - "附件", - "证明", - "邮件", - "截图", - "凭证", - "审批", - "单据", - "发票" -]; - -export const STRICT_QUANTITATIVE_INDICATORS = [ - "¥", - "$", - "€", - "元", - "不得超过", - "不超过", - "超过", - "低于", - "不低于", - "最高", - "封顶", - "限额", - "禁止", - "严禁", - "必须", - "不予", - "仅限", - "每人", - "每日", - "每月", - "每年", - "每次", - "单笔" -]; - -export const STRICT_SPECIFIC_APPROVERS = [ - "总监", - "VP", - "总经理", - "直接上级", - "部门负责人", - "项目经理", - "财务", - "分管领导", - "HR", - "CEO" -]; - -export function lintRule(rule: RuleLintTarget): RuleLintResult { - const text = (rule.description || "").trim(); - const issues: RuleLintIssue[] = []; - - // 1. 规则长度检查 (严格模式下少于 10 字进行警告) - if (text.length < 5) { - issues.push({ - level: "error", - code: "TOO_SHORT", - message: "规则描述过于简短(少于 5 个字),大模型难以形成明确的判定逻辑", - suggestion: "请补充具体的费用类型、核验条件与限制标准" - }); - } else if (text.length < 10) { - issues.push({ - level: "warning", - code: "SHORT_DESCRIPTION", - message: "规则描述偏短(少于 10 个字),可能缺少适用的单据范围或执行细节", - suggestion: "建议扩充核验场景、限制标准或异常处理方式" - }); - } - - // 2. 主观模糊词拦截(严格词库) - for (const word of STRICT_VAGUE_WORDS) { - if (text.includes(word)) { - issues.push({ - level: "error", - code: "VAGUE_WORD", - snippet: word, - message: \`包含主观模糊词 "\${word}",在严格风控模式下容易引起审核判定分歧\`, - suggestion: \`请移除 "\${word}",明确量化标准或枚举具体允许的情形\` - }); - } - } - - // 3. 例外条款与凭据要求(严格模式下无凭据直接判定为 Error 阻断) - const matchedTrigger = STRICT_EXCEPTION_TRIGGERS.find((trigger) => text.includes(trigger)); - const hasEvidence = STRICT_EVIDENCE_KEYWORDS.some((kw) => text.includes(kw)); - - if (matchedTrigger && !hasEvidence) { - issues.push({ - level: "error", - code: "HANGING_EXCEPTION", - snippet: matchedTrigger, - message: \`包含例外条款 "\${matchedTrigger}",但未指定 AI 从何处核验该例外成立的凭证依据\`, - suggestion: "严格模式要求必须补充明确的核验来源(如:需在【单据备注】中说明原因,或在【附件】中提供审批截图)" - }); - } - - // 4. 定量约束或刚性边界检查 - const hasNumber = /\\d+/.test(text); - const hasConstraint = STRICT_QUANTITATIVE_INDICATORS.some((kw) => text.includes(kw)); - if (!hasNumber && !hasConstraint) { - issues.push({ - level: "warning", - code: "LACKS_EXPLICIT_CONSTRAINT", - message: "规则缺乏明确的定量标准(如金额、天数、频次)或绝对刚性边界词(如不得、禁止、仅限)", - suggestion: "建议设定具体数值阈值或明确的禁止/准入条件,以便大模型精确判定" - }); - } - - // 5. 审批角色具体化检查 - const mentionsApproval = /经(批准|审批|领导同意|领导签字)|审批通过/.test(text); - const hasSpecificApprover = STRICT_SPECIFIC_APPROVERS.some((approver) => text.includes(approver)); - if (mentionsApproval && !hasSpecificApprover) { - issues.push({ - level: "warning", - code: "AMBIGUOUS_APPROVER", - message: "规则提及审批例外,但未明确指定具体的审批角色(如部门总监、直接上级、财务负责人)", - suggestion: "建议明确审批人角色(例如:经【部门总监】批准,经【直接上级】邮件确认)" - }); - } - - const errorCount = issues.filter((i) => i.level === "error").length; - const warningCount = issues.filter((i) => i.level === "warning").length; - const score = Math.max(0, 100 - errorCount * 30 - warningCount * 15); - - return { - score, - passed: errorCount === 0, - issues - }; -} - -export default lintRule; -`; - -export const OFFICIAL_HLAB_LINTER_SOURCE = `/** - * ============================================================================== - * 合思实验室 (HLab) 结构化规则校验器 (HLab Structured SOP Rule Linter) - * ============================================================================== - * - * 存放路径: ~/.config/seal-use/linters/official/hlab.ts - * 维护说明: 本文件由 seal-use 官方自动同步并保护。 - * 每次运行时系统会自动重写本文件并清理 official/ 目录下的非官方文件。 - * 若您需要编写企业私有规则校验器,请将自定义 .ts 文件放置在外层的用户目录: - * ~/.config/seal-use/linters/ 即可,系统将自动识别并加载。 - */ - -export interface RuleLintTarget { - id?: string; - code?: string; - name?: string; - description: string; - scope?: string; - strictness?: string; -} - -export interface RuleLintIssue { - level: "error" | "warning"; - code: string; - message: string; - snippet?: string; - suggestion?: string; -} - -export interface RuleLintResult { - score: number; - passed: boolean; - issues: RuleLintIssue[]; -} - -export const HLAB_DISPOSAL_WORDS = [ - "驳回单据", - "直接驳回", - "整单退回", - "退回单据", - "退单处理", - "进行提醒", - "请进行提醒", - "予以驳回", - "直接退回", - "无需人工关注", - "无需展示在最后的审核结论中" -]; - -export const HLAB_SCOPE_SKIP_WORDS = [ - "若上传了", - "如上传了", - "若提供了", - "如提供了", - "附件需上传", - "上传了发票", - "提供了支付截图", - "提供了行程单", - "上传了行程单" -]; - -export const HLAB_RISK_SUPPRESSION_WORDS = [ - "忽略行程冲突", - "忽略重复报销", - "忽略跨城一致性", - "不识别为风险", - "不作为风险事项", - "无需作为风险" -]; - -export const HLAB_EXCEPTION_TRIGGERS = [ - "除非", - "特殊情况", - "特殊原因", - "经批准", - "经审批", - "经领导同意", - "除外", - "例外" -]; - -export const HLAB_EVIDENCE_KEYWORDS = [ - "备注", - "说明", - "附件", - "证明", - "邮件", - "截图", - "凭证", - "审批", - "单据", - "发票", - "流程" -]; - -export function lintRule(rule: RuleLintTarget): RuleLintResult { - const text = (rule.description || "").trim(); - const scopeText = (rule.scope || "").trim(); - const issues: RuleLintIssue[] = []; - - // 1. 规则长度检查 - if (text.length < 10) { - issues.push({ - level: "error", - code: "TOO_SHORT", - message: "规则描述过于简短(少于 10 个字),无法承载 HLab 结构化规范所要求的判定逻辑", - suggestion: "请按照 HLab 工业化规范补充【检查方法】与【判定标准】" - }); - } else if (text.length < 30 && !text.includes("**") && !text.includes("检查方法")) { - issues.push({ - level: "warning", - code: "SHORT_DESCRIPTION", - message: "规则正文偏短且缺少结构化要素,可能缺少执行细节或证据边界", - suggestion: "建议扩充核验场景、限制标准或异常处理方式" - }); - } - - // 2. 结构完备性检查 - const hasMethod = /\\*\\*检查方法\\*\\*|检查方法[::]/.test(text); - if (!hasMethod) { - issues.push({ - level: "error", - code: "MISSING_CHECK_METHOD", - message: "规则正文缺少【检查方法】结构块,大模型难以确定数据提取来源与对齐逻辑", - suggestion: "建议在正文前部增加 **检查方法**:明确 SealAI 应读取的凭证类型、字段名称、归一化方式或前置规则依赖" - }); - } - - const hasStandard = /\\*\\*判定标准\\*\\*|判定标准[::]/.test(text); - if (!hasStandard) { - issues.push({ - level: "error", - code: "MISSING_EVAL_STANDARD", - message: "规则正文缺少【判定标准】结构块,缺乏标准化判定边界", - suggestion: "建议在正文后部增加 **判定标准**:包含清晰的 PASS、FAIL 以及证据不足分支" - }); - } - - // 3. 三元闭环判定检查 - const hasPass = /[-*•]?\\s*PASS[::]/i.test(text); - const hasFail = /[-*•]?\\s*FAIL[::]/i.test(text); - const hasInsufficient = /[-*•]?\\s*证据不足[::]/.test(text); - - if (!hasPass || !hasFail || !hasInsufficient) { - const missing: string[] = []; - if (!hasPass) missing.push("PASS"); - if (!hasFail) missing.push("FAIL"); - if (!hasInsufficient) missing.push("证据不足"); - issues.push({ - level: "error", - code: "INCOMPLETE_TERNARY_BRANCH", - message: \`判定标准未形成三元闭环,缺少分支:\${missing.join("、")}\`, - suggestion: "HLab 规范要求必须提供完整的三元分支:- PASS(充分合规条件)、- FAIL(明确违规条件)、- 证据不足(容错与复核条件)" - }); - } - - // 4. 证据不足分支人工复核兜底检查 - if (hasInsufficient) { - const snippet = text.split("证据不足")?.[1]?.slice(0, 100) || ""; - const hasManualReview = /人工复核|人工核对|人工审核|转人工/.test(snippet); - if (!hasManualReview) { - issues.push({ - level: "warning", - code: "INSUFFICIENT_WITHOUT_MANUAL_REVIEW", - message: "【证据不足】分支未明确指定转【人工复核】兜底,大模型在材料模糊或冲突时可能失控", - suggestion: "建议在【证据不足】分支末尾补充标准处置话术:'转人工复核',确保容错降级路径统一" - }); - } - } - - // 5. 整单处置动作越界拦截 - for (const word of HLAB_DISPOSAL_WORDS) { - if (text.includes(word)) { - issues.push({ - level: "warning", - code: "DISPOSAL_ACTION_LEAK", - snippet: word, - message: \`规则正文包含整单处置动作话术 "\${word}",违反 HLab 规则事实判定与处置动作解耦规范\`, - suggestion: \`请移除正文中的 "\${word}";单据处置动作(驳回/提醒)应交由平台严格程度(必须遵守/仅建议)或业务工作流定义\` - }); - break; - } - } - - // 6. 适用场景防静默漏判检查 - if (scopeText) { - for (const word of HLAB_SCOPE_SKIP_WORDS) { - if (scopeText.includes(word)) { - issues.push({ - level: "warning", - code: "SCOPE_FALSE_SKIP_PRONE", - snippet: word, - message: \`适用场景包含材料上传前置判断 "\${word}",当材料未上传时可能导致该规则被静默跳过(SKIP)而非报违规(FAIL)\`, - suggestion: "建议适用场景仅保留业务与单据触发条件(如单据模板、费用类型);材料缺失的检查应显式置于【判定标准】的 FAIL 分支中" - }); - break; - } - } - } - - // 7. 消极风险压制拦截 - for (const word of HLAB_RISK_SUPPRESSION_WORDS) { - if (text.includes(word)) { - issues.push({ - level: "error", - code: "RISK_SUPPRESSION", - snippet: word, - message: \`规则正文包含消极风险压制话术 "\${word}",可能破坏模型正常审计底线或压制有效违规\`, - suggestion: "请移除该规则或改写为正向合规要求;若需豁免特定场景,请在 **例外** 结构块中封闭说明豁免条件与凭证依据" - }); - break; - } - } - - // 8. 悬空例外与凭据检查 - const matchedTrigger = HLAB_EXCEPTION_TRIGGERS.find((trigger) => text.includes(trigger)); - const hasEvidence = HLAB_EVIDENCE_KEYWORDS.some((kw) => text.includes(kw)); - - if (matchedTrigger && !hasEvidence) { - issues.push({ - level: "error", - code: "HANGING_EXCEPTION", - snippet: matchedTrigger, - message: \`包含例外条款 "\${matchedTrigger}",但未指定 AI 从何处核验该例外成立的凭据来源\`, - suggestion: "HLab 规范要求例外条款必须明确凭据载体(如:在【**例外**】块中注明需提供专项 OA 审批 PDF 附件或商家盖章证明)" - }); - } - - const errorCount = issues.filter((i) => i.level === "error").length; - const warningCount = issues.filter((i) => i.level === "warning").length; - const score = Math.max(0, 100 - errorCount * 25 - warningCount * 10); - - return { - score, - passed: errorCount === 0, - issues - }; -} - -export default lintRule; -`; - -export const OFFICIAL_LINTER_TEMPLATES: Record = { - "builtin.ts": OFFICIAL_BUILTIN_LINTER_SOURCE, - "strict.ts": OFFICIAL_STRICT_LINTER_SOURCE, - "hlab.ts": OFFICIAL_HLAB_LINTER_SOURCE -}; diff --git a/src/domains/seal/linter/plaintext.generated.ts b/src/domains/seal/linter/plaintext.generated.ts new file mode 100644 index 0000000..9797441 --- /dev/null +++ b/src/domains/seal/linter/plaintext.generated.ts @@ -0,0 +1,9 @@ +/** + * 生成文件 —— 由 scripts/generate-linter-plaintext.mjs 从 linter/checkers/ 生成,勿手改。 + * 明文下发的官方校验器源码(manifest.ts 中 plaintext: true 的条目)。 + */ +export const OFFICIAL_LINTER_PLAINTEXT: Record = { + "builtin.ts": "import type { RuleLintIssue, RuleLintResult, RuleLintTarget } from \"../types.js\";\n\nexport const BUILTIN_VAGUE_WORDS = [\n \"原则上\",\n \"尽量\",\n \"适当\",\n \"酌情\",\n \"一般情况下\",\n \"尽可能\",\n \"合理控制\",\n \"视情况\",\n \"视具体情况\"\n];\n\nexport const BUILTIN_EXCEPTION_TRIGGERS = [\n \"除非\",\n \"特殊情况\",\n \"特殊原因\",\n \"经批准\",\n \"经审批\",\n \"经领导同意\",\n \"除外\",\n \"例外\"\n];\n\nexport const BUILTIN_EVIDENCE_KEYWORDS = [\n \"备注\",\n \"说明\",\n \"附件\",\n \"证明\",\n \"邮件\",\n \"截图\",\n \"凭证\",\n \"审批\",\n \"单据\",\n \"发票\"\n];\n\nexport function builtinRuleLinter(rule: RuleLintTarget): RuleLintResult {\n const text = (rule.description || \"\").trim();\n const issues: RuleLintIssue[] = [];\n\n // 1. 规则过短检查\n if (text.length < 5) {\n issues.push({\n level: \"error\",\n code: \"TOO_SHORT\",\n message: \"规则描述过于简短(少于 5 个字),大模型难以形成明确的判定逻辑\",\n suggestion: \"请补充具体的费用类型、核验条件与限制标准\"\n });\n }\n\n // 2. 主观模糊词拦截\n for (const word of BUILTIN_VAGUE_WORDS) {\n if (text.includes(word)) {\n issues.push({\n level: \"error\",\n code: \"VAGUE_WORD\",\n snippet: word,\n message: `包含主观模糊词 \"${word}\",容易导致大模型判定标准产生波动与幻觉`,\n suggestion: `建议移除 \"${word}\",改为具体的金额上限、枚举范围或刚性判定条件`\n });\n }\n }\n\n // 3. 悬空例外条款检测\n const matchedTrigger = BUILTIN_EXCEPTION_TRIGGERS.find((trigger) => text.includes(trigger));\n const hasEvidence = BUILTIN_EVIDENCE_KEYWORDS.some((kw) => text.includes(kw));\n\n if (matchedTrigger && !hasEvidence) {\n issues.push({\n level: \"warning\",\n code: \"HANGING_EXCEPTION\",\n snippet: matchedTrigger,\n message: `包含例外条款 \"${matchedTrigger}\",但未指定 AI 从何处核验该例外成立的依据`,\n suggestion: `建议补充明确的凭据来源(例如:\"需在【单据备注】中说明原因\" 或 \"需在【附件】中上传审批截图\")`\n });\n }\n\n const errorCount = issues.filter((i) => i.level === \"error\").length;\n const warningCount = issues.filter((i) => i.level === \"warning\").length;\n const score = Math.max(0, 100 - errorCount * 25 - warningCount * 10);\n\n return {\n score,\n passed: errorCount === 0,\n issues\n };\n}\n", + "strict.ts": "import type { RuleLintIssue, RuleLintResult, RuleLintTarget } from \"../types.js\";\n\nexport const STRICT_VAGUE_WORDS = [\n \"原则上\",\n \"尽量\",\n \"适当\",\n \"酌情\",\n \"一般情况下\",\n \"尽可能\",\n \"合理控制\",\n \"视情况\",\n \"视具体情况\",\n \"必要时\",\n \"及时\",\n \"适量\",\n \"差不多\",\n \"相关部门\"\n];\n\nexport const STRICT_EXCEPTION_TRIGGERS = [\n \"除非\",\n \"特殊情况\",\n \"特殊原因\",\n \"经批准\",\n \"经审批\",\n \"经领导同意\",\n \"除外\",\n \"例外\"\n];\n\nexport const STRICT_EVIDENCE_KEYWORDS = [\n \"备注\",\n \"说明\",\n \"附件\",\n \"证明\",\n \"邮件\",\n \"截图\",\n \"凭证\",\n \"审批\",\n \"单据\",\n \"发票\"\n];\n\nexport const STRICT_QUANTITATIVE_INDICATORS = [\n \"¥\",\n \"$\",\n \"€\",\n \"元\",\n \"不得超过\",\n \"不超过\",\n \"超过\",\n \"低于\",\n \"不低于\",\n \"最高\",\n \"封顶\",\n \"限额\",\n \"禁止\",\n \"严禁\",\n \"必须\",\n \"不予\",\n \"仅限\",\n \"每人\",\n \"每日\",\n \"每月\",\n \"每年\",\n \"每次\",\n \"单笔\"\n];\n\nexport const STRICT_SPECIFIC_APPROVERS = [\n \"总监\",\n \"VP\",\n \"总经理\",\n \"直接上级\",\n \"部门负责人\",\n \"项目经理\",\n \"财务\",\n \"分管领导\",\n \"HR\",\n \"CEO\"\n];\n\nexport function strictRuleLinter(rule: RuleLintTarget): RuleLintResult {\n const text = (rule.description || \"\").trim();\n const issues: RuleLintIssue[] = [];\n\n // 1. 规则长度检查\n if (text.length < 5) {\n issues.push({\n level: \"error\",\n code: \"TOO_SHORT\",\n message: \"规则描述过于简短(少于 5 个字),大模型难以形成明确的判定逻辑\",\n suggestion: \"请补充具体的费用类型、核验条件与限制标准\"\n });\n } else if (text.length < 10) {\n issues.push({\n level: \"warning\",\n code: \"SHORT_DESCRIPTION\",\n message: \"规则描述偏短(少于 10 个字),可能缺少适用的单据范围或执行细节\",\n suggestion: \"建议扩充核验场景、限制标准或异常处理方式\"\n });\n }\n\n // 2. 主观模糊词拦截(严格集合)\n for (const word of STRICT_VAGUE_WORDS) {\n if (text.includes(word)) {\n issues.push({\n level: \"error\",\n code: \"VAGUE_WORD\",\n snippet: word,\n message: `包含主观模糊词 \"${word}\",在严格风控模式下容易引起审核判定分歧`,\n suggestion: `请移除 \"${word}\",明确量化标准或枚举具体允许的情形`\n });\n }\n }\n\n // 3. 例外条款与凭据要求(严格模式下无凭证直接判定为 error)\n const matchedTrigger = STRICT_EXCEPTION_TRIGGERS.find((trigger) => text.includes(trigger));\n const hasEvidence = STRICT_EVIDENCE_KEYWORDS.some((kw) => text.includes(kw));\n\n if (matchedTrigger && !hasEvidence) {\n issues.push({\n level: \"error\",\n code: \"HANGING_EXCEPTION\",\n snippet: matchedTrigger,\n message: `包含例外条款 \"${matchedTrigger}\",但未指定 AI 从何处核验该例外成立的凭证依据`,\n suggestion: `严格模式要求必须补充明确的核验来源(如:\"需在【单据备注】中说明原因\" 或 \"需在【附件】中提供审批截图\")`\n });\n }\n\n // 4. 定量约束或刚性边界检查\n const hasNumber = /\\d+/.test(text);\n const hasConstraint = STRICT_QUANTITATIVE_INDICATORS.some((kw) => text.includes(kw));\n if (!hasNumber && !hasConstraint) {\n issues.push({\n level: \"warning\",\n code: \"LACKS_EXPLICIT_CONSTRAINT\",\n message: \"规则缺乏明确的定量标准(如金额、天数、频次)或绝对刚性边界词(如不得、禁止、仅限)\",\n suggestion: \"建议设定具体数值阈值或明确的禁止/准入条件,以便大模型精确判定\"\n });\n }\n\n // 5. 审批角色具体化检查\n const mentionsApproval = /经(批准|审批|领导同意|领导签字)|审批通过/.test(text);\n const hasSpecificApprover = STRICT_SPECIFIC_APPROVERS.some((approver) => text.includes(approver));\n if (mentionsApproval && !hasSpecificApprover) {\n issues.push({\n level: \"warning\",\n code: \"AMBIGUOUS_APPROVER\",\n message: \"规则提及审批例外,但未明确指定具体的审批角色(如部门总监、直接上级、财务负责人)\",\n suggestion: \"建议明确审批人角色(例如:经【部门总监】批准,经【直接上级】邮件确认)\"\n });\n }\n\n const errorCount = issues.filter((i) => i.level === \"error\").length;\n const warningCount = issues.filter((i) => i.level === \"warning\").length;\n const score = Math.max(0, 100 - errorCount * 30 - warningCount * 15);\n\n return {\n score,\n passed: errorCount === 0,\n issues\n };\n}\n\nexport default strictRuleLinter;\n", + "hlab.ts": "import type { RuleLintIssue, RuleLintResult, RuleLintTarget } from \"../types.js\";\n\nexport const HLAB_DISPOSAL_WORDS = [\n \"驳回单据\",\n \"直接驳回\",\n \"整单退回\",\n \"退回单据\",\n \"退单处理\",\n \"进行提醒\",\n \"请进行提醒\",\n \"予以驳回\",\n \"直接退回\",\n \"无需人工关注\",\n \"无需展示在最后的审核结论中\"\n];\n\nexport const HLAB_SCOPE_SKIP_WORDS = [\n \"若上传了\",\n \"如上传了\",\n \"若提供了\",\n \"如提供了\",\n \"附件需上传\",\n \"上传了发票\",\n \"提供了支付截图\",\n \"提供了行程单\",\n \"上传了行程单\"\n];\n\nexport const HLAB_RISK_SUPPRESSION_WORDS = [\n \"忽略行程冲突\",\n \"忽略重复报销\",\n \"忽略跨城一致性\",\n \"不识别为风险\",\n \"不作为风险事项\",\n \"无需作为风险\"\n];\n\nexport const HLAB_EXCEPTION_TRIGGERS = [\n \"除非\",\n \"特殊情况\",\n \"特殊原因\",\n \"经批准\",\n \"经审批\",\n \"经领导同意\",\n \"除外\",\n \"例外\"\n];\n\nexport const HLAB_EVIDENCE_KEYWORDS = [\n \"备注\",\n \"说明\",\n \"附件\",\n \"证明\",\n \"邮件\",\n \"截图\",\n \"凭证\",\n \"审批\",\n \"单据\",\n \"发票\",\n \"流程\"\n];\n\n/**\n * 合思实验室 (HLab) 结构化审批规则校验器。\n * 遵循 HLab 规则工业化编写规范 (Rule-as-SOP):\n * 1. 结构完备性:必须包含【检查方法】与【判定标准】结构块\n * 2. 三元闭环判定:必须具备 PASS、FAIL 与 证据不足 三个分支,且证据不足须明确转人工复核\n * 3. 处置话术解耦:严禁在规则正文写整单处置动作(如驳回单据、直接驳回、进行提醒)\n * 4. 适用场景防漏判:拦截在适用场景中设置材料存在前置条件,避免缺失材料时被静默跳过 (False SKIP)\n * 5. 消极风险压制拦截:严禁在规则中配置忽略行程冲突或不识别风险等反模式\n * 6. 例外条款闭环:包含例外必须指定核验凭据\n */\nexport function hlabRuleLinter(rule: RuleLintTarget): RuleLintResult {\n const text = (rule.description || \"\").trim();\n const scopeText = (rule.scope || \"\").trim();\n const issues: RuleLintIssue[] = [];\n\n // 1. 规则长度检查\n if (text.length < 10) {\n issues.push({\n level: \"error\",\n code: \"TOO_SHORT\",\n message: \"规则描述过于简短(少于 10 个字),无法承载 HLab 结构化规范所要求的判定逻辑\",\n suggestion: \"请按照 HLab 工业化规范补充【检查方法】与【判定标准】\"\n });\n } else if (text.length < 30 && !text.includes(\"**\") && !text.includes(\"检查方法\")) {\n issues.push({\n level: \"warning\",\n code: \"SHORT_DESCRIPTION\",\n message: \"规则正文偏短且缺少结构化要素,可能缺少执行细节或证据边界\",\n suggestion: \"建议扩充核验场景、限制标准或异常处理方式\"\n });\n }\n\n // 2. 结构完备性检查\n const hasMethod = /\\*\\*检查方法\\*\\*|检查方法[::]/.test(text);\n if (!hasMethod) {\n issues.push({\n level: \"error\",\n code: \"MISSING_CHECK_METHOD\",\n message: \"规则正文缺少【检查方法】结构块,大模型难以确定数据提取来源与对齐逻辑\",\n suggestion: \"建议在正文前部增加 **检查方法**:明确 SealAI 应读取的凭证类型、字段名称、归一化方式或前置规则依赖\"\n });\n }\n\n const hasStandard = /\\*\\*判定标准\\*\\*|判定标准[::]/.test(text);\n if (!hasStandard) {\n issues.push({\n level: \"error\",\n code: \"MISSING_EVAL_STANDARD\",\n message: \"规则正文缺少【判定标准】结构块,缺乏标准化判定边界\",\n suggestion: \"建议在正文后部增加 **判定标准**:包含清晰的 PASS、FAIL 以及证据不足分支\"\n });\n }\n\n // 3. 三元闭环判定检查\n const hasPass = /[-*•]?\\s*PASS[::]/i.test(text);\n const hasFail = /[-*•]?\\s*FAIL[::]/i.test(text);\n const hasInsufficient = /[-*•]?\\s*证据不足[::]/.test(text);\n\n if (!hasPass || !hasFail || !hasInsufficient) {\n const missing: string[] = [];\n if (!hasPass) missing.push(\"PASS\");\n if (!hasFail) missing.push(\"FAIL\");\n if (!hasInsufficient) missing.push(\"证据不足\");\n issues.push({\n level: \"error\",\n code: \"INCOMPLETE_TERNARY_BRANCH\",\n message: `判定标准未形成三元闭环,缺少分支:${missing.join(\"、\")}`,\n suggestion: \"HLab 规范要求必须提供完整的三元分支:- PASS(充分合规条件)、- FAIL(明确违规条件)、- 证据不足(容错与复核条件)\"\n });\n }\n\n // 4. 证据不足分支人工复核兜底检查\n if (hasInsufficient) {\n const snippet = text.split(\"证据不足\")?.[1]?.slice(0, 100) || \"\";\n const hasManualReview = /人工复核|人工核对|人工审核|转人工/.test(snippet);\n if (!hasManualReview) {\n issues.push({\n level: \"warning\",\n code: \"INSUFFICIENT_WITHOUT_MANUAL_REVIEW\",\n message: \"【证据不足】分支未明确指定转【人工复核】兜底,大模型在材料模糊或冲突时可能失控\",\n suggestion: \"建议在【证据不足】分支末尾补充标准处置话术:'转人工复核',确保容错降级路径统一\"\n });\n }\n }\n\n // 5. 整单处置动作越界拦截\n for (const word of HLAB_DISPOSAL_WORDS) {\n if (text.includes(word)) {\n issues.push({\n level: \"warning\",\n code: \"DISPOSAL_ACTION_LEAK\",\n snippet: word,\n message: `规则正文包含整单处置动作话术 \"${word}\",违反 HLab 规则事实判定与处置动作解耦规范`,\n suggestion: `请移除正文中的 \"${word}\";单据处置动作(驳回/提醒)应交由平台严格程度(必须遵守/仅建议)或业务工作流定义`\n });\n break;\n }\n }\n\n // 6. 适用场景防静默漏判检查\n if (scopeText) {\n for (const word of HLAB_SCOPE_SKIP_WORDS) {\n if (scopeText.includes(word)) {\n issues.push({\n level: \"warning\",\n code: \"SCOPE_FALSE_SKIP_PRONE\",\n snippet: word,\n message: `适用场景包含材料上传前置判断 \"${word}\",当材料未上传时可能导致该规则被静默跳过(SKIP)而非报违规(FAIL)`,\n suggestion: `建议适用场景仅保留业务与单据触发条件(如单据模板、费用类型);材料缺失的检查应显式置于【判定标准】的 FAIL 分支中`\n });\n break;\n }\n }\n }\n\n // 7. 消极风险压制拦截\n for (const word of HLAB_RISK_SUPPRESSION_WORDS) {\n if (text.includes(word)) {\n issues.push({\n level: \"error\",\n code: \"RISK_SUPPRESSION\",\n snippet: word,\n message: `规则正文包含消极风险压制话术 \"${word}\",可能破坏模型正常审计底线或压制有效违规`,\n suggestion: \"请移除该规则或改写为正向合规要求;若需豁免特定场景,请在 **例外** 结构块中封闭说明豁免条件与凭证依据\"\n });\n break;\n }\n }\n\n // 8. 悬空例外与凭据检查\n const matchedTrigger = HLAB_EXCEPTION_TRIGGERS.find((trigger) => text.includes(trigger));\n const hasEvidence = HLAB_EVIDENCE_KEYWORDS.some((kw) => text.includes(kw));\n\n if (matchedTrigger && !hasEvidence) {\n issues.push({\n level: \"error\",\n code: \"HANGING_EXCEPTION\",\n snippet: matchedTrigger,\n message: `包含例外条款 \"${matchedTrigger}\",但未指定 AI 从何处核验该例外成立的凭据来源`,\n suggestion: `HLab 规范要求例外条款必须明确凭据载体(如:在【**例外**】块中注明需提供专项 OA 审批 PDF 附件或商家盖章证明)`\n });\n }\n\n const errorCount = issues.filter((i) => i.level === \"error\").length;\n const warningCount = issues.filter((i) => i.level === \"warning\").length;\n const score = Math.max(0, 100 - errorCount * 25 - warningCount * 10);\n\n return {\n score,\n passed: errorCount === 0,\n issues\n };\n}\n\nexport default hlabRuleLinter;\n" +}; diff --git a/ops/README.md b/wsl-infra/README.md similarity index 100% rename from ops/README.md rename to wsl-infra/README.md diff --git a/ops/backup-workspace-scripts.sh b/wsl-infra/backup-workspace-scripts.sh similarity index 100% rename from ops/backup-workspace-scripts.sh rename to wsl-infra/backup-workspace-scripts.sh diff --git a/ops/infra-healthcheck.sh b/wsl-infra/infra-healthcheck.sh similarity index 100% rename from ops/infra-healthcheck.sh rename to wsl-infra/infra-healthcheck.sh diff --git a/ops/release-sync.sh b/wsl-infra/release-sync.sh similarity index 100% rename from ops/release-sync.sh rename to wsl-infra/release-sync.sh diff --git a/ops/systemd/mihomo.service b/wsl-infra/systemd/mihomo.service similarity index 100% rename from ops/systemd/mihomo.service rename to wsl-infra/systemd/mihomo.service diff --git a/ops/systemd/seal-use-release-sync.service b/wsl-infra/systemd/seal-use-release-sync.service similarity index 100% rename from ops/systemd/seal-use-release-sync.service rename to wsl-infra/systemd/seal-use-release-sync.service diff --git a/ops/systemd/seal-use-release-sync.timer b/wsl-infra/systemd/seal-use-release-sync.timer similarity index 100% rename from ops/systemd/seal-use-release-sync.timer rename to wsl-infra/systemd/seal-use-release-sync.timer