@takara-ai/miru-code 0.4.2 → 0.4.4
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 +2 -2
- package/package.json +1 -1
- package/src/cli.ts +2 -0
- package/src/credentials.ts +2 -1
- package/src/embeddings/openai.ts +1 -1
- package/src/env.ts +20 -2
- package/src/help.ts +1 -1
- package/src/installer/agents.ts +1 -1
- package/src/installer/installer.ts +1 -1
- package/src/setup.ts +1 -1
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
|
-
|
|
28
|
+
MCP loads your key from `credentials.json` automatically. Set `TAKARA_API_KEY` in MCP config only to override.
|
|
29
29
|
|
|
30
30
|
## Add to your IDE
|
|
31
31
|
|
|
@@ -120,7 +120,7 @@ const results = await index.search({ query: "BM25 tokenize", topK: 10 });
|
|
|
120
120
|
| Variable | Notes |
|
|
121
121
|
|----------|-------|
|
|
122
122
|
| `TAKARA_API_KEY` | Required |
|
|
123
|
-
| `MIRU_OPENAI_BASE_URL` | Default `https://infer.
|
|
123
|
+
| `MIRU_OPENAI_BASE_URL` | Default `https://infer.takara.ai/v1` |
|
|
124
124
|
| `MIRU_MCP_WATCH` | Set `0` to disable MCP file watch |
|
|
125
125
|
| `NO_COLOR` | Disable CLI colors |
|
|
126
126
|
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "./cli-ui.ts";
|
|
14
14
|
import { loadStoredCredentials } from "./credentials.ts";
|
|
15
15
|
import { loadEnvFiles } from "./env-files.ts";
|
|
16
|
+
import { normalizeTakaraApiKeyEnv } from "./env.ts";
|
|
16
17
|
import {
|
|
17
18
|
AGENT_IDS,
|
|
18
19
|
formatUnknownAgent,
|
|
@@ -29,6 +30,7 @@ import type { ContentType, SearchResult } from "./types.ts";
|
|
|
29
30
|
import { formatResults, resolveChunk, resolveContent } from "./utils.ts";
|
|
30
31
|
|
|
31
32
|
loadEnvFiles();
|
|
33
|
+
normalizeTakaraApiKeyEnv();
|
|
32
34
|
await loadStoredCredentials();
|
|
33
35
|
|
|
34
36
|
const CLI_COMMANDS = new Set([
|
package/src/credentials.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { hasTakaraApiKeyInEnv } from "./env.ts";
|
|
3
|
+
import { hasTakaraApiKeyInEnv, normalizeTakaraApiKeyEnv } from "./env.ts";
|
|
4
4
|
|
|
5
5
|
const CREDENTIALS_FILENAME = "credentials.json";
|
|
6
6
|
const CREDENTIALS_VERSION = 1;
|
|
@@ -49,6 +49,7 @@ export async function readStoredCredentials(): Promise<StoredCredentials | null>
|
|
|
49
49
|
|
|
50
50
|
/** Set TAKARA_API_KEY from the user credentials file when env is unset. */
|
|
51
51
|
export async function loadStoredCredentials(): Promise<boolean> {
|
|
52
|
+
normalizeTakaraApiKeyEnv();
|
|
52
53
|
if (hasTakaraApiKeyInEnv()) {
|
|
53
54
|
return false;
|
|
54
55
|
}
|
package/src/embeddings/openai.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { mapPool, resolveWorkerConcurrency } from "../concurrency.ts";
|
|
|
2
2
|
import { envFirstString, envOptionalInt, resolveEmbeddingApiKey } from "../env.ts";
|
|
3
3
|
|
|
4
4
|
const DEFAULT_MODEL = "ds1-potion-code-16m";
|
|
5
|
-
const DEFAULT_BASE_URL = "https://infer.
|
|
5
|
+
const DEFAULT_BASE_URL = "https://infer.takara.ai/v1";
|
|
6
6
|
const DEFAULT_BATCH_SIZE = 32;
|
|
7
7
|
const DEFAULT_MAX_EMBED_CHARS = 1300;
|
|
8
8
|
const WINDOW_OVERLAP_CHARS = 120;
|
package/src/env.ts
CHANGED
|
@@ -33,13 +33,31 @@ 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 TAKARA_API_KEY_PLACEHOLDERS = new Set(["${TAKARA_API_KEY}", "$TAKARA_API_KEY"]);
|
|
37
|
+
|
|
38
|
+
/** True when the value is a real key, not empty or an unexpanded MCP env placeholder. */
|
|
39
|
+
export function isUsableTakaraApiKey(value: string | undefined): boolean {
|
|
40
|
+
const key = value?.trim() ?? "";
|
|
41
|
+
if (!key) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return !TAKARA_API_KEY_PLACEHOLDERS.has(key);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Drop placeholder values so credentials.json can supply the key for MCP. */
|
|
48
|
+
export function normalizeTakaraApiKeyEnv(): void {
|
|
49
|
+
if (!isUsableTakaraApiKey(process.env[TAKARA_API_KEY_ENV])) {
|
|
50
|
+
delete process.env[TAKARA_API_KEY_ENV];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
36
54
|
export function hasTakaraApiKeyInEnv(): boolean {
|
|
37
|
-
return
|
|
55
|
+
return isUsableTakaraApiKey(process.env[TAKARA_API_KEY_ENV]);
|
|
38
56
|
}
|
|
39
57
|
|
|
40
58
|
export function resolveEmbeddingApiKey(): string {
|
|
41
59
|
const key = process.env[TAKARA_API_KEY_ENV]?.trim() ?? "";
|
|
42
|
-
if (!key) {
|
|
60
|
+
if (!isUsableTakaraApiKey(key)) {
|
|
43
61
|
throw new Error(
|
|
44
62
|
"Takara API key required. Run `miru setup`, or set TAKARA_API_KEY in your MCP server env or .env.local.",
|
|
45
63
|
);
|
package/src/help.ts
CHANGED
|
@@ -53,7 +53,7 @@ export function printEnvHelp(): void {
|
|
|
53
53
|
writeStdout(" TAKARA_API_KEY");
|
|
54
54
|
writeStdout(" Takara bearer token for embeddings");
|
|
55
55
|
writeStdout(" MIRU_OPENAI_BASE_URL");
|
|
56
|
-
writeStdout(" Default: https://infer.
|
|
56
|
+
writeStdout(" Default: https://infer.takara.ai/v1");
|
|
57
57
|
writeStdout(" MIRU_CONCURRENCY");
|
|
58
58
|
writeStdout(" Parallel workers (default: CPUs − 2)");
|
|
59
59
|
writeStdout("");
|
package/src/installer/agents.ts
CHANGED
|
@@ -54,7 +54,7 @@ A \`miru\` MCP server is available with two tools:
|
|
|
54
54
|
|
|
55
55
|
Always call \`search\` before using Grep, Glob, or Read to explore the codebase. Use Grep/Glob/Read only for exact path lookup, exhaustive literal matches, or when the returned chunk lacks enough context.
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
Run \`miru setup\` once to store your API key — the MCP server loads it from \`credentials.json\`. Optionally set \`TAKARA_API_KEY\` in MCP config to override.
|
|
58
58
|
|
|
59
59
|
Pass \`--content docs\` to search documentation, \`--content config\` for config files, or \`--content all\` for everything.
|
|
60
60
|
|
|
@@ -246,7 +246,7 @@ export async function runInstaller(mode: InstallMode): Promise<void> {
|
|
|
246
246
|
install ? "Done! Restart your agents to pick up changes." : "Done! Configuration removed.",
|
|
247
247
|
);
|
|
248
248
|
if (install) {
|
|
249
|
-
hint("Run miru setup
|
|
249
|
+
hint("Run miru setup — MCP loads the key from credentials.json automatically.");
|
|
250
250
|
}
|
|
251
251
|
writeStdout("");
|
|
252
252
|
}
|
package/src/setup.ts
CHANGED
|
@@ -73,7 +73,7 @@ export async function runSetup(options: RunSetupOptions = {}): Promise<string> {
|
|
|
73
73
|
process.env.TAKARA_API_KEY = apiKey;
|
|
74
74
|
writeStderr("");
|
|
75
75
|
success(`Saved credentials to ${path}`);
|
|
76
|
-
hint("
|
|
76
|
+
hint("MCP loads this key from credentials.json automatically.");
|
|
77
77
|
writeStderr("");
|
|
78
78
|
return path;
|
|
79
79
|
}
|