gravity-core 1.0.2 → 1.0.3

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/README.md CHANGED
@@ -14,7 +14,7 @@ Gravity will:
14
14
  3. Analyze its position, styles, and visibility
15
15
  4. Return specific issues and fixes
16
16
 
17
- ## 🚀 Quick Start (3 minutes)
17
+ ## 🚀 Quick Start (5 minutes)
18
18
 
19
19
  ### 1. Install Package
20
20
 
@@ -22,29 +22,48 @@ Gravity will:
22
22
  npm install gravity-core
23
23
  ```
24
24
 
25
- ### 2. Extract Chrome Extension
25
+ ### 2. Setup Extension
26
26
 
27
27
  ```bash
28
- npx gravity-core setup-extension
28
+ gravity setup-extension
29
29
  ```
30
30
 
31
- This creates a `gravity-extension/` folder in your current directory with all the extension files.
31
+ This extracts the Chrome extension to `~/.gravity-extension`.
32
32
 
33
- ### 3. Load Extension in Chrome
33
+ ### 3. Setup Native Host
34
+
35
+ ```bash
36
+ gravity setup-native-host
37
+ ```
38
+
39
+ This:
40
+ - Auto-detects your Gravity extension ID
41
+ - Asks for confirmation before modifying registry
42
+ - Sets up native messaging for Chrome
43
+ - Optionally restarts Chrome
44
+
45
+ ### 4. Load Extension in Chrome
34
46
 
35
47
  1. Open Chrome and go to `chrome://extensions`
36
48
  2. Enable "Developer mode" (toggle in top right)
37
49
  3. Click "Load unpacked"
38
- 4. Select the `gravity-extension/` folder that was just created
50
+ 4. Select the `~/.gravity-extension` folder
39
51
  5. ✅ Done!
40
52
 
41
- ### 4. Connect to Tab
53
+ ### 5. Test Connection
42
54
 
43
- 1. Click the Gravity extension icon in your toolbar
44
- 2. Click "Connect to Tab"
45
- 3. Status turns 🟢 Green
55
+ ```bash
56
+ gravity test-connection
57
+ ```
46
58
 
47
- ### 5. Configure Your IDE
59
+ This verifies:
60
+ - ✅ Registry key exists
61
+ - ✅ Manifest is valid
62
+ - ✅ Extension ID is configured
63
+ - ✅ Native host is executable
64
+ - ✅ WebSocket connection works
65
+
66
+ ### 6. Configure Your IDE
48
67
 
49
68
  **VSCode:**
50
69
  ```json
@@ -78,7 +97,7 @@ Same as VSCode
78
97
  **Warp or any IDE with MCP:**
79
98
  Add the same config to your IDE's MCP settings.
80
99
 
81
- ### 6. Start Diagnosing
100
+ ### 7. Start Diagnosing
82
101
 
83
102
  Ask your AI:
84
103
  - "Diagnose the #modal element"
@@ -119,7 +138,7 @@ Your IDE (VSCode, Cursor, Kiro, etc.)
119
138
 
120
139
  MCP Server (gravity-core)
121
140
 
122
- WebSocket Connection (port 9224)
141
+ Native Messaging Host (Windows Registry)
123
142
 
124
143
  Chrome Extension (running native bridge)
125
144
 
@@ -141,9 +160,9 @@ Browser Tab (DOM, CSS, Layout data)
141
160
 
142
161
  ### Fix Offscreen Modal
143
162
 
144
- 1. Browser: Open page with broken layout
145
- 2. Terminal: Run `npx gravity-core setup-extension`
146
- 3. Chrome: Load the extension from `gravity-extension/` folder
163
+ 1. Terminal: Run `gravity setup-extension` and `gravity setup-native-host`
164
+ 2. Chrome: Load extension from `~/.gravity-extension`
165
+ 3. Browser: Open page with broken layout
147
166
  4. Extension: Click icon → "Connect to Tab" (🟢 Green)
148
167
  5. IDE: Ask AI: "Diagnose the .modal element"
149
168
  6. AI: Shows "Element extends 50px beyond right edge"
@@ -164,26 +183,58 @@ Browser Tab (DOM, CSS, Layout data)
164
183
 
165
184
  ### Setup Extension
166
185
 
167
- Extract the Chrome extension to your current directory:
186
+ Extract the Chrome extension to your home directory:
187
+
188
+ ```bash
189
+ gravity setup-extension
190
+ ```
191
+
192
+ Creates `~/.gravity-extension/` ready to load in Chrome.
193
+
194
+ ### Setup Native Host
195
+
196
+ Configure native messaging for Chrome:
197
+
198
+ ```bash
199
+ gravity setup-native-host
200
+ ```
201
+
202
+ This command:
203
+ - Auto-detects your Gravity extension ID
204
+ - Asks for confirmation before modifying registry
205
+ - Copies native host to `~/.gravity-host/`
206
+ - Patches manifest with extension ID
207
+ - Writes Windows registry entry
208
+ - Optionally restarts Chrome
209
+
210
+ ### Test Connection
211
+
212
+ Verify everything is working:
168
213
 
169
214
  ```bash
170
- npx gravity-core setup-extension
215
+ gravity test-connection
171
216
  ```
172
217
 
173
- Creates a `gravity-extension/` folder ready to load in Chrome.
218
+ Checks:
219
+ - Registry key exists
220
+ - Manifest file is valid
221
+ - Extension ID is configured
222
+ - Native host is executable
223
+ - WebSocket connection works
224
+ - Browser handshake succeeds
174
225
 
175
226
  ### Start MCP Server
176
227
 
177
228
  Run the MCP server (used by your IDE):
178
229
 
179
230
  ```bash
180
- npx gravity-core
231
+ gravity
181
232
  ```
182
233
 
183
234
  ### Show Help
184
235
 
185
236
  ```bash
186
- npx gravity-core --help
237
+ gravity --help
187
238
  ```
188
239
 
189
240
  ## 🔧 API Reference
@@ -251,28 +302,44 @@ bridge.on('error', (error) => {
251
302
 
252
303
  ## 🐛 Troubleshooting
253
304
 
254
- **"Not connected to browser"**
255
- - Make sure Chrome/Edge is open
256
- - Click extension icon → "Connect to Tab"
257
- - Status should turn green
305
+ ### "Could not find Gravity extension"
258
306
 
259
- **"Extension not loaded"**
260
- - Run `npx gravity-core setup-extension`
261
- - Go to `chrome://extensions`
262
- - Enable "Developer mode"
263
- - Click "Load unpacked"
264
- - Select the `gravity-extension/` folder
307
+ **Solution:**
308
+ 1. Run `gravity setup-extension`
309
+ 2. Open Chrome and go to `chrome://extensions`
310
+ 3. Enable "Developer mode"
311
+ 4. Click "Load unpacked"
312
+ 5. Select `~/.gravity-extension`
313
+ 6. Run `gravity setup-native-host`
265
314
 
266
- **"Port 9224 already in use"**
267
- - Edit extension's `background.js` in the `gravity-extension/` folder
268
- - Change `WEBSOCKET_PORT` to 9225
269
- - Update IDE config with `GRAVITY_PORT: 9225`
315
+ ### "Registry key not found"
270
316
 
271
- **"Element not found"**
317
+ **Solution:**
318
+ - Run `gravity setup-native-host` again
319
+ - You may need to run as Administrator
320
+ - Check that Chrome is installed in the default location
321
+
322
+ ### "WebSocket connection failed"
323
+
324
+ **Solution:**
325
+ - Make sure the MCP server is running: `gravity`
326
+ - Check that port 9224 is not blocked by firewall
327
+ - Try a different port: `GRAVITY_PORT=9225 gravity`
328
+
329
+ ### "Element not found"
330
+
331
+ **Solution:**
272
332
  - Check selector is correct
273
333
  - Make sure element exists in page
274
334
  - Try simpler selector: `div` instead of `#modal`
275
335
 
336
+ ### "Chrome is running" warning
337
+
338
+ **Solution:**
339
+ - The setup will ask if you want to restart Chrome
340
+ - Restart Chrome manually if you prefer
341
+ - Changes take effect after restart
342
+
276
343
  ## 📖 Documentation
277
344
 
278
345
  - [Setup Guide](./SETUP.md) - Complete setup instructions
@@ -293,6 +360,8 @@ bridge.on('error', (error) => {
293
360
  - ✅ No external API calls
294
361
  - ✅ All data stays local
295
362
  - ✅ No user data collection
363
+ - ✅ Registry changes require explicit user confirmation
364
+ - ✅ No silent installations or modifications
296
365
 
297
366
  ## 📝 License
298
367
 
@@ -313,7 +382,9 @@ Contributions welcome! Please open an issue or PR on GitHub.
313
382
 
314
383
  ```bash
315
384
  npm install gravity-core
316
- npx gravity-core setup-extension
385
+ gravity setup-extension
386
+ gravity setup-native-host
387
+ gravity test-connection
317
388
  ```
318
389
 
319
- Then load the extension in Chrome and configure your IDE. Happy debugging! 🎉
390
+ Then configure your IDE and start debugging! 🎉