@shakecodeslikecray/whiterose 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,578 @@
1
+ # whiterose
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@shakecodeslikecray/whiterose.svg)](https://www.npmjs.com/package/@shakecodeslikecray/whiterose)
4
+ [![License: PolyForm Noncommercial](https://img.shields.io/badge/License-PolyForm%20NC%201.0-blue.svg)](LICENSE)
5
+ [![Test Coverage](https://img.shields.io/badge/coverage-93%25-brightgreen.svg)]()
6
+
7
+ > "I've been staring at your code for a long time."
8
+
9
+ AI-powered bug hunter that uses your existing LLM subscription. No API keys needed. No extra costs.
10
+
11
+ ```
12
+ ██╗ ██╗██╗ ██╗██╗████████╗███████╗██████╗ ██████╗ ███████╗███████╗
13
+ ██║ ██║██║ ██║██║╚══██╔══╝██╔════╝██╔══██╗██╔═══██╗██╔════╝██╔════╝
14
+ ██║ █╗ ██║███████║██║ ██║ █████╗ ██████╔╝██║ ██║███████╗█████╗
15
+ ██║███╗██║██╔══██║██║ ██║ ██╔══╝ ██╔══██╗██║ ██║╚════██║██╔══╝
16
+ ╚███╔███╔╝██║ ██║██║ ██║ ███████╗██║ ██║╚██████╔╝███████║███████╗
17
+ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝
18
+ ```
19
+
20
+ ## Why whiterose?
21
+
22
+ You're already paying for Claude Code Max, Cursor, Codex, or similar AI coding tools. Why pay again for bug detection APIs?
23
+
24
+ whiterose piggybacks on your existing subscription to find bugs in your code. Zero additional cost.
25
+
26
+ ## Features
27
+
28
+ - **Leverages Existing AI Agents**: Uses Claude Code, Aider, or other LLM CLI tools you already have
29
+ - **Real-Time Progress**: See exactly which files are being analyzed as it happens
30
+ - **Grounded in Reality**: Uses static analysis (tsc, eslint) as signals. Requires code path traces.
31
+ - **Intent-Aware**: Merges your existing documentation with AI-generated understanding
32
+ - **Provider Agnostic**: Works with Claude Code, Aider, Codex, and more
33
+ - **Fix Any Bug**: Fix whiterose-found bugs, import from SARIF files, GitHub issues, or describe manually
34
+ - **Interactive Menu**: Just run `whiterose` to get started
35
+
36
+ ---
37
+
38
+ ## Three-Layer Architecture
39
+
40
+ whiterose operates in three distinct layers:
41
+
42
+ ```
43
+ ┌─────────────────────────────────────────────────────────────────────┐
44
+ │ LAYER 0: DOCUMENTATION │
45
+ │ (whiterose init) │
46
+ │ │
47
+ │ Reads existing docs: AI generates understanding: │
48
+ │ - README.md - Project type │
49
+ │ - package.json - Framework detection │
50
+ │ - CONTRIBUTING.md - Feature extraction │
51
+ │ - .env.example - Behavioral contracts │
52
+ │ - API docs - Architecture mapping │
53
+ │ │
54
+ │ Output: .whiterose/intent.md + .whiterose/cache/understanding.json │
55
+ └─────────────────────────────────────────────────────────────────────┘
56
+
57
+
58
+ ┌─────────────────────────────────────────────────────────────────────┐
59
+ │ LAYER 1: BUG FINDING │
60
+ │ (whiterose scan) │
61
+ │ │
62
+ │ 1. Load understanding from Layer 0 │
63
+ │ 2. Run static analysis (tsc, eslint) as pre-filter │
64
+ │ 3. Spawn LLM agent to explore codebase │
65
+ │ 4. Stream progress in real-time │
66
+ │ 5. Collect bugs with evidence and code paths │
67
+ │ │
68
+ │ Output: .whiterose/reports/*.sarif + BUGS.md │
69
+ └─────────────────────────────────────────────────────────────────────┘
70
+
71
+
72
+ ┌─────────────────────────────────────────────────────────────────────┐
73
+ │ LAYER 2: BUG FIXING │
74
+ │ (whiterose fix) │
75
+ │ │
76
+ │ Bug Sources: Fix Actions: │
77
+ │ - whiterose scan results - Interactive TUI │
78
+ │ - External SARIF files - Single bug by ID │
79
+ │ - GitHub issues - Dry-run preview │
80
+ │ - Manual description - Branch creation │
81
+ │ │
82
+ │ Output: Fixed code + commits │
83
+ └─────────────────────────────────────────────────────────────────────┘
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Architecture: How whiterose Actually Works
89
+
90
+ **This section is critical to understanding what whiterose is and isn't.**
91
+
92
+ ### What whiterose IS
93
+
94
+ whiterose is an **orchestrator/wrapper** that:
95
+ 1. Spawns an LLM CLI tool (like Claude Code) as a subprocess
96
+ 2. Passes it a specialized prompt with a communication protocol
97
+ 3. Streams and parses the LLM's output in real-time
98
+ 4. Displays progress to the user
99
+ 5. Collects and formats bug reports
100
+
101
+ ### What whiterose IS NOT
102
+
103
+ whiterose is **NOT** a custom AI agent with its own tool-calling loop. It does not:
104
+ - Make direct API calls to Claude/OpenAI/etc.
105
+ - Define or execute its own tools
106
+ - Implement an LLM-in-a-loop architecture itself
107
+
108
+ ### The Real Agent: Your LLM Provider
109
+
110
+ The actual "agent" is **Claude Code** (or Aider, etc.). These tools have their own internal agentic architecture:
111
+
112
+ ```
113
+ ┌─────────────────────────────────────────────────────────────────────┐
114
+ │ CLAUDE CODE │
115
+ │ (The Actual AI Agent) │
116
+ │ │
117
+ │ Claude Code runs an internal agent loop: │
118
+ │ │
119
+ │ while (task not complete): │
120
+ │ 1. LLM decides what to do next │
121
+ │ 2. LLM issues a tool call (Read, Glob, Grep, Bash, etc.) │
122
+ │ 3. Claude Code executes the tool locally │
123
+ │ 4. Tool result is sent back to the LLM │
124
+ │ 5. LLM processes result and decides next action │
125
+ │ 6. Repeat until done │
126
+ │ │
127
+ │ Built-in Tools: │
128
+ │ - Read: Read file contents │
129
+ │ - Glob: Find files by pattern │
130
+ │ - Grep: Search file contents │
131
+ │ - Bash: Execute shell commands │
132
+ │ - Write/Edit: Modify files │
133
+ │ - Task: Spawn sub-agents │
134
+ │ - And more... │
135
+ │ │
136
+ └─────────────────────────────────────────────────────────────────────┘
137
+ ```
138
+
139
+ ### The Complete Flow
140
+
141
+ ```
142
+ ┌─────────────────────────────────────────────────────────────────────┐
143
+ │ USER │
144
+ │ runs: whiterose scan │
145
+ └─────────────────────────────────┬───────────────────────────────────┘
146
+
147
+
148
+ ┌─────────────────────────────────────────────────────────────────────┐
149
+ │ WHITEROSE CLI │
150
+ │ │
151
+ │ 1. Loads config from .whiterose/config.yml │
152
+ │ 2. Loads codebase understanding from cache │
153
+ │ 3. Runs static analysis (tsc, eslint) as pre-filter │
154
+ │ 4. Spawns Claude Code as subprocess: │
155
+ │ │
156
+ │ claude --dangerously-skip-permissions -p "<prompt>" │
157
+ │ │
158
+ │ 5. Streams stdout from Claude Code │
159
+ │ 6. Parses protocol markers in real-time │
160
+ │ 7. Updates UI with progress │
161
+ │ 8. Collects bug reports │
162
+ │ 9. Outputs SARIF + Markdown reports │
163
+ │ │
164
+ └─────────────────────────────────┬───────────────────────────────────┘
165
+ │ spawns
166
+
167
+ ┌─────────────────────────────────────────────────────────────────────┐
168
+ │ CLAUDE CODE │
169
+ │ (runs autonomously) │
170
+ │ │
171
+ │ Receives prompt telling it to: │
172
+ │ - Explore the codebase │
173
+ │ - Find bugs in specific categories │
174
+ │ - Output progress using protocol markers │
175
+ │ - Output bugs as JSON │
176
+ │ │
177
+ │ Claude Code then: │
178
+ │ - Uses its Read tool to examine files │
179
+ │ - Uses Glob/Grep to find relevant code │
180
+ │ - Analyzes code for bugs │
181
+ │ - Outputs markers that whiterose parses │
182
+ │ │
183
+ └─────────────────────────────────────────────────────────────────────┘
184
+ ```
185
+
186
+ ### The Communication Protocol
187
+
188
+ whiterose and the LLM communicate via stdout using protocol markers:
189
+
190
+ ```
191
+ ###SCANNING:src/api/users.ts <- LLM is about to analyze this file
192
+ ###SCANNING:src/api/auth.ts <- LLM moved to next file
193
+ ###BUG:{"file":"src/api/users.ts","line":42,"title":"Null dereference",...}
194
+ ###SCANNING:src/hooks/useCart.ts <- LLM continues exploring
195
+ ###BUG:{"file":"src/hooks/useCart.ts","line":17,"title":"Missing await",...}
196
+ ###COMPLETE <- LLM finished analysis
197
+ ```
198
+
199
+ whiterose parses these markers in real-time to:
200
+ - Show progress: "Scanning: src/api/users.ts"
201
+ - Show findings: "Found: Null dereference (high)"
202
+ - Collect bugs for the final report
203
+
204
+ ### Why This Architecture?
205
+
206
+ 1. **No API Keys Needed**: Uses CLI tools you already have installed and authenticated
207
+ 2. **Zero Extra Cost**: Piggybacks on your existing subscriptions (Claude Max, etc.)
208
+ 3. **Real Progress**: Streaming output shows exactly what's happening
209
+ 4. **Leverages Existing Agents**: Claude Code already knows how to explore codebases intelligently
210
+ 5. **Respects .gitignore**: Claude Code automatically ignores files you don't want scanned
211
+ 6. **No Token Limits**: Claude Code reads files on-demand, not all at once
212
+
213
+ ---
214
+
215
+ ## Installation
216
+
217
+ ```bash
218
+ npm install -g @shakecodeslikecray/whiterose
219
+ ```
220
+
221
+ The CLI command is `whiterose` (no scope prefix needed).
222
+
223
+ ### Prerequisites
224
+
225
+ You need at least one of these LLM CLI tools installed:
226
+
227
+ | Provider | Installation | Status |
228
+ |----------|-------------|--------|
229
+ | Claude Code | `npm install -g @anthropic-ai/claude-code` | Ready |
230
+ | Aider | `pip install aider-chat` | Coming Soon |
231
+ | Codex | OpenAI CLI | Coming Soon |
232
+ | Gemini | Google CLI | Coming Soon |
233
+
234
+ ## Quick Start
235
+
236
+ ```bash
237
+ # Interactive menu (recommended)
238
+ whiterose
239
+
240
+ # Or use commands directly:
241
+ whiterose init # Initialize (explores codebase, generates understanding)
242
+ whiterose scan # Scan for bugs
243
+ whiterose fix # Fix bugs interactively
244
+ ```
245
+
246
+ Running `whiterose` without arguments shows an interactive menu:
247
+
248
+ ```
249
+ ██╗ ██╗██╗ ██╗██╗████████╗███████╗██████╗ ██████╗ ███████╗███████╗
250
+ ...
251
+
252
+ Project: my-app
253
+ Status: initialized
254
+
255
+ ? What would you like to do?
256
+ > Scan find bugs in the codebase
257
+ Fix fix bugs interactively
258
+ Status show current status
259
+ Report generate bug report
260
+ Refresh rebuild codebase understanding
261
+ Help show all commands
262
+ Exit
263
+ ```
264
+
265
+ ## Commands
266
+
267
+ ### `whiterose init`
268
+
269
+ First-time setup. whiterose will:
270
+ 1. Detect available LLM providers (claude-code, aider, codex, etc.)
271
+ 2. Ask you to select one
272
+ 3. Read existing documentation (README, package.json, CONTRIBUTING, etc.)
273
+ 4. Spawn the LLM to explore and understand your codebase
274
+ 5. Merge existing docs with AI-generated understanding
275
+ 6. Show real-time progress as files are examined
276
+ 7. Create `.whiterose/` directory with config and understanding
277
+
278
+ **What you'll see:**
279
+ ```
280
+ whiterose - initialization
281
+
282
+ ✓ Detected providers: claude-code, aider
283
+ ? Which LLM provider should whiterose use?
284
+ > claude-code (recommended)
285
+ aider
286
+
287
+ ✓ Found existing docs: README, package.json, .env.example
288
+ Examining: src/index.ts
289
+ Examining: src/api/users.ts
290
+ ...
291
+ ✓ Analysis complete (45s)
292
+
293
+ Here's what I understand about your codebase:
294
+
295
+ Type: E-commerce Application
296
+ Framework: Next.js
297
+ Language: TypeScript
298
+ Files: 127
299
+ Lines: 15,234
300
+
301
+ ? Is this understanding accurate? Yes
302
+
303
+ whiterose initialized successfully!
304
+ ```
305
+
306
+ ### `whiterose scan`
307
+
308
+ Find bugs. Uses incremental scanning by default (only changed files).
309
+
310
+ ```bash
311
+ whiterose scan # Incremental scan
312
+ whiterose scan --full # Full scan
313
+ whiterose scan --json # JSON output
314
+ whiterose scan src/api/ # Scan specific path
315
+ whiterose scan --unsafe # Bypass LLM permission prompts
316
+ ```
317
+
318
+ **What you'll see:**
319
+ ```
320
+ whiterose - scanning for bugs
321
+
322
+ Scanning: src/api/users.ts
323
+ Scanning: src/api/auth.ts
324
+ Found: Null dereference in getUserById (high)
325
+ Scanning: src/hooks/useCart.ts
326
+ Found: Missing await in checkout (medium)
327
+ ...
328
+ Analysis complete. Found 3 bugs.
329
+
330
+ Scan Results
331
+
332
+ ● Critical: 0
333
+ ● High: 1
334
+ ● Medium: 2
335
+ ● Low: 0
336
+
337
+ Total: 3 bugs found
338
+ ```
339
+
340
+ ### `whiterose fix`
341
+
342
+ Interactive TUI for reviewing and fixing bugs. Supports multiple bug sources.
343
+
344
+ ```bash
345
+ # From whiterose scan results (default)
346
+ whiterose fix # Interactive dashboard
347
+ whiterose fix WR-001 # Fix specific bug
348
+ whiterose fix --dry-run # Preview fixes without applying
349
+ whiterose fix --branch fix/bugs # Create fixes in new branch
350
+
351
+ # From external SARIF file
352
+ whiterose fix --sarif ./reports/semgrep.sarif
353
+
354
+ # From GitHub issue
355
+ whiterose fix --github https://github.com/owner/repo/issues/123
356
+
357
+ # Manually describe a bug
358
+ whiterose fix --describe
359
+ ```
360
+
361
+ **External Bug Sources:**
362
+
363
+ | Source | Option | Description |
364
+ |--------|--------|-------------|
365
+ | whiterose scan | (default) | Bugs from latest scan in `.whiterose/reports/` |
366
+ | External SARIF | `--sarif <path>` | Import bugs from any SARIF-compatible tool |
367
+ | GitHub Issue | `--github <url>` | Parse bug from GitHub issue (requires `gh` CLI) |
368
+ | Manual | `--describe` | Interactive prompts to describe a bug |
369
+
370
+ When using `--github`, whiterose:
371
+ - Extracts file path and line number from issue body (if present)
372
+ - Determines severity from labels (critical, security, bug, etc.)
373
+ - Prompts for missing information
374
+
375
+ ### `whiterose refresh`
376
+
377
+ Rebuild codebase understanding from scratch.
378
+
379
+ ### `whiterose status`
380
+
381
+ Show current status (provider, cache, last scan).
382
+
383
+ ### `whiterose report`
384
+
385
+ Generate bug report from last scan.
386
+
387
+ ## Configuration
388
+
389
+ `.whiterose/config.yml`:
390
+
391
+ ```yaml
392
+ version: "1"
393
+ provider: claude-code
394
+
395
+ include:
396
+ - "**/*.ts"
397
+ - "**/*.tsx"
398
+
399
+ exclude:
400
+ - node_modules
401
+ - dist
402
+ - "**/*.test.*"
403
+
404
+ priorities:
405
+ src/api/checkout.ts: critical
406
+ src/auth/: high
407
+
408
+ categories:
409
+ - logic-error
410
+ - security
411
+ - async-race-condition
412
+ - edge-case
413
+ - null-reference
414
+
415
+ minConfidence: low
416
+
417
+ staticAnalysis:
418
+ typescript: true
419
+ eslint: true
420
+
421
+ output:
422
+ sarif: true
423
+ markdown: true
424
+ ```
425
+
426
+ ## Intent Document
427
+
428
+ `.whiterose/intent.md` describes your app's intent and behavioral contracts:
429
+
430
+ ```markdown
431
+ # App Intent: acme-store
432
+
433
+ ## Overview
434
+ E-commerce platform for selling widgets.
435
+
436
+ ## Critical Features
437
+
438
+ ### Checkout [CRITICAL]
439
+ Must never double-charge. Must handle payment failures gracefully.
440
+
441
+ **Constraints:**
442
+ - Create order record before charging payment
443
+ - Rollback order if charge fails
444
+
445
+ ---
446
+
447
+ ## Behavioral Contracts
448
+
449
+ ### `src/api/checkout.ts:processPayment()`
450
+
451
+ **Inputs:**
452
+ - `cartId`: string
453
+ - `paymentMethod`: stripe | paypal
454
+
455
+ **Returns:** `PaymentResult`
456
+
457
+ **Invariants:**
458
+ - Must not charge if inventory unavailable
459
+ - Must create order before charging
460
+ - Must rollback if charge fails
461
+ ```
462
+
463
+ ## Supported Providers
464
+
465
+ | Provider | Status | Notes |
466
+ |----------|--------|-------|
467
+ | Claude Code | Ready | Recommended. Uses Max subscription. |
468
+ | Aider | Coming Soon | Will support when implemented |
469
+ | Codex | Coming Soon | Will support when implemented |
470
+ | Gemini | Coming Soon | Will support when implemented |
471
+ | Ollama | Coming Soon | Local LLMs |
472
+
473
+ ## Bug Categories
474
+
475
+ whiterose looks for bugs in these categories:
476
+
477
+ - **logic-error**: Off-by-one errors, wrong operators, incorrect conditions
478
+ - **null-reference**: Accessing properties on potentially null/undefined values
479
+ - **security**: Injection, auth bypass, XSS, data exposure
480
+ - **async-race-condition**: Missing await, unhandled promises, race conditions
481
+ - **edge-case**: Empty arrays, zero values, boundary conditions
482
+ - **resource-leak**: Unclosed connections, event listener leaks
483
+ - **type-coercion**: Loose equality bugs, implicit conversions
484
+ - **intent-violation**: Code that violates documented business rules
485
+
486
+ ## Output Formats
487
+
488
+ ### SARIF
489
+
490
+ Standard format for static analysis tools. Works with:
491
+ - VS Code (SARIF Viewer extension)
492
+ - GitHub Code Scanning
493
+ - Azure DevOps
494
+
495
+ ### Markdown
496
+
497
+ Human-readable report with:
498
+ - Bug severity badges
499
+ - Code path traces
500
+ - Suggested fixes
501
+ - Evidence
502
+
503
+ ## Philosophy
504
+
505
+ - **SRP**: whiterose finds bugs. It doesn't write tests, lint code, or format files.
506
+ - **Leverage, Don't Reinvent**: Uses existing AI agents (Claude Code) rather than building a custom agent loop.
507
+ - **Transparency**: Shows exactly what's happening in real-time.
508
+ - **Grounded**: Every bug must have evidence and a code path trace.
509
+ - **Zero Cost**: Uses your existing LLM subscription.
510
+
511
+ ## Technical Details
512
+
513
+ ### How Provider Detection Works
514
+
515
+ whiterose checks for installed CLI tools in this order:
516
+ 1. Checks if command exists in PATH
517
+ 2. Checks common installation locations:
518
+ - `~/.local/bin/`
519
+ - `/usr/local/bin/`
520
+ - `/opt/homebrew/bin/`
521
+
522
+ ### How Streaming Works
523
+
524
+ 1. whiterose spawns: `claude --verbose -p "<prompt>"` (or with `--dangerously-skip-permissions` if `--unsafe` flag used)
525
+ 2. Attaches to stdout stream
526
+ 3. Buffers output line-by-line
527
+ 4. Parses lines for protocol markers (`###SCANNING:`, `###BUG:`, etc.)
528
+ 5. Triggers callbacks for UI updates and bug collection
529
+
530
+ ### Security Features
531
+
532
+ - **Path traversal prevention**: File paths in bug reports are validated to stay within the project directory
533
+ - **Opt-in unsafe mode**: LLM permission prompts are shown by default; use `--unsafe` flag to bypass
534
+ - **No external network calls**: All analysis happens locally via your LLM CLI
535
+
536
+ ### Protocol Markers
537
+
538
+ | Marker | Purpose | Example |
539
+ |--------|---------|---------|
540
+ | `###SCANNING:` | File being analyzed | `###SCANNING:src/api/users.ts` |
541
+ | `###BUG:` | Bug found (JSON) | `###BUG:{"file":"...","line":42,...}` |
542
+ | `###UNDERSTANDING:` | Codebase understanding (JSON) | `###UNDERSTANDING:{"summary":{...}}` |
543
+ | `###COMPLETE` | Analysis finished | `###COMPLETE` |
544
+ | `###ERROR:` | Error occurred | `###ERROR:Failed to read file` |
545
+
546
+ ## Roadmap
547
+
548
+ ### v0.2 (Coming Soon)
549
+ - [ ] VSCode extension for inline bug display
550
+ - [ ] GitHub Actions integration for PR scanning
551
+ - [ ] Improved monorepo support
552
+ - [ ] Custom bug category definitions
553
+
554
+ ### v0.3
555
+ - [ ] Historical bug tracking and trend analysis
556
+ - [ ] Team collaboration features
557
+ - [ ] Ollama/local LLM support
558
+ - [ ] Plugin architecture for custom providers
559
+
560
+ ### v1.0
561
+ - [ ] Production-ready stability
562
+ - [ ] Enterprise features
563
+ - [ ] Comprehensive documentation site
564
+ - [ ] IDE integrations (JetBrains, Neovim)
565
+
566
+ ## License
567
+
568
+ PolyForm Noncommercial 1.0.0
569
+
570
+ This software is free for non-commercial use. See [LICENSE](LICENSE) for details.
571
+
572
+ ## Credits
573
+
574
+ Named after the [Mr. Robot](https://en.wikipedia.org/wiki/Mr._Robot) character who sees everything and orchestrates from the shadows.
575
+
576
+ ---
577
+
578
+ **Required Notice:** Copyright (c) 2024 shakecodeslikecray (https://github.com/shakecodeslikecray)
@@ -0,0 +1,2 @@
1
+
2
+ export { }