소스 검색

update readme

Colby McHenry 5 달 전
부모
커밋
e306114607
2개의 변경된 파일90개의 추가작업 그리고 92개의 파일을 삭제
  1. 88 92
      README.md
  2. 2 0
      package.json

+ 88 - 92
README.md

@@ -1,54 +1,108 @@
 # CodeGraph
 
-A local-first code intelligence system that builds a semantic knowledge graph from any codebase. CodeGraph provides structural understanding of code relationships—not just text similarity—enabling AI assistants to understand how code connects, what depends on what, and what breaks when something changes.
+A local-first code intelligence system that builds a semantic knowledge graph from any codebase. Designed to give Claude Code deep understanding of code relationships.
 
-## Features
-
-- **Universal language support** via tree-sitter (TypeScript, JavaScript, Python, Go, Rust, Java, PHP, Ruby, C#, C, C++, Swift, Kotlin)
-- **Zero external API dependencies** — all processing happens locally
-- **Semantic search** — find code by meaning, not just text matching
-- **Graph-based code intelligence** — callers, callees, impact analysis, dependency chains
-- **Incremental updates** — only reindex changed files
-- **Git integration** — automatic sync via post-commit hooks
-- **MCP Server** — integrate directly with Claude Code and other AI assistants
+## Quick Start
 
-## Installation
+### 1. Install
 
 ```bash
-# Clone and install
-git clone <repository-url>
-cd codegraph
-npm install
+npm install -g @colbymchenry/codegraph
+```
+
+### 2. Configure Claude Code MCP
 
-# Build
-npm run build
+Add to your `~/.claude.json` in the `mcpServers` section:
 
-# Link globally (optional, for CLI usage)
-npm link
+```json
+{
+  "mcpServers": {
+    "codegraph": {
+      "type": "stdio",
+      "command": "codegraph",
+      "args": ["serve", "--mcp"]
+    }
+  }
+}
 ```
 
-### Requirements
+### 3. Add Global Instructions
 
-- Node.js >= 18.0.0
-- npm or yarn
+Create or append to `~/.claude/CLAUDE.md`:
 
-## Quick Start
+```markdown
+## CodeGraph
+
+CodeGraph builds a semantic knowledge graph of codebases for better code exploration.
+
+### If `.codegraph/` exists in the project
+
+Use the codegraph MCP tools instead of manually searching:
+
+- `codegraph_search` - Find symbols by name
+- `codegraph_context` - Get context for a task/issue
+- `codegraph_callers` - Find what calls a function
+- `codegraph_callees` - Find what a function calls
+- `codegraph_impact` - See what's affected by changing a symbol
+- `codegraph_node` - Get details about a specific symbol
+- `codegraph_status` - Check index status
+
+Use these tools when:
+- Exploring unfamiliar code
+- Finding where a function is used
+- Understanding dependencies before making changes
+- Building context for bug fixes or features
+
+The index auto-updates via git post-commit hook, so no manual sync needed.
+
+### If `.codegraph/` does NOT exist
+
+At the start of a session, ask the user if they'd like to initialize CodeGraph for better code intelligence:
+
+"I notice this project doesn't have CodeGraph initialized. Would you like me to run `codegraph init -i` to build a code knowledge graph? This enables smarter code exploration, caller/callee analysis, and impact detection."
+
+If they agree, run:
+codegraph init -i
+```
+
+### 4. Initialize Your Projects
 
 ```bash
-# Initialize CodeGraph in your project
-codegraph init /path/to/your/project
+cd your-project
+codegraph init -i    # Initialize and index
+```
 
-# Index the codebase (with progress)
-codegraph index /path/to/your/project
+### 5. Restart Claude Code
 
-# Search for symbols
-codegraph query "UserService"
+Restart Claude Code for the MCP server to load. The tools will be available in any project with a `.codegraph/` directory.
 
-# Build context for a task
-codegraph context "fix the login bug"
+---
 
-# Check index status
-codegraph status
+## Features
+
+- **Universal language support** via tree-sitter (TypeScript, JavaScript, Python, Go, Rust, Java, PHP, Ruby, C#, C, C++, Swift, Kotlin)
+- **Zero external API dependencies** — all processing happens locally
+- **Semantic search** — find code by meaning, not just text matching
+- **Graph-based code intelligence** — callers, callees, impact analysis, dependency chains
+- **Incremental updates** — only reindex changed files
+- **Git integration** — automatic sync via post-commit hooks
+- **MCP Server** — integrate directly with Claude Code and other AI assistants
+
+## Requirements
+
+- Node.js >= 18.0.0
+
+## CLI Usage
+
+```bash
+codegraph init [path]       # Initialize in a project
+codegraph index [path]      # Full index
+codegraph sync [path]       # Incremental update
+codegraph status [path]     # Show statistics
+codegraph query <search>    # Search symbols
+codegraph context <task>    # Build context for AI
+codegraph hooks install     # Install git auto-sync hook
+codegraph serve --mcp       # Start MCP server
 ```
 
 ## CLI Commands
@@ -139,70 +193,12 @@ codegraph serve --mcp                    # Start MCP server (stdio)
 codegraph serve --mcp --path /project    # Specify project path
 ```
 
-## Using with Claude Code (MCP)
-
-CodeGraph can be used as an MCP (Model Context Protocol) server, allowing Claude Code to directly query your codebase.
-
-### Setup
-
-1. Initialize and index your project:
-   ```bash
-   codegraph init /path/to/your/project --index
-   ```
-
-2. Add to your Claude Code MCP configuration (`~/.claude/claude_desktop_config.json` or similar):
-   ```json
-   {
-     "mcpServers": {
-       "codegraph": {
-         "command": "codegraph",
-         "args": ["serve", "--mcp", "--path", "/path/to/your/project"]
-       }
-     }
-   }
-   ```
-
-   Or if using npx:
-   ```json
-   {
-     "mcpServers": {
-       "codegraph": {
-         "command": "npx",
-         "args": ["codegraph", "serve", "--mcp", "--path", "/path/to/your/project"]
-       }
-     }
-   }
-   ```
-
-3. Restart Claude Code. The following tools will be available:
-
-### MCP Tools
-
-| Tool | Description |
-|------|-------------|
-| `codegraph_search` | Search for code symbols by name or semantic similarity |
-| `codegraph_context` | Build relevant code context for a task or issue |
-| `codegraph_callers` | Find all functions/methods that call a specific symbol |
-| `codegraph_callees` | Find all functions/methods that a symbol calls |
-| `codegraph_impact` | Analyze what code could be affected by changing a symbol |
-| `codegraph_node` | Get detailed information about a specific symbol |
-| `codegraph_status` | Get index statistics |
-
-### Example Prompts for Claude Code
-
-Once configured, you can ask Claude Code things like:
-
-- "Use codegraph to find all callers of the `authenticate` function"
-- "What would be impacted if I change the `UserService` class?"
-- "Build context for fixing the checkout bug"
-- "Search for all functions related to payment processing"
-
 ## Library Usage
 
 CodeGraph can also be used as a library in your Node.js applications:
 
 ```typescript
-import CodeGraph from 'codegraph';
+import CodeGraph from '@colbymchenry/codegraph';
 
 // Initialize a new project
 const cg = await CodeGraph.init('/path/to/project');

+ 2 - 0
package.json

@@ -10,6 +10,8 @@
   "scripts": {
     "build": "tsc && npm run copy-assets",
     "copy-assets": "cp -r src/extraction/queries dist/extraction/ && cp src/db/schema.sql dist/db/",
+    "dev": "tsc --watch",
+    "cli": "npm run build && node dist/bin/codegraph.js",
     "test": "vitest run",
     "test:watch": "vitest",
     "clean": "rm -rf dist"