@takara-ai/miru-code 0.4.5 → 0.4.9
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 +38 -15
- package/package.json +1 -1
- package/src/agents/claude.md +16 -28
- package/src/agents/copilot.md +9 -35
- package/src/agents/cursor.md +15 -28
- package/src/agents/gemini.md +10 -36
- package/src/agents/kiro.md +4 -37
- package/src/agents/opencode.md +4 -37
- package/src/cache.ts +1 -1
- package/src/cli.ts +10 -1
- package/src/env.ts +2 -1
- package/src/installer/agents.ts +146 -52
- package/src/installer/config.ts +0 -1
- package/src/installer/hooks/install.ts +463 -0
- package/src/installer/hooks/opencode-plugin.ts +68 -0
- package/src/installer/hooks/search-guard.ts +215 -0
- package/src/installer/installer.ts +56 -3
- package/src/installer/prompt.ts +218 -32
- package/src/installer/search-policy.ts +68 -0
- package/src/mcp/server.ts +8 -9
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ miru setup --key YOUR_TOKEN # non-interactive
|
|
|
25
25
|
miru setup --clear # remove stored key
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
MCP loads your key from `credentials.json` automatically
|
|
28
|
+
MCP loads your key from `credentials.json` automatically — no env block needed in MCP config.
|
|
29
29
|
|
|
30
30
|
## Add to your IDE
|
|
31
31
|
|
|
@@ -33,23 +33,44 @@ MCP loads your key from `credentials.json` automatically. Set `TAKARA_API_KEY` i
|
|
|
33
33
|
miru install
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
Interactive —
|
|
36
|
+
Interactive TUI — **↑↓** move, **space** toggle, **a** all, **enter** confirm. Pick agents and integrations:
|
|
37
|
+
|
|
38
|
+
| Integration | What it does |
|
|
39
|
+
|-------------|----------------|
|
|
40
|
+
| MCP server | `search` and `find_related` tools in the agent |
|
|
41
|
+
| Instructions | Search policy in `CLAUDE.md` / `AGENTS.md` / `GEMINI.md` |
|
|
42
|
+
| Sub-agent | Dedicated `miru-code` agent file |
|
|
43
|
+
| Cursor rules | Always-on `.cursor/rules/miru-code.mdc` (Cursor only) |
|
|
44
|
+
| Search hooks | Block built-in Grep/Glob and redirect to Miru MCP |
|
|
45
|
+
|
|
46
|
+
Restart the IDE when done.
|
|
37
47
|
|
|
38
48
|
```bash
|
|
39
49
|
miru uninstall # remove miru config
|
|
40
50
|
```
|
|
41
51
|
|
|
42
|
-
**Supported:** Cursor · Claude Code · Gemini CLI · Kiro · OpenCode · GitHub Copilot · Codex · VS Code
|
|
52
|
+
**Supported:** Cursor · Claude Code · Gemini CLI · Kiro · OpenCode · GitHub Copilot · Codex · VS Code · Visual Studio (Windows) · Windsurf / Devin Desktop
|
|
53
|
+
|
|
54
|
+
| IDE | MCP | Instructions / rules | Hooks |
|
|
55
|
+
|-----|-----|------------------------|-------|
|
|
56
|
+
| Cursor | `~/.cursor/mcp.json` | `~/.cursor/rules/miru-code.mdc` | `~/.cursor/hooks.json` |
|
|
57
|
+
| Claude Code | `~/.claude.json` | `~/.claude/CLAUDE.md` | `~/.claude/settings.json` |
|
|
58
|
+
| Gemini CLI | `~/.gemini/settings.json` | `~/.gemini/GEMINI.md` | `~/.gemini/settings.json` (`BeforeTool`) |
|
|
59
|
+
| Kiro | `~/.kiro/settings/mcp.json` | `~/.kiro/steering/miru.md` | `~/.kiro/settings/hooks.json` |
|
|
60
|
+
| OpenCode | `~/.config/opencode/opencode.json(c)` | `~/.config/opencode/AGENTS.md` | `~/.config/opencode/plugins/miru-search-guard.ts` |
|
|
61
|
+
| GitHub Copilot | `~/.copilot/mcp-config.json` | — | `~/.copilot/hooks/miru-search.json` |
|
|
62
|
+
| Codex | `~/.codex/config.toml` | `~/.codex/AGENTS.md` | `~/.codex/hooks.json` |
|
|
63
|
+
| VS Code | `…/Code/User/mcp.json` | — | `~/.copilot/hooks/miru-search.json` |
|
|
64
|
+
| Visual Studio | `%USERPROFILE%\.mcp.json` | — | `~/.copilot/hooks/miru-search.json` |
|
|
65
|
+
| Windsurf | — | — | `~/.codeium/windsurf/hooks.json` |
|
|
66
|
+
|
|
67
|
+
Sub-agent files are also written where supported (see `miru install` plan). Windsurf hooks only — no MCP entry yet.
|
|
43
68
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
| Kiro | `~/.kiro/settings/mcp.json` + `~/.kiro/agents/miru-code.md` |
|
|
50
|
-
| OpenCode | `~/.config/opencode/opencode.json(c)` + agents dir |
|
|
51
|
-
| GitHub Copilot | `~/.copilot/mcp-config.json` + `~/.copilot/agents/miru-code.agent.md` |
|
|
52
|
-
| Codex / VS Code | MCP config only |
|
|
69
|
+
### Search hooks
|
|
70
|
+
|
|
71
|
+
Hooks run `miru hook-guard` before built-in search tools execute. They **block** conceptual Grep/Glob/SemanticSearch and shell `rg`/`grep`/`find`, and tell the agent to use Miru MCP `search` instead. Exact literal lookups (e.g. `REDIS_HOST`, a symbol name) still pass through.
|
|
72
|
+
|
|
73
|
+
Hooks are optional at install time but **on by default**. Disable them in the installer if you only want MCP + instructions.
|
|
53
74
|
|
|
54
75
|
**Team sub-agent in a repo** (optional):
|
|
55
76
|
|
|
@@ -81,7 +102,7 @@ When wired via `miru install`, your agent gets:
|
|
|
81
102
|
| `search` | Query by meaning; pass `repo` (project root or `https://` git URL) |
|
|
82
103
|
| `find_related` | Similar code at a `file_path` + line from a search hit |
|
|
83
104
|
|
|
84
|
-
Pass the **project root** as `repo` for local projects.
|
|
105
|
+
Pass the **project root** as `repo` for local projects. Prefer these over Grep, Glob, or SemanticSearch when Miru MCP is connected — hooks and instructions enforce that when enabled.
|
|
85
106
|
|
|
86
107
|
## How it works
|
|
87
108
|
|
|
@@ -100,6 +121,7 @@ Disk cache: `~/Library/Caches/miru` (macOS), `~/.cache/miru` (Linux). MCP watche
|
|
|
100
121
|
| `miru find-related <file> <line> [path]` | Related chunks |
|
|
101
122
|
| `miru init --agent <id>` | Project-local sub-agent |
|
|
102
123
|
| `miru clear [path]` | Drop index cache |
|
|
124
|
+
| `miru hook-guard` | PreToolUse hook entrypoint (used by installers; reads JSON stdin) |
|
|
103
125
|
| `miru` | Start MCP server |
|
|
104
126
|
|
|
105
127
|
## Library
|
|
@@ -132,12 +154,13 @@ See `.env.example` for more.
|
|
|
132
154
|
{
|
|
133
155
|
"miru": {
|
|
134
156
|
"command": "miru",
|
|
135
|
-
"args": []
|
|
136
|
-
"env": { "TAKARA_API_KEY": "your-token" }
|
|
157
|
+
"args": []
|
|
137
158
|
}
|
|
138
159
|
}
|
|
139
160
|
```
|
|
140
161
|
|
|
162
|
+
Run `miru setup` once so the server can load your key from `credentials.json`.
|
|
163
|
+
|
|
141
164
|
Use `bunx` + `@takara-ai/miru-code` if `miru` is not global. Wrapper key varies by IDE (`mcpServers`, `servers`, or `mcp`).
|
|
142
165
|
|
|
143
166
|
## Developing
|
package/package.json
CHANGED
package/src/agents/claude.md
CHANGED
|
@@ -1,41 +1,29 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: miru-code
|
|
3
|
-
description: Code search
|
|
3
|
+
description: Code search via Miru MCP. Use search and find_related for any question about how code works. DO NOT use Grep, Glob, or Read for exploration when Miru MCP is available.
|
|
4
4
|
tools: Bash, Read
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
When Miru MCP is available, use MCP `search` and `find_related` — not Grep, Glob, or Read-for-exploration.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
| Task | Tool |
|
|
10
|
+
|------|------|
|
|
11
|
+
| How/where/what handles X? | Miru `search` |
|
|
12
|
+
| Similar implementations | Miru `find_related` |
|
|
13
|
+
| Exact literal confirmation | Grep |
|
|
14
|
+
| Edit a located file | Read |
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
### MCP workflow
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
miru search "deployment guide" ./my-project --content docs
|
|
21
|
-
miru search "database host port" ./my-project --content config
|
|
22
|
-
miru search "authentication" ./my-project --content all
|
|
23
|
-
```
|
|
18
|
+
1. Call `search` with `repo` set to the project root.
|
|
19
|
+
2. Use `find_related` with a hit's `file_path` and `line`.
|
|
20
|
+
3. Read files only to edit or when chunks lack context.
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
### CLI fallback
|
|
26
23
|
|
|
27
24
|
```bash
|
|
28
|
-
miru
|
|
25
|
+
miru search "authentication flow" .
|
|
26
|
+
miru find-related src/auth.ts 42 .
|
|
29
27
|
```
|
|
30
28
|
|
|
31
|
-
`
|
|
32
|
-
|
|
33
|
-
If `miru` is not on `$PATH`, use `bunx miru` in its place.
|
|
34
|
-
|
|
35
|
-
### Workflow
|
|
36
|
-
|
|
37
|
-
1. Start with `miru search` to find relevant chunks. The index is built and cached automatically.
|
|
38
|
-
2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything.
|
|
39
|
-
3. Inspect full files only when the returned chunk does not give enough context.
|
|
40
|
-
4. Optionally use `miru find-related` with a promising result's `file_path` and `line` to discover related implementations.
|
|
41
|
-
5. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string.
|
|
29
|
+
If `miru` is not on `$PATH`, use `bunx @takara-ai/miru-code`.
|
package/src/agents/copilot.md
CHANGED
|
@@ -1,41 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: miru-code
|
|
3
|
-
description: Code search
|
|
4
|
-
tools: Bash, Read
|
|
3
|
+
description: Code search via Miru MCP. Use search and find_related instead of grep_search or codebase_search when Miru is connected.
|
|
5
4
|
---
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
When Miru MCP is available, use `search` and `find_related` instead of `grep_search`, `codebase_search`, or broad file reads.
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
| Task | Tool |
|
|
9
|
+
|------|------|
|
|
10
|
+
| How/where/what handles X? | Miru `search` |
|
|
11
|
+
| Similar implementations | Miru `find_related` |
|
|
12
|
+
| Exact literal confirmation | grep_search |
|
|
13
|
+
| Edit a located file | read_file |
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
```bash
|
|
20
|
-
miru search "deployment guide" ./my-project --content docs
|
|
21
|
-
miru search "database host port" ./my-project --content config
|
|
22
|
-
miru search "authentication" ./my-project --content all
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Use `miru find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result):
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
miru find-related src/auth.py 42 ./my-project
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
`path` defaults to the current directory when omitted; git URLs are accepted.
|
|
32
|
-
|
|
33
|
-
If `miru` is not on `$PATH`, use `bunx miru` in its place.
|
|
34
|
-
|
|
35
|
-
### Workflow
|
|
36
|
-
|
|
37
|
-
1. Start with `miru search` to find relevant chunks. The index is built and cached automatically.
|
|
38
|
-
2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything.
|
|
39
|
-
3. Inspect full files only when the returned chunk does not give enough context.
|
|
40
|
-
4. Optionally use `miru find-related` with a promising result's `file_path` and `line` to discover related implementations.
|
|
41
|
-
5. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string.
|
|
15
|
+
Pass project root as `repo` on every MCP call.
|
package/src/agents/cursor.md
CHANGED
|
@@ -1,40 +1,27 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: miru-code
|
|
3
|
-
description: Code search
|
|
3
|
+
description: Code search via Miru MCP. Use search and find_related for any question about how code works. DO NOT use Grep, Glob, or SemanticSearch when Miru MCP is available.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Use
|
|
6
|
+
Use Miru MCP tools when connected:
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
miru search "save_pretrained" ./my-project
|
|
11
|
-
miru search "save model to disk" ./my-project --top-k 10
|
|
12
|
-
```
|
|
8
|
+
- `search` — natural-language or code query; always pass project root as `repo`
|
|
9
|
+
- `find_related` — similar chunks after a search hit (`file_path` + `line`)
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
Do not use Grep, Glob, SemanticSearch, or Read to explore the codebase when Miru MCP is available.
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
```
|
|
13
|
+
| Task | Tool |
|
|
14
|
+
|------|------|
|
|
15
|
+
| How/where/what handles X? | Miru `search` |
|
|
16
|
+
| Similar implementations | Miru `find_related` |
|
|
17
|
+
| Exact literal confirmation | Grep |
|
|
18
|
+
| Edit a located file | Read |
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
CLI fallback when MCP is unavailable:
|
|
25
21
|
|
|
26
22
|
```bash
|
|
27
|
-
miru
|
|
23
|
+
miru search "authentication flow" .
|
|
24
|
+
miru find-related src/auth.ts 42 .
|
|
28
25
|
```
|
|
29
26
|
|
|
30
|
-
`
|
|
31
|
-
|
|
32
|
-
If `miru` is not on `$PATH`, use `bunx miru` in its place.
|
|
33
|
-
|
|
34
|
-
### Workflow
|
|
35
|
-
|
|
36
|
-
1. Start with `miru search` to find relevant chunks. The index is built and cached automatically.
|
|
37
|
-
2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything.
|
|
38
|
-
3. Inspect full files only when the returned chunk does not give enough context.
|
|
39
|
-
4. Optionally use `miru find-related` with a promising result's `file_path` and `line` to discover related implementations.
|
|
40
|
-
5. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string.
|
|
27
|
+
If `miru` is not on `$PATH`, use `bunx @takara-ai/miru-code`.
|
package/src/agents/gemini.md
CHANGED
|
@@ -1,43 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: miru-code
|
|
3
|
-
description: Code search
|
|
4
|
-
tools:
|
|
5
|
-
- run_shell_command
|
|
6
|
-
- read_file
|
|
3
|
+
description: Code search via Miru MCP. Use search and find_related instead of grep_search or read_file for exploration.
|
|
7
4
|
---
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
When Miru MCP is available, use `search` and `find_related` instead of `grep_search`, `glob`, or `read_file` for codebase exploration.
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
| Task | Tool |
|
|
9
|
+
|------|------|
|
|
10
|
+
| How/where/what handles X? | Miru `search` |
|
|
11
|
+
| Similar implementations | Miru `find_related` |
|
|
12
|
+
| Exact literal confirmation | grep_search |
|
|
13
|
+
| Edit a located file | read_file |
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
Pass project root as `repo` on every MCP call.
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
miru search "deployment guide" ./my-project --content docs
|
|
23
|
-
miru search "database host port" ./my-project --content config
|
|
24
|
-
miru search "authentication" ./my-project --content all
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Use `miru find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result):
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
miru find-related src/auth.py 42 ./my-project
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
`path` defaults to the current directory when omitted; git URLs are accepted.
|
|
34
|
-
|
|
35
|
-
If `miru` is not on `$PATH`, use `bunx miru` in its place.
|
|
36
|
-
|
|
37
|
-
### Workflow
|
|
38
|
-
|
|
39
|
-
1. Start with `miru search` to find relevant chunks. The index is built and cached automatically.
|
|
40
|
-
2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything.
|
|
41
|
-
3. Inspect full files only when the returned chunk does not give enough context.
|
|
42
|
-
4. Optionally use `miru find-related` with a promising result's `file_path` and `line` to discover related implementations.
|
|
43
|
-
5. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string.
|
|
17
|
+
CLI fallback: `miru search "query" .` or `bunx @takara-ai/miru-code search "query" .`
|
package/src/agents/kiro.md
CHANGED
|
@@ -1,43 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: miru-code
|
|
3
|
-
description: Code search
|
|
4
|
-
tools:
|
|
5
|
-
- shell
|
|
6
|
-
- read
|
|
3
|
+
description: Code search via Miru MCP. Use search and find_related for codebase exploration instead of built-in grep or file search.
|
|
7
4
|
---
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
When Miru MCP is available, use `search` and `find_related` before any built-in search or broad file reads.
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
miru search "authentication flow" ./my-project
|
|
13
|
-
miru search "save_pretrained" ./my-project
|
|
14
|
-
miru search "save model to disk" ./my-project --top-k 10
|
|
15
|
-
```
|
|
8
|
+
Pass project root as `repo`. Use Grep only for exact literal confirmation.
|
|
16
9
|
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
21
|
-
```bash
|
|
22
|
-
miru search "deployment guide" ./my-project --content docs
|
|
23
|
-
miru search "database host port" ./my-project --content config
|
|
24
|
-
miru search "authentication" ./my-project --content all
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Use `miru find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result):
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
miru find-related src/auth.py 42 ./my-project
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
`path` defaults to the current directory when omitted; git URLs are accepted.
|
|
34
|
-
|
|
35
|
-
If `miru` is not on `$PATH`, use `bunx miru` in its place.
|
|
36
|
-
|
|
37
|
-
### Workflow
|
|
38
|
-
|
|
39
|
-
1. Start with `miru search` to find relevant chunks. The index is built and cached automatically.
|
|
40
|
-
2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything.
|
|
41
|
-
3. Inspect full files only when the returned chunk does not give enough context.
|
|
42
|
-
4. Optionally use `miru find-related` with a promising result's `file_path` and `line` to discover related implementations.
|
|
43
|
-
5. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string.
|
|
10
|
+
CLI fallback: `miru search "query" .`
|
package/src/agents/opencode.md
CHANGED
|
@@ -1,44 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: miru-code
|
|
3
|
-
description: Code search
|
|
3
|
+
description: Code search via Miru MCP. Use search and find_related instead of grep or glob for exploration.
|
|
4
4
|
mode: subagent
|
|
5
|
-
permission:
|
|
6
|
-
bash: allow
|
|
7
|
-
read: allow
|
|
8
5
|
---
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
When Miru MCP is available, use `search` and `find_related` instead of grep, glob, or read-for-exploration.
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
miru search "authentication flow" ./my-project
|
|
14
|
-
miru search "save_pretrained" ./my-project
|
|
15
|
-
miru search "save model to disk" ./my-project --top-k 10
|
|
16
|
-
```
|
|
9
|
+
Pass project root as `repo` on every MCP call.
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
```bash
|
|
23
|
-
miru search "deployment guide" ./my-project --content docs
|
|
24
|
-
miru search "database host port" ./my-project --content config
|
|
25
|
-
miru search "authentication" ./my-project --content all
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Use `miru find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result):
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
miru find-related src/auth.py 42 ./my-project
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
`path` defaults to the current directory when omitted; git URLs are accepted.
|
|
35
|
-
|
|
36
|
-
If `miru` is not on `$PATH`, use `bunx miru` in its place.
|
|
37
|
-
|
|
38
|
-
### Workflow
|
|
39
|
-
|
|
40
|
-
1. Start with `miru search` to find relevant chunks. The index is built and cached automatically.
|
|
41
|
-
2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything.
|
|
42
|
-
3. Inspect full files only when the returned chunk does not give enough context.
|
|
43
|
-
4. Optionally use `miru find-related` with a promising result's `file_path` and `line` to discover related implementations.
|
|
44
|
-
5. Use grep only when you need exhaustive literal matches or quick confirmation of an exact string.
|
|
11
|
+
CLI fallback: `miru search "query" .`
|
package/src/cache.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { rm } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { computeSourceCacheKey } from "./utils.ts";
|
|
5
4
|
import { resolveEmbeddingDimensions, resolveEmbeddingModel } from "./embeddings/openai.ts";
|
|
6
5
|
import {
|
|
7
6
|
loadBm25,
|
|
@@ -13,6 +12,7 @@ import {
|
|
|
13
12
|
import { resolveSemanticStorage, semanticStorageFromMetadata } from "./index/vector-storage.ts";
|
|
14
13
|
import type { Chunk, ContentType } from "./types.ts";
|
|
15
14
|
import { chunkFromDict } from "./types.ts";
|
|
15
|
+
import { computeSourceCacheKey } from "./utils.ts";
|
|
16
16
|
|
|
17
17
|
export function resolveCacheFolder(): string {
|
|
18
18
|
const name = "miru";
|
package/src/cli.ts
CHANGED
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
success,
|
|
12
12
|
} from "./cli-ui.ts";
|
|
13
13
|
import { loadStoredCredentials } from "./credentials.ts";
|
|
14
|
-
import { loadEnvFiles } from "./env-files.ts";
|
|
15
14
|
import { normalizeTakaraApiKeyEnv } from "./env.ts";
|
|
15
|
+
import { loadEnvFiles } from "./env-files.ts";
|
|
16
16
|
import {
|
|
17
17
|
AGENT_IDS,
|
|
18
18
|
formatUnknownAgent,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
printFullHelp,
|
|
21
21
|
printMainHelp,
|
|
22
22
|
} from "./help.ts";
|
|
23
|
+
import { runSearchGuardFromStdin } from "./installer/hooks/search-guard.ts";
|
|
23
24
|
import { runInstaller } from "./installer/installer.ts";
|
|
24
25
|
import { serveMcp } from "./mcp/serve.ts";
|
|
25
26
|
import { MiruIndex } from "./miru-index.ts";
|
|
@@ -40,6 +41,7 @@ const CLI_COMMANDS = new Set([
|
|
|
40
41
|
"uninstall",
|
|
41
42
|
"setup",
|
|
42
43
|
"clear",
|
|
44
|
+
"hook-guard",
|
|
43
45
|
"help",
|
|
44
46
|
"-h",
|
|
45
47
|
"--help",
|
|
@@ -220,6 +222,10 @@ async function runCli(argv: string[]): Promise<void> {
|
|
|
220
222
|
return;
|
|
221
223
|
}
|
|
222
224
|
|
|
225
|
+
if (command === "hook-guard") {
|
|
226
|
+
process.exit(await runSearchGuardFromStdin());
|
|
227
|
+
}
|
|
228
|
+
|
|
223
229
|
if (command === "install" || command === "uninstall") {
|
|
224
230
|
await runInstaller(command);
|
|
225
231
|
return;
|
|
@@ -366,6 +372,9 @@ async function runMcpWithCredentials(argv: string[]): Promise<void> {
|
|
|
366
372
|
async function main(): Promise<void> {
|
|
367
373
|
const argv = process.argv.slice(2);
|
|
368
374
|
const first = argv[0];
|
|
375
|
+
if (first === "hook-guard") {
|
|
376
|
+
process.exit(await runSearchGuardFromStdin());
|
|
377
|
+
}
|
|
369
378
|
if (first && CLI_COMMANDS.has(first)) {
|
|
370
379
|
await runCli(argv);
|
|
371
380
|
return;
|
package/src/env.ts
CHANGED
|
@@ -33,7 +33,8 @@ export function envOptionalInt(names: string[], min = 1): number | undefined {
|
|
|
33
33
|
|
|
34
34
|
export const TAKARA_API_KEY_ENV = "TAKARA_API_KEY";
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const MCP_KEY_PLACEHOLDER = "$" + "{TAKARA_API_KEY}";
|
|
37
|
+
const TAKARA_API_KEY_PLACEHOLDERS = new Set([MCP_KEY_PLACEHOLDER, "$TAKARA_API_KEY"]);
|
|
37
38
|
|
|
38
39
|
/** True when the value is a real key, not empty or an unexpanded MCP env placeholder. */
|
|
39
40
|
export function isUsableTakaraApiKey(value: string | undefined): boolean {
|