yats-toolkit 0.1.13 → 0.1.20

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 CHANGED
@@ -119,7 +119,7 @@ TypeScript, JavaScript, Python, Go, C#, PHP — plus universal fallback via Tree
119
119
 
120
120
  ## Architecture
121
121
 
122
- See the [GitHub repository](https://github.com/fvinciarelli/yats) for the full architecture and source code.
122
+ See the [GitHub repository](https://github.com/fvinciarelli/yats.ai) for the full architecture and source code.
123
123
 
124
124
  ## CLI Reference
125
125
 
package/benchmark/run.sh CHANGED
@@ -211,8 +211,8 @@ if [ "$AGENT" = "gemini" ] || [ "$AGENT" = "copilot-cli" ] || [ "$AGENT" = "code
211
211
  {
212
212
  "mcpServers": {
213
213
  "yats": {
214
- "command": "node",
215
- "args": ["/home/franco/cosas/code_indexer/packages/yats-toolkit/benchmark/adapters/mcp-bridge-stdio.cjs", "--stdio"],
214
+ "command": "yats",
215
+ "args": ["bridge"],
216
216
  "trust": true
217
217
  }
218
218
  }
package/bin/setup.js CHANGED
@@ -11,8 +11,12 @@
11
11
  * yats clear <repo> # Delete indexed data
12
12
  * yats status # Check indexed repos
13
13
  * yats stop # Stop all YATS services
14
+ * yats start # Start YATS services
15
+ * yats update # Update CLI to latest version
16
+ * yats update-base # Update Docker images
14
17
  * yats bridge # MCP stdio ↔ HTTP proxy (for Copilot, Claude)
15
18
  * yats benchmark # AI agent token comparison
19
+ * yats watch <path> # Watch a repo and keep the index live
16
20
  */
17
21
 
18
22
  const cmd = process.argv[2] || "setup";
@@ -47,12 +51,24 @@ switch (cmd) {
47
51
  case "stop":
48
52
  import("../src/stop.js").then(m => m.default());
49
53
  break;
54
+ case "start":
55
+ import("../src/start.js").then(m => m.default());
56
+ break;
57
+ case "update":
58
+ import("../src/update.js").then(m => m.default());
59
+ break;
60
+ case "update-base":
61
+ import("../src/update-base.js").then(m => m.default());
62
+ break;
50
63
  case "bridge":
51
64
  import("../src/bridge.js");
52
65
  break;
53
66
  case "benchmark":
54
67
  import("../src/benchmark.js").then(m => m.runBenchmark());
55
68
  break;
69
+ case "watch":
70
+ import("../src/watch.js");
71
+ break;
56
72
  case "--version":
57
73
  case "-v":
58
74
  try {
@@ -74,7 +90,11 @@ switch (cmd) {
74
90
  console.log(` yats clear <repo> Delete indexed data`);
75
91
  console.log(` yats status Check indexed repos`);
76
92
  console.log(` yats stop Stop YATS services`);
93
+ console.log(` yats start Start YATS services`);
94
+ console.log(` yats update Update CLI to latest version`);
95
+ console.log(` yats update-base Update Docker images`);
77
96
  console.log(` yats bridge Stdio proxy for Copilot/Claude`);
78
97
  console.log(` yats benchmark AI agent token comparison`);
98
+ console.log(` yats watch <path> Keep index in sync with live edits`);
79
99
  break;
80
100
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "yats-toolkit",
3
- "version": "0.1.13",
3
+ "version": "0.1.20",
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",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/fvinciarelli/yats.git"
9
+ "url": "git+https://github.com/fvinciarelli/yats.ai.git"
10
10
  },
11
11
  "keywords": [
12
12
  "mcp",
package/src/setup.js CHANGED
@@ -31,7 +31,7 @@ const COMPOSE_FILE = join(YATS_DIR, "docker-compose.yml");
31
31
  const MCP_CONFIG_FILE = join(YATS_DIR, "mcp-config.json");
32
32
 
33
33
  const GITHUB_COMPOSE_URL =
34
- "https://raw.githubusercontent.com/fvinciarelli/yats/main/docker/docker-compose.yml";
34
+ "https://raw.githubusercontent.com/fvinciarelli/yats.ai/main/docker/docker-compose.yml";
35
35
 
36
36
  const B = "\x1b[1m";
37
37
  const D = "\x1b[2m";
@@ -81,7 +81,7 @@ const EMBEDDED_COMPOSE = `services:
81
81
  restart: unless-stopped
82
82
  __OLLAMA_PLACEHOLDER__
83
83
  yats:
84
- image: ghcr.io/fvinciarelli/yats:latest
84
+ image: ghcr.io/fvinciarelli/yats.ai:latest
85
85
  ports: ["__MCP_PORT__:__MCP_PORT__"]
86
86
  environment:
87
87
  - NEO4J_URI=bolt://neo4j:7687
@@ -588,7 +588,7 @@ async function main() {
588
588
  // Pull the YATS Docker image from GitHub Container Registry
589
589
  const sPull = spinner("Pulling YATS image from registry...");
590
590
  try {
591
- await runCmd("docker", ["pull", "ghcr.io/fvinciarelli/yats:latest"]);
591
+ await runCmd("docker", ["pull", "ghcr.io/fvinciarelli/yats.ai:latest"]);
592
592
  sPull.done(true);
593
593
  } catch {
594
594
  sPull.done(false);
@@ -670,7 +670,9 @@ async function main() {
670
670
  console.log(` yats add ~/work/project Add a repo to index`);
671
671
  console.log(` yats status Check what's indexed`);
672
672
  console.log(` yats stop Stop all services`);
673
- console.log(` yats update Update to latest version`);
673
+ console.log(` yats start Start all services`);
674
+ console.log(` yats update Update CLI to latest`);
675
+ console.log(` yats update-base Update Docker images`);
674
676
  console.log("");
675
677
  console.log(` Docs: ${C}https://yats.site${R}`);
676
678
  console.log("");
@@ -0,0 +1,55 @@
1
+ /** yats update-base — Update YATS Docker images to the latest version */
2
+ import { spawn } from "node:child_process";
3
+ import { join } from "node:path";
4
+ import { homedir } from "node:os";
5
+ import { createInterface } from "node:readline";
6
+
7
+ export default async function updateBase() {
8
+ const composeFile = join(homedir(), ".yats", "docker-compose.yml");
9
+ const B = "\x1b[1m";
10
+ const Y = "\x1b[33m";
11
+ const G = "\x1b[32m";
12
+ const R = "\x1b[0m";
13
+
14
+ console.log("");
15
+ console.log(` ${Y}${B}⚠️ This will:${R}`);
16
+ console.log(` • Stop all YATS containers (Neo4j, Qdrant, YATS server)`);
17
+ console.log(` • Pull the latest Docker images`);
18
+ console.log(` • Recreate containers with the new images`);
19
+ console.log("");
20
+ console.log(` ${G}✓${R} Your indexed data is preserved in Docker volumes.`);
21
+ console.log(` ${Y}⏳${R} Downtime: ~30-60 seconds.`);
22
+ console.log("");
23
+
24
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
25
+ const answer = await new Promise((resolve) => {
26
+ rl.question(` ${B}Proceed? [y/N]${R} `, resolve);
27
+ });
28
+ rl.close();
29
+
30
+ if (answer.toLowerCase() !== "y") {
31
+ console.log("");
32
+ console.log(" Cancelled.");
33
+ console.log("");
34
+ process.exit(0);
35
+ }
36
+
37
+ console.log("");
38
+ console.log(" Pulling latest images...");
39
+ await run("docker", ["compose", "-f", composeFile, "pull"]);
40
+
41
+ console.log(" Recreating containers...");
42
+ await run("docker", ["compose", "-f", composeFile, "up", "-d", "--force-recreate"]);
43
+
44
+ console.log("");
45
+ console.log(` ${G}✓${R} YATS base updated.`);
46
+ console.log("");
47
+ }
48
+
49
+ function run(cmd, args) {
50
+ return new Promise((resolve, reject) => {
51
+ const proc = spawn(cmd, args, { stdio: "inherit" });
52
+ proc.on("close", (code) => code === 0 ? resolve() : reject(new Error(`exit ${code}`)));
53
+ proc.on("error", reject);
54
+ });
55
+ }
package/src/update.js ADDED
@@ -0,0 +1,12 @@
1
+ /** yats update — Update YATS CLI to the latest version */
2
+ import { spawn } from "node:child_process";
3
+
4
+ export default async function update() {
5
+ console.log("Updating yats-toolkit to latest version...");
6
+ await new Promise((resolve, reject) => {
7
+ const proc = spawn("npm", ["install", "-g", "yats-toolkit@latest"], { stdio: "inherit" });
8
+ proc.on("close", (code) => code === 0 ? resolve() : reject(new Error(`exit ${code}`)));
9
+ proc.on("error", reject);
10
+ });
11
+ console.log("YATS CLI updated.");
12
+ }
package/src/watch.js ADDED
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * yats watch — file watcher that keeps the YATS index in sync with live edits.
4
+ *
5
+ * Usage:
6
+ * yats watch <path> [--repo <name>]
7
+ *
8
+ * Zero dependencies — uses Node.js built-in fs.watch and http.
9
+ */
10
+
11
+ import { watch, statSync, readFileSync } from "node:fs";
12
+ import { resolve, basename, relative } from "node:path";
13
+ import { request } from "node:http";
14
+
15
+ // ============================================================
16
+ // Config
17
+ // ============================================================
18
+
19
+ const YATS_URL = process.env.YATS_URL ?? "http://localhost:5555";
20
+ const DEBOUNCE_MS = parseInt(process.env.YATS_WATCH_DEBOUNCE ?? "500", 10);
21
+
22
+ const repoPath = resolve(process.argv[2] ?? process.cwd());
23
+ const repoArgIdx = process.argv.indexOf("--repo");
24
+ const repoName = repoArgIdx >= 0 ? process.argv[repoArgIdx + 1] : basename(repoPath);
25
+
26
+ if (!process.argv[2]) {
27
+ console.log("Usage: yats watch <path> [--repo <name>]");
28
+ console.log("");
29
+ console.log("Watches a directory and keeps the YATS index in sync.");
30
+ console.log("When files change, it tells the YATS server to re-index them.");
31
+ console.log("");
32
+ console.log(" yats watch ~/my-project");
33
+ console.log(" yats watch ~/my-project --repo my-api");
34
+ process.exit(1);
35
+ }
36
+
37
+ // ============================================================
38
+ // HTTP helpers
39
+ // ============================================================
40
+
41
+ function post(path, body) {
42
+ return new Promise((resolve, reject) => {
43
+ const data = JSON.stringify(body);
44
+ const url = new URL(path, YATS_URL);
45
+ const req = request(
46
+ {
47
+ hostname: url.hostname,
48
+ port: url.port,
49
+ path: url.pathname,
50
+ method: "POST",
51
+ headers: {
52
+ "Content-Type": "application/json",
53
+ "Content-Length": Buffer.byteLength(data),
54
+ },
55
+ },
56
+ (res) => {
57
+ let body = "";
58
+ res.on("data", (chunk) => (body += chunk));
59
+ res.on("end", () => {
60
+ if (res.statusCode === 200) {
61
+ resolve(body);
62
+ } else {
63
+ reject(new Error(`HTTP ${res.statusCode}: ${body}`));
64
+ }
65
+ });
66
+ },
67
+ );
68
+ req.on("error", reject);
69
+ req.write(data);
70
+ req.end();
71
+ });
72
+ }
73
+
74
+ async function indexFile(filePath) {
75
+ const rel = relative(repoPath, filePath);
76
+ console.log(` ↻ Indexing: ${rel}`);
77
+ try {
78
+ const content = readFileSync(filePath, "utf-8");
79
+ await post("/index/file", { path: filePath, content, repository: repoName });
80
+ console.log(` ✓ Done: ${rel}`);
81
+ } catch (err) {
82
+ console.error(` ✗ Failed: ${rel} — ${err.message}`);
83
+ }
84
+ }
85
+
86
+ async function removeFile(filePath) {
87
+ const rel = relative(repoPath, filePath);
88
+ console.log(` ↻ Removing from index: ${rel}`);
89
+ try {
90
+ await post("/index/remove", { path: filePath, repository: repoName });
91
+ console.log(` ✓ Removed: ${rel}`);
92
+ } catch (err) {
93
+ console.error(` ✗ Failed: ${rel} — ${err.message}`);
94
+ }
95
+ }
96
+
97
+ // ============================================================
98
+ // Debounced watcher
99
+ // ============================================================
100
+
101
+ const pending = new Map();
102
+ const SKIP_PATTERNS = [
103
+ /node_modules/,
104
+ /\.git\//,
105
+ /vendor\//,
106
+ /__pycache__/,
107
+ /\.next\//,
108
+ /dist\//,
109
+ /\.yarn\//,
110
+ ];
111
+
112
+ function shouldSkip(filename) {
113
+ if (!filename || filename.startsWith(".")) return true;
114
+ return SKIP_PATTERNS.some((p) => p.test(filename));
115
+ }
116
+
117
+ console.log(`👀 Watching: ${repoPath}`);
118
+ console.log(` Repo: ${repoName}`);
119
+ console.log(` Server: ${YATS_URL}`);
120
+ console.log(` (debounce: ${DEBOUNCE_MS}ms)`);
121
+ console.log("");
122
+
123
+ watch(repoPath, { recursive: true }, (eventType, filename) => {
124
+ if (!filename || shouldSkip(filename)) return;
125
+
126
+ const fullPath = resolve(repoPath, filename);
127
+
128
+ // Debounce: group rapid changes to the same file
129
+ const existing = pending.get(fullPath);
130
+ if (existing) clearTimeout(existing);
131
+
132
+ pending.set(
133
+ fullPath,
134
+ setTimeout(async () => {
135
+ pending.delete(fullPath);
136
+
137
+ // Check if file still exists (or was deleted)
138
+ try {
139
+ statSync(fullPath);
140
+ await indexFile(fullPath);
141
+ } catch {
142
+ await removeFile(fullPath);
143
+ }
144
+ }, DEBOUNCE_MS),
145
+ );
146
+ });
147
+
148
+ // Keep the process alive
149
+ process.stdin.resume();
150
+
151
+ // Clean shutdown
152
+ process.on("SIGINT", () => {
153
+ console.log("\n👋 Stopped watching.");
154
+ process.exit(0);
155
+ });