11# AGENTS — Root Contract
22
3- This file is the ** entry point** for any agent (human or AI) working in
4- this repository. It is intentionally short. Authoritative rules live in
5- [ SPEC.md] ( SPEC.md ) . Per-project specifics live in each project's own
6- ` AGENTS.md ` under [ projects/] ( projects/ ) .
3+ This file is the ** single, authoritative agent contract** for the entire
4+ repository. It is intentionally short. Authoritative engineering rules
5+ live in [ SPEC.md] ( SPEC.md ) . Scoped, machine-loaded rules live under
6+ [ .github/instructions/] ( .github/instructions/ ) and are applied
7+ automatically by VS Code / Copilot via ` applyTo ` globs (see ADR-0009).
8+
9+ There are ** no per-project ` AGENTS.md ` files** — the same checklist and
10+ hard rules apply to every project under [ projects/] ( projects/ ) .
711
812## Repository Shape
913
10- This is a ** uv workspace monorepo** . The structure is :
14+ This is a ** uv workspace monorepo** with a unified per-project layout :
1115
1216```
1317projects/
1418 llm-patch/ engine — the generic Ingest → Compile → Attach → Use framework
15- shared- utils/ cross-project, stdlib-only utilities
19+ utils/ cross-project, stdlib-only utilities (llm_patch_utils)
1620 wiki-agent/ first downstream use-case (wiki-specialized agent)
1721docs/
1822 adr/ Architecture Decision Records (MADR format)
@@ -25,43 +29,70 @@ SPEC.md the engineering specification (binding)
2529AGENTS.md this file
2630```
2731
32+ Every ` projects/<name>/ ` follows the same flat layout — see
33+ [ SPEC.md §1.1 Project Shape] ( SPEC.md ) :
34+
35+ ```
36+ projects/<name>/
37+ pyproject.toml # name = "llm-patch[-<usecase>]"
38+ README.md
39+ CHANGELOG.md
40+ src/<import_pkg>/ # llm_patch[_<usecase>]
41+ tests/
42+ ```
43+
2844## Mandatory Pre-Change Checklist
2945
3046Before changing any file, the agent must:
3147
32- 1 . ** Read the closest ` AGENTS.md ` ** — the per-project file overrides /
33- refines this root file. If editing a use-case, read the use-case's
34- ` AGENTS.md ` and the engine's ` AGENTS.md ` .
48+ 1 . ** Read this file ** and the relevant scoped instructions under
49+ [ .github/instructions/ ] ( .github/instructions/ ) (engine boundary,
50+ utils boundary, use-case boundary, python style, tests) .
35512 . ** Re-read the relevant section of [ SPEC.md] ( SPEC.md ) ** — especially
36- Dependency Direction and Public API Stability.
52+ Dependency Direction (§1) and Public API Stability (§3) .
37533 . ** Write or update tests first** — the project follows TDD for new
3854 public API. See SPEC §Testing.
39554 . ** Run ` uv run --package <project> pytest -q ` ** for the affected
4056 project(s) and confirm baselines hold:
41- - ` llm-patch ` engine: ` 216 passed, 3 skipped`
42- - ` llm-patch-shared ` , ` llm-patch-wiki-agent ` : smoke tests pass.
57+ - ` llm-patch ` engine: ` 464 passed, 12 skipped` .
58+ - ` llm-patch-utils ` , ` llm-patch-wiki-agent ` : smoke tests pass.
43595 . ** Add an ADR** under [ docs/adr/] ( docs/adr/ ) for any cross-cutting,
4460 architectural, or dependency-direction-affecting decision. Use
4561 [ docs/adr/0000-template.md] ( docs/adr/0000-template.md ) .
4662
4763## Hard Rules (do not violate without an ADR)
4864
49- - ** Dependency direction is one-way** : use-cases → engine → shared- utils.
65+ - ** Dependency direction is one-way** : use-cases → engine → utils.
5066 No reverse imports. Enforced by [ tools/check_layering.py] ( tools/check_layering.py ) .
5167- ** Public API is sacred** : only symbols re-exported from a project's
5268 top-level ` __init__.py ` are public. Use-cases must consume only the
5369 public API of the engine.
5470- ** No behavior changes alongside structural changes** in the same PR.
5571- ** No module-level side effects** (no I/O, no network) at import time.
72+ - ** No per-project ` AGENTS.md ` ** : scoped rules belong in
73+ ` .github/instructions/*.instructions.md ` with an ` applyTo ` glob.
74+
75+ ## Adding a New Use-Case Project
76+
77+ ``` pwsh
78+ uv run python tools/scaffold_project.py <name>
79+ ```
80+
81+ This materializes the unified layout above. The new project consumes
82+ the engine via its public API and may depend on ` llm-patch-utils ` . See
83+ [ SPEC.md §9] ( SPEC.md ) and use [ projects/wiki-agent/] ( projects/wiki-agent/ )
84+ as the reference implementation.
5685
5786## Where to Look for What
5887
5988| If you want to… | Read… |
6089| ---| ---|
6190| Understand the system architecture | [ docs/ARCHITECTURE.md] ( docs/ARCHITECTURE.md ) |
6291| Understand the engineering rules | [ SPEC.md] ( SPEC.md ) |
63- | Add a new use-case project | [ tools/scaffold_project.py] ( tools/scaffold_project.py ) + this file |
64- | Change the engine | [ projects/llm-patch/AGENTS.md] ( projects/llm-patch/AGENTS.md ) |
65- | Change shared utilities | [ projects/shared-utils/AGENTS.md] ( projects/shared-utils/AGENTS.md ) |
66- | Change the wiki agent | [ projects/wiki-agent/AGENTS.md] ( projects/wiki-agent/AGENTS.md ) |
92+ | Add a new use-case project | [ tools/scaffold_project.py] ( tools/scaffold_project.py ) + [ SPEC.md §9] ( SPEC.md ) |
93+ | Change the engine | [ .github/instructions/engine-boundary.instructions.md] ( .github/instructions/engine-boundary.instructions.md ) |
94+ | Change utilities | [ .github/instructions/utils-boundary.instructions.md] ( .github/instructions/utils-boundary.instructions.md ) |
95+ | Change a use-case | [ .github/instructions/usecase-boundary.instructions.md] ( .github/instructions/usecase-boundary.instructions.md ) |
96+ | Write Python | [ .github/instructions/python-style.instructions.md] ( .github/instructions/python-style.instructions.md ) |
97+ | Write tests | [ .github/instructions/tests.instructions.md] ( .github/instructions/tests.instructions.md ) |
6798| See past architectural decisions | [ docs/adr/README.md] ( docs/adr/README.md ) |
0 commit comments