@spectratools/graphic-designer-cli 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 spectra-the-bot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # @spectratools/graphic-designer-cli
2
+
3
+ Deterministic visual content generator for code screenshots, terminal shots, flowcharts, infographics, and hero graphics. No browser dependency — renders directly to PNG via [@napi-rs/canvas](https://github.com/nicolo-ribaudo/napi-rs-canvas).
4
+
5
+ ## Features
6
+
7
+ - **Carbon-quality code screenshots** — macOS window chrome, drop shadows, colored surrounds, syntax highlighting via [shiki](https://shiki.matsu.io)
8
+ - **Terminal screenshots** — command + output rendering with the same polished frame
9
+ - **Flowcharts** — auto-layout via [ELK.js](https://github.com/kieler/elkjs) with 5 algorithms (layered, stress, force, radial, box)
10
+ - **Freestyle draw layer** — 8 draw command types for hero graphics and custom compositions
11
+ - **Built-in QA** — automated checks for clipping, contrast, bounds, and content safety
12
+ - **Deterministic output** — same spec + version = same artifact hash
13
+ - **Bundled fonts** — Inter, JetBrains Mono, Space Grotesk (no system font dependency)
14
+ - **6 built-in themes** — dark, light, dracula, github-dark, one-dark, nord
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ pnpm add @spectratools/graphic-designer-cli
20
+ # or global CLI
21
+ pnpm add -g @spectratools/graphic-designer-cli
22
+ ```
23
+
24
+ ## CLI
25
+
26
+ ### Code Screenshot
27
+
28
+ ```bash
29
+ design template code \
30
+ --file ./src/index.ts \
31
+ --language typescript \
32
+ --title "index.ts" \
33
+ --theme dark \
34
+ --show-line-numbers \
35
+ --out ./output/
36
+ ```
37
+
38
+ Options: `--surround-color <hex>`, `--window-controls <macos|bw|none>`, `--scale <1|2|4>`
39
+
40
+ ### Terminal Screenshot
41
+
42
+ ```bash
43
+ design template terminal \
44
+ --command "pnpm test" \
45
+ --output "✓ 63 tests passed" \
46
+ --title "~/spectra-tools" \
47
+ --theme dark \
48
+ --out ./output/
49
+ ```
50
+
51
+ ### Flowchart
52
+
53
+ ```bash
54
+ design template flowchart \
55
+ --nodes "Lint,Test,Build,Deploy" \
56
+ --edges "Lint->Test,Test->Build,Build->Deploy" \
57
+ --algorithm stress \
58
+ --out ./output/
59
+ ```
60
+
61
+ ### Cards
62
+
63
+ ```bash
64
+ design template cards \
65
+ --cards '[{"title":"Lint","body":"Static analysis"},{"title":"Test","body":"Unit + integration"},{"title":"Build","body":"Production bundle"}]' \
66
+ --out ./output/
67
+ ```
68
+
69
+ Options: `--title <text>`, `--subtitle <text>`, `--columns <n>`, `--theme <name>`, `--width <px>`, `--height <px>`
70
+
71
+ ### Render from Spec
72
+
73
+ ```bash
74
+ design render --spec ./design.json --out ./output/
75
+ design qa --in ./output/design-v2-*.png --spec ./output/design-v2-*.spec.json
76
+ design publish --in ./output/design-v2-*.png --target gist
77
+ ```
78
+
79
+ ## Carbon-Style Rendering
80
+
81
+ Code and terminal screenshots use design parameters inspired by [Carbon](https://carbon.now.sh) (MIT):
82
+
83
+ | Parameter | Default | Description |
84
+ |-----------|---------|-------------|
85
+ | `paddingVertical` | 56px | Space above/below code container |
86
+ | `paddingHorizontal` | 56px | Space left/right of code container |
87
+ | `windowControls` | `macos` | Traffic light dots style (`macos`, `bw`, `none`) |
88
+ | `dropShadow` | `true` | Floating card shadow effect |
89
+ | `dropShadowBlurRadius` | 68px | Shadow gaussian blur |
90
+ | `surroundColor` | `rgba(171,184,195,1)` | Background color around the code container |
91
+ | `scale` | 2 | Export scale factor (2x for retina) |
92
+
93
+ Override via CLI flags or the `style` field in DesignSpec elements.
94
+
95
+ ## DesignSpec
96
+
97
+ The core schema supports 8 element types:
98
+
99
+ - `card` — titled content cards
100
+ - `flow-node` — flowchart nodes with labels, sublabels, colors
101
+ - `connection` — edges between nodes with arrowheads and ELK routing
102
+ - `code-block` — syntax-highlighted code with Carbon-style frame
103
+ - `terminal` — command/output with Carbon-style frame
104
+ - `text` — standalone text blocks
105
+ - `shape` — rectangles, circles, rounded-boxes
106
+ - `image` — embedded images
107
+
108
+ Plus a **freestyle draw layer** with 8 draw command types: `rect`, `circle`, `text`, `line`, `bezier`, `path`, `badge`, `gradient-rect`.
109
+
110
+ ### Layout Modes
111
+
112
+ - **auto** — ELK.js layout engine (layered, stress, force, radial, box algorithms)
113
+ - **grid** — column-based grid layout
114
+ - **stack** — vertical or horizontal stack
115
+ - **manual** — explicit x/y coordinates
116
+
117
+ ## Programmatic Usage
118
+
119
+ ```ts
120
+ import {
121
+ parseDesignSpec,
122
+ renderDesign,
123
+ runQa,
124
+ writeRenderArtifacts,
125
+ } from '@spectratools/graphic-designer-cli';
126
+
127
+ const spec = parseDesignSpec({
128
+ version: 2,
129
+ theme: 'dark',
130
+ header: { title: 'My Diagram', align: 'center' },
131
+ elements: [
132
+ { type: 'flow-node', id: 'a', label: 'Start', shape: 'rounded-box', color: '#7c3aed' },
133
+ { type: 'flow-node', id: 'b', label: 'End', shape: 'rounded-box', color: '#059669' },
134
+ { type: 'connection', from: 'a', to: 'b', label: 'next' },
135
+ ],
136
+ layout: { mode: 'auto', algorithm: 'layered' },
137
+ });
138
+
139
+ const render = await renderDesign(spec, { generatorVersion: '0.3.0' });
140
+ const written = await writeRenderArtifacts(render, './output');
141
+ const qa = await runQa({ imagePath: written.imagePath, spec, metadata: written.metadata });
142
+ console.log(qa.pass ? '✅ QA passed' : `❌ ${qa.issueCount} issues`);
143
+ ```
144
+
145
+ ## Output Files
146
+
147
+ `design render` produces three files:
148
+
149
+ ```
150
+ design-v2-g<version>-s<specHash>.png # rendered image
151
+ design-v2-g<version>-s<specHash>.meta.json # metadata (dimensions, hash, QA, scale)
152
+ design-v2-g<version>-s<specHash>.spec.json # normalized validated spec
153
+ ```
154
+
155
+ ## Themes
156
+
157
+ | Theme | Background |
158
+ |-------|------------|
159
+ | `dark` | Deep navy (`#0d1117`) |
160
+ | `light` | Clean white (`#ffffff`) |
161
+ | `dracula` | Classic purple-dark (`#282a36`) |
162
+ | `github-dark` | GitHub's dark mode |
163
+ | `one-dark` | Atom One Dark |
164
+ | `nord` | Arctic blue palette |
165
+
166
+ Custom theme overrides are supported via the `themeOverrides` field in DesignSpec.
167
+
168
+ ## Credits
169
+
170
+ - Code screenshot styling inspired by [Carbon](https://carbon.now.sh) (MIT)
171
+ - Layout engine powered by [ELK.js](https://github.com/kieler/elkjs) (EPL-2.0)
172
+ - Syntax highlighting by [shiki](https://shiki.matsu.io) (MIT)
173
+ - Canvas rendering by [@napi-rs/canvas](https://github.com/nicolo-ribaudo/napi-rs-canvas) (MIT)
174
+
175
+ ## License
176
+
177
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { Cli } from 'incur';
2
+
3
+ declare const cli: Cli.Cli<{}, undefined, undefined>;
4
+
5
+ export { cli };