sniff-qa 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +41 -0
  2. package/dist/classifier-XEA6ZGE7.js +673 -0
  3. package/dist/classifier-XEA6ZGE7.js.map +1 -0
  4. package/dist/cli/index.js +80 -4
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/discover-BLUSO42Q.js +228 -0
  7. package/dist/discover-BLUSO42Q.js.map +1 -0
  8. package/dist/domain-UQ34YE4B.js +1817 -0
  9. package/dist/domain-UQ34YE4B.js.map +1 -0
  10. package/dist/edge-cases-ZADKDZHL.js +246 -0
  11. package/dist/edge-cases-ZADKDZHL.js.map +1 -0
  12. package/dist/flakiness-OLJAY7CS.js +53 -0
  13. package/dist/flakiness-OLJAY7CS.js.map +1 -0
  14. package/dist/llm-VJAI6H6G.js +126 -0
  15. package/dist/llm-VJAI6H6G.js.map +1 -0
  16. package/dist/mcp/server.js +89 -0
  17. package/dist/mcp/server.js.map +1 -1
  18. package/dist/persistence-KTCRIGHU.js +270 -0
  19. package/dist/persistence-KTCRIGHU.js.map +1 -0
  20. package/dist/{repo-analyzer-WK5WP7NT.js → repo-analyzer-4OURSITY.js} +1 -1
  21. package/dist/report-SDZWX25B.js +280 -0
  22. package/dist/report-SDZWX25B.js.map +1 -0
  23. package/dist/{report-WLDV72FM.js → report-STC6CAVJ.js} +1 -1
  24. package/dist/runner-OYTN2NFD.js +996 -0
  25. package/dist/runner-OYTN2NFD.js.map +1 -0
  26. package/dist/scenarios-25UAZY6F.js +982 -0
  27. package/dist/scenarios-25UAZY6F.js.map +1 -0
  28. package/dist/tiebreak-L5UFNKU2.js +60 -0
  29. package/dist/tiebreak-L5UFNKU2.js.map +1 -0
  30. package/dist/{unified-7RKNG3EI.js → unified-2PM442OY.js} +2 -2
  31. package/package.json +1 -1
  32. /package/dist/{repo-analyzer-WK5WP7NT.js.map → repo-analyzer-4OURSITY.js.map} +0 -0
  33. /package/dist/{report-WLDV72FM.js.map → report-STC6CAVJ.js.map} +0 -0
  34. /package/dist/{unified-7RKNG3EI.js.map → unified-2PM442OY.js.map} +0 -0
package/README.md CHANGED
@@ -186,6 +186,8 @@ sniff Scan source + auto-detect dev server
186
186
  sniff --url <url> Scan source + test specific URL
187
187
  sniff --url <url> --ci Full audit for CI pipelines
188
188
  sniff <path> Scan a specific directory
189
+ sniff discover Autonomous E2E discovery (scenarios + edge cases)
190
+ sniff discover --regenerate-only Write sniff-scenarios/ tree without running
189
191
  sniff fix Auto-fix safe issues (debugger, console.log)
190
192
  sniff fix --check Dry run: show what would be fixed
191
193
  sniff init Create sniff.config.ts
@@ -337,6 +339,45 @@ Generates `.github/workflows/sniff.yml` with Playwright caching, JUnit output, a
337
339
 
338
340
  ---
339
341
 
342
+ ## Autonomous discovery
343
+
344
+ ```bash
345
+ sniff discover # run against the detected dev server
346
+ sniff discover --regenerate-only # write sniff-scenarios/ and exit (no run)
347
+ ```
348
+
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.
350
+
351
+ **What you get:**
352
+
353
+ - `sniff-scenarios/_generated/<app-type>/<journey>.<variant>.scenario.md` — reviewable scenarios with JSON frontmatter. Track them in git. Hand-edit them — sniff detects the change and asks before regenerating.
354
+ - `sniff-reports/discovery/` — HTML, JSON, and JUnit reports per run.
355
+ - Flakiness quarantine for scenarios that fail 3 of the last 5 runs.
356
+
357
+ **Flags:**
358
+
359
+ | Flag | What it does |
360
+ |:-----|:-------------|
361
+ | `--url <url>` | Target URL (default: auto-detect dev server) |
362
+ | `--max-scenarios <n>` | Cap total scenarios (default: 50) |
363
+ | `--max-variants-per-scenario <n>` | Cap edge variants per scenario (default: 3) |
364
+ | `--max-variants-per-run <n>` | Cap edge variants per run (default: 40) |
365
+ | `--realism <profile>` | `robot`, `careful-user`, `casual-user` (default), `frustrated-user`, `power-user` |
366
+ | `--seed <n>` | Replay a specific random seed |
367
+ | `--only <filter>` | Filter scenarios by id substring or app type |
368
+ | `--app-type <types>` | Force app types (comma-separated) |
369
+ | `--regenerate` | Regenerate `sniff-scenarios/` before running |
370
+ | `--regenerate-only` | Regenerate and exit (no browser) |
371
+ | `--force-regenerate` | Overwrite hand-edits without prompting |
372
+ | `--non-interactive` | Skip prompts and the production-URL countdown |
373
+ | `--no-llm` | Skip Claude Code CLI polish (deterministic only) |
374
+
375
+ **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
+
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.
378
+
379
+ ---
380
+
340
381
  ## How it works
341
382
 
342
383
  <picture>
@@ -0,0 +1,673 @@
1
+ // src/discovery/classifier/signatures/ecommerce.ts
2
+ var ecommerce = {
3
+ type: "ecommerce",
4
+ routes: {
5
+ cart: 5,
6
+ checkout: 8,
7
+ product: 4,
8
+ products: 4,
9
+ category: 2,
10
+ categories: 2,
11
+ orders: 3,
12
+ order: 3,
13
+ shop: 3,
14
+ store: 3,
15
+ collection: 2,
16
+ collections: 2,
17
+ wishlist: 2
18
+ },
19
+ elements: {
20
+ "add to cart": 5,
21
+ "add to bag": 5,
22
+ "buy now": 5,
23
+ checkout: 4,
24
+ quantity: 2,
25
+ price: 1,
26
+ sku: 3,
27
+ "place order": 5,
28
+ cart: 2,
29
+ "in stock": 2
30
+ },
31
+ deps: {
32
+ stripe: 6,
33
+ "@stripe/stripe-js": 6,
34
+ "@stripe/react-stripe-js": 6,
35
+ shopify: 8,
36
+ "@shopify/hydrogen": 8,
37
+ "@shopify/polaris": 6,
38
+ "commerce.js": 6,
39
+ "@commerce/core": 6,
40
+ medusa: 6,
41
+ "@medusajs/medusa": 6,
42
+ "use-shopping-cart": 5,
43
+ braintree: 5,
44
+ "braintree-web": 5,
45
+ paypal: 4,
46
+ "@paypal/react-paypal-js": 5
47
+ },
48
+ schema: {
49
+ product: 6,
50
+ products: 5,
51
+ order: 6,
52
+ orders: 5,
53
+ orderitem: 5,
54
+ cart: 5,
55
+ cartitem: 4,
56
+ invoice: 3,
57
+ customer: 3,
58
+ inventory: 3,
59
+ sku: 3,
60
+ payment: 4
61
+ }
62
+ };
63
+
64
+ // src/discovery/classifier/signatures/booking.ts
65
+ var booking = {
66
+ type: "booking",
67
+ routes: {
68
+ booking: 6,
69
+ bookings: 6,
70
+ book: 6,
71
+ reserve: 5,
72
+ reservation: 6,
73
+ reservations: 6,
74
+ reschedule: 4,
75
+ availability: 5,
76
+ listing: 5,
77
+ listings: 5,
78
+ appointment: 6,
79
+ appointments: 6,
80
+ schedule: 4,
81
+ calendar: 3,
82
+ stay: 3,
83
+ stays: 3,
84
+ room: 2,
85
+ rooms: 2
86
+ },
87
+ elements: {
88
+ "book now": 6,
89
+ "reserve now": 5,
90
+ "check in": 4,
91
+ "check out": 4,
92
+ "select dates": 4,
93
+ "confirm booking": 5,
94
+ availability: 4,
95
+ "per night": 3,
96
+ guests: 3,
97
+ "date range": 3
98
+ },
99
+ deps: {
100
+ fullcalendar: 6,
101
+ "@fullcalendar/core": 6,
102
+ "@fullcalendar/react": 6,
103
+ calendly: 5,
104
+ "react-day-picker": 4,
105
+ "react-calendar": 4,
106
+ "date-fns": 2,
107
+ "mapbox-gl": 3,
108
+ leaflet: 3,
109
+ "react-leaflet": 3,
110
+ "airbnb-js-shims": 5
111
+ },
112
+ schema: {
113
+ reservation: 6,
114
+ reservations: 5,
115
+ booking: 6,
116
+ bookings: 5,
117
+ listing: 6,
118
+ listings: 5,
119
+ appointment: 6,
120
+ appointments: 5,
121
+ slot: 4,
122
+ slots: 4,
123
+ availability: 4,
124
+ host: 4,
125
+ guest: 3,
126
+ property: 3,
127
+ stay: 3,
128
+ room: 3
129
+ }
130
+ };
131
+
132
+ // src/discovery/classifier/signatures/social.ts
133
+ var social = {
134
+ type: "social",
135
+ routes: {
136
+ feed: 6,
137
+ post: 5,
138
+ posts: 5,
139
+ profile: 4,
140
+ profiles: 4,
141
+ friends: 5,
142
+ followers: 5,
143
+ following: 5,
144
+ messages: 5,
145
+ message: 4,
146
+ chat: 4,
147
+ chats: 4,
148
+ notifications: 4,
149
+ timeline: 5,
150
+ comments: 4,
151
+ likes: 4,
152
+ explore: 4,
153
+ groups: 3,
154
+ community: 3
155
+ },
156
+ elements: {
157
+ like: 3,
158
+ comment: 3,
159
+ share: 3,
160
+ follow: 4,
161
+ unfollow: 4,
162
+ "send message": 4,
163
+ post: 2,
164
+ repost: 4,
165
+ "add friend": 5,
166
+ retweet: 5,
167
+ mention: 3
168
+ },
169
+ deps: {
170
+ "socket.io": 4,
171
+ "socket.io-client": 4,
172
+ "stream-chat-react": 6,
173
+ "getstream.io": 5,
174
+ pusher: 4,
175
+ "pusher-js": 4,
176
+ emoji: 2,
177
+ "emoji-mart": 3
178
+ },
179
+ schema: {
180
+ post: 6,
181
+ posts: 5,
182
+ comment: 5,
183
+ comments: 4,
184
+ like: 4,
185
+ likes: 3,
186
+ follow: 5,
187
+ follows: 5,
188
+ friend: 4,
189
+ message: 4,
190
+ notification: 3,
191
+ reaction: 4,
192
+ profile: 3
193
+ }
194
+ };
195
+
196
+ // src/discovery/classifier/signatures/saas.ts
197
+ var saas = {
198
+ type: "saas",
199
+ routes: {
200
+ dashboard: 6,
201
+ settings: 5,
202
+ billing: 6,
203
+ subscription: 5,
204
+ subscriptions: 5,
205
+ onboarding: 5,
206
+ workspace: 5,
207
+ workspaces: 5,
208
+ team: 4,
209
+ teams: 4,
210
+ members: 4,
211
+ invites: 4,
212
+ integrations: 4,
213
+ usage: 3,
214
+ api: 2,
215
+ app: 2
216
+ },
217
+ elements: {
218
+ "invite team": 4,
219
+ "create workspace": 5,
220
+ "upgrade plan": 5,
221
+ "start trial": 5,
222
+ "connect integration": 4,
223
+ "api key": 4,
224
+ "manage billing": 5,
225
+ plan: 3,
226
+ seats: 4
227
+ },
228
+ deps: {
229
+ "next-auth": 4,
230
+ "@auth/core": 4,
231
+ clerk: 5,
232
+ "@clerk/nextjs": 5,
233
+ "@clerk/clerk-react": 5,
234
+ supabase: 3,
235
+ "@supabase/supabase-js": 3,
236
+ "@supabase/auth-helpers-nextjs": 4,
237
+ stripe: 4,
238
+ "@stripe/stripe-js": 4,
239
+ auth0: 5,
240
+ "@auth0/nextjs-auth0": 5,
241
+ posthog: 3,
242
+ "posthog-js": 3,
243
+ launchdarkly: 3,
244
+ "launchdarkly-react-client-sdk": 4,
245
+ sentry: 2,
246
+ "@sentry/nextjs": 3
247
+ },
248
+ schema: {
249
+ workspace: 6,
250
+ workspaces: 5,
251
+ subscription: 6,
252
+ subscriptions: 5,
253
+ plan: 5,
254
+ user: 3,
255
+ users: 3,
256
+ team: 4,
257
+ teams: 4,
258
+ membership: 4,
259
+ invite: 4,
260
+ apikey: 4,
261
+ apitoken: 4,
262
+ organization: 4,
263
+ org: 3
264
+ }
265
+ };
266
+
267
+ // src/discovery/classifier/signatures/content.ts
268
+ var content = {
269
+ type: "content",
270
+ routes: {
271
+ articles: 5,
272
+ article: 5,
273
+ blog: 6,
274
+ post: 4,
275
+ posts: 4,
276
+ read: 4,
277
+ author: 3,
278
+ authors: 3,
279
+ tag: 3,
280
+ tags: 3,
281
+ topic: 3,
282
+ topics: 3,
283
+ category: 3,
284
+ rss: 3,
285
+ feed: 2,
286
+ newsletter: 4,
287
+ search: 2
288
+ },
289
+ elements: {
290
+ "read more": 4,
291
+ "read article": 4,
292
+ subscribe: 3,
293
+ "newsletter signup": 5,
294
+ "share article": 3,
295
+ "estimated reading time": 4,
296
+ "by author": 3,
297
+ "published on": 3
298
+ },
299
+ deps: {
300
+ contentful: 6,
301
+ "@contentful/rich-text-react-renderer": 5,
302
+ sanity: 6,
303
+ "@sanity/client": 6,
304
+ "next-sanity": 6,
305
+ ghost: 5,
306
+ "@tryghost/content-api": 6,
307
+ "gray-matter": 4,
308
+ "remark": 3,
309
+ "remark-gfm": 3,
310
+ "rehype": 3,
311
+ "mdx-bundler": 5,
312
+ "@next/mdx": 5,
313
+ "next-mdx-remote": 5,
314
+ prismic: 5,
315
+ "@prismicio/client": 5,
316
+ strapi: 5
317
+ },
318
+ schema: {
319
+ post: 4,
320
+ posts: 4,
321
+ article: 5,
322
+ articles: 4,
323
+ author: 4,
324
+ category: 3,
325
+ tag: 3,
326
+ comment: 2
327
+ }
328
+ };
329
+
330
+ // src/discovery/classifier/signatures/crm.ts
331
+ var crm = {
332
+ type: "crm",
333
+ routes: {
334
+ contacts: 6,
335
+ contact: 5,
336
+ leads: 6,
337
+ lead: 5,
338
+ deals: 6,
339
+ deal: 5,
340
+ pipeline: 6,
341
+ pipelines: 5,
342
+ accounts: 4,
343
+ account: 3,
344
+ opportunities: 6,
345
+ opportunity: 5,
346
+ tasks: 3,
347
+ task: 3,
348
+ reports: 3,
349
+ activities: 4
350
+ },
351
+ elements: {
352
+ "add contact": 5,
353
+ "create deal": 5,
354
+ "assign to": 3,
355
+ "log activity": 4,
356
+ "next step": 3,
357
+ "close deal": 5,
358
+ "move to": 3,
359
+ pipeline: 3,
360
+ "follow up": 4
361
+ },
362
+ deps: {
363
+ "@hubspot/api-client": 6,
364
+ "salesforce-jsforce": 6,
365
+ jsforce: 6,
366
+ "pipedrive": 6,
367
+ "@sendgrid/mail": 3,
368
+ mailgun: 2
369
+ },
370
+ schema: {
371
+ contact: 6,
372
+ contacts: 5,
373
+ lead: 6,
374
+ leads: 5,
375
+ deal: 6,
376
+ deals: 5,
377
+ opportunity: 6,
378
+ opportunities: 5,
379
+ account: 4,
380
+ pipeline: 5,
381
+ stage: 4,
382
+ activity: 4,
383
+ task: 3
384
+ }
385
+ };
386
+
387
+ // src/discovery/classifier/signatures/auth-only.ts
388
+ var authOnly = {
389
+ type: "auth-only",
390
+ routes: {
391
+ login: 6,
392
+ signin: 6,
393
+ signup: 6,
394
+ register: 6,
395
+ logout: 4,
396
+ "forgot-password": 5,
397
+ "reset-password": 5,
398
+ verify: 4,
399
+ auth: 4,
400
+ profile: 3,
401
+ account: 2
402
+ },
403
+ elements: {
404
+ "sign in": 5,
405
+ "log in": 5,
406
+ "sign up": 5,
407
+ register: 5,
408
+ "create account": 5,
409
+ "forgot password": 5,
410
+ "reset password": 5,
411
+ password: 2,
412
+ email: 1
413
+ },
414
+ deps: {
415
+ "next-auth": 5,
416
+ "@auth/core": 5,
417
+ clerk: 5,
418
+ "@clerk/nextjs": 5,
419
+ auth0: 5,
420
+ "@auth0/nextjs-auth0": 5,
421
+ "@supabase/auth-helpers-nextjs": 5,
422
+ "firebase-auth": 5,
423
+ "firebase/auth": 5,
424
+ lucia: 5,
425
+ "lucia-auth": 5
426
+ },
427
+ schema: {
428
+ user: 3,
429
+ users: 3,
430
+ session: 3,
431
+ sessions: 3,
432
+ account: 2,
433
+ verification: 3
434
+ }
435
+ };
436
+
437
+ // src/discovery/classifier/signatures/marketing.ts
438
+ var marketing = {
439
+ type: "marketing",
440
+ routes: {
441
+ pricing: 6,
442
+ features: 5,
443
+ about: 4,
444
+ contact: 4,
445
+ home: 2,
446
+ faq: 4,
447
+ testimonials: 4,
448
+ customers: 3,
449
+ partners: 3,
450
+ careers: 3,
451
+ "case-studies": 4,
452
+ demo: 4,
453
+ "get-started": 3
454
+ },
455
+ elements: {
456
+ "get started": 4,
457
+ "request demo": 5,
458
+ "book a demo": 5,
459
+ "contact sales": 5,
460
+ "start free trial": 5,
461
+ "learn more": 2,
462
+ "see pricing": 4,
463
+ testimonial: 3,
464
+ "our customers": 3
465
+ },
466
+ deps: {
467
+ "@vercel/analytics": 2,
468
+ "react-hubspot-form": 4,
469
+ hubspot: 3,
470
+ mailchimp: 3,
471
+ intercom: 4,
472
+ "@intercom/messenger-js-sdk": 4,
473
+ calendly: 3,
474
+ typeform: 3,
475
+ "react-typeform-embed": 4
476
+ },
477
+ schema: {
478
+ lead: 3,
479
+ subscriber: 4,
480
+ feedback: 2
481
+ }
482
+ };
483
+
484
+ // src/discovery/classifier/signatures/admin.ts
485
+ var admin = {
486
+ type: "admin",
487
+ routes: {
488
+ admin: 6,
489
+ dashboard: 3,
490
+ users: 4,
491
+ roles: 4,
492
+ permissions: 5,
493
+ audit: 4,
494
+ logs: 4,
495
+ reports: 3,
496
+ exports: 3,
497
+ moderation: 5,
498
+ settings: 2
499
+ },
500
+ elements: {
501
+ "edit row": 4,
502
+ "delete row": 4,
503
+ "export csv": 5,
504
+ "bulk actions": 5,
505
+ "assign role": 4,
506
+ "revoke access": 4,
507
+ "view logs": 3
508
+ },
509
+ deps: {
510
+ "react-admin": 7,
511
+ refine: 6,
512
+ "@refinedev/core": 6,
513
+ "ant-design/pro-components": 5,
514
+ "mui-datatables": 5,
515
+ "@tanstack/react-table": 4,
516
+ agGrid: 4,
517
+ "ag-grid-react": 5,
518
+ keystonejs: 5,
519
+ "@keystone-6/core": 5
520
+ },
521
+ schema: {
522
+ user: 2,
523
+ role: 4,
524
+ permission: 5,
525
+ audit: 4,
526
+ log: 3,
527
+ auditlog: 5
528
+ }
529
+ };
530
+
531
+ // src/discovery/classifier/signatures/blank.ts
532
+ var blank = {
533
+ type: "blank",
534
+ routes: {},
535
+ elements: {},
536
+ deps: {},
537
+ schema: {}
538
+ };
539
+
540
+ // src/discovery/classifier/signatures/index.ts
541
+ var SIGNATURES = [
542
+ ecommerce,
543
+ booking,
544
+ social,
545
+ saas,
546
+ content,
547
+ crm,
548
+ authOnly,
549
+ marketing,
550
+ admin,
551
+ blank
552
+ ];
553
+
554
+ // src/discovery/classifier/index.ts
555
+ var MIN_CONFIDENCE_TO_KEEP = 0.1;
556
+ var STOPWORDS = /* @__PURE__ */ new Set([
557
+ "a",
558
+ "an",
559
+ "the",
560
+ "and",
561
+ "or",
562
+ "to",
563
+ "for",
564
+ "of",
565
+ "in",
566
+ "on",
567
+ "at"
568
+ ]);
569
+ function tokenize(s) {
570
+ return s.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length >= 2 && !STOPWORDS.has(t));
571
+ }
572
+ function signatureTotalWeight(signature) {
573
+ let total = 0;
574
+ for (const weight of Object.values(signature.routes)) total += weight;
575
+ for (const weight of Object.values(signature.elements)) total += weight;
576
+ for (const weight of Object.values(signature.deps)) total += weight;
577
+ for (const weight of Object.values(signature.schema)) total += weight;
578
+ return total;
579
+ }
580
+ function scoreRoutes(signature, routeTokens) {
581
+ let score = 0;
582
+ const evidence = [];
583
+ for (const [token, weight] of Object.entries(signature.routes)) {
584
+ if (routeTokens.has(token)) {
585
+ score += weight;
586
+ evidence.push({ signal: "route", value: token, weight });
587
+ }
588
+ }
589
+ return { score, evidence };
590
+ }
591
+ function scoreElements(signature, elementTokens) {
592
+ let score = 0;
593
+ const evidence = [];
594
+ for (const [phrase, weight] of Object.entries(signature.elements)) {
595
+ const phraseTokens = tokenize(phrase);
596
+ if (phraseTokens.length === 0) continue;
597
+ const allPresent = phraseTokens.every((t) => elementTokens.has(t));
598
+ if (allPresent) {
599
+ score += weight;
600
+ evidence.push({ signal: "element", value: phrase, weight });
601
+ }
602
+ }
603
+ return { score, evidence };
604
+ }
605
+ function scoreDeps(signature, deps) {
606
+ let score = 0;
607
+ const evidence = [];
608
+ for (const [dep, weight] of Object.entries(signature.deps)) {
609
+ if (deps.has(dep)) {
610
+ score += weight;
611
+ evidence.push({ signal: "dep", value: dep, weight });
612
+ }
613
+ }
614
+ return { score, evidence };
615
+ }
616
+ function scoreSchema(signature, entityNames) {
617
+ let score = 0;
618
+ const evidence = [];
619
+ for (const [entityKey, weight] of Object.entries(signature.schema)) {
620
+ if (entityNames.has(entityKey)) {
621
+ score += weight;
622
+ evidence.push({ signal: "schema", value: entityKey, weight });
623
+ }
624
+ }
625
+ return { score, evidence };
626
+ }
627
+ function scoreSignature(signature, snapshot) {
628
+ const routeTokens = new Set(snapshot.vocabulary.routes);
629
+ const elementTokens = new Set(snapshot.vocabulary.elements);
630
+ const deps = new Set(snapshot.vocabulary.deps);
631
+ const entityNames = new Set(snapshot.entities.map((e) => e.name.toLowerCase()));
632
+ const r = scoreRoutes(signature, routeTokens);
633
+ const el = scoreElements(signature, elementTokens);
634
+ const d = scoreDeps(signature, deps);
635
+ const s = scoreSchema(signature, entityNames);
636
+ const rawScore = r.score + el.score + d.score + s.score;
637
+ const evidence = [...r.evidence, ...el.evidence, ...d.evidence, ...s.evidence];
638
+ const totalWeight = signatureTotalWeight(signature);
639
+ const confidence = totalWeight > 0 ? Math.min(rawScore / totalWeight, 1) : 0;
640
+ return {
641
+ type: signature.type,
642
+ confidence,
643
+ evidence,
644
+ rawScore
645
+ };
646
+ }
647
+ function applyBlankFallback(guesses) {
648
+ const nonBlank = guesses.filter((g) => g.type !== "blank");
649
+ const topNonBlank = nonBlank.reduce(
650
+ (max, g) => g.confidence > max ? g.confidence : max,
651
+ 0
652
+ );
653
+ if (topNonBlank >= MIN_CONFIDENCE_TO_KEEP) {
654
+ return guesses.filter((g) => g.type !== "blank" || topNonBlank < 0.05);
655
+ }
656
+ return guesses.map(
657
+ (g) => g.type === "blank" ? { ...g, confidence: 1, rawScore: 0, evidence: [{ signal: "pkg", value: "no signals matched any signature", weight: 0 }] } : g
658
+ );
659
+ }
660
+ function classifyApp(snapshot) {
661
+ const raw = SIGNATURES.map((signature) => scoreSignature(signature, snapshot));
662
+ const withBlank = applyBlankFallback(raw);
663
+ return withBlank.filter((g) => g.confidence >= MIN_CONFIDENCE_TO_KEEP).sort((a, b) => b.confidence - a.confidence);
664
+ }
665
+ function topAppType(snapshot) {
666
+ const ranked = classifyApp(snapshot);
667
+ return ranked[0]?.type ?? "blank";
668
+ }
669
+ export {
670
+ classifyApp,
671
+ topAppType
672
+ };
673
+ //# sourceMappingURL=classifier-XEA6ZGE7.js.map