Files
omnigent-ai--omnigent/.pre-commit-config.yaml
Zeyi (Rice) Fan 244ded1ed9 chore(deps): move development tooling to internal groups (#4626)
## Related issue

N/A

## Summary

The published `dev` extra mixed repository workflows with installable Omnigent capabilities. Move contributor-only dependencies to PEP 735 groups so package extras describe product functionality and CI installs only the workflow dependencies it executes.

- Replace the `dev` extra with local-only `lint`, `test`, and aggregate `dev` groups; configure no default groups so plain `uv sync` matches the published base package.
- Remove the retired mypy dependency/configuration, `types-PyYAML`, the orphaned `pathspec` declaration, and the duplicate `filelock` declaration.
- Migrate workflows, actions, contributor commands, tests, and development skills from `--extra dev` to the smallest required group, or no group for application/benchmark jobs.
- Compose Pyrefly's lint environment from the `lint` group plus the existing `hindsight`, `nimble`, `s3`, and `tracing` capability extras. Remove the OpenTelemetry missing-import configuration and Nimble's inline missing-import suppression so real package types remain checked.
- Update OpenShell, e2e, browser-test, Slack, and implementation-plan commands to compose capability extras with repository groups explicitly. Document why read-only/tools-less agent workflows intentionally keep runtime-only environments.
- Avoid `--all-extras`: it resolves but selects 240 product packages, including unrelated large/native integrations. Keep capability ownership explicit instead.

ELI5: product features remain extras users can install; lint and test toolboxes become private repository groups that never appear in the wheel.

```text
published wheel: base + capability extras
repository:      lint group | test group | dev = lint + test
CI lint:         lint + explicitly type-checked capability extras
```

## Test Plan

- `uv lock && just normalize-locks`
- Built the wheel and verified its metadata contains no `dev` extra or lint/test dependencies.
- Verified a fresh base environment imports Omnigent, excludes lint/test/pathspec packages, and imports each release benchmark script.
- `uv run --isolated --frozen --group lint --extra hindsight --extra nimble --extra s3 --extra tracing pre-commit run pyrefly --all-files`
- `uv run --isolated --frozen --group lint python scripts/gen_routing_pb2.py --check`
- Verified isolated `test` and aggregate `dev` group membership independently.
- `uv run --isolated --frozen --group test pytest tests/tools/builtins/test_hindsight.py tests/tools/builtins/test_nimble_research.py tests/stores/test_s3_artifact_store.py tests/db/test_d1_fts_dialect.py -q` (172 passed)
- `uv run --isolated --frozen --group test --extra tracing pytest tests/runtime/test_telemetry.py tests/inner/test_tracing_genai_semconv.py -q` (69 passed)
- `uv run --isolated --frozen --extra openshell --group test pytest tests/onboarding/sandboxes/test_openshell.py tests/server/test_managed_hosts.py -q` (259 passed)
- Verified load-test modules import with only `loadtest` and `agents-sdk` extras.
- Ran the exact locked lint sync against PyPI and Pyrefly passed.
- Rebased onto current `origin/main`; migrated the newly added compatibility-smoke test actions and host benchmark workflow.
- Surveyed all tracked uv install/run commands and removed every remaining published-`dev`/implicit-tooling command. Verified the documented e2e and Slack environments and collected the Kimi/live-DDG tests in fresh group-selected environments.
- `uv run --frozen pre-commit run --all-files`

## Demo

N/A — dependency metadata and CI configuration only.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [ ] UI / frontend change
- [x] Refactor / chore
- [ ] Docs
- [ ] Test / CI
- [ ] Breaking change

## Test coverage

- [ ] Unit tests added / updated
- [ ] Integration tests added / updated
- [ ] E2E tests added / updated
- [x] Manual verification completed
- [x] Existing tests cover this change
- [ ] Not applicable

## Coverage notes

Fresh isolated environments validated the base, lint, test, aggregate dev, tracing-test, and load-test dependency boundaries. Focused tests prove retained optional clients are genuine test runtimes, while wheel inspection proves repository groups are not published.

Signed-off-by: Zeyi (Rice) Fan <zeyi.f@databricks.com>
2026-08-13 18:00:38 -07:00

180 lines
7.6 KiB
YAML

# Pre-commit hooks for this repository: ruff, Pyrefly, project-specific lint,
# and standard file-hygiene checks.
#
# A built web-UI bundle may be committed at this path (vendored, minified
# JS/CSS) — never lint or "fix" it.
exclude: ^omnigent/server/static/web-ui/
repos:
- repo: local
hooks:
- id: ruff-format
name: ruff format
language: system
entry: .venv/bin/python -m ruff format --force-exclude
types: [python]
- id: ruff-check
name: ruff check
language: system
entry: .venv/bin/python -m ruff check --fix --force-exclude
types: [python]
- id: pyrefly
name: pyrefly
language: system
entry: .venv/bin/pyrefly check
pass_filenames: false
files: ^(omnigent/.*\.pyi?|sdks/python-client/.*\.py|pyproject\.toml|pyrefly\.toml|uv\.lock)$
# Project-specific test-quality lint rules (dev/lint/). Run on test
# files only — the patterns never occur in production code.
- id: no-global-asyncio-patch
name: no globally-clobbering asyncio monkeypatch
language: system
entry: .venv/bin/python dev/lint/lint_no_global_asyncio_patch.py
types: [python]
files: ^tests/
- id: no-skipped-tests
name: no unconditional `@pytest.mark.skip`
language: system
entry: .venv/bin/python dev/lint/lint_no_skipped_tests.py
types: [python]
files: ^tests/
- id: no-hardcoded-models
name: no new hardcoded LLM model ids
language: system
entry: .venv/bin/python dev/lint/lint_no_hardcoded_models.py
pass_filenames: false
files: \.(py|ya?ml|json|toml|sh)$
exclude: (^|/)tests/|^openapi\.json$
- id: web-prettier
name: web prettier
language: system
entry: bash -c 'test -x web/node_modules/.bin/prettier && web/node_modules/.bin/prettier --write "$@"' --
files: ^web/.*\.(css|html|js|jsx|json|md|mdx|ts|tsx|yaml|yml)$
# Exclude generated assets: web-ui build output, Xcode asset catalogs,
# and Apple Icon Composer `.icon` bundles (machine-formatted; prettier
# fights the tooling).
exclude: ^(omnigent/server/static/web-ui/assets/|web/.*\.xcassets/|web/.*\.icon/)
- id: web-oxlint
name: web oxlint
language: system
entry: bash -c 'test -x web/node_modules/.bin/oxlint && cd web && node_modules/.bin/oxlint --deny-warnings --report-unused-disable-directives .'
files: ^(web/.*\.[cm]?[jt]sx?|web/\.oxlintrc\.json|web/package\.json|pnpm-lock\.yaml)$
pass_filenames: false
- id: web-tsc
name: web TypeScript type check
language: system
entry: bash -c 'test -x web/node_modules/.bin/tsc && cd web && node_modules/.bin/tsc -b'
files: ^(web/.*\.[cm]?[jt]sx?|web/tsconfig(?:\.[^.]+)?\.json|web/package\.json|pnpm-(?:lock|workspace)\.yaml)$
pass_filenames: false
- id: vscode-tsc
name: VS Code extension TypeScript type check
language: system
entry: bash -c 'test -x editors/vscode/node_modules/.bin/tsc && cd editors/vscode && node_modules/.bin/tsc --noEmit'
files: ^(editors/vscode/.*\.[cm]?[jt]sx?|editors/vscode/tsconfig\.json|editors/vscode/package\.json|pnpm-(?:lock|workspace)\.yaml)$
pass_filenames: false
# Android Kotlin formatting + linting via ktlint (config:
# web/android/.editorconfig). The wrapper no-ops when ktlint is absent,
# so local machines without ktlint installed skip cleanly. CI installs
# ktlint before running pre-commit, so the check is enforced there.
# Install locally with `brew install ktlint` (macOS) or download from
# https://github.com/pinterest/ktlint/releases.
- id: android-ktlint-format
name: android ktlint format
language: system
entry: web/android/bin/ktlint.sh --format
files: ^web/android/.*\.kts?$
exclude: ^web/android/(build|\.gradle)/
- id: android-ktlint-check
name: android ktlint check
language: system
entry: web/android/bin/ktlint.sh
files: ^web/android/.*\.kts?$
exclude: ^web/android/(build|\.gradle)/
# iOS Swift formatting + linting via Apple's `swift format` (config:
# web/ios/.swift-format). The wrapper no-ops when the Swift toolchain
# is absent, so these run on macOS dev machines but skip the ubuntu-latest
# CI pre-commit job — there is no Swift there. Enforcement is local.
- id: web-ios-swift-format
name: web ios swift-format
language: system
entry: web/ios/bin/swift-format.sh format --in-place --parallel
files: ^web/ios/.*\.swift$
exclude: ^web/ios/(build|vendor)/
- id: web-ios-swift-lint
name: web ios swift format lint
language: system
entry: web/ios/bin/swift-format.sh format lint --strict --parallel
files: ^web/ios/.*\.swift$
exclude: ^web/ios/(build|vendor)/
# Keep omnigent/version.py's VERSION constant equal to the canonical
# [project].version in pyproject.toml (the runtime imports the constant;
# the build reads pyproject). Fixer: rewrites the constant and re-stages.
- id: sync-version-py
name: sync omnigent/version.py to pyproject version
language: system
entry: .venv/bin/python scripts/sync_version_py.py
files: ^(pyproject\.toml|omnigent/version\.py)$
pass_filenames: false
# Local `uv` runs rewrite uv.lock's registry to whatever index is
# configured on the developer's machine (e.g. the Databricks PyPI
# proxy). This OSS repo must always commit the public PyPI URL, so
# normalize it back before it lands. Fixer: re-stage if it changes.
- id: normalize-uv-lock-registry
name: normalize uv.lock registry to pypi.org
language: system
entry: .venv/bin/python scripts/normalize_uv_lock_registry.py
files: ^uv\.lock$
pass_filenames: true
# Fail if routing.proto changed without regenerating the committed
# bindings (or vice versa). Verify-only, not a fixer: regen needs
# grpcio-tools, so CI's `uv sync --group lint` enforces it (like ktlint).
- id: routing-pb2-fresh
name: routing protobuf bindings are up to date
language: system
entry: .venv/bin/python scripts/gen_routing_pb2.py --check
files: ^omnigent/api/routing/v1/routing(\.proto|_pb2\.pyi?)$
pass_filenames: false
# ── File hygiene ────────────────────────────────────────────────
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
name: trim trailing whitespace
exclude: \.(md|svg)$
- id: end-of-file-fixer
name: ensure files end with newline
# AppIcon.icon/ is generated by Apple's Icon Composer, which writes
# icon.json without a trailing newline — don't "fix" it.
exclude: (\.(md|svg)$|/AppIcon\.icon/)
- id: check-yaml
name: check yaml syntax
# docker-compose override files use non-standard tags
# (`!reset`, `!override`) that PyYAML can't parse.
exclude: ^deploy/docker/docker-compose\.[a-z]+\.yaml$
- id: check-merge-conflict
name: check for merge conflicts
- id: check-added-large-files
name: prevent large files
args: ['--maxkb=1000']
- id: check-case-conflict
name: check for case conflicts
- id: mixed-line-ending
name: check line endings
args: ['--fix=lf']