yats-toolkit 0.3.0 → 0.3.2
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/bin/setup.js +3 -0
- package/package.json +1 -1
- package/src/benchmark.js +62 -25
- package/src/reindex.js +40 -0
- package/src/setup.js +70 -28
package/bin/setup.js
CHANGED
|
@@ -50,6 +50,9 @@ switch (cmd) {
|
|
|
50
50
|
import("../src/indexer.js").then(m => m.default(cleanArgs, { skipDocs }));
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
|
+
case "reindex":
|
|
54
|
+
import("../src/reindex.js").then(m => m.default(args));
|
|
55
|
+
break;
|
|
53
56
|
case "search":
|
|
54
57
|
import("../src/search.js").then(m => m.default(args));
|
|
55
58
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yats-toolkit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "YATS — Yet Another Token Saver. One-command MCP server that indexes your codebase into a knowledge graph so AI agents (Claude, Cursor, Copilot) can search and navigate it without burning tokens.",
|
|
5
5
|
"author": "Franco Vinciarelli <vinciarellifranco@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
package/src/benchmark.js
CHANGED
|
@@ -263,9 +263,11 @@ function loadEnvFile(filePath) {
|
|
|
263
263
|
|
|
264
264
|
function loadEnv() {
|
|
265
265
|
const candidates = [];
|
|
266
|
+
// Canonical: ~/.yats/.env (setup writes embedding + benchmark keys there)
|
|
267
|
+
candidates.push(path.join(process.env.HOME ?? "/tmp", ".yats", ".env"));
|
|
266
268
|
candidates.push(path.join(process.cwd(), ".env"));
|
|
267
269
|
|
|
268
|
-
// walk up from this module (src/) to find a repo-root .env
|
|
270
|
+
// walk up from this module (src/) to find a repo-root .env (legacy fallback)
|
|
269
271
|
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
270
272
|
for (let i = 0; i < 6; i++) {
|
|
271
273
|
const p = path.join(dir, ".env");
|
|
@@ -275,16 +277,19 @@ function loadEnv() {
|
|
|
275
277
|
dir = parent;
|
|
276
278
|
}
|
|
277
279
|
|
|
280
|
+
// Load ALL candidates so keys accumulate (first one wins per key).
|
|
281
|
+
let loaded = null;
|
|
278
282
|
for (const c of candidates) {
|
|
279
|
-
if (loadEnvFile(c) > 0)
|
|
283
|
+
if (loadEnvFile(c) > 0 && !loaded) loaded = c;
|
|
280
284
|
}
|
|
281
|
-
return
|
|
285
|
+
return loaded;
|
|
282
286
|
}
|
|
283
287
|
|
|
284
288
|
const LOADED_ENV = loadEnv();
|
|
285
289
|
if (LOADED_ENV) logger.info(`Loaded ${LOADED_ENV}`);
|
|
286
290
|
|
|
287
291
|
let selectedModel = null;
|
|
292
|
+
let copilotConsent = false;
|
|
288
293
|
let workDir = path.join(process.cwd(), "repos");
|
|
289
294
|
|
|
290
295
|
// ============================================================
|
|
@@ -384,7 +389,7 @@ const KNOWN_AGENTS = [
|
|
|
384
389
|
{ name: "sonnet", hint: "balanced" },
|
|
385
390
|
{ name: "opus", hint: "most powerful" },
|
|
386
391
|
],
|
|
387
|
-
authLabel: "ANTHROPIC_API_KEY
|
|
392
|
+
authLabel: "ANTHROPIC_API_KEY (in ~/.yats/.env)",
|
|
388
393
|
needsSkill: true,
|
|
389
394
|
mcpKind: "stdio",
|
|
390
395
|
runCmd: (prompt, repoDir, hasMcp, model) => [
|
|
@@ -401,14 +406,14 @@ const KNOWN_AGENTS = [
|
|
|
401
406
|
cli: "codex",
|
|
402
407
|
checkCmd: "which codex",
|
|
403
408
|
installHint: "npm install -g @openai/codex",
|
|
404
|
-
needsApiKey: "",
|
|
409
|
+
needsApiKey: "OPENAI_API_KEY",
|
|
405
410
|
defaultModel: "gpt-4.1-mini",
|
|
406
411
|
models: [
|
|
407
412
|
{ name: "gpt-4.1-mini", hint: "fastest & cheapest" },
|
|
408
413
|
{ name: "gpt-4.1", hint: "balanced" },
|
|
409
414
|
{ name: "gpt-5.4", hint: "most powerful" },
|
|
410
415
|
],
|
|
411
|
-
authLabel: "
|
|
416
|
+
authLabel: "OPENAI_API_KEY (in ~/.yats/.env)",
|
|
412
417
|
needsSkill: false,
|
|
413
418
|
mcpKind: "codex-config",
|
|
414
419
|
runCmd: (prompt, repoDir, hasMcp, model) => ["exec", "--json", "--skip-git-repo-check", "--dangerously-bypass-approvals-and-sandbox", prompt],
|
|
@@ -423,7 +428,7 @@ const KNOWN_AGENTS = [
|
|
|
423
428
|
models: [
|
|
424
429
|
{ name: "default", hint: "Copilot-managed model" },
|
|
425
430
|
],
|
|
426
|
-
authLabel: "copilot
|
|
431
|
+
authLabel: "copilot auth (consent asked at start)",
|
|
427
432
|
needsSkill: false,
|
|
428
433
|
mcpKind: "copilot-config",
|
|
429
434
|
runCmd: (prompt, repoDir, hasMcp, model) => [
|
|
@@ -466,7 +471,7 @@ const KNOWN_AGENTS = [
|
|
|
466
471
|
{ name: "gemini-2.5-pro", hint: "most powerful" },
|
|
467
472
|
{ name: "gemini-pro-latest", hint: "balanced" },
|
|
468
473
|
],
|
|
469
|
-
authLabel: "GEMINI_API_KEY",
|
|
474
|
+
authLabel: "GEMINI_API_KEY (in ~/.yats/.env)",
|
|
470
475
|
needsSkill: false,
|
|
471
476
|
mcpKind: "gemini-config",
|
|
472
477
|
runCmd: (prompt, repoDir, hasMcp, model) => [
|
|
@@ -483,12 +488,13 @@ const KNOWN_AGENTS = [
|
|
|
483
488
|
// ============================================================
|
|
484
489
|
|
|
485
490
|
async function selectAgent() {
|
|
486
|
-
const opts = KNOWN_AGENTS.map((a) =>
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
491
|
+
const opts = KNOWN_AGENTS.map((a) => {
|
|
492
|
+
const installed = isInstalled(a.cli);
|
|
493
|
+
const hasKey = !a.needsApiKey || hasApiKey(a.needsApiKey);
|
|
494
|
+
let hint = installed ? "installed" : "not installed";
|
|
495
|
+
if (installed && a.needsApiKey && !hasKey) hint = `missing ${a.needsApiKey} in ~/.yats/.env`;
|
|
496
|
+
return { label: a.name, hint, ok: installed && hasKey, value: a };
|
|
497
|
+
});
|
|
492
498
|
return select("Select your AI agent", opts);
|
|
493
499
|
}
|
|
494
500
|
|
|
@@ -760,12 +766,12 @@ function setupAgent(agent, repoPath, withYats) {
|
|
|
760
766
|
|
|
761
767
|
case "copilot-config": { // Copilot
|
|
762
768
|
process.env.COPILOT_HOME = home;
|
|
763
|
-
//
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
+
// Only copy the user's auth metadata if they explicitly consented in checkAgent().
|
|
770
|
+
if (copilotConsent) {
|
|
771
|
+
const realConfig = path.join(os.homedir(), ".copilot", "config.json");
|
|
772
|
+
if (fs.existsSync(realConfig)) {
|
|
773
|
+
fs.copyFileSync(realConfig, path.join(home, "config.json"));
|
|
774
|
+
}
|
|
769
775
|
}
|
|
770
776
|
if (withYats) {
|
|
771
777
|
const bridge = path.join(BENCH_DIR, "adapters", "mcp-bridge-stdio.cjs");
|
|
@@ -825,7 +831,7 @@ function setupAgent(agent, repoPath, withYats) {
|
|
|
825
831
|
}
|
|
826
832
|
}
|
|
827
833
|
|
|
828
|
-
function checkAgent(agent) {
|
|
834
|
+
async function checkAgent(agent) {
|
|
829
835
|
console.log(`\n ${A.dim}Checking ${agent.name}...${A.reset}`);
|
|
830
836
|
if (!isInstalled(agent.cli)) {
|
|
831
837
|
console.log(` ${A.red}✖ ${agent.cli} is not installed.${A.reset}`);
|
|
@@ -833,10 +839,41 @@ function checkAgent(agent) {
|
|
|
833
839
|
return false;
|
|
834
840
|
}
|
|
835
841
|
console.log(` ${A.green}✓${A.reset} ${agent.cli} found`);
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
842
|
+
|
|
843
|
+
// API-key agents (claude/codex/gemini) read keys from ~/.yats/.env
|
|
844
|
+
if (agent.needsApiKey) {
|
|
845
|
+
if (!hasApiKey(agent.needsApiKey)) {
|
|
846
|
+
console.log(` ${A.red}✖ ${agent.needsApiKey} not set.${A.reset}`);
|
|
847
|
+
console.log(` Add it to ${A.bold}~/.yats/.env${A.reset} to use ${agent.name}.`);
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
850
|
+
console.log(` ${A.green}✓${A.reset} ${agent.needsApiKey} found in ~/.yats/.env`);
|
|
851
|
+
return true;
|
|
839
852
|
}
|
|
853
|
+
|
|
854
|
+
// copilot / cursor use their own OAuth login (no API key in .env)
|
|
855
|
+
if (agent.name === "copilot") {
|
|
856
|
+
const realConfig = path.join(os.homedir(), ".copilot", "config.json");
|
|
857
|
+
if (fs.existsSync(realConfig)) {
|
|
858
|
+
const use = await select("Copilot login", [
|
|
859
|
+
{ label: "Use my existing Copilot login (copy ~/.copilot/config.json)", value: true },
|
|
860
|
+
{ label: "No — cancel", value: false },
|
|
861
|
+
]);
|
|
862
|
+
if (!use) {
|
|
863
|
+
console.log(` ${A.yellow}✖ Cancelled${A.reset}`);
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
copilotConsent = true;
|
|
867
|
+
console.log(` ${A.green}✓${A.reset} Will use your existing Copilot login`);
|
|
868
|
+
} else {
|
|
869
|
+
console.log(` ${A.red}✖ No ~/.copilot/config.json found.${A.reset}`);
|
|
870
|
+
console.log(` Run ${A.bold}copilot auth${A.reset} first.`);
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
return true;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
console.log(` ${A.dim}Auth: ${agent.authLabel}${A.reset}`);
|
|
840
877
|
return true;
|
|
841
878
|
}
|
|
842
879
|
|
|
@@ -1357,7 +1394,7 @@ async function runOnce() {
|
|
|
1357
1394
|
|
|
1358
1395
|
// 1. Agent
|
|
1359
1396
|
const agent = await selectAgent();
|
|
1360
|
-
if (!checkAgent(agent)) {
|
|
1397
|
+
if (!(await checkAgent(agent))) {
|
|
1361
1398
|
restoreTerminal();
|
|
1362
1399
|
process.exit(1);
|
|
1363
1400
|
}
|
package/src/reindex.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* yats reindex --rebuild-vectors — Rebuild the vector index (re-embed all symbols).
|
|
3
|
+
* Thin HTTP client that POSTs to /reindex on the YATS server.
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ Re-embedding calls the embedding API and may cost money. This is a
|
|
6
|
+
* user-initiated command — run it only after changing the embedding provider
|
|
7
|
+
* or model to a different vector dimension.
|
|
8
|
+
*/
|
|
9
|
+
const YATS_URL = process.env.YATS_URL || "http://localhost:5555";
|
|
10
|
+
|
|
11
|
+
export default async function reindex(args = []) {
|
|
12
|
+
if (!args.includes("--rebuild-vectors")) {
|
|
13
|
+
console.log("Usage: yats reindex --rebuild-vectors");
|
|
14
|
+
console.log("");
|
|
15
|
+
console.log(" --rebuild-vectors Re-embed every indexed symbol with the current embedding model.");
|
|
16
|
+
console.log(" This may incur API costs. Use it after changing the embedding");
|
|
17
|
+
console.log(" provider or model (different vector dimension).");
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
console.log("Rebuilding vector index... (this may take a while and may incur API costs)");
|
|
22
|
+
try {
|
|
23
|
+
const res = await fetch(`${YATS_URL}/reindex`, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
headers: { "Content-Type": "application/json" },
|
|
26
|
+
body: "{}",
|
|
27
|
+
});
|
|
28
|
+
const data = await res.json();
|
|
29
|
+
if (!res.ok) {
|
|
30
|
+
console.error(`Rebuild failed (${res.status}): ${data?.error ?? "unknown error"}`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
console.log("");
|
|
34
|
+
console.log(` ✓ ${data.symbols} symbols re-embedded across ${data.repositories} repositories${data.errors ? ` (${data.errors} errors)` : ""}`);
|
|
35
|
+
console.log("");
|
|
36
|
+
} catch {
|
|
37
|
+
console.error(`Cannot reach YATS at ${YATS_URL}. Is it running?`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/setup.js
CHANGED
|
@@ -30,6 +30,7 @@ const REPOS_DIR = join(YATS_DIR, "repos");
|
|
|
30
30
|
const COMPOSE_FILE = join(YATS_DIR, "docker-compose.yml");
|
|
31
31
|
const MCP_CONFIG_FILE = join(YATS_DIR, "mcp-config.json");
|
|
32
32
|
const YATS_BIN_DIR = join(YATS_DIR, "bin");
|
|
33
|
+
const ENV_FILE = join(YATS_DIR, ".env");
|
|
33
34
|
|
|
34
35
|
const GITHUB_COMPOSE_URL =
|
|
35
36
|
"https://raw.githubusercontent.com/fvinciarelli/yats.ai/main/docker/docker-compose.yml";
|
|
@@ -42,6 +43,33 @@ const Y = "\x1b[33m";
|
|
|
42
43
|
const C = "\x1b[36m";
|
|
43
44
|
const RED = "\x1b[31m";
|
|
44
45
|
|
|
46
|
+
// Embedding models per provider (with their vector dimensions)
|
|
47
|
+
const PROVIDER_MODELS = {
|
|
48
|
+
openai: [
|
|
49
|
+
{ label: "text-embedding-3-small (1536d, fast & cheap)", value: "text-embedding-3-small" },
|
|
50
|
+
{ label: "text-embedding-3-large (3072d, more accurate)", value: "text-embedding-3-large" },
|
|
51
|
+
{ label: "text-embedding-ada-002 (1536d, legacy)", value: "text-embedding-ada-002" },
|
|
52
|
+
],
|
|
53
|
+
mistral: [
|
|
54
|
+
{ label: "mistral-embed (1024d)", value: "mistral-embed" },
|
|
55
|
+
],
|
|
56
|
+
voyage: [
|
|
57
|
+
{ label: "voyage-code-2 (1536d, code-optimized)", value: "voyage-code-2" },
|
|
58
|
+
{ label: "voyage-3 (1024d)", value: "voyage-3" },
|
|
59
|
+
{ label: "voyage-3-large (1024d, most accurate)", value: "voyage-3-large" },
|
|
60
|
+
{ label: "voyage-3-lite (512d, fastest & cheapest)", value: "voyage-3-lite" },
|
|
61
|
+
{ label: "voyage-2 (1024d, legacy)", value: "voyage-2" },
|
|
62
|
+
],
|
|
63
|
+
ollama: [
|
|
64
|
+
{ label: "nomic-embed-text (768d, fast, ~274MB)", value: "nomic-embed-text" },
|
|
65
|
+
{ label: "mxbai-embed-large (1024d, more accurate, ~669MB)", value: "mxbai-embed-large" },
|
|
66
|
+
{ label: "bge-m3 (1024d, multilingual)", value: "bge-m3" },
|
|
67
|
+
{ label: "snowflake-arctic-embed (1024d)", value: "snowflake-arctic-embed" },
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const DEFAULT_MODEL = { openai: "text-embedding-3-small", mistral: "mistral-embed", voyage: "voyage-code-2", ollama: "nomic-embed-text" };
|
|
72
|
+
|
|
45
73
|
// Minimal embedded docker-compose as fallback
|
|
46
74
|
const EMBEDDED_COMPOSE = `services:
|
|
47
75
|
neo4j:
|
|
@@ -89,12 +117,15 @@ const EMBEDDED_COMPOSE = `services:
|
|
|
89
117
|
- NEO4J_USER=neo4j
|
|
90
118
|
- NEO4J_PASSWORD=\${NEO4J_PASSWORD:-password}
|
|
91
119
|
- QDRANT_URL=http://qdrant:6333
|
|
92
|
-
- EMBEDDING_PROVIDER
|
|
120
|
+
- EMBEDDING_PROVIDER=\${EMBEDDING_PROVIDER:-ollama}
|
|
93
121
|
- OLLAMA_URL=http://ollama:11434
|
|
94
|
-
- OLLAMA_MODEL
|
|
95
|
-
- OPENAI_API_KEY
|
|
96
|
-
-
|
|
97
|
-
-
|
|
122
|
+
- OLLAMA_MODEL=\${EMBEDDING_OLLAMA_MODEL:-nomic-embed-text}
|
|
123
|
+
- OPENAI_API_KEY=\${EMBEDDING_OPENAI_API_KEY:-}
|
|
124
|
+
- OPENAI_MODEL=\${EMBEDDING_OPENAI_MODEL:-text-embedding-3-small}
|
|
125
|
+
- MISTRAL_API_KEY=\${EMBEDDING_MISTRAL_API_KEY:-}
|
|
126
|
+
- MISTRAL_MODEL=\${EMBEDDING_MISTRAL_MODEL:-mistral-embed}
|
|
127
|
+
- VOYAGE_API_KEY=\${EMBEDDING_VOYAGE_API_KEY:-}
|
|
128
|
+
- VOYAGE_MODEL=\${EMBEDDING_VOYAGE_MODEL:-voyage-code-2}
|
|
98
129
|
- REPOSITORIES_PATH=/repos
|
|
99
130
|
- YATS_PORT=__MCP_PORT__
|
|
100
131
|
- EMBEDDING_BATCH_SIZE=__BATCH_SIZE__
|
|
@@ -128,7 +159,7 @@ const OLLAMA_SERVICE = ` ollama:
|
|
|
128
159
|
- |
|
|
129
160
|
ollama serve &
|
|
130
161
|
sleep 5
|
|
131
|
-
ollama pull
|
|
162
|
+
ollama pull \${EMBEDDING_OLLAMA_MODEL:-nomic-embed-text} 2>/dev/null || true
|
|
132
163
|
wait
|
|
133
164
|
ollama-models:
|
|
134
165
|
`;
|
|
@@ -321,21 +352,16 @@ async function checkYatsRunning() {
|
|
|
321
352
|
// Compose file generation
|
|
322
353
|
// ============================================================
|
|
323
354
|
|
|
324
|
-
function generateCompose(provider,
|
|
355
|
+
function generateCompose(provider, mcpPort, batchSize, indexDocs, docMaxFiles) {
|
|
325
356
|
let compose = EMBEDDED_COMPOSE;
|
|
326
357
|
|
|
327
358
|
if (provider === "ollama") {
|
|
328
|
-
compose = compose.replace("__OLLAMA_PLACEHOLDER__", OLLAMA_SERVICE
|
|
359
|
+
compose = compose.replace("__OLLAMA_PLACEHOLDER__", OLLAMA_SERVICE);
|
|
329
360
|
} else {
|
|
330
361
|
compose = compose.replace("__OLLAMA_PLACEHOLDER__", "");
|
|
331
362
|
}
|
|
332
363
|
|
|
333
364
|
compose = compose
|
|
334
|
-
.replace(/__PROVIDER__/g, provider)
|
|
335
|
-
.replace(/__OLLAMA_MODEL__/g, ollamaModel)
|
|
336
|
-
.replace(/__OPENAI_KEY__/g, provider === "openai" ? apiKey : "")
|
|
337
|
-
.replace(/__MISTRAL_KEY__/g, provider === "mistral" ? apiKey : "")
|
|
338
|
-
.replace(/__VOYAGE_KEY__/g, provider === "voyage" ? apiKey : "")
|
|
339
365
|
.replace(/__MCP_PORT__/g, String(mcpPort))
|
|
340
366
|
.replace(/__BATCH_SIZE__/g, String(batchSize))
|
|
341
367
|
.replace(/__INDEX_DOCS__/g, indexDocs ? "true" : "false")
|
|
@@ -418,8 +444,8 @@ async function main(options = {}) {
|
|
|
418
444
|
const env = loadEnv();
|
|
419
445
|
const nonInteractive = options.nonInteractive || false;
|
|
420
446
|
const prefill = {
|
|
421
|
-
provider: options.provider || env.YATS_PROVIDER || null,
|
|
422
|
-
apiKey: options.apiKey || env.
|
|
447
|
+
provider: options.provider || env.YATS_PROVIDER || env.EMBEDDING_PROVIDER || null,
|
|
448
|
+
apiKey: options.apiKey || env.EMBEDDING_OPENAI_API_KEY || env.EMBEDDING_MISTRAL_API_KEY || env.EMBEDDING_VOYAGE_API_KEY || null,
|
|
423
449
|
port: options.port ? parseInt(options.port, 10) : null,
|
|
424
450
|
batch: options.batch ? parseInt(options.batch, 10) : null,
|
|
425
451
|
noDocs: options.noDocs || false,
|
|
@@ -499,15 +525,9 @@ async function main(options = {}) {
|
|
|
499
525
|
}
|
|
500
526
|
|
|
501
527
|
let apiKey = "";
|
|
502
|
-
let
|
|
528
|
+
let model = DEFAULT_MODEL[provider];
|
|
503
529
|
|
|
504
|
-
if (provider
|
|
505
|
-
step("Step 2 — Ollama model");
|
|
506
|
-
ollamaModel = await choose("Which model?", [
|
|
507
|
-
{ label: "nomic-embed-text (768d, fast, ~274MB)", value: "nomic-embed-text" },
|
|
508
|
-
{ label: "mxbai-embed-large (1024d, more accurate, ~669MB)", value: "mxbai-embed-large" },
|
|
509
|
-
]);
|
|
510
|
-
} else {
|
|
530
|
+
if (provider !== "ollama") {
|
|
511
531
|
const providerNames = { openai: "OpenAI", mistral: "Mistral", voyage: "Voyage AI" };
|
|
512
532
|
step(`Step 2 — ${providerNames[provider]} API key`);
|
|
513
533
|
|
|
@@ -564,7 +584,16 @@ async function main(options = {}) {
|
|
|
564
584
|
console.log("");
|
|
565
585
|
}
|
|
566
586
|
|
|
567
|
-
//
|
|
587
|
+
// Embedding model (every provider)
|
|
588
|
+
if (nonInteractive) {
|
|
589
|
+
console.log(` Embedding model: ${model}`);
|
|
590
|
+
} else {
|
|
591
|
+
step(provider === "ollama" ? "Step 2 — Embedding model" : "Step 3 — Embedding model");
|
|
592
|
+
model = await choose("Which embedding model?", PROVIDER_MODELS[provider]);
|
|
593
|
+
console.log("");
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// Step 4: Embedding batch size
|
|
568
597
|
const BATCH_DEFAULTS = { openai: 200, mistral: 200, voyage: 100, ollama: 4 };
|
|
569
598
|
const BATCH_MAX = { openai: 2048, mistral: 1024, voyage: 128, ollama: 4 };
|
|
570
599
|
const defaultBatch = prefill.batch || BATCH_DEFAULTS[provider];
|
|
@@ -574,7 +603,7 @@ async function main(options = {}) {
|
|
|
574
603
|
if (nonInteractive) {
|
|
575
604
|
console.log(` Batch size: ${batchSize}`);
|
|
576
605
|
} else {
|
|
577
|
-
step(`Step
|
|
606
|
+
step(`Step 4 — Embedding batch size`);
|
|
578
607
|
console.log(` ${D}How many texts to embed per API request.${R}`);
|
|
579
608
|
console.log(` ${D}Higher = faster indexing, lower = safer for rate limits.${R}`);
|
|
580
609
|
console.log(` ${D}Provider max: ${maxBatch}${R}`);
|
|
@@ -597,7 +626,7 @@ async function main(options = {}) {
|
|
|
597
626
|
let indexDocs = !prefill.noDocs;
|
|
598
627
|
|
|
599
628
|
if (!nonInteractive) {
|
|
600
|
-
step("Step
|
|
629
|
+
step("Step 5 — Documentation indexing");
|
|
601
630
|
console.log(` ${D}Index README, ARCHITECTURE, AI/ docs, and docs/ directory.${R}`);
|
|
602
631
|
console.log(` ${D}Patterns (edit via DOC_PATTERNS env): AI/*.md, README.md, docs/${R}`);
|
|
603
632
|
console.log(` ${D}If docs/ has >${docMaxFiles} .md files, you'll get a warning.${R}`);
|
|
@@ -673,7 +702,7 @@ async function main(options = {}) {
|
|
|
673
702
|
if (!nonInteractive && !prefill.skipConfirm) {
|
|
674
703
|
step(`Step ${pathsToIndex.length ? "6" : "5"} — Confirm`);
|
|
675
704
|
const providerName = provider === "ollama"
|
|
676
|
-
? `Ollama (${
|
|
705
|
+
? `Ollama (${model})`
|
|
677
706
|
: { openai: "OpenAI", mistral: "Mistral", voyage: "Voyage AI" }[provider];
|
|
678
707
|
box([
|
|
679
708
|
`${B}Provider:${R} ${providerName}`,
|
|
@@ -706,13 +735,25 @@ async function main(options = {}) {
|
|
|
706
735
|
mkdirSync(REPOS_DIR, { recursive: true });
|
|
707
736
|
|
|
708
737
|
// Generate and write docker-compose
|
|
709
|
-
const compose = generateCompose(provider,
|
|
738
|
+
const compose = generateCompose(provider, mcpPort, batchSize, indexDocs, docMaxFiles);
|
|
710
739
|
writeFileSync(COMPOSE_FILE, compose);
|
|
711
740
|
|
|
712
741
|
// Write MCP config
|
|
713
742
|
const mcpConfig = { mcpServers: { yats: { url: `http://localhost:${mcpPort}/mcp/sse` } } };
|
|
714
743
|
writeFileSync(MCP_CONFIG_FILE, JSON.stringify(mcpConfig, null, 2));
|
|
715
744
|
|
|
745
|
+
// Persist keys to ~/.yats/.env — canonical source (embedding + benchmark keys).
|
|
746
|
+
// Merge with any keys the user already added (e.g. ANTHROPIC_API_KEY, GEMINI_API_KEY).
|
|
747
|
+
const envMap = loadEnv();
|
|
748
|
+
envMap.EMBEDDING_PROVIDER = provider;
|
|
749
|
+
envMap.YATS_PROVIDER = provider;
|
|
750
|
+
if (provider === "openai" && apiKey) envMap.EMBEDDING_OPENAI_API_KEY = apiKey;
|
|
751
|
+
if (provider === "mistral" && apiKey) envMap.EMBEDDING_MISTRAL_API_KEY = apiKey;
|
|
752
|
+
if (provider === "voyage" && apiKey) envMap.EMBEDDING_VOYAGE_API_KEY = apiKey;
|
|
753
|
+
const modelVar = { openai: "EMBEDDING_OPENAI_MODEL", mistral: "EMBEDDING_MISTRAL_MODEL", voyage: "EMBEDDING_VOYAGE_MODEL", ollama: "EMBEDDING_OLLAMA_MODEL" }[provider];
|
|
754
|
+
if (model && modelVar) envMap[modelVar] = model;
|
|
755
|
+
writeFileSync(ENV_FILE, Object.entries(envMap).map(([k, v]) => `${k}=${v}`).join("\n") + "\n");
|
|
756
|
+
|
|
716
757
|
// Pull the YATS Docker image from GitHub Container Registry
|
|
717
758
|
const sPull = spinner("Pulling YATS image from registry...");
|
|
718
759
|
try {
|
|
@@ -827,6 +868,7 @@ async function main(options = {}) {
|
|
|
827
868
|
console.log(` ✅ ${G}YATS is ready!${R} → ${C}http://localhost:${mcpPort}/mcp/sse${R}`);
|
|
828
869
|
console.log("");
|
|
829
870
|
console.log(` Config saved to ${C}~/.yats/.env${R}`);
|
|
871
|
+
console.log(` ${D}Benchmark agent keys (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY) go there too.${R}`);
|
|
830
872
|
console.log("");
|
|
831
873
|
box([
|
|
832
874
|
`${B}Copy this URL into your AI agent:${R}`,
|