devlens-mcp 0.3.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/.claude/settings.json +12 -0
- package/.claude/settings.local.json +17 -0
- package/INSTALLATION_GUIDE.md +354 -0
- package/QUICK_START.md +153 -0
- package/README.md +354 -0
- package/bin/cli.ts +22 -0
- package/bin/register.ts +96 -0
- package/dist/bin/cli.d.ts +3 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +20 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/bin/register.d.ts +10 -0
- package/dist/bin/register.d.ts.map +1 -0
- package/dist/bin/register.js +92 -0
- package/dist/bin/register.js.map +1 -0
- package/dist/src/config/devlens-config.d.ts +92 -0
- package/dist/src/config/devlens-config.d.ts.map +1 -0
- package/dist/src/config/devlens-config.js +70 -0
- package/dist/src/config/devlens-config.js.map +1 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/metro/cdp-client.d.ts +48 -0
- package/dist/src/metro/cdp-client.d.ts.map +1 -0
- package/dist/src/metro/cdp-client.js +127 -0
- package/dist/src/metro/cdp-client.js.map +1 -0
- package/dist/src/metro/log-collector.d.ts +30 -0
- package/dist/src/metro/log-collector.d.ts.map +1 -0
- package/dist/src/metro/log-collector.js +114 -0
- package/dist/src/metro/log-collector.js.map +1 -0
- package/dist/src/metro/metro-bridge.d.ts +56 -0
- package/dist/src/metro/metro-bridge.d.ts.map +1 -0
- package/dist/src/metro/metro-bridge.js +255 -0
- package/dist/src/metro/metro-bridge.js.map +1 -0
- package/dist/src/metro/network-inspector.d.ts +34 -0
- package/dist/src/metro/network-inspector.d.ts.map +1 -0
- package/dist/src/metro/network-inspector.js +100 -0
- package/dist/src/metro/network-inspector.js.map +1 -0
- package/dist/src/platform/android/adb.d.ts +50 -0
- package/dist/src/platform/android/adb.d.ts.map +1 -0
- package/dist/src/platform/android/adb.js +137 -0
- package/dist/src/platform/android/adb.js.map +1 -0
- package/dist/src/platform/android/android-device.d.ts +21 -0
- package/dist/src/platform/android/android-device.d.ts.map +1 -0
- package/dist/src/platform/android/android-device.js +94 -0
- package/dist/src/platform/android/android-device.js.map +1 -0
- package/dist/src/platform/android/ui-automator.d.ts +17 -0
- package/dist/src/platform/android/ui-automator.d.ts.map +1 -0
- package/dist/src/platform/android/ui-automator.js +126 -0
- package/dist/src/platform/android/ui-automator.js.map +1 -0
- package/dist/src/platform/device-manager.d.ts +28 -0
- package/dist/src/platform/device-manager.d.ts.map +1 -0
- package/dist/src/platform/device-manager.js +185 -0
- package/dist/src/platform/device-manager.js.map +1 -0
- package/dist/src/platform/device.d.ts +86 -0
- package/dist/src/platform/device.d.ts.map +1 -0
- package/dist/src/platform/device.js +7 -0
- package/dist/src/platform/device.js.map +1 -0
- package/dist/src/platform/ios/accessibility.d.ts +17 -0
- package/dist/src/platform/ios/accessibility.d.ts.map +1 -0
- package/dist/src/platform/ios/accessibility.js +159 -0
- package/dist/src/platform/ios/accessibility.js.map +1 -0
- package/dist/src/platform/ios/ios-device.d.ts +22 -0
- package/dist/src/platform/ios/ios-device.d.ts.map +1 -0
- package/dist/src/platform/ios/ios-device.js +97 -0
- package/dist/src/platform/ios/ios-device.js.map +1 -0
- package/dist/src/platform/ios/simctl.d.ts +54 -0
- package/dist/src/platform/ios/simctl.d.ts.map +1 -0
- package/dist/src/platform/ios/simctl.js +192 -0
- package/dist/src/platform/ios/simctl.js.map +1 -0
- package/dist/src/server.d.ts +3 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +176 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/snapshot/formatter.d.ts +18 -0
- package/dist/src/snapshot/formatter.d.ts.map +1 -0
- package/dist/src/snapshot/formatter.js +86 -0
- package/dist/src/snapshot/formatter.js.map +1 -0
- package/dist/src/snapshot/ref-registry.d.ts +67 -0
- package/dist/src/snapshot/ref-registry.d.ts.map +1 -0
- package/dist/src/snapshot/ref-registry.js +169 -0
- package/dist/src/snapshot/ref-registry.js.map +1 -0
- package/dist/src/snapshot/snapshot-differ.d.ts +57 -0
- package/dist/src/snapshot/snapshot-differ.d.ts.map +1 -0
- package/dist/src/snapshot/snapshot-differ.js +153 -0
- package/dist/src/snapshot/snapshot-differ.js.map +1 -0
- package/dist/src/tools/app-tools.d.ts +71 -0
- package/dist/src/tools/app-tools.d.ts.map +1 -0
- package/dist/src/tools/app-tools.js +97 -0
- package/dist/src/tools/app-tools.js.map +1 -0
- package/dist/src/tools/device-tools.d.ts +53 -0
- package/dist/src/tools/device-tools.d.ts.map +1 -0
- package/dist/src/tools/device-tools.js +86 -0
- package/dist/src/tools/device-tools.js.map +1 -0
- package/dist/src/tools/ds-tools.d.ts +65 -0
- package/dist/src/tools/ds-tools.d.ts.map +1 -0
- package/dist/src/tools/ds-tools.js +314 -0
- package/dist/src/tools/ds-tools.js.map +1 -0
- package/dist/src/tools/interaction-tools.d.ts +248 -0
- package/dist/src/tools/interaction-tools.d.ts.map +1 -0
- package/dist/src/tools/interaction-tools.js +391 -0
- package/dist/src/tools/interaction-tools.js.map +1 -0
- package/dist/src/tools/metro-tools.d.ts +115 -0
- package/dist/src/tools/metro-tools.d.ts.map +1 -0
- package/dist/src/tools/metro-tools.js +270 -0
- package/dist/src/tools/metro-tools.js.map +1 -0
- package/dist/src/tools/navigation-tools.d.ts +36 -0
- package/dist/src/tools/navigation-tools.d.ts.map +1 -0
- package/dist/src/tools/navigation-tools.js +60 -0
- package/dist/src/tools/navigation-tools.js.map +1 -0
- package/dist/src/tools/screenshot-tools.d.ts +298 -0
- package/dist/src/tools/screenshot-tools.d.ts.map +1 -0
- package/dist/src/tools/screenshot-tools.js +565 -0
- package/dist/src/tools/screenshot-tools.js.map +1 -0
- package/dist/src/tools/snapshot-tools.d.ts +161 -0
- package/dist/src/tools/snapshot-tools.d.ts.map +1 -0
- package/dist/src/tools/snapshot-tools.js +479 -0
- package/dist/src/tools/snapshot-tools.js.map +1 -0
- package/dist/src/utils/image-preprocess.d.ts +49 -0
- package/dist/src/utils/image-preprocess.d.ts.map +1 -0
- package/dist/src/utils/image-preprocess.js +322 -0
- package/dist/src/utils/image-preprocess.js.map +1 -0
- package/dist/src/utils/retry.d.ts +21 -0
- package/dist/src/utils/retry.d.ts.map +1 -0
- package/dist/src/utils/retry.js +33 -0
- package/dist/src/utils/retry.js.map +1 -0
- package/dist/src/visual/comparator.d.ts +51 -0
- package/dist/src/visual/comparator.d.ts.map +1 -0
- package/dist/src/visual/comparator.js +119 -0
- package/dist/src/visual/comparator.js.map +1 -0
- package/dist/src/visual/layout-analyzer.d.ts +64 -0
- package/dist/src/visual/layout-analyzer.d.ts.map +1 -0
- package/dist/src/visual/layout-analyzer.js +198 -0
- package/dist/src/visual/layout-analyzer.js.map +1 -0
- package/dist/src/visual/screenshot.d.ts +17 -0
- package/dist/src/visual/screenshot.d.ts.map +1 -0
- package/dist/src/visual/screenshot.js +39 -0
- package/dist/src/visual/screenshot.js.map +1 -0
- package/docs/figma-workflow.md +289 -0
- package/docs/setup-guide.md +360 -0
- package/docs/tool-reference.md +622 -0
- package/package.json +57 -0
- package/src/config/devlens-config.ts +76 -0
- package/src/index.ts +5 -0
- package/src/metro/cdp-client.ts +160 -0
- package/src/metro/log-collector.ts +137 -0
- package/src/metro/metro-bridge.ts +307 -0
- package/src/metro/network-inspector.ts +134 -0
- package/src/platform/android/adb.ts +200 -0
- package/src/platform/android/android-device.ts +116 -0
- package/src/platform/android/ui-automator.ts +141 -0
- package/src/platform/device-manager.ts +229 -0
- package/src/platform/device.ts +110 -0
- package/src/platform/ios/accessibility.ts +189 -0
- package/src/platform/ios/ios-device.ts +116 -0
- package/src/platform/ios/simctl.ts +244 -0
- package/src/server.ts +228 -0
- package/src/snapshot/formatter.ts +102 -0
- package/src/snapshot/ref-registry.ts +230 -0
- package/src/snapshot/snapshot-differ.ts +220 -0
- package/src/tools/app-tools.ts +111 -0
- package/src/tools/device-tools.ts +96 -0
- package/src/tools/ds-tools.ts +395 -0
- package/src/tools/interaction-tools.ts +467 -0
- package/src/tools/metro-tools.ts +320 -0
- package/src/tools/navigation-tools.ts +71 -0
- package/src/tools/screenshot-tools.ts +698 -0
- package/src/tools/snapshot-tools.ts +585 -0
- package/src/utils/image-preprocess.ts +430 -0
- package/src/utils/retry.ts +51 -0
- package/src/visual/comparator.ts +191 -0
- package/src/visual/layout-analyzer.ts +283 -0
- package/src/visual/screenshot.ts +49 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dsToolSchemas = void 0;
|
|
4
|
+
exports.createDsToolHandlers = createDsToolHandlers;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const promises_1 = require("fs/promises");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
// ─── Tool Schema ─────────────────────────────────────────────────────────────
|
|
9
|
+
exports.dsToolSchemas = {
|
|
10
|
+
devlens_ds_context: {
|
|
11
|
+
description: "Get design system context: available DS3 components with their TypeScript prop interfaces, design token values (colors, spacing, typography), and usage patterns from the codebase. Use this before fixing code — it tells you exactly which components and tokens to use. Requires 'designSystem' to be configured in devlens.config.json (pointed to by DEVLENS_CONFIG env var).",
|
|
12
|
+
parameters: zod_1.z.object({
|
|
13
|
+
includeTokens: zod_1.z
|
|
14
|
+
.boolean()
|
|
15
|
+
.default(true)
|
|
16
|
+
.describe("Include design token values (colors, spacing, typography)"),
|
|
17
|
+
includeComponents: zod_1.z
|
|
18
|
+
.boolean()
|
|
19
|
+
.default(true)
|
|
20
|
+
.describe("Scan source files for DS component usage patterns and prop value combinations"),
|
|
21
|
+
includeInterfaces: zod_1.z
|
|
22
|
+
.boolean()
|
|
23
|
+
.default(true)
|
|
24
|
+
.describe("Include TypeScript prop interface definitions for each DS component"),
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
// ─── Token Parsing ────────────────────────────────────────────────────────────
|
|
29
|
+
/**
|
|
30
|
+
* Parse a TypeScript constants file for exported const objects.
|
|
31
|
+
* Handles patterns like:
|
|
32
|
+
* export const FIGMA_COLORS = { KEY: '#hex', ... }
|
|
33
|
+
* export const FIGMA_SPACING = { XS: 8, ... }
|
|
34
|
+
*/
|
|
35
|
+
async function parseTokensFile(absolutePath) {
|
|
36
|
+
const tokens = [];
|
|
37
|
+
let content;
|
|
38
|
+
try {
|
|
39
|
+
content = await (0, promises_1.readFile)(absolutePath, "utf-8");
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return tokens;
|
|
43
|
+
}
|
|
44
|
+
const blockRegex = /export\s+const\s+(\w+)\s*=\s*\{([^}]+)\}/g;
|
|
45
|
+
let blockMatch;
|
|
46
|
+
while ((blockMatch = blockRegex.exec(content)) !== null) {
|
|
47
|
+
const blockName = blockMatch[1];
|
|
48
|
+
const blockBody = blockMatch[2];
|
|
49
|
+
const lower = blockName.toLowerCase();
|
|
50
|
+
const group = lower.includes("color") ? "colors"
|
|
51
|
+
: lower.includes("spacing") ? "spacing"
|
|
52
|
+
: lower.includes("typo") ? "typography"
|
|
53
|
+
: lower.includes("shape") ? "shapes"
|
|
54
|
+
: lower.includes("dimension") ? "dimensions"
|
|
55
|
+
: "other";
|
|
56
|
+
const entryRegex = /['"]?(\w+)['"]?\s*:\s*([^,\n]+)/g;
|
|
57
|
+
let entryMatch;
|
|
58
|
+
while ((entryMatch = entryRegex.exec(blockBody)) !== null) {
|
|
59
|
+
const name = entryMatch[1].trim();
|
|
60
|
+
const raw = entryMatch[2]
|
|
61
|
+
.trim()
|
|
62
|
+
.replace(/\/\/.*$/, "") // strip trailing comments
|
|
63
|
+
.trim()
|
|
64
|
+
.replace(/,$/, "") // strip trailing comma
|
|
65
|
+
.trim()
|
|
66
|
+
.replace(/^['"]/, "") // strip leading quote
|
|
67
|
+
.replace(/['"]$/, "") // strip trailing quote
|
|
68
|
+
.replace(/\s+as\s+const$/, "") // strip "as const"
|
|
69
|
+
.trim();
|
|
70
|
+
if (name && raw) {
|
|
71
|
+
tokens.push({ name, value: raw, group });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return tokens;
|
|
76
|
+
}
|
|
77
|
+
// ─── Component Interface Reading ──────────────────────────────────────────────
|
|
78
|
+
const SKIP_DIRS = new Set(["node_modules", ".git", "dist", "build", "__tests__", "__mocks__", ".expo"]);
|
|
79
|
+
/** Recursively walk a directory and collect .ts/.tsx files */
|
|
80
|
+
async function collectSourceFiles(dir) {
|
|
81
|
+
const files = [];
|
|
82
|
+
async function walk(current) {
|
|
83
|
+
let entries;
|
|
84
|
+
try {
|
|
85
|
+
entries = await (0, promises_1.readdir)(current);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
for (const entry of entries) {
|
|
91
|
+
if (SKIP_DIRS.has(entry))
|
|
92
|
+
continue;
|
|
93
|
+
const fullPath = (0, path_1.join)(current, entry);
|
|
94
|
+
try {
|
|
95
|
+
const s = await (0, promises_1.stat)(fullPath);
|
|
96
|
+
if (s.isDirectory()) {
|
|
97
|
+
await walk(fullPath);
|
|
98
|
+
}
|
|
99
|
+
else if (entry.endsWith(".tsx") || entry.endsWith(".ts")) {
|
|
100
|
+
files.push(fullPath);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// ignore permission errors
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
await walk(dir);
|
|
109
|
+
return files;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Read component interface definitions from a DS components directory.
|
|
113
|
+
* Expects structure: componentsDir/<ComponentName>/generated/interface.ts
|
|
114
|
+
* Returns map of interface name → full TypeScript interface text.
|
|
115
|
+
*/
|
|
116
|
+
async function readComponentInterfaces(componentsDir) {
|
|
117
|
+
const interfaces = {};
|
|
118
|
+
let entries;
|
|
119
|
+
try {
|
|
120
|
+
entries = await (0, promises_1.readdir)(componentsDir);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return interfaces;
|
|
124
|
+
}
|
|
125
|
+
for (const entry of entries) {
|
|
126
|
+
// Try common paths for generated interfaces
|
|
127
|
+
const candidates = [
|
|
128
|
+
(0, path_1.join)(componentsDir, entry, "generated", "interface.ts"),
|
|
129
|
+
(0, path_1.join)(componentsDir, entry, "interface.ts"),
|
|
130
|
+
(0, path_1.join)(componentsDir, entry, "types.ts"),
|
|
131
|
+
];
|
|
132
|
+
for (const interfacePath of candidates) {
|
|
133
|
+
try {
|
|
134
|
+
const content = await (0, promises_1.readFile)(interfacePath, "utf-8");
|
|
135
|
+
// Extract first interface name from "export interface FooProps {"
|
|
136
|
+
const nameMatch = content.match(/export\s+(?:interface|type)\s+(\w+)/);
|
|
137
|
+
if (nameMatch) {
|
|
138
|
+
interfaces[nameMatch[1]] = content.trim();
|
|
139
|
+
break; // found one for this component
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
// file not found — try next candidate
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return interfaces;
|
|
148
|
+
}
|
|
149
|
+
// ─── Usage Pattern Scanning ───────────────────────────────────────────────────
|
|
150
|
+
/**
|
|
151
|
+
* Scan TSX/TS source files for DS component usages and collect prop patterns.
|
|
152
|
+
* Detects: <JDS*> components and common React Native DS component names.
|
|
153
|
+
*/
|
|
154
|
+
async function scanComponentUsages(projectRoot) {
|
|
155
|
+
const files = await collectSourceFiles(projectRoot);
|
|
156
|
+
const usageMap = new Map();
|
|
157
|
+
// Matches JSX tags: <JDSText variant="..." /> or <Icon name="..." />
|
|
158
|
+
const componentTagRegex = /<(JDS\w+|DS3\w+|(?:Icon|Chip|Divider|JDSButton|JDSInput|JDSText)\b)\s([^>]{0,500})(?:\/?>|>)/g;
|
|
159
|
+
const propRegex = /(\w+)=["'{]([^"'}\n]{0,80})["'}]/g;
|
|
160
|
+
for (const filePath of files) {
|
|
161
|
+
let content;
|
|
162
|
+
try {
|
|
163
|
+
content = await (0, promises_1.readFile)(filePath, "utf-8");
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
// Find import lines to identify where components come from
|
|
169
|
+
const importLines = content.match(/import[^;]+from\s+['"][^'"]+['"]/g) || [];
|
|
170
|
+
componentTagRegex.lastIndex = 0;
|
|
171
|
+
let tagMatch;
|
|
172
|
+
while ((tagMatch = componentTagRegex.exec(content)) !== null) {
|
|
173
|
+
const componentName = tagMatch[1];
|
|
174
|
+
const propsStr = tagMatch[2];
|
|
175
|
+
// Find import source for this component
|
|
176
|
+
const importedFrom = importLines
|
|
177
|
+
.find(line => line.includes(componentName))
|
|
178
|
+
?.match(/from\s+['"]([^'"]+)['"]/)?.[1] ?? "unknown";
|
|
179
|
+
if (!usageMap.has(componentName)) {
|
|
180
|
+
usageMap.set(componentName, {
|
|
181
|
+
componentName,
|
|
182
|
+
importedFrom,
|
|
183
|
+
usageCount: 0,
|
|
184
|
+
sampleProps: {},
|
|
185
|
+
sourceFiles: [],
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const usage = usageMap.get(componentName);
|
|
189
|
+
usage.usageCount++;
|
|
190
|
+
if (!usage.sourceFiles.includes(filePath)) {
|
|
191
|
+
usage.sourceFiles.push(filePath);
|
|
192
|
+
}
|
|
193
|
+
propRegex.lastIndex = 0;
|
|
194
|
+
let propMatch;
|
|
195
|
+
while ((propMatch = propRegex.exec(propsStr)) !== null) {
|
|
196
|
+
const propName = propMatch[1];
|
|
197
|
+
const propValue = propMatch[2];
|
|
198
|
+
if (!usage.sampleProps[propName]) {
|
|
199
|
+
usage.sampleProps[propName] = [];
|
|
200
|
+
}
|
|
201
|
+
if (!usage.sampleProps[propName].includes(propValue)) {
|
|
202
|
+
usage.sampleProps[propName].push(propValue);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return Array.from(usageMap.values()).sort((a, b) => b.usageCount - a.usageCount);
|
|
208
|
+
}
|
|
209
|
+
// ─── Formatting ───────────────────────────────────────────────────────────────
|
|
210
|
+
function formatOutput(dsName, tokens, componentInterfaces, components) {
|
|
211
|
+
const lines = [`=== Design System: ${dsName} ===`, ""];
|
|
212
|
+
// Tokens grouped by category
|
|
213
|
+
if (tokens.length > 0) {
|
|
214
|
+
const groups = new Map();
|
|
215
|
+
for (const t of tokens) {
|
|
216
|
+
if (!groups.has(t.group))
|
|
217
|
+
groups.set(t.group, []);
|
|
218
|
+
groups.get(t.group).push(t);
|
|
219
|
+
}
|
|
220
|
+
for (const [group, groupTokens] of groups) {
|
|
221
|
+
lines.push(`--- ${group.toUpperCase()} ---`);
|
|
222
|
+
for (const t of groupTokens) {
|
|
223
|
+
lines.push(` ${t.name}: ${t.value}`);
|
|
224
|
+
}
|
|
225
|
+
lines.push("");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// Component TypeScript interfaces
|
|
229
|
+
if (Object.keys(componentInterfaces).length > 0) {
|
|
230
|
+
lines.push("--- COMPONENT INTERFACES ---");
|
|
231
|
+
for (const [, iface] of Object.entries(componentInterfaces)) {
|
|
232
|
+
lines.push("", iface);
|
|
233
|
+
}
|
|
234
|
+
lines.push("");
|
|
235
|
+
}
|
|
236
|
+
// Usage patterns
|
|
237
|
+
if (components.length > 0) {
|
|
238
|
+
lines.push("--- COMPONENT USAGE PATTERNS ---");
|
|
239
|
+
lines.push("(props and values observed in the codebase)");
|
|
240
|
+
for (const c of components.slice(0, 20)) {
|
|
241
|
+
lines.push(`\n${c.componentName} (${c.usageCount} uses, from '${c.importedFrom}')`);
|
|
242
|
+
for (const [prop, values] of Object.entries(c.sampleProps)) {
|
|
243
|
+
lines.push(` ${prop}: ${values.slice(0, 10).join(" | ")}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return lines.join("\n");
|
|
248
|
+
}
|
|
249
|
+
// ─── Handler Factory ──────────────────────────────────────────────────────────
|
|
250
|
+
function createDsToolHandlers(dsConfig) {
|
|
251
|
+
return {
|
|
252
|
+
devlens_ds_context: async (params) => {
|
|
253
|
+
if (!dsConfig) {
|
|
254
|
+
return {
|
|
255
|
+
content: [
|
|
256
|
+
{
|
|
257
|
+
type: "text",
|
|
258
|
+
text: [
|
|
259
|
+
"No design system configured.",
|
|
260
|
+
"",
|
|
261
|
+
"To enable DS context, create devlens.config.json in your app root:",
|
|
262
|
+
JSON.stringify({
|
|
263
|
+
designSystem: {
|
|
264
|
+
name: "jds3",
|
|
265
|
+
projectRoot: "/absolute/path/to/your-app",
|
|
266
|
+
tokensFile: "src/constants/figmaTokens.ts",
|
|
267
|
+
componentsDir: "src/jds-components",
|
|
268
|
+
componentsGlob: "src/**/*.tsx",
|
|
269
|
+
},
|
|
270
|
+
}, null, 2),
|
|
271
|
+
"",
|
|
272
|
+
"Then point to it in your MCP config env block:",
|
|
273
|
+
' "DEVLENS_CONFIG": "/absolute/path/to/your-app/devlens.config.json"',
|
|
274
|
+
].join("\n"),
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
isError: true,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
const absoluteProjectRoot = (0, path_1.resolve)(dsConfig.projectRoot);
|
|
281
|
+
const absoluteTokensFile = (0, path_1.join)(absoluteProjectRoot, dsConfig.tokensFile);
|
|
282
|
+
const absoluteComponentsDir = dsConfig.componentsDir
|
|
283
|
+
? (0, path_1.join)(absoluteProjectRoot, dsConfig.componentsDir)
|
|
284
|
+
: null;
|
|
285
|
+
// Run all analyses in parallel
|
|
286
|
+
const [tokens, componentInterfaces, components] = await Promise.all([
|
|
287
|
+
params.includeTokens
|
|
288
|
+
? parseTokensFile(absoluteTokensFile)
|
|
289
|
+
: Promise.resolve([]),
|
|
290
|
+
params.includeInterfaces && absoluteComponentsDir
|
|
291
|
+
? readComponentInterfaces(absoluteComponentsDir)
|
|
292
|
+
: Promise.resolve({}),
|
|
293
|
+
params.includeComponents
|
|
294
|
+
? scanComponentUsages(absoluteProjectRoot)
|
|
295
|
+
: Promise.resolve([]),
|
|
296
|
+
]);
|
|
297
|
+
const summary = [
|
|
298
|
+
`${tokens.length} tokens`,
|
|
299
|
+
`${Object.keys(componentInterfaces).length} component interfaces`,
|
|
300
|
+
`${components.reduce((s, c) => s + c.usageCount, 0)} component usages across ${components.length} component types`,
|
|
301
|
+
].join(", ");
|
|
302
|
+
console.error(`[devlens] DS context: ${summary}`);
|
|
303
|
+
return {
|
|
304
|
+
content: [
|
|
305
|
+
{
|
|
306
|
+
type: "text",
|
|
307
|
+
text: formatOutput(dsConfig.name, tokens, componentInterfaces, components),
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
};
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
//# sourceMappingURL=ds-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ds-tools.js","sourceRoot":"","sources":["../../../src/tools/ds-tools.ts"],"names":[],"mappings":";;;AA8TA,oDA4EC;AA1YD,6BAAwB;AACxB,0CAAsD;AACtD,+BAAqC;AAiCrC,gFAAgF;AAEnE,QAAA,aAAa,GAAG;IAC3B,kBAAkB,EAAE;QAClB,WAAW,EACT,oXAAoX;QACtX,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;YACnB,aAAa,EAAE,OAAC;iBACb,OAAO,EAAE;iBACT,OAAO,CAAC,IAAI,CAAC;iBACb,QAAQ,CAAC,2DAA2D,CAAC;YACxE,iBAAiB,EAAE,OAAC;iBACjB,OAAO,EAAE;iBACT,OAAO,CAAC,IAAI,CAAC;iBACb,QAAQ,CAAC,+EAA+E,CAAC;YAC5F,iBAAiB,EAAE,OAAC;iBACjB,OAAO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e,CAAC,kBAAkB,CAAC;oBACrC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAkB,CAAC;gBACvC,MAAM,CAAC,iBAAiB,IAAI,qBAAqB;oBAC/C,CAAC,CAAC,uBAAuB,CAAC,qBAAqB,CAAC;oBAChD,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAA4B,CAAC;gBACjD,MAAM,CAAC,iBAAiB;oBACtB,CAAC,CAAC,mBAAmB,CAAC,mBAAmB,CAAC;oBAC1C,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAA6B,CAAC;aACnD,CAAC,CAAC;YAEH,MAAM,OAAO,GAAG;gBACd,GAAG,MAAM,CAAC,MAAM,SAAS;gBACzB,GAAG,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,MAAM,uBAAuB;gBACjE,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,4BAA4B,UAAU,CAAC,MAAM,kBAAkB;aACnH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEb,OAAO,CAAC,KAAK,CAAC,yBAAyB,OAAO,EAAE,CAAC,CAAC;YAElD,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,mBAAmB,EAAE,UAAU,CAAC;qBAC3E;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { DeviceManager } from "../platform/device-manager.js";
|
|
3
|
+
import { RefRegistry } from "../snapshot/ref-registry.js";
|
|
4
|
+
export declare const interactionToolSchemas: {
|
|
5
|
+
devlens_tap: {
|
|
6
|
+
description: string;
|
|
7
|
+
parameters: z.ZodObject<{
|
|
8
|
+
ref: z.ZodString;
|
|
9
|
+
element: z.ZodString;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
ref: string;
|
|
12
|
+
element: string;
|
|
13
|
+
}, {
|
|
14
|
+
ref: string;
|
|
15
|
+
element: string;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
devlens_type: {
|
|
19
|
+
description: string;
|
|
20
|
+
parameters: z.ZodObject<{
|
|
21
|
+
ref: z.ZodString;
|
|
22
|
+
text: z.ZodString;
|
|
23
|
+
submit: z.ZodDefault<z.ZodBoolean>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
text: string;
|
|
26
|
+
ref: string;
|
|
27
|
+
submit: boolean;
|
|
28
|
+
}, {
|
|
29
|
+
text: string;
|
|
30
|
+
ref: string;
|
|
31
|
+
submit?: boolean | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
34
|
+
devlens_swipe: {
|
|
35
|
+
description: string;
|
|
36
|
+
parameters: z.ZodObject<{
|
|
37
|
+
direction: z.ZodEnum<["up", "down", "left", "right"]>;
|
|
38
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
39
|
+
distance: z.ZodDefault<z.ZodNumber>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
direction: "up" | "down" | "left" | "right";
|
|
42
|
+
distance: number;
|
|
43
|
+
ref?: string | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
direction: "up" | "down" | "left" | "right";
|
|
46
|
+
ref?: string | undefined;
|
|
47
|
+
distance?: number | undefined;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
devlens_scroll: {
|
|
51
|
+
description: string;
|
|
52
|
+
parameters: z.ZodObject<{
|
|
53
|
+
ref: z.ZodString;
|
|
54
|
+
direction: z.ZodEnum<["up", "down"]>;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
ref: string;
|
|
57
|
+
direction: "up" | "down";
|
|
58
|
+
}, {
|
|
59
|
+
ref: string;
|
|
60
|
+
direction: "up" | "down";
|
|
61
|
+
}>;
|
|
62
|
+
};
|
|
63
|
+
devlens_long_press: {
|
|
64
|
+
description: string;
|
|
65
|
+
parameters: z.ZodObject<{
|
|
66
|
+
ref: z.ZodString;
|
|
67
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
ref: string;
|
|
70
|
+
duration: number;
|
|
71
|
+
}, {
|
|
72
|
+
ref: string;
|
|
73
|
+
duration?: number | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
};
|
|
76
|
+
devlens_press_button: {
|
|
77
|
+
description: string;
|
|
78
|
+
parameters: z.ZodObject<{
|
|
79
|
+
button: z.ZodEnum<["home", "back", "enter"]>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
button: "home" | "back" | "enter";
|
|
82
|
+
}, {
|
|
83
|
+
button: "home" | "back" | "enter";
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
devlens_fill_form: {
|
|
87
|
+
description: string;
|
|
88
|
+
parameters: z.ZodObject<{
|
|
89
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
90
|
+
ref: z.ZodString;
|
|
91
|
+
value: z.ZodString;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
value: string;
|
|
94
|
+
ref: string;
|
|
95
|
+
}, {
|
|
96
|
+
value: string;
|
|
97
|
+
ref: string;
|
|
98
|
+
}>, "many">;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
fields: {
|
|
101
|
+
value: string;
|
|
102
|
+
ref: string;
|
|
103
|
+
}[];
|
|
104
|
+
}, {
|
|
105
|
+
fields: {
|
|
106
|
+
value: string;
|
|
107
|
+
ref: string;
|
|
108
|
+
}[];
|
|
109
|
+
}>;
|
|
110
|
+
};
|
|
111
|
+
devlens_capture_flow: {
|
|
112
|
+
description: string;
|
|
113
|
+
parameters: z.ZodObject<{
|
|
114
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
115
|
+
action: z.ZodEnum<["tap", "screenshot", "go_back", "swipe", "wait", "press_button"]>;
|
|
116
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
117
|
+
element: z.ZodOptional<z.ZodString>;
|
|
118
|
+
label: z.ZodOptional<z.ZodString>;
|
|
119
|
+
direction: z.ZodOptional<z.ZodEnum<["up", "down", "left", "right"]>>;
|
|
120
|
+
button: z.ZodOptional<z.ZodEnum<["home", "back", "enter"]>>;
|
|
121
|
+
ms: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
action: "screenshot" | "tap" | "swipe" | "go_back" | "wait" | "press_button";
|
|
124
|
+
button?: "home" | "back" | "enter" | undefined;
|
|
125
|
+
label?: string | undefined;
|
|
126
|
+
ref?: string | undefined;
|
|
127
|
+
element?: string | undefined;
|
|
128
|
+
direction?: "up" | "down" | "left" | "right" | undefined;
|
|
129
|
+
ms?: number | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
action: "screenshot" | "tap" | "swipe" | "go_back" | "wait" | "press_button";
|
|
132
|
+
button?: "home" | "back" | "enter" | undefined;
|
|
133
|
+
label?: string | undefined;
|
|
134
|
+
ref?: string | undefined;
|
|
135
|
+
element?: string | undefined;
|
|
136
|
+
direction?: "up" | "down" | "left" | "right" | undefined;
|
|
137
|
+
ms?: number | undefined;
|
|
138
|
+
}>, "many">;
|
|
139
|
+
}, "strip", z.ZodTypeAny, {
|
|
140
|
+
steps: {
|
|
141
|
+
action: "screenshot" | "tap" | "swipe" | "go_back" | "wait" | "press_button";
|
|
142
|
+
button?: "home" | "back" | "enter" | undefined;
|
|
143
|
+
label?: string | undefined;
|
|
144
|
+
ref?: string | undefined;
|
|
145
|
+
element?: string | undefined;
|
|
146
|
+
direction?: "up" | "down" | "left" | "right" | undefined;
|
|
147
|
+
ms?: number | undefined;
|
|
148
|
+
}[];
|
|
149
|
+
}, {
|
|
150
|
+
steps: {
|
|
151
|
+
action: "screenshot" | "tap" | "swipe" | "go_back" | "wait" | "press_button";
|
|
152
|
+
button?: "home" | "back" | "enter" | undefined;
|
|
153
|
+
label?: string | undefined;
|
|
154
|
+
ref?: string | undefined;
|
|
155
|
+
element?: string | undefined;
|
|
156
|
+
direction?: "up" | "down" | "left" | "right" | undefined;
|
|
157
|
+
ms?: number | undefined;
|
|
158
|
+
}[];
|
|
159
|
+
}>;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
export declare function createInteractionToolHandlers(deviceManager: DeviceManager, refRegistry: RefRegistry, onNavigate?: () => void): {
|
|
163
|
+
devlens_tap: (params: {
|
|
164
|
+
ref: string;
|
|
165
|
+
element: string;
|
|
166
|
+
}) => Promise<{
|
|
167
|
+
content: {
|
|
168
|
+
type: "text";
|
|
169
|
+
text: string;
|
|
170
|
+
}[];
|
|
171
|
+
}>;
|
|
172
|
+
devlens_type: (params: {
|
|
173
|
+
ref: string;
|
|
174
|
+
text: string;
|
|
175
|
+
submit: boolean;
|
|
176
|
+
}) => Promise<{
|
|
177
|
+
content: {
|
|
178
|
+
type: "text";
|
|
179
|
+
text: string;
|
|
180
|
+
}[];
|
|
181
|
+
}>;
|
|
182
|
+
devlens_swipe: (params: {
|
|
183
|
+
direction: "up" | "down" | "left" | "right";
|
|
184
|
+
ref?: string;
|
|
185
|
+
distance: number;
|
|
186
|
+
}) => Promise<{
|
|
187
|
+
content: {
|
|
188
|
+
type: "text";
|
|
189
|
+
text: string;
|
|
190
|
+
}[];
|
|
191
|
+
}>;
|
|
192
|
+
devlens_scroll: (params: {
|
|
193
|
+
ref: string;
|
|
194
|
+
direction: "up" | "down";
|
|
195
|
+
}) => Promise<{
|
|
196
|
+
content: {
|
|
197
|
+
type: "text";
|
|
198
|
+
text: string;
|
|
199
|
+
}[];
|
|
200
|
+
}>;
|
|
201
|
+
devlens_long_press: (params: {
|
|
202
|
+
ref: string;
|
|
203
|
+
duration: number;
|
|
204
|
+
}) => Promise<{
|
|
205
|
+
content: {
|
|
206
|
+
type: "text";
|
|
207
|
+
text: string;
|
|
208
|
+
}[];
|
|
209
|
+
}>;
|
|
210
|
+
devlens_press_button: (params: {
|
|
211
|
+
button: "home" | "back" | "enter";
|
|
212
|
+
}) => Promise<{
|
|
213
|
+
content: {
|
|
214
|
+
type: "text";
|
|
215
|
+
text: string;
|
|
216
|
+
}[];
|
|
217
|
+
}>;
|
|
218
|
+
devlens_fill_form: (params: {
|
|
219
|
+
fields: Array<{
|
|
220
|
+
ref: string;
|
|
221
|
+
value: string;
|
|
222
|
+
}>;
|
|
223
|
+
}) => Promise<{
|
|
224
|
+
content: {
|
|
225
|
+
type: "text";
|
|
226
|
+
text: string;
|
|
227
|
+
}[];
|
|
228
|
+
}>;
|
|
229
|
+
devlens_capture_flow: (params: {
|
|
230
|
+
steps: Array<{
|
|
231
|
+
action: "tap" | "screenshot" | "go_back" | "swipe" | "wait" | "press_button";
|
|
232
|
+
ref?: string;
|
|
233
|
+
element?: string;
|
|
234
|
+
label?: string;
|
|
235
|
+
direction?: "up" | "down" | "left" | "right";
|
|
236
|
+
button?: "home" | "back" | "enter";
|
|
237
|
+
ms?: number;
|
|
238
|
+
}>;
|
|
239
|
+
}) => Promise<{
|
|
240
|
+
content: {
|
|
241
|
+
type: "text" | "image";
|
|
242
|
+
text?: string;
|
|
243
|
+
data?: string;
|
|
244
|
+
mimeType?: string;
|
|
245
|
+
}[];
|
|
246
|
+
}>;
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=interaction-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/interaction-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,WA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