|
| 1 | +# RustySpec Project Guidelines |
| 2 | + |
| 3 | +## What This Project Is |
| 4 | + |
| 5 | +RustySpec is a Rust CLI tool (`rustyspec`) implementing Specification-Driven Development (SDD) — it transforms feature descriptions into structured specs, plans, tasks, and test scaffolds, then orchestrates AI agents to implement them. |
| 6 | + |
| 7 | +See [docs/ARCHITECTURE.md](../docs/ARCHITECTURE.md) for full system architecture and data flows. |
| 8 | + |
| 9 | +## Build and Test |
| 10 | + |
| 11 | +```bash |
| 12 | +# Build |
| 13 | +cargo build --release |
| 14 | + |
| 15 | +# Test (uses assert_cmd + tempfile for CLI integration tests) |
| 16 | +cargo test |
| 17 | + |
| 18 | +# Run locally |
| 19 | +cargo run -- [subcommand] |
| 20 | +``` |
| 21 | + |
| 22 | +Rust edition: **2024**. No Makefile or justfile — Cargo is the sole build tool. |
| 23 | + |
| 24 | +## Architecture |
| 25 | + |
| 26 | +The codebase has a strict layered separation: |
| 27 | + |
| 28 | +| Layer | Location | Rule | |
| 29 | +|-------|----------|------| |
| 30 | +| CLI | `src/cli/` | **No business logic** — thin handlers only; delegate to core/agents/templates | |
| 31 | +| Domain | `src/core/` | Pure logic, no CLI imports — library-ready | |
| 32 | +| Agent integration | `src/agents/` | 21 AI agents, data-driven config, CLI invocation with fallback to handoff | |
| 33 | +| Templating | `src/templates/` | Tera rendering; 4-layer resolution (see below) | |
| 34 | +| Config | `src/config/` | TOML-based; `RootConfig` + `PipelineConfig` | |
| 35 | +| Extensions/Presets | `src/extensions/`, `src/presets/` | CRUD + cross-platform hook execution | |
| 36 | + |
| 37 | +Each `src/cli/` file maps 1-to-1 to a subcommand. Never add business logic there. |
| 38 | + |
| 39 | +## Key Conventions |
| 40 | + |
| 41 | +**Errors:** Use `RustySpecError` (`src/core/errors.rs`) with `thiserror`. Every error variant must include a `fix` field with a human-actionable suggestion. Use `anyhow::Result` in fallible functions. |
| 42 | + |
| 43 | +**CLI parsing:** Clap derive macros (`#[derive(Parser)]`). Global `--debug` flag lives on the root `Cli` struct. |
| 44 | + |
| 45 | +**Serialization:** `serde` with `#[derive(Serialize, Deserialize)]` for all config/manifest types. |
| 46 | + |
| 47 | +**Embedded templates:** Use `include_str!()` to embed templates from `templates/` into the binary. Template resolution priority: |
| 48 | +``` |
| 49 | +1. .rustyspec/templates/overrides/ ← project-level tweaks (highest) |
| 50 | +2. .rustyspec/presets/<id>/templates/ |
| 51 | +3. .rustyspec/extensions/<id>/templates/ |
| 52 | +4. Binary-embedded defaults ← fallback |
| 53 | +``` |
| 54 | + |
| 55 | +**Runtime config locations:** |
| 56 | +- `rustyspec.toml` — project config (root) |
| 57 | +- `.rustyspec/` — constitution, templates, extensions, presets, internal state |
| 58 | +- `.rustyspec/project-config.json` — `ProjectInternalConfig` (internal state, not user-facing) |
| 59 | + |
| 60 | +**Feature resolution** cascades: explicit CLI arg → env var → current git branch → latest `specs/` directory. |
| 61 | + |
| 62 | +## Module Organization |
| 63 | + |
| 64 | +- Max 2 directory levels under `src/` |
| 65 | +- `mod.rs` re-exports public symbols; sub-files are focused on a single concern |
| 66 | +- `src/core/` modules: `spec_parser`, `task_generator`, `test_generator`, `constitution`, `analyzer`, `review`, `git`, `feature`, `errors`, `token`, `vscode`, `pipeline` |
| 67 | + |
| 68 | +## Documentation |
| 69 | + |
| 70 | +Don't duplicate — link: |
| 71 | +- Architecture details → [docs/ARCHITECTURE.md](../docs/ARCHITECTURE.md) |
| 72 | +- SDD methodology → [docs/rusty-specification.md](../docs/rusty-specification.md) |
| 73 | +- Pipeline orchestration → [docs/multi-agent-pipeline.md](../docs/multi-agent-pipeline.md) |
| 74 | +- Test scaffold generation → [docs/spec-to-test-generation.md](../docs/spec-to-test-generation.md) |
| 75 | +- Feature backlog → [docs/KILLER_FEATURE_IDEAS.md](../docs/KILLER_FEATURE_IDEAS.md) |
0 commit comments