@phnx-labs/artifacts-cli 0.6.1 → 0.8.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,583 +1,127 @@
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
- ```
49
-
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.
56
-
57
- Try the [component gallery](examples/components/gallery.md) to open an explorer,
58
- compare values, expand a diff, inspect a pinned source excerpt and edit a saved
59
- worksheet answer. Each example includes its authoring input:
59
+ ## Story
60
60
 
61
- ```bash
62
- artifacts render examples/components/gallery.md --open
63
- ```
61
+ Most of the removable code sits in two services.
64
62
 
65
- Components inherit the artifact's `DESIGN.md` palette automatically, including
66
- light and dark mode. Supply content, not per-component colors or CSS. The gallery
67
- has its own sample [palette](examples/components/DESIGN.md) beside the Markdown;
68
- without one, the renderer uses the default design. Code wells and syntax colors
69
- intentionally use the renderer's fixed dark code palette.
63
+ ## Figure
70
64
 
71
65
  ```explorer
72
- {
73
- "title": "Cleanup candidates",
74
- "metric": {"label": "Estimated removable share", "unit": "%", "max": 100},
75
- "items": [{
76
- "label": "Web", "value": 25, "detail": "2,000 of 8,000 lines (illustrative)",
77
- "children": [{"label": "Legacy editor", "description": "Check remaining callers before removal."}]
78
- }]
79
- }
66
+ { "title": "Removable code", "metric": {"label": "Removable", "unit": "%", "max": 100},
67
+ "items": [{ "label": "Web", "value": 25 }, { "label": "API", "value": 10 }] }
80
68
  ```
81
-
82
- Strings are plain text. Source links belong to their item as
83
- `sources: [{"label": "Evidence", "href": "https://…"}]` (or `#section`). Unknown
84
- fields, missing scales and out-of-range values are errors. See the
85
- [complete example](examples/explorer.md) and [authoring contract](skills/artifacts/references/authoring.md).
86
-
87
- The registry/data approach follows `phnx-labs/harness-ui`; its React components
88
- are not imported. Its chart drill-down emits a live-agent callback, whereas an
89
- artifact must carry the breakdown with it. This component uses native HTML
90
- `details` and the existing artifact theme; it does not execute agent actions.
91
-
92
- ## Origin and revision history
93
-
94
- The header shows the document type, a clickable Created/Updated timestamp,
95
- and compact device/session copy controls. Clicking the device copies its full
96
- recorded context: canonical name, available address, OS/architecture, agent CLI
97
- version, and session. Clicking the short session copies the complete UUID.
98
- There is no origin dropdown or visible table of missing fields. Clipboard failure
99
- exposes selectable text instead of claiming success. Resume remains in Details.
100
-
101
- The header also carries **Share** and **Favorite** actions. Share is owner-only
102
- first (`artifacts share <id> --visibility me`): served by `render --open` it
103
- publishes through the loopback server and copies the resulting link; on a plain
104
- file:// page it copies the exact command to run; on an already-published page it
105
- degrades to copying the page's own URL instead of re-sharing. Favorite toggles the
106
- star through the same loopback channel (persisted to the local store and reflected
107
- after reload), or copies `artifacts favorite <id>` where no server is present.
108
- Both address the artifact by its store id, so no local path enters the page.
109
-
110
- New scaffolds preserve `sessionId`, `harnessVersion`, `hostPlatform`, and
111
- `hostArch`, and `hostAddress` when this device has an exact-match Tailscale entry
112
- in the local Agents device registry. No DNS lookup or guessed address is used.
113
- Anonymized defaults omit addresses as well as session/device identity; explicit
114
- metadata remains embedded in the HTML, so do not publish private addresses.
115
- The version comes from `AGENTS_RUN_VERSION`, not whichever binary is
116
- currently installed. Any already-recorded origin owns the entire origin tuple:
117
- missing fields remain unrecorded rather than being borrowed from today's renderer.
118
- Legacy short-only sessions are labeled honestly; the full UUID cannot be invented.
119
-
120
- Every successful Markdown compile to an output path participates in local history:
69
+ ````
121
70
 
122
71
  ```bash
123
- artifacts render plan.md # first saved version: Created just now
124
- artifacts render plan.md # unchanged render: no new version
125
- artifacts history plan.md # list local snapshots
126
- artifacts history plan.md --open 1 # view saved HTML; never overwrite source
127
- artifacts history plan.md --json
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
128
74
  ```
129
75
 
130
- Changing source content, embedded assets, design, or visible metadata creates the
131
- next revision. Merely touching the source mtime does not. Click the timestamp for
132
- History; entries use Created/Updated dates, not internal revision codes. It shows
133
- the latest ten saved entries and copies an open command using the artifact ID,
134
- so an agent does not need to keep track of a source path or maintain a version field.
135
- Run that command on the rendering device. Complete history remains available via
136
- the CLI.
137
-
138
- History lives privately in `~/.agents/artifact-history/` (override with
139
- `ARTIFACTS_HISTORY_DIR`). Identity follows the canonical source path, not the output
140
- filename; output variants share a history, symlink aliases resolve together, and
141
- moving the source or rendering on another device starts separate history.
142
- Snapshots retain previous content until explicitly removed; they are not pruned
143
- automatically. They are never embedded in, or uploaded alongside, the current HTML.
144
- The shared page carries only revision numbers/times and local open commands.
145
-
146
- Favorites live beside the history in `favorites.json` under the same directory.
147
- `artifacts favorite <source.md|artifact-id>` toggles the star (the header star on a
148
- served page writes here too), and `artifacts list [--favorites] [--json]` enumerates
149
- everything the local store knows — id, title, source path, first/last saved dates,
150
- favorite marker.
151
-
152
- Validation/storage failures do not replace the previous output. Concurrent renders
153
- serialize their history writes, and repeated unchanged renders reuse the revision.
154
- Direct `renderMarkdown()` previews without an output path and imported raw HTML
155
- do not create Markdown revision history.
156
-
157
- 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.
158
-
159
- **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.
160
-
161
- Additional frontmatter carries into the artifact header:
162
-
163
- The built-in cover shows the creating harness's logo as its background artwork,
164
- a brand-colored palette, a linked project, and the title. The creator line has
165
- one small logo and the recorded model. The human's profile sits at the top left,
166
- opposite the project link. The product name stays
167
- in the logo's accessible label and tooltip, not repeated in visible text. Missing
168
- models are not guessed. Freshness lives in the header; the reader has no duplicate
169
- Details block. Full provenance remains available in printed copies. The same mark
170
- becomes the tab's favicon, embedded in the HTML for offline use. Known harness
171
- aliases resolve to the same mark; unknown harnesses use a neutral cover and
172
- terminal glyph.
173
-
174
- When `avatar` is an https URL the cover's first row shows it as the human's picture
175
- beside their name (with no referrer sent to the image host). `artifacts new`
176
- pre-fills it from `AGENTS_ACTOR_AVATAR`, which agents-cli sets from the Phoenix
177
- ID session signed in on the device; a published artifact is scaffolded without
178
- it, like the other anonymized provenance.
179
-
180
- When `project` exactly matches a registered `agents projects` ID, the page uses
181
- its `linear.name` as the readable label and its `linear.url` when available.
182
- An explicit `projectUrl` wins, otherwise the repository is the link target.
183
- IDs and authored names are never title-cased or stripped of dots/dashes.
184
- The full project name wraps on the page; only its tab-title prefix is bounded
185
- to 24 Unicode code points. Author from the subject checkout using
186
- `artifacts new visual --project <id> --out <absolute-path>` to keep this context
187
- when storing the source outside the checkout.
188
-
189
- `artifacts new` records the real creation instant (except with `--blank`).
190
- Precise `created`/`updated` timestamps display relative ages and exact-time
191
- tooltips. Date-only values remain absolute. Without `updated`, the source
192
- file's modification time is labeled **Source updated**. Opening or re-rendering
193
- the page does not reset its creation time.
194
-
195
- `render --open` already watches the source through the local preview server.
196
- Updated previews and hosted renders offer **New version available · Reload**;
197
- they never reload automatically beneath unfinished input. `--no-serve` opens
198
- a static file snapshot, which cannot watch its source on its own.
199
-
200
- ```yaml
201
- project: agents-cli
202
- projectUrl: https://github.com/phnx-labs/agents-cli # optional; HTTP(S) only. Links the project name.
203
- context: session context
204
- header: Phoenix Labs / Engineering
205
- footer: Internal planning artifact
206
- repository: phnx-labs/agents-cli
207
- branch: main
208
- tracking: "#1757"
209
- status: implementing
210
- harness: codex
211
- agent: gpt-5
212
- human: Ada Lovelace
213
- avatar: https://lh3.googleusercontent.com/a/example=s96-c # optional; https only. The human's picture in the cover's first row.
214
- host: yosemite-s1
215
- session: fcd64597
216
- date: "2026-08-03" # date-only, absolute
217
- created: "2026-08-01T09:00:00Z" # optional ISO 8601 — shown as "Created"
218
- updated: "2026-08-03T14:30:00Z" # optional ISO 8601 — shown as "Updated"
219
- facts:
220
- - 3 delivery tracks
221
- - 2 repositories
222
- links:
223
- - https://github.com/phnx-labs/agents-cli/pull/1914
224
- - url: https://linear.app/phnx/issue/RUSH-2119/title
225
- label: RUSH-2119
226
- - https://jira.example.com/browse/ENG-42
227
- ```
228
-
229
- `links` is multipurpose: any related ticket, PR, issue, or design URL from any
230
- tracker. Each entry is a plain `https://` string or `{url, label?}`. Labels
231
- auto-derive for GitHub PRs/issues, Jira browse keys, and Linear-style `KEY-N`
232
- paths when omitted. They render under a **Related** label as the hero's only
233
- chip row. When the host is a known tracker (GitHub, Linear, Jira/Atlassian,
234
- Notion, GitLab, Bitbucket, Asana, Trello, Slack, Figma) the chip shows an
235
- 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.
236
79
 
237
80
  ## Commands
238
81
 
239
- Ten commands (`share` spans three rows). Everything else is a flag or subcommand on one of them.
240
-
241
- | Command | Purpose |
82
+ | Command | What it does |
242
83
  | --- | --- |
243
- | `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`. |
244
- | `artifacts check file.md` | Validates frontmatter metadata, required sections, asset paths, and embedded HTML/SVG safety. |
245
- | `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. |
246
- | `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. |
247
- | `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. |
248
- | `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. |
249
- | `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). |
250
- | `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. |
251
- | `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). |
252
- | `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. |
253
- | `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). |
254
- | `artifacts list [--favorites] [--json]` | Lists artifacts known to this device — id, title, source, created/updated dates, favorite marker. `--favorites` filters to starred. |
255
-
256
- ### Internal commands
257
-
258
- These work but are deliberately absent from `--help` — they are maintenance tools,
259
- not part of the authoring flow, and may change without a major version. Each also
260
- answers to an underscore spelling (`_estimate`, `_decompile`, `_pdf`).
261
-
262
- | Command | Purpose |
263
- | --- | --- |
264
- | `artifacts estimate file.md` | Counts Markdown and equivalent rendered HTML with `o200k_base`, then reports the authoring-token reduction without writing output. |
265
- | `artifacts decompile file.html --out file.md` | Recovers Markdown from HTML generated by `artifacts render`. |
266
- | `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. |
267
-
268
- ## Design And Fonts
269
-
270
- `DESIGN.md` is the single style source. Artifact-specific fields live in each Markdown file's frontmatter.
271
-
272
- 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.
273
-
274
- ```yaml
275
- theme:
276
- default: system
277
- themes:
278
- light:
279
- background: "#faf9f6"
280
- surface: "#ffffff"
281
- surfaceAlt: "#f2f4f0"
282
- line: "#e2e6df"
283
- text: "#1a1c1a"
284
- muted: "#5c655c"
285
- accent: "#4d7c0f"
286
- accentAlt: "#0e7490"
287
- warn: "#b45309"
288
- danger: "#dc2626"
289
- dark:
290
- background: "#0a0a0a"
291
- surface: "#111312"
292
- surfaceAlt: "#161a18"
293
- line: "#26302a"
294
- text: "#e7ece8"
295
- muted: "#8b938c"
296
- accent: "#a3e635"
297
- accentAlt: "#5ad6c0"
298
- warn: "#f5c451"
299
- danger: "#ff6b6b"
300
- layout:
301
- contentWidth: 980
302
- pagePadding: 24
303
- mobilePagePadding: 16
304
- heroTop: 40
305
- heroBottom: 28
306
- sectionSpacing: 36
307
- figureSpacing: 22
308
- panelPadding: 16
309
- footerSpacing: 64
310
- printMargin: 24
311
- artifact:
312
- printTheme: light
313
- ```
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 comments plan.md [--json]` | Read, reply to and resolve a shared page's review threads as your agent |
92
+ | `artifacts answers ws.md` | Read or merge worksheet answers |
93
+ | `artifacts list [--favorites]` | Artifacts known to this machine |
94
+
95
+ Run `artifacts <command> --help` for the workflow and flags. Theming,
96
+ components, embedded HTML classes, sharing, self-hosting the Worker and local
97
+ history are all covered in the [full reference](docs/reference.md).
314
98
 
315
- 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.
316
-
317
- 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.
318
-
319
- The default families — **Inter** (body and display) and **JetBrains Mono**
320
- (mono) — are bundled in the package and inlined as `@font-face` data URIs, so a
321
- render is self-contained for type even on a machine that does not have those
322
- faces installed. A `DESIGN.md` `fonts.files` path still wins when it resolves.
323
-
324
- ```yaml
325
- fonts:
326
- body: Inter
327
- mono: JetBrains Mono
328
- display: Inter
329
- files:
330
- Inter: ./fonts/Inter.woff2 # optional override
331
- ```
332
-
333
- Font paths resolve relative to the artifact. If an override path is missing, the
334
- bundled face is used when the family is Inter or JetBrains Mono; otherwise
335
- `artifacts render` warns and emits a fallback stack.
336
-
337
- For fonts stored **outside** the project — a shared company font cache, say — add
338
- the directory to `~/.artifacts/config.json` once. Every later `render` picks it up:
339
-
340
- ```json
341
- {
342
- "fonts": { "dirs": ["/Library/Fonts/Corporate"] }
343
- }
344
- ```
345
-
346
- ## Token Estimate
347
-
348
- `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.
349
-
350
- The committed [representative plan](examples/plan.md) measures:
351
-
352
- | Source | Tokens | Difference from HTML |
353
- | --- | ---: | ---: |
354
- | Markdown authored by the agent | 2,391 | 22,637 fewer |
355
- | Equivalent rendered HTML | 25,028 | baseline |
356
-
357
- 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.
358
-
359
- ## Links
360
-
361
- 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.
362
-
363
- 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.
364
-
365
- ```markdown
366
- See [the merge guard](https://github.com/phnx-labs/agents-cli/pull/1914) for context.
367
- Ticket: [RUSH-2513](https://linear.app/phnx/issue/RUSH-2513/version-drift)
368
- https://github.com/phnx-labs/artifacts-cli
369
- ```
370
-
371
- 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.
372
-
373
- These stay plain anchors, because a pill would fight the surrounding element or misrepresent the link:
374
-
375
- | Link | Why it stays plain |
376
- | --- | --- |
377
- | In a heading, `code`, or a `<pre>` block | The pill would break the type. |
378
- | In-page anchor (`#section`) | Not an outbound source. |
379
- | `mailto:` and `tel:` | Not a web source. |
380
- | Relative path (`./notes.html`) | Not an outbound source. |
381
- | An image wrapped in a link | The image is the content, not a citation. |
382
-
383
- 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.
384
-
385
- ## Reading Surfaces
386
-
387
- Five reader affordances are generated from the artifact itself. An agent writes nothing extra for any of them.
388
-
389
- **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.
390
-
391
- **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.
392
-
393
- **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.
394
-
395
- **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.
396
-
397
- **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.
398
-
399
- 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.
400
-
401
- ## Hosted Review Threads
402
-
403
- 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.
404
-
405
- Nothing about the host is baked into the file. The page asks its **own origin** whether collaboration exists:
406
-
407
- ```
408
- GET /__collab/context?share=<encoded normalized path>
409
- GET /__collab/threads?share=<path>[&after=<cursor>]
410
- POST /__collab/threads { share, anchor, body }
411
- POST /__collab/threads/:threadId/replies { share, body }
412
- PATCH /__collab/comments/:commentId { share, body } | { share, deleted: true }
413
- PATCH /__collab/threads/:threadId { share, status: "open" | "resolved" }
414
- GET /__collab/events?share=<path> (text/event-stream)
415
- ```
416
-
417
- 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.
418
-
419
- 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.
420
-
421
- **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.
422
-
423
- **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.
424
-
425
- ## Embedded HTML And SVG
426
-
427
- 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.
428
-
429
- 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.
430
-
431
- ```html
432
- <section class="artifact-grid artifact-grid-2">
433
- <article class="artifact-panel">Markdown input</article>
434
- <article class="artifact-panel">HTML and PDF output</article>
435
- </section>
436
-
437
- <figure class="artifact-figure artifact-figure-diagram artifact-figure-wide">
438
- <svg class="artifact-diagram" viewBox="0 0 1200 420" role="img" aria-label="Compilation flow">
439
- <rect x="40" y="80" width="360" height="220" rx="12"></rect>
440
- <line x1="400" y1="190" x2="800" y2="190"></line>
441
- <rect x="800" y="80" width="360" height="220" rx="12"></rect>
442
- </svg>
443
- <figcaption>Markdown is compiled once into self-contained outputs.</figcaption>
444
- </figure>
445
- ```
446
-
447
- The supported layout classes are:
448
-
449
- | Class | Use |
450
- | --- | --- |
451
- | `artifact-grid` with `artifact-grid-2` or `artifact-grid-3` | Responsive two- or three-column layout. |
452
- | `artifact-panel` | One item inside a grid. |
453
- | `artifact-stat`, `artifact-stat-value`, `artifact-stat-label` | Headline metrics. |
454
- | `artifact-figure` | Responsive image or SVG with an optional `figcaption`. |
455
- | `artifact-figure-diagram` | Dark diagram surface in both themes. |
456
- | `artifact-figure-wide` | Wide SVG; scrolls inside its figure on narrow screens. |
457
- | `artifact-figure-tall` | Centers and caps a portrait diagram instead of stretching it to article width. |
458
- | `artifact-image`, `artifact-diagram` | Responsive raster-image and inline-SVG sizing. |
459
- | `artifact-callout`, `artifact-legend` | A load-bearing note or a figure legend. |
460
- | `artifact-tag`, `artifact-tag-accent` | Compact labels inside panels. |
461
-
462
- 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.
463
-
464
- 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.
465
-
466
- HTML is the output. PDF lives on the internal `artifacts pdf` command, where
467
- `--layout document` is the default for plans and reports and produces tagged,
468
- paginated Letter output, and `--layout poster` produces one 1200-pixel-wide page
469
- sized to the rendered content, appropriate for `visual` artifacts and
470
- infographics. Both modes use the `artifact.printTheme` palette and run in
471
- isolated headless Chromium. To print an HTML artifact yourself, `artifacts render
472
- file.md --open` and use the browser's own print dialog.
473
-
474
- ## Sharing
475
-
476
- A share is a single object behind a Cloudflare Worker in front of R2. There are
477
- two ways to reach one, and you pick by signing in or not.
478
-
479
- ### Managed — sign in, publish, done
99
+ ## Install
480
100
 
481
101
  ```bash
482
- artifacts auth login # device-code sign-in in your browser
483
- artifacts share plan.md # https://share.getrush.ai/<handle>/<slug>
102
+ npm i -g @phnx-labs/artifacts-cli # installs the `artifacts` command (Node 20+)
103
+ artifacts auth login # optional, enables managed sharing
484
104
  ```
485
105
 
486
- No Cloudflare account, bucket, or write token. The URL namespace is your handle,
487
- the local-part of the signed-in email (`--handle <name>` publishes under a
488
- different one; the first account to write a handle claims it). The session lives
489
- in `~/.artifacts/phoenix-session.json`; `artifacts auth logout` clears this
490
- machine only, and `PHOENIX_ID_BASE` points the CLI at a different backend.
491
-
492
- ### Bring your own Cloudflare
106
+ Give your agents the authoring skill through
107
+ [agents-cli](https://github.com/phnx-labs/agents-cli):
493
108
 
494
109
  ```bash
495
- artifacts share setup --token "$CLOUDFLARE_API_TOKEN" --account "$CLOUDFLARE_ACCOUNT_ID"
496
- artifacts share join https://artifacts-share.example.workers.dev --token "$WRITE_TOKEN"
110
+ agents skills add gh:phnx-labs/artifacts-cli --names artifacts --agents claude,codex -y
497
111
  ```
498
112
 
499
- `setup` provisions the bucket, its lifecycle rule, and the Worker, then mints a
500
- write token; `join` adopts an endpoint someone else provisioned. Both persist to
501
- `~/.artifacts/config.json`. For ephemeral agents, inject `ARTIFACTS_SHARE_TOKEN`
502
- (or `SHARE_WRITE_TOKEN`) instead of storing one. Signed in and want BYO anyway?
503
- `ARTIFACTS_SHARE_BACKEND=byo`.
504
-
505
- ### Visibility
113
+ PDF export is optional and needs `playwright`.
506
114
 
507
- A bare `artifacts share <file>` is **public**: listed in your gallery, with an
508
- Open Graph cover so the link unfurls into a preview card in Slack, iMessage,
509
- Twitter, and Discord. Narrow it with one flag:
510
-
511
- | Flag | What the link is |
512
- | --- | --- |
513
- | *(none)* | `public` — listed, OG cover, indexable |
514
- | `--visibility me` | owner-only; anyone else gets a login gate (needs a session) |
515
- | `--visibility org` | everyone at your signed-in email domain (needs a session) |
516
- | `--unlisted` (alias `--private`) | a capability URL: hidden from the gallery, `noindex`, **still world-readable by anyone holding it** |
517
- | `--protected` | token-gated: the URL carries a secret `?k=` key and GET returns `404` without it |
518
-
519
- `me` and `org` are refused on a BYO endpoint — there is no signed-in owner to
520
- gate on. `--no-cover` skips the OG image; hidden visibilities never get one.
521
- Published HTML pages embed a footer QR of the exact share URL by default — on
522
- `--protected` pages it encodes the full `?k=` URL, since the page `404`s
523
- without it — and `--no-qr` opts out.
524
-
525
- Links expire in 30 days by default so an accidental publish decays; `--expire
526
- never` for a permanent one. Before every publish the file body, the label, and
527
- every `--meta` value are scanned for email addresses and credential-shaped
528
- strings, and the publish is refused unless you pass `--force` — all three are
529
- world-readable on a public page.
530
-
531
- ### Managing what you published
115
+ ## Develop
532
116
 
533
117
  ```bash
534
- artifacts share list --all # every page, including hidden ones
535
- artifacts share revisions q3-plan # prior versions kept on republish
536
- artifacts share edit q3-plan --label "Q3" # retitle without republishing
537
- artifacts share visibility q3-plan me # re-scope in place, same URL
538
- artifacts share open q3-plan # open it signed in as the owner
539
- artifacts unshare q3-plan # take it down, cover and revisions too
118
+ bun install
119
+ bun run test
120
+ scripts/build.sh
540
121
  ```
541
122
 
542
- Republishing an existing slug keeps the version it replaces as a retained
543
- revision (`--no-revision` opts out). A takedown is only reported as successful
544
- once a follow-up GET returns `404` — R2's delete is idempotent, so `{"ok":true}`
545
- alone proves nothing.
546
-
547
- ### The Worker
123
+ Releases go through `scripts/release.sh`. See [CHANGELOG.md](CHANGELOG.md).
548
124
 
549
- **Operator storage policy.** `share setup` and `share update` accept
550
- `--unlimited-storage '<json>'`, with exact `emails` and `domains` arrays:
551
-
552
- ```sh
553
- artifacts share update --unlimited-storage '{"emails":[],"domains":["example.org"]}'
554
- ```
125
+ ## License
555
126
 
556
- The allowlist uses only the email returned by Phoenix authentication or retained
557
- in a server-signed identity cookie. Entries are trimmed and case-insensitive;
558
- domains match exactly, with no subdomain, wildcard, Gmail dot, or plus-alias
559
- expansion. There are no built-in allowed identities. An allowed identity can
560
- publish beyond the aggregate 200 MiB / 150-page free limits, including when its
561
- existing usage ledger is full. Accounting continues for pages and retained
562
- revisions. The 20 MiB request-body cap and 60 publishes per hour still apply.
563
- Missing/unknown ledger plans remain free; a ledger plan or client identity header
564
- cannot grant unlimited storage.
565
-
566
- The operator's endpoint config persists this policy as `share.unlimitedStorage`.
567
- Every subsequent update reapplies it, including template-current updates, and
568
- uploads include it in the `SHARE_UNLIMITED_STORAGE` Worker secret binding.
569
- When the deploying host has no local policy, uploads discover and inherit the
570
- existing Worker binding. A failed settings read stops the upload, except when
571
- Cloudflare confirms the Worker does not exist. Pass `'{"emails":[],"domains":[]}'` to revoke all
572
- exceptions. `--check` reports a supplied policy change without saving or deploying
573
- it. Missing or malformed Worker bindings grant no exceptions. This policy does
574
- not change link expiration or the bucket's lifecycle rules.
575
-
576
- `artifacts share setup` and `artifacts share update` deploy the Worker in
577
- `src/lib/share/worker-template.ts`, which owns visibility enforcement, the
578
- gallery, revision retention, OG card rendering, and Phoenix bearer verification.
579
- `artifacts share status` reports whether your endpoint's deployed template is
580
- current; `artifacts share update --check --update-json` answers the same
581
- question as JSON without touching Cloudflare. The release script runs that check
582
- after publishing and redeploys the managed Worker when the shipped template
583
- changed, so what is deployed never drifts from what was released.
127
+ [Apache-2.0](LICENSE)