@phnx-labs/artifacts-cli 0.1.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 (52) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +16 -0
  3. package/README.md +223 -0
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.js +239 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/setup.d.ts +5 -0
  8. package/dist/commands/setup.js +40 -0
  9. package/dist/commands/setup.js.map +1 -0
  10. package/dist/commands/share.d.ts +20 -0
  11. package/dist/commands/share.js +75 -0
  12. package/dist/commands/share.js.map +1 -0
  13. package/dist/lib/config.d.ts +18 -0
  14. package/dist/lib/config.js +24 -0
  15. package/dist/lib/config.js.map +1 -0
  16. package/dist/lib/design.d.ts +52 -0
  17. package/dist/lib/design.js +168 -0
  18. package/dist/lib/design.js.map +1 -0
  19. package/dist/lib/embedded-html.d.ts +12 -0
  20. package/dist/lib/embedded-html.js +192 -0
  21. package/dist/lib/embedded-html.js.map +1 -0
  22. package/dist/lib/fonts.d.ts +12 -0
  23. package/dist/lib/fonts.js +58 -0
  24. package/dist/lib/fonts.js.map +1 -0
  25. package/dist/lib/icons.d.ts +2 -0
  26. package/dist/lib/icons.js +21 -0
  27. package/dist/lib/icons.js.map +1 -0
  28. package/dist/lib/pdf.d.ts +13 -0
  29. package/dist/lib/pdf.js +66 -0
  30. package/dist/lib/pdf.js.map +1 -0
  31. package/dist/lib/render.d.ts +12 -0
  32. package/dist/lib/render.js +346 -0
  33. package/dist/lib/render.js.map +1 -0
  34. package/dist/lib/share-provision.d.ts +31 -0
  35. package/dist/lib/share-provision.js +83 -0
  36. package/dist/lib/share-provision.js.map +1 -0
  37. package/dist/lib/share-worker.d.ts +1 -0
  38. package/dist/lib/share-worker.js +66 -0
  39. package/dist/lib/share-worker.js.map +1 -0
  40. package/dist/lib/share.d.ts +22 -0
  41. package/dist/lib/share.js +130 -0
  42. package/dist/lib/share.js.map +1 -0
  43. package/dist/lib/templates.d.ts +19 -0
  44. package/dist/lib/templates.js +196 -0
  45. package/dist/lib/templates.js.map +1 -0
  46. package/dist/lib/tokens.d.ts +10 -0
  47. package/dist/lib/tokens.js +24 -0
  48. package/dist/lib/tokens.js.map +1 -0
  49. package/dist/lib/validate.d.ts +12 -0
  50. package/dist/lib/validate.js +123 -0
  51. package/dist/lib/validate.js.map +1 -0
  52. package/package.json +42 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2026-08-03
4
+
5
+ First public release.
6
+
7
+ - One-step API: `artifacts render <file.md>` writes HTML next to the source, `--format html,pdf` adds PDF in the same run through headless Chromium, and `compile` remains as an alias. The `template` frontmatter field is inferred from `kind`, and provenance (project, repository, branch, harness, agent, human, host, session, date) auto-fills at render time from the Git checkout and agent environment — hand-written Markdown gets full provenance chips with only `kind` + `title` declared.
8
+ - Provenance chips: the `human` field names the person behind the run (auto-seeded from the Git identity), the repo chip links to its GitHub repository when `owner/repo`-shaped, and the harness chip shows an inline monochrome brand mark (Claude, Codex/OpenAI, Gemini, Cursor, Copilot via CC0 simple-icons; other harnesses get a generic terminal glyph).
9
+ - Default artifact design: green-tinted neutral palettes with explicit `surfaceAlt` and `line` palette keys, optional `warn`/`danger` semantic hues wired into `artifact-callout-warn`/`artifact-callout-danger` variants, cyan `accentAlt`, monospace metadata chrome (kicker, chips, contents, table headers, captions, footer), auto-numbered `h2` sections, inline-code pills, soft-tinted tags, and radius 10.
10
+ - `examples/showcase.md` exercises every embedded layout class for design review, with a documented SVG diagram recipe (tinted concept boxes, dashed connectors) and skill guidance that encourages rich figures for structured concepts.
11
+ - `artifacts estimate <file.md>` for exact `o200k_base` Markdown-versus-rendered-HTML token counts, plus validated `DESIGN.md` layout spacing and PDF margin controls.
12
+ - Bundled `artifacts` agent skill for Markdown-first authoring, safe HTML/SVG layout, headless visual QA, PDF export, and explicit sharing.
13
+ - Documented, sanitized embedded HTML/SVG layout vocabulary with responsive raster, wide-diagram, tall-diagram, grid, panel, stat, callout, and legend styles.
14
+ - `artifacts pdf --layout poster` for a single content-sized page, tagged PDF output, and print-aware figure pagination without opening the user's browser.
15
+ - Validation errors for custom style blocks, inline style attributes, and unsupported embedded HTML classes so rendering defects are surfaced at the Markdown source line.
16
+ - System-aware light/dark themes, an accessible theme toggle, optional document headers and footers, and explicit headless PDF behavior.
17
+ - First-class artifact provenance header, numbered section navigation, metadata validation, and Git/agent context seeding.
18
+ - Fixed remote raster images and relative links being stripped or embedded, kept HTML examples in Markdown code out of safety diagnostics, and expanded the safe inline SVG primitive set.
19
+ - Fixed inline SVG diagrams with blank lines so geometry and case-sensitive attributes render correctly, and contained wide tables on mobile.
20
+ - Initial `artifacts` CLI: Markdown artifact templates, validation, HTML compilation, decompile, PDF export, local setup, and R2/Worker sharing.
package/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+
4
+ Copyright 2026 Phoenix Labs
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,223 @@
1
+ # artifacts-cli
2
+
3
+ `artifacts-cli` turns agent-authored Markdown into polished, validated, shareable artifacts. The installed binary is `artifacts`.
4
+
5
+ The source of truth is Markdown. HTML and PDF are build outputs.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ bun install
11
+ bun run build
12
+ npm link
13
+ ```
14
+
15
+ Install the bundled agent skill through agents-cli:
16
+
17
+ ```bash
18
+ agents skills add gh:phnx-labs/artifacts-cli --names artifacts --agents claude,codex -y
19
+ ```
20
+
21
+ The repository exposes the skill at `skills/artifacts/SKILL.md`; agents-cli copies it and its references into the selected agent version homes.
22
+
23
+ ## Core Flow
24
+
25
+ Write the Markdown, run one command:
26
+
27
+ ```bash
28
+ # one-time machine setup (fonts, share endpoint)
29
+ artifacts setup
30
+
31
+ # every artifact: author the source, then render it
32
+ $EDITOR plan.md # frontmatter needs only kind + title; provenance auto-fills
33
+ artifacts render plan.md # writes plan.html next to the source
34
+ artifacts render plan.md --format html,pdf --layout poster
35
+ ```
36
+
37
+ Helpers when you want them:
38
+
39
+ ```bash
40
+ artifacts new plan --out plan.md # scaffold the frontmatter + sections from the template
41
+ artifacts init design # project-wide branding (DESIGN.md)
42
+ artifacts check plan.md # validate without rendering
43
+ artifacts estimate plan.md # Markdown-vs-HTML authoring token cost
44
+ artifacts share plan.md # publish a shareable link
45
+ ```
46
+
47
+ Provenance (project, repository, branch, harness, agent, human, host, session, date) fills automatically from the current Git checkout and agent environment at render time; any value you declare in frontmatter wins. Additional frontmatter carries into the artifact header:
48
+
49
+ ```yaml
50
+ project: agents-cli
51
+ context: session context
52
+ header: Phoenix Labs / Engineering
53
+ footer: Internal planning artifact
54
+ repository: phnx-labs/agents-cli
55
+ branch: main
56
+ tracking: "#1757"
57
+ status: implementing
58
+ harness: codex
59
+ agent: gpt-5
60
+ human: Ada Lovelace
61
+ host: yosemite-s1
62
+ session: fcd64597
63
+ date: "2026-08-03"
64
+ facts:
65
+ - 3 delivery tracks
66
+ - 2 repositories
67
+ ```
68
+
69
+ ## Commands
70
+
71
+ | Command | Purpose |
72
+ | --- | --- |
73
+ | `artifacts render file.md [--format html\|pdf\|html,pdf] [--out file] [--layout document\|poster]` | Renders Markdown to self-contained HTML next to the source (default), and/or to PDF through headless Chromium. Embeds the Markdown source for decompile. |
74
+ | `artifacts setup` | Creates `~/.artifacts/config.json`, records font directories/share endpoint options, and reports missing fonts. |
75
+ | `artifacts init design` | Creates starter `DESIGN.md`. |
76
+ | `artifacts template <plan|report|visual>` | Writes a fillable Markdown template. |
77
+ | `artifacts new <plan|report|visual> --out file.md` | Creates a working artifact Markdown file and pre-fills detectable provenance metadata. |
78
+ | `artifacts check file.md` | Validates frontmatter metadata, required sections, asset paths, and embedded HTML/SVG safety. |
79
+ | `artifacts estimate file.md` | Counts Markdown and equivalent rendered HTML with `o200k_base`, then reports the authoring-token reduction without writing output. |
80
+ | `artifacts preview file.md` | Renders and opens the HTML. |
81
+ | `artifacts pdf file.md --out file.pdf [--layout document\|poster]` | Exports a paginated Letter document or one content-sized poster through headless Chromium without opening the user's browser. |
82
+ | `artifacts decompile file.html --out file.md` | Recovers Markdown from HTML generated by `artifacts render`. |
83
+ | `artifacts share file.md` | Renders Markdown when needed and publishes through the configured R2/Worker endpoint. |
84
+
85
+ ## Design And Fonts
86
+
87
+ `DESIGN.md` is the single style source. Artifact-specific fields live in each Markdown file's frontmatter.
88
+
89
+ Define both palettes and layout defaults once. `theme.default: system` follows the operating-system preference until the reader uses the in-page toggle; that explicit reader choice is remembered and wins over later defaults. `artifact.printTheme` selects the static palette used for PDF and print output. A legacy `colors` block is migrated to `themes.dark` with a warning so existing brand colors are not discarded.
90
+
91
+ ```yaml
92
+ theme:
93
+ default: system
94
+ themes:
95
+ light:
96
+ background: "#faf9f6"
97
+ surface: "#ffffff"
98
+ surfaceAlt: "#f2f4f0"
99
+ line: "#e2e6df"
100
+ text: "#1a1c1a"
101
+ muted: "#5c655c"
102
+ accent: "#4d7c0f"
103
+ accentAlt: "#0e7490"
104
+ warn: "#b45309"
105
+ danger: "#dc2626"
106
+ dark:
107
+ background: "#0a0a0a"
108
+ surface: "#111312"
109
+ surfaceAlt: "#161a18"
110
+ line: "#26302a"
111
+ text: "#e7ece8"
112
+ muted: "#8b938c"
113
+ accent: "#a3e635"
114
+ accentAlt: "#5ad6c0"
115
+ warn: "#f5c451"
116
+ danger: "#ff6b6b"
117
+ layout:
118
+ contentWidth: 980
119
+ pagePadding: 24
120
+ mobilePagePadding: 16
121
+ heroTop: 40
122
+ heroBottom: 28
123
+ sectionSpacing: 36
124
+ figureSpacing: 22
125
+ panelPadding: 16
126
+ footerSpacing: 64
127
+ printMargin: 24
128
+ artifact:
129
+ printTheme: light
130
+ ```
131
+
132
+ Layout numbers are pixels. They control the content measure, horizontal page padding, hero rhythm, heading spacing, figure spacing, panel padding, footer separation, and repeated browser-print/document-PDF margins. Invalid or out-of-range values produce a `DESIGN.md` warning and use the documented starter value. Poster PDFs keep zero outer page margin and apply `printMargin` inside the single poster page.
133
+
134
+ Optional `header` and `footer` frontmatter strings add document chrome to HTML and PDF without repeating those values in the Markdown body. In the provenance row, an `owner/repo`-shaped `repository` value renders as a link to its GitHub repository, and the `harness` value carries an inline brand mark for known harnesses. The `human` field names the person behind the run and is seeded automatically by `artifacts new` from the Git identity (`user.name`, falling back to the OS username).
135
+
136
+ Fonts can be referenced by family name or inlined from files:
137
+
138
+ ```yaml
139
+ fonts:
140
+ body: Inter
141
+ mono: JetBrains Mono
142
+ display: Inter
143
+ files:
144
+ Inter: ./fonts/Inter.woff2
145
+ ```
146
+
147
+ If a font file is missing, `artifacts render` warns and emits a fallback stack. `artifacts setup --fonts-dir ./fonts` adds a directory that font files can be resolved from.
148
+
149
+ ## Token Estimate
150
+
151
+ `artifacts estimate` measures the Markdown source against equivalent self-contained HTML generated in memory. It excludes the compiler-only embedded recovery copy of the Markdown so that payload is not counted as agent-authored HTML. It uses the exact `o200k_base` tokenizer and names that encoding in its output; model-family token counts can differ.
152
+
153
+ The committed [representative plan](examples/plan.md) measures:
154
+
155
+ | Source | Tokens | Difference from HTML |
156
+ | --- | ---: | ---: |
157
+ | Markdown authored by the agent | 1,274 | 3,489 fewer |
158
+ | Equivalent rendered HTML | 4,763 | baseline |
159
+
160
+ That example is a **73.3% authoring-token reduction** when the alternative is having the agent emit the same self-contained HTML. It includes complete metadata, ordinary Markdown, a table, embedded layout HTML, inline SVG, theme CSS, responsive rules, print rules, and the theme toggle. Run `artifacts estimate examples/plan.md` to reproduce it.
161
+
162
+ ## Embedded HTML And SVG
163
+
164
+ Use Markdown for prose, lists, tables, and code. When Markdown cannot express a figure or comparison, write semantic HTML directly in the Markdown file. The renderer sanitizes it, applies the active `DESIGN.md` theme, and keeps the output responsive.
165
+
166
+ Content inside an embedded HTML block is parsed as HTML, not Markdown. Use `<p>`, `<strong>`, `<code>`, and other semantic tags inside the block instead of Markdown emphasis or code syntax.
167
+
168
+ ```html
169
+ <section class="artifact-grid artifact-grid-2">
170
+ <article class="artifact-panel">Markdown input</article>
171
+ <article class="artifact-panel">HTML and PDF output</article>
172
+ </section>
173
+
174
+ <figure class="artifact-figure artifact-figure-diagram artifact-figure-wide">
175
+ <svg class="artifact-diagram" viewBox="0 0 1200 420" role="img" aria-label="Compilation flow">
176
+ <rect x="40" y="80" width="360" height="220" rx="12"></rect>
177
+ <line x1="400" y1="190" x2="800" y2="190"></line>
178
+ <rect x="800" y="80" width="360" height="220" rx="12"></rect>
179
+ </svg>
180
+ <figcaption>Markdown is compiled once into self-contained outputs.</figcaption>
181
+ </figure>
182
+ ```
183
+
184
+ The supported layout classes are:
185
+
186
+ | Class | Use |
187
+ | --- | --- |
188
+ | `artifact-grid` with `artifact-grid-2` or `artifact-grid-3` | Responsive two- or three-column layout. |
189
+ | `artifact-panel` | One item inside a grid. |
190
+ | `artifact-stat`, `artifact-stat-value`, `artifact-stat-label` | Headline metrics. |
191
+ | `artifact-figure` | Responsive image or SVG with an optional `figcaption`. |
192
+ | `artifact-figure-diagram` | Dark diagram surface in both themes. |
193
+ | `artifact-figure-wide` | Wide SVG; scrolls inside its figure on narrow screens. |
194
+ | `artifact-figure-tall` | Centers and caps a portrait diagram instead of stretching it to article width. |
195
+ | `artifact-image`, `artifact-diagram` | Responsive raster-image and inline-SVG sizing. |
196
+ | `artifact-callout`, `artifact-legend` | A load-bearing note or a figure legend. |
197
+ | `artifact-tag`, `artifact-tag-accent` | Compact labels inside panels. |
198
+
199
+ Inline SVG supports gradients, markers, filters, clip paths, masks, symbols, text paths, SVG images, and SMIL animation of geometry, transforms, motion, or paint attributes. Local raster images referenced by `src` are embedded as data URLs so the generated HTML remains self-contained; explicit `https:` image sources remain remote.
200
+
201
+ Custom `<style>` blocks, inline `style` attributes, scripts, event handlers, executable embeds, and unlisted classes are errors. Run `artifacts check file.md` to get the source line and replace custom CSS with the supported classes.
202
+
203
+ `--layout document` is the default PDF mode for plans and reports. It produces tagged, paginated Letter output. `--layout poster` produces one 1200-pixel-wide page sized to the rendered content, which is appropriate for `visual` artifacts and infographics. Both modes use the `artifact.printTheme` palette and run in isolated headless Chromium.
204
+
205
+ ## Sharing
206
+
207
+ Sharing uses a Cloudflare Worker in front of R2. The local config lives at `~/.artifacts/config.json`.
208
+
209
+ Provision a new endpoint:
210
+
211
+ ```bash
212
+ artifacts share setup --token "$CLOUDFLARE_API_TOKEN" --account "$CLOUDFLARE_ACCOUNT_ID"
213
+ ```
214
+
215
+ Join an existing endpoint:
216
+
217
+ ```bash
218
+ artifacts share join https://artifacts-share.example.workers.dev --token "$WRITE_TOKEN"
219
+ ```
220
+
221
+ The share write token is stored in `~/.artifacts/config.json` for simplicity. For ephemeral agents, set `ARTIFACTS_SHARE_TOKEN` instead.
222
+
223
+ Published links are public and unlisted. They are not private. Use `--expire 30d` for sensitive artifacts and `artifacts share delete <url|key>` to remove a share.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,239 @@
1
+ #!/usr/bin/env node
2
+ import { mkdirSync, writeFileSync } from 'node:fs';
3
+ import { dirname, join, resolve } from 'node:path';
4
+ import { spawn } from 'node:child_process';
5
+ import { Command } from 'commander';
6
+ import chalk from 'chalk';
7
+ import { exportPdf, parsePdfLayout } from './lib/pdf.js';
8
+ import { compileArtifact, decompileHtml } from './lib/render.js';
9
+ import { estimateArtifactTokens } from './lib/tokens.js';
10
+ import { detectArtifactContext, STARTER_DESIGN, templateFor } from './lib/templates.js';
11
+ import { validateMarkdown } from './lib/validate.js';
12
+ import { runSetup } from './commands/setup.js';
13
+ import { shareAnalytics, shareDelete, shareJoin, sharePublish, shareSetup, shareStatus } from './commands/share.js';
14
+ const program = new Command();
15
+ function printDiagnostics(diagnostics) {
16
+ for (const diagnostic of diagnostics) {
17
+ const label = diagnostic.level === 'error' ? chalk.red('error') : chalk.yellow('warning');
18
+ const where = diagnostic.line ? `:${diagnostic.line}` : '';
19
+ console.error(`${label}${where} ${diagnostic.message}`);
20
+ }
21
+ }
22
+ function defaultHtmlOut(input) {
23
+ return join(process.cwd(), '.artifacts', input.replace(/.*\//, '').replace(/\.[^.]+$/, '') + '.html');
24
+ }
25
+ function defaultOutFor(input, ext) {
26
+ // Markdown sources render next to the source; HTML inputs keep the .artifacts
27
+ // default so normalization never clobbers the input file.
28
+ if (!/\.html?$/i.test(input))
29
+ return input.replace(/\.[^.]+$/, '') + ext;
30
+ return join(process.cwd(), '.artifacts', input.replace(/.*\//, '').replace(/\.[^.]+$/, '') + ext);
31
+ }
32
+ function openPath(path) {
33
+ const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
34
+ const args = process.platform === 'win32' ? ['/c', 'start', '', path] : [path];
35
+ const child = spawn(cmd, args, { detached: true, stdio: 'ignore' });
36
+ child.unref();
37
+ }
38
+ program
39
+ .name('artifacts')
40
+ .description('Compile Markdown artifacts into polished HTML, PDF, and shareable static links.')
41
+ .version('0.1.0');
42
+ program
43
+ .command('setup')
44
+ .description('Create ~/.artifacts/config.json and check local rendering prerequisites.')
45
+ .option('--fonts-dir <dir>', 'directory containing local font files')
46
+ .option('--share-base-url <url>', 'existing share endpoint base URL')
47
+ .option('--share-token <token>', 'existing share write token')
48
+ .action(runSetup);
49
+ const init = program.command('init').description('Create starter project files.');
50
+ init
51
+ .command('design')
52
+ .description('Create starter DESIGN.md.')
53
+ .option('--out <file>', 'output file', 'DESIGN.md')
54
+ .action((opts) => {
55
+ writeFileSync(opts.out, STARTER_DESIGN);
56
+ console.log(`${chalk.bold('wrote')} ${opts.out}`);
57
+ });
58
+ program
59
+ .command('template')
60
+ .description('Write a fillable artifact template.')
61
+ .argument('<kind>', 'plan, report, or visual')
62
+ .option('--out <file>', 'output file')
63
+ .action((kind, opts) => {
64
+ if (!['plan', 'report', 'visual'].includes(kind))
65
+ throw new Error(`Unknown template kind: ${kind}`);
66
+ const out = opts.out || `${kind}.template.md`;
67
+ writeFileSync(out, templateFor(kind));
68
+ console.log(`${chalk.bold('wrote')} ${out}`);
69
+ });
70
+ program
71
+ .command('new')
72
+ .description('Create a working Markdown artifact from a built-in template.')
73
+ .argument('<kind>', 'plan, report, or visual')
74
+ .requiredOption('--out <file>', 'output Markdown file')
75
+ .action((kind, opts) => {
76
+ if (!['plan', 'report', 'visual'].includes(kind))
77
+ throw new Error(`Unknown artifact kind: ${kind}`);
78
+ writeFileSync(opts.out, templateFor(kind, detectArtifactContext()));
79
+ console.log(`${chalk.bold('wrote')} ${opts.out}`);
80
+ });
81
+ program
82
+ .command('check')
83
+ .alias('validate')
84
+ .description('Validate frontmatter, assets, and embedded HTML/SVG safety.')
85
+ .argument('<file.md>')
86
+ .action((file) => {
87
+ const result = validateMarkdown(file);
88
+ printDiagnostics(result.diagnostics);
89
+ if (!result.ok)
90
+ process.exitCode = 1;
91
+ else
92
+ console.log(chalk.green('ok'));
93
+ });
94
+ program
95
+ .command('estimate')
96
+ .description('Compare Markdown authoring tokens with equivalent rendered HTML tokens.')
97
+ .argument('<file.md>')
98
+ .action(async (file) => {
99
+ const result = await estimateArtifactTokens(file);
100
+ printDiagnostics(result.diagnostics);
101
+ if (result.diagnostics.some((diagnostic) => diagnostic.level === 'error')) {
102
+ process.exitCode = 1;
103
+ return;
104
+ }
105
+ console.log(`${chalk.bold('encoding')} ${result.encoding}`);
106
+ console.log(`${chalk.bold('markdown')} ${result.markdownTokens.toLocaleString('en-US')} tokens`);
107
+ console.log(`${chalk.bold('html')} ${result.htmlTokens.toLocaleString('en-US')} tokens`);
108
+ console.log(`${chalk.bold('reduction')} ${result.avoidedTokens.toLocaleString('en-US')} tokens (${result.reductionPercent.toFixed(1)}%)`);
109
+ });
110
+ program
111
+ .command('render')
112
+ .alias('compile')
113
+ .description('Render Markdown to HTML next to the source (default), normalize HTML, or export PDF.')
114
+ .argument('<file.md|file.html>')
115
+ .option('--out <file>', 'output file (single format only)')
116
+ .option('--format <formats>', 'output formats: html, pdf (comma-separated)', 'html')
117
+ .option('--layout <layout>', 'PDF layout: document or poster', parsePdfLayout, 'document')
118
+ .action(async (file, opts) => {
119
+ const formats = [...new Set(opts.format.split(',').map((format) => format.trim().toLowerCase()))];
120
+ const unknown = formats.filter((format) => !['html', 'pdf'].includes(format));
121
+ if (unknown.length)
122
+ throw new Error(`Unknown format: ${unknown.join(', ')}; use html and/or pdf.`);
123
+ if (opts.out && formats.length > 1)
124
+ throw new Error('--out requires a single --format.');
125
+ const isHtmlInput = /\.html?$/i.test(file);
126
+ let htmlSource = file;
127
+ let compiled = false;
128
+ const compileOnce = async (out) => {
129
+ const result = await compileArtifact(file, out);
130
+ printDiagnostics(result.diagnostics);
131
+ if (result.diagnostics.some((diagnostic) => diagnostic.level === 'error')) {
132
+ process.exitCode = 1;
133
+ return false;
134
+ }
135
+ htmlSource = out;
136
+ compiled = true;
137
+ console.log(`${chalk.bold('wrote')} ${out}`);
138
+ return true;
139
+ };
140
+ for (const format of formats) {
141
+ if (format === 'html') {
142
+ if (!(await compileOnce(opts.out || defaultOutFor(file, '.html'))))
143
+ return;
144
+ }
145
+ else {
146
+ // PDF renders from the compiled HTML; compile once, naming the
147
+ // intermediate so it is never a silent side effect.
148
+ if (!compiled && !isHtmlInput && !(await compileOnce(defaultOutFor(file, '.html'))))
149
+ return;
150
+ const out = opts.out || defaultOutFor(file, '.pdf');
151
+ await exportPdf(htmlSource, out, { layout: opts.layout });
152
+ console.log(`${chalk.bold('wrote')} ${out}`);
153
+ }
154
+ }
155
+ });
156
+ program
157
+ .command('preview')
158
+ .description('Compile if needed and open the rendered HTML.')
159
+ .argument('<file.md|file.html>')
160
+ .option('--out <file>', 'output HTML file')
161
+ .action(async (file, opts) => {
162
+ const out = opts.out || defaultOutFor(file, '.html');
163
+ const result = await compileArtifact(file, out);
164
+ printDiagnostics(result.diagnostics);
165
+ if (result.diagnostics.some((diagnostic) => diagnostic.level === 'error')) {
166
+ process.exitCode = 1;
167
+ return;
168
+ }
169
+ openPath(resolve(out));
170
+ console.log(`${chalk.bold('opened')} ${out}`);
171
+ });
172
+ program
173
+ .command('decompile')
174
+ .description('Recover Markdown from HTML generated by artifacts compile.')
175
+ .argument('<file.html>')
176
+ .requiredOption('--out <file>', 'output Markdown file')
177
+ .action((file, opts) => {
178
+ const markdown = decompileHtml(file);
179
+ mkdirSync(dirname(opts.out), { recursive: true });
180
+ writeFileSync(opts.out, markdown);
181
+ console.log(`${chalk.bold('wrote')} ${opts.out}`);
182
+ });
183
+ program
184
+ .command('pdf')
185
+ .description('Export through headless Chromium without opening the user browser. Run artifacts setup to check readiness.')
186
+ .argument('<file.md|file.html>')
187
+ .requiredOption('--out <file>', 'output PDF file')
188
+ .option('--layout <layout>', 'PDF layout: document or poster', parsePdfLayout, 'document')
189
+ .action(async (file, opts) => {
190
+ const outHtml = /\.md$/i.test(file) ? defaultHtmlOut(file) : file;
191
+ if (/\.md$/i.test(file)) {
192
+ const result = await compileArtifact(file, outHtml);
193
+ printDiagnostics(result.diagnostics);
194
+ if (result.diagnostics.some((diagnostic) => diagnostic.level === 'error')) {
195
+ process.exitCode = 1;
196
+ return;
197
+ }
198
+ }
199
+ await exportPdf(outHtml, opts.out, { layout: opts.layout });
200
+ console.log(`${chalk.bold('wrote')} ${opts.out}`);
201
+ });
202
+ const share = program.command('share').description('Publish static artifacts with the R2/Worker share model.');
203
+ share
204
+ .argument('[file]', 'file to publish')
205
+ .option('--slug <slug>', 'URL slug')
206
+ .option('--expire <spec>', 'expiry such as 30d, 12h, or 2026-08-01')
207
+ .option('--github-user <user>', 'URL namespace')
208
+ .option('--json', 'emit JSON')
209
+ .action(async (file, opts) => {
210
+ if (!file) {
211
+ share.help();
212
+ return;
213
+ }
214
+ await sharePublish(file, opts);
215
+ });
216
+ share.command('setup').description('Provision Cloudflare R2 + Worker and save ~/.artifacts/config.json.')
217
+ .option('--token <token>', 'Cloudflare API token')
218
+ .option('--account <id>', 'Cloudflare account id')
219
+ .option('--worker <name>', 'Worker name')
220
+ .option('--bucket <name>', 'R2 bucket name')
221
+ .option('--domain <host>', 'custom hostname already mapped in Cloudflare')
222
+ .option('--analytics-token <token>', 'Cloudflare Web Analytics token')
223
+ .action(shareSetup);
224
+ share.command('join').description('Use an existing share endpoint.')
225
+ .argument('<baseUrl>')
226
+ .option('--token <token>', 'write token')
227
+ .action(shareJoin);
228
+ share.command('status').description('Show configured share endpoint.').action(shareStatus);
229
+ share.command('analytics').description('Show Cloudflare Web Analytics dashboard link.').action(shareAnalytics);
230
+ share.command('delete').description('Delete a published artifact by URL or key.').argument('<url|key>').action(shareDelete);
231
+ program
232
+ .command('doctor')
233
+ .description('Check local artifact prerequisites.')
234
+ .action(() => runSetup({}));
235
+ program.parseAsync().catch((error) => {
236
+ console.error(`${chalk.red('error')} ${error instanceof Error ? error.message : String(error)}`);
237
+ process.exitCode = 1;
238
+ });
239
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,c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AAqC,CAAC;KAClD,MAAM,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9B,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC5C,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACjG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function runSetup(opts: {
2
+ fontsDir?: string;
3
+ shareBaseUrl?: string;
4
+ shareToken?: string;
5
+ }): Promise<void>;
@@ -0,0 +1,40 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ import chalk from 'chalk';
4
+ import { configPath, updateConfig } from '../lib/config.js';
5
+ import { loadDesign } from '../lib/design.js';
6
+ import { resolveFonts } from '../lib/fonts.js';
7
+ export async function runSetup(opts) {
8
+ const cfg = updateConfig((current) => ({
9
+ ...current,
10
+ fonts: {
11
+ ...(current.fonts ?? {}),
12
+ dirs: opts.fontsDir ? [...new Set([...(current.fonts?.dirs ?? []), resolve(opts.fontsDir)])] : current.fonts?.dirs ?? [],
13
+ },
14
+ share: opts.shareBaseUrl || opts.shareToken
15
+ ? {
16
+ ...(current.share ?? {}),
17
+ ...(opts.shareBaseUrl ? { baseUrl: opts.shareBaseUrl.replace(/\/+$/, '') } : {}),
18
+ ...(opts.shareToken ? { writeToken: opts.shareToken } : {}),
19
+ }
20
+ : current.share,
21
+ }));
22
+ const design = loadDesign();
23
+ const fonts = resolveFonts(design.design, process.cwd(), cfg);
24
+ console.log(`${chalk.bold('config')} ${configPath()}`);
25
+ console.log(`${chalk.bold('design')} ${design.path ?? 'default'}`);
26
+ console.log(`${chalk.bold('share')} ${cfg.share?.baseUrl ? chalk.green(cfg.share.baseUrl) : chalk.dim('not configured')}`);
27
+ const playwright = await import('playwright').catch(() => null);
28
+ if (playwright) {
29
+ const chromiumPath = playwright.chromium.executablePath();
30
+ console.log(`${chalk.bold('pdf')} ${existsSync(chromiumPath) ? chalk.green('chromium ready') : chalk.yellow('playwright installed, chromium browser missing')}`);
31
+ }
32
+ else {
33
+ console.log(`${chalk.bold('pdf')} ${chalk.yellow('playwright missing')}`);
34
+ }
35
+ for (const dir of cfg.fonts?.dirs ?? [])
36
+ console.log(`${chalk.bold('font-dir')} ${existsSync(dir) ? chalk.green(dir) : chalk.yellow(`${dir} missing`)}`);
37
+ for (const warning of [...design.warnings, ...fonts.warnings])
38
+ console.log(`${chalk.yellow('warning')} ${warning}`);
39
+ }
40
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAuE;IACpG,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACrC,GAAG,OAAO;QACV,KAAK,EAAE;YACL,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;YACxB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAA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C"}
@@ -0,0 +1,20 @@
1
+ export declare function shareSetup(opts: {
2
+ token?: string;
3
+ account?: string;
4
+ worker?: string;
5
+ bucket?: string;
6
+ domain?: string;
7
+ analyticsToken?: string;
8
+ }): Promise<void>;
9
+ export declare function sharePublish(file: string, opts: {
10
+ slug?: string;
11
+ expire?: string;
12
+ githubUser?: string;
13
+ json?: boolean;
14
+ }): Promise<void>;
15
+ export declare function shareJoin(baseUrl: string, opts: {
16
+ token?: string;
17
+ }): void;
18
+ export declare function shareStatus(): void;
19
+ export declare function shareAnalytics(): void;
20
+ export declare function shareDelete(slugOrUrl: string): Promise<void>;