imugi-ai 1.0.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/LICENSE +21 -0
- package/README.md +234 -0
- package/dist/cli.js +2404 -0
- package/dist/cli.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 M00N7682
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# imugi
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/imugi)
|
|
6
|
+
[](https://github.com/M00N7682/imugi/stargazers)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
|
|
10
|
+
**Give AI eyes to see your frontend.**
|
|
11
|
+
|
|
12
|
+
*Design-to-code with visual verification. imugi captures screenshots, compares them pixel-by-pixel against your design, and iterates until the code matches — automatically.*
|
|
13
|
+
|
|
14
|
+
[Get Started](#quick-start) · [MCP Tools](#mcp-tools) · [Configuration](#configuration) · [Contributing](CONTRIBUTING.md)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## How it works
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
Design Image → Code Generation → Screenshot → Compare → Analyze → Patch
|
|
24
|
+
↓
|
|
25
|
+
Score ≥ 95%? → Done!
|
|
26
|
+
↓ No
|
|
27
|
+
Repeat
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
imugi uses **SSIM** (Structural Similarity) + **pixelmatch** + **Claude Vision** to compare design images against live rendered output, then automatically patches the code to close the gap. This is the **Boulder Loop** — it keeps rolling until your code matches the design.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Why imugi?
|
|
35
|
+
|
|
36
|
+
| | Without imugi | With imugi |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| **Design match** | Eyeball it, hope for the best | Pixel-level verification with composite scoring |
|
|
39
|
+
| **Iteration** | Manual back-and-forth | Automated loop until 95%+ match |
|
|
40
|
+
| **Framework support** | Set up each project manually | Auto-detects React, Vue, Svelte, Tailwind, and more |
|
|
41
|
+
| **AI integration** | Copy-paste between tools | Native MCP server for Claude Code / Cursor |
|
|
42
|
+
| **Strategy** | One-size-fits-all | Smart switching: full regen for low scores, surgical patches for high scores |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
### Step 1: Install
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install -g imugi
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Step 2: Add to your AI tool
|
|
55
|
+
|
|
56
|
+
Add imugi as an MCP server in your Claude Code or Cursor config:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"imugi": {
|
|
62
|
+
"command": "npx",
|
|
63
|
+
"args": ["-y", "imugi", "mcp"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Step 3: Build something
|
|
70
|
+
|
|
71
|
+
Ask your AI to implement a design — imugi handles the visual verification loop.
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
Implement this login page design. Here's the reference: ./login-design.png
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
That's it. imugi captures, compares, and patches until the output matches your design.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Features
|
|
82
|
+
|
|
83
|
+
- **Visual Comparison Engine** — SSIM + pixel diff + Claude Vision scoring with heatmap output
|
|
84
|
+
- **Boulder Loop** — Iterative code improvement that keeps going until the design match threshold is met
|
|
85
|
+
- **MCP Server** — Drop-in integration with Claude Code, Cursor, or any MCP-compatible AI tool
|
|
86
|
+
- **Project Detection** — Auto-detects framework (React/Vue/Svelte), CSS method (Tailwind/modules/styled-components), language (TypeScript/JavaScript)
|
|
87
|
+
- **Interactive Agent** — Terminal UI with real-time iteration progress (powered by Ink)
|
|
88
|
+
- **Smart Patching** — Full regeneration for scores below 0.7, surgical patches for scores above 0.7
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Usage Modes
|
|
93
|
+
|
|
94
|
+
### As MCP Server (Recommended)
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
imugi mcp
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Works with Claude Code, Cursor, and any MCP-compatible tool. The AI calls imugi tools directly.
|
|
101
|
+
|
|
102
|
+
### As Interactive Agent
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
106
|
+
imugi
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Then describe what you want:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
> implement this design ./login-design.png
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### One-shot Generation
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
imugi generate ./design.png --output src/app/page.tsx
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Compare Only
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
imugi compare ./design.png --screenshot ./current.png
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## MCP Tools
|
|
130
|
+
|
|
131
|
+
| Tool | Description |
|
|
132
|
+
|------|-------------|
|
|
133
|
+
| `imugi_capture` | Screenshot a URL via headless Chromium |
|
|
134
|
+
| `imugi_compare` | Compare design vs screenshot — returns SSIM score, pixel diff, and heatmap |
|
|
135
|
+
| `imugi_analyze` | Analyze visual differences with actionable fix suggestions |
|
|
136
|
+
| `imugi_detect` | Detect project tech stack (framework, CSS, language) |
|
|
137
|
+
| `imugi_serve` | Start a dev server for the target project |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Comparison Algorithm
|
|
142
|
+
|
|
143
|
+
The composite score combines multiple signals:
|
|
144
|
+
|
|
145
|
+
| Signal | What it measures |
|
|
146
|
+
|--------|-----------------|
|
|
147
|
+
| **SSIM** | Structural similarity — luminance, contrast, structure |
|
|
148
|
+
| **Pixel diff** | Raw pixel-level comparison via pixelmatch |
|
|
149
|
+
| **Claude Vision** | AI-powered visual assessment (activated for scores < 0.98) |
|
|
150
|
+
|
|
151
|
+
Strategy selection based on score:
|
|
152
|
+
|
|
153
|
+
| Score | Strategy | Description |
|
|
154
|
+
|-------|----------|-------------|
|
|
155
|
+
| < 0.7 | **Full regeneration** | Rewrite the code from scratch |
|
|
156
|
+
| >= 0.7 | **Surgical patch** | Targeted fixes only |
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Configuration
|
|
161
|
+
|
|
162
|
+
Create `imugi.config.json` in your project root:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"comparison": {
|
|
167
|
+
"threshold": 0.95,
|
|
168
|
+
"maxIterations": 10
|
|
169
|
+
},
|
|
170
|
+
"rendering": {
|
|
171
|
+
"port": 3000,
|
|
172
|
+
"viewport": { "width": 1440, "height": 900 }
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Environment Variables
|
|
178
|
+
|
|
179
|
+
| Variable | Description |
|
|
180
|
+
|----------|-------------|
|
|
181
|
+
| `ANTHROPIC_API_KEY` | Anthropic API key |
|
|
182
|
+
| `IMUGI_API_KEY` | Alternative API key |
|
|
183
|
+
| `IMUGI_THRESHOLD` | Similarity threshold (0.8–0.99) |
|
|
184
|
+
| `IMUGI_MAX_ITERATIONS` | Max iterations (1–50) |
|
|
185
|
+
| `IMUGI_PORT` | Dev server port |
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Architecture
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
src/
|
|
193
|
+
├── cli.ts # CLI entry point (Commander.js)
|
|
194
|
+
├── mcp/server.ts # MCP server (stdio transport)
|
|
195
|
+
├── agent/
|
|
196
|
+
│ ├── auth.ts # OAuth PKCE + API key auth
|
|
197
|
+
│ ├── loop.ts # Boulder Loop — iterative improvement
|
|
198
|
+
│ ├── session.ts # State management
|
|
199
|
+
│ └── ui.tsx # Terminal UI (Ink/React)
|
|
200
|
+
├── core/
|
|
201
|
+
│ ├── comparator.ts # SSIM + pixelmatch + heatmap
|
|
202
|
+
│ ├── analyzer.ts # Diff classification + strategy
|
|
203
|
+
│ ├── renderer.ts # Playwright screenshot engine
|
|
204
|
+
│ ├── patcher.ts # Code generation + patching
|
|
205
|
+
│ └── context.ts # Project tech stack detection
|
|
206
|
+
├── llm/
|
|
207
|
+
│ ├── client.ts # Anthropic SDK wrapper
|
|
208
|
+
│ └── prompts.ts # Prompt engineering
|
|
209
|
+
├── config/
|
|
210
|
+
│ ├── schema.ts # Zod validation
|
|
211
|
+
│ ├── loader.ts # Config loading (file + env + CLI)
|
|
212
|
+
│ └── defaults.ts # Default configuration
|
|
213
|
+
└── types.ts # Shared type definitions
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Development
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
git clone https://github.com/M00N7682/imugi.git
|
|
222
|
+
cd imugi
|
|
223
|
+
npm install
|
|
224
|
+
npm run build
|
|
225
|
+
npm test
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
[MIT](LICENSE)
|