Brand note:
codeiis the new product and CLI name forCodeindex. Theistands for bothindexandintelligentcontext retrieval. The published CLI package ispnftrading_codei, while the core and adapter packages are published underpnftrading_codei-*.
Start the server:
codei 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 |
codei 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-Codei-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-Codei-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. Recommended: keep this file minimal and put API/provider settings in the project's .env.
{
"indexDir": ".index",
"projectName": "my-project",
"summaryMode": "heuristic",
"serverApiKey": "optional-api-key",
"serverCorsOrigin": "*",
"serverMaxBodyBytes": 1048576,
"serverRateLimitPerMinute": 120
}summaryMode controls how codei generates file/module summaries:
| Mode | Behavior | LLM calls during index |
|---|---|---|
heuristic |
Build summaries locally from symbols/imports/exports | 0 |
llm |
Use LLM to generate summaries | High |
auto |
Heuristic-first, may use LLM in future versions | Low |
Recommended default: heuristic (stable and avoids provider rate limits).
You can override summaryMode per command:
codei index . --summary-mode heuristic
codei query "your question" --summary-mode heuristic
codei serve . --summary-mode heuristicYou can also inspect and manage caches:
codei status . --json
codei status . --clear-cacheOptional per-project override configuration.
NVIDIA_API_KEY=nvapi-...
CODEI_BASE_URL=https://integrate.api.nvidia.com/v1
# Optional:
# CODEI_PROVIDER=nvidia
# CODEI_MODEL=minimaxai/minimax-m3If NVIDIA_API_KEY or the NVIDIA base URL is present, codei can infer the NVIDIA provider automatically.
Recommended global runtime configuration when you want to run codei setup once and reuse it across all projects.
CODEI_PROVIDER=nvidia
CODEI_API_KEY=nvapi-...
CODEI_MODEL=minimaxai/minimax-m3
CODEI_BASE_URL=https://integrate.api.nvidia.com/v1Backward-compatible global configuration (also created by codei setup).
{
"provider": "nvidia",
"model": "minimaxai/minimax-m3",
"apiKey": "nvapi-...",
"baseURL": "https://integrate.api.nvidia.com/v1"
}| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key |
ANTHROPIC_API_KEY |
Anthropic API key |
GOOGLE_API_KEY |
Google AI API key |
NVIDIA_API_KEY |
NVIDIA API key |
CODEI_PROVIDER |
Override default provider |
CODEI_MODEL |
Override default model |
CODEI_BASE_URL |
Override API base URL |
CODEI_API_KEY |
Override API key |
When indexing, codei writes:
| Path | Description |
|---|---|
.index/tree.json |
Main tree index |
.index/meta.json |
Metadata + git hash map |
.index/summaries.json |
File summary cache (reused across index/update) |
.index/traversal-cache.json |
Persistent traversal cache for query results |
import { IndexManager } from "pnftrading_codei-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 "pnftrading_codei-core"
const traversal = new TreeTraversal({
tree,
llmClient,
maxTokens: 3000,
maxSymbols: 10
})
const result = await traversal.traverse("How does auth work?")Interactive optional global configuration.
codei setupInitialize project in current directory.
codei init [path]Build or rebuild index.
codei index [path] [options]| Option | Description |
|---|---|
--verbose, -v |
Verbose output |
--force |
Force rebuild |
Query the index.
codei query "<text>" [options]| Option | Description |
|---|---|
--cwd |
Project directory |
--format |
Output format (text or json) |
--max-tokens |
Max tokens |
--verbose |
Show traversal path |
Incremental update.
codei update [path] [options]| Option | Description |
|---|---|
--force |
Force full rebuild |
Check index health.
codei status [path]Start HTTP server.
codei 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 |