Metadata-Version: 2.4
Name: graphtyy
Version: 0.1.0
Summary: AI coding assistant skill (Claude Code, CodeBuddy, Codex, OpenCode, Kilo Code, Cursor, Gemini CLI, Aider, OpenClaw, Factory Droid, Trae, Hermes, Kiro, Pi, Devin CLI, Google Antigravity) - turn any folder of code, docs, papers, images, or videos into a queryable knowledge graph
License: MIT License
        
        Copyright (c) 2026 Safi Shamsi (original Graphify project)
        Copyright (c) 2026 m3rcha (Graphty fork)
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/m3rcha/graphty
Project-URL: Repository, https://github.com/m3rcha/graphty
Project-URL: Issues, https://github.com/m3rcha/graphty/issues
Keywords: graphty,claude,claude-code,codex,opencode,kilo,cursor,gemini,aider,kiro,pi,devin,knowledge-graph,code-graph,codebase,code-search,rag,graphrag,mcp,ai-agent,obsidian,community-detection,tree-sitter,leiden,llm
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: networkx>=3.4
Requires-Dist: numpy>=1.21
Requires-Dist: rapidfuzz>=3.0
Requires-Dist: tree-sitter>=0.23.0
Requires-Dist: tree-sitter-python
Requires-Dist: tree-sitter-javascript
Requires-Dist: tree-sitter-typescript
Requires-Dist: tree-sitter-go
Requires-Dist: tree-sitter-rust
Requires-Dist: tree-sitter-java
Requires-Dist: tree-sitter-groovy
Requires-Dist: tree-sitter-c
Requires-Dist: tree-sitter-cpp
Requires-Dist: tree-sitter-ruby
Requires-Dist: tree-sitter-c-sharp
Requires-Dist: tree-sitter-kotlin
Requires-Dist: tree-sitter-scala
Requires-Dist: tree-sitter-php
Requires-Dist: tree-sitter-swift
Requires-Dist: tree-sitter-lua
Requires-Dist: tree-sitter-zig
Requires-Dist: tree-sitter-powershell
Requires-Dist: tree-sitter-elixir
Requires-Dist: tree-sitter-objc
Requires-Dist: tree-sitter-julia
Requires-Dist: tree-sitter-verilog
Requires-Dist: tree-sitter-fortran
Requires-Dist: tree-sitter-bash
Requires-Dist: tree-sitter-json
Provides-Extra: mcp
Requires-Dist: mcp; extra == "mcp"
Provides-Extra: neo4j
Requires-Dist: neo4j; extra == "neo4j"
Provides-Extra: pdf
Requires-Dist: pypdf; extra == "pdf"
Requires-Dist: markdownify; extra == "pdf"
Provides-Extra: watch
Requires-Dist: watchdog; extra == "watch"
Provides-Extra: svg
Requires-Dist: matplotlib; extra == "svg"
Requires-Dist: numpy>=2.0; python_version >= "3.13" and extra == "svg"
Provides-Extra: leiden
Requires-Dist: graspologic; python_version < "3.13" and extra == "leiden"
Provides-Extra: office
Requires-Dist: python-docx; extra == "office"
Requires-Dist: openpyxl; extra == "office"
Provides-Extra: google
Requires-Dist: openpyxl; extra == "google"
Provides-Extra: postgres
Requires-Dist: psycopg[binary]; extra == "postgres"
Provides-Extra: video
Requires-Dist: faster-whisper; python_version >= "3.11" and extra == "video"
Requires-Dist: yt-dlp; extra == "video"
Provides-Extra: kimi
Requires-Dist: openai; extra == "kimi"
Requires-Dist: tiktoken; extra == "kimi"
Provides-Extra: ollama
Requires-Dist: openai; extra == "ollama"
Provides-Extra: bedrock
Requires-Dist: boto3; extra == "bedrock"
Provides-Extra: anthropic
Requires-Dist: anthropic; extra == "anthropic"
Provides-Extra: gemini
Requires-Dist: openai; extra == "gemini"
Requires-Dist: tiktoken; extra == "gemini"
Provides-Extra: openai
Requires-Dist: openai; extra == "openai"
Requires-Dist: tiktoken; extra == "openai"
Provides-Extra: chinese
Requires-Dist: jieba; extra == "chinese"
Provides-Extra: sql
Requires-Dist: tree-sitter-sql; extra == "sql"
Provides-Extra: dm
Requires-Dist: tree-sitter-dm; extra == "dm"
Provides-Extra: terraform
Requires-Dist: tree-sitter-hcl; extra == "terraform"
Provides-Extra: all
Requires-Dist: mcp; extra == "all"
Requires-Dist: neo4j; extra == "all"
Requires-Dist: pypdf; extra == "all"
Requires-Dist: markdownify; extra == "all"
Requires-Dist: watchdog; extra == "all"
Requires-Dist: graspologic; python_version < "3.13" and extra == "all"
Requires-Dist: python-docx; extra == "all"
Requires-Dist: openpyxl; extra == "all"
Requires-Dist: faster-whisper; python_version >= "3.11" and extra == "all"
Requires-Dist: yt-dlp; extra == "all"
Requires-Dist: matplotlib; extra == "all"
Requires-Dist: numpy>=2.0; python_version >= "3.13" and extra == "all"
Requires-Dist: openai; extra == "all"
Requires-Dist: tiktoken; extra == "all"
Requires-Dist: boto3; extra == "all"
Requires-Dist: anthropic; extra == "all"
Requires-Dist: tree-sitter-sql; extra == "all"
Requires-Dist: jieba; extra == "all"
Requires-Dist: tree-sitter-dm; extra == "all"
Requires-Dist: tree-sitter-hcl; extra == "all"
Dynamic: license-file

<p align="center">
  <a href="https://github.com/m3rcha/graphty"><img src="docs/logo-text.svg" width="260" height="64" alt="Graphty"/></a>
</p>

<p align="center">
  🇺🇸 <a href="README.md">English</a> | 🇨🇳 <a href="docs/translations/README.zh-CN.md">简体中文</a> | 🇯🇵 <a href="docs/translations/README.ja-JP.md">日本語</a> | 🇰🇷 <a href="docs/translations/README.ko-KR.md">한국어</a> | 🇩🇪 <a href="docs/translations/README.de-DE.md">Deutsch</a> | 🇫🇷 <a href="docs/translations/README.fr-FR.md">Français</a> | 🇪🇸 <a href="docs/translations/README.es-ES.md">Español</a> | 🇮🇳 <a href="docs/translations/README.hi-IN.md">हिन्दी</a> | 🇧🇷 <a href="docs/translations/README.pt-BR.md">Português</a> | 🇷🇺 <a href="docs/translations/README.ru-RU.md">Русский</a> | 🇸🇦 <a href="docs/translations/README.ar-SA.md">العربية</a> | 🇮🇹 <a href="docs/translations/README.it-IT.md">Italiano</a> | 🇵🇱 <a href="docs/translations/README.pl-PL.md">Polski</a> | 🇳🇱 <a href="docs/translations/README.nl-NL.md">Nederlands</a> | 🇹🇷 <a href="docs/translations/README.tr-TR.md">Türkçe</a> | 🇺🇦 <a href="docs/translations/README.uk-UA.md">Українська</a> | 🇻🇳 <a href="docs/translations/README.vi-VN.md">Tiếng Việt</a> | 🇮🇩 <a href="docs/translations/README.id-ID.md">Bahasa Indonesia</a> | 🇸🇪 <a href="docs/translations/README.sv-SE.md">Svenska</a> | 🇬🇷 <a href="docs/translations/README.el-GR.md">Ελληνικά</a> | 🇷🇴 <a href="docs/translations/README.ro-RO.md">Română</a> | 🇨🇿 <a href="docs/translations/README.cs-CZ.md">Čeština</a> | 🇫🇮 <a href="docs/translations/README.fi-FI.md">Suomi</a> | 🇩🇰 <a href="docs/translations/README.da-DK.md">Dansk</a> | 🇳🇴 <a href="docs/translations/README.no-NO.md">Norsk</a> | 🇭🇺 <a href="docs/translations/README.hu-HU.md">Magyar</a> | 🇹🇭 <a href="docs/translations/README.th-TH.md">ภาษาไทย</a> | 🇺🇿 <a href="docs/translations/README.uz-UZ.md">Oʻzbekcha</a> | 🇹🇼 <a href="docs/translations/README.zh-TW.md">繁體中文</a> | 🇵🇭 <a href="docs/translations/README.fil-PH.md">Filipino</a>
</p>

<p align="center">
  <a href="https://github.com/m3rcha/graphty/actions/workflows/ci.yml"><img src="https://github.com/m3rcha/graphty/actions/workflows/ci.yml/badge.svg?branch=v8" alt="CI"/></a>
  <a href="https://pypi.org/project/graphtyy/"><img src="https://img.shields.io/pypi/v/graphtyy" alt="PyPI"/></a>
  <a href="https://pepy.tech/project/graphtyy"><img src="https://img.shields.io/pepy/dt/graphtyy?color=blue&label=downloads" alt="Downloads"/></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License"/></a>
</p>

<p align="center">
  <em>Graphty is an open-source fork of <a href="https://github.com/safishamsi/graphify">Graphify</a> by Safi Shamsi, continued under the MIT license.</em>
</p>

<p align="center">
  <a href="https://star-history.com/#m3rcha/graphty&Date">
    <img src="https://api.star-history.com/svg?repos=m3rcha/graphty&type=Date" alt="Star History Chart" width="370"/>
  </a>
</p>

**Stop grepping. Start asking.** Type `/graphty` in your AI coding assistant and it maps your entire project — code, docs, PDFs, images, videos — into a knowledge graph your agent *queries* instead of reading files one at a time. Fewer tokens burned, fewer wrong turns, answers that span files.

Works in Claude Code, Codex, OpenCode, Kilo Code, Cursor, Gemini CLI, GitHub Copilot CLI, VS Code Copilot Chat, Aider, Amp, OpenClaw, Factory Droid, Trae, Hermes, Kimi Code, Kiro, Pi, Devin CLI, and Google Antigravity.

```
/graphty .
```

That's it. You get three files:

```
graphty-out/
├── graph.html       open in any browser — click nodes, filter, search
├── GRAPH_REPORT.md  the highlights: key concepts, surprising connections, suggested questions
└── graph.json       the full graph — query it anytime without re-reading your files
```

For a readable architecture page with Mermaid call-flow diagrams, run:

```bash
graphty export callflow-html
```

---

## Why Graphty

- **Works everywhere you code.** 19+ AI coding tools supported — Claude Code, Codex, Cursor, Gemini, Copilot, and more — each a one-line `graphty install`.
- **Query, don't grep.** Your agent asks the graph a question and gets back a small, scoped subgraph instead of a wall of files. Run `graphty benchmark` to see the token savings on your own repo.
- **Honest by design.** Every edge is labeled `EXTRACTED`, `INFERRED`, or `AMBIGUOUS`, so you know what's certain and what to double-check — no hidden hallucinated links.
- **Take the graph anywhere.** Export to interactive HTML, JSON, Obsidian, Neo4j, GraphML, **Graphviz DOT**, and **CSV**, or get a one-glance overview with **`graphty stats`** (no LLM, instant).
- **Persistent + incremental.** The graph lives in `graphty-out/` across sessions and updates on each commit via a git hook — `graphty update .` re-extracts only what changed (AST-only, no API cost).

> Graphty is a community-maintained fork of [Graphify](https://github.com/safishamsi/graphify) by Safi Shamsi — the same extraction engine, kept actively maintained, with added exporters (DOT, CSV) and a fast `stats` command.

---

## Prerequisites

| Requirement | Minimum | Check | Install |
|---|---|---|---|
| Python | 3.10+ | `python --version` | [python.org](https://www.python.org/downloads/) |
| uv *(recommended)* | any | `uv --version` | `curl -LsSf https://astral.sh/uv/install.sh \| sh` |
| pipx *(alternative)* | any | `pipx --version` | `pip install pipx` |

**macOS quick install (Homebrew):**
```bash
brew install python@3.12 uv
```

**Windows quick install:**
```powershell
winget install astral-sh.uv
```

**Ubuntu/Debian:**
```bash
sudo apt install python3.12 python3-pip pipx
# or install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
```

---

## Install

> **Package name:** The PyPI package is **`graphtyy`** (double-y) — `graphty` was already taken, so this follows the same convention upstream used (`graphifyy`). The CLI command, import, and skill name are all just **`graphty`**. You can also install from source (Option A) if you prefer.

**Step 1 — install the package:**

```bash
# Option A — from source (works today):
git clone https://github.com/m3rcha/graphty.git
uv tool install ./graphty        # uv puts `graphty` on PATH automatically
# or: pipx install ./graphty

# Option B — from PyPI (once published):
uv tool install graphtyy
# Alternatives: pipx install graphtyy  /  pip install graphtyy (may need PATH setup)
```

**Step 2 — register the skill with your AI assistant:**

```bash
graphty install
```

That's it. Open your AI assistant and type `/graphty .`

To install the assistant skill into the current repository instead of your user
profile, add `--project`:

```bash
graphty install --project
graphty install --project --platform codex
```

Project-scoped installs write under the current directory, for example
`.claude/skills/graphty/SKILL.md` or `.agents/skills/graphty/SKILL.md` (plus a
`references/` sidecar the skill loads on demand), and
print a `git add` hint for files that can be committed.
Per-platform commands that support project-scoped installs accept the same flag,
for example `graphty claude install --project` or `graphty codex install --project`.

> **PowerShell note:** Use `graphty .` not `/graphty .` — the leading slash is a path separator in PowerShell.

> **`graphty: command not found`?** Use `uv tool install graphtyy` or `pipx install graphtyy` — both put the CLI on PATH automatically. With plain `pip`, add `~/.local/bin` (Linux) or `~/Library/Python/3.x/bin` (Mac) to your PATH, or run `python -m graphty`.

> **Avoid `pip install` on Mac/Windows** if possible. The skill resolves Python at runtime from `graphty-out/.graphty_python`; if that points to a different environment than where `pip` installed the package, you'll get `ModuleNotFoundError: No module named 'graphty'`. `uv tool install` and `pipx install` isolate the package in their own env and avoid this entirely.

> **Git hooks and uv tool / pipx:** `graphty hook install` embeds the current interpreter path directly into the hook scripts at install time, so the post-commit hook fires correctly even in GUI git clients and CI runners where `~/.local/bin` is not on PATH. If you reinstall or upgrade graphtyy, re-run `graphty hook install` to refresh the embedded path.

### Pick your platform

| Platform | Install command |
|----------|----------------|
| Claude Code (Linux/Mac) | `graphty install` |
| Claude Code (Windows) | `graphty install` (auto-detected) or `graphty install --platform windows` |
| CodeBuddy | `graphty install --platform codebuddy` |
| Codex | `graphty install --platform codex` |
| OpenCode | `graphty install --platform opencode` |
| Kilo Code | `graphty install --platform kilo` |
| GitHub Copilot CLI | `graphty install --platform copilot` |
| VS Code Copilot Chat | `graphty vscode install` |
| Aider | `graphty install --platform aider` |
| OpenClaw | `graphty install --platform claw` |
| Factory Droid | `graphty install --platform droid` |
| Trae | `graphty install --platform trae` |
| Trae CN | `graphty install --platform trae-cn` |
| Gemini CLI | `graphty install --platform gemini` |
| Hermes | `graphty install --platform hermes` |
| Kimi Code | `graphty install --platform kimi` |
| Amp | `graphty amp install` |
| Kiro IDE/CLI | `graphty kiro install` |
| Pi coding agent | `graphty install --platform pi` |
| Cursor | `graphty cursor install` |
| Devin CLI | `graphty devin install` |
| Google Antigravity | `graphty antigravity install` |

Codex users also need `multi_agent = true` under `[features]` in `~/.codex/config.toml` for parallel extraction. CodeBuddy uses the same Agent tool and PreToolUse hook mechanism as Claude Code. Factory Droid uses the `Task` tool for parallel subagent dispatch. OpenClaw and Aider use sequential extraction (parallel agent support is still early on those platforms). Trae uses the Agent tool for parallel subagent dispatch and does **not** support PreToolUse hooks — AGENTS.md is the always-on mechanism.

> Codex uses `$graphty` instead of `/graphty`.

### Optional extras

Install only what you need:

| Extra | What it adds | Install |
|---|---|---|
| `pdf` | PDF extraction | `uv tool install "graphtyy[pdf]"` |
| `office` | `.docx` and `.xlsx` support | `uv tool install "graphtyy[office]"` |
| `google` | Google Sheets rendering | `uv tool install "graphtyy[google]"` |
| `video` | Video/audio transcription (faster-whisper + yt-dlp) | `uv tool install "graphtyy[video]"` |
| `mcp` | MCP stdio server | `uv tool install "graphtyy[mcp]"` |
| `neo4j` | Neo4j push support | `uv tool install "graphtyy[neo4j]"` |
| `svg` | SVG graph export | `uv tool install "graphtyy[svg]"` |
| `leiden` | Leiden community detection (Python < 3.13 only) | `uv tool install "graphtyy[leiden]"` |
| `ollama` | Ollama local inference | `uv tool install "graphtyy[ollama]"` |
| `openai` | OpenAI / OpenAI-compatible APIs | `uv tool install "graphtyy[openai]"` |
| `gemini` | Google Gemini API | `uv tool install "graphtyy[gemini]"` |
| `anthropic` | Anthropic Claude API (`--backend claude`, uses `ANTHROPIC_API_KEY`) | `uv tool install "graphtyy[anthropic]"` |
| `bedrock` | AWS Bedrock (uses IAM, no API key) | `uv tool install "graphtyy[bedrock]"` |
| `azure` | Azure OpenAI Service (`--backend azure`, uses `AZURE_OPENAI_API_KEY` + `AZURE_OPENAI_ENDPOINT`) | `uv tool install "graphtyy[openai]"` |
| `sql` | SQL schema extraction | `uv tool install "graphtyy[sql]"` |
| `postgres` | Live PostgreSQL introspection (`--postgres DSN`) | `uv tool install "graphtyy[postgres]"` |
| `dm` | BYOND DreamMaker `.dm`/`.dme` AST extraction (may need a C compiler + `python3-dev` if no wheel matches your platform) | `uv tool install "graphtyy[dm]"` |
| `terraform` | Terraform / HCL `.tf`/`.tfvars`/`.hcl` AST extraction | `uv tool install "graphtyy[terraform]"` |
| `chinese` | Chinese query segmentation (jieba) | `uv tool install "graphtyy[chinese]"` |
| `all` | Everything above | `uv tool install "graphtyy[all]"` |

---

## Make your assistant always use the graph

Run this once in your project after building a graph:

| Platform | Command |
|----------|---------|
| Claude Code | `graphty claude install` |
| CodeBuddy | `graphty codebuddy install` |
| Codex | `graphty codex install` |
| OpenCode | `graphty opencode install` |
| Kilo Code | `graphty kilo install` |
| GitHub Copilot CLI | `graphty copilot install` |
| VS Code Copilot Chat | `graphty vscode install` |
| Aider | `graphty aider install` |
| OpenClaw | `graphty claw install` |
| Factory Droid | `graphty droid install` |
| Trae | `graphty trae install` |
| Trae CN | `graphty trae-cn install` |
| Cursor | `graphty cursor install` |
| Gemini CLI | `graphty gemini install` |
| Hermes | `graphty hermes install` |
| Kimi Code | `graphty install --platform kimi` |
| Amp | `graphty amp install` |
| Kiro IDE/CLI | `graphty kiro install` |
| Pi coding agent | `graphty pi install` |
| Devin CLI | `graphty devin install` |
| Google Antigravity | `graphty antigravity install` |

This writes a small config file that tells your assistant to consult the knowledge graph for codebase questions — preferring scoped queries like `graphty query "<question>"` over reading the full report or grepping raw files. On platforms that support payload-bearing hooks (Claude Code, Gemini CLI), a hook fires automatically before search-style tool calls (and, on Claude Code, before reading source files one by one via the Read/Glob tools) and nudges your assistant toward the graph path. On the others (Codex, OpenCode, Cursor, etc.), the persistent instruction files (`AGENTS.md`, `.cursor/rules/`, etc.) provide the same query-first guidance. `GRAPH_REPORT.md` is still available for broad architecture review.

**CodeBuddy** does the same two things as Claude Code: writes a `CODEBUDDY.md` section telling CodeBuddy to read `graphty-out/GRAPH_REPORT.md` before answering architecture questions, and installs **PreToolUse hooks** (`.codebuddy/settings.json`) that fire before Bash search commands and file reads, nudging toward `graphty query` instead.

**Codex** writes to `AGENTS.md` and also installs a **PreToolUse hook** in `.codex/hooks.json` that fires before every Bash tool call — same always-on mechanism as Claude Code.

To remove graphty from all platforms at once: `graphty uninstall` (add `--purge` to also delete `graphty-out/`). Or use the per-platform command (e.g. `graphty claude uninstall`).

---

**Kilo Code** installs the Graphty skill to `~/.config/kilo/skills/graphty/SKILL.md` and a native `/graphty` command to `~/.config/kilo/command/graphty.md`. `graphty kilo install` also writes `AGENTS.md` plus a native **`tool.execute.before` plugin** (`.kilo/plugins/graphty.js` + `.kilo/kilo.json` or `.kilo/kilo.jsonc` registration) so Kilo gets the same always-on graph reminder behavior through native `.kilo` config.

**Cursor** writes `.cursor/rules/graphty.mdc` with `alwaysApply: true` — Cursor includes it in every conversation automatically, no hook needed.

## What's in the report

- **God nodes** — the most-connected concepts in your project. Everything flows through these.
- **Surprising connections** — links between things that live in different files or modules. Ranked by how unexpected they are.
- **The "why"** — inline comments (`# NOTE:`, `# WHY:`, `# HACK:`), docstrings, and design rationale from docs are extracted as separate nodes linked to the code they explain.
- **Suggested questions** — 4–5 questions the graph is uniquely positioned to answer.
- **Confidence tags** — every inferred relationship is marked `EXTRACTED`, `INFERRED`, or `AMBIGUOUS`. You always know what was found vs guessed.

---

## What files it handles

| Type | Extensions |
|------|-----------|
| Code (28 tree-sitter grammars) | `.py .ts .js .jsx .tsx .mjs .go .rs .java .c .cpp .h .hpp .rb .cs .kt .scala .php .swift .lua .luau .zig .ps1 .ex .exs .m .mm .jl .vue .svelte .astro .groovy .gradle .dart .v .sv .svh .sql .f .f90 .f95 .f03 .f08 .pas .pp .dpr .dpk .lpr .inc .dfm .lfm .lpk .sh .bash .json .dm .dme .dmi .dmm .dmf .sln .slnx .csproj .fsproj .vbproj .razor .cshtml` (`.dm`/`.dme` requires `uv tool install graphtyy[dm]`) |
| Salesforce Apex | `.cls .trigger` (regex-based; classes, interfaces, enums, methods, triggers, SOQL/DML edges) |
| Terraform / HCL | `.tf .tfvars .hcl` (requires `uv tool install graphtyy[terraform]`) |
| MCP configs | `.mcp.json` `mcp.json` `mcp_servers.json` `claude_desktop_config.json` — extracts server nodes, package refs, env var requirements |
| Docs | `.md .mdx .qmd .html .txt .rst .yaml .yml` |
| Office | `.docx .xlsx` (requires `uv tool install graphtyy[office]`) |
| Google Workspace | `.gdoc .gsheet .gslides` (opt-in; requires `gws` auth and `--google-workspace`; Sheets need `uv tool install graphtyy[google]`) |
| PDFs | `.pdf` |
| Images | `.png .jpg .webp .gif` |
| Video / Audio | `.mp4 .mov .mp3 .wav` and more (requires `uv tool install graphtyy[video]`) |
| YouTube / URLs | any video URL (requires `uv tool install graphtyy[video]`) |

Code is extracted locally with no API calls (AST via tree-sitter). Everything else goes through your AI assistant's model API.

Google Drive for desktop `.gdoc`, `.gsheet`, and `.gslides` files are shortcut
pointers, not document content. To include native Google Docs, Sheets, and Slides
in a headless extraction, install and authenticate the
[`gws` CLI](https://github.com/googleworkspace/cli), then run:

```bash
uv tool install "graphtyy[google]"  # needed for Google Sheets table rendering
gws auth login -s drive
graphty extract ./docs --google-workspace
```

You can also set `GRAPHTY_GOOGLE_WORKSPACE=1`. Graphty exports shortcuts into
`graphty-out/converted/` as Markdown sidecars, then extracts those files.

---

## Common commands

```bash
/graphty .                        # build graph for current folder
/graphty ./docs --update          # re-extract only changed files
/graphty . --cluster-only         # rerun clustering without re-extracting
/graphty . --cluster-only --resolution 1.5      # more granular communities
/graphty . --cluster-only --exclude-hubs 99     # suppress utility super-hubs from god-node rankings
/graphty . --no-viz               # skip the HTML, just the report + JSON
/graphty . --wiki                 # build a markdown wiki from the graph
graphty export callflow-html      # Mermaid architecture/call-flow HTML (auto-regenerates on every git commit if hook is installed)
graphty export dot                # Graphviz DOT (render with `dot -Tsvg graphty-out/graph.dot`)
graphty export csv                # nodes.csv + edges.csv for spreadsheets / pandas
graphty stats                     # quick terminal summary of the graph (no LLM)

/graphty query "what connects auth to the database?"
/graphty path "UserService" "DatabasePool"
/graphty explain "RateLimiter"

/graphty add https://arxiv.org/abs/1706.03762   # fetch a paper and add it
/graphty add <youtube-url>                       # transcribe and add a video

graphty hook install              # auto-rebuild on git commit
graphty merge-graphs a.json b.json              # combine two graphs

graphty prs                       # PR dashboard: CI state, review status, worktree mapping
graphty prs 42                    # deep dive on PR #42 with graph impact
graphty prs --triage              # AI ranks your review queue (uses whatever backend is configured)
graphty prs --conflicts           # PRs sharing graph communities — merge-order risk
```

See the [full command reference](#full-command-reference) below.

---

## Ignoring files

Create a `.graphtyignore` in your project root — same syntax as `.gitignore`, including `!` negation.

**`.gitignore` is respected automatically.** If no `.graphtyignore` is present in a directory, graphty falls back to the `.gitignore` in that directory. If both exist, `.graphtyignore` takes priority. Subdirectory scoping works the same way as git — an ignore file only affects its own subtree.

```
# .graphtyignore
node_modules/
dist/
*.generated.py

# only index src/, ignore everything else
*
!src/
!src/**
```

---

## Team setup

`graphty-out/` is meant to be committed to git so everyone on the team starts with a map.

**Recommended `.gitignore` additions:**
```
graphty-out/cost.json        # local only
# graphty-out/cache/         # optional: commit for speed, skip to keep repo small
```

> `manifest.json` is now portable — keys are stored as relative paths and re-anchored on load, so committing it is safe and avoids a full rebuild on first checkout.

**Workflow:**
1. One person runs `/graphty .` and commits `graphty-out/`.
2. Everyone pulls — their assistant reads the graph immediately.
3. Run `graphty hook install` to auto-rebuild after each commit (AST only, no API cost). This also sets up a git merge driver so `graph.json` is never left with conflict markers — two devs committing in parallel get their graphs union-merged automatically.
4. When docs or papers change, run `/graphty --update` to refresh those nodes.

---

## Using the graph directly

```bash
# query the graph from the terminal
graphty query "show the auth flow"
graphty query "what connects DigestAuth to Response?" --graph graphty-out/graph.json

# expose the graph as an MCP server (for repeated tool-call access)
python -m graphty.serve graphty-out/graph.json

# register with Kimi Code:
kimi mcp add --transport stdio graphty -- python -m graphty.serve graphty-out/graph.json

# or serve over HTTP so a whole team points at one URL (no local graphty needed):
python -m graphty.serve graphty-out/graph.json --transport http --port 8080
python -m graphty.serve graphty-out/graph.json --transport http --host 0.0.0.0 --api-key "$SECRET"
```

The MCP server gives your assistant structured access: `query_graph`, `get_node`, `get_neighbors`, `shortest_path`, `list_prs`, `get_pr_impact`, `triage_prs`.

### Shared HTTP server

`--transport stdio` (the default) spawns one local server per developer. `--transport http` serves the same tools over the MCP Streamable HTTP transport, so a single shared process can serve the graph for the whole team — clients point their IDE MCP config at `http://<host>:8080/mcp` instead of running graphty locally.

| Flag | Default | Purpose |
|---|---|---|
| `--transport {stdio,http}` | `stdio` | Transport to serve on |
| `--host` | `127.0.0.1` | HTTP bind host (use `0.0.0.0` to expose beyond localhost) |
| `--port` | `8080` | HTTP bind port |
| `--api-key` | env `GRAPHTY_API_KEY` | Require `Authorization: Bearer <key>` (or `X-API-Key`) |
| `--path` | `/mcp` | HTTP mount path |
| `--json-response` | off | Return plain JSON instead of SSE streams |
| `--stateless` | off | No per-session state (for load-balanced / CI deployments) |
| `--session-timeout` | `3600` | Reap idle stateful sessions after N seconds (`0` disables) |

The default `127.0.0.1` bind is loopback-only. Set `--host 0.0.0.0` **and** `--api-key` together when exposing on a shared host. Run it in a container:

```bash
docker build -t graphty .
docker run -p 8080:8080 -v "$(pwd)/graphty-out:/data" graphty \
  /data/graph.json --transport http --host 0.0.0.0 --api-key "$SECRET"
```

> **WSL / Linux note:** Ubuntu ships `python3`, not `python`. Use a venv to avoid conflicts:
> ```bash
> python3 -m venv .venv && .venv/bin/pip install "graphtyy[mcp]"
> ```

---

## Environment variables

These are only needed for **headless / CI extraction** (`graphty extract`). When running via the `/graphty` skill inside your IDE, the model API is provided by your IDE session — no extra keys needed.

| Variable | Used for | When required |
|---|---|---|
| `ANTHROPIC_API_KEY` | Claude (Anthropic) backend | `--backend claude` |
| `GEMINI_API_KEY` or `GOOGLE_API_KEY` | Google Gemini backend | `--backend gemini` |
| `OPENAI_API_KEY` | OpenAI or OpenAI-compatible APIs | `--backend openai` |
| `DEEPSEEK_API_KEY` | DeepSeek backend | `--backend deepseek` |
| `MOONSHOT_API_KEY` | Kimi Code backend | `--backend kimi` |
| `OLLAMA_BASE_URL` | Ollama local inference URL | `--backend ollama` (default: `http://localhost:11434`) |
| `OLLAMA_MODEL` | Ollama model name | `--backend ollama` (default: auto-detect) |
| `GRAPHTY_OLLAMA_NUM_CTX` | Override Ollama KV-cache window size | optional — auto-sized by default |
| `GRAPHTY_OLLAMA_KEEP_ALIVE` | Minutes to keep Ollama model loaded | optional — set `0` to unload after each chunk |
| `AZURE_OPENAI_API_KEY` | Azure OpenAI Service backend | `--backend azure` |
| `AZURE_OPENAI_ENDPOINT` | Azure resource endpoint URL | `--backend azure` (required alongside API key) |
| `AZURE_OPENAI_API_VERSION` | Azure API version override | optional — default `2024-12-01-preview` |
| `AZURE_OPENAI_DEPLOYMENT` or `GRAPHTY_AZURE_MODEL` | Azure deployment name | optional — default `gpt-4o` |
| `AWS_*` / `~/.aws/credentials` | AWS Bedrock — standard credential chain | `--backend bedrock` (no API key, uses IAM) |
| `GRAPHTY_MAX_WORKERS` | AST parallelism thread count | optional — also `--max-workers` flag |
| `GRAPHTY_MAX_OUTPUT_TOKENS` | Raise output cap for dense corpora | optional — e.g. `32768` for large files |
| `GRAPHTY_API_TIMEOUT` | Per-call timeout in seconds for HTTP, claude-cli, and Anthropic SDK backends (default: 600) | optional — also `--api-timeout` flag |
| `GRAPHTY_FORCE` | Force graph rebuild even with fewer nodes | optional — also `--force` flag |
| `GRAPHTY_GOOGLE_WORKSPACE` | Auto-enable Google Workspace export | optional — set to `1` |
| `GRAPHTY_TRIAGE_BACKEND` | Backend for `graphty prs --triage` | optional — auto-detected from available keys |
| `GRAPHTY_TRIAGE_MODEL` | Model override for triage | optional — e.g. `claude-opus-4-7` |
| `GRAPHTY_QUERY_LOG` | Override query log path (default: `~/.cache/graphty-queries.log`) | optional — set to empty or `/dev/null` to silence |
| `GRAPHTY_QUERY_LOG_DISABLE` | Set to `1` to disable query logging entirely | optional |
| `GRAPHTY_QUERY_LOG_RESPONSES` | Set to `1` to also log full subgraph responses (off by default) | optional |
| `GRAPHTY_MAX_GRAPH_BYTES` | Override the 512 MiB graph.json size cap — e.g. `700MB`, `2GB`, or plain bytes | optional — useful for very large corpora |
| `GRAPHTY_LLM_TEMPERATURE` | Override LLM temperature for semantic extraction — e.g. `0.7`, or `none` to omit | optional — auto-omitted for o1/o3/o4/gpt-5 reasoning models |

---

## Privacy

- **Code files** — processed locally via tree-sitter. Nothing leaves your machine. A code-only corpus requires no API key — `graphty extract` runs fully offline.
- **Video / audio** — transcribed locally with faster-whisper. Nothing leaves your machine.
- **Docs, PDFs, images** — sent to your AI assistant for semantic extraction (via the `/graphty` skill, using whatever model your IDE session runs). Headless `graphty extract` requires `GEMINI_API_KEY` / `GOOGLE_API_KEY` (Gemini), `MOONSHOT_API_KEY` (Kimi), `ANTHROPIC_API_KEY` (Claude), `OPENAI_API_KEY` (OpenAI), `DEEPSEEK_API_KEY` (DeepSeek), a running Ollama instance (`OLLAMA_BASE_URL`), AWS credentials via the standard provider chain (Bedrock - no API key needed, uses IAM), or the `claude` CLI binary (Claude Code - no API key needed, uses your Claude subscription). The `--dedup-llm` flag uses the same key.
- **Data residency** — `graphty extract` auto-detects which provider to use based on which API key is set (priority: Gemini → Kimi → Claude → OpenAI → DeepSeek → Azure → Bedrock → Ollama). For code with data-residency requirements, use `--backend ollama` (fully local) or pass an explicit `--backend` flag. Kimi (`MOONSHOT_API_KEY`) routes to Moonshot AI servers in China.
- No telemetry, no usage tracking, no analytics.
- **Query logging** — every `graphty query`, `graphty path`, `graphty explain`, and MCP `query_graph` call is logged to `~/.cache/graphty-queries.log` in JSON Lines format (timestamp, question, corpus, nodes returned, duration). Full subgraph responses are **not** stored by default. Set `GRAPHTY_QUERY_LOG_DISABLE=1` to opt out, or `GRAPHTY_QUERY_LOG=/dev/null` to silence without disabling the code path.

---

## Troubleshooting

**`graphty: command not found` after `pip install graphtyy`**
pip installs scripts to a user bin directory that may not be on your PATH. Fix:
- macOS: add `~/Library/Python/3.x/bin` to your PATH in `~/.zshrc`
- Linux: add `~/.local/bin` to your PATH in `~/.bashrc`
- Or use `uv tool install graphtyy` / `pipx install graphtyy` — both manage PATH automatically.

**`python -m graphty` works but `graphty` command doesn't**
Your shell's PATH doesn't include the Python scripts directory. Use `uv` or `pipx` instead of plain `pip`.

**`/graphty .` causes "path not recognized" in PowerShell**
PowerShell treats a leading `/` as a path separator. Use `graphty .` (no slash) on Windows.

**Graph has fewer nodes after `--update` or rebuild**
If a refactor deleted files, the old nodes linger. Pass `--force` (or set `GRAPHTY_FORCE=1`) to overwrite even when the rebuild has fewer nodes.

**Graph has duplicate nodes for the same entity (ghost duplicates)**
Ghost duplicates (same symbol appearing twice — once from AST extraction with a source location, once from semantic extraction without) are now automatically merged at build time. If you see this in a graph built before v0.8.33, run a full re-extract to clean up:
```bash
graphty extract . --force
```

**Ollama runs out of VRAM / context window exceeded**
The KV-cache window is auto-sized but may be too large for your GPU. Reduce it:
```bash
GRAPHTY_OLLAMA_NUM_CTX=8192 graphty extract ./docs --backend ollama --token-budget 4000
```

**Graph HTML is too large to open in a browser (>5000 nodes)**
Skip HTML generation and use the JSON directly:
```bash
graphty cluster-only ./my-project --no-viz
graphty query "..."
```

**`graph.json` has conflict markers after two devs commit at once**
Run `graphty hook install` — it sets up a git merge driver that union-merges `graph.json` automatically so conflicts never happen.

**Extraction returns empty nodes/edges for docs or PDFs**
Docs, PDFs, and images require an LLM call — code-only corpora need no key. Check that your API key is set and the backend is correct:
```bash
ANTHROPIC_API_KEY=sk-... graphty extract ./docs --backend claude
```

**Skill version mismatch warning in your IDE**
Your installed graphty version is different from the skill file. Update:
```bash
uv tool upgrade graphtyy
graphty install  # overwrites the skill file
```

---

## Full command reference

```
/graphty                          # run on current directory
/graphty ./raw                    # run on a specific folder
/graphty ./raw --mode deep        # more aggressive relationship extraction
/graphty ./raw --update           # re-extract only changed files
/graphty ./raw --directed         # preserve edge direction
/graphty ./raw --cluster-only     # rerun clustering on existing graph
/graphty ./raw --no-viz           # skip HTML visualization
/graphty ./raw --obsidian         # generate Obsidian vault
/graphty ./raw --wiki             # build agent-crawlable markdown wiki
/graphty ./raw --svg              # export graph.svg
/graphty ./raw --graphml          # export for Gephi / yEd
/graphty ./raw --neo4j            # generate cypher.txt for Neo4j
/graphty ./raw --neo4j-push bolt://localhost:7687
/graphty ./raw --watch            # auto-sync as files change
/graphty ./raw --mcp              # start MCP stdio server

/graphty add https://arxiv.org/abs/1706.03762
/graphty add <video-url>
/graphty add https://... --author "Name" --contributor "Name"

/graphty query "what connects attention to the optimizer?"
/graphty query "..." --dfs --budget 1500
/graphty path "DigestAuth" "Response"
/graphty explain "SwinTransformer"

graphty uninstall                 # remove from all platforms in one shot
graphty uninstall --purge         # also delete graphty-out/
graphty uninstall --project --platform codex  # remove project-scoped install files only

graphty hook install              # post-commit + post-checkout hooks
graphty hook uninstall
graphty hook status

# always-on assistant instructions - platform-specific
graphty claude install            # CLAUDE.md + PreToolUse hook (Claude Code)
graphty claude uninstall
graphty codebuddy install         # CODEBUDDY.md + PreToolUse hook (CodeBuddy)
graphty codebuddy uninstall
graphty codex install             # AGENTS.md + PreToolUse hook in .codex/hooks.json (Codex)
graphty opencode install          # AGENTS.md + tool.execute.before plugin (OpenCode)
graphty kilo install              # native Kilo skill + /graphty command + AGENTS.md + .kilo plugin
graphty kilo uninstall
graphty cursor install            # .cursor/rules/graphty.mdc (Cursor)
graphty cursor uninstall
graphty gemini install            # GEMINI.md + BeforeTool hook (Gemini CLI)
graphty gemini uninstall
graphty copilot install           # skill file (GitHub Copilot CLI)
graphty copilot uninstall
graphty aider install             # AGENTS.md (Aider)
graphty aider uninstall
graphty claw install              # AGENTS.md (OpenClaw)
graphty claw uninstall
graphty droid install             # AGENTS.md (Factory Droid)
graphty droid uninstall
graphty trae install              # AGENTS.md (Trae)
graphty trae uninstall
graphty trae-cn install           # AGENTS.md (Trae CN)
graphty trae-cn uninstall
graphty hermes install             # AGENTS.md + ~/.hermes/skills/ (Hermes)
graphty hermes uninstall
graphty amp install               # skill file (Amp)
graphty amp uninstall
graphty kiro install               # .kiro/skills/ + .kiro/steering/graphty.md (Kiro IDE/CLI)
graphty kiro uninstall
graphty pi install                # skill file (Pi coding agent)
graphty pi uninstall
graphty devin install             # skill file + .windsurf/rules/graphty.md (Devin CLI)
graphty devin uninstall
graphty antigravity install       # .agents/rules + .agents/workflows (Google Antigravity)
graphty antigravity uninstall

graphty extract ./docs                        # headless LLM extraction for CI (no IDE needed)
graphty extract ./docs --backend gemini       # explicit backend: gemini, kimi, claude, openai, deepseek, ollama, bedrock, or claude-cli
graphty extract ./docs --backend gemini --model gemini-3.1-pro-preview
graphty extract ./docs --backend ollama       # local Ollama (set OLLAMA_BASE_URL / OLLAMA_MODEL) - no API key needed for loopback
GRAPHTY_OLLAMA_NUM_CTX=32768 graphty extract ./docs --backend ollama   # override KV-cache window (auto-sized by default)
GRAPHTY_OLLAMA_KEEP_ALIVE=0 graphty extract ./docs --backend ollama    # unload model after each chunk (saves VRAM on small GPUs)
graphty extract ./docs --backend bedrock      # AWS Bedrock via IAM - no API key, uses AWS credential chain
graphty extract ./docs --backend claude-cli   # route through Claude Code CLI - no API key, uses your Claude subscription
graphty extract ./docs --backend azure        # Azure OpenAI (set AZURE_OPENAI_API_KEY + AZURE_OPENAI_ENDPOINT)
graphty extract ./docs --max-workers 16       # AST parallelism (also GRAPHTY_MAX_WORKERS)
graphty extract --postgres "postgresql://user:pass@host/db"   # introspect live PostgreSQL schema directly
graphty extract ./docs --token-budget 30000   # smaller semantic chunks for local/small models
graphty extract ./docs --max-concurrency 2    # fewer parallel LLM calls (useful for local inference)
graphty extract ./docs --api-timeout 900      # longer HTTP timeout for slow local models (default 600s)
graphty extract ./docs --google-workspace     # export .gdoc/.gsheet/.gslides via gws before extraction
graphty extract ./docs --mode deep            # richer semantic extraction via extended system prompt
graphty extract ./docs --no-cluster           # raw extraction only, skip clustering
graphty extract ./docs --force                # overwrite graph.json even if new graph has fewer nodes (use after refactors or to clear ghost duplicates)
graphty extract ./docs --dedup-llm            # LLM tiebreaker for ambiguous entity pairs (uses same API key)
graphty extract ./docs --global --as myrepo   # extract and register into the cross-project global graph
GRAPHTY_MAX_OUTPUT_TOKENS=32768 graphty extract ./docs --backend claude  # raise output cap for dense corpora

graphty export callflow-html                       # graphty-out/<project>-callflow.html
graphty export callflow-html --max-sections 8      # cap generated architecture sections
graphty export callflow-html --output docs/arch.html
graphty export callflow-html ./some-repo/graphty-out

graphty global add graphty-out/graph.json myrepo   # register a project graph into ~/.graphty/global.json
graphty global remove myrepo                         # remove a project from the global graph
graphty global list                                  # show all registered repos + node/edge counts
graphty global path                                  # print path to the global graph file

graphty prs                              # PR dashboard: CI, review, worktree, graph impact
graphty prs 42                           # deep dive on PR #42
graphty prs --triage                     # AI triage ranking (auto-detects backend from env)
graphty prs --worktrees                  # worktree → branch → PR mapping
graphty prs --conflicts                  # PRs sharing graph communities (merge-order risk)
graphty prs --base main                  # filter to PRs targeting a specific base branch
graphty prs --repo owner/repo            # run against a different GitHub repo
GRAPHTY_TRIAGE_BACKEND=kimi graphty prs --triage   # use a specific backend for triage

graphty clone https://github.com/karpathy/nanoGPT
graphty merge-graphs a.json b.json --out merged.json
graphty --version                                    # print installed version
graphty watch ./src
graphty check-update ./src
graphty update ./src
graphty update ./src --no-cluster  # skip reclustering, write raw AST graph only
graphty update ./src --force       # overwrite even if new graph has fewer nodes
graphty cluster-only ./my-project
graphty cluster-only ./my-project --graph path/to/graph.json  # custom graph location
graphty cluster-only ./my-project --resolution 1.5            # more, smaller communities
graphty cluster-only ./my-project --exclude-hubs 99           # exclude p99 degree nodes from partitioning
graphty cluster-only ./my-project --no-label                  # keep "Community N" placeholders
graphty cluster-only ./my-project --backend=gemini            # backend for community naming
graphty label ./my-project                                    # (re)name communities with the configured backend
graphty label ./my-project --backend=openai                   # force a specific backend
```

> **Community names:** inside an agent (Claude Code, Gemini CLI) the agent names communities itself. When you run the bare CLI, `cluster-only` auto-names them with the configured backend (built-in or custom OpenAI-compatible provider) — pass `--no-label` to keep `Community N`, or run `graphty label` to (re)generate names on demand.

---

## Learn more

- [How it works](docs/how-it-works.md) — the extraction pipeline, community detection, confidence scoring, benchmarks
- [ARCHITECTURE.md](ARCHITECTURE.md) — module breakdown, how to add a language
- [Optional integrations](docs/docker-mcp-sqlite.md) — Docker MCP Toolkit + SQLite

---

<details>
<summary>Contributing</summary>

### Development setup

The project uses [uv](https://docs.astral.sh/uv/) for dev workflow. Install it once, then:

```bash
git clone https://github.com/m3rcha/graphty.git
cd graphty
git checkout v8                        # active development branch

# Create the project venv and install graphty + all extras + the dev group
# (pytest). uv installs the dev dependency group by default; pass --no-dev to
# skip it.
uv sync --all-extras
```

Verify the editable install:
```bash
uv run graphty --version
uv run python -c "import graphty; print(graphty.__file__)"
```

### Running tests

```bash
uv run pytest tests/ -q                # run the full suite
uv run pytest tests/test_extract.py -q # one module
uv run pytest tests/ -q -k "python"    # filter by name
```

> macOS note: the test suite includes both `sample.f90` and `sample.F90` fixtures. These collide on case-insensitive HFS+ / APFS file systems. Run on Linux or in a Docker container if you need to test both Fortran variants simultaneously.

### Git workflow

- Active development happens on the `v8` branch.
- Commit style: `fix: <description>` / `feat: <description>` / `docs: <description>`
- Before opening a PR, run `uv run pytest tests/ -q` and confirm it passes.
- Add a fixture file to `tests/fixtures/` and tests to `tests/test_languages.py` for any new language extractor.

### What to contribute

**Worked examples** are the most useful contribution. Run `/graphty` on a real corpus, save the output to `worked/{slug}/`, write an honest `review.md` covering what the graph got right and wrong, and open a PR.

**Extraction bugs** — open an issue with the input file, the cache entry (`graphty-out/cache/`), and what was missed or wrong.

See [ARCHITECTURE.md](ARCHITECTURE.md) for module responsibilities and how to add a language.

</details>
