devlens-mcp 0.1.1 → 0.1.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 +6 -10
- package/dist/index.js +35 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,23 +17,19 @@ DevLens keeps a single Chromium instance alive for the duration of your Claude C
|
|
|
17
17
|
|
|
18
18
|
## Setup
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
npm install -g devlens-mcp
|
|
22
|
-
npx playwright install chromium
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Then in your project root:
|
|
20
|
+
In your project root:
|
|
26
21
|
|
|
27
22
|
```bash
|
|
28
23
|
npx devlens-mcp init
|
|
29
24
|
```
|
|
30
25
|
|
|
31
|
-
This creates `.mcp.json`, `.claude/skills/devlens.md`, and `devlens.config.ts
|
|
26
|
+
This creates `.mcp.json`, `.claude/skills/devlens.md`, and `devlens.config.ts`, and installs the Chromium browser automatically.
|
|
32
27
|
|
|
33
|
-
Edit `devlens.config.
|
|
28
|
+
Edit `devlens.config.js` to map your source files to dev server routes, then restart Claude Code.
|
|
34
29
|
|
|
35
|
-
```
|
|
36
|
-
// devlens.config.
|
|
30
|
+
```js
|
|
31
|
+
// devlens.config.js
|
|
32
|
+
/** @type {import('devlens-mcp').DevLensConfig} */
|
|
37
33
|
const config = {
|
|
38
34
|
devServerUrl: 'http://localhost:5173',
|
|
39
35
|
routes: [
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// src/cli/init.ts
|
|
4
4
|
import { writeFileSync, mkdirSync, existsSync, readFileSync } from "fs";
|
|
5
5
|
import { resolve, join } from "path";
|
|
6
|
+
import { spawnSync } from "child_process";
|
|
6
7
|
var SKILL_CONTENT = `---
|
|
7
8
|
name: devlens
|
|
8
9
|
description: Real-time visual QA for frontend development. Auto-invoked when editing frontend files.
|
|
@@ -63,7 +64,8 @@ call \`dl_capture\` immediately and show the result.
|
|
|
63
64
|
- Omit selector for full-page captures (slower, larger image)
|
|
64
65
|
- Prefer element-level captures during iteration, full-page before deploy
|
|
65
66
|
`;
|
|
66
|
-
var CONFIG_TEMPLATE = `// devlens.config.
|
|
67
|
+
var CONFIG_TEMPLATE = `// devlens.config.js \u2014 map your source files to dev server routes
|
|
68
|
+
/** @type {import('devlens-mcp').DevLensConfig} */
|
|
67
69
|
const config = {
|
|
68
70
|
devServerUrl: 'http://localhost:5173',
|
|
69
71
|
hmrDebounceMs: 150,
|
|
@@ -96,22 +98,26 @@ async function runInit() {
|
|
|
96
98
|
mkdirSync(skillsDir, { recursive: true });
|
|
97
99
|
writeFileSync(join(skillsDir, "devlens.md"), SKILL_CONTENT);
|
|
98
100
|
console.log(" \u2713 .claude/skills/devlens.md written");
|
|
99
|
-
const configPath = resolve(cwd, "devlens.config.
|
|
101
|
+
const configPath = resolve(cwd, "devlens.config.js");
|
|
100
102
|
if (!existsSync(configPath)) {
|
|
101
103
|
writeFileSync(configPath, CONFIG_TEMPLATE);
|
|
102
|
-
console.log(" \u2713 devlens.config.
|
|
104
|
+
console.log(" \u2713 devlens.config.js created (edit this to add your routes)");
|
|
103
105
|
} else {
|
|
104
|
-
console.log(" \u2713 devlens.config.
|
|
106
|
+
console.log(" \u2713 devlens.config.js already exists \u2014 skipped");
|
|
107
|
+
}
|
|
108
|
+
console.log(" Installing Chromium browser...");
|
|
109
|
+
const result = spawnSync("npx", ["playwright", "install", "chromium"], { stdio: "inherit", shell: true });
|
|
110
|
+
if (result.status === 0) {
|
|
111
|
+
console.log(" \u2713 Chromium installed");
|
|
112
|
+
} else {
|
|
113
|
+
console.warn(' \u26A0 Chromium install failed \u2014 run "npx playwright install chromium" manually');
|
|
105
114
|
}
|
|
106
115
|
console.log("");
|
|
107
|
-
console.log("DevLens initialized. Next
|
|
108
|
-
console.log("");
|
|
109
|
-
console.log(" 1. Install Chromium (one-time):");
|
|
110
|
-
console.log(" npx playwright install chromium");
|
|
116
|
+
console.log("DevLens initialized. Next step:");
|
|
111
117
|
console.log("");
|
|
112
|
-
console.log("
|
|
118
|
+
console.log(" 1. Edit devlens.config.ts to map your pages to routes");
|
|
113
119
|
console.log("");
|
|
114
|
-
console.log("
|
|
120
|
+
console.log(" 2. Restart Claude Code");
|
|
115
121
|
console.log("");
|
|
116
122
|
console.log(" Claude will then automatically screenshot your UI after every file write.");
|
|
117
123
|
}
|
|
@@ -129,18 +135,26 @@ var defaults = {
|
|
|
129
135
|
hmrDebounceMs: 150
|
|
130
136
|
};
|
|
131
137
|
async function loadConfig(cwd = process.cwd()) {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
...defaults,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
const candidates = [
|
|
139
|
+
resolve2(cwd, "devlens.config.js"),
|
|
140
|
+
resolve2(cwd, "devlens.config.ts")
|
|
141
|
+
];
|
|
142
|
+
for (const configPath of candidates) {
|
|
143
|
+
try {
|
|
144
|
+
const mod = await import(pathToFileURL(configPath).href);
|
|
145
|
+
return { ...defaults, ...mod.default };
|
|
146
|
+
} catch (err) {
|
|
147
|
+
const code = err.code;
|
|
148
|
+
if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") continue;
|
|
149
|
+
console.error(`[devlens] Failed to load ${configPath}:`, err);
|
|
150
|
+
}
|
|
143
151
|
}
|
|
152
|
+
console.warn('[devlens] No devlens.config.js found \u2014 using defaults (routes: []). Run "npx devlens-mcp init" to create one.');
|
|
153
|
+
return {
|
|
154
|
+
...defaults,
|
|
155
|
+
devServerUrl: "http://localhost:5173",
|
|
156
|
+
routes: []
|
|
157
|
+
};
|
|
144
158
|
}
|
|
145
159
|
|
|
146
160
|
// src/browser/manager.ts
|