@takara-ai/miru-code 0.2.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 +202 -167
- package/package.json +1 -1
- package/src/agents/claude.md +1 -1
- package/src/agents/copilot.md +1 -1
- package/src/agents/cursor.md +1 -1
- package/src/agents/gemini.md +1 -1
- package/src/agents/kiro.md +1 -1
- package/src/agents/opencode.md +1 -1
- package/src/cli-ui.ts +189 -0
- package/src/cli.ts +167 -64
- package/src/credentials.ts +2 -6
- package/src/env.ts +6 -10
- package/src/help.ts +160 -0
- package/src/installer/agents.ts +246 -0
- package/src/installer/config.ts +273 -0
- package/src/installer/installer.ts +256 -0
- package/src/installer/prompt.ts +77 -0
- package/src/prompt.ts +111 -0
- package/src/setup.ts +20 -72
- package/src/spinner.ts +10 -4
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**
|
|
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
|
|
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
|
-
|
|
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 |
|
|
27
|
-
| **CLI sub-agent** | Any agent with shell access | `miru init --agent <id>`
|
|
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
|
-
|
|
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
|
|
72
|
+
Requires [Bun](https://bun.sh) 1.1+ on your PATH.
|
|
34
73
|
|
|
35
74
|
```bash
|
|
36
|
-
#
|
|
75
|
+
# One-off
|
|
37
76
|
bunx @takara-ai/miru-code search "auth middleware" ./src
|
|
38
77
|
|
|
39
78
|
# Global CLI
|
|
@@ -44,71 +83,96 @@ miru search "auth middleware" ./src
|
|
|
44
83
|
bun add @takara-ai/miru-code
|
|
45
84
|
```
|
|
46
85
|
|
|
47
|
-
|
|
48
|
-
import { MiruIndex } from "@takara-ai/miru-code";
|
|
86
|
+
## Credentials
|
|
49
87
|
|
|
50
|
-
|
|
51
|
-
```
|
|
88
|
+
Miru needs a **Takara bearer token** for embeddings (`TAKARA_API_KEY`).
|
|
52
89
|
|
|
53
|
-
|
|
90
|
+
**CLI / terminal (recommended for local dev):**
|
|
54
91
|
|
|
55
92
|
```bash
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
62
|
-
|----------|---------|
|
|
63
|
-
| `TAKARA_API_KEY` / `OPENAI_API_KEY` / `MIRU_OPENAI_API_KEY` | (required) Bearer token for Takara |
|
|
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
|
-
`
|
|
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
|
-
|
|
106
|
+
### Recommended: `miru install`
|
|
76
107
|
|
|
77
|
-
|
|
108
|
+
Interactive setup (like Semble’s `semble install`). Detects installed agents and configures any combination of:
|
|
78
109
|
|
|
79
|
-
|
|
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
|
+
```
|
|
80
121
|
|
|
81
|
-
|
|
122
|
+
Undo with `miru uninstall`. Restart your IDE/agent session after install.
|
|
82
123
|
|
|
83
|
-
|
|
84
|
-
|-----|-----------------|-------------------|------------------|
|
|
85
|
-
| [Cursor](#cursor) | `~/.cursor/mcp.json` or `.cursor/mcp.json` | `miru init --agent cursor` | `.cursor/agents/miru-code.md` |
|
|
86
|
-
| [Claude Code](#claude-code) | `.mcp.json` (project root) or `~/.claude.json` | `miru init --agent claude` | `.claude/agents/miru-code.md` |
|
|
87
|
-
| [VS Code / Copilot](#vs-code--github-copilot) | `.vscode/mcp.json` or user profile `mcp.json` | `miru init --agent copilot` | `.github/agents/miru-code.md` |
|
|
88
|
-
| [Gemini CLI](#gemini-cli) | `~/.gemini/settings.json` or `.gemini/settings.json` | `miru init --agent gemini` | `.gemini/agents/miru-code.md` |
|
|
89
|
-
| [Kiro](#kiro) | `~/.kiro/settings/mcp.json` or `.kiro/settings/mcp.json` | `miru init --agent kiro` | `.kiro/agents/miru-code.md` |
|
|
90
|
-
| [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.
|
|
91
125
|
|
|
92
|
-
|
|
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`.
|
|
93
150
|
|
|
94
151
|
### MCP server
|
|
95
152
|
|
|
96
|
-
|
|
153
|
+
No subcommand starts stdio MCP:
|
|
97
154
|
|
|
98
155
|
```bash
|
|
99
156
|
bunx @takara-ai/miru-code
|
|
100
|
-
# or
|
|
157
|
+
# or: miru
|
|
101
158
|
```
|
|
102
159
|
|
|
103
|
-
|
|
160
|
+
Optional startup flags: `--ref BRANCH` (default git ref for remote repos), `--content code docs …` (same types as CLI).
|
|
161
|
+
|
|
162
|
+
**Tools**
|
|
104
163
|
|
|
105
|
-
|
|
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` |
|
|
106
168
|
|
|
107
|
-
|
|
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.
|
|
108
172
|
|
|
109
173
|
#### Shared env block
|
|
110
174
|
|
|
111
|
-
Use
|
|
175
|
+
Use in every MCP config (some IDEs use `environment` instead of `env`):
|
|
112
176
|
|
|
113
177
|
```json
|
|
114
178
|
{
|
|
@@ -121,7 +185,7 @@ Use this in every MCP config below (adjust the key name if your IDE uses `enviro
|
|
|
121
185
|
|
|
122
186
|
### Cursor
|
|
123
187
|
|
|
124
|
-
|
|
188
|
+
`~/.cursor/mcp.json` or project `.cursor/mcp.json`:
|
|
125
189
|
|
|
126
190
|
```json
|
|
127
191
|
{
|
|
@@ -137,19 +201,11 @@ Use this in every MCP config below (adjust the key name if your IDE uses `enviro
|
|
|
137
201
|
}
|
|
138
202
|
```
|
|
139
203
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
**Sub-agent:**
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
miru init --agent cursor
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
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).
|
|
149
205
|
|
|
150
206
|
### Claude Code
|
|
151
207
|
|
|
152
|
-
|
|
208
|
+
Project `.mcp.json` or `~/.claude.json`:
|
|
153
209
|
|
|
154
210
|
```json
|
|
155
211
|
{
|
|
@@ -166,25 +222,13 @@ Commit `.cursor/agents/miru-code.md` to share the exploration agent with your te
|
|
|
166
222
|
}
|
|
167
223
|
```
|
|
168
224
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
Or via CLI:
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
claude mcp add miru -s project -- bunx @takara-ai/miru-code
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
**Sub-agent:**
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
miru init --agent claude
|
|
181
|
-
```
|
|
225
|
+
`${VAR}` expansion is supported. Restart and run `/mcp`, or: `claude mcp add miru -s project -- bunx @takara-ai/miru-code`.
|
|
182
226
|
|
|
183
|
-
|
|
227
|
+
Sub-agent: `miru install` (global) or `miru init --agent claude` (project-local).
|
|
184
228
|
|
|
185
229
|
### VS Code / GitHub Copilot
|
|
186
230
|
|
|
187
|
-
|
|
231
|
+
`.vscode/mcp.json` or user profile (**MCP: Open User Configuration**). Note `"servers"` not `mcpServers`:
|
|
188
232
|
|
|
189
233
|
```json
|
|
190
234
|
{
|
|
@@ -201,76 +245,28 @@ Writes `.claude/agents/miru-code.md` — invoke the `miru-code` agent for semant
|
|
|
201
245
|
}
|
|
202
246
|
```
|
|
203
247
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
**Sub-agent:**
|
|
207
|
-
|
|
208
|
-
```bash
|
|
209
|
-
miru init --agent copilot
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
Writes `.github/agents/miru-code.md` for Copilot’s agent system.
|
|
248
|
+
Use **MCP: List Servers** to restart after edits. Sub-agent: `miru install`.
|
|
213
249
|
|
|
214
250
|
### Gemini CLI
|
|
215
251
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
```json
|
|
219
|
-
{
|
|
220
|
-
"mcpServers": {
|
|
221
|
-
"miru": {
|
|
222
|
-
"command": "bunx",
|
|
223
|
-
"args": ["@takara-ai/miru-code"],
|
|
224
|
-
"env": {
|
|
225
|
-
"TAKARA_API_KEY": "your-takara-bearer-token"
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
Or add interactively: `gemini mcp add`. Run `/mcp` inside a session to confirm tools are available.
|
|
233
|
-
|
|
234
|
-
**Sub-agent:**
|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
miru init --agent gemini
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
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`.
|
|
241
253
|
|
|
242
254
|
### Kiro
|
|
243
255
|
|
|
244
|
-
|
|
256
|
+
`~/.kiro/settings/mcp.json` — include `PATH` if Bun is not on the default path:
|
|
245
257
|
|
|
246
258
|
```json
|
|
247
|
-
{
|
|
248
|
-
"
|
|
249
|
-
|
|
250
|
-
"command": "bunx",
|
|
251
|
-
"args": ["@takara-ai/miru-code"],
|
|
252
|
-
"env": {
|
|
253
|
-
"TAKARA_API_KEY": "your-takara-bearer-token",
|
|
254
|
-
"PATH": "/usr/local/bin:/usr/bin:/bin"
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
259
|
+
"env": {
|
|
260
|
+
"TAKARA_API_KEY": "your-takara-bearer-token",
|
|
261
|
+
"PATH": "/usr/local/bin:/usr/bin:/bin"
|
|
258
262
|
}
|
|
259
263
|
```
|
|
260
264
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
**Sub-agent:**
|
|
264
|
-
|
|
265
|
-
```bash
|
|
266
|
-
miru init --agent kiro
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
Writes `.kiro/agents/miru-code.md`.
|
|
265
|
+
Sub-agent: `miru install`.
|
|
270
266
|
|
|
271
267
|
### OpenCode
|
|
272
268
|
|
|
273
|
-
|
|
269
|
+
`opencode.json` uses `mcp`, `"type": "local"`, and `environment`:
|
|
274
270
|
|
|
275
271
|
```json
|
|
276
272
|
{
|
|
@@ -288,87 +284,126 @@ Writes `.kiro/agents/miru-code.md`.
|
|
|
288
284
|
}
|
|
289
285
|
```
|
|
290
286
|
|
|
291
|
-
|
|
287
|
+
Verify with `opencode mcp list`. Sub-agent: `miru install`.
|
|
288
|
+
|
|
289
|
+
## CLI
|
|
292
290
|
|
|
293
|
-
|
|
291
|
+
Installed globally or via `bunx`:
|
|
294
292
|
|
|
295
293
|
```bash
|
|
296
|
-
miru
|
|
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
|
|
297
302
|
```
|
|
298
303
|
|
|
299
|
-
|
|
304
|
+
From **this repo** (development), prefix with `bun run miru` instead of `miru`.
|
|
300
305
|
|
|
301
|
-
|
|
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 |
|
|
302
316
|
|
|
303
|
-
|
|
317
|
+
**Options:** `-k` / `--top-k N` (default 5), `--content code|docs|config|all` (default `code`). Multiple types: `--content code docs`.
|
|
304
318
|
|
|
305
|
-
|
|
306
|
-
{
|
|
307
|
-
"command": "bun",
|
|
308
|
-
"args": ["/absolute/path/to/miru-code/src/cli.ts"],
|
|
309
|
-
"env": {
|
|
310
|
-
"TAKARA_API_KEY": "your-takara-bearer-token"
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
```
|
|
319
|
+
Output is JSON (`query` + `results` with `chunk`, `score`, `location`).
|
|
314
320
|
|
|
315
|
-
|
|
321
|
+
## Library
|
|
316
322
|
|
|
317
|
-
|
|
323
|
+
```ts
|
|
324
|
+
import { MiruIndex } from "@takara-ai/miru-code";
|
|
318
325
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
bun run miru search "where are embeddings created" ./src -k 5
|
|
326
|
+
// Local directory
|
|
327
|
+
const index = await MiruIndex.fromPath("./src", ["code"]);
|
|
322
328
|
|
|
323
|
-
|
|
324
|
-
|
|
329
|
+
// Local path or https:// git URL
|
|
330
|
+
const fromUrl = await MiruIndex.fromSource("https://github.com/org/repo", ["code"], undefined, "main");
|
|
325
331
|
|
|
326
|
-
|
|
327
|
-
|
|
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
|
+
});
|
|
328
338
|
|
|
329
|
-
|
|
330
|
-
|
|
339
|
+
const related = await index.findRelated(results[0], 5);
|
|
340
|
+
await index.saveToDefaultCache("./src");
|
|
331
341
|
```
|
|
332
342
|
|
|
333
|
-
|
|
343
|
+
Exports: `MiruIndex`, `clearCache`, `findIndexCachePath`, `resolveCacheFolder`, and chunk/result types.
|
|
334
344
|
|
|
335
|
-
##
|
|
345
|
+
## Environment variables
|
|
336
346
|
|
|
337
|
-
|
|
338
|
-
|
|
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 |
|
|
339
360
|
|
|
340
|
-
|
|
341
|
-
const results = await index.search({ query: "BM25 tokenize", topK: 10 });
|
|
342
|
-
```
|
|
361
|
+
Parallelism covers chunking, concurrent embedding requests, overlapping query embed with BM25, and BM25 worker sharding on large indexes.
|
|
343
362
|
|
|
344
|
-
##
|
|
363
|
+
## Developing Miru
|
|
345
364
|
|
|
346
365
|
```bash
|
|
366
|
+
bun install
|
|
367
|
+
cp .env.example .env.local # add TAKARA_API_KEY
|
|
347
368
|
bun test
|
|
348
369
|
bun run typecheck
|
|
349
370
|
```
|
|
350
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
|
+
|
|
351
386
|
## Publishing
|
|
352
387
|
|
|
353
|
-
Releases use **Bun** for install, test, and `bun pm pack`.
|
|
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).
|
|
354
389
|
|
|
355
|
-
**Local
|
|
390
|
+
**Local** (logged in to npm):
|
|
356
391
|
|
|
357
392
|
```bash
|
|
358
393
|
bun publish
|
|
359
394
|
```
|
|
360
395
|
|
|
361
|
-
Runs `prepublishOnly` (typecheck + tests)
|
|
396
|
+
Runs `prepublishOnly` (typecheck + tests). Do not add a `publish` script that calls `npm publish` — that would upload twice.
|
|
362
397
|
|
|
363
|
-
**CI** (
|
|
398
|
+
**CI** (Trusted Publisher on npm):
|
|
364
399
|
|
|
365
400
|
```bash
|
|
366
401
|
npm version patch
|
|
367
402
|
git push && git push --tags
|
|
368
|
-
gh release create
|
|
403
|
+
gh release create v$(node -p "require('./package.json').version") --generate-notes
|
|
369
404
|
```
|
|
370
405
|
|
|
371
|
-
|
|
406
|
+
`release.yml` publishes when the GitHub Release is published.
|
|
372
407
|
|
|
373
408
|
## License
|
|
374
409
|
|
package/package.json
CHANGED
package/src/agents/claude.md
CHANGED
|
@@ -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
|
-
|
|
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
|
|
package/src/agents/copilot.md
CHANGED
|
@@ -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
|
-
|
|
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
|
|
package/src/agents/cursor.md
CHANGED
|
@@ -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
|
-
|
|
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
|
|
package/src/agents/gemini.md
CHANGED
|
@@ -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
|
-
|
|
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
|
|
package/src/agents/kiro.md
CHANGED
|
@@ -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
|
-
|
|
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
|
|
package/src/agents/opencode.md
CHANGED
|
@@ -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
|
-
|
|
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
|
|