kiri-mcp-server 0.18.0 โ 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -897
- package/dist/package.json +7 -1
- package/dist/src/indexer/cli.d.ts.map +1 -1
- package/dist/src/indexer/cli.js +47 -7
- package/dist/src/indexer/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,127 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
> Intelligent code context extraction for LLMs via Model Context Protocol
|
|
4
4
|
|
|
5
|
-
[](package.json)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
[](https://modelcontextprotocol.io/)
|
|
9
9
|
|
|
10
|
-
**KIRI** is an MCP
|
|
10
|
+
**KIRI** is an MCP server that provides intelligent code context extraction from Git repositories. It indexes your codebase into DuckDB and exposes semantic search tools for LLMs.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Why KIRI?
|
|
13
13
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
- **๐ Concurrency-Safe** _(v0.9.7+)_: Per-database queues, canonicalized DuckDB paths, and bootstrap-safe locking prevent FTS rebuild conflicts and keep locks consistent across symlinksโeven on first run
|
|
14
|
+
- **MCP Native**: Plug-and-play with Claude Desktop, Codex CLI, and other MCP clients
|
|
15
|
+
- **Smart Context**: Extract minimal, relevant code fragments based on task goals
|
|
16
|
+
- **Accurate**: MRR 1.0 โ the most relevant file always ranks first
|
|
17
|
+
- **Fast**: Sub-second response time for most queries
|
|
18
|
+
- **Semantic Search**: Multi-word queries, dependency analysis, BM25 ranking
|
|
19
|
+
- **Auto-Sync**: Watch mode automatically re-indexes on file changes
|
|
20
|
+
- **Phrase-Aware**: Recognizes compound terms (kebab-case, snake_case)
|
|
22
21
|
|
|
23
|
-
##
|
|
22
|
+
## Quick Start
|
|
24
23
|
|
|
25
|
-
###
|
|
26
|
-
|
|
27
|
-
- **Rust code intelligence**: tree-sitter-rust based analyzer extracts symbols/snippets (struct/enum/trait/impl/fn/mod/const/static/type/macro) and resolves imports, module files, and extern crates for dependency graph integration
|
|
28
|
-
- **shirushi document ID management**: Document ID uniqueness validation and management via shirushi linting
|
|
29
|
-
|
|
30
|
-
### ๐ง Improvements
|
|
31
|
-
|
|
32
|
-
- **Clean Architecture refactoring**: Reorganized language analyzers using Clean Architecture for improved extensibility and maintainability
|
|
33
|
-
|
|
34
|
-
### ๐ Bug Fixes
|
|
35
|
-
|
|
36
|
-
- **Rust imports resolution**: Fixed resolution of Rust imports ending with items
|
|
37
|
-
- **Build cleanup**: Clean dist directory before build to prevent stale files from persisting
|
|
38
|
-
|
|
39
|
-
### Previous Releases
|
|
40
|
-
|
|
41
|
-
- **v0.17.0**: `code` boost_profile, graph metrics retry logic
|
|
42
|
-
- **v0.16.1**: Graceful degradation for graph layer tables
|
|
43
|
-
- **v0.16.0**: DuckDB client migration to `@duckdb/node-api`
|
|
44
|
-
- **v0.15.0**: `snippets_get` view parameter, co-change scoring, stop words & IDF weighting
|
|
45
|
-
|
|
46
|
-
## โ๏ธ Prerequisites
|
|
47
|
-
|
|
48
|
-
Before using KIRI, ensure you have:
|
|
49
|
-
|
|
50
|
-
- **Node.js** v18.0.0 or higher
|
|
51
|
-
- **npm** v9.0.0 or higher
|
|
52
|
-
- **Git** v2.0 or higher
|
|
53
|
-
- A Git repository to index
|
|
54
|
-
|
|
55
|
-
Check your versions:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
node --version # Should be >= v18.0.0
|
|
59
|
-
npm --version # Should be >= v9.0.0
|
|
60
|
-
git --version # Should be >= v2.0
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## โ ๏ธ Troubleshooting
|
|
64
|
-
|
|
65
|
-
### Migration or Database Issues
|
|
66
|
-
|
|
67
|
-
If you encounter issues after upgrading (database corruption, migration failures, etc.), the simplest solution is to delete the database and let KIRI recreate it:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
# For MCP users (Claude Code, Codex CLI, etc.)
|
|
71
|
-
# 1. Restart your MCP client to stop the KIRI server
|
|
72
|
-
# 2. Delete the database
|
|
73
|
-
rm -rf .kiri/
|
|
74
|
-
# 3. Restart your MCP client - KIRI will automatically reindex
|
|
75
|
-
|
|
76
|
-
# For CLI/Daemon users
|
|
77
|
-
pkill -f "kiri.*daemon" # Stop daemon if running
|
|
78
|
-
rm -rf .kiri/ # Delete database
|
|
79
|
-
kiri --repo . --db .kiri/index.duckdb --full # Reindex
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
> **Note**: Deleting the database is safe - it only removes the index, not your source code. KIRI will automatically rebuild the index on next startup. For MCP users, no manual reindexing is needed.
|
|
83
|
-
|
|
84
|
-
## ๐ Quick Start for MCP Users
|
|
85
|
-
|
|
86
|
-
### Step 1: Install KIRI
|
|
87
|
-
|
|
88
|
-
Choose one of the following methods:
|
|
89
|
-
|
|
90
|
-
**Option A: Global Installation (Recommended)**
|
|
24
|
+
### 1. Install
|
|
91
25
|
|
|
92
26
|
```bash
|
|
93
27
|
npm install -g kiri-mcp-server
|
|
94
28
|
```
|
|
95
29
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
- [Authoring Docs for KIRI Search](docs/documentation-best-practices.md) โ best practices for writing metadata-rich, link-aware documentation so that `context_bundle` and the docs vs. docs-plain benchmark maintain high precision. Includes guidance on querying custom front-matter keys via `meta.<key>:<value>` (for example, `meta.id:runbook-001`).
|
|
99
|
-
- [Path Penalties (User Guide)](docs/user/path-penalties.md) โ `.kiri/config.yaml` ใจ็ฐๅขๅคๆฐใงใในๅ็ใ่จญๅฎใใๆ้ ใๅชๅ
้ ไฝใๆญฃ่ฆๅใซใผใซใ้ฉ็จใฟใคใใณใฐใใพใจใใใฆใผใถใผๅใใฌใคใใ
|
|
100
|
-
|
|
101
|
-
> **Note**: This installs the `kiri` command globally. You can verify with `kiri --version`.
|
|
30
|
+
Or use `npx` without installation.
|
|
102
31
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
No permanent installation neededโ`npx` downloads and caches the package on first use. Just configure your MCP client to use `npx`.
|
|
106
|
-
|
|
107
|
-
### Step 2: Configure Your MCP Client
|
|
108
|
-
|
|
109
|
-
#### For Claude Code
|
|
32
|
+
### 2. Configure Claude Code
|
|
110
33
|
|
|
111
34
|
Edit `~/.claude/mcp.json`:
|
|
112
35
|
|
|
113
|
-
```json
|
|
114
|
-
{
|
|
115
|
-
"mcpServers": {
|
|
116
|
-
"kiri": {
|
|
117
|
-
"command": "npx",
|
|
118
|
-
"args": ["kiri-mcp-server@latest", "--repo", ".", "--db", ".kiri/index.duckdb", "--watch"]
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
**With Global Installation:**
|
|
125
|
-
|
|
126
36
|
```json
|
|
127
37
|
{
|
|
128
38
|
"mcpServers": {
|
|
@@ -134,869 +44,181 @@ Edit `~/.claude/mcp.json`:
|
|
|
134
44
|
}
|
|
135
45
|
```
|
|
136
46
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
For very large repositories (10,000+ files), you may need to increase the timeout:
|
|
140
|
-
|
|
141
|
-
```json
|
|
142
|
-
{
|
|
143
|
-
"mcpServers": {
|
|
144
|
-
"kiri": {
|
|
145
|
-
"command": "kiri",
|
|
146
|
-
"args": ["--repo", ".", "--db", ".kiri/index.duckdb", "--watch"],
|
|
147
|
-
"env": {
|
|
148
|
-
"KIRI_DAEMON_READY_TIMEOUT": "480"
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
> **Note**: The example shows `480` seconds (8 minutes) for very large repositories (>20,000 files). The default `240` seconds (4 minutes) is sufficient for most projects with <10,000 files.
|
|
156
|
-
|
|
157
|
-
| Variable | Default | Description |
|
|
158
|
-
| --------------------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
159
|
-
| `KIRI_DAEMON_READY_TIMEOUT` | `240` | Daemon initialization timeout in seconds. Increase for very large repositories |
|
|
160
|
-
| `KIRI_SOCKET_DIR` | OS tmp directory | Directory for Unix socket fallback when repo paths are too long (e.g., `/var/run/kiri`). Keeps worktree sockets short |
|
|
161
|
-
|
|
162
|
-
> **Tip**: If you encounter `listen EINVAL` on deep worktrees, set `export KIRI_SOCKET_DIR=/var/run/kiri` (or any short 0700 directory) before launching `kiri`. This fallback ships in v0.9.9+, and an explicit path keeps logs and cleanup predictable.
|
|
163
|
-
|
|
164
|
-
**Dart Analysis Server Configuration:**
|
|
165
|
-
|
|
166
|
-
For projects containing Dart code, KIRI uses the Dart Analysis Server to extract accurate symbol information. The following environment variables control the Dart analyzer behavior:
|
|
167
|
-
|
|
168
|
-
| Variable | Default | Description |
|
|
169
|
-
| ------------------------------ | ------- | ------------------------------------------------------------------------------------------------- |
|
|
170
|
-
| `DART_SDK_DETECT_TIMEOUT_MS` | `5000` | Timeout in milliseconds for SDK detection (prevents hanging on network issues) |
|
|
171
|
-
| `DART_ANALYSIS_MAX_CLIENTS` | `8` | Maximum concurrent Dart Analysis Server processes (prevents memory exhaustion on large monorepos) |
|
|
172
|
-
| `DART_ANALYSIS_CLIENT_WAIT_MS` | `10000` | Max wait time in milliseconds for available analysis server slot |
|
|
173
|
-
| `DART_ANALYSIS_IDLE_MS` | `60000` | Idle time in milliseconds before disposing unused analysis server (60s default) |
|
|
174
|
-
| `DART_FILE_QUEUE_TTL_MS` | `30000` | TTL in milliseconds for file-level request queues (prevents memory leaks) |
|
|
175
|
-
|
|
176
|
-
**When to adjust these values:**
|
|
177
|
-
|
|
178
|
-
- **Large Dart projects (>500 files)**: Increase `DART_ANALYSIS_MAX_CLIENTS` to 16 or 32
|
|
179
|
-
- **Network/UNC path issues**: Decrease `DART_SDK_DETECT_TIMEOUT_MS` to 2000 for faster failure
|
|
180
|
-
- **Memory constraints**: Decrease `DART_ANALYSIS_MAX_CLIENTS` to 4 and increase `DART_ANALYSIS_IDLE_MS` to 30000
|
|
181
|
-
- **Monorepo with many workspaces**: Increase `DART_ANALYSIS_CLIENT_WAIT_MS` to 30000
|
|
182
|
-
|
|
183
|
-
#### For Codex CLI
|
|
184
|
-
|
|
185
|
-
Edit `~/.config/codex/mcp.toml`:
|
|
186
|
-
|
|
187
|
-
```toml
|
|
188
|
-
[mcp_servers.kiri]
|
|
189
|
-
command = "npx"
|
|
190
|
-
args = ["kiri-mcp-server@latest", "--repo", ".", "--db", ".kiri/index.duckdb", "--watch"]
|
|
191
|
-
startup_timeout_sec = 240
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
**With Global Installation:**
|
|
195
|
-
|
|
196
|
-
```toml
|
|
197
|
-
[mcp_servers.kiri]
|
|
198
|
-
command = "kiri"
|
|
199
|
-
args = ["--repo", ".", "--db", ".kiri/index.duckdb", "--watch"]
|
|
200
|
-
startup_timeout_sec = 240
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
| Parameter | Default | Description |
|
|
204
|
-
| --------------------- | ------- | ----------------------------------------------------------------------------- |
|
|
205
|
-
| `startup_timeout_sec` | `30` | Daemon initialization timeout in seconds. Set to `240` for large repositories |
|
|
206
|
-
|
|
207
|
-
**Note**: The default internal timeout was increased from 30s to 240s in v0.3.0. We recommend setting `startup_timeout_sec = 240` explicitly for Codex CLI.
|
|
208
|
-
|
|
209
|
-
### Step 3: Restart Your MCP Client
|
|
210
|
-
|
|
211
|
-
Restart Claude Desktop or Codex CLI to load the KIRI server. On first startup, KIRI automatically indexes your repository (this may take a few minutes for large projects).
|
|
212
|
-
|
|
213
|
-
### Step 4: Start Using KIRI Tools
|
|
214
|
-
|
|
215
|
-
Once configured, you can use KIRI tools in your conversations with Claude:
|
|
216
|
-
|
|
217
|
-
- **Search for files**: "Find files related to authentication"
|
|
218
|
-
- **Get code context**: "Show me the implementation of the user login flow"
|
|
219
|
-
- **Analyze dependencies**: "What files depend on utils.ts?"
|
|
220
|
-
- **Extract snippets**: "Show me the handleRequest function"
|
|
221
|
-
|
|
222
|
-
## ๐ MCP Tools Reference
|
|
223
|
-
|
|
224
|
-
KIRI provides 5 MCP tools for intelligent code exploration:
|
|
225
|
-
|
|
226
|
-
### 1. context_bundle
|
|
227
|
-
|
|
228
|
-
**Extract relevant code context based on task goals (95% accuracy)**
|
|
229
|
-
|
|
230
|
-
The most powerful tool for getting started with unfamiliar code. Provide a task description, and KIRI returns the most relevant code snippets using phrase-aware tokenization and path-based scoring.
|
|
231
|
-
|
|
232
|
-
Tip: Avoid leading command words like `find` or `show`; instead list concrete modules, files, and observed symptoms to keep rankings sharp.
|
|
233
|
-
|
|
234
|
-
> **Docs search tip:** Set `boost_profile: "docs"` and include metadata filters when the target lives under `docs/`. Front matter keys are queryable via `meta.<key>:<value>` or `frontmatter.<key>:<value>` โ e.g., `meta.id:runbook-001`, `tag:degrade`, `category:operations`. Use `docmeta.<key>:<value>` (or legacy `metadata.<key>`) when you want strict doc-only filtering. See the [Metadata alias reference](docs/documentation-best-practices.md#metadata-aliases--filters) for the full list. This keeps `context_bundle` aligned with the docs vs docs-plain benchmark expectations.
|
|
235
|
-
|
|
236
|
-
**v0.8.0 improvements:**
|
|
237
|
-
|
|
238
|
-
- **โก Compact mode default (BREAKING)**: `compact: true` is now default, reducing token usage by ~95% (55K โ 2.5K tokens). Set `compact: false` to restore full preview mode.
|
|
239
|
-
- **๐ง Separated config penalties**: Configuration files (`.json`, `.yaml`, `.env`) now have independent 95% penalty (ร0.05), separate from documentation penalty (ร0.5)
|
|
240
|
-
- **๐ Multi-language config support**: Recognizes config files across all languages (`package.json`, `tsconfig.json`, `composer.json`, `Gemfile`, etc.)
|
|
241
|
-
- **๐ก๏ธ Production hardening**: Memory leak prevention in WarningManager, configurable warning limits, improved path matching
|
|
242
|
-
|
|
243
|
-
**v0.7.0 improvements:**
|
|
244
|
-
|
|
245
|
-
- **Multiplicative penalties**: Documentation files now penalized by ร0.5 (50% reduction) instead of additive -2.0
|
|
246
|
-
- **Implementation prioritization**: Implementation files rank 3-5ร higher than documentation
|
|
247
|
-
- **Unified boosting logic**: Consistent file ranking across `files_search` and `context_bundle`
|
|
248
|
-
- **Configurable profiles**: `boost_profile` parameter supports "default" (implementation-first), "docs" (documentation-first), or "none" (natural BM25)
|
|
249
|
-
|
|
250
|
-
**When to use:**
|
|
251
|
-
|
|
252
|
-
- Understanding how a feature works
|
|
253
|
-
- Finding implementation patterns
|
|
254
|
-
- Gathering context before making changes
|
|
255
|
-
- Exploring unfamiliar codebases
|
|
256
|
-
|
|
257
|
-
**Example:**
|
|
258
|
-
|
|
259
|
-
```typescript
|
|
260
|
-
// Request
|
|
261
|
-
{
|
|
262
|
-
"goal": "auth token refresh bug; file=src/server/auth/session.ts; symptom=expired tokens accepted",
|
|
263
|
-
"limit": 10
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Returns: Relevant snippets from auth-related files, ranked by relevance
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
**Parameters:**
|
|
270
|
-
|
|
271
|
-
| Parameter | Type | Required | Description |
|
|
272
|
-
| --------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
273
|
-
| `goal` | string | Yes | Task description or question about the code |
|
|
274
|
-
| `limit` | number | No | Max snippets to return (default: 12, max: 20) |
|
|
275
|
-
| `compact` | boolean | No | Return only metadata without preview (default: **true** in v0.8.0+, false in v0.7) |
|
|
276
|
-
| `boost_profile` | string | No | File type boosting: `"default"` (prioritizes src/, blacklists docs/), `"code"` (strongly deprioritizes docs/config, 95% penalty), `"docs"` (prioritizes .md/.yaml, includes docs/ directory), `"balanced"` (equal weight for docs and impl), `"none"` (no boosting) |
|
|
277
|
-
|
|
278
|
-
### 2. files_search
|
|
279
|
-
|
|
280
|
-
**Full-text search with multi-word queries**
|
|
281
|
-
|
|
282
|
-
Fast search across all indexed files. Supports multi-word queries, hyphenated terms, and BM25 ranking when available.
|
|
283
|
-
|
|
284
|
-
**When to use:**
|
|
285
|
-
|
|
286
|
-
- Finding files by name or content
|
|
287
|
-
- Searching for specific keywords or patterns
|
|
288
|
-
- Locating API endpoints or configuration
|
|
289
|
-
|
|
290
|
-
**Example:**
|
|
291
|
-
|
|
292
|
-
```typescript
|
|
293
|
-
// Request
|
|
294
|
-
{
|
|
295
|
-
"query": "MCP server handler",
|
|
296
|
-
"limit": 20
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Returns: Files containing any of these words (OR logic)
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
**Query Syntax:**
|
|
303
|
-
|
|
304
|
-
- Multi-word: `"tools call implementation"` โ Finds files containing ANY word
|
|
305
|
-
- Hyphenated: `"MCP-server-handler"` โ Splits on hyphens and searches each part
|
|
306
|
-
- Single word: `"DuckDB"` โ Exact match
|
|
307
|
-
- Metadata filter: `meta.<key>:<value>` / `frontmatter.<key>:<value>` matches front matter (e.g., `meta.id:runbook-001`); `tag:<value>` / `category:<value>` remain shorthand aliases for those standard keys. Use `docmeta.<key>:<value>` (or `metadata.<key>`) when you need strict doc-only filtering.
|
|
308
|
-
|
|
309
|
-
> **Docs search tip:** Combine `boost_profile: "docs"` (either by parameter or CLI flag) with metadata filters for Markdown corpora. Refer to the [Metadata alias reference](docs/documentation-best-practices.md#metadata-aliases--filters) when issuing `files_search` requests so the same filters you use in benchmarks carry over to ad-hoc queries, and switch to `docmeta.*` when you want docs only.
|
|
310
|
-
|
|
311
|
-
**Parameters:**
|
|
312
|
-
|
|
313
|
-
| Parameter | Type | Required | Description |
|
|
314
|
-
| --------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
315
|
-
| `query` | string | Yes | Search keywords or phrase |
|
|
316
|
-
| `limit` | number | No | Max results to return (default: 50, max: 200) |
|
|
317
|
-
| `lang` | string | No | Filter by language (e.g., "typescript", "python") |
|
|
318
|
-
| `ext` | string | No | Filter by extension (e.g., ".ts", ".md") |
|
|
319
|
-
| `path_prefix` | string | No | Filter by path prefix (e.g., "src/auth/") |
|
|
320
|
-
| `boost_profile` | string | No | File type boosting: `"default"` (prioritizes src/, blacklists docs/), `"code"` (strongly deprioritizes docs/config, 95% penalty), `"docs"` **(prioritizes .md/.yaml, includes docs/ directory)**, `"balanced"` (equal weight), `"none"` (no boosting) |
|
|
321
|
-
|
|
322
|
-
### 3. snippets_get
|
|
323
|
-
|
|
324
|
-
**Retrieve code snippets with symbol boundaries**
|
|
47
|
+
### 3. Restart Claude Code
|
|
325
48
|
|
|
326
|
-
|
|
49
|
+
KIRI automatically indexes your repository on first startup.
|
|
327
50
|
|
|
328
|
-
**
|
|
51
|
+
> **Other MCP clients**: See [Setup Guide](docs/setup.md) for Codex CLI and other configurations.
|
|
329
52
|
|
|
330
|
-
|
|
331
|
-
- Extracting a code section you already know about
|
|
332
|
-
- Getting implementation details
|
|
53
|
+
## MCP Tools
|
|
333
54
|
|
|
334
|
-
|
|
55
|
+
| Tool | Purpose | Example |
|
|
56
|
+
| ----------------- | ----------------------------- | -------------------------------- |
|
|
57
|
+
| `context_bundle` | Find relevant code for a task | `goal: "auth token refresh bug"` |
|
|
58
|
+
| `files_search` | Search files by keywords | `query: "handler"` |
|
|
59
|
+
| `snippets_get` | Read specific code sections | `path: "src/server/handlers.ts"` |
|
|
60
|
+
| `deps_closure` | Analyze dependencies | `direction: "inbound"` |
|
|
61
|
+
| `semantic_rerank` | Refine search results | `candidates: [...]` |
|
|
335
62
|
|
|
336
|
-
|
|
337
|
-
// Request
|
|
338
|
-
{
|
|
339
|
-
"path": "src/server/handlers.ts",
|
|
340
|
-
"start_line": 100
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
// Returns: Code snippet starting at line 100, aligned to symbol boundary
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
**Parameters:**
|
|
63
|
+
> **Full documentation**: [Tools Reference](docs/tools-reference.md)
|
|
347
64
|
|
|
348
|
-
|
|
349
|
-
| ------------ | ------ | -------- | ------------------------------------- |
|
|
350
|
-
| `path` | string | Yes | File path relative to repository root |
|
|
351
|
-
| `start_line` | number | No | Starting line number |
|
|
352
|
-
| `end_line` | number | No | Ending line number (inclusive) |
|
|
65
|
+
## Supported Languages
|
|
353
66
|
|
|
354
|
-
|
|
67
|
+
| Language | Extensions | Parser |
|
|
68
|
+
| ---------- | ------------- | ----------------------- |
|
|
69
|
+
| TypeScript | `.ts`, `.tsx` | TypeScript Compiler API |
|
|
70
|
+
| Swift | `.swift` | tree-sitter-swift |
|
|
71
|
+
| PHP | `.php` | tree-sitter-php |
|
|
72
|
+
| Java | `.java` | tree-sitter-java |
|
|
73
|
+
| Dart | `.dart` | Dart Analysis Server |
|
|
74
|
+
| Rust | `.rs` | tree-sitter-rust |
|
|
355
75
|
|
|
356
|
-
|
|
76
|
+
Other languages are indexed but use full-file snippets instead of symbol extraction.
|
|
357
77
|
|
|
358
|
-
|
|
78
|
+
## Troubleshooting
|
|
359
79
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
- Understanding what a file depends on
|
|
363
|
-
- Finding all files affected by a change (impact analysis)
|
|
364
|
-
- Tracing import chains
|
|
365
|
-
- Refactoring planning
|
|
366
|
-
|
|
367
|
-
**Example:**
|
|
368
|
-
|
|
369
|
-
```typescript
|
|
370
|
-
// Outbound: What does this file import?
|
|
371
|
-
{
|
|
372
|
-
"path": "src/server/handlers.ts",
|
|
373
|
-
"direction": "outbound",
|
|
374
|
-
"max_depth": 2
|
|
375
|
-
}
|
|
80
|
+
### Database Issues
|
|
376
81
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
"max_depth": 3
|
|
382
|
-
}
|
|
82
|
+
```bash
|
|
83
|
+
# Delete and rebuild
|
|
84
|
+
rm -rf .kiri/
|
|
85
|
+
# Restart MCP client - KIRI will automatically reindex
|
|
383
86
|
```
|
|
384
87
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
| Parameter | Type | Required | Description |
|
|
388
|
-
| ------------------ | ------- | -------- | ------------------------------------- |
|
|
389
|
-
| `path` | string | Yes | Starting file path |
|
|
390
|
-
| `direction` | string | Yes | "outbound" or "inbound" |
|
|
391
|
-
| `max_depth` | number | No | Max traversal depth (default: 3) |
|
|
392
|
-
| `include_packages` | boolean | No | Include npm packages (default: false) |
|
|
393
|
-
|
|
394
|
-
### 5. semantic_rerank
|
|
395
|
-
|
|
396
|
-
**Re-rank candidates by semantic similarity**
|
|
397
|
-
|
|
398
|
-
Refine search results by semantic relevance to your specific query. Useful when you have too many results and need better ranking.
|
|
399
|
-
|
|
400
|
-
**When to use:**
|
|
88
|
+
### Daemon Timeout (Large Repositories)
|
|
401
89
|
|
|
402
|
-
|
|
403
|
-
- When you need more precise relevance ranking
|
|
404
|
-
- Refining context_bundle results for specific needs
|
|
405
|
-
|
|
406
|
-
**Example:**
|
|
407
|
-
|
|
408
|
-
```typescript
|
|
409
|
-
// Request
|
|
90
|
+
```json
|
|
410
91
|
{
|
|
411
|
-
"
|
|
412
|
-
"candidates": [
|
|
413
|
-
{ "path": "src/auth/oauth.ts", "score": 0.8 },
|
|
414
|
-
{ "path": "src/auth/jwt.ts", "score": 0.7 },
|
|
415
|
-
{ "path": "src/utils/crypto.ts", "score": 0.6 }
|
|
416
|
-
],
|
|
417
|
-
"k": 2
|
|
92
|
+
"env": { "KIRI_DAEMON_READY_TIMEOUT": "480" }
|
|
418
93
|
}
|
|
419
|
-
|
|
420
|
-
// Returns: Top 2 candidates re-ranked by semantic similarity
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
**Parameters:**
|
|
424
|
-
|
|
425
|
-
| Parameter | Type | Required | Description |
|
|
426
|
-
| ------------ | ------ | -------- | ------------------------------------ |
|
|
427
|
-
| `text` | string | Yes | Query or goal text for comparison |
|
|
428
|
-
| `candidates` | array | Yes | Array of {path, score?} objects |
|
|
429
|
-
| `k` | number | No | Number of top results (default: all) |
|
|
430
|
-
|
|
431
|
-
## ๐ก Common Use Cases
|
|
432
|
-
|
|
433
|
-
### 1. Understanding a New Codebase
|
|
434
|
-
|
|
435
|
-
**Goal**: Quickly understand how authentication works in an unfamiliar project
|
|
436
|
-
|
|
437
|
-
```
|
|
438
|
-
You: "How does user authentication work in this project?"
|
|
439
|
-
|
|
440
|
-
Claude (using KIRI):
|
|
441
|
-
1. Uses context_bundle with goal "user authentication flow JWT validation session management"
|
|
442
|
-
2. Analyzes returned snippets
|
|
443
|
-
3. Explains the authentication flow with code references
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
### 2. Finding Related Code
|
|
447
|
-
|
|
448
|
-
**Goal**: Find all files related to API endpoints
|
|
449
|
-
|
|
450
|
-
```
|
|
451
|
-
You: "Find all API endpoint handlers"
|
|
452
|
-
|
|
453
|
-
Claude (using KIRI):
|
|
454
|
-
1. Uses files_search with query "API endpoint handler"
|
|
455
|
-
2. Uses deps_closure to find related files
|
|
456
|
-
3. Lists all relevant files with descriptions
|
|
457
94
|
```
|
|
458
95
|
|
|
459
|
-
###
|
|
460
|
-
|
|
461
|
-
**Goal**: Understand what will be affected by changing a utility function
|
|
462
|
-
|
|
463
|
-
```
|
|
464
|
-
You: "If I change the parseRequest function in utils.ts, what will be affected?"
|
|
465
|
-
|
|
466
|
-
Claude (using KIRI):
|
|
467
|
-
1. Uses deps_closure with direction="inbound" on utils.ts
|
|
468
|
-
2. Analyzes all dependent files
|
|
469
|
-
3. Explains potential impact of the change
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
### 4. Code Review Preparation
|
|
473
|
-
|
|
474
|
-
**Goal**: Get context for reviewing a pull request
|
|
475
|
-
|
|
476
|
-
```
|
|
477
|
-
You: "Show me the context for the authentication module changes"
|
|
478
|
-
|
|
479
|
-
Claude (using KIRI):
|
|
480
|
-
1. Uses context_bundle for authentication-related code
|
|
481
|
-
2. Uses snippets_get for specific changed files
|
|
482
|
-
3. Provides comprehensive context for review
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
## ๐ง Advanced Configuration
|
|
486
|
-
|
|
487
|
-
### Watch Mode
|
|
488
|
-
|
|
489
|
-
KIRI can automatically re-index your repository when files change:
|
|
96
|
+
### Stale Lock File
|
|
490
97
|
|
|
491
98
|
```bash
|
|
492
|
-
|
|
493
|
-
kiri --repo . --db .kiri/index.duckdb --watch
|
|
494
|
-
|
|
495
|
-
# Customize debounce timing (default: 500ms)
|
|
496
|
-
kiri --repo . --db .kiri/index.duckdb --watch --debounce 1000
|
|
99
|
+
rm -f .kiri/index.duckdb.sock.lock
|
|
497
100
|
```
|
|
498
101
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
- **Debouncing**: Aggregates rapid changes to minimize reindex operations
|
|
502
|
-
- **Incremental Indexing**: Only reindexes changed files (10-100x faster)
|
|
503
|
-
- **Background Operation**: Doesn't interrupt ongoing queries
|
|
504
|
-
- **Denylist Integration**: Respects `.gitignore` and `denylist.yml`
|
|
505
|
-
- **Lock Management**: Prevents concurrent indexing
|
|
506
|
-
- **Statistics**: Tracks reindex count, duration, and queue depth
|
|
507
|
-
|
|
508
|
-
### Tokenization Strategy
|
|
509
|
-
|
|
510
|
-
Control how KIRI tokenizes and matches compound terms using the `KIRI_TOKENIZATION_STRATEGY` environment variable:
|
|
102
|
+
### Version Mismatch After Upgrade
|
|
511
103
|
|
|
512
104
|
```bash
|
|
513
|
-
|
|
514
|
-
export KIRI_TOKENIZATION_STRATEGY=phrase-aware
|
|
515
|
-
|
|
516
|
-
# Legacy: Traditional word-by-word tokenization
|
|
517
|
-
export KIRI_TOKENIZATION_STRATEGY=legacy
|
|
518
|
-
|
|
519
|
-
# Hybrid: Both phrase and word-level matching
|
|
520
|
-
export KIRI_TOKENIZATION_STRATEGY=hybrid
|
|
105
|
+
pkill -f "kiri.*daemon"
|
|
521
106
|
```
|
|
522
107
|
|
|
523
|
-
**
|
|
524
|
-
|
|
525
|
-
- **`phrase-aware`** (default): Compound terms like `page-agent`, `user_profile` are treated as single phrases with 2ร scoring weight. Best for codebases with consistent naming conventions.
|
|
526
|
-
- **`legacy`**: Traditional tokenization that splits all delimiters. Use for backward compatibility.
|
|
527
|
-
- **`hybrid`**: Combines both strategies for maximum flexibility.
|
|
528
|
-
|
|
529
|
-
### Database Auto-Gitignore
|
|
530
|
-
|
|
531
|
-
KIRI automatically creates `.gitignore` files in database directories to prevent accidental commits:
|
|
108
|
+
> **More issues**: See [full troubleshooting guide](#detailed-troubleshooting) below.
|
|
532
109
|
|
|
533
|
-
|
|
534
|
-
// Enabled by default
|
|
535
|
-
const db = await DuckDBClient.connect({
|
|
536
|
-
databasePath: ".kiri/index.duckdb",
|
|
537
|
-
autoGitignore: true, // Creates .gitignore with "*" pattern
|
|
538
|
-
});
|
|
110
|
+
## For Developers
|
|
539
111
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
**Behavior:**
|
|
548
|
-
|
|
549
|
-
- Only creates `.gitignore` if directory is inside a Git repository
|
|
550
|
-
- Never overwrites existing `.gitignore` files
|
|
551
|
-
- Uses wildcard pattern (`*`) to ignore all database files
|
|
552
|
-
|
|
553
|
-
### File Type Boosting
|
|
554
|
-
|
|
555
|
-
Control search ranking behavior with the `boost_profile` parameter:
|
|
556
|
-
|
|
557
|
-
- **`"default"`** (default): Prioritizes implementation files (`src/*.ts`) over documentation
|
|
558
|
-
- Implementation files get 30% boost, documentation files get 50% penalty
|
|
559
|
-
- Config files heavily penalized (95% reduction)
|
|
560
|
-
- `docs/` directory is blacklisted
|
|
561
|
-
- **`"code"`** (NEW in v0.17.0): Strongly prioritizes implementation code only
|
|
562
|
-
- Documentation and config files get 95% penalty
|
|
563
|
-
- Best for finding actual implementation when you don't want docs in results
|
|
564
|
-
- `docs/` directory is blacklisted
|
|
565
|
-
- **`"docs"`**: Prioritizes documentation files (`*.md`) over implementation
|
|
566
|
-
- Documentation files get 50% boost, implementation files get 50% penalty
|
|
567
|
-
- `docs/` directory is included in search results
|
|
568
|
-
- **`"balanced"`** (NEW in v0.9.10): Equal weight for docs and implementation
|
|
569
|
-
- Both documentation and implementation files: no penalty/boost (1.0x)
|
|
570
|
-
- Config files: relaxed penalty (0.3x, compared to 0.05x in default)
|
|
571
|
-
- `docs/` directory is included in search results
|
|
572
|
-
- No path-specific multipliers (treats all `src/` equally)
|
|
573
|
-
- **`"none"`**: Pure BM25 scoring without file type adjustments
|
|
574
|
-
|
|
575
|
-
```typescript
|
|
576
|
-
// Find implementation files (default behavior)
|
|
577
|
-
files_search({ query: "authentication", boost_profile: "default" });
|
|
578
|
-
|
|
579
|
-
// Find only implementation code (no docs/config in results)
|
|
580
|
-
files_search({ query: "authentication", boost_profile: "code" });
|
|
581
|
-
|
|
582
|
-
// Find documentation
|
|
583
|
-
files_search({ query: "setup guide", boost_profile: "docs" });
|
|
584
|
-
|
|
585
|
-
// Balanced search (docs and code equally weighted)
|
|
586
|
-
files_search({ query: "authentication design", boost_profile: "balanced" });
|
|
587
|
-
|
|
588
|
-
// Pure BM25 ranking without boosting
|
|
589
|
-
files_search({ query: "API", boost_profile: "none" });
|
|
112
|
+
```bash
|
|
113
|
+
git clone https://github.com/CAPHTECH/kiri.git
|
|
114
|
+
cd kiri
|
|
115
|
+
pnpm install
|
|
116
|
+
pnpm run build
|
|
117
|
+
pnpm run test
|
|
118
|
+
pnpm run dev # HTTP server on :8765
|
|
590
119
|
```
|
|
591
120
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
KIRI automatically filters sensitive files and masks sensitive values:
|
|
595
|
-
|
|
596
|
-
- `.env*`, `*.pem`, `secrets/**` are excluded from indexing
|
|
597
|
-
- Sensitive values in responses are masked with `***`
|
|
598
|
-
- Respects both `.gitignore` and custom denylist patterns
|
|
599
|
-
|
|
600
|
-
## ๐ง Troubleshooting
|
|
601
|
-
|
|
602
|
-
### Common Issues
|
|
603
|
-
|
|
604
|
-
#### Daemon Initialization Timeout
|
|
605
|
-
|
|
606
|
-
**Problem**: MCP client shows "Daemon did not become ready within X seconds"
|
|
121
|
+
> **Guidelines**: See [AGENTS.md](AGENTS.md) for development standards.
|
|
607
122
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
1. **Increase timeout** for large repositories:
|
|
611
|
-
- Claude Code: Set `KIRI_DAEMON_READY_TIMEOUT` to `480` or higher
|
|
612
|
-
- Codex CLI: Set `startup_timeout_sec = 480` or higher
|
|
613
|
-
|
|
614
|
-
2. **Check daemon logs**:
|
|
615
|
-
|
|
616
|
-
```bash
|
|
617
|
-
cat .kiri/index.duckdb.daemon.log
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
3. **Manual indexing** to verify repository can be indexed:
|
|
621
|
-
```bash
|
|
622
|
-
kiri --repo . --db .kiri/index.duckdb --port 8765
|
|
623
|
-
```
|
|
624
|
-
|
|
625
|
-
#### Command Not Found
|
|
626
|
-
|
|
627
|
-
**Problem**: `kiri: command not found` when using global installation
|
|
628
|
-
|
|
629
|
-
**Solutions**:
|
|
630
|
-
|
|
631
|
-
1. **Verify installation**:
|
|
632
|
-
|
|
633
|
-
```bash
|
|
634
|
-
npm list -g kiri-mcp-server
|
|
635
|
-
```
|
|
636
|
-
|
|
637
|
-
2. **Re-link package**:
|
|
638
|
-
|
|
639
|
-
```bash
|
|
640
|
-
npm link kiri-mcp-server
|
|
641
|
-
```
|
|
642
|
-
|
|
643
|
-
3. **Use npx instead**:
|
|
644
|
-
```bash
|
|
645
|
-
npx kiri-mcp-server@latest --repo . --db .kiri/index.duckdb
|
|
646
|
-
```
|
|
647
|
-
|
|
648
|
-
#### Slow Indexing
|
|
649
|
-
|
|
650
|
-
**Problem**: Initial indexing takes too long
|
|
651
|
-
|
|
652
|
-
**Solutions**:
|
|
653
|
-
|
|
654
|
-
1. **Check repository size**:
|
|
123
|
+
## Documentation
|
|
655
124
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
125
|
+
| Document | Description |
|
|
126
|
+
| ------------------------------------------------------ | ------------------------------------------- |
|
|
127
|
+
| [Setup Guide](docs/setup.md) | Installation and MCP client configuration |
|
|
128
|
+
| [Tools Reference](docs/tools-reference.md) | Complete MCP tools documentation |
|
|
129
|
+
| [Configuration](docs/configuration.md) | Environment variables and advanced settings |
|
|
130
|
+
| [Architecture](docs/overview.md) | System design and data flow |
|
|
131
|
+
| [Data Model](docs/data-model.md) | Database schema details |
|
|
132
|
+
| [Search & Ranking](docs/search-ranking.md) | Search algorithms |
|
|
133
|
+
| [API Reference](docs/api-and-client.md) | Complete API documentation |
|
|
134
|
+
| [Authoring Docs](docs/documentation-best-practices.md) | Writing metadata-rich documentation |
|
|
659
135
|
|
|
660
|
-
|
|
136
|
+
## Changelog
|
|
661
137
|
|
|
662
|
-
|
|
663
|
-
```yaml
|
|
664
|
-
patterns:
|
|
665
|
-
- "**/*.min.js"
|
|
666
|
-
- "**/vendor/**"
|
|
667
|
-
- "**/dist/**"
|
|
668
|
-
```
|
|
138
|
+
See [CHANGELOG.md](CHANGELOG.md) for release notes.
|
|
669
139
|
|
|
670
|
-
|
|
140
|
+
**Recent highlights:**
|
|
671
141
|
|
|
672
|
-
**
|
|
142
|
+
- **v0.18.2**: Defensive JSON sanitization for metadata persistence
|
|
143
|
+
- **v0.18.1**: Unicode surrogate fix, DCCA analysis documentation
|
|
144
|
+
- **v0.18.0**: Rust code intelligence, shirushi document ID management
|
|
145
|
+
- **v0.17.0**: `code` boost_profile for implementation-focused search
|
|
673
146
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
1. **Check database size**:
|
|
677
|
-
|
|
678
|
-
```bash
|
|
679
|
-
du -h .kiri/index.duckdb
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
2. **Force reindex with cleanup**:
|
|
683
|
-
|
|
684
|
-
```bash
|
|
685
|
-
rm -f .kiri/index.duckdb*
|
|
686
|
-
kiri --repo . --db .kiri/index.duckdb --port 8765
|
|
687
|
-
```
|
|
688
|
-
|
|
689
|
-
3. **Typical database sizes**:
|
|
690
|
-
- Small project (<1,000 files): 1-10 MB
|
|
691
|
-
- Medium project (1,000-10,000 files): 10-100 MB
|
|
692
|
-
- Large project (>10,000 files): 100-500 MB
|
|
147
|
+
---
|
|
693
148
|
|
|
694
|
-
|
|
149
|
+
## Detailed Troubleshooting
|
|
695
150
|
|
|
696
|
-
|
|
151
|
+
### Daemon Initialization Timeout
|
|
697
152
|
|
|
698
|
-
**
|
|
153
|
+
**Problem**: "Daemon did not become ready within X seconds"
|
|
699
154
|
|
|
700
155
|
**Solutions**:
|
|
701
156
|
|
|
702
|
-
1.
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
# Remove existing npm link (if any)
|
|
706
|
-
npm unlink -g kiri-mcp-server 2>/dev/null || true
|
|
707
|
-
|
|
708
|
-
# Clean and reinstall
|
|
709
|
-
rm -rf node_modules pnpm-lock.yaml
|
|
710
|
-
pnpm install --frozen-lockfile
|
|
711
|
-
|
|
712
|
-
# Verify native binding exists
|
|
713
|
-
ls -la node_modules/.pnpm/duckdb@*/node_modules/duckdb/lib/binding/duckdb.node
|
|
157
|
+
1. Increase timeout (Claude Code: `KIRI_DAEMON_READY_TIMEOUT=480`, Codex CLI: `startup_timeout_sec = 480`)
|
|
158
|
+
2. Check logs: `cat .kiri/index.duckdb.daemon.log`
|
|
159
|
+
3. Manual test: `kiri --repo . --db .kiri/index.duckdb --port 8765`
|
|
714
160
|
|
|
715
|
-
|
|
716
|
-
pnpm rebuild duckdb
|
|
717
|
-
|
|
718
|
-
# Build and link (use pnpm, not npm!)
|
|
719
|
-
pnpm run build
|
|
720
|
-
pnpm link --global
|
|
721
|
-
```
|
|
722
|
-
|
|
723
|
-
2. **Prerequisites for building DuckDB**:
|
|
724
|
-
- **macOS**: Install Xcode Command Line Tools: `xcode-select --install`
|
|
725
|
-
- **Node.js**: Version 20 or higher: `node -v`
|
|
726
|
-
- **Network**: Access to `npm.duckdb.org` for prebuilt binaries
|
|
727
|
-
|
|
728
|
-
3. **Unlink when done**:
|
|
729
|
-
```bash
|
|
730
|
-
pnpm unlink --global kiri-mcp-server
|
|
731
|
-
```
|
|
732
|
-
|
|
733
|
-
#### Stale Lock File
|
|
734
|
-
|
|
735
|
-
**Problem**: Daemon fails to start with error `Lock file already exists. Another process is indexing.`
|
|
736
|
-
|
|
737
|
-
**Root Cause**: A previous daemon process crashed or was killed without proper cleanup, leaving a stale lock file.
|
|
738
|
-
|
|
739
|
-
**Solution**:
|
|
161
|
+
### Command Not Found
|
|
740
162
|
|
|
741
163
|
```bash
|
|
742
|
-
#
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
# Optionally, also remove the socket file
|
|
746
|
-
rm -f .kiri/index.duckdb.sock
|
|
164
|
+
# Verify installation
|
|
165
|
+
npm list -g kiri-mcp-server
|
|
747
166
|
|
|
748
|
-
#
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
#### Version Mismatch After Upgrade
|
|
752
|
-
|
|
753
|
-
**Problem**: After upgrading KIRI, connection fails with `Version mismatch: client X.Y.Z is incompatible with daemon A.B.C`
|
|
754
|
-
|
|
755
|
-
**Root Cause**: An old daemon process is still running after upgrading to a new version.
|
|
756
|
-
|
|
757
|
-
**Solutions**:
|
|
758
|
-
|
|
759
|
-
1. **Kill old daemon processes**:
|
|
760
|
-
|
|
761
|
-
```bash
|
|
762
|
-
pkill -f "kiri.*daemon"
|
|
763
|
-
```
|
|
764
|
-
|
|
765
|
-
2. **Clear npx cache** (if using npx):
|
|
766
|
-
|
|
767
|
-
```bash
|
|
768
|
-
npx clear-npx-cache
|
|
769
|
-
```
|
|
770
|
-
|
|
771
|
-
3. **Restart the MCP connection**
|
|
772
|
-
|
|
773
|
-
#### Schema Mismatch After Upgrade (Degrade Mode)
|
|
774
|
-
|
|
775
|
-
**Problem**: After upgrading KIRI, server shows `Server is running in degrade mode` and logs show errors like `Table with name graph_metrics does not exist`
|
|
776
|
-
|
|
777
|
-
**Root Cause**: The existing index was created with an older schema version that doesn't include new tables (e.g., `graph_metrics`, `cochange`).
|
|
778
|
-
|
|
779
|
-
**Solution**:
|
|
780
|
-
|
|
781
|
-
1. **Stop the daemon**:
|
|
782
|
-
|
|
783
|
-
```bash
|
|
784
|
-
pkill -f "kiri.*daemon"
|
|
785
|
-
rm -f .kiri/index.duckdb.sock.lock .kiri/index.duckdb.sock
|
|
786
|
-
```
|
|
787
|
-
|
|
788
|
-
2. **Rebuild index with full schema**:
|
|
789
|
-
|
|
790
|
-
```bash
|
|
791
|
-
kiri --repo . --db .kiri/index.duckdb --full
|
|
792
|
-
```
|
|
793
|
-
|
|
794
|
-
3. **Restart your MCP client**
|
|
795
|
-
|
|
796
|
-
> **Note**: The `--full` flag ensures all tables including `graph_metrics` and `cochange` are created. This is required when upgrading from versions prior to v0.15.0.
|
|
797
|
-
|
|
798
|
-
### Getting Help
|
|
799
|
-
|
|
800
|
-
If you encounter issues not covered here:
|
|
801
|
-
|
|
802
|
-
1. **Check daemon logs**: `.kiri/index.duckdb.daemon.log`
|
|
803
|
-
2. **Enable verbose logging**: Set `DEBUG=kiri:*` environment variable
|
|
804
|
-
3. **Report issues**: [GitHub Issues](https://github.com/CAPHTECH/kiri/issues)
|
|
805
|
-
4. **Community support**: [GitHub Discussions](https://github.com/CAPHTECH/kiri/discussions)
|
|
806
|
-
|
|
807
|
-
## ๐ Supported Languages
|
|
808
|
-
|
|
809
|
-
KIRI provides AST-based symbol extraction for the following languages:
|
|
810
|
-
|
|
811
|
-
| Language | Extensions | Symbol Types | Parser |
|
|
812
|
-
| -------------- | ------------- | ---------------------------------------------------------------------------------------- | ----------------------------------- |
|
|
813
|
-
| **TypeScript** | `.ts`, `.tsx` | `class`, `interface`, `enum`, `function`, `method` | TypeScript Compiler API |
|
|
814
|
-
| **Swift** | `.swift` | `class`, `struct`, `protocol`, `enum`, `extension`, `func`, `init`, `property` | tree-sitter-swift |
|
|
815
|
-
| **PHP** | `.php` | `class`, `interface`, `trait`, `function`, `method`, `property`, `constant`, `namespace` | tree-sitter-php (pure & HTML-mixed) |
|
|
816
|
-
| **Java** | `.java` | `class`, `interface`, `enum`, `annotation`, `method`, `constructor`, `field` | tree-sitter-java |
|
|
817
|
-
| **Dart** | `.dart` | `class`, `mixin`, `enum`, `extension`, `function`, `method`, `getter`, `setter` | Dart Analysis Server |
|
|
818
|
-
| **Rust** | `.rs` | `struct`, `enum`, `trait`, `impl`, `fn`, `mod`, `const`, `static`, `macro`, `type` | tree-sitter-rust |
|
|
819
|
-
|
|
820
|
-
**Dart Integration Features:**
|
|
821
|
-
|
|
822
|
-
- Full IDE-quality symbol extraction via official Dart Analysis Server
|
|
823
|
-
- Automatic SDK detection from PATH or `DART_SDK` environment variable
|
|
824
|
-
- Memory-efficient client pooling with configurable limits
|
|
825
|
-
- Windows path normalization for case-insensitive filesystems
|
|
826
|
-
- Graceful degradation when Dart SDK is unavailable
|
|
827
|
-
|
|
828
|
-
Other languages are detected and indexed but use full-file snippets instead of symbol-level extraction. Support for additional languages (Go, Python, etc.) is planned.
|
|
829
|
-
|
|
830
|
-
## ๐๏ธ How It Works
|
|
167
|
+
# Re-link
|
|
168
|
+
npm link kiri-mcp-server
|
|
831
169
|
|
|
170
|
+
# Or use npx
|
|
171
|
+
npx kiri-mcp-server@latest --repo . --db .kiri/index.duckdb
|
|
832
172
|
```
|
|
833
|
-
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ
|
|
834
|
-
โ MCP Client โ <โโโโ> โ KIRI MCP Server โ <โโโโ> โ DuckDB โ
|
|
835
|
-
โ (Claude, Codex) โ stdio โ (JSON-RPC 2.0) โ โ Database โ
|
|
836
|
-
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ
|
|
837
|
-
โ
|
|
838
|
-
โผ
|
|
839
|
-
โโโโโโโโโโโโโโโโโโโโ
|
|
840
|
-
โ Indexer โ
|
|
841
|
-
โ Git Scanner โ
|
|
842
|
-
โ AST Parser โ
|
|
843
|
-
โ FTS Indexing โ
|
|
844
|
-
โโโโโโโโโโโโโโโโโโโโ
|
|
845
|
-
```
|
|
846
|
-
|
|
847
|
-
**Architecture:**
|
|
848
|
-
|
|
849
|
-
1. **Indexer**: Scans your Git repository, extracts code structure and content
|
|
850
|
-
2. **DuckDB Database**: Stores indexed data with efficient query support
|
|
851
|
-
3. **MCP Server**: Exposes JSON-RPC 2.0 tools via stdio for MCP clients
|
|
852
|
-
4. **Watch Mode** (optional): Monitors file changes and re-indexes automatically
|
|
853
|
-
|
|
854
|
-
**Data Model:**
|
|
855
|
-
|
|
856
|
-
- **blob/tree separation**: Deduplicates renamed/copied files (Git-like model)
|
|
857
|
-
- **Symbol extraction**: AST-based function/class boundaries for precise snippets
|
|
858
|
-
- **FTS indexing**: Full-text search with BM25 ranking when available
|
|
859
|
-
- **Dependency graph**: Import/export relationships for impact analysis
|
|
860
|
-
|
|
861
|
-
See [docs/architecture.md](docs/architecture.md) for detailed technical information.
|
|
862
173
|
|
|
863
|
-
|
|
174
|
+
### Slow Indexing
|
|
864
175
|
|
|
865
|
-
|
|
176
|
+
1. Check size: `git ls-files | wc -l`
|
|
177
|
+
2. Review `.gitignore`
|
|
178
|
+
3. Add denylist: Create `.kiri/denylist.yml`:
|
|
866
179
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
-
|
|
870
|
-
-
|
|
871
|
-
- [API Reference](docs/api-and-client.md) - Complete API documentation
|
|
872
|
-
|
|
873
|
-
### Performance
|
|
874
|
-
|
|
875
|
-
| Metric | Target | Current |
|
|
876
|
-
| ----------------------------- | ------ | --------------------------------------------------------------------------------------- |
|
|
877
|
-
| **Time to First Result** | โค 1.0s | โ
0.8s |
|
|
878
|
-
| **Precision @ 10** | โฅ 0.7 | โ ๏ธ 0.25 (2025-11-21, dataset v2025-11-docs-plain, K=10, see var/eval/2025-11-21-k10.md) |
|
|
879
|
-
| **Token Reduction (compact)** | โฅ 90% | โ
95% (v0.8) |
|
|
880
|
-
|
|
881
|
-
### Evaluation & Quality Assurance
|
|
882
|
-
|
|
883
|
-
KIRI includes a **Golden Set Evaluation System** for tracking search accuracy over time using representative queries.
|
|
884
|
-
|
|
885
|
-
**Metrics:**
|
|
886
|
-
|
|
887
|
-
- **P@10** (Precision at K=10): Fraction of relevant results in top 10 (target: โฅ0.70)
|
|
888
|
-
- **TFFU** (Time To First Useful): Time until first relevant result appears (target: โค1000ms)
|
|
889
|
-
|
|
890
|
-
**For Developers:**
|
|
891
|
-
|
|
892
|
-
```bash
|
|
893
|
-
# Run benchmark evaluation (local only)
|
|
894
|
-
pnpm run eval:golden
|
|
895
|
-
|
|
896
|
-
# Verbose output
|
|
897
|
-
pnpm run eval:golden:verbose
|
|
180
|
+
```yaml
|
|
181
|
+
patterns:
|
|
182
|
+
- "**/*.min.js"
|
|
183
|
+
- "**/vendor/**"
|
|
898
184
|
```
|
|
899
185
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
- JSON: Detailed per-query results (`var/eval/latest.json`)
|
|
903
|
-
- Markdown: Summary table (`var/eval/latest.md`)
|
|
904
|
-
|
|
905
|
-
**Documentation:**
|
|
906
|
-
|
|
907
|
-
- [Golden Set Guide](tests/eval/goldens/README.md) - Query format, categories, adding queries
|
|
908
|
-
- [Results Recording](tests/eval/results/README.md) - Tracking improvements over time
|
|
909
|
-
|
|
910
|
-
See [docs/testing.md](docs/testing.md) for complete testing and evaluation guidelines.
|
|
911
|
-
|
|
912
|
-
### Community
|
|
913
|
-
|
|
914
|
-
- [GitHub Issues](https://github.com/CAPHTECH/kiri/issues) - Bug reports and feature requests
|
|
915
|
-
- [Discussions](https://github.com/CAPHTECH/kiri/discussions) - Questions and community support
|
|
916
|
-
- [Contributing Guide](AGENTS.md) - How to contribute
|
|
917
|
-
|
|
918
|
-
## ๐ ๏ธ For Developers
|
|
919
|
-
|
|
920
|
-
### Local Development
|
|
186
|
+
### DuckDB Native Binding Errors
|
|
921
187
|
|
|
922
188
|
```bash
|
|
923
|
-
#
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
pnpm
|
|
927
|
-
|
|
928
|
-
# Build
|
|
189
|
+
# Use pnpm link, not npm link
|
|
190
|
+
rm -rf node_modules pnpm-lock.yaml
|
|
191
|
+
pnpm install --frozen-lockfile
|
|
192
|
+
pnpm rebuild duckdb
|
|
929
193
|
pnpm run build
|
|
930
|
-
|
|
931
|
-
# Link globally for testing (IMPORTANT: use pnpm link, not npm link)
|
|
932
194
|
pnpm link --global
|
|
933
|
-
|
|
934
|
-
# Verify DuckDB native binding is installed
|
|
935
|
-
ls -la node_modules/.pnpm/duckdb@*/node_modules/duckdb/lib/binding/duckdb.node
|
|
936
|
-
|
|
937
|
-
# If duckdb.node is missing, rebuild it
|
|
938
|
-
pnpm rebuild duckdb
|
|
939
|
-
|
|
940
|
-
# Run tests
|
|
941
|
-
pnpm run test
|
|
942
|
-
|
|
943
|
-
# Start in development mode (HTTP server on :8765)
|
|
944
|
-
pnpm run dev
|
|
945
|
-
|
|
946
|
-
# Unlink when done
|
|
947
|
-
pnpm unlink --global kiri-mcp-server
|
|
948
195
|
```
|
|
949
196
|
|
|
950
|
-
###
|
|
197
|
+
### Schema Mismatch (Degrade Mode)
|
|
951
198
|
|
|
952
199
|
```bash
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
kiri --repo
|
|
956
|
-
kiri --repo <path> --db <db-path> --reindex # Force re-indexing
|
|
957
|
-
kiri --repo <path> --db <db-path> --watch # Enable watch mode
|
|
958
|
-
|
|
959
|
-
# Development
|
|
960
|
-
pnpm run build # Build TypeScript
|
|
961
|
-
pnpm run dev # HTTP server with hot reload
|
|
962
|
-
pnpm run test # Run all tests
|
|
963
|
-
pnpm run check # Lint + test
|
|
200
|
+
pkill -f "kiri.*daemon"
|
|
201
|
+
rm -f .kiri/index.duckdb.sock.lock .kiri/index.duckdb.sock
|
|
202
|
+
kiri --repo . --db .kiri/index.duckdb --full
|
|
964
203
|
```
|
|
965
204
|
|
|
966
|
-
###
|
|
967
|
-
|
|
968
|
-
```
|
|
969
|
-
kiri/
|
|
970
|
-
โโโ src/
|
|
971
|
-
โ โโโ indexer/ # Git scanning, AST parsing, schema management
|
|
972
|
-
โ โโโ server/ # MCP server, JSON-RPC handlers
|
|
973
|
-
โ โโโ client/ # CLI utilities, daemon management
|
|
974
|
-
โ โโโ shared/ # DuckDB client, utilities
|
|
975
|
-
โโโ tests/ # Test files (mirrors src/)
|
|
976
|
-
โโโ docs/ # Architecture documentation
|
|
977
|
-
โโโ config/ # YAML configuration schemas
|
|
978
|
-
โโโ sql/ # SQL schema definitions
|
|
979
|
-
โโโ examples/ # Usage examples
|
|
980
|
-
```
|
|
205
|
+
### Getting Help
|
|
981
206
|
|
|
982
|
-
|
|
207
|
+
1. Check logs: `.kiri/index.duckdb.daemon.log`
|
|
208
|
+
2. Enable debug: `DEBUG=kiri:*`
|
|
209
|
+
3. [GitHub Issues](https://github.com/CAPHTECH/kiri/issues)
|
|
210
|
+
4. [Discussions](https://github.com/CAPHTECH/kiri/discussions)
|
|
983
211
|
|
|
984
|
-
|
|
212
|
+
---
|
|
985
213
|
|
|
986
|
-
|
|
214
|
+
## License
|
|
987
215
|
|
|
988
|
-
|
|
216
|
+
MIT License - See [LICENSE](LICENSE).
|
|
989
217
|
|
|
990
|
-
|
|
218
|
+
## Acknowledgments
|
|
991
219
|
|
|
992
|
-
|
|
993
|
-
- [DuckDB](https://duckdb.org/) - Embedded analytical database
|
|
994
|
-
- [tree-sitter](https://tree-sitter.github.io/) - Parser generator for AST extraction
|
|
220
|
+
Built with [Model Context Protocol](https://modelcontextprotocol.io/), [DuckDB](https://duckdb.org/), and [tree-sitter](https://tree-sitter.github.io/).
|
|
995
221
|
|
|
996
222
|
---
|
|
997
223
|
|
|
998
|
-
**Status**: v0.
|
|
999
|
-
|
|
1000
|
-
**New in v0.17.0**: `code` boost_profile for implementation-focused search. See [CHANGELOG.md](CHANGELOG.md) for details.
|
|
1001
|
-
|
|
1002
|
-
For questions or support, please open a [GitHub issue](https://github.com/CAPHTECH/kiri/issues).
|
|
224
|
+
**Status**: v0.18.2 (Beta) - Production-ready for MCP clients
|