@takara-ai/miru-code 0.3.0 → 0.4.0

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 CHANGED
@@ -2,38 +2,77 @@
2
2
 
3
3
  Hybrid code search for AI agents — **TypeScript**, **Bun**, and **Takara embeddings**.
4
4
 
5
+ ## How to read this doc
6
+
7
+ | If you want to… | Start here |
8
+ |-----------------|------------|
9
+ | Use Miru in an IDE (Cursor, Claude Code, etc.) | [User flow](#user-flow) → [Credentials](#credentials) → [IDE integration](#ide-integration) |
10
+ | Run search from a terminal or script | [User flow](#user-flow) → [CLI](#cli) |
11
+ | Embed Miru in your own tool | [Library](#library) |
12
+ | Hack on this repo | [Developing Miru](#developing-miru) |
13
+
14
+ The sections below follow that order: **what Miru does**, **how you use it end to end**, then **reference** (CLI flags, env vars, per-IDE MCP JSON).
15
+
5
16
  ## What is Miru?
6
17
 
7
18
  *Miru* (見る) means “to see” or “to look” in Japanese. Miru helps coding agents **find code by meaning** instead of guessing file paths or running exhaustive greps.
8
19
 
9
- When an agent asks “where is auth middleware configured?” or “how do we batch embeddings?”, Miru returns the most relevant **chunks** of your codebase — file path, line range, and snippet — so the agent can read only what matters.
20
+ When an agent asks “where is auth middleware configured?” or “how do we batch embeddings?”, Miru returns the most relevant **chunks** — file path, line range, and snippet — so the agent can read only what matters.
10
21
 
11
22
  ### Why hybrid search?
12
23
 
13
24
  Pure semantic search misses exact symbol matches. Pure keyword search misses paraphrased intent. Miru combines both:
14
25
 
15
26
  1. **Dense (semantic)** — Takara code embeddings (`ds1-potion-code-16m`) over structurally chunked source files.
16
- 2. **Sparse (BM25)** — keyword scoring with an inverted index; parallelized in Bun workers on large repos.
27
+ 2. **Sparse (BM25)** — keyword scoring with an inverted index; parallelized in Bun workers when the index has 256+ chunks.
17
28
  3. **RRF fusion** — reciprocal rank fusion merges the two ranked lists.
18
29
  4. **Reranking** — code-tuned penalties and boosts (e.g. multi-chunk files, query-term overlap).
19
30
 
20
- Indexes are built on demand, cached on disk, and invalidated when files change. You can search **code**, **docs**, **config**, or **all** content types.
31
+ You can index **code**, **docs**, **config**, or **all** of the above via `--content` (CLI/MCP) or when building an index in the library.
32
+
33
+ ### Caching (what “fresh” means)
34
+
35
+ | Layer | Behavior |
36
+ |-------|----------|
37
+ | **First search** | Builds an index (chunk → embed → BM25 + vectors), then writes a disk cache. |
38
+ | **MCP server (local repo, same session)** | Watches the workspace and **incrementally** re-indexes changed files; updates the disk cache. Disable with `MIRU_MCP_WATCH=0`. |
39
+ | **CLI or a new MCP session** | Reuses the disk cache if the embedding model, content types, and indexed files still match. Cache does **not** detect file edits by itself — run `miru clear <path>` after large changes, or rely on MCP live updates. |
40
+ | **Remote `https://` repos** | Cloned per session; no filesystem watch. Use `--ref` for a branch/tag. |
41
+
42
+ Cache locations: `~/Library/Caches/miru` (macOS), `~/.cache/miru` (Linux), `%LOCALAPPDATA%\miru\Cache` (Windows).
21
43
 
22
44
  ### How agents use Miru
23
45
 
24
46
  | Mode | Best for | What the agent gets |
25
47
  |------|----------|---------------------|
26
- | **MCP server** | Cursor, Claude Code, VS Code Copilot, Gemini CLI, Kiro, OpenCode | Native `search` and `find_related` tools over the workspace |
27
- | **CLI sub-agent** | Any agent with shell access | `miru init --agent <id>` writes a specialist agent that runs `miru search` / `miru find-related` via Bash |
48
+ | **MCP server** | Cursor, Claude Code, VS Code Copilot, Gemini CLI, Kiro, OpenCode | `search` and `find_related` tools; pass `repo` (local path or `https://` git URL) |
49
+ | **CLI sub-agent** | Any agent with shell access | `miru install` (global) or `miru init --agent <id>` (per-repo) |
50
+
51
+ Both modes share the same indexing logic and disk cache layout.
52
+
53
+ ## User flow
28
54
 
29
- Both modes share the same index and cache. Pick MCP when your IDE supports it; use the sub-agent when you want a dedicated exploration agent without MCP wiring.
55
+ Typical path from zero to useful search:
56
+
57
+ ```text
58
+ 1. Install Bun + Miru → bun add -g @takara-ai/miru-code (or bunx for one-off)
59
+ 2. Credentials → miru setup OR TAKARA_API_KEY in MCP env / .env.local
60
+ 3. Integrate → miru install (MCP + instructions + sub-agent)
61
+ 4. Search → Agent calls search("…", repo: project root)
62
+ 5. Go deeper (optional) → find_related(file, line) on a hit
63
+ 6. Refresh cache (if needed) → miru clear . after big refactors when using CLI only
64
+ ```
65
+
66
+ **Agent workflow:** `search` first → read returned chunks → `find_related` on a promising `file_path` + line → open full files only when the chunk is not enough → use grep for exhaustive literal matches.
67
+
68
+ **`repo` rules:** Local workspaces use the **project root** path. Remote repos use an explicit **`https://` or `http://`** URL (not `git@` SSH). Never guess URLs.
30
69
 
31
70
  ## Install
32
71
 
33
- Requires [Bun](https://bun.sh) 1.1+ on your PATH (`curl -fsSL https://bun.sh/install | bash`).
72
+ Requires [Bun](https://bun.sh) 1.1+ on your PATH.
34
73
 
35
74
  ```bash
36
- # Run once without installing
75
+ # One-off
37
76
  bunx @takara-ai/miru-code search "auth middleware" ./src
38
77
 
39
78
  # Global CLI
@@ -44,67 +83,96 @@ miru search "auth middleware" ./src
44
83
  bun add @takara-ai/miru-code
45
84
  ```
46
85
 
47
- ```ts
48
- import { MiruIndex } from "@takara-ai/miru-code";
86
+ ## Credentials
49
87
 
50
- const index = await MiruIndex.fromPath("./src");
51
- ```
88
+ Miru needs a **Takara bearer token** for embeddings (`TAKARA_API_KEY`).
52
89
 
53
- ## Setup
90
+ **CLI / terminal (recommended for local dev):**
54
91
 
55
92
  ```bash
56
- bun install
93
+ miru setup # interactive; validates key and stores locally
94
+ miru setup --key TOKEN # non-interactive
95
+ miru setup --clear # remove stored key
57
96
  ```
58
97
 
59
- Add credentials to `.env.local` (loaded automatically when you run from this repo), or pass them in your MCP config `env` block (recommended — MCP does not inherit IDE env vars reliably).
98
+ Stored at `~/Library/Application Support/miru/credentials.json` (macOS), `~/.config/miru/` (Linux), or `%APPDATA%\miru\` (Windows). Override directory with `MIRU_CREDENTIALS_DIR`.
60
99
 
61
- | Variable | Default |
62
- |----------|---------|
63
- | `TAKARA_API_KEY` | (required) Takara bearer token for embeddings |
64
- | `MIRU_OPENAI_BASE_URL` | `https://infer.dev.takara.ai/v1` |
65
- | `MIRU_OPENAI_EMBEDDING_MODEL` | `ds1-potion-code-16m` |
66
- | `MIRU_EMBEDDING_DIMENSIONS` | `256` (auto for potion) |
67
- | `MIRU_FLOAT_VECTORS` | unset (default **int8** quantized vectors); set `1` for float32 |
68
- | `MIRU_EMBEDDING_BATCH_SIZE` | `32` (max for this model) |
69
- | `MIRU_CONCURRENCY` | logical CPUs **minus 2** (min 1) |
100
+ **MCP in an IDE:** Put `TAKARA_API_KEY` in the MCP server `env` block. MCP does not reliably inherit your shell or `.env.local` — set it explicitly.
70
101
 
71
- Parallelism: file reads/chunking, embedding batches (up to concurrency in flight), query embed overlapping BM25, and **BM25 scoring in Bun workers** (shards by doc range when index has 256+ chunks). BM25 uses an inverted postings list for fast single-threaded search on small indexes. Override with `MIRU_CONCURRENCY`.
102
+ **This repo:** `bun install` then add `TAKARA_API_KEY` to `.env.local` (Bun loads it when you run from the project root).
72
103
 
73
104
  ## IDE integration
74
105
 
75
- Miru supports six agent platforms. For each, you can wire the **MCP server** (recommended) and/or install a **CLI sub-agent** with `miru init`.
106
+ ### Recommended: `miru install`
107
+
108
+ Interactive setup (like Semble’s `semble install`). Detects installed agents and configures any combination of:
109
+
110
+ | Integration | What it does |
111
+ |-------------|----------------|
112
+ | **MCP server** | Adds `miru` to your agent’s MCP config (`search`, `find_related`) |
113
+ | **Instructions** | Appends a marked block to `CLAUDE.md`, `GEMINI.md`, `AGENTS.md`, etc. |
114
+ | **Sub-agent** | Installs `miru-code` under your **user** config (global, all projects) |
115
+
116
+ ```bash
117
+ bun add -g @takara-ai/miru-code
118
+ miru setup # store API key (or set TAKARA_API_KEY for ${TAKARA_API_KEY} in MCP)
119
+ miru install
120
+ ```
76
121
 
77
- ### Quick reference
122
+ Undo with `miru uninstall`. Restart your IDE/agent session after install.
78
123
 
79
- | IDE | MCP config file | Sub-agent command | Sub-agent output |
80
- |-----|-----------------|-------------------|------------------|
81
- | [Cursor](#cursor) | `~/.cursor/mcp.json` or `.cursor/mcp.json` | `miru init --agent cursor` | `.cursor/agents/miru-code.md` |
82
- | [Claude Code](#claude-code) | `.mcp.json` (project root) or `~/.claude.json` | `miru init --agent claude` | `.claude/agents/miru-code.md` |
83
- | [VS Code / Copilot](#vs-code--github-copilot) | `.vscode/mcp.json` or user profile `mcp.json` | `miru init --agent copilot` | `.github/agents/miru-code.md` |
84
- | [Gemini CLI](#gemini-cli) | `~/.gemini/settings.json` or `.gemini/settings.json` | `miru init --agent gemini` | `.gemini/agents/miru-code.md` |
85
- | [Kiro](#kiro) | `~/.kiro/settings/mcp.json` or `.kiro/settings/mcp.json` | `miru init --agent kiro` | `.kiro/agents/miru-code.md` |
86
- | [OpenCode](#opencode) | `~/.config/opencode/opencode.json` or `opencode.json` | `miru init --agent opencode` | `.opencode/agents/miru-code.md` |
124
+ **Supported agents:** Claude Code, Cursor, Gemini CLI, Kiro, OpenCode, GitHub Copilot, Codex, VS Code.
87
125
 
88
- Run `miru init --agent <id> --force` to overwrite an existing sub-agent file.
126
+ ### Global paths (after `miru install`)
127
+
128
+ | Agent | MCP config | Sub-agent |
129
+ |-------|------------|-----------|
130
+ | Claude Code | `~/.claude.json` | `~/.claude/agents/miru-code.md` |
131
+ | Cursor | `~/.cursor/mcp.json` | `~/.cursor/agents/miru-code.md` |
132
+ | Gemini CLI | `~/.gemini/settings.json` | `~/.gemini/agents/miru-code.md` |
133
+ | Kiro | `~/.kiro/settings/mcp.json` | `~/.kiro/agents/miru-code.md` |
134
+ | OpenCode | `~/.config/opencode/opencode.json(c)` | `~/.config/opencode/agents/miru-code.md` |
135
+ | GitHub Copilot | `~/.copilot/mcp-config.json` | `~/.copilot/agents/miru-code.agent.md` |
136
+ | Codex | `~/.codex/config.toml` | (MCP only) |
137
+ | VS Code | user profile `mcp.json` | (MCP only) |
138
+
139
+ MCP entries use `"env": { "TAKARA_API_KEY": "${TAKARA_API_KEY}" }` where the IDE supports expansion. Export the variable or edit the config with your token.
140
+
141
+ ### Per-project sub-agent (`miru init`)
142
+
143
+ To commit a sub-agent into a repo (team-shared) instead of global user config:
144
+
145
+ ```bash
146
+ miru init --agent claude --force # → .claude/agents/miru-code.md in cwd
147
+ ```
148
+
149
+ Agents: `cursor`, `claude`, `copilot`, `gemini`, `kiro`, `opencode`.
89
150
 
90
151
  ### MCP server
91
152
 
92
- Run with **no arguments** to start the stdio MCP server. Indexing begins on the first `search` or `find_related` call, using the `repo` path you pass. Optional `--ref` sets the default git ref for remote repos.
153
+ No subcommand starts stdio MCP:
93
154
 
94
155
  ```bash
95
156
  bunx @takara-ai/miru-code
96
- # or after bun add -g @takara-ai/miru-code: miru
157
+ # or: miru
97
158
  ```
98
159
 
99
- **Tools:** `search`, `find_related` — `repo` is required (project root or https:// git URL).
160
+ Optional startup flags: `--ref BRANCH` (default git ref for remote repos), `--content code docs …` (same types as CLI).
161
+
162
+ **Tools**
100
163
 
101
- For MCP configs, use `bunx` as the command (`bun` with `x` in `args` works too — they're equivalent).
164
+ | Tool | Purpose |
165
+ |------|---------|
166
+ | `search` | Natural-language or code query; requires `repo`; optional `top_k` (default 5) |
167
+ | `find_related` | Similar chunks to `file_path` + `line` (from a search hit); requires `repo`; optional `top_k` |
102
168
 
103
- Put the bearer token in `env`; MCP will not read `.env.local` unless those vars are unset.
169
+ Indexing runs on the first tool call for each `repo`. Later calls in the same MCP session reuse memory and refresh local files via watch (see [Caching](#caching-what-fresh-means)).
170
+
171
+ Use `bunx` in MCP config (`command`: `bunx`, `args`: `["@takara-ai/miru-code"]`). After `bun add -g`, you may use `"command": "miru"` instead.
104
172
 
105
173
  #### Shared env block
106
174
 
107
- Use this in every MCP config below (adjust the key name if your IDE uses `environment` instead of `env`):
175
+ Use in every MCP config (some IDEs use `environment` instead of `env`):
108
176
 
109
177
  ```json
110
178
  {
@@ -117,7 +185,7 @@ Use this in every MCP config below (adjust the key name if your IDE uses `enviro
117
185
 
118
186
  ### Cursor
119
187
 
120
- **MCP** — `~/.cursor/mcp.json` or project `.cursor/mcp.json`:
188
+ `~/.cursor/mcp.json` or project `.cursor/mcp.json`:
121
189
 
122
190
  ```json
123
191
  {
@@ -133,19 +201,11 @@ Use this in every MCP config below (adjust the key name if your IDE uses `enviro
133
201
  }
134
202
  ```
135
203
 
136
- After `bun add -g @takara-ai/miru-code`, you can use `"command": "miru"` instead.
137
-
138
- **Sub-agent:**
139
-
140
- ```bash
141
- miru init --agent cursor
142
- ```
143
-
144
- Commit `.cursor/agents/miru-code.md` to share the exploration agent with your team.
204
+ Sub-agent: `miru install` (global) or `miru init --agent cursor` (project-local).
145
205
 
146
206
  ### Claude Code
147
207
 
148
- **MCP** — project `.mcp.json` (check into git) or user scope in `~/.claude.json`:
208
+ Project `.mcp.json` or `~/.claude.json`:
149
209
 
150
210
  ```json
151
211
  {
@@ -162,25 +222,13 @@ Commit `.cursor/agents/miru-code.md` to share the exploration agent with your te
162
222
  }
163
223
  ```
164
224
 
165
- Claude Code supports `${VAR}` expansion in config files. Restart the session and run `/mcp` to verify the connection.
166
-
167
- Or via CLI:
168
-
169
- ```bash
170
- claude mcp add miru -s project -- bunx @takara-ai/miru-code
171
- ```
172
-
173
- **Sub-agent:**
174
-
175
- ```bash
176
- miru init --agent claude
177
- ```
225
+ `${VAR}` expansion is supported. Restart and run `/mcp`, or: `claude mcp add miru -s project -- bunx @takara-ai/miru-code`.
178
226
 
179
- Writes `.claude/agents/miru-code.md` — invoke the `miru-code` agent for semantic exploration tasks.
227
+ Sub-agent: `miru install` (global) or `miru init --agent claude` (project-local).
180
228
 
181
229
  ### VS Code / GitHub Copilot
182
230
 
183
- **MCP** — workspace `.vscode/mcp.json` or user profile (Command Palette: **MCP: Open User Configuration**):
231
+ `.vscode/mcp.json` or user profile (**MCP: Open User Configuration**). Note `"servers"` not `mcpServers`:
184
232
 
185
233
  ```json
186
234
  {
@@ -197,76 +245,28 @@ Writes `.claude/agents/miru-code.md` — invoke the `miru-code` agent for semant
197
245
  }
198
246
  ```
199
247
 
200
- VS Code uses `"servers"` (not `mcpServers`). Use **MCP: List Servers** to start or restart the server after editing the config.
201
-
202
- **Sub-agent:**
203
-
204
- ```bash
205
- miru init --agent copilot
206
- ```
207
-
208
- Writes `.github/agents/miru-code.md` for Copilot’s agent system.
248
+ Use **MCP: List Servers** to restart after edits. Sub-agent: `miru install`.
209
249
 
210
250
  ### Gemini CLI
211
251
 
212
- **MCP** — `~/.gemini/settings.json` or project `.gemini/settings.json`:
213
-
214
- ```json
215
- {
216
- "mcpServers": {
217
- "miru": {
218
- "command": "bunx",
219
- "args": ["@takara-ai/miru-code"],
220
- "env": {
221
- "TAKARA_API_KEY": "your-takara-bearer-token"
222
- }
223
- }
224
- }
225
- }
226
- ```
227
-
228
- Or add interactively: `gemini mcp add`. Run `/mcp` inside a session to confirm tools are available.
229
-
230
- **Sub-agent:**
231
-
232
- ```bash
233
- miru init --agent gemini
234
- ```
235
-
236
- Writes `.gemini/agents/miru-code.md`.
252
+ `~/.gemini/settings.json` — same `mcpServers` shape as Cursor. `gemini mcp add` or `/mcp` to verify. Prefer `miru install`.
237
253
 
238
254
  ### Kiro
239
255
 
240
- **MCP** — `~/.kiro/settings/mcp.json` or workspace `.kiro/settings/mcp.json`:
256
+ `~/.kiro/settings/mcp.json` — include `PATH` if Bun is not on the default path:
241
257
 
242
258
  ```json
243
- {
244
- "mcpServers": {
245
- "miru": {
246
- "command": "bunx",
247
- "args": ["@takara-ai/miru-code"],
248
- "env": {
249
- "TAKARA_API_KEY": "your-takara-bearer-token",
250
- "PATH": "/usr/local/bin:/usr/bin:/bin"
251
- }
252
- }
253
- }
259
+ "env": {
260
+ "TAKARA_API_KEY": "your-takara-bearer-token",
261
+ "PATH": "/usr/local/bin:/usr/bin:/bin"
254
262
  }
255
263
  ```
256
264
 
257
- Kiro runs with a minimal environment — include `PATH` if Bun is not on the default path. Approve env vars when prompted in the IDE.
258
-
259
- **Sub-agent:**
260
-
261
- ```bash
262
- miru init --agent kiro
263
- ```
264
-
265
- Writes `.kiro/agents/miru-code.md`.
265
+ Sub-agent: `miru install`.
266
266
 
267
267
  ### OpenCode
268
268
 
269
- **MCP** — `~/.config/opencode/opencode.json` or project `opencode.json`:
269
+ `opencode.json` uses `mcp`, `"type": "local"`, and `environment`:
270
270
 
271
271
  ```json
272
272
  {
@@ -284,87 +284,126 @@ Writes `.kiro/agents/miru-code.md`.
284
284
  }
285
285
  ```
286
286
 
287
- OpenCode uses the `mcp` key (not `mcpServers`), requires `"type": "local"`, and uses `environment` instead of `env`. Verify with `opencode mcp list`.
287
+ Verify with `opencode mcp list`. Sub-agent: `miru install`.
288
+
289
+ ## CLI
288
290
 
289
- **Sub-agent:**
291
+ Installed globally or via `bunx`:
290
292
 
291
293
  ```bash
292
- miru init --agent opencode
294
+ miru setup
295
+ miru install # interactive MCP + instructions + sub-agent (recommended)
296
+ miru search "where are embeddings created" ./src -k 10 --content code
297
+ miru find-related src/embeddings/openai.ts 120 ./src
298
+ miru uninstall # remove miru config from agents
299
+ miru clear ./src
300
+ miru help search # per-command help
301
+ miru -h # environment variables
293
302
  ```
294
303
 
295
- Writes `.opencode/agents/miru-code.md` (subagent mode with bash/read permissions).
304
+ From **this repo** (development), prefix with `bun run miru` instead of `miru`.
296
305
 
297
- ### Local development (any IDE)
306
+ | Command | Summary |
307
+ |---------|---------|
308
+ | `search <query> [path]` | Hybrid search; `path` defaults to cwd; accepts local path or `https://` git URL |
309
+ | `find-related <file> <line> [path]` | Semantic neighbors of the chunk containing that line |
310
+ | `setup` | Store and validate `TAKARA_API_KEY` locally |
311
+ | `install` | Interactive global agent setup (MCP, instructions, sub-agent) |
312
+ | `uninstall` | Remove miru configuration from agents |
313
+ | `init --agent <id>` | Write project-local sub-agent markdown |
314
+ | `clear [path]` | Delete disk cache for that source |
315
+ | *(no command)* | Start MCP server |
298
316
 
299
- Point MCP at this repo instead of the published package:
317
+ **Options:** `-k` / `--top-k N` (default 5), `--content code|docs|config|all` (default `code`). Multiple types: `--content code docs`.
300
318
 
301
- ```json
302
- {
303
- "command": "bun",
304
- "args": ["/absolute/path/to/miru-code/src/cli.ts"],
305
- "env": {
306
- "TAKARA_API_KEY": "your-takara-bearer-token"
307
- }
308
- }
309
- ```
319
+ Output is JSON (`query` + `results` with `chunk`, `score`, `location`).
310
320
 
311
- Merge into the appropriate wrapper key (`mcpServers`, `servers`, or `mcp`) for your IDE.
321
+ ## Library
312
322
 
313
- ## CLI
323
+ ```ts
324
+ import { MiruIndex } from "@takara-ai/miru-code";
314
325
 
315
- ```bash
316
- # Hybrid search (positional, Python-compatible)
317
- bun run miru search "where are embeddings created" ./src -k 5
326
+ // Local directory
327
+ const index = await MiruIndex.fromPath("./src", ["code"]);
318
328
 
319
- # Find semantically related chunks
320
- bun run miru find-related src/embeddings/openai.ts 120 ./src
329
+ // Local path or https:// git URL
330
+ const fromUrl = await MiruIndex.fromSource("https://github.com/org/repo", ["code"], undefined, "main");
321
331
 
322
- # Write a miru-code sub-agent for your IDE
323
- bun run miru init --agent cursor
332
+ const results = await index.search({
333
+ query: "BM25 tokenize",
334
+ topK: 10, // default 10 in the library API
335
+ filterPaths: ["src/index/bm25.ts"],
336
+ rerank: true,
337
+ });
324
338
 
325
- # Clear disk cache
326
- bun run miru clear ./src
339
+ const related = await index.findRelated(results[0], 5);
340
+ await index.saveToDefaultCache("./src");
327
341
  ```
328
342
 
329
- Indexes are cached under `~/Library/Caches/miru` (macOS) or `~/.cache/miru` (Linux).
343
+ Exports: `MiruIndex`, `clearCache`, `findIndexCachePath`, `resolveCacheFolder`, and chunk/result types.
330
344
 
331
- ## Library
345
+ ## Environment variables
332
346
 
333
- ```ts
334
- import { MiruIndex } from "@takara-ai/miru-code";
347
+ | Variable | Default / notes |
348
+ |----------|-----------------|
349
+ | `TAKARA_API_KEY` | **Required** — Takara bearer token |
350
+ | `MIRU_OPENAI_BASE_URL` | `https://infer.dev.takara.ai/v1` |
351
+ | `MIRU_OPENAI_EMBEDDING_MODEL` | `ds1-potion-code-16m` |
352
+ | `MIRU_EMBEDDING_DIMENSIONS` | `256` for potion (auto when unset) |
353
+ | `MIRU_FLOAT_VECTORS` | unset = **int8** vectors; `1` = float32 |
354
+ | `MIRU_EMBEDDING_BATCH_SIZE` | `32` |
355
+ | `MIRU_CONCURRENCY` | logical CPUs **minus 2** (min 1); file IO, embedding batches, BM25 workers |
356
+ | `MIRU_MCP_WATCH` | on; set `0` or `false` to disable MCP filesystem watch |
357
+ | `MIRU_CREDENTIALS_DIR` | override stored-credentials directory |
358
+ | `MIRU_PIPELINE_EMBED_BATCH` | optional pipeline tuning (see `.env.example`) |
359
+ | `MIRU_PIPELINE_EMBED_INFLIGHT` | optional pipeline tuning |
335
360
 
336
- const index = await MiruIndex.fromPath("./src");
337
- const results = await index.search({ query: "BM25 tokenize", topK: 10 });
338
- ```
361
+ Parallelism covers chunking, concurrent embedding requests, overlapping query embed with BM25, and BM25 worker sharding on large indexes.
339
362
 
340
- ## Tests
363
+ ## Developing Miru
341
364
 
342
365
  ```bash
366
+ bun install
367
+ cp .env.example .env.local # add TAKARA_API_KEY
343
368
  bun test
344
369
  bun run typecheck
345
370
  ```
346
371
 
372
+ **Local MCP** — point at your `miru-code` clone:
373
+
374
+ ```json
375
+ {
376
+ "command": "bun",
377
+ "args": ["/absolute/path/to/miru-code/src/cli.ts"],
378
+ "env": {
379
+ "TAKARA_API_KEY": "your-takara-bearer-token"
380
+ }
381
+ }
382
+ ```
383
+
384
+ Merge into the IDE’s wrapper (`mcpServers`, `servers`, or `mcp`).
385
+
347
386
  ## Publishing
348
387
 
349
- Releases use **Bun** for install, test, and `bun pm pack`. The registry upload uses **`npm publish`** on that tarball because [Bun does not yet support npm OIDC trusted publishing](https://github.com/oven-sh/bun/issues/22423) — no long-lived npm tokens in GitHub secrets.
388
+ Releases use **Bun** for install, test, and `bun pm pack`. Registry upload uses **`npm publish`** on that tarball because [Bun does not yet support npm OIDC trusted publishing](https://github.com/oven-sh/bun/issues/22423).
350
389
 
351
- **Local publish** (logged in to npm; `publishConfig.access` is already `public`):
390
+ **Local** (logged in to npm):
352
391
 
353
392
  ```bash
354
393
  bun publish
355
394
  ```
356
395
 
357
- Runs `prepublishOnly` (typecheck + tests), then a single registry upload. Do not add a `publish` script that calls `npm publish` — Bun runs lifecycle scripts after its own upload and would publish twice.
396
+ Runs `prepublishOnly` (typecheck + tests). Do not add a `publish` script that calls `npm publish` — that would upload twice.
358
397
 
359
- **CI** (after Trusted Publisher is configured on npm):
398
+ **CI** (Trusted Publisher on npm):
360
399
 
361
400
  ```bash
362
401
  npm version patch
363
402
  git push && git push --tags
364
- gh release create v0.1.1 --generate-notes
403
+ gh release create v$(node -p "require('./package.json').version") --generate-notes
365
404
  ```
366
405
 
367
- The `release.yml` workflow runs when the GitHub Release is published.
406
+ `release.yml` publishes when the GitHub Release is published.
368
407
 
369
408
  ## License
370
409
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takara-ai/miru-code",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Miru (見る) — hybrid code search for agents. Bun, TypeScript, Takara embeddings.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@ miru search "save_pretrained" ./my-project
12
12
  miru search "save model to disk" ./my-project --top-k 10
13
13
  ```
14
14
 
15
- Results are cached automatically on first run and invalidated when files change.
15
+ First run builds a disk cache. The MCP server incrementally updates local indexes while it runs; after CLI-only use or large refactors, run `miru clear <path>` to rebuild.
16
16
 
17
17
  Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config:
18
18
 
@@ -12,7 +12,7 @@ miru search "save_pretrained" ./my-project
12
12
  miru search "save model to disk" ./my-project --top-k 10
13
13
  ```
14
14
 
15
- Results are cached automatically on first run and invalidated when files change.
15
+ First run builds a disk cache. The MCP server incrementally updates local indexes while it runs; after CLI-only use or large refactors, run `miru clear <path>` to rebuild.
16
16
 
17
17
  Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config:
18
18
 
@@ -11,7 +11,7 @@ miru search "save_pretrained" ./my-project
11
11
  miru search "save model to disk" ./my-project --top-k 10
12
12
  ```
13
13
 
14
- Results are cached automatically on first run and invalidated when files change.
14
+ First run builds a disk cache. The MCP server incrementally updates local indexes while it runs; after CLI-only use or large refactors, run `miru clear <path>` to rebuild.
15
15
 
16
16
  Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config:
17
17
 
@@ -14,7 +14,7 @@ miru search "save_pretrained" ./my-project
14
14
  miru search "save model to disk" ./my-project --top-k 10
15
15
  ```
16
16
 
17
- Results are cached automatically on first run and invalidated when files change.
17
+ First run builds a disk cache. The MCP server incrementally updates local indexes while it runs; after CLI-only use or large refactors, run `miru clear <path>` to rebuild.
18
18
 
19
19
  Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config:
20
20
 
@@ -14,7 +14,7 @@ miru search "save_pretrained" ./my-project
14
14
  miru search "save model to disk" ./my-project --top-k 10
15
15
  ```
16
16
 
17
- Results are cached automatically on first run and invalidated when files change.
17
+ First run builds a disk cache. The MCP server incrementally updates local indexes while it runs; after CLI-only use or large refactors, run `miru clear <path>` to rebuild.
18
18
 
19
19
  Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config:
20
20
 
@@ -15,7 +15,7 @@ miru search "save_pretrained" ./my-project
15
15
  miru search "save model to disk" ./my-project --top-k 10
16
16
  ```
17
17
 
18
- Results are cached automatically on first run and invalidated when files change.
18
+ First run builds a disk cache. The MCP server incrementally updates local indexes while it runs; after CLI-only use or large refactors, run `miru clear <path>` to rebuild.
19
19
 
20
20
  Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config:
21
21