@phnx-labs/artifacts-cli 0.6.0 → 0.7.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.
package/README.md CHANGED
@@ -1,569 +1,126 @@
1
- # artifacts-cli
1
+ # artifacts
2
2
 
3
- `artifacts-cli` turns agent-authored Markdown into polished, validated, shareable artifacts. The installed binary is `artifacts`.
3
+ **Your agent writes Markdown. Your readers get a polished page.**
4
4
 
5
- The source of truth is Markdown. HTML and PDF are build outputs.
5
+ `artifacts` compiles agent-authored Markdown into self-contained HTML (diagrams,
6
+ charts, drill-downs, diffs, forms) and publishes it as a link you can send.
6
7
 
7
- ## Install
8
+ <picture>
9
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/hero-dark.png">
10
+ <img alt="A short plan.md on the left; on the right, the rendered page with a branded cover and an interactive explorer" src="docs/assets/hero-light.png">
11
+ </picture>
8
12
 
9
- ```bash
10
- bun install
11
- bun run build
12
- npm link
13
- ```
13
+ ## Gallery
14
14
 
15
- Install the bundled agent skill through agents-cli:
15
+ These are real renders of the files in [`examples/`](examples). Each one is a
16
+ single HTML file that works offline, in light and dark.
16
17
 
17
- ```bash
18
- agents skills add gh:phnx-labs/artifacts-cli --names artifacts --agents claude,codex -y
19
- ```
18
+ <picture>
19
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/gallery-dark.png">
20
+ <img alt="Rendered components: SVG diagram, explorer, bar chart, source excerpt, diff, worksheet, stat panels and a harness cover" src="docs/assets/gallery-light.png">
21
+ </picture>
20
22
 
21
- The repository exposes the skill at `skills/artifacts/SKILL.md`; agents-cli copies it and its references into the selected agent version homes.
23
+ ## Why
22
24
 
23
- ## Core Flow
25
+ - **About 90% fewer tokens.** The agent writes content, not CSS. The
26
+ [example plan](examples/plan.md) is 2,391 tokens of Markdown against 25,028
27
+ tokens of equivalent HTML.
28
+ - **One look across every agent.** Claude, Codex and Gemini all render through
29
+ the same design. Set your palette once in `DESIGN.md`.
30
+ - **Components from plain fences.** `explorer`, `bar-chart`, `diff`, `excerpt`
31
+ and `field` take JSON or tables. You don't write any HTML for them.
32
+ - **Built for reading.** Contents rail, collapsible sections, link previews, a
33
+ generated references list, highlights and notes.
34
+ - **Share in one command.** Get a public, org-only or private link with an
35
+ unfurl card. Re-sharing keeps the same URL and saves the old version.
36
+ - **Safe by default.** Embedded HTML and SVG are sanitized. Before publishing,
37
+ the file is scanned for emails and credentials.
24
38
 
25
- Write the Markdown, run one command:
39
+ ## How it works
26
40
 
27
- ```bash
28
- artifacts new plan --out plan.md # scaffold; provenance auto-fills
29
- $EDITOR plan.md # kind + title; plans also need surface
30
- artifacts render plan.md --open # writes, serves on 127.0.0.1, watches, opens
31
- artifacts auth login # once per machine, for the managed endpoint
32
- artifacts share plan.md # publish a public link with a preview card
33
- ```
41
+ **The agent writes the content. The renderer writes the page.** The agent never
42
+ writes component HTML, CSS or JavaScript. It learns the format from the
43
+ `artifacts` skill and `artifacts components --json`. `artifacts check` reports
44
+ mistakes by line number until the source is valid. The renderer then adds the
45
+ layout, theme, components, code highlighting and provenance, and writes one
46
+ self-contained `.html` file.
34
47
 
35
- That is the whole surface. Two more when you want them:
48
+ <img alt="How artifacts-cli works: the agent reads the skill and component catalogue and writes plan.md; artifacts check sends errors back; artifacts render combines the Markdown with components, DESIGN.md and git into one HTML file, which is previewed locally, saved to history, or shared as a link" src="docs/assets/how-it-works.png">
36
49
 
37
- ```bash
38
- artifacts new design # project-wide branding (DESIGN.md)
39
- artifacts check plan.md # validate without rendering
40
- ```
50
+ This is everything the agent writes for an interactive drill-down:
41
51
 
42
- ## Reusable components
52
+ ````markdown
53
+ ---
54
+ kind: visual
55
+ title: Where the dead code is
56
+ summary: Two services carry most of the dead code.
57
+ ---
43
58
 
44
- ```bash
45
- artifacts components # available names and when to use them
46
- artifacts components explorer # input contract and copyable example
47
- artifacts components explorer --json # machine-readable catalogue entry
48
- ```
59
+ ## Story
60
+
61
+ Most of the removable code sits in two services.
49
62
 
50
- Use an `explorer` fence for service → module → evidence, a finding's affected
51
- paths, or stages with supporting detail. Agents fill in JSON; the compiler
52
- supplies expandable rows, optional bars, keyboard navigation, responsive styles
53
- and print expansion. It works as a standalone file, without React, a CDN or a
54
- running agent. Existing `bar-chart`, `excerpt`, `diff` and worksheet `field`
55
- components are discoverable through the same catalogue.
63
+ ## Figure
56
64
 
57
65
  ```explorer
58
- {
59
- "title": "Cleanup candidates",
60
- "metric": {"label": "Estimated removable share", "unit": "%", "max": 100},
61
- "items": [{
62
- "label": "Web", "value": 25, "detail": "2,000 of 8,000 lines (illustrative)",
63
- "children": [{"label": "Legacy editor", "description": "Check remaining callers before removal."}]
64
- }]
65
- }
66
+ { "title": "Removable code", "metric": {"label": "Removable", "unit": "%", "max": 100},
67
+ "items": [{ "label": "Web", "value": 25 }, { "label": "API", "value": 10 }] }
66
68
  ```
67
-
68
- Strings are plain text. Source links belong to their item as
69
- `sources: [{"label": "Evidence", "href": "https://…"}]` (or `#section`). Unknown
70
- fields, missing scales and out-of-range values are errors. See the
71
- [complete example](examples/explorer.md) and [authoring contract](skills/artifacts/references/authoring.md).
72
-
73
- The registry/data approach follows `phnx-labs/harness-ui`; its React components
74
- are not imported. Its chart drill-down emits a live-agent callback, whereas an
75
- artifact must carry the breakdown with it. This component uses native HTML
76
- `details` and the existing artifact theme; it does not execute agent actions.
77
-
78
- ## Origin and revision history
79
-
80
- The header shows the document type, a clickable Created/Updated timestamp,
81
- and compact device/session copy controls. Clicking the device copies its full
82
- recorded context: canonical name, available address, OS/architecture, agent CLI
83
- version, and session. Clicking the short session copies the complete UUID.
84
- There is no origin dropdown or visible table of missing fields. Clipboard failure
85
- exposes selectable text instead of claiming success. Resume remains in Details.
86
-
87
- The header also carries **Share** and **Favorite** actions. Share is owner-only
88
- first (`artifacts share <id> --visibility me`): served by `render --open` it
89
- publishes through the loopback server and copies the resulting link; on a plain
90
- file:// page it copies the exact command to run; on an already-published page it
91
- degrades to copying the page's own URL instead of re-sharing. Favorite toggles the
92
- star through the same loopback channel (persisted to the local store and reflected
93
- after reload), or copies `artifacts favorite <id>` where no server is present.
94
- Both address the artifact by its store id, so no local path enters the page.
95
-
96
- New scaffolds preserve `sessionId`, `harnessVersion`, `hostPlatform`, and
97
- `hostArch`, and `hostAddress` when this device has an exact-match Tailscale entry
98
- in the local Agents device registry. No DNS lookup or guessed address is used.
99
- Anonymized defaults omit addresses as well as session/device identity; explicit
100
- metadata remains embedded in the HTML, so do not publish private addresses.
101
- The version comes from `AGENTS_RUN_VERSION`, not whichever binary is
102
- currently installed. Any already-recorded origin owns the entire origin tuple:
103
- missing fields remain unrecorded rather than being borrowed from today's renderer.
104
- Legacy short-only sessions are labeled honestly; the full UUID cannot be invented.
105
-
106
- Every successful Markdown compile to an output path participates in local history:
69
+ ````
107
70
 
108
71
  ```bash
109
- artifacts render plan.md # first saved version: Created just now
110
- artifacts render plan.md # unchanged render: no new version
111
- artifacts history plan.md # list local snapshots
112
- artifacts history plan.md --open 1 # view saved HTML; never overwrite source
113
- artifacts history plan.md --json
114
- ```
115
-
116
- Changing source content, embedded assets, design, or visible metadata creates the
117
- next revision. Merely touching the source mtime does not. Click the timestamp for
118
- History; entries use Created/Updated dates, not internal revision codes. It shows
119
- the latest ten saved entries and copies an open command using the artifact ID,
120
- so an agent does not need to keep track of a source path or maintain a version field.
121
- Run that command on the rendering device. Complete history remains available via
122
- the CLI.
123
-
124
- History lives privately in `~/.agents/artifact-history/` (override with
125
- `ARTIFACTS_HISTORY_DIR`). Identity follows the canonical source path, not the output
126
- filename; output variants share a history, symlink aliases resolve together, and
127
- moving the source or rendering on another device starts separate history.
128
- Snapshots retain previous content until explicitly removed; they are not pruned
129
- automatically. They are never embedded in, or uploaded alongside, the current HTML.
130
- The shared page carries only revision numbers/times and local open commands.
131
-
132
- Favorites live beside the history in `favorites.json` under the same directory.
133
- `artifacts favorite <source.md|artifact-id>` toggles the star (the header star on a
134
- served page writes here too), and `artifacts list [--favorites] [--json]` enumerates
135
- everything the local store knows — id, title, source path, first/last saved dates,
136
- favorite marker.
137
-
138
- Validation/storage failures do not replace the previous output. Concurrent renders
139
- serialize their history writes, and repeated unchanged renders reuse the revision.
140
- Direct `renderMarkdown()` previews without an output path and imported raw HTML
141
- do not create Markdown revision history.
142
-
143
- 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. `project` is never invented: it auto-fills only when the checkout identifies a real project (a `~/.agents/projects/` entry, or the git remote's repository name), and stays empty — with a warning from `artifacts check` — when the file lives somewhere that says nothing about what it is about, like the durable artifact home.
144
-
145
- **Authoring in the durable home (`~/.agents/artifacts/`) — set project, repository, and harness explicitly.** That directory is not a project checkout, so auto-fill has nothing to detect: `project` stays empty (with a warning) and there is no repository or agent context to read. Declare them in frontmatter so the render still identifies itself — an explicit `project` / `repository` / `harness` always wins and is used verbatim. When `project` is absent the renderer falls back to the repository's bare name, and the project links to `projectUrl` (HTTP(S) only) or, absent that, the repository's own GitHub page.
146
-
147
- Additional frontmatter carries into the artifact header:
148
-
149
- The built-in cover shows the creating harness's logo as its background artwork,
150
- a brand-colored palette, a linked project, and the title. The creator line has
151
- one small logo and the recorded model. The human's profile sits at the top left,
152
- opposite the project link. The product name stays
153
- in the logo's accessible label and tooltip, not repeated in visible text. Missing
154
- models are not guessed. Freshness lives in the header; the reader has no duplicate
155
- Details block. Full provenance remains available in printed copies. The same mark
156
- becomes the tab's favicon, embedded in the HTML for offline use. Known harness
157
- aliases resolve to the same mark; unknown harnesses use a neutral cover and
158
- terminal glyph.
159
-
160
- When `avatar` is an https URL the cover's first row shows it as the human's picture
161
- beside their name (with no referrer sent to the image host). `artifacts new`
162
- pre-fills it from `AGENTS_ACTOR_AVATAR`, which agents-cli sets from the Phoenix
163
- ID session signed in on the device; a published artifact is scaffolded without
164
- it, like the other anonymized provenance.
165
-
166
- When `project` exactly matches a registered `agents projects` ID, the page uses
167
- its `linear.name` as the readable label and its `linear.url` when available.
168
- An explicit `projectUrl` wins, otherwise the repository is the link target.
169
- IDs and authored names are never title-cased or stripped of dots/dashes.
170
- The full project name wraps on the page; only its tab-title prefix is bounded
171
- to 24 Unicode code points. Author from the subject checkout using
172
- `artifacts new visual --project <id> --out <absolute-path>` to keep this context
173
- when storing the source outside the checkout.
174
-
175
- `artifacts new` records the real creation instant (except with `--blank`).
176
- Precise `created`/`updated` timestamps display relative ages and exact-time
177
- tooltips. Date-only values remain absolute. Without `updated`, the source
178
- file's modification time is labeled **Source updated**. Opening or re-rendering
179
- the page does not reset its creation time.
180
-
181
- `render --open` already watches the source through the local preview server.
182
- Updated previews and hosted renders offer **New version available · Reload**;
183
- they never reload automatically beneath unfinished input. `--no-serve` opens
184
- a static file snapshot, which cannot watch its source on its own.
185
-
186
- ```yaml
187
- project: agents-cli
188
- projectUrl: https://github.com/phnx-labs/agents-cli # optional; HTTP(S) only. Links the project name.
189
- context: session context
190
- header: Phoenix Labs / Engineering
191
- footer: Internal planning artifact
192
- repository: phnx-labs/agents-cli
193
- branch: main
194
- tracking: "#1757"
195
- status: implementing
196
- harness: codex
197
- agent: gpt-5
198
- human: Ada Lovelace
199
- avatar: https://lh3.googleusercontent.com/a/example=s96-c # optional; https only. The human's picture in the cover's first row.
200
- host: yosemite-s1
201
- session: fcd64597
202
- date: "2026-08-03" # date-only, absolute
203
- created: "2026-08-01T09:00:00Z" # optional ISO 8601 — shown as "Created"
204
- updated: "2026-08-03T14:30:00Z" # optional ISO 8601 — shown as "Updated"
205
- facts:
206
- - 3 delivery tracks
207
- - 2 repositories
208
- links:
209
- - https://github.com/phnx-labs/agents-cli/pull/1914
210
- - url: https://linear.app/phnx/issue/RUSH-2119/title
211
- label: RUSH-2119
212
- - https://jira.example.com/browse/ENG-42
72
+ artifacts render cleanup.md --open # live preview, re-renders on save
73
+ artifacts share cleanup.md # https://share.getrush.ai/<you>/where-the-dead-code-is
213
74
  ```
214
75
 
215
- `links` is multipurpose: any related ticket, PR, issue, or design URL from any
216
- tracker. Each entry is a plain `https://` string or `{url, label?}`. Labels
217
- auto-derive for GitHub PRs/issues, Jira browse keys, and Linear-style `KEY-N`
218
- paths when omitted. They render under a **Related** label as the hero's only
219
- chip row. When the host is a known tracker (GitHub, Linear, Jira/Atlassian,
220
- Notion, GitLab, Bitbucket, Asana, Trello, Slack, Figma) the chip shows an
221
- offline brand mark; other hosts try a remote favicon and drop it if load fails.
76
+ The `.html` file is written next to its Markdown, usually in
77
+ `.agents/artifacts/<date>/` inside your repository. Every render is also saved
78
+ to local history, so earlier versions can be reopened.
222
79
 
223
80
  ## Commands
224
81
 
225
- Ten commands (`share` spans three rows). Everything else is a flag or subcommand on one of them.
226
-
227
- | Command | Purpose |
228
- | --- | --- |
229
- | `artifacts new <plan\|report\|visual\|worksheet\|design> [--out file] [--project name] [--blank] [--stdout]` | Scaffolds an artifact and pre-fills detectable provenance. When the target lands under a committed `.agents/artifacts/` tree it pre-fills anonymized provenance instead (`human: author`, `host: fleet-worker`, no session id) — that directory is published. `project` is detected only when cwd is genuinely inside the project's own checkout (a known `~/.agents/projects/` entry or the git remote's repo name); inside the durable artifact home (`~/.agents/artifacts/`) detection stays empty rather than inventing a name — pass `--project` or fill the frontmatter, and `artifacts check` warns until you do. `--blank` leaves every field empty (an explicit `--project` still pins the project); `--stdout` prints the skeleton without writing; `design` writes a starter `DESIGN.md`; `worksheet` generates a `worksheet_id`. |
230
- | `artifacts check file.md` | Validates frontmatter metadata, required sections, asset paths, and embedded HTML/SVG safety. |
231
- | `artifacts render file.md [--out file] [--open] [--no-serve] [--publish] [--no-link-previews]` | Renders Markdown to self-contained HTML next to the source. Local by default: `--publish` additionally publishes it to a durable **private** managed URL and prints the URL plus a terminal QR (every render used to publish, which filled the managed quota with intermediate iterations; `ARTIFACTS_NO_PUBLISH=1` still overrides `--publish`, and the `--open` watch loop re-renders on save but never publishes). `--open` serves on 127.0.0.1, watches the Markdown, and shows it in your browser; `--no-serve` keeps file:// behavior. Embeds the Markdown source for recovery. |
232
- | `artifacts answers <ws.md> [--from file.json] [--json] [--pending]` | Reads or merges a `worksheet`'s answers. No flag prints a filled/pending table; `--json` emits `id → {label, value, state}`; `--pending` filters to pending fields or worksheets; `--from` merges an exported answers file back into the `.md` (id-matched, dirty-only, atomic). A directory scans for worksheets and lists per-file pending counts. |
233
- | `artifacts notes <file.md\|file.html> [--from sidecar.json] [--json]` | Reads the adjacent `<basename>.notes.json` review sidecar as a table or JSON, or imports an `artifacts.notes.v1` sidecar. |
234
- | `artifacts auth <login\|whoami\|logout>` | Signs this machine in to Phoenix ID, which is what lets `artifacts share` publish to the managed endpoint with no Cloudflare setup. Optional — everything else works signed out. |
235
- | `artifacts share file.md [--slug slug] [--visibility level] [--unlisted] [--protected] [--no-cover] [--no-qr] [--expire spec] [--label text] [--meta k=v] [--json]` | Renders Markdown when needed and publishes it — managed when signed in, otherwise your own R2/Worker. Public by default, with an OG cover. The published page's footer carries a small QR of the exact share URL (including the `?k=` key on `--protected`), so a desktop reader can hand the page to a phone; `--no-qr` skips it. The URL slug is derived from the artifact title (filename for title-less files); `--slug` overrides it. Re-sharing the same title updates the same URL and keeps the replaced version as a revision. See [Sharing](#sharing). |
236
- | `artifacts share <list\|revisions\|edit\|visibility\|open\|status\|analytics>` | Inspect and manage what you have published: the listing, retained revisions, label/metadata edits, in-place visibility changes, and an owner-authenticated browser open. |
237
- | `artifacts share <setup\|join\|update>` | Provision your own Cloudflare endpoint, adopt an existing one, or redeploy the current Worker template to one you already have (`--check` answers "is a deploy due?" without credentials). |
238
- | `artifacts unshare <targets...>` | Alias of `artifacts share delete`. Takes a page down along with its OG cover and retained revisions, and verifies it `404`s before reporting success. |
239
- | `artifacts favorite <source.md\|artifact-id> [--on\|--off] [--json]` | Toggles an artifact's favorite flag in the local store (the header star on a served page writes the same store). |
240
- | `artifacts list [--favorites] [--json]` | Lists artifacts known to this device — id, title, source, created/updated dates, favorite marker. `--favorites` filters to starred. |
241
-
242
- ### Internal commands
243
-
244
- These work but are deliberately absent from `--help` — they are maintenance tools,
245
- not part of the authoring flow, and may change without a major version. Each also
246
- answers to an underscore spelling (`_estimate`, `_decompile`, `_pdf`).
247
-
248
- | Command | Purpose |
249
- | --- | --- |
250
- | `artifacts estimate file.md` | Counts Markdown and equivalent rendered HTML with `o200k_base`, then reports the authoring-token reduction without writing output. |
251
- | `artifacts decompile file.html --out file.md` | Recovers Markdown from HTML generated by `artifacts render`. |
252
- | `artifacts pdf file.md --out file.pdf [--layout document\|poster]` | Exports a paginated Letter document or one content-sized poster through headless Chromium. Requires `playwright`, which is an optional dependency and is not installed by default. |
253
-
254
- ## Design And Fonts
255
-
256
- `DESIGN.md` is the single style source. Artifact-specific fields live in each Markdown file's frontmatter.
257
-
258
- Define both palettes and layout defaults once. The reader always starts with the operating-system preference, regardless of `theme.default`. The theme button cycles through explicit light/dark overrides and back to System; only reader overrides persist. System mode follows live OS changes. `artifact.printTheme` still 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.
259
-
260
- ```yaml
261
- theme:
262
- default: system
263
- themes:
264
- light:
265
- background: "#faf9f6"
266
- surface: "#ffffff"
267
- surfaceAlt: "#f2f4f0"
268
- line: "#e2e6df"
269
- text: "#1a1c1a"
270
- muted: "#5c655c"
271
- accent: "#4d7c0f"
272
- accentAlt: "#0e7490"
273
- warn: "#b45309"
274
- danger: "#dc2626"
275
- dark:
276
- background: "#0a0a0a"
277
- surface: "#111312"
278
- surfaceAlt: "#161a18"
279
- line: "#26302a"
280
- text: "#e7ece8"
281
- muted: "#8b938c"
282
- accent: "#a3e635"
283
- accentAlt: "#5ad6c0"
284
- warn: "#f5c451"
285
- danger: "#ff6b6b"
286
- layout:
287
- contentWidth: 980
288
- pagePadding: 24
289
- mobilePagePadding: 16
290
- heroTop: 40
291
- heroBottom: 28
292
- sectionSpacing: 36
293
- figureSpacing: 22
294
- panelPadding: 16
295
- footerSpacing: 64
296
- printMargin: 24
297
- artifact:
298
- printTheme: light
299
- ```
300
-
301
- 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.
302
-
303
- Optional `header` and `footer` frontmatter strings add document chrome to HTML and PDF without repeating those values in the Markdown body. The hero is work-first: `status` is a kicker badge, freeform `facts` are a quiet monoline, `links` render under a **Related** label as the only chip row, and provenance is one unlabeled line (`repository` · `branch` · optional `tracking` · combined harness/model display · `human` · `host` · `session` · `date`). An `owner/repo`-shaped `repository` value links to GitHub. Harness + model merge into one display name (e.g. `grok` + `grok-4.5` → **Grok 4.5**). The `human` field is seeded by `artifacts new` from the Git identity (`user.name`, falling back to the OS username) — except under a committed `.agents/artifacts/` tree, where it is seeded as `author` and no host or session is filled, because that directory is published.
304
-
305
- The default families — **Inter** (body and display) and **JetBrains Mono**
306
- (mono) — are bundled in the package and inlined as `@font-face` data URIs, so a
307
- render is self-contained for type even on a machine that does not have those
308
- faces installed. A `DESIGN.md` `fonts.files` path still wins when it resolves.
309
-
310
- ```yaml
311
- fonts:
312
- body: Inter
313
- mono: JetBrains Mono
314
- display: Inter
315
- files:
316
- Inter: ./fonts/Inter.woff2 # optional override
317
- ```
318
-
319
- Font paths resolve relative to the artifact. If an override path is missing, the
320
- bundled face is used when the family is Inter or JetBrains Mono; otherwise
321
- `artifacts render` warns and emits a fallback stack.
322
-
323
- For fonts stored **outside** the project — a shared company font cache, say — add
324
- the directory to `~/.artifacts/config.json` once. Every later `render` picks it up:
325
-
326
- ```json
327
- {
328
- "fonts": { "dirs": ["/Library/Fonts/Corporate"] }
329
- }
330
- ```
331
-
332
- ## Token Estimate
333
-
334
- `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 and inlined `@font-face` data URIs so those payloads are 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.
335
-
336
- The committed [representative plan](examples/plan.md) measures:
337
-
338
- | Source | Tokens | Difference from HTML |
339
- | --- | ---: | ---: |
340
- | Markdown authored by the agent | 2,391 | 22,637 fewer |
341
- | Equivalent rendered HTML | 25,028 | baseline |
342
-
343
- That example is a **90.4% 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 — the command is absent from `--help` but still runs.
344
-
345
- ## Links
346
-
347
- Write links as ordinary Markdown. Every outbound `http(s)` link in the body renders as a **link pill**: the source's brand mark (GitHub, Linear, Jira, Notion, GitLab, Bitbucket, Asana, Trello, Slack, Figma) or its favicon, followed by the link text, in a bordered, clickable container. No HTML to hand-write.
348
-
349
- Body links render as pills. A numbered citation (`[[1]](url)`) shows the host with the number as a superscript. Every outbound pill gets a click preview card whose title, description, and site name are fetched once at render time (5s timeout, 512 KB cap, cached for a week in the artifact history directory) and embedded as JSON outside the body, so previews never change the body revision. The card's Open link, or a modifier-click on the pill, goes to the page; a pill whose target could not be fetched opens directly. Only public hosts are fetched, on every redirect hop, so a render never pulls a loopback or private-network page into an artifact; set `ARTIFACTS_LINK_PREVIEWS_ALLOW_PRIVATE=1` for intranet documentation. `--no-link-previews` or `ARTIFACTS_NO_LINK_PREVIEWS=1` skips the fetch for offline renders.
350
-
351
- ```markdown
352
- See [the merge guard](https://github.com/phnx-labs/agents-cli/pull/1914) for context.
353
- Ticket: [RUSH-2513](https://linear.app/phnx/issue/RUSH-2513/version-drift)
354
- https://github.com/phnx-labs/artifacts-cli
355
- ```
356
-
357
- A pasted bare URL is labelled instead of printed in full — `PR #1914`, `RUSH-2513`, or the host — the same short form the frontmatter `links` chips use.
358
-
359
- These stay plain anchors, because a pill would fight the surrounding element or misrepresent the link:
360
-
361
- | Link | Why it stays plain |
82
+ | Command | What it does |
362
83
  | --- | --- |
363
- | In a heading, `code`, or a `<pre>` block | The pill would break the type. |
364
- | In-page anchor (`#section`) | Not an outbound source. |
365
- | `mailto:` and `tel:` | Not a web source. |
366
- | Relative path (`./notes.html`) | Not an outbound source. |
367
- | An image wrapped in a link | The image is the content, not a citation. |
84
+ | `artifacts new <plan\|report\|visual\|worksheet\|design>` | Scaffold an artifact with provenance filled in |
85
+ | `artifacts render file.md [--open]` | Compile to self-contained HTML, optionally serve and watch |
86
+ | `artifacts check file.md` | Validate without rendering |
87
+ | `artifacts components [name]` | List components and their input contracts |
88
+ | `artifacts share file.md [--visibility me\|org] [--unlisted]` | Publish a link (managed, or your own Cloudflare) |
89
+ | `artifacts share list \| revisions \| visibility \| open` | Manage what you've published |
90
+ | `artifacts unshare <slug>` | Take a page down and verify it 404s |
91
+ | `artifacts answers ws.md` | Read or merge worksheet answers |
92
+ | `artifacts list [--favorites]` | Artifacts known to this machine |
93
+
94
+ Run `artifacts <command> --help` for the workflow and flags. Theming,
95
+ components, embedded HTML classes, sharing, self-hosting the Worker and local
96
+ history are all covered in the [full reference](docs/reference.md).
368
97
 
369
- Brand marks are bundled, so a known host needs no network. Unknown hosts fall back to a remote favicon that removes itself if it cannot load.
370
-
371
- ## Reading Surfaces
372
-
373
- Five reader affordances are generated from the artifact itself. An agent writes nothing extra for any of them.
374
-
375
- **References appendix.** Every outbound link in the body is collected into a numbered `References` section at the end — deduped, in order of first appearance, each row carrying the source's mark, its label, and its host. A bare URL lists under its short label (`PR #1914`), not the raw address. Writing your own `References`, `Sources`, `Bibliography`, or `Citations` heading suppresses the generated one.
376
-
377
- **Contents rail.** The table of contents lists sections and their subsections. At viewports wider than 1380px it becomes a fixed side rail that tracks the section you are reading; below that it stays inline at the top with subsections hidden. Heading ids are unique even when two subsections share a title, so every rail entry addresses its own heading. A heading inside an embedded panel or figure is that block's caption and is deliberately left out of the rail.
378
-
379
- **Collapsible sections.** Every `##`/`###` heading gets a small toggle after its title — a native `<button>` with `aria-expanded`/`aria-controls`, reachable and operable from the keyboard, with a visible focus ring. Collapsing an `##` section takes its `###` subsections with it; collapsing a `###` subsection leaves its parent and siblings alone. Everything starts expanded and stays that way for a reader with JavaScript disabled — collapsing is a pure client-side enhancement, never a server-side omission. A reader's choices are remembered per browser, per document (not synced to an account), and survive a re-render of the same file as long as a heading's text — and so its id — stays the same. Navigating to a heading, an in-page link, or an anchor tag placed right before or after a heading reopens every collapsed section on the way to it, including a same-page click back to a section you just re-collapsed. The contents rail adds **Collapse all** / **Expand all** once there is more than one section. Printing, and a corrupt or unavailable `localStorage`, both fail open to the full expanded document.
380
-
381
- **Read count.** Each artifact keeps a per-browser read count in `localStorage`, shown in the document header (`first read`, then `2 reads`). It is scoped to the artifact's own URL and title, so two artifacts published under the same title do not share a counter. Nothing is sent anywhere.
382
-
383
- **Reader review.** Selecting text always copies it and opens **Copied · Highlight · Note** without clearing the browser selection. **Highlight** explicitly saves the range. **Note** saves it and opens a textarea; clicking an existing highlight opens the same quote/note popover with Copy and Remove. Local state uses the artifact's URL-and-title identity. With `render --open`, notes also autosave after roughly 600 ms to `<basename>.notes.json` beside the Markdown, and a re-render surfaces a **New version available · Reload** chip. The chip is driven by a single canonical `<meta name="artifacts-content-hash">` marker — a hash over the whole rendered document, so a metadata-only change (a new `updated` stamp, a changed project) is noticed too. The renderer emits that marker itself, so a hosted standalone share detects updates over HTTP(S) the same way the loopback `--open` watch does; the poll runs only over HTTP(S), trusts only a successful same-origin response, and pauses while the tab is hidden. It stays **manual** — the chip appears rather than reloading under the reader — so an unsaved worksheet field or scroll position survives until you choose to reload. A `file://` page has no server to re-serve it, so on-disk changes cannot be watched there and the chip stays hidden. Static/shared pages never post feedback off-box.
384
-
385
- Themes already follow the reader's system preference and switch live when the OS theme changes, unless the reader picks one explicitly with the in-page toggle.
386
-
387
- ## Hosted Review Threads
388
-
389
- On a host that serves collaboration, the same artifact also carries human-to-human review threads: select a sentence, press **Comment**, and the thread appears in a right-side rail with replies, resolve/reopen, and edit/delete on your own comments. A second reader sees every change live, without reloading. Below 980px the rail becomes a dismissible bottom sheet instead of a squeezed column. Markers and thread controls are keyboard reachable — <kbd>Enter</kbd> or <kbd>Space</kbd> on a marker opens its thread, <kbd>Escape</kbd> closes the rail and returns focus to the marker — and arriving comments are announced through an `aria-live` region.
390
-
391
- Nothing about the host is baked into the file. The page asks its **own origin** whether collaboration exists:
392
-
393
- ```
394
- GET /__collab/context?share=<encoded normalized path>
395
- GET /__collab/threads?share=<path>[&after=<cursor>]
396
- POST /__collab/threads { share, anchor, body }
397
- POST /__collab/threads/:threadId/replies { share, body }
398
- PATCH /__collab/comments/:commentId { share, body } | { share, deleted: true }
399
- PATCH /__collab/threads/:threadId { share, status: "open" | "resolved" }
400
- GET /__collab/events?share=<path> (text/event-stream)
401
- ```
402
-
403
- There is no endpoint, token, or account id in the rendered HTML. If discovery is absent or answers anything other than an explicit read grant, the page stays exactly what it was — `file://`, a loopback dev server, and a BYO bucket keep their local highlights and notes and show no collaboration chrome at all. Mutations carry an `Idempotency-Key` that is reused across retries, and the client deduplicates stream and catch-up deliveries by event cursor, so a reconnect replays a missed change exactly once.
404
-
405
- Every response and every event carries a whole thread, and **each thread carries the `cursor` it was last written at**. That is what makes ordering safe without a lock: the client applies a snapshot only when its cursor is newer than the one it already holds for that thread, so a slow write response overtaken by a teammate's newer change cannot revert it.
406
-
407
- **Anchors and revisions.** A comment stores the same range vocabulary local highlights use — `{ revision, quote, section, start: { anchor, offset }, end: { anchor, offset } }`. The canonical revision is `<meta name="artifacts-body-revision">`: the SHA-256 of the `<article class="artifact-body">` inner HTML and nothing else, so re-rendering with a new `updated` date, session id, or header does not invalidate a single comment. Renderer, Worker, and viewer all read that one value rather than each deriving their own. A thread repaints only when both anchors resolve to exactly one block each *and* the quoted text still matches; otherwise nothing is painted and the thread is listed as **From an earlier revision** rather than decorating the wrong sentence.
408
-
409
- **Visibility.** The rail labels a share **Only me**, **Company**, **Anyone with link**, or **Public**, mapped from the context's `me`, `org`, `unlisted`/`private`, and `public`. A company share is never shown as public, and an unrecognized visibility is left unlabeled rather than guessed.
410
-
411
- ## Embedded HTML And SVG
412
-
413
- 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.
414
-
415
- 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.
416
-
417
- ```html
418
- <section class="artifact-grid artifact-grid-2">
419
- <article class="artifact-panel">Markdown input</article>
420
- <article class="artifact-panel">HTML and PDF output</article>
421
- </section>
422
-
423
- <figure class="artifact-figure artifact-figure-diagram artifact-figure-wide">
424
- <svg class="artifact-diagram" viewBox="0 0 1200 420" role="img" aria-label="Compilation flow">
425
- <rect x="40" y="80" width="360" height="220" rx="12"></rect>
426
- <line x1="400" y1="190" x2="800" y2="190"></line>
427
- <rect x="800" y="80" width="360" height="220" rx="12"></rect>
428
- </svg>
429
- <figcaption>Markdown is compiled once into self-contained outputs.</figcaption>
430
- </figure>
431
- ```
432
-
433
- The supported layout classes are:
434
-
435
- | Class | Use |
436
- | --- | --- |
437
- | `artifact-grid` with `artifact-grid-2` or `artifact-grid-3` | Responsive two- or three-column layout. |
438
- | `artifact-panel` | One item inside a grid. |
439
- | `artifact-stat`, `artifact-stat-value`, `artifact-stat-label` | Headline metrics. |
440
- | `artifact-figure` | Responsive image or SVG with an optional `figcaption`. |
441
- | `artifact-figure-diagram` | Dark diagram surface in both themes. |
442
- | `artifact-figure-wide` | Wide SVG; scrolls inside its figure on narrow screens. |
443
- | `artifact-figure-tall` | Centers and caps a portrait diagram instead of stretching it to article width. |
444
- | `artifact-image`, `artifact-diagram` | Responsive raster-image and inline-SVG sizing. |
445
- | `artifact-callout`, `artifact-legend` | A load-bearing note or a figure legend. |
446
- | `artifact-tag`, `artifact-tag-accent` | Compact labels inside panels. |
447
-
448
- 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.
449
-
450
- 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.
451
-
452
- HTML is the output. PDF lives on the internal `artifacts pdf` command, where
453
- `--layout document` is the default for plans and reports and produces tagged,
454
- paginated Letter output, and `--layout poster` produces one 1200-pixel-wide page
455
- sized to the rendered content, appropriate for `visual` artifacts and
456
- infographics. Both modes use the `artifact.printTheme` palette and run in
457
- isolated headless Chromium. To print an HTML artifact yourself, `artifacts render
458
- file.md --open` and use the browser's own print dialog.
459
-
460
- ## Sharing
461
-
462
- A share is a single object behind a Cloudflare Worker in front of R2. There are
463
- two ways to reach one, and you pick by signing in or not.
464
-
465
- ### Managed — sign in, publish, done
98
+ ## Install
466
99
 
467
100
  ```bash
468
- artifacts auth login # device-code sign-in in your browser
469
- artifacts share plan.md # https://share.getrush.ai/<handle>/<slug>
101
+ npm i -g @phnx-labs/artifacts-cli # installs the `artifacts` command (Node 20+)
102
+ artifacts auth login # optional, enables managed sharing
470
103
  ```
471
104
 
472
- No Cloudflare account, bucket, or write token. The URL namespace is your handle,
473
- the local-part of the signed-in email (`--handle <name>` publishes under a
474
- different one; the first account to write a handle claims it). The session lives
475
- in `~/.artifacts/phoenix-session.json`; `artifacts auth logout` clears this
476
- machine only, and `PHOENIX_ID_BASE` points the CLI at a different backend.
477
-
478
- ### Bring your own Cloudflare
105
+ Give your agents the authoring skill through
106
+ [agents-cli](https://github.com/phnx-labs/agents-cli):
479
107
 
480
108
  ```bash
481
- artifacts share setup --token "$CLOUDFLARE_API_TOKEN" --account "$CLOUDFLARE_ACCOUNT_ID"
482
- artifacts share join https://artifacts-share.example.workers.dev --token "$WRITE_TOKEN"
109
+ agents skills add gh:phnx-labs/artifacts-cli --names artifacts --agents claude,codex -y
483
110
  ```
484
111
 
485
- `setup` provisions the bucket, its lifecycle rule, and the Worker, then mints a
486
- write token; `join` adopts an endpoint someone else provisioned. Both persist to
487
- `~/.artifacts/config.json`. For ephemeral agents, inject `ARTIFACTS_SHARE_TOKEN`
488
- (or `SHARE_WRITE_TOKEN`) instead of storing one. Signed in and want BYO anyway?
489
- `ARTIFACTS_SHARE_BACKEND=byo`.
490
-
491
- ### Visibility
492
-
493
- A bare `artifacts share <file>` is **public**: listed in your gallery, with an
494
- Open Graph cover so the link unfurls into a preview card in Slack, iMessage,
495
- Twitter, and Discord. Narrow it with one flag:
112
+ PDF export is optional and needs `playwright`.
496
113
 
497
- | Flag | What the link is |
498
- | --- | --- |
499
- | *(none)* | `public` — listed, OG cover, indexable |
500
- | `--visibility me` | owner-only; anyone else gets a login gate (needs a session) |
501
- | `--visibility org` | everyone at your signed-in email domain (needs a session) |
502
- | `--unlisted` (alias `--private`) | a capability URL: hidden from the gallery, `noindex`, **still world-readable by anyone holding it** |
503
- | `--protected` | token-gated: the URL carries a secret `?k=` key and GET returns `404` without it |
504
-
505
- `me` and `org` are refused on a BYO endpoint — there is no signed-in owner to
506
- gate on. `--no-cover` skips the OG image; hidden visibilities never get one.
507
- Published HTML pages embed a footer QR of the exact share URL by default — on
508
- `--protected` pages it encodes the full `?k=` URL, since the page `404`s
509
- without it — and `--no-qr` opts out.
510
-
511
- Links expire in 30 days by default so an accidental publish decays; `--expire
512
- never` for a permanent one. Before every publish the file body, the label, and
513
- every `--meta` value are scanned for email addresses and credential-shaped
514
- strings, and the publish is refused unless you pass `--force` — all three are
515
- world-readable on a public page.
516
-
517
- ### Managing what you published
114
+ ## Develop
518
115
 
519
116
  ```bash
520
- artifacts share list --all # every page, including hidden ones
521
- artifacts share revisions q3-plan # prior versions kept on republish
522
- artifacts share edit q3-plan --label "Q3" # retitle without republishing
523
- artifacts share visibility q3-plan me # re-scope in place, same URL
524
- artifacts share open q3-plan # open it signed in as the owner
525
- artifacts unshare q3-plan # take it down, cover and revisions too
117
+ bun install
118
+ bun run test
119
+ scripts/build.sh
526
120
  ```
527
121
 
528
- Republishing an existing slug keeps the version it replaces as a retained
529
- revision (`--no-revision` opts out). A takedown is only reported as successful
530
- once a follow-up GET returns `404` — R2's delete is idempotent, so `{"ok":true}`
531
- alone proves nothing.
532
-
533
- ### The Worker
122
+ Releases go through `scripts/release.sh`. See [CHANGELOG.md](CHANGELOG.md).
534
123
 
535
- **Operator storage policy.** `share setup` and `share update` accept
536
- `--unlimited-storage '<json>'`, with exact `emails` and `domains` arrays:
537
-
538
- ```sh
539
- artifacts share update --unlimited-storage '{"emails":[],"domains":["example.org"]}'
540
- ```
124
+ ## License
541
125
 
542
- The allowlist uses only the email returned by Phoenix authentication or retained
543
- in a server-signed identity cookie. Entries are trimmed and case-insensitive;
544
- domains match exactly, with no subdomain, wildcard, Gmail dot, or plus-alias
545
- expansion. There are no built-in allowed identities. An allowed identity can
546
- publish beyond the aggregate 200 MiB / 150-page free limits, including when its
547
- existing usage ledger is full. Accounting continues for pages and retained
548
- revisions. The 20 MiB request-body cap and 60 publishes per hour still apply.
549
- Missing/unknown ledger plans remain free; a ledger plan or client identity header
550
- cannot grant unlimited storage.
551
-
552
- The operator's endpoint config persists this policy as `share.unlimitedStorage`.
553
- Every subsequent update reapplies it, including template-current updates, and
554
- uploads include it in the `SHARE_UNLIMITED_STORAGE` Worker secret binding.
555
- When the deploying host has no local policy, uploads discover and inherit the
556
- existing Worker binding. A failed settings read stops the upload, except when
557
- Cloudflare confirms the Worker does not exist. Pass `'{"emails":[],"domains":[]}'` to revoke all
558
- exceptions. `--check` reports a supplied policy change without saving or deploying
559
- it. Missing or malformed Worker bindings grant no exceptions. This policy does
560
- not change link expiration or the bucket's lifecycle rules.
561
-
562
- `artifacts share setup` and `artifacts share update` deploy the Worker in
563
- `src/lib/share/worker-template.ts`, which owns visibility enforcement, the
564
- gallery, revision retention, OG card rendering, and Phoenix bearer verification.
565
- `artifacts share status` reports whether your endpoint's deployed template is
566
- current; `artifacts share update --check --update-json` answers the same
567
- question as JSON without touching Cloudflare. The release script runs that check
568
- after publishing and redeploys the managed Worker when the shipped template
569
- changed, so what is deployed never drifts from what was released.
126
+ [Apache-2.0](LICENSE)