yats-toolkit 0.2.0 → 0.2.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/setup.js +69 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yats-toolkit",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
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";
@@ -153,6 +154,7 @@ function pad(s) {
153
154
  /** Center text within width, preserving ANSI codes */
154
155
  function center(text, width = W) {
155
156
  const vlen = visibleLen(text);
157
+ if (vlen >= width) return text;
156
158
  const left = Math.floor((width - vlen) / 2);
157
159
  const right = width - vlen - left;
158
160
  return " ".repeat(left) + text + " ".repeat(right);
@@ -766,42 +768,83 @@ async function main(options = {}) {
766
768
  }
767
769
  }
768
770
 
771
+ // Install YATS CLI globally (or to ~/.yats/bin if global fails)
772
+ const sCli = spinner("Installing YATS CLI...");
773
+ try {
774
+ const osPlatform = platform();
775
+ mkdirSync(YATS_BIN_DIR, { recursive: true });
776
+
777
+ if (osPlatform === "win32") {
778
+ // Windows: create a .cmd wrapper
779
+ const cmdScript = `@echo off\r\nnpx yats %*\r\n`;
780
+ writeFileSync(join(YATS_BIN_DIR, "yats.cmd"), cmdScript);
781
+ } else {
782
+ // Linux/macOS: create a shell wrapper
783
+ const shScript = `#!/usr/bin/env bash\nnpx yats "$@"\n`;
784
+ writeFileSync(join(YATS_BIN_DIR, "yats"), shScript);
785
+ chmodSync(join(YATS_BIN_DIR, "yats"), 0o755);
786
+ }
787
+ sCli.done(true);
788
+
789
+ // Add to PATH
790
+ const rcFiles = [];
791
+ if (osPlatform !== "win32") {
792
+ // Try .bashrc and .zshrc
793
+ const bashrc = join(homedir(), ".bashrc");
794
+ const zshrc = join(homedir(), ".zshrc");
795
+ if (existsSync(bashrc)) rcFiles.push(bashrc);
796
+ if (existsSync(zshrc)) rcFiles.push(zshrc);
797
+ if (rcFiles.length === 0) rcFiles.push(bashrc); // if neither exists, create .bashrc
798
+
799
+ const exportLine = `\nexport PATH="$HOME/.yats/bin:$PATH" # YATS CLI\n`;
800
+ for (const rc of rcFiles) {
801
+ const content = existsSync(rc) ? readFileSync(rc, "utf-8") : "";
802
+ if (!content.includes(".yats/bin")) {
803
+ writeFileSync(rc, content + exportLine);
804
+ }
805
+ }
806
+ } else {
807
+ // Windows: use setx (no visual feedback needed for the spinner)
808
+ // setx is best-effort; user may need admin
809
+ try {
810
+ await runCmd("setx", ["PATH", `${YATS_BIN_DIR};%PATH%`]);
811
+ } catch {}
812
+ }
813
+
814
+ console.log(` ${G}✓${R} CLI installed to ${C}${YATS_BIN_DIR}${R}`);
815
+ if (osPlatform !== "win32") {
816
+ const names = rcFiles.map(f => f.split("/").pop()).join(" and ");
817
+ console.log(` ${Y}⚠${R} Added ${C}~/.yats/bin${R} to your ${C}${names}${R}`);
818
+ console.log(` ${Y}⚠${R} Run ${B}source ${names.includes("zshrc") ? "~/.zshrc" : "~/.bashrc"}${R} or restart your terminal`);
819
+ console.log(` ${Y}⚠${R} for the ${B}yats${R} command to be available.`);
820
+ }
821
+ } catch (e) {
822
+ sCli.done(false);
823
+ }
824
+
769
825
  // Done
770
826
  console.log("");
771
- console.log(` ✅ ${G}YATS is ready!${R}`);
772
- divider();
827
+ console.log(` ✅ ${G}YATS is ready!${R} → ${C}http://localhost:${mcpPort}/mcp/sse${R}`);
773
828
  console.log("");
774
- console.log(` ${B}Next step — connect your AI agent:${R}`);
829
+ console.log(` Config saved to ${C}~/.yats/.env${R}`);
775
830
  console.log("");
776
831
  box([
777
- `${B}For Cursor, Zed, Cline, Continue.dev, Roo Code:${R}`,
832
+ `${B}Copy this URL into your AI agent:${R}`,
778
833
  `{ "url": "http://localhost:${mcpPort}/mcp/sse" }`,
779
834
  "",
780
- `${B}For Copilot, Claude Desktop (stdio only):${R}`,
835
+ `${B}Copilot / Claude Desktop:${R}`,
781
836
  `{ "command": "npx", "args": ["yats-bridge"] }`,
837
+ "",
838
+ `${D}For more: yats connect${R}`,
839
+ `${C}github.com/fvinciarelli/yats.ai/connect${R}`,
782
840
  ]);
783
841
  console.log("");
784
- console.log(` Config saved to ${C}${MCP_CONFIG_FILE}${R}`);
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.`);
842
+ console.log(` ${B}Try:${R} ${C}"how does auth work in this project?"${R}`);
793
843
  console.log("");
794
- console.log(` ${B}Commands:${R}`);
795
- console.log(` yats status Check what's indexed`);
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`);
844
+ console.log(` ${B}Commands:${R} yats status | yats clear | yats stop/start`);
845
+ console.log(` yats update | yats connect`);
803
846
  console.log("");
804
- console.log(` Docs: ${C}https://yats.site${R}`);
847
+ console.log(` Docs: ${C}https://fvinciarelli.github.io/yats.ai/${R} · ${C}https://yats.site${R}`);
805
848
  console.log("");
806
849
  }
807
850
  export default main;