dev-ready 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dev_ready-0.1.2 → dev_ready-0.1.3}/.github/workflows/release.yml +7 -1
- {dev_ready-0.1.2 → dev_ready-0.1.3}/PKG-INFO +19 -3
- {dev_ready-0.1.2 → dev_ready-0.1.3}/README-pypi.md +17 -2
- {dev_ready-0.1.2 → dev_ready-0.1.3}/README.md +18 -3
- {dev_ready-0.1.2 → dev_ready-0.1.3}/docs/architecture.md +17 -4
- {dev_ready-0.1.2 → dev_ready-0.1.3}/docs/releasing.md +5 -1
- {dev_ready-0.1.2 → dev_ready-0.1.3}/docs/v0.1-overview.md +41 -29
- {dev_ready-0.1.2 → dev_ready-0.1.3}/pyproject.toml +2 -1
- dev_ready-0.1.3/src/dev_ready/fetch/__init__.py +9 -0
- dev_ready-0.1.3/src/dev_ready/fetch/snapshot.py +108 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/generate.py +31 -1
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/manifest/loader.py +31 -1
- dev_ready-0.1.3/src/dev_ready/manifest/models.py +33 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/manifest.json +7 -1
- dev_ready-0.1.3/tests/unit/test_fetch.py +199 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/unit/test_generate.py +41 -6
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/unit/test_manifest.py +66 -0
- dev_ready-0.1.3/uv.lock +478 -0
- dev_ready-0.1.2/src/dev_ready/fetch/__init__.py +0 -9
- dev_ready-0.1.2/src/dev_ready/fetch/download.py +0 -92
- dev_ready-0.1.2/src/dev_ready/fetch/extract.py +0 -114
- dev_ready-0.1.2/src/dev_ready/fetch/snapshot.py +0 -60
- dev_ready-0.1.2/src/dev_ready/fetch/urls.py +0 -13
- dev_ready-0.1.2/src/dev_ready/manifest/models.py +0 -23
- dev_ready-0.1.2/tests/unit/test_fetch.py +0 -330
- dev_ready-0.1.2/uv.lock +0 -145
- {dev_ready-0.1.2 → dev_ready-0.1.3}/.bob/qa.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/.bob/security.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/.bob/sre.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/.github/dependabot.yml +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/.github/workflows/ci.yml +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/.github/workflows/upstream-bump.yml +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/.gitignore +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/.python-version +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/CLAUDE.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/LICENSE +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/THIRD_PARTY_NOTICES.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/docs/cli-spec.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/docs/requirements.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/scripts/bump_upstream.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/README.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/__init__.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/__main__.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/cli.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/errors.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/manifest/__init__.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/overlay/__init__.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/prompts/__init__.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/prompts/_questionary_asker.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/prompts/answers.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/prompts/asker.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/prompts/collect.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/report/__init__.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/report/render.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/templates/claude/CLAUDE.md.tmpl +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/templates/claude/skills/project-orientation/SKILL.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/templates/docs/architecture.md.tmpl +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/templates/docs/requirements.md.tmpl +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/templates/mcp/mcp.json +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/src/dev_ready/verify.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/templates/README.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/README.md +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/e2e/.gitkeep +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/e2e/test_init_real.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/integration/.gitkeep +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/integration/test_fetch_real.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/unit/test_bump_upstream.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/unit/test_cli.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/unit/test_overlay.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/unit/test_prompts.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/unit/test_report.py +0 -0
- {dev_ready-0.1.2 → dev_ready-0.1.3}/tests/unit/test_verify.py +0 -0
|
@@ -7,9 +7,10 @@ on:
|
|
|
7
7
|
jobs:
|
|
8
8
|
publish:
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
|
+
environment: pypi # shows up under the repo's Deployments; also referenced by the PyPI trusted publisher config
|
|
10
11
|
permissions:
|
|
11
12
|
id-token: write # trusted publishing to PyPI — no token/password needed
|
|
12
|
-
contents:
|
|
13
|
+
contents: write # create the GitHub Release for the pushed tag
|
|
13
14
|
steps:
|
|
14
15
|
- uses: actions/checkout@v7
|
|
15
16
|
- uses: astral-sh/setup-uv@v7
|
|
@@ -35,3 +36,8 @@ jobs:
|
|
|
35
36
|
|
|
36
37
|
- name: Publish to PyPI
|
|
37
38
|
uses: pypa/gh-action-pypi-publish@v1.14.0
|
|
39
|
+
|
|
40
|
+
- name: Create GitHub Release
|
|
41
|
+
run: gh release create "$GITHUB_REF_NAME" --generate-notes dist/*
|
|
42
|
+
env:
|
|
43
|
+
GH_TOKEN: ${{ github.token }}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dev-ready
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Scaffold AI-development-ready FastAPI projects: pinned upstream template plus Claude Code skills, MCP config, and design docs
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -25,6 +25,7 @@ License: MIT License
|
|
|
25
25
|
SOFTWARE.
|
|
26
26
|
License-File: LICENSE
|
|
27
27
|
Requires-Python: >=3.12
|
|
28
|
+
Requires-Dist: copier<10,>=9.4
|
|
28
29
|
Requires-Dist: questionary<3,>=2.0
|
|
29
30
|
Description-Content-Type: text/markdown
|
|
30
31
|
|
|
@@ -49,11 +50,26 @@ A generated project based on [fastapi/full-stack-fastapi-template](https://githu
|
|
|
49
50
|
|
|
50
51
|
## Requirements
|
|
51
52
|
|
|
52
|
-
- Python >= 3.12
|
|
53
|
-
-
|
|
53
|
+
- Python >= 3.12 (uv can install this for you automatically)
|
|
54
|
+
- git (Copier fetches the pinned template via git)
|
|
54
55
|
- Network access to github.com (to fetch the pinned template snapshot)
|
|
55
56
|
- Docker is **not** required to generate a project — only to run the generated one
|
|
56
57
|
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
No install needed with [uv](https://docs.astral.sh/uv/) (any recent version):
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
uvx dev-ready init my-app
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or install with pip (requires Python >= 3.12):
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install dev-ready
|
|
70
|
+
dev-ready init my-app
|
|
71
|
+
```
|
|
72
|
+
|
|
57
73
|
## Usage
|
|
58
74
|
|
|
59
75
|
```bash
|
|
@@ -19,11 +19,26 @@ A generated project based on [fastapi/full-stack-fastapi-template](https://githu
|
|
|
19
19
|
|
|
20
20
|
## Requirements
|
|
21
21
|
|
|
22
|
-
- Python >= 3.12
|
|
23
|
-
-
|
|
22
|
+
- Python >= 3.12 (uv can install this for you automatically)
|
|
23
|
+
- git (Copier fetches the pinned template via git)
|
|
24
24
|
- Network access to github.com (to fetch the pinned template snapshot)
|
|
25
25
|
- Docker is **not** required to generate a project — only to run the generated one
|
|
26
26
|
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
No install needed with [uv](https://docs.astral.sh/uv/) (any recent version):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
uvx dev-ready init my-app
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or install with pip (requires Python >= 3.12):
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install dev-ready
|
|
39
|
+
dev-ready init my-app
|
|
40
|
+
```
|
|
41
|
+
|
|
27
42
|
## Usage
|
|
28
43
|
|
|
29
44
|
```bash
|
|
@@ -23,11 +23,26 @@ A generated project based on [fastapi/full-stack-fastapi-template](https://githu
|
|
|
23
23
|
|
|
24
24
|
## Requirements
|
|
25
25
|
|
|
26
|
-
- Python >= 3.12
|
|
27
|
-
-
|
|
26
|
+
- Python >= 3.12 (uv can install this for you automatically)
|
|
27
|
+
- git (Copier fetches the pinned template via git)
|
|
28
28
|
- Network access to github.com (to fetch the pinned template snapshot)
|
|
29
29
|
- Docker is **not** required to generate a project — only to run the generated one
|
|
30
30
|
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
No install needed with [uv](https://docs.astral.sh/uv/) (any recent version):
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
uvx dev-ready init my-app
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or install with pip (requires Python >= 3.12):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install dev-ready
|
|
43
|
+
dev-ready init my-app
|
|
44
|
+
```
|
|
45
|
+
|
|
31
46
|
## Usage
|
|
32
47
|
|
|
33
48
|
```bash
|
|
@@ -63,7 +78,7 @@ Full CLI contract: [docs/cli-spec.md](docs/cli-spec.md).
|
|
|
63
78
|
## How it works
|
|
64
79
|
|
|
65
80
|
1. **Prompt & confirm** — collect answers, show a summary before any network call or write (`--yes` skips this).
|
|
66
|
-
2. **Fetch** —
|
|
81
|
+
2. **Fetch** — run [Copier](https://copier.readthedocs.io/) against the upstream template at the commit pinned in `src/dev_ready/manifest.json` (a lockfile shipped inside the wheel), into a staging directory. Your project name and freshly generated secrets are written into the project's `.env` — no upstream `changethis` placeholders.
|
|
67
82
|
3. **Overlay** — apply the AI tooling files with template-variable substitution, still in staging.
|
|
68
83
|
4. **Verify** — structural checks against required paths (backend, frontend, compose files, ...).
|
|
69
84
|
5. **Finalize** — move staging into the target. This is the only step that touches the target.
|
|
@@ -14,8 +14,8 @@ uvx dev-ready init my-app
|
|
|
14
14
|
| 1. Prompt user | --> | 2. Fetch upstream | --> | 3. Apply overlay |
|
|
15
15
|
| (questionary) | | at pinned commit | | (CLAUDE.md, |
|
|
16
16
|
| | | from manifest | | skills, MCP, |
|
|
17
|
-
| | | (
|
|
18
|
-
| | | history)
|
|
17
|
+
| | | (Copier, no git | | docs) |
|
|
18
|
+
| | | history kept) | | |
|
|
19
19
|
+-------------------+ +---------------------+ +------------------+
|
|
20
20
|
|
|
|
21
21
|
v
|
|
@@ -48,6 +48,7 @@ uvx dev-ready init my-app
|
|
|
48
48
|
- Context: The original plan was a Node CLI (`npx create-ai-stack`, degit + @clack/prompts). The project has since moved to a Python implementation named dev-ready, matching the maintainer's primary stack (Python) and the target audience (FastAPI developers who already have uv).
|
|
49
49
|
- Decision: Pure Python CLI, `uvx dev-ready`. Node-specific choices are replaced: degit -> GitHub tarball download at pinned commit; @clack/prompts -> questionary (or equivalent); npm publish -> PyPI publish.
|
|
50
50
|
- Consequences: Single-language repo; one less runtime assumption for the target audience. The npx name `create-ai-stack` is abandoned.
|
|
51
|
+
- Amended by ADR-005: the tarball download is replaced by Copier; the pinning, staging, and all-or-nothing guarantees are unchanged.
|
|
51
52
|
|
|
52
53
|
### ADR-004: Interactive prompts with a non-interactive escape hatch
|
|
53
54
|
|
|
@@ -56,13 +57,25 @@ uvx dev-ready init my-app
|
|
|
56
57
|
- Decision: Interactive by default; `--yes` plus explicit flags cover every prompt.
|
|
57
58
|
- Consequences: All prompt logic must route through a single answers model so both paths share one code path.
|
|
58
59
|
|
|
60
|
+
### ADR-005: Consume upstream via Copier, superseding the tarball fetch (v0.1.3)
|
|
61
|
+
|
|
62
|
+
- Status: Accepted (2026-07-14), amends ADR-003
|
|
63
|
+
- Context: v0.1 downloaded the upstream as a raw tarball. Real-world use showed two gaps: (1) the template's own copier.yml questions (project_name, stack_name, secret_key, postgres_password, first_superuser_password) were never answered, so every generated project shipped the upstream "changethis" placeholder secrets and default project name in `.env`; (2) the template's `_exclude` list was ignored. Copier is the upstream template's officially supported consumption path.
|
|
64
|
+
- Decision: `fetch` runs `copier.run_copy(https://github.com/<repo>.git, staging, data=..., vcs_ref=<pinned commit>, defaults=True, unsafe=True, quiet=True)`. `generate` builds the template data from Answers, generating per-project secrets (`secrets.token_urlsafe`) that the template's `_tasks` write into the project's `.env`. Everything else — manifest pin, staging directory, all-or-nothing finalize, weekly bump CI — is unchanged. The tarball download/extract modules and their tests are removed.
|
|
65
|
+
- Consequences:
|
|
66
|
+
- Generated projects get correct names and unique secrets, and carry `.copier/.copier-answers.yml`, enabling `copier update` for users later.
|
|
67
|
+
- New runtime dependency (copier, which brings jinja2/pydantic/plumbum) and a new host requirement: git must be installed (Copier clones; checked up front, mapped to FetchError/exit 3).
|
|
68
|
+
- `unsafe=True` executes the template's `_tasks` (`.copier/update_dotenv.py`) at generation time. Accepted because the executed code is pinned to a CI-verified commit (ADR-002), never floating "latest".
|
|
69
|
+
- Template question names are coupled to the pinned commit; an upstream rename is caught by the bump PR's generate-and-verify job, not by end users.
|
|
70
|
+
- Unwanted template-repo metadata files (upstream `.github/` workflows, SECURITY.md, release-notes.md) are NOT excluded by the template's `_exclude`; a manifest-driven prune list remains future work.
|
|
71
|
+
|
|
59
72
|
## Module Boundary
|
|
60
73
|
|
|
61
74
|
| Module | Responsibility | Must not |
|
|
62
75
|
|---|---|---|
|
|
63
76
|
| `cli` | Argument parsing, command wiring, exit codes | contain generation logic |
|
|
64
77
|
| `prompts` | Interactive/non-interactive collection of user answers into one model | perform I/O other than terminal |
|
|
65
|
-
| `fetch` |
|
|
78
|
+
| `fetch` | Generate the upstream base via Copier at the manifest-pinned commit | know about overlay content |
|
|
66
79
|
| `overlay` | Apply dev-ready files onto the fetched base; templating of names/values | fetch anything from the network |
|
|
67
80
|
| `manifest` | Load/validate manifest.json; single source of truth for pins | be bypassed by other modules |
|
|
68
81
|
| `report` | Post-generation summary and next steps | mutate the generated project |
|
|
@@ -72,7 +85,7 @@ uvx dev-ready init my-app
|
|
|
72
85
|
|
|
73
86
|
- Direction: `cli` -> `prompts`/`manifest`/`fetch`/`overlay`/`report`/`verify`. Lower modules never import `cli`.
|
|
74
87
|
- `fetch`, `overlay`, and `verify` are independent of each other; only `generate` (called only by `cli`) sequences them.
|
|
75
|
-
- Runtime dependencies are kept minimal (
|
|
88
|
+
- Runtime dependencies are kept minimal (current: questionary, copier — see ADR-005; rich optional). Every new dependency requires a note here.
|
|
76
89
|
- No module reads `manifest.json` directly except `manifest`.
|
|
77
90
|
- `scripts/` (CI-only maintainer tooling, e.g. `scripts/bump_upstream.py`) is not part of the wheel and is not subject to the `fetch/`-only network-call rule above, which governs `src/dev_ready` only.
|
|
78
91
|
|
|
@@ -9,11 +9,15 @@
|
|
|
9
9
|
- **Owner:** this repository's GitHub org/user
|
|
10
10
|
- **Repository name:** this repo's name
|
|
11
11
|
- **Workflow name:** `release.yml`
|
|
12
|
-
- **Environment name:**
|
|
12
|
+
- **Environment name:** `pypi` — the publish job runs with `environment: pypi` (see `release.yml`). Leaving this blank still works (a blank publisher-side environment accepts a token from *any* environment), but naming it `pypi` is what actually restricts publishing to that environment, so set it.
|
|
13
13
|
3. Save. No further action is needed — `pypa/gh-action-pypi-publish` in `release.yml` requests a short-lived OIDC token from GitHub Actions at publish time and PyPI verifies it against this configuration.
|
|
14
14
|
|
|
15
15
|
This is a one-time setup per PyPI project. It does not need to be repeated for future releases.
|
|
16
16
|
|
|
17
|
+
### GitHub Environment (`pypi`)
|
|
18
|
+
|
|
19
|
+
The publish job declares `environment: pypi`. GitHub auto-creates the environment on first use, so nothing is strictly required up front. For real protection, pre-create it under the repo's **Settings → Environments** before the first tagged release and add a deployment branch/tag rule limiting it to `v*` tags (and optionally required reviewers). This pairs with the PyPI-side `pypi` environment above so only the release workflow, on a version tag, can publish.
|
|
20
|
+
|
|
17
21
|
## Cutting a release
|
|
18
22
|
|
|
19
23
|
1. Bump the version in `pyproject.toml` (`[project].version`).
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
# dev-ready v0.1 Overview — Phases 1–
|
|
1
|
+
# dev-ready v0.1 Overview — Phases 1–6
|
|
2
2
|
|
|
3
|
-
Status
|
|
3
|
+
Status (2026-07-14): Phases 1–5 are released as v0.1.0–v0.1.2 on PyPI (v0.1.0/v0.1.1 are placeholders slated for yanking). Phase 6 (Copier consumption + release-pipeline hardening) is implemented and sits uncommitted in the working tree, targeting **v0.1.3**. Phase 6 reviews: QA APPROVE; Security and SRE REQUEST CHANGES — two small blocking fixes remain before release (see "Release gate for v0.1.3").
|
|
4
4
|
|
|
5
5
|
## What this project is
|
|
6
6
|
|
|
7
|
-
dev-ready is a Python CLI (`uvx dev-ready init <name>`) that generates an "AI-assisted-development-ready" FastAPI full-stack project in a single command: the base is
|
|
7
|
+
dev-ready is a Python CLI (`uvx dev-ready init <name>`) that generates an "AI-assisted-development-ready" FastAPI full-stack project in a single command: the base is `fastapi/full-stack-fastapi-template` consumed via Copier at a manifest-pinned commit, with dev-ready's own overlay on top (CLAUDE.md, Claude Code skills, MCP configuration, design-doc templates).
|
|
8
8
|
|
|
9
|
-
Two core architecture decisions run through all
|
|
9
|
+
Two core architecture decisions run through all phases:
|
|
10
10
|
|
|
11
|
-
- **ADR-001/002 — No fork, pin commits**: upstream is
|
|
11
|
+
- **ADR-001/002 — No fork, pin commits**: upstream is consumed at a commit pinned in `src/dev_ready/manifest.json` (a lockfile shipped inside the wheel). Never fetch "latest" at generation time. Upstream updates come from a weekly CI job that opens bump PRs, fully validated by CI and merged manually.
|
|
12
12
|
- **All-or-nothing**: the entire pipeline runs in a staging directory; only the final step moves it into the target. If any step fails, the target is never touched and no half-finished output is left behind.
|
|
13
13
|
|
|
14
|
+
Since Phase 6 (ADR-005), fetching means running Copier — the template's officially supported consumption path — which also answers the template's own questions: the user's project name, a slugified stack name, and per-project generated secrets land in the generated project's `.env` (no more upstream `changethis` placeholders).
|
|
15
|
+
|
|
14
16
|
## End-to-end flow
|
|
15
17
|
|
|
16
18
|
```
|
|
@@ -19,10 +21,10 @@ uvx dev-ready init my-app
|
|
|
19
21
|
v
|
|
20
22
|
+------------------+ +------------------+ +------------------+
|
|
21
23
|
| 1. prompts | | 2. fetch | | 3. overlay |
|
|
22
|
-
| interactively |-->|
|
|
24
|
+
| interactively |-->| copier run_copy |-->| apply CLAUDE.md/|
|
|
23
25
|
| collect missing | | @ pinned commit | | skills/MCP/docs |
|
|
24
|
-
| answers + confirm| |
|
|
25
|
-
| (--yes skips all)| | staging
|
|
26
|
+
| answers + confirm| | answers+secrets | | template variable|
|
|
27
|
+
| (--yes skips all)| | -> .env, staging| | substitution |
|
|
26
28
|
+------------------+ +------------------+ +------------------+
|
|
27
29
|
|
|
|
28
30
|
+----------------------------------------------+
|
|
@@ -38,7 +40,7 @@ uvx dev-ready init my-app
|
|
|
38
40
|
|
|
39
41
|
Execution-order guarantees: the confirmation summary happens before any network call or write; in non-TTY environments, missing input exits 2 immediately and never hangs; steps 2–4 all happen inside a `tempfile.mkdtemp()` staging directory, with cleanup guaranteed by `finally`.
|
|
40
42
|
|
|
41
|
-
Exit codes (`docs/cli-spec.md`): 0 success; 1 unexpected error or user abort; 2 argument error; 3 network/fetch failure; 4 target directory conflict; 5 generated output failed structural verification.
|
|
43
|
+
Exit codes (`docs/cli-spec.md`): 0 success; 1 unexpected error or user abort; 2 argument error; 3 network/fetch failure (including missing git and Copier errors since Phase 6); 4 target directory conflict; 5 generated output failed structural verification.
|
|
42
44
|
|
|
43
45
|
## Module map
|
|
44
46
|
|
|
@@ -47,16 +49,16 @@ Exit codes (`docs/cli-spec.md`): 0 success; 1 unexpected error or user abort; 2
|
|
|
47
49
|
| `src/dev_ready/cli.py` | argparse, command dispatch, exception → exit-code mapping | No generation logic |
|
|
48
50
|
| `src/dev_ready/prompts/` | Interactive/non-interactive answer collection, unified into the `Answers` model (ADR-004) | I/O other than the terminal |
|
|
49
51
|
| `src/dev_ready/manifest/` | Load/validate manifest.json, single source of truth for pins | Being bypassed by other modules |
|
|
50
|
-
| `src/dev_ready/fetch/` |
|
|
52
|
+
| `src/dev_ready/fetch/` | Run Copier against the pinned upstream commit into staging (ADR-005) | Knowing overlay contents; **the only module in the repo allowed to touch the network** |
|
|
51
53
|
| `src/dev_ready/overlay/` | Apply templates/ assets onto staging, template variable substitution | Any network call |
|
|
52
54
|
| `src/dev_ready/verify.py` | Structural post-gen checks (read-only) | Network, writes |
|
|
53
55
|
| `src/dev_ready/report/` | Pure-function rendering of the success summary | Any I/O |
|
|
54
|
-
| `src/dev_ready/generate.py` | Chains fetch→overlay→verify→move
|
|
56
|
+
| `src/dev_ready/generate.py` | Chains fetch→overlay→verify→move; builds the template answers (secrets) | — |
|
|
55
57
|
| `src/dev_ready/errors.py` | Typed exception hierarchy (each carrying its exit_code) | — |
|
|
56
58
|
| `src/dev_ready/templates/` | Overlay assets (CLAUDE.md.tmpl, skills, mcp.json, docs templates), accessed via `importlib.resources` | — |
|
|
57
59
|
| `scripts/bump_upstream.py` | CI-only pin bump tool (stdlib-only, not shipped in the wheel) | — |
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
Runtime dependencies: `questionary>=2.0,<3` (importable only from `prompts/`, lazily imported, never on the `--yes` path) and, since Phase 6, `copier>=9.4,<10` (lazily imported inside `fetch`, so `--help`/`--version` stay fast). git is now a host requirement (Copier clones; missing git = clean exit 3).
|
|
60
62
|
|
|
61
63
|
## What each phase delivered
|
|
62
64
|
|
|
@@ -72,6 +74,7 @@ The only runtime dependency: `questionary>=2.0,<3` (importable only from `prompt
|
|
|
72
74
|
- `src/dev_ready/fetch/`: urls.py (codeload tarball URL, built only from validated pin fields), download.py, extract.py (safe extraction guarding against path traversal / symlinks / hardlinks), snapshot.py (fetch into temp, move only on success).
|
|
73
75
|
- Fetch-level all-or-nothing and exit 3.
|
|
74
76
|
- Review fixes: hardlink test, error messages carrying the URL, next-step guidance, known-limitation notes.
|
|
77
|
+
- (The tarball machinery built here was replaced by Copier in Phase 6; the staging/all-or-nothing pattern it established survives unchanged.)
|
|
75
78
|
|
|
76
79
|
### Phase 3 — Overlay + end-to-end wiring (`20c5614`, follow-up fix `4e2aad9`)
|
|
77
80
|
|
|
@@ -95,37 +98,46 @@ The only runtime dependency: `questionary>=2.0,<3` (importable only from `prompt
|
|
|
95
98
|
- `.github/workflows/release.yml`: tag version vs pyproject version gate → `uv build` → wheel smoke test (install into a scratch venv and run `--version`) → PyPI trusted publishing (OIDC, no tokens).
|
|
96
99
|
- `.github/dependabot.yml` (pip + github-actions, weekly), `THIRD_PARTY_NOTICES.md`, `docs/releasing.md` (one-time PyPI Trusted Publisher setup + release runbook).
|
|
97
100
|
|
|
101
|
+
### Phase 6 — Copier consumption + release-pipeline hardening (targeting v0.1.3, uncommitted)
|
|
102
|
+
|
|
103
|
+
- **ADR-005 (amends ADR-003)**: `fetch` now runs `copier.run_copy(https://github.com/<repo>.git, staging, data=..., vcs_ref=<pinned commit>, defaults=True, unsafe=True, quiet=True)`. `download.py`/`extract.py`/`urls.py` and their tar-safety tests are deleted. `generate._template_data()` supplies the template answers: project name, slugified `stack_name`, and `secrets.token_urlsafe` values for SECRET_KEY / POSTGRES_PASSWORD / FIRST_SUPERUSER_PASSWORD, written into the generated `.env` by the template's own `_tasks`. Generated projects also gain `.copier/.copier-answers.yml` (enables `copier update`).
|
|
104
|
+
- Accepted trade-offs (documented in ADR-005): new dependency tree (jinja2/pydantic/plumbum via copier), git as a host requirement, and — the material one — `unsafe=True` executes the template's pinned `_tasks` script on the end user's machine at generation time. Containment argument (pin is a 40-hex SHA, HTTPS-only clone, pin changes only via CI-gated bump PRs) was traced end-to-end and passed security review.
|
|
105
|
+
- `release.yml`: `environment: pypi` on the publish job (Deployments recording + PyPI trusted-publisher narrowing), `contents: write`, and a final `gh release create "$GITHUB_REF_NAME" --generate-notes dist/*` step so tags produce real GitHub Releases.
|
|
106
|
+
- READMEs: explicit Installation section (uvx / pip), git requirement, Copier wording.
|
|
107
|
+
- Process note: implemented out-of-band in a Cowork session rather than via the normal Architect → Engineer handoff; the deviation and its unverified claims were documented in `handoff/phase6/0-engineer-report.md`, then verified by Opus + Bob. Reviews: QA APPROVE (123 passed, ruff clean, real generation confirmed `.env` secrets); Security REQUEST CHANGES (1 blocking); SRE REQUEST CHANGES (2 blocking, 1 already resolved — `uv.lock` has been regenerated).
|
|
108
|
+
|
|
98
109
|
## Testing strategy and current state
|
|
99
110
|
|
|
100
111
|
Three test layers (`pyproject.toml` defaults to `-m 'not network'`, excluding network tests):
|
|
101
112
|
|
|
102
|
-
- **Unit (
|
|
103
|
-
- **Integration / E2E (2, `network` marker)**: `test_fetch_real.py`, `test_init_real.py` run a full init against real GitHub.
|
|
113
|
+
- **Unit (123, all run by default)**: no network, no filesystem outside tmp_path, no real TTY. Prompt behavior uses a fake asker; the bump script uses a `urlopen` monkeypatch; verify is parametrized over every entry in `REQUIRED_UPSTREAM_PATHS`; Copier is mocked in `test_fetch.py` (call contract: pinned `vcs_ref`, `defaults`/`unsafe`/URL, failure→FetchError, no temp leaks). Count dropped from 129: tar-safety tests left with the tarball code, copier-contract and template-data tests arrived.
|
|
114
|
+
- **Integration / E2E (2, `network` marker)**: `test_fetch_real.py`, `test_init_real.py` run a full init against real GitHub (now requiring git in the environment).
|
|
104
115
|
- **CI's generate-and-verify job**: the final line of defense for FR-5 — a real project + real Docker + real health check, required on every PR (including bump PRs).
|
|
105
116
|
|
|
106
117
|
## Development process (multi-agent workflow)
|
|
107
118
|
|
|
108
|
-
Each phase followed a fixed cycle: Architect (Claude, producing
|
|
109
|
-
|
|
110
|
-
## Remaining work
|
|
119
|
+
Each phase followed a fixed cycle: Architect (Claude, producing documents in `handoff/phaseN/`: engineer / QA / security / SRE) → Engineer (implements per 1-engineer and commits) → IBM Bob three-way review (written to `.bob/reviews/phaseN-*.md`) → Architect reconciles the reviews and schedules non-blocking items as the first carry-over commit of the next phase. Conventional Commits throughout (`feat:`/`fix:`/`ci:`/`docs:`), feeding the release automation. Phase 6 deviated (implementation preceded the handoff); the review gate caught real blockers, which is the system working as intended.
|
|
111
120
|
|
|
112
|
-
|
|
121
|
+
## Release gate for v0.1.3 (blocking, in order)
|
|
113
122
|
|
|
114
|
-
1. **
|
|
115
|
-
2.
|
|
116
|
-
3.
|
|
117
|
-
4.
|
|
123
|
+
1. **Security blocker** — tighten `_REPO_PATTERN` in `src/dev_ready/manifest/loader.py` to GitHub's actual owner/name charset (see `.bob/reviews/phase6-security.md`, item 1). One-line change + its unit test.
|
|
124
|
+
2. **SRE B-1** — `docs/releasing.md` still instructs "Environment name: leave blank", contradicting `environment: pypi` in release.yml. Update the runbook: PyPI trusted publisher environment = `pypi`, plus a GitHub Environment pre-creation step (tag-pattern protection `v*`). (Note: per PyPI's documented semantics a blank publisher-side environment accepts tokens from any environment, so the review's day-1-failure scenario is likely overstated — but the runbook/workflow contradiction is real and the narrowing is wanted anyway.)
|
|
125
|
+
3. Bump `pyproject.toml` version to `0.1.3`, re-run `uv lock`, full suite + ruff green.
|
|
126
|
+
4. Yank v0.1.0/v0.1.1 placeholders on PyPI before installation docs circulate (SRE N-4; pip on Python 3.10/3.11 currently resolves to the broken 0.1.0 placeholder).
|
|
127
|
+
5. Commit (Conventional Commits split), push, confirm CI green, tag `v0.1.3`, push the tag.
|
|
118
128
|
|
|
119
|
-
### Non-blocking backlog from
|
|
129
|
+
### Non-blocking backlog from Phase 6 reviews
|
|
120
130
|
|
|
121
|
-
-
|
|
122
|
-
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
131
|
+
- Document / harden the publish-succeeds-but-release-fails split-brain (SRE N-1); consider an idempotent `gh release create || gh release edit` guard.
|
|
132
|
+
- Copier shallow-clone depth for slow networks (SRE N-3); track generate-and-verify job timing (N-5).
|
|
133
|
+
- Success report should tell users their credentials live in `.env` (SEC H-3); verify `_tasks` output can't leak secrets on all platforms (H-1/H-2).
|
|
134
|
+
- `load_manifest(path)` accepts arbitrary paths — keep it un-exposed or validate (H-4); PyPI publisher environment narrowing (H-5); `uv audit`/dependabot advisory scanning in CI (H-6); overlay prompt-injection review cadence (H-7).
|
|
135
|
+
- `_slugify` parametrized edge-case tests (QA suggestion).
|
|
136
|
+
- Carried from Phase 5: pin `pypa/gh-action-pypi-publish` to a full SHA; network isolation of generate-and-verify; `verify_project` collecting all missing paths; branch protection on main.
|
|
126
137
|
|
|
127
|
-
### Planned, explicitly out of
|
|
138
|
+
### Planned, explicitly out of scope (`docs/requirements.md` roadmap)
|
|
128
139
|
|
|
140
|
+
- Manifest-driven prune list for upstream template-repo metadata (upstream `.github/` workflows, SECURITY.md, release-notes.md) — Copier's `_exclude` does not remove these; deliberately deferred from Phase 6.
|
|
129
141
|
- `dev-ready check` (validate an existing project against the manifest) and `dev-ready upgrade` (re-apply a newer overlay).
|
|
130
142
|
- Support for other base templates; a Web UI companion (decision deferred).
|
|
131
143
|
- **Vendoring external skill content** (mattpocock/skills, the Apache 2.0 parts of anthropics/skills, caveman, awesome-design-md, etc.): currently everything in `templates/` is original content, and THIRD_PARTY_NOTICES records this accurately. Actually vendoring will require per-repo license handling (Apache NOTICE, excluding source-available and Commons Clause items) and provenance records in a manifest `vendored` section.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "dev-ready"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.3"
|
|
4
4
|
description = "Scaffold AI-development-ready FastAPI projects: pinned upstream template plus Claude Code skills, MCP config, and design docs"
|
|
5
5
|
readme = "README-pypi.md"
|
|
6
6
|
license = { file = "LICENSE" }
|
|
7
7
|
requires-python = ">=3.12"
|
|
8
8
|
dependencies = [
|
|
9
|
+
"copier>=9.4,<10",
|
|
9
10
|
"questionary>=2.0,<3",
|
|
10
11
|
]
|
|
11
12
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""fetch: generate the upstream base via Copier at the manifest-pinned commit.
|
|
2
|
+
|
|
3
|
+
Only module allowed to make network calls (Copier's git clone happens here).
|
|
4
|
+
Knows nothing about overlay content. See docs/architecture.md (ADR-005).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from dev_ready.fetch.snapshot import fetch_snapshot
|
|
8
|
+
|
|
9
|
+
__all__ = ["fetch_snapshot"]
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Generate the upstream base with Copier at the manifest-pinned commit (ADR-005).
|
|
2
|
+
|
|
3
|
+
Copier is the upstream template's officially supported consumption path: it
|
|
4
|
+
applies the template's own question defaults/answers (project name, stack
|
|
5
|
+
name, secrets written into .env via the template's `_tasks`) and its
|
|
6
|
+
`_exclude` list, neither of which a raw tarball download can do.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import shutil
|
|
10
|
+
import subprocess
|
|
11
|
+
import tempfile
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
from dev_ready.errors import FetchError, TargetDirectoryError
|
|
16
|
+
from dev_ready.manifest import UpstreamPin
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def fetch_snapshot(
|
|
20
|
+
pin: UpstreamPin, dest: Path, template_data: dict[str, Any] | None = None
|
|
21
|
+
) -> Path:
|
|
22
|
+
"""Run Copier against the upstream template pinned by `pin`, into `dest`.
|
|
23
|
+
|
|
24
|
+
`template_data` answers the template's own copier.yml questions; anything
|
|
25
|
+
not provided falls back to the template's defaults (never an interactive
|
|
26
|
+
prompt — `defaults=True`).
|
|
27
|
+
|
|
28
|
+
All-or-nothing: `dest` is populated only after a fully successful Copier
|
|
29
|
+
run. On any failure, all temp artifacts are removed and `dest` is left
|
|
30
|
+
untouched.
|
|
31
|
+
"""
|
|
32
|
+
_validate_target_dir(dest)
|
|
33
|
+
if shutil.which("git") is None:
|
|
34
|
+
raise FetchError(
|
|
35
|
+
"git executable not found — Copier needs git to fetch the pinned template."
|
|
36
|
+
" Install git and retry."
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
staging_dir = Path(tempfile.mkdtemp(prefix="dev-ready-staging-"))
|
|
40
|
+
try:
|
|
41
|
+
_run_copier(pin, staging_dir, template_data or {})
|
|
42
|
+
_finalize(staging_dir, dest)
|
|
43
|
+
finally:
|
|
44
|
+
shutil.rmtree(staging_dir, ignore_errors=True)
|
|
45
|
+
|
|
46
|
+
return dest
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _run_copier(pin: UpstreamPin, staging_dir: Path, data: dict[str, Any]) -> None:
|
|
50
|
+
# Imported lazily so `dev-ready --help/--version` never pays Copier's
|
|
51
|
+
# import cost (pydantic, jinja2, ...).
|
|
52
|
+
import copier
|
|
53
|
+
from copier.errors import CopierError
|
|
54
|
+
|
|
55
|
+
# UpstreamPin.repo and .commit are validated by dev_ready.manifest (strict
|
|
56
|
+
# owner/name pattern, 40-hex-char sha) before a pin ever reaches this
|
|
57
|
+
# function, so no raw/unvalidated input is interpolated into the URL.
|
|
58
|
+
src_url = f"https://github.com/{pin.repo}.git"
|
|
59
|
+
try:
|
|
60
|
+
copier.run_copy(
|
|
61
|
+
src_url,
|
|
62
|
+
staging_dir,
|
|
63
|
+
data=data,
|
|
64
|
+
vcs_ref=pin.commit,
|
|
65
|
+
# Per-pin source paths Copier must skip, merged with the
|
|
66
|
+
# template's own _exclude. The pinned template ships symlinks
|
|
67
|
+
# into .venv/ that dangle until the user creates the venv;
|
|
68
|
+
# Copier follows symlinks and crashes on them (see manifest.json
|
|
69
|
+
# and UpstreamPin.exclude).
|
|
70
|
+
exclude=pin.exclude,
|
|
71
|
+
# Unanswered template questions take the template's defaults;
|
|
72
|
+
# dev-ready's own prompting happens in `prompts`, never here.
|
|
73
|
+
defaults=True,
|
|
74
|
+
# Required because the template declares `_tasks`
|
|
75
|
+
# (.copier/update_dotenv.py). The executed code is pinned to a
|
|
76
|
+
# CI-verified commit (ADR-002/ADR-005), not floating "latest".
|
|
77
|
+
unsafe=True,
|
|
78
|
+
quiet=True,
|
|
79
|
+
)
|
|
80
|
+
except (CopierError, subprocess.CalledProcessError, OSError) as error:
|
|
81
|
+
raise FetchError(
|
|
82
|
+
f"copier generation from {src_url}@{pin.commit} failed: {error}"
|
|
83
|
+
) from error
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _validate_target_dir(dest: Path) -> None:
|
|
87
|
+
# When called from generate(), dest is always a fresh subdirectory of a
|
|
88
|
+
# just-created staging root, so this check is a no-op in that path; it
|
|
89
|
+
# only bites when fetch_snapshot is called directly at an existing path.
|
|
90
|
+
if not dest.exists():
|
|
91
|
+
return
|
|
92
|
+
if not dest.is_dir():
|
|
93
|
+
raise TargetDirectoryError(
|
|
94
|
+
f"target {dest} exists and is not a directory — remove or rename it and retry."
|
|
95
|
+
)
|
|
96
|
+
if any(dest.iterdir()):
|
|
97
|
+
raise TargetDirectoryError(
|
|
98
|
+
f"target directory {dest} is not empty — remove or rename it and retry."
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _finalize(staging_dir: Path, dest: Path) -> None:
|
|
103
|
+
try:
|
|
104
|
+
if dest.exists():
|
|
105
|
+
dest.rmdir()
|
|
106
|
+
shutil.move(str(staging_dir), str(dest))
|
|
107
|
+
except OSError as error:
|
|
108
|
+
raise FetchError(f"failed to move generated snapshot into {dest}: {error}") from error
|
|
@@ -4,6 +4,8 @@ Only `cli` (or this module, which only `cli` calls) sequences `fetch`,
|
|
|
4
4
|
`overlay`, and `verify` — see docs/architecture.md, Dependency Rules.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
import re
|
|
8
|
+
import secrets
|
|
7
9
|
import shutil
|
|
8
10
|
import sys
|
|
9
11
|
import tempfile
|
|
@@ -35,7 +37,7 @@ def generate(answers: Answers, pin: UpstreamPin) -> list[Path]:
|
|
|
35
37
|
staging_root = Path(tempfile.mkdtemp(prefix="dev-ready-generate-"))
|
|
36
38
|
try:
|
|
37
39
|
project_staging = staging_root / "project"
|
|
38
|
-
fetch_snapshot(pin, project_staging)
|
|
40
|
+
fetch_snapshot(pin, project_staging, _template_data(answers))
|
|
39
41
|
written = apply_overlay(answers, project_staging)
|
|
40
42
|
verify_project(project_staging)
|
|
41
43
|
_finalize(project_staging, answers.target_dir)
|
|
@@ -47,6 +49,34 @@ def generate(answers: Answers, pin: UpstreamPin) -> list[Path]:
|
|
|
47
49
|
return written
|
|
48
50
|
|
|
49
51
|
|
|
52
|
+
def _template_data(answers: Answers) -> dict[str, str]:
|
|
53
|
+
"""Answers for the upstream template's own copier.yml questions.
|
|
54
|
+
|
|
55
|
+
Anything not listed here falls back to the template's defaults
|
|
56
|
+
(fetch_snapshot runs Copier with defaults=True). Secrets are generated
|
|
57
|
+
per-project so a generated project never ships the upstream "changethis"
|
|
58
|
+
placeholders; the template's `_tasks` write them into the project's .env,
|
|
59
|
+
which is where users find them (including the first superuser password).
|
|
60
|
+
|
|
61
|
+
The question names are coupled to the pinned upstream commit; the weekly
|
|
62
|
+
bump CI (ADR-002) regenerates a real project, so a rename upstream fails
|
|
63
|
+
the bump PR rather than end users.
|
|
64
|
+
"""
|
|
65
|
+
return {
|
|
66
|
+
"project_name": answers.project_name,
|
|
67
|
+
"stack_name": _slugify(answers.project_name),
|
|
68
|
+
"secret_key": secrets.token_urlsafe(32),
|
|
69
|
+
"postgres_password": secrets.token_urlsafe(32),
|
|
70
|
+
"first_superuser_password": secrets.token_urlsafe(16),
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _slugify(name: str) -> str:
|
|
75
|
+
"""Docker-Compose-label-safe stack name: lowercase, alnum and hyphens only."""
|
|
76
|
+
slug = re.sub(r"[^a-z0-9]+", "-", name.lower()).strip("-")
|
|
77
|
+
return slug or "app"
|
|
78
|
+
|
|
79
|
+
|
|
50
80
|
def _validate_target_dir(target_dir: Path) -> None:
|
|
51
81
|
if not target_dir.exists():
|
|
52
82
|
return
|
|
@@ -16,7 +16,12 @@ from dev_ready.manifest.models import Manifest, UpstreamPin
|
|
|
16
16
|
SUPPORTED_MANIFEST_VERSION = 1
|
|
17
17
|
|
|
18
18
|
_COMMIT_PATTERN = re.compile(r"^[0-9a-f]{40}$")
|
|
19
|
-
|
|
19
|
+
# owner/name, GitHub-shaped: each side must start with an alphanumeric so no
|
|
20
|
+
# segment can begin with '.' (blocks traversal-shaped values like '..x/y' that
|
|
21
|
+
# the old `[\w.-]+` permitted). owner is alphanumeric + hyphen; repo name also
|
|
22
|
+
# allows '.' and '_'. Defense-in-depth for the URL built in fetch, hardening the
|
|
23
|
+
# path before load_manifest() is ever pointed at a non-bundled manifest.
|
|
24
|
+
_REPO_PATTERN = re.compile(r"^[a-zA-Z0-9][a-zA-Z0-9-]*/[a-zA-Z0-9][a-zA-Z0-9._-]*$")
|
|
20
25
|
|
|
21
26
|
|
|
22
27
|
def load_manifest(path: Path) -> Manifest:
|
|
@@ -100,10 +105,35 @@ def _parse_pin(name: str, entry: object, source: str) -> UpstreamPin:
|
|
|
100
105
|
f"{source}: upstream '{name}' field 'verified_at' must be a string or null"
|
|
101
106
|
)
|
|
102
107
|
|
|
108
|
+
exclude = _parse_exclude(name, entry, source)
|
|
109
|
+
|
|
103
110
|
return UpstreamPin(
|
|
104
111
|
repo=values["repo"],
|
|
105
112
|
ref=values["ref"],
|
|
106
113
|
commit=values["commit"],
|
|
107
114
|
license=values["license"],
|
|
108
115
|
verified_at=verified_at,
|
|
116
|
+
exclude=exclude,
|
|
109
117
|
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _parse_exclude(name: str, entry: dict, source: str) -> tuple[str, ...]:
|
|
121
|
+
"""Validate the optional per-pin 'exclude' list (Copier source-path patterns)."""
|
|
122
|
+
raw = entry.get("exclude")
|
|
123
|
+
if raw is None:
|
|
124
|
+
return ()
|
|
125
|
+
if not isinstance(raw, list):
|
|
126
|
+
raise ManifestError(f"{source}: upstream '{name}' field 'exclude' must be a list")
|
|
127
|
+
patterns: list[str] = []
|
|
128
|
+
for item in raw:
|
|
129
|
+
if not isinstance(item, str) or not item:
|
|
130
|
+
raise ManifestError(
|
|
131
|
+
f"{source}: upstream '{name}' 'exclude' entries must be non-empty strings"
|
|
132
|
+
)
|
|
133
|
+
if item.startswith(("/", "\\")) or ".." in item.split("/"):
|
|
134
|
+
raise ManifestError(
|
|
135
|
+
f"{source}: upstream '{name}' 'exclude' entries must be relative"
|
|
136
|
+
f" paths without '..', got {item!r}"
|
|
137
|
+
)
|
|
138
|
+
patterns.append(item)
|
|
139
|
+
return tuple(patterns)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Data models for the upstream pin manifest."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(frozen=True)
|
|
7
|
+
class UpstreamPin:
|
|
8
|
+
"""One pinned upstream source (repo at an exact commit).
|
|
9
|
+
|
|
10
|
+
`exclude` lists source paths Copier must skip for this pin, on top of the
|
|
11
|
+
template's own `_exclude` (Copier merges both). Needed for entries that
|
|
12
|
+
are broken by design at clone time — e.g. the FastAPI template ships
|
|
13
|
+
symlinks into `.venv/` that dangle until the user creates the venv, and
|
|
14
|
+
Copier follows symlinks by default. The list lives next to the pin so a
|
|
15
|
+
weekly bump PR that hits new dangling entries fails CI loudly and gets
|
|
16
|
+
fixed here, in one reviewed place (ADR-002/ADR-005).
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
repo: str
|
|
20
|
+
ref: str
|
|
21
|
+
commit: str
|
|
22
|
+
license: str
|
|
23
|
+
verified_at: str | None = None
|
|
24
|
+
exclude: tuple[str, ...] = ()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class Manifest:
|
|
29
|
+
"""Validated content of manifest.json."""
|
|
30
|
+
|
|
31
|
+
manifest_version: int
|
|
32
|
+
upstream: dict[str, UpstreamPin]
|
|
33
|
+
overlay_version: str
|