Skip to content

feat(scripts): Add npm run scripts for Python linting and testing #886

@WilliamBerryiii

Description

@WilliamBerryiii

Summary

The repository uses npm run scripts as the canonical interface for all validation commands (lint:md, lint:ps, test:ps, etc.). Python has no equivalent entries, meaning developers and CI workflows have no standardized way to run Python linting or testing. Adding lint:py, lint:py:fix, and test:py scripts creates developer-facing commands that mirror the existing patterns.

Context

The codebase convention documented in copilot-instructions.md states that all scripts used by the codebase have an npm run script for ease of use. The Coding Agent environment section lists specific npm run commands that agents should use for validation. Without Python entries, neither human developers nor AI agents have discoverable commands for Python quality gates.

These scripts should invoke ruff for linting and pytest for testing via uv run to ensure the correct virtual environment is used. The lint:all composite script should also be updated to include lint:py.

Architecture: Multi-Skill Discovery

Each Python skill maintains its own pyproject.toml. Rather than hardcoding paths, npm scripts should use find-based discovery to automatically locate and iterate over all Python skill directories. This scales to N skills without per-skill configuration changes.

Changes Required

File Change
package.json Add lint:py script using find-based discovery
package.json Add lint:py:fix script using find-based discovery
package.json Add test:py script using find-based discovery
package.json Update lint:all to include lint:py in the chain

Example entries using dynamic discovery:

{
  "lint:py": "find .github/skills -name pyproject.toml -execdir uv run ruff check . ';'",
  "lint:py:fix": "find .github/skills -name pyproject.toml -execdir uv run ruff format . ';'",
  "test:py": "find .github/skills -name pyproject.toml -execdir uv run pytest ';'"
}

The find -execdir pattern runs each command in the directory containing the pyproject.toml, ensuring uv resolves the correct virtual environment per skill. Adding a new Python skill with a pyproject.toml causes it to be discovered by all scripts automatically.

Acceptance Criteria

  • npm run lint:py executes ruff check against Python files in all skill directories
  • npm run lint:py:fix applies auto-fixable ruff corrections across all skill directories
  • npm run test:py executes pytest against Python test files in all skill directories
  • npm run lint:all includes lint:py in its execution chain
  • All three commands produce clear output and exit with appropriate codes
  • Commands work in both devcontainer and Copilot Agent environments (requires uv to be installed)
  • Adding a new Python skill with pyproject.toml is automatically discovered without script changes

Dependencies

Related

Metadata

Metadata

Labels

infrastructureRepository infrastructure and tooling

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions