yats-toolkit 0.2.0 → 0.2.1
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 +68 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yats-toolkit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
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/setup.js
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { spawn } from "node:child_process";
|
|
12
|
-
import { writeFileSync, mkdirSync, existsSync, readFileSync, statSync } from "node:fs";
|
|
13
|
-
import { homedir } from "node:os";
|
|
12
|
+
import { writeFileSync, mkdirSync, existsSync, readFileSync, statSync, chmodSync } from "node:fs";
|
|
13
|
+
import { homedir, platform } from "node:os";
|
|
14
14
|
import { join, resolve } from "node:path";
|
|
15
15
|
import { createInterface } from "node:readline";
|
|
16
16
|
|
|
@@ -29,6 +29,7 @@ const YATS_DIR = join(homedir(), ".yats");
|
|
|
29
29
|
const REPOS_DIR = join(YATS_DIR, "repos");
|
|
30
30
|
const COMPOSE_FILE = join(YATS_DIR, "docker-compose.yml");
|
|
31
31
|
const MCP_CONFIG_FILE = join(YATS_DIR, "mcp-config.json");
|
|
32
|
+
const YATS_BIN_DIR = join(YATS_DIR, "bin");
|
|
32
33
|
|
|
33
34
|
const GITHUB_COMPOSE_URL =
|
|
34
35
|
"https://raw.githubusercontent.com/fvinciarelli/yats.ai/main/docker/docker-compose.yml";
|
|
@@ -766,42 +767,83 @@ async function main(options = {}) {
|
|
|
766
767
|
}
|
|
767
768
|
}
|
|
768
769
|
|
|
770
|
+
// Install YATS CLI globally (or to ~/.yats/bin if global fails)
|
|
771
|
+
const sCli = spinner("Installing YATS CLI...");
|
|
772
|
+
try {
|
|
773
|
+
const osPlatform = platform();
|
|
774
|
+
mkdirSync(YATS_BIN_DIR, { recursive: true });
|
|
775
|
+
|
|
776
|
+
if (osPlatform === "win32") {
|
|
777
|
+
// Windows: create a .cmd wrapper
|
|
778
|
+
const cmdScript = `@echo off\r\nnpx yats %*\r\n`;
|
|
779
|
+
writeFileSync(join(YATS_BIN_DIR, "yats.cmd"), cmdScript);
|
|
780
|
+
} else {
|
|
781
|
+
// Linux/macOS: create a shell wrapper
|
|
782
|
+
const shScript = `#!/usr/bin/env bash\nnpx yats "$@"\n`;
|
|
783
|
+
writeFileSync(join(YATS_BIN_DIR, "yats"), shScript);
|
|
784
|
+
chmodSync(join(YATS_BIN_DIR, "yats"), 0o755);
|
|
785
|
+
}
|
|
786
|
+
sCli.done(true);
|
|
787
|
+
|
|
788
|
+
// Add to PATH
|
|
789
|
+
const rcFiles = [];
|
|
790
|
+
if (osPlatform !== "win32") {
|
|
791
|
+
// Try .bashrc and .zshrc
|
|
792
|
+
const bashrc = join(homedir(), ".bashrc");
|
|
793
|
+
const zshrc = join(homedir(), ".zshrc");
|
|
794
|
+
if (existsSync(bashrc)) rcFiles.push(bashrc);
|
|
795
|
+
if (existsSync(zshrc)) rcFiles.push(zshrc);
|
|
796
|
+
if (rcFiles.length === 0) rcFiles.push(bashrc); // if neither exists, create .bashrc
|
|
797
|
+
|
|
798
|
+
const exportLine = `\nexport PATH="$HOME/.yats/bin:$PATH" # YATS CLI\n`;
|
|
799
|
+
for (const rc of rcFiles) {
|
|
800
|
+
const content = existsSync(rc) ? readFileSync(rc, "utf-8") : "";
|
|
801
|
+
if (!content.includes(".yats/bin")) {
|
|
802
|
+
writeFileSync(rc, content + exportLine);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
} else {
|
|
806
|
+
// Windows: use setx (no visual feedback needed for the spinner)
|
|
807
|
+
// setx is best-effort; user may need admin
|
|
808
|
+
try {
|
|
809
|
+
await runCmd("setx", ["PATH", `${YATS_BIN_DIR};%PATH%`]);
|
|
810
|
+
} catch {}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
console.log(` ${G}✓${R} CLI installed to ${C}${YATS_BIN_DIR}${R}`);
|
|
814
|
+
if (osPlatform !== "win32") {
|
|
815
|
+
const names = rcFiles.map(f => f.split("/").pop()).join(" and ");
|
|
816
|
+
console.log(` ${Y}⚠${R} Added ${C}~/.yats/bin${R} to your ${C}${names}${R}`);
|
|
817
|
+
console.log(` ${Y}⚠${R} Run ${B}source ${names.includes("zshrc") ? "~/.zshrc" : "~/.bashrc"}${R} or restart your terminal`);
|
|
818
|
+
console.log(` ${Y}⚠${R} for the ${B}yats${R} command to be available.`);
|
|
819
|
+
}
|
|
820
|
+
} catch (e) {
|
|
821
|
+
sCli.done(false);
|
|
822
|
+
}
|
|
823
|
+
|
|
769
824
|
// Done
|
|
770
825
|
console.log("");
|
|
771
|
-
console.log(` ✅ ${G}YATS is ready!${R}`);
|
|
772
|
-
divider();
|
|
826
|
+
console.log(` ✅ ${G}YATS is ready!${R} → ${C}http://localhost:${mcpPort}/mcp/sse${R}`);
|
|
773
827
|
console.log("");
|
|
774
|
-
console.log(`
|
|
828
|
+
console.log(` Config saved to ${C}~/.yats/.env${R}`);
|
|
775
829
|
console.log("");
|
|
776
830
|
box([
|
|
777
|
-
`${B}
|
|
831
|
+
`${B}Copy this URL into your AI agent:${R}`,
|
|
778
832
|
`{ "url": "http://localhost:${mcpPort}/mcp/sse" }`,
|
|
779
833
|
"",
|
|
780
|
-
`${B}
|
|
834
|
+
`${B}Copilot / Claude Desktop:${R}`,
|
|
781
835
|
`{ "command": "npx", "args": ["yats-bridge"] }`,
|
|
836
|
+
"",
|
|
837
|
+
`${D}For more: yats connect${R}`,
|
|
838
|
+
`${C}https://github.com/fvinciarelli/yats.ai/tree/master/connect${R}`,
|
|
782
839
|
]);
|
|
783
840
|
console.log("");
|
|
784
|
-
console.log(`
|
|
785
|
-
divider();
|
|
786
|
-
console.log("");
|
|
787
|
-
console.log(` ${B}Try it now:${R}`);
|
|
788
|
-
console.log("");
|
|
789
|
-
console.log(` Open your project in your AI agent and ask:`);
|
|
790
|
-
console.log(` ${C}"how does authentication work in this project?"${R}`);
|
|
791
|
-
console.log("");
|
|
792
|
-
console.log(` YATS will auto-index on the first search.`);
|
|
841
|
+
console.log(` ${B}Try:${R} ${C}"how does auth work in this project?"${R}`);
|
|
793
842
|
console.log("");
|
|
794
|
-
console.log(` ${B}Commands:${R}`);
|
|
795
|
-
console.log(`
|
|
796
|
-
console.log(` yats clear <repo> Delete index by name`);
|
|
797
|
-
console.log(` yats remove <path> Delete index by path`);
|
|
798
|
-
console.log(` yats stop Stop all services`);
|
|
799
|
-
console.log(` yats start Start all services`);
|
|
800
|
-
console.log(` yats update Update CLI to latest`);
|
|
801
|
-
console.log(` yats update-base Update Docker images`);
|
|
802
|
-
console.log(` yats connect Set up your AI agent`);
|
|
843
|
+
console.log(` ${B}Commands:${R} yats status | yats clear | yats stop/start`);
|
|
844
|
+
console.log(` yats update | yats connect`);
|
|
803
845
|
console.log("");
|
|
804
|
-
console.log(` Docs:
|
|
846
|
+
console.log(` Docs: ${C}https://fvinciarelli.github.io/yats.ai/${R} · ${C}https://yats.site${R}`);
|
|
805
847
|
console.log("");
|
|
806
848
|
}
|
|
807
849
|
export default main;
|