openmagic 0.1.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 +299 -0
- package/dist/cli.js +1222 -0
- package/dist/cli.js.map +1 -0
- package/dist/toolbar/index.global.js +584 -0
- package/dist/toolbar/index.global.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenMagic Contributors
|
|
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,299 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# ✨ OpenMagic
|
|
4
|
+
|
|
5
|
+
**AI-powered coding toolbar for any web application**
|
|
6
|
+
|
|
7
|
+
Add AI code editing to your existing web app in one command. No IDE extension, no desktop app, no account required.
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/openmagic)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
|
|
12
|
+
[Quick Start](#quick-start) | [How It Works](#how-it-works) | [Providers](#supported-providers) | [Configuration](#configuration) | [Contributing](#contributing)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## What is OpenMagic?
|
|
19
|
+
|
|
20
|
+
OpenMagic is an open-source npm package that injects a floating AI coding toolbar into your running web application during development. Select elements, capture screenshots, send context to any LLM, and apply code changes that reflect instantly via hot reload.
|
|
21
|
+
|
|
22
|
+
**Works with any framework.** React, Vue, Angular, Svelte, Next.js, Nuxt, Vite, plain HTML — if it runs in a browser, OpenMagic works.
|
|
23
|
+
|
|
24
|
+
### The Developer Experience
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
1. You have an existing web app running on localhost:3000
|
|
28
|
+
2. Run `npx openmagic`
|
|
29
|
+
3. A floating toolbar appears in your app
|
|
30
|
+
4. Select a button → "Make it bigger with a gradient"
|
|
31
|
+
5. AI proposes changes → You approve → Code updates → UI refreshes
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
<!-- TODO: Add demo GIF here -->
|
|
35
|
+
<!--  -->
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
Make sure your dev server is running first (e.g., `npm run dev`), then:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx openmagic@latest
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
That's it. OpenMagic auto-detects your dev server and opens a proxied version with the toolbar injected.
|
|
46
|
+
|
|
47
|
+
### Specify a port
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx openmagic --port 3000
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Multiple project roots (e.g., frontend + backend)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx openmagic --port 3000 --root ./frontend --root ./backend
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## How It Works
|
|
60
|
+
|
|
61
|
+
OpenMagic runs a **reverse proxy** between your browser and your dev server. This is completely non-invasive — your project files are never modified by the install.
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
┌─────────────────────────────────────────────────┐
|
|
65
|
+
│ Your Browser │
|
|
66
|
+
│ http://localhost:4567 │
|
|
67
|
+
├─────────────┬───────────────────┬───────────────┤
|
|
68
|
+
│ Your App │ OpenMagic │ WebSocket │
|
|
69
|
+
│ (proxied) │ Toolbar (UI) │ Connection │
|
|
70
|
+
└──────┬──────┴───────────────────┴───────┬───────┘
|
|
71
|
+
│ │
|
|
72
|
+
▼ ▼
|
|
73
|
+
┌──────────────┐ ┌───────────────────┐
|
|
74
|
+
│ Your Dev │ │ OpenMagic Server │
|
|
75
|
+
│ Server │ │ ┌──────────────┐ │
|
|
76
|
+
│ :3000 │ │ │ File System │ │
|
|
77
|
+
└──────────────┘ │ │ Read/Write │ │
|
|
78
|
+
│ ├──────────────┤ │
|
|
79
|
+
│ │ LLM Proxy │ │
|
|
80
|
+
│ │ (your API key)│ │
|
|
81
|
+
│ └──────────────┘ │
|
|
82
|
+
└───────────────────┘
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
1. **Proxy** — All HTTP requests are forwarded to your dev server. HTML responses get the toolbar `<script>` injected before `</body>`.
|
|
86
|
+
2. **Toolbar** — A Shadow DOM Web Component that floats on top of your app. Completely isolated — no CSS conflicts with your app.
|
|
87
|
+
3. **Server** — A local Node.js server that handles file operations and proxies LLM API calls. Your API keys never leave localhost.
|
|
88
|
+
4. **HMR** — When AI modifies your source files, your dev server's hot module replacement picks up the changes automatically.
|
|
89
|
+
|
|
90
|
+
### What happens when you stop?
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
Ctrl+C
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Everything stops. No files modified. No dependencies added. No traces left in your project.
|
|
97
|
+
|
|
98
|
+
## Features
|
|
99
|
+
|
|
100
|
+
### Element Selection
|
|
101
|
+
Click any element in your app to capture its DOM structure, computed styles, and surrounding HTML. This context is sent to the LLM so it knows exactly what to modify.
|
|
102
|
+
|
|
103
|
+
### Screenshot Capture
|
|
104
|
+
Take a screenshot of the page or a specific element. Vision-capable models (GPT-4o, Claude, Gemini) use this to understand the visual layout.
|
|
105
|
+
|
|
106
|
+
### Network & Console Logs
|
|
107
|
+
OpenMagic automatically captures `fetch`/`XHR` requests and `console.log` output. This context helps the LLM understand API responses, errors, and application state.
|
|
108
|
+
|
|
109
|
+
### Multi-Repo Context
|
|
110
|
+
Working on a fullstack app? Add both your frontend and backend directories:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npx openmagic --root ./my-frontend --root ./my-api
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The LLM can read and modify files across both repositories.
|
|
117
|
+
|
|
118
|
+
### Streaming Responses
|
|
119
|
+
LLM responses stream in real-time. You see the AI thinking as it generates code.
|
|
120
|
+
|
|
121
|
+
### Code Modifications
|
|
122
|
+
The AI returns structured edits (search/replace on source files). Changes are applied directly and your dev server's HMR reflects them instantly.
|
|
123
|
+
|
|
124
|
+
## Supported Providers
|
|
125
|
+
|
|
126
|
+
All providers and models are pre-configured. You only need to:
|
|
127
|
+
1. Select a provider from the dropdown
|
|
128
|
+
2. Pick a model
|
|
129
|
+
3. Paste your API key
|
|
130
|
+
|
|
131
|
+
| Provider | Models | Vision | API Key |
|
|
132
|
+
|----------|--------|--------|---------|
|
|
133
|
+
| **OpenAI** | GPT-4.1, GPT-4.1 Mini, GPT-4o, GPT-4o Mini, o3, o4-mini | Yes | [platform.openai.com](https://platform.openai.com/api-keys) |
|
|
134
|
+
| **Anthropic** | Claude Opus 4, Claude Sonnet 4, Claude Haiku 4 | Yes | [console.anthropic.com](https://console.anthropic.com/) |
|
|
135
|
+
| **Google Gemini** | Gemini 2.5 Pro, Gemini 2.5 Flash, Gemini 2.0 Flash | Yes | [aistudio.google.com](https://aistudio.google.com/apikey) |
|
|
136
|
+
| **DeepSeek** | DeepSeek V3, DeepSeek R1 | No | [platform.deepseek.com](https://platform.deepseek.com/) |
|
|
137
|
+
| **Groq** | Llama 3.3 70B, Llama 3.1 8B | No | [console.groq.com](https://console.groq.com/) |
|
|
138
|
+
| **Mistral** | Mistral Large, Codestral | No | [console.mistral.ai](https://console.mistral.ai/) |
|
|
139
|
+
| **xAI (Grok)** | Grok 3, Grok 3 Mini | Yes | [console.x.ai](https://console.x.ai/) |
|
|
140
|
+
| **Ollama** | Any local model | Varies | Not required (local) |
|
|
141
|
+
| **OpenRouter** | 200+ models | Varies | [openrouter.ai](https://openrouter.ai/) |
|
|
142
|
+
|
|
143
|
+
### Using Ollama (Free, Local)
|
|
144
|
+
|
|
145
|
+
Run any model locally with zero API costs:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Install Ollama
|
|
149
|
+
curl -fsSL https://ollama.com/install.sh | sh
|
|
150
|
+
|
|
151
|
+
# Pull a model
|
|
152
|
+
ollama pull llama3.3
|
|
153
|
+
|
|
154
|
+
# Start openmagic and select "Ollama (Local)" as provider
|
|
155
|
+
npx openmagic --port 3000
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Configuration
|
|
159
|
+
|
|
160
|
+
### CLI Options
|
|
161
|
+
|
|
162
|
+
| Option | Description | Default |
|
|
163
|
+
|--------|-------------|---------|
|
|
164
|
+
| `-p, --port <port>` | Dev server port to proxy | Auto-detect |
|
|
165
|
+
| `-l, --listen <port>` | OpenMagic proxy port | `4567` |
|
|
166
|
+
| `-r, --root <paths...>` | Project root directories | Current directory |
|
|
167
|
+
| `--host <host>` | Dev server host | `127.0.0.1` |
|
|
168
|
+
| `--no-open` | Don't auto-open browser | `false` |
|
|
169
|
+
|
|
170
|
+
### Config File
|
|
171
|
+
|
|
172
|
+
Settings are stored in `~/.openmagic/config.json`:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"provider": "anthropic",
|
|
177
|
+
"model": "claude-sonnet-4-20250514",
|
|
178
|
+
"apiKey": "sk-ant-...",
|
|
179
|
+
"roots": ["/path/to/project"]
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
This file is in your home directory, never in your project. It won't be committed to git.
|
|
184
|
+
|
|
185
|
+
## Security
|
|
186
|
+
|
|
187
|
+
- **Localhost only** — The proxy and WebSocket server bind to `127.0.0.1`. They are not accessible from the network.
|
|
188
|
+
- **Session tokens** — Each session generates a random token. The toolbar must authenticate before accessing any APIs.
|
|
189
|
+
- **Path sandboxing** — File operations are restricted to configured root directories. The server cannot read/write outside your project.
|
|
190
|
+
- **API keys stay local** — Keys are stored in `~/.openmagic/config.json` on your machine. They are proxied through the local server and never exposed to the browser or any third party.
|
|
191
|
+
- **Zero project modification** — OpenMagic never modifies your `package.json`, config files, or source code during installation. The toolbar exists only in the proxy layer.
|
|
192
|
+
|
|
193
|
+
## Comparison
|
|
194
|
+
|
|
195
|
+
| Feature | OpenMagic | Stagewise | Frontman | Agentation |
|
|
196
|
+
|---------|-----------|-----------|----------|------------|
|
|
197
|
+
| Install method | `npx openmagic` | npm package / Electron app | Framework middleware | npm package |
|
|
198
|
+
| Framework support | Any (reverse proxy) | React, Vue, Angular, Svelte | Next.js, Astro, Vite | React |
|
|
199
|
+
| Code modification | Yes (auto-apply) | Yes (via IDE) | Yes | No (clipboard only) |
|
|
200
|
+
| BYOK (Bring Your Own Key) | Yes | Paid tiers | Yes | N/A |
|
|
201
|
+
| Prompt limits | None | 10 free/day | None | N/A |
|
|
202
|
+
| Vision (screenshots) | Yes | Yes | No | No |
|
|
203
|
+
| Network/console logs | Yes | No | Yes (server-side) | No |
|
|
204
|
+
| Multi-repo | Yes | No | No | No |
|
|
205
|
+
| IDE required | No | VS Code extension | No | No |
|
|
206
|
+
| Open source | MIT | Partial | Apache 2.0 | MIT |
|
|
207
|
+
|
|
208
|
+
## Framework Compatibility
|
|
209
|
+
|
|
210
|
+
OpenMagic works via a reverse proxy, so it's compatible with **any** framework or tool that serves HTML:
|
|
211
|
+
|
|
212
|
+
- React (CRA, Vite)
|
|
213
|
+
- Next.js
|
|
214
|
+
- Vue (Vue CLI, Vite)
|
|
215
|
+
- Nuxt
|
|
216
|
+
- Angular
|
|
217
|
+
- Svelte / SvelteKit
|
|
218
|
+
- Astro
|
|
219
|
+
- Remix
|
|
220
|
+
- Solid
|
|
221
|
+
- Qwik
|
|
222
|
+
- Ember
|
|
223
|
+
- Django / Flask templates
|
|
224
|
+
- Rails views
|
|
225
|
+
- PHP (Laravel, WordPress)
|
|
226
|
+
- Plain HTML + any HTTP server
|
|
227
|
+
|
|
228
|
+
## Contributing
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# Clone the repo
|
|
232
|
+
git clone https://github.com/your-username/openmagic.git
|
|
233
|
+
cd openmagic
|
|
234
|
+
|
|
235
|
+
# Install dependencies
|
|
236
|
+
npm install
|
|
237
|
+
|
|
238
|
+
# Build (CLI + Toolbar)
|
|
239
|
+
npm run build
|
|
240
|
+
|
|
241
|
+
# Test locally against a dev server running on port 3000
|
|
242
|
+
node dist/cli.js --port 3000
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Project Structure
|
|
246
|
+
|
|
247
|
+
```
|
|
248
|
+
src/
|
|
249
|
+
cli.ts # CLI entry point (commander)
|
|
250
|
+
proxy.ts # Reverse proxy + HTML injection
|
|
251
|
+
server.ts # WebSocket + HTTP server
|
|
252
|
+
filesystem.ts # Safe file read/write
|
|
253
|
+
config.ts # User config management
|
|
254
|
+
security.ts # Session tokens
|
|
255
|
+
detect.ts # Dev server auto-detection
|
|
256
|
+
shared-types.ts # TypeScript interfaces
|
|
257
|
+
llm/
|
|
258
|
+
registry.ts # Pre-configured provider/model list
|
|
259
|
+
proxy.ts # Routes to correct provider adapter
|
|
260
|
+
openai.ts # OpenAI-compatible adapter
|
|
261
|
+
anthropic.ts # Anthropic adapter
|
|
262
|
+
google.ts # Google Gemini adapter
|
|
263
|
+
prompts.ts # System prompts for code modification
|
|
264
|
+
toolbar/
|
|
265
|
+
index.ts # Web Component (Shadow DOM)
|
|
266
|
+
services/
|
|
267
|
+
ws-client.ts # WebSocket client
|
|
268
|
+
dom-inspector.ts # Element inspection
|
|
269
|
+
capture.ts # Screenshot capture
|
|
270
|
+
context-builder.ts # Assembles LLM context
|
|
271
|
+
styles/
|
|
272
|
+
toolbar.css.ts # Scoped styles
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Roadmap
|
|
276
|
+
|
|
277
|
+
- [ ] Diff viewer with approve/reject per-file
|
|
278
|
+
- [ ] Undo/rollback for applied changes
|
|
279
|
+
- [ ] File tree browser in toolbar
|
|
280
|
+
- [ ] Voice input
|
|
281
|
+
- [ ] Keyboard shortcuts
|
|
282
|
+
- [ ] Plugin system for custom context providers
|
|
283
|
+
- [ ] Collaborative editing (multiple developers)
|
|
284
|
+
- [ ] Git integration (auto-branch, auto-commit)
|
|
285
|
+
- [ ] VS Code extension for side-by-side view
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
<div align="center">
|
|
294
|
+
|
|
295
|
+
**Built with love for developers who vibe code on their own terms.**
|
|
296
|
+
|
|
297
|
+
[Report a Bug](https://github.com/your-username/openmagic/issues) | [Request a Feature](https://github.com/your-username/openmagic/issues)
|
|
298
|
+
|
|
299
|
+
</div>
|