pi-canvas0.1.1
Live web preview, UI mockup, and Mermaid canvas extension for Pi Coding Agent
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
๐จ Overview
pi-canvas brings the visual power of Claude Artifacts and v0.dev live UI previews directly to Pi Coding Agent sessions in your terminal.
Pi Agent is minimal by design, but software development is fundamentally visual. pi-canvas bridges the gap by spinning up an ultra-lightweight, zero-dependency local loopback web server (127.0.0.1) that receives diagrams, prototypes, and vector graphics pushed by the AI agent in real time via Server-Sent Events (SSE).
โโโโโโโโโโโโโโโโ render_canvas โโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ> โ โ
โ Pi Agent โ โ pi-canvas (127.0.0.1)โ
โ (Terminal) โ <โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ (SSE Stream) โ
โโโโโโโโโโโโโโโโ user feedback โโโโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโ
โ Browser Artifact โ
โ (Mermaid / HTML / SVG)โ
โโโโโโโโโโโโโโโโโโโโโโโโโ
โจ Features
- โก Live Hot-Reload via SSE: Instant push updates whenever Pi creates or refines an artifact.
- ๐ Native Mermaid 11 Diagrams: Flowcharts, sequence diagrams, class models, and state diagrams.
- ๐ป Interactive HTML/Tailwind Sandbox: Isolated iframe stage to preview web components, forms, and pages.
- ๐ผ๏ธ SVG Inspector: Vector graphics with dark-mode canvas integration.
- ๐ Session History Sidebar: Switch between artifacts generated during your session.
- ๐ Loopback Security: Binds strictly to
127.0.0.1and rejects external network requests.
๐ Installation
Via Pi Package Registry (Recommended)
pi install npm:pi-canvas
Direct from GitHub
pi install git:https://github.com/lleontor705/pi-canvas.git
From Local Clone
git clone https://github.com/lleontor705/pi-canvas.git
cd pi-canvas
npm install && npm run build
pi install ./
๐ Usage & Commands
Slash Commands
| Command | Description |
|---|---|
/canvas |
Starts the server (if not already running) and opens your browser. |
/canvas stop |
Stops the background loopback HTTP server. |
/canvas clear |
Clears all active artifacts from the sidebar. |
/preview <path> |
Previews an existing .html, .svg, .mmd, or .md file directly. |
Agent Autonomous Tool (render_canvas)
When pi-canvas is installed, Pi gains the ability to display visual content autonomously:
// Example prompt:
"Design a sequence diagram showing our OAuth2 authentication flow with refresh tokens."
Pi will invoke render_canvas with:
title: "OAuth2 Auth Flow"type: "mermaid"content: Flowchart syntaxautoOpen:true
Your default browser automatically opens displaying the rendered diagram with dark mode styling!
๐๏ธ Architecture & Development
# Clone the repository
git clone https://github.com/lleontor705/pi-canvas.git
cd pi-canvas
# Install dependencies
npm install
# Compile TypeScript
npm run build
Project Structure:
pi-canvas/
โโโ assets/
โ โโโ banner.svg # SVG vector banner
โโโ dist/ # Compiled ESM JavaScript & Type definitions
โโโ skills/
โ โโโ canvas/SKILL.md # Pi Agent Skill instructions
โโโ src/
โ โโโ index.ts # Extension entry point & tool definitions
โ โโโ server.ts # Loopback HTTP + SSE server & embedded web app
โ โโโ types.ts # Type definitions
โโโ .github/workflows/
โ โโโ ci.yml # Build & validation workflow
โ โโโ release.yml # Tagged release & npm publish
โโโ package.json # Pi manifest declaration
โโโ tsconfig.json # TypeScript NodeNext configuration
๐ License
MIT ยฉ Luis Leon