Skip to content

Commit d7d97e4

Browse files
committed
feat: enhance validation and documentation across multiple modules
1 parent 96b23d2 commit d7d97e4

File tree

27 files changed

+2683
-365
lines changed

27 files changed

+2683
-365
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,17 @@ pb-spec init --ai all -g # install globally to each agent's home/config di
9191

9292
## Supported AI Tools
9393

94-
| AI Tool | Target Directory | File Format |
95-
|---|---|---|
96-
| Claude Code | `.claude/skills/pb-<name>/SKILL.md` | YAML frontmatter + Markdown |
97-
| VS Code Copilot | `.github/prompts/pb-<name>.prompt.md` | Markdown (no frontmatter) |
98-
| OpenCode | `.opencode/skills/pb-<name>/SKILL.md` | YAML frontmatter + Markdown |
99-
| Gemini CLI | `.gemini/commands/pb-<name>.toml` | TOML (`description` + `prompt`) |
100-
| Codex | `.codex/prompts/pb-<name>.md` | YAML frontmatter + Markdown |
94+
All platform adapters are **fully implemented** and production-ready. Each platform has been tested for path generation, content rendering, and file installation.
95+
96+
| AI Tool | Status | Target Directory | File Format | Global Install |
97+
|---|---|---|---|---|
98+
| Claude Code | ✅ Complete | `.claude/skills/pb-<name>/SKILL.md` | YAML frontmatter + Markdown |`~/.claude/skills/` |
99+
| VS Code Copilot | ✅ Complete | `.github/prompts/pb-<name>.prompt.md` | Markdown (no frontmatter) |`~/.copilot/prompts/` |
100+
| OpenCode | ✅ Complete | `.opencode/skills/pb-<name>/SKILL.md` | YAML frontmatter + Markdown |`~/.config/opencode/skills/` |
101+
| Gemini CLI | ✅ Complete | `.gemini/commands/pb-<name>.toml` | TOML (`description` + `prompt`) |`~/.gemini/commands/` |
102+
| Codex | ✅ Complete | `.codex/prompts/pb-<name>.md` | YAML frontmatter + Markdown |`~/.codex/prompts/` |
103+
104+
For detailed implementation information, see [docs/platform-implementation-status.md](docs/platform-implementation-status.md).
101105

102106
## CLI Reference
103107

@@ -158,7 +162,7 @@ This stronger contract does not add a new command or side-channel validator. The
158162

159163
### 2. `/pb-plan <requirement>` — Design & Task Planning
160164

161-
Takes a natural-language requirement and produces a complete feature spec:
165+
Takes source material in arbitrary format and produces a complete feature spec. You can hand it raw design docs, rough notes, copied requirements, partial design drafts, or mixed-format planning input without wrapping that material in a special pb-plan prompt recipe:
162166

163167
```text
164168
specs/<YYYY-MM-DD-NO-feature-name>/
@@ -178,6 +182,8 @@ It also performs two additional planning audits before implementation starts:
178182
- Template identity alignment: if the repo still contains generic crate/package/module names from a scaffold, `pb-plan` must front-load renaming those identifiers to project-matching names.
179183
- Risk-based advanced testing: property testing is planned by default for broad input-domain logic, while fuzzing and benchmarks are added only when the feature profile justifies them. Tool selection follows repo language conventions: `Hypothesis` / `fast-check` / `proptest`, `Atheris` / `jazzer.js` / `cargo-fuzz`, and `pytest-benchmark` / `Vitest Bench` / `criterion`.
180184

185+
It should also normalize the incoming source material into a source requirement ledger and use multiple fresh subagents when that improves quality, typically separating source requirement extraction, live codebase analysis, and spec reconciliation. Before finalizing the spec, `pb-plan` should reconcile the extracted source requirements against the generated `design.md`, `tasks.md`, and `features/*.feature` so missing requirements are closed in the planning phase instead of being discovered later during `pb-build`.
186+
181187
It also adds an explicit **Architecture Decisions** section to `design.md`. For work that introduces a new boundary or is likely to exceed 200 lines, planning must evaluate **SRP**, **DIP**, and the classic patterns **Factory**, **Strategy**, **Observer**, **Adapter**, and **Decorator**. The chosen pattern must be justified against alternatives and checked against the code-simplification lens so the design stays simpler, not just more abstract.
182188

183189
The resulting `design.md`, `tasks.md`, and `features/*.feature` files are also the workflow's type carrier in plain markdown. `pb-plan` keeps the current artifact family and command surface, but those artifacts now need explicit contract fields so downstream stages can validate readiness without inventing a separate YAML or JSON schema.

docs/contract.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,42 @@ A spec is build-eligible when all of the following are true:
407407

408408
Future validator versions may extend build eligibility checks to include stronger cross-link validation.
409409

410-
## 12. Validator-Ready Priorities
410+
## 12. Validation Type System
411+
412+
### 12.1 Structured Validation Results
413+
414+
The validation system uses structured types for better error handling and reporting:
415+
416+
| Type | Purpose |
417+
| :--- | :--- |
418+
| `ValidationResult` | Collection of errors and warnings with severity levels |
419+
| `ValidationError` | Single validation issue with file, line, column context |
420+
| `ErrorLevel` | Severity enum: `ERROR`, `WARNING`, `INFO` |
421+
422+
### 12.2 Backward Compatibility
423+
424+
For backward compatibility, the validation functions maintain two interfaces:
425+
426+
| Function | Return Type | Purpose |
427+
| :--- | :--- | :--- |
428+
| `validate_design_file()` | `list[str]` | Legacy interface returning error strings |
429+
| `validate_design_file_structured()` | `ValidationResult` | New interface with structured errors |
430+
| `validate_task_file()` | `list[str]` | Legacy interface returning error strings |
431+
| `validate_task_file_structured()` | `ValidationResult` | New interface with structured errors |
432+
433+
The legacy functions return `[error.message for error in result.errors]` to maintain backward compatibility with existing code and tests.
434+
435+
### 12.3 Feature Parsing Types
436+
437+
The feature parsing system uses structured types:
438+
439+
| Type | Purpose |
440+
| :--- | :--- |
441+
| `FeatureScenario` | Parsed Gherkin scenario with file, line number, and outline flag |
442+
| `parse_feature_file()` | Returns `list[FeatureScenario]` for structured access |
443+
| `get_scenario_by_name()` | Finds a specific scenario by name |
444+
445+
## 13. Validator-Ready Priorities
411446

412447
The first validator tranche should prioritize the narrowest high-value checks:
413448

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Platform Implementation Status
2+
3+
All platform adapters in pb-spec are **fully implemented** and production-ready.
4+
5+
## Supported Platforms
6+
7+
| Platform | Status | Directory Structure | File Format | Global Install Support |
8+
| :--- | :--- | :--- | :--- | :--- |
9+
| **Claude Code** | ✅ Complete | `.claude/skills/<name>/SKILL.md` | YAML frontmatter + Markdown | ✅ Yes (`~/.claude/skills/`) |
10+
| **VS Code Copilot** | ✅ Complete | `.github/prompts/<name>.prompt.md` | Plain Markdown | ✅ Yes (`~/.copilot/prompts/`) |
11+
| **OpenCode** | ✅ Complete | `.opencode/skills/<name>/SKILL.md` | YAML frontmatter + Markdown | ✅ Yes (`~/.config/opencode/skills/`) |
12+
| **Gemini CLI** | ✅ Complete | `.gemini/commands/<name>.toml` | TOML (description + prompt) | ✅ Yes (`~/.gemini/commands/`) |
13+
| **OpenAI Codex** | ✅ Complete | `.codex/prompts/<name>.md` | YAML frontmatter + Markdown | ✅ Yes (`~/.codex/prompts/`) |
14+
15+
## Implementation Details
16+
17+
### Claude Code (`claude.py`)
18+
19+
- Uses SKILL.md files with YAML frontmatter
20+
- Supports `CLAUDE_CONFIG_DIR` environment variable for custom config location
21+
- Installs reference files alongside skill files
22+
23+
### VS Code Copilot (`copilot.py`)
24+
25+
- Uses `.prompt.md` files without frontmatter
26+
- Simplest format - just raw prompt content
27+
- Self-contained prompts (no reference files)
28+
29+
### OpenCode (`opencode.py`)
30+
31+
- Uses SKILL.md files with YAML frontmatter
32+
- Supports XDG Base Directory specification (`XDG_CONFIG_HOME`)
33+
- Installs reference files alongside skill files
34+
35+
### Gemini CLI (`gemini.py`)
36+
37+
- Uses TOML format with `description` and `prompt` fields
38+
- Self-contained prompts (no reference files)
39+
- Handles quote escaping in TOML values
40+
41+
### OpenAI Codex (`codex.py`)
42+
43+
- Uses `.md` files with YAML frontmatter
44+
- Supports `CODEX_HOME` environment variable for custom config location
45+
- Self-contained prompts (no reference files)
46+
47+
## Platform-Specific Features
48+
49+
### Skill Loading Strategy
50+
51+
- **Claude, OpenCode**: Use `load_skill_content()` (SKILL.md with frontmatter)
52+
- **Copilot, Gemini, Codex**: Use `load_prompt()` (simple prompt files)
53+
54+
### Reference File Installation
55+
56+
- **Claude, OpenCode**: Install reference files in `references/` subdirectory
57+
- **Copilot, Gemini, Codex**: Self-contained, no reference files needed
58+
59+
## Usage Examples
60+
61+
```bash
62+
# Install for all platforms
63+
pb-spec init --ai all
64+
65+
# Install for specific platform
66+
pb-spec init --ai claude
67+
pb-spec init --ai copilot
68+
pb-spec init --ai opencode
69+
pb-spec init --ai gemini
70+
pb-spec init --ai codex
71+
72+
# Global installation
73+
pb-spec init --ai claude -g
74+
```
75+
76+
## Testing
77+
78+
All platform adapters are tested in `tests/test_platforms.py`:
79+
80+
- Path generation (local and global)
81+
- Content rendering
82+
- File installation
83+
- Idempotency (skip existing files without `--force`)
84+
85+
## Contributing
86+
87+
When adding new platform support:
88+
89+
1. Create a new file in `src/pb_spec/platforms/`
90+
2. Inherit from `Platform` base class
91+
3. Implement required abstract methods:
92+
- `name` property
93+
- `get_skill_path()` method
94+
- `render_skill()` method
95+
4. Add platform to `PLATFORMS` dict in `src/pb_spec/platforms/__init__.py`
96+
5. Add tests in `tests/test_platforms.py`
97+
6. Update this documentation

0 commit comments

Comments
 (0)