infiniloom 0.3.1

High-performance repository context generator for LLMs - Claude, GPT-4, Gemini optimized
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
<div align="center">

# ๐Ÿงต Infiniloom

**The fastest and most feature-rich way to pack repository context for LLMs**

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Rust](https://img.shields.io/badge/rust-1.91+-orange.svg)](https://www.rust-lang.org/)
[![Crates.io](https://img.shields.io/crates/v/infiniloom.svg)](https://crates.io/crates/infiniloom)

[Installation](#installation) โ€ข [Quick Start](#quick-start) โ€ข [Features](#features) โ€ข [Unique Features](#unique-features) โ€ข [Documentation](#documentation)

</div>

---

## What is Infiniloom?

Infiniloom transforms your codebase into optimized context for Large Language Models. It extracts code, symbols, and structure from repositories and outputs them in formats specifically optimized for Claude, GPT-4, Gemini, and other LLMs.

```bash
# Pack your repo for Claude in under a second
infiniloom pack . --format xml --output context.xml
```

**Why Infiniloom?**

- **Blazing Fast**: High-performance pure Rust architecture
- **Smart**: AST-based symbol extraction with PageRank importance ranking
- **Optimized**: Model-specific output formats (XML for Claude, Markdown for GPT)
- **Secure**: Automatic detection and redaction of secrets and API keys
- **Flexible**: Python and Node.js bindings included

---

## Installation

### Quick Install (Recommended)

```bash
# npm (easiest, works on macOS/Linux/Windows)
npm install -g infiniloom

# Homebrew Cask (macOS - fast, pre-built binary)
brew tap Topos-Labs/infiniloom
brew install --cask infiniloom

# Cargo (if you have Rust installed)
cargo install infiniloom
```

### All Installation Options

| Method | Command | Notes |
|--------|---------|-------|
| **npm** | `npm install -g infiniloom` | Easiest, cross-platform |
| **Homebrew Cask** | `brew install --cask infiniloom` | Fast, pre-built binary (macOS) |
| **Homebrew Formula** | `brew install infiniloom` | Builds from source, needs Rust |
| **Cargo** | `cargo install infiniloom` | Rust users |
| **pip** | `pip install infiniloom` | Python library |
| **npm library** | `npm install infiniloom-node` | Node.js library |

### From Source

```bash
# Clone and build
git clone https://github.com/Topos-Labs/infiniloom.git
cd infiniloom
cargo build --release

# Binary at ./target/release/infiniloom
```

Requires Rust 1.91+: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`

---

## Quick Start

### Basic Commands

```bash
# Pack repository into XML (optimized for Claude)
infiniloom pack /path/to/repo --format xml

# Scan repository and show statistics
infiniloom scan /path/to/repo

# Fast estimation for large repos via sampling
infiniloom scan /path/to/repo --sample 500
infiniloom scan /path/to/repo --sample-percent 1

# Generate repository map with key symbols
infiniloom map /path/to/repo --budget 2000

# Split large repo into chunks for multi-turn conversations
infiniloom chunk /path/to/repo --strategy semantic --max-tokens 8000

# Chunk with overlap for context continuity
infiniloom chunk /path/to/repo --overlap 500

# Priority ordering (core modules first)
infiniloom chunk /path/to/repo --priority-first

# Show repository information
infiniloom info /path/to/repo
```

### Output Formats

```bash
# XML format โ€” optimized for Claude (with prompt caching hints)
infiniloom pack . --format xml --model claude

# Markdown format โ€” optimized for GPT-4/GPT-4o
infiniloom pack . --format markdown --model gpt-4o

# TOON format โ€” most token-efficient (~40% smaller than JSON)
infiniloom pack . --format toon

# JSON format โ€” for programmatic use
infiniloom pack . --format json

# YAML format โ€” optimized for Gemini
infiniloom pack . --format yaml --model gemini
```

### Working with Git

```bash
# Include recent commits in output
infiniloom pack . --include-logs --logs-count 10

# Include uncommitted changes with diff content (+/- lines)
infiniloom pack . --include-diffs

# Pack a remote GitHub repository
infiniloom pack github:facebook/react
infiniloom pack https://github.com/tokio-rs/tokio.git
```

### Diff Context for AI Code Reviews

```bash
# Build symbol index for fast diff context
infiniloom index /path/to/repo

# Keep index fresh with watch mode
infiniloom index /path/to/repo --watch

# Get context for unstaged changes
infiniloom diff .

# Get context for staged changes
infiniloom diff . --staged

# Get context for a specific commit or range
infiniloom diff . HEAD~1
infiniloom diff . main..feature

# Options
infiniloom diff . --depth 2             # Context depth (1-3, default: 2)
infiniloom diff . --budget 50000        # Token budget limit
infiniloom diff . --include-diff        # Include actual diff content (+/- lines)
infiniloom diff . --format json         # Output format (xml/json/markdown)
infiniloom diff . --include-history     # Include recent commit history per file
infiniloom diff . --history-count 5     # Number of commits to include (default: 3)

# Analyze impact of changes to a file or symbol
infiniloom impact . src/auth.rs
infiniloom impact . --symbol "authenticate"
```

Note: `diff` and `impact` take the repository path first; any commit/range or target comes after the path.

The `--include-diff` flag embeds the actual git diff (+/- lines) within the semantic context, giving AI reviewers both WHAT changed and its surrounding context in one view.

The `--include-history` flag adds recent commit history for each changed file, showing when and why code was previously modified.

### File Selection

```bash
# Include only specific file types
infiniloom pack . --include "*.rs" --include "*.py"

# Exclude directories
infiniloom pack . --exclude "tests/*" --exclude "docs/*"

# Set token budget
infiniloom pack . --max-tokens 50000

# Limit to top N most important files (applied after ranking)
infiniloom pack . --top-files 50

# Use compression
infiniloom pack . --compression aggressive
```

### Watch Mode

```bash
# Continuously regenerate output when files change
infiniloom pack . --output context.xml --watch

# Watch mode respects all pack options (compression, security, etc.)
infiniloom pack . --output context.xml --watch \
  --compression aggressive --security-check --truncate-base64
```

### Pack Extras (Format-Safe)

```bash
# Add header/instructions and include token tree + security scan
infiniloom pack . --header-text "My header" \
  --instruction-file instructions.md --token-tree --security-check
```

- XML: extras are inserted inside `<repository>` as `<extras>...</extras>`
- JSON/YAML: extras are added as top-level fields (output remains valid)
- Markdown/Plain/TOON: header is prepended; other extras are appended as sections

### Copy to Clipboard (macOS)

```bash
# Pack and copy directly to clipboard for pasting into Claude/ChatGPT
infiniloom pack . --format xml | pbcopy
```

---

## Features

### Model-Specific Optimization

| Model | Format | Optimizations |
|-------|--------|---------------|
| **Claude** | XML | Prompt caching hints, CDATA sections, structured tags |
| **GPT-4/4o** | Markdown | Tables, code fences, hierarchical headers |
| **Gemini** | YAML | Query at end, hierarchical structure |
| **Any** | TOON | ~40% smaller than JSON, tabular metadata, minimal syntax |
| **JSON** | JSON | Full metadata, programmatic access |

### AST-Based Symbol Extraction

Infiniloom uses [Tree-sitter](https://tree-sitter.github.io/) to parse source code and extract symbols from **21 languages**:

| Language | Symbols Extracted |
|----------|-------------------|
| Python | Functions, Classes, Methods, Decorators |
| JavaScript/TypeScript | Functions, Classes, Interfaces, Types |
| Rust | Functions, Structs, Enums, Traits, Impl blocks |
| Go | Functions, Methods, Structs, Interfaces |
| Java | Classes, Interfaces, Methods, Enums |
| C/C++ | Functions, Structs, Classes |
| C# | Classes, Methods, Interfaces, Properties |
| Ruby | Classes, Modules, Methods |
| PHP | Classes, Functions, Methods |
| Kotlin | Classes, Functions, Interfaces |
| Swift | Classes, Structs, Functions, Protocols |
| Scala | Classes, Objects, Traits, Functions |
| Haskell | Functions, Types, Data, Typeclasses |
| Elixir | Modules, Functions, Macros |
| Clojure | Functions, Macros, Vars |
| OCaml | Functions, Modules, Types |
| Lua | Functions, Tables |
| R | Functions, Classes |
| Bash | Functions |

### PageRank Symbol Ranking

Important symbols are ranked using PageRank algorithm based on:
- Reference count (how often a symbol is used)
- Import centrality (position in dependency graph)
- File importance (entry points, main modules)

### Security Scanning

Automatically detects and redacts:
- API keys and tokens
- Passwords and secrets
- Private keys (RSA, SSH)
- Database connection strings
- Cloud credentials (AWS, GCP, Azure)

**Note**: Comment lines (starting with `//`, `#`, `/*`, etc.) are automatically skipped to reduce false positives from example code and documentation.

### Compression Levels

| Level | Token Reduction | What's Removed |
|-------|-----------------|----------------|
| `none` | 0% | Nothing |
| `minimal` | 10-20% | Empty lines, trailing whitespace |
| `balanced` | 30-40% | Comments, redundant whitespace |
| `aggressive` | 50-60% | Docstrings, inline comments |
| `extreme` | 70-80% | Everything except signatures |

---

## Language Bindings

### Python

```bash
cd bindings/python
pip install maturin
maturin develop
```

```python
import infiniloom

# Pack a repository
context = infiniloom.pack("/path/to/repo", format="xml", model="claude")

# Get repository statistics
stats = infiniloom.scan("/path/to/repo")
print(f"Files: {stats['total_files']}, Tokens: {stats['total_tokens']}")

# Count tokens
tokens = infiniloom.count_tokens("def hello(): pass", model="claude")
```

### Node.js

```bash
cd bindings/node
npm install
npm run build
```

```javascript
const { pack, scan, Infiniloom } = require('@infiniloom/node');

// Pack a repository
const context = pack('./my-repo', { format: 'xml', model: 'claude' });

// Get statistics
const stats = scan('./my-repo');
console.log(`Files: ${stats.total_files}`);
```

---

## Performance

Infiniloom is designed for speed and efficiency, significantly outperforming existing solutions through its pure Rust architecture. Typical processing times for medium-sized repositories (100-500 files) are under 100ms.

---

## Unique Features

Infiniloom offers capabilities not found in other repository packing tools:

### Repository Map Generation

Generate a concise map of your codebase showing the most important symbols, ranked by importance:

```bash
infiniloom map /path/to/repo --budget 2000
```

The map uses PageRank algorithm to identify key entry points, heavily-used functions, and central abstractions โ€” giving LLMs a bird's-eye view of your architecture.

Map output sections:
- Summary (repo stats, primary language, key modules)
- Key symbols (ranked list with file + line)
- Module graph (directory dependencies)
- File index (top files by importance)

### Intelligent Token Budgeting

Set a token budget and Infiniloom will intelligently select the most relevant files:

```bash
infiniloom pack . --budget 50000
```

Files are prioritized based on:
- Symbol importance (PageRank scores)
- File centrality in the dependency graph
- Recent modification time
- Configuration file detection (package.json, Cargo.toml, etc.)

### Multi-Model Token Counting

Accurate token counts for 20+ LLM models:

```bash
# OpenAI models (exact tokenization via tiktoken)
infiniloom scan . --model gpt52      # GPT-5.2 (o200k_base)
infiniloom scan . --model gpt51      # GPT-5.1 (o200k_base)
infiniloom scan . --model gpt5       # GPT-5 (o200k_base)
infiniloom scan . --model o3         # O3 reasoning model
infiniloom scan . --model o1         # O1 reasoning model
infiniloom scan . --model gpt4o      # GPT-4o (o200k_base)
infiniloom scan . --model gpt4       # GPT-4 (cl100k_base, legacy)

# Other vendors (calibrated estimation)
infiniloom scan . --model claude     # Anthropic Claude (default)
infiniloom scan . --model gemini     # Google Gemini
infiniloom scan . --model llama      # Meta Llama 3/4
infiniloom scan . --model mistral    # Mistral AI
infiniloom scan . --model deepseek   # DeepSeek V3/R1
infiniloom scan . --model qwen       # Alibaba Qwen
infiniloom scan . --model cohere     # Cohere Command R+
infiniloom scan . --model grok       # xAI Grok
```

### Secret Detection & Redaction

Automatically scans for and redacts sensitive information before output:

- AWS access keys and secrets
- GitHub tokens (classic and fine-grained PATs)
- Private keys (RSA, EC, DSA, OPENSSH)
- API keys and generic secrets
- Database connection strings (MongoDB, PostgreSQL, MySQL, Redis)
- JWT tokens
- Slack and Stripe tokens
- Custom patterns via configuration

```bash
infiniloom pack .                   # No scanning (fast, for trusted code)
infiniloom pack . --security-check  # Scan and report findings in metadata
infiniloom pack . --redact-secrets  # Scan and redact secrets with [REDACTED]
```

**Note**: With a config file (from `infiniloom init`), scanning is enabled by default.

**Security configuration options:**
- `fail_on_secrets`: Exit with error if secrets are detected (CI/CD integration)
- `allowlist`: Patterns to exclude from detection
- `custom_patterns`: Additional regex patterns for company-specific secrets

### Native Language Bindings

Use Infiniloom directly in your applications โ€” no shell commands needed:

- **Python**: PyO3-based native extension
- **Node.js**: NAPI-RS bindings with TypeScript types

---

## Configuration

### `.infiniloomignore`

Create a `.infiniloomignore` file to exclude files (in addition to `.gitignore`):

```gitignore
# Build artifacts
target/
dist/
build/

# Dependencies
node_modules/
vendor/

# Large files
*.bin
*.dat
data/

# Generated
*.generated.*
```

### Environment Variables

Environment variables use double underscore (`__`) to separate nested config keys:

| Variable | Description | Default |
|----------|-------------|---------|
| `INFINILOOM_OUTPUT__MODEL` | Default tokenizer model | `claude` |
| `INFINILOOM_OUTPUT__FORMAT` | Default output format | `xml` |
| `INFINILOOM_OUTPUT__COMPRESSION` | Default compression | `balanced` |
| `INFINILOOM_OUTPUT__TOKEN_BUDGET` | Default token budget | `0` (no limit) |
| `INFINILOOM_SCAN__INCLUDE_HIDDEN` | Include hidden files | `false` |
| `INFINILOOM_SCAN__RESPECT_GITIGNORE` | Respect .gitignore | `true` |
| `INFINILOOM_SECURITY__SCAN_SECRETS` | Enable secret scanning | `false` |
| `INFINILOOM_SECURITY__REDACT_SECRETS` | Redact detected secrets | `true` |

**Note**: CLI default for `--max-tokens` is 0 (no limit). Config files can override this.

### Configuration File

Run `infiniloom init` to create a configuration file. Supports YAML, TOML, and JSON:

```bash
infiniloom init                    # Creates .infiniloom.yaml
infiniloom init --format toml      # Creates .infiniloom.toml
infiniloom init --format json      # Creates .infiniloom.json
infiniloom init --template rust    # Pre-configured for Rust projects
infiniloom init --template python  # Pre-configured for Python projects
infiniloom init --template typescript  # Pre-configured for TypeScript projects
```

Example `.infiniloom.yaml`:

```yaml
output:
  format: xml
  model: claude
  compression: balanced
  token_budget: 100000
  line_numbers: true
  show_file_summary: true

scan:
  include:
    - "*.rs"
    - "*.py"
    - "*.ts"
  exclude:
    - "tests/*"
    - "docs/*"
    - "*.test.*"

security:
  scan_secrets: true           # Enable secret scanning
  fail_on_secrets: false       # Exit with error if secrets found
  redact_secrets: true         # Replace detected secrets with [REDACTED]
  allowlist:                   # Patterns to ignore (won't be flagged)
    - "EXAMPLE"
    - "test_key"
  custom_patterns:             # Additional regex patterns to detect
    - "MY_SECRET_[A-Z0-9]{32}"
    - "CUSTOM_TOKEN_\\w+"
```

Both flat and nested formats are supported for backward compatibility:

```yaml
# Flat format (also works)
include:
  - "*.rs"
exclude:
  - "tests/*"
include_tests: false
include_docs: false
```

---

## Documentation

| Document | Description |
|----------|-------------|
| [Architecture](docs/INFINILOOM_DESIGN.md) | System design and architecture |
| [Output Formats](docs/INFINILOOM_OUTPUT_FORMATS.md) | Detailed format specifications |
| [Release Plan](docs/RELEASE_PLAN.md) | Publishing and distribution |

---

## Development

### Project Structure

```
infiniloom/
โ”œโ”€โ”€ cli/                 # Rust CLI application
โ”œโ”€โ”€ engine/              # Core Rust engine
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ parser.rs    # Tree-sitter AST parsing
โ”‚   โ”‚   โ”œโ”€โ”€ repomap/     # PageRank symbol ranking
โ”‚   โ”‚   โ”œโ”€โ”€ output/      # Format generators
โ”‚   โ”‚   โ””โ”€โ”€ security.rs  # Secret detection
โ”œโ”€โ”€ bindings/
โ”‚   โ”œโ”€โ”€ python/          # PyO3 bindings
โ”‚   โ””โ”€โ”€ node/            # NAPI-RS bindings
โ””โ”€โ”€ docs/                # Documentation
```

### Building

```bash
# Build everything
cargo build --release

# Run tests
cargo test

# Run clippy
cargo clippy

# Run benchmarks
cargo bench
```

### Running Tests

```bash
# All tests
cargo test --all

# Specific crate
cargo test -p infiniloom-engine

# With output
cargo test -- --nocapture
```

---

## Contributing

Contributions are welcome! Please:

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing`)
3. Make your changes
4. Run tests (`cargo test`) and lints (`cargo clippy`)
5. Commit with clear messages
6. Push and open a Pull Request

See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.

---

## License

MIT License โ€” see [LICENSE](LICENSE) for details.

---

## Acknowledgments

- [Tree-sitter]https://tree-sitter.github.io/ for fast, reliable parsing
- [tiktoken-rs]https://github.com/zurawiki/tiktoken-rs for token counting
- [Aider]https://github.com/paul-gauthier/aider for the repo-map concept

### Alternatives & Inspiration

These projects inspired Infiniloom and are great alternatives:

- [repomix]https://github.com/yamadashy/repomix โ€” Node.js-based repository packer
- [gitingest]https://github.com/cyclotruc/gitingest โ€” Python-based repository ingestion tool

---

<div align="center">

**[โฌ† Back to Top](#-infiniloom)**

Made with ๐Ÿงต by [Topos Labs](https://github.com/Topos-Labs)

</div>