yats-toolkit 0.1.13 → 0.1.14
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 +1 -1
- package/benchmark/run.sh +2 -2
- package/package.json +2 -2
- package/src/setup.js +3 -3
- package/src/watch.js +155 -0
- package/bin/setup.js +0 -80
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": "
|
|
215
|
-
"args": ["
|
|
214
|
+
"command": "yats",
|
|
215
|
+
"args": ["bridge"],
|
|
216
216
|
"trust": true
|
|
217
217
|
}
|
|
218
218
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yats-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
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);
|
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
|
+
});
|
package/bin/setup.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* YATS Toolkit — Code intelligence for AI agents.
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* yats setup # One-time setup wizard
|
|
7
|
-
* yats index <path> # Index a repository
|
|
8
|
-
* yats search <query> # Search indexed code
|
|
9
|
-
* yats list # List indexed repositories
|
|
10
|
-
* yats summary <repo> # Show repository summary
|
|
11
|
-
* yats clear <repo> # Delete indexed data
|
|
12
|
-
* yats status # Check indexed repos
|
|
13
|
-
* yats stop # Stop all YATS services
|
|
14
|
-
* yats bridge # MCP stdio ↔ HTTP proxy (for Copilot, Claude)
|
|
15
|
-
* yats benchmark # AI agent token comparison
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const cmd = process.argv[2] || "setup";
|
|
19
|
-
const args = process.argv.slice(3);
|
|
20
|
-
|
|
21
|
-
switch (cmd) {
|
|
22
|
-
case "setup":
|
|
23
|
-
import("../src/setup.js").then(m => m.default());
|
|
24
|
-
break;
|
|
25
|
-
case "index":
|
|
26
|
-
case "add": {
|
|
27
|
-
const skipDocs = args.includes("--skip-docs");
|
|
28
|
-
const cleanArgs = args.filter(a => a !== "--skip-docs");
|
|
29
|
-
import("../src/indexer.js").then(m => m.default(cleanArgs, { skipDocs }));
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case "search":
|
|
33
|
-
import("../src/search.js").then(m => m.default(args));
|
|
34
|
-
break;
|
|
35
|
-
case "list":
|
|
36
|
-
import("../src/list.js").then(m => m.default());
|
|
37
|
-
break;
|
|
38
|
-
case "summary":
|
|
39
|
-
import("../src/summary.js").then(m => m.default(args));
|
|
40
|
-
break;
|
|
41
|
-
case "clear":
|
|
42
|
-
import("../src/clear.js").then(m => m.default(args));
|
|
43
|
-
break;
|
|
44
|
-
case "status":
|
|
45
|
-
import("../src/status.js").then(m => m.default());
|
|
46
|
-
break;
|
|
47
|
-
case "stop":
|
|
48
|
-
import("../src/stop.js").then(m => m.default());
|
|
49
|
-
break;
|
|
50
|
-
case "bridge":
|
|
51
|
-
import("../src/bridge.js");
|
|
52
|
-
break;
|
|
53
|
-
case "benchmark":
|
|
54
|
-
import("../src/benchmark.js").then(m => m.runBenchmark());
|
|
55
|
-
break;
|
|
56
|
-
case "--version":
|
|
57
|
-
case "-v":
|
|
58
|
-
try {
|
|
59
|
-
const { readFileSync } = await import("node:fs");
|
|
60
|
-
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
61
|
-
console.log(`yats v${pkg.version}`);
|
|
62
|
-
} catch {
|
|
63
|
-
console.log("yats v0.1.10");
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
console.log(`YATS Toolkit — Code intelligence for AI agents`);
|
|
68
|
-
console.log(``);
|
|
69
|
-
console.log(` yats setup Setup wizard`);
|
|
70
|
-
console.log(` yats index <path> Index a repository`);
|
|
71
|
-
console.log(` yats search <query> Search indexed code`);
|
|
72
|
-
console.log(` yats list List indexed repositories`);
|
|
73
|
-
console.log(` yats summary <repo> Show repository summary`);
|
|
74
|
-
console.log(` yats clear <repo> Delete indexed data`);
|
|
75
|
-
console.log(` yats status Check indexed repos`);
|
|
76
|
-
console.log(` yats stop Stop YATS services`);
|
|
77
|
-
console.log(` yats bridge Stdio proxy for Copilot/Claude`);
|
|
78
|
-
console.log(` yats benchmark AI agent token comparison`);
|
|
79
|
-
break;
|
|
80
|
-
}
|