diff --git a/.gitignore b/.gitignore index bb65593..220e5f6 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,3 @@ enterprises/*.json 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 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/skills/seal-use/references/rule-lint.md b/skills/seal-use/references/rule-lint.md index 565dc22..b6d1357 100644 --- a/skills/seal-use/references/rule-lint.md +++ b/skills/seal-use/references/rule-lint.md @@ -53,6 +53,14 @@ seal-use config lint disable ## Official Linters +校验器分三层,加载顺序:CLI 内置 → 官方明文版 → 用户自定义。 + +| 层 | 位置 | 说明 | +| :--- | :--- | :--- | +| 内置引擎 | 编译进二进制 | 永远可用,`builtin` 即此层 | +| 官方明文版 | `~/.config/seal-use/linters/official/` | `syncOfficialLinters` 自动同步,改动会被覆盖;agent 可直接阅读源码理解校验逻辑 | +| 用户自定义 | `~/.config/seal-use/linters/.ts` 或 `/linters/.ts` | 私有脚本,前者全局生效、后者仅当前项目 | + | Linter Name | Scope & Purpose | Aliases | | :--- | :--- | :--- | | `builtin` | Seal 官方标准校验器:拦截过短描述、主观模糊词与悬空例外条款。 | `default`, `official/builtin` |