use Codex 5.3 to review template to spec

This commit is contained in:
Jev
2026-02-14 11:47:18 +01:00
parent 1b66fecb9a
commit 46e0ef9de7
16 changed files with 277 additions and 123 deletions

View File

@@ -1,63 +1,31 @@
#!/usr/bin/env python3
"""Post-generation hook for the Python library template."""
"""Post-generation hook for deterministic project bootstrapping."""
from __future__ import annotations
import shutil
import subprocess
import sys
from pathlib import Path
def run_command(cmd: list[str], description: str) -> None:
"""Run a command and handle errors."""
print(f"Running: {description}")
try:
result = subprocess.run(cmd, check=True, capture_output=True, text=True)
if result.stdout:
print(result.stdout)
except subprocess.CalledProcessError as e:
print(f"Error running {description}: {e}")
if e.stderr:
print(f"Error output: {e.stderr}")
def main() -> None:
"""Create a lockfile so generated projects are reproducible by default."""
if shutil.which("uv") is None:
print("Error: 'uv' is required but was not found on PATH.", file=sys.stderr)
sys.exit(1)
print("Running: uv lock")
try:
subprocess.run(["uv", "lock"], check=True)
except subprocess.CalledProcessError as exc:
print(f"Error: uv lock failed with exit code {exc.returncode}.", file=sys.stderr)
sys.exit(exc.returncode)
def main():
"""Initialize the generated project."""
project_dir = Path.cwd()
print(f"Setting up project in: {project_dir}")
# Initialize git repository
run_command(["git", "init"], "git init")
# Sync dependencies with uv
run_command(["uv", "sync", "--group", "dev"], "uv sync --group dev")
# Run initial formatting and linting
run_command(["uv", "run", "ruff", "format", "src", "tests"], "ruff format")
run_command(
["uv", "run", "ruff", "check", "--fix", "src", "tests"],
"ruff check --fix",
)
# Run type checking
try:
run_command(["uv", "run", "mypy", "src"], "mypy type checking")
except SystemExit:
# mypy might fail on initial template, continue anyway
print("MyPy check failed - this is normal for initial template")
# Run tests to ensure everything works
try:
run_command(["uv", "run", "pytest"], "pytest")
except SystemExit:
print("Tests failed - you may need to adjust the generated code")
print("\n✅ Project setup complete!")
print("\nProject lockfile generated.")
print("Next steps:")
print("1. Review and customize the generated files")
print("2. Add your actual dependencies to pyproject.toml")
print("3. Implement your core logic in src/")
print("4. Update tests as needed")
print("5. Update README.md with proper documentation")
print("1. uv sync --frozen --group dev")
print("2. uv run invoke lint")
print("3. uv run invoke test")
if __name__ == "__main__":