Start the server:
codeindex serve [path] [options]| Option | Default | Description |
|---|---|---|
--port, -p |
3131 |
Server port |
--host |
127.0.0.1 |
Server host |
--api-key |
- | Require API key for endpoints |
--cors |
* |
CORS origin |
--rate-limit |
120 |
Requests per minute per IP |
codeindex serve . --port 3131 --host 0.0.0.0 --api-key my-secret-keyQuery the index for relevant context.
Request
{
"query": "How does authentication work?",
"maxTokens": 3000,
"maxSymbols": 10
}| Field | Type | Default | Description |
|---|---|---|---|
query |
string | required | Search query |
maxTokens |
number | 3000 |
Max tokens in response |
maxSymbols |
number | 10 |
Max symbols to include |
Response
{
"query": "How does authentication work?",
"estimatedTokens": 1450,
"traversalPath": ["root-descend [mod:src]", "modules: [mod:auth]", "selected: [file:src/auth/auth.service.ts]"],
"files": [
{
"path": "src/auth/auth.service.ts",
"symbols": ["AuthService", "login", "refreshToken"]
}
],
"context": "=== src/auth/auth.service.ts ===\nclass AuthService {\n async login(credentials) { ... }\n}"
}With API Key
curl -X POST http://localhost:3131/query \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{"query": "How does authentication work?"}'Trigger an incremental index update.
Request
{
"force": false
}| Field | Type | Default | Description |
|---|---|---|---|
force |
boolean | false |
Force full rebuild |
Response
{
"upToDate": false,
"filesUpdated": 3,
"filesNew": 1,
"filesDeleted": 0,
"durationMs": 2340
}With API Key
curl -X POST http://localhost:3131/update \
-H "X-API-Key: your-api-key"Get index health and statistics.
Response
{
"exists": true,
"projectName": "my-project",
"totalFiles": 142,
"totalSymbols": 892,
"builtAt": 1699000000000,
"isStale": false,
"staleFiles": []
}Server health check.
Response
{
"status": "ok",
"uptime": 3600,
"version": "0.1.0"
}Project-level configuration.
{
"provider": "openai",
"model": "gpt-4o",
"indexDir": ".index",
"projectName": "my-project",
"serverApiKey": "optional-api-key",
"serverCorsOrigin": "*",
"serverMaxBodyBytes": 1048576,
"serverRateLimitPerMinute": 120
}Global configuration (created by codeindex setup).
{
"provider": "openai",
"model": "gpt-4o",
"apiKey": "sk-...",
"baseURL": "https://api.openai.com/v1"
}| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key |
ANTHROPIC_API_KEY |
Anthropic API key |
GOOGLE_API_KEY |
Google AI API key |
CODEINDEX_PROVIDER |
Override default provider |
CODEINDEX_MODEL |
Override default model |
CODEINDEX_API_KEY |
Override API key |
import { IndexManager } from "@codeindex/core"
const manager = new IndexManager({
projectRoot: "/path/to/project",
projectName: "my-project",
llmClient: openAiClient,
adapters: [typescriptAdapter, pythonAdapter],
indexDir: ".index",
verbose: false
})
// Build index
const buildResult = await manager.build()
// Incremental update
const updateResult = await manager.update()
// Watch for changes
manager.watch({
debounceMs: 500,
onBatch: (changes) => console.log(changes)
})import { TreeTraversal } from "@codeindex/core"
const traversal = new TreeTraversal({
tree,
llmClient,
maxTokens: 3000,
maxSymbols: 10
})
const result = await traversal.traverse("How does auth work?")Interactive global configuration.
codeindex setupInitialize project in current directory.
codeindex init [path]Build or rebuild index.
codeindex index [path] [options]| Option | Description |
|---|---|
--verbose, -v |
Verbose output |
--force |
Force rebuild |
Query the index.
codeindex query "<text>" [options]| Option | Description |
|---|---|
--cwd |
Project directory |
--format |
Output format (text or json) |
--max-tokens |
Max tokens |
--verbose |
Show traversal path |
Incremental update.
codeindex update [path] [options]| Option | Description |
|---|---|
--force |
Force full rebuild |
Check index health.
codeindex status [path]Start HTTP server.
codeindex serve [path] [options]| Option | Default | Description |
|---|---|---|
--port, -p |
3131 |
Port |
--host |
127.0.0.1 |
Host |
--api-key |
- | Require API key |
--cors |
* |
CORS origin |
--rate-limit |
120 |
Rate limit |