yats-toolkit 0.3.1 → 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/reindex.js +40 -0
- package/src/setup.js +52 -18
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/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")
|
|
@@ -496,15 +525,9 @@ async function main(options = {}) {
|
|
|
496
525
|
}
|
|
497
526
|
|
|
498
527
|
let apiKey = "";
|
|
499
|
-
let
|
|
528
|
+
let model = DEFAULT_MODEL[provider];
|
|
500
529
|
|
|
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 {
|
|
530
|
+
if (provider !== "ollama") {
|
|
508
531
|
const providerNames = { openai: "OpenAI", mistral: "Mistral", voyage: "Voyage AI" };
|
|
509
532
|
step(`Step 2 — ${providerNames[provider]} API key`);
|
|
510
533
|
|
|
@@ -561,7 +584,16 @@ async function main(options = {}) {
|
|
|
561
584
|
console.log("");
|
|
562
585
|
}
|
|
563
586
|
|
|
564
|
-
//
|
|
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
|
|
565
597
|
const BATCH_DEFAULTS = { openai: 200, mistral: 200, voyage: 100, ollama: 4 };
|
|
566
598
|
const BATCH_MAX = { openai: 2048, mistral: 1024, voyage: 128, ollama: 4 };
|
|
567
599
|
const defaultBatch = prefill.batch || BATCH_DEFAULTS[provider];
|
|
@@ -571,7 +603,7 @@ async function main(options = {}) {
|
|
|
571
603
|
if (nonInteractive) {
|
|
572
604
|
console.log(` Batch size: ${batchSize}`);
|
|
573
605
|
} else {
|
|
574
|
-
step(`Step
|
|
606
|
+
step(`Step 4 — Embedding batch size`);
|
|
575
607
|
console.log(` ${D}How many texts to embed per API request.${R}`);
|
|
576
608
|
console.log(` ${D}Higher = faster indexing, lower = safer for rate limits.${R}`);
|
|
577
609
|
console.log(` ${D}Provider max: ${maxBatch}${R}`);
|
|
@@ -594,7 +626,7 @@ async function main(options = {}) {
|
|
|
594
626
|
let indexDocs = !prefill.noDocs;
|
|
595
627
|
|
|
596
628
|
if (!nonInteractive) {
|
|
597
|
-
step("Step
|
|
629
|
+
step("Step 5 — Documentation indexing");
|
|
598
630
|
console.log(` ${D}Index README, ARCHITECTURE, AI/ docs, and docs/ directory.${R}`);
|
|
599
631
|
console.log(` ${D}Patterns (edit via DOC_PATTERNS env): AI/*.md, README.md, docs/${R}`);
|
|
600
632
|
console.log(` ${D}If docs/ has >${docMaxFiles} .md files, you'll get a warning.${R}`);
|
|
@@ -670,7 +702,7 @@ async function main(options = {}) {
|
|
|
670
702
|
if (!nonInteractive && !prefill.skipConfirm) {
|
|
671
703
|
step(`Step ${pathsToIndex.length ? "6" : "5"} — Confirm`);
|
|
672
704
|
const providerName = provider === "ollama"
|
|
673
|
-
? `Ollama (${
|
|
705
|
+
? `Ollama (${model})`
|
|
674
706
|
: { openai: "OpenAI", mistral: "Mistral", voyage: "Voyage AI" }[provider];
|
|
675
707
|
box([
|
|
676
708
|
`${B}Provider:${R} ${providerName}`,
|
|
@@ -703,7 +735,7 @@ async function main(options = {}) {
|
|
|
703
735
|
mkdirSync(REPOS_DIR, { recursive: true });
|
|
704
736
|
|
|
705
737
|
// Generate and write docker-compose
|
|
706
|
-
const compose = generateCompose(provider,
|
|
738
|
+
const compose = generateCompose(provider, mcpPort, batchSize, indexDocs, docMaxFiles);
|
|
707
739
|
writeFileSync(COMPOSE_FILE, compose);
|
|
708
740
|
|
|
709
741
|
// Write MCP config
|
|
@@ -718,6 +750,8 @@ async function main(options = {}) {
|
|
|
718
750
|
if (provider === "openai" && apiKey) envMap.EMBEDDING_OPENAI_API_KEY = apiKey;
|
|
719
751
|
if (provider === "mistral" && apiKey) envMap.EMBEDDING_MISTRAL_API_KEY = apiKey;
|
|
720
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;
|
|
721
755
|
writeFileSync(ENV_FILE, Object.entries(envMap).map(([k, v]) => `${k}=${v}`).join("\n") + "\n");
|
|
722
756
|
|
|
723
757
|
// Pull the YATS Docker image from GitHub Container Registry
|