@butttons/dora 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +525 -0
  3. package/dist/index.js +34960 -0
  4. package/package.json +52 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [year] [fullname]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,525 @@
1
+ # dora - Code Context CLI for AI Agents
2
+
3
+ Stop wasting tokens on grep/find/glob. Give your AI agent fast, structured code intelligence.
4
+
5
+ ## Features
6
+
7
+ - **Instant answers** - Pre-computed aggregates mean no waiting for grep/find/glob to finish or tokens wasted on file reads
8
+ - **Understand relationships** - See what depends on what without reading import statements or parsing code
9
+ - **Find issues fast** - Detect circular dependencies, coupling, and complexity hotspots with pre-indexed data
10
+ - **Track usage** - Know where every symbol is used across your codebase in milliseconds, not minutes
11
+ - **Language-agnostic** - Works with any SCIP-compatible indexer (TypeScript, Java, Rust, Python, etc.)
12
+
13
+ ## See It In Action
14
+
15
+ ### Typical Workflow Without dora
16
+
17
+ ![Baseline CLI workflow showing grep/find approach](docs/public/baseline-cli.gif)
18
+
19
+ ### With dora CLI
20
+
21
+ ![dora CLI workflow showing fast structured queries](docs/public/dora-cli.gif)
22
+
23
+ ## System Requirements
24
+
25
+ - **Binary users**: No dependencies - standalone executable
26
+ - **From source**: Bun 1.0+ required
27
+ - **SCIP indexer**: Language-specific (e.g., scip-typescript for TS/JS)
28
+ - **Supported OS**: macOS, Linux, Windows
29
+ - **Disk space**: ~5-50MB for index (varies by codebase size)
30
+
31
+ ## Installation
32
+
33
+ ### Option 1: Download Pre-built Binary (Recommended)
34
+
35
+ Download the latest binary for your platform from the [releases page](https://github.com/butttons/dora/releases):
36
+
37
+ ```bash
38
+ # macOS (ARM64)
39
+ curl -L https://github.com/butttons/dora/releases/latest/download/dora-darwin-arm64 -o dora
40
+ chmod +x dora
41
+ sudo mv dora /usr/local/bin/
42
+
43
+ # macOS (Intel)
44
+ curl -L https://github.com/butttons/dora/releases/latest/download/dora-darwin-x64 -o dora
45
+ chmod +x dora
46
+ sudo mv dora /usr/local/bin/
47
+
48
+ # Linux
49
+ curl -L https://github.com/butttons/dora/releases/latest/download/dora-linux-x64 -o dora
50
+ chmod +x dora
51
+ sudo mv dora /usr/local/bin/
52
+
53
+ # Windows
54
+ # Download dora-windows-x64.exe and add to PATH
55
+ ```
56
+
57
+ ### Option 2: Build from Source
58
+
59
+ ```bash
60
+ # Install Bun (if not already installed)
61
+ curl -fsSL https://bun.sh/install | bash
62
+
63
+ # Clone the repository
64
+ git clone https://github.com/butttons/dora.git
65
+ cd dora
66
+
67
+ # Install dependencies
68
+ bun install
69
+
70
+ # Build the binary
71
+ bun run build
72
+
73
+ # The binary will be at dist/dora
74
+ # Move it to your PATH
75
+ sudo mv dist/dora /usr/local/bin/
76
+ ```
77
+
78
+ ### Install SCIP Indexer
79
+
80
+ You'll need a SCIP indexer for your language. For TypeScript/JavaScript:
81
+
82
+ ```bash
83
+ # Install scip-typescript globally
84
+ npm install -g @sourcegraph/scip-typescript
85
+
86
+ # Verify installation
87
+ scip-typescript --help
88
+ ```
89
+
90
+ For other languages, see [SCIP Indexers](#scip-indexers).
91
+
92
+ ## AI Agent Integration
93
+
94
+ **→ See [AGENTS.README.md](AGENTS.README.md) for complete integration guides** for:
95
+
96
+ - **Claude Code** - Skills, hooks, auto-indexing
97
+ - **OpenCode** - Agent system integration
98
+ - **Cursor** - Custom commands and rules
99
+ - **Windsurf** - Skills, AGENTS.md, and rules
100
+ - **Other AI agents** - Generic integration using SKILL.md and SNIPPET.md
101
+
102
+ Quick start for any agent:
103
+
104
+ ```bash
105
+ dora init && dora index # Initialize and index your codebase
106
+ dora cookbook show agent-setup --format markdown # Get setup instructions for your agent
107
+ dora status # Verify index is ready
108
+ ```
109
+
110
+ ## Claude Code Integration
111
+
112
+ dora integrates with Claude Code via settings and optional skill configuration. Just add these files to your project:
113
+
114
+ **1. Add to `.claude/settings.json`** (enables auto-indexing and permissions):
115
+
116
+ ```json
117
+ {
118
+ "permissions": {
119
+ "allow": ["Bash(dora:*)", "Skill(dora)"]
120
+ },
121
+ "hooks": {
122
+ "SessionStart": [
123
+ {
124
+ "hooks": [
125
+ {
126
+ "type": "command",
127
+ "command": "dora status 2>/dev/null && (dora index > /tmp/dora-index.log 2>&1 &) || echo 'dora not initialized. Run: dora init && dora index'"
128
+ }
129
+ ]
130
+ }
131
+ ],
132
+ "Stop": [
133
+ {
134
+ "hooks": [
135
+ {
136
+ "type": "command",
137
+ "command": "(dora index > /tmp/dora-index.log 2>&1 &) || true"
138
+ }
139
+ ]
140
+ }
141
+ ]
142
+ }
143
+ }
144
+ ```
145
+
146
+ **2. (Optional) Add the dora skill** at `.claude/skills/dora/SKILL.md`:
147
+
148
+ After running `dora init`, create a symlink:
149
+
150
+ ```bash
151
+ mkdir -p .claude/skills/dora
152
+ ln -s ../../../.dora/docs/SKILL.md .claude/skills/dora/SKILL.md
153
+ ```
154
+
155
+ This enables the `/dora` command in Claude Code. [View the skill file](https://github.com/butttons/dora/blob/main/src/templates/docs/SKILL.md).
156
+
157
+ **3. Add to CLAUDE.md** (after running `dora init`):
158
+
159
+ ```bash
160
+ cat .dora/docs/SNIPPET.md >> CLAUDE.md
161
+ ```
162
+
163
+ This gives Claude quick access to dora commands and guidance on when to use dora for code exploration. The snippet includes command reference and best practices.
164
+
165
+ **4. Initialize dora:**
166
+
167
+ ```bash
168
+ dora init
169
+ dora index
170
+ ```
171
+
172
+ **What this gives you:**
173
+
174
+ - Auto-indexing after each Claude turn
175
+ - Pre-approved permissions (no prompts for dora commands)
176
+ - Session startup checks
177
+ - CLAUDE.md context for better code exploration
178
+
179
+ **Troubleshooting:**
180
+
181
+ - **Index not updating?** Check `/tmp/dora-index.log` for errors
182
+ - **dora not found?** Ensure dora is in PATH: `which dora`
183
+
184
+ ## MCP Server
185
+
186
+ dora can run as an MCP (Model Context Protocol) server.
187
+
188
+ ### Quick Start
189
+
190
+ ```bash
191
+ # Start MCP server (runs in foreground)
192
+ dora mcp
193
+ ```
194
+
195
+ ### Claude Code
196
+
197
+ Add the MCP server with one command:
198
+
199
+ ```bash
200
+ claude mcp add --transport stdio dora -- dora mcp
201
+ ```
202
+
203
+ ### Other MCP Clients
204
+
205
+ Add to your MCP client configuration:
206
+
207
+ ```json
208
+ {
209
+ "mcpServers": {
210
+ "dora": {
211
+ "type": "stdio",
212
+ "command": "dora",
213
+ "args": ["mcp"]
214
+ }
215
+ }
216
+ }
217
+ ```
218
+
219
+ ### What You Get
220
+
221
+ All dora commands are available as MCP tools:
222
+
223
+ - `dora_status` - Check index health
224
+ - `dora_map` - Get codebase overview
225
+ - `dora_symbol` - Search for symbols
226
+ - `dora_file` - Analyze files with dependencies
227
+ - `dora_deps` / `dora_rdeps` - Explore dependencies
228
+ - And all other dora commands
229
+
230
+ ## Quick Start
231
+
232
+ ### 1. Initialize
233
+
234
+ ```bash
235
+ dora init
236
+ ```
237
+
238
+ This creates a `.dora/` directory with a default config.
239
+
240
+ ### 2. Configure Commands
241
+
242
+ Edit `.dora/config.json` to configure your SCIP indexer:
243
+
244
+ **For TypeScript/JavaScript:**
245
+
246
+ ```json
247
+ {
248
+ "commands": {
249
+ "index": "scip-typescript index --output .dora/index.scip"
250
+ }
251
+ }
252
+ ```
253
+
254
+ **For Rust:**
255
+
256
+ ```json
257
+ {
258
+ "commands": {
259
+ "index": "rust-analyzer scip . --output .dora/index.scip"
260
+ }
261
+ }
262
+ ```
263
+
264
+ ### 3. Index Your Codebase
265
+
266
+ ```bash
267
+ # If commands are configured:
268
+ dora index
269
+
270
+ # Or manually:
271
+ scip-typescript index --output .dora/index.scip
272
+ ```
273
+
274
+ ### 4. Try It Out
275
+
276
+ ```bash
277
+ # Check index status
278
+ dora status
279
+
280
+ # Get codebase overview
281
+ dora map
282
+
283
+ # Find a symbol
284
+ dora symbol Logger
285
+ ```
286
+
287
+ ### 5. Example Workflow
288
+
289
+ ```bash
290
+ # Find a class definition
291
+ dora symbol AuthService
292
+
293
+ # Explore the file
294
+ dora file src/auth/service.ts
295
+
296
+ # See what depends on it
297
+ dora rdeps src/auth/service.ts --depth 2
298
+
299
+ # Check for circular dependencies
300
+ dora cycles
301
+ ```
302
+
303
+ ### 6. Learn Custom Queries
304
+
305
+ New to dora? The cookbook has recipes with real examples:
306
+
307
+ ```bash
308
+ # Start here - complete walkthrough
309
+ dora cookbook show quickstart
310
+
311
+ # Find class methods
312
+ dora cookbook show methods
313
+
314
+ # Track symbol references
315
+ dora cookbook show references
316
+
317
+ # Find exported APIs
318
+ dora cookbook show exports
319
+ ```
320
+
321
+ All recipes include tested SQL patterns from real codebases.
322
+
323
+ ## Commands Overview
324
+
325
+ ### Setup & Status
326
+
327
+ ```bash
328
+ dora init # Initialize in repo
329
+ dora index # Index codebase
330
+ dora status # Show index health
331
+ dora map # High-level statistics
332
+ ```
333
+
334
+ ### Code Navigation
335
+
336
+ ```bash
337
+ dora ls [directory] # List files in directory with metadata
338
+ dora symbol <query> # Find symbols by name
339
+ dora file <path> # File info with dependencies
340
+ dora refs <symbol> # Find all references
341
+ dora deps <path> --depth 2 # Show dependencies
342
+ dora rdeps <path> --depth 2 # Show dependents
343
+ dora adventure <from> <to> # Find shortest path
344
+ ```
345
+
346
+ ### Documentation
347
+
348
+ ```bash
349
+ dora docs # List all documentation files
350
+ dora docs --type md # Filter by document type
351
+ dora docs search <query> # Search documentation content
352
+ dora docs show <path> # Show document details
353
+ ```
354
+
355
+ ### Architecture Analysis
356
+
357
+ ```bash
358
+ dora cycles # Find bidirectional dependencies
359
+ dora coupling --threshold 5 # Find tightly coupled files
360
+ dora complexity --sort complexity # High-impact files
361
+ dora treasure --limit 20 # Most referenced files
362
+ dora lost --limit 50 # Potentially dead code
363
+ dora leaves --max-dependents 3 # Leaf nodes
364
+ ```
365
+
366
+ ### Advanced Queries
367
+
368
+ ```bash
369
+ dora schema # Show database schema
370
+ dora cookbook show [recipe] # Show query pattern examples
371
+ dora query "<sql>" # Execute raw SQL (read-only)
372
+ dora changes <ref> # Changed/impacted files
373
+ dora exports <path|package> # List exports
374
+ dora imports <path> # Show imports
375
+ dora graph <path> # Dependency graph
376
+ ```
377
+
378
+ ## Command Reference
379
+
380
+ Quick reference for all commands with common flags:
381
+
382
+ ### Setup Commands
383
+
384
+ | Command | Description | Common Flags |
385
+ | ------------- | ----------------------------- | --------------------------------------------- |
386
+ | `dora init` | Initialize dora in repository | - |
387
+ | `dora index` | Build/update index | `--full`, `--skip-scip`, `--ignore <pattern>` |
388
+ | `dora status` | Check index status | - |
389
+ | `dora map` | High-level statistics | - |
390
+
391
+ ### Code Navigation
392
+
393
+ | Command | Description | Common Flags |
394
+ | ---------------------------- | ------------------------------ | ----------------------------- |
395
+ | `dora ls [directory]` | List files in directory | `--limit N`, `--sort <field>` |
396
+ | `dora file <path>` | Analyze file with dependencies | - |
397
+ | `dora symbol <query>` | Search for symbols | `--kind <type>`, `--limit N` |
398
+ | `dora refs <symbol>` | Find all references | - |
399
+ | `dora deps <path>` | Show dependencies | `--depth N` (default: 1) |
400
+ | `dora rdeps <path>` | Show reverse dependencies | `--depth N` (default: 1) |
401
+ | `dora adventure <from> <to>` | Find dependency path | - |
402
+
403
+ ### Documentation
404
+
405
+ | Command | Description | Common Flags |
406
+ | -------------------------- | ---------------------------- | ---------------------------------- |
407
+ | `dora docs` | List all documentation files | `--type <type>` (md, txt) |
408
+ | `dora docs search <query>` | Search documentation content | `--limit N` (default: 20) |
409
+ | `dora docs show <path>` | Show document metadata | `--content` (include full content) |
410
+
411
+ ### Architecture Analysis
412
+
413
+ | Command | Description | Common Flags |
414
+ | ----------------- | ------------------------------- | ---------------------------- |
415
+ | `dora cycles` | Find bidirectional dependencies | `--limit N` (default: 50) |
416
+ | `dora coupling` | Find tightly coupled files | `--threshold N` (default: 5) |
417
+ | `dora complexity` | Show complexity metrics | `--sort <metric>` |
418
+ | `dora treasure` | Most referenced files | `--limit N` (default: 10) |
419
+ | `dora lost` | Find unused symbols | `--limit N` (default: 50) |
420
+ | `dora leaves` | Find leaf nodes | `--max-dependents N` |
421
+
422
+ ### Advanced Commands
423
+
424
+ | Command | Description | Common Flags |
425
+ | ----------------------------- | --------------------------- | ------------------------------------------ |
426
+ | `dora schema` | Show database schema | - |
427
+ | `dora cookbook show [recipe]` | Query pattern cookbook | `quickstart`, `methods`, `refs`, `exports` |
428
+ | `dora query "<sql>"` | Execute raw SQL (read-only) | - |
429
+ | `dora changes <ref>` | Git impact analysis | - |
430
+ | `dora exports <target>` | List exported symbols | - |
431
+ | `dora imports <path>` | Show file imports | - |
432
+ | `dora graph <path>` | Dependency graph | `--depth N`, `--direction` |
433
+
434
+ ## SCIP Indexers
435
+
436
+ - [scip-typescript](https://github.com/sourcegraph/scip-typescript): TypeScript, JavaScript
437
+ - [scip-java](https://github.com/sourcegraph/scip-java): Java, Scala, Kotlin
438
+ - [rust-analyzer](https://github.com/rust-lang/rust-analyzer): Rust
439
+ - [scip-clang](https://github.com/sourcegraph/scip-clang): C++, C
440
+ - [scip-ruby](https://github.com/sourcegraph/scip-ruby): Ruby
441
+ - [scip-python](https://github.com/sourcegraph/scip-python): Python
442
+ - [scip-dotnet](https://github.com/sourcegraph/scip-dotnet): C#, Visual Basic
443
+ - [scip-dart](https://github.com/Workiva/scip-dart): Dart
444
+ - [scip-php](https://github.com/davidrjenni/scip-php): PHP
445
+
446
+ ## Output Format
447
+
448
+ All commands output valid JSON to stdout. Errors go to stderr with exit code 1.
449
+
450
+ ## Debug Logging
451
+
452
+ For debug logging, testing, building, and development instructions, see [CONTRIBUTING.md](./CONTRIBUTING.md).
453
+
454
+ ## Troubleshooting
455
+
456
+ ### Common Issues
457
+
458
+ | Issue | Solution |
459
+ | -------------------------- | ------------------------------------------------------------ |
460
+ | **Database not found** | Run `dora index` to create the database |
461
+ | **File not in index** | Check if file is in .gitignore, run `dora index` |
462
+ | **Stale results** | Run `dora index` to rebuild |
463
+ | **Slow queries** | Use `--depth 1` when possible, reduce `--limit` |
464
+ | **Symbol not found** | Ensure index is up to date: `dora status`, then `dora index` |
465
+ | **dora command not found** | Ensure dora is in PATH: `which dora`, reinstall if needed |
466
+
467
+ ### Integration Issues
468
+
469
+ **Claude Code index not updating:**
470
+
471
+ - Check `/tmp/dora-index.log` for errors
472
+ - Verify dora is in PATH: `which dora`
473
+ - Test manually: `dora index`
474
+ - Ensure `dora index` is in the `allow` permissions list in `.claude/settings.json`
475
+
476
+ **Stop hook not firing:**
477
+
478
+ - Verify `.claude/settings.json` syntax is correct (valid JSON)
479
+ - Check that the hook runs by viewing verbose logs
480
+ - Try manually running the hook command
481
+
482
+ **Want to see indexing progress:**
483
+
484
+ - Edit `.claude/settings.json` Stop hook
485
+ - Change command to: `"DEBUG=dora:* dora index 2>&1 || true"` (removes background `&`)
486
+ - You'll see progress after each turn, but will wait 15-30s
487
+
488
+ ### Performance Issues
489
+
490
+ **Index takes too long:**
491
+
492
+ - Run SCIP indexer separately if it supports caching
493
+ - Use background indexing mode in Claude Code integration
494
+ - Check if your SCIP indexer can be optimized
495
+
496
+ **Queries are slow:**
497
+
498
+ - Use `--depth 1` instead of deep traversals
499
+ - Reduce `--limit` for large result sets
500
+ - Ensure database indexes are created (automatic)
501
+ - Run `dora index` if database is corrupted
502
+
503
+ ## Contributing
504
+
505
+ Contributions are welcome! For development setup, testing, building binaries, and code style guidelines, see [CONTRIBUTING.md](./CONTRIBUTING.md).
506
+
507
+ Quick start:
508
+
509
+ 1. Fork the repository
510
+ 2. Create a feature branch
511
+ 3. Make your changes with tests (`bun test`)
512
+ 4. Submit a pull request
513
+
514
+ For detailed architecture and development guidelines, see [CLAUDE.md](./CLAUDE.md).
515
+
516
+ ## License
517
+
518
+ MIT
519
+
520
+ ## Links
521
+
522
+ - **AI Agent Integration**: [AGENTS.README.md](./AGENTS.README.md) - Integration guides for Claude Code, OpenCode, Cursor, Windsurf
523
+ - **GitHub**: [https://github.com/butttons/dora](https://github.com/butttons/dora)
524
+ - **SCIP Protocol**: [https://github.com/sourcegraph/scip](https://github.com/sourcegraph/scip)
525
+ - **Claude Code**: [https://claude.ai/code](https://claude.ai/code)