@bytechain.cn/colamd-themes 0.3.2 → 0.5.1
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.
- package/.claude/skills/colamd-themes-preview.skill.md +333 -0
- package/.claude/skills/colamd-themes.skill.md +10 -0
- package/.dsh/skills/colamd-themes/SKILL.md +14 -0
- package/.github/supported-topics.yml +17 -0
- package/.hermes/skills/tools/colamd-themes/SKILL.md +14 -0
- package/.openclaw/skills/colamd-themes/SKILL.md +1 -37
- package/.opencode/skills/colamd-themes/SKILL.md +17 -0
- package/.trae/rules/colamd-themes.md +0 -36
- package/CHANGELOG.md +331 -241
- package/DSH_SUPPORT_SUMMARY.md +87 -0
- package/README.md +414 -384
- package/README_CN.md +412 -384
- package/RELEASENOTE.md +541 -389
- package/dist/cli.js +36 -55
- package/dist/cli.js.map +1 -1
- package/dist/color-utils.d.ts +1 -0
- package/dist/color-utils.js +25 -6
- package/dist/color-utils.js.map +1 -1
- package/dist/extractors/pdf-extractor.js +6 -1
- package/dist/extractors/pdf-extractor.js.map +1 -1
- package/dist/extractors/url-extractor.d.ts +0 -4
- package/dist/extractors/url-extractor.js +13 -126
- package/dist/extractors/url-extractor.js.map +1 -1
- package/dist/generator.d.ts +1 -1
- package/dist/generator.js +32 -11
- package/dist/generator.js.map +1 -1
- package/dist/models.d.ts +5 -4
- package/dist/models.js +2 -3
- package/dist/models.js.map +1 -1
- package/dist/renderer.d.ts +6 -3
- package/dist/renderer.js +54 -93
- package/dist/renderer.js.map +1 -1
- package/dist/templates/template.css +220 -498
- package/dist/templates/theme-paradigm.md +530 -658
- package/dist/templates/theme-template.hbs +256 -370
- package/dist/theme-store.js +19 -3
- package/dist/theme-store.js.map +1 -1
- package/dist/utils/document-paradigm.d.ts +12 -0
- package/dist/utils/document-paradigm.js +109 -0
- package/dist/utils/document-paradigm.js.map +1 -0
- package/dist/validators.d.ts +4 -1
- package/dist/validators.js +115 -1
- package/dist/validators.js.map +1 -1
- package/mcp-server/dist/index.d.ts +13 -0
- package/mcp-server/dist/index.d.ts.map +1 -0
- package/mcp-server/dist/index.js +0 -0
- package/mcp-server/dist/index.js.map +1 -0
- package/mcp-server/package-lock.json +1759 -0
- package/mcp-server/package.json +24 -0
- package/mcp-server/src/index.ts +0 -0
- package/mcp-server/tsconfig.json +19 -0
- package/package.json +54 -36
- package/skills/build-skills.sh +30 -5
- package/skills/colamd-themes/SKILL.md +180 -178
- package/src/cli.ts +474 -487
- package/src/color-systems.ts +289 -289
- package/src/color-utils.ts +137 -120
- package/src/contrast.ts +66 -66
- package/src/docx-style-paradigm.ts +811 -811
- package/src/export-cli.ts +356 -356
- package/src/extractors/base.ts +8 -8
- package/src/extractors/docx-extractor.ts +417 -417
- package/src/extractors/pdf-extractor.ts +533 -527
- package/src/extractors/url-extractor.ts +846 -981
- package/src/generator.ts +197 -169
- package/src/index.ts +29 -29
- package/src/models.ts +212 -212
- package/src/renderer.ts +310 -359
- package/src/templates/template.css +220 -498
- package/src/templates/theme-paradigm.md +530 -658
- package/src/templates/theme-template.hbs +256 -370
- package/src/theme-store.ts +185 -170
- package/src/types/pdf-parse.d.ts +12 -12
- package/src/utils/cli-utils.ts +84 -84
- package/src/utils/document-paradigm.ts +118 -0
- package/src/validators.ts +298 -176
- package/themes/academic-paper-pt.css +353 -1805
- package/themes/academic-paper.css +350 -1099
- package/themes/academic-style.css +342 -2430
- package/themes/colly.css +256 -370
- package/themes/elegant.css +288 -671
- package/themes/forest-ink.css +240 -664
- package/themes/guizang.css +250 -732
- package/themes/hermes-security.css +279 -0
- package/themes/meeting-minutes.css +256 -370
- package/themes/pixso-design.css +278 -1261
- package/themes/salvator-blog.css +256 -370
- package/themes/shimo-theme.css +256 -0
- package/themes/swiss-design.css +285 -746
- package/themes/template.css +220 -498
- package/themes/trae-blue.css +280 -737
- package/themes/word-contract.css +249 -0
- package/themes-preview/demo-content.md +187 -187
- package/tsconfig.json +18 -18
- package/src/mermaid-presets.ts +0 -142
- package/themes/swiss-design copy.css +0 -746
- package/themes-preview/colly-preview.html +0 -623
- package/themes-preview/meeting-minutes-preview.html +0 -625
- package/themes-preview/salvator-blog-preview.html +0 -623
package/README.md
CHANGED
|
@@ -1,384 +1,414 @@
|
|
|
1
|
-
# ColaMD Themes
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- **`
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
###
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
- **
|
|
33
|
-
|
|
34
|
-
###
|
|
35
|
-
|
|
36
|
-
- **
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
40
|
-
- **
|
|
41
|
-
- **
|
|
42
|
-
|
|
43
|
-
###
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
cthemes
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
###
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
#
|
|
198
|
-
cthemes
|
|
199
|
-
|
|
200
|
-
#
|
|
201
|
-
cthemes
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
###
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
│
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
│
|
|
286
|
-
|
|
287
|
-
│
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
│
|
|
291
|
-
│
|
|
292
|
-
|
|
293
|
-
│
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
###
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
│
|
|
360
|
-
│
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
1
|
+
# ColaMD Themes
|
|
2
|
+
|
|
3
|
+
[
|
|
4
|
+
[](https://github.com/Dominic789654/awesome-deepseek-harness)
|
|
5
|
+
[](https://github.com/beancookie/awesome-dsh-plugin)
|
|
6
|
+
|
|
7
|
+
**Topics**: `dsh` `deepseek-harness` `colamd` `themes` `css` `markdown` `pdf` `html` `skill` `ai-agent`
|
|
8
|
+
|
|
9
|
+
A theme development & export toolkit for [ColaMD](https://github.com/cola-md/cola-md) — the Agent-native Markdown editor. Extract visual formatting from web pages, Word documents, and PDFs, convert them into validated CSS theme files, and export Markdown to standalone HTML or PDF with any theme applied.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
### Theme Extraction
|
|
14
|
+
|
|
15
|
+
- **URL** — fetch a web page, parse its CSS rules (via `css-tree`), resolve inline styles with specificity calculation, and derive a coherent theme palette
|
|
16
|
+
- **DOCX** — read Word document styles (H1–H6, tables, code blocks) via mammoth, map to theme variables
|
|
17
|
+
- **PDF** — extract typography metadata from PDF text using multi-layer heuristic analysis
|
|
18
|
+
- **Auto‑detect** — `extract` command automatically routes to the right extractor
|
|
19
|
+
|
|
20
|
+
### HTML / PDF Export
|
|
21
|
+
|
|
22
|
+
- **`export-html`** — render Markdown to a standalone HTML document with theme CSS embedded, Mermaid diagrams and KaTeX math fully rendered
|
|
23
|
+
- **`export-pdf`** — render Markdown to PDF via Puppeteer (Chromium); theme colors are preserved with `print-color-adjust: exact`
|
|
24
|
+
- **`export`** — batch export multiple files or entire directories to HTML or PDF
|
|
25
|
+
- Powered by `@bytechain.cn/colamd/renderer` (2.x library build, requires `@bytechain.cn/colamd@^2.7.8-rc.1`) — the same CM6 editor as the app runs headless via Puppeteer. Theme CSS is consumed directly as `:root` declarations, `buildExportHTML({ title })` serializes only contract live variables, and mermaid diagrams (Pele SVG) / KaTeX math stay fully rendered offline. Built-in theme names resolve their local contract CSS first. Generated themes target the **2.7.8-rc.1 contract**, so they carry over unchanged.
|
|
26
|
+
|
|
27
|
+
### Theme Management
|
|
28
|
+
|
|
29
|
+
- **`set-theme`** — configure default export theme, register custom CSS themes, switch between built-in themes
|
|
30
|
+
- Built-in themes: `light`, `dark`, `elegant`, `newsprint`
|
|
31
|
+
- Custom themes: any `.css` file registered by name, referenced in exports
|
|
32
|
+
- **Using themes in the ColaMD 2.7.7+ app** — import via *Theme > Import Theme* or drop the `.css` into `~/.colamd/themes/`. The app ships its own built-in `elegant`; rename our `elegant.css` (e.g. `elegant-brick.css`) before importing to avoid a name clash.
|
|
33
|
+
|
|
34
|
+
### Validation & Color Systems
|
|
35
|
+
|
|
36
|
+
- **Contrast Engine** — WCAG 2.1 relative luminance & contrast ratio calculations
|
|
37
|
+
- **Paradigm Validator** — 15+ design constraint rules (CR, HR, SL, NT, BD, MP, FP, FS, SH) with auto-fix suggestions
|
|
38
|
+
- **Color System Library** — 15 predefined seed palettes across 5 families (Morandi, Macaron, Nordic, Vintage, Mint)
|
|
39
|
+
- **2.7.8-rc.1 CSS Contract Validator** — flags dead selectors (`#write`, `.ProseMirror`, `body.theme-custom`), dead variables (`--mermaid-*`, `--radius-*`, `--font-size-root`…), `pt` units, and vertical padding on quote/code lines
|
|
40
|
+
- **2.7.8-rc.1 Verified** — all 16 shipped themes audited against `@bytechain.cn/colamd@2.7.7` (contract unchanged through 2.7.8-rc.1) and smoke-tested on the 2.7.8-rc.1 export pipeline: zero `.cm-md-*` hook drift, all `:root` live variables and `--pele-*` overrides consumed, exports carry exactly the 27 contract live variables
|
|
41
|
+
- **Pele Diagram Colors** — 9 `--pele-*` variables derived from `--code-block-bg` / `--code-block-text` / `--link-color`, replacing the 20 Mermaid variables
|
|
42
|
+
|
|
43
|
+
### Security & Performance (v0.4.0+)
|
|
44
|
+
|
|
45
|
+
- **SSRF Protection** — URL extractor validates against protocol whitelist and blocks private network access to prevent Server-Side Request Forgery attacks
|
|
46
|
+
- **Input Validation** — CSS files validated for extension, size limit (1MB max), and content validity to prevent OOM attacks
|
|
47
|
+
- **Async I/O** — Non-blocking file operations for improved responsiveness during batch exports
|
|
48
|
+
- **Template Caching** — LRU-style cache (max 10 templates) with TTL expiration (30min) and mtime-based auto-invalidation for stable memory usage
|
|
49
|
+
- **Unified Error Handling** — Structured error codes (`CLIError` + `ErrorCode`) across all commands for consistent debugging experience
|
|
50
|
+
- **Resource Cleanup** — Explicit Puppeteer page cleanup prevents zombie processes and resource leaks
|
|
51
|
+
|
|
52
|
+
### CSS Template Engine
|
|
53
|
+
|
|
54
|
+
Handlebars-powered template produces ColaMD 2.7.8-rc.1 contract CSS (≤300 lines):
|
|
55
|
+
|
|
56
|
+
| Section | Content |
|
|
57
|
+
|---------|---------|
|
|
58
|
+
| 1 | Design Tokens — `:root` seed palette (11 vars), 14 semantic colors, fonts, metrics, 9 `--pele-*` |
|
|
59
|
+
| 2 | Editor DOM — `#editor .cm-content` + `.cm-md-*` (headings, inline, quote, code block, table, indent) |
|
|
60
|
+
| 3 | Exported HTML — `.colamd-document` color layer for semantic tags |
|
|
61
|
+
| 4 | `@media print` — print-color fidelity only (screen rules already apply) |
|
|
62
|
+
|
|
63
|
+
### MCP Server (Model Context Protocol)
|
|
64
|
+
|
|
65
|
+
Full MCP server for AI-native integration — connect ColaMD-themes to Chatbox, Cursor, Claude Desktop, Continue, and all MCP-compatible clients.
|
|
66
|
+
|
|
67
|
+
- **14 MCP tools** covering theme extraction, export, validation, and management
|
|
68
|
+
- **Stdio transport** — zero network config, direct process communication
|
|
69
|
+
- **Chinese theme name support** — non-ASCII names handled via smart path resolution
|
|
70
|
+
|
|
71
|
+
| Category | Tool | Description |
|
|
72
|
+
|----------|------|-------------|
|
|
73
|
+
| Extraction | `extract_from_url` | Theme from web page |
|
|
74
|
+
| | `extract_from_docx` | Theme from Word doc |
|
|
75
|
+
| | `extract_from_pdf` | Theme from PDF |
|
|
76
|
+
| | `extract_auto` | Auto-detect source |
|
|
77
|
+
| Management | `list_themes` | List all themes |
|
|
78
|
+
| | `validate_theme` | Validate theme rules |
|
|
79
|
+
| | `check_fonts` | Check font availability |
|
|
80
|
+
| | `set_theme` | Register custom theme |
|
|
81
|
+
| Color | `list_color_systems` | 15 built-in palettes |
|
|
82
|
+
| | `list_mermaid_presets` | 3 Mermaid presets |
|
|
83
|
+
| Export | `export_html` | Markdown to HTML |
|
|
84
|
+
| | `export_pdf` | Markdown to PDF |
|
|
85
|
+
| | `export_batch` | Batch export |
|
|
86
|
+
|
|
87
|
+
### Multi-Agent Skill
|
|
88
|
+
|
|
89
|
+
Universal skill definitions for 6 AI coding agents, auto-generated from a single source:
|
|
90
|
+
|
|
91
|
+
| Agent | Skill Path | Frontmatter |
|
|
92
|
+
|-------|-----------|-------------|
|
|
93
|
+
| **Claude Code** | `.claude/skills/colamd-themes.skill.md` | `name`, `description` |
|
|
94
|
+
| **OpenCode** | `.opencode/skills/colamd-themes/SKILL.md` | `name`, `version`, `user-invocable`, `allowed-tools`, `hooks` |
|
|
95
|
+
| **OpenClaw** | `.openclaw/skills/colamd-themes/SKILL.md` | `id`, `name`, `version`, `icon`, `author`, `homepage`, `metadata.openclaw.os` |
|
|
96
|
+
| **Hermes** | `.hermes/skills/tools/colamd-themes/SKILL.md` | `name`, `version`, `author`, `license`, `metadata.hermes.tags`, `prerequisites` |
|
|
97
|
+
| **Trae** | `.trae/rules/colamd-themes.md` | Plain Markdown (no frontmatter) |
|
|
98
|
+
| **DeepSeek Harness** | `.dsh/skills/colamd-themes/SKILL.md` | `name`, `version`, `description`, `metadata.dsh.tags`, `prerequisites` |
|
|
99
|
+
|
|
100
|
+
**Architecture:**
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
skills/colamd-themes/SKILL.md ← Canonical source (single source of truth)
|
|
104
|
+
│
|
|
105
|
+
▼
|
|
106
|
+
skills/build-skills.sh ← Build script (bash)
|
|
107
|
+
│
|
|
108
|
+
├──→ .claude/skills/colamd-themes.skill.md
|
|
109
|
+
├──→ .opencode/skills/colamd-themes/SKILL.md
|
|
110
|
+
├──→ .openclaw/skills/colamd-themes/SKILL.md
|
|
111
|
+
├──→ .hermes/skills/tools/colamd-themes/SKILL.md
|
|
112
|
+
├──→ .trae/rules/colamd-themes.md
|
|
113
|
+
└──→ .dsh/skills/colamd-themes/SKILL.md
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Regenerate all agent skills:**
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm run build:skills # generate all
|
|
120
|
+
bash skills/build-skills.sh # same thing
|
|
121
|
+
|
|
122
|
+
# Or generate for a single agent:
|
|
123
|
+
bash skills/build-skills.sh claude
|
|
124
|
+
bash skills/build-skills.sh opencode
|
|
125
|
+
bash skills/build-skills.sh openclaw
|
|
126
|
+
bash skills/build-skills.sh hermes
|
|
127
|
+
bash skills/build-skills.sh trae
|
|
128
|
+
bash skills/build-skills.sh dsh
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
To customize: edit `skills/colamd-themes/SKILL.md`, then run `npm run build:skills`.
|
|
132
|
+
|
|
133
|
+
## Installation
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
git clone git@github.com:byteuser1977/ColaMD-themes.git
|
|
137
|
+
cd ColaMD-themes
|
|
138
|
+
npm install
|
|
139
|
+
npm run build
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
For development with hot‑reload:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npx tsx src/cli.ts <command>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Usage
|
|
149
|
+
|
|
150
|
+
The package provides two equivalent CLI commands:
|
|
151
|
+
|
|
152
|
+
- **`colamd-themes`** — full command name
|
|
153
|
+
- **`cthemes`** — short alias (recommended for frequent use)
|
|
154
|
+
|
|
155
|
+
Examples below use the short alias `cthemes`, but you can substitute `colamd-themes` interchangeably.
|
|
156
|
+
|
|
157
|
+
### Extract a theme from a URL
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
cthemes from-url "https://example.com" --name my-theme
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Extract from a Word document
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
cthemes from-docx report.docx --name corporate-theme
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Extract from a PDF
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
cthemes from-pdf paper.pdf --name academic-theme
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Auto‑detect source type
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
cthemes extract source.docx --name auto-theme
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Validate a theme
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
cthemes validate themes/my-theme.css
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### List themes and color systems
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
cthemes list
|
|
191
|
+
cthemes color-systems
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Export to HTML
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Single file with a built-in theme
|
|
198
|
+
cthemes export-html document.md -t elegant -o output.html
|
|
199
|
+
|
|
200
|
+
# With a custom theme
|
|
201
|
+
cthemes export-html document.md -t my-brand -o output.html
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Export to PDF
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# Single file
|
|
208
|
+
cthemes export-pdf document.md -t dark -o output.pdf
|
|
209
|
+
|
|
210
|
+
# With page format
|
|
211
|
+
cthemes export-pdf document.md -t elegant --format Letter -o output.pdf
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Batch export
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# Multiple files to HTML
|
|
218
|
+
cthemes export docs/*.md --format html -t light -d output/
|
|
219
|
+
|
|
220
|
+
# Directory of Markdown files to PDF
|
|
221
|
+
cthemes export docs/ --format pdf -t elegant -d output/
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Theme management
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Set a built-in theme as default
|
|
228
|
+
cthemes set-theme elegant --default
|
|
229
|
+
|
|
230
|
+
# Register a custom theme from a CSS file
|
|
231
|
+
cthemes set-theme my-brand --css themes/swiss-design.css
|
|
232
|
+
|
|
233
|
+
# Register and set as default
|
|
234
|
+
cthemes set-theme my-brand --css themes/swiss-design.css --default
|
|
235
|
+
|
|
236
|
+
# Unregister a custom theme
|
|
237
|
+
cthemes set-theme my-brand --remove
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### All commands
|
|
241
|
+
|
|
242
|
+
| Command | Description |
|
|
243
|
+
|---------|-------------|
|
|
244
|
+
| `from-url <url>` | Extract theme from a web page URL |
|
|
245
|
+
| `from-docx <file>` | Extract theme from a .docx document |
|
|
246
|
+
| `from-pdf <file>` | Extract theme from a PDF document |
|
|
247
|
+
| `extract <source>` | Auto-detect source type and extract theme |
|
|
248
|
+
| `color-systems` | List 15 built-in color systems |
|
|
249
|
+
| `list` | List all generated themes |
|
|
250
|
+
| `validate <file>` | Validate a theme against the 2.7.8-rc.1 contract and paradigm rules |
|
|
251
|
+
| `set-theme <name>` | Set, register, or remove export themes |
|
|
252
|
+
| `export-html <input>` | Export Markdown → standalone HTML |
|
|
253
|
+
| `export-pdf <input>` | Export Markdown → PDF |
|
|
254
|
+
| `export <inputs...>` | Batch export multiple files or directories |
|
|
255
|
+
|
|
256
|
+
### Extract options
|
|
257
|
+
|
|
258
|
+
| Flag | Description |
|
|
259
|
+
|------|-------------|
|
|
260
|
+
| `-n, --name` | Theme name (derived from source by default) |
|
|
261
|
+
| `-o, --output` | Output CSS file path |
|
|
262
|
+
| `-d, --themes-dir` | Themes directory (default: `themes/`) |
|
|
263
|
+
| `-c, --color-system` | Force a color system |
|
|
264
|
+
| `-A, --auto-match` | Auto-match a color system from the extracted palette |
|
|
265
|
+
|
|
266
|
+
### Export options
|
|
267
|
+
|
|
268
|
+
| Flag | Description |
|
|
269
|
+
|------|-------------|
|
|
270
|
+
| `-t, --theme` | Theme name (built-in, custom, or CSS file path) |
|
|
271
|
+
| `-o, --output` | Output file path |
|
|
272
|
+
| `-d, --output-dir` | Output directory for batch export |
|
|
273
|
+
| `--format` | Output format for batch: `html` or `pdf` (default: `html`) |
|
|
274
|
+
| `--format` | PDF page size: `A4`, `Letter`, `A3` (default: `A4`) |
|
|
275
|
+
|
|
276
|
+
## How It Works
|
|
277
|
+
|
|
278
|
+
### Theme Extraction Pipeline
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
Source (URL / .docx / .pdf)
|
|
282
|
+
│
|
|
283
|
+
▼
|
|
284
|
+
┌─────────────────────┐
|
|
285
|
+
│ Extractor │ Parse → raw ThemeStyle
|
|
286
|
+
└──────────┬──────────┘
|
|
287
|
+
│
|
|
288
|
+
▼
|
|
289
|
+
┌─────────────────────┐
|
|
290
|
+
│ Color System │ Match → 15 built-in palettes
|
|
291
|
+
│ Validators │ WCAG contrast + paradigm + 2.7.8-rc.1 contract
|
|
292
|
+
└──────────┬──────────┘
|
|
293
|
+
│
|
|
294
|
+
▼
|
|
295
|
+
┌─────────────────────┐
|
|
296
|
+
│ Template Engine │ Handlebars → 2.7.8-rc.1 CSS (≤300 lines)
|
|
297
|
+
└──────────┬──────────┘
|
|
298
|
+
│
|
|
299
|
+
▼
|
|
300
|
+
themes/<name>.css
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Export Pipeline
|
|
304
|
+
|
|
305
|
+
```
|
|
306
|
+
Markdown file
|
|
307
|
+
│
|
|
308
|
+
▼
|
|
309
|
+
┌─────────────────────────────────────────────┐
|
|
310
|
+
│ Puppeteer (headless Chromium) │
|
|
311
|
+
│ ┌───────────────────────────────────────┐ │
|
|
312
|
+
│ │ Local HTTP Server │ │
|
|
313
|
+
│ │ serves @bytechain.cn/colamd/renderer │ │
|
|
314
|
+
│ │ (same-origin, no CORS) │ │
|
|
315
|
+
│ └──────────────┬────────────────────────┘ │
|
|
316
|
+
│ │ │
|
|
317
|
+
│ createColaMDEditor({ editable: false }) │
|
|
318
|
+
│ applyTheme(name, customCSS?) │
|
|
319
|
+
│ setMarkdown(content) │
|
|
320
|
+
│ ensureAllPluginsRendered() ← mermaid/KaTeX │
|
|
321
|
+
│ │ │
|
|
322
|
+
│ ┌──────────────┴──────────────┐ │
|
|
323
|
+
│ │ buildExportHTML({title}) → .html │ │
|
|
324
|
+
│ │ page.pdf() → .pdf │ │
|
|
325
|
+
│ └─────────────────────────────┘ │
|
|
326
|
+
└─────────────────────────────────────────────┘
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Design Paradigm (2.7.8-rc.1 contract)
|
|
330
|
+
|
|
331
|
+
Full specification: [`templates/theme-paradigm.md`](src/templates/theme-paradigm.md).
|
|
332
|
+
|
|
333
|
+
### Core Principles
|
|
334
|
+
|
|
335
|
+
| Principle | Description |
|
|
336
|
+
|-----------|-------------|
|
|
337
|
+
| **Variable-first** | All colors, fonts, sizes, spacing as CSS custom properties. No raw values in selectors |
|
|
338
|
+
| **Modular** | Theme = variables + minimal selector tweaks. Built-in systems inherit automatically |
|
|
339
|
+
| **Semantic** | `--link-color` not `--color-blue`; `--font-body` not `--font-sans` |
|
|
340
|
+
| **Derivable** | Full theme from 11 seed tokens + 3 font stacks. AI agents modify only Section 1 |
|
|
341
|
+
| **Print-faithful** | Export prints the current window, so screen rules apply as-is; `@media print` only adds `print-color-adjust` |
|
|
342
|
+
| **No dead rules** | CodeMirror 6 has no `#write`, `.ProseMirror`, `<h1>` or `<blockquote>` elements — only `.cm-md-*` line classes |
|
|
343
|
+
|
|
344
|
+
### Contrast Requirements (WCAG 2.1)
|
|
345
|
+
|
|
346
|
+
| Rule ID | Level | Requirement | Threshold |
|
|
347
|
+
|---------|-------|-------------|-----------|
|
|
348
|
+
| CR-01 | MUST | Body text vs background | ≥ 7:1 (AAA) |
|
|
349
|
+
| CR-02 | MUST | Secondary text vs background | ≥ 4.5:1 (AA) |
|
|
350
|
+
| CR-03 | MUST | Dimmed text vs background | ≥ 3:1 (AA large) |
|
|
351
|
+
| CR-04 | MUST | Accent color vs background | ≥ 4.5:1 (AA) |
|
|
352
|
+
| CR-05 | SHOULD | Inline code bg vs background | ≥ 1.5:1 |
|
|
353
|
+
|
|
354
|
+
## Project Structure
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
ColaMD-themes/
|
|
358
|
+
├── skills/
|
|
359
|
+
│ ├── colamd-themes/SKILL.md # Canonical skill source
|
|
360
|
+
│ └── build-skills.sh # Generate agent-specific files
|
|
361
|
+
├── .claude/skills/colamd-themes.skill.md # Claude Code skill
|
|
362
|
+
├── .opencode/skills/colamd-themes/SKILL.md # OpenCode skill
|
|
363
|
+
├── .openclaw/skills/colamd-themes/SKILL.md # OpenClaw skill
|
|
364
|
+
├── .hermes/skills/tools/colamd-themes/ # Hermes skill
|
|
365
|
+
├── .trae/rules/colamd-themes.md # Trae rules
|
|
366
|
+
├── package.json
|
|
367
|
+
├── tsconfig.json
|
|
368
|
+
├── themes/ # Generated CSS themes
|
|
369
|
+
├── src/
|
|
370
|
+
│ ├── cli.ts # CLI entry point
|
|
371
|
+
│ ├── index.ts # Public API exports
|
|
372
|
+
│ ├── models.ts # ThemeStyle / SeedPalette types
|
|
373
|
+
│ ├── generator.ts # Handlebars → CSS pipeline
|
|
374
|
+
│ ├── renderer.ts # Puppeteer HTML/PDF export engine
|
|
375
|
+
│ ├── export-cli.ts # Export CLI commands
|
|
376
|
+
│ ├── theme-store.ts # Theme config persistence (async API)
|
|
377
|
+
│ ├── utils/
|
|
378
|
+
│ │ └── cli-utils.ts # Shared utilities & error handling
|
|
379
|
+
│ ├── color-utils.ts # Color manipulation utilities
|
|
380
|
+
│ ├── contrast.ts # WCAG 2.1 luminance & contrast
|
|
381
|
+
│ ├── validators.ts # Paradigm validation engine
|
|
382
|
+
│ ├── color-systems.ts # 15 predefined seed palettes
|
|
383
|
+
│ ├── docx-style-paradigm.ts # Document style specification
|
|
384
|
+
│ ├── extractors/
|
|
385
|
+
│ │ ├── base.ts # Extractor interface
|
|
386
|
+
│ │ ├── url-extractor.ts # URL → ThemeStyle
|
|
387
|
+
│ │ ├── docx-extractor.ts # DOCX → ThemeStyle
|
|
388
|
+
│ │ └── pdf-extractor.ts # PDF → ThemeStyle
|
|
389
|
+
│ └── templates/
|
|
390
|
+
│ ├── template.css # Paradigm companion CSS
|
|
391
|
+
│ ├── theme-paradigm.md # v4.0 design specification (2.7.8-rc.1 contract)
|
|
392
|
+
│ └── theme-template.hbs # Handlebars CSS template
|
|
393
|
+
└── tests/
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Tech Stack
|
|
397
|
+
|
|
398
|
+
| Component | Library | Purpose |
|
|
399
|
+
|-----------|---------|---------|
|
|
400
|
+
| Runtime | Node.js + TypeScript | ESM modules, strict typing |
|
|
401
|
+
| CLI framework | Commander.js | Argument parsing, subcommands |
|
|
402
|
+
| CSS templating | Handlebars | 2.7.8-rc.1 contract CSS generation |
|
|
403
|
+
| HTML parsing | Cheerio | DOM traversal for URL extraction |
|
|
404
|
+
| CSS parsing | css-tree | CSS rule AST parsing |
|
|
405
|
+
| DOCX parsing | Mammoth | Word → HTML conversion |
|
|
406
|
+
| PDF parsing | pdf-parse | PDF text extraction |
|
|
407
|
+
| HTTP client | Axios | Web page fetching |
|
|
408
|
+
| Browser engine | Puppeteer | Headless Chromium for HTML/PDF export |
|
|
409
|
+
| Editor engine | @bytechain.cn/colamd | CM6-based Markdown renderer (2.7.8-rc.1 contract) |
|
|
410
|
+
| Terminal output | Chalk + Ora | Colored text + spinners |
|
|
411
|
+
|
|
412
|
+
## License
|
|
413
|
+
|
|
414
|
+
MIT
|