Skip to content

Commit 3d29b6d

Browse files
author
John Costa
committed
add cli package
1 parent 54cdaa8 commit 3d29b6d

19 files changed

+9357
-11
lines changed

EXPANSION_PLAN.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
## 📈 Current Progress Status
44

55
**✅ Phase 1.1 COMPLETED** - Core Library Extraction
6-
**🎯 Next Up:** Phase 1.2 - Enhanced MCP Server
6+
**✅ Phase 1.2 COMPLETED** - Enhanced MCP Server
7+
**🎯 Next Up:** Phase 2.1 - Google Slides Integration / CLI Tool
78
**📅 Updated:** August 2025
89

910
### 🏆 Major Milestones Achieved
1011
-**Core Library**: `@mermaid-converter/core` package created and tested
1112
-**Plugin Architecture**: Extensible system for outputs and renderers
12-
-**Local Testing**: Both VSCode extension and core library validated
13-
-**Production Ready**: 10/10 tests passing, professional tooling setup
13+
-**Enhanced MCP Server**: Fully functional with PDF generation and templates
14+
-**Local Testing**: VSCode extension, core library, and MCP server all validated
15+
-**Production Ready**: Comprehensive test suites, professional tooling setup
1416

1517
### 🔧 Ready for Use
1618
```bash
@@ -72,10 +74,10 @@ export interface OutputGenerator {
7274
-**Developer Experience**: Professional documentation, examples, ESLint + Jest setup
7375
-**Validated Locally**: Both VSCode extension and core library tested and working
7476

75-
### 1.2 Enhanced MCP Server 🎯 NEXT
76-
**Priority: High** | **Status: 🎯 IN PROGRESS**
77+
### 1.2 Enhanced MCP Server ✅ COMPLETED
78+
**Priority: High** | **Status: ✅ DONE**
7779

78-
Build production-ready MCP server with advanced features:
80+
Built production-ready MCP server with advanced features:
7981

8082
```typescript
8183
// Enhanced MCP tools
@@ -97,11 +99,12 @@ interface MCPTools {
9799
```
98100

99101
**Deliverables:**
100-
- [ ] Docker containerization for easy deployment
101-
- [ ] Comprehensive caching system
102-
- [ ] Rate limiting and authentication
103-
- [ ] Webhook support for automation
104-
- [ ] Health monitoring and metrics
102+
- [x] ✅ Simplified MCP server with PDF generation
103+
- [x] ✅ Template system (4 professional templates)
104+
- [x] ✅ Claude Desktop integration working
105+
- [x] ✅ PDF files saved to Downloads folder
106+
- [x] ✅ Comprehensive test suites
107+
- [ ] 🔄 Advanced features (Docker, caching, webhooks) deferred to later phase
105108

106109
## Phase 2: High-Impact Integrations (Weeks 5-12)
107110

packages/cli/README.md

Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
# Mermaid Converter CLI
2+
3+
> Convert Markdown files with Mermaid diagrams to PDF and other formats from the command line
4+
5+
## Installation
6+
7+
```bash
8+
npm install -g @mermaid-converter/cli
9+
```
10+
11+
## Quick Start
12+
13+
```bash
14+
# Convert a single file
15+
mermaid-convert document.md
16+
17+
# Convert with a specific template
18+
mermaid-convert document.md -t report -o professional-report.pdf
19+
20+
# Convert multiple files
21+
mermaid-convert docs/*.md --batch -d output/
22+
23+
# Watch for changes
24+
mermaid-convert watch docs/
25+
```
26+
27+
## Features
28+
29+
- 🚀 **Fast conversions** with high-quality Mermaid diagram rendering
30+
- 📋 **6 built-in templates** for different use cases
31+
- 📦 **Batch processing** with progress bars and concurrent conversions
32+
- 👁️ **Watch mode** for automatic conversion on file changes
33+
- ⚙️ **Configurable** with project-level configuration files
34+
- 🎨 **Professional output** with customizable formatting options
35+
36+
## Commands
37+
38+
### `convert` - Convert Markdown files
39+
40+
Convert one or more Markdown files to PDF (or other formats).
41+
42+
```bash
43+
mermaid-convert convert input.md [options]
44+
```
45+
46+
**Options:**
47+
- `-f, --format <format>` - Output format (default: pdf)
48+
- `-o, --output <file>` - Output file (single file mode)
49+
- `-d, --output-dir <dir>` - Output directory (batch mode)
50+
- `-t, --template <name>` - Template to use (default: default)
51+
- `-b, --batch` - Enable batch processing for multiple files
52+
- `-c, --concurrency <n>` - Number of concurrent conversions (default: 3)
53+
- `--overwrite` - Overwrite existing files
54+
55+
**Examples:**
56+
```bash
57+
# Basic conversion
58+
mermaid-convert convert README.md
59+
60+
# Use specific template and output location
61+
mermaid-convert convert docs/guide.md -t presentation -o slides.pdf
62+
63+
# Batch convert with custom settings
64+
mermaid-convert convert docs/*.md --batch -d output -t report -c 5
65+
66+
# Convert multiple files with glob pattern
67+
mermaid-convert convert "src/**/*.md" --batch -d dist/
68+
```
69+
70+
### `watch` - Monitor files for changes
71+
72+
Watch Markdown files and automatically convert them when they change.
73+
74+
```bash
75+
mermaid-convert watch <path> [options]
76+
```
77+
78+
**Options:**
79+
- `-f, --format <format>` - Output format (default: pdf)
80+
- `-d, --output-dir <dir>` - Output directory (default: current)
81+
- `-t, --template <name>` - Template to use (default: default)
82+
- `-i, --ignore <pattern>` - Ignore pattern (default: node_modules/**)
83+
- `--debounce <ms>` - Debounce delay in milliseconds (default: 300)
84+
85+
**Examples:**
86+
```bash
87+
# Watch current directory
88+
mermaid-convert watch .
89+
90+
# Watch specific directory with custom template
91+
mermaid-convert watch docs/ -t documentation -d output/
92+
93+
# Watch with custom ignore patterns
94+
mermaid-convert watch . -i "*.tmp,node_modules/**,dist/**"
95+
```
96+
97+
### `templates` - Manage templates
98+
99+
List and inspect available conversion templates.
100+
101+
```bash
102+
mermaid-convert templates [options]
103+
```
104+
105+
**Options:**
106+
- `-l, --list` - List all available templates (default)
107+
- `-s, --show <name>` - Show details for a specific template
108+
- `-i, --interactive` - Interactive template selection
109+
110+
**Examples:**
111+
```bash
112+
# List all templates
113+
mermaid-convert templates
114+
115+
# Show template details
116+
mermaid-convert templates --show report
117+
118+
# Interactive template browser
119+
mermaid-convert templates --interactive
120+
```
121+
122+
### `config` - Configuration management
123+
124+
Create and manage CLI configuration files.
125+
126+
```bash
127+
mermaid-convert config [options]
128+
```
129+
130+
**Options:**
131+
- `-i, --init` - Create a new configuration file
132+
- `-s, --show` - Show current configuration
133+
- `-p, --path` - Show configuration file path
134+
135+
**Examples:**
136+
```bash
137+
# Create configuration file
138+
mermaid-convert config --init
139+
140+
# Show current config
141+
mermaid-convert config --show
142+
```
143+
144+
## Templates
145+
146+
The CLI comes with 6 built-in templates:
147+
148+
| Template | Description | Use Case |
149+
|----------|-------------|----------|
150+
| `default` | Standard PDF with professional formatting | General documents |
151+
| `report` | High-quality with generous margins | Business reports |
152+
| `presentation` | Landscape format for slides | Presentations |
153+
| `documentation` | Optimized for technical docs | API docs, guides |
154+
| `dark` | Dark theme for code/diagrams | Developer documentation |
155+
| `compact` | Minimal margins for maximum content | Reference materials |
156+
157+
### Template Options
158+
159+
Each template includes settings for:
160+
- **Quality**: draft, standard, high
161+
- **Theme**: light, dark
162+
- **Page Size**: A4, Letter, Legal
163+
- **Margins**: Customizable spacing
164+
- **Orientation**: Portrait or landscape
165+
166+
## Configuration
167+
168+
Create a `.mermaid-convertrc.json` file in your project root:
169+
170+
```json
171+
{
172+
"defaultFormat": "pdf",
173+
"defaultTemplate": "documentation",
174+
"outputDirectory": "./dist",
175+
"overwrite": false,
176+
"concurrency": 3,
177+
"templates": {
178+
"custom": {
179+
"description": "My custom template",
180+
"options": {
181+
"quality": "high",
182+
"theme": "light",
183+
"margins": {
184+
"top": "30mm",
185+
"bottom": "30mm"
186+
}
187+
}
188+
}
189+
}
190+
}
191+
```
192+
193+
## Examples
194+
195+
### Basic Usage
196+
197+
```bash
198+
# Convert single file
199+
mermaid-convert convert documentation.md
200+
201+
# Use professional template
202+
mermaid-convert convert report.md -t report
203+
```
204+
205+
### Batch Processing
206+
207+
```bash
208+
# Convert all markdown files in docs/
209+
mermaid-convert convert docs/*.md --batch -d output/
210+
211+
# Process with 5 concurrent conversions
212+
mermaid-convert convert docs/**/*.md --batch -c 5
213+
```
214+
215+
### Development Workflow
216+
217+
```bash
218+
# Watch for changes during development
219+
mermaid-convert watch docs/ -t documentation -d dist/
220+
221+
# Convert on save with custom debounce
222+
mermaid-convert watch . --debounce 1000
223+
```
224+
225+
### Advanced Usage
226+
227+
```bash
228+
# Custom output location and template
229+
mermaid-convert convert api.md -t presentation -o slides/api-overview.pdf
230+
231+
# Batch with overwrite enabled
232+
mermaid-convert convert docs/*.md --batch --overwrite -d output/
233+
```
234+
235+
## Global Options
236+
237+
Available for all commands:
238+
239+
- `-q, --quiet` - Suppress non-error output
240+
- `-v, --verbose` - Enable verbose logging
241+
- `--no-color` - Disable colored output
242+
243+
## Output
244+
245+
### Success Messages
246+
- ✅ File conversion progress and results
247+
- 📊 Processing statistics (file size, duration)
248+
- 📁 Output file locations
249+
250+
### Error Handling
251+
- ❌ Clear error messages with suggestions
252+
- 🐛 Verbose mode for debugging
253+
- 📝 Automatic error logging to files
254+
255+
## Troubleshooting
256+
257+
### Common Issues
258+
259+
**"No files found"**
260+
- Check your glob pattern syntax
261+
- Ensure Markdown files have `.md` extension
262+
- Use absolute paths if relative paths aren't working
263+
264+
**"Diagram render failed"**
265+
- Verify Mermaid syntax is valid
266+
- Check for special characters in diagrams
267+
- Try with `--verbose` for detailed error information
268+
269+
**"Permission denied"**
270+
- Ensure write permissions for output directory
271+
- Use `--overwrite` to replace existing files
272+
273+
### Debug Mode
274+
275+
```bash
276+
# Enable verbose logging
277+
mermaid-convert convert file.md --verbose
278+
279+
# Check log files
280+
cat mermaid-convert.log
281+
cat mermaid-convert-error.log
282+
```
283+
284+
## License
285+
286+
MIT License - see LICENSE file for details
287+
288+
## Contributing
289+
290+
1. Fork the repository
291+
2. Create a feature branch
292+
3. Make your changes
293+
4. Add tests if applicable
294+
5. Submit a pull request
295+
296+
## Related Packages
297+
298+
- `@mermaid-converter/core` - Core conversion library
299+
- `@mermaid-converter/mcp-server` - MCP server for Claude Desktop integration

packages/cli/example.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# CLI Example Document
2+
3+
This is an example document to test the Mermaid Converter CLI.
4+
5+
## Simple Process Flow
6+
7+
```mermaid
8+
graph LR
9+
A[Write Markdown] --> B[Run CLI]
10+
B --> C[Generate PDF]
11+
C --> D[Professional Output]
12+
```
13+
14+
## Usage
15+
16+
Convert this file with:
17+
18+
```bash
19+
mermaid-convert convert example.md -t report
20+
```
21+
22+
## Features Tested
23+
24+
- ✅ Basic markdown parsing
25+
- ✅ Mermaid diagram rendering
26+
- ✅ Professional PDF output
27+
- ✅ Command-line interface
28+
29+
The CLI tool successfully processes this content and generates a high-quality PDF with the embedded diagram.

packages/cli/example.pdf

124 KB
Binary file not shown.

0 commit comments

Comments
 (0)