diff --git a/.agents/skills/deploy/SKILL.md b/.agents/skills/deploy/SKILL.md index 15435d5..49946f4 100644 --- a/.agents/skills/deploy/SKILL.md +++ b/.agents/skills/deploy/SKILL.md @@ -26,6 +26,9 @@ broken or over-budget deploy. ```bash pnpm typecheck pnpm lint +# Unused files, exports, dependencies, or configuration and tag hints fail these checks. +pnpm knip +pnpm knip:production ``` ## 2. Build diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 8f6a0f1..951149e 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -11,6 +11,7 @@ - [ ] `pnpm lint` (vp check) and `pnpm typecheck` +- [ ] Run `pnpm knip` and `pnpm knip:production`. Unused files, exports, dependencies, or configuration and tag hints fail CI. - [ ] `pnpm duplicates` (fails on any reported clone, while `pnpm duplicates:audit` only reports findings) - [ ] `pnpm test` — unit tests - [ ] `pnpm --filter @blog/web build` + size gate (`wrangler deploy --dry-run`, < 3 MiB gzip) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9d2c5e2..dc74e12 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -35,6 +35,12 @@ jobs: - name: Lint (vp check) run: pnpm lint + - name: Check for unused files, exports, and dependencies + run: pnpm knip + + - name: Check production code with Knip + run: pnpm knip:production + - name: Check for duplicate code run: pnpm duplicates diff --git a/AGENTS.md b/AGENTS.md index 0f84a23..c018052 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -91,6 +91,9 @@ pnpm deploy ```bash pnpm typecheck pnpm lint # = vp check(Oxfmt 格式检查 + Oxlint lint,含 shadcn token 规则,与 CI lint job 一致) +# 两项 Knip 检查发现未使用的文件、导出、依赖或配置、标签提示时,CI 失败。 +pnpm knip +pnpm knip:production # 单独检查生产代码 pnpm duplicates # 检出任何一处重复即失败。`pnpm duplicates:audit` 只生成报告。 pnpm --filter @blog/web build pnpm --filter @blog/web exec wrangler deploy -c dist/server/wrangler.json --dry-run # 守 3 MiB diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db2059a..1f5ff35 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,6 +64,9 @@ Specs and Plans in the delivery PR. ```bash pnpm lint # vp check — Oxfmt format check + Oxlint across the repo pnpm typecheck # tsc (TypeScript 7 native) +# Both Knip checks fail CI on unused files, exports, dependencies, or configuration and tag hints. +pnpm knip +pnpm knip:production # Check production code separately. pnpm duplicates # Fails on any reported clone. `pnpm duplicates:audit` only reports findings. pnpm test # vp test (Vitest 5) — unit tests pnpm --filter @blog/web build diff --git a/docs/architecture.md b/docs/architecture.md index 6372939..fc37204 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -225,6 +225,7 @@ pnpm --filter @blog/web dev # vp dev(Vite+) - **改表结构**:加 `apps/web/migrations/000N_*.sql`;deploy 时自动应用到远端、本地用 `--local`。 - **改可见性逻辑**:`packages/shared/src/access.ts`(`canAccessVisibility`)+ 在数据层 fn 里强制。 - **提交前最低验证**:`pnpm typecheck`;`pnpm lint`(`vp check`:Oxfmt 格式检查 + Oxlint); + `pnpm knip` 和 `pnpm knip:production`(分别检查全项目和生产代码,检出未使用的文件、导出、依赖或配置、标签提示即失败); `pnpm duplicates` 检出任何一处重复即失败(`pnpm duplicates:audit` 只生成报告); `pnpm --filter @blog/web build`;`pnpm --filter @blog/web exec wrangler deploy -c apps/web/dist/server/wrangler.json --dry-run`(体积守门)。