pi-artifacts — User Flow

How a request becomes a live URL via the publish_artifact tool
User
START
User asks pi for something visual
"Build a dashboard of our open PRs and publish it as an artifact" · "Make an annotated diff walkthrough" · "Create a comparison page"
pi — LLM Agent
ACTION
Build self-contained HTML
Inline CSS & JS, images as data URIs — one portable file
TOOL CALL
Call publish_artifact(html, title, platform?)
Same title on a later call = update in place. platform is optional.
Extension — publish_artifact
LOAD
Load state from .pi/artifacts/state.json
Check if an artifact with this title already exists (for updates)
DECISION
Detect installed deployment CLIs
deployers.filter(d => d.check()) — which of Vercel / Wrangler / Netlify / gh-pages are installed?
ERROR
No CLI found
Return install instructions for all four platforms
RESOLVE
Resolve platform choice
Priority: preferred param → existing artifact's platform → session choice → single available → ask user
MULTI?
Multiple CLIs & no preference?
UI PROMPT
User picks platform
ctx.ui.select() — choice remembered for session
▲ Vercel ☁ Cloudflare Netlify GitHub Pages
DECISION
First deploy this session & no autoConfirm?
Skipped if: artifact already exists (update), session already confirmed, or settings.artifacts.autoConfirm = true
No
CANCELLED
User declines
Return "publishing cancelled"
Yes / autoConfirm
WRITE
Write artifact HTML to hub directory
.pi/artifacts/hub/<platform>/<slug>/index.html — slug derived from title (reused if updating)
DEPLOY
Run platform CLI to deploy entire hub
Streams output live to the TUI via execAsync · 120s timeout · all artifacts on one platform share a single project
SAVE
Update & persist state
Store { id, url, platform, slug } keyed by title · record platform baseUrl & projectName
DONE
Return live URL to user
https://<project>.vercel.app/<slug>/
https://<project>.pages.dev/<slug>/
https://<site>.netlify.app/<slug>/
https://<user>.github.io/<repo>/<slug>/
Start / Success
LLM Action
I/O (read/write)
Decision
Error / Cancel
pi-artifacts · @mrsamdev/pi-artifacts · MIT