Skip to content

Latest commit

 

History

History
195 lines (136 loc) · 9.28 KB

README.md

File metadata and controls

195 lines (136 loc) · 9.28 KB

⚡ PixelForge AI

License: MIT Node: >=18 TypeScript: 5.7+ Agent Skill Standard PRs Welcome

Turn your AI Coding Agent into a Senior Frontend Staff Engineer.
Autonomous design perception, semantic token extraction, and closed-loop browser verification for pixel-perfect production interfaces.

English • 简体中文 • Agent Skill • Documentation • Examples • CLI Reference


👁️ Show, Don't Tell: Closed-Loop Visual Refinement

Most "screenshot-to-code" tools stop after a single blind text-generation pass, leaving behind broken grids, arbitrary pixel hacks, and illegible contrast.

PixelForge AI closes the loop in real browsers. It inspects its own work, computes perceptual pixel diffs, diagnoses semantic layout drift, and iterates until visual convergence:

1. Design Reference 2. Initial Pass (81.4%) 3. Perceptual Diff Heatmap 4. Converged Output (97.2% ✅)
Design Reference Initial Pass Perceptual Diff Mask Refined Output
Original Mockup / Spec Raw synthesis: spacing & radii drift Diagnostic mask clusters 4 errors Surgical CSS patch: 97.2% fidelity

🎯 97.2% Perceptual Similarity • 🚫 Zero CSS Hacks • ♿ WCAG 2.1 AA Contrast • 📱 Responsive 4px/8px Cadence


⚡ The Difference: Naive Code-Gen vs. Senior Frontend Engineer

Dimension Naive "Screenshot-to-Code" ⚡ PixelForge AI
Architecture Single-file spaghetti with inline CSS hacks Clean modular components (Atoms / Molecules / Organisms)
Design System Hardcoded magic numbers (mt-[37px], w-[312px]) Semantic tokens (spacing-4, color-primary, tracking-tight)
Verification Zero. Assumes LLM output is correct Real browser execution + anti-aliased pixel diffing
Refinement Manual human debugging and manual edits Autonomous feedback loop converging to >= 95% fidelity
Multi-Framework Rigid static output React 19, Next.js 14+ App Router, Vue 3, and Standalone HTML5
Browser Runtime Requires heavy setup or headless dependencies Tier 1: Host Agent Browser (instant) ➔ Tier 2: Playwright fallback

🤖 AI Agent Integration (Universal Skill)

PixelForge AI follows the Universal Agent Skill Standard, instantly compatible with all modern AI engineering platforms:

Claude Code  •  OpenCode  •  Cursor  •  Windsurf  •  OpenAI Codex

1-Command Installation

OpenCode

mkdir -p ~/.config/opencode/skills/pixelforge-ai
cp -r skills/pixelforge-ai/SKILL.md ~/.config/opencode/skills/pixelforge-ai/

Claude Code

mkdir -p ~/.claude/skills/pixelforge-ai
cp -r skills/pixelforge-ai/SKILL.md ~/.claude/skills/pixelforge-ai/

Cursor / Windsurf

Add skills/pixelforge-ai/SKILL.md to your .cursorrules or project instructions.

How It Works in Conversation

Simply prompt your agent naturally with a screenshot, mockup, or URL:

User: "Recreate this cloud telemetry dashboard from @screenshot.png using Next.js and Tailwind."

Agent (Powered by PixelForge):
1. Analyzes spatial cadence, color palette, and WCAG contrast.
2. Exports design-tokens.json and builds modular components.
3. Renders preview in host browser (OpenCode / Browser MCP).
4. Runs perceptual pixel diff against reference image.
5. Diagnosed 88.2% similarity (header padding + card radius drift).
6. Autonomously patches classes -> Re-checks at 96.8% similarity.
7. Delivers production-ready, verified code.

🚀 30-Second Quickstart (Local & CI)

Run PixelForge directly in your terminal or automation pipeline:

# 1. Clone & install
git clone https://github.com/pixelforge-ai/pixelforge-ai.git
cd pixelforge-ai
npm install && npm run build

# 2. Run visual validation loop against your implementation
npm run cli:validate -- \
  --ref ./examples/screenshot-to-page/input.png \
  --target ./examples/screenshot-to-page/output/index.html \
  --out-dir ./.pixelforge/runs

🧩 Core Capabilities

1. 🎯 Design Intent Perception & Token Extraction

Before generating code, PixelForge extracts design rules into structured JSON, CSS Custom Properties (:root), and tailwind.config.ts:

  • Color Scales: Primary, secondary, semantic accents, surfaces, and dark-mode tokens.
  • Typography Matrix: Fluid typographic scale (clamp()), font weights, and line-height cadence.
  • Spatial Rhythm: Automatic detection of 4px/8px layout grids and elevation shadows.

2. ⚛️ Multi-Framework Production Synthesis

Generates production-quality frontend code adhering to strict engineering standards:

  • React 19 & Next.js 14+: Server/Client components with App Router architecture and TypeScript definitions.
  • Vue 3 SFCs: Composition API <script setup lang="ts"> with scoped Tailwind styling.
  • Zero-Dependency HTML5 Previews: Instant browser previews configured with Tailwind Play CDN for immediate rendering without npm install.

3. 🌐 Zero-Config Browser Runtime Tiering

Seamlessly switches execution backends depending on where it runs:

  • Priority 1 — Built-in Agent Browser: Utilizes host browser tools (OpenCode openchamber_web, Claude Code MCP browser) with zero subprocess overhead.
  • Priority 2 — Playwright Fallback: Automatically spins up headless Chromium in terminal and CI environments.

4. 🔬 Perceptual Diffing & Autonomous Convergence

  • Compares rendered screenshots against design mockups using anti-aliasing aware pixelmatch.
  • Groups pixel discrepancies into semantic clusters (spatial layout drift, typography mismatch, color shift).
  • Applies targeted CSS patches until the interface reaches >= 95% similarity.

💡 Showcase Gallery

Explore end-to-end verified examples in the repository:

Example Output Code Verification Report Key Highlight
Screenshot to App (Textify) TextifyApp.tsx + Modular UI 96.63% Similarity (Gemini 3.8 Flash High) Full SaaS web app, extracted design-tokens.json, 5 viewports verified
Landing Page Generation LandingPage.tsx 97.1% Similarity High-converting SaaS layout, responsive nav
Dashboard Generation DashboardView.tsx 95.8% Similarity Data-dense KPI widgets, workload tables
UI Refinement Workflow CandidateIter2.html 97.2% Similarity Autonomous 2-pass feedback loop demonstration

📚 In-Depth Documentation

Detailed technical guides and architectural specifications have been organized into the docs/ directory:


🗺 Roadmap

  • Universal Agent Skill specification (skills/pixelforge-ai/SKILL.md)
  • Design Analyzer token extractor (JSON, CSS variables, Tailwind theme)
  • Multi-tier Browser Provider (Built-in Agent browser + Playwright fallback)
  • Perceptual pixel diff engine (pixelmatch + pngjs) with semantic diagnosis
  • Multi-framework synthesizers (React 19, Next.js App Router, Vue 3, HTML5)
  • Figma REST API direct token synchronization
  • Multi-viewport simultaneous diff matrix (Mobile, Tablet, Desktop grid)
  • Vision-model assisted semantic diff evaluation
  • Storybook & component catalog automatic synthesis

🤝 Contributing & Community

Contributions make the open-source community an incredible place to learn, inspire, and create. Any contribution is greatly appreciated!


📄 License

PixelForge AI is open-source software licensed under the MIT License.