infigraph-cli 1.0.0

CLI for infigraph — AST-powered code analysis and impact review
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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
# Infigraph

AST-powered code intelligence engine. Indexes codebases into a persistent knowledge graph with full Cypher queries, hybrid semantic search, cross-file call resolution, and **62 programming languages**.

Built in Rust. Zero LLM dependency. Runs locally.

## Key Highlights
- **62 Languages:** Tree-sitter parsing for 62 languages + ANTLR grammar plugins for custom DSLs. Zero config.
- **Graph Database:** Full Cypher queries on your codebase — WITH, OPTIONAL MATCH, variable-length paths.
- **Semantic Search:** BM25 + Model2Vec hybrid search. Finds "retry logic" even if the function isn't named retry.
- **SCIP Integration:** Auto-downloads compiler-grade indexers (TypeScript, Python, Java, Go, Rust, C#, Ruby, Scala). Falls back to lsp-to-scip bridge for 14+ more languages.
- **Cross-File Resolution:** Import-aware call resolution links function calls to actual definitions across files.
- **HTTP Route-Aware:** Maps your API surface across 22 frameworks (Flask, Express, Spring, Actix, Phoenix, Rails, etc.).
- **Multi-Repo/Microservice:** Group repos, cross-repo Cypher queries, HTTP contract extraction, cross-service dependency detection.
- **PR Review & CI:** Symbol-level diff review with optional LLM enrichment. Configurable CI check gates (security, complexity, dead code, vulns).
- **OSV Vulnerability Scanning:** Scans dependencies against the OSV database for known vulnerabilities.
- **Design Pattern Detection:** Identifies Singleton, Factory, Observer, Strategy, Builder, and other patterns.
- **Refactor Analysis:** Complexity hotspots, coupling, near-duplicate detection, dead code — ranked by impact/effort.
- **Document Indexing:** Index PDF, DOCX, PPTX, HTML, Markdown with hybrid search.
- **Confluence Wiki Crawler:** BFS wiki crawl with incremental sync — indexes pages into the same search pipeline as code.
- **Auto-Watch:** File watcher auto-starts after indexing. Index stays fresh without manual intervention.
- **HNSW Vector Index:** Approximate nearest neighbor search for fast similarity queries at scale (~2ms for 500K symbols).
- **Session Continuity:** Persists context across AI agent sessions — summary, pending tasks, decisions, touched files.
- **74 MCP Tools:** Full AI agent integration for 11 coding agents (Claude Code, Cursor, VS Code, Copilot, Windsurf, etc.).
- **Sequence Diagrams:** Auto-generates Mermaid sequence diagrams from call graphs.
- **Cross-Language Detection:** Delphi↔COM, VB6↔COM, C#↔JNI, FFI, gRPC, WASM bridges.
- **Grammar Plugins:** Drop `.g4` + `plugin.toml` — parse any custom/internal DSL without Rust compilation.
- **Pipeline Plugins:** Runtime-extensible pipeline metadata extraction — add new data pipeline formats (dbt, Airflow, custom) without recompiling. Dependency graphs, impact analysis, compliance queries.
- **Web UI:** Built-in graph explorer, search, route map at localhost:9749.
- **Export:** Neo4j Cypher, GraphML, JSON — take your graph anywhere.

## Install

### macOS / Linux

```bash
curl -fsSL https://raw.githubusercontent.com/intuit/infigraph/main/install.sh | bash
```

This:
- Downloads pre-built binaries from GitHub releases (if available)
- Falls back to cloning + `cargo build --release` (installs Rust if needed)
- Adds `infigraph`, `infigraph-mcp`, and `lsp-to-scip` to `~/.local/bin`
- Registers MCP server for all 11 AI coding agents
- Writes primary search instructions to `~/.claude/CLAUDE.md`

> **System dependency:** `cmake` is required to build the graph database.
> Install before building: `brew install cmake` (macOS) or `sudo apt install cmake` (Linux).

### Windows

Run this single command from **PowerShell**:

```powershell
iwr https://raw.githubusercontent.com/intuit/infigraph/main/install.ps1 -UseBasicParsing | iex
```

This downloads and runs the full installer — which fetches the pre-built binary and registers the MCP server.

## Update

Re-run the installer to pull latest and rebuild:

```bash
curl -fsSL https://raw.githubusercontent.com/intuit/infigraph/main/install.sh | bash
```

Or if building manually:

```bash
cd /path/to/infigraph && git pull && cargo build --release
infigraph update
```

`infigraph update` re-registers MCP server paths and refreshes CLAUDE.md instructions.

Infigraph also checks for updates in the background (once per 24h) and prints a hint when a newer version is available.

## Uninstall

```bash
infigraph uninstall
```

Removes:
- MCP server config from all 11 AI agents
- Primary search instructions from `~/.claude/CLAUDE.md`

Does NOT delete the binary — remove `~/.local/bin/infigraph` and `~/.local/bin/infigraph-mcp` manually if desired.

## How to Use

Infigraph is designed to be used through AI coding agents (Claude Code, Cursor, Copilot, etc.) rather than directly from the CLI. After install, the MCP server provides 69 tools that any AI agent can call.

### With Claude Code (recommended)

```
# Just start working — Infigraph indexes on first query
> Ask Claude: "search for authentication logic in this project"
> Ask Claude: "who calls the validate_user function?"
> Ask Claude: "show me the architecture of this codebase"
> Ask Claude: "find dead code"
> Ask Claude: "what's the blast radius if I change this function?"
```

Claude Code auto-indexes the project on first use. No manual `infigraph index` needed. A file watcher starts automatically after indexing to keep the graph in sync with code changes.

### With other AI agents

Any agent with MCP support (Cursor, VS Code + Copilot, Windsurf, etc.) can use Infigraph tools after `infigraph install`. The agent calls `index_project` automatically when needed.

### Manual CLI (optional)

```bash
cd /path/to/project
infigraph index              # Index the project
infigraph search "auth"      # Hybrid search
infigraph query "MATCH ..."  # Cypher query
infigraph routes             # HTTP endpoints
infigraph dead-code          # Unused functions
```

## Grammar Plugins (ANTLR)

Infigraph supports runtime-loaded ANTLR grammar plugins. Drop `.g4` grammar files + a `plugin.toml` config into a directory — infigraph parses the language automatically via a JVM subprocess. **No Rust compilation needed.**

### Quick start: adding a new language

1. Create a grammar plugin directory:
   ```
   ~/.infigraph/grammars/my-lang/
   ├── MyLang_Lexer.g4      # ANTLR lexer grammar
   ├── MyLang_Parser.g4     # ANTLR parser grammar
   └── plugin.toml          # Extension mapping + extraction rules
   ```

2. Write `plugin.toml`:
   ```toml
   [language]
   name = "my-lang"
   extensions = [".ml", ".myl"]
   entry_rule = "program"
   lexer = "MyLang_Lexer.g4"
   parser = "MyLang_Parser.g4"
   strip_preprocessor = false   # true if files have #include/#ifdef lines

   [[entities]]
   rule = "functionDecl"        # ANTLR parser rule name
   kind = "Function"            # Symbol kind (Function, Method, Class, Variable, etc.)
   name_child = "identifier"    # Child rule that holds the name
   scope = true                 # Creates a scope (section/function boundary)

   [[entities]]
   rule = "classDecl"
   kind = "Class"
   name_child = "identifier"
   scope = true

   [[relations]]
   rule = "functionCall"
   kind = "Calls"
   target_child = "identifier"

   [[relations]]
   rule = "fieldAccess"
   kind = "Reads"
   target_child = "fieldName"
   condition = "has_token:."    # Only match when DOT token is present
   ```

3. Index your project — infigraph discovers the plugin automatically:
   ```bash
   infigraph -r /path/to/project index
   ```

### Plugin discovery

Plugins are loaded from two locations:
- `~/.infigraph/grammars/*/plugin.toml` — user-level (all projects)
- `<project>/grammars/*/plugin.toml` — project-level (per repo)

Project-level plugins take precedence.

### Requirements

- **Java 11+** — the ANTLR interpreter runs in a JVM subprocess
- **No Rust toolchain needed** — grammar plugins are pure config + `.g4` files

### How it works

```
plugin.toml + .g4 files
┌─────────────────┐     stdin/stdout JSON     ┌──────────────────┐
│  Rust host       │ ◄──────────────────────► │  JVM subprocess   │
│  (infigraph)     │                          │  (ANTLR interp.)  │
│                  │  1. Load grammar          │                   │
│  Discovers       │  2. Parse file            │  Grammar.load()   │
│  plugin.toml     │  3. Get parse tree JSON   │  ParserInterpreter│
│  Walks tree      │                          │                   │
│  → Symbol/Rel    │                          │                   │
└─────────────────┘                          └──────────────────┘
```

1. **Startup**: infigraph scans plugin directories, spawns a single persistent JVM process
2. **Load**: sends `.g4` grammar paths to the JVM driver, which loads them in ANTLR interpreter mode
3. **Parse**: for each source file, sends content to JVM, receives JSON parse tree
4. **Extract**: Rust walks the JSON parse tree using `plugin.toml` entity/relation rules, produces `Symbol` + `Relation` objects
5. **Graph**: extracted data flows into the same graph/search/analysis pipeline as all other languages

### Grammar imports

If your grammar uses `import` (e.g., `import Base_Lexer;`), place the imported `.g4` file in the same plugin directory. ANTLR resolves imports from the grammar file's directory.

### Extraction rule reference

#### Entity mappings (`[[entities]]`)

| Field | Required | Description |
|-------|----------|-------------|
| `rule` | yes | ANTLR parser rule name to match |
| `kind` | yes | `Function`, `Method`, `Class`, `Struct`, `Variable`, `Constant`, `Section`, `Module`, `Field`, `Test`, `Route` |
| `name_child` | yes | Child rule that holds the entity name |
| `scope` | no | If `true`, pushes a scope (nested symbols get `parent::name` IDs) |

#### Relation mappings (`[[relations]]`)

| Field | Required | Description |
|-------|----------|-------------|
| `rule` | yes | ANTLR parser rule name to match |
| `kind` | yes | `Calls`, `Imports`, `Reads`, `Writes`, `Inherits`, `Implements`, `Contains` |
| `target_child` | yes | Child rule that holds the target name |
| `condition` | no | `has_child:RULE`, `has_token:TEXT` — only match when condition is true |

### Performance

Grammar plugins use the ANTLR interpreter (no code generation). Slower than native tree-sitter but requires zero compilation:

| Metric | Value |
|--------|-------|
| JVM cold start + grammar load | ~450ms (once) |
| Per-file parse (100 lines) | ~90ms |
| Per-file parse (500 lines) | ~770ms |
| 55-file batch | ~18s (324ms/file avg) |

The JVM stays alive for the duration of the infigraph session — subsequent parses only pay the per-file cost.

### Architecture: tree-sitter vs grammar plugins

| | Tree-sitter | Grammar Plugin |
|---|---|---|
| Grammar format | `.scm` queries | `.g4` grammars |
| Runtime | Native (compiled C) | JVM subprocess (ANTLR interpreter) |
| Adding a language | Write `.scm` query files | Drop `.g4` + `plugin.toml` |
| Compilation needed | No (queries are text) | No (interpreter mode) |
| Performance | ~1ms/file | ~100-800ms/file |
| Best for | Mainstream languages | Custom/internal DSLs |

Both backends produce the same `Symbol` + `Relation` output. Everything downstream (graph, search, analysis, MCP tools) is backend-agnostic.

## Pipeline Plugins

Infigraph supports runtime-loaded pipeline plugins for extracting data pipeline metadata from documents (e.g. Confluence design docs). Each plugin is a subprocess that communicates via JSON over stdin/stdout — no recompilation needed to add new pipeline formats.

### How it works

1. Plugin is a directory with `plugin.toml` + an extractor binary/script
2. Infigraph discovers plugins at startup from two locations:
   - `~/.infigraph/pipelines/*/plugin.toml` — user-level (all projects)
   - `<project>/pipelines/*/plugin.toml` — project-level (per repo)
3. When a document is indexed, infigraph tries each plugin's `detect_patterns` against the content
4. Matching plugin's extractor subprocess receives the document, returns structured pipeline metadata
5. Metadata is stored in the graph DB: `PipelineCore` shared table + plugin-specific detail table

### Directory structure

```
pipelines/
  my-plugin/
    plugin.toml              # Plugin manifest (schema, command, detection patterns)
```

### plugin.toml format

```toml
[plugin]
name = "My Pipeline Format"
plugin_id = "myformat"                        # lowercase, used as table suffix
command = ["infigraph-pipeline-extractor"]     # any executable that speaks the JSON protocol
detect_patterns = ["## Source Systems", "## Scheduler"]  # regex patterns for auto-detection

# Per-plugin table columns (creates Pipeline_myformat node table)
[[plugin.schema]]
name = "scheduler_type"
col_type = "STRING"    # STRING | INT64 | BOOL | DOUBLE | STRING[]

[[plugin.schema]]
name = "compliance"
col_type = "STRING"

[plugin.dependency_fields]
inputs = "core.inputs"
outputs = "core.outputs"
```

### JSON IPC protocol

**Startup:** Plugin writes `{"ready": true, "plugin_id": "myformat", "version": "1.0"}`

**Extract command** (infigraph → plugin stdin):
```json
{"command": "extract", "content": "...", "title": "My Pipeline", "doc_id": "doc::123"}
```

**Response** (plugin stdout):
```json
{
  "status": "ok",
  "data": {
    "core": {"name": "My Pipeline", "inputs": ["src.table_a"], "outputs": ["dm.table_b"]},
    "properties": {"scheduler_type": "Airflow", "compliance": "SOX"}
  }
}
```

Or `{"status": "skip"}` if the document doesn't match this plugin's format.

### Schema: shared core + per-plugin tables

All plugins share a `PipelineCore` table for cross-plugin dependency linking:

```
PipelineCore: id, name, doc_id, plugin_id, inputs[], outputs[]
```

Each plugin gets its own detail table (e.g. `Pipeline_myformat`) for format-specific fields. Cross-plugin queries (impact analysis, dependency graphs) use `PipelineCore.inputs/outputs`.

### Built-in extractor

Infigraph ships `infigraph-pipeline-extractor` — a reference implementation that extracts pipeline metadata from Confluence-style design documents with sections like Source Systems, Destination Tables, Scheduler, Compliance, DACI, etc. It ships as a compiled Rust binary with zero runtime dependencies.

### MCP tools

| Tool | Description |
|------|-------------|
| `pipeline_plugins` | List loaded pipeline plugins |
| `pipeline_deps` | Show pipeline dependency graph |
| `pipeline_impact` | Transitive impact analysis for a table/dataset |
| `pipeline_compliance` | Query pipelines by compliance scope |
| `pipeline_query` | Generic query against plugin-specific fields |

### Writing a custom plugin

1. Create `~/.infigraph/pipelines/my-plugin/plugin.toml`
2. Define your schema columns and detection patterns
3. Implement an extractor (any language) that reads JSON from stdin, writes JSON to stdout
4. Test: `echo '{"command":"extract","content":"...","title":"Test","doc_id":"test::1"}' | ./my-extractor`

## Building from Source

### Prerequisites

| Platform | Required |
|----------|---------|
| macOS | `brew install cmake`, Rust (`rustup`) |
| Linux | `sudo apt install cmake`, Rust (`rustup`) |
| Windows | Rust (`rustup`), Docker (for cross-compilation) |

### macOS (native — ARM64 or x86_64)

```bash
brew install cmake
git clone https://github.com/intuit/infigraph.git
cd infigraph
cargo build --release -p infigraph-cli -p infigraph-mcp
cp target/release/infigraph target/release/infigraph-mcp ~/.local/bin/
infigraph install
```

### Linux (x86_64 or ARM64)

```bash
sudo apt update && sudo apt install -y cmake
git clone https://github.com/intuit/infigraph.git
cd infigraph
cargo build --release -p infigraph-cli -p infigraph-mcp
cp target/release/infigraph target/release/infigraph-mcp ~/.local/bin/
infigraph install
```

### Windows (native build)

Build natively on a Windows machine. **Cross-compiling from macOS is not currently supported** — LadybugDB (lbug) requires C++20 `<format>` (GCC 13+), but available cross-compilation Docker images ship GCC 9.

```powershell
# Install Rust
winget install Rustlang.Rustup

# Install CMake (required by lbug graph DB)
winget install Kitware.CMake

# Install Visual Studio Build Tools with C++ workload
winget install Microsoft.VisualStudio.2022.BuildTools

# Clone and build
git clone https://github.com/intuit/infigraph.git
cd infigraph
cargo build --release -p infigraph-cli -p infigraph-mcp

# Binaries at:
#   target\release\infigraph.exe
#   target\release\infigraph-mcp.exe
```

### Cross-compiling macOS targets on ARM64 machine

```bash
# Add Intel target
rustup target add x86_64-apple-darwin

# Build for Intel Mac (from ARM64 machine)
cargo build --release --target x86_64-apple-darwin -p infigraph-cli -p infigraph-mcp
```

### Releasing a new version (maintainers)

The `release.sh` script builds, signs, packages with the bundled model, and uploads to GHE releases:

```bash
./release.sh v1.0.0
```

What it does:
1. Builds `aarch64-apple-darwin` targets (Intel commented out — add when needed)
2. Ad-hoc signs both binaries with `codesign --sign -` (no Apple Developer cert required)
3. Packages `infigraph`, `infigraph-mcp`, and `models/` into `infigraph-<target>.tar.gz`
4. Creates a GitHub release at `github.com/intuit/infigraph` and uploads the archive

**Requirements:** `gh` CLI authenticated with `github.com`, `cmake`, Rust toolchain

## Setup as Primary Search

After install, register Infigraph as the primary search engine for all AI coding agents:

```bash
infigraph install
```

This does four things:
1. **Registers `infigraph-mcp`** as an MCP server for 11 agents: Claude Code, Cursor, VS Code, Codex, Gemini CLI, Zed, OpenCode, Aider, Windsurf, Kiro, GitHub Copilot
2. **Writes primary search instructions** to `~/.claude/CLAUDE.md` so AI agents prefer Infigraph over raw grep/glob
3. **Installs Claude Code hooks** — enforcement hook (warns on raw search) + session save hooks (auto-save context on compaction)
4. **Configures Claude Code allowlist** — adds all Infigraph MCP tools to `~/.claude/settings.local.json` permissions

Then index your projects:
```bash
cd /path/to/project
infigraph index
# Full reindex (clean rebuild from scratch):
infigraph index --full
```

Every search, symbol lookup, and code navigation now goes through Infigraph's graph — saving 60-80% of tokens versus raw file reads.

## Web UI

Infigraph includes a built-in web UI for visual code exploration.

**It starts automatically** when the MCP server launches — open it at:

```
http://localhost:9749/?path=/your/project
```

The UI is served by the same `infigraph-mcp` process Claude Code spawns. No separate process needed.

**Multiple Claude sessions:** the first session to start binds port 9749 and serves the UI. All subsequent sessions skip the port bind silently and still get full MCP tool access. The UI stays up as long as at least one session is open.

**From Claude:** ask Claude to open the UI — it can launch a browser or give you the URL for your indexed project.

## Troubleshooting

### MCP tools not available in Claude Code

**Symptom:** `mcp__infigraph__*` tools appear as "deferred" in ToolSearch but aren't active, or Claude says Infigraph isn't loaded.

**Most common cause:** A project-level `.claude/settings.json` with an `mcpServers` block overrides the global `~/.claude/settings.json` where `infigraph install` wrote its config. Claude Code merges settings but project-level `mcpServers` takes precedence.

**Fix:** Run `infigraph install` from inside the project directory — or manually add the infigraph entry to the project's `.claude/settings.json`:

```json
{
  "mcpServers": {
    "infigraph": {
      "command": "/path/to/infigraph-mcp",
      "args": ["--ui", "--mcp", "--port=9749"]
    }
  }
}
```

Replace `/path/to/infigraph-mcp` with the output of `which infigraph-mcp`.

**Other causes:**
- Binary not found: verify `which infigraph-mcp` returns a path
- `infigraph install` failed silently during setup: re-run it manually and check for errors
- Invalid JSON in existing `settings.json`: fix the JSON, then re-run `infigraph install`

## Features

### Core
- **62 languages** — see full list below
- **LadybugDB graph database** — columnar embedded graph DB (Kuzu successor), full Cypher including WITH, OPTIONAL MATCH, variable-length paths, mutations
- **Hybrid search** — BM25 text ranking + Model2Vec neural embeddings (bundled, no network) with tunable alpha
- **HNSW vector index** — approximate nearest neighbor search for fast similarity queries at scale (~2ms for 500K symbols)
- **Embedding cache** — vectors saved to `.infigraph/embeddings.bin`, loaded on next search (first index = cache, subsequent = instant)
- **Cross-file call resolution** — import-aware resolution links function calls to actual definitions across files
- **Auto-watch** — file watcher auto-starts after indexing, keeps graph in sync via OS filesystem events with 500ms debounce
- **Session continuity** — persists session context (summary, pending tasks, decisions, touched files) across AI agent sessions
- **Docstring extraction** — captures docstrings/comments from AST, indexed for richer search
- **Function signatures** — extracts parameter lists and return types from AST for richer embeddings and search
- **Louvain community detection** — discovers functional modules/clusters in the call graph
- **Multi-repo groups** — group microservice repos, cross-repo Cypher queries, HTTP contracts, cross-service dependency detection
- **Custom edge types** — extensible relation system: language plugins can define custom edges (DECORATED_BY, SPAWNS, etc.) that persist in the graph
- **Gitignore-aware** — respects `.gitignore` and `.infigraphignore` patterns during indexing via the `ignore` crate
- **Learned resolution** — records successful cross-file call resolutions to improve accuracy on subsequent indexes

### Analysis
- **Refactor analysis** — complexity hotspots, coupling (fan-in/fan-out), near-duplicate detection, dead code, file size — ranked by impact/effort
- **PR review** — symbol-level diff review with optional LLM enrichment (Anthropic API), cross-repo blast radius
- **CI check runner** — configurable checks (security, complexity, dead code, vuln scan) with pass/fail gates
- **OSV vulnerability scanning** — scans dependencies against the OSV database for known vulnerabilities
- **Design pattern detection** — identifies Singleton, Factory, Observer, Strategy, Builder, and other patterns
- Dead code detection (uncalled functions/methods)
- Transitive impact / blast radius analysis
- Git diff → affected symbols mapping
- Architecture overview (language breakdown, hotspots, hub functions, entry points)
- HTTP route/endpoint detection across 22 languages (Flask, Express, Spring, Django, Gin, Actix, Phoenix, Rails, NestJS, and more)
- Cross-service HTTP dependency detection (`group deps`) — scans URL strings, matches to contracts across repos
- Bridge-to-call promotion — promotes detected cross-language bridges to CALLS edges for unified call graph analysis

### SCIP Integration (Compiler-grade Enrichment)
Infigraph natively imports [SCIP](https://sourcegraph.com/blog/announcing-scip) indexes to enrich the graph with precise compiler-grade symbols, types, and cross-file relationships. SCIP indexers are **auto-downloaded** — `infigraph index` detects project languages and fetches the right indexer binaries (with portable runtimes for Node.js, JRE, .NET, Dart, PHP) on first use:

```bash
# Generate SCIP index with an existing indexer
scip-typescript index --cwd .          # TypeScript/JavaScript
scip-python index --cwd .              # Python
scip-java index                        # Java/Kotlin
scip-go --cwd .                        # Go
# Then import into Infigraph
infigraph scip-import --index index.scip
```

**Languages with dedicated SCIP indexers:** TypeScript, JavaScript, Python, Java, Kotlin, Go, Rust (rust-analyzer), C# (scip-dotnet), Ruby (scip-ruby), Scala

**Languages via lsp-to-scip bridge:** C/C++, Zig, Swift, Dart, Elixir, PHP, Lua, Haskell, F#, Clojure, Erlang, Perl, OCaml, and any language with an LSP server

#### lsp-to-scip Bridge

Generic tool that spawns any LSP server and generates `index.scip`:

```bash
# C/C++ via clangd
lsp-to-scip --server clangd --root /path/to/project --lang cpp

# Zig via zls
lsp-to-scip --server zls --root . --lang zig

# Swift via sourcekit-lsp
lsp-to-scip --server sourcekit-lsp --root . --lang swift

# Elixir via elixir-ls
lsp-to-scip --server "elixir-ls" --root . --lang elixir

# Dart
lsp-to-scip --server "dart language-server" --root . --lang dart

# Haskell
lsp-to-scip --server haskell-language-server-wrapper --root . --lang haskell

# F#
lsp-to-scip --server fsautocomplete --root . --lang fsharp

# Clojure
lsp-to-scip --server clojure-lsp --root . --lang clojure

# Erlang
lsp-to-scip --server erlang-ls --root . --lang erlang

# Then import
infigraph scip-import --index index.scip
```

### Integration
- **74 MCP tools** for AI coding agents
- **11 agent auto-configs** — Claude Code, Cursor, VS Code, Codex, Gemini CLI, Zed, OpenCode, Aider, Windsurf, Kiro, GitHub Copilot
- **Web UI** at localhost:9749 with graph explorer, search, route map, multi-repo groups, contracts
- **Export** — Neo4j Cypher, GraphML, JSON

## Supported Languages (62)

| Category | Languages |
|----------|-----------|
| **Systems** | Rust, C, C++, Zig, CUDA, Verilog, Assembly |
| **JVM** | Java, Kotlin, Scala, Groovy, Clojure |
| **Web** | JavaScript, TypeScript, TSX, PHP, HTML, CSS, GraphQL |
| **Python** | Python (+ Django, Flask, FastAPI route detection) |
| **Mobile** | Swift, Kotlin, Dart, Objective-C |
| **Functional** | Haskell, OCaml, F#, Elm, Elixir, Erlang, Common Lisp, Emacs Lisp, Clojure |
| **Scripting** | Ruby, Perl, Lua, Bash, PowerShell, R, Julia, MATLAB |
| **Go ecosystem** | Go |
| **Config/Data** | TOML, YAML, JSON, XML, HCL, Makefile, CMake, Dockerfile, Starlark, INI, SQL, Protobuf |
| **Other** | Fortran, GLSL, Nix, Svelte, Markdown |
| **NEW** | **Pascal/Delphi** (.pas, .pp, .dpr, .dpk, .lpr) |
| **Grammar Plugins** | Any ANTLR4-compatible language via [grammar plugins]GRAMMAR_PLUGINS.md |

Every language includes:
- `entities.scm` — symbols (functions, classes, methods, types, variables, constants, routes)
- `relations.scm` — call edges, imports, inheritance

## Quick Start

```bash
cd /path/to/project

# Index
infigraph index

# Search (BM25 + Model2Vec hybrid)
infigraph search "authenticate user"

# Query with Cypher
infigraph query "MATCH (a)-[:CALLS]->(b) RETURN a.name, b.name LIMIT 10"

# Architecture overview
infigraph architecture

# Dead code
infigraph dead-code

# Refactoring recommendations
infigraph refactor
infigraph refactor --focus complexity --limit 20
infigraph refactor --target src/auth.rs

# Impact analysis
infigraph impact "auth.py::authenticate"

# Git diff impact
infigraph detect-changes

# HTTP routes
infigraph routes

# Cluster detection
infigraph cluster

# Code snippet
infigraph snippet "auth.py::authenticate"

# Grep search
infigraph search-code "def authenticate"

# Export
infigraph export json
infigraph export cypher --output graph.cypher
infigraph export graphml --output graph.graphml

# Visualization
infigraph visualize

# Import SCIP index (enriches graph with compiler-grade data)
infigraph scip-import --index index.scip

# PR review (symbol-level diff analysis)
infigraph review

# CI checks (security, complexity, dead code gates)
infigraph check

# Vulnerability scanning
infigraph vulns

# Design pattern detection
infigraph detect-patterns

# Document indexing (PDF, DOCX, Markdown, HTML)
infigraph index-docs
infigraph search-docs "deployment process"

# Confluence wiki indexing
infigraph index-confluence --base-url https://wiki.example.com --space PROJ

# Multi-repo
infigraph group create my-services
infigraph group add my-services /path/to/service-a
infigraph group add my-services /path/to/service-b
infigraph group sync my-services         # extract HTTP contracts
infigraph group contracts my-services    # show contracts
infigraph group deps my-services         # cross-service HTTP dependencies
infigraph group query my-services "MATCH (s:Symbol) WHERE s.kind = 'Route' RETURN s.name, s.file"
```

## MCP Server

```bash
# Start MCP server (stdio)
infigraph-mcp

# Start with web UI
infigraph-mcp --ui --port=9749
# Open http://localhost:9749/?path=/your/project
```

### 74 MCP Tools

| Tool | Description |
|------|-------------|
| **Search & Navigation** | |
| `index_project` | Parse all source files and build code knowledge graph (60+ languages) |
| `search` | Unified code search — keyword-hybrid + semantic-hybrid + regex grep in one call, auto-escalates |
| `search_symbols` | Find symbols by name (keyword-weighted hybrid, alpha=0.3) |
| `semantic_search` | Find code by meaning (semantic-weighted hybrid, alpha=0.85) |
| `search_code` | Regex text search across all project files |
| `get_symbols_in_file` | List all symbols in a file with line numbers |
| `get_code_snippet` | Source code for a symbol by ID |
| `get_doc_context` | Full context: signature + docstring + source + callers + callees in one call |
| `symbol_context` | 360° view: callers, callees, parent scope, file, kind, docstring |
| `list_files` | List source files with optional glob pattern filter |
| **Analysis** | |
| `trace_callers` | Direct callers of a symbol |
| `trace_callees` | What a symbol calls |
| `transitive_impact` | Blast radius — all symbols transitively affected by changes |
| `find_all_references` | Every location where a symbol is referenced |
| `detect_dead_code` | Unreachable functions/methods with zero callers |
| `detect_changes` | Git diff → affected symbols and blast radius |
| `semantic_diff` | Symbol-level diff between git refs (added/removed/moved/changed) |
| `git_summary` | Symbol-level commit history (which functions changed per commit) |
| `get_complexity` | Cyclomatic complexity metrics per symbol |
| `detect_clones` | Near-duplicate functions via vector similarity |
| `detect_clusters` | Louvain community detection on call graph |
| `detect_security_issues` | Security scan: SQL injection, secrets, eval, path traversal, XSS, etc. |
| `detect_bridges` | Cross-language boundaries: FFI, JNI, cgo, gRPC, WASM, COM |
| `detect_routes` | HTTP route/endpoint detection (22 frameworks) |
| `get_test_coverage` | Test coverage analysis — covered %, uncovered symbols |
| `refactor` | Refactoring analysis — complexity, coupling, duplication, size, dead code. Ranked recommendations with impact/effort scores |
| **Architecture** | |
| `get_architecture` | Codebase overview: language breakdown, hotspots, hub functions, entry points |
| `get_api_surface` | Public API surface — all public symbols and HTTP routes |
| `get_file_deps` | File-level import graph (what imports what) |
| `get_type_hierarchy` | Full inheritance tree (ancestors + descendants) |
| `get_graph_schema` | Node/edge types, counts, property names |
| `get_stats` | Graph statistics |
| `generate_sequence_diagram` | Mermaid sequence diagram from call graph |
| **Dependencies** | |
| `index_manifests` | Parse package manifests (package.json, Cargo.toml, go.mod, etc.) |
| `get_dependencies` | List external dependencies by ecosystem |
| `scip_import` | Import SCIP index for compiler-grade enrichment |
| **Review & CI** | |
| `review` | PR review — symbol-level diff analysis with optional LLM enrichment |
| **Document Search** | |
| `index_docs` | Index documents (PDF, DOCX, PPTX, Markdown, HTML) |
| `reindex_docs` | Reindex all documents from scratch |
| `clean_docs` | Remove document index |
| `search_docs` | Search indexed documents with hybrid BM25+semantic |
| `watch_docs` | Watch document directory for changes |
| `stop_watch_docs` | Stop document watcher |
| **Confluence** | |
| `index_confluence` | Crawl and index Confluence wiki space |
| `index_confluence_pages` | Index specific Confluence pages by ID |
| **Multi-repo Groups** | |
| `group_create` | Create a repo group |
| `group_add` | Add repo to group |
| `group_list` | List groups and members |
| `group_index` | Index all repos in a group |
| `group_query` | Cross-repo Cypher query |
| `group_sync` | Extract HTTP contracts across repos |
| `group_contracts` | List discovered contracts |
| `group_deps` | Cross-service HTTP dependency detection |
| `group_link` | Link cross-service deps as CALLS_SERVICE edges |
| **Export & Visualization** | |
| `export_graph` | Export as Cypher/GraphML/JSON |
| `visualize` | Interactive HTML graph visualization |
| `visualize_symbol` | Focused subgraph centered on one symbol |
| **Project Management** | |
| `list_projects` | All indexed repos |
| `delete_project` | Remove project data |
| `list_languages` | Supported languages and extensions |
| **File Watching** | |
| `watch_project` | Background file watcher with auto-reindex |
| `stop_watch` | Stop a running watcher |
| `get_watch_status` | Check watcher status and pending reindexes |
| **Session Context** | |
| `save_session` | Save session context to graph DB with TOUCHED edges + semantic embedding. Auto-purges after configurable days (default: 30) |
| `get_latest_session` | Retrieve most recent session — summary, pending tasks, decisions, linked files. Suggests purge if old sessions exist |
| `purge_sessions` | Delete sessions older than N days (default: 30). User-initiated cleanup |

## Architecture

> For a detailed technical design — including graph schema, hybrid search internals, incremental indexing, cross-file call resolution, and design rationale — see [ARCHITECTURE.md]ARCHITECTURE.md.

```
infigraph/
├── crates/
│   ├── infigraph-core/          # Graph DB, parsing, search, analysis
│   │   └── src/
│   │       ├── model/           # Symbol, Relation, FileExtraction types
│   │       ├── lang/            # LanguagePack, LanguageRegistry
│   │       ├── extract/         # AST entity + relation extraction
│   │       ├── graph/           # LadybugDB store, schema, queries
│   │       ├── search/          # BM25, hybrid search, grep
│   │       ├── embed/           # Model2Vec (bundled potion-base-8M, 256-dim)
│   │       ├── resolve/         # Cross-file call resolution
│   │       ├── cluster/         # Louvain community detection
│   │       ├── multi/           # Multi-repo registry, groups, contracts, cross-service deps
│   │       ├── routes/          # HTTP route detection (22 frameworks)
│   │       ├── scip/            # SCIP index import (compiler-grade enrichment)
│   │       ├── refactor/        # Refactoring analysis (complexity, coupling, clones, dead code)
│   │       ├── watch/           # File watcher with auto-start after indexing + change batching
│   │       ├── session/         # Session context persistence across AI sessions
│   │       ├── review/          # PR review engine with optional LLM enrichment
│   │       ├── check/           # CI check runner (security, complexity, dead code gates)
│   │       ├── vuln/            # OSV vulnerability scanning
│   │       ├── patterns/        # Design pattern detection
│   │       ├── learned/         # Learned resolution patterns for cross-file calls
│   │       ├── viz/             # HTML graph visualization
│   │       └── export/          # Cypher, GraphML, JSON export
│   ├── infigraph-docs/          # Document indexing (PDF, DOCX, PPTX, HTML, Markdown)
│   ├── infigraph-confluence/    # Confluence wiki crawler with incremental sync
│   ├── infigraph-languages/     # 59 tree-sitter language packs
│   │   └── languages/           # entities.scm + relations.scm per language
│   ├── infigraph-grammar-plugin/   # Runtime ANTLR grammar plugin system (JVM subprocess)
│   │   └── src/                 # Driver, config-driven extractor, plugin discovery
│   ├── infigraph-cli/           # 50+ CLI commands
│   ├── infigraph-mcp/           # 69-tool MCP server + web UI
│   └── lsp-to-scip/             # Generic LSP → SCIP bridge binary
├── driver/                          # Java ANTLR grammar driver (JVM subprocess)
│   ├── infigraph-driver.jar       # Fat jar (ANTLR4 runtime bundled)
│   └── src/                       # GrammarDriver.java
├── grammars/                        # Grammar plugin definitions (user-provided)
├── models/
│   └── potion-base-8M/          # Bundled Model2Vec embeddings (256-dim, ~30MB)
├── release.sh                   # Local release builder (macOS ARM64 → GHE)
├── install.sh                   # One-line installer (pre-built binary or source)
└── tests/
    └── fixtures/microservices/  # Test fixtures: Python/TS/Rust microservices
```

## Graph Schema

### Nodes
- **Symbol** — functions, methods, classes, structs, enums, variables, constants, tests, sections, routes (with parameters, return_type, docstring, complexity)
- **Module** — file-level grouping
- **Cluster** — Louvain-detected community
- **File** — source file
- **Folder** — directory
- **Dependency** — external package dependency (name, version, ecosystem, is_dev)

### Edges
- **CALLS** — function/method call (cross-file resolved + SCIP-enriched)
- **INHERITS** — class/interface inheritance
- **IMPLEMENTS** — interface implementation (from SCIP)
- **CONTAINS** — module contains symbol
- **TESTED_BY** — test function tests symbol
- **IMPORTS** — module imports module
- **READS** / **WRITES** — variable access
- **MEMBER_OF** — symbol belongs to cluster
- **SIMILAR_TO** — semantic similarity (embedding-based)
- **BRIDGE_TO** — cross-language bridge (FFI, JNI, gRPC, COM, WASM)
- **CALLS_SERVICE** — cross-service HTTP call (with method, path, target_service)
- **DEPENDS_ON** — module depends on external package
- **DEFINES** — file defines symbol
- **CONTAINS_FILE** — folder contains file
- **CONTAINS_FOLDER** — folder contains subfolder
- **Custom edges** — extensible via language plugins (DECORATED_BY, SPAWNS, etc.)

## Tech Stack

- **Rust** — core engine
- **LadybugDB** (`lbug`) — embedded columnar graph database (Kuzu successor)
- **tree-sitter** 0.26 — AST parsing for 59 languages
- **Model2Vec** — neural embeddings (potion-base-8M, 256-dim, bundled — no proxy/network needed)
- **SCIP** — Sourcegraph Code Intelligence Protocol for compiler-grade enrichment
- **vis.js** — graph visualization
- **tiny_http** — embedded web server

## Contributing: Route & Decorator Extraction

Infigraph captures HTTP route decorators/attributes and stores them in symbol docstrings for semantic search. When a user searches "GET /api/users", the route-decorated function scores highest.

### How it works

Two mechanisms capture decorators:

1. **Tree-sitter query capture** (`entities.scm`) — for languages where decorators are syntactic wrappers (Python `decorated_definition`, Java annotation modifiers)
2. **AST sibling scan** (`extract/entities.rs`) — for languages where attributes are preceding sibling nodes (Rust `attribute_item`, C# `attribute_list`, Kotlin `annotation`, PHP `attribute_list`)

### HTTP Route Coverage

| Language | Framework examples | Status |
|----------|--------------------|--------|
| Python | Flask `@app.route`, FastAPI `@get`, Django `@api_view` | Working |
| Java | Spring `@GetMapping`, `@RequestMapping`, `@RestController` | Working |
| Rust | Actix `#[get]`, Axum, Rocket `#[get]` | Working |
| C# | ASP.NET `[HttpGet]`, `[Route]`, `[ApiController]` | Working |
| Kotlin | Spring `@GetMapping`, Ktor | Working |
| PHP | Laravel `#[Route]` (PHP 8+) | Working |
| TypeScript | NestJS `@Get()`, `@Controller()` | Working |
| JavaScript | Express `router.get("/path", ...)` | Working |
| Go | `r.GET("/path", handler)` (Gin, Chi, gorilla) | Working |
| Ruby | Rails `get "/path" do...end` | Working |
| Elixir | Phoenix `get "/path" do...end` | Working |
| Swift | Vapor `router.get("/path")` | Working |
| Dart | shelf `get("/path", handler)` | Working |
| Haskell | Servant `type API = "path" :> Get` | Working |
| Lua | Lapis `app:get("/path", ...)` | Working |
| Perl | Mojolicious `get "/path" => sub {...}` | Working |
| Clojure | Compojure `GET "/path"` | Working |
| Erlang | Cowboy `dispatch_rules` / `handle` | Working |
| GraphQL | Schema definitions | Working |
| Scala | Play `GET("path")` | Working |
| Django | `path("/url", view)` | Working |
| F# | Giraffe/Saturn (AST scan) | Deferred |

### Adding route support for a new language

#### Option A: Query-based (decorator-wrapper syntax)

Edit `crates/infigraph-languages/languages/<lang>/entities.scm`:

```scheme
; Capture route method, path, handler
(call_expression
  function: (identifier) @route.method
  arguments: (arguments
    (string_literal) @route.path)
  (#match? @route.method "^(get|post|put|delete|patch)$")) @route.def
```

#### Option B: AST sibling (attribute-preceded syntax)

Add the tree-sitter node kind to `ATTR_KINDS` in `crates/infigraph-core/src/extract/entities.rs`:

```rust
const ATTR_KINDS: &[&str] = &[
    "attribute_item",    // Rust
    "attribute_list",    // C#, PHP 8
    "annotation",        // Kotlin, Scala
    "decorator",         // TypeScript, JavaScript
    "marker_annotation", // Java
    // Add your language's attribute node kind here
];
```

### Test fixtures

`tests/fixtures/microservices/` contains realistic microservice repos for testing:
- `user-service/` — Python Flask (3 files, 6 routes)
- `order-service/` — TypeScript Express (4 files, 5 routes)
- `payment-service/` — Rust Actix-web (5 files, 4 routes)

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for build instructions, code style, and how to add a language or submit a PR.

## License

Apache-2.0