Lines 154-194javascript
155@cachlydev`);console.log(""),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 \u{1F9E0} Your cachly Brain invite link \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\ ...
156`))console.log(`\u2502 \x1B[90m${r.slice(0,58).padEnd(58)}\x1B[0m \u2502`);console.log("\u2502 \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 \x1B[36m\u{1D54F} ...
157\u274C Could not fetch invite link: ${t.message}
158`),process.exit(1)}process.exit(0)}if(process.argv[2]==="join"){const{writeFile:e,readFile:t,mkdir:n}=await import("node:fs/promises"),{existsSync:s}=await import("node:fs"),{resolve:o,
159\u274C Usage: npx @cachly-dev/mcp-server@latest join <token>
160`),console.log(` Get a token from a teammate: npx @cachly-dev/mcp-server@latest invite
161`),process.exit(1)),console.log(`
162\u23F3 Looking up invite...`);let l;try{const $=await fetch(`${_}/api/invite/${p}`,{signal:AbortSignal.timeout(8e3)});$.status===404&&(console.log(`
163\u274C Invite not found \u2014 the link may be invalid.
164`),process.exit(1)),$.status===410&&(console.log(`
165\u274C This invite link has expired (7-day limit).
166`),process.exit(1)),$.ok||(console.log(`
167\u274C Could not fetch invite: HTTP ${$.status}
168`),process.exit(1)),l=await $.json()}catch($){console.log(`
169\u274C Network error: ${$.message}
170`),process.exit(1)}const{instance_id:d,instance_name:y,tier:f,label:v}=l,h=new Date(l.expires_at).toLocaleDateString();console.log(""),console.log(" \x1B[35m\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\x1B[0m"),console.log(" \x1B[35m\u2551\x1B[0m \x1B
172`),process.exit(0));let b=x;if(!b){console.log(`
173 No API key found \u2014 starting sign-in (10 seconds)...
174`);try{const $=await fetch(`${_}/api/v1/auth/device/code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:"cachly-mcp-cli"}),signal:AbortSignal.timeout(1e4)});if($.ok){const k=await $.json();console.log(` \u{1F449} Open: \x1B[36m${k.verification_uri}\x1B[0m`),console.log(` Code: \x1B[1m${k.user_code}\x1B[0m
175`);const I=(k.interval??5)*1e3;for(let H=0;H<24;H++){await new Promise(T=>setTimeout(T,I));try{const T=await fetch(`${_}/api/v1/auth/device/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:k.device_code,client_id:"cachly-mcp-cli"}),signal:AbortSignal.timeout(8e3)});if(T.ok){const D=await T.json();if(D.access_token){b=D.access_token;break}}}catch{}}b||(console.log(`
176\u274C Sign-in timed out. Run the command again.
177`),process.exit(1)),console.log(` \u2705 Signed in!
178`)}}catch($){console.log(`
179 \u26A0\uFE0F Could not start sign-in: ${$.message}`),console.log(` Set CACHLY_JWT manually from ${N("/setup-ai","join")}
180`),process.exit(1)}}const g=process.cwd(),E=i(),B=[{label:".mcp.json (Claude Code project)",path:o(g,".mcp.json")},{label:".cursor/mcp.json",path:o(g,".cursor","mcp.json")},{label:".windsurf/mcp.json",path:o(g,".windsurf","mcp.json")},{label:".vscode/mcp.json (Copilot/Cline)",path:o(g,".vscode","mcp.json")},{label:"~/.claude/mcp.json (global)",path:o(E,".claude","mcp.json"),global:!0}];let C=0;for(const{label:$,path:k,global:I}of B){const H=a(k);if(!(!I&&!s(H)&&!s(k)))try{await n(H,{recursive:!0});let T={};if(s(k))try{T=JSON.parse(await t(k,"utf-8"))}catch{try{await(await import("node:fs/promi ...
181`),console.log(" \u{1F4DB} Add the badge to your README:"),console.log(` npx @cachly-dev/mcp-server@latest badge
182`)),process.exit(0)}if(process.argv[2]==="upgrade"){process.stdout.write(`
183\u23F3 Checking for updates...
184`);try{const e=await fetch("https://registry.npmjs.org/@cachly-dev/mcp-server/latest",{signal:AbortSignal.timeout(8e3)});if(!e.ok)throw new Error(`registry HTTP ${e.status}`);const n=(await e.json()).version;if(!n||!/^\d
185\u2705 Already on the latest version: \x1B[32mv${J}\x1B[0m
186`):(console.log(""),console.log("\x1B[35m \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\x1B[0m"),console.log("\x1B[35m \u2551\x1B[0m \x1B[1m\u{1F9E0} cachly update available\x1B[0m \x1B[35m
187\u274C Could not check for updates: ${e.message}
188`),process.exit(1)}process.exit(0)}if(process.argv[2]==="bench"){const{fileURLToPath:e}=await import("node:url"),{dirname:t,resolve:n}=await import("node:path"),{loadExternalCorpus:s,runExternalBenchmark:o}=await import("./bench/external-corpus.js"),a=process.argv.includes("--json"),i=process.argv.slice(3).find(l=>!l.startsWith("--")),r=t(e(import.meta.url)),p=i?n(process.cwd(),i):n(r,"bench","external","sample-corpus.json");try{const l=await s(p),d=await o(l);a&&(console.log(JSON.stringify({corpus:l.name,lessons:d.corpusSize,queries:d.queryCount,cachly_p1:Math.round(d.cachly.precisionAt1*1e3) ...
189\u274C bench failed: ${l.message}
190`),process.exit(1)}process.exit(0)}if(process.argv[2]==="demo"){const{execSync:e}=await import("node:child_process"),{existsSync:t,readFileSync:n}=await import("node:fs"),{resolve:s,basename:o}=await
191\x1B[35m\u{1F9E0} cachly Brain \u2014 Live Demo\x1B[0m`),console.log(`\x1B[90mNo account needed. Reading your git history...\x1B[0m
HighCommand Output Exfiltration
Source combines command execution, command-output handling, and outbound requests; review data flow before blocking.
dist/src/index.jsView on unpkg · L174 192`),t(s(a,".git"))||(console.log("\u26A0\uFE0F No git repository found here."),console.log(` Run this command inside a project directory with git history.
193`),console.log(` Example: cd ~/my-project && npx @cachly-dev/mcp-server@latest demo
194`),process.exit(0));let i="";try{i=e("git config user.name",{cwd:a,encoding:"utf-8",stdio:"pipe"}).trim().split(" ")[0]??""}catch{}let r=o(a);try{const S=JSON.parse(n(s(a,"package.json"),
Long lines were clipped for display.