@letsrunit/mcp-server 0.14.3 → 0.14.5
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/dist/{chunk-XJCBPTOU.js → chunk-CEICWMN3.js} +21 -11
- package/dist/chunk-CEICWMN3.js.map +1 -0
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/{tools-T3XUV2RO.js → tools-3QWUX4W5.js} +52 -42
- package/dist/tools-3QWUX4W5.js.map +1 -0
- package/package.json +8 -8
- package/src/bootstrap.ts +20 -9
- package/src/index.ts +5 -4
- package/src/tools/diagnostics.ts +2 -2
- package/src/tools/session-start.ts +13 -3
- package/src/utility/diagnostics.ts +159 -0
- package/src/utility/support.ts +9 -146
- package/dist/chunk-XJCBPTOU.js.map +0 -1
- package/dist/tools-T3XUV2RO.js.map +0 -1
|
@@ -30,16 +30,28 @@ function sameEntrypoint(a, b) {
|
|
|
30
30
|
if (!a || !b) return false;
|
|
31
31
|
return a === b;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function resolveRuntimeModeOverride() {
|
|
34
|
+
const runtimeMode = process.env.LETSRUNIT_MCP_RUNTIME_MODE;
|
|
35
|
+
if (runtimeMode == null || runtimeMode === "") {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (runtimeMode === "project" || runtimeMode === "standalone") {
|
|
39
|
+
return runtimeMode;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Invalid LETSRUNIT_MCP_RUNTIME_MODE: ${runtimeMode}. Expected "project" or "standalone".`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function decideHandoff(currentEntrypointPath, projectEntrypointPath, runtimeModeOverride) {
|
|
46
|
+
if (runtimeModeOverride) {
|
|
47
|
+
return { shouldHandoff: false, runtimeMode: runtimeModeOverride };
|
|
48
|
+
}
|
|
34
49
|
if (!projectEntrypointPath) {
|
|
35
50
|
return { shouldHandoff: false, runtimeMode: "standalone" };
|
|
36
51
|
}
|
|
37
52
|
if (sameEntrypoint(currentEntrypointPath, projectEntrypointPath)) {
|
|
38
53
|
return { shouldHandoff: false, runtimeMode: "project" };
|
|
39
54
|
}
|
|
40
|
-
if (isBootstrapped) {
|
|
41
|
-
return { shouldHandoff: false, runtimeMode: "standalone" };
|
|
42
|
-
}
|
|
43
55
|
return { shouldHandoff: true, runtimeMode: "project" };
|
|
44
56
|
}
|
|
45
57
|
function runProjectLocalServer(projectEntrypointPath) {
|
|
@@ -47,7 +59,6 @@ function runProjectLocalServer(projectEntrypointPath) {
|
|
|
47
59
|
stdio: "inherit",
|
|
48
60
|
env: {
|
|
49
61
|
...process.env,
|
|
50
|
-
LETSRUNIT_MCP_BOOTSTRAPPED: "1",
|
|
51
62
|
LETSRUNIT_MCP_RUNTIME_MODE: "project"
|
|
52
63
|
}
|
|
53
64
|
});
|
|
@@ -56,17 +67,16 @@ function runProjectLocalServer(projectEntrypointPath) {
|
|
|
56
67
|
}
|
|
57
68
|
function bootstrapProjectServer() {
|
|
58
69
|
const projectRoot = resolveProjectRoot();
|
|
59
|
-
const
|
|
70
|
+
const runtimeModeOverride = resolveRuntimeModeOverride();
|
|
60
71
|
const currentEntryPath = toRealpath(fileURLToPath(import.meta.url));
|
|
61
72
|
const projectEntryPath = toRealpath(resolveFromProject("@letsrunit/mcp-server", projectRoot));
|
|
62
|
-
const decision = decideHandoff(currentEntryPath, projectEntryPath,
|
|
73
|
+
const decision = decideHandoff(currentEntryPath, projectEntryPath, runtimeModeOverride);
|
|
63
74
|
if (decision.shouldHandoff && projectEntryPath) {
|
|
64
75
|
runProjectLocalServer(projectEntryPath);
|
|
65
76
|
}
|
|
66
|
-
process.env.LETSRUNIT_MCP_RUNTIME_MODE = decision.runtimeMode;
|
|
67
77
|
return decision.runtimeMode;
|
|
68
78
|
}
|
|
69
79
|
|
|
70
|
-
export { bootstrapProjectServer, decideHandoff };
|
|
71
|
-
//# sourceMappingURL=chunk-
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
export { bootstrapProjectServer, decideHandoff, resolveRuntimeModeOverride };
|
|
81
|
+
//# sourceMappingURL=chunk-CEICWMN3.js.map
|
|
82
|
+
//# sourceMappingURL=chunk-CEICWMN3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bootstrap.ts"],"names":[],"mappings":";;;;;;;;;AAaA,SAAS,kBAAA,GAA6B;AACpC,EAAA,OAAO,QAAQ,OAAA,CAAQ,GAAA,CAAI,qBAAA,IAAyB,OAAA,CAAQ,KAAK,CAAA;AACnE;AAEA,SAAS,kBAAA,CAAmB,UAAkB,WAAA,EAAoC;AAChF,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,aAAA,CAAc,OAAA,CAAQ,WAAA,EAAa,cAAc,CAAC,CAAA;AAC9D,IAAA,OAAO,GAAA,CAAI,QAAQ,QAAQ,CAAA;AAAA,EAC7B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,SAAS,WAAW,IAAA,EAAoC;AACtD,EAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,EAAA,IAAI;AACF,IAAA,OAAO,aAAa,IAAI,CAAA;AAAA,EAC1B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,SAAS,cAAA,CAAe,GAAkB,CAAA,EAA2B;AACnE,EAAA,IAAI,CAAC,CAAA,IAAK,CAAC,CAAA,EAAG,OAAO,KAAA;AACrB,EAAA,OAAO,CAAA,KAAM,CAAA;AACf;AAEO,SAAS,0BAAA,GAAoD;AAClE,EAAA,MAAM,WAAA,GAAc,QAAQ,GAAA,CAAI,0BAAA;AAChC,EAAA,IAAI,WAAA,IAAe,IAAA,IAAQ,WAAA,KAAgB,EAAA,EAAI;AAC7C,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAI,WAAA,KAAgB,SAAA,IAAa,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AM,sBAAsB,0BAAA,EAA2B;AAEvD,EAAA,MAAM,gBAAA,GAAmB,UAAA,CAAW,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAClE,EAAA,MAAM,gBAAA,GAAmB,UAAA,CAAW,kBAAA,CAAmB,uBAAA,EAAyB,WAAW,CAAC,CAAA;AAE5F,EAAA,MAAM,QAAA,GAAW,aAAA,CAAc,gBAAA,EAAkB,gBAAA,EAAkB,mBAAmB,CAAA;AAEtF,EAAA,IAAI,QAAA,CAAS,iBAAiB,gBAAA,EAAkB;AAC9C,IAAA,qBAAA,CAAsB,gBAAgB,CAAA;AAAA,EACxC;AAEA,EAAA,OAAO,QAAA,CAAS,WAAA;AAClB","file":"chunk-CEICWMN3.js","sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { realpathSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport type McpRuntimeMode = 'project' | 'standalone';\n\nexport type HandoffDecision = {\n shouldHandoff: boolean;\n runtimeMode: McpRuntimeMode;\n};\n\nfunction resolveProjectRoot(): string {\n return resolve(process.env.LETSRUNIT_PROJECT_CWD ?? process.cwd());\n}\n\nfunction resolveFromProject(moduleId: string, projectRoot: string): string | null {\n try {\n const req = createRequire(resolve(projectRoot, 'package.json'));\n return req.resolve(moduleId);\n } catch {\n return null;\n }\n}\n\nfunction toRealpath(path: string | null): string | null {\n if (!path) return null;\n try {\n return realpathSync(path);\n } catch {\n return null;\n }\n}\n\nfunction sameEntrypoint(a: string | null, b: string | null): boolean {\n if (!a || !b) return false;\n return a === b;\n}\n\nexport function resolveRuntimeModeOverride(): McpRuntimeMode | null {\n const runtimeMode = process.env.LETSRUNIT_MCP_RUNTIME_MODE;\n if (runtimeMode == null || runtimeMode === '') {\n return null;\n }\n if (runtimeMode === 'project' || runtimeMode === 'standalone') {\n return runtimeMode;\n }\n throw new Error(\n `Invalid LETSRUNIT_MCP_RUNTIME_MODE: ${runtimeMode}. Expected \"project\" or \"standalone\".`,\n );\n}\n\nexport function decideHandoff(\n currentEntrypointPath: string | null,\n projectEntrypointPath: string | null,\n runtimeModeOverride: McpRuntimeMode | null,\n): HandoffDecision {\n if (runtimeModeOverride) {\n return { shouldHandoff: false, runtimeMode: runtimeModeOverride };\n }\n\n if (!projectEntrypointPath) {\n return { shouldHandoff: false, runtimeMode: 'standalone' };\n }\n\n if (sameEntrypoint(currentEntrypointPath, projectEntrypointPath)) {\n return { shouldHandoff: false, runtimeMode: 'project' };\n }\n\n return { shouldHandoff: true, runtimeMode: 'project' };\n}\n\nfunction runProjectLocalServer(projectEntrypointPath: string): never {\n const result = spawnSync(process.execPath, [projectEntrypointPath, ...process.argv.slice(2)], {\n stdio: 'inherit',\n env: {\n ...process.env,\n LETSRUNIT_MCP_RUNTIME_MODE: 'project',\n },\n });\n\n if (result.error) throw result.error;\n process.exit(result.status ?? 1);\n}\n\nexport function bootstrapProjectServer(): McpRuntimeMode {\n const projectRoot = resolveProjectRoot();\n const runtimeModeOverride = resolveRuntimeModeOverride();\n\n const currentEntryPath = toRealpath(fileURLToPath(import.meta.url));\n const projectEntryPath = toRealpath(resolveFromProject('@letsrunit/mcp-server', projectRoot));\n\n const decision = decideHandoff(currentEntryPath, projectEntryPath, runtimeModeOverride);\n\n if (decision.shouldHandoff && projectEntryPath) {\n runProjectLocalServer(projectEntryPath);\n }\n\n return decision.runtimeMode;\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as __m from 'node:module';
|
|
3
|
-
import { bootstrapProjectServer } from './chunk-
|
|
4
|
-
import { createRequire } from 'module';
|
|
3
|
+
import { bootstrapProjectServer } from './chunk-CEICWMN3.js';
|
|
5
4
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
5
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
7
6
|
|
|
8
7
|
__m.createRequire(import.meta.url);
|
|
9
|
-
var
|
|
10
|
-
bootstrapProjectServer();
|
|
8
|
+
var version = "0.14.5" ;
|
|
9
|
+
var runtimeMode = bootstrapProjectServer();
|
|
11
10
|
var { SessionManager } = await import('./sessions-BYH3NJQG.js');
|
|
12
11
|
var {
|
|
13
12
|
registerDebug,
|
|
@@ -20,14 +19,14 @@ var {
|
|
|
20
19
|
registerSessionClose,
|
|
21
20
|
registerSessionStart,
|
|
22
21
|
registerSnapshot
|
|
23
|
-
} = await import('./tools-
|
|
22
|
+
} = await import('./tools-3QWUX4W5.js');
|
|
24
23
|
var sessions = new SessionManager();
|
|
25
24
|
var server = new McpServer({
|
|
26
25
|
name: "letsrunit",
|
|
27
26
|
version,
|
|
28
27
|
websiteUrl: "https://letsrunit.ai"
|
|
29
28
|
});
|
|
30
|
-
registerSessionStart(server, sessions);
|
|
29
|
+
registerSessionStart(server, sessions, { runtimeMode });
|
|
31
30
|
registerRun(server, sessions);
|
|
32
31
|
registerSnapshot(server, sessions);
|
|
33
32
|
registerScreenshot(server, sessions);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAMA,IAAM,OAAA,GAAsD,QAAA,CAAwB;AACpF,IAAM,cAAc,sBAAA,EAAuB;AAE3C,IAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,wBAAY,CAAA;AACpD,IAAM;AAAA,EACJ,aAAA;AAAA,EACA,mBAAA;AAAA,EACA,YAAA;AAAA,EACA,iBAAA;AAAA,EACA,oBAAA;AAAA,EACA,WAAA;AAAA,EACA,kBAAA;AAAA,EACA,oBAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF,CAAA,GAAI,MAAM,OAAO,qBAAS,CAAA;AAE1B,IAAM,QAAA,GAAW,IAAI,cAAA,EAAe;AAEpC,IAAM,MAAA,GAAS,IAAI,SAAA,CAAU;AAAA,EAC3B,IAAA,EAAM,WAAA;AAAA,EACN,OAAA;AAAA,EACA,UAAA,EAAY;AACd,CAAC,CAAA;AAED,oBAAA,CAAqB,MAAA,EAAQ,QAAA,EAAU,EAAE,WAAA,EAAa,CAAA;AACtD,WAAA,CAAY,QAAQ,QAAQ,CAAA;AAC5B,gBAAA,CAAiB,QAAQ,QAAQ,CAAA;AACjC,kBAAA,CAAmB,QAAQ,QAAQ,CAAA;AACnC,aAAA,CAAc,QAAQ,QAAQ,CAAA;AAC9B,oBAAA,CAAqB,QAAQ,QAAQ,CAAA;AACrC,iBAAA,CAAkB,QAAQ,QAAQ,CAAA;AAClC,oBAAA,CAAqB,QAAQ,QAAQ,CAAA;AACrC,YAAA,CAAa,QAAQ,QAAQ,CAAA;AAC7B,IAAI,OAAA,CAAQ,GAAA,CAAI,yBAAA,KAA8B,SAAA,EAAW;AACvD,EAAA,mBAAA,CAAoB,QAAQ,QAAQ,CAAA;AACtC;AAEA,IAAM,SAAA,GAAY,IAAI,oBAAA,EAAqB;AAC3C,MAAM,MAAA,CAAO,QAAQ,SAAS,CAAA","file":"index.js","sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { bootstrapProjectServer } from './bootstrap';\n\ndeclare const __LETSRUNIT_VERSION__: string | undefined;\n\nconst version = typeof __LETSRUNIT_VERSION__ === 'string' ? __LETSRUNIT_VERSION__ : 'unknown';\nconst runtimeMode = bootstrapProjectServer();\n\nconst { SessionManager } = await import('./sessions');\nconst {\n registerDebug,\n registerDiagnostics,\n registerDiff,\n registerListSteps,\n registerListSessions,\n registerRun,\n registerScreenshot,\n registerSessionClose,\n registerSessionStart,\n registerSnapshot,\n} = await import('./tools');\n\nconst sessions = new SessionManager();\n\nconst server = new McpServer({\n name: 'letsrunit',\n version,\n websiteUrl: 'https://letsrunit.ai',\n});\n\nregisterSessionStart(server, sessions, { runtimeMode });\nregisterRun(server, sessions);\nregisterSnapshot(server, sessions);\nregisterScreenshot(server, sessions);\nregisterDebug(server, sessions);\nregisterSessionClose(server, sessions);\nregisterListSteps(server, sessions);\nregisterListSessions(server, sessions);\nregisterDiff(server, sessions);\nif (process.env.LETSRUNIT_MCP_DIAGNOSTICS === 'enabled') {\n registerDiagnostics(server, sessions);\n}\n\nconst transport = new StdioServerTransport();\nawait server.connect(transport);\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as __m from 'node:module';
|
|
3
|
-
import { decideHandoff } from './chunk-
|
|
3
|
+
import { decideHandoff, resolveRuntimeModeOverride } from './chunk-CEICWMN3.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { loadConfiguration } from '@cucumber/cucumber/api';
|
|
6
6
|
import { registry } from '@letsrunit/bdd';
|
|
7
7
|
import { readFileSync, existsSync, realpathSync } from 'fs';
|
|
8
|
-
import { mkdir, writeFile, glob } from 'fs/promises';
|
|
9
8
|
import { createRequire } from 'module';
|
|
10
9
|
import { join, dirname, resolve, isAbsolute } from 'path';
|
|
11
10
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
11
|
+
import { mkdir, writeFile, glob } from 'fs/promises';
|
|
12
12
|
import { unifiedHtmlDiff, screenshotElement, screenshot, scrubHtml } from '@letsrunit/playwright';
|
|
13
13
|
import { openStore, findLastTest, findArtifacts } from '@letsrunit/store';
|
|
14
14
|
import { execSync } from 'child_process';
|
|
@@ -120,6 +120,41 @@ async function loadLetsrunitIgnorePatterns(cwd) {
|
|
|
120
120
|
function resolveEffectiveCwd(cwd) {
|
|
121
121
|
return cwd ?? process.env.LETSRUNIT_PROJECT_CWD ?? process.cwd();
|
|
122
122
|
}
|
|
123
|
+
function getSupportLoadState() {
|
|
124
|
+
return {
|
|
125
|
+
loadedProjectRoots: [...loadedProjectRoots].sort(),
|
|
126
|
+
loadedSupportEntries: [...loadedSupportEntries].sort()
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
async function loadSupportFiles(cwd) {
|
|
130
|
+
const projectRoot = resolve(resolveEffectiveCwd(cwd));
|
|
131
|
+
if (loadedProjectRoots.has(projectRoot)) return;
|
|
132
|
+
const { useConfiguration } = await loadConfiguration({}, { cwd: projectRoot });
|
|
133
|
+
const supportPatterns = [...toStrings(useConfiguration.require), ...toStrings(useConfiguration.import)];
|
|
134
|
+
if (supportPatterns.length === 0) {
|
|
135
|
+
loadedProjectRoots.add(projectRoot);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const ignorePatterns = await loadLetsrunitIgnorePatterns(projectRoot);
|
|
139
|
+
const ignoredPaths = await expandPathPatterns(projectRoot, ignorePatterns);
|
|
140
|
+
const supportEntries = await resolveSupportEntries(projectRoot, supportPatterns);
|
|
141
|
+
for (const entry of supportEntries) {
|
|
142
|
+
if (entry.kind === "path" && ignoredPaths.has(entry.value)) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const key = `${entry.kind}:${entry.value}`;
|
|
146
|
+
if (loadedSupportEntries.has(key)) continue;
|
|
147
|
+
if (entry.kind === "path") {
|
|
148
|
+
await import(pathToFileURL(entry.value).href);
|
|
149
|
+
} else {
|
|
150
|
+
await import(entry.value);
|
|
151
|
+
}
|
|
152
|
+
loadedSupportEntries.add(key);
|
|
153
|
+
}
|
|
154
|
+
loadedProjectRoots.add(projectRoot);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/utility/diagnostics.ts
|
|
123
158
|
function resolveFrom(moduleId, fromPath) {
|
|
124
159
|
try {
|
|
125
160
|
const req = createRequire(fromPath);
|
|
@@ -141,30 +176,30 @@ function pickLetsrunitEnv() {
|
|
|
141
176
|
Object.entries(process.env).filter(([key, value]) => key.startsWith("LETSRUNIT_") && typeof value === "string").map(([key, value]) => [key, value])
|
|
142
177
|
);
|
|
143
178
|
}
|
|
144
|
-
async function
|
|
179
|
+
async function collectDiagnostics(cwd) {
|
|
145
180
|
const effectiveCwd = resolveEffectiveCwd(cwd);
|
|
146
181
|
const projectRoot = resolve(effectiveCwd);
|
|
147
182
|
const cucumberConfigPath = findCucumberConfig(projectRoot);
|
|
148
183
|
const { useConfiguration } = await loadConfiguration({}, { cwd: projectRoot });
|
|
149
|
-
const supportPatterns = [...
|
|
184
|
+
const supportPatterns = [...useConfiguration.require ?? [], ...useConfiguration.import ?? []];
|
|
150
185
|
const ignorePatterns = await loadLetsrunitIgnorePatterns(projectRoot);
|
|
151
186
|
const ignoredPaths = await expandPathPatterns(projectRoot, ignorePatterns);
|
|
152
187
|
const supportEntries = await resolveSupportEntries(projectRoot, supportPatterns);
|
|
188
|
+
const supportLoadState = getSupportLoadState();
|
|
153
189
|
const serverBddPath = toRealpath(resolveFrom("@letsrunit/bdd", import.meta.url));
|
|
154
190
|
const projectBddPath = toRealpath(resolveFrom("@letsrunit/bdd", resolve(projectRoot, "package.json")));
|
|
155
191
|
const projectMcpEntryPath = resolveFrom("@letsrunit/mcp-server", resolve(projectRoot, "package.json"));
|
|
156
|
-
const currentReq = createRequire(import.meta.url);
|
|
157
192
|
const currentEntrypointPath = toRealpath(fileURLToPath(import.meta.url));
|
|
158
193
|
const projectEntrypointPath = toRealpath(projectMcpEntryPath);
|
|
159
194
|
const handoffDecision = decideHandoff(
|
|
160
195
|
currentEntrypointPath,
|
|
161
196
|
projectEntrypointPath,
|
|
162
|
-
|
|
197
|
+
resolveRuntimeModeOverride()
|
|
163
198
|
);
|
|
164
199
|
const serverMcpPath = toRealpath(resolveFrom("@letsrunit/mcp-server", import.meta.url));
|
|
165
200
|
const projectMcpPath = toRealpath(projectMcpEntryPath);
|
|
166
201
|
const executablePath = toRealpath(process.argv[1] ?? null);
|
|
167
|
-
const
|
|
202
|
+
const version = "0.14.5" ;
|
|
168
203
|
const registryDefinitions = registry.defs.map((def) => ({
|
|
169
204
|
type: def.type,
|
|
170
205
|
source: def.source,
|
|
@@ -181,8 +216,8 @@ async function collectSupportDiagnostics(cwd) {
|
|
|
181
216
|
ignorePatterns,
|
|
182
217
|
ignoredPaths: [...ignoredPaths].sort(),
|
|
183
218
|
supportEntries,
|
|
184
|
-
loadedProjectRoots:
|
|
185
|
-
loadedSupportEntries:
|
|
219
|
+
loadedProjectRoots: supportLoadState.loadedProjectRoots,
|
|
220
|
+
loadedSupportEntries: supportLoadState.loadedSupportEntries,
|
|
186
221
|
mcpServer: {
|
|
187
222
|
version,
|
|
188
223
|
executablePath,
|
|
@@ -210,33 +245,6 @@ async function collectSupportDiagnostics(cwd) {
|
|
|
210
245
|
}
|
|
211
246
|
};
|
|
212
247
|
}
|
|
213
|
-
async function loadSupportFiles(cwd) {
|
|
214
|
-
const projectRoot = resolve(resolveEffectiveCwd(cwd));
|
|
215
|
-
if (loadedProjectRoots.has(projectRoot)) return;
|
|
216
|
-
const { useConfiguration } = await loadConfiguration({}, { cwd: projectRoot });
|
|
217
|
-
const supportPatterns = [...toStrings(useConfiguration.require), ...toStrings(useConfiguration.import)];
|
|
218
|
-
if (supportPatterns.length === 0) {
|
|
219
|
-
loadedProjectRoots.add(projectRoot);
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
const ignorePatterns = await loadLetsrunitIgnorePatterns(projectRoot);
|
|
223
|
-
const ignoredPaths = await expandPathPatterns(projectRoot, ignorePatterns);
|
|
224
|
-
const supportEntries = await resolveSupportEntries(projectRoot, supportPatterns);
|
|
225
|
-
for (const entry of supportEntries) {
|
|
226
|
-
if (entry.kind === "path" && ignoredPaths.has(entry.value)) {
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
const key = `${entry.kind}:${entry.value}`;
|
|
230
|
-
if (loadedSupportEntries.has(key)) continue;
|
|
231
|
-
if (entry.kind === "path") {
|
|
232
|
-
await import(pathToFileURL(entry.value).href);
|
|
233
|
-
} else {
|
|
234
|
-
await import(entry.value);
|
|
235
|
-
}
|
|
236
|
-
loadedSupportEntries.add(key);
|
|
237
|
-
}
|
|
238
|
-
loadedProjectRoots.add(projectRoot);
|
|
239
|
-
}
|
|
240
248
|
|
|
241
249
|
// src/tools/diagnostics.ts
|
|
242
250
|
function registerDiagnostics(server, sessions) {
|
|
@@ -250,7 +258,7 @@ function registerDiagnostics(server, sessions) {
|
|
|
250
258
|
},
|
|
251
259
|
async (input) => {
|
|
252
260
|
try {
|
|
253
|
-
const diagnostics = await
|
|
261
|
+
const diagnostics = await collectDiagnostics();
|
|
254
262
|
const session = sessions.get(input.sessionId);
|
|
255
263
|
const sessionInfo = {
|
|
256
264
|
sessionId: session.id,
|
|
@@ -484,13 +492,15 @@ function registerSessionClose(server, sessions) {
|
|
|
484
492
|
}
|
|
485
493
|
);
|
|
486
494
|
}
|
|
487
|
-
function registerSessionStart(server, sessions) {
|
|
495
|
+
function registerSessionStart(server, sessions, opts) {
|
|
488
496
|
server.registerTool(
|
|
489
497
|
"letsrunit_session_start",
|
|
490
498
|
{
|
|
491
499
|
description: `Launch a new browser session. Does not navigate anywhere \u2014 use letsrunit_run with a Given step to navigate. Set baseURL to enable relative paths like "Given I'm on the homepage".`,
|
|
492
500
|
inputSchema: {
|
|
493
|
-
baseURL: z.string().optional().describe(
|
|
501
|
+
baseURL: z.string().optional().describe(
|
|
502
|
+
`Base URL for the session, e.g. "http://localhost:3000". Enables relative paths in Given steps like "Given I'm on the homepage" or "Given I'm on page \\"/login\\""`
|
|
503
|
+
),
|
|
494
504
|
language: z.string().optional().describe("Browser language code, e.g. 'en', 'fr'"),
|
|
495
505
|
headless: z.boolean().optional().describe("Run browser in headless mode (default: true)"),
|
|
496
506
|
viewportWidth: z.number().int().optional().describe("Viewport width in pixels (default: 1280)"),
|
|
@@ -499,7 +509,7 @@ function registerSessionStart(server, sessions) {
|
|
|
499
509
|
},
|
|
500
510
|
async (input) => {
|
|
501
511
|
try {
|
|
502
|
-
if (
|
|
512
|
+
if (opts?.runtimeMode === "project") {
|
|
503
513
|
await loadSupportFiles();
|
|
504
514
|
}
|
|
505
515
|
const viewport = input.viewportWidth || input.viewportHeight ? { width: input.viewportWidth ?? 1280, height: input.viewportHeight ?? 720 } : void 0;
|
|
@@ -563,5 +573,5 @@ function registerSnapshot(server, sessions) {
|
|
|
563
573
|
}
|
|
564
574
|
|
|
565
575
|
export { registerDebug, registerDiagnostics, registerDiff, registerListSessions, registerListSteps, registerRun, registerScreenshot, registerSessionClose, registerSessionStart, registerSnapshot };
|
|
566
|
-
//# sourceMappingURL=tools-
|
|
567
|
-
//# sourceMappingURL=tools-
|
|
576
|
+
//# sourceMappingURL=tools-3QWUX4W5.js.map
|
|
577
|
+
//# sourceMappingURL=tools-3QWUX4W5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utility/response.ts","../src/tools/debug.ts","../src/utility/support.ts","../src/utility/diagnostics.ts","../src/tools/diagnostics.ts","../src/tools/diff.ts","../src/tools/list-steps.ts","../src/tools/list-sessions.ts","../src/utility/gherkin.ts","../src/tools/run.ts","../src/tools/screenshot.ts","../src/tools/session-close.ts","../src/tools/session-start.ts","../src/tools/snapshot.ts"],"names":["resolve","loadConfiguration","z","join"],"mappings":";;;;;;;;;;;;;;;;;;;AAAO,SAAS,KAAK,OAAA,EAAiB;AACpC,EAAA,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,MAAA,EAAiB,IAAA,EAAM,OAAA,EAAS,CAAA,EAAE;AAC/D;AAEO,SAAS,IAAI,OAAA,EAAiB;AACnC,EAAA,OAAO,EAAE,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,MAAA,EAAiB,IAAA,EAAM,OAAA,EAAS,CAAA,EAAG,OAAA,EAAS,IAAA,EAAK;AAC9E;;;ACDO,SAAS,aAAA,CAAc,QAAmB,QAAA,EAAgC;AAC/E,EAAA,MAAA,CAAO,YAAA;AAAA,IACL,iBAAA;AAAA,IACA;AAAA,MACE,WAAA,EACE,sHAAA;AAAA,MACF,WAAA,EAAa;AAAA,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A,CAAM,QAAA;AAAA,UAChB,UAAU,KAAA,CAAM,QAAA;AAAA,UAChB,iBAAiB,KAAA,CAAM;AAAA,SACzB;AAEA,QAAA,IAAI,IAAA;AAEJ,QAAA,IAAI,MAAM,QAAA,EAAU;AAClB,UAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CACnB,OAAA,CAAQ,KAAA,CAAM,QAAQ,CAAA,CACtB,KAAA,EAAM,CACN,QAAA,CAAS,CAAC,EAAA,KAAgB,GAAG,SAAS,CAAA;AACzC,UAAA,IAAA,GAAO,MAAM,SAAA,CAAU,EAAE,MAAM,OAAA,EAAS,GAAA,IAAO,IAAI,CAAA;AAAA,QACrD,CAAA,MAAO;AACL,UAAA,IAAA,GAAO,MAAM,SAAA,CAAU,IAAA,EAAM,IAAI,CAAA;AAAA,QACnC;AAEA,QAAA,OAAO,KAAK,IAAA,CAAK,SAAA,CAAU,EAAE,GAAA,EAAK,IAAA,EAAM,CAAC,CAAA;AAAA,MAC3C,SAAS,CAAA,EAAG;AACV,QAAA,OAAO,GAAA,CAAI,CAAA,iBAAA,EAAqB,CAAA,CAAY,OAAO,CAAA,CAAE,CAAA;AAAA,MACvD;AAAA,IACF;AAAA,GACF;AACF","file":"tools-3QWUX4W5.js","sourcesContent":["export function text(content: string) {\n return { content: [{ type: 'text' as const, text: content }] };\n}\n\nexport function err(message: string) {\n return { content: [{ type: 'text' as const, text: message }], isError: true };\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { type SessionManager } from '../sessions';\nimport { text } from '../utility/response';\n\nexport function registerDebug(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_debug',\n {\n description:\n 'Evaluate JavaScript on the current page via Playwright page.evaluate(). Use for debugging — not for test logic.',\n inputSchema: {\n sessionId: z.string().describe('Session ID'),\n script: z.string().describe('JavaScript expression or function body to evaluate in the page context'),\n },\n },\n async (input) => {\n try {\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const result = await session.controller.page.evaluate(input.script);\n return text(JSON.stringify({ result }));\n } catch (e) {\n return text(JSON.stringify({ result: null, error: (e as Error).message }));\n }\n },\n );\n}\n","import { loadConfiguration } from '@cucumber/cucumber/api';\nimport { existsSync } from 'node:fs';\nimport { glob } from 'node:fs/promises';\nimport { isAbsolute, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\ntype CucumberConfig = {\n require?: unknown;\n import?: unknown;\n letsrunit?: {\n ignore?: unknown;\n };\n};\n\nexport type SupportEntry = { kind: 'path'; value: string } | { kind: 'module'; value: string };\n\nconst CUCUMBER_CONFIG_FILES = [\n 'cucumber.js',\n 'cucumber.mjs',\n 'cucumber.cjs',\n 'cucumber.ts',\n 'cucumber.mts',\n 'cucumber.cts',\n];\n\nconst loadedProjectRoots = new Set<string>();\nconst loadedSupportEntries = new Set<string>();\n\nfunction toStrings(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((entry): entry is string => typeof entry === 'string');\n}\n\nfunction hasGlobMagic(input: string): boolean {\n return /[*?[\\]{}]/.test(input);\n}\n\nfunction isPathLike(input: string): boolean {\n return input.startsWith('.') || input.startsWith('/') || /^[A-Za-z]:[\\\\/]/.test(input);\n}\n\nfunction toAbsolutePath(baseDir: string, input: string): string {\n return isAbsolute(input) ? resolve(input) : resolve(baseDir, input);\n}\n\nfunction normalizeMatch(baseDir: string, match: string): string {\n return isAbsolute(match) ? resolve(match) : resolve(baseDir, match);\n}\n\nexport async function expandPathPatterns(baseDir: string, patterns: string[]): Promise<Set<string>> {\n const files = new Set<string>();\n\n for (const pattern of patterns) {\n if (hasGlobMagic(pattern)) {\n for await (const match of glob(pattern, { cwd: baseDir })) {\n files.add(normalizeMatch(baseDir, match));\n }\n continue;\n }\n\n files.add(toAbsolutePath(baseDir, pattern));\n }\n\n return files;\n}\n\nexport async function resolveSupportEntries(baseDir: string, entries: string[]): Promise<SupportEntry[]> {\n const resolved: SupportEntry[] = [];\n\n for (const entry of entries) {\n if (hasGlobMagic(entry)) {\n for await (const match of glob(entry, { cwd: baseDir })) {\n resolved.push({ kind: 'path', value: normalizeMatch(baseDir, match) });\n }\n continue;\n }\n\n if (!isPathLike(entry)) {\n resolved.push({ kind: 'module', value: entry });\n continue;\n }\n\n resolved.push({ kind: 'path', value: toAbsolutePath(baseDir, entry) });\n }\n\n return resolved;\n}\n\nexport function findCucumberConfig(cwd: string): string | null {\n for (const filename of CUCUMBER_CONFIG_FILES) {\n const path = resolve(cwd, filename);\n if (existsSync(path)) return path;\n }\n\n return null;\n}\n\nexport async function loadLetsrunitIgnorePatterns(cwd: string): Promise<string[]> {\n const configPath = findCucumberConfig(cwd);\n if (!configPath) return [];\n\n const configModule = await import(pathToFileURL(configPath).href);\n const config = (configModule.default ?? configModule) as CucumberConfig;\n\n return toStrings(config.letsrunit?.ignore);\n}\n\nexport function resolveEffectiveCwd(cwd?: string): string {\n return cwd ?? process.env.LETSRUNIT_PROJECT_CWD ?? process.cwd();\n}\n\nexport function getSupportLoadState(): { loadedProjectRoots: string[]; loadedSupportEntries: string[] } {\n return {\n loadedProjectRoots: [...loadedProjectRoots].sort(),\n loadedSupportEntries: [...loadedSupportEntries].sort(),\n };\n}\n\nexport async function loadSupportFiles(cwd?: string): Promise<void> {\n const projectRoot = resolve(resolveEffectiveCwd(cwd));\n if (loadedProjectRoots.has(projectRoot)) return;\n\n const { useConfiguration } = await loadConfiguration({}, { cwd: projectRoot });\n const supportPatterns = [...toStrings(useConfiguration.require), ...toStrings(useConfiguration.import)];\n if (supportPatterns.length === 0) {\n loadedProjectRoots.add(projectRoot);\n return;\n }\n\n const ignorePatterns = await loadLetsrunitIgnorePatterns(projectRoot);\n const ignoredPaths = await expandPathPatterns(projectRoot, ignorePatterns);\n const supportEntries = await resolveSupportEntries(projectRoot, supportPatterns);\n\n for (const entry of supportEntries) {\n if (entry.kind === 'path' && ignoredPaths.has(entry.value)) {\n continue;\n }\n\n const key = `${entry.kind}:${entry.value}`;\n if (loadedSupportEntries.has(key)) continue;\n\n if (entry.kind === 'path') {\n await import(pathToFileURL(entry.value).href);\n } else {\n await import(entry.value);\n }\n\n loadedSupportEntries.add(key);\n }\n\n loadedProjectRoots.add(projectRoot);\n}\n","import { loadConfiguration } from '@cucumber/cucumber/api';\nimport { registry } from '@letsrunit/bdd';\nimport { realpathSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { decideHandoff, resolveRuntimeModeOverride } from '../bootstrap';\nimport {\n expandPathPatterns,\n findCucumberConfig,\n getSupportLoadState,\n loadLetsrunitIgnorePatterns,\n resolveEffectiveCwd,\n resolveSupportEntries,\n type SupportEntry,\n} from './support';\n\ndeclare const __LETSRUNIT_VERSION__: string | undefined;\n\nexport type Diagnostics = {\n envProjectCwd: string | null;\n processCwd: string;\n inputCwd: string | null;\n effectiveCwd: string;\n projectRoot: string;\n cucumberConfigPath: string | null;\n supportPatterns: string[];\n ignorePatterns: string[];\n ignoredPaths: string[];\n supportEntries: SupportEntry[];\n loadedProjectRoots: string[];\n loadedSupportEntries: string[];\n mcpServer: {\n version: string;\n executablePath: string | null;\n projectServerUsed: boolean;\n handoffDecision: {\n shouldHandoff: boolean;\n runtimeMode: string;\n };\n serverMcpPath: string | null;\n projectMcpPath: string | null;\n };\n letsrunitEnv: Record<string, string>;\n moduleResolution: {\n serverBddPath: string | null;\n projectBddPath: string | null;\n };\n registry: {\n total: number;\n byType: {\n Given: number;\n When: number;\n Then: number;\n };\n definitions: Array<{\n type: 'Given' | 'When' | 'Then';\n source: string;\n comment?: string;\n }>;\n };\n};\n\nfunction resolveFrom(moduleId: string, fromPath: string): string | null {\n try {\n const req = createRequire(fromPath);\n return req.resolve(moduleId);\n } catch {\n return null;\n }\n}\n\nfunction toRealpath(path: string | null): string | null {\n if (!path) return null;\n try {\n return realpathSync(path);\n } catch {\n return path;\n }\n}\n\nfunction pickLetsrunitEnv(): Record<string, string> {\n return Object.fromEntries(\n Object.entries(process.env)\n .filter(([key, value]) => key.startsWith('LETSRUNIT_') && typeof value === 'string')\n .map(([key, value]) => [key, value as string]),\n );\n}\n\nexport async function collectDiagnostics(cwd?: string): Promise<Diagnostics> {\n const effectiveCwd = resolveEffectiveCwd(cwd);\n const projectRoot = resolve(effectiveCwd);\n const cucumberConfigPath = findCucumberConfig(projectRoot);\n const { useConfiguration } = await loadConfiguration({}, { cwd: projectRoot });\n const supportPatterns = [...(useConfiguration.require ?? []), ...(useConfiguration.import ?? [])];\n const ignorePatterns = await loadLetsrunitIgnorePatterns(projectRoot);\n const ignoredPaths = await expandPathPatterns(projectRoot, ignorePatterns);\n const supportEntries = await resolveSupportEntries(projectRoot, supportPatterns);\n const supportLoadState = getSupportLoadState();\n const serverBddPath = toRealpath(resolveFrom('@letsrunit/bdd', import.meta.url));\n const projectBddPath = toRealpath(resolveFrom('@letsrunit/bdd', resolve(projectRoot, 'package.json')));\n const projectMcpEntryPath = resolveFrom('@letsrunit/mcp-server', resolve(projectRoot, 'package.json'));\n const currentEntrypointPath = toRealpath(fileURLToPath(import.meta.url));\n const projectEntrypointPath = toRealpath(projectMcpEntryPath);\n const handoffDecision = decideHandoff(\n currentEntrypointPath,\n projectEntrypointPath,\n resolveRuntimeModeOverride(),\n );\n const serverMcpPath = toRealpath(resolveFrom('@letsrunit/mcp-server', import.meta.url));\n const projectMcpPath = toRealpath(projectMcpEntryPath);\n const executablePath = toRealpath(process.argv[1] ?? null);\n const version = typeof __LETSRUNIT_VERSION__ === 'string' ? __LETSRUNIT_VERSION__ : 'unknown';\n const registryDefinitions = registry.defs.map((def) => ({\n type: def.type,\n source: def.source,\n comment: def.comment,\n }));\n\n return {\n envProjectCwd: process.env.LETSRUNIT_PROJECT_CWD ?? null,\n processCwd: process.cwd(),\n inputCwd: cwd ?? null,\n effectiveCwd,\n projectRoot,\n cucumberConfigPath,\n supportPatterns,\n ignorePatterns,\n ignoredPaths: [...ignoredPaths].sort(),\n supportEntries,\n loadedProjectRoots: supportLoadState.loadedProjectRoots,\n loadedSupportEntries: supportLoadState.loadedSupportEntries,\n mcpServer: {\n version,\n executablePath,\n projectServerUsed: handoffDecision.runtimeMode === 'project',\n handoffDecision: {\n shouldHandoff: handoffDecision.shouldHandoff,\n runtimeMode: handoffDecision.runtimeMode,\n },\n serverMcpPath,\n projectMcpPath,\n },\n letsrunitEnv: pickLetsrunitEnv(),\n moduleResolution: {\n serverBddPath,\n projectBddPath,\n },\n registry: {\n total: registryDefinitions.length,\n byType: {\n Given: registryDefinitions.filter((d) => d.type === 'Given').length,\n When: registryDefinitions.filter((d) => d.type === 'When').length,\n Then: registryDefinitions.filter((d) => d.type === 'Then').length,\n },\n definitions: registryDefinitions,\n },\n };\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { SessionManager } from '../sessions';\nimport { collectDiagnostics } from '../utility/diagnostics';\nimport { err, text } from '../utility/response';\n\nexport function registerDiagnostics(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_diagnostics',\n {\n description:\n 'Return runtime diagnostics for MCP support-file loading (cwd resolution, cucumber config path, support entries). Available only when LETSRUNIT_MCP_DIAGNOSTICS=enabled.',\n inputSchema: {\n sessionId: z.string().describe('Session ID returned by letsrunit_session_start'),\n },\n },\n async (input) => {\n try {\n const diagnostics = await collectDiagnostics();\n const session = sessions.get(input.sessionId);\n const sessionInfo = {\n sessionId: session.id,\n createdAt: session.createdAt,\n lastActivity: session.lastActivity,\n stepCount: session.stepCount,\n artifactDir: session.artifactDir,\n pageUrl: session.controller.page.url(),\n };\n return text(JSON.stringify({ ...diagnostics, session: sessionInfo }));\n } catch (e) {\n return err(`Diagnostics failed: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { unifiedHtmlDiff } from '@letsrunit/playwright';\nimport { openStore, findLastTest, findArtifacts } from '@letsrunit/store';\nimport { execSync } from 'node:child_process';\nimport { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { z } from 'zod';\nimport type { SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\n\nconst DEFAULT_DB_PATH = join(process.cwd(), '.letsrunit', 'letsrunit.db');\n\nfunction getDbPath(): string {\n return process.env.LETSRUNIT_DB_PATH ?? DEFAULT_DB_PATH;\n}\n\nfunction resolveAllowedCommits(): string[] | undefined {\n try {\n const output = execSync('git log --format=%H', { encoding: 'utf8' });\n return output.trim().split('\\n').filter(Boolean);\n } catch {\n return undefined;\n }\n}\n\nexport function registerDiff(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_diff',\n {\n description:\n 'Diff the current live page against the HTML snapshot from the last passing test of a scenario. ' +\n 'Pass the scenarioId returned by letsrunit_run. ' +\n 'Returns a unified HTML diff and paths to baseline screenshots. ' +\n 'By default only considers baseline tests from the current git ancestry (gitTreeOnly: true).',\n inputSchema: {\n sessionId: z.string().describe('Session ID returned by letsrunit_session_start'),\n scenarioId: z.string().describe('Scenario UUID returned by letsrunit_run'),\n gitTreeOnly: z\n .boolean()\n .optional()\n .describe('Restrict baseline to tests from the current git ancestry (default: true)'),\n },\n },\n async (input) => {\n const dbPath = getDbPath();\n const artifactDir = join(dirname(dbPath), 'artifacts');\n let db: ReturnType<typeof openStore> | undefined;\n\n try {\n try {\n db = openStore(dbPath);\n } catch {\n return err('Could not open the letsrunit store. Run cucumber with the store formatter first.');\n }\n\n const allowedCommits = (input.gitTreeOnly ?? true) ? resolveAllowedCommits() : undefined;\n\n const test = findLastTest(db, input.scenarioId, 'passed', allowedCommits ?? undefined);\n if (!test) {\n return err(\n allowedCommits\n ? 'No passing test found for this scenario in the current git ancestry. Try gitTreeOnly: false or run cucumber first.'\n : 'No passing test found for this scenario.',\n );\n }\n\n const artifacts = findArtifacts(db, test.id);\n\n const htmlArtifact = [...artifacts].reverse().find((a) => a.filename.endsWith('.html'));\n if (!htmlArtifact) {\n return err('No HTML snapshot found in the baseline test. Ensure the store formatter is configured.');\n }\n\n const storedHtml = readFileSync(join(artifactDir, htmlArtifact.filename), 'utf-8');\n\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const diff = await unifiedHtmlDiff({ html: storedHtml, url: 'about:blank' }, session.controller.page);\n\n const screenshots = artifacts\n .filter((a) => a.stepIdx === htmlArtifact.stepIdx && a.filename.endsWith('.png'))\n .map((a) => join(artifactDir, a.filename));\n\n return text(\n JSON.stringify({\n diff,\n baseline: {\n testId: test.id,\n commit: test.gitCommit,\n screenshots,\n },\n }),\n );\n } catch (e) {\n return err(`Diff failed: ${(e as Error).message}`);\n } finally {\n db?.close();\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { type SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\n\nconst stepTypeSchema = z.enum(['Given', 'When', 'Then']);\n\nexport function registerListSteps(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_list_steps',\n {\n description:\n 'List available step definitions for a session. Optionally filter by step type (Given/When/Then).',\n inputSchema: {\n sessionId: z.string().describe('Session ID returned by letsrunit_session_start'),\n type: stepTypeSchema.optional().describe('Optional step type filter'),\n },\n },\n async (input) => {\n try {\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const steps = session.controller.listSteps(input.type);\n return text(JSON.stringify({ steps }));\n } catch (e) {\n return err(`List steps failed: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { type SessionManager } from '../sessions';\nimport { text } from '../utility/response';\n\nexport function registerListSessions(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_list_sessions',\n {\n description: 'List all active browser sessions.',\n inputSchema: {},\n },\n async () => {\n const list = sessions.list().map((s) => ({\n sessionId: s.id,\n createdAt: s.createdAt,\n lastActivity: s.lastActivity,\n stepCount: s.stepCount,\n artifactDir: s.artifactDir,\n }));\n\n return text(JSON.stringify({ sessions: list }));\n },\n );\n}\n","export function normalizeGherkin(input: string): string {\n const trimmed = input.trim();\n\n if (/^(Feature|Scenario|Background):/im.test(trimmed)) {\n return trimmed;\n }\n\n return `Feature: MCP\\n\\nScenario: Steps\\n ${trimmed.split('\\n').join('\\n ')}`;\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { scenarioIdFromGherkin } from '@letsrunit/gherkin';\nimport type { SessionManager } from '../sessions';\nimport { normalizeGherkin } from '../utility/gherkin';\nimport { err, text } from '../utility/response';\n\nexport function registerRun(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_run',\n {\n description:\n 'Execute Gherkin steps or a complete feature in the browser. ' +\n 'Accepts a single step line, multiple step lines, a full Scenario, or a full Feature. ' +\n 'Returns status, steps, reason on failure, and journal entries. Does not return a page snapshot — call letsrunit_snapshot explicitly if you need the DOM.',\n inputSchema: {\n sessionId: z.string().describe('Session ID returned by letsrunit_session_start'),\n input: z\n .string()\n .describe(\n 'Gherkin text to execute: one or more step lines (e.g. \"Given I am on \\\\\"https://example.com\\\\\"\"), a Scenario block, or a full Feature block.',\n ),\n },\n },\n async (input) => {\n try {\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const feature = normalizeGherkin(input.input);\n\n session.sink.clear();\n const result = await session.controller.run(feature);\n session.stepCount += result.steps.length;\n\n return text(\n JSON.stringify({\n status: result.status,\n steps: result.steps,\n reason: result.reason?.message,\n journal: session.sink.getEntries(),\n scenarioId: scenarioIdFromGherkin(input.input),\n }),\n );\n } catch (e) {\n return err(`Run failed: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { screenshot, screenshotElement } from '@letsrunit/playwright';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { z } from 'zod';\nimport { type SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\n\nexport function registerScreenshot(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_screenshot',\n {\n description:\n 'Take a screenshot of the current page. Optionally crop to a specific element (selector) or highlight elements before capturing (mask).',\n inputSchema: {\n sessionId: z.string().describe('Session ID'),\n selector: z\n .string()\n .optional()\n .describe('CSS selector — crop screenshot to the bounding box of this element'),\n mask: z\n .array(z.string())\n .optional()\n .describe('CSS selectors whose matching elements are highlighted (dark overlay, element spotlighted).'),\n fullPage: z.boolean().optional().describe('Capture the full scrollable page (default: false)'),\n },\n },\n async (input) => {\n try {\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const page = session.controller.page;\n\n let file: File;\n\n if (input.selector) {\n file = await screenshotElement(page, input.selector);\n } else {\n const masks = input.mask?.map((sel) => page.locator(sel)) ?? [];\n file = await screenshot(page, {\n fullPage: input.fullPage ?? false,\n ...(masks.length ? { mask: masks } : {}),\n });\n }\n\n await mkdir(session.artifactDir, { recursive: true });\n const path = join(session.artifactDir, file.name);\n await writeFile(path, await file.bytes());\n\n return text(JSON.stringify({ path, mimeType: 'image/png' }));\n } catch (e) {\n return err(`Screenshot failed: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\n\nexport function registerSessionClose(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_session_close',\n {\n description: 'Close a browser session and release its resources.',\n inputSchema: {\n sessionId: z.string().describe('Session ID to close'),\n },\n },\n async (input) => {\n try {\n await sessions.close(input.sessionId);\n return text(JSON.stringify({ closed: true }));\n } catch (e) {\n return err(`Failed to close session: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { McpRuntimeMode } from '../bootstrap';\nimport type { SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\nimport { loadSupportFiles } from '../utility/support';\n\ninterface Options {\n runtimeMode: McpRuntimeMode;\n}\n\nexport function registerSessionStart(server: McpServer, sessions: SessionManager, opts?: Options): void {\n server.registerTool(\n 'letsrunit_session_start',\n {\n description:\n 'Launch a new browser session. Does not navigate anywhere — use letsrunit_run with a Given step to navigate. Set baseURL to enable relative paths like \"Given I\\'m on the homepage\".',\n inputSchema: {\n baseURL: z\n .string()\n .optional()\n .describe(\n 'Base URL for the session, e.g. \"http://localhost:3000\". Enables relative paths in Given steps like \"Given I\\'m on the homepage\" or \"Given I\\'m on page \\\\\"/login\\\\\"\"',\n ),\n language: z.string().optional().describe(\"Browser language code, e.g. 'en', 'fr'\"),\n headless: z.boolean().optional().describe('Run browser in headless mode (default: true)'),\n viewportWidth: z.number().int().optional().describe('Viewport width in pixels (default: 1280)'),\n viewportHeight: z.number().int().optional().describe('Viewport height in pixels (default: 720)'),\n },\n },\n async (input) => {\n try {\n if (opts?.runtimeMode === 'project') {\n await loadSupportFiles();\n }\n\n const viewport =\n input.viewportWidth || input.viewportHeight\n ? { width: input.viewportWidth ?? 1280, height: input.viewportHeight ?? 720 }\n : undefined;\n\n const session = await sessions.create({\n baseURL: input.baseURL,\n headless: input.headless ?? true,\n locale: input.language,\n viewport,\n });\n\n return text(JSON.stringify({ sessionId: session.id }));\n } catch (e) {\n return err(`Failed to start session: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { scrubHtml } from '@letsrunit/playwright';\nimport { z } from 'zod';\nimport { type SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\n\nconst stripAttributesSchema = z.nativeEnum({\n none: 0,\n semantic: 1,\n aggressive: 2,\n});\n\nexport function registerSnapshot(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_snapshot',\n {\n description:\n 'Get the current page HTML, scrubbed for LLM consumption. Use selector to scope to a DOM subtree.',\n inputSchema: {\n sessionId: z.string().describe('Session ID'),\n selector: z\n .string()\n .optional()\n .describe(\"CSS selector — return only the matching element's outer HTML instead of the full page\"),\n dropHidden: z.boolean().optional().describe('Remove hidden/inert nodes (default: true)'),\n dropHead: z.boolean().optional().describe('Remove the <head> element (default: true)'),\n pickMain: z.boolean().optional().describe('Keep only the <main> element (default: auto)'),\n stripAttributes: stripAttributesSchema\n .optional()\n .describe('Attribute allowlist level: 0=none, 1=semantic (default), 2=aggressive'),\n },\n },\n async (input) => {\n try {\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const page = session.controller.page;\n const url = page.url();\n\n const opts = {\n dropHidden: input.dropHidden,\n dropHead: input.dropHead,\n pickMain: input.pickMain,\n stripAttributes: input.stripAttributes,\n };\n\n let html: string;\n\n if (input.selector) {\n const rawHtml = await page\n .locator(input.selector)\n .first()\n .evaluate((el: Element) => el.outerHTML);\n html = await scrubHtml({ html: rawHtml, url }, opts);\n } else {\n html = await scrubHtml(page, opts);\n }\n\n return text(JSON.stringify({ url, html }));\n } catch (e) {\n return err(`Snapshot failed: ${(e as Error).message}`);\n }\n },\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@letsrunit/mcp-server",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.5",
|
|
4
4
|
"description": "MCP server for letsrunit — AI-agent browser test generation and execution",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"testing",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"packageManager": "yarn@4.10.3",
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@cucumber/cucumber": "^12.7.0",
|
|
50
|
-
"@letsrunit/bdd": "0.14.
|
|
51
|
-
"@letsrunit/controller": "0.14.
|
|
52
|
-
"@letsrunit/gherkin": "0.14.
|
|
53
|
-
"@letsrunit/journal": "0.14.
|
|
54
|
-
"@letsrunit/playwright": "0.14.
|
|
55
|
-
"@letsrunit/store": "0.14.
|
|
56
|
-
"@letsrunit/utils": "0.14.
|
|
50
|
+
"@letsrunit/bdd": "0.14.5",
|
|
51
|
+
"@letsrunit/controller": "0.14.5",
|
|
52
|
+
"@letsrunit/gherkin": "0.14.5",
|
|
53
|
+
"@letsrunit/journal": "0.14.5",
|
|
54
|
+
"@letsrunit/playwright": "0.14.5",
|
|
55
|
+
"@letsrunit/store": "0.14.5",
|
|
56
|
+
"@letsrunit/utils": "0.14.5",
|
|
57
57
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
58
58
|
"@playwright/test": "^1.57.0",
|
|
59
59
|
"zod": "^4.3.5"
|
package/src/bootstrap.ts
CHANGED
|
@@ -38,11 +38,28 @@ function sameEntrypoint(a: string | null, b: string | null): boolean {
|
|
|
38
38
|
return a === b;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export function resolveRuntimeModeOverride(): McpRuntimeMode | null {
|
|
42
|
+
const runtimeMode = process.env.LETSRUNIT_MCP_RUNTIME_MODE;
|
|
43
|
+
if (runtimeMode == null || runtimeMode === '') {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (runtimeMode === 'project' || runtimeMode === 'standalone') {
|
|
47
|
+
return runtimeMode;
|
|
48
|
+
}
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Invalid LETSRUNIT_MCP_RUNTIME_MODE: ${runtimeMode}. Expected "project" or "standalone".`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
export function decideHandoff(
|
|
42
55
|
currentEntrypointPath: string | null,
|
|
43
56
|
projectEntrypointPath: string | null,
|
|
44
|
-
|
|
57
|
+
runtimeModeOverride: McpRuntimeMode | null,
|
|
45
58
|
): HandoffDecision {
|
|
59
|
+
if (runtimeModeOverride) {
|
|
60
|
+
return { shouldHandoff: false, runtimeMode: runtimeModeOverride };
|
|
61
|
+
}
|
|
62
|
+
|
|
46
63
|
if (!projectEntrypointPath) {
|
|
47
64
|
return { shouldHandoff: false, runtimeMode: 'standalone' };
|
|
48
65
|
}
|
|
@@ -51,10 +68,6 @@ export function decideHandoff(
|
|
|
51
68
|
return { shouldHandoff: false, runtimeMode: 'project' };
|
|
52
69
|
}
|
|
53
70
|
|
|
54
|
-
if (isBootstrapped) {
|
|
55
|
-
return { shouldHandoff: false, runtimeMode: 'standalone' };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
71
|
return { shouldHandoff: true, runtimeMode: 'project' };
|
|
59
72
|
}
|
|
60
73
|
|
|
@@ -63,7 +76,6 @@ function runProjectLocalServer(projectEntrypointPath: string): never {
|
|
|
63
76
|
stdio: 'inherit',
|
|
64
77
|
env: {
|
|
65
78
|
...process.env,
|
|
66
|
-
LETSRUNIT_MCP_BOOTSTRAPPED: '1',
|
|
67
79
|
LETSRUNIT_MCP_RUNTIME_MODE: 'project',
|
|
68
80
|
},
|
|
69
81
|
});
|
|
@@ -74,17 +86,16 @@ function runProjectLocalServer(projectEntrypointPath: string): never {
|
|
|
74
86
|
|
|
75
87
|
export function bootstrapProjectServer(): McpRuntimeMode {
|
|
76
88
|
const projectRoot = resolveProjectRoot();
|
|
77
|
-
const
|
|
89
|
+
const runtimeModeOverride = resolveRuntimeModeOverride();
|
|
78
90
|
|
|
79
91
|
const currentEntryPath = toRealpath(fileURLToPath(import.meta.url));
|
|
80
92
|
const projectEntryPath = toRealpath(resolveFromProject('@letsrunit/mcp-server', projectRoot));
|
|
81
93
|
|
|
82
|
-
const decision = decideHandoff(currentEntryPath, projectEntryPath,
|
|
94
|
+
const decision = decideHandoff(currentEntryPath, projectEntryPath, runtimeModeOverride);
|
|
83
95
|
|
|
84
96
|
if (decision.shouldHandoff && projectEntryPath) {
|
|
85
97
|
runProjectLocalServer(projectEntryPath);
|
|
86
98
|
}
|
|
87
99
|
|
|
88
|
-
process.env.LETSRUNIT_MCP_RUNTIME_MODE = decision.runtimeMode;
|
|
89
100
|
return decision.runtimeMode;
|
|
90
101
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { createRequire } from 'module';
|
|
2
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
3
|
import { bootstrapProjectServer } from './bootstrap';
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
declare const __LETSRUNIT_VERSION__: string | undefined;
|
|
6
|
+
|
|
7
|
+
const version = typeof __LETSRUNIT_VERSION__ === 'string' ? __LETSRUNIT_VERSION__ : 'unknown';
|
|
8
|
+
const runtimeMode = bootstrapProjectServer();
|
|
8
9
|
|
|
9
10
|
const { SessionManager } = await import('./sessions');
|
|
10
11
|
const {
|
|
@@ -28,7 +29,7 @@ const server = new McpServer({
|
|
|
28
29
|
websiteUrl: 'https://letsrunit.ai',
|
|
29
30
|
});
|
|
30
31
|
|
|
31
|
-
registerSessionStart(server, sessions);
|
|
32
|
+
registerSessionStart(server, sessions, { runtimeMode });
|
|
32
33
|
registerRun(server, sessions);
|
|
33
34
|
registerSnapshot(server, sessions);
|
|
34
35
|
registerScreenshot(server, sessions);
|
package/src/tools/diagnostics.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import type { SessionManager } from '../sessions';
|
|
4
|
-
import {
|
|
4
|
+
import { collectDiagnostics } from '../utility/diagnostics';
|
|
5
5
|
import { err, text } from '../utility/response';
|
|
6
6
|
|
|
7
7
|
export function registerDiagnostics(server: McpServer, sessions: SessionManager): void {
|
|
@@ -16,7 +16,7 @@ export function registerDiagnostics(server: McpServer, sessions: SessionManager)
|
|
|
16
16
|
},
|
|
17
17
|
async (input) => {
|
|
18
18
|
try {
|
|
19
|
-
const diagnostics = await
|
|
19
|
+
const diagnostics = await collectDiagnostics();
|
|
20
20
|
const session = sessions.get(input.sessionId);
|
|
21
21
|
const sessionInfo = {
|
|
22
22
|
sessionId: session.id,
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import type { McpRuntimeMode } from '../bootstrap';
|
|
3
4
|
import type { SessionManager } from '../sessions';
|
|
4
5
|
import { err, text } from '../utility/response';
|
|
5
6
|
import { loadSupportFiles } from '../utility/support';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
interface Options {
|
|
9
|
+
runtimeMode: McpRuntimeMode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function registerSessionStart(server: McpServer, sessions: SessionManager, opts?: Options): void {
|
|
8
13
|
server.registerTool(
|
|
9
14
|
'letsrunit_session_start',
|
|
10
15
|
{
|
|
11
16
|
description:
|
|
12
17
|
'Launch a new browser session. Does not navigate anywhere — use letsrunit_run with a Given step to navigate. Set baseURL to enable relative paths like "Given I\'m on the homepage".',
|
|
13
18
|
inputSchema: {
|
|
14
|
-
baseURL: z
|
|
19
|
+
baseURL: z
|
|
20
|
+
.string()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe(
|
|
23
|
+
'Base URL for the session, e.g. "http://localhost:3000". Enables relative paths in Given steps like "Given I\'m on the homepage" or "Given I\'m on page \\"/login\\""',
|
|
24
|
+
),
|
|
15
25
|
language: z.string().optional().describe("Browser language code, e.g. 'en', 'fr'"),
|
|
16
26
|
headless: z.boolean().optional().describe('Run browser in headless mode (default: true)'),
|
|
17
27
|
viewportWidth: z.number().int().optional().describe('Viewport width in pixels (default: 1280)'),
|
|
@@ -20,7 +30,7 @@ export function registerSessionStart(server: McpServer, sessions: SessionManager
|
|
|
20
30
|
},
|
|
21
31
|
async (input) => {
|
|
22
32
|
try {
|
|
23
|
-
if (
|
|
33
|
+
if (opts?.runtimeMode === 'project') {
|
|
24
34
|
await loadSupportFiles();
|
|
25
35
|
}
|
|
26
36
|
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { loadConfiguration } from '@cucumber/cucumber/api';
|
|
2
|
+
import { registry } from '@letsrunit/bdd';
|
|
3
|
+
import { realpathSync } from 'node:fs';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { decideHandoff, resolveRuntimeModeOverride } from '../bootstrap';
|
|
8
|
+
import {
|
|
9
|
+
expandPathPatterns,
|
|
10
|
+
findCucumberConfig,
|
|
11
|
+
getSupportLoadState,
|
|
12
|
+
loadLetsrunitIgnorePatterns,
|
|
13
|
+
resolveEffectiveCwd,
|
|
14
|
+
resolveSupportEntries,
|
|
15
|
+
type SupportEntry,
|
|
16
|
+
} from './support';
|
|
17
|
+
|
|
18
|
+
declare const __LETSRUNIT_VERSION__: string | undefined;
|
|
19
|
+
|
|
20
|
+
export type Diagnostics = {
|
|
21
|
+
envProjectCwd: string | null;
|
|
22
|
+
processCwd: string;
|
|
23
|
+
inputCwd: string | null;
|
|
24
|
+
effectiveCwd: string;
|
|
25
|
+
projectRoot: string;
|
|
26
|
+
cucumberConfigPath: string | null;
|
|
27
|
+
supportPatterns: string[];
|
|
28
|
+
ignorePatterns: string[];
|
|
29
|
+
ignoredPaths: string[];
|
|
30
|
+
supportEntries: SupportEntry[];
|
|
31
|
+
loadedProjectRoots: string[];
|
|
32
|
+
loadedSupportEntries: string[];
|
|
33
|
+
mcpServer: {
|
|
34
|
+
version: string;
|
|
35
|
+
executablePath: string | null;
|
|
36
|
+
projectServerUsed: boolean;
|
|
37
|
+
handoffDecision: {
|
|
38
|
+
shouldHandoff: boolean;
|
|
39
|
+
runtimeMode: string;
|
|
40
|
+
};
|
|
41
|
+
serverMcpPath: string | null;
|
|
42
|
+
projectMcpPath: string | null;
|
|
43
|
+
};
|
|
44
|
+
letsrunitEnv: Record<string, string>;
|
|
45
|
+
moduleResolution: {
|
|
46
|
+
serverBddPath: string | null;
|
|
47
|
+
projectBddPath: string | null;
|
|
48
|
+
};
|
|
49
|
+
registry: {
|
|
50
|
+
total: number;
|
|
51
|
+
byType: {
|
|
52
|
+
Given: number;
|
|
53
|
+
When: number;
|
|
54
|
+
Then: number;
|
|
55
|
+
};
|
|
56
|
+
definitions: Array<{
|
|
57
|
+
type: 'Given' | 'When' | 'Then';
|
|
58
|
+
source: string;
|
|
59
|
+
comment?: string;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function resolveFrom(moduleId: string, fromPath: string): string | null {
|
|
65
|
+
try {
|
|
66
|
+
const req = createRequire(fromPath);
|
|
67
|
+
return req.resolve(moduleId);
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function toRealpath(path: string | null): string | null {
|
|
74
|
+
if (!path) return null;
|
|
75
|
+
try {
|
|
76
|
+
return realpathSync(path);
|
|
77
|
+
} catch {
|
|
78
|
+
return path;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function pickLetsrunitEnv(): Record<string, string> {
|
|
83
|
+
return Object.fromEntries(
|
|
84
|
+
Object.entries(process.env)
|
|
85
|
+
.filter(([key, value]) => key.startsWith('LETSRUNIT_') && typeof value === 'string')
|
|
86
|
+
.map(([key, value]) => [key, value as string]),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export async function collectDiagnostics(cwd?: string): Promise<Diagnostics> {
|
|
91
|
+
const effectiveCwd = resolveEffectiveCwd(cwd);
|
|
92
|
+
const projectRoot = resolve(effectiveCwd);
|
|
93
|
+
const cucumberConfigPath = findCucumberConfig(projectRoot);
|
|
94
|
+
const { useConfiguration } = await loadConfiguration({}, { cwd: projectRoot });
|
|
95
|
+
const supportPatterns = [...(useConfiguration.require ?? []), ...(useConfiguration.import ?? [])];
|
|
96
|
+
const ignorePatterns = await loadLetsrunitIgnorePatterns(projectRoot);
|
|
97
|
+
const ignoredPaths = await expandPathPatterns(projectRoot, ignorePatterns);
|
|
98
|
+
const supportEntries = await resolveSupportEntries(projectRoot, supportPatterns);
|
|
99
|
+
const supportLoadState = getSupportLoadState();
|
|
100
|
+
const serverBddPath = toRealpath(resolveFrom('@letsrunit/bdd', import.meta.url));
|
|
101
|
+
const projectBddPath = toRealpath(resolveFrom('@letsrunit/bdd', resolve(projectRoot, 'package.json')));
|
|
102
|
+
const projectMcpEntryPath = resolveFrom('@letsrunit/mcp-server', resolve(projectRoot, 'package.json'));
|
|
103
|
+
const currentEntrypointPath = toRealpath(fileURLToPath(import.meta.url));
|
|
104
|
+
const projectEntrypointPath = toRealpath(projectMcpEntryPath);
|
|
105
|
+
const handoffDecision = decideHandoff(
|
|
106
|
+
currentEntrypointPath,
|
|
107
|
+
projectEntrypointPath,
|
|
108
|
+
resolveRuntimeModeOverride(),
|
|
109
|
+
);
|
|
110
|
+
const serverMcpPath = toRealpath(resolveFrom('@letsrunit/mcp-server', import.meta.url));
|
|
111
|
+
const projectMcpPath = toRealpath(projectMcpEntryPath);
|
|
112
|
+
const executablePath = toRealpath(process.argv[1] ?? null);
|
|
113
|
+
const version = typeof __LETSRUNIT_VERSION__ === 'string' ? __LETSRUNIT_VERSION__ : 'unknown';
|
|
114
|
+
const registryDefinitions = registry.defs.map((def) => ({
|
|
115
|
+
type: def.type,
|
|
116
|
+
source: def.source,
|
|
117
|
+
comment: def.comment,
|
|
118
|
+
}));
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
envProjectCwd: process.env.LETSRUNIT_PROJECT_CWD ?? null,
|
|
122
|
+
processCwd: process.cwd(),
|
|
123
|
+
inputCwd: cwd ?? null,
|
|
124
|
+
effectiveCwd,
|
|
125
|
+
projectRoot,
|
|
126
|
+
cucumberConfigPath,
|
|
127
|
+
supportPatterns,
|
|
128
|
+
ignorePatterns,
|
|
129
|
+
ignoredPaths: [...ignoredPaths].sort(),
|
|
130
|
+
supportEntries,
|
|
131
|
+
loadedProjectRoots: supportLoadState.loadedProjectRoots,
|
|
132
|
+
loadedSupportEntries: supportLoadState.loadedSupportEntries,
|
|
133
|
+
mcpServer: {
|
|
134
|
+
version,
|
|
135
|
+
executablePath,
|
|
136
|
+
projectServerUsed: handoffDecision.runtimeMode === 'project',
|
|
137
|
+
handoffDecision: {
|
|
138
|
+
shouldHandoff: handoffDecision.shouldHandoff,
|
|
139
|
+
runtimeMode: handoffDecision.runtimeMode,
|
|
140
|
+
},
|
|
141
|
+
serverMcpPath,
|
|
142
|
+
projectMcpPath,
|
|
143
|
+
},
|
|
144
|
+
letsrunitEnv: pickLetsrunitEnv(),
|
|
145
|
+
moduleResolution: {
|
|
146
|
+
serverBddPath,
|
|
147
|
+
projectBddPath,
|
|
148
|
+
},
|
|
149
|
+
registry: {
|
|
150
|
+
total: registryDefinitions.length,
|
|
151
|
+
byType: {
|
|
152
|
+
Given: registryDefinitions.filter((d) => d.type === 'Given').length,
|
|
153
|
+
When: registryDefinitions.filter((d) => d.type === 'When').length,
|
|
154
|
+
Then: registryDefinitions.filter((d) => d.type === 'Then').length,
|
|
155
|
+
},
|
|
156
|
+
definitions: registryDefinitions,
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
}
|
package/src/utility/support.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { loadConfiguration } from '@cucumber/cucumber/api';
|
|
2
|
-
import {
|
|
3
|
-
import { existsSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
4
3
|
import { glob } from 'node:fs/promises';
|
|
5
|
-
import { createRequire } from 'node:module';
|
|
6
4
|
import { isAbsolute, resolve } from 'node:path';
|
|
7
|
-
import {
|
|
8
|
-
import { decideHandoff } from '../bootstrap';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
9
6
|
|
|
10
7
|
type CucumberConfig = {
|
|
11
8
|
require?: unknown;
|
|
@@ -15,7 +12,7 @@ type CucumberConfig = {
|
|
|
15
12
|
};
|
|
16
13
|
};
|
|
17
14
|
|
|
18
|
-
type SupportEntry = { kind: 'path'; value: string } | { kind: 'module'; value: string };
|
|
15
|
+
export type SupportEntry = { kind: 'path'; value: string } | { kind: 'module'; value: string };
|
|
19
16
|
|
|
20
17
|
const CUCUMBER_CONFIG_FILES = [
|
|
21
18
|
'cucumber.js',
|
|
@@ -29,50 +26,6 @@ const CUCUMBER_CONFIG_FILES = [
|
|
|
29
26
|
const loadedProjectRoots = new Set<string>();
|
|
30
27
|
const loadedSupportEntries = new Set<string>();
|
|
31
28
|
|
|
32
|
-
export type SupportDiagnostics = {
|
|
33
|
-
envProjectCwd: string | null;
|
|
34
|
-
processCwd: string;
|
|
35
|
-
inputCwd: string | null;
|
|
36
|
-
effectiveCwd: string;
|
|
37
|
-
projectRoot: string;
|
|
38
|
-
cucumberConfigPath: string | null;
|
|
39
|
-
supportPatterns: string[];
|
|
40
|
-
ignorePatterns: string[];
|
|
41
|
-
ignoredPaths: string[];
|
|
42
|
-
supportEntries: SupportEntry[];
|
|
43
|
-
loadedProjectRoots: string[];
|
|
44
|
-
loadedSupportEntries: string[];
|
|
45
|
-
mcpServer: {
|
|
46
|
-
version: string;
|
|
47
|
-
executablePath: string | null;
|
|
48
|
-
projectServerUsed: boolean;
|
|
49
|
-
handoffDecision: {
|
|
50
|
-
shouldHandoff: boolean;
|
|
51
|
-
runtimeMode: string;
|
|
52
|
-
};
|
|
53
|
-
serverMcpPath: string | null;
|
|
54
|
-
projectMcpPath: string | null;
|
|
55
|
-
};
|
|
56
|
-
letsrunitEnv: Record<string, string>;
|
|
57
|
-
moduleResolution: {
|
|
58
|
-
serverBddPath: string | null;
|
|
59
|
-
projectBddPath: string | null;
|
|
60
|
-
};
|
|
61
|
-
registry: {
|
|
62
|
-
total: number;
|
|
63
|
-
byType: {
|
|
64
|
-
Given: number;
|
|
65
|
-
When: number;
|
|
66
|
-
Then: number;
|
|
67
|
-
};
|
|
68
|
-
definitions: Array<{
|
|
69
|
-
type: 'Given' | 'When' | 'Then';
|
|
70
|
-
source: string;
|
|
71
|
-
comment?: string;
|
|
72
|
-
}>;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
29
|
function toStrings(value: unknown): string[] {
|
|
77
30
|
if (!Array.isArray(value)) return [];
|
|
78
31
|
return value.filter((entry): entry is string => typeof entry === 'string');
|
|
@@ -94,7 +47,7 @@ function normalizeMatch(baseDir: string, match: string): string {
|
|
|
94
47
|
return isAbsolute(match) ? resolve(match) : resolve(baseDir, match);
|
|
95
48
|
}
|
|
96
49
|
|
|
97
|
-
async function expandPathPatterns(baseDir: string, patterns: string[]): Promise<Set<string>> {
|
|
50
|
+
export async function expandPathPatterns(baseDir: string, patterns: string[]): Promise<Set<string>> {
|
|
98
51
|
const files = new Set<string>();
|
|
99
52
|
|
|
100
53
|
for (const pattern of patterns) {
|
|
@@ -111,7 +64,7 @@ async function expandPathPatterns(baseDir: string, patterns: string[]): Promise<
|
|
|
111
64
|
return files;
|
|
112
65
|
}
|
|
113
66
|
|
|
114
|
-
async function resolveSupportEntries(baseDir: string, entries: string[]): Promise<SupportEntry[]> {
|
|
67
|
+
export async function resolveSupportEntries(baseDir: string, entries: string[]): Promise<SupportEntry[]> {
|
|
115
68
|
const resolved: SupportEntry[] = [];
|
|
116
69
|
|
|
117
70
|
for (const entry of entries) {
|
|
@@ -133,7 +86,7 @@ async function resolveSupportEntries(baseDir: string, entries: string[]): Promis
|
|
|
133
86
|
return resolved;
|
|
134
87
|
}
|
|
135
88
|
|
|
136
|
-
function findCucumberConfig(cwd: string): string | null {
|
|
89
|
+
export function findCucumberConfig(cwd: string): string | null {
|
|
137
90
|
for (const filename of CUCUMBER_CONFIG_FILES) {
|
|
138
91
|
const path = resolve(cwd, filename);
|
|
139
92
|
if (existsSync(path)) return path;
|
|
@@ -142,7 +95,7 @@ function findCucumberConfig(cwd: string): string | null {
|
|
|
142
95
|
return null;
|
|
143
96
|
}
|
|
144
97
|
|
|
145
|
-
async function loadLetsrunitIgnorePatterns(cwd: string): Promise<string[]> {
|
|
98
|
+
export async function loadLetsrunitIgnorePatterns(cwd: string): Promise<string[]> {
|
|
146
99
|
const configPath = findCucumberConfig(cwd);
|
|
147
100
|
if (!configPath) return [];
|
|
148
101
|
|
|
@@ -152,104 +105,14 @@ async function loadLetsrunitIgnorePatterns(cwd: string): Promise<string[]> {
|
|
|
152
105
|
return toStrings(config.letsrunit?.ignore);
|
|
153
106
|
}
|
|
154
107
|
|
|
155
|
-
function resolveEffectiveCwd(cwd?: string): string {
|
|
108
|
+
export function resolveEffectiveCwd(cwd?: string): string {
|
|
156
109
|
return cwd ?? process.env.LETSRUNIT_PROJECT_CWD ?? process.cwd();
|
|
157
110
|
}
|
|
158
111
|
|
|
159
|
-
function
|
|
160
|
-
try {
|
|
161
|
-
const req = createRequire(fromPath);
|
|
162
|
-
return req.resolve(moduleId);
|
|
163
|
-
} catch {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function toRealpath(path: string | null): string | null {
|
|
169
|
-
if (!path) return null;
|
|
170
|
-
try {
|
|
171
|
-
return realpathSync(path);
|
|
172
|
-
} catch {
|
|
173
|
-
return path;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function pickLetsrunitEnv(): Record<string, string> {
|
|
178
|
-
return Object.fromEntries(
|
|
179
|
-
Object.entries(process.env)
|
|
180
|
-
.filter(([key, value]) => key.startsWith('LETSRUNIT_') && typeof value === 'string')
|
|
181
|
-
.map(([key, value]) => [key, value as string]),
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export async function collectSupportDiagnostics(cwd?: string): Promise<SupportDiagnostics> {
|
|
186
|
-
const effectiveCwd = resolveEffectiveCwd(cwd);
|
|
187
|
-
const projectRoot = resolve(effectiveCwd);
|
|
188
|
-
const cucumberConfigPath = findCucumberConfig(projectRoot);
|
|
189
|
-
const { useConfiguration } = await loadConfiguration({}, { cwd: projectRoot });
|
|
190
|
-
const supportPatterns = [...toStrings(useConfiguration.require), ...toStrings(useConfiguration.import)];
|
|
191
|
-
const ignorePatterns = await loadLetsrunitIgnorePatterns(projectRoot);
|
|
192
|
-
const ignoredPaths = await expandPathPatterns(projectRoot, ignorePatterns);
|
|
193
|
-
const supportEntries = await resolveSupportEntries(projectRoot, supportPatterns);
|
|
194
|
-
const serverBddPath = toRealpath(resolveFrom('@letsrunit/bdd', import.meta.url));
|
|
195
|
-
const projectBddPath = toRealpath(resolveFrom('@letsrunit/bdd', resolve(projectRoot, 'package.json')));
|
|
196
|
-
const projectMcpEntryPath = resolveFrom('@letsrunit/mcp-server', resolve(projectRoot, 'package.json'));
|
|
197
|
-
const currentReq = createRequire(import.meta.url);
|
|
198
|
-
const currentEntrypointPath = toRealpath(fileURLToPath(import.meta.url));
|
|
199
|
-
const projectEntrypointPath = toRealpath(projectMcpEntryPath);
|
|
200
|
-
const handoffDecision = decideHandoff(
|
|
201
|
-
currentEntrypointPath,
|
|
202
|
-
projectEntrypointPath,
|
|
203
|
-
process.env.LETSRUNIT_MCP_BOOTSTRAPPED === '1',
|
|
204
|
-
);
|
|
205
|
-
const serverMcpPath = toRealpath(resolveFrom('@letsrunit/mcp-server', import.meta.url));
|
|
206
|
-
const projectMcpPath = toRealpath(projectMcpEntryPath);
|
|
207
|
-
const executablePath = toRealpath(process.argv[1] ?? null);
|
|
208
|
-
const { version } = currentReq('../../package.json') as { version: string };
|
|
209
|
-
const registryDefinitions = registry.defs.map((def) => ({
|
|
210
|
-
type: def.type,
|
|
211
|
-
source: def.source,
|
|
212
|
-
comment: def.comment,
|
|
213
|
-
}));
|
|
214
|
-
|
|
112
|
+
export function getSupportLoadState(): { loadedProjectRoots: string[]; loadedSupportEntries: string[] } {
|
|
215
113
|
return {
|
|
216
|
-
envProjectCwd: process.env.LETSRUNIT_PROJECT_CWD ?? null,
|
|
217
|
-
processCwd: process.cwd(),
|
|
218
|
-
inputCwd: cwd ?? null,
|
|
219
|
-
effectiveCwd,
|
|
220
|
-
projectRoot,
|
|
221
|
-
cucumberConfigPath,
|
|
222
|
-
supportPatterns,
|
|
223
|
-
ignorePatterns,
|
|
224
|
-
ignoredPaths: [...ignoredPaths].sort(),
|
|
225
|
-
supportEntries,
|
|
226
114
|
loadedProjectRoots: [...loadedProjectRoots].sort(),
|
|
227
115
|
loadedSupportEntries: [...loadedSupportEntries].sort(),
|
|
228
|
-
mcpServer: {
|
|
229
|
-
version,
|
|
230
|
-
executablePath,
|
|
231
|
-
projectServerUsed: handoffDecision.runtimeMode === 'project',
|
|
232
|
-
handoffDecision: {
|
|
233
|
-
shouldHandoff: handoffDecision.shouldHandoff,
|
|
234
|
-
runtimeMode: handoffDecision.runtimeMode,
|
|
235
|
-
},
|
|
236
|
-
serverMcpPath,
|
|
237
|
-
projectMcpPath,
|
|
238
|
-
},
|
|
239
|
-
letsrunitEnv: pickLetsrunitEnv(),
|
|
240
|
-
moduleResolution: {
|
|
241
|
-
serverBddPath,
|
|
242
|
-
projectBddPath,
|
|
243
|
-
},
|
|
244
|
-
registry: {
|
|
245
|
-
total: registryDefinitions.length,
|
|
246
|
-
byType: {
|
|
247
|
-
Given: registryDefinitions.filter((d) => d.type === 'Given').length,
|
|
248
|
-
When: registryDefinitions.filter((d) => d.type === 'When').length,
|
|
249
|
-
Then: registryDefinitions.filter((d) => d.type === 'Then').length,
|
|
250
|
-
},
|
|
251
|
-
definitions: registryDefinitions,
|
|
252
|
-
},
|
|
253
116
|
};
|
|
254
117
|
}
|
|
255
118
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bootstrap.ts"],"names":[],"mappings":";;;;;;;;;AAaA,SAAS,kBAAA,GAA6B;AACpC,EAAA,OAAO,QAAQ,OAAA,CAAQ,GAAA,CAAI,qBAAA,IAAyB,OAAA,CAAQ,KAAK,CAAA;AAC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AA,CAAQ,QAAA,EAAU,CAAC,qBAAA,EAAuB,GAAG,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA,EAAG;AAAA,IAC5F,KAAA,EAAO,SAAA;AAAA,IACP,GAAA,EAAK;AAAA,MACH,GAAG,OAAA,CAAQ,GAAA;AAAA,MACX,0BAAA,EAA4B,GAAA;AAAA,MAC5B,0BAAA,EAA4B;AAAA;AAC9B,GACD,CAAA;AAED,EAAA,IAAI,MAAA,CAAO,KAAA,EAAO,MAAM,MAAA,CAAO,KAAA;AAC/B,EAAA,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAO,MAAA,IAAU,CAAC,CAAA;AACjC;AAEO,SAAS,sBAAA,GAAyC;AACvD,EAAA,MAAM,cAAc,kBAAA,EAAmB;AACvC,EAAA,MAAM,cAAA,GAAiB,OAAA,CAAQ,GAAA,CAAI,0BAAA,KAA+B,GAAA;AAElE,EAAA,MAAM,gBAAA,GAAmB,UAAA,CAAW,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAClE,EAAA,MAAM,gBAAA,GAAmB,UAAA,CAAW,kBAAA,CAAmB,uBAAA,EAAyB,WAAW,CAAC,CAAA;AAE5F,EAAA,MAAM,QAAA,GAAW,aAAA,CAAc,gBAAA,EAAkB,gBAAA,EAAkB,cAAc,CAAA;AAEjF,EAAA,IAAI,QAAA,CAAS,iBAAiB,gBAAA,EAAkB;AAC9C,IAAA,qBAAA,CAAsB,gBAAgB,CAAA;AAAA,EACxC;AAEA,EAAA,OAAA,CAAQ,GAAA,CAAI,6BAA6B,QAAA,CAAS,WAAA;AAClD,EAAA,OAAO,QAAA,CAAS,WAAA;AAClB","file":"chunk-XJCBPTOU.js","sourcesContent":["import { spawnSync } from 'node:child_process';\nimport { realpathSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport type McpRuntimeMode = 'project' | 'standalone';\n\nexport type HandoffDecision = {\n shouldHandoff: boolean;\n runtimeMode: McpRuntimeMode;\n};\n\nfunction resolveProjectRoot(): string {\n return resolve(process.env.LETSRUNIT_PROJECT_CWD ?? process.cwd());\n}\n\nfunction resolveFromProject(moduleId: string, projectRoot: string): string | null {\n try {\n const req = createRequire(resolve(projectRoot, 'package.json'));\n return req.resolve(moduleId);\n } catch {\n return null;\n }\n}\n\nfunction toRealpath(path: string | null): string | null {\n if (!path) return null;\n try {\n return realpathSync(path);\n } catch {\n return null;\n }\n}\n\nfunction sameEntrypoint(a: string | null, b: string | null): boolean {\n if (!a || !b) return false;\n return a === b;\n}\n\nexport function decideHandoff(\n currentEntrypointPath: string | null,\n projectEntrypointPath: string | null,\n isBootstrapped: boolean,\n): HandoffDecision {\n if (!projectEntrypointPath) {\n return { shouldHandoff: false, runtimeMode: 'standalone' };\n }\n\n if (sameEntrypoint(currentEntrypointPath, projectEntrypointPath)) {\n return { shouldHandoff: false, runtimeMode: 'project' };\n }\n\n if (isBootstrapped) {\n return { shouldHandoff: false, runtimeMode: 'standalone' };\n }\n\n return { shouldHandoff: true, runtimeMode: 'project' };\n}\n\nfunction runProjectLocalServer(projectEntrypointPath: string): never {\n const result = spawnSync(process.execPath, [projectEntrypointPath, ...process.argv.slice(2)], {\n stdio: 'inherit',\n env: {\n ...process.env,\n LETSRUNIT_MCP_BOOTSTRAPPED: '1',\n LETSRUNIT_MCP_RUNTIME_MODE: 'project',\n },\n });\n\n if (result.error) throw result.error;\n process.exit(result.status ?? 1);\n}\n\nexport function bootstrapProjectServer(): McpRuntimeMode {\n const projectRoot = resolveProjectRoot();\n const isBootstrapped = process.env.LETSRUNIT_MCP_BOOTSTRAPPED === '1';\n\n const currentEntryPath = toRealpath(fileURLToPath(import.meta.url));\n const projectEntryPath = toRealpath(resolveFromProject('@letsrunit/mcp-server', projectRoot));\n\n const decision = decideHandoff(currentEntryPath, projectEntryPath, isBootstrapped);\n\n if (decision.shouldHandoff && projectEntryPath) {\n runProjectLocalServer(projectEntryPath);\n }\n\n process.env.LETSRUNIT_MCP_RUNTIME_MODE = decision.runtimeMode;\n return decision.runtimeMode;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utility/response.ts","../src/tools/debug.ts","../src/utility/support.ts","../src/tools/diagnostics.ts","../src/tools/diff.ts","../src/tools/list-steps.ts","../src/tools/list-sessions.ts","../src/utility/gherkin.ts","../src/tools/run.ts","../src/tools/screenshot.ts","../src/tools/session-close.ts","../src/tools/session-start.ts","../src/tools/snapshot.ts"],"names":["z","join"],"mappings":";;;;;;;;;;;;;;;;;;;AAAO,SAAS,KAAK,OAAA,EAAiB;AACpC,EAAA,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,MAAA,EAAiB,IAAA,EAAM,OAAA,EAAS,CAAA,EAAE;AAC/D;AAEO,SAAS,IAAI,OAAA,EAAiB;AACnC,EAAA,OAAO,EAAE,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,MAAA,EAAiB,IAAA,EAAM,OAAA,EAAS,CAAA,EAAG,OAAA,EAAS,IAAA,EAAK;AAC9E;;;ACDO,SAAS,aAAA,CAAc,QAAmB,QAAA,EAAgC;AAC/E,EAAA,MAAA,CAAO,YAAA;AAAA,IACL,iBAAA;AAAA,IACA;AAAA,MACE,WAAA,EACE,sHAAA;AAAA,MACF,WAAA,EAAa;AAAA,QACX,SAAA,EAAW,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,YAAY,CAAA;AAAA,QAC3C,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,wEAAwE;AAAA;AACtG,KACF;AAAA,IACA,OAAO,KAAA,KAAU;AACf,MAAA,IAAI;AACF,QAAA,MAAM,OAAA,GAAU,QAAA,CAAS,GAAA,CAAI,KAAA,CAAM,SAAS,CAAA;AAC5C,QAAA,QAAA,CAAS,KAAA,CAAM,MAAM,SAAS,CAAA;AAE9B,QAAA,MAAM,SAAS,MAAM,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MAAO;AACL,UAAA,IAAA,GAAO,MAAM,SAAA,CAAU,IAAA,EAAM,IAAI,CAAA;AAAA,QACnC;AAEA,QAAA,OAAO,KAAK,IAAA,CAAK,SAAA,CAAU,EAAE,GAAA,EAAK,IAAA,EAAM,CAAC,CAAA;AAAA,MAC3C,SAAS,CAAA,EAAG;AACV,QAAA,OAAO,GAAA,CAAI,CAAA,iBAAA,EAAqB,CAAA,CAAY,OAAO,CAAA,CAAE,CAAA;AAAA,MACvD;AAAA,IACF;AAAA,GACF;AACF","file":"tools-T3XUV2RO.js","sourcesContent":["export function text(content: string) {\n return { content: [{ type: 'text' as const, text: content }] };\n}\n\nexport function err(message: string) {\n return { content: [{ type: 'text' as const, text: message }], isError: true };\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { type SessionManager } from '../sessions';\nimport { text } from '../utility/response';\n\nexport function registerDebug(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_debug',\n {\n description:\n 'Evaluate JavaScript on the current page via Playwright page.evaluate(). Use for debugging — not for test logic.',\n inputSchema: {\n sessionId: z.string().describe('Session ID'),\n script: z.string().describe('JavaScript expression or function body to evaluate in the page context'),\n },\n },\n async (input) => {\n try {\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const result = await session.controller.page.evaluate(input.script);\n return text(JSON.stringify({ result }));\n } catch (e) {\n return text(JSON.stringify({ result: null, error: (e as Error).message }));\n }\n },\n );\n}\n","import { loadConfiguration } from '@cucumber/cucumber/api';\nimport { registry } from '@letsrunit/bdd';\nimport { existsSync, realpathSync } from 'node:fs';\nimport { glob } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { isAbsolute, resolve } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { decideHandoff } from '../bootstrap';\n\ntype CucumberConfig = {\n require?: unknown;\n import?: unknown;\n letsrunit?: {\n ignore?: unknown;\n };\n};\n\ntype SupportEntry = { kind: 'path'; value: string } | { kind: 'module'; value: string };\n\nconst CUCUMBER_CONFIG_FILES = [\n 'cucumber.js',\n 'cucumber.mjs',\n 'cucumber.cjs',\n 'cucumber.ts',\n 'cucumber.mts',\n 'cucumber.cts',\n];\n\nconst loadedProjectRoots = new Set<string>();\nconst loadedSupportEntries = new Set<string>();\n\nexport type SupportDiagnostics = {\n envProjectCwd: string | null;\n processCwd: string;\n inputCwd: string | null;\n effectiveCwd: string;\n projectRoot: string;\n cucumberConfigPath: string | null;\n supportPatterns: string[];\n ignorePatterns: string[];\n ignoredPaths: string[];\n supportEntries: SupportEntry[];\n loadedProjectRoots: string[];\n loadedSupportEntries: string[];\n mcpServer: {\n version: string;\n executablePath: string | null;\n projectServerUsed: boolean;\n handoffDecision: {\n shouldHandoff: boolean;\n runtimeMode: string;\n };\n serverMcpPath: string | null;\n projectMcpPath: string | null;\n };\n letsrunitEnv: Record<string, string>;\n moduleResolution: {\n serverBddPath: string | null;\n projectBddPath: string | null;\n };\n registry: {\n total: number;\n byType: {\n Given: number;\n When: number;\n Then: number;\n };\n definitions: Array<{\n type: 'Given' | 'When' | 'Then';\n source: string;\n comment?: string;\n }>;\n };\n};\n\nfunction toStrings(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((entry): entry is string => typeof entry === 'string');\n}\n\nfunction hasGlobMagic(input: string): boolean {\n return /[*?[\\]{}]/.test(input);\n}\n\nfunction isPathLike(input: string): boolean {\n return input.startsWith('.') || input.startsWith('/') || /^[A-Za-z]:[\\\\/]/.test(input);\n}\n\nfunction toAbsolutePath(baseDir: string, input: string): string {\n return isAbsolute(input) ? resolve(input) : resolve(baseDir, input);\n}\n\nfunction normalizeMatch(baseDir: string, match: string): string {\n return isAbsolute(match) ? resolve(match) : resolve(baseDir, match);\n}\n\nasync function expandPathPatterns(baseDir: string, patterns: string[]): Promise<Set<string>> {\n const files = new Set<string>();\n\n for (const pattern of patterns) {\n if (hasGlobMagic(pattern)) {\n for await (const match of glob(pattern, { cwd: baseDir })) {\n files.add(normalizeMatch(baseDir, match));\n }\n continue;\n }\n\n files.add(toAbsolutePath(baseDir, pattern));\n }\n\n return files;\n}\n\nasync function resolveSupportEntries(baseDir: string, entries: string[]): Promise<SupportEntry[]> {\n const resolved: SupportEntry[] = [];\n\n for (const entry of entries) {\n if (hasGlobMagic(entry)) {\n for await (const match of glob(entry, { cwd: baseDir })) {\n resolved.push({ kind: 'path', value: normalizeMatch(baseDir, match) });\n }\n continue;\n }\n\n if (!isPathLike(entry)) {\n resolved.push({ kind: 'module', value: entry });\n continue;\n }\n\n resolved.push({ kind: 'path', value: toAbsolutePath(baseDir, entry) });\n }\n\n return resolved;\n}\n\nfunction findCucumberConfig(cwd: string): string | null {\n for (const filename of CUCUMBER_CONFIG_FILES) {\n const path = resolve(cwd, filename);\n if (existsSync(path)) return path;\n }\n\n return null;\n}\n\nasync function loadLetsrunitIgnorePatterns(cwd: string): Promise<string[]> {\n const configPath = findCucumberConfig(cwd);\n if (!configPath) return [];\n\n const configModule = await import(pathToFileURL(configPath).href);\n const config = (configModule.default ?? configModule) as CucumberConfig;\n\n return toStrings(config.letsrunit?.ignore);\n}\n\nfunction resolveEffectiveCwd(cwd?: string): string {\n return cwd ?? process.env.LETSRUNIT_PROJECT_CWD ?? process.cwd();\n}\n\nfunction resolveFrom(moduleId: string, fromPath: string): string | null {\n try {\n const req = createRequire(fromPath);\n return req.resolve(moduleId);\n } catch {\n return null;\n }\n}\n\nfunction toRealpath(path: string | null): string | null {\n if (!path) return null;\n try {\n return realpathSync(path);\n } catch {\n return path;\n }\n}\n\nfunction pickLetsrunitEnv(): Record<string, string> {\n return Object.fromEntries(\n Object.entries(process.env)\n .filter(([key, value]) => key.startsWith('LETSRUNIT_') && typeof value === 'string')\n .map(([key, value]) => [key, value as string]),\n );\n}\n\nexport async function collectSupportDiagnostics(cwd?: string): Promise<SupportDiagnostics> {\n const effectiveCwd = resolveEffectiveCwd(cwd);\n const projectRoot = resolve(effectiveCwd);\n const cucumberConfigPath = findCucumberConfig(projectRoot);\n const { useConfiguration } = await loadConfiguration({}, { cwd: projectRoot });\n const supportPatterns = [...toStrings(useConfiguration.require), ...toStrings(useConfiguration.import)];\n const ignorePatterns = await loadLetsrunitIgnorePatterns(projectRoot);\n const ignoredPaths = await expandPathPatterns(projectRoot, ignorePatterns);\n const supportEntries = await resolveSupportEntries(projectRoot, supportPatterns);\n const serverBddPath = toRealpath(resolveFrom('@letsrunit/bdd', import.meta.url));\n const projectBddPath = toRealpath(resolveFrom('@letsrunit/bdd', resolve(projectRoot, 'package.json')));\n const projectMcpEntryPath = resolveFrom('@letsrunit/mcp-server', resolve(projectRoot, 'package.json'));\n const currentReq = createRequire(import.meta.url);\n const currentEntrypointPath = toRealpath(fileURLToPath(import.meta.url));\n const projectEntrypointPath = toRealpath(projectMcpEntryPath);\n const handoffDecision = decideHandoff(\n currentEntrypointPath,\n projectEntrypointPath,\n process.env.LETSRUNIT_MCP_BOOTSTRAPPED === '1',\n );\n const serverMcpPath = toRealpath(resolveFrom('@letsrunit/mcp-server', import.meta.url));\n const projectMcpPath = toRealpath(projectMcpEntryPath);\n const executablePath = toRealpath(process.argv[1] ?? null);\n const { version } = currentReq('../../package.json') as { version: string };\n const registryDefinitions = registry.defs.map((def) => ({\n type: def.type,\n source: def.source,\n comment: def.comment,\n }));\n\n return {\n envProjectCwd: process.env.LETSRUNIT_PROJECT_CWD ?? null,\n processCwd: process.cwd(),\n inputCwd: cwd ?? null,\n effectiveCwd,\n projectRoot,\n cucumberConfigPath,\n supportPatterns,\n ignorePatterns,\n ignoredPaths: [...ignoredPaths].sort(),\n supportEntries,\n loadedProjectRoots: [...loadedProjectRoots].sort(),\n loadedSupportEntries: [...loadedSupportEntries].sort(),\n mcpServer: {\n version,\n executablePath,\n projectServerUsed: handoffDecision.runtimeMode === 'project',\n handoffDecision: {\n shouldHandoff: handoffDecision.shouldHandoff,\n runtimeMode: handoffDecision.runtimeMode,\n },\n serverMcpPath,\n projectMcpPath,\n },\n letsrunitEnv: pickLetsrunitEnv(),\n moduleResolution: {\n serverBddPath,\n projectBddPath,\n },\n registry: {\n total: registryDefinitions.length,\n byType: {\n Given: registryDefinitions.filter((d) => d.type === 'Given').length,\n When: registryDefinitions.filter((d) => d.type === 'When').length,\n Then: registryDefinitions.filter((d) => d.type === 'Then').length,\n },\n definitions: registryDefinitions,\n },\n };\n}\n\nexport async function loadSupportFiles(cwd?: string): Promise<void> {\n const projectRoot = resolve(resolveEffectiveCwd(cwd));\n if (loadedProjectRoots.has(projectRoot)) return;\n\n const { useConfiguration } = await loadConfiguration({}, { cwd: projectRoot });\n const supportPatterns = [...toStrings(useConfiguration.require), ...toStrings(useConfiguration.import)];\n if (supportPatterns.length === 0) {\n loadedProjectRoots.add(projectRoot);\n return;\n }\n\n const ignorePatterns = await loadLetsrunitIgnorePatterns(projectRoot);\n const ignoredPaths = await expandPathPatterns(projectRoot, ignorePatterns);\n const supportEntries = await resolveSupportEntries(projectRoot, supportPatterns);\n\n for (const entry of supportEntries) {\n if (entry.kind === 'path' && ignoredPaths.has(entry.value)) {\n continue;\n }\n\n const key = `${entry.kind}:${entry.value}`;\n if (loadedSupportEntries.has(key)) continue;\n\n if (entry.kind === 'path') {\n await import(pathToFileURL(entry.value).href);\n } else {\n await import(entry.value);\n }\n\n loadedSupportEntries.add(key);\n }\n\n loadedProjectRoots.add(projectRoot);\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { SessionManager } from '../sessions';\nimport { collectSupportDiagnostics } from '../utility/support';\nimport { err, text } from '../utility/response';\n\nexport function registerDiagnostics(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_diagnostics',\n {\n description:\n 'Return runtime diagnostics for MCP support-file loading (cwd resolution, cucumber config path, support entries). Available only when LETSRUNIT_MCP_DIAGNOSTICS=enabled.',\n inputSchema: {\n sessionId: z.string().describe('Session ID returned by letsrunit_session_start'),\n },\n },\n async (input) => {\n try {\n const diagnostics = await collectSupportDiagnostics();\n const session = sessions.get(input.sessionId);\n const sessionInfo = {\n sessionId: session.id,\n createdAt: session.createdAt,\n lastActivity: session.lastActivity,\n stepCount: session.stepCount,\n artifactDir: session.artifactDir,\n pageUrl: session.controller.page.url(),\n };\n return text(JSON.stringify({ ...diagnostics, session: sessionInfo }));\n } catch (e) {\n return err(`Diagnostics failed: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { unifiedHtmlDiff } from '@letsrunit/playwright';\nimport { openStore, findLastTest, findArtifacts } from '@letsrunit/store';\nimport { execSync } from 'node:child_process';\nimport { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { z } from 'zod';\nimport type { SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\n\nconst DEFAULT_DB_PATH = join(process.cwd(), '.letsrunit', 'letsrunit.db');\n\nfunction getDbPath(): string {\n return process.env.LETSRUNIT_DB_PATH ?? DEFAULT_DB_PATH;\n}\n\nfunction resolveAllowedCommits(): string[] | undefined {\n try {\n const output = execSync('git log --format=%H', { encoding: 'utf8' });\n return output.trim().split('\\n').filter(Boolean);\n } catch {\n return undefined;\n }\n}\n\nexport function registerDiff(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_diff',\n {\n description:\n 'Diff the current live page against the HTML snapshot from the last passing test of a scenario. ' +\n 'Pass the scenarioId returned by letsrunit_run. ' +\n 'Returns a unified HTML diff and paths to baseline screenshots. ' +\n 'By default only considers baseline tests from the current git ancestry (gitTreeOnly: true).',\n inputSchema: {\n sessionId: z.string().describe('Session ID returned by letsrunit_session_start'),\n scenarioId: z.string().describe('Scenario UUID returned by letsrunit_run'),\n gitTreeOnly: z\n .boolean()\n .optional()\n .describe('Restrict baseline to tests from the current git ancestry (default: true)'),\n },\n },\n async (input) => {\n const dbPath = getDbPath();\n const artifactDir = join(dirname(dbPath), 'artifacts');\n let db: ReturnType<typeof openStore> | undefined;\n\n try {\n try {\n db = openStore(dbPath);\n } catch {\n return err('Could not open the letsrunit store. Run cucumber with the store formatter first.');\n }\n\n const allowedCommits = (input.gitTreeOnly ?? true) ? resolveAllowedCommits() : undefined;\n\n const test = findLastTest(db, input.scenarioId, 'passed', allowedCommits ?? undefined);\n if (!test) {\n return err(\n allowedCommits\n ? 'No passing test found for this scenario in the current git ancestry. Try gitTreeOnly: false or run cucumber first.'\n : 'No passing test found for this scenario.',\n );\n }\n\n const artifacts = findArtifacts(db, test.id);\n\n const htmlArtifact = [...artifacts].reverse().find((a) => a.filename.endsWith('.html'));\n if (!htmlArtifact) {\n return err('No HTML snapshot found in the baseline test. Ensure the store formatter is configured.');\n }\n\n const storedHtml = readFileSync(join(artifactDir, htmlArtifact.filename), 'utf-8');\n\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const diff = await unifiedHtmlDiff({ html: storedHtml, url: 'about:blank' }, session.controller.page);\n\n const screenshots = artifacts\n .filter((a) => a.stepIdx === htmlArtifact.stepIdx && a.filename.endsWith('.png'))\n .map((a) => join(artifactDir, a.filename));\n\n return text(\n JSON.stringify({\n diff,\n baseline: {\n testId: test.id,\n commit: test.gitCommit,\n screenshots,\n },\n }),\n );\n } catch (e) {\n return err(`Diff failed: ${(e as Error).message}`);\n } finally {\n db?.close();\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { type SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\n\nconst stepTypeSchema = z.enum(['Given', 'When', 'Then']);\n\nexport function registerListSteps(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_list_steps',\n {\n description:\n 'List available step definitions for a session. Optionally filter by step type (Given/When/Then).',\n inputSchema: {\n sessionId: z.string().describe('Session ID returned by letsrunit_session_start'),\n type: stepTypeSchema.optional().describe('Optional step type filter'),\n },\n },\n async (input) => {\n try {\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const steps = session.controller.listSteps(input.type);\n return text(JSON.stringify({ steps }));\n } catch (e) {\n return err(`List steps failed: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { type SessionManager } from '../sessions';\nimport { text } from '../utility/response';\n\nexport function registerListSessions(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_list_sessions',\n {\n description: 'List all active browser sessions.',\n inputSchema: {},\n },\n async () => {\n const list = sessions.list().map((s) => ({\n sessionId: s.id,\n createdAt: s.createdAt,\n lastActivity: s.lastActivity,\n stepCount: s.stepCount,\n artifactDir: s.artifactDir,\n }));\n\n return text(JSON.stringify({ sessions: list }));\n },\n );\n}\n","export function normalizeGherkin(input: string): string {\n const trimmed = input.trim();\n\n if (/^(Feature|Scenario|Background):/im.test(trimmed)) {\n return trimmed;\n }\n\n return `Feature: MCP\\n\\nScenario: Steps\\n ${trimmed.split('\\n').join('\\n ')}`;\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { scenarioIdFromGherkin } from '@letsrunit/gherkin';\nimport type { SessionManager } from '../sessions';\nimport { normalizeGherkin } from '../utility/gherkin';\nimport { err, text } from '../utility/response';\n\nexport function registerRun(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_run',\n {\n description:\n 'Execute Gherkin steps or a complete feature in the browser. ' +\n 'Accepts a single step line, multiple step lines, a full Scenario, or a full Feature. ' +\n 'Returns status, steps, reason on failure, and journal entries. Does not return a page snapshot — call letsrunit_snapshot explicitly if you need the DOM.',\n inputSchema: {\n sessionId: z.string().describe('Session ID returned by letsrunit_session_start'),\n input: z\n .string()\n .describe(\n 'Gherkin text to execute: one or more step lines (e.g. \"Given I am on \\\\\"https://example.com\\\\\"\"), a Scenario block, or a full Feature block.',\n ),\n },\n },\n async (input) => {\n try {\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const feature = normalizeGherkin(input.input);\n\n session.sink.clear();\n const result = await session.controller.run(feature);\n session.stepCount += result.steps.length;\n\n return text(\n JSON.stringify({\n status: result.status,\n steps: result.steps,\n reason: result.reason?.message,\n journal: session.sink.getEntries(),\n scenarioId: scenarioIdFromGherkin(input.input),\n }),\n );\n } catch (e) {\n return err(`Run failed: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { screenshot, screenshotElement } from '@letsrunit/playwright';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { z } from 'zod';\nimport { type SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\n\nexport function registerScreenshot(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_screenshot',\n {\n description:\n 'Take a screenshot of the current page. Optionally crop to a specific element (selector) or highlight elements before capturing (mask).',\n inputSchema: {\n sessionId: z.string().describe('Session ID'),\n selector: z\n .string()\n .optional()\n .describe('CSS selector — crop screenshot to the bounding box of this element'),\n mask: z\n .array(z.string())\n .optional()\n .describe('CSS selectors whose matching elements are highlighted (dark overlay, element spotlighted).'),\n fullPage: z.boolean().optional().describe('Capture the full scrollable page (default: false)'),\n },\n },\n async (input) => {\n try {\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const page = session.controller.page;\n\n let file: File;\n\n if (input.selector) {\n file = await screenshotElement(page, input.selector);\n } else {\n const masks = input.mask?.map((sel) => page.locator(sel)) ?? [];\n file = await screenshot(page, {\n fullPage: input.fullPage ?? false,\n ...(masks.length ? { mask: masks } : {}),\n });\n }\n\n await mkdir(session.artifactDir, { recursive: true });\n const path = join(session.artifactDir, file.name);\n await writeFile(path, await file.bytes());\n\n return text(JSON.stringify({ path, mimeType: 'image/png' }));\n } catch (e) {\n return err(`Screenshot failed: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\n\nexport function registerSessionClose(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_session_close',\n {\n description: 'Close a browser session and release its resources.',\n inputSchema: {\n sessionId: z.string().describe('Session ID to close'),\n },\n },\n async (input) => {\n try {\n await sessions.close(input.sessionId);\n return text(JSON.stringify({ closed: true }));\n } catch (e) {\n return err(`Failed to close session: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\nimport { loadSupportFiles } from '../utility/support';\n\nexport function registerSessionStart(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_session_start',\n {\n description:\n 'Launch a new browser session. Does not navigate anywhere — use letsrunit_run with a Given step to navigate. Set baseURL to enable relative paths like \"Given I\\'m on the homepage\".',\n inputSchema: {\n baseURL: z.string().optional().describe('Base URL for the session, e.g. \"http://localhost:3000\". Enables relative paths in Given steps like \"Given I\\'m on the homepage\" or \"Given I\\'m on page \\\\\"/login\\\\\"\"'),\n language: z.string().optional().describe(\"Browser language code, e.g. 'en', 'fr'\"),\n headless: z.boolean().optional().describe('Run browser in headless mode (default: true)'),\n viewportWidth: z.number().int().optional().describe('Viewport width in pixels (default: 1280)'),\n viewportHeight: z.number().int().optional().describe('Viewport height in pixels (default: 720)'),\n },\n },\n async (input) => {\n try {\n if (process.env.LETSRUNIT_MCP_RUNTIME_MODE === 'project') {\n await loadSupportFiles();\n }\n\n const viewport =\n input.viewportWidth || input.viewportHeight\n ? { width: input.viewportWidth ?? 1280, height: input.viewportHeight ?? 720 }\n : undefined;\n\n const session = await sessions.create({\n baseURL: input.baseURL,\n headless: input.headless ?? true,\n locale: input.language,\n viewport,\n });\n\n return text(JSON.stringify({ sessionId: session.id }));\n } catch (e) {\n return err(`Failed to start session: ${(e as Error).message}`);\n }\n },\n );\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { scrubHtml } from '@letsrunit/playwright';\nimport { z } from 'zod';\nimport { type SessionManager } from '../sessions';\nimport { err, text } from '../utility/response';\n\nconst stripAttributesSchema = z.nativeEnum({\n none: 0,\n semantic: 1,\n aggressive: 2,\n});\n\nexport function registerSnapshot(server: McpServer, sessions: SessionManager): void {\n server.registerTool(\n 'letsrunit_snapshot',\n {\n description:\n 'Get the current page HTML, scrubbed for LLM consumption. Use selector to scope to a DOM subtree.',\n inputSchema: {\n sessionId: z.string().describe('Session ID'),\n selector: z\n .string()\n .optional()\n .describe(\"CSS selector — return only the matching element's outer HTML instead of the full page\"),\n dropHidden: z.boolean().optional().describe('Remove hidden/inert nodes (default: true)'),\n dropHead: z.boolean().optional().describe('Remove the <head> element (default: true)'),\n pickMain: z.boolean().optional().describe('Keep only the <main> element (default: auto)'),\n stripAttributes: stripAttributesSchema\n .optional()\n .describe('Attribute allowlist level: 0=none, 1=semantic (default), 2=aggressive'),\n },\n },\n async (input) => {\n try {\n const session = sessions.get(input.sessionId);\n sessions.touch(input.sessionId);\n\n const page = session.controller.page;\n const url = page.url();\n\n const opts = {\n dropHidden: input.dropHidden,\n dropHead: input.dropHead,\n pickMain: input.pickMain,\n stripAttributes: input.stripAttributes,\n };\n\n let html: string;\n\n if (input.selector) {\n const rawHtml = await page\n .locator(input.selector)\n .first()\n .evaluate((el: Element) => el.outerHTML);\n html = await scrubHtml({ html: rawHtml, url }, opts);\n } else {\n html = await scrubHtml(page, opts);\n }\n\n return text(JSON.stringify({ url, html }));\n } catch (e) {\n return err(`Snapshot failed: ${(e as Error).message}`);\n }\n },\n );\n}\n"]}
|