devlens-mcp 0.1.2 → 0.1.4
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 -5
- package/dist/index.js +26 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,12 +23,13 @@ In your project root:
|
|
|
23
23
|
npx devlens-mcp init
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
This creates `.mcp.json`, `.claude/skills/devlens.md`, and `devlens.config.
|
|
26
|
+
This creates `.mcp.json`, `.claude/skills/devlens.md`, and `devlens.config.js`, and installs the Chromium browser automatically.
|
|
27
27
|
|
|
28
|
-
Edit `devlens.config.
|
|
28
|
+
Edit `devlens.config.js` to map your source files to dev server routes, then restart Claude Code.
|
|
29
29
|
|
|
30
|
-
```
|
|
31
|
-
// devlens.config.
|
|
30
|
+
```js
|
|
31
|
+
// devlens.config.js
|
|
32
|
+
/** @type {import('devlens-mcp').DevLensConfig} */
|
|
32
33
|
const config = {
|
|
33
34
|
devServerUrl: 'http://localhost:5173',
|
|
34
35
|
routes: [
|
|
@@ -44,7 +45,7 @@ export default config;
|
|
|
44
45
|
|
|
45
46
|
- **`.mcp.json`** — registers the devlens MCP server so Claude Code can call the `dl_*` tools
|
|
46
47
|
- **`.claude/skills/devlens.md`** — the skill that tells Claude to automatically capture after every file write, diff before/after significant changes, and run a visual audit before deploying
|
|
47
|
-
- **`devlens.config.
|
|
48
|
+
- **`devlens.config.js`** — maps file glob patterns to dev server routes
|
|
48
49
|
|
|
49
50
|
## Performance
|
|
50
51
|
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ Only call it once per session.
|
|
|
28
28
|
|
|
29
29
|
### Rule 2: Capture after every frontend file write
|
|
30
30
|
After every \`Edit\` or \`Write\` to a \`.tsx\`, \`.jsx\`, \`.css\`, \`.vue\`, or \`.svelte\` file:
|
|
31
|
-
1. Call \`dl_capture\` with either \`route\` (if you know it) or \`filePath\` (auto-resolved from devlens.config.
|
|
31
|
+
1. Call \`dl_capture\` with either \`route\` (if you know it) or \`filePath\` (auto-resolved from devlens.config.js)
|
|
32
32
|
2. Add \`selector\` if you only changed a specific component (keeps the image small and fast)
|
|
33
33
|
3. Look at the returned image \u2014 does it look right?
|
|
34
34
|
4. If something looks wrong (layout broken, text missing, wrong color, overlapping elements), fix it before moving on
|
|
@@ -64,7 +64,8 @@ call \`dl_capture\` immediately and show the result.
|
|
|
64
64
|
- Omit selector for full-page captures (slower, larger image)
|
|
65
65
|
- Prefer element-level captures during iteration, full-page before deploy
|
|
66
66
|
`;
|
|
67
|
-
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} */
|
|
68
69
|
const config = {
|
|
69
70
|
devServerUrl: 'http://localhost:5173',
|
|
70
71
|
hmrDebounceMs: 150,
|
|
@@ -97,12 +98,12 @@ async function runInit() {
|
|
|
97
98
|
mkdirSync(skillsDir, { recursive: true });
|
|
98
99
|
writeFileSync(join(skillsDir, "devlens.md"), SKILL_CONTENT);
|
|
99
100
|
console.log(" \u2713 .claude/skills/devlens.md written");
|
|
100
|
-
const configPath = resolve(cwd, "devlens.config.
|
|
101
|
+
const configPath = resolve(cwd, "devlens.config.js");
|
|
101
102
|
if (!existsSync(configPath)) {
|
|
102
103
|
writeFileSync(configPath, CONFIG_TEMPLATE);
|
|
103
|
-
console.log(" \u2713 devlens.config.
|
|
104
|
+
console.log(" \u2713 devlens.config.js created (edit this to add your routes)");
|
|
104
105
|
} else {
|
|
105
|
-
console.log(" \u2713 devlens.config.
|
|
106
|
+
console.log(" \u2713 devlens.config.js already exists \u2014 skipped");
|
|
106
107
|
}
|
|
107
108
|
console.log(" Installing Chromium browser...");
|
|
108
109
|
const result = spawnSync("npx", ["playwright", "install", "chromium"], { stdio: "inherit", shell: true });
|
|
@@ -114,7 +115,7 @@ async function runInit() {
|
|
|
114
115
|
console.log("");
|
|
115
116
|
console.log("DevLens initialized. Next step:");
|
|
116
117
|
console.log("");
|
|
117
|
-
console.log(" 1. Edit devlens.config.
|
|
118
|
+
console.log(" 1. Edit devlens.config.js to map your pages to routes");
|
|
118
119
|
console.log("");
|
|
119
120
|
console.log(" 2. Restart Claude Code");
|
|
120
121
|
console.log("");
|
|
@@ -134,18 +135,26 @@ var defaults = {
|
|
|
134
135
|
hmrDebounceMs: 150
|
|
135
136
|
};
|
|
136
137
|
async function loadConfig(cwd = process.cwd()) {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
...defaults,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
+
}
|
|
148
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
|
+
};
|
|
149
158
|
}
|
|
150
159
|
|
|
151
160
|
// src/browser/manager.ts
|