@takara-ai/miru-code 0.4.0 → 0.4.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.
- package/README.md +130 -248
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,128 +2,98 @@
|
|
|
2
2
|
|
|
3
3
|
Hybrid code search for AI agents — **TypeScript**, **Bun**, and **Takara embeddings**.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
16
|
-
## What is Miru?
|
|
17
|
-
|
|
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.
|
|
19
|
-
|
|
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.
|
|
5
|
+
Miru helps coding agents **find code by meaning**. Ask “where is auth middleware configured?” and get back the most relevant **chunks** (file path, line range, snippet) instead of grepping the whole tree.
|
|
21
6
|
|
|
22
|
-
|
|
7
|
+
## Quick start
|
|
23
8
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
1. **Dense (semantic)** — Takara code embeddings (`ds1-potion-code-16m`) over structurally chunked source files.
|
|
27
|
-
2. **Sparse (BM25)** — keyword scoring with an inverted index; parallelized in Bun workers when the index has 256+ chunks.
|
|
28
|
-
3. **RRF fusion** — reciprocal rank fusion merges the two ranked lists.
|
|
29
|
-
4. **Reranking** — code-tuned penalties and boosts (e.g. multi-chunk files, query-term overlap).
|
|
30
|
-
|
|
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. |
|
|
9
|
+
**Requirements:** [Bun](https://bun.sh) 1.1+ and a [Takara API key](https://takara.ai) for embeddings.
|
|
41
10
|
|
|
42
|
-
|
|
11
|
+
```bash
|
|
12
|
+
# 1. Install the CLI
|
|
13
|
+
bun add -g @takara-ai/miru-code
|
|
43
14
|
|
|
44
|
-
|
|
15
|
+
# 2. Store your API key (validates against Takara)
|
|
16
|
+
miru setup
|
|
45
17
|
|
|
46
|
-
|
|
47
|
-
|
|
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) |
|
|
18
|
+
# 3. Wire into your agents (MCP + instructions + sub-agent)
|
|
19
|
+
miru install
|
|
50
20
|
|
|
51
|
-
|
|
21
|
+
# 4. Restart your IDE / agent session, then search
|
|
22
|
+
miru search "auth middleware" ./src
|
|
23
|
+
```
|
|
52
24
|
|
|
53
|
-
|
|
25
|
+
That’s the full path for most users. `miru install` is interactive — it detects Cursor, Claude Code, Gemini CLI, Kiro, OpenCode, GitHub Copilot, Codex, and VS Code, and lets you pick what to configure.
|
|
54
26
|
|
|
55
|
-
|
|
27
|
+
**One-off without installing:**
|
|
56
28
|
|
|
57
|
-
```
|
|
58
|
-
|
|
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
|
|
29
|
+
```bash
|
|
30
|
+
bunx @takara-ai/miru-code search "auth middleware" ./src
|
|
64
31
|
```
|
|
65
32
|
|
|
66
|
-
**
|
|
33
|
+
**Undo agent setup:** `miru uninstall`
|
|
67
34
|
|
|
68
|
-
|
|
35
|
+
---
|
|
69
36
|
|
|
70
|
-
##
|
|
37
|
+
## How to read this doc
|
|
71
38
|
|
|
72
|
-
|
|
39
|
+
| Goal | Section |
|
|
40
|
+
|------|---------|
|
|
41
|
+
| Get running in an IDE | [Quick start](#quick-start) → [IDE integration](#ide-integration) |
|
|
42
|
+
| Search from terminal or scripts | [CLI](#cli) |
|
|
43
|
+
| Use as a library | [Library](#library) |
|
|
44
|
+
| Contribute to this repo | [Developing Miru](#developing-miru) |
|
|
73
45
|
|
|
74
|
-
|
|
75
|
-
# One-off
|
|
76
|
-
bunx @takara-ai/miru-code search "auth middleware" ./src
|
|
46
|
+
## Install options
|
|
77
47
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
miru
|
|
48
|
+
| Method | Command | When to use |
|
|
49
|
+
|--------|---------|-------------|
|
|
50
|
+
| Global CLI | `bun add -g @takara-ai/miru-code` | Daily use, `miru install`, terminal search |
|
|
51
|
+
| One-off | `bunx @takara-ai/miru-code …` | Try before installing |
|
|
52
|
+
| Library | `bun add @takara-ai/miru-code` | Embed search in your own tool |
|
|
53
|
+
| From source | [Developing Miru](#developing-miru) | Contributors |
|
|
81
54
|
|
|
82
|
-
|
|
83
|
-
bun add @takara-ai/miru-code
|
|
84
|
-
```
|
|
55
|
+
After install, `miru` is on your PATH. Run `miru` with no args for help.
|
|
85
56
|
|
|
86
57
|
## Credentials
|
|
87
58
|
|
|
88
|
-
Miru needs a
|
|
89
|
-
|
|
90
|
-
**CLI / terminal (recommended for local dev):**
|
|
59
|
+
Miru needs `TAKARA_API_KEY` — a Takara bearer token for code embeddings.
|
|
91
60
|
|
|
92
61
|
```bash
|
|
93
|
-
miru setup # interactive; validates
|
|
62
|
+
miru setup # interactive; validates and stores locally
|
|
94
63
|
miru setup --key TOKEN # non-interactive
|
|
95
64
|
miru setup --clear # remove stored key
|
|
96
65
|
```
|
|
97
66
|
|
|
98
|
-
Stored
|
|
67
|
+
Stored credentials live at:
|
|
68
|
+
|
|
69
|
+
- macOS: `~/Library/Application Support/miru/credentials.json`
|
|
70
|
+
- Linux: `~/.config/miru/credentials.json`
|
|
71
|
+
- Windows: `%APPDATA%\miru\credentials.json`
|
|
99
72
|
|
|
100
|
-
|
|
73
|
+
Override with `MIRU_CREDENTIALS_DIR`.
|
|
101
74
|
|
|
102
|
-
**
|
|
75
|
+
**For MCP in an IDE:** also set `TAKARA_API_KEY` in the MCP server `env` block. MCP subprocesses do not reliably inherit your shell or `.env.local`. `miru install` writes `"TAKARA_API_KEY": "${TAKARA_API_KEY}"` where your IDE supports variable expansion — export the var or paste your token.
|
|
103
76
|
|
|
104
77
|
## IDE integration
|
|
105
78
|
|
|
106
79
|
### Recommended: `miru install`
|
|
107
80
|
|
|
108
|
-
|
|
81
|
+
Configures up to three integrations per agent:
|
|
109
82
|
|
|
110
83
|
| Integration | What it does |
|
|
111
84
|
|-------------|----------------|
|
|
112
|
-
| **MCP server** |
|
|
113
|
-
| **Instructions** |
|
|
114
|
-
| **Sub-agent** |
|
|
85
|
+
| **MCP server** | Native `search` and `find_related` tools |
|
|
86
|
+
| **Instructions** | Marked usage block in `CLAUDE.md`, `GEMINI.md`, `AGENTS.md`, etc. |
|
|
87
|
+
| **Sub-agent** | Global `miru-code` agent file (Bash-backed search for sub-agents without MCP) |
|
|
115
88
|
|
|
116
89
|
```bash
|
|
117
|
-
|
|
118
|
-
miru
|
|
119
|
-
miru install
|
|
90
|
+
miru install # pick agents + integrations
|
|
91
|
+
miru uninstall # remove miru entries
|
|
120
92
|
```
|
|
121
93
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
**Supported agents:** Claude Code, Cursor, Gemini CLI, Kiro, OpenCode, GitHub Copilot, Codex, VS Code.
|
|
94
|
+
Restart your IDE or agent session after install.
|
|
125
95
|
|
|
126
|
-
###
|
|
96
|
+
### Where files go (global user config)
|
|
127
97
|
|
|
128
98
|
| Agent | MCP config | Sub-agent |
|
|
129
99
|
|-------|------------|-----------|
|
|
@@ -133,207 +103,131 @@ Undo with `miru uninstall`. Restart your IDE/agent session after install.
|
|
|
133
103
|
| Kiro | `~/.kiro/settings/mcp.json` | `~/.kiro/agents/miru-code.md` |
|
|
134
104
|
| OpenCode | `~/.config/opencode/opencode.json(c)` | `~/.config/opencode/agents/miru-code.md` |
|
|
135
105
|
| GitHub Copilot | `~/.copilot/mcp-config.json` | `~/.copilot/agents/miru-code.agent.md` |
|
|
136
|
-
| Codex | `~/.codex/config.toml` |
|
|
137
|
-
| VS Code | user profile `mcp.json` |
|
|
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.
|
|
106
|
+
| Codex | `~/.codex/config.toml` | — |
|
|
107
|
+
| VS Code | user profile `Code/User/mcp.json` | — |
|
|
140
108
|
|
|
141
109
|
### Per-project sub-agent (`miru init`)
|
|
142
110
|
|
|
143
|
-
To commit a sub-agent into a repo (
|
|
111
|
+
To commit a sub-agent into a repo for your team (project-local, not global):
|
|
144
112
|
|
|
145
113
|
```bash
|
|
146
|
-
miru init --agent claude --force # → .claude/agents/miru-code.md
|
|
114
|
+
miru init --agent claude --force # → .claude/agents/miru-code.md
|
|
147
115
|
```
|
|
148
116
|
|
|
149
117
|
Agents: `cursor`, `claude`, `copilot`, `gemini`, `kiro`, `opencode`.
|
|
150
118
|
|
|
151
|
-
### MCP
|
|
119
|
+
### Manual MCP setup
|
|
152
120
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
bunx @takara-ai/miru-code
|
|
157
|
-
# or: miru
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Optional startup flags: `--ref BRANCH` (default git ref for remote repos), `--content code docs …` (same types as CLI).
|
|
161
|
-
|
|
162
|
-
**Tools**
|
|
163
|
-
|
|
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` |
|
|
168
|
-
|
|
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.
|
|
172
|
-
|
|
173
|
-
#### Shared env block
|
|
174
|
-
|
|
175
|
-
Use in every MCP config (some IDEs use `environment` instead of `env`):
|
|
121
|
+
Skip `miru install` and add this to your IDE’s MCP config (`mcpServers`, `servers`, or `mcp` depending on the tool):
|
|
176
122
|
|
|
177
123
|
```json
|
|
178
124
|
{
|
|
179
|
-
"
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### Cursor
|
|
187
|
-
|
|
188
|
-
`~/.cursor/mcp.json` or project `.cursor/mcp.json`:
|
|
189
|
-
|
|
190
|
-
```json
|
|
191
|
-
{
|
|
192
|
-
"mcpServers": {
|
|
193
|
-
"miru": {
|
|
194
|
-
"command": "bunx",
|
|
195
|
-
"args": ["@takara-ai/miru-code"],
|
|
196
|
-
"env": {
|
|
197
|
-
"TAKARA_API_KEY": "your-takara-bearer-token"
|
|
198
|
-
}
|
|
125
|
+
"miru": {
|
|
126
|
+
"command": "bunx",
|
|
127
|
+
"args": ["@takara-ai/miru-code"],
|
|
128
|
+
"env": {
|
|
129
|
+
"TAKARA_API_KEY": "your-takara-bearer-token"
|
|
199
130
|
}
|
|
200
131
|
}
|
|
201
132
|
}
|
|
202
133
|
```
|
|
203
134
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
### Claude Code
|
|
135
|
+
After `bun add -g @takara-ai/miru-code`, you can use `"command": "miru"` instead of `bunx`.
|
|
207
136
|
|
|
208
|
-
|
|
137
|
+
**MCP tools**
|
|
209
138
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
"type": "stdio",
|
|
215
|
-
"command": "bunx",
|
|
216
|
-
"args": ["@takara-ai/miru-code"],
|
|
217
|
-
"env": {
|
|
218
|
-
"TAKARA_API_KEY": "${TAKARA_API_KEY}"
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
`${VAR}` expansion is supported. Restart and run `/mcp`, or: `claude mcp add miru -s project -- bunx @takara-ai/miru-code`.
|
|
226
|
-
|
|
227
|
-
Sub-agent: `miru install` (global) or `miru init --agent claude` (project-local).
|
|
228
|
-
|
|
229
|
-
### VS Code / GitHub Copilot
|
|
139
|
+
| Tool | Purpose |
|
|
140
|
+
|------|---------|
|
|
141
|
+
| `search` | Natural-language or code query; requires `repo` (project root or `https://` git URL); optional `top_k` (default 5) |
|
|
142
|
+
| `find_related` | Similar chunks to `file_path` + `line` from a prior hit; requires `repo` |
|
|
230
143
|
|
|
231
|
-
`.
|
|
144
|
+
Indexing runs on the first tool call per `repo`. Pass the **project root** for local workspaces. Remote repos need an explicit `https://` or `http://` URL (not `git@` SSH).
|
|
232
145
|
|
|
233
|
-
|
|
234
|
-
{
|
|
235
|
-
"servers": {
|
|
236
|
-
"miru": {
|
|
237
|
-
"type": "stdio",
|
|
238
|
-
"command": "bunx",
|
|
239
|
-
"args": ["@takara-ai/miru-code"],
|
|
240
|
-
"env": {
|
|
241
|
-
"TAKARA_API_KEY": "your-takara-bearer-token"
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
```
|
|
146
|
+
**IDE-specific notes**
|
|
247
147
|
|
|
248
|
-
|
|
148
|
+
- **Claude Code:** supports `${TAKARA_API_KEY}` in config; verify with `/mcp`. Or: `claude mcp add miru -s user -- bunx @takara-ai/miru-code`
|
|
149
|
+
- **VS Code:** uses `"servers"` not `mcpServers`; restart via **MCP: List Servers**
|
|
150
|
+
- **OpenCode:** uses `mcp`, `"type": "local"`, and `environment` instead of `env`
|
|
151
|
+
- **Kiro:** include `PATH` in `env` if Bun is not on the default path
|
|
249
152
|
|
|
250
|
-
|
|
153
|
+
Optional MCP startup flags: `--ref BRANCH`, `--content code docs …`
|
|
251
154
|
|
|
252
|
-
|
|
155
|
+
## How Miru works
|
|
253
156
|
|
|
254
|
-
###
|
|
157
|
+
### Hybrid search
|
|
255
158
|
|
|
256
|
-
|
|
159
|
+
1. **Dense (semantic)** — Takara code embeddings (`ds1-potion-code-16m`) over structurally chunked files
|
|
160
|
+
2. **Sparse (BM25)** — keyword index; parallelized in Bun workers when the index has 256+ chunks
|
|
161
|
+
3. **RRF fusion** — merges semantic and keyword rankings
|
|
162
|
+
4. **Reranking** — code-tuned boosts and penalties
|
|
257
163
|
|
|
258
|
-
|
|
259
|
-
"env": {
|
|
260
|
-
"TAKARA_API_KEY": "your-takara-bearer-token",
|
|
261
|
-
"PATH": "/usr/local/bin:/usr/bin:/bin"
|
|
262
|
-
}
|
|
263
|
-
```
|
|
164
|
+
Index **code**, **docs**, **config**, or **all** via `--content` (CLI/MCP) or when building a library index.
|
|
264
165
|
|
|
265
|
-
|
|
166
|
+
### Agent workflow
|
|
266
167
|
|
|
267
|
-
|
|
168
|
+
1. `search` with a natural-language or code query
|
|
169
|
+
2. Read returned chunks
|
|
170
|
+
3. `find_related` on a promising `file_path` + line (optional)
|
|
171
|
+
4. Open full files only when the chunk is not enough
|
|
172
|
+
5. Use grep for exhaustive literal matches
|
|
268
173
|
|
|
269
|
-
|
|
174
|
+
### Caching
|
|
270
175
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
"command": ["bunx", "@takara-ai/miru-code"],
|
|
278
|
-
"enabled": true,
|
|
279
|
-
"environment": {
|
|
280
|
-
"TAKARA_API_KEY": "your-takara-bearer-token"
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
```
|
|
176
|
+
| Layer | Behavior |
|
|
177
|
+
|-------|----------|
|
|
178
|
+
| **First search** | Builds index, writes disk cache |
|
|
179
|
+
| **MCP (local repo, same session)** | Watches files and incrementally re-indexes; disable with `MIRU_MCP_WATCH=0` |
|
|
180
|
+
| **CLI / new MCP session** | Reuses disk cache; run `miru clear <path>` after large refactors |
|
|
181
|
+
| **Remote repos** | Cloned per session; use `--ref` for branch/tag |
|
|
286
182
|
|
|
287
|
-
|
|
183
|
+
Cache: `~/Library/Caches/miru` (macOS), `~/.cache/miru` (Linux), `%LOCALAPPDATA%\miru\Cache` (Windows).
|
|
288
184
|
|
|
289
185
|
## CLI
|
|
290
186
|
|
|
291
|
-
Installed globally or via `bunx`:
|
|
292
|
-
|
|
293
187
|
```bash
|
|
294
188
|
miru setup
|
|
295
|
-
miru install
|
|
189
|
+
miru install
|
|
296
190
|
miru search "where are embeddings created" ./src -k 10 --content code
|
|
297
191
|
miru find-related src/embeddings/openai.ts 120 ./src
|
|
298
|
-
miru uninstall # remove miru config from agents
|
|
299
192
|
miru clear ./src
|
|
300
|
-
miru
|
|
301
|
-
miru
|
|
193
|
+
miru uninstall
|
|
194
|
+
miru help search
|
|
302
195
|
```
|
|
303
196
|
|
|
304
|
-
From **this repo** (development), prefix with `bun run miru` instead of `miru`.
|
|
305
|
-
|
|
306
197
|
| Command | Summary |
|
|
307
198
|
|---------|---------|
|
|
308
|
-
| `search <query> [path]` | Hybrid search;
|
|
309
|
-
| `find-related <file> <line> [path]` | Semantic neighbors
|
|
310
|
-
| `setup` | Store and validate `TAKARA_API_KEY`
|
|
311
|
-
| `install` | Interactive global agent setup
|
|
312
|
-
| `uninstall` | Remove miru configuration
|
|
313
|
-
| `init --agent <id>` |
|
|
314
|
-
| `clear [path]` | Delete disk cache
|
|
315
|
-
| *(no command)* | Start MCP server |
|
|
199
|
+
| `search <query> [path]` | Hybrid search; path defaults to cwd; local path or `https://` git URL |
|
|
200
|
+
| `find-related <file> <line> [path]` | Semantic neighbors at that line |
|
|
201
|
+
| `setup` | Store and validate `TAKARA_API_KEY` |
|
|
202
|
+
| `install` | Interactive global agent setup |
|
|
203
|
+
| `uninstall` | Remove miru agent configuration |
|
|
204
|
+
| `init --agent <id>` | Project-local sub-agent markdown |
|
|
205
|
+
| `clear [path]` | Delete disk cache |
|
|
206
|
+
| *(no command)* | Start stdio MCP server |
|
|
207
|
+
|
|
208
|
+
**Options:** `-k` / `--top-k N` (default 5), `--content code|docs|config|all`, `--json` (force JSON output).
|
|
316
209
|
|
|
317
|
-
**
|
|
210
|
+
**Output:** In a terminal, search results are formatted for reading (path, score, snippet preview). Piped output and `--json` emit JSON (`query` + `results` with `chunk`, `score`, `location`). Progress spinners go to stderr.
|
|
318
211
|
|
|
319
|
-
|
|
212
|
+
From **this repo**, prefix commands with `bun run miru`.
|
|
320
213
|
|
|
321
214
|
## Library
|
|
322
215
|
|
|
323
216
|
```ts
|
|
324
217
|
import { MiruIndex } from "@takara-ai/miru-code";
|
|
325
218
|
|
|
326
|
-
// Local directory
|
|
327
219
|
const index = await MiruIndex.fromPath("./src", ["code"]);
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
220
|
+
const fromUrl = await MiruIndex.fromSource(
|
|
221
|
+
"https://github.com/org/repo",
|
|
222
|
+
["code"],
|
|
223
|
+
undefined,
|
|
224
|
+
"main",
|
|
225
|
+
);
|
|
331
226
|
|
|
332
227
|
const results = await index.search({
|
|
333
228
|
query: "BM25 tokenize",
|
|
334
|
-
topK: 10,
|
|
229
|
+
topK: 10,
|
|
335
230
|
filterPaths: ["src/index/bm25.ts"],
|
|
336
|
-
rerank: true,
|
|
337
231
|
});
|
|
338
232
|
|
|
339
233
|
const related = await index.findRelated(results[0], 5);
|
|
@@ -350,26 +244,28 @@ Exports: `MiruIndex`, `clearCache`, `findIndexCachePath`, `resolveCacheFolder`,
|
|
|
350
244
|
| `MIRU_OPENAI_BASE_URL` | `https://infer.dev.takara.ai/v1` |
|
|
351
245
|
| `MIRU_OPENAI_EMBEDDING_MODEL` | `ds1-potion-code-16m` |
|
|
352
246
|
| `MIRU_EMBEDDING_DIMENSIONS` | `256` for potion (auto when unset) |
|
|
353
|
-
| `MIRU_FLOAT_VECTORS` | unset =
|
|
247
|
+
| `MIRU_FLOAT_VECTORS` | unset = int8; `1` = float32 |
|
|
354
248
|
| `MIRU_EMBEDDING_BATCH_SIZE` | `32` |
|
|
355
|
-
| `MIRU_CONCURRENCY` | logical CPUs
|
|
356
|
-
| `MIRU_MCP_WATCH` | on;
|
|
357
|
-
| `MIRU_CREDENTIALS_DIR` |
|
|
358
|
-
| `
|
|
359
|
-
| `MIRU_PIPELINE_EMBED_INFLIGHT` | optional pipeline tuning |
|
|
249
|
+
| `MIRU_CONCURRENCY` | logical CPUs minus 2 (min 1) |
|
|
250
|
+
| `MIRU_MCP_WATCH` | on; `0` or `false` disables MCP file watch |
|
|
251
|
+
| `MIRU_CREDENTIALS_DIR` | Override credentials directory |
|
|
252
|
+
| `NO_COLOR` | Disable CLI colors |
|
|
360
253
|
|
|
361
|
-
|
|
254
|
+
See `.env.example` for optional pipeline tuning (`MIRU_PIPELINE_*`).
|
|
362
255
|
|
|
363
256
|
## Developing Miru
|
|
364
257
|
|
|
365
258
|
```bash
|
|
259
|
+
git clone https://github.com/takara-ai/miru-code.git
|
|
260
|
+
cd miru-code
|
|
366
261
|
bun install
|
|
367
262
|
cp .env.example .env.local # add TAKARA_API_KEY
|
|
368
263
|
bun test
|
|
369
264
|
bun run typecheck
|
|
265
|
+
bun run lint
|
|
370
266
|
```
|
|
371
267
|
|
|
372
|
-
**Local MCP** — point at your
|
|
268
|
+
**Local MCP** — point at your clone:
|
|
373
269
|
|
|
374
270
|
```json
|
|
375
271
|
{
|
|
@@ -381,29 +277,15 @@ bun run typecheck
|
|
|
381
277
|
}
|
|
382
278
|
```
|
|
383
279
|
|
|
384
|
-
Merge into the IDE’s wrapper (`mcpServers`, `servers`, or `mcp`).
|
|
385
|
-
|
|
386
280
|
## Publishing
|
|
387
281
|
|
|
388
282
|
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).
|
|
389
283
|
|
|
390
|
-
**Local** (logged in to npm):
|
|
391
|
-
|
|
392
|
-
```bash
|
|
393
|
-
bun publish
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
Runs `prepublishOnly` (typecheck + tests). Do not add a `publish` script that calls `npm publish` — that would upload twice.
|
|
397
|
-
|
|
398
|
-
**CI** (Trusted Publisher on npm):
|
|
399
|
-
|
|
400
284
|
```bash
|
|
401
|
-
|
|
402
|
-
git push && git push --tags
|
|
403
|
-
gh release create v$(node -p "require('./package.json').version") --generate-notes
|
|
285
|
+
bun publish # local, logged in to npm
|
|
404
286
|
```
|
|
405
287
|
|
|
406
|
-
`release.yml` publishes
|
|
288
|
+
**CI:** tag a GitHub Release; `release.yml` publishes to npm via Trusted Publisher.
|
|
407
289
|
|
|
408
290
|
## License
|
|
409
291
|
|