sniff-qa 0.5.2 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +2 -2
- package/CHANGELOG.md +60 -0
- package/README.md +219 -347
- package/SECURITY.md +3 -3
- package/dist/chunk-LJYT4MD5.js +1246 -0
- package/dist/chunk-LJYT4MD5.js.map +1 -0
- package/dist/cli/index.js +41 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/crawl-666NLYDC.js +11 -0
- package/dist/crawl-666NLYDC.js.map +1 -0
- package/dist/crawl-command-3OB4IUBU.js +54 -0
- package/dist/crawl-command-3OB4IUBU.js.map +1 -0
- package/dist/{discover-ENPRVN5A.js → discover-Q363YJ5X.js} +2 -2
- package/dist/{domain-UQ34YE4B.js → domain-NNL2PPRK.js} +1 -1
- package/dist/index.d.ts +94 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +76 -6
- package/dist/mcp/server.js.map +1 -1
- package/dist/{model-X5J2JR5U.js → model-2DTSAX7T.js} +1 -1
- package/dist/{quality-run-6SXCN5CD.js → quality-run-LLBZZI7X.js} +2 -2
- package/dist/{repo-analyzer-4OURSITY.js → repo-analyzer-WK5WP7NT.js} +1 -1
- package/dist/{report-OAHSB56I.js → report-IKRVVIW4.js} +2 -2
- package/dist/{unified-SKXQQX3Y.js → unified-67Z6YA64.js} +4 -4
- package/package.json +2 -2
- package/skills/sniff/SKILL.md +20 -25
- /package/dist/{discover-ENPRVN5A.js.map → discover-Q363YJ5X.js.map} +0 -0
- /package/dist/{domain-UQ34YE4B.js.map → domain-NNL2PPRK.js.map} +0 -0
- /package/dist/{model-X5J2JR5U.js.map → model-2DTSAX7T.js.map} +0 -0
- /package/dist/{quality-run-6SXCN5CD.js.map → quality-run-LLBZZI7X.js.map} +0 -0
- /package/dist/{repo-analyzer-4OURSITY.js.map → repo-analyzer-WK5WP7NT.js.map} +0 -0
- /package/dist/{report-OAHSB56I.js.map → report-IKRVVIW4.js.map} +0 -0
- /package/dist/{unified-SKXQQX3Y.js.map → unified-67Z6YA64.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/crawl-command.ts"],"sourcesContent":["import { join } from 'node:path';\nimport type { Severity } from '../../core/types.js';\n\nexport interface CrawlCommandOptions {\n rootDir: string;\n url: string;\n headless?: boolean;\n json?: boolean;\n /** Write a self-contained HTML report. */\n report?: boolean;\n /** Show low-confidence (uncertain) findings too. */\n all?: boolean;\n maxPages?: number;\n /** Include the mobile (375px) pass. Default true. */\n mobile?: boolean;\n failOn?: string;\n ci?: boolean;\n}\n\nconst VALID_SEVERITIES = new Set(['critical', 'high', 'medium', 'low', 'info']);\n\n/**\n * The default browser experience: drive a real browser, walk the app's flows,\n * and report real issues with proof. Returns the process exit code.\n */\nexport async function crawlCommand(opts: CrawlCommandOptions): Promise<number> {\n const pc = (await import('picocolors')).default;\n const { runCrawl, formatReportText, renderHtmlReport } = await import('../../crawl/index.js');\n const { writeFile, mkdir } = await import('node:fs/promises');\n\n const reportDir = join(opts.rootDir, 'sniff-reports');\n const isCi = opts.ci || !!process.env.CI;\n\n if (!opts.json) {\n const { getVersion } = await import('../../version.js');\n console.log(`\\n${pc.bold('sniff')} v${getVersion()} ${pc.dim('walking')} ${pc.bold(opts.url)}\\n`);\n }\n\n const report = await runCrawl({\n startUrl: opts.url,\n headless: opts.headless ?? true,\n includeMobile: opts.mobile ?? true,\n ...(opts.maxPages ? { maxPages: opts.maxPages } : {}),\n outputDir: join(reportDir, 'crawl'),\n onProgress: opts.json ? undefined : (m) => process.stderr.write(` ${pc.dim('·')} ${pc.dim(m)}\\n`),\n });\n\n // Persist the machine-readable report so `sniff` integrates with CI/agents.\n await mkdir(reportDir, { recursive: true }).catch(() => {});\n await writeFile(join(reportDir, 'sniff-crawl.json'), JSON.stringify(report, null, 2)).catch(() => {});\n\n if (opts.report) {\n const html = renderHtmlReport(report, { title: `sniff — ${new URL(opts.url).host}` });\n const htmlPath = join(reportDir, 'sniff-report.html');\n await writeFile(htmlPath, html).catch(() => {});\n if (!opts.json) console.log(pc.dim(` HTML report: ${htmlPath}`));\n }\n\n // Exit code: fail on shown findings at/above the configured severities.\n const failOn = (opts.failOn ?? 'critical,high')\n .split(',').map((s) => s.trim()).filter((s): s is Severity => VALID_SEVERITIES.has(s));\n const shown = report.findings.filter((f) => opts.all || f.confidence !== 'uncertain');\n const hasFailure = shown.some((f) => failOn.includes(f.severity));\n\n if (opts.json) {\n console.log(JSON.stringify(report, null, 2));\n } else {\n console.log(formatReportText(report, { all: opts.all }));\n // Make \"ran fine, found bugs\" unmistakable — a non-zero exit must not read\n // like a crash (first-time-user feedback).\n if (hasFailure) {\n console.log(pc.green('✓ Scan complete') + pc.dim(` — ${shown.length} issue(s) found. Exit code 1 so CI fails on bugs; pass `) + pc.bold('--fail-on none') + pc.dim(' to always exit 0.'));\n } else {\n console.log(pc.green('✓ Scan complete') + pc.dim(` — ${shown.length} issue(s) found.`));\n }\n }\n return hasFailure ? 1 : 0;\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAmBrB,IAAM,mBAAmB,oBAAI,IAAI,CAAC,YAAY,QAAQ,UAAU,OAAO,MAAM,CAAC;AAM9E,eAAsB,aAAa,MAA4C;AAC7E,QAAM,MAAM,MAAM,OAAO,YAAY,GAAG;AACxC,QAAM,EAAE,UAAU,kBAAkB,iBAAiB,IAAI,MAAM,OAAO,qBAAsB;AAC5F,QAAM,EAAE,WAAW,MAAM,IAAI,MAAM,OAAO,aAAkB;AAE5D,QAAM,YAAY,KAAK,KAAK,SAAS,eAAe;AACpD,QAAM,OAAO,KAAK,MAAM,CAAC,CAAC,QAAQ,IAAI;AAEtC,MAAI,CAAC,KAAK,MAAM;AACd,UAAM,EAAE,WAAW,IAAI,MAAM,OAAO,uBAAkB;AACtD,YAAQ,IAAI;AAAA,EAAK,GAAG,KAAK,OAAO,CAAC,KAAK,W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AACpF,QAAM,aAAa,MAAM,KAAK,CAAC,MAAM,OAAO,SAAS,EAAE,QAAQ,CAAC;AAEhE,MAAI,KAAK,MAAM;AACb,YAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,EAC7C,OAAO;AACL,YAAQ,IAAI,iBAAiB,QAAQ,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC;AAGvD,QAAI,YAAY;AACd,cAAQ,IAAI,GAAG,MAAM,sBAAiB,IAAI,GAAG,IAAI,WAAM,MAAM,MAAM,yDAAyD,IAAI,GAAG,KAAK,gBAAgB,IAAI,GAAG,IAAI,oBAAoB,CAAC;AAAA,IAC1L,OAAO;AACL,cAAQ,IAAI,GAAG,MAAM,sBAAiB,IAAI,GAAG,IAAI,WAAM,MAAM,MAAM,kBAAkB,CAAC;AAAA,IACxF;AAAA,EACF;AACA,SAAO,aAAa,IAAI;AAC1B;","names":[]}
|
|
@@ -109,7 +109,7 @@ async function discoverCommand(options) {
|
|
|
109
109
|
if (!options.json) {
|
|
110
110
|
console.log(`${pc.blue("[discover]")} Extracting domain snapshot...`);
|
|
111
111
|
}
|
|
112
|
-
const { extractDomainSnapshot } = await import("./domain-
|
|
112
|
+
const { extractDomainSnapshot } = await import("./domain-NNL2PPRK.js");
|
|
113
113
|
const snapshot = await extractDomainSnapshot(options.rootDir);
|
|
114
114
|
if (!options.json) {
|
|
115
115
|
console.log(`${pc.blue("[discover]")} Classifying app type...`);
|
|
@@ -324,4 +324,4 @@ export {
|
|
|
324
324
|
discoverCommand,
|
|
325
325
|
productionUrlWarning
|
|
326
326
|
};
|
|
327
|
-
//# sourceMappingURL=discover-
|
|
327
|
+
//# sourceMappingURL=discover-Q363YJ5X.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -250,4 +250,97 @@ interface GenerateOptions {
|
|
|
250
250
|
}
|
|
251
251
|
declare function generateTests(analysis: AnalysisResult, options: GenerateOptions): Promise<GeneratedTest[]>;
|
|
252
252
|
|
|
253
|
-
|
|
253
|
+
/**
|
|
254
|
+
* How sure we are the finding is a real, user-visible defect.
|
|
255
|
+
* - `confirmed`: deterministically reproduced with proof (e.g. an HTTP 500, an
|
|
256
|
+
* axe violation, a horizontal-overflow measurement). Safe to show by default.
|
|
257
|
+
* - `likely`: a strong heuristic fired (e.g. a submit click produced no
|
|
258
|
+
* observable effect) but a benign explanation is conceivable.
|
|
259
|
+
* - `uncertain`: worth a look but easily a false positive; suppressed from the
|
|
260
|
+
* default report unless `--all` is passed.
|
|
261
|
+
*/
|
|
262
|
+
type Confidence = 'confirmed' | 'likely' | 'uncertain';
|
|
263
|
+
/**
|
|
264
|
+
* Reproduction proof. The engine never emits a finding without at least a
|
|
265
|
+
* route and the ordered steps that produced it — "a finding without
|
|
266
|
+
* reproduction proof is not a finding".
|
|
267
|
+
*/
|
|
268
|
+
interface Reproduction {
|
|
269
|
+
/** Full URL where the issue was observed. */
|
|
270
|
+
url: string;
|
|
271
|
+
/** Pathname (normalized) for grouping/scoring. */
|
|
272
|
+
route: string;
|
|
273
|
+
/** Ordered, human-readable actions taken to reach/observe the issue. */
|
|
274
|
+
steps: string[];
|
|
275
|
+
/** Relative path to a screenshot captured at the moment of the finding. */
|
|
276
|
+
screenshotPath?: string;
|
|
277
|
+
/** Relevant console lines (errors/warnings) captured during the steps. */
|
|
278
|
+
consoleExcerpt?: string[];
|
|
279
|
+
/** Relevant failed/relevant network lines captured during the steps. */
|
|
280
|
+
networkExcerpt?: string[];
|
|
281
|
+
}
|
|
282
|
+
interface QaFinding {
|
|
283
|
+
/** Stable rule id, namespaced by domain, e.g. `route/broken-page`. */
|
|
284
|
+
ruleId: string;
|
|
285
|
+
/** Which of the 12 product issue classes this maps to (1-12). */
|
|
286
|
+
issueClass: number;
|
|
287
|
+
title: string;
|
|
288
|
+
severity: Severity;
|
|
289
|
+
confidence: Confidence;
|
|
290
|
+
/** Proof of reproduction — required. */
|
|
291
|
+
reproduction: Reproduction;
|
|
292
|
+
/** Actionable suggested fix. */
|
|
293
|
+
suggestedFix: string;
|
|
294
|
+
/**
|
|
295
|
+
* Set when the real outcome can only be confirmed outside the browser
|
|
296
|
+
* (e.g. a confirmation email, a webhook, an async job). The finding then
|
|
297
|
+
* explains how to check.
|
|
298
|
+
*/
|
|
299
|
+
needsOutOfBandVerification?: boolean;
|
|
300
|
+
}
|
|
301
|
+
interface CrawlStats {
|
|
302
|
+
pagesVisited: number;
|
|
303
|
+
linksChecked: number;
|
|
304
|
+
durationMs: number;
|
|
305
|
+
startUrl: string;
|
|
306
|
+
}
|
|
307
|
+
interface CrawlReport {
|
|
308
|
+
findings: QaFinding[];
|
|
309
|
+
stats: CrawlStats;
|
|
310
|
+
/** Routes that were reached and scanned. */
|
|
311
|
+
routes: string[];
|
|
312
|
+
runAt: string;
|
|
313
|
+
summary: {
|
|
314
|
+
total: number;
|
|
315
|
+
bySeverity: Record<string, number>;
|
|
316
|
+
byConfidence: Record<string, number>;
|
|
317
|
+
byIssueClass: Record<string, number>;
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
interface CrawlOptions {
|
|
322
|
+
startUrl: string;
|
|
323
|
+
maxPages?: number;
|
|
324
|
+
headless?: boolean;
|
|
325
|
+
includeMobile?: boolean;
|
|
326
|
+
outputDir?: string;
|
|
327
|
+
settleMs?: number;
|
|
328
|
+
linkTimeoutMs?: number;
|
|
329
|
+
onProgress?: (msg: string) => void;
|
|
330
|
+
}
|
|
331
|
+
declare function runCrawl(opts: CrawlOptions): Promise<CrawlReport>;
|
|
332
|
+
|
|
333
|
+
/** Render a self-contained (no external refs/scripts) dark-mode HTML report. */
|
|
334
|
+
declare function renderHtmlReport(report: CrawlReport, opts?: {
|
|
335
|
+
title?: string;
|
|
336
|
+
}): string;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Render a CrawlReport as a readable CLI summary. By default `uncertain`
|
|
340
|
+
* findings are hidden (shown with `all: true`).
|
|
341
|
+
*/
|
|
342
|
+
declare function formatReportText(report: CrawlReport, opts?: {
|
|
343
|
+
all?: boolean;
|
|
344
|
+
}): string;
|
|
345
|
+
|
|
346
|
+
export { type AIProvider, type AnalysisResult, type ComponentInfo, type Confidence, type CrawlOptions, type CrawlReport, type ElementInfo, type Finding, type FrameworkInfo, type GeneratedTest, type QaFinding, type Reproduction, type RouteInfo, type RouteTestContext, type Severity, type SniffConfig, type SniffUserConfig, defineConfig, formatReportText, generateTests, renderHtmlReport, runCrawl };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generateTests
|
|
3
3
|
} from "./chunk-CZKMOAXU.js";
|
|
4
|
+
import {
|
|
5
|
+
formatReportText,
|
|
6
|
+
renderHtmlReport,
|
|
7
|
+
runCrawl
|
|
8
|
+
} from "./chunk-LJYT4MD5.js";
|
|
4
9
|
|
|
5
10
|
// src/config/define-config.ts
|
|
6
11
|
function defineConfig(config) {
|
|
@@ -8,6 +13,9 @@ function defineConfig(config) {
|
|
|
8
13
|
}
|
|
9
14
|
export {
|
|
10
15
|
defineConfig,
|
|
11
|
-
|
|
16
|
+
formatReportText,
|
|
17
|
+
generateTests,
|
|
18
|
+
renderHtmlReport,
|
|
19
|
+
runCrawl
|
|
12
20
|
};
|
|
13
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config/define-config.ts"],"sourcesContent":["import type { SniffUserConfig } from './schema.js';\n\n/**\n * Helper for TypeScript autocomplete in sniff.config.ts\n * Usage: export default defineConfig({ ... })\n */\nexport function defineConfig(config: SniffUserConfig): SniffUserConfig {\n return config;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/config/define-config.ts"],"sourcesContent":["import type { SniffUserConfig } from './schema.js';\n\n/**\n * Helper for TypeScript autocomplete in sniff.config.ts\n * Usage: export default defineConfig({ ... })\n */\nexport function defineConfig(config: SniffUserConfig): SniffUserConfig {\n return config;\n}\n"],"mappings":";;;;;;;;;;AAMO,SAAS,aAAa,QAA0C;AACrE,SAAO;AACT;","names":[]}
|
package/dist/mcp/server.js
CHANGED
|
@@ -37,7 +37,7 @@ async function handleSniffScan(rootDir) {
|
|
|
37
37
|
return { content: [{ type: "text", text: JSON.stringify({ error: rootErr }) }] };
|
|
38
38
|
}
|
|
39
39
|
const { loadConfig } = await import("../loader-UG2XADG7.js");
|
|
40
|
-
const { runSourceScan } = await import("../quality-run-
|
|
40
|
+
const { runSourceScan } = await import("../quality-run-LLBZZI7X.js");
|
|
41
41
|
const { saveResults } = await import("../persistence-RHUFBQAY.js");
|
|
42
42
|
await loadConfig(rootDir);
|
|
43
43
|
const { results } = await runSourceScan(rootDir);
|
|
@@ -55,7 +55,7 @@ async function handleSniffRun(rootDir, baseUrl, headless) {
|
|
|
55
55
|
if (urlErr) {
|
|
56
56
|
return { content: [{ type: "text", text: JSON.stringify({ error: urlErr }) }] };
|
|
57
57
|
}
|
|
58
|
-
const { runSourceScan, routesFromAnalysis, runBrowserAudit } = await import("../quality-run-
|
|
58
|
+
const { runSourceScan, routesFromAnalysis, runBrowserAudit } = await import("../quality-run-LLBZZI7X.js");
|
|
59
59
|
const { saveResults } = await import("../persistence-RHUFBQAY.js");
|
|
60
60
|
const sourceRun = await runSourceScan(rootDir);
|
|
61
61
|
const { checkPlaywrightBrowsers } = await import("../ensure-browsers-AYKMLUHV.js");
|
|
@@ -103,6 +103,64 @@ async function handleSniffRun(rootDir, baseUrl, headless) {
|
|
|
103
103
|
]
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
+
async function handleSniffWalk(options) {
|
|
107
|
+
const rootErr = validateRootDir(options.rootDir);
|
|
108
|
+
if (rootErr) return { content: [{ type: "text", text: JSON.stringify({ error: rootErr }) }] };
|
|
109
|
+
let url = options.baseUrl;
|
|
110
|
+
if (!url) {
|
|
111
|
+
const { detectDevServerUrl } = await import("../dev-server-detector-XQ5AYPDT.js");
|
|
112
|
+
const detection = await detectDevServerUrl(options.rootDir);
|
|
113
|
+
url = detection.url;
|
|
114
|
+
}
|
|
115
|
+
if (!url) {
|
|
116
|
+
const scan = await handleSniffScan(options.rootDir);
|
|
117
|
+
return {
|
|
118
|
+
content: [{
|
|
119
|
+
type: "text",
|
|
120
|
+
text: JSON.stringify({
|
|
121
|
+
note: "No running app detected (no baseUrl, no dev server). Ran a source-only scan instead. Start your dev server or pass baseUrl to walk the live app and find runtime bugs.",
|
|
122
|
+
sourceScan: JSON.parse(scan.content[0].text)
|
|
123
|
+
})
|
|
124
|
+
}]
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const urlErr = validateBaseUrl(url);
|
|
128
|
+
if (urlErr) return { content: [{ type: "text", text: JSON.stringify({ error: urlErr }) }] };
|
|
129
|
+
const { loadConfig } = await import("../loader-UG2XADG7.js");
|
|
130
|
+
const config = await loadConfig(options.rootDir);
|
|
131
|
+
const { checkPlaywrightBrowsers } = await import("../ensure-browsers-AYKMLUHV.js");
|
|
132
|
+
const check = await checkPlaywrightBrowsers(config.browser?.projects);
|
|
133
|
+
if (check.status !== "installed") {
|
|
134
|
+
return {
|
|
135
|
+
content: [{
|
|
136
|
+
type: "text",
|
|
137
|
+
text: JSON.stringify({
|
|
138
|
+
needsSetup: "playwright-browsers",
|
|
139
|
+
projects: check.status === "missing" ? check.missingProjects : config.browser?.projects ?? ["chromium"],
|
|
140
|
+
installCommand: check.status === "missing" ? check.installCommand : `npx playwright install ${(config.browser?.projects ?? ["chromium"]).join(" ")}`,
|
|
141
|
+
installSizeMb: check.status === "missing" ? check.installSizeMb : 165,
|
|
142
|
+
hint: "Run the sniff_install MCP tool with the same projects, or run the install command manually, then retry."
|
|
143
|
+
})
|
|
144
|
+
}]
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const { join } = await import("path");
|
|
148
|
+
const { runCrawl } = await import("../crawl-666NLYDC.js");
|
|
149
|
+
const report = await runCrawl({
|
|
150
|
+
startUrl: url,
|
|
151
|
+
headless: options.headless ?? true,
|
|
152
|
+
includeMobile: options.mobile ?? true,
|
|
153
|
+
...options.maxPages ? { maxPages: options.maxPages } : {},
|
|
154
|
+
outputDir: join(options.rootDir, "sniff-reports", "crawl")
|
|
155
|
+
});
|
|
156
|
+
const shown = options.all ? report.findings : report.findings.filter((f) => f.confidence !== "uncertain");
|
|
157
|
+
return {
|
|
158
|
+
content: [{
|
|
159
|
+
type: "text",
|
|
160
|
+
text: JSON.stringify({ stats: report.stats, summary: report.summary, findings: shown }, null, 2)
|
|
161
|
+
}]
|
|
162
|
+
};
|
|
163
|
+
}
|
|
106
164
|
async function handleSniffDiscover(options) {
|
|
107
165
|
const rootErr = validateRootDir(options.rootDir);
|
|
108
166
|
if (rootErr) {
|
|
@@ -146,7 +204,7 @@ async function handleSniffDiscover(options) {
|
|
|
146
204
|
};
|
|
147
205
|
}
|
|
148
206
|
}
|
|
149
|
-
const { discoverCommand } = await import("../discover-
|
|
207
|
+
const { discoverCommand } = await import("../discover-Q363YJ5X.js");
|
|
150
208
|
const result = await discoverCommand({
|
|
151
209
|
rootDir: options.rootDir,
|
|
152
210
|
...options.baseUrl ? { url: options.baseUrl } : {},
|
|
@@ -192,6 +250,15 @@ async function handleSniffDiscover(options) {
|
|
|
192
250
|
}
|
|
193
251
|
async function handleSniffUnified(options) {
|
|
194
252
|
switch (options.mode) {
|
|
253
|
+
case "walk":
|
|
254
|
+
return handleSniffWalk({
|
|
255
|
+
rootDir: options.rootDir,
|
|
256
|
+
...options.baseUrl ? { baseUrl: options.baseUrl } : {},
|
|
257
|
+
headless: options.headless ?? true,
|
|
258
|
+
...options.maxPages !== void 0 ? { maxPages: options.maxPages } : {},
|
|
259
|
+
...options.mobile !== void 0 ? { mobile: options.mobile } : {},
|
|
260
|
+
...options.all !== void 0 ? { all: options.all } : {}
|
|
261
|
+
});
|
|
195
262
|
case "scan":
|
|
196
263
|
return handleSniffScan(options.rootDir);
|
|
197
264
|
case "run": {
|
|
@@ -288,12 +355,15 @@ async function startMcpServer() {
|
|
|
288
355
|
});
|
|
289
356
|
server.tool(
|
|
290
357
|
"sniff",
|
|
291
|
-
|
|
358
|
+
`Find real, reproducible QA bugs in a web app. Pass { mode, rootDir, baseUrl? }. Use mode:"walk" (RECOMMENDED) to drive a real browser, walk the app's user flows, and report broken pages/links, console & network errors, empty/placeholder data, broken forms, state-loss, dead-ends, bad loading/error states, responsive issues and accessibility \u2014 each with reproduction proof, severity, confidence, and a fix. mode:"scan" = source-only (no browser). mode:"report" = load last results. (mode:"run"/"discover" are legacy.) Auto-detects a running dev server if baseUrl is omitted. Prefer this over the narrow tools (sniff_scan / sniff_run / sniff_discover / sniff_report).`,
|
|
292
359
|
{
|
|
293
|
-
mode: z.enum(["scan", "run", "discover", "report"]).describe("
|
|
360
|
+
mode: z.enum(["walk", "scan", "run", "discover", "report"]).describe("walk = autonomous flow-walk that finds real bugs (RECOMMENDED for a running app); scan = source only; run/discover = legacy; report = load last results"),
|
|
294
361
|
rootDir: z.string().describe("Absolute path to the project root directory"),
|
|
295
|
-
baseUrl: z.string().optional(),
|
|
362
|
+
baseUrl: z.string().optional().describe("URL of the running app (walk/run/discover). Optional \u2014 auto-detected if omitted."),
|
|
296
363
|
headless: z.boolean().optional(),
|
|
364
|
+
maxPages: z.number().int().min(1).max(200).optional().describe("walk: max pages to crawl (default 25)"),
|
|
365
|
+
mobile: z.boolean().optional().describe("walk: include the mobile (375px) responsive pass (default true)"),
|
|
366
|
+
all: z.boolean().optional().describe("walk: include low-confidence findings too (default false)"),
|
|
297
367
|
format: z.enum(["json", "summary"]).optional(),
|
|
298
368
|
maxScenarios: z.number().int().min(1).max(200).optional(),
|
|
299
369
|
maxVariantsPerScenario: z.number().int().min(0).max(20).optional(),
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/server.ts","../../src/mcp/handlers.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod';\nimport { handleSniffScan, handleSniffRun, handleSniffReport, handleSniffDiscover, handleSniffInstall, handleSniffUnified } from './handlers.js';\nimport { getVersion } from '../version.js';\nimport type { BrowserProject } from '../config/schema.js';\n\nexport async function startMcpServer(): Promise<void> {\n const server = new McpServer({\n name: 'sniff',\n version: getVersion(),\n });\n\n // Tool: sniff -- unified entry point (preferred). Dispatches to the narrow\n // tools below. The narrow tools remain registered for back-compat and to\n // preserve the documented security pattern of scoped capabilities\n // (sniff-qa/DEEP-DIVE.md:1108). Marked deprecated in v0.5, removal planned v0.7.\n server.tool(\n 'sniff',\n 'Unified entry point. Pass { mode: \"scan\" | \"run\" | \"discover\" | \"report\", rootDir, ...} to dispatch. Prefer this over the narrow tools (sniff_scan / sniff_run / sniff_discover / sniff_report) which are kept only for back-compat.',\n {\n mode: z.enum(['scan', 'run', 'discover', 'report']).describe('scan = source only, run = source + browser audit, discover = autonomous E2E, report = load last results'),\n rootDir: z.string().describe('Absolute path to the project root directory'),\n baseUrl: z.string().optional(),\n headless: z.boolean().optional(),\n format: z.enum(['json', 'summary']).optional(),\n maxScenarios: z.number().int().min(1).max(200).optional(),\n maxVariantsPerScenario: z.number().int().min(0).max(20).optional(),\n maxVariantsPerRun: z.number().int().min(0).max(200).optional(),\n realism: z.enum(['robot', 'careful-user', 'casual-user', 'frustrated-user', 'power-user']).optional(),\n seed: z.number().int().optional(),\n only: z.string().optional(),\n appType: z.array(z.string()).optional(),\n forceAppType: z.string().optional(),\n dryRun: z.boolean().optional(),\n },\n async (args) => handleSniffUnified(args),\n );\n\n // Tool: sniff_scan -- static source analysis (no browser needed)\n server.tool(\n 'sniff_scan',\n 'Scan project source code for bugs. Finds debug statements, placeholder text, dead links, broken imports, hardcoded URLs, and API endpoint issues (missing validation, auth, error handling, secrets). Works offline, no browser or API key needed. Just pass the project path.',\n {\n rootDir: z.string().describe('Absolute path to the project root directory'),\n },\n async ({ rootDir }) => handleSniffScan(rootDir),\n );\n\n // Tool: sniff_run -- full audit (source + browser, auto-detects URL)\n server.tool(\n 'sniff_run',\n 'Run a full quality audit: source scan + browser checks (accessibility, visual regression, performance). The URL is optional -- sniff auto-detects running dev servers. If no server is found, runs source scan only. No API key needed.',\n {\n rootDir: z.string().describe('Absolute path to the project root directory'),\n baseUrl: z.string().optional().describe('URL of the running app. Optional -- sniff auto-detects localhost servers if omitted.'),\n headless: z.boolean().default(true).describe('Run browser in headless mode'),\n },\n async ({ rootDir, baseUrl, headless }) => {\n // Auto-detect URL if not provided\n let url = baseUrl;\n if (!url) {\n const { detectDevServerUrl } = await import('../config/dev-server-detector.js');\n const detection = await detectDevServerUrl(rootDir);\n url = detection.url;\n }\n\n if (url) {\n // Gate on Playwright — return structured setup hint instead of\n // silently running `npx playwright install` (MCP stdio transports\n // commonly time out on the ~45s install).\n const { loadConfig } = await import('../config/loader.js');\n const config = await loadConfig(rootDir);\n const { checkPlaywrightBrowsers } = await import('../core/ensure-browsers.js');\n const check = await checkPlaywrightBrowsers(config.browser?.projects);\n if (check.status !== 'installed') {\n return {\n content: [{\n type: 'text',\n text: JSON.stringify({\n needsSetup: 'playwright-browsers',\n projects: check.status === 'missing' ? check.missingProjects : config.browser?.projects ?? ['chromium'],\n installCommand: check.status === 'missing' ? check.installCommand : `npx playwright install ${(config.browser?.projects ?? ['chromium']).join(' ')}`,\n installSizeMb: check.status === 'missing' ? check.installSizeMb : 165,\n hint: 'Run the sniff_install MCP tool with the same projects, or run the install command manually, then retry.',\n }),\n }],\n };\n }\n return handleSniffRun(rootDir, url, headless);\n }\n\n // No server found -- fall back to source scan only\n return handleSniffScan(rootDir);\n },\n );\n\n // Tool: sniff_discover -- autonomous E2E discovery (scenarios + edge cases)\n server.tool(\n 'sniff_discover',\n 'Run autonomous end-to-end discovery: extract the app domain from source, classify the app type, generate scenarios with edge-case variants, drive them through Playwright, and return a compact summary. Requires a running dev server (baseUrl optional, auto-detected if omitted). Writes HTML/JSON reports to sniff-reports/discovery/.',\n {\n rootDir: z.string().describe('Absolute path to the project root directory'),\n baseUrl: z.string().optional().describe('URL of the running app. Optional -- sniff auto-detects localhost servers if omitted.'),\n headless: z.boolean().default(true).describe('Run browser in headless mode'),\n maxScenarios: z.number().int().min(1).max(200).optional().describe('Cap total scenarios (default: 50)'),\n maxVariantsPerScenario: z.number().int().min(0).max(20).optional().describe('Cap edge variants per scenario (default: 3)'),\n maxVariantsPerRun: z.number().int().min(0).max(200).optional().describe('Cap edge variants per run (default: 40)'),\n realism: z.enum(['robot', 'careful-user', 'casual-user', 'frustrated-user', 'power-user']).optional().describe('Realism profile (default: robot in CI, casual-user otherwise)'),\n seed: z.number().int().optional().describe('Replay a specific random seed'),\n only: z.string().optional().describe('Filter scenarios by id substring or app type'),\n appType: z.array(z.string()).optional().describe('Filter classifier guesses to these app types (does NOT bypass classification — use forceAppType for that)'),\n forceAppType: z.string().optional().describe('Force a single app type, bypassing the classifier entirely. Use when classification returns blank.'),\n dryRun: z.boolean().optional().describe('Generate scenarios + classify without launching a browser or writing reports. Useful for preview.'),\n },\n async (args) => {\n let url = args.baseUrl;\n if (!url) {\n const { detectDevServerUrl } = await import('../config/dev-server-detector.js');\n const detection = await detectDevServerUrl(args.rootDir);\n url = detection.url;\n }\n return handleSniffDiscover({\n rootDir: args.rootDir,\n baseUrl: url,\n headless: args.headless,\n ...(args.maxScenarios !== undefined ? { maxScenarios: args.maxScenarios } : {}),\n ...(args.maxVariantsPerScenario !== undefined ? { maxVariantsPerScenario: args.maxVariantsPerScenario } : {}),\n ...(args.maxVariantsPerRun !== undefined ? { maxVariantsPerRun: args.maxVariantsPerRun } : {}),\n ...(args.realism !== undefined ? { realism: args.realism } : {}),\n ...(args.seed !== undefined ? { seed: args.seed } : {}),\n ...(args.only !== undefined ? { only: args.only } : {}),\n ...(args.appType !== undefined ? { appType: args.appType } : {}),\n ...(args.forceAppType !== undefined ? { forceAppType: args.forceAppType } : {}),\n ...(args.dryRun !== undefined ? { dryRun: args.dryRun } : {}),\n });\n },\n );\n\n // Tool: sniff_install -- explicitly install requested Playwright browsers.\n // MCP browser tools return `needsSetup: playwright-browsers` instead of\n // silently shelling out (install takes ~45s, transports time out). Call\n // this tool when that happens, then retry the browser tool.\n server.tool(\n 'sniff_install',\n 'Install requested Playwright browser binaries (default: chromium). Run this when sniff_run or sniff_discover returns `needsSetup: playwright-browsers`.',\n {\n projects: z.array(z.enum(['chromium', 'firefox', 'webkit'])).optional().describe('Browser projects to install. Defaults to [\"chromium\"].'),\n },\n async ({ projects }) => handleSniffInstall(projects as BrowserProject[] | undefined),\n );\n\n // Tool: sniff_report -- load last results\n server.tool(\n 'sniff_report',\n 'Get the results from the most recent sniff scan. Returns findings, severities, and fix suggestions.',\n {\n rootDir: z.string().describe('Absolute path to the project root directory'),\n format: z.enum(['json', 'summary']).default('summary').describe('Output format: full JSON or text summary'),\n },\n async ({ rootDir, format }) => handleSniffReport(rootDir, format),\n );\n\n // Connect via stdio transport\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","import { resolve } from 'node:path';\nimport { existsSync } from 'node:fs';\nimport type { Finding, BrowserFinding } from '../core/types.js';\nimport type { BrowserProject } from '../config/schema.js';\n\nexport interface McpToolResult {\n [key: string]: unknown;\n content: Array<{ type: 'text'; text: string }>;\n}\n\n/**\n * Validate rootDir is absolute and exists on disk (T-04-15 mitigation).\n */\nfunction validateRootDir(rootDir: string): string | null {\n const resolved = resolve(rootDir);\n if (resolved !== rootDir) {\n return `rootDir must be an absolute path, got: ${rootDir}`;\n }\n if (!existsSync(resolved)) {\n return `rootDir does not exist: ${resolved}`;\n }\n return null;\n}\n\n/**\n * Validate baseUrl is a valid http/https URL (T-04-16 mitigation).\n */\nfunction validateBaseUrl(baseUrl: string): string | null {\n try {\n const parsed = new URL(baseUrl);\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n return `baseUrl must use http or https scheme, got: ${parsed.protocol}`;\n }\n return null;\n } catch {\n return `Invalid URL: ${baseUrl}`;\n }\n}\n\nexport async function handleSniffScan(rootDir: string): Promise<McpToolResult> {\n const rootErr = validateRootDir(rootDir);\n if (rootErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: rootErr }) }] };\n }\n\n const { loadConfig } = await import('../config/loader.js');\n const { runSourceScan } = await import('../core/quality-run.js');\n const { saveResults } = await import('../core/persistence.js');\n\n await loadConfig(rootDir); // Preserve config validation errors in this path.\n const { results } = await runSourceScan(rootDir);\n await saveResults(rootDir, results);\n return {\n content: [{ type: 'text', text: JSON.stringify(results, null, 2) }],\n };\n}\n\nexport async function handleSniffRun(\n rootDir: string,\n baseUrl: string,\n headless: boolean,\n): Promise<McpToolResult> {\n const rootErr = validateRootDir(rootDir);\n if (rootErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: rootErr }) }] };\n }\n\n const urlErr = validateBaseUrl(baseUrl);\n if (urlErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: urlErr }) }] };\n }\n\n const { runSourceScan, routesFromAnalysis, runBrowserAudit } = await import('../core/quality-run.js');\n const { saveResults } = await import('../core/persistence.js');\n\n const sourceRun = await runSourceScan(rootDir);\n const { checkPlaywrightBrowsers } = await import('../core/ensure-browsers.js');\n const check = await checkPlaywrightBrowsers(sourceRun.config.browser?.projects);\n if (check.status !== 'installed') {\n return {\n content: [{\n type: 'text',\n text: JSON.stringify({\n needsSetup: 'playwright-browsers',\n projects: check.status === 'missing' ? check.missingProjects : sourceRun.config.browser?.projects ?? ['chromium'],\n installCommand: check.status === 'missing' ? check.installCommand : `npx playwright install ${(sourceRun.config.browser?.projects ?? ['chromium']).join(' ')}`,\n installSizeMb: check.status === 'missing' ? check.installSizeMb : 165,\n hint: 'Run the sniff_install MCP tool with the same projects, or run the install command manually, then retry.',\n }),\n }],\n };\n }\n\n const browserRun = await runBrowserAudit({\n rootDir,\n config: sourceRun.config,\n baseUrl,\n routes: routesFromAnalysis(sourceRun.analysis),\n headless,\n });\n\n const results = [...sourceRun.results, ...browserRun.results];\n await saveResults(rootDir, results);\n\n const allFindings: Array<Finding | BrowserFinding> = results.flatMap((r) => r.findings);\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n {\n findings: allFindings,\n urls: browserRun.browserRun.urls,\n duration: browserRun.duration,\n scanners: results.map((r) => r.scanner),\n findingCount: allFindings.length,\n },\n null,\n 2,\n ),\n },\n ],\n };\n}\n\nexport interface SniffDiscoverOptions {\n rootDir: string;\n baseUrl?: string;\n headless?: boolean;\n maxScenarios?: number;\n maxVariantsPerScenario?: number;\n maxVariantsPerRun?: number;\n realism?: 'robot' | 'careful-user' | 'casual-user' | 'frustrated-user' | 'power-user';\n seed?: number;\n only?: string;\n appType?: string[];\n forceAppType?: string;\n dryRun?: boolean;\n}\n\nexport async function handleSniffDiscover(options: SniffDiscoverOptions): Promise<McpToolResult> {\n const rootErr = validateRootDir(options.rootDir);\n if (rootErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: rootErr }) }] };\n }\n\n if (!options.baseUrl && !options.dryRun) {\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n error: 'No baseUrl provided and no local dev server detected. Start your dev server or pass baseUrl.',\n }),\n },\n ],\n };\n }\n\n if (options.baseUrl) {\n const urlErr = validateBaseUrl(options.baseUrl);\n if (urlErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: urlErr }) }] };\n }\n }\n\n // Gate on Playwright install — skip when dryRun since no browser runs.\n if (!options.dryRun) {\n const { loadConfig } = await import('../config/loader.js');\n const config = await loadConfig(options.rootDir);\n const { checkPlaywrightBrowsers } = await import('../core/ensure-browsers.js');\n const check = await checkPlaywrightBrowsers(config.browser?.projects);\n if (check.status !== 'installed') {\n return {\n content: [{\n type: 'text',\n text: JSON.stringify({\n needsSetup: 'playwright-browsers',\n projects: check.status === 'missing' ? check.missingProjects : config.browser?.projects ?? ['chromium'],\n installCommand: check.status === 'missing' ? check.installCommand : `npx playwright install ${(config.browser?.projects ?? ['chromium']).join(' ')}`,\n installSizeMb: check.status === 'missing' ? check.installSizeMb : 165,\n hint: 'Run the sniff_install MCP tool with the same projects, or run the install command manually, then retry.',\n }),\n }],\n };\n }\n }\n\n const { discoverCommand } = await import('../cli/commands/discover.js');\n const result = await discoverCommand({\n rootDir: options.rootDir,\n ...(options.baseUrl ? { url: options.baseUrl } : {}),\n headless: options.headless ?? true,\n nonInteractive: true,\n json: true,\n ...(options.maxScenarios !== undefined ? { maxScenarios: options.maxScenarios } : {}),\n ...(options.maxVariantsPerScenario !== undefined\n ? { maxVariantsPerScenario: options.maxVariantsPerScenario }\n : {}),\n ...(options.maxVariantsPerRun !== undefined ? { maxVariantsPerRun: options.maxVariantsPerRun } : {}),\n ...(options.realism !== undefined ? { realism: options.realism } : {}),\n ...(options.seed !== undefined ? { seed: options.seed } : {}),\n ...(options.only !== undefined ? { only: options.only } : {}),\n ...(options.appType !== undefined ? { appType: options.appType } : {}),\n ...(options.forceAppType !== undefined ? { forceAppType: options.forceAppType } : {}),\n ...(options.dryRun ? { dryRun: true } : {}),\n });\n\n const reports: { html?: string; json?: string; junit?: string } = {};\n for (const p of result.savedPaths) {\n if (p.endsWith('.html')) reports.html = p;\n else if (p.endsWith('.xml')) reports.junit = p;\n else if (p.endsWith('.json')) reports.json = p;\n }\n const summary = {\n baseUrl: result.baseUrl,\n detectedFrom: result.detectedFrom,\n stats: result.report.stats,\n topAppType: result.report.appTypeGuesses[0]?.type,\n topAppConfidence: result.report.appTypeGuesses[0]?.confidence,\n classificationBreakdown: result.report.classificationBreakdown,\n ...(result.dryRun ? { dryRun: result.dryRun } : {}),\n reports,\n savedPaths: result.savedPaths,\n failedScenarios: result.report.scenarios\n .filter((s) => s.status === 'fail' && s.quarantined !== true)\n .map((s) => ({\n id: s.scenario.id,\n name: s.scenario.name,\n failureReason: s.steps.find((step) => step.status === 'fail')?.failureReason,\n })),\n exitCode: result.exitCode,\n };\n\n return {\n content: [{ type: 'text', text: JSON.stringify(summary, null, 2) }],\n };\n}\n\nexport interface SniffUnifiedOptions {\n mode: 'scan' | 'run' | 'discover' | 'report';\n rootDir: string;\n baseUrl?: string;\n headless?: boolean;\n format?: 'json' | 'summary';\n maxScenarios?: number;\n maxVariantsPerScenario?: number;\n maxVariantsPerRun?: number;\n realism?: 'robot' | 'careful-user' | 'casual-user' | 'frustrated-user' | 'power-user';\n seed?: number;\n only?: string;\n appType?: string[];\n forceAppType?: string;\n dryRun?: boolean;\n}\n\n/**\n * Dispatch for the unified `sniff` MCP tool. Normalizes the discriminated\n * union input and calls through to the narrow handlers. No new capabilities —\n * this is a UX wrapper only, preserving the security pattern of scoped tools.\n */\nexport async function handleSniffUnified(options: SniffUnifiedOptions): Promise<McpToolResult> {\n switch (options.mode) {\n case 'scan':\n return handleSniffScan(options.rootDir);\n case 'run': {\n let url = options.baseUrl;\n if (!url) {\n const { detectDevServerUrl } = await import('../config/dev-server-detector.js');\n const detection = await detectDevServerUrl(options.rootDir);\n url = detection.url;\n }\n if (!url) return handleSniffScan(options.rootDir);\n return handleSniffRun(options.rootDir, url, options.headless ?? true);\n }\n case 'discover': {\n let url = options.baseUrl;\n if (!url && !options.dryRun) {\n const { detectDevServerUrl } = await import('../config/dev-server-detector.js');\n const detection = await detectDevServerUrl(options.rootDir);\n url = detection.url;\n }\n return handleSniffDiscover({\n rootDir: options.rootDir,\n ...(url ? { baseUrl: url } : {}),\n headless: options.headless ?? true,\n ...(options.maxScenarios !== undefined ? { maxScenarios: options.maxScenarios } : {}),\n ...(options.maxVariantsPerScenario !== undefined ? { maxVariantsPerScenario: options.maxVariantsPerScenario } : {}),\n ...(options.maxVariantsPerRun !== undefined ? { maxVariantsPerRun: options.maxVariantsPerRun } : {}),\n ...(options.realism !== undefined ? { realism: options.realism } : {}),\n ...(options.seed !== undefined ? { seed: options.seed } : {}),\n ...(options.only !== undefined ? { only: options.only } : {}),\n ...(options.appType !== undefined ? { appType: options.appType } : {}),\n ...(options.forceAppType !== undefined ? { forceAppType: options.forceAppType } : {}),\n ...(options.dryRun ? { dryRun: true } : {}),\n });\n }\n case 'report':\n return handleSniffReport(options.rootDir, options.format ?? 'summary');\n }\n}\n\nexport async function handleSniffInstall(projects?: BrowserProject[]): Promise<McpToolResult> {\n const { installPlaywrightBrowserProjects } = await import('../core/ensure-browsers.js');\n const requestedProjects: BrowserProject[] = projects && projects.length > 0 ? projects : ['chromium'];\n const result = await installPlaywrightBrowserProjects(requestedProjects);\n return {\n content: [{\n type: 'text',\n text: JSON.stringify(\n result.status === 'ok'\n ? { status: 'installed', projects: result.projects }\n : { status: 'failed', projects: result.projects, error: result.error, hint: `Run \\`npx playwright install ${requestedProjects.join(' ')}\\` manually for full error output.` },\n ),\n }],\n };\n}\n\nexport async function handleSniffReport(\n rootDir: string,\n format: 'json' | 'summary',\n): Promise<McpToolResult> {\n const rootErr = validateRootDir(rootDir);\n if (rootErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: rootErr }) }] };\n }\n\n const { loadLastResults } = await import('../core/persistence.js');\n const results = await loadLastResults(rootDir);\n\n if (!results) {\n return {\n content: [\n {\n type: 'text',\n text: 'No previous sniff results found. Run the unified sniff tool with mode \"scan\" or \"run\" first.',\n },\n ],\n };\n }\n\n if (format === 'json') {\n return { content: [{ type: 'text', text: JSON.stringify(results, null, 2) }] };\n }\n\n // Summary format\n const totalFindings = results.results.reduce((sum, r) => sum + r.findings.length, 0);\n const bySeverity: Record<string, number> = {};\n for (const r of results.results) {\n for (const f of r.findings) {\n bySeverity[f.severity] = (bySeverity[f.severity] ?? 0) + 1;\n }\n }\n const scanners = results.results.map((r) => r.scanner).join(', ');\n const summary = [\n `Sniff Results (${results.timestamp})`,\n `Scanners: ${scanners}`,\n `Total findings: ${totalFindings}`,\n ...Object.entries(bySeverity).map(([sev, count]) => ` ${sev}: ${count}`),\n ].join('\\n');\n\n return { content: [{ type: 'text', text: summary }] };\n}\n"],"mappings":";;;;;AAAA,SAAS,iBAAiB;AAC1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KAAK,QAAQ,IAAI,CAAC;AAAA,QAC9D,GAAI,KAAK,SAAS,SAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;AAAA,QACrD,GAAI,KAAK,SAAS,SAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;AAAA,QACrD,GAAI,KAAK,YAAY,SAAY,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,QAC9D,GAAI,KAAK,iBAAiB,SAAY,EAAE,cAAc,KAAK,aAAa,IAAI,CAAC;AAAA,QAC7E,GAAI,KAAK,WAAW,SAAY,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;AAAA,MAC7D,CAAC;AAAA,IACH;AAAA,EACF;AAMA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,MACE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,YAAY,WAAW,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,wDAAwD;AAAA,IAC3I;AAAA,IACA,OAAO,EAAE,SAAS,MAAM,mBAAmB,QAAwC;AAAA,EACrF;AAGA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,MACE,SAAS,EAAE,OAAO,EAAE,SAAS,6CAA6C;AAAA,MAC1E,QAAQ,EAAE,KAAK,CAAC,QAAQ,SAAS,CAAC,EAAE,QAAQ,SAAS,EAAE,SAAS,0CAA0C;AAAA,IAC5G;AAAA,IACA,OAAO,EAAE,SAAS,OAAO,MAAM,kBAAkB,SAAS,MAAM;AAAA,EAClE;AAGA,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/server.ts","../../src/mcp/handlers.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod';\nimport { handleSniffScan, handleSniffRun, handleSniffReport, handleSniffDiscover, handleSniffInstall, handleSniffUnified } from './handlers.js';\nimport { getVersion } from '../version.js';\nimport type { BrowserProject } from '../config/schema.js';\n\nexport async function startMcpServer(): Promise<void> {\n const server = new McpServer({\n name: 'sniff',\n version: getVersion(),\n });\n\n // Tool: sniff -- unified entry point (preferred). Dispatches to the narrow\n // tools below. The narrow tools remain registered for back-compat and to\n // preserve the documented security pattern of scoped capabilities\n // (sniff-qa/DEEP-DIVE.md:1108). Marked deprecated in v0.5, removal planned v0.7.\n server.tool(\n 'sniff',\n 'Find real, reproducible QA bugs in a web app. Pass { mode, rootDir, baseUrl? }. Use mode:\"walk\" (RECOMMENDED) to drive a real browser, walk the app\\'s user flows, and report broken pages/links, console & network errors, empty/placeholder data, broken forms, state-loss, dead-ends, bad loading/error states, responsive issues and accessibility — each with reproduction proof, severity, confidence, and a fix. mode:\"scan\" = source-only (no browser). mode:\"report\" = load last results. (mode:\"run\"/\"discover\" are legacy.) Auto-detects a running dev server if baseUrl is omitted. Prefer this over the narrow tools (sniff_scan / sniff_run / sniff_discover / sniff_report).',\n {\n mode: z.enum(['walk', 'scan', 'run', 'discover', 'report']).describe('walk = autonomous flow-walk that finds real bugs (RECOMMENDED for a running app); scan = source only; run/discover = legacy; report = load last results'),\n rootDir: z.string().describe('Absolute path to the project root directory'),\n baseUrl: z.string().optional().describe('URL of the running app (walk/run/discover). Optional — auto-detected if omitted.'),\n headless: z.boolean().optional(),\n maxPages: z.number().int().min(1).max(200).optional().describe('walk: max pages to crawl (default 25)'),\n mobile: z.boolean().optional().describe('walk: include the mobile (375px) responsive pass (default true)'),\n all: z.boolean().optional().describe('walk: include low-confidence findings too (default false)'),\n format: z.enum(['json', 'summary']).optional(),\n maxScenarios: z.number().int().min(1).max(200).optional(),\n maxVariantsPerScenario: z.number().int().min(0).max(20).optional(),\n maxVariantsPerRun: z.number().int().min(0).max(200).optional(),\n realism: z.enum(['robot', 'careful-user', 'casual-user', 'frustrated-user', 'power-user']).optional(),\n seed: z.number().int().optional(),\n only: z.string().optional(),\n appType: z.array(z.string()).optional(),\n forceAppType: z.string().optional(),\n dryRun: z.boolean().optional(),\n },\n async (args) => handleSniffUnified(args),\n );\n\n // Tool: sniff_scan -- static source analysis (no browser needed)\n server.tool(\n 'sniff_scan',\n 'Scan project source code for bugs. Finds debug statements, placeholder text, dead links, broken imports, hardcoded URLs, and API endpoint issues (missing validation, auth, error handling, secrets). Works offline, no browser or API key needed. Just pass the project path.',\n {\n rootDir: z.string().describe('Absolute path to the project root directory'),\n },\n async ({ rootDir }) => handleSniffScan(rootDir),\n );\n\n // Tool: sniff_run -- full audit (source + browser, auto-detects URL)\n server.tool(\n 'sniff_run',\n 'Run a full quality audit: source scan + browser checks (accessibility, visual regression, performance). The URL is optional -- sniff auto-detects running dev servers. If no server is found, runs source scan only. No API key needed.',\n {\n rootDir: z.string().describe('Absolute path to the project root directory'),\n baseUrl: z.string().optional().describe('URL of the running app. Optional -- sniff auto-detects localhost servers if omitted.'),\n headless: z.boolean().default(true).describe('Run browser in headless mode'),\n },\n async ({ rootDir, baseUrl, headless }) => {\n // Auto-detect URL if not provided\n let url = baseUrl;\n if (!url) {\n const { detectDevServerUrl } = await import('../config/dev-server-detector.js');\n const detection = await detectDevServerUrl(rootDir);\n url = detection.url;\n }\n\n if (url) {\n // Gate on Playwright — return structured setup hint instead of\n // silently running `npx playwright install` (MCP stdio transports\n // commonly time out on the ~45s install).\n const { loadConfig } = await import('../config/loader.js');\n const config = await loadConfig(rootDir);\n const { checkPlaywrightBrowsers } = await import('../core/ensure-browsers.js');\n const check = await checkPlaywrightBrowsers(config.browser?.projects);\n if (check.status !== 'installed') {\n return {\n content: [{\n type: 'text',\n text: JSON.stringify({\n needsSetup: 'playwright-browsers',\n projects: check.status === 'missing' ? check.missingProjects : config.browser?.projects ?? ['chromium'],\n installCommand: check.status === 'missing' ? check.installCommand : `npx playwright install ${(config.browser?.projects ?? ['chromium']).join(' ')}`,\n installSizeMb: check.status === 'missing' ? check.installSizeMb : 165,\n hint: 'Run the sniff_install MCP tool with the same projects, or run the install command manually, then retry.',\n }),\n }],\n };\n }\n return handleSniffRun(rootDir, url, headless);\n }\n\n // No server found -- fall back to source scan only\n return handleSniffScan(rootDir);\n },\n );\n\n // Tool: sniff_discover -- autonomous E2E discovery (scenarios + edge cases)\n server.tool(\n 'sniff_discover',\n 'Run autonomous end-to-end discovery: extract the app domain from source, classify the app type, generate scenarios with edge-case variants, drive them through Playwright, and return a compact summary. Requires a running dev server (baseUrl optional, auto-detected if omitted). Writes HTML/JSON reports to sniff-reports/discovery/.',\n {\n rootDir: z.string().describe('Absolute path to the project root directory'),\n baseUrl: z.string().optional().describe('URL of the running app. Optional -- sniff auto-detects localhost servers if omitted.'),\n headless: z.boolean().default(true).describe('Run browser in headless mode'),\n maxScenarios: z.number().int().min(1).max(200).optional().describe('Cap total scenarios (default: 50)'),\n maxVariantsPerScenario: z.number().int().min(0).max(20).optional().describe('Cap edge variants per scenario (default: 3)'),\n maxVariantsPerRun: z.number().int().min(0).max(200).optional().describe('Cap edge variants per run (default: 40)'),\n realism: z.enum(['robot', 'careful-user', 'casual-user', 'frustrated-user', 'power-user']).optional().describe('Realism profile (default: robot in CI, casual-user otherwise)'),\n seed: z.number().int().optional().describe('Replay a specific random seed'),\n only: z.string().optional().describe('Filter scenarios by id substring or app type'),\n appType: z.array(z.string()).optional().describe('Filter classifier guesses to these app types (does NOT bypass classification — use forceAppType for that)'),\n forceAppType: z.string().optional().describe('Force a single app type, bypassing the classifier entirely. Use when classification returns blank.'),\n dryRun: z.boolean().optional().describe('Generate scenarios + classify without launching a browser or writing reports. Useful for preview.'),\n },\n async (args) => {\n let url = args.baseUrl;\n if (!url) {\n const { detectDevServerUrl } = await import('../config/dev-server-detector.js');\n const detection = await detectDevServerUrl(args.rootDir);\n url = detection.url;\n }\n return handleSniffDiscover({\n rootDir: args.rootDir,\n baseUrl: url,\n headless: args.headless,\n ...(args.maxScenarios !== undefined ? { maxScenarios: args.maxScenarios } : {}),\n ...(args.maxVariantsPerScenario !== undefined ? { maxVariantsPerScenario: args.maxVariantsPerScenario } : {}),\n ...(args.maxVariantsPerRun !== undefined ? { maxVariantsPerRun: args.maxVariantsPerRun } : {}),\n ...(args.realism !== undefined ? { realism: args.realism } : {}),\n ...(args.seed !== undefined ? { seed: args.seed } : {}),\n ...(args.only !== undefined ? { only: args.only } : {}),\n ...(args.appType !== undefined ? { appType: args.appType } : {}),\n ...(args.forceAppType !== undefined ? { forceAppType: args.forceAppType } : {}),\n ...(args.dryRun !== undefined ? { dryRun: args.dryRun } : {}),\n });\n },\n );\n\n // Tool: sniff_install -- explicitly install requested Playwright browsers.\n // MCP browser tools return `needsSetup: playwright-browsers` instead of\n // silently shelling out (install takes ~45s, transports time out). Call\n // this tool when that happens, then retry the browser tool.\n server.tool(\n 'sniff_install',\n 'Install requested Playwright browser binaries (default: chromium). Run this when sniff_run or sniff_discover returns `needsSetup: playwright-browsers`.',\n {\n projects: z.array(z.enum(['chromium', 'firefox', 'webkit'])).optional().describe('Browser projects to install. Defaults to [\"chromium\"].'),\n },\n async ({ projects }) => handleSniffInstall(projects as BrowserProject[] | undefined),\n );\n\n // Tool: sniff_report -- load last results\n server.tool(\n 'sniff_report',\n 'Get the results from the most recent sniff scan. Returns findings, severities, and fix suggestions.',\n {\n rootDir: z.string().describe('Absolute path to the project root directory'),\n format: z.enum(['json', 'summary']).default('summary').describe('Output format: full JSON or text summary'),\n },\n async ({ rootDir, format }) => handleSniffReport(rootDir, format),\n );\n\n // Connect via stdio transport\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","import { resolve } from 'node:path';\nimport { existsSync } from 'node:fs';\nimport type { Finding, BrowserFinding } from '../core/types.js';\nimport type { BrowserProject } from '../config/schema.js';\n\nexport interface McpToolResult {\n [key: string]: unknown;\n content: Array<{ type: 'text'; text: string }>;\n}\n\n/**\n * Validate rootDir is absolute and exists on disk (T-04-15 mitigation).\n */\nfunction validateRootDir(rootDir: string): string | null {\n const resolved = resolve(rootDir);\n if (resolved !== rootDir) {\n return `rootDir must be an absolute path, got: ${rootDir}`;\n }\n if (!existsSync(resolved)) {\n return `rootDir does not exist: ${resolved}`;\n }\n return null;\n}\n\n/**\n * Validate baseUrl is a valid http/https URL (T-04-16 mitigation).\n */\nfunction validateBaseUrl(baseUrl: string): string | null {\n try {\n const parsed = new URL(baseUrl);\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n return `baseUrl must use http or https scheme, got: ${parsed.protocol}`;\n }\n return null;\n } catch {\n return `Invalid URL: ${baseUrl}`;\n }\n}\n\nexport async function handleSniffScan(rootDir: string): Promise<McpToolResult> {\n const rootErr = validateRootDir(rootDir);\n if (rootErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: rootErr }) }] };\n }\n\n const { loadConfig } = await import('../config/loader.js');\n const { runSourceScan } = await import('../core/quality-run.js');\n const { saveResults } = await import('../core/persistence.js');\n\n await loadConfig(rootDir); // Preserve config validation errors in this path.\n const { results } = await runSourceScan(rootDir);\n await saveResults(rootDir, results);\n return {\n content: [{ type: 'text', text: JSON.stringify(results, null, 2) }],\n };\n}\n\nexport async function handleSniffRun(\n rootDir: string,\n baseUrl: string,\n headless: boolean,\n): Promise<McpToolResult> {\n const rootErr = validateRootDir(rootDir);\n if (rootErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: rootErr }) }] };\n }\n\n const urlErr = validateBaseUrl(baseUrl);\n if (urlErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: urlErr }) }] };\n }\n\n const { runSourceScan, routesFromAnalysis, runBrowserAudit } = await import('../core/quality-run.js');\n const { saveResults } = await import('../core/persistence.js');\n\n const sourceRun = await runSourceScan(rootDir);\n const { checkPlaywrightBrowsers } = await import('../core/ensure-browsers.js');\n const check = await checkPlaywrightBrowsers(sourceRun.config.browser?.projects);\n if (check.status !== 'installed') {\n return {\n content: [{\n type: 'text',\n text: JSON.stringify({\n needsSetup: 'playwright-browsers',\n projects: check.status === 'missing' ? check.missingProjects : sourceRun.config.browser?.projects ?? ['chromium'],\n installCommand: check.status === 'missing' ? check.installCommand : `npx playwright install ${(sourceRun.config.browser?.projects ?? ['chromium']).join(' ')}`,\n installSizeMb: check.status === 'missing' ? check.installSizeMb : 165,\n hint: 'Run the sniff_install MCP tool with the same projects, or run the install command manually, then retry.',\n }),\n }],\n };\n }\n\n const browserRun = await runBrowserAudit({\n rootDir,\n config: sourceRun.config,\n baseUrl,\n routes: routesFromAnalysis(sourceRun.analysis),\n headless,\n });\n\n const results = [...sourceRun.results, ...browserRun.results];\n await saveResults(rootDir, results);\n\n const allFindings: Array<Finding | BrowserFinding> = results.flatMap((r) => r.findings);\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(\n {\n findings: allFindings,\n urls: browserRun.browserRun.urls,\n duration: browserRun.duration,\n scanners: results.map((r) => r.scanner),\n findingCount: allFindings.length,\n },\n null,\n 2,\n ),\n },\n ],\n };\n}\n\nexport interface SniffWalkOptions {\n rootDir: string;\n baseUrl?: string;\n headless?: boolean;\n maxPages?: number;\n mobile?: boolean;\n all?: boolean;\n}\n\n/**\n * The recommended action: drive a real browser, walk the app's user flows, and\n * return real issues with reproduction proof (route + steps + console/network),\n * severity, confidence, and a suggested fix. Auto-detects a running dev server\n * if baseUrl is omitted; falls back to a source scan when no app is running.\n */\nexport async function handleSniffWalk(options: SniffWalkOptions): Promise<McpToolResult> {\n const rootErr = validateRootDir(options.rootDir);\n if (rootErr) return { content: [{ type: 'text', text: JSON.stringify({ error: rootErr }) }] };\n\n let url = options.baseUrl;\n if (!url) {\n const { detectDevServerUrl } = await import('../config/dev-server-detector.js');\n const detection = await detectDevServerUrl(options.rootDir);\n url = detection.url;\n }\n if (!url) {\n // No running app — degrade gracefully to a source scan so the agent still\n // gets something useful, and say so.\n const scan = await handleSniffScan(options.rootDir);\n return {\n content: [{\n type: 'text',\n text: JSON.stringify({\n note: 'No running app detected (no baseUrl, no dev server). Ran a source-only scan instead. Start your dev server or pass baseUrl to walk the live app and find runtime bugs.',\n sourceScan: JSON.parse(scan.content[0]!.text),\n }),\n }],\n };\n }\n\n const urlErr = validateBaseUrl(url);\n if (urlErr) return { content: [{ type: 'text', text: JSON.stringify({ error: urlErr }) }] };\n\n const { loadConfig } = await import('../config/loader.js');\n const config = await loadConfig(options.rootDir);\n const { checkPlaywrightBrowsers } = await import('../core/ensure-browsers.js');\n const check = await checkPlaywrightBrowsers(config.browser?.projects);\n if (check.status !== 'installed') {\n return {\n content: [{\n type: 'text',\n text: JSON.stringify({\n needsSetup: 'playwright-browsers',\n projects: check.status === 'missing' ? check.missingProjects : config.browser?.projects ?? ['chromium'],\n installCommand: check.status === 'missing' ? check.installCommand : `npx playwright install ${(config.browser?.projects ?? ['chromium']).join(' ')}`,\n installSizeMb: check.status === 'missing' ? check.installSizeMb : 165,\n hint: 'Run the sniff_install MCP tool with the same projects, or run the install command manually, then retry.',\n }),\n }],\n };\n }\n\n const { join } = await import('node:path');\n const { runCrawl } = await import('../crawl/index.js');\n const report = await runCrawl({\n startUrl: url,\n headless: options.headless ?? true,\n includeMobile: options.mobile ?? true,\n ...(options.maxPages ? { maxPages: options.maxPages } : {}),\n outputDir: join(options.rootDir, 'sniff-reports', 'crawl'),\n });\n\n const shown = options.all ? report.findings : report.findings.filter((f) => f.confidence !== 'uncertain');\n return {\n content: [{\n type: 'text',\n text: JSON.stringify({ stats: report.stats, summary: report.summary, findings: shown }, null, 2),\n }],\n };\n}\n\nexport interface SniffDiscoverOptions {\n rootDir: string;\n baseUrl?: string;\n headless?: boolean;\n maxScenarios?: number;\n maxVariantsPerScenario?: number;\n maxVariantsPerRun?: number;\n realism?: 'robot' | 'careful-user' | 'casual-user' | 'frustrated-user' | 'power-user';\n seed?: number;\n only?: string;\n appType?: string[];\n forceAppType?: string;\n dryRun?: boolean;\n}\n\nexport async function handleSniffDiscover(options: SniffDiscoverOptions): Promise<McpToolResult> {\n const rootErr = validateRootDir(options.rootDir);\n if (rootErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: rootErr }) }] };\n }\n\n if (!options.baseUrl && !options.dryRun) {\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n error: 'No baseUrl provided and no local dev server detected. Start your dev server or pass baseUrl.',\n }),\n },\n ],\n };\n }\n\n if (options.baseUrl) {\n const urlErr = validateBaseUrl(options.baseUrl);\n if (urlErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: urlErr }) }] };\n }\n }\n\n // Gate on Playwright install — skip when dryRun since no browser runs.\n if (!options.dryRun) {\n const { loadConfig } = await import('../config/loader.js');\n const config = await loadConfig(options.rootDir);\n const { checkPlaywrightBrowsers } = await import('../core/ensure-browsers.js');\n const check = await checkPlaywrightBrowsers(config.browser?.projects);\n if (check.status !== 'installed') {\n return {\n content: [{\n type: 'text',\n text: JSON.stringify({\n needsSetup: 'playwright-browsers',\n projects: check.status === 'missing' ? check.missingProjects : config.browser?.projects ?? ['chromium'],\n installCommand: check.status === 'missing' ? check.installCommand : `npx playwright install ${(config.browser?.projects ?? ['chromium']).join(' ')}`,\n installSizeMb: check.status === 'missing' ? check.installSizeMb : 165,\n hint: 'Run the sniff_install MCP tool with the same projects, or run the install command manually, then retry.',\n }),\n }],\n };\n }\n }\n\n const { discoverCommand } = await import('../cli/commands/discover.js');\n const result = await discoverCommand({\n rootDir: options.rootDir,\n ...(options.baseUrl ? { url: options.baseUrl } : {}),\n headless: options.headless ?? true,\n nonInteractive: true,\n json: true,\n ...(options.maxScenarios !== undefined ? { maxScenarios: options.maxScenarios } : {}),\n ...(options.maxVariantsPerScenario !== undefined\n ? { maxVariantsPerScenario: options.maxVariantsPerScenario }\n : {}),\n ...(options.maxVariantsPerRun !== undefined ? { maxVariantsPerRun: options.maxVariantsPerRun } : {}),\n ...(options.realism !== undefined ? { realism: options.realism } : {}),\n ...(options.seed !== undefined ? { seed: options.seed } : {}),\n ...(options.only !== undefined ? { only: options.only } : {}),\n ...(options.appType !== undefined ? { appType: options.appType } : {}),\n ...(options.forceAppType !== undefined ? { forceAppType: options.forceAppType } : {}),\n ...(options.dryRun ? { dryRun: true } : {}),\n });\n\n const reports: { html?: string; json?: string; junit?: string } = {};\n for (const p of result.savedPaths) {\n if (p.endsWith('.html')) reports.html = p;\n else if (p.endsWith('.xml')) reports.junit = p;\n else if (p.endsWith('.json')) reports.json = p;\n }\n const summary = {\n baseUrl: result.baseUrl,\n detectedFrom: result.detectedFrom,\n stats: result.report.stats,\n topAppType: result.report.appTypeGuesses[0]?.type,\n topAppConfidence: result.report.appTypeGuesses[0]?.confidence,\n classificationBreakdown: result.report.classificationBreakdown,\n ...(result.dryRun ? { dryRun: result.dryRun } : {}),\n reports,\n savedPaths: result.savedPaths,\n failedScenarios: result.report.scenarios\n .filter((s) => s.status === 'fail' && s.quarantined !== true)\n .map((s) => ({\n id: s.scenario.id,\n name: s.scenario.name,\n failureReason: s.steps.find((step) => step.status === 'fail')?.failureReason,\n })),\n exitCode: result.exitCode,\n };\n\n return {\n content: [{ type: 'text', text: JSON.stringify(summary, null, 2) }],\n };\n}\n\nexport interface SniffUnifiedOptions {\n mode: 'walk' | 'scan' | 'run' | 'discover' | 'report';\n rootDir: string;\n baseUrl?: string;\n headless?: boolean;\n maxPages?: number;\n mobile?: boolean;\n all?: boolean;\n format?: 'json' | 'summary';\n maxScenarios?: number;\n maxVariantsPerScenario?: number;\n maxVariantsPerRun?: number;\n realism?: 'robot' | 'careful-user' | 'casual-user' | 'frustrated-user' | 'power-user';\n seed?: number;\n only?: string;\n appType?: string[];\n forceAppType?: string;\n dryRun?: boolean;\n}\n\n/**\n * Dispatch for the unified `sniff` MCP tool. Normalizes the discriminated\n * union input and calls through to the narrow handlers. No new capabilities —\n * this is a UX wrapper only, preserving the security pattern of scoped tools.\n */\nexport async function handleSniffUnified(options: SniffUnifiedOptions): Promise<McpToolResult> {\n switch (options.mode) {\n case 'walk':\n return handleSniffWalk({\n rootDir: options.rootDir,\n ...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),\n headless: options.headless ?? true,\n ...(options.maxPages !== undefined ? { maxPages: options.maxPages } : {}),\n ...(options.mobile !== undefined ? { mobile: options.mobile } : {}),\n ...(options.all !== undefined ? { all: options.all } : {}),\n });\n case 'scan':\n return handleSniffScan(options.rootDir);\n case 'run': {\n let url = options.baseUrl;\n if (!url) {\n const { detectDevServerUrl } = await import('../config/dev-server-detector.js');\n const detection = await detectDevServerUrl(options.rootDir);\n url = detection.url;\n }\n if (!url) return handleSniffScan(options.rootDir);\n return handleSniffRun(options.rootDir, url, options.headless ?? true);\n }\n case 'discover': {\n let url = options.baseUrl;\n if (!url && !options.dryRun) {\n const { detectDevServerUrl } = await import('../config/dev-server-detector.js');\n const detection = await detectDevServerUrl(options.rootDir);\n url = detection.url;\n }\n return handleSniffDiscover({\n rootDir: options.rootDir,\n ...(url ? { baseUrl: url } : {}),\n headless: options.headless ?? true,\n ...(options.maxScenarios !== undefined ? { maxScenarios: options.maxScenarios } : {}),\n ...(options.maxVariantsPerScenario !== undefined ? { maxVariantsPerScenario: options.maxVariantsPerScenario } : {}),\n ...(options.maxVariantsPerRun !== undefined ? { maxVariantsPerRun: options.maxVariantsPerRun } : {}),\n ...(options.realism !== undefined ? { realism: options.realism } : {}),\n ...(options.seed !== undefined ? { seed: options.seed } : {}),\n ...(options.only !== undefined ? { only: options.only } : {}),\n ...(options.appType !== undefined ? { appType: options.appType } : {}),\n ...(options.forceAppType !== undefined ? { forceAppType: options.forceAppType } : {}),\n ...(options.dryRun ? { dryRun: true } : {}),\n });\n }\n case 'report':\n return handleSniffReport(options.rootDir, options.format ?? 'summary');\n }\n}\n\nexport async function handleSniffInstall(projects?: BrowserProject[]): Promise<McpToolResult> {\n const { installPlaywrightBrowserProjects } = await import('../core/ensure-browsers.js');\n const requestedProjects: BrowserProject[] = projects && projects.length > 0 ? projects : ['chromium'];\n const result = await installPlaywrightBrowserProjects(requestedProjects);\n return {\n content: [{\n type: 'text',\n text: JSON.stringify(\n result.status === 'ok'\n ? { status: 'installed', projects: result.projects }\n : { status: 'failed', projects: result.projects, error: result.error, hint: `Run \\`npx playwright install ${requestedProjects.join(' ')}\\` manually for full error output.` },\n ),\n }],\n };\n}\n\nexport async function handleSniffReport(\n rootDir: string,\n format: 'json' | 'summary',\n): Promise<McpToolResult> {\n const rootErr = validateRootDir(rootDir);\n if (rootErr) {\n return { content: [{ type: 'text', text: JSON.stringify({ error: rootErr }) }] };\n }\n\n const { loadLastResults } = await import('../core/persistence.js');\n const results = await loadLastResults(rootDir);\n\n if (!results) {\n return {\n content: [\n {\n type: 'text',\n text: 'No previous sniff results found. Run the unified sniff tool with mode \"scan\" or \"run\" first.',\n },\n ],\n };\n }\n\n if (format === 'json') {\n return { content: [{ type: 'text', text: JSON.stringify(results, null, 2) }] };\n }\n\n // Summary format\n const totalFindings = results.results.reduce((sum, r) => sum + r.findings.length, 0);\n const bySeverity: Record<string, number> = {};\n for (const r of results.results) {\n for (const f of r.findings) {\n bySeverity[f.severity] = (bySeverity[f.severity] ?? 0) + 1;\n }\n }\n const scanners = results.results.map((r) => r.scanner).join(', ');\n const summary = [\n `Sniff Results (${results.timestamp})`,\n `Scanners: ${scanners}`,\n `Total findings: ${totalFindings}`,\n ...Object.entries(bySeverity).map(([sev, count]) => ` ${sev}: ${count}`),\n ].join('\\n');\n\n return { content: [{ type: 'text', text: summary }] };\n}\n"],"mappings":";;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,SAAS;;;ACFlB,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAY3B,SAAS,gBAAgB,SAAgC;AACvD,QAAM,WAAW,QAAQ,OAAO;AAChC,MAAI,aAAa,SAAS;AACxB,WAAO,0CAA0C,OAAO;AAAA,EAC1D;AACA,MAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,WAAO,2BAA2B,QAAQ;AAAA,EAC5C;AACA,SAAO;AACT;AAKA,SAAS,gBAAgB,SAAgC;AACvD,MAAI;AACF,UAAM,SAAS,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AAI,KAAK,SAAS,SAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;AAAA,QACrD,GAAI,KAAK,SAAS,SAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;AAAA,QACrD,GAAI,KAAK,YAAY,SAAY,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,QAC9D,GAAI,KAAK,iBAAiB,SAAY,EAAE,cAAc,KAAK,aAAa,IAAI,CAAC;AAAA,QAC7E,GAAI,KAAK,WAAW,SAAY,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;AAAA,MAC7D,CAAC;AAAA,IACH;AAAA,EACF;AAMA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,MACE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,YAAY,WAAW,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,wDAAwD;AAAA,IAC3I;AAAA,IACA,OAAO,EAAE,SAAS,MAAM,mBAAmB,QAAwC;AAAA,EACrF;AAGA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,MACE,SAAS,EAAE,OAAO,EAAE,SAAS,6CAA6C;AAAA,MAC1E,QAAQ,EAAE,KAAK,CAAC,QAAQ,SAAS,CAAC,EAAE,QAAQ,SAAS,EAAE,SAAS,0CAA0C;AAAA,IAC5G;AAAA,IACA,OAAO,EAAE,SAAS,OAAO,MAAM,kBAAkB,SAAS,MAAM;AAAA,EAClE;AAGA,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;","names":[]}
|
|
@@ -3,7 +3,7 @@ async function runSourceScan(rootDir) {
|
|
|
3
3
|
const { loadConfig } = await import("./loader-UG2XADG7.js");
|
|
4
4
|
const { ScannerRegistry } = await import("./registry-5XCXUAYJ.js");
|
|
5
5
|
const { SourceScanner } = await import("./source-5LS2B7TN.js");
|
|
6
|
-
const { RepoAnalyzer } = await import("./repo-analyzer-
|
|
6
|
+
const { RepoAnalyzer } = await import("./repo-analyzer-WK5WP7NT.js");
|
|
7
7
|
const config = await loadConfig(rootDir);
|
|
8
8
|
const registry = new ScannerRegistry();
|
|
9
9
|
registry.register(new SourceScanner());
|
|
@@ -76,4 +76,4 @@ export {
|
|
|
76
76
|
runBrowserAudit,
|
|
77
77
|
runSourceScan
|
|
78
78
|
};
|
|
79
|
-
//# sourceMappingURL=quality-run-
|
|
79
|
+
//# sourceMappingURL=quality-run-LLBZZI7X.js.map
|
|
@@ -9,7 +9,7 @@ async function reportCommand(options) {
|
|
|
9
9
|
console.log(`Last scan: ${data.timestamp}`);
|
|
10
10
|
const findings = data.results.flatMap((r) => r.findings);
|
|
11
11
|
if (options.format) {
|
|
12
|
-
const { buildReport, saveReport } = await import("./model-
|
|
12
|
+
const { buildReport, saveReport } = await import("./model-2DTSAX7T.js");
|
|
13
13
|
const report = buildReport(
|
|
14
14
|
data.results,
|
|
15
15
|
{
|
|
@@ -58,4 +58,4 @@ async function reportCommand(options) {
|
|
|
58
58
|
export {
|
|
59
59
|
reportCommand
|
|
60
60
|
};
|
|
61
|
-
//# sourceMappingURL=report-
|
|
61
|
+
//# sourceMappingURL=report-IKRVVIW4.js.map
|
|
@@ -30,7 +30,7 @@ ${pc.bold("sniff")} v${getVersion()}
|
|
|
30
30
|
console.log(`${pc.blue("[source]")} Scanning source code...`);
|
|
31
31
|
}
|
|
32
32
|
const { saveResults } = await import("./persistence-RHUFBQAY.js");
|
|
33
|
-
const { runSourceScan, generateAiTestsIfEnabled } = await import("./quality-run-
|
|
33
|
+
const { runSourceScan, generateAiTestsIfEnabled } = await import("./quality-run-LLBZZI7X.js");
|
|
34
34
|
const sourceRun = await runSourceScan(options.rootDir);
|
|
35
35
|
const { config, results: sourceResults, analysis } = sourceRun;
|
|
36
36
|
allResults.push(...sourceResults);
|
|
@@ -54,7 +54,7 @@ ${pc.bold("sniff")} v${getVersion()}
|
|
|
54
54
|
console.log(`
|
|
55
55
|
${pc.green("[browser]")} Testing ${options.url}...`);
|
|
56
56
|
}
|
|
57
|
-
const { routesFromAnalysis, runBrowserAudit } = await import("./quality-run-
|
|
57
|
+
const { routesFromAnalysis, runBrowserAudit } = await import("./quality-run-LLBZZI7X.js");
|
|
58
58
|
const viewports = config.viewports ?? [
|
|
59
59
|
{ name: "desktop", width: 1280, height: 720 },
|
|
60
60
|
{ name: "mobile", width: 375, height: 667 },
|
|
@@ -87,7 +87,7 @@ ${pc.green("[browser]")} Testing ${options.url}...`);
|
|
|
87
87
|
console.log(`${pc.green("[perf]")} ${perfResult.findings.length} budget violation${perfResult.findings.length !== 1 ? "s" : ""}`);
|
|
88
88
|
}
|
|
89
89
|
allResults.push(...browserAudit.results);
|
|
90
|
-
const { buildReport, saveReport } = await import("./model-
|
|
90
|
+
const { buildReport, saveReport } = await import("./model-2DTSAX7T.js");
|
|
91
91
|
const report = buildReport(
|
|
92
92
|
allResults,
|
|
93
93
|
{
|
|
@@ -224,4 +224,4 @@ ${pc.magenta("[explore]")} Chaos monkey starting...`);
|
|
|
224
224
|
export {
|
|
225
225
|
unifiedCommand
|
|
226
226
|
};
|
|
227
|
-
//# sourceMappingURL=unified-
|
|
227
|
+
//# sourceMappingURL=unified-67Z6YA64.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sniff-qa",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"description": "Autonomous QA scanner: point it at your running app and it walks the real user flows in a headless browser and reports what's actually broken — broken pages/links, console & network errors, empty/placeholder data, broken forms, state-loss, bad loading/error states, responsive and accessibility issues — each with reproduction proof, severity, confidence, and a fix. CLI + MCP server. No API key. Uses Playwright and axe-core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|