diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e5e0ba0..ff5ed50 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,10 +11,17 @@ repos: hooks: - id: check-format name: Check Ruff formatting - entry: ruff format --check . + entry: pdm run format:check language: system files: ^(.*\.py|pyproject\.toml|ruff\.toml)$ - exclude: ^(cli/|\.agents/) + exclude: ^(cli/|\.agents/|tasks/) + pass_filenames: false + - id: check-lint + name: Check Ruff lint + entry: pdm run lint + language: system + files: ^(.*\.py|pyproject\.toml|ruff\.toml|\.pre-commit-config\.yaml)$ + exclude: ^(cli/|\.agents/|tasks/) pass_filenames: false - id: typecheck name: Check Pyrefly types diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index feae76b..1578d01 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,7 @@ bugs that do not cross a security boundary. ```bash git submodule update --init --recursive pdm install -G dev --frozen-lockfile +pdm run pre-commit install pdm run doctor pdm run check ``` @@ -23,6 +24,10 @@ pdm run check `.python-version` is the shared Python runtime anchor. CI installs PDM 2.28.0, and `doctor` reports a mismatch when the local toolchain does not match that contract. +Git hook 需要在每个本地 checkout 安装;提交前会执行与 CI 相同的格式和 lint 入口。 +移动仓库目录后,需要重建含旧绝对路径的虚拟环境入口并重新安装 hook;CI 的完整 +`check` 仍是交付检查依据。 + `check` is the same hermetic repository gate used by CI. It verifies the lock and requirements export, migration configuration and append-only baseline, Ruff formatting, repository lint, and static types. Use narrower commands while iterating: diff --git a/docs/40-deployment/development-environment.md b/docs/40-deployment/development-environment.md index fda0d52..42dcbd3 100644 --- a/docs/40-deployment/development-environment.md +++ b/docs/40-deployment/development-environment.md @@ -103,6 +103,8 @@ pdm run dev repository contract checks tool versions, lock/export consistency, migration integrity, formatting, lint, settings isolation, and the complete unit-test suite. +格式与 lint 的范围由 `ruff.toml` 拥有,覆盖正式源码、测试与脚本。`tasks/` 是临时实验材料,`.agents/` 是独立维护的技能;二者不参与产品门禁。成为正式验证步骤的实验应迁入 `scripts/` 或 `tests/`。已发布迁移保持不可变;独立 CLI 使用 `pdm run --project cli check` 及自己的 CI。pre-commit 的格式与 lint 钩子复用 `pdm run format:check` 和 `pdm run lint`,CI 的完整入口仍为 `pdm run check`。 + Use narrower read-only checks while iterating: ```bash diff --git a/ruff.toml b/ruff.toml index 8029742..d1b4b67 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,6 +1,7 @@ line-length = 92 indent-width = 2 -extend-exclude = ["migrations/versions", "*.md", "cli", ".agents"] +# Task probes are disposable evidence; maintained checks belong in scripts/ or tests/. +extend-exclude = ["migrations/versions", "*.md", "cli", ".agents", "tasks"] [format] indent-style = "space"