@bytechain.cn/colamd-themes 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.claude/skills/colamd-themes-preview.skill.md +333 -0
  2. package/.claude/skills/colamd-themes.skill.md +10 -0
  3. package/.dsh/skills/colamd-themes/SKILL.md +14 -0
  4. package/.github/supported-topics.yml +17 -0
  5. package/.hermes/skills/tools/colamd-themes/SKILL.md +14 -0
  6. package/.openclaw/skills/colamd-themes/SKILL.md +1 -146
  7. package/.opencode/skills/colamd-themes/SKILL.md +17 -0
  8. package/.trae/rules/colamd-themes.md +0 -145
  9. package/CHANGELOG.md +318 -240
  10. package/DSH_SUPPORT_SUMMARY.md +87 -0
  11. package/README.md +414 -384
  12. package/README_CN.md +412 -384
  13. package/RELEASENOTE.md +541 -365
  14. package/bytechain.cn-colamd-themes-0.5.0.tgz +0 -0
  15. package/dist/cli.js +272 -32
  16. package/dist/cli.js.map +1 -1
  17. package/dist/color-utils.d.ts +1 -0
  18. package/dist/color-utils.js +25 -6
  19. package/dist/color-utils.js.map +1 -1
  20. package/dist/extractors/pdf-extractor.js +6 -1
  21. package/dist/extractors/pdf-extractor.js.map +1 -1
  22. package/dist/extractors/url-extractor.d.ts +0 -4
  23. package/dist/extractors/url-extractor.js +13 -126
  24. package/dist/extractors/url-extractor.js.map +1 -1
  25. package/dist/generator.d.ts +1 -1
  26. package/dist/generator.js +32 -11
  27. package/dist/generator.js.map +1 -1
  28. package/dist/models.d.ts +5 -4
  29. package/dist/models.js +2 -3
  30. package/dist/models.js.map +1 -1
  31. package/dist/renderer.d.ts +4 -2
  32. package/dist/renderer.js +68 -25
  33. package/dist/renderer.js.map +1 -1
  34. package/dist/templates/template.css +220 -498
  35. package/dist/templates/theme-paradigm.md +530 -658
  36. package/dist/templates/theme-template.hbs +256 -370
  37. package/dist/theme-store.js +19 -3
  38. package/dist/theme-store.js.map +1 -1
  39. package/dist/utils/document-paradigm.d.ts +12 -0
  40. package/dist/utils/document-paradigm.js +109 -0
  41. package/dist/utils/document-paradigm.js.map +1 -0
  42. package/dist/validators.d.ts +4 -1
  43. package/dist/validators.js +115 -1
  44. package/dist/validators.js.map +1 -1
  45. package/mcp-server/dist/index.d.ts +13 -0
  46. package/mcp-server/dist/index.d.ts.map +1 -0
  47. package/mcp-server/dist/index.js +0 -0
  48. package/mcp-server/dist/index.js.map +1 -0
  49. package/mcp-server/package-lock.json +1759 -0
  50. package/mcp-server/package.json +24 -0
  51. package/mcp-server/src/index.ts +0 -0
  52. package/mcp-server/tsconfig.json +19 -0
  53. package/package.json +54 -36
  54. package/skills/build-skills.sh +30 -5
  55. package/skills/colamd-themes/SKILL.md +180 -148
  56. package/src/cli.ts +474 -217
  57. package/src/color-systems.ts +289 -289
  58. package/src/color-utils.ts +137 -120
  59. package/src/contrast.ts +66 -66
  60. package/src/docx-style-paradigm.ts +811 -811
  61. package/src/export-cli.ts +356 -356
  62. package/src/extractors/base.ts +8 -8
  63. package/src/extractors/docx-extractor.ts +417 -417
  64. package/src/extractors/pdf-extractor.ts +533 -527
  65. package/src/extractors/url-extractor.ts +846 -981
  66. package/src/generator.ts +197 -169
  67. package/src/index.ts +29 -29
  68. package/src/models.ts +212 -212
  69. package/src/renderer.ts +332 -288
  70. package/src/templates/template.css +220 -498
  71. package/src/templates/theme-paradigm.md +530 -658
  72. package/src/templates/theme-template.hbs +256 -370
  73. package/src/theme-store.ts +185 -170
  74. package/src/types/pdf-parse.d.ts +12 -12
  75. package/src/utils/cli-utils.ts +84 -84
  76. package/src/utils/document-paradigm.ts +118 -0
  77. package/src/validators.ts +298 -176
  78. package/themes/academic-paper-pt.css +353 -1805
  79. package/themes/academic-paper.css +350 -1099
  80. package/themes/academic-style.css +342 -2430
  81. package/themes/colly.css +256 -370
  82. package/themes/elegant.css +288 -671
  83. package/themes/forest-ink.css +240 -664
  84. package/themes/guizang.css +250 -732
  85. package/themes/hermes-security.css +279 -0
  86. package/themes/meeting-minutes.css +256 -370
  87. package/themes/pixso-design.css +278 -1261
  88. package/themes/salvator-blog.css +256 -370
  89. package/themes/shimo-theme.css +256 -0
  90. package/themes/swiss-design.css +285 -746
  91. package/themes/template.css +220 -498
  92. package/themes/trae-blue.css +280 -737
  93. package/themes/word-contract.css +249 -0
  94. package/themes-preview/demo-content.md +187 -187
  95. package/tsconfig.json +18 -18
  96. package/src/mermaid-presets.ts +0 -142
  97. package/themes/swiss-design copy.css +0 -746
  98. package/themes-preview/colly-preview.html +0 -623
  99. package/themes-preview/meeting-minutes-preview.html +0 -625
  100. package/themes-preview/salvator-blog-preview.html +0 -623
package/RELEASENOTE.md CHANGED
@@ -1,365 +1,541 @@
1
- # Release Notes
2
-
3
- ## Version 0.3.1 (2026-06-01) — Security & Stability Patch 🔒
4
-
5
- > **Important**: This release contains critical security fixes and important stability improvements.
6
- > **All users are strongly recommended to upgrade.**
7
-
8
- ### 🚨 Critical Security Fixes
9
-
10
- **SSRF Vulnerability Patch (CVE-Level)**
11
- - **Issue**: URL extractor was vulnerable to Server-Side Request Forgery attacks
12
- - Attackers could force the server to access internal network resources
13
- - Could expose sensitive internal services or cause denial-of-service
14
- - **Fix**: Implemented comprehensive URL validation in [`url-extractor.ts`](src/extractors/url-extractor.ts):
15
- - ✅ Protocol whitelist: Only `http:` and `https:` allowed
16
- - ✅ Private network blocking: localhost, 10.x, 172.16-31.x, 192.168.x, 169.254.x
17
- - ✅ Clear error messages for blocked attempts
18
- - **Impact**: Prevents unauthorized internal network access; protects against SSRF attacks
19
-
20
- **Input Validation Hardening**
21
- - **Issue**: No validation on custom CSS theme files before processing
22
- - Large files could cause memory exhaustion (OOM)
23
- - Invalid file formats could crash the process
24
- - **Fix**: Added multi-layer validation in [`theme-store.ts`](src/theme-store.ts):
25
- - ✅ File extension check (must be `.css`)
26
- - ✅ Size limit enforcement (1MB maximum)
27
- - ✅ Content validity verification (minimum 10 characters)
28
- - ✅ Sanitized filename extraction (removes special chars, limits length)
29
- - **Impact**: Prevents OOM attacks; ensures graceful error handling
30
-
31
- ### 🐛 Major Bug Fixes
32
-
33
- **PDF Export Theme Not Applied**
34
- - **Symptom**: Custom themes were ignored when exporting to PDF; documents rendered with default styling only
35
- - **Root Cause**: Puppeteer's `emulateMediaType("screen")` forced browser into screen mode, causing CSS `@media print { ... }` rules to be completely ignored
36
- - **Fix**: Removed screen media type emulation in [`renderer.ts`](src/renderer.ts); allows default print mode where all `@media print` styles apply correctly
37
- - **Result**: PDF exports now render with full theme fidelity — colors, fonts, backgrounds, spacing, and all visual styling correctly applied
38
-
39
- **Puppeteer Resource Leak**
40
- - **Symptom**: Zombie Chromium processes left running after export operations completed
41
- - **Cause**: Page objects not explicitly closed before browser termination
42
- - **Fix**: Explicit page cleanup in [`renderer.ts`](src/renderer.ts#L150-L155) close() method
43
- - **Result**: Clean process shutdown; no resource leaks
44
-
45
- **CLI Version Display Incorrect**
46
- - **Symptom**: `colamd-themes --version` always showed "0.2.0" regardless of actual version
47
- - **Cause**: Hardcoded version string in CLI initialization
48
- - **Fix**: Dynamic version reading from [`package.json`](package.json) via [`getPackageVersion()`](src/cli.ts)
49
- - **Result**: Accurate version display matching published package version
50
-
51
- ### ⚡ Performance Improvements
52
-
53
- **Async I/O Migration**
54
- - **Before**: Synchronous file operations (`readFileSync`, `writeFileSync`) blocked event loop during theme configuration
55
- - **After**: All theme store operations now use async API (`fs/promises`)
56
- - **Benefit**:
57
- - Non-blocking configuration reads/writes
58
- - Improved responsiveness during batch exports
59
- - Better scalability for concurrent operations
60
- - **Files Updated**: [`theme-store.ts`](src/theme-store.ts)
61
-
62
- **Template Cache Management**
63
- - **Before**: Single global template variable; recompiled on every call after first use; no size limits
64
- - **After**: Sophisticated cache system with three-layer invalidation:
65
- 1. **LRU Eviction**: Maximum 10 cached templates (evicts oldest when full)
66
- 2. **TTL Expiration**: Automatic expiry after 30 minutes of inactivity
67
- 3. **mtime Detection**: Auto-invalidates when source template file is modified on disk
68
- - **Benefit**:
69
- - ~90% reduction in template compilations for repeated operations
70
- - Stable memory usage in long-running processes
71
- - Fresh templates automatically loaded after updates
72
- - **Files Updated**: [`generator.ts`](src/generator.ts)
73
-
74
- ### 🛠️ Code Quality Enhancements
75
-
76
- **Unified Error Handling System**
77
- - **New Module**: [`cli-utils.ts`](src/utils/cli-utils.ts)
78
- - **Features**:
79
- - `CLIError` class: Structured errors with code, message, and cause chain
80
- - `ErrorCode` enum: Standardized categories (FILE_NOT_FOUND, THEME_ERROR, RENDER_ERROR, INVALID_INPUT, UNKNOWN)
81
- - Consistent error propagation across all commands
82
- - **Impact**:
83
- - Better debugging experience with detailed error context
84
- - Consistent user-facing error messages
85
- - Easier error tracking and logging
86
- - Process exits with meaningful exit codes
87
-
88
- **Code Deduplication**
89
- - **Extracted Utilities**:
90
- - `resolveInputPath(input)`: Validates existence, converts relative→absolute paths
91
- - `resolveOutputPath(input, output?, ext?)`: Smart output path derivation
92
- - `getDocumentTitle(filePath)`: Extracts clean document title from path
93
- - **Impact**:
94
- - Eliminated duplicate path resolution logic across 4+ command handlers
95
- - Single source of truth reduces maintenance burden
96
- - Consistent behavior across all export commands
97
-
98
- ### 📊 Metrics & Benchmarks
99
-
100
- | Metric | v0.3.0 | v0.3.1 | Improvement |
101
- |--------|--------|--------|-------------|
102
- | **Security Vulnerabilities** | 2 Critical | 0 Known | ✅ Resolved |
103
- | **Memory Usage (100 files)** | Unbounded | Stable | ✅ Predictable |
104
- | **Template Compilations** | ~100 per batch | ~10 max | ⚡ 90% fewer |
105
- | **Event Loop Blocking** | Frequent sync I/O | Minimal async ops | ⚡ Responsive |
106
- | **Error Consistency** | Mixed patterns | Unified codes | ✅ Maintainable |
107
- | **Zombie Processes** | Possible leak | Clean shutdown | ✅ Reliable |
108
-
109
- ### 🔧 Migration Guide
110
-
111
- **For Most Users**: No action required! This is a drop-in replacement.
112
-
113
- **Breaking Changes**: None — fully backward compatible.
114
-
115
- **API Changes** (for programmatic usage):
116
- ```typescript
117
- // Before (v0.3.0): Sync API
118
- import { resolveTheme } from '@bytechain.cn/colamd-themes';
119
- const theme = resolveTheme('elegant'); // Sync
120
-
121
- // After (v0.3.1): Async API
122
- import { resolveTheme } from '@bytechain.cn/colamd-themes';
123
- const theme = await resolveTheme('elegant'); // Async
124
- ```
125
-
126
- **New Error Handling** (recommended):
127
- ```typescript
128
- import { CLIError, ErrorCode } from '@bytechain.cn/colamd-themes';
129
-
130
- try {
131
- await exportHTML(document, { theme: 'custom' });
132
- } catch (error) {
133
- if (error instanceof CLIError) {
134
- console.error(`Error ${error.code}: ${error.message}`);
135
- // Handle specific error types
136
- switch (error.code) {
137
- case ErrorCode.FILE_NOT_FOUND: /* ... */ break;
138
- case ErrorCode.THEME_ERROR: /* ... */ break;
139
- case ErrorCode.RENDER_ERROR: /* ... */ break;
140
- default: /* ... */ break;
141
- }
142
- }
143
- }
144
- ```
145
-
146
- ### ✅ Testing Recommendations
147
-
148
- After upgrading, verify these critical scenarios:
149
-
150
- 1. **Security Test**:
151
- ```bash
152
- # Should be blocked (private network)
153
- cthemes from-url "http://localhost:3000" --name test
154
-
155
- # Should be blocked (invalid protocol)
156
- cthemes from-url "ftp://example.com/file.css" --name test
157
-
158
- # Should work (public HTTPS)
159
- cthemes from-url "https://example.com" --name my-theme
160
- ```
161
-
162
- 2. **PDF Export Test**:
163
- ```bash
164
- # Verify themes now apply correctly
165
- cthemes export-pdf doc.md -t elegant -o test.pdf
166
- open test.pdf # Check styling is applied
167
- ```
168
-
169
- 3. **Version Display Test**:
170
- ```bash
171
- # Should show 0.3.1
172
- cthemes --version
173
- ```
174
-
175
- 4. **Large File Protection Test**:
176
- ```bash
177
- # Create a large CSS file (>1MB)
178
- dd if=/dev/urandom of=large-theme.css bs=1024 count=1100
179
-
180
- # Should fail gracefully
181
- cthemes set-theme big --css large-theme.css
182
- ```
183
-
184
- ### 📝 Full Changelog
185
-
186
- For complete details on all changes, see [CHANGELOG.md](./CHANGELOG.md).
187
-
188
- ---
189
-
190
- ## Version 0.3.0 (2026-06-01)
191
-
192
- ### 📦 Package Name Change
193
-
194
- **Migrated to Scoped Package**
195
- - Package name changed from `colamd-themes` to **`@bytechain.cn/colamd-themes`**
196
- - Belongs to the `@bytechain.cn` organization ecosystem
197
- - Consistent with dependency `@bytechain.cn/colamd`
198
-
199
- **New Short CLI Command**
200
- - Added `cthemes` as a short alias for `colamd-themes`
201
- - Both commands are fully equivalent and interchangeable
202
- - Recommended for frequent use: shorter to type, same functionality
203
-
204
- ### 🎨 New Themes
205
-
206
- **Trae Blue Theme**
207
- - Modern blue color scheme optimized for technical documentation
208
- - Enhanced readability with carefully tuned contrast ratios
209
- - Perfect for developer guides, API documentation, and code-heavy content
210
-
211
- **Forest Ink Theme**
212
- - Nature-inspired dark green palette with elegant ink aesthetics
213
- - Sophisticated design suitable for long-form reading and literary content
214
- - Unique visual identity that stands out from traditional themes
215
-
216
- ### ✨ Improvements
217
-
218
- **Enhanced Swiss Design Theme**
219
- - Refined typography with improved spacing and line heights
220
- - Better color contrast for enhanced accessibility
221
- - Polished overall visual appearance
222
-
223
- **Better Developer Experience**
224
- - **Absolute Path Support**: Use full file paths in all CLI commands — no more relative path confusion
225
- ```bash
226
- cthemes export-html /full/path/to/document.md -t elegant -o output.html
227
- ```
228
- - **Interactive Previews**: New HTML preview files for colly and salvator-blog themes
229
- - **Build Process**: Fixed template file copying to ensure reliable distributions
230
-
231
- ### 🧹 Housekeeping
232
-
233
- - Removed system files (`.DS_Store`) from repository
234
-
235
- ---
236
-
237
- ## Version 0.2.0 (2026-05-25)
238
-
239
- ### 🚀 Major Upgrade: v3.0 Design System
240
-
241
- **Complete Paradigm Overhaul**
242
- - Implemented ColaMD's new v3.0 seed palette architecture
243
- - **15 predefined palettes** across 5 color families:
244
- - Morandi (soft, muted tones)
245
- - Macaron (pastel, playful)
246
- - Nordic (cool, minimalist)
247
- - Vintage (warm, retro)
248
- - Mint (fresh, vibrant)
249
- - **Auto-derived semantic mapping**: Design tokens automatically generate consistent color relationships
250
- - **Mermaid Integration**: 3 diagram presets with 20 customizable variables
251
-
252
- ### 📚 Academic Focus
253
-
254
- **New Academic Style Theme**
255
- - Specialized formatting for research papers and scholarly documents
256
- - Optimized typography for citations, references, and structured content
257
- - Follows academic publishing conventions
258
-
259
- **Redesigned Academic Paper Theme**
260
- - Restructured to comply with v3.0 paradigm specifications
261
- - Improved consistency with other themes in the ecosystem
262
-
263
- ### 🔧 Under the Hood
264
-
265
- **Refactored Extractors**
266
- - **URL Extractor**: Advanced CSS parsing with specificity-aware style resolution
267
- - **DOCX Extractor**: Enhanced Word document style mapping via mammoth
268
- - **PDF Extractor**: Multi-layer heuristic analysis for better metadata extraction
269
- - **Auto-Detection**: Smarter source type identification
270
-
271
- **Validation Engine**
272
- - WCAG 2.1 compliance checking built-in
273
- - 15+ design constraint rules with auto-fix suggestions
274
- - Contrast ratio and luminance calculations
275
-
276
- ---
277
-
278
- ## Version 0.1.0 (2026-05-22) — Initial Release 🎉
279
-
280
- ### Core Features
281
-
282
- **Theme Extraction from Any Source**
283
- - **Web Pages**: Fetch URLs and extract CSS styling automatically
284
- - **Word Documents**: Import `.docx` files and preserve document styles
285
- - **PDF Files**: Analyze PDF typography and generate matching themes
286
- - **Smart Detection**: Automatically identifies source type
287
-
288
- **Professional Export Capabilities**
289
- - **HTML Export**: Standalone documents with embedded themes
290
- - Full Mermaid diagram rendering
291
- - KaTeX math formula support
292
- - Responsive layout with print optimization
293
- - **PDF Export**: High-quality PDF generation via Chromium
294
- - Pixel-perfect theme reproduction
295
- - Custom page formats (A4, Letter, etc.)
296
- - Batch processing for multiple files
297
-
298
- **Complete Theme Management**
299
- - Built-in theme library (light, dark, elegant, newsprint)
300
- - Custom theme registration from CSS files
301
- - Default theme configuration
302
- - Easy switching between themes
303
-
304
- **Developer-Friendly CLI**
305
-
306
- ```bash
307
- # Extract theme from any source (use `colamd-themes` or short alias `cthemes`)
308
- cthemes extract source.docx --name my-theme
309
-
310
- # Export with beautiful styling
311
- cthemes export-html doc.md -t elegant -o output.html
312
- cthemes export-pdf doc.md -t dark --format A4 -o output.pdf
313
-
314
- # Batch process entire directories
315
- cthemes export docs/ --format pdf -t elegant -d output/
316
-
317
- # Manage your themes
318
- cthemes list
319
- cthemes validate themes/my-theme.css
320
- cthemes set-theme my-brand --css custom.css --default
321
- ```
322
-
323
- ### Technology Stack
324
-
325
- - **TypeScript**: Type-safe implementation with full IDE support
326
- - **css-tree**: Robust CSS parsing and analysis
327
- - **mammoth**: Reliable DOCX processing
328
- - **puppeteer**: Accurate PDF rendering
329
- - **handlebars**: Flexible template engine
330
- - **commander**: Intuitive CLI framework
331
-
332
- ### Perfect For
333
-
334
- ✅ Technical documentation teams needing consistent branding
335
- ✅ Content creators exporting Markdown to professional formats
336
- ✅ Developers building documentation pipelines
337
- ✅ Anyone wanting beautiful, themed Markdown output
338
-
339
- ---
340
-
341
- ## Quick Start
342
-
343
- ```bash
344
- # Install
345
- git clone https://github.com/byteuser1977/ColaMD-themes.git
346
- cd ColaMD-themes
347
- npm install
348
- npm run build
349
-
350
- # Try it out (use either command)
351
- cthemes export-html README.md -t trae-blue -o preview.html
352
- open preview.html
353
- ```
354
-
355
- ## Links
356
-
357
- - **Documentation**: [README.md](./README.md)
358
- - **Chinese Documentation**: [README_CN.md](./README_CN.md)
359
- - **Changelog**: [CHANGELOG.md](./CHANGELOG.md)
360
- - **Issues**: [GitHub Issues](https://github.com/byteuser1977/ColaMD-themes/issues)
361
- - **Contributing**: Pull requests welcome!
362
-
363
- ---
364
-
365
- *Last updated: 2026-06-01*
1
+ # Release Notes
2
+ ## Version 0.5.0 (2026-10-25) — ColaMD 2.7.7 Support 🎨
3
+
4
+ > **Verified against the published `@bytechain.cn/colamd@2.7.7` npm package**: all 16 themes are fully contract-compatible, and the design quality of 10 themes has been brought to zero paradigm errors.
5
+
6
+ ### 🎨 Theme Quality Overhaul
7
+
8
+ **10 themes optimized to pass every paradigm rule (0 errors):**
9
+
10
+ | Theme | Fix |
11
+ |-------|-----|
12
+ | `colly` / `salvator-blog` / `meeting-minutes` | Panel hierarchy inverted → `--seed-panel-alt` deepened for a proper 2-step contrast |
13
+ | `swiss-design` | Border vs panel-alt lightness gap widened to 3 steps |
14
+ | `shimo-theme` | Panels now neutral grey; accent saturation raised to 83% (`#2a6bf2`) |
15
+ | `elegant` | Brick accent saturation 55% → 70% (`#b0401f`); hardcoded rgba values synced |
16
+ | `guizang` | Beige panels moved to neutral warm grey (fixes NT-02 hue drift) |
17
+ | `pixso-design` | Accent saturation 56% → 76% (`#4f46e5`); 6 gradients/borders migrated from `#6366f1` |
18
+ | `trae-blue` | Accent saturation 70% → 85% (`#2563eb`); panels neutralized |
19
+ | `forest-ink` | Accent saturation raised (`#356b44`); text greys re-tinted onto the ink-green hue axis |
20
+
21
+ Intentional warnings kept: the low-saturation scholarly accents of the academic trio, and meeting-minutes' pure-black accent (Swiss-minimal signature).
22
+
23
+ **Removed**: the legacy pre-2.7 theme (`body.theme-custom` root block, 58 dead variables, mojibake filename) — it had no effect under 2.7.7.
24
+
25
+ ### ✅ 2.7.7 Compatibility Audit
26
+
27
+ Audited against the actual published npm package (`@bytechain.cn/colamd@2.7.7`):
28
+
29
+ - **Class hooks**: zero drift — every `.cm-md-*` class used by our themes exists among the 49 hooks in the 2.7.7 renderer CSS
30
+ - **Live variables**: the 14 core + 4 typography variables and all 9 `--pele-*` overrides are consumed by 2.7.7
31
+ - **Injection**: the 2.7.7 app appends custom theme CSS to `document.head` (`applyTheme`), so `:root` declarations cascade correctly
32
+ - **Contract version references** across the CLI, validators, and generator unified to 2.7.7
33
+
34
+ ### 🛡️ Export Pipeline Guard
35
+
36
+ The npm `@bytechain.cn/colamd@2.7.7` package is the **Electron app distribution** — it no longer ships `dist/lib/colamd-renderer.js`, the library entry our HTML/PDF export pipeline needs. The CLI therefore keeps `@bytechain.cn/colamd@^1.5.2`, and `renderer.ts` now detects a 2.x install and fails with a clear downgrade instruction instead of a generic "Cannot find renderer" error.
37
+
38
+ Two related export fixes verified by smoke test:
39
+
40
+ - **Built-in theme resolution** — `-t elegant` previously let the 1.5.x renderer apply its own pre-2.7 built-in palette (`#c44b2b`); it now loads our `themes/elegant.css` (2.7.7 contract) first. Registered custom themes and direct `.css` paths were already correct.
41
+ - **Body-variable bridge** — the 1.5.x base CSS declares theme variables on `body`, overriding `:root` inheritance; the pipeline mirrors the theme's `:root` declarations onto `body` at injection time. Theme files themselves remain `:root`-only per the 2.7.7 contract.
42
+
43
+ > Theme files need no changes for the 2.7.7 app — import them via **Theme > Import Theme** or drop them into `~/.colamd/themes/`.
44
+ > Note: the app now ships its own built-in `elegant` theme; if you import our `elegant.css` into the app, consider renaming the file (e.g. `elegant-brick.css`) to avoid a name clash.
45
+
46
+ ### 🔧 Housekeeping
47
+
48
+ - Fixed `package-lock.json` root manifest drift (`^2.0.0` → `^1.5.2`, matching `package.json`)
49
+ - Version bumped to **0.5.0**
50
+
51
+ ### 📦 Upgrade
52
+
53
+ No breaking changes. Pull and rebuild:
54
+
55
+ ```bash
56
+ git pull
57
+ npm install
58
+ npm run build
59
+ ```
60
+
61
+ ---
62
+
63
+
64
+ ## Version 0.4.0 (2026-08-17) — DeepSeek Harness Integration 🤖
65
+
66
+ > **Multi-agent ecosystem update**: added DeepSeek Harness skill support and formalized 6-agent coverage.
67
+
68
+ ### 🤖 AI Agent Update
69
+
70
+ **DeepSeek Harness Skill Support**
71
+ - Added `.dsh/skills/colamd-themes/SKILL.md` for DeepSeek Harness integration
72
+ - Build script now supports `bash skills/build-skills.sh dsh` target
73
+ - Consolidated multi-agent documentation across Claude Code, OpenCode, OpenClaw, Hermes, Trae, and DeepSeek Harness
74
+
75
+ ### 🛠️ Improvements
76
+
77
+ - Standardized agent skill frontmatter with agent-specific metadata and command prerequisites
78
+ - Extended verification scripts (`DSH_SUPPORT_SUMMARY.md`, `test-dsh-skill.sh`)
79
+
80
+ ---
81
+
82
+
83
+ ## Version 0.3.3 (2026-08-26) — MCP Server & AI Agent Integration 🤖
84
+
85
+ > **AI ecosystem integration**: ColaMD-themes now connects to AI coding assistants via MCP protocol.
86
+ > **Chinese theme names now fully supported** — no more ASCII-only restriction.
87
+
88
+ ### ✨ New Features
89
+
90
+ **MCP Server (Model Context Protocol)**
91
+ - Full MCP server implementation in `mcp-server/` directory
92
+ - 14 tools covering theme extraction, export, validation, and management
93
+ - Works with Chatbox, Cursor, Claude Desktop, Continue, and all MCP-compatible clients
94
+ - Quick setup via `npm run mcp` or configure in your MCP client settings
95
+
96
+ **Multi-Agent Skill Definitions**
97
+ - Added skill files for 5 AI coding agents:
98
+ - Claude Code, OpenCode, OpenClaw, Hermes, Trae
99
+ - Auto-generated from `skills/colamd-themes/SKILL.md` via `build-skills.sh`
100
+
101
+ **Chinese Theme Name Support**
102
+ - Fixed CLI ASCII-only filter that stripped non-ASCII characters from theme names
103
+ - MCP server detects non-ASCII names and bypasses the filter using `-o` flag
104
+ - Tested with: `"我的主题"` -> `themes/我的主题.css` ✅
105
+
106
+ ### 📦 Quick Start (MCP)
107
+
108
+ **Chatbox Configuration:**
109
+ ```json
110
+ {
111
+ "mcpServers": {
112
+ "colamd-themes": {
113
+ "command": "node",
114
+ "args": ["D:/path/to/ColaMD-themes/mcp-server/dist/index.js"],
115
+ "cwd": "D:/path/to/ColaMD-themes"
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ **Then in your chat:**
122
+ > "Extract a theme from https://example.com named 'My Theme'"
123
+
124
+ ### 🛠️ MCP Tools Reference
125
+
126
+ | Category | Tool | Description |
127
+ |----------|------|-------------|
128
+ | Extraction | `extract_from_url` | Theme from web page |
129
+ | | `extract_from_docx` | Theme from Word doc |
130
+ | | `extract_from_pdf` | Theme from PDF |
131
+ | | `extract_auto` | Auto-detect source |
132
+ | Management | `list_themes` | List all themes |
133
+ | | `validate_theme` | Validate theme rules |
134
+ | | `check_fonts` | Check font availability |
135
+ | | `set_theme` | Register custom theme |
136
+ | Color | `list_color_systems` | 15 built-in palettes |
137
+ | | `list_mermaid_presets` | 3 Mermaid presets |
138
+ | Export | `export_html` | Markdown to HTML |
139
+ | | `export_pdf` | Markdown to PDF |
140
+ | | `export_batch` | Batch export |
141
+
142
+ ### 🔧 Migration
143
+
144
+ **No breaking changes** — fully backward compatible.
145
+
146
+ **New scripts available:**
147
+ ```bash
148
+ npm run build:mcp # Build MCP server only
149
+ npm run build:all # Build CLI + MCP server
150
+ npm run mcp # Start MCP server
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Version 0.3.2 (2026-05-29) — Theme Authoring Guide 📝
156
+
157
+ > **AI agent skill enhancement**: Added comprehensive CSS pitfall quick reference for reliable theme generation.
158
+
159
+ ### 📝 AI Agent Skill Update
160
+
161
+ **CSS Pitfall Quick Reference**
162
+ - Added 6-topic theme authoring guide to all AI agent skill definitions:
163
+ 1. **Screen & Print Sync** — every SECTION 5 rule must mirror in SECTION 6 `@media print`
164
+ 2. **Body Text First-Line Indent** — correct selector chain: `body.theme-custom p, body.theme-custom #write > p`
165
+ 3. **Indent Exclusion** — prevent indent pollution in lists, tables, mermaid blocks, blockquotes, and figures
166
+ 4. **List Indentation** — use `margin-left: 2em` instead of `padding-left`; include `#editor .ProseMirror` selectors
167
+ 5. **Mermaid CJK Text Overflow** — ≤ 2 lines per node, `fontSize: 14px`, simplified text
168
+ 6. **Mermaid classDef Inheritance** — must explicitly declare `fill / color / stroke`
169
+ - References `academic-paper.css` and `swiss-design.css` as canonical examples
170
+ - Skill files affected: `.claude/skills/`, `.opencode/skills/`, `.openclaw/skills/`, `.hermes/skills/`, `.trae/rules/`, `.dsh/skills/colamd-themes/SKILL.md`
171
+
172
+ ### 🔧 Changes
173
+
174
+ - Consolidated all unreleased changes from v0.3.1 into this patch release
175
+ - Updated CHANGELOG and version links for the 0.3.2 release
176
+
177
+ ---
178
+
179
+ ## Version 0.3.1 (2026-06-01) — Security & Stability Patch 🔒
180
+
181
+ > **Important**: This release contains critical security fixes and important stability improvements.
182
+ > **All users are strongly recommended to upgrade.**
183
+
184
+ ### 🚨 Critical Security Fixes
185
+
186
+ **SSRF Vulnerability Patch (CVE-Level)**
187
+ - **Issue**: URL extractor was vulnerable to Server-Side Request Forgery attacks
188
+ - Attackers could force the server to access internal network resources
189
+ - Could expose sensitive internal services or cause denial-of-service
190
+ - **Fix**: Implemented comprehensive URL validation in [`url-extractor.ts`](src/extractors/url-extractor.ts):
191
+ - ✅ Protocol whitelist: Only `http:` and `https:` allowed
192
+ - ✅ Private network blocking: localhost, 10.x, 172.16-31.x, 192.168.x, 169.254.x
193
+ - ✅ Clear error messages for blocked attempts
194
+ - **Impact**: Prevents unauthorized internal network access; protects against SSRF attacks
195
+
196
+ **Input Validation Hardening**
197
+ - **Issue**: No validation on custom CSS theme files before processing
198
+ - Large files could cause memory exhaustion (OOM)
199
+ - Invalid file formats could crash the process
200
+ - **Fix**: Added multi-layer validation in [`theme-store.ts`](src/theme-store.ts):
201
+ - ✅ File extension check (must be `.css`)
202
+ - ✅ Size limit enforcement (1MB maximum)
203
+ - ✅ Content validity verification (minimum 10 characters)
204
+ - ✅ Sanitized filename extraction (removes special chars, limits length)
205
+ - **Impact**: Prevents OOM attacks; ensures graceful error handling
206
+
207
+ ### 🐛 Major Bug Fixes
208
+
209
+ **PDF Export Theme Not Applied**
210
+ - **Symptom**: Custom themes were ignored when exporting to PDF; documents rendered with default styling only
211
+ - **Root Cause**: Puppeteer's `emulateMediaType("screen")` forced browser into screen mode, causing CSS `@media print { ... }` rules to be completely ignored
212
+ - **Fix**: Removed screen media type emulation in [`renderer.ts`](src/renderer.ts); allows default print mode where all `@media print` styles apply correctly
213
+ - **Result**: PDF exports now render with full theme fidelity — colors, fonts, backgrounds, spacing, and all visual styling correctly applied
214
+
215
+ **Puppeteer Resource Leak**
216
+ - **Symptom**: Zombie Chromium processes left running after export operations completed
217
+ - **Cause**: Page objects not explicitly closed before browser termination
218
+ - **Fix**: Explicit page cleanup in [`renderer.ts`](src/renderer.ts#L150-L155) close() method
219
+ - **Result**: Clean process shutdown; no resource leaks
220
+
221
+ **CLI Version Display Incorrect**
222
+ - **Symptom**: `colamd-themes --version` always showed "0.2.0" regardless of actual version
223
+ - **Cause**: Hardcoded version string in CLI initialization
224
+ - **Fix**: Dynamic version reading from [`package.json`](package.json) via [`getPackageVersion()`](src/cli.ts)
225
+ - **Result**: Accurate version display matching published package version
226
+
227
+ ### ⚡ Performance Improvements
228
+
229
+ **Async I/O Migration**
230
+ - **Before**: Synchronous file operations (`readFileSync`, `writeFileSync`) blocked event loop during theme configuration
231
+ - **After**: All theme store operations now use async API (`fs/promises`)
232
+ - **Benefit**:
233
+ - Non-blocking configuration reads/writes
234
+ - Improved responsiveness during batch exports
235
+ - Better scalability for concurrent operations
236
+ - **Files Updated**: [`theme-store.ts`](src/theme-store.ts)
237
+
238
+ **Template Cache Management**
239
+ - **Before**: Single global template variable; recompiled on every call after first use; no size limits
240
+ - **After**: Sophisticated cache system with three-layer invalidation:
241
+ 1. **LRU Eviction**: Maximum 10 cached templates (evicts oldest when full)
242
+ 2. **TTL Expiration**: Automatic expiry after 30 minutes of inactivity
243
+ 3. **mtime Detection**: Auto-invalidates when source template file is modified on disk
244
+ - **Benefit**:
245
+ - ~90% reduction in template compilations for repeated operations
246
+ - Stable memory usage in long-running processes
247
+ - Fresh templates automatically loaded after updates
248
+ - **Files Updated**: [`generator.ts`](src/generator.ts)
249
+
250
+ ### 🛠️ Code Quality Enhancements
251
+
252
+ **Unified Error Handling System**
253
+ - **New Module**: [`cli-utils.ts`](src/utils/cli-utils.ts)
254
+ - **Features**:
255
+ - `CLIError` class: Structured errors with code, message, and cause chain
256
+ - `ErrorCode` enum: Standardized categories (FILE_NOT_FOUND, THEME_ERROR, RENDER_ERROR, INVALID_INPUT, UNKNOWN)
257
+ - Consistent error propagation across all commands
258
+ - **Impact**:
259
+ - Better debugging experience with detailed error context
260
+ - Consistent user-facing error messages
261
+ - Easier error tracking and logging
262
+ - Process exits with meaningful exit codes
263
+
264
+ **Code Deduplication**
265
+ - **Extracted Utilities**:
266
+ - `resolveInputPath(input)`: Validates existence, converts relative→absolute paths
267
+ - `resolveOutputPath(input, output?, ext?)`: Smart output path derivation
268
+ - `getDocumentTitle(filePath)`: Extracts clean document title from path
269
+ - **Impact**:
270
+ - Eliminated duplicate path resolution logic across 4+ command handlers
271
+ - Single source of truth reduces maintenance burden
272
+ - Consistent behavior across all export commands
273
+
274
+ ### 📊 Metrics & Benchmarks
275
+
276
+ | Metric | v0.3.0 | v0.3.1 | Improvement |
277
+ |--------|--------|--------|-------------|
278
+ | **Security Vulnerabilities** | 2 Critical | 0 Known | ✅ Resolved |
279
+ | **Memory Usage (100 files)** | Unbounded | Stable | ✅ Predictable |
280
+ | **Template Compilations** | ~100 per batch | ~10 max | ⚡ 90% fewer |
281
+ | **Event Loop Blocking** | Frequent sync I/O | Minimal async ops | ⚡ Responsive |
282
+ | **Error Consistency** | Mixed patterns | Unified codes | ✅ Maintainable |
283
+ | **Zombie Processes** | Possible leak | Clean shutdown | ✅ Reliable |
284
+
285
+ ### 🔧 Migration Guide
286
+
287
+ **For Most Users**: No action required! This is a drop-in replacement.
288
+
289
+ **Breaking Changes**: None — fully backward compatible.
290
+
291
+ **API Changes** (for programmatic usage):
292
+ ```typescript
293
+ // Before (v0.3.0): Sync API
294
+ import { resolveTheme } from '@bytechain.cn/colamd-themes';
295
+ const theme = resolveTheme('elegant'); // Sync
296
+
297
+ // After (v0.3.1): Async API
298
+ import { resolveTheme } from '@bytechain.cn/colamd-themes';
299
+ const theme = await resolveTheme('elegant'); // Async
300
+ ```
301
+
302
+ **New Error Handling** (recommended):
303
+ ```typescript
304
+ import { CLIError, ErrorCode } from '@bytechain.cn/colamd-themes';
305
+
306
+ try {
307
+ await exportHTML(document, { theme: 'custom' });
308
+ } catch (error) {
309
+ if (error instanceof CLIError) {
310
+ console.error(`Error ${error.code}: ${error.message}`);
311
+ // Handle specific error types
312
+ switch (error.code) {
313
+ case ErrorCode.FILE_NOT_FOUND: /* ... */ break;
314
+ case ErrorCode.THEME_ERROR: /* ... */ break;
315
+ case ErrorCode.RENDER_ERROR: /* ... */ break;
316
+ default: /* ... */ break;
317
+ }
318
+ }
319
+ }
320
+ ```
321
+
322
+ ### ✅ Testing Recommendations
323
+
324
+ After upgrading, verify these critical scenarios:
325
+
326
+ 1. **Security Test**:
327
+ ```bash
328
+ # Should be blocked (private network)
329
+ cthemes from-url "http://localhost:3000" --name test
330
+
331
+ # Should be blocked (invalid protocol)
332
+ cthemes from-url "ftp://example.com/file.css" --name test
333
+
334
+ # Should work (public HTTPS)
335
+ cthemes from-url "https://example.com" --name my-theme
336
+ ```
337
+
338
+ 2. **PDF Export Test**:
339
+ ```bash
340
+ # Verify themes now apply correctly
341
+ cthemes export-pdf doc.md -t elegant -o test.pdf
342
+ open test.pdf # Check styling is applied
343
+ ```
344
+
345
+ 3. **Version Display Test**:
346
+ ```bash
347
+ # Should show 0.3.1
348
+ cthemes --version
349
+ ```
350
+
351
+ 4. **Large File Protection Test**:
352
+ ```bash
353
+ # Create a large CSS file (>1MB)
354
+ dd if=/dev/urandom of=large-theme.css bs=1024 count=1100
355
+
356
+ # Should fail gracefully
357
+ cthemes set-theme big --css large-theme.css
358
+ ```
359
+
360
+ ### 📝 Full Changelog
361
+
362
+ For complete details on all changes, see [CHANGELOG.md](./CHANGELOG.md).
363
+
364
+ ---
365
+
366
+ ## Version 0.3.0 (2026-06-01)
367
+
368
+ ### 📦 Package Name Change
369
+
370
+ **Migrated to Scoped Package**
371
+ - Package name changed from `colamd-themes` to **`@bytechain.cn/colamd-themes`**
372
+ - Belongs to the `@bytechain.cn` organization ecosystem
373
+ - Consistent with dependency `@bytechain.cn/colamd`
374
+
375
+ **New Short CLI Command**
376
+ - Added `cthemes` as a short alias for `colamd-themes`
377
+ - Both commands are fully equivalent and interchangeable
378
+ - Recommended for frequent use: shorter to type, same functionality
379
+
380
+ ### 🎨 New Themes
381
+
382
+ **Trae Blue Theme**
383
+ - Modern blue color scheme optimized for technical documentation
384
+ - Enhanced readability with carefully tuned contrast ratios
385
+ - Perfect for developer guides, API documentation, and code-heavy content
386
+
387
+ **Forest Ink Theme**
388
+ - Nature-inspired dark green palette with elegant ink aesthetics
389
+ - Sophisticated design suitable for long-form reading and literary content
390
+ - Unique visual identity that stands out from traditional themes
391
+
392
+ ### ✨ Improvements
393
+
394
+ **Enhanced Swiss Design Theme**
395
+ - Refined typography with improved spacing and line heights
396
+ - Better color contrast for enhanced accessibility
397
+ - Polished overall visual appearance
398
+
399
+ **Better Developer Experience**
400
+ - **Absolute Path Support**: Use full file paths in all CLI commands — no more relative path confusion
401
+ ```bash
402
+ cthemes export-html /full/path/to/document.md -t elegant -o output.html
403
+ ```
404
+ - **Interactive Previews**: New HTML preview files for colly and salvator-blog themes
405
+ - **Build Process**: Fixed template file copying to ensure reliable distributions
406
+
407
+ ### 🧹 Housekeeping
408
+
409
+ - Removed system files (`.DS_Store`) from repository
410
+
411
+ ---
412
+
413
+ ## Version 0.2.0 (2026-05-25)
414
+
415
+ ### 🚀 Major Upgrade: v3.0 Design System
416
+
417
+ **Complete Paradigm Overhaul**
418
+ - Implemented ColaMD's new v3.0 seed palette architecture
419
+ - **15 predefined palettes** across 5 color families:
420
+ - Morandi (soft, muted tones)
421
+ - Macaron (pastel, playful)
422
+ - Nordic (cool, minimalist)
423
+ - Vintage (warm, retro)
424
+ - Mint (fresh, vibrant)
425
+ - **Auto-derived semantic mapping**: Design tokens automatically generate consistent color relationships
426
+ - **Mermaid Integration**: 3 diagram presets with 20 customizable variables
427
+
428
+ ### 📚 Academic Focus
429
+
430
+ **New Academic Style Theme**
431
+ - Specialized formatting for research papers and scholarly documents
432
+ - Optimized typography for citations, references, and structured content
433
+ - Follows academic publishing conventions
434
+
435
+ **Redesigned Academic Paper Theme**
436
+ - Restructured to comply with v3.0 paradigm specifications
437
+ - Improved consistency with other themes in the ecosystem
438
+
439
+ ### 🔧 Under the Hood
440
+
441
+ **Refactored Extractors**
442
+ - **URL Extractor**: Advanced CSS parsing with specificity-aware style resolution
443
+ - **DOCX Extractor**: Enhanced Word document style mapping via mammoth
444
+ - **PDF Extractor**: Multi-layer heuristic analysis for better metadata extraction
445
+ - **Auto-Detection**: Smarter source type identification
446
+
447
+ **Validation Engine**
448
+ - WCAG 2.1 compliance checking built-in
449
+ - 15+ design constraint rules with auto-fix suggestions
450
+ - Contrast ratio and luminance calculations
451
+
452
+ ---
453
+
454
+ ## Version 0.1.0 (2026-05-22) — Initial Release 🎉
455
+
456
+ ### Core Features
457
+
458
+ **Theme Extraction from Any Source**
459
+ - **Web Pages**: Fetch URLs and extract CSS styling automatically
460
+ - **Word Documents**: Import `.docx` files and preserve document styles
461
+ - **PDF Files**: Analyze PDF typography and generate matching themes
462
+ - **Smart Detection**: Automatically identifies source type
463
+
464
+ **Professional Export Capabilities**
465
+ - **HTML Export**: Standalone documents with embedded themes
466
+ - Full Mermaid diagram rendering
467
+ - KaTeX math formula support
468
+ - Responsive layout with print optimization
469
+ - **PDF Export**: High-quality PDF generation via Chromium
470
+ - Pixel-perfect theme reproduction
471
+ - Custom page formats (A4, Letter, etc.)
472
+ - Batch processing for multiple files
473
+
474
+ **Complete Theme Management**
475
+ - Built-in theme library (light, dark, elegant, newsprint)
476
+ - Custom theme registration from CSS files
477
+ - Default theme configuration
478
+ - Easy switching between themes
479
+
480
+ **Developer-Friendly CLI**
481
+
482
+ ```bash
483
+ # Extract theme from any source (use `colamd-themes` or short alias `cthemes`)
484
+ cthemes extract source.docx --name my-theme
485
+
486
+ # Export with beautiful styling
487
+ cthemes export-html doc.md -t elegant -o output.html
488
+ cthemes export-pdf doc.md -t dark --format A4 -o output.pdf
489
+
490
+ # Batch process entire directories
491
+ cthemes export docs/ --format pdf -t elegant -d output/
492
+
493
+ # Manage your themes
494
+ cthemes list
495
+ cthemes validate themes/my-theme.css
496
+ cthemes set-theme my-brand --css custom.css --default
497
+ ```
498
+
499
+ ### Technology Stack
500
+
501
+ - **TypeScript**: Type-safe implementation with full IDE support
502
+ - **css-tree**: Robust CSS parsing and analysis
503
+ - **mammoth**: Reliable DOCX processing
504
+ - **puppeteer**: Accurate PDF rendering
505
+ - **handlebars**: Flexible template engine
506
+ - **commander**: Intuitive CLI framework
507
+
508
+ ### Perfect For
509
+
510
+ ✅ Technical documentation teams needing consistent branding
511
+ ✅ Content creators exporting Markdown to professional formats
512
+ ✅ Developers building documentation pipelines
513
+ ✅ Anyone wanting beautiful, themed Markdown output
514
+
515
+ ---
516
+
517
+ ## Quick Start
518
+
519
+ ```bash
520
+ # Install
521
+ git clone https://github.com/byteuser1977/ColaMD-themes.git
522
+ cd ColaMD-themes
523
+ npm install
524
+ npm run build
525
+
526
+ # Try it out (use either command)
527
+ cthemes export-html README.md -t trae-blue -o preview.html
528
+ open preview.html
529
+ ```
530
+
531
+ ## Links
532
+
533
+ - **Documentation**: [README.md](./README.md)
534
+ - **Chinese Documentation**: [README_CN.md](./README_CN.md)
535
+ - **Changelog**: [CHANGELOG.md](./CHANGELOG.md)
536
+ - **Issues**: [GitHub Issues](https://github.com/byteuser1977/ColaMD-themes/issues)
537
+ - **Contributing**: Pull requests welcome!
538
+
539
+ ---
540
+
541
+ *Last updated: 2026-10-25*