kiri-mcp-server 0.17.0 → 0.18.1

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