yats-toolkit 0.1.14 → 0.1.21
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 +105 -0
- package/package.json +1 -1
- package/src/remove.js +61 -0
- package/src/setup.js +5 -1
- package/src/update-base.js +55 -0
- package/src/update.js +12 -0
package/bin/setup.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
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 by name
|
|
12
|
+
* yats remove <path> # Delete indexed data by path
|
|
13
|
+
* yats status # Check indexed repos
|
|
14
|
+
* yats stop # Stop all YATS services
|
|
15
|
+
* yats start # Start YATS services
|
|
16
|
+
* yats update # Update CLI to latest version
|
|
17
|
+
* yats update-base # Update Docker images
|
|
18
|
+
* yats bridge # MCP stdio ↔ HTTP proxy (for Copilot, Claude)
|
|
19
|
+
* yats benchmark # AI agent token comparison
|
|
20
|
+
* yats watch <path> # Watch a repo and keep the index live
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const cmd = process.argv[2] || "setup";
|
|
24
|
+
const args = process.argv.slice(3);
|
|
25
|
+
|
|
26
|
+
switch (cmd) {
|
|
27
|
+
case "setup":
|
|
28
|
+
import("../src/setup.js").then(m => m.default());
|
|
29
|
+
break;
|
|
30
|
+
case "index":
|
|
31
|
+
case "add": {
|
|
32
|
+
const skipDocs = args.includes("--skip-docs");
|
|
33
|
+
const cleanArgs = args.filter(a => a !== "--skip-docs");
|
|
34
|
+
import("../src/indexer.js").then(m => m.default(cleanArgs, { skipDocs }));
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case "search":
|
|
38
|
+
import("../src/search.js").then(m => m.default(args));
|
|
39
|
+
break;
|
|
40
|
+
case "list":
|
|
41
|
+
import("../src/list.js").then(m => m.default());
|
|
42
|
+
break;
|
|
43
|
+
case "summary":
|
|
44
|
+
import("../src/summary.js").then(m => m.default(args));
|
|
45
|
+
break;
|
|
46
|
+
case "clear":
|
|
47
|
+
import("../src/clear.js").then(m => m.default(args));
|
|
48
|
+
break;
|
|
49
|
+
case "remove":
|
|
50
|
+
import("../src/remove.js").then(m => m.default(args));
|
|
51
|
+
break;
|
|
52
|
+
case "status":
|
|
53
|
+
import("../src/status.js").then(m => m.default());
|
|
54
|
+
break;
|
|
55
|
+
case "stop":
|
|
56
|
+
import("../src/stop.js").then(m => m.default());
|
|
57
|
+
break;
|
|
58
|
+
case "start":
|
|
59
|
+
import("../src/start.js").then(m => m.default());
|
|
60
|
+
break;
|
|
61
|
+
case "update":
|
|
62
|
+
import("../src/update.js").then(m => m.default());
|
|
63
|
+
break;
|
|
64
|
+
case "update-base":
|
|
65
|
+
import("../src/update-base.js").then(m => m.default());
|
|
66
|
+
break;
|
|
67
|
+
case "bridge":
|
|
68
|
+
import("../src/bridge.js");
|
|
69
|
+
break;
|
|
70
|
+
case "benchmark":
|
|
71
|
+
import("../src/benchmark.js").then(m => m.runBenchmark());
|
|
72
|
+
break;
|
|
73
|
+
case "watch":
|
|
74
|
+
import("../src/watch.js");
|
|
75
|
+
break;
|
|
76
|
+
case "--version":
|
|
77
|
+
case "-v":
|
|
78
|
+
try {
|
|
79
|
+
const { readFileSync } = await import("node:fs");
|
|
80
|
+
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
81
|
+
console.log(`yats v${pkg.version}`);
|
|
82
|
+
} catch {
|
|
83
|
+
console.log("yats v0.1.10");
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
console.log(`YATS Toolkit — Code intelligence for AI agents`);
|
|
88
|
+
console.log(``);
|
|
89
|
+
console.log(` yats setup Setup wizard`);
|
|
90
|
+
console.log(` yats index <path> Index a repository`);
|
|
91
|
+
console.log(` yats search <query> Search indexed code`);
|
|
92
|
+
console.log(` yats list List indexed repositories`);
|
|
93
|
+
console.log(` yats summary <repo> Show repository summary`);
|
|
94
|
+
console.log(` yats clear <repo> Delete indexed data by name`);
|
|
95
|
+
console.log(` yats remove <path> Delete indexed data by path`);
|
|
96
|
+
console.log(` yats status Check indexed repos`);
|
|
97
|
+
console.log(` yats stop Stop YATS services`);
|
|
98
|
+
console.log(` yats start Start YATS services`);
|
|
99
|
+
console.log(` yats update Update CLI to latest version`);
|
|
100
|
+
console.log(` yats update-base Update Docker images`);
|
|
101
|
+
console.log(` yats bridge Stdio proxy for Copilot/Claude`);
|
|
102
|
+
console.log(` yats benchmark AI agent token comparison`);
|
|
103
|
+
console.log(` yats watch <path> Keep index in sync with live edits`);
|
|
104
|
+
break;
|
|
105
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yats-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
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/remove.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* yats remove <path> — Delete a repository from the index by its path.
|
|
3
|
+
* Wraps the MCP delete_repository tool, accepting a directory path
|
|
4
|
+
* instead of requiring the exact repo name.
|
|
5
|
+
*/
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
|
|
8
|
+
const YATS_URL = process.env.YATS_URL || "http://localhost:5555";
|
|
9
|
+
|
|
10
|
+
async function mcpCall(tool, args = {}) {
|
|
11
|
+
const res = await fetch(`${YATS_URL}/mcp`, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: { "Content-Type": "application/json" },
|
|
14
|
+
body: JSON.stringify({
|
|
15
|
+
jsonrpc: "2.0",
|
|
16
|
+
id: 1,
|
|
17
|
+
method: "tools/call",
|
|
18
|
+
params: { name: tool, arguments: args },
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
const data = await res.json();
|
|
22
|
+
return data?.result?.content?.[0]?.text;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default async function remove(args) {
|
|
26
|
+
const rawPath = args[0];
|
|
27
|
+
if (!rawPath) {
|
|
28
|
+
console.error("Usage: yats remove <path>");
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const repoPath = resolve(rawPath);
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
// Step 1: ask for confirmation (using path, server resolves to repo)
|
|
36
|
+
console.log(`Looking up "${repoPath}"...`);
|
|
37
|
+
const warning = await mcpCall("delete_repository", { path: repoPath });
|
|
38
|
+
console.log(warning);
|
|
39
|
+
console.log("");
|
|
40
|
+
|
|
41
|
+
// Step 2: confirm
|
|
42
|
+
const readline = await import("node:readline");
|
|
43
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
44
|
+
const answer = await new Promise((resolve) => rl.question(" Confirm deletion? [y/N] ", resolve));
|
|
45
|
+
rl.close();
|
|
46
|
+
|
|
47
|
+
if (answer.toLowerCase() !== "y") {
|
|
48
|
+
console.log("Cancelled.");
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Step 3: execute
|
|
53
|
+
console.log("Deleting...");
|
|
54
|
+
const result = await mcpCall("delete_repository", { path: repoPath, confirm: true });
|
|
55
|
+
console.log(result);
|
|
56
|
+
console.log("");
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error(`Cannot reach YATS at ${YATS_URL}. Is it running?`);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/setup.js
CHANGED
|
@@ -669,8 +669,12 @@ async function main() {
|
|
|
669
669
|
console.log(` ${B}Commands:${R}`);
|
|
670
670
|
console.log(` yats add ~/work/project Add a repo to index`);
|
|
671
671
|
console.log(` yats status Check what's indexed`);
|
|
672
|
+
console.log(` yats clear <repo> Delete index by name`);
|
|
673
|
+
console.log(` yats remove <path> Delete index by path`);
|
|
672
674
|
console.log(` yats stop Stop all services`);
|
|
673
|
-
console.log(` yats
|
|
675
|
+
console.log(` yats start Start all services`);
|
|
676
|
+
console.log(` yats update Update CLI to latest`);
|
|
677
|
+
console.log(` yats update-base Update Docker images`);
|
|
674
678
|
console.log("");
|
|
675
679
|
console.log(` Docs: ${C}https://yats.site${R}`);
|
|
676
680
|
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
|
+
}
|