@databuddy/scan 0.1.0 → 0.1.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 (3) hide show
  1. package/README.md +41 -29
  2. package/dist/cli.js +477 -311
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,49 +1,61 @@
1
- # Databuddy scan
1
+ # @databuddy/scan
2
2
 
3
- Find places to add product analytics events in a Git repository, with live terminal progress.
3
+ Find the places in your codebase where a product analytics event is missing.
4
4
 
5
5
  ```sh
6
- npx @databuddy/scan --run
7
- # or
8
- bunx @databuddy/scan --run
6
+ npx @databuddy/scan
9
7
  ```
10
8
 
11
- Requires Git, Node.js 22+, and a Vercel AI Gateway key in `AI_GATEWAY_API_KEY` or your repository's `.env`. To run directly on Bun without Node, use `bunx --bun @databuddy/scan --run` (Bun 1.2+).
9
+ Run it inside a Git repository, or pass a folder to scan only that folder. No account or key. Node.js 22+, or `bunx @databuddy/scan`.
12
10
 
13
- Run without `--run` to preview the number of eligible files without sending code. **`--run` sends included source code to Jev through your Vercel AI Gateway account**, requesting zero data retention. Provider charges may apply. The scanner reads tracked files from your working tree, including uncommitted edits; it excludes tests, examples, symlinks, unsupported files, and detected embedded secrets. Detection is not a guarantee that source contains no secrets.
11
+ ```
12
+ databuddy. / event scan
14
13
 
15
- ```sh
16
- npx @databuddy/scan --report # Saved summary
17
- npx @databuddy/scan --report --verbose # Every flagged source location
18
- npx @databuddy/scan --diagnostics # Failures, retries and output quality
19
- npx @databuddy/scan --fresh # Scan again without reusing responses
20
- npx @databuddy/scan --run --no-actions # Review whole files instead of grouped actions
21
- npx @databuddy/scan --help # All options
14
+ Scan complete · 9 files to review · 13 findings · 14s
15
+
16
+ app/api/stripe/checkout/route.ts:9 · GET · missing · Payments
17
+ app/(dashboard)/pricing/page.tsx:88 · form.action checkoutAction · missing · Payments
18
+ app/(dashboard)/dashboard/page.tsx:204 · form.action inviteAction · missing · Setup & onboarding
22
19
  ```
23
20
 
24
- Press Ctrl+C to save completed work. Repeat `--run` to resume using successful cached responses. Findings are potential gaps to review in source, not verified insertion points or automatically added events. Source context can miss shared tracking wrappers and callees.
21
+ ## Where your code goes
25
22
 
26
- Grouped action review is the default. It groups JavaScript/TypeScript action handlers with callback and persistence evidence, so a button and its mutation are evaluated together. Routine UI state changes and name-only helpers do not become independent candidates. Unresolved or oversized context is recorded with the finding; unsupported files fall back to whole-source review, and files that parse with no action are not reviewed at all (`--no-actions` reviews everything). On a 190-item labelled intersection, grouping raised covered precision from 51.6% to 93.9% (p=0.027) at 2.4x the speed. This is a bounded syntax analysis, not a complete call graph.
23
+ The scan sends code to Databuddy's scan API (`api.databuddy.cc`), which classifies it with the Jev model on Vercel AI Gateway under **zero data retention**. For JavaScript and TypeScript it sends only the user actions it finds and the functions they call, not whole files. **Your source is never stored or logged.** The API only counts scans, using a random run ID, the CLI version and request sizes; nothing identifies you or your repository. The CLI prints where the source is going, with the number of files, before it sends anything.
27
24
 
28
- Results, response caches and request logs are stored under `$XDG_CACHE_HOME/databuddy/scan/<repository-hash>` or `~/.cache/databuddy/scan/<repository-hash>`. Use `--output=/path/to/results` to choose another location, or `--root=/path/to/repository` to scan elsewhere. Reports work offline; `--cache-only` replays matching responses without network access or writes.
25
+ - `--dry-run` lists every file and line range that would be sent, and sends nothing. `--dry-run --json` prints the exact payload.
26
+ - `databuddy-scan <folder>` reads and sends nothing outside that folder.
27
+ - To keep source off Databuddy entirely, set `AI_GATEWAY_API_KEY` to your own [Vercel AI Gateway](https://vercel.com/docs/ai-gateway) key. Requests then go straight to your account and Databuddy receives nothing.
29
28
 
30
- Request logs contain timing, retries and provider error codes, without credentials, source bodies or raw provider error bodies. The private local inventory includes file paths, hashes and tracking-call snippets. `--json` writes the result to stdout without progress output; `--plain` disables terminal control codes.
29
+ Only Git-tracked files are read. See the [privacy policy](https://www.databuddy.cc/privacy). Tests, examples, symlinks and files that look like they contain secrets are skipped.
31
30
 
32
- For local development from the monorepo root:
31
+ ## For agents
33
32
 
34
33
  ```sh
35
- bun ./scan.ts --run
36
- bun run --cwd packages/scan build
37
- bun run --cwd packages/scan check-types
38
- bun run --cwd packages/scan test
39
- bun run --cwd packages/scan eval:quality # Offline extraction report
40
- bun run --cwd packages/scan eval:quality --run # Bounded live comparison
34
+ npx @databuddy/scan --json
41
35
  ```
42
36
 
43
- TypeScript source compiles to `dist/cli.js`. Commander handles arguments, Zod validates inputs and model responses, p-limit schedules requests, and Chalk/log-update render terminal progress. The npm package contains the compiled executable; users do not need to build it.
37
+ Prints every finding with its file, line, coverage (`missing`, `partial`, `covered`), product area and priority, most important first. `summary.destination` and `summary.zeroDataRetention` state where the source went. The privacy notice goes to stderr, so stdout is always one JSON document, including `{"error": ...}` on failure.
38
+
39
+ ## Options
40
+
41
+ | | |
42
+ | --- | --- |
43
+ | `[path]` | Folder or file to scan. Defaults to the current folder. |
44
+ | `--dry-run` | List the lines that would be sent. Sends nothing. |
45
+ | `--json` | Print results as JSON. |
44
46
 
45
- Quality tests use synthetic source to reproduce the reviewed misses, duplicate flags, noise, and ambiguous callbacks. They verify extraction and evidence, not model accuracy. The optional live comparison uses 20 previously reviewed Databuddy targets, keeps review labels out of prompts, and reports unmatched or ambiguous targets separately. This selected set is a regression check, not a whole-repository accuracy estimate. It sends source through the same Gateway account as a normal scan.
47
+ Running again is fast: results are cached in `~/.cache/databuddy/scan`, unchanged code is not sent again, and an interrupted scan resumes where it stopped. Findings are suggestions to review; the scanner never edits your code.
48
+
49
+ ## Contributing
50
+
51
+ From the Databuddy monorepo root:
52
+
53
+ ```sh
54
+ bun ./scan.ts # Run from source
55
+ bun run --cwd packages/scan test # Build and test
56
+ bun run --cwd packages/scan eval:quality # Extraction audit against reviewed cases
57
+ ```
46
58
 
47
- Grouping is the default, on a 190-item labelled intersection where it raised covered precision from 51.6% to 93.9% (McNemar p=0.027) at 2.4x the speed of whole-file review. Known gaps: only `onClick`, `onSubmit` and `onCopy` seed a candidate, so selector-driven workflows using `onValueChange`, `onCheckedChange` or `onSelect` are missed; docs-copy and upgrade controls still classify as operational.
59
+ ## License
48
60
 
49
- Licensed under MIT; see [LICENSE](LICENSE).
61
+ MIT