Implement Phase 3 & 4: Generation Pipeline and Polish

Phase 3 - Generation Pipeline:
- SpecificationGenerator: generates features, data models, interfaces
- PRDGenerator: generates PROMPT.md, prd.json, GUIDE.md, CLAUDE.md
- ScaffoldGenerator: creates complete project structure with git init
- Interactive prompts with Inquirer.js for user confirmation
- Full pipeline integration in new command

Phase 4 - Polish:
- Validate command for PROMPT.md files
- Standalone research command using Perplexity
- Dry-run mode with --dry-run flag
- Comprehensive README.md documentation
- Examples directory with sample outputs
- npm packaging verified (npm pack, npm publish --dry-run)

Bug fixes:
- Fix EXDEV error in atomic file writes (use same-dir temp files)
- Update Claude model to claude-sonnet-4-5-20250929

All 110 tests passing, all completion criteria met.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-01-11 01:20:13 +00:00
parent ae0165a802
commit 0352e56a20
22 changed files with 3113 additions and 69 deletions

41
examples/README.md Normal file
View File

@@ -0,0 +1,41 @@
# Examples
This directory contains sample files demonstrating ralph-vibe output.
## Files
### `test-idea.txt`
A sample idea file that can be used with the `--idea-file` flag:
```bash
ralph-vibe new md2pdf --idea-file examples/test-idea.txt
```
### `sample-PROMPT.md`
An example of a generated PROMPT.md file for a markdown-to-PDF converter CLI tool. Shows:
- Project structure
- User flow diagram
- Feature specifications with acceptance criteria
- Phase-based implementation plan
- Completion criteria with verification commands
- Promise tags for Ralph loop integration
### `sample-prd.json`
An example prd.json file showing the feature tracking structure.
## Usage
To test validation on the sample file:
```bash
ralph-vibe validate examples/sample-PROMPT.md
```
To generate a new project using the test idea:
```bash
ralph-vibe new test-project --idea-file examples/test-idea.txt --skip-confirm
```

187
examples/sample-PROMPT.md Normal file
View File

@@ -0,0 +1,187 @@
# Project: md2pdf
## Objective
CLI tool that converts markdown files to beautifully styled PDF documents with syntax highlighting for code blocks, multiple theme support, and optional table of contents.
---
## Application Type
CLI tool
## Architecture
- Interface types: CLI arguments
- Persistence: None (stateless transformation)
- Deployment: Package registry (npm) + standalone binary
## Tech Stack
- Language: TypeScript
- Runtime: Node.js 20+
- CLI: Commander.js
- PDF Generation: puppeteer + marked
- Syntax Highlighting: shiki
- Testing: Vitest
- Build: tsup
---
## User Flow
```
┌─────────────────────────────────────────────────────────────────────┐
│ USER JOURNEY │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ 1. BASIC USAGE │
│ $ md2pdf input.md │
│ → Converts input.md to input.pdf │
│ │
│ 2. WITH OPTIONS │
│ $ md2pdf input.md -o output.pdf --theme dark --toc │
│ → Converts with dark theme and table of contents │
│ │
│ 3. MULTIPLE FILES │
│ $ md2pdf *.md -o combined.pdf │
│ → Combines all markdown files into one PDF │
│ │
│ 4. STDIN │
│ $ cat README.md | md2pdf -o readme.pdf │
│ → Reads from stdin │
│ │
└─────────────────────────────────────────────────────────────────────┘
```
---
## Commands
### `md2pdf <input> [options]`
Convert markdown to PDF.
```
Options:
-o, --output <path> Output PDF path (default: input with .pdf extension)
-t, --theme <name> Theme: light, dark, custom (default: light)
--toc Include table of contents
--no-highlight Disable syntax highlighting
--page-size <size> Page size: A4, Letter, Legal (default: A4)
--margin <size> Page margins in mm (default: 20)
```
---
## Core Features
### Feature 1: Basic Conversion
**Description**: Convert a single markdown file to PDF.
**Acceptance Criteria**:
- `md2pdf input.md` creates `input.pdf`
- Output is valid PDF that opens in all readers
- Markdown headings render as styled headings
- Links are clickable in PDF
- Images are embedded
### Feature 2: Syntax Highlighting
**Description**: Code blocks render with syntax highlighting.
**Acceptance Criteria**:
- Code blocks with language tags are highlighted
- Supports at least: js, ts, python, rust, go, bash
- Colors appropriate to selected theme
- Monospace font for code
- Line numbers optional
### Feature 3: Theme Support
**Description**: Multiple visual themes for output.
**Acceptance Criteria**:
- `--theme light` uses light background with dark text
- `--theme dark` uses dark background with light text
- Custom CSS can be loaded via `--theme path/to/custom.css`
- Theme affects both prose and code blocks
### Feature 4: Table of Contents
**Description**: Generate TOC from headings.
**Acceptance Criteria**:
- `--toc` flag adds TOC at beginning
- TOC entries are clickable links
- Supports heading levels 1-3
- Page numbers shown
### Feature 5: GitHub Flavored Markdown
**Description**: Support GFM extensions.
**Acceptance Criteria**:
- Tables render correctly
- Task lists render with checkboxes
- Strikethrough text renders
- Autolinks work
---
## Completion Criteria
1. `npm run build` exits 0
2. `npm run test` exits 0 with >80% coverage
3. `npm run lint` exits 0
4. `md2pdf --help` shows all options
5. `md2pdf README.md` produces valid PDF
6. `md2pdf test.md --theme dark` uses dark theme
7. Code blocks show syntax highlighting
8. `md2pdf test.md --toc` includes table of contents
9. GFM tables render correctly
Output `<promise>PROJECT_COMPLETE</promise>` when all criteria met.
---
## Phase 1: Foundation
- [ ] Project setup with TypeScript, tsup, vitest
- [ ] CLI framework with Commander.js
- [ ] Basic markdown parsing with marked
- [ ] PDF generation with puppeteer
**Acceptance**: `md2pdf input.md` produces basic PDF
## Phase 2: Styling
- [ ] Light theme CSS
- [ ] Dark theme CSS
- [ ] Custom theme loading
- [ ] Syntax highlighting with shiki
**Acceptance**: `md2pdf test.md --theme dark` works with highlighting
## Phase 3: Features
- [ ] Table of contents generation
- [ ] GFM support (tables, task lists)
- [ ] Multiple file handling
- [ ] Stdin support
**Acceptance**: All features work, tests pass
## Phase 4: Polish
- [ ] Error handling and messages
- [ ] Documentation
- [ ] npm packaging
**Acceptance**: All completion criteria met
---
*PRD Version: 1.0*
*Target: Claude Code + Ralph Method*

51
examples/sample-prd.json Normal file
View File

@@ -0,0 +1,51 @@
{
"project": "md2pdf",
"version": "1.0.0",
"features": [
{
"id": "basic-conversion",
"phase": 1,
"name": "Basic Conversion",
"description": "Convert a single markdown file to PDF",
"priority": 1,
"passes": false,
"acceptance": "md2pdf input.md creates input.pdf as valid PDF"
},
{
"id": "syntax-highlighting",
"phase": 2,
"name": "Syntax Highlighting",
"description": "Code blocks render with syntax highlighting",
"priority": 2,
"passes": false,
"acceptance": "Code blocks with language tags are highlighted correctly"
},
{
"id": "theme-support",
"phase": 2,
"name": "Theme Support",
"description": "Multiple visual themes for output",
"priority": 3,
"passes": false,
"acceptance": "--theme light/dark/custom works correctly"
},
{
"id": "table-of-contents",
"phase": 3,
"name": "Table of Contents",
"description": "Generate TOC from headings",
"priority": 4,
"passes": false,
"acceptance": "--toc flag adds clickable table of contents"
},
{
"id": "gfm-support",
"phase": 3,
"name": "GitHub Flavored Markdown",
"description": "Support GFM extensions",
"priority": 5,
"passes": false,
"acceptance": "Tables, task lists, and strikethrough render correctly"
}
]
}

1
examples/test-idea.txt Normal file
View File

@@ -0,0 +1 @@
A CLI tool that converts markdown files to beautifully styled PDF documents with syntax highlighting for code blocks. It should support multiple themes (dark, light, custom), handle GitHub Flavored Markdown, and optionally include a table of contents. The tool should be fast and work offline.