yats-toolkit 0.1.2 → 0.1.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/package.json +1 -1
- package/src/setup.js +22 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yats-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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": "MIT",
|
package/src/setup.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { spawn } from "node:child_process";
|
|
12
|
-
import { writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
12
|
+
import { writeFileSync, mkdirSync, existsSync, readFileSync } from "node:fs";
|
|
13
13
|
import { homedir } from "node:os";
|
|
14
14
|
import { join } from "node:path";
|
|
15
15
|
import { createInterface } from "node:readline";
|
|
@@ -18,7 +18,13 @@ import { createInterface } from "node:readline";
|
|
|
18
18
|
// Constants
|
|
19
19
|
// ============================================================
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
// Read version from package.json dynamically
|
|
22
|
+
let YATS_VERSION = "0.1.0";
|
|
23
|
+
try {
|
|
24
|
+
const pkgPath = new URL("../package.json", import.meta.url);
|
|
25
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
26
|
+
YATS_VERSION = pkg.version || YATS_VERSION;
|
|
27
|
+
} catch {}
|
|
22
28
|
const YATS_DIR = join(homedir(), ".yats");
|
|
23
29
|
const REPOS_DIR = join(YATS_DIR, "repos");
|
|
24
30
|
const COMPOSE_FILE = join(YATS_DIR, "docker-compose.yml");
|
|
@@ -161,7 +167,7 @@ function box(lines, width = W) {
|
|
|
161
167
|
if (line === "") {
|
|
162
168
|
console.log(` ║ ${" ".repeat(width)} ║`);
|
|
163
169
|
} else {
|
|
164
|
-
console.log(` ║ ${
|
|
170
|
+
console.log(` ║ ${center(line)} ║`);
|
|
165
171
|
}
|
|
166
172
|
}
|
|
167
173
|
console.log(bottom);
|
|
@@ -297,8 +303,10 @@ async function checkPort(port) {
|
|
|
297
303
|
}
|
|
298
304
|
|
|
299
305
|
async function checkYatsRunning() {
|
|
306
|
+
// Check if the compose file from a previous setup exists
|
|
307
|
+
if (!existsSync(COMPOSE_FILE)) return false;
|
|
308
|
+
// Check if the YATS setup container is actually running
|
|
300
309
|
return new Promise((resolve) => {
|
|
301
|
-
// Only match the YATS setup containers (not dev containers)
|
|
302
310
|
const proc = spawn("docker", ["ps", "--format", "{{.Names}}", "--filter", "name=yats-yats"], { stdio: "pipe" });
|
|
303
311
|
let out = "";
|
|
304
312
|
proc.stdout.on("data", (d) => (out += d));
|
|
@@ -384,13 +392,19 @@ async function main() {
|
|
|
384
392
|
// Check for existing YATS containers BEFORE the wizard
|
|
385
393
|
const existingContainers = await checkYatsRunning();
|
|
386
394
|
if (existingContainers) {
|
|
387
|
-
|
|
395
|
+
// Try to read the port from the existing compose/env
|
|
396
|
+
let port = 5555;
|
|
397
|
+
try {
|
|
398
|
+
const composeContent = require("fs").readFileSync(COMPOSE_FILE, "utf-8");
|
|
399
|
+
const match = composeContent.match(/YATS_PORT=(\d+)/) || composeContent.match(/"(\d+):(\d+)"/);
|
|
400
|
+
if (match) port = parseInt(match[1] || match[2], 10);
|
|
401
|
+
} catch {}
|
|
402
|
+
|
|
403
|
+
console.log(` ${G}✓${R} YATS is already running on ${C}http://localhost:${port}/mcp${R}`);
|
|
388
404
|
console.log("");
|
|
389
405
|
console.log(` To start fresh ${B}(destroys all indexed data):${R}`);
|
|
390
406
|
console.log(` ${C}cd ~/.yats && docker compose down -v${R}`);
|
|
391
407
|
console.log("");
|
|
392
|
-
console.log(` To reconnect your AI agent, just point it at ${C}http://localhost:5555/mcp${R}`);
|
|
393
|
-
console.log("");
|
|
394
408
|
process.exit(0);
|
|
395
409
|
}
|
|
396
410
|
|
|
@@ -422,6 +436,7 @@ async function main() {
|
|
|
422
436
|
console.log("");
|
|
423
437
|
console.log(` ${Y}⚠${R} This is a paid service — you may be charged for API usage.`);
|
|
424
438
|
console.log("");
|
|
439
|
+
console.log("");
|
|
425
440
|
}
|
|
426
441
|
|
|
427
442
|
// Step 3: Embedding batch size
|