yats-toolkit 0.3.1 → 0.3.3
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 +4 -3
- package/bin/setup.js +3 -0
- package/package.json +1 -1
- package/src/reindex.js +40 -0
- package/src/setup.js +68 -24
package/README.md
CHANGED
|
@@ -126,7 +126,7 @@ See the [GitHub repository](https://github.com/fvinciarelli/yats.ai) for the ful
|
|
|
126
126
|
```bash
|
|
127
127
|
yats setup
|
|
128
128
|
```
|
|
129
|
-
Runs the one-time setup wizard. Detects if YATS is already running, asks for embedding provider (Ollama/OpenAI/Mistral/Voyage), API keys if needed, batch size, docs indexing preference, optional pre-index directories, and MCP port. Generates `~/.yats/docker-compose.yml` and starts all services.
|
|
129
|
+
Runs the one-time setup wizard. Detects if YATS is already running, asks for embedding provider (Ollama/OpenAI/Mistral/Voyage), API keys if needed, batch size, docs indexing preference, optional pre-index directories, and MCP port. Generates `~/.yats/docker-compose.yml`, writes `~/.yats/.env` (embedding keys plus empty `ANTHROPIC_API_KEY` / `OPENAI_API_KEY` / `GEMINI_API_KEY` / `DEEPSEEK_API_KEY` placeholders for `yats benchmark`), and starts all services.
|
|
130
130
|
|
|
131
131
|
```bash
|
|
132
132
|
yats index <path> [--skip-docs]
|
|
@@ -176,8 +176,9 @@ codebase questions with and without YATS. Supports Claude, Codex, Copilot, Gemin
|
|
|
176
176
|
and Cursor (CLI). Clones/indexes test repos and saves results with averages.
|
|
177
177
|
|
|
178
178
|
**Where your agent's keys come from** — the benchmark runs *your* agent, which uses
|
|
179
|
-
*your* credentials with its provider. It
|
|
180
|
-
|
|
179
|
+
*your* credentials with its provider. It loads `~/.yats/.env` (written by `yats setup`,
|
|
180
|
+
which pre-fills the agent key names) and any `.env` in the current dir or repo root;
|
|
181
|
+
shell env vars take precedence.
|
|
181
182
|
|
|
182
183
|
| Agent | Credential |
|
|
183
184
|
|---|---|
|
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.3",
|
|
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/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
|
@@ -43,6 +43,33 @@ const Y = "\x1b[33m";
|
|
|
43
43
|
const C = "\x1b[36m";
|
|
44
44
|
const RED = "\x1b[31m";
|
|
45
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
|
+
|
|
46
73
|
// Minimal embedded docker-compose as fallback
|
|
47
74
|
const EMBEDDED_COMPOSE = `services:
|
|
48
75
|
neo4j:
|
|
@@ -92,10 +119,13 @@ const EMBEDDED_COMPOSE = `services:
|
|
|
92
119
|
- QDRANT_URL=http://qdrant:6333
|
|
93
120
|
- EMBEDDING_PROVIDER=\${EMBEDDING_PROVIDER:-ollama}
|
|
94
121
|
- OLLAMA_URL=http://ollama:11434
|
|
95
|
-
- OLLAMA_MODEL
|
|
122
|
+
- OLLAMA_MODEL=\${EMBEDDING_OLLAMA_MODEL:-nomic-embed-text}
|
|
96
123
|
- OPENAI_API_KEY=\${EMBEDDING_OPENAI_API_KEY:-}
|
|
124
|
+
- OPENAI_MODEL=\${EMBEDDING_OPENAI_MODEL:-text-embedding-3-small}
|
|
97
125
|
- MISTRAL_API_KEY=\${EMBEDDING_MISTRAL_API_KEY:-}
|
|
126
|
+
- MISTRAL_MODEL=\${EMBEDDING_MISTRAL_MODEL:-mistral-embed}
|
|
98
127
|
- VOYAGE_API_KEY=\${EMBEDDING_VOYAGE_API_KEY:-}
|
|
128
|
+
- VOYAGE_MODEL=\${EMBEDDING_VOYAGE_MODEL:-voyage-code-2}
|
|
99
129
|
- REPOSITORIES_PATH=/repos
|
|
100
130
|
- YATS_PORT=__MCP_PORT__
|
|
101
131
|
- EMBEDDING_BATCH_SIZE=__BATCH_SIZE__
|
|
@@ -129,7 +159,7 @@ const OLLAMA_SERVICE = ` ollama:
|
|
|
129
159
|
- |
|
|
130
160
|
ollama serve &
|
|
131
161
|
sleep 5
|
|
132
|
-
ollama pull
|
|
162
|
+
ollama pull \${EMBEDDING_OLLAMA_MODEL:-nomic-embed-text} 2>/dev/null || true
|
|
133
163
|
wait
|
|
134
164
|
ollama-models:
|
|
135
165
|
`;
|
|
@@ -322,17 +352,16 @@ async function checkYatsRunning() {
|
|
|
322
352
|
// Compose file generation
|
|
323
353
|
// ============================================================
|
|
324
354
|
|
|
325
|
-
function generateCompose(provider,
|
|
355
|
+
function generateCompose(provider, mcpPort, batchSize, indexDocs, docMaxFiles) {
|
|
326
356
|
let compose = EMBEDDED_COMPOSE;
|
|
327
357
|
|
|
328
358
|
if (provider === "ollama") {
|
|
329
|
-
compose = compose.replace("__OLLAMA_PLACEHOLDER__", OLLAMA_SERVICE
|
|
359
|
+
compose = compose.replace("__OLLAMA_PLACEHOLDER__", OLLAMA_SERVICE);
|
|
330
360
|
} else {
|
|
331
361
|
compose = compose.replace("__OLLAMA_PLACEHOLDER__", "");
|
|
332
362
|
}
|
|
333
363
|
|
|
334
364
|
compose = compose
|
|
335
|
-
.replace(/__OLLAMA_MODEL__/g, ollamaModel)
|
|
336
365
|
.replace(/__MCP_PORT__/g, String(mcpPort))
|
|
337
366
|
.replace(/__BATCH_SIZE__/g, String(batchSize))
|
|
338
367
|
.replace(/__INDEX_DOCS__/g, indexDocs ? "true" : "false")
|
|
@@ -387,6 +416,23 @@ async function loadEnv() {
|
|
|
387
416
|
return env;
|
|
388
417
|
}
|
|
389
418
|
|
|
419
|
+
// Merge embedding + benchmark keys into the env map before writing ~/.yats/.env.
|
|
420
|
+
// Benchmark agent keys are added empty (if missing) so users see exactly what to
|
|
421
|
+
// fill in for `yats benchmark`; any existing values are preserved.
|
|
422
|
+
export function applyEnvKeys(envMap, { provider, apiKey, model }) {
|
|
423
|
+
envMap.EMBEDDING_PROVIDER = provider;
|
|
424
|
+
envMap.YATS_PROVIDER = provider;
|
|
425
|
+
if (provider === "openai" && apiKey) envMap.EMBEDDING_OPENAI_API_KEY = apiKey;
|
|
426
|
+
if (provider === "mistral" && apiKey) envMap.EMBEDDING_MISTRAL_API_KEY = apiKey;
|
|
427
|
+
if (provider === "voyage" && apiKey) envMap.EMBEDDING_VOYAGE_API_KEY = apiKey;
|
|
428
|
+
const modelVar = { openai: "EMBEDDING_OPENAI_MODEL", mistral: "EMBEDDING_MISTRAL_MODEL", voyage: "EMBEDDING_VOYAGE_MODEL", ollama: "EMBEDDING_OLLAMA_MODEL" }[provider];
|
|
429
|
+
if (model && modelVar) envMap[modelVar] = model;
|
|
430
|
+
for (const k of ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "GEMINI_API_KEY", "DEEPSEEK_API_KEY"]) {
|
|
431
|
+
if (!(k in envMap)) envMap[k] = "";
|
|
432
|
+
}
|
|
433
|
+
return envMap;
|
|
434
|
+
}
|
|
435
|
+
|
|
390
436
|
async function testApiConnection(provider, apiKey) {
|
|
391
437
|
const endpoints = {
|
|
392
438
|
openai: { url: "https://api.openai.com/v1/embeddings", key: apiKey, body: { model: "text-embedding-3-small", input: ["test"] } },
|
|
@@ -496,15 +542,9 @@ async function main(options = {}) {
|
|
|
496
542
|
}
|
|
497
543
|
|
|
498
544
|
let apiKey = "";
|
|
499
|
-
let
|
|
545
|
+
let model = DEFAULT_MODEL[provider];
|
|
500
546
|
|
|
501
|
-
if (provider
|
|
502
|
-
step("Step 2 — Ollama model");
|
|
503
|
-
ollamaModel = await choose("Which model?", [
|
|
504
|
-
{ label: "nomic-embed-text (768d, fast, ~274MB)", value: "nomic-embed-text" },
|
|
505
|
-
{ label: "mxbai-embed-large (1024d, more accurate, ~669MB)", value: "mxbai-embed-large" },
|
|
506
|
-
]);
|
|
507
|
-
} else {
|
|
547
|
+
if (provider !== "ollama") {
|
|
508
548
|
const providerNames = { openai: "OpenAI", mistral: "Mistral", voyage: "Voyage AI" };
|
|
509
549
|
step(`Step 2 — ${providerNames[provider]} API key`);
|
|
510
550
|
|
|
@@ -561,7 +601,16 @@ async function main(options = {}) {
|
|
|
561
601
|
console.log("");
|
|
562
602
|
}
|
|
563
603
|
|
|
564
|
-
//
|
|
604
|
+
// Embedding model (every provider)
|
|
605
|
+
if (nonInteractive) {
|
|
606
|
+
console.log(` Embedding model: ${model}`);
|
|
607
|
+
} else {
|
|
608
|
+
step(provider === "ollama" ? "Step 2 — Embedding model" : "Step 3 — Embedding model");
|
|
609
|
+
model = await choose("Which embedding model?", PROVIDER_MODELS[provider]);
|
|
610
|
+
console.log("");
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// Step 4: Embedding batch size
|
|
565
614
|
const BATCH_DEFAULTS = { openai: 200, mistral: 200, voyage: 100, ollama: 4 };
|
|
566
615
|
const BATCH_MAX = { openai: 2048, mistral: 1024, voyage: 128, ollama: 4 };
|
|
567
616
|
const defaultBatch = prefill.batch || BATCH_DEFAULTS[provider];
|
|
@@ -571,7 +620,7 @@ async function main(options = {}) {
|
|
|
571
620
|
if (nonInteractive) {
|
|
572
621
|
console.log(` Batch size: ${batchSize}`);
|
|
573
622
|
} else {
|
|
574
|
-
step(`Step
|
|
623
|
+
step(`Step 4 — Embedding batch size`);
|
|
575
624
|
console.log(` ${D}How many texts to embed per API request.${R}`);
|
|
576
625
|
console.log(` ${D}Higher = faster indexing, lower = safer for rate limits.${R}`);
|
|
577
626
|
console.log(` ${D}Provider max: ${maxBatch}${R}`);
|
|
@@ -594,7 +643,7 @@ async function main(options = {}) {
|
|
|
594
643
|
let indexDocs = !prefill.noDocs;
|
|
595
644
|
|
|
596
645
|
if (!nonInteractive) {
|
|
597
|
-
step("Step
|
|
646
|
+
step("Step 5 — Documentation indexing");
|
|
598
647
|
console.log(` ${D}Index README, ARCHITECTURE, AI/ docs, and docs/ directory.${R}`);
|
|
599
648
|
console.log(` ${D}Patterns (edit via DOC_PATTERNS env): AI/*.md, README.md, docs/${R}`);
|
|
600
649
|
console.log(` ${D}If docs/ has >${docMaxFiles} .md files, you'll get a warning.${R}`);
|
|
@@ -670,7 +719,7 @@ async function main(options = {}) {
|
|
|
670
719
|
if (!nonInteractive && !prefill.skipConfirm) {
|
|
671
720
|
step(`Step ${pathsToIndex.length ? "6" : "5"} — Confirm`);
|
|
672
721
|
const providerName = provider === "ollama"
|
|
673
|
-
? `Ollama (${
|
|
722
|
+
? `Ollama (${model})`
|
|
674
723
|
: { openai: "OpenAI", mistral: "Mistral", voyage: "Voyage AI" }[provider];
|
|
675
724
|
box([
|
|
676
725
|
`${B}Provider:${R} ${providerName}`,
|
|
@@ -703,7 +752,7 @@ async function main(options = {}) {
|
|
|
703
752
|
mkdirSync(REPOS_DIR, { recursive: true });
|
|
704
753
|
|
|
705
754
|
// Generate and write docker-compose
|
|
706
|
-
const compose = generateCompose(provider,
|
|
755
|
+
const compose = generateCompose(provider, mcpPort, batchSize, indexDocs, docMaxFiles);
|
|
707
756
|
writeFileSync(COMPOSE_FILE, compose);
|
|
708
757
|
|
|
709
758
|
// Write MCP config
|
|
@@ -711,13 +760,8 @@ async function main(options = {}) {
|
|
|
711
760
|
writeFileSync(MCP_CONFIG_FILE, JSON.stringify(mcpConfig, null, 2));
|
|
712
761
|
|
|
713
762
|
// Persist keys to ~/.yats/.env — canonical source (embedding + benchmark keys).
|
|
714
|
-
// Merge with any keys the user already added (e.g. ANTHROPIC_API_KEY, GEMINI_API_KEY).
|
|
715
763
|
const envMap = loadEnv();
|
|
716
|
-
envMap
|
|
717
|
-
envMap.YATS_PROVIDER = provider;
|
|
718
|
-
if (provider === "openai" && apiKey) envMap.EMBEDDING_OPENAI_API_KEY = apiKey;
|
|
719
|
-
if (provider === "mistral" && apiKey) envMap.EMBEDDING_MISTRAL_API_KEY = apiKey;
|
|
720
|
-
if (provider === "voyage" && apiKey) envMap.EMBEDDING_VOYAGE_API_KEY = apiKey;
|
|
764
|
+
applyEnvKeys(envMap, { provider, apiKey, model });
|
|
721
765
|
writeFileSync(ENV_FILE, Object.entries(envMap).map(([k, v]) => `${k}=${v}`).join("\n") + "\n");
|
|
722
766
|
|
|
723
767
|
// Pull the YATS Docker image from GitHub Container Registry
|