sniff-qa 0.4.0 → 0.5.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.
Files changed (100) hide show
  1. package/.claude-plugin/plugin.json +13 -0
  2. package/CHANGELOG.md +89 -0
  3. package/NOTICE +14 -0
  4. package/README.md +127 -38
  5. package/SECURITY.md +33 -0
  6. package/dist/{accessibility-UNJB57T6.js → accessibility-JXRMWF5Y.js} +10 -1
  7. package/dist/accessibility-JXRMWF5Y.js.map +1 -0
  8. package/dist/{anthropic-api-MRDZ7BJA.js → anthropic-api-ZR3UEB3Z.js} +5 -3
  9. package/dist/anthropic-api-ZR3UEB3Z.js.map +1 -0
  10. package/dist/{chunk-623BAIU2.js → chunk-CZKMOAXU.js} +10 -3
  11. package/dist/chunk-CZKMOAXU.js.map +1 -0
  12. package/dist/{chunk-CBDOJUXB.js → chunk-MYWWSM3V.js} +14 -6
  13. package/dist/chunk-MYWWSM3V.js.map +1 -0
  14. package/dist/{ci-2MVD2ISE.js → ci-ISCWZJD3.js} +3 -3
  15. package/dist/{ci-2MVD2ISE.js.map → ci-ISCWZJD3.js.map} +1 -1
  16. package/dist/classifier-MWQMQ727.js +1701 -0
  17. package/dist/classifier-MWQMQ727.js.map +1 -0
  18. package/dist/{claude-code-F722EIIC.js → claude-code-ZFTBQXY4.js} +7 -3
  19. package/dist/claude-code-ZFTBQXY4.js.map +1 -0
  20. package/dist/cli/index.js +38 -44
  21. package/dist/cli/index.js.map +1 -1
  22. package/dist/dev-server-detector-XQ5AYPDT.js +319 -0
  23. package/dist/dev-server-detector-XQ5AYPDT.js.map +1 -0
  24. package/dist/{discover-BLUSO42Q.js → discover-ENPRVN5A.js} +114 -15
  25. package/dist/discover-ENPRVN5A.js.map +1 -0
  26. package/dist/ensure-browsers-AYKMLUHV.js +86 -0
  27. package/dist/ensure-browsers-AYKMLUHV.js.map +1 -0
  28. package/dist/generator-HIFV67NI.js +7 -0
  29. package/dist/index.d.ts +43 -2
  30. package/dist/index.js +1 -1
  31. package/dist/init-IQKT4ANC.js +148 -0
  32. package/dist/init-IQKT4ANC.js.map +1 -0
  33. package/dist/{loader-QII5CZSX.js → loader-UG2XADG7.js} +25 -4
  34. package/dist/loader-UG2XADG7.js.map +1 -0
  35. package/dist/mcp/server.js +186 -41
  36. package/dist/mcp/server.js.map +1 -1
  37. package/dist/{model-2DTSAX7T.js → model-X5J2JR5U.js} +1 -1
  38. package/dist/{page-hooks-DOZWXF7Z.js → page-hooks-6RALVZB5.js} +2 -2
  39. package/dist/{performance-FBUGBRB3.js → performance-7HWKY5O2.js} +6 -3
  40. package/dist/performance-7HWKY5O2.js.map +1 -0
  41. package/dist/provider-BCKFVPTN.js +183 -0
  42. package/dist/provider-BCKFVPTN.js.map +1 -0
  43. package/dist/quality-run-6SXCN5CD.js +79 -0
  44. package/dist/quality-run-6SXCN5CD.js.map +1 -0
  45. package/dist/{registry-NB5CZB6W.js → registry-5XCXUAYJ.js} +14 -2
  46. package/dist/registry-5XCXUAYJ.js.map +1 -0
  47. package/dist/{report-STC6CAVJ.js → report-OAHSB56I.js} +2 -2
  48. package/dist/{runner-OYTN2NFD.js → runner-AXZXNWYH.js} +3 -3
  49. package/dist/runner-AXZXNWYH.js.map +1 -0
  50. package/dist/{runner-Z4I2YVVM.js → runner-HFJDHS2I.js} +3 -3
  51. package/dist/runner-HFJDHS2I.js.map +1 -0
  52. package/dist/runner-II7BPB63.js +201 -0
  53. package/dist/runner-II7BPB63.js.map +1 -0
  54. package/dist/{scenarios-25UAZY6F.js → scenarios-I7YYVTD2.js} +11 -6
  55. package/dist/{scenarios-25UAZY6F.js.map → scenarios-I7YYVTD2.js.map} +1 -1
  56. package/dist/{source-4DOO224X.js → source-5LS2B7TN.js} +38 -22
  57. package/dist/source-5LS2B7TN.js.map +1 -0
  58. package/dist/{unified-2PM442OY.js → unified-SKXQQX3Y.js} +25 -74
  59. package/dist/unified-SKXQQX3Y.js.map +1 -0
  60. package/dist/{update-baselines-MDTCFO2U.js → update-baselines-UCAW3SDN.js} +2 -2
  61. package/dist/{visual-ZSQPDE7A.js → visual-EUZG2STF.js} +8 -4
  62. package/dist/visual-EUZG2STF.js.map +1 -0
  63. package/dist/{workflow-template-3KFPCVIC.js → workflow-template-6DADGPHA.js} +5 -3
  64. package/dist/workflow-template-6DADGPHA.js.map +1 -0
  65. package/package.json +21 -8
  66. package/skills/sniff/SKILL.md +47 -0
  67. package/skills/sniff-fix/SKILL.md +44 -0
  68. package/skills/sniff-report/SKILL.md +40 -0
  69. package/smithery.yaml +10 -0
  70. package/dist/accessibility-UNJB57T6.js.map +0 -1
  71. package/dist/anthropic-api-MRDZ7BJA.js.map +0 -1
  72. package/dist/chunk-623BAIU2.js.map +0 -1
  73. package/dist/chunk-CBDOJUXB.js.map +0 -1
  74. package/dist/classifier-XEA6ZGE7.js +0 -673
  75. package/dist/classifier-XEA6ZGE7.js.map +0 -1
  76. package/dist/claude-code-F722EIIC.js.map +0 -1
  77. package/dist/dev-server-detector-NJ5RN4IC.js +0 -150
  78. package/dist/dev-server-detector-NJ5RN4IC.js.map +0 -1
  79. package/dist/discover-BLUSO42Q.js.map +0 -1
  80. package/dist/generator-OZY3HMJW.js +0 -7
  81. package/dist/init-75MMIW4A.js +0 -66
  82. package/dist/init-75MMIW4A.js.map +0 -1
  83. package/dist/loader-QII5CZSX.js.map +0 -1
  84. package/dist/performance-FBUGBRB3.js.map +0 -1
  85. package/dist/provider-7IHXYR6V.js +0 -13
  86. package/dist/provider-7IHXYR6V.js.map +0 -1
  87. package/dist/registry-NB5CZB6W.js.map +0 -1
  88. package/dist/runner-MS2SNTMR.js +0 -153
  89. package/dist/runner-MS2SNTMR.js.map +0 -1
  90. package/dist/runner-OYTN2NFD.js.map +0 -1
  91. package/dist/runner-Z4I2YVVM.js.map +0 -1
  92. package/dist/source-4DOO224X.js.map +0 -1
  93. package/dist/unified-2PM442OY.js.map +0 -1
  94. package/dist/visual-ZSQPDE7A.js.map +0 -1
  95. package/dist/workflow-template-3KFPCVIC.js.map +0 -1
  96. /package/dist/{generator-OZY3HMJW.js.map → generator-HIFV67NI.js.map} +0 -0
  97. /package/dist/{model-2DTSAX7T.js.map → model-X5J2JR5U.js.map} +0 -0
  98. /package/dist/{page-hooks-DOZWXF7Z.js.map → page-hooks-6RALVZB5.js.map} +0 -0
  99. /package/dist/{report-STC6CAVJ.js.map → report-OAHSB56I.js.map} +0 -0
  100. /package/dist/{update-baselines-MDTCFO2U.js.map → update-baselines-UCAW3SDN.js.map} +0 -0
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "sniff",
3
+ "version": "0.5.1",
4
+ "description": "Local QA automation via sniff-qa: source scans, browser audits, discovery, and reports with no API key required by default",
5
+ "author": {
6
+ "name": "Adam Boudj",
7
+ "url": "https://github.com/Aboudjem/sniff"
8
+ },
9
+ "homepage": "https://github.com/Aboudjem/sniff",
10
+ "repository": "https://github.com/Aboudjem/sniff",
11
+ "license": "Apache-2.0",
12
+ "keywords": ["testing", "qa", "playwright", "accessibility", "mcp", "sniff-qa"]
13
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,89 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.5.1] - 2026-05-06
11
+
12
+ ### Added
13
+
14
+ - Agent-agnostic AI provider selection with deterministic `ai.provider: "none"` as the default and optional `codex-cli`, `claude-code`, `anthropic-api`, `openai-api`, `gemini-cli`, and `ollama` providers.
15
+ - Multi-browser config via `browser.projects` with Chromium as the default and Firefox/WebKit opt-in.
16
+ - `sniff_install` MCP support for requested Playwright browser projects.
17
+ - Test typechecking through `tsconfig.test.json`.
18
+
19
+ ### Changed
20
+
21
+ - Browser runtime console/network hook findings now flow into normal results, reports, persistence, MCP responses, and exit codes.
22
+ - MCP `sniff({ mode: "run" })` now uses the shared source + browser path instead of a browser-only root route.
23
+ - Browser audits use the current repo analysis routes before falling back to `/`, avoiding stale `.sniff/last-results.json` route reuse.
24
+ - Scanner crashes now produce high-severity `scanner-error/*` findings instead of silent metadata-only errors.
25
+ - Dead-link scanning now ignores code files by default and requires `deadLinks.scanCode: true` for JSX/TSX/JS/TS extraction.
26
+ - `--explore` is now opt-in so default CLI scans remain deterministic and local.
27
+ - README assets now use absolute GitHub URLs so npm rendering works.
28
+
29
+ ### Fixed
30
+
31
+ - `BrowserRunner` now receives the target `rootDir`, so reports and visual baselines are written for the scanned project instead of the caller process.
32
+ - Accessibility, visual, performance, and e2e scanners now honor `config.scanners` and their enabled flags consistently.
33
+ - CI workflow generation now uploads `.sniff/reports/` and uses `npx sniff-qa --ci --format html,json,junit`.
34
+
35
+ ## [0.4.0] - 2026-04-17
36
+
37
+ ### Added
38
+
39
+ - **Autonomous E2E discovery** (`sniff discover`): scans source (Prisma, Drizzle, TypeORM, Zod, GraphQL, OpenAPI, TS types), classifies the app into one of 10 types, generates happy-path journeys with personas, enumerates edge variants (invalid email, XSS, payment declined, empty cart, offline, slow network, and more), drives them through Playwright, and writes HTML/JSON/JUnit reports
40
+ - **Scenario persistence** at `sniff-scenarios/_generated/<app-type>/<journey>.<variant>.scenario.md` with JSON frontmatter, hash-tracked to protect hand-edits; `custom/` directory for user-authored scenarios
41
+ - **Regenerate semantics**: `--regenerate`, `--regenerate-only`, `--force-regenerate` flags; non-interactive runs default to keeping hand-edits
42
+ - **Realism profiles** (`robot`, `careful-user`, `casual-user`, `frustrated-user`, `power-user`) with seeded RNG and `--seed <n>` for replay
43
+ - **Real-world variant caps** (3 per scenario, 40 per run, both configurable) surface the most informative edge variants first
44
+ - **Production-URL safety banner**: 5-second non-blocking countdown before running against a non-localhost URL
45
+ - **Flakiness quarantine** for discovery scenarios using the existing quarantine engine
46
+ - **LLM polish via Claude Code CLI**: optional tie-break for close-call app-type classifications, cached under `.sniff/discover/cache/`; falls back to deterministic classification if the CLI is unavailable or `--no-llm` is set
47
+ - **`sniff_discover` MCP tool**: returns compact summary (top app type, stats, failures) so AI editors can drive discovery
48
+ - **Doctor awareness** of `sniff-scenarios/` baselines
49
+
50
+ ### Changed
51
+
52
+ - `sniff doctor` now also reports on discovery baselines
53
+
54
+ ## [0.2.0] - 2026-04-16
55
+
56
+ ### Added
57
+
58
+ - **Dead link checker** validates internal file references, external URLs (HTTP HEAD with retry/timeout), and anchor links across .md, .html, .jsx, .tsx, .vue, .svelte, and .astro files
59
+ - **API endpoint discovery** auto-detects routes from Express, Fastify, Hono, Next.js (App + Pages Router), SvelteKit, tRPC, and GraphQL schema definitions
60
+ - **API endpoint issue detection** flags missing error handling, input validation, auth middleware, and hardcoded secrets in route handlers
61
+ - **Cross-reference engine** correlates source code findings with browser runtime evidence (5 strategies: broken imports to 404s, console.log to runtime output, hardcoded URLs to network requests, a11y issues to axe violations, placeholders to visible text)
62
+ - **Corroborated findings** with bumped severity and confidence tags when issues are confirmed in both source and browser layers
63
+ - **Pipeline SVG diagrams** (light/dark) showing the full 8-check pipeline
64
+ - **Architecture SVG diagrams** (light/dark) showing all system components
65
+ - **Report example SVG** (light/dark) showing styled terminal output
66
+ - **Dead link config** section in `sniff.config.ts` (checkExternal, timeout, retries, ignorePatterns, maxConcurrent)
67
+ - **API endpoints config** section in `sniff.config.ts` (checkErrorHandling, checkValidation, checkAuth, checkSecrets, frameworks filter)
68
+
69
+ ### Changed
70
+
71
+ - README updated to document all 8 checks with detailed examples, source rule reference table, cross-reference examples, and expanded config reference
72
+ - "Five checks" updated to "Eight checks" across all documentation
73
+ - Comparison table expanded with dead link checking, API endpoint discovery, and cross-reference engine rows
74
+
75
+ ## [0.1.0] - 2026-04-16
76
+
77
+ ### Added
78
+
79
+ - **Source scanner** with AST and regex rules for debugger statements, placeholder text, hardcoded URLs, broken imports, TODO/FIXME tags
80
+ - **Accessibility scanner** powered by axe-core for WCAG 2.x violations with fix guidance
81
+ - **Visual regression scanner** using pixelmatch for pixel level diffing with baseline tracking
82
+ - **Performance scanner** using Lighthouse for LCP, FCP, TTI budget enforcement
83
+ - **AI explorer** that roams your app, fills forms with adversarial inputs (XSS, SQL injection, Unicode), and reports crashes
84
+ - **Three modes**: quick scan (source only), full audit (all 5 checks), CI mode (deterministic)
85
+ - **MCP server** for native AI editor integration (Claude Code, Cursor, Windsurf, VS Code + Cline)
86
+ - **Flakiness quarantine** for stable CI pipelines
87
+ - **HTML, JSON, and JUnit report** generation
88
+ - **Zero config** operation with framework auto detection
89
+ - **CLI** with `npx sniff-qa` entry point
package/NOTICE ADDED
@@ -0,0 +1,14 @@
1
+ Sniff
2
+ Copyright 2025 Adam Boudj <adam@integralayer.com>
3
+
4
+ This product includes software developed by Adam Boudj.
5
+
6
+ If you use Sniff in your project, a mention or attribution is appreciated:
7
+ - In your README, docs, or project credits
8
+ - "QA powered by Sniff (https://github.com/adamboudj/sniff)"
9
+
10
+ Third-party licenses:
11
+ - Playwright (Apache-2.0) - https://playwright.dev
12
+ - axe-core (MPL-2.0) - https://www.deque.com/axe/
13
+ - Lighthouse (Apache-2.0) - https://developer.chrome.com/docs/lighthouse
14
+ - pixelmatch (ISC) - https://github.com/mapbox/pixelmatch
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <picture>
2
- <source media="(prefers-color-scheme: dark)" srcset=".github/assets/logo-dark.svg">
3
- <source media="(prefers-color-scheme: light)" srcset=".github/assets/logo-light.svg">
4
- <img alt="Sniff" src=".github/assets/logo-light.svg" width="100%">
2
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/logo-dark.svg">
3
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/logo-light.svg">
4
+ <img alt="Sniff" src="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/logo-light.svg" width="100%">
5
5
  </picture>
6
6
 
7
7
  <p align="center">
@@ -12,7 +12,43 @@
12
12
  <a href="https://github.com/Aboudjem/sniff/stargazers"><img src="https://img.shields.io/github/stars/Aboudjem/sniff?style=flat-square&color=ef4444" alt="Stars"></a>
13
13
  </p>
14
14
 
15
- <p align="center">Scan your source code, your live site, or both. Finds bugs before your users do.</p>
15
+ <p align="center"><b>Scan your source code, your live site, or both. Finds bugs before your users do.</b></p>
16
+
17
+ <p align="center">
18
+ <a href="#get-started">Get started</a> ·
19
+ <a href="#what-it-finds">What it finds</a> ·
20
+ <a href="#commands">Commands</a> ·
21
+ <a href="#works-with-any-stack">Stacks</a> ·
22
+ <a href="docs/VIDEO-PLAN.md">Demo videos</a>
23
+ </p>
24
+
25
+ <picture>
26
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/sniff-diagram.svg">
27
+ <img alt="Sniff flow: source -> radar scanner -> findings" src="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/sniff-diagram.svg" width="100%">
28
+ </picture>
29
+
30
+ ---
31
+
32
+ ## The 30-second pitch
33
+
34
+ > You ship a feature. A user finds the bug before you do. Sniff is the opposite of that.
35
+
36
+ Sniff is a tiny CLI that reads your source, opens your app in a headless browser, and hunts down bugs across **eight dimensions** — functional, visual, accessibility, performance, dead links, API endpoints, broken imports, and optional AI-assisted exploration. No API key required. No manual Playwright setup. No config.
37
+
38
+ ```bash
39
+ npx sniff-qa
40
+ ```
41
+
42
+ That's the whole setup. The rest of this README is detail.
43
+
44
+ ### Why developers love it
45
+
46
+ - **One command.** `npx sniff-qa` auto-detects your framework, your dev server, your test scenarios. If `npm run dev` is running, sniff finds it.
47
+ - **Zero API keys by default.** Deterministic local QA is the default. Codex, Claude, Gemini, Ollama, Anthropic, and OpenAI providers are optional enhancements.
48
+ - **Eight checks, every time.** Accessibility + visual regression + performance + dead links + API contracts + source scanning + broken imports + browser runtime hooks — out of the box.
49
+ - **Talks to your editor.** Ships as an MCP server. Just say *"scan this project"* in Claude / Cursor / Copilot / Continue / Windsurf / Codex / Gemini.
50
+ - **CI-ready.** `sniff --ci` emits JUnit, tracks flakes, and fails on severity thresholds you set. `sniff ci` generates the GitHub Actions workflow.
51
+ - **Actually explains the fix.** Every finding cites the rule, the file, the line — and `/sniff-fix` generates the patch.
16
52
 
17
53
  ---
18
54
 
@@ -34,14 +70,25 @@ npx sniff-qa --url http://localhost:3000 # specific local URL
34
70
  npx sniff-qa --url https://myapp.com # production URL
35
71
  ```
36
72
 
37
- > **No API keys. No Playwright install. No config files.** Everything works out of the box. Browser checks auto-install Chromium on first run.
73
+ > **No API keys. No manual Playwright install. No config files.** Everything works out of the box. Browser checks auto-install the configured Playwright browser projects on first CLI run.
38
74
 
39
75
  ### Use from your AI editor
40
76
 
41
77
  Sniff ships as an MCP server. Add it to your editor, then ask your AI to scan.
42
78
 
43
79
  <details>
44
- <summary><b>Claude Code</b></summary>
80
+ <summary><b>Claude Code plugin marketplace</b> (one-command install)</summary>
81
+
82
+ ```bash
83
+ claude plugin marketplace add Aboudjem/10x
84
+ claude plugin install sniff@10x
85
+ ```
86
+
87
+ This installs sniff as a Claude Code plugin from the [10x marketplace](https://github.com/Aboudjem/10x). Skills, commands, and the MCP server are wired up automatically.
88
+ </details>
89
+
90
+ <details>
91
+ <summary><b>Claude Code (MCP server only)</b></summary>
45
92
 
46
93
  ```bash
47
94
  claude mcp add sniff-qa npx sniff-qa --mcp
@@ -110,9 +157,9 @@ clawhub install sniff-qa
110
157
  ```
111
158
  </details>
112
159
 
113
- Then ask: *"Scan this project for issues"* or *"Check accessibility on localhost:3000"*
160
+ Then ask: *"Scan this project for issues"* or *"Check accessibility on localhost:3000"* or *"Discover and run E2E tests"*
114
161
 
115
- **MCP tools:** `sniff_scan` (source) · `sniff_run` (browser) · `sniff_report` (results)
162
+ **MCP tools:** `sniff({ mode: "scan" | "run" | "discover" | "report" })` — unified entry point. Plus `sniff_install` when Playwright browser binaries are missing. MCP returns a structured `needsSetup` payload instead of doing a long install inside stdio; call `sniff_install` or run the shown `npx playwright install ...` command, then retry. The legacy per-mode tools (`sniff_scan`, `sniff_run`, `sniff_discover`, `sniff_report`) remain available but are deprecated in v0.5 and will be removed in v0.7.
116
163
 
117
164
  ### Install as a dev dependency
118
165
 
@@ -130,7 +177,7 @@ npm install -D sniff-qa
130
177
 
131
178
  That's all you need. Sniff auto-detects your dev server when it's running.
132
179
 
133
- Requires Node.js 22+. Playwright installs automatically on first browser scan.
180
+ Requires Node.js 22+. Playwright installs automatically on first CLI browser scan; MCP asks you to run `sniff_install` when setup is missing.
134
181
 
135
182
  ---
136
183
 
@@ -141,18 +188,22 @@ npx sniff-qa # scan source + auto-detect
141
188
  npx sniff-qa --url https://myapp.com # scan source + specific URL
142
189
  npx sniff-qa ./path/to/project # scan a specific directory
143
190
  npx sniff-qa --ci # CI mode (JUnit output, no AI explorer)
191
+ npx sniff-qa --url http://localhost:3000 --explore # opt-in AI exploration
192
+ npx sniff-qa --verbose # show classifier top 3 + matched signals
193
+ npx sniff-qa discover --dry-run # preview generated scenarios, no browser
194
+ npx sniff-qa discover --force-app-type saas # skip classification, treat as SaaS
144
195
  ```
145
196
 
146
- Sniff auto-detects your dev server by reading `package.json` scripts and probing common ports (3000, 5173, 8080, 4200). If it finds a running server, browser checks run automatically.
197
+ Sniff auto-detects your dev server by reading `package.json` scripts plus `vite.config`, `nuxt.config`, `astro.config`, and `angular.json`, then probing the framework's default port *and* the next 20 after it (to catch auto-increment when the default is taken). If a port responds with framework markers (Next.js, Vite, Nuxt, Astro, Remix, SvelteKit, Angular), browser checks run automatically. Ghost-process ports like macOS AirPlay on `:5000` no longer collide.
147
198
 
148
199
  ---
149
200
 
150
201
  ## What it finds
151
202
 
152
203
  <picture>
153
- <source media="(prefers-color-scheme: dark)" srcset=".github/assets/features-dark.svg">
154
- <source media="(prefers-color-scheme: light)" srcset=".github/assets/features-light.svg">
155
- <img alt="Sniff checks: source bugs, dead links, API endpoints, broken imports, accessibility, visual regression, performance, AI explorer" src=".github/assets/features-light.svg" width="100%">
204
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/features-dark.svg">
205
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/features-light.svg">
206
+ <img alt="Sniff checks: source bugs, dead links, API endpoints, broken imports, accessibility, visual regression, performance, optional AI explorer" src="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/features-light.svg" width="100%">
156
207
  </picture>
157
208
 
158
209
  **Source checks** run on every scan. **Browser checks** run automatically when sniff detects a running dev server, or when you pass `--url`.
@@ -162,9 +213,9 @@ Sniff auto-detects your dev server by reading `package.json` scripts and probing
162
213
  ## Example output
163
214
 
164
215
  <picture>
165
- <source media="(prefers-color-scheme: dark)" srcset=".github/assets/report-dark.svg">
166
- <source media="(prefers-color-scheme: light)" srcset=".github/assets/report-light.svg">
167
- <img alt="Sniff terminal output" src=".github/assets/report-light.svg" width="100%">
216
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/report-dark.svg">
217
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/report-light.svg">
218
+ <img alt="Sniff terminal output" src="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/report-light.svg" width="100%">
168
219
  </picture>
169
220
 
170
221
  ---
@@ -206,14 +257,20 @@ sniff --version Show version
206
257
  |:-----|:-------------|
207
258
  | `--url <url>` | Enable browser checks (accessibility, visual, performance, AI) |
208
259
  | `--ci` | CI mode: skip AI explorer, add JUnit output, track flaky tests |
209
- | `--no-explore` | Browser checks without AI explorer |
260
+ | `--explore` | Opt into AI-assisted exploration after browser checks |
261
+ | `--no-explore` | Compatibility flag; exploration is off by default |
210
262
  | `--no-browser` | Source only even if `--url` is set |
211
263
  | `--max-steps <n>` | Limit AI explorer steps (default: 50) |
212
264
  | `--no-headless` | Show the browser window |
265
+ | `--headed` | Alias for `--no-headless` |
213
266
  | `--format html,json,junit` | Choose report formats |
214
267
  | `--fail-on critical,high` | Severities that cause non-zero exit |
215
268
  | `--track-flakes` | Track test flakiness across runs |
216
269
  | `--json` | JSON output for scripts |
270
+ | `--verbose` | Print classifier top-3 guesses and matched signals per dimension |
271
+ | `--dry-run` | Discover: generate scenarios without launching browser or writing reports |
272
+ | `--force-app-type <type>` | Discover: bypass the classifier (e.g. `saas`, `ecommerce`, `booking`) |
273
+ | `--app-type <types>` | Discover: filter classifier guesses to these app types (comma-separated) |
217
274
 
218
275
  </details>
219
276
 
@@ -244,7 +301,9 @@ API discovery also supports **Fastify**, **Hono**, **tRPC**, and **GraphQL**.
244
301
  Sniff works with zero config. Only create a config file if you want to customize.
245
302
 
246
303
  ```bash
247
- npx sniff-qa init
304
+ npx sniff-qa init # auto-detects: .ts if TypeScript, .mjs if ESM, .js otherwise
305
+ npx sniff-qa init --ts # force TypeScript config
306
+ npx sniff-qa init --js # force JavaScript config (respects package.json "type")
248
307
  ```
249
308
 
250
309
  <details>
@@ -255,7 +314,10 @@ import { defineConfig } from 'sniff-qa';
255
314
 
256
315
  export default defineConfig({
257
316
  // Save your URL so you can just run `sniff`
258
- browser: { baseUrl: 'http://localhost:3000' },
317
+ browser: {
318
+ baseUrl: 'http://localhost:3000',
319
+ projects: ['chromium'], // also supports 'firefox' and 'webkit'
320
+ },
259
321
 
260
322
  // Viewports to test
261
323
  viewports: [
@@ -263,17 +325,26 @@ export default defineConfig({
263
325
  { name: 'desktop', width: 1280, height: 720 },
264
326
  ],
265
327
 
266
- // Performance budgets (ms)
267
- performance: { budgets: { lcp: 2500, fcp: 1800, tti: 3800 } },
268
-
269
- // Visual regression threshold (0-1)
270
- visual: { threshold: 0.1 },
328
+ // Toggle scanner groups
329
+ scanners: ['source', 'repo-analyzer', 'e2e', 'accessibility', 'visual', 'performance'],
330
+ accessibility: { enabled: true, standard: 'wcag21aa' },
331
+ visual: { enabled: true, threshold: 0.1 },
332
+ performance: { enabled: true, budgets: { lcp: 2500, fcp: 1800, tti: 3800 } },
333
+
334
+ // Optional AI providers. Default is deterministic local QA with provider: 'none'.
335
+ ai: {
336
+ provider: 'none', // codex-cli, claude-code, anthropic-api, openai-api, gemini-cli, ollama
337
+ model: undefined,
338
+ command: undefined,
339
+ baseUrl: undefined,
340
+ },
271
341
 
272
- // AI explorer
273
- exploration: { maxSteps: 50 },
342
+ // Optional AI explorer, run only with --explore
343
+ exploration: { enabled: true, maxSteps: 50 },
274
344
 
275
345
  // Dead link checker
276
346
  deadLinks: {
347
+ scanCode: false, // docs/HTML by default; opt into JSX/TSX/JS/TS to reduce noise
277
348
  checkExternal: true,
278
349
  timeout: 5000,
279
350
  retries: 2,
@@ -297,6 +368,8 @@ export default defineConfig({
297
368
  });
298
369
  ```
299
370
 
371
+ Provider selection can also come from environment: `SNIFF_AI_PROVIDER`, `SNIFF_AI_MODEL`, `SNIFF_AI_COMMAND`, and `SNIFF_AI_BASE_URL`. API-backed providers use their normal keys: `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`. If the selected provider is missing, Sniff skips AI generation and keeps the deterministic QA run moving.
372
+
300
373
  </details>
301
374
 
302
375
  <details>
@@ -329,11 +402,19 @@ Set any to `'off'` to disable.
329
402
 
330
403
  ## CI integration
331
404
 
405
+ Run Sniff directly in CI:
406
+
407
+ ```bash
408
+ npx sniff-qa --ci --format html,json,junit
409
+ ```
410
+
411
+ Generate a GitHub Actions workflow:
412
+
332
413
  ```bash
333
414
  npx sniff-qa ci
334
415
  ```
335
416
 
336
- Generates `.github/workflows/sniff.yml` with Playwright caching, JUnit output, and report artifacts.
417
+ This writes `.github/workflows/sniff.yml` with Playwright caching, JUnit output, and report artifacts.
337
418
 
338
419
  **Flakiness quarantine:** Tests that fail 3 of 5 runs get quarantined. They still run, still report, but won't block your pipeline.
339
420
 
@@ -346,7 +427,11 @@ sniff discover # run against the detected dev server
346
427
  sniff discover --regenerate-only # write sniff-scenarios/ and exit (no run)
347
428
  ```
348
429
 
349
- `sniff discover` reads your source (Prisma, Drizzle, TypeORM, Zod, GraphQL, OpenAPI, TS types), classifies what the app is (ecommerce, booking, saas, social, content, crm, auth-only, marketing, admin), generates happy-path journeys with real personas, enumerates edge variants (invalid email, XSS, payment declined, empty cart, offline, and more), and drives everything through Playwright.
430
+ `sniff discover` reads your source (Prisma, Drizzle, TypeORM, Zod, GraphQL, OpenAPI, TS types), classifies what the app is (ecommerce, booking, saas, social, content, crm, auth-only, marketing, admin) with route tokens in **English, French, Spanish, German, Portuguese, and Italian** (a French SaaS on `/fr/tableau-de-bord` classifies correctly), generates happy-path journeys with real personas, enumerates edge variants (invalid email, XSS, payment declined, empty cart, offline, and more), and drives everything through Playwright.
431
+
432
+ Pass `--verbose` to see the top-3 candidates and every matched signal — useful for understanding *why* a classification happened. Pass `--force-app-type <type>` to skip classification entirely. Pass `--dry-run` to preview scenarios without launching a browser or writing reports.
433
+
434
+ **Multilingual projects supported.** The classifier matches French, Spanish, German, Portuguese (BR/PT), and Italian equivalents for every signature token, so a French SaaS on `/fr/tableau-de-bord` classifies the same as an English one on `/dashboard`.
350
435
 
351
436
  **What you get:**
352
437
 
@@ -365,34 +450,38 @@ sniff discover --regenerate-only # write sniff-scenarios/ and exit (no run)
365
450
  | `--realism <profile>` | `robot`, `careful-user`, `casual-user` (default), `frustrated-user`, `power-user` |
366
451
  | `--seed <n>` | Replay a specific random seed |
367
452
  | `--only <filter>` | Filter scenarios by id substring or app type |
368
- | `--app-type <types>` | Force app types (comma-separated) |
453
+ | `--app-type <types>` | Filter classifier guesses to these app types (comma-separated, kept for back-compat) |
454
+ | `--force-app-type <type>` | Bypass the classifier entirely — treat the app as this type |
455
+ | `--verbose` | Print classifier breakdown (top 3 guesses + matched signals per dimension) |
456
+ | `--dry-run` | Generate scenarios without launching the browser or writing reports |
369
457
  | `--regenerate` | Regenerate `sniff-scenarios/` before running |
370
458
  | `--regenerate-only` | Regenerate and exit (no browser) |
371
459
  | `--force-regenerate` | Overwrite hand-edits without prompting |
372
460
  | `--non-interactive` | Skip prompts and the production-URL countdown |
461
+ | `--verbose` | Print classification breakdown (top 3 guesses + matched signals per dimension) |
373
462
  | `--no-llm` | Skip Claude Code CLI polish (deterministic only) |
374
463
 
375
464
  **Production-URL safety:** when the target is not a local address, sniff prints a 5-second countdown banner before running. Hit Ctrl+C to cancel. No `--allow-destructive` flag.
376
465
 
377
- **LLM polish (optional):** if the `claude` CLI is available, sniff uses it to break close-call app-type classifications. Responses are cached under `.sniff/discover/cache/`. Pass `--no-llm` to skip.
466
+ **LLM polish (optional):** discovery can use the `claude` CLI to break close-call app-type classifications. Responses are cached under `.sniff/discover/cache/`. Pass `--no-llm` to skip.
378
467
 
379
468
  ---
380
469
 
381
470
  ## How it works
382
471
 
383
472
  <picture>
384
- <source media="(prefers-color-scheme: dark)" srcset=".github/assets/pipeline-dark.svg">
385
- <source media="(prefers-color-scheme: light)" srcset=".github/assets/pipeline-light.svg">
386
- <img alt="Sniff pipeline" src=".github/assets/pipeline-light.svg" width="100%">
473
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/pipeline-dark.svg">
474
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/pipeline-light.svg">
475
+ <img alt="Sniff pipeline" src="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/pipeline-light.svg" width="100%">
387
476
  </picture>
388
477
 
389
478
  <details>
390
479
  <summary><b>Architecture</b></summary>
391
480
 
392
481
  <picture>
393
- <source media="(prefers-color-scheme: dark)" srcset=".github/assets/architecture-dark.svg">
394
- <source media="(prefers-color-scheme: light)" srcset=".github/assets/architecture-light.svg">
395
- <img alt="Sniff architecture" src=".github/assets/architecture-light.svg" width="100%">
482
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/architecture-dark.svg">
483
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/architecture-light.svg">
484
+ <img alt="Sniff architecture" src="https://raw.githubusercontent.com/Aboudjem/sniff/main/.github/assets/architecture-light.svg" width="100%">
396
485
  </picture>
397
486
 
398
487
  </details>
@@ -401,10 +490,10 @@ sniff discover --regenerate-only # write sniff-scenarios/ and exit (no run)
401
490
 
402
491
  ## Privacy
403
492
 
404
- No telemetry. No signup. No data collection. No API keys. Your code stays on your machine.
493
+ No telemetry. No signup. No data collection. No API keys required. Your code stays on your machine unless you explicitly configure an API-backed AI provider.
405
494
 
406
495
  > [!NOTE]
407
- > All 8 checks work without any API key. The AI explorer uses Claude Code as the AI provider when run through MCP, so no separate Anthropic key is needed. Dead link checking validates external URLs but never sends your code.
496
+ > All deterministic checks work without any API key. Optional AI providers are off by default and must be selected through config or environment. Dead link checking validates external URLs but never sends your code.
408
497
 
409
498
  ---
410
499
 
package/SECURITY.md ADDED
@@ -0,0 +1,33 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ If you discover a security vulnerability in Sniff, please report it responsibly.
6
+
7
+ **Do NOT open a public GitHub issue for security vulnerabilities.**
8
+
9
+ Instead, email **adam@integralayer.com** with:
10
+
11
+ 1. Description of the vulnerability
12
+ 2. Steps to reproduce
13
+ 3. Potential impact
14
+ 4. Suggested fix (if any)
15
+
16
+ You will receive a response within 48 hours. We will work with you to understand
17
+ and address the issue before any public disclosure.
18
+
19
+ ## Scope
20
+
21
+ Sniff runs locally on your machine. Security concerns include:
22
+
23
+ - **Path traversal** in CLI arguments or config
24
+ - **Code injection** via malformed config files
25
+ - **Unsafe browser operations** in the exploration module
26
+ - **Dependency vulnerabilities** in the supply chain
27
+
28
+ ## Supported Versions
29
+
30
+ | Version | Supported |
31
+ |---------|-----------|
32
+ | 0.5.x | Yes |
33
+ | <0.5 | No |
@@ -34,6 +34,14 @@ var AccessibilityScanner = class {
34
34
  name = "accessibility";
35
35
  async scan(ctx) {
36
36
  const start = performance.now();
37
+ if (ctx.config.accessibility?.enabled === false) {
38
+ return {
39
+ scanner: this.name,
40
+ findings: [],
41
+ duration: performance.now() - start,
42
+ metadata: { skipped: true }
43
+ };
44
+ }
37
45
  const { AxeBuilder } = await import("@axe-core/playwright");
38
46
  const a11yConfig = ctx.config.accessibility;
39
47
  const standard = a11yConfig?.standard ?? "wcag21aa";
@@ -76,6 +84,7 @@ var AccessibilityScanner = class {
76
84
  snippet: node.html,
77
85
  url: ctx.page.url(),
78
86
  viewport: ctx.viewport.name,
87
+ browser: ctx.browser,
79
88
  fixSuggestion: buildFixSuggestion(violation, node)
80
89
  });
81
90
  }
@@ -90,4 +99,4 @@ var AccessibilityScanner = class {
90
99
  export {
91
100
  AccessibilityScanner
92
101
  };
93
- //# sourceMappingURL=accessibility-UNJB57T6.js.map
102
+ //# sourceMappingURL=accessibility-JXRMWF5Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/scanners/accessibility/index.ts"],"sourcesContent":["import { performance } from 'node:perf_hooks';\n\nimport type { BrowserScanner, BrowserScanContext, ScanResult } from '../types.js';\nimport type { BrowserFinding } from '../../core/types.js';\nimport type { Severity } from '../../core/types.js';\n\nfunction mapAxeImpact(impact: string | null | undefined): Severity {\n switch (impact) {\n case 'critical': return 'critical';\n case 'serious': return 'high';\n case 'moderate': return 'medium';\n case 'minor': return 'low';\n default: return 'medium';\n }\n}\n\nfunction buildFixSuggestion(\n violation: { id: string; helpUrl: string },\n node: { failureSummary?: string; any?: Array<{ id: string; data?: Record<string, unknown> }> },\n): string {\n if (violation.id === 'color-contrast') {\n const contrastData = node.any?.find((check) => check.id === 'color-contrast');\n if (contrastData?.data) {\n const expected = contrastData.data['expected'] as string | undefined;\n const actual = contrastData.data['contrastRatio'] as number | undefined;\n if (expected && actual !== undefined) {\n return `Expected contrast ratio of at least ${expected}:1, but found ${actual}:1. Increase the color difference between foreground and background.`;\n }\n }\n }\n\n if (node.failureSummary) {\n return node.failureSummary;\n }\n\n return `See ${violation.helpUrl} for remediation guidance.`;\n}\n\nexport class AccessibilityScanner implements BrowserScanner {\n name = 'accessibility';\n\n async scan(ctx: BrowserScanContext): Promise<ScanResult> {\n const start = performance.now();\n\n if (ctx.config.accessibility?.enabled === false) {\n return {\n scanner: this.name,\n findings: [],\n duration: performance.now() - start,\n metadata: { skipped: true },\n };\n }\n\n const { AxeBuilder } = await import('@axe-core/playwright');\n\n const a11yConfig = ctx.config.accessibility;\n\n const standard = a11yConfig?.standard ?? 'wcag21aa';\n let tags: string[];\n switch (standard) {\n case 'wcag2a':\n tags = ['wcag2a'];\n break;\n case 'wcag2aa':\n tags = ['wcag2a', 'wcag2aa'];\n break;\n case 'wcag21aa':\n default:\n tags = ['wcag2a', 'wcag2aa', 'wcag21aa'];\n break;\n }\n\n let builder = new AxeBuilder({ page: ctx.page }).withTags(tags);\n\n // Apply custom rule overrides\n if (a11yConfig?.rules) {\n for (const [ruleId, enabled] of Object.entries(a11yConfig.rules)) {\n if (enabled === false) {\n builder = builder.disableRules([ruleId]);\n }\n }\n }\n\n // Enable touch target-size rule on mobile viewports (A11Y-02)\n if (ctx.viewport.name === 'mobile') {\n builder = builder.withRules(['target-size']);\n }\n\n const results = await builder.analyze();\n\n const findings: BrowserFinding[] = [];\n for (const violation of results.violations) {\n const severity = mapAxeImpact(violation.impact);\n for (const node of violation.nodes) {\n findings.push({\n ruleId: `a11y/${violation.id}`,\n severity,\n message: `${violation.help}. ${violation.description}`,\n filePath: ctx.page.url(),\n line: 0,\n column: 0,\n snippet: node.html,\n url: ctx.page.url(),\n viewport: ctx.viewport.name,\n browser: ctx.browser,\n fixSuggestion: buildFixSuggestion(violation, node),\n });\n }\n }\n\n return {\n scanner: this.name,\n findings,\n duration: performance.now() - start,\n };\n }\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAM5B,SAAS,aAAa,QAA6C;AACjE,UAAQ,QAAQ;AAAA,IACd,KAAK;AA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AE,MAAM,IAAI,KAAK,CAAC,EAAE,SAAS,IAAI;AAG9D,QAAI,YAAY,OAAO;AACrB,iBAAW,CAAC,QAAQ,OAAO,KAAK,OAAO,QAAQ,WAAW,KAAK,GAAG;AAChE,YAAI,YAAY,OAAO;AACrB,oBAAU,QAAQ,aAAa,CAAC,MAAM,CAAC;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAGA,QAAI,IAAI,SAAS,SAAS,UAAU;AAClC,gBAAU,QAAQ,UAAU,CAAC,aAAa,CAAC;AAAA,IAC7C;AAEA,UAAM,UAAU,MAAM,QAAQ,QAAQ;AAEtC,UAAM,WAA6B,CAAC;AACpC,eAAW,aAAa,QAAQ,YAAY;AAC1C,YAAM,WAAW,aAAa,UAAU,MAAM;AAC9C,iBAAW,QAAQ,UAAU,OAAO;AAClC,iBAAS,KAAK;AAAA,UACZ,QAAQ,QAAQ,UAAU,EAAE;AAAA,UAC5B;AAAA,UACA,SAAS,GAAG,UAAU,IAAI,KAAK,UAAU,WAAW;AAAA,UACpD,UAAU,IAAI,KAAK,IAAI;AAAA,UACvB,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,SAAS,KAAK;AAAA,UACd,KAAK,IAAI,KAAK,IAAI;AAAA,UAClB,UAAU,IAAI,SAAS;AAAA,UACvB,SAAS,IAAI;AAAA,UACb,eAAe,mBAAmB,WAAW,IAAI;AAAA,QACnD,CAAC;AAAA,MACH;AAAA,IACF;AAEA,WAAO;AAAA,MACL,SAAS,KAAK;AAAA,MACd;AAAA,MACA,UAAU,YAAY,IAAI,IAAI;AAAA,IAChC;AAAA,EACF;AACF;","names":[]}
@@ -2,8 +2,10 @@
2
2
  var AnthropicAPIProvider = class {
3
3
  name = "anthropic-api";
4
4
  apiKey;
5
- constructor(apiKey) {
5
+ model;
6
+ constructor(apiKey, model = "claude-sonnet-4-5-20250514") {
6
7
  this.apiKey = apiKey;
8
+ this.model = model;
7
9
  }
8
10
  async generateTests(context) {
9
11
  const { buildSystemPrompt, buildUserPrompt } = await import("./prompt-builder-D3FBH534.js");
@@ -14,7 +16,7 @@ var AnthropicAPIProvider = class {
14
16
  const userPrompt = buildUserPrompt(context);
15
17
  try {
16
18
  const message = await client.messages.create({
17
- model: "claude-sonnet-4-5-20250514",
19
+ model: this.model,
18
20
  max_tokens: 4096,
19
21
  system: systemPrompt,
20
22
  messages: [{ role: "user", content: userPrompt }]
@@ -30,4 +32,4 @@ var AnthropicAPIProvider = class {
30
32
  export {
31
33
  AnthropicAPIProvider
32
34
  };
33
- //# sourceMappingURL=anthropic-api-MRDZ7BJA.js.map
35
+ //# sourceMappingURL=anthropic-api-ZR3UEB3Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ai/anthropic-api.ts"],"sourcesContent":["import type { AIProvider, RouteTestContext, GeneratedTest } from './types.js';\nimport type { TextBlock } from '@anthropic-ai/sdk/resources/messages/messages.js';\n\nexport class AnthropicAPIProvider implements AIProvider {\n name = 'anthropic-api' as const;\n private apiKey: string;\n private model: string;\n\n constructor(apiKey: string, model = 'claude-sonnet-4-5-20250514') {\n this.apiKey = apiKey;\n this.model = model;\n }\n\n async generateTests(context: RouteTestContext): Promise<GeneratedTest> {\n const { buildSystemPrompt, buildUserPrompt } = await import('./prompt-builder.js');\n const { parseGeneratedTest } = await import('./response-parser.js');\n const { default: Anthropic } = await import('@anthropic-ai/sdk');\n\n const client = new Anthropic({ apiKey: this.apiKey });\n const systemPrompt = buildSystemPrompt();\n const userPrompt = buildUserPrompt(context);\n\n try {\n const message = await client.messages.create({\n model: this.model,\n max_tokens: 4096,\n system: systemPrompt,\n messages: [{ role: 'user', content: userPrompt }],\n });\n\n const rawContent = message.content\n .filter((block): block is TextBlock => block.type === 'text')\n .map((block) => block.text)\n .join('\\n');\n\n return parseGeneratedTest(rawContent, context.route.path);\n } catch (err) {\n const { SniffError } = await import('../core/errors.js');\n throw new SniffError('ANTHROPIC_API_ERROR', `Anthropic API failed: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n}\n"],"mappings":";AAGO,IAAM,uBAAN,MAAiD;AAAA,EACtD,OAAO;AAAA,EACC;AAAA,EACA;AAAA,EAER,YAAY,QAAgB,QAAQ,8BAA8B;AAChE,SAAK,SAAS;AACd,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,MAAM,cAAc,SAAmD;AACrE,UAAM,EAAE,mBAAmB,gBAAgB,IAAI,MAAM,OAAO,8BAAqB;AACjF,UAAM,EAAE,mBAAmB,IAAI,MAAM,OAAO,+BAAsB;AAClE,UAAM,EAAE,SAAS,UAAU,IAAI,MAAM,OAAO,mBAAmB;AAE/D,UAAM,SAAS,IAAI,UAAU,EAAE,QAAQ,KAAK,OAAO,CAAC;AACpD,UAAM,eAAe,kBAAkB;AACvC,UAAM,aAAa,gBAAgB,OAAO;AAE1C,QAAI;AACF,YAAM,UAAU,MAAM,OAAO,SAAS,OAAO;AAAA,QAC3C,OAAO,KAAK;AAAA,QACZ,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,UAAU,CAAC,EAAE,MAAM,QAAQ,SAAS,WAAW,CAAC;AAAA,MAClD,CAAC;AAED,YAAM,aAAa,QAAQ,QACxB,OAAO,CAAC,UAA8B,MAAM,SAAS,MAAM,EAC3D,IAAI,CAAC,UAAU,MAAM,IAAI,EACzB,KAAK,IAAI;AAEZ,aAAO,mBAAmB,YAAY,QAAQ,MAAM,IAAI;AAAA,IAC1D,SAAS,KAAK;AACZ,YAAM,EAAE,WAAW,IAAI,MAAM,OAAO,sBAAmB;AACvD,YAAM,IAAI,WAAW,uBAAuB,yBAAyB,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,EAAE;AAAA,IACzH;AAAA,EACF;AACF;","names":[]}
@@ -2,8 +2,15 @@
2
2
  import { mkdir, writeFile, readFile } from "fs/promises";
3
3
  import { join } from "path";
4
4
  async function generateTests(analysis, options) {
5
- const { resolveProvider } = await import("./provider-7IHXYR6V.js");
6
- const provider = await resolveProvider();
5
+ const { resolveProvider } = await import("./provider-BCKFVPTN.js");
6
+ const resolution = await resolveProvider(options.ai);
7
+ const provider = resolution.provider;
8
+ if (!provider) {
9
+ if (resolution.name !== "none") {
10
+ console.warn(`Skipping AI test generation (${resolution.name}): ${resolution.reason ?? "provider unavailable"}`);
11
+ }
12
+ return [];
13
+ }
7
14
  const outputDir = join(options.rootDir, options.outputDir);
8
15
  await mkdir(outputDir, { recursive: true });
9
16
  const results = [];
@@ -70,4 +77,4 @@ function routePathToFileName(routePath) {
70
77
  export {
71
78
  generateTests
72
79
  };
73
- //# sourceMappingURL=chunk-623BAIU2.js.map
80
+ //# sourceMappingURL=chunk-CZKMOAXU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ai/generator.ts"],"sourcesContent":["import { mkdir, writeFile, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { AnalysisResult } from '../analyzers/types.js';\nimport type { AIConfig } from '../config/schema.js';\nimport type { GeneratedTest, RouteTestContext } from './types.js';\n\nexport interface GenerateOptions {\n outputDir: string; // default 'sniff-tests'\n maxConcurrency: number; // default 5\n rootDir: string;\n ai?: AIConfig;\n}\n\nexport async function generateTests(\n analysis: AnalysisResult,\n options: GenerateOptions,\n): Promise<GeneratedTest[]> {\n const { resolveProvider } = await import('./provider.js');\n const resolution = await resolveProvider(options.ai);\n const provider = resolution.provider;\n\n if (!provider) {\n if (resolution.name !== 'none') {\n console.warn(`Skipping AI test generation (${resolution.name}): ${resolution.reason ?? 'provider unavailable'}`);\n }\n return [];\n }\n\n const outputDir = join(options.rootDir, options.outputDir);\n await mkdir(outputDir, { recursive: true });\n\n const results: GeneratedTest[] = [];\n const errors: Array<{ route: string; error: string }> = [];\n\n // Process routes with concurrency limit\n const routes = analysis.routes;\n const totalRoutes = routes.length;\n console.log(`Generating tests for ${totalRoutes} route(s) using ${provider.name}...`);\n\n for (let i = 0; i < routes.length; i += options.maxConcurrency) {\n const batch = routes.slice(i, i + options.maxConcurrency);\n const batchEnd = Math.min(i + options.maxConcurrency, totalRoutes);\n console.log(` Generating tests: ${batchEnd}/${totalRoutes} routes...`);\n\n const batchResults = await Promise.allSettled(\n batch.map(async (route) => {\n // Build context for this route\n const routeElements = analysis.elements.filter(\n (el) => el.filePath === route.filePath,\n );\n const routeComponents = analysis.components.filter(\n (comp) => comp.filePath === route.filePath || comp.routes.includes(route.path),\n );\n const framework = analysis.project.frameworks[0] ?? { name: 'unknown' as const, configFiles: [] };\n\n // Read source content for context\n let sourceContent: string | undefined;\n try {\n sourceContent = await readFile(join(options.rootDir, route.filePath), 'utf-8');\n } catch { /* file might not be readable */ }\n\n const context: RouteTestContext = {\n route,\n elements: routeElements,\n components: routeComponents,\n framework,\n sourceContent,\n };\n\n const result = await provider.generateTests(context);\n\n // Write .spec.ts file\n const fileName = routePathToFileName(route.path);\n await writeFile(join(outputDir, fileName), result.specContent, 'utf-8');\n\n return result;\n }),\n );\n\n for (const [idx, result] of batchResults.entries()) {\n if (result.status === 'fulfilled') {\n results.push(result.value);\n } else {\n errors.push({\n route: batch[idx].path,\n error: result.reason instanceof Error ? result.reason.message : String(result.reason),\n });\n }\n }\n }\n\n if (errors.length > 0) {\n console.warn(`Warning: ${errors.length} route(s) failed AI generation:`);\n for (const err of errors) {\n console.warn(` - ${err.route}: ${err.error}`);\n }\n }\n\n console.log(`Generated ${results.length} test file(s) in ${options.outputDir}/`);\n return results;\n}\n\nfunction routePathToFileName(routePath: string): string {\n if (routePath === '/') return 'home.spec.ts';\n return routePath\n .replace(/^\\//, '')\n .replace(/\\//g, '-')\n .replace(/\\[([^\\]]+)\\]/g, '$1')\n .replace(/[^a-zA-Z0-9-]/g, '')\n + '.spec.ts';\n}\n"],"mappings":";AAAA,SAAS,OAAO,WAAW,gBAAgB;AAC3C,SAAS,YAAY;AAYrB,eAAsB,cACpB,UACA,SAC0B;AAC1B,QAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,wBAAe;AACxD,QAAM,aAAa,MAAM,gBAAgB,QAAQ,EAAE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