devlens-mcp 0.3.2 → 0.4.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.
Files changed (121) hide show
  1. package/README.md +45 -37
  2. package/RELEASE_NOTES.md +249 -0
  3. package/dist/bin/cli.js +2 -0
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/src/figma/figma-properties.d.ts +88 -0
  6. package/dist/src/figma/figma-properties.d.ts.map +1 -0
  7. package/dist/src/figma/figma-properties.js +121 -0
  8. package/dist/src/figma/figma-properties.js.map +1 -0
  9. package/dist/src/figma/figma-structure.d.ts +43 -0
  10. package/dist/src/figma/figma-structure.d.ts.map +1 -0
  11. package/dist/src/figma/figma-structure.js +74 -0
  12. package/dist/src/figma/figma-structure.js.map +1 -0
  13. package/dist/src/figma/figma-url.d.ts +37 -0
  14. package/dist/src/figma/figma-url.d.ts.map +1 -0
  15. package/dist/src/figma/figma-url.js +68 -0
  16. package/dist/src/figma/figma-url.js.map +1 -0
  17. package/dist/src/jds-tokens/resolve-token.d.ts +2 -0
  18. package/dist/src/jds-tokens/resolve-token.d.ts.map +1 -0
  19. package/dist/src/jds-tokens/resolve-token.js +24 -0
  20. package/dist/src/jds-tokens/resolve-token.js.map +1 -0
  21. package/dist/src/jds-tokens/tokens.d.ts +2 -0
  22. package/dist/src/jds-tokens/tokens.d.ts.map +1 -0
  23. package/dist/src/jds-tokens/tokens.js +12 -0
  24. package/dist/src/jds-tokens/tokens.js.map +1 -0
  25. package/dist/src/platform/ios/ios-device.d.ts +2 -0
  26. package/dist/src/platform/ios/ios-device.d.ts.map +1 -1
  27. package/dist/src/platform/ios/ios-device.js +18 -8
  28. package/dist/src/platform/ios/ios-device.js.map +1 -1
  29. package/dist/src/platform/ios/scale-resolver.d.ts +29 -0
  30. package/dist/src/platform/ios/scale-resolver.d.ts.map +1 -0
  31. package/dist/src/platform/ios/scale-resolver.js +114 -0
  32. package/dist/src/platform/ios/scale-resolver.js.map +1 -0
  33. package/dist/src/platform/ios/simctl.d.ts +5 -0
  34. package/dist/src/platform/ios/simctl.d.ts.map +1 -1
  35. package/dist/src/platform/ios/simctl.js +4 -0
  36. package/dist/src/platform/ios/simctl.js.map +1 -1
  37. package/dist/src/server.d.ts.map +1 -1
  38. package/dist/src/server.js +9 -1
  39. package/dist/src/server.js.map +1 -1
  40. package/dist/src/setup/config-patcher.d.ts +2 -0
  41. package/dist/src/setup/config-patcher.d.ts.map +1 -0
  42. package/dist/src/setup/config-patcher.js +128 -0
  43. package/dist/src/setup/config-patcher.js.map +1 -0
  44. package/dist/src/setup/shell-detector.d.ts +10 -0
  45. package/dist/src/setup/shell-detector.d.ts.map +1 -0
  46. package/dist/src/setup/shell-detector.js +72 -0
  47. package/dist/src/setup/shell-detector.js.map +1 -0
  48. package/dist/src/snapshot/device-properties.d.ts +53 -0
  49. package/dist/src/snapshot/device-properties.d.ts.map +1 -0
  50. package/dist/src/snapshot/device-properties.js +94 -0
  51. package/dist/src/snapshot/device-properties.js.map +1 -0
  52. package/dist/src/snapshot/formatter.d.ts +13 -5
  53. package/dist/src/snapshot/formatter.d.ts.map +1 -1
  54. package/dist/src/snapshot/formatter.js +28 -19
  55. package/dist/src/snapshot/formatter.js.map +1 -1
  56. package/dist/src/snapshot/layout-inference.d.ts +44 -0
  57. package/dist/src/snapshot/layout-inference.d.ts.map +1 -0
  58. package/dist/src/snapshot/layout-inference.js +138 -0
  59. package/dist/src/snapshot/layout-inference.js.map +1 -0
  60. package/dist/src/tools/analyze-tools.d.ts +60 -0
  61. package/dist/src/tools/analyze-tools.d.ts.map +1 -0
  62. package/dist/src/tools/analyze-tools.js +196 -0
  63. package/dist/src/tools/analyze-tools.js.map +1 -0
  64. package/dist/src/tools/interaction-tools.d.ts +6 -6
  65. package/dist/src/tools/interaction-tools.d.ts.map +1 -1
  66. package/dist/src/tools/interaction-tools.js +12 -2
  67. package/dist/src/tools/interaction-tools.js.map +1 -1
  68. package/dist/src/tools/metro-tools.d.ts +2 -2
  69. package/dist/src/tools/navigation-tools.d.ts.map +1 -1
  70. package/dist/src/tools/navigation-tools.js +6 -1
  71. package/dist/src/tools/navigation-tools.js.map +1 -1
  72. package/dist/src/tools/screenshot-tools.d.ts +75 -0
  73. package/dist/src/tools/screenshot-tools.d.ts.map +1 -1
  74. package/dist/src/tools/screenshot-tools.js +238 -8
  75. package/dist/src/tools/screenshot-tools.js.map +1 -1
  76. package/dist/src/tools/snapshot-tools.d.ts +15 -0
  77. package/dist/src/tools/snapshot-tools.d.ts.map +1 -1
  78. package/dist/src/tools/snapshot-tools.js +32 -1
  79. package/dist/src/tools/snapshot-tools.js.map +1 -1
  80. package/dist/src/tools/vqa-tools.d.ts +62 -0
  81. package/dist/src/tools/vqa-tools.d.ts.map +1 -0
  82. package/dist/src/tools/vqa-tools.js +204 -0
  83. package/dist/src/tools/vqa-tools.js.map +1 -0
  84. package/dist/src/utils/image-preprocess.d.ts +1 -1
  85. package/dist/src/utils/image-preprocess.d.ts.map +1 -1
  86. package/dist/src/utils/image-preprocess.js +79 -0
  87. package/dist/src/utils/image-preprocess.js.map +1 -1
  88. package/dist/src/visual/color-extractor.d.ts +37 -0
  89. package/dist/src/visual/color-extractor.d.ts.map +1 -0
  90. package/dist/src/visual/color-extractor.js +116 -0
  91. package/dist/src/visual/color-extractor.js.map +1 -0
  92. package/dist/src/visual/comparator.d.ts +21 -0
  93. package/dist/src/visual/comparator.d.ts.map +1 -1
  94. package/dist/src/visual/comparator.js +110 -13
  95. package/dist/src/visual/comparator.js.map +1 -1
  96. package/dist/src/visual/layout-analyzer.d.ts.map +1 -1
  97. package/dist/src/visual/layout-analyzer.js +17 -7
  98. package/dist/src/visual/layout-analyzer.js.map +1 -1
  99. package/dist/src/visual/node-matcher.d.ts +43 -0
  100. package/dist/src/visual/node-matcher.d.ts.map +1 -0
  101. package/dist/src/visual/node-matcher.js +190 -0
  102. package/dist/src/visual/node-matcher.js.map +1 -0
  103. package/dist/src/visual/property-comparator.d.ts +49 -0
  104. package/dist/src/visual/property-comparator.d.ts.map +1 -0
  105. package/dist/src/visual/property-comparator.js +246 -0
  106. package/dist/src/visual/property-comparator.js.map +1 -0
  107. package/dist/src/visual/structural-comparator.d.ts +46 -0
  108. package/dist/src/visual/structural-comparator.d.ts.map +1 -0
  109. package/dist/src/visual/structural-comparator.js +293 -0
  110. package/dist/src/visual/structural-comparator.js.map +1 -0
  111. package/dist/src/visual/vqa-analyzer.d.ts +30 -0
  112. package/dist/src/visual/vqa-analyzer.d.ts.map +1 -0
  113. package/dist/src/visual/vqa-analyzer.js +271 -0
  114. package/dist/src/visual/vqa-analyzer.js.map +1 -0
  115. package/docs/figma-workflow.md +207 -40
  116. package/docs/setup-guide.md +221 -226
  117. package/docs/tool-reference.md +71 -0
  118. package/package.json +1 -1
  119. package/tsconfig.json +1 -1
  120. package/INSTALLATION_GUIDE.md +0 -354
  121. package/QUICK_START.md +0 -153
@@ -1,123 +1,207 @@
1
1
  # DevLens Setup Guide
2
2
 
3
- Get DevLens running in under 5 minutes. This guide covers prerequisites, installation, configuration, and verification.
3
+ ## 1-Minute Install (Cursor IDE)
4
4
 
5
- ---
5
+ Add this to `~/.cursor/mcp.json` and restart Cursor:
6
6
 
7
- ## Prerequisites
7
+ ```json
8
+ {
9
+ "mcpServers": {
10
+ "devlens": {
11
+ "command": "/bin/zsh",
12
+ "args": ["-l", "-c", "npx devlens-mcp@latest"],
13
+ "env": {
14
+ "METRO_PORT": "8081"
15
+ }
16
+ }
17
+ }
18
+ }
19
+ ```
8
20
 
9
- ### For Android Development
10
- 1. **Android Studio** installed with SDK
11
- 2. **Android Emulator** running (start one from Android Studio > Device Manager)
12
- 3. **ADB** accessible in PATH (comes with Android SDK)
21
+ That's it. DevLens tools will appear in Cursor's MCP panel after restart.
13
22
 
14
- Verify:
15
- ```bash
16
- adb devices
17
- # Should show your running emulator, e.g.:
18
- # emulator-5554 device
19
- ```
23
+ > **v0.4.0 Auto-Detection**: DevLens now automatically detects your shell (bash/zsh/fish) and `node`/`npx` path on every startup. If it finds a misconfigured command or path in your MCP config JSON, it patches it automatically (with backup). Check startup logs for `[devlens] Patched` or `[devlens] Config OK` messages.
24
+ >
25
+ > **Why `/bin/zsh -l`?** Cursor doesn't load your shell profile, so `node` from nvm/fnm isn't in PATH. Using `/bin/zsh -l` loads your login profile first. DevLens v0.4.0+ handles this automatically — if you put `/bin/bash` but use zsh, it will auto-correct.
20
26
 
21
- ### For iOS Development (macOS only)
22
- 1. **Xcode** installed with Command Line Tools
23
- 2. **iOS Simulator** booted (open from Xcode > Window > Devices & Simulators)
27
+ ---
24
28
 
25
- Verify:
26
- ```bash
27
- xcrun simctl list devices | grep Booted
28
- # Should show your booted simulator, e.g.:
29
- # iPhone 16 (XXXX-XXXX) (Booted)
30
- ```
29
+ ## Installation for Other Clients
31
30
 
32
- ### For React Native Metro Integration
33
- 1. **Metro bundler** running:
31
+ ### Claude Code
34
32
  ```bash
35
- cd your-rn-project
36
- npx react-native start
37
- # or
38
- npx expo start
33
+ claude mcp add devlens -- npx devlens-mcp@latest
39
34
  ```
35
+ > Claude Code loads shell profiles automatically, so no `/bin/zsh` wrapper needed.
40
36
 
41
- ---
42
-
43
- ## Installation
44
-
45
- ### Option 1: Cursor IDE
46
- Add to `~/.cursor/mcp.json`:
37
+ ### Claude Desktop
38
+ Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
47
39
  ```json
48
40
  {
49
41
  "mcpServers": {
50
42
  "devlens": {
51
- "command": "npx",
52
- "args": ["devlens-mcp@latest"],
53
- "env": {
54
- "METRO_PORT": "8081",
55
- "FIGMA_TOKEN": "figd_xxxxx",
56
- "DEVLENS_CONFIG": "/path/to/your-app/devlens.config.json"
57
- }
43
+ "command": "/bin/zsh",
44
+ "args": ["-l", "-c", "npx devlens-mcp@latest"],
45
+ "env": { "METRO_PORT": "8081" }
58
46
  }
59
47
  }
60
48
  }
61
49
  ```
62
50
 
63
- Restart Cursor after saving. DevLens tools will appear in the MCP tools panel.
51
+ ### Local Development (Build from Source)
52
+ ```bash
53
+ git clone https://JioOmni@dev.azure.com/JioOmni/OmniAI/_git/mcp-devlens
54
+ cd mcp-devlens && npm install && npm run build
55
+ npm run register # auto-registers with Claude Code
56
+ ```
57
+
58
+ For Cursor with local build, use `"command": "node"` and `"args": ["/absolute/path/to/mcp-devlens/dist/bin/cli.js"]` instead of the zsh wrapper.
59
+
60
+ ---
61
+
62
+ ## Prerequisites
63
+
64
+ - **Node.js** >= 18
65
+ - **Android**: Android SDK with `adb` in PATH (via Android Studio)
66
+ - **iOS** (macOS only): Xcode with Command Line Tools
67
+ - **React Native**: Metro bundler running (`npx react-native start`)
64
68
 
65
- ### Option 2: Claude Code
69
+ Quick checks:
66
70
  ```bash
67
- claude mcp add devlens -- npx devlens-mcp@latest
71
+ node -v # Should print v18+
72
+ adb devices # Should list your emulator
73
+ xcrun simctl list devices | grep Booted # (iOS) Should list simulator
68
74
  ```
69
75
 
70
- ### Option 3: Claude Desktop
71
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
76
+ ---
77
+
78
+ ## Environment Variables
79
+
80
+ Add any of these to the `"env"` block in your MCP config:
81
+
82
+ | Variable | Required | Default | Description |
83
+ |----------|----------|---------|-------------|
84
+ | `METRO_PORT` | No | `8081` | Port where Metro bundler is running |
85
+ | `FIGMA_TOKEN` | For Figma compare | — | Figma personal access token. [How to get one](#figma-token-setup). |
86
+ | `DEVLENS_CONFIG` | For DS context | — | Absolute path to `devlens.config.json`. [Details](#design-system-configuration). |
87
+ | `ANDROID_HOME` | No | auto-detect | Android SDK path |
88
+ | `DEVICE_ID` | No | first available | Target a specific device by ID |
89
+
90
+ Full example with all optional vars:
72
91
  ```json
73
92
  {
74
93
  "mcpServers": {
75
94
  "devlens": {
76
- "command": "npx",
77
- "args": ["devlens-mcp@latest"],
95
+ "command": "/bin/zsh",
96
+ "args": ["-l", "-c", "npx devlens-mcp@latest"],
78
97
  "env": {
79
98
  "METRO_PORT": "8081",
80
99
  "FIGMA_TOKEN": "figd_xxxxx",
81
- "DEVLENS_CONFIG": "/path/to/your-app/devlens.config.json"
100
+ "DEVLENS_CONFIG": "/Users/you/your-app/devlens.config.json"
82
101
  }
83
102
  }
84
103
  }
85
104
  }
86
105
  ```
87
106
 
88
- > **Note:** `npx` downloads and runs DevLens automatically on first use. No clone or build step needed.
107
+ ---
108
+
109
+ ## Verify It Works
110
+
111
+ Start your emulator/simulator and Metro, then ask your AI:
112
+
113
+ | Step | What to say | Expected |
114
+ |------|-------------|----------|
115
+ | 1 | "List running devices" | Your emulator/simulator listed |
116
+ | 2 | "Take a screenshot" | Device screenshot as inline image |
117
+ | 3 | "Take a snapshot with validation" | Accessibility tree with `ref=eN` IDs |
118
+ | 4 | "Show Metro logs" | Console output from your app |
119
+ | 5 | "Run VQA on this screen against Figma: `<url>`" | VQA report with PASS/WARNING/FAIL |
120
+
121
+ If step 1 works, DevLens is running correctly.
89
122
 
90
123
  ---
91
124
 
92
- ## Configuration
125
+ ## VQA Workflow — Quick Reference for Developers
126
+
127
+ DevLens v0.4.0 includes a VQA (Visual Quality Assurance) validator. Use it to catch design issues **before** designers see the build — zero VQA tickets.
93
128
 
94
- ### Environment Variables
129
+ ### Copy-paste prompts you can use in Cursor:
95
130
 
96
- Set these in the `env` section of your MCP config, or export them in your shell:
131
+ **Build a new screen + VQA:**
132
+ ```
133
+ Build the HomeScreen component based on this Figma design:
134
+ https://figma.com/design/ABC123/MyApp?node-id=10-200
97
135
 
98
- | Variable | Default | Description |
99
- |----------|---------|-------------|
100
- | `FIGMA_TOKEN` | | Figma personal access token. Required for `devlens_compare_with_figma`. Generate at [figma.com/developers](https://www.figma.com/developers/api#access-tokens). Required scope: **File content: Read**. |
101
- | `DEVLENS_CONFIG` | — | Absolute path to your `devlens.config.json`. Enables the `devlens_ds_context` tool. |
102
- | `METRO_PORT` | `8081` | Port where Metro bundler is running |
103
- | `ANDROID_HOME` | auto-detect | Path to Android SDK (e.g., `/Users/you/Library/Android/sdk`) |
104
- | `ANDROID_SDK_ROOT` | auto-detect | Alternative to `ANDROID_HOME` |
105
- | `DEVICE_ID` | first available | Target a specific device by ID |
136
+ After building, run VQA validation to make sure there are ZERO issues.
137
+ Fix any spacing, color, alignment, or sizing issues automatically.
138
+ Keep running VQA until the report shows PASS.
139
+ ```
106
140
 
107
- ### Multiple Devices
141
+ **Run VQA on an already-built screen:**
142
+ ```
143
+ Take a snapshot of the current screen, then run VQA validation against this Figma:
144
+ https://figma.com/design/ABC123/MyApp?node-id=10-200
108
145
 
109
- If you have multiple emulators/simulators running, DevLens auto-selects the first one. To target a specific device:
146
+ Show me the full VQA report. If there are any issues, fix them and re-run until PASS.
147
+ ```
148
+
149
+ **Quick check after a small CSS change:**
150
+ ```
151
+ I just changed the padding on the header. Do a minimal VQA check — only check
152
+ spacing and alignment against this Figma:
153
+ https://figma.com/design/ABC123/MyApp?node-id=10-200
154
+ ```
155
+
156
+ **Full implementation + zero VQA guarantee:**
157
+ ```
158
+ I need to implement this Figma screen and hand it to the designer with ZERO VQA issues:
159
+ https://figma.com/design/ABC123/MyApp?node-id=10-200
160
+
161
+ Steps:
162
+ 1. Load the design system context first
163
+ 2. Build the component using correct DS tokens
164
+ 3. Hot reload and wait for screen to stabilize
165
+ 4. Run full VQA validation (spacing, colors, alignment, sizing, missing elements)
166
+ 5. Fix every issue the VQA report finds
167
+ 6. Re-run VQA until the report says PASS with 0 issues
168
+ 7. Show me the final VQA report as proof
169
+ ```
170
+
171
+ For the full VQA workflow guide with report format details, see [Figma Workflow](./figma-workflow.md#vqa-workflow--zero-designer-tickets-v040).
172
+
173
+ ---
174
+
175
+ ## Figma Token Setup
176
+
177
+ Required only for `devlens_compare_with_figma`.
178
+
179
+ 1. Go to [figma.com/settings](https://www.figma.com/settings)
180
+ 2. Scroll to **Personal access tokens** → **Generate new token**
181
+ 3. Name: `devlens` (or anything)
182
+ 4. Scope: **File content → Read** (only scope needed)
183
+ 5. Copy the token (starts with `figd_`)
184
+
185
+ Verify it works:
186
+ ```bash
187
+ curl -H "X-Figma-Token: figd_yourtoken" "https://api.figma.com/v1/me"
188
+ # Should return your account info
189
+ ```
110
190
 
111
- 1. Run `devlens_list_devices` to see all available devices
112
- 2. Pass `deviceId` to any tool: `devlens_device_info(deviceId: "emulator-5554")`
191
+ Add to your MCP config:
192
+ ```json
193
+ "env": {
194
+ "FIGMA_TOKEN": "figd_yourtoken"
195
+ }
196
+ ```
113
197
 
114
- Or set `DEVICE_ID=emulator-5554` in your environment.
198
+ > **Security:** Never paste your PAT in chat messages or commit it to git.
115
199
 
116
200
  ---
117
201
 
118
202
  ## Design System Configuration
119
203
 
120
- DevLens can read your design tokens and component interfaces to give the AI accurate context when writing or fixing UI code. This is configured via a `devlens.config.json` file in your app root.
204
+ Optional. Enables `devlens_ds_context` for design-token-aware code generation.
121
205
 
122
206
  ### 1. Create `devlens.config.json` in your app root
123
207
 
@@ -135,22 +219,20 @@ DevLens can read your design tokens and component interfaces to give the AI accu
135
219
 
136
220
  | Field | Required | Description |
137
221
  |-------|----------|-------------|
138
- | `name` | Yes | Design system identifier (e.g. `"jds3"`, `"my-ds"`) |
139
- | `projectRoot` | Yes | Absolute path to your app root |
140
- | `tokensFile` | Yes | Path to your token constants file, relative to `projectRoot` |
141
- | `componentsDir` | No | Path to generated component interface directory, relative to `projectRoot` |
222
+ | `name` | Yes | Design system identifier (e.g. `"jds3"`) |
223
+ | `projectRoot` | Yes | **Absolute** path to your app root |
224
+ | `tokensFile` | Yes | Token file, relative to `projectRoot` |
225
+ | `componentsDir` | No | Generated component interfaces directory |
142
226
  | `componentsGlob` | No | Glob for component source files (default: `"src/**/*.tsx"`) |
143
227
 
144
- ### 2. Point DevLens to the config via the MCP env block
145
-
146
- Add `DEVLENS_CONFIG` to your `~/.cursor/mcp.json` (or equivalent):
228
+ ### 2. Point to it in your MCP config
147
229
 
148
230
  ```json
149
231
  {
150
232
  "mcpServers": {
151
233
  "devlens": {
152
- "command": "node",
153
- "args": ["/path/to/devlens/dist/bin/cli.js"],
234
+ "command": "/bin/zsh",
235
+ "args": ["-l", "-c", "npx devlens-mcp@latest"],
154
236
  "env": {
155
237
  "METRO_PORT": "8081",
156
238
  "FIGMA_TOKEN": "figd_xxxxx",
@@ -161,195 +243,107 @@ Add `DEVLENS_CONFIG` to your `~/.cursor/mcp.json` (or equivalent):
161
243
  }
162
244
  ```
163
245
 
164
- The `devlens.config.json` file lives in your consumer app repository so it stays version-controlled alongside the app it describes.
165
-
166
- ### 3. Verify with `devlens_ds_context`
246
+ ### 3. Verify
167
247
 
168
- After restarting your AI client, ask:
169
-
170
- > *"Load the design system context"*
171
-
172
- `devlens_ds_context` will return:
173
- - All token names and values from your tokens file (colors, spacing, typography, etc.)
174
- - Component prop interfaces from `componentsDir`
175
- - Real usage patterns scanned from your `.tsx` files
248
+ Ask your AI: *"Load the design system context"* — it should return token names, component interfaces, and usage patterns.
176
249
 
177
250
  ---
178
251
 
179
- ## Figma Token Setup
180
-
181
- `devlens_compare_with_figma` requires a Figma personal access token (PAT).
182
-
183
- ### Generate a PAT
184
-
185
- 1. Go to [figma.com](https://www.figma.com) → your profile icon → **Settings**
186
- 2. Scroll to **Personal access tokens** → **Generate new token**
187
- 3. Give it a name (e.g. `devlens`)
188
- 4. Set scope: **File content → Read** (this is the only scope needed)
189
- 5. Copy the token — it starts with `figd_`
252
+ ## Troubleshooting
190
253
 
191
- ### Verify the token works
254
+ ### Fix: Used `node` as command with shell flags (`-l`, `-c`)
192
255
 
193
- ```bash
194
- curl -H "X-Figma-Token: figd_yourtoken" "https://api.figma.com/v1/me"
195
- # Expected: {"id":"...","email":"you@example.com","handle":"..."}
256
+ If your old config looked like this:
257
+ ```json
258
+ {
259
+ "command": "/opt/homebrew/bin/node",
260
+ "args": ["-l", "-c", "npx devlens-mcp@latest"]
261
+ }
196
262
  ```
263
+ This is incorrect — `-l` and `-c` are shell flags (zsh/bash), not node flags. Node ignores or errors on them.
197
264
 
198
- ### Add to MCP config
265
+ **v0.4.0 auto-fix:** DevLens detects this misconfiguration on startup and patches `command` to your actual shell (`/bin/zsh`, `/bin/bash`, etc.) automatically. Check logs for `[devlens] Patched`.
199
266
 
267
+ **Manual fix:** Replace `node` with `/bin/zsh`:
200
268
  ```json
201
- "env": {
202
- "FIGMA_TOKEN": "figd_yourtoken"
269
+ {
270
+ "command": "/bin/zsh",
271
+ "args": ["-l", "-c", "npx devlens-mcp@latest"]
203
272
  }
204
273
  ```
205
274
 
206
- > **Security note:** Never paste your PAT in a chat or commit it to source control. Use environment variables or a secrets manager.
207
-
208
275
  ---
209
276
 
210
- ## Verifying Setup
211
-
212
- After configuration, start a conversation with your AI assistant and try these commands in order:
213
-
214
- ### 1. Check Metro Health
215
-
216
- > **Say:** *"Check if Metro is running"*
217
- >
218
- > **Tool called:** `devlens_metro_status`
219
- >
220
- > **Expected:** Running: `true`, Port: `8081`
221
-
222
- ### 2. List Devices
223
-
224
- > **Say:** *"List my devices"*
225
- >
226
- > **Tool called:** `devlens_list_devices`
227
- >
228
- > **Expected:** Your running emulators/simulators listed with IDs
229
-
230
- ### 3. Take a Screenshot
277
+ ### Fix: `env: node: No such file or directory`
231
278
 
232
- > **Say:** *"Take a screenshot of the device"*
233
- >
234
- > **Tool called:** `devlens_screenshot`
235
- >
236
- > **Expected:** Device screenshot returned as an inline image
237
-
238
- ### 4. Take a Snapshot
239
-
240
- > **Say:** *"Take a snapshot of the screen with validation"*
241
- >
242
- > **Tool called:** `devlens_snapshot(validate: true)`
243
- >
244
- > **Expected:** Accessibility tree with `ref=eN` IDs + validation report
245
-
246
- ### 5. Test Metro Logs
247
-
248
- > **Say:** *"Show me the Metro logs"*
249
- >
250
- > **Tool called:** `devlens_metro_logs`
251
- >
252
- > **Expected:** Console output from your React Native app
253
-
254
- ### 6. Compare with Figma (optional — requires FIGMA_TOKEN)
255
-
256
- > **Say:** *"Compare the current screen with this Figma frame: [your Figma URL]"*
257
- >
258
- > **Tool called:** `devlens_compare_with_figma`
259
- >
260
- > **Expected:** Three images (device, Figma reference, diff) + layout region report
279
+ This means Cursor can't find `node`. It happens when Node is installed via nvm/fnm and the MCP config uses `"command": "npx"` directly.
261
280
 
262
- ### 7. Design System Context (optional requires DEVLENS_CONFIG)
281
+ **Fix:** Use the `/bin/zsh -l` wrapper as shown in the install section above:
282
+ ```json
283
+ {
284
+ "command": "/bin/zsh",
285
+ "args": ["-l", "-c", "npx devlens-mcp@latest"]
286
+ }
287
+ ```
263
288
 
264
- > **Say:** *"Load the design system context"*
265
- >
266
- > **Tool called:** `devlens_ds_context`
267
- >
268
- > **Expected:** Token list, component interfaces, and usage patterns
289
+ The `-l` flag loads your login shell profile (where nvm/fnm initialize), making `node` available. This is the default recommended config and works for everyone on macOS. DevLens v0.4.0 auto-detects and patches this if misconfigured.
269
290
 
270
- If steps 1–5 succeed, DevLens is fully operational. Steps 6–7 require the optional env vars.
291
+ **Alternative:** If you prefer not to use the zsh wrapper, you can use the full absolute path to `npx`:
292
+ 1. Run `which npx` in Terminal
293
+ 2. Use that full path as `"command"` (e.g. `"/Users/you/.nvm/versions/node/v20.12.2/bin/npx"`)
271
294
 
272
295
  ---
273
296
 
274
- ## Troubleshooting
297
+ ### Fix: "No server info found" / DevLens tools not showing
275
298
 
276
- ### "No running simulators or emulators found"
277
- - Start an Android emulator from Android Studio, or boot an iOS Simulator from Xcode
278
- - Verify with `adb devices` (Android) or `xcrun simctl list devices | grep Booted` (iOS)
279
- - If the device was recently started, DevLens may have a stale cache — the retry system will auto-reconnect
299
+ This means Cursor couldn't start the MCP server. Check these in order:
280
300
 
281
- ### "Could not connect to Metro bundler"
282
- - Ensure Metro is running: `npx react-native start` or `npx expo start`
283
- - Check the port: default is 8081, set `METRO_PORT` if different
284
- - Metro must be running on the same machine as DevLens
285
- - Use `devlens_metro_status` to diagnose — it gives actionable error messages
301
+ 1. **Is the JSON valid?** Paste your `~/.cursor/mcp.json` into [jsonlint.com](https://jsonlint.com) to check for syntax errors (trailing commas, missing quotes, etc.)
286
302
 
287
- ### "ADB command not found"
288
- - Set `ANDROID_HOME` to your Android SDK path
289
- - Or add `$ANDROID_HOME/platform-tools` to your PATH
303
+ 2. **Is it `"command": "npx"`?** Not `"command": "node"`. Using `"node"` makes it look for a local file instead of downloading the package.
290
304
 
291
- ### iOS "simctl not found"
292
- - Install Xcode Command Line Tools: `xcode-select --install`
293
- - Ensure Xcode is installed (not just CLT)
305
+ 3. **Does `npx devlens-mcp@latest` work in Terminal?**
306
+ ```bash
307
+ npx devlens-mcp@latest
308
+ ```
309
+ - If this hangs (no output) — that's correct, it's waiting for MCP input via stdin. Press `Ctrl+C`.
310
+ - If it errors with `env: node: No such file` — see the [nvm/PATH fix](#fix-nvmpath-issue-env-node-no-such-file-or-directory) above.
311
+ - If it errors with `Cannot find module` — clear the npx cache: `rm -rf ~/.npm/_npx/*devlens*` and try again.
294
312
 
295
- ### Screenshots return empty or black
296
- - The app might not be in the foreground; use `devlens_launch_app` first
297
- - Wait a moment after navigation for the screen to render
298
- - Use `devlens_wait_for_screen(stableMs: 2000)` to wait for screen stability
313
+ 4. **Restart Cursor completely** (quit and reopen, not just reload window).
299
314
 
300
- ### "Invalid token" when using Figma comparison
301
- - Make sure you're using a **personal access token** (`figd_...`), not an OAuth token
302
- - Verify it has the **File content: Read** scope
303
- - Test with: `curl -H "X-Figma-Token: YOUR_TOKEN" "https://api.figma.com/v1/me"`
315
+ ---
304
316
 
305
- ### "File not exportable" when using Figma comparison
306
- - The Figma file has export restrictions enabled
307
- - Ask the file owner to go to **Share → Anyone with link → Uncheck "Prevent viewers from copying and exporting"**
317
+ ### Fix: Stale npx cache after update
308
318
 
309
- ### Layout report is empty or missing in Figma comparison
310
- - Run `devlens_snapshot` on the current screen before `devlens_compare_with_figma` — the layout report uses element bounds from the snapshot
311
- - If refs are stale (screen changed), take a fresh snapshot first
319
+ If you were on an older version and get `Cannot find module` errors:
312
320
 
313
- ### `devlens_ds_context` returns empty or fails
314
- - Check that `DEVLENS_CONFIG` points to a valid `devlens.config.json` with an absolute `projectRoot`
315
- - Verify the `tokensFile` path is correct relative to `projectRoot`
316
- - The tool logs warnings to stderr — check your MCP server logs
321
+ ```bash
322
+ rm -rf ~/.npm/_npx/*devlens*
323
+ ```
317
324
 
318
- ### "env: node: No such file or directory" when using npx
319
- This happens on macOS when Node.js is installed via `nvm`, `fnm`, or a version manager. Cursor (and other GUI apps) don't load shell profiles, so `node` isn't in their PATH even though `npx` is found.
325
+ Then restart Cursor. npx will re-download the latest version.
320
326
 
321
- **Fix:** Use the full absolute path to `npx` instead of just `npx`.
327
+ ---
322
328
 
323
- 1. Open Terminal and run:
324
- ```bash
325
- which npx
326
- # e.g. /Users/yourname/.nvm/versions/node/v23.10.0/bin/npx
327
- ```
328
- 2. Replace `"command": "npx"` in `~/.cursor/mcp.json` with that full path:
329
- ```json
330
- {
331
- "mcpServers": {
332
- "devlens": {
333
- "command": "/Users/yourname/.nvm/versions/node/v23.10.0/bin/npx",
334
- "args": ["devlens-mcp@latest"],
335
- "env": { "METRO_PORT": "8081", "FIGMA_TOKEN": "figd_xxxxx" }
336
- }
337
- }
338
- }
339
- ```
340
- 3. Restart Cursor.
329
+ ### Other Issues
341
330
 
342
- ### DevLens tools not available in AI assistant
343
- - Verify `"command": "npx"` (not `"command": "node"`) in your MCP config
344
- - If you see `env: node: No such file or directory`, see the section above
345
- - Restart your AI client after any config change
346
- - Check `~/.cursor/mcp.json` or your IDE's MCP config for a `devlens` entry
331
+ | Problem | Solution |
332
+ |---------|----------|
333
+ | "No running simulators or emulators" | Start a device from Android Studio or Xcode |
334
+ | "Could not connect to Metro bundler" | Run `npx react-native start` and check `METRO_PORT` |
335
+ | "ADB command not found" | Set `ANDROID_HOME` or add `platform-tools` to PATH |
336
+ | "simctl not found" (iOS) | Run `xcode-select --install` |
337
+ | "Invalid token" on Figma compare | Use a personal access token (`figd_...`) with **File content: Read** scope |
338
+ | "File not exportable" on Figma compare | Ask file owner to uncheck "Prevent copying and exporting" in Figma share settings |
339
+ | Layout report empty in Figma compare | Run `devlens_snapshot` first — layout report needs element bounds from the snapshot |
340
+ | `devlens_ds_context` returns empty | Verify `DEVLENS_CONFIG` path and that `projectRoot` is absolute |
347
341
 
348
342
  ---
349
343
 
350
344
  ## What's Available
351
345
 
352
- DevLens provides **34 tools** across 8 categories:
346
+ DevLens provides **36 tools** across 9 categories:
353
347
 
354
348
  | Category | Tools | Count |
355
349
  |----------|-------|-------|
@@ -361,5 +355,6 @@ DevLens provides **34 tools** across 8 categories:
361
355
  | React Native / Metro | metro_status, metro_logs, component_tree, hot_reload, network_requests, dismiss_overlays | 6 |
362
356
  | Navigation | open_url, go_back | 2 |
363
357
  | Design System | ds_context | 1 |
358
+ | Analysis & VQA | analyze, vqa_validate | 2 |
364
359
 
365
- See the [Tool Reference](./tool-reference.md) for detailed documentation of every tool and parameter.
360
+ See the [Tool Reference](./tool-reference.md) for detailed parameter docs.
@@ -583,6 +583,74 @@ On Android: presses system Back button. On iOS: performs back swipe.
583
583
 
584
584
  ---
585
585
 
586
+ ## Analysis & VQA Tools
587
+
588
+ ### devlens_analyze
589
+ Smart analysis tool with configurable depth. Respects scope of request — if a user asks for a minimal check, it performs minimal analysis.
590
+
591
+ | Param | Type | Required | Default | Description |
592
+ |-------|------|----------|---------|-------------|
593
+ | `scope` | `"minimal"` \| `"targeted"` \| `"full"` | No | `"full"` | `"minimal"`: quick pixel diff, no layout report. `"targeted"`: compare specific refs only. `"full"`: complete analysis. |
594
+ | `targetRefs` | string[] | No | — | Element refs to focus on (for `"targeted"` scope). E.g., `["e1", "e5"]`. |
595
+ | `referenceImagePath` | string | No | — | Path or URL to reference image. |
596
+ | `referenceImageBase64` | string | No | — | Base64-encoded reference image. |
597
+ | `figmaUrl` | string | No | — | Figma URL for reference. |
598
+ | `threshold` | number | No | `0.1` | Color difference threshold (0-1). |
599
+
600
+ **Scope behaviors:**
601
+ - **minimal**: Captures screenshot, runs quick pixel diff with perceptual mode and system bar exclusion. Skips layout report. Fast.
602
+ - **targeted**: Takes full snapshot but only inspects the specified refs. Returns bounds and properties for targeted elements.
603
+ - **full**: Complete snapshot + optional layout report + comparison with reference.
604
+
605
+ ---
606
+
607
+ ### devlens_vqa_validate
608
+ Run Visual Quality Assurance validation against a Figma design. Returns structured VQA report with issues and fix suggestions.
609
+
610
+ | Param | Type | Required | Default | Description |
611
+ |-------|------|----------|---------|-------------|
612
+ | `figmaUrl` | string | No | — | Full Figma URL (e.g., `"https://figma.com/design/ABC123/MyApp?node-id=10-200"`). |
613
+ | `fileKey` | string | No | — | Figma file key (use instead of figmaUrl). |
614
+ | `nodeId` | string | No | — | Figma node ID (e.g., `"10:200"`). |
615
+ | `scale` | number | No | `2` | Figma export scale. |
616
+ | `checkCategories` | string[] | No | `["spacing","color","alignment","sizing","missing"]` | VQA categories to check. Options: `spacing`, `color`, `typography`, `alignment`, `missing`, `extra`, `sizing`. |
617
+ | `enableAutoFix` | boolean | No | `true` | Generate fix suggestions for each issue. |
618
+ | `preprocessReference` | boolean | No | `true` | Remove Figma artifacts before comparison. |
619
+
620
+ **VQA Check Categories:**
621
+ - **spacing**: Verifies margins/paddings between adjacent elements match Figma specs
622
+ - **color**: Extracts dominant colors per region and compares with design reference
623
+ - **alignment**: Checks element center/edge alignment against Figma positions
624
+ - **sizing**: Verifies element dimensions match Figma within tolerance
625
+ - **missing**: Detects regions with very low visual match (possible missing content)
626
+ - **extra**: Detects extra elements on device not in Figma
627
+ - **typography**: Font size/weight checks via accessibility metadata
628
+
629
+ **VQA Report format:**
630
+ ```
631
+ === VQA Report: PASS/WARNING/FAIL ===
632
+ Overall Score: 94.2%
633
+ Issues: 3 (0 critical, 2 major, 1 minor)
634
+
635
+ --- Issues ---
636
+ 1. [MAJOR] [spacing] Vertical gap between [e3] and [e5] differs from Figma.
637
+ Expected: 12px gap
638
+ Actual: 20px gap (8px off)
639
+ 2. [MAJOR] [color] Color mismatch on [e7]: Significant color mismatch...
640
+ Expected: #1A73E8
641
+ Actual: #2196F3
642
+ 3. [minor] [alignment] Element [e2] is misaligned from Figma position.
643
+ Expected: center (215, 120)
644
+ Actual: center (218, 122) — off by (3, 2)px
645
+
646
+ --- Suggested Fixes ---
647
+ 1. [high] Adjust margin/padding on element [e3] to match Figma specs: 12px gap.
648
+ 2. [high] Update color value for [e7]. Expected: #1A73E8. Check design token mapping.
649
+ 3. [medium] Fix alignment of [e2]. Adjust flex alignment or positioning.
650
+ ```
651
+
652
+ ---
653
+
586
654
  ## Quick Reference Table
587
655
 
588
656
  | # | Tool | Category | Key Params |
@@ -620,3 +688,6 @@ On Android: presses system Back button. On iOS: performs back swipe.
620
688
  | 31 | `devlens_dismiss_overlays` | Metro | suppressLogBox?, pressBack? |
621
689
  | 32 | `devlens_open_url` | Navigation | url |
622
690
  | 33 | `devlens_go_back` | Navigation | — |
691
+ | 34 | `devlens_ds_context` | Design System | — |
692
+ | 35 | `devlens_analyze` | Analysis | scope, targetRefs?, referenceImagePath?, referenceImageBase64?, figmaUrl?, threshold? |
693
+ | 36 | `devlens_vqa_validate` | VQA | figmaUrl?, fileKey?, nodeId?, scale?, checkCategories?, enableAutoFix?, preprocessReference? |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devlens-mcp",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "DevLens — Playwright-style MCP server for mobile development. Take screenshots, compare with Figma designs, interact with iOS Simulators & Android Emulators, and access Metro bundler logs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",