sniff-qa 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -7
- package/dist/classifier-MWQMQ727.js +1701 -0
- package/dist/classifier-MWQMQ727.js.map +1 -0
- package/dist/cli/index.js +25 -36
- package/dist/cli/index.js.map +1 -1
- package/dist/dev-server-detector-XQ5AYPDT.js +319 -0
- package/dist/dev-server-detector-XQ5AYPDT.js.map +1 -0
- package/dist/{discover-BLUSO42Q.js → discover-JRU5E4FR.js} +112 -13
- package/dist/discover-JRU5E4FR.js.map +1 -0
- package/dist/ensure-browsers-ACHCEQCT.js +60 -0
- package/dist/ensure-browsers-ACHCEQCT.js.map +1 -0
- package/dist/init-IQKT4ANC.js +148 -0
- package/dist/init-IQKT4ANC.js.map +1 -0
- package/dist/mcp/server.js +140 -11
- package/dist/mcp/server.js.map +1 -1
- package/dist/{report-STC6CAVJ.js → report-IKRVVIW4.js} +1 -1
- package/dist/{scenarios-25UAZY6F.js → scenarios-I7YYVTD2.js} +11 -6
- package/dist/{scenarios-25UAZY6F.js.map → scenarios-I7YYVTD2.js.map} +1 -1
- package/dist/{unified-2PM442OY.js → unified-JCUBP6UO.js} +1 -1
- package/package.json +2 -2
- package/dist/classifier-XEA6ZGE7.js +0 -673
- package/dist/classifier-XEA6ZGE7.js.map +0 -1
- package/dist/dev-server-detector-NJ5RN4IC.js +0 -150
- package/dist/dev-server-detector-NJ5RN4IC.js.map +0 -1
- package/dist/discover-BLUSO42Q.js.map +0 -1
- package/dist/init-75MMIW4A.js +0 -66
- package/dist/init-75MMIW4A.js.map +0 -1
- /package/dist/{report-STC6CAVJ.js.map → report-IKRVVIW4.js.map} +0 -0
- /package/dist/{unified-2PM442OY.js.map → unified-JCUBP6UO.js.map} +0 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// src/config/dev-server-detector.ts
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
var FRAMEWORK_PORTS = {
|
|
5
|
+
nextjs: [3e3, 3001],
|
|
6
|
+
vite: [5173, 5174],
|
|
7
|
+
svelte: [5173, 5174],
|
|
8
|
+
vue: [5173, 5174],
|
|
9
|
+
react: [3e3, 5173],
|
|
10
|
+
angular: [4200],
|
|
11
|
+
astro: [4321],
|
|
12
|
+
remix: [3e3],
|
|
13
|
+
nuxt: [3e3]
|
|
14
|
+
};
|
|
15
|
+
var DEV_SCRIPT_PATTERNS = [
|
|
16
|
+
{ pattern: /\bnext\s+dev\b/, ports: [3e3] },
|
|
17
|
+
{ pattern: /\bvite\b/, ports: [5173] },
|
|
18
|
+
{ pattern: /\bsvelte-kit\s+dev\b/, ports: [5173] },
|
|
19
|
+
{ pattern: /\bnuxi?\s+dev\b/, ports: [3e3] },
|
|
20
|
+
{ pattern: /\bastro\s+dev\b/, ports: [4321] },
|
|
21
|
+
{ pattern: /\bremix\s+dev\b/, ports: [3e3] },
|
|
22
|
+
{ pattern: /\bng\s+serve\b/, ports: [4200] },
|
|
23
|
+
{ pattern: /\bwebpack\s+serve\b/, ports: [8080] },
|
|
24
|
+
{ pattern: /\bparcel\b/, ports: [1234] },
|
|
25
|
+
// Explicit port flags in scripts
|
|
26
|
+
{ pattern: /-p\s+(\d+)/, ports: [] },
|
|
27
|
+
// captured dynamically
|
|
28
|
+
{ pattern: /--port[= ](\d+)/, ports: [] },
|
|
29
|
+
{ pattern: /PORT=(\d+)/, ports: [] }
|
|
30
|
+
];
|
|
31
|
+
var COMMON_PORTS = [3e3, 5173, 4200, 4321, 1234];
|
|
32
|
+
var AUTO_INCREMENT_RANGE = 20;
|
|
33
|
+
var VITE_CONFIG_FILES = ["vite.config.ts", "vite.config.js", "vite.config.mjs", "vite.config.cjs"];
|
|
34
|
+
var NUXT_CONFIG_FILES = ["nuxt.config.ts", "nuxt.config.js", "nuxt.config.mjs"];
|
|
35
|
+
var ASTRO_CONFIG_FILES = ["astro.config.mjs", "astro.config.ts", "astro.config.js"];
|
|
36
|
+
var ANGULAR_CONFIG_FILE = "angular.json";
|
|
37
|
+
async function readFileIfExists(path) {
|
|
38
|
+
try {
|
|
39
|
+
return await readFile(path, "utf-8");
|
|
40
|
+
} catch {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function readFirstMatching(rootDir, names) {
|
|
45
|
+
for (const name of names) {
|
|
46
|
+
const content = await readFileIfExists(join(rootDir, name));
|
|
47
|
+
if (content !== void 0) return content;
|
|
48
|
+
}
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
function extractViteOrNuxtOrAstroPort(content) {
|
|
52
|
+
const match = content.match(/(?:server|devServer)\s*:\s*\{[^}]*\bport\s*:\s*(\d+)/s);
|
|
53
|
+
if (match) {
|
|
54
|
+
const port = parseInt(match[1], 10);
|
|
55
|
+
if (!isNaN(port) && port > 0 && port < 65536) return port;
|
|
56
|
+
}
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
function extractAngularPort(content) {
|
|
60
|
+
try {
|
|
61
|
+
const json = JSON.parse(content);
|
|
62
|
+
const projects = json.projects ?? {};
|
|
63
|
+
for (const project of Object.values(projects)) {
|
|
64
|
+
const architect = project.architect ?? project.targets;
|
|
65
|
+
const serve = architect?.serve;
|
|
66
|
+
const options = serve?.options;
|
|
67
|
+
if (options?.port && typeof options.port === "number") return options.port;
|
|
68
|
+
}
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
async function extractConfigFilePort(rootDir) {
|
|
74
|
+
const vite = await readFirstMatching(rootDir, VITE_CONFIG_FILES);
|
|
75
|
+
if (vite) {
|
|
76
|
+
const port = extractViteOrNuxtOrAstroPort(vite);
|
|
77
|
+
if (port !== void 0) return { port, source: "vite.config" };
|
|
78
|
+
}
|
|
79
|
+
const nuxt = await readFirstMatching(rootDir, NUXT_CONFIG_FILES);
|
|
80
|
+
if (nuxt) {
|
|
81
|
+
const port = extractViteOrNuxtOrAstroPort(nuxt);
|
|
82
|
+
if (port !== void 0) return { port, source: "nuxt.config" };
|
|
83
|
+
}
|
|
84
|
+
const astro = await readFirstMatching(rootDir, ASTRO_CONFIG_FILES);
|
|
85
|
+
if (astro) {
|
|
86
|
+
const port = extractViteOrNuxtOrAstroPort(astro);
|
|
87
|
+
if (port !== void 0) return { port, source: "astro.config" };
|
|
88
|
+
}
|
|
89
|
+
const angular = await readFileIfExists(join(rootDir, ANGULAR_CONFIG_FILE));
|
|
90
|
+
if (angular) {
|
|
91
|
+
const port = extractAngularPort(angular);
|
|
92
|
+
if (port !== void 0) return { port, source: "angular.json" };
|
|
93
|
+
}
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
async function parseDevScript(rootDir) {
|
|
97
|
+
try {
|
|
98
|
+
const pkg = JSON.parse(await readFile(join(rootDir, "package.json"), "utf-8"));
|
|
99
|
+
const scripts = pkg.scripts ?? {};
|
|
100
|
+
const scriptNames = ["dev", "start", "serve", "dev:local", "start:dev"];
|
|
101
|
+
for (const name of scriptNames) {
|
|
102
|
+
const cmd = scripts[name];
|
|
103
|
+
if (!cmd || typeof cmd !== "string") continue;
|
|
104
|
+
const portMatch = cmd.match(/(?:-p|--port[= ]|PORT=)\s*(\d+)/);
|
|
105
|
+
if (portMatch) {
|
|
106
|
+
return {
|
|
107
|
+
script: name,
|
|
108
|
+
command: cmd,
|
|
109
|
+
ports: [parseInt(portMatch[1], 10)]
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
for (const { pattern, ports } of DEV_SCRIPT_PATTERNS) {
|
|
113
|
+
if (pattern.test(cmd)) {
|
|
114
|
+
return { script: name, command: cmd, ports };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
119
|
+
const detectedPorts = [];
|
|
120
|
+
for (const [fw, ports] of Object.entries(FRAMEWORK_PORTS)) {
|
|
121
|
+
const depName = fw === "nextjs" ? "next" : fw === "vue" ? "vue" : fw;
|
|
122
|
+
if (allDeps[depName]) {
|
|
123
|
+
detectedPorts.push(...ports);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (detectedPorts.length > 0) {
|
|
127
|
+
return { ports: [...new Set(detectedPorts)] };
|
|
128
|
+
}
|
|
129
|
+
return { ports: [] };
|
|
130
|
+
} catch {
|
|
131
|
+
return { ports: [] };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async function probePort(port, hostname = "localhost") {
|
|
135
|
+
const url = `http://${hostname}:${port}`;
|
|
136
|
+
try {
|
|
137
|
+
const controller = new AbortController();
|
|
138
|
+
const timer = setTimeout(() => controller.abort(), 2e3);
|
|
139
|
+
const response = await fetch(url, {
|
|
140
|
+
method: "GET",
|
|
141
|
+
signal: controller.signal,
|
|
142
|
+
redirect: "follow",
|
|
143
|
+
headers: { Accept: "text/html,*/*" }
|
|
144
|
+
});
|
|
145
|
+
clearTimeout(timer);
|
|
146
|
+
if (!response.ok && response.status >= 500) return { alive: false, framework: null };
|
|
147
|
+
const framework = detectFrameworkFromResponse(response);
|
|
148
|
+
if (framework === null) {
|
|
149
|
+
const reader = response.body?.getReader();
|
|
150
|
+
if (!reader) return { alive: response.ok || response.status < 500, framework: "unknown" };
|
|
151
|
+
const chunks = [];
|
|
152
|
+
let total = 0;
|
|
153
|
+
const MAX = 4096;
|
|
154
|
+
while (total < MAX) {
|
|
155
|
+
const { done, value } = await reader.read();
|
|
156
|
+
if (done) break;
|
|
157
|
+
if (value) {
|
|
158
|
+
chunks.push(value);
|
|
159
|
+
total += value.byteLength;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
await reader.cancel();
|
|
164
|
+
} catch {
|
|
165
|
+
}
|
|
166
|
+
const snippet = Buffer.concat(chunks.map((c) => Buffer.from(c))).toString("utf-8").slice(0, MAX);
|
|
167
|
+
return { alive: true, framework: detectFrameworkFromBody(snippet) };
|
|
168
|
+
}
|
|
169
|
+
return { alive: true, framework };
|
|
170
|
+
} catch {
|
|
171
|
+
return { alive: false, framework: null };
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function detectFrameworkFromResponse(response) {
|
|
175
|
+
const headers = response.headers;
|
|
176
|
+
const xPoweredBy = headers.get("x-powered-by") ?? "";
|
|
177
|
+
if (xPoweredBy.toLowerCase().includes("next")) return "next";
|
|
178
|
+
if (xPoweredBy.toLowerCase().includes("express")) return "unknown";
|
|
179
|
+
for (const [k] of headers.entries()) {
|
|
180
|
+
if (k.toLowerCase().startsWith("x-nuxt-")) return "nuxt";
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
function detectFrameworkFromBody(body) {
|
|
185
|
+
const lower = body.toLowerCase();
|
|
186
|
+
if (lower.includes("/@vite/client")) return "vite";
|
|
187
|
+
if (lower.includes("__next_data__") || lower.includes("/_next/static")) return "next";
|
|
188
|
+
if (lower.includes("__nuxt__") || lower.includes("/_nuxt/")) return "nuxt";
|
|
189
|
+
if (lower.includes("astro-island") || lower.includes("data-astro-cid")) return "astro";
|
|
190
|
+
if (lower.includes("__remix_context__") || lower.includes("/_build/")) return "remix";
|
|
191
|
+
if (lower.includes("ng-version=") || lower.includes("data-ng-")) return "angular";
|
|
192
|
+
if (lower.includes("__sveltekit_data") || lower.includes("/@fs/")) return "svelte";
|
|
193
|
+
if (lower.includes("airtunes") || lower.includes("<title>control center")) return null;
|
|
194
|
+
return "unknown";
|
|
195
|
+
}
|
|
196
|
+
async function isPortAlive(port, hostname = "localhost") {
|
|
197
|
+
const { alive } = await probePort(port, hostname);
|
|
198
|
+
return alive;
|
|
199
|
+
}
|
|
200
|
+
async function probeAndRecord(port, method, detail, candidates) {
|
|
201
|
+
const { alive, framework } = await probePort(port);
|
|
202
|
+
if (!alive) return void 0;
|
|
203
|
+
const candidate = {
|
|
204
|
+
url: `http://localhost:${port}`,
|
|
205
|
+
port,
|
|
206
|
+
framework,
|
|
207
|
+
method,
|
|
208
|
+
detail
|
|
209
|
+
};
|
|
210
|
+
candidates.push(candidate);
|
|
211
|
+
return candidate;
|
|
212
|
+
}
|
|
213
|
+
async function detectDevServerUrl(rootDir) {
|
|
214
|
+
const candidates = [];
|
|
215
|
+
if (process.env.SNIFF_URL) {
|
|
216
|
+
return {
|
|
217
|
+
url: process.env.SNIFF_URL,
|
|
218
|
+
method: "env",
|
|
219
|
+
detail: "SNIFF_URL",
|
|
220
|
+
candidates: [{
|
|
221
|
+
url: process.env.SNIFF_URL,
|
|
222
|
+
port: 0,
|
|
223
|
+
framework: null,
|
|
224
|
+
method: "env",
|
|
225
|
+
detail: "SNIFF_URL"
|
|
226
|
+
}]
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
if (process.env.PORT) {
|
|
230
|
+
const port = parseInt(process.env.PORT, 10);
|
|
231
|
+
if (!isNaN(port)) {
|
|
232
|
+
const hit = await probeAndRecord(port, "env", `PORT=${port}`, candidates);
|
|
233
|
+
if (hit) {
|
|
234
|
+
return { url: hit.url, method: "env", detail: hit.detail, candidates };
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const devInfo = await parseDevScript(rootDir);
|
|
239
|
+
if (devInfo.ports.length > 0) {
|
|
240
|
+
for (const port of devInfo.ports) {
|
|
241
|
+
const detail = devInfo.script ? `npm run ${devInfo.script} (port ${port})` : `framework default (port ${port})`;
|
|
242
|
+
const hit = await probeAndRecord(port, devInfo.script ? "script" : "framework", detail, candidates);
|
|
243
|
+
if (hit) {
|
|
244
|
+
return { url: hit.url, method: hit.method, detail: hit.detail, candidates };
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
for (const basePort of devInfo.ports) {
|
|
248
|
+
for (let offset = 1; offset <= AUTO_INCREMENT_RANGE; offset++) {
|
|
249
|
+
const port = basePort + offset;
|
|
250
|
+
const { alive, framework } = await probePort(port);
|
|
251
|
+
if (alive && framework && framework !== "unknown") {
|
|
252
|
+
const candidate = {
|
|
253
|
+
url: `http://localhost:${port}`,
|
|
254
|
+
port,
|
|
255
|
+
framework,
|
|
256
|
+
method: "auto-increment",
|
|
257
|
+
detail: `auto-incremented from ${basePort} to ${port} (${framework})`
|
|
258
|
+
};
|
|
259
|
+
candidates.push(candidate);
|
|
260
|
+
return { url: candidate.url, method: "auto-increment", detail: candidate.detail, candidates };
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const configPort = await extractConfigFilePort(rootDir);
|
|
266
|
+
if (configPort) {
|
|
267
|
+
const hit = await probeAndRecord(
|
|
268
|
+
configPort.port,
|
|
269
|
+
"config",
|
|
270
|
+
`${configPort.source} (port ${configPort.port})`,
|
|
271
|
+
candidates
|
|
272
|
+
);
|
|
273
|
+
if (hit) return { url: hit.url, method: "config", detail: hit.detail, candidates };
|
|
274
|
+
}
|
|
275
|
+
for (const port of COMMON_PORTS) {
|
|
276
|
+
if (candidates.some((c) => c.port === port)) continue;
|
|
277
|
+
const { alive, framework } = await probePort(port);
|
|
278
|
+
if (!alive) continue;
|
|
279
|
+
if (framework && framework !== "unknown") {
|
|
280
|
+
const candidate = {
|
|
281
|
+
url: `http://localhost:${port}`,
|
|
282
|
+
port,
|
|
283
|
+
framework,
|
|
284
|
+
method: "probe",
|
|
285
|
+
detail: `probed ${port} (${framework})`
|
|
286
|
+
};
|
|
287
|
+
candidates.push(candidate);
|
|
288
|
+
return { url: candidate.url, method: "probe", detail: candidate.detail, candidates };
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return { url: void 0, method: "none", candidates };
|
|
292
|
+
}
|
|
293
|
+
async function getDevCommand(rootDir) {
|
|
294
|
+
try {
|
|
295
|
+
const pkg = JSON.parse(await readFile(join(rootDir, "package.json"), "utf-8"));
|
|
296
|
+
const scripts = pkg.scripts ?? {};
|
|
297
|
+
for (const name of ["dev", "start", "serve"]) {
|
|
298
|
+
if (scripts[name]) return `npm run ${name}`;
|
|
299
|
+
}
|
|
300
|
+
} catch {
|
|
301
|
+
}
|
|
302
|
+
return void 0;
|
|
303
|
+
}
|
|
304
|
+
var __testing = {
|
|
305
|
+
isPortAlive,
|
|
306
|
+
probePort,
|
|
307
|
+
parseDevScript,
|
|
308
|
+
extractViteOrNuxtOrAstroPort,
|
|
309
|
+
extractAngularPort,
|
|
310
|
+
detectFrameworkFromBody,
|
|
311
|
+
COMMON_PORTS,
|
|
312
|
+
AUTO_INCREMENT_RANGE
|
|
313
|
+
};
|
|
314
|
+
export {
|
|
315
|
+
__testing,
|
|
316
|
+
detectDevServerUrl,
|
|
317
|
+
getDevCommand
|
|
318
|
+
};
|
|
319
|
+
//# sourceMappingURL=dev-server-detector-XQ5AYPDT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/config/dev-server-detector.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n// ---------------------------------------------------------------------------\n// Framework-to-port mappings\n// ---------------------------------------------------------------------------\n\nconst FRAMEWORK_PORTS: Record<string, number[]> = {\n nextjs: [3000, 3001],\n vite: [5173, 5174],\n svelte: [5173, 5174],\n vue: [5173, 5174],\n react: [3000, 5173],\n angular: [4200],\n astro: [4321],\n remix: [3000],\n nuxt: [3000],\n};\n\n// Dev script patterns that indicate a dev server\nconst DEV_SCRIPT_PATTERNS: Array<{ pattern: RegExp; ports: number[] }> = [\n { pattern: /\\bnext\\s+dev\\b/, ports: [3000] },\n { pattern: /\\bvite\\b/, ports: [5173] },\n { pattern: /\\bsvelte-kit\\s+dev\\b/, ports: [5173] },\n { pattern: /\\bnuxi?\\s+dev\\b/, ports: [3000] },\n { pattern: /\\bastro\\s+dev\\b/, ports: [4321] },\n { pattern: /\\bremix\\s+dev\\b/, ports: [3000] },\n { pattern: /\\bng\\s+serve\\b/, ports: [4200] },\n { pattern: /\\bwebpack\\s+serve\\b/, ports: [8080] },\n { pattern: /\\bparcel\\b/, ports: [1234] },\n // Explicit port flags in scripts\n { pattern: /-p\\s+(\\d+)/, ports: [] }, // captured dynamically\n { pattern: /--port[= ](\\d+)/, ports: [] },\n { pattern: /PORT=(\\d+)/, ports: [] },\n];\n\n// Conservative fallback probe list. Intentionally excludes 5000, 8000, 8080 —\n// these collide with macOS AirPlay Receiver (5000), python http.server (8000),\n// and every Java/Tomcat/Jenkins default (8080). Issue #4.\nconst COMMON_PORTS = [3000, 5173, 4200, 4321, 1234];\n\n// How many ports above the default to probe when looking for auto-incremented\n// dev servers (Next.js and Vite both roll forward when the default port is busy).\nconst AUTO_INCREMENT_RANGE = 20;\n\n// ---------------------------------------------------------------------------\n// Config-file parsing (no execution — static regex only)\n// ---------------------------------------------------------------------------\n\nconst VITE_CONFIG_FILES = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs', 'vite.config.cjs'];\nconst NUXT_CONFIG_FILES = ['nuxt.config.ts', 'nuxt.config.js', 'nuxt.config.mjs'];\nconst ASTRO_CONFIG_FILES = ['astro.config.mjs', 'astro.config.ts', 'astro.config.js'];\nconst ANGULAR_CONFIG_FILE = 'angular.json';\n\nasync function readFileIfExists(path: string): Promise<string | undefined> {\n try {\n return await readFile(path, 'utf-8');\n } catch {\n return undefined;\n }\n}\n\nasync function readFirstMatching(rootDir: string, names: string[]): Promise<string | undefined> {\n for (const name of names) {\n const content = await readFileIfExists(join(rootDir, name));\n if (content !== undefined) return content;\n }\n return undefined;\n}\n\nfunction extractViteOrNuxtOrAstroPort(content: string): number | undefined {\n // Matches `server: { port: 4000 }` and `devServer: { port: 4000 }`.\n // Regex is deliberately loose — we're not parsing JS, just fishing for\n // the first explicit port under a server/devServer key.\n const match = content.match(/(?:server|devServer)\\s*:\\s*\\{[^}]*\\bport\\s*:\\s*(\\d+)/s);\n if (match) {\n const port = parseInt(match[1], 10);\n if (!isNaN(port) && port > 0 && port < 65536) return port;\n }\n return undefined;\n}\n\nfunction extractAngularPort(content: string): number | undefined {\n try {\n const json = JSON.parse(content);\n const projects = json.projects ?? {};\n for (const project of Object.values(projects) as Array<Record<string, unknown>>) {\n const architect = (project.architect ?? project.targets) as Record<string, unknown> | undefined;\n const serve = architect?.serve as Record<string, unknown> | undefined;\n const options = serve?.options as Record<string, unknown> | undefined;\n if (options?.port && typeof options.port === 'number') return options.port;\n }\n } catch {\n // fall through\n }\n return undefined;\n}\n\nasync function extractConfigFilePort(rootDir: string): Promise<{ port: number; source: string } | undefined> {\n const vite = await readFirstMatching(rootDir, VITE_CONFIG_FILES);\n if (vite) {\n const port = extractViteOrNuxtOrAstroPort(vite);\n if (port !== undefined) return { port, source: 'vite.config' };\n }\n\n const nuxt = await readFirstMatching(rootDir, NUXT_CONFIG_FILES);\n if (nuxt) {\n const port = extractViteOrNuxtOrAstroPort(nuxt);\n if (port !== undefined) return { port, source: 'nuxt.config' };\n }\n\n const astro = await readFirstMatching(rootDir, ASTRO_CONFIG_FILES);\n if (astro) {\n const port = extractViteOrNuxtOrAstroPort(astro);\n if (port !== undefined) return { port, source: 'astro.config' };\n }\n\n const angular = await readFileIfExists(join(rootDir, ANGULAR_CONFIG_FILE));\n if (angular) {\n const port = extractAngularPort(angular);\n if (port !== undefined) return { port, source: 'angular.json' };\n }\n\n return undefined;\n}\n\n// ---------------------------------------------------------------------------\n// Package.json script parsing\n// ---------------------------------------------------------------------------\n\ninterface DetectedDevInfo {\n script?: string;\n command?: string;\n ports: number[];\n}\n\nasync function parseDevScript(rootDir: string): Promise<DetectedDevInfo> {\n try {\n const pkg = JSON.parse(await readFile(join(rootDir, 'package.json'), 'utf-8'));\n const scripts = pkg.scripts ?? {};\n\n // Try these script names in order\n const scriptNames = ['dev', 'start', 'serve', 'dev:local', 'start:dev'];\n\n for (const name of scriptNames) {\n const cmd = scripts[name];\n if (!cmd || typeof cmd !== 'string') continue;\n\n // Check for explicit port in script\n const portMatch = cmd.match(/(?:-p|--port[= ]|PORT=)\\s*(\\d+)/);\n if (portMatch) {\n return {\n script: name,\n command: cmd,\n ports: [parseInt(portMatch[1], 10)],\n };\n }\n\n // Match against known dev server patterns\n for (const { pattern, ports } of DEV_SCRIPT_PATTERNS) {\n if (pattern.test(cmd)) {\n return { script: name, command: cmd, ports };\n }\n }\n }\n\n // Check dependencies for framework hints\n const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };\n const detectedPorts: number[] = [];\n\n for (const [fw, ports] of Object.entries(FRAMEWORK_PORTS)) {\n const depName = fw === 'nextjs' ? 'next' : fw === 'vue' ? 'vue' : fw;\n if (allDeps[depName]) {\n detectedPorts.push(...ports);\n }\n }\n\n if (detectedPorts.length > 0) {\n return { ports: [...new Set(detectedPorts)] };\n }\n\n return { ports: [] };\n } catch {\n return { ports: [] };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Liveness + framework-marker sniffing\n// ---------------------------------------------------------------------------\n\nexport type FrameworkMarker = 'next' | 'vite' | 'nuxt' | 'astro' | 'remix' | 'angular' | 'svelte' | 'unknown' | null;\n\ninterface ProbeResult {\n alive: boolean;\n framework: FrameworkMarker;\n}\n\nasync function probePort(port: number, hostname = 'localhost'): Promise<ProbeResult> {\n const url = `http://${hostname}:${port}`;\n try {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), 2000);\n\n const response = await fetch(url, {\n method: 'GET',\n signal: controller.signal,\n redirect: 'follow',\n headers: { Accept: 'text/html,*/*' },\n });\n\n clearTimeout(timer);\n if (!response.ok && response.status >= 500) return { alive: false, framework: null };\n\n const framework = detectFrameworkFromResponse(response);\n if (framework === null) {\n // Response, but no framework markers. Try to read body briefly (max ~4KB).\n const reader = response.body?.getReader();\n if (!reader) return { alive: response.ok || response.status < 500, framework: 'unknown' };\n const chunks: Uint8Array[] = [];\n let total = 0;\n const MAX = 4096;\n while (total < MAX) {\n const { done, value } = await reader.read();\n if (done) break;\n if (value) {\n chunks.push(value);\n total += value.byteLength;\n }\n }\n try { await reader.cancel(); } catch { /* ignore */ }\n const snippet = Buffer.concat(chunks.map((c) => Buffer.from(c))).toString('utf-8').slice(0, MAX);\n return { alive: true, framework: detectFrameworkFromBody(snippet) };\n }\n\n return { alive: true, framework };\n } catch {\n return { alive: false, framework: null };\n }\n}\n\nfunction detectFrameworkFromResponse(response: Response): FrameworkMarker {\n // Each framework leaves telltale response headers.\n const headers = response.headers;\n const xPoweredBy = headers.get('x-powered-by') ?? '';\n if (xPoweredBy.toLowerCase().includes('next')) return 'next';\n if (xPoweredBy.toLowerCase().includes('express')) return 'unknown'; // could be anything\n // Nuxt dev sends x-nuxt-*\n for (const [k] of headers.entries()) {\n if (k.toLowerCase().startsWith('x-nuxt-')) return 'nuxt';\n }\n return null;\n}\n\nfunction detectFrameworkFromBody(body: string): FrameworkMarker {\n const lower = body.toLowerCase();\n if (lower.includes('/@vite/client')) return 'vite';\n if (lower.includes('__next_data__') || lower.includes('/_next/static')) return 'next';\n if (lower.includes('__nuxt__') || lower.includes('/_nuxt/')) return 'nuxt';\n if (lower.includes('astro-island') || lower.includes('data-astro-cid')) return 'astro';\n if (lower.includes('__remix_context__') || lower.includes('/_build/')) return 'remix';\n if (lower.includes('ng-version=') || lower.includes('data-ng-')) return 'angular';\n if (lower.includes('__sveltekit_data') || lower.includes('/@fs/')) return 'svelte';\n // macOS AirPlay Receiver returns \"Control Center\" / specific strings\n if (lower.includes('airtunes') || lower.includes('<title>control center')) return null;\n return 'unknown';\n}\n\n// Back-compat alias used by other callers in sniff.\nasync function isPortAlive(port: number, hostname = 'localhost'): Promise<boolean> {\n const { alive } = await probePort(port, hostname);\n return alive;\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\nexport interface DetectionCandidate {\n url: string;\n port: number;\n framework: FrameworkMarker;\n method: 'env' | 'script' | 'config' | 'framework' | 'probe' | 'auto-increment';\n detail: string;\n}\n\nexport interface DetectionResult {\n url: string | undefined;\n method: 'config' | 'env' | 'script' | 'framework' | 'probe' | 'auto-increment' | 'none';\n detail?: string;\n /**\n * All candidate URLs found during detection. The caller may pick, or\n * prompt the user, if multiple frameworks look alive. The chosen `url`\n * is always `candidates[0].url` when candidates is non-empty.\n */\n candidates?: DetectionCandidate[];\n}\n\nasync function probeAndRecord(\n port: number,\n method: DetectionCandidate['method'],\n detail: string,\n candidates: DetectionCandidate[],\n): Promise<DetectionCandidate | undefined> {\n const { alive, framework } = await probePort(port);\n if (!alive) return undefined;\n const candidate: DetectionCandidate = {\n url: `http://localhost:${port}`,\n port,\n framework,\n method,\n detail,\n };\n candidates.push(candidate);\n return candidate;\n}\n\n/**\n * Auto-detect the dev server URL by checking (in order):\n * 1. SNIFF_URL or PORT environment variables\n * 2. package.json scripts (dev, start, serve)\n * 3. Framework config files (vite/nuxt/astro/angular)\n * 4. Framework-default ports\n * 5. Auto-increment probe (defaultPort + 1..20) — catches Next.js/Vite port roll\n * 6. Conservative common-port probe (excludes 5000/8000/8080 to avoid AirPlay etc.)\n */\nexport async function detectDevServerUrl(rootDir: string): Promise<DetectionResult> {\n const candidates: DetectionCandidate[] = [];\n\n // 1. Environment variables\n if (process.env.SNIFF_URL) {\n return {\n url: process.env.SNIFF_URL,\n method: 'env',\n detail: 'SNIFF_URL',\n candidates: [{\n url: process.env.SNIFF_URL,\n port: 0,\n framework: null,\n method: 'env',\n detail: 'SNIFF_URL',\n }],\n };\n }\n\n if (process.env.PORT) {\n const port = parseInt(process.env.PORT, 10);\n if (!isNaN(port)) {\n const hit = await probeAndRecord(port, 'env', `PORT=${port}`, candidates);\n if (hit) {\n return { url: hit.url, method: 'env', detail: hit.detail, candidates };\n }\n }\n }\n\n // 2. Parse package.json scripts\n const devInfo = await parseDevScript(rootDir);\n\n // Try script-detected ports first\n if (devInfo.ports.length > 0) {\n for (const port of devInfo.ports) {\n const detail = devInfo.script\n ? `npm run ${devInfo.script} (port ${port})`\n : `framework default (port ${port})`;\n const hit = await probeAndRecord(port, devInfo.script ? 'script' : 'framework', detail, candidates);\n if (hit) {\n return { url: hit.url, method: hit.method, detail: hit.detail, candidates };\n }\n }\n\n // 5. Auto-increment probe (Next.js/Vite roll forward on busy port)\n for (const basePort of devInfo.ports) {\n for (let offset = 1; offset <= AUTO_INCREMENT_RANGE; offset++) {\n const port = basePort + offset;\n const { alive, framework } = await probePort(port);\n if (alive && framework && framework !== 'unknown') {\n const candidate: DetectionCandidate = {\n url: `http://localhost:${port}`,\n port,\n framework,\n method: 'auto-increment',\n detail: `auto-incremented from ${basePort} to ${port} (${framework})`,\n };\n candidates.push(candidate);\n return { url: candidate.url, method: 'auto-increment', detail: candidate.detail, candidates };\n }\n }\n }\n }\n\n // 3. Framework config files — read static config for explicit port overrides\n const configPort = await extractConfigFilePort(rootDir);\n if (configPort) {\n const hit = await probeAndRecord(\n configPort.port,\n 'config',\n `${configPort.source} (port ${configPort.port})`,\n candidates,\n );\n if (hit) return { url: hit.url, method: 'config', detail: hit.detail, candidates };\n }\n\n // 4 & 6. Probe conservative common ports — only ones with clear framework association\n for (const port of COMMON_PORTS) {\n // Skip ports we already probed\n if (candidates.some((c) => c.port === port)) continue;\n const { alive, framework } = await probePort(port);\n if (!alive) continue;\n // Require a framework marker here — probing blind into :3000 on a\n // random machine could land on an unrelated service.\n if (framework && framework !== 'unknown') {\n const candidate: DetectionCandidate = {\n url: `http://localhost:${port}`,\n port,\n framework,\n method: 'probe',\n detail: `probed ${port} (${framework})`,\n };\n candidates.push(candidate);\n return { url: candidate.url, method: 'probe', detail: candidate.detail, candidates };\n }\n }\n\n // Nothing confirmed\n return { url: undefined, method: 'none', candidates };\n}\n\n/**\n * Get the dev start command from package.json (for suggesting to user).\n */\nexport async function getDevCommand(rootDir: string): Promise<string | undefined> {\n try {\n const pkg = JSON.parse(await readFile(join(rootDir, 'package.json'), 'utf-8'));\n const scripts = pkg.scripts ?? {};\n\n for (const name of ['dev', 'start', 'serve']) {\n if (scripts[name]) return `npm run ${name}`;\n }\n } catch {\n // no package.json\n }\n return undefined;\n}\n\n// Internal exports for tests\nexport const __testing = {\n isPortA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W,QAAQ,cAAc;AAE/B,QAAI,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI,EAAG;AAC7C,UAAM,EAAE,OAAO,UAAU,IAAI,MAAM,UAAU,IAAI;AACjD,QAAI,CAAC,MAAO;AAGZ,QAAI,aAAa,cAAc,WAAW;AACxC,YAAM,YAAgC;AAAA,QACpC,KAAK,oBAAoB,IAAI;AAAA,QAC7B;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR,QAAQ,UAAU,IAAI,KAAK,SAAS;AAAA,MACtC;AACA,iBAAW,KAAK,SAAS;AACzB,aAAO,EAAE,KAAK,UAAU,KAAK,QAAQ,SAAS,QAAQ,UAAU,QAAQ,WAAW;AAAA,IACrF;AAAA,EACF;AAGA,SAAO,EAAE,KAAK,QAAW,QAAQ,QAAQ,WAAW;AACtD;AAKA,eAAsB,cAAc,SAA8C;AAChF,MAAI;AACF,UAAM,MAAM,KAAK,MAAM,MAAM,SAAS,KAAK,SAAS,cAAc,GAAG,OAAO,CAAC;AAC7E,UAAM,UAAU,IAAI,WAAW,CAAC;AAEhC,eAAW,QAAQ,CAAC,OAAO,SAAS,OAAO,GAAG;AAC5C,UAAI,QAAQ,IAAI,EAAG,QAAO,WAAW,IAAI;AAAA,IAC3C;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO;AACT;AAGO,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
|
@@ -42,13 +42,49 @@ async function discoverCommand(options) {
|
|
|
42
42
|
stats: { total: 0, passed: 0, failed: 0, skipped: 0, quarantined: 0, durationMs: 0 },
|
|
43
43
|
runAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
44
44
|
});
|
|
45
|
+
function printVerboseBreakdown(breakdown2) {
|
|
46
|
+
if (options.json) return;
|
|
47
|
+
console.log("");
|
|
48
|
+
console.log(pc.bold(" classification breakdown:"));
|
|
49
|
+
console.log(pc.dim(" top 3:"));
|
|
50
|
+
for (const t of breakdown2.top3) {
|
|
51
|
+
const pct = Math.round(t.confidence * 100);
|
|
52
|
+
console.log(` ${pc.bold(t.type.padEnd(12))} ${String(pct).padStart(3)}% (raw score: ${t.rawScore})`);
|
|
53
|
+
}
|
|
54
|
+
const describeBucket = (label, entries) => {
|
|
55
|
+
if (entries.length === 0) {
|
|
56
|
+
console.log(pc.dim(` ${label}: \u2014`));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const top = [...entries].sort((a, b) => b.weight - a.weight).slice(0, 8);
|
|
60
|
+
console.log(pc.dim(` ${label}:`));
|
|
61
|
+
for (const e of top) {
|
|
62
|
+
console.log(` ${pc.dim(e.appType.padEnd(12))} ${e.value} ${pc.dim(`(+${e.weight})`)}`);
|
|
63
|
+
}
|
|
64
|
+
if (entries.length > top.length) {
|
|
65
|
+
console.log(pc.dim(` ... ${entries.length - top.length} more`));
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
describeBucket("routes ", breakdown2.matchedSignals.routes);
|
|
69
|
+
describeBucket("elements", breakdown2.matchedSignals.elements);
|
|
70
|
+
describeBucket("deps ", breakdown2.matchedSignals.deps);
|
|
71
|
+
describeBucket("schema ", breakdown2.matchedSignals.schema);
|
|
72
|
+
console.log("");
|
|
73
|
+
}
|
|
45
74
|
let url;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
75
|
+
let detectedFrom;
|
|
76
|
+
if (!options.regenerateOnly && !options.dryRun) {
|
|
77
|
+
if (options.url) {
|
|
78
|
+
url = options.url;
|
|
79
|
+
detectedFrom = { method: "flag", detail: "--url" };
|
|
80
|
+
} else if (config.browser?.baseUrl) {
|
|
81
|
+
url = config.browser.baseUrl;
|
|
82
|
+
detectedFrom = { method: "config", detail: "sniff.config.ts" };
|
|
83
|
+
} else {
|
|
84
|
+
const { detectDevServerUrl } = await import("./dev-server-detector-XQ5AYPDT.js");
|
|
50
85
|
const detection = await detectDevServerUrl(options.rootDir);
|
|
51
86
|
url = detection.url;
|
|
87
|
+
detectedFrom = { method: detection.method, ...detection.detail ? { detail: detection.detail } : {} };
|
|
52
88
|
if (url && !options.json) {
|
|
53
89
|
console.log(`${pc.green("[auto]")} Found dev server at ${pc.bold(url)} (${detection.detail})
|
|
54
90
|
`);
|
|
@@ -78,8 +114,10 @@ async function discoverCommand(options) {
|
|
|
78
114
|
if (!options.json) {
|
|
79
115
|
console.log(`${pc.blue("[discover]")} Classifying app type...`);
|
|
80
116
|
}
|
|
81
|
-
const { classifyApp } = await import("./classifier-
|
|
117
|
+
const { classifyApp, scoreAllSignatures, buildClassificationBreakdown } = await import("./classifier-MWQMQ727.js");
|
|
82
118
|
let guesses = classifyApp(snapshot);
|
|
119
|
+
const allScored = scoreAllSignatures(snapshot);
|
|
120
|
+
const breakdown = buildClassificationBreakdown(allScored);
|
|
83
121
|
if (!options.noLlm) {
|
|
84
122
|
const { needsTieBreak, tieBreakClassification } = await import("./tiebreak-L5UFNKU2.js");
|
|
85
123
|
if (needsTieBreak(guesses)) {
|
|
@@ -104,13 +142,17 @@ async function discoverCommand(options) {
|
|
|
104
142
|
console.log(pc.yellow(" no app type matched any signature"));
|
|
105
143
|
}
|
|
106
144
|
}
|
|
145
|
+
if (options.verbose) {
|
|
146
|
+
printVerboseBreakdown(breakdown);
|
|
147
|
+
}
|
|
107
148
|
if (!options.json) {
|
|
108
149
|
console.log(`${pc.blue("[discover]")} Generating scenarios...`);
|
|
109
150
|
}
|
|
110
|
-
const { generateScenarios } = await import("./scenarios-
|
|
151
|
+
const { generateScenarios } = await import("./scenarios-I7YYVTD2.js");
|
|
111
152
|
const happyScenarios = generateScenarios(snapshot, guesses, {
|
|
112
153
|
realism,
|
|
113
|
-
...options.appType && options.appType.length > 0 ? {
|
|
154
|
+
...options.appType && options.appType.length > 0 ? { filterAppTypes: options.appType } : {},
|
|
155
|
+
...options.forceAppType ? { forceAppType: options.forceAppType } : {}
|
|
114
156
|
});
|
|
115
157
|
const { enumerateAllEdgeVariants } = await import("./edge-cases-ZADKDZHL.js");
|
|
116
158
|
const edgeScenarios = enumerateAllEdgeVariants(happyScenarios, snapshot, {
|
|
@@ -129,12 +171,55 @@ async function discoverCommand(options) {
|
|
|
129
171
|
if (!options.json) {
|
|
130
172
|
console.log(pc.yellow(" no scenarios generated for this project"));
|
|
131
173
|
}
|
|
132
|
-
const report2 = { ...emptyReport(), appTypeGuesses: guesses };
|
|
133
|
-
return {
|
|
174
|
+
const report2 = { ...emptyReport(), appTypeGuesses: guesses, classificationBreakdown: breakdown };
|
|
175
|
+
return {
|
|
176
|
+
report: report2,
|
|
177
|
+
savedPaths: [],
|
|
178
|
+
baseUrl: url ?? "",
|
|
179
|
+
exitCode: 0,
|
|
180
|
+
...detectedFrom ? { detectedFrom } : {}
|
|
181
|
+
};
|
|
134
182
|
}
|
|
135
183
|
if (!options.json) {
|
|
136
184
|
console.log(` ${happyScenarios.length} happy + ${edgeScenarios.length} edge = ${allScenarios.length} total`);
|
|
137
185
|
}
|
|
186
|
+
if (options.dryRun) {
|
|
187
|
+
const DRY_RUN_CAP = 50;
|
|
188
|
+
const scenarios = allScenarios.slice(0, DRY_RUN_CAP).map((s) => ({
|
|
189
|
+
id: s.id,
|
|
190
|
+
name: s.name,
|
|
191
|
+
appType: s.appType,
|
|
192
|
+
journey: s.journey,
|
|
193
|
+
variant: s.variant,
|
|
194
|
+
...s.persona !== void 0 ? { persona: s.persona } : {},
|
|
195
|
+
stepCount: s.steps.length,
|
|
196
|
+
steps: s.steps.map((step) => `${step.n}. ${step.intent}`)
|
|
197
|
+
}));
|
|
198
|
+
const avgSteps = allScenarios.reduce((sum, s) => sum + s.steps.length, 0) / allScenarios.length;
|
|
199
|
+
const perScenarioMs = Math.min(avgSteps * DEFAULT_STEP_TIMEOUT_MS, DEFAULT_SCENARIO_TIMEOUT_MS);
|
|
200
|
+
const estimatedDurationMs = Math.round(perScenarioMs * allScenarios.length);
|
|
201
|
+
if (!options.json) {
|
|
202
|
+
console.log("");
|
|
203
|
+
console.log(pc.bold(" dry run \u2014 no browser launched, no reports written"));
|
|
204
|
+
for (const s of scenarios) {
|
|
205
|
+
console.log(` ${pc.green(s.appType)} ${s.id} ${pc.dim(`(${s.stepCount} steps)`)}`);
|
|
206
|
+
}
|
|
207
|
+
if (allScenarios.length > DRY_RUN_CAP) {
|
|
208
|
+
console.log(pc.dim(` ... ${allScenarios.length - DRY_RUN_CAP} more`));
|
|
209
|
+
}
|
|
210
|
+
console.log("");
|
|
211
|
+
console.log(pc.dim(` estimated run duration: ~${Math.round(estimatedDurationMs / 1e3)}s`));
|
|
212
|
+
}
|
|
213
|
+
const report2 = { ...emptyReport(), appTypeGuesses: guesses, classificationBreakdown: breakdown };
|
|
214
|
+
return {
|
|
215
|
+
report: report2,
|
|
216
|
+
savedPaths: [],
|
|
217
|
+
baseUrl: url ?? "",
|
|
218
|
+
exitCode: 0,
|
|
219
|
+
...detectedFrom ? { detectedFrom } : {},
|
|
220
|
+
dryRun: { scenarios, totalGenerated: allScenarios.length, estimatedDurationMs }
|
|
221
|
+
};
|
|
222
|
+
}
|
|
138
223
|
if (options.regenerate || options.regenerateOnly) {
|
|
139
224
|
const { saveDiscoveryScenarios } = await import("./persistence-KTCRIGHU.js");
|
|
140
225
|
const saveResult = await saveDiscoveryScenarios({
|
|
@@ -161,8 +246,14 @@ async function discoverCommand(options) {
|
|
|
161
246
|
}
|
|
162
247
|
}
|
|
163
248
|
if (options.regenerateOnly) {
|
|
164
|
-
const report2 = { ...emptyReport(), appTypeGuesses: guesses };
|
|
165
|
-
return {
|
|
249
|
+
const report2 = { ...emptyReport(), appTypeGuesses: guesses, classificationBreakdown: breakdown };
|
|
250
|
+
return {
|
|
251
|
+
report: report2,
|
|
252
|
+
savedPaths: [],
|
|
253
|
+
baseUrl: url ?? "",
|
|
254
|
+
exitCode: 0,
|
|
255
|
+
...detectedFrom ? { detectedFrom } : {}
|
|
256
|
+
};
|
|
166
257
|
}
|
|
167
258
|
}
|
|
168
259
|
if (!url) {
|
|
@@ -188,11 +279,13 @@ async function discoverCommand(options) {
|
|
|
188
279
|
}
|
|
189
280
|
const { runScenarios } = await import("./runner-OYTN2NFD.js");
|
|
190
281
|
let report = await runScenarios(allScenarios, guesses, runContext, config);
|
|
282
|
+
report.classificationBreakdown = breakdown;
|
|
191
283
|
const { markQuarantinedScenarios } = await import("./flakiness-OLJAY7CS.js");
|
|
192
284
|
const { loadFlakinessHistory } = await import("./persistence-RHUFBQAY.js");
|
|
193
285
|
const history = await loadFlakinessHistory(options.rootDir);
|
|
194
286
|
if (history) {
|
|
195
287
|
report = markQuarantinedScenarios(report, history, resolvedUrl);
|
|
288
|
+
report.classificationBreakdown = breakdown;
|
|
196
289
|
}
|
|
197
290
|
const { saveDiscoveryReport } = await import("./report-SDZWX25B.js");
|
|
198
291
|
const formats = options.format ? options.format.split(",").map((f) => f.trim()) : isCi ? ["html", "json", "junit"] : ["html", "json"];
|
|
@@ -219,10 +312,16 @@ async function discoverCommand(options) {
|
|
|
219
312
|
}
|
|
220
313
|
const { shouldFailCi } = await import("./flakiness-OLJAY7CS.js");
|
|
221
314
|
const exitCode = shouldFailCi(report) ? 1 : 0;
|
|
222
|
-
return {
|
|
315
|
+
return {
|
|
316
|
+
report,
|
|
317
|
+
savedPaths,
|
|
318
|
+
baseUrl: resolvedUrl,
|
|
319
|
+
exitCode,
|
|
320
|
+
...detectedFrom ? { detectedFrom } : {}
|
|
321
|
+
};
|
|
223
322
|
}
|
|
224
323
|
export {
|
|
225
324
|
discoverCommand,
|
|
226
325
|
productionUrlWarning
|
|
227
326
|
};
|
|
228
|
-
//# sourceMappingURL=discover-
|
|
327
|
+
//# sourceMappingURL=discover-JRU5E4FR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/discover.ts"],"sourcesContent":["import type { DiscoveryReport, DiscoveryRunContext } from '../../discovery/run-types.js';\nimport type { RealismProfile } from '../../discovery/scenarios/types.js';\n\nexport interface DiscoverOptions {\n rootDir: string;\n url?: string;\n headless?: boolean;\n ci?: boolean;\n json?: boolean;\n maxScenarios?: number;\n maxVariantsPerScenario?: number;\n maxVariantsPerRun?: number;\n realism?: RealismProfile;\n seed?: number;\n only?: string;\n /**\n * Filter classifier-provided guesses to these app types. Does NOT bypass\n * classification — if none of these types scored above threshold, no\n * scenarios are generated. Old `--app-type` CLI flag maps here.\n */\n appType?: string[];\n /**\n * Force a specific app type, bypassing the classifier entirely. New in\n * v0.5, wired to `--force-app-type <type>` on the CLI and `forceAppType`\n * on MCP.\n */\n forceAppType?: string;\n noLlm?: boolean;\n nonInteractive?: boolean;\n format?: string;\n regenerate?: boolean;\n regenerateOnly?: boolean;\n forceRegenerate?: boolean;\n verbose?: boolean;\n /**\n * Generate scenarios + classification and return them without opening a\n * browser, running tests, or writing reports. Useful for CI preview and\n * for iterating on force-app-type decisions.\n */\n dryRun?: boolean;\n}\n\nexport interface DryRunScenarioSummary {\n id: string;\n name: string;\n appType: string;\n journey: string;\n variant: string;\n persona?: string;\n stepCount: number;\n steps: string[];\n}\n\nexport interface DetectedFrom {\n method: 'flag' | 'config' | 'env' | 'script' | 'framework' | 'probe' | 'auto-increment' | 'none';\n detail?: string;\n}\n\nexport interface DiscoverResult {\n report: DiscoveryReport;\n savedPaths: string[];\n baseUrl: string;\n exitCode: number;\n /** How the baseUrl was resolved. */\n detectedFrom?: DetectedFrom;\n /** Populated only when `options.dryRun === true`. Capped at 50 entries. */\n dryRun?: {\n scenarios: DryRunScenarioSummary[];\n totalGenerated: number;\n estimatedDurationMs: number;\n };\n}\n\nconst DEFAULT_STEP_TIMEOUT_MS = 10_000;\nconst DEFAULT_SCENARIO_TIMEOUT_MS = 90_000;\nconst PROD_WARNING_DELAY_MS = 5_000;\n\nfunction isLocalhost(url: string): boolean {\n try {\n const parsed = new URL(url);\n const host = parsed.hostname;\n return (\n host === 'localhost' ||\n host === '127.0.0.1' ||\n host === '::1' ||\n host.endsWith('.localhost') ||\n /^192\\.168\\./.test(host) ||\n /^10\\./.test(host) ||\n /^172\\.(1[6-9]|2\\d|3[01])\\./.test(host)\n );\n } catch {\n return false;\n }\n}\n\nexport async function productionUrlWarning(\n url: string,\n options: { json?: boolean; nonInteractive?: boolean; delayMs?: number } = {},\n): Promise<void> {\n if (options.json || options.nonInteractive) return;\n if (isLocalhost(url)) return;\n\n const pc = (await import('picocolors')).default;\n const delay = options.delayMs ?? PROD_WARNING_DELAY_MS;\n const seconds = Math.max(1, Math.round(delay / 1000));\n\n console.log('');\n console.log(pc.yellow(pc.bold('WARNING: This URL looks like production.')));\n console.log(pc.yellow(` ${url}`));\n console.log(pc.yellow(' Discovery scenarios will create real data (orders, accounts, etc.).'));\n console.log(pc.yellow(` Press Ctrl+C in ${seconds}s to cancel, or wait to proceed.`));\n console.log('');\n\n await new Promise<void>((resolve) => setTimeout(resolve, delay));\n}\n\nexport async function discoverCommand(options: DiscoverOptions): Promise<DiscoverResult> {\n const pc = (await import('picocolors')).default;\n const isCi = !!options.ci || !!process.env.CI;\n const nonInteractive = !!options.nonInteractive || isCi;\n const headless = options.headless ?? true;\n const realism: RealismProfile = options.realism ?? (isCi ? 'robot' : 'casual-user');\n const maxScenarios = options.maxScenarios ?? 50;\n const maxVariantsPerScenario = options.maxVariantsPerScenario ?? 3;\n const maxVariantsPerRun = options.maxVariantsPerRun ?? 40;\n\n const { loadConfig } = await import('../../config/loader.js');\n const config = await loadConfig(options.rootDir);\n\n const emptyReport = (): DiscoveryReport => ({\n appTypeGuesses: [],\n scenarios: [],\n stats: { total: 0, passed: 0, failed: 0, skipped: 0, quarantined: 0, durationMs: 0 },\n runAt: new Date().toISOString(),\n });\n\n function printVerboseBreakdown(breakdown: import('../../discovery/classifier/index.js').ClassificationBreakdown): void {\n if (options.json) return;\n console.log('');\n console.log(pc.bold(' classification breakdown:'));\n console.log(pc.dim(' top 3:'));\n for (const t of breakdown.top3) {\n const pct = Math.round(t.confidence * 100);\n console.log(` ${pc.bold(t.type.padEnd(12))} ${String(pct).padStart(3)}% (raw score: ${t.rawScore})`);\n }\n const describeBucket = (label: string, entries: Array<{ value: string; weight: number; appType: string }>): void => {\n if (entries.length === 0) {\n console.log(pc.dim(` ${label}: —`));\n return;\n }\n const top = [...entries].sort((a, b) => b.weight - a.weight).slice(0, 8);\n console.log(pc.dim(` ${label}:`));\n for (const e of top) {\n console.log(` ${pc.dim(e.appType.padEnd(12))} ${e.value} ${pc.dim(`(+${e.weight})`)}`);\n }\n if (entries.length > top.length) {\n console.log(pc.dim(` ... ${entries.length - top.length} more`));\n }\n };\n describeBucket('routes ', breakdown.matchedSignals.routes);\n describeBucket('elements', breakdown.matchedSignals.elements);\n describeBucket('deps ', breakdown.matchedSignals.deps);\n describeBucket('schema ', breakdown.matchedSignals.schema);\n console.log('');\n }\n\n let url: string | undefined;\n let detectedFrom: DetectedFrom | undefined;\n if (!options.regenerateOnly && !options.dryRun) {\n if (options.url) {\n url = options.url;\n detectedFrom = { method: 'flag', detail: '--url' };\n } else if (config.browser?.baseUrl) {\n url = config.browser.baseUrl;\n detectedFrom = { method: 'config', detail: 'sniff.config.ts' };\n } else {\n const { detectDevServerUrl } = await import('../../config/dev-server-detector.js');\n const detection = await detectDevServerUrl(options.rootDir);\n url = detection.url;\n detectedFrom = { method: detection.method, ...(detection.detail ? { detail: detection.detail } : {}) };\n if (url && !options.json) {\n console.log(`${pc.green('[auto]')} Found dev server at ${pc.bold(url)} (${detection.detail})\\n`);\n }\n }\n\n if (!url) {\n console.error(pc.red('No URL available. Pass --url <url> or start your dev server.'));\n return { report: emptyReport(), savedPaths: [], baseUrl: '', exitCode: 1 };\n }\n\n try {\n const parsed = new URL(url);\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n console.error(pc.red(`URL must use http or https: ${url}`));\n return { report: emptyReport(), savedPaths: [], baseUrl: url, exitCode: 1 };\n }\n } catch {\n console.error(pc.red(`Invalid URL: ${url}`));\n return { report: emptyReport(), savedPaths: [], baseUrl: url, exitCode: 1 };\n }\n\n await productionUrlWarning(url, { json: options.json, nonInteractive });\n }\n\n if (!options.json) {\n console.log(`${pc.blue('[discover]')} Extracting domain snapshot...`);\n }\n const { extractDomainSnapshot } = await import('../../discovery/domain/index.js');\n const snapshot = await extractDomainSnapshot(options.rootDir);\n\n if (!options.json) {\n console.log(`${pc.blue('[discover]')} Classifying app type...`);\n }\n const { classifyApp, scoreAllSignatures, buildClassificationBreakdown } = await import(\n '../../discovery/classifier/index.js'\n );\n let guesses = classifyApp(snapshot);\n const allScored = scoreAllSignatures(snapshot);\n const breakdown = buildClassificationBreakdown(allScored);\n\n if (!options.noLlm) {\n const { needsTieBreak, tieBreakClassification } = await import('../../discovery/classifier/tiebreak.js');\n if (needsTieBreak(guesses)) {\n const { resolveDiscoveryLLM } = await import('../../discovery/llm/index.js');\n const llm = await resolveDiscoveryLLM({\n rootDir: options.rootDir,\n cacheDir: '.sniff/discover/cache',\n });\n if (llm) {\n if (!options.json) {\n console.log(pc.dim(' tie-break: asking Claude Code to break a close call...'));\n }\n guesses = await tieBreakClassification(guesses, snapshot, llm);\n }\n }\n }\n\n if (!options.json) {\n const top = guesses[0];\n if (top) {\n console.log(` top guess: ${pc.bold(top.type)} (${Math.round(top.confidence * 100)}%)`);\n } else {\n console.log(pc.yellow(' no app type matched any signature'));\n }\n }\n\n if (options.verbose) {\n printVerboseBreakdown(breakdown);\n }\n\n if (!options.json) {\n console.log(`${pc.blue('[discover]')} Generating scenarios...`);\n }\n const { generateScenarios } = await import('../../discovery/scenarios/index.js');\n const happyScenarios = generateScenarios(snapshot, guesses, {\n realism,\n ...(options.appType && options.appType.length > 0 ? { filterAppTypes: options.appType } : {}),\n ...(options.forceAppType ? { forceAppType: options.forceAppType } : {}),\n });\n\n const { enumerateAllEdgeVariants } = await import('../../discovery/edge-cases/index.js');\n const edgeScenarios = enumerateAllEdgeVariants(happyScenarios, snapshot, {\n maxPerScenario: maxVariantsPerScenario,\n maxPerRun: maxVariantsPerRun,\n });\n\n let allScenarios = [...happyScenarios, ...edgeScenarios];\n\n if (options.only) {\n const filter = options.only;\n allScenarios = allScenarios.filter((s) => s.id.includes(filter) || s.appType === filter);\n }\n\n if (allScenarios.length > maxScenarios) {\n allScenarios = allScenarios.slice(0, maxScenarios);\n }\n\n if (allScenarios.length === 0) {\n if (!options.json) {\n console.log(pc.yellow(' no scenarios generated for this project'));\n }\n const report: DiscoveryReport = { ...emptyReport(), appTypeGuesses: guesses, classificationBreakdown: breakdown };\n return {\n report,\n savedPaths: [],\n baseUrl: url ?? '',\n exitCode: 0,\n ...(detectedFrom ? { detectedFrom } : {}),\n };\n }\n\n if (!options.json) {\n console.log(` ${happyScenarios.length} happy + ${edgeScenarios.length} edge = ${allScenarios.length} total`);\n }\n\n if (options.dryRun) {\n // Short-circuit before runScenarios. No browser, no disk writes, no\n // network. Return a compact summary the caller can render or feed back\n // to an agent for review before committing to a real run.\n const DRY_RUN_CAP = 50;\n const scenarios: DryRunScenarioSummary[] = allScenarios.slice(0, DRY_RUN_CAP).map((s) => ({\n id: s.id,\n name: s.name,\n appType: s.appType,\n journey: s.journey,\n variant: s.variant,\n ...(s.persona !== undefined ? { persona: s.persona } : {}),\n stepCount: s.steps.length,\n steps: s.steps.map((step) => `${step.n}. ${step.intent}`),\n }));\n const avgSteps = allScenarios.reduce((sum, s) => sum + s.steps.length, 0) / allScenarios.length;\n const perScenarioMs = Math.min(avgSteps * DEFAULT_STEP_TIMEOUT_MS, DEFAULT_SCENARIO_TIMEOUT_MS);\n const estimatedDurationMs = Math.round(perScenarioMs * allScenarios.length);\n if (!options.json) {\n console.log('');\n console.log(pc.bold(' dry run — no browser launched, no reports written'));\n for (const s of scenarios) {\n console.log(` ${pc.green(s.appType)} ${s.id} ${pc.dim(`(${s.stepCount} steps)`)}`);\n }\n if (allScenarios.length > DRY_RUN_CAP) {\n console.log(pc.dim(` ... ${allScenarios.length - DRY_RUN_CAP} more`));\n }\n console.log('');\n console.log(pc.dim(` estimated run duration: ~${Math.round(estimatedDurationMs / 1000)}s`));\n }\n const report: DiscoveryReport = { ...emptyReport(), appTypeGuesses: guesses, classificationBreakdown: breakdown };\n return {\n report,\n savedPaths: [],\n baseUrl: url ?? '',\n exitCode: 0,\n ...(detectedFrom ? { detectedFrom } : {}),\n dryRun: { scenarios, totalGenerated: allScenarios.length, estimatedDurationMs },\n };\n }\n\n if (options.regenerate || options.regenerateOnly) {\n const { saveDiscoveryScenarios } = await import('../../discovery/persistence/index.js');\n const saveResult = await saveDiscoveryScenarios({\n rootDir: options.rootDir,\n snapshot,\n guesses,\n scenarios: allScenarios,\n ...(options.forceRegenerate ? { forceRegenerate: true } : {}),\n ...(nonInteractive ? { nonInteractive: true } : {}),\n });\n if (!options.json) {\n console.log(`${pc.blue('[persist]')} scenarios written to ${pc.dim(saveResult.generatedDir)}`);\n if (saveResult.written.length > 0) {\n console.log(` written: ${saveResult.written.length}`);\n }\n if (saveResult.skippedKept.length > 0) {\n console.log(` kept (hand-edited): ${saveResult.skippedKept.length}`);\n }\n if (saveResult.movedToCustom.length > 0) {\n console.log(` moved to custom/: ${saveResult.movedToCustom.length}`);\n }\n if (saveResult.removed.length > 0) {\n console.log(` removed: ${saveResult.removed.length}`);\n }\n }\n if (options.regenerateOnly) {\n const report: DiscoveryReport = { ...emptyReport(), appTypeGuesses: guesses, classificationBreakdown: breakdown };\n return {\n report,\n savedPaths: [],\n baseUrl: url ?? '',\n exitCode: 0,\n ...(detectedFrom ? { detectedFrom } : {}),\n };\n }\n }\n\n if (!url) {\n console.error(pc.red('Internal: URL missing after resolution. This should not happen.'));\n return { report: emptyReport(), savedPaths: [], baseUrl: '', exitCode: 1 };\n }\n const resolvedUrl: string = url;\n\n const { join } = await import('node:path');\n const reportDir = join(options.rootDir, 'sniff-reports', 'discovery');\n const viewport = { width: 1280, height: 720 };\n\n const runContext: DiscoveryRunContext = {\n baseUrl: resolvedUrl,\n rootDir: options.rootDir,\n headless,\n viewport,\n stepTimeoutMs: DEFAULT_STEP_TIMEOUT_MS,\n scenarioTimeoutMs: DEFAULT_SCENARIO_TIMEOUT_MS,\n reportDir,\n ...(options.seed !== undefined ? { seed: options.seed } : {}),\n };\n\n if (!options.json) {\n console.log(`${pc.green('[discover]')} Running ${allScenarios.length} scenarios against ${resolvedUrl}...`);\n }\n\n const { runScenarios } = await import('../../discovery/runner.js');\n let report = await runScenarios(allScenarios, guesses, runContext, config);\n report.classificationBreakdown = breakdown;\n\n const { markQuarantinedScenarios } = await import('../../discovery/report/flakiness.js');\n const { loadFlakinessHistory } = await import('../../core/persistence.js');\n const history = await loadFlakinessHistory(options.rootDir);\n if (history) {\n report = markQuarantinedScenarios(report, history, resolvedUrl);\n report.classificationBreakdown = breakdown;\n }\n\n const { saveDiscoveryReport } = await import('../../discovery/report/index.js');\n const formats: Array<'html' | 'json' | 'junit'> = options.format\n ? (options.format.split(',').map((f) => f.trim()) as Array<'html' | 'json' | 'junit'>)\n : (isCi ? ['html', 'json', 'junit'] : ['html', 'json']);\n const savedPaths = await saveDiscoveryReport({\n rootDir: options.rootDir,\n report,\n formats,\n });\n\n if (options.json) {\n console.log(JSON.stringify({ report, savedPaths }, null, 2));\n } else {\n console.log('');\n console.log(` passed: ${pc.green(report.stats.passed)}`);\n console.log(` failed: ${pc.red(report.stats.failed)}`);\n console.log(` skipped: ${pc.dim(report.stats.skipped)}`);\n if (report.stats.quarantined > 0) {\n console.log(` quarantined: ${pc.yellow(report.stats.quarantined)}`);\n }\n console.log(` duration: ${Math.round(report.stats.durationMs)}ms`);\n console.log('');\n for (const p of savedPaths) {\n console.log(pc.dim(` Report: ${p}`));\n }\n }\n\n const { shouldFailCi } = await import('../../discovery/report/flakiness.js');\n const exitCode = shouldFailCi(report) ? 1 : 0;\n return {\n report,\n savedPaths,\n baseUrl: resolvedUrl,\n exitCode,\n ...(detectedFrom ? { detectedFrom } : {}),\n };\n}\n"],"mappings":";AAyEA,IAAM,0BAA0B;A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