325 lines
6.8 KiB
Python
325 lines
6.8 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
CORE_QUESTIONS = [
|
|
"What problem are we solving?",
|
|
"Who is the user?",
|
|
"What does success look like?",
|
|
"What is the minimum useful version?",
|
|
"What data do we need?",
|
|
"What systems must it connect to?",
|
|
"What are the risks?",
|
|
"What must not happen?",
|
|
"How will we test it?",
|
|
"How will it be deployed?",
|
|
"Who owns and directs the project, and what are its organisational goals?",
|
|
"What is the technology stack, repository structure, and architecture approach?",
|
|
"Where is it hosted, which environments exist, and what are the security requirements?",
|
|
"What agent and developer workflow tools, constraints, and guidelines apply?",
|
|
]
|
|
|
|
CONTEXT_FILES: dict[str, str] = {
|
|
"context/discovery-log.md": """# Discovery Log
|
|
|
|
| ID | Question | Answer | Confidence | Follow-up needed | Linked decision | Linked task | Date |
|
|
|---|---|---|---|---|---|---|---|
|
|
""",
|
|
"context/product-brief.md": """# Product Brief
|
|
|
|
## Problem
|
|
|
|
TBD
|
|
|
|
## Users
|
|
|
|
TBD
|
|
|
|
## Success Criteria
|
|
|
|
TBD
|
|
|
|
## Minimum Useful Version
|
|
|
|
TBD
|
|
""",
|
|
"context/decisions.md": """# Decisions
|
|
|
|
| ID | Decision | Reason | Date |
|
|
|---|---|---|---|
|
|
""",
|
|
"context/risks.md": """# Risks
|
|
|
|
| ID | Risk | Impact | Mitigation | Status |
|
|
|---|---|---|---|---|
|
|
""",
|
|
"context/assumptions.md": """# Assumptions
|
|
|
|
| ID | Assumption | Confidence | Validation Needed |
|
|
|---|---|---|---|
|
|
""",
|
|
"context/repository-context.md": """# Repository Context
|
|
|
|
## Purpose
|
|
|
|
TBD
|
|
|
|
## Key Components
|
|
|
|
TBD
|
|
|
|
## Dependencies
|
|
|
|
TBD
|
|
|
|
## Contributing
|
|
|
|
TBD
|
|
""",
|
|
"PROJECT_STATE.md": """# Project State
|
|
|
|
Current Stage: DISCOVERY
|
|
Previous Stage: NONE
|
|
Next Stage: BOOTSTRAP_READY
|
|
|
|
Current Task: None
|
|
Active Branch: main
|
|
|
|
Last Updated: TBD
|
|
""",
|
|
"AGENT_HANDOFF.md": """# Agent Handoff
|
|
|
|
## Current Stage
|
|
|
|
DISCOVERY
|
|
|
|
## Instructions For Agent
|
|
|
|
- Complete one task only
|
|
- Make the smallest useful change
|
|
- Update documentation
|
|
- Run tests
|
|
- Commit changes
|
|
- Stop after task completion
|
|
""",
|
|
".rdb/project.json": """{
|
|
"name": "rdb-discovery",
|
|
"stage": "DISCOVERY",
|
|
"tasks": [],
|
|
"created": "TBD"
|
|
}
|
|
""",
|
|
"context/open-questions.md": """# Open Questions
|
|
|
|
| ID | Question | Reason | Owner | Status |
|
|
|---|---|---|---|---|
|
|
""",
|
|
"context/company-context.md": """# Company Context
|
|
|
|
## Mission
|
|
|
|
TBD — What is the organisation's core mission?
|
|
|
|
## Products & Services
|
|
|
|
TBD — List of products and services offered.
|
|
|
|
## Customers / Users
|
|
|
|
TBD — Who are the primary customers or users?
|
|
|
|
## Brand & Positioning
|
|
|
|
TBD — How does the company position itself in the market?
|
|
|
|
## Key Stakeholders
|
|
|
|
TBD — Names, roles, and contact information.
|
|
""",
|
|
"context/development-context.md": """# Development Context
|
|
|
|
## Tech Stack
|
|
|
|
TBD — Languages, frameworks, libraries, and tooling.
|
|
|
|
## Coding Standards
|
|
|
|
TBD — Style guide conventions, naming patterns, and linting rules.
|
|
|
|
## Repository Structure
|
|
|
|
TBD — Overview of directory layout and module organisation.
|
|
|
|
## Build & Test
|
|
|
|
TBD — How to build, test, and run the codebase locally.
|
|
|
|
## Dependencies
|
|
|
|
TBD — External services, databases, and third-party APIs required.
|
|
""",
|
|
"context/infrastructure-context.md": """# Infrastructure Context
|
|
|
|
## Hosting
|
|
|
|
TBD — Where is the application hosted (cloud provider, on-prem, etc.)?
|
|
|
|
## Environments
|
|
|
|
TBD — Development, staging, production environment details.
|
|
|
|
## CI / CD Pipeline
|
|
|
|
TBD — Build, test, and deployment pipeline configuration.
|
|
|
|
## Monitoring & Alerting
|
|
|
|
TBD — Tools used for monitoring, logging, and alerting.
|
|
|
|
## Security
|
|
|
|
TBD — Authentication, data protection, and access control measures.
|
|
""",
|
|
"context/agent-guidelines.md": """# Agent Guidelines
|
|
|
|
## Purpose
|
|
|
|
TBD — What should agents know about working with this project?
|
|
|
|
## Preferred Tools
|
|
|
|
TBD — Recommended editors, debuggers, testing frameworks, and CLI tools.
|
|
|
|
## Testing Preferences
|
|
|
|
TBD — How the team prefers tests to be written, run, and verified.
|
|
|
|
## Common Tasks
|
|
|
|
TBD — Typical workflows for developers and AI coding agents.
|
|
|
|
## Known Gotchas
|
|
|
|
TBD — Pitfalls, quirks, or important caveats to be aware of.
|
|
""",
|
|
"context/project-brief.md": """# Project Brief
|
|
|
|
## Problem Statement
|
|
|
|
TBD — What problem does this project solve?
|
|
|
|
## Target Audience
|
|
|
|
TBD — Who is the intended audience?
|
|
|
|
## Key Features (MVP)
|
|
|
|
TBD — Minimum set of features for the first release.
|
|
|
|
## Success Metrics
|
|
|
|
TBD — How will success be measured?
|
|
|
|
## Timeline & Milestones
|
|
|
|
TBD — Expected delivery dates and key milestones.
|
|
""",
|
|
"context/architecture.md": """# Architecture
|
|
|
|
## Overview
|
|
|
|
TBD — High-level system description and design principles.
|
|
|
|
## Core Components
|
|
|
|
TBD — Key modules, services, and their responsibilities.
|
|
|
|
## Data Flow
|
|
|
|
TBD — How data moves through the system (APIs, queues, databases).
|
|
|
|
## External Integrations
|
|
|
|
TBD — Third-party services, APIs, and dependencies.
|
|
|
|
## Deployment Architecture
|
|
|
|
TBD — Infrastructure layout, scaling strategy, and deployment process.
|
|
""",
|
|
"TASKS.md": """# TASKS.md
|
|
|
|
## TASK-001 - Create Python CLI project skeleton
|
|
Status: Done
|
|
|
|
Goal: Create the initial package structure, CLI entry point, and markdown-first bootstrap.
|
|
|
|
Acceptance Criteria:
|
|
- `rdb --help` runs
|
|
- `rdb init` creates project files
|
|
- README exists
|
|
|
|
## TASK-002 - Run initial project discovery
|
|
Status: Todo
|
|
|
|
Goal: Run `rdb discover` and capture the core project answers.
|
|
|
|
Acceptance Criteria:
|
|
- all 10 core questions are answered
|
|
- discovery-log.md contains ledger entries
|
|
- low-confidence answers are marked for follow-up
|
|
|
|
## TASK-003 - Review generated context files
|
|
Status: Todo
|
|
|
|
Goal: Review the generated markdown files and fill in obvious gaps.
|
|
|
|
Acceptance Criteria:
|
|
- product-brief.md reviewed
|
|
- architecture.md reviewed
|
|
- open-questions.md updated
|
|
|
|
## TASK-004 - Implement ask-more command
|
|
Status: Todo
|
|
|
|
Goal: Add a command that finds weak answers and asks deeper follow-up questions.
|
|
|
|
Acceptance Criteria:
|
|
- command reads discovery-log.md
|
|
- low-confidence answers are detected
|
|
- follow-up answers are appended to discovery-log.md
|
|
""",
|
|
"TEST_PLAN.md": """# TEST_PLAN.md
|
|
|
|
## Manual Tests
|
|
|
|
| ID | Test | Expected Result | Status |
|
|
|---|---|---|---|
|
|
| TEST-001 | Run `rdb --help` | CLI help is displayed | Not run |
|
|
| TEST-002 | Run `rdb init` | Markdown files are created | Not run |
|
|
| TEST-003 | Run `rdb status` | Project status is displayed | Not run |
|
|
| TEST-004 | Run `rdb next` | Next Todo task is shown | Not run |
|
|
|
|
## Automated Tests
|
|
|
|
Run:
|
|
|
|
```bash
|
|
pytest
|
|
```
|
|
""",
|
|
"RUN_LOG.md": """# RUN_LOG.md
|
|
|
|
| Date | Event | Task | Notes |
|
|
|---|---|---|---|
|
|
""",
|
|
}
|
|
|
|
|
|
def write_file_if_missing(root: Path, relative_path: str, content: str) -> bool:
|
|
target = root / relative_path
|
|
if target.exists():
|
|
return False
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
target.write_text(content, encoding="utf-8")
|
|
return True
|