magicpath-ai 2.4.1 → 2.4.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/dist/cli.js +1 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{readFileSync as qr}from"fs";import{dirname as Xr,join as Yr}from"path";import{fileURLToPath as Zr}from"url";import{program as T}from"commander";import et from"axios";var p=class extends Error{code;suggestion;constructor(n,t){super(n),this.code=t==null?void 0:t.code,this.suggestion=t==null?void 0:t.suggestion}};function Ut(e){if(!(!e||typeof e!="object"))return e}function M(e){var n,t,o;if(e instanceof p)return e;if(et.isAxiosError(e)){let r=Ut((n=e.response)==null?void 0:n.data),s=typeof(r==null?void 0:r.message)=="string"?r.message:e.response?`API error: ${e.response.status} ${e.response.statusText}`:e.message,i=typeof(r==null?void 0:r.code)=="string"?r.code:void 0,c=typeof((t=r==null?void 0:r.details)==null?void 0:t.billing_url)=="string"?r.details.billing_url:typeof((o=r==null?void 0:r.details)==null?void 0:o.billingUrl)=="string"?r.details.billingUrl:void 0,a=typeof(r==null?void 0:r.suggestion)=="string"?r.suggestion:i==="GUEST_FORBIDDEN"?"Guest sessions are scoped to one project. Sign up at https://magicpath.ai to unlock this.":c?"Upgrade to Pro from billing to keep using external agents.":void 0;return new p(s,{code:i,...a?{suggestion:a}:{}})}return e instanceof Error?new p(e.message):new p(String(e))}function Ft(){et.interceptors.response.use(e=>e,e=>{var n;if(et.isAxiosError(e)){let t=Ut((n=e.response)==null?void 0:n.data);if(typeof(t==null?void 0:t.code)=="string")return Promise.reject(M(e))}return Promise.reject(e)})}var Mt=!1;function Dt(e){Mt=e}function x(){return Mt}function b(e){console.log(JSON.stringify(e,null,2)),process.exit(0)}function E(e){let t={error:e instanceof Error?e.message:String(e)};e instanceof p&&(e.code&&(t.code=e.code),e.suggestion&&(t.suggestion=e.suggestion)),console.error(JSON.stringify(t,null,2)),process.exit(1)}var B="0.0.0-dev";function _t(e){B=e}import ie from"chalk";import ye from"fs-extra";import an from"path";import Ro from"os";import cn from"axios";var A=process.env.MAGICPATH_API_URL??"https://api.magicpath.ai";function ke(e,n){return`${A}/${e}/${n}`}function Lt(e){return`${A}/v1/registry/${e}`}var Ao=process.env.MAGICPATH_WEB_URL??"https://www.magicpath.ai";function Pe(e){return`${Ao}${e}`}function Wt(e){return Pe(`/files/${e}`)}function Ae(e,n){return Pe(`/projects/${e}?guest=${encodeURIComponent(n)}`)}function Te(e){return`${A}/auth/${e}`}function tt(){return`${A}/v1/external-agent/components`}function nt(e){return`${A}/v1/external-agent/components/${e}/context`}function Ht(e){return`${A}/v1/external-agent/components/${e}/start`}function Gt(e){return`${A}/v1/external-agent/components/${e}/revisions`}function ot(e,n){return`${A}/v1/external-agent/components/${e}/revisions/${n}/files`}function rt(e){return`${A}/v1/external-agent/jobs/${e}`}function Q(){return`${A}/users/me`}function st(){return`${A}/users/me/projects`}function it(){return`${A}/users/me/skills`}function Vt(){return`${A}/users/me/skills/import`}function zt(){return`${A}/users/me/assets/upload-url`}function Jt(){return`${A}/projects`}function Ne(e){return`${A}/projects/${e}`}function Bt(e){return`${A}/projects/${e}/components`}function at(e){return`${A}/projects/${e}/images`}function Re(){return`${A}/users/me/design-systems`}function Kt(e){return`${A}/design-systems/${e}`}function re(){return`${A}/users/me/socket-rooms`}function qt(){return`${A}/liveblocks/auth`}function Xt(e){return`${A}/components/${e}`}function Yt(){return`${A}/components/search`}function Zt(e){return`${A}/organizations/${e}`}function ct(e){return`${A}/organizations/${e}/projects`}function lt(e){return`${A}/organizations/${e}/skills`}function Qt(e){return`${A}/organizations/${e}/skills/import`}function Oe(e){return`${A}/organizations/${e}/design-systems`}function mt(e){return`${A}/skills/${e}`}function en(e){return`${A}/skills/${e}/files`}function tn(e,n){return`${A}/skills/${e}/files/content?path=${encodeURIComponent(n)}`}var To=[{type:"claude-code",envVar:"CLAUDECODE"},{type:"cursor",envVar:"CURSOR_TRACE_ID"},{type:"cursor",envVar:"CURSOR_AGENT"},{type:"codex",envVar:"CODEX_SANDBOX"},{type:"codex",envVar:"CODEX_THREAD_ID"},{type:"codex",envVar:"CODEX_CI"},{type:"gemini",envVar:"GEMINI_CLI"},{type:"antigravity",envVar:"ANTIGRAVITY_AGENT"},{type:"augment",envVar:"AUGMENT_AGENT"},{type:"opencode",envVar:"OPENCODE_CLIENT"},{type:"copilot",envVar:"COPILOT_MODEL"},{type:"cline",envVar:"CLINE_ACTIVE"},{type:"replit",envVar:"REPL_ID"},{type:"goose",envVar:"GOOSE_TERMINAL"}],Ue={"claude-code":"claude-code",claude:"claude-code",cursor:"cursor","cursor-agent":"cursor",codex:"codex","codex-cli":"codex",gemini:"gemini","gemini-cli":"gemini",antigravity:"antigravity",augment:"augment",opencode:"opencode",copilot:"copilot","github-copilot":"copilot","github-copilot-cli":"copilot",cline:"cline",replit:"replit",v0:"v0",devin:"devin",aider:"aider",goose:"goose",amp:"amp"};function nn(e){let n=e.trim();if(!n)return null;let t=n.indexOf("@");if(t===-1)return{slug:n.toLowerCase()};let o=n.slice(0,t).trim().toLowerCase(),r=n.slice(t+1).trim()||void 0;return o?{slug:o,version:r}:null}function on(e){if(e in Ue)return Ue[e];for(let n of Object.keys(Ue))if(e.startsWith(`${n}_`)||e.startsWith(`${n}-`))return Ue[n];return e}var Fe;function rn(){return Fe||(Fe=No(),Fe)}function No(){let e=process.env.MAGICPATH_AGENT;if(e){let t=nn(e);if(t)return{kind:"known-agent",slug:on(t.slug),version:t.version}}for(let t of To){let o=process.env[t.envVar];if(o&&o!=="0"&&o.toLowerCase()!=="false")return{kind:"known-agent",slug:t.type}}let n=process.env.AI_AGENT;if(n){let t=nn(n);if(t)return{kind:"known-agent",slug:on(t.slug),version:t.version}}return process.stdin.isTTY?{kind:"interactive-human"}:{kind:"unknown-agent"}}function sn(e){switch(e.kind){case"known-agent":return{type:e.slug,version:e.version};case"interactive-human":return{type:"interactive"};case"unknown-agent":return{}}}var ln=an.join(Ro.homedir(),".magicpath"),Me=an.join(ln,"session.json");function ee(){try{if(!ye.existsSync(Me))return null;let e=ye.readJsonSync(Me);return e.accessToken&&(e.refreshToken||e.guest)?e:null}catch{return null}}function dt(e){ye.ensureDirSync(ln),ye.writeJsonSync(Me,e)}function pt(e,n){let t=ee();dt({accessToken:e,refreshToken:n,user:t==null?void 0:t.user})}function mn(e,n){dt({accessToken:e,guest:n})}function se(){let e=ee();return e?{accessToken:e.accessToken,refreshToken:e.refreshToken}:null}function De(){let e=ee();return(e==null?void 0:e.guest)??null}function dn(){let e=ee();return e!=null&&e.guest?Ae(e.guest.projectId,e.accessToken):null}function pn(){try{ye.removeSync(Me)}catch{}}function Oo(e){try{let n=ee();n&&(n.user=e,dt(n))}catch{}}function gn(){let e=ee();return(e==null?void 0:e.user)??null}function j(){let{type:e,version:n}=sn(rn()),t={"X-Client-Type":"cli","X-Client-Version":B};e&&(t["X-Agent-Type"]=e),n&&(t["X-Agent-Version"]=n);let o=process.env.MAGICPATH_TOKEN;if(o)return t.Authorization=`Bearer ${o}`,t;let r=ee();if(!r)throw new Error("Not logged in. Run `magicpath-ai login` first.");if(r.guest&&Date.parse(r.guest.expiresAt)<Date.now())throw new p("Your guest session has expired. Sign up at https://magicpath.ai to keep building.",{code:"GUEST_EXPIRED",suggestion:"Sign up at https://magicpath.ai or start a new guest project from the MagicPath site."});return t.Authorization=`Bearer ${r.accessToken}`,t}function Ie(e){var o,r;let n=(o=e.subscription)!=null&&o.active?(r=e.subscription.type)!=null&&r.startsWith("PRO")?"Pro":"Creator":"Free",t={name:e.name||e.firstName||e.displayName,email:e.email,plan:n};return Oo(t),t}async function gt(){let e=j(),n=await cn.get(Q(),{headers:e}),t=n.data.user??n.data;return Ie(t)}async function be(e){let n=await cn.get(Q(),{headers:e});return((n.data.user??n.data).organizationUsers??[]).map(r=>({id:String(r.organization.id),name:r.organization.name,role:r.role}))}async function _(e,n){let t=await be(n),o=t.find(i=>i.id===e);if(o)return{id:o.id,name:o.name};let r=e.toLowerCase(),s=t.find(i=>i.name.toLowerCase()===r);if(s)return{id:s.id,name:s.name};throw new p(`Team "${e}" not found.`,{code:"TEAM_NOT_FOUND",suggestion:"Run `magicpath-ai list-teams` to see your teams."})}var un=["#95D5B2","#74C69D","#52B788","#40916C","#2D6A4F","#1B4332"];function Uo(e){return ie.hex(un[Math.min(e,un.length-1)])}var ut=ie.hex("#2D6A4F"),Fo=ie.hex("#1B4332"),Mo=ie.hex("#E8F5E9"),ft=ie.hex("#888888"),Do=["\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557","\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D","\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 ","\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551 ","\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557","\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D"],_o=["\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551","\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551","\u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551","\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D"],Lo=Do.map((e,n)=>e+" "+_o[n]);function Wo(e){return e.map((n,t)=>{let o=Uo(t),r="";for(let s of n)r+=s===" "?s:o(s);return r})}function fn(e){let n=!!se(),t=n?gn():null;console.log();for(let s of Wo(Lo))console.log(s);if(console.log(),n&&t){let s=t.plan?` \xB7 ${t.plan}`:"";console.log(" "+ut("\u25CF")+" "+ie.bold(Mo(t.name??"MagicPath User"))+Fo(" "+(t.email??"")+s))}else console.log(" "+ft("\u25CB Not logged in \xB7 run")+" "+ut("magicpath-ai login"));console.log();let o=20,r=[["search <query>","Search components"],["add <name>","Add to project"],["list-projects","Your projects"],["setup-skills","Set up AI agents"]];for(let[s,i]of r)console.log(" "+ut(s.padEnd(o))+ft(i));console.log(),console.log(" "+ft(`v${e} \u2500 magicpath-ai --help`)),console.log()}import Le from"prompts";import Pn from"ora";import{z as le}from"zod";import me from"path";import Yo from"os";import yt from"fs-extra";import{pino as hn}from"pino";var ae=hn();function ce(){ae=hn({level:"debug"}),ae.debug({message:"DEBUG logger enabled. "})}var R={info:e=>{ae.info(e)},debug:e=>{ae.debug(e)},warn:e=>{ae.warn(e)},error:e=>{ae.error(e)}};import wn from"axios";import _e from"path";import Go from"os";import{Readable as Vo}from"stream";import $e from"fs-extra";import zo from"adm-zip";import{v4 as Jo}from"uuid";async function Bo(e){if(!(e instanceof Vo))return;let n=[];return new Promise((t,o)=>{e.on("data",r=>{n.push(Buffer.isBuffer(r)?r:Buffer.from(r))}),e.on("error",o),e.on("end",()=>t(Buffer.concat(n).toString("utf8")))})}async function Ko(e){var n;if(e instanceof p)return e;if(wn.isAxiosError(e)){let t=await Bo((n=e.response)==null?void 0:n.data);if(t)try{let o=JSON.parse(t);return M({...e,response:{...e.response,data:o},isAxiosError:!0})}catch{}return M(e)}return new p("Failed to download project. Make sure your key is valid.")}async function yn(e){let n=ke("v1","components/repository"),t=`${Jo()}.zip`,o=_e.join(Go.tmpdir(),t);try{let r=await wn({url:n,params:{key:e},method:"GET",responseType:"stream"});return await $e.ensureDir(_e.dirname(o)),await new Promise(async(s,i)=>{try{r.data.pipe($e.createWriteStream(o)).on("error",i).once("close",()=>s(o))}catch(c){i(c)}}),o}catch(r){throw await Ko(r)}}function ht(e){try{$e.removeSync(e)}catch{}}function In(e,n,t){try{let o=_e.join(t,n),r=1;for(;$e.existsSync(o);)r++,o=_e.join(t,`${n}-${r}`);return $e.mkdirSync(o,{recursive:!0}),new zo(e).extractAllTo(o,!0),ht(e),o}catch{throw new p("Failed to extract project. Please try again.")}}import{execSync as wt}from"child_process";import $n from"ora";import bn from"fs-extra";import qo from"path";function xn(){try{return wt("yarn --version",{stdio:"ignore"}),"yarn"}catch{return"npm"}}function vn(e){let n=xn(),t=$n(`\u{1F4E6} Installing dependencies using ${n}...`).start();try{wt(n==="yarn"?"yarn install":"npm install",{cwd:e,stdio:"ignore"}),t.succeed("Dependencies installed successfully!")}catch{throw t.fail("Failed to install dependencies"),new p("Failed to install dependencies. Please check your internet connection and try again.")}}function Xo(e){let n=qo.join(e,"package.json");if(!bn.existsSync(n))return new Set;try{let t=bn.readJsonSync(n),o=new Set;return t.dependencies&&Object.keys(t.dependencies).forEach(r=>o.add(r)),t.devDependencies&&Object.keys(t.devDependencies).forEach(r=>o.add(r)),o}catch{return new Set}}function Sn(e,n){if(e.length===0)return{installed:[],skipped:[]};let t=Xo(n),o=e.filter(c=>!t.has(c)),r=e.filter(c=>t.has(c));if(o.length===0)return R.debug("All dependencies already installed"),{installed:[],skipped:r};let s=xn(),i=$n(`\u{1F4E6} Installing ${o.length} package${o.length>1?"s":""} using ${s}...`).start();try{let c=o.join(" "),a=s==="yarn"?`yarn add ${c}`:`npm install ${c}`;return R.debug({command:a}),wt(a,{cwd:n,stdio:"ignore"}),i.succeed(`Installed ${o.length} package${o.length>1?"s":""}`),{installed:o,skipped:r}}catch{throw i.fail("Failed to install packages"),new p(`Failed to install packages: ${o.join(", ")}. Please install them manually.`)}}import{execSync as Cn}from"child_process";import jn from"ora";function En(e,n){let t={cursor:"Cursor",antigravity:"Antigravity",vscode:"VS Code",webstorm:"WebStorm"},o={cursor:["cursor","code"],antigravity:["agy","antigravity"],vscode:["code"],webstorm:["webstorm","web"]},r=jn(`\u{1F680} Opening project in ${t[n]}...`).start(),s=!1;try{for(let i of o[n]){if(s)break;try{Cn(`${i} .`,{cwd:e,stdio:"ignore"}),s=!0}catch{s=!1}}if(!s)throw new Error("Failed to open with command.");r.succeed(`Project opened in ${t[n]}!`)}catch{r.fail(`Failed to open ${t[n]}`);let i={cursor:`\u274C Cursor command not found!
2
+ import{readFileSync as qr}from"fs";import{dirname as Xr,join as Yr}from"path";import{fileURLToPath as Zr}from"url";import{program as T}from"commander";import et from"axios";var p=class extends Error{code;suggestion;constructor(n,t){super(n),this.code=t==null?void 0:t.code,this.suggestion=t==null?void 0:t.suggestion}};function Ut(e){if(!(!e||typeof e!="object"))return e}function M(e){var n,t,o;if(e instanceof p)return e;if(et.isAxiosError(e)){let r=Ut((n=e.response)==null?void 0:n.data),s=typeof(r==null?void 0:r.message)=="string"?r.message:e.response?`API error: ${e.response.status} ${e.response.statusText}`:e.message,i=typeof(r==null?void 0:r.code)=="string"?r.code:void 0,c=typeof((t=r==null?void 0:r.details)==null?void 0:t.billing_url)=="string"?r.details.billing_url:typeof((o=r==null?void 0:r.details)==null?void 0:o.billingUrl)=="string"?r.details.billingUrl:void 0,a=typeof(r==null?void 0:r.suggestion)=="string"?r.suggestion:i==="GUEST_FORBIDDEN"?"Guest sessions are scoped to one project. Sign up at https://magicpath.ai to unlock this.":i==="GUEST_BUILD_LIMIT_REACHED"?"You have used all your free guest builds. Sign up at https://magicpath.ai to keep building and save this project.":c?"Upgrade to Pro from billing to keep using external agents.":void 0;return new p(s,{code:i,...a?{suggestion:a}:{}})}return e instanceof Error?new p(e.message):new p(String(e))}function Ft(){et.interceptors.response.use(e=>e,e=>{var n;if(et.isAxiosError(e)){let t=Ut((n=e.response)==null?void 0:n.data);if(typeof(t==null?void 0:t.code)=="string")return Promise.reject(M(e))}return Promise.reject(e)})}var Mt=!1;function Dt(e){Mt=e}function x(){return Mt}function b(e){console.log(JSON.stringify(e,null,2)),process.exit(0)}function E(e){let t={error:e instanceof Error?e.message:String(e)};e instanceof p&&(e.code&&(t.code=e.code),e.suggestion&&(t.suggestion=e.suggestion)),console.error(JSON.stringify(t,null,2)),process.exit(1)}var B="0.0.0-dev";function _t(e){B=e}import ie from"chalk";import ye from"fs-extra";import an from"path";import Ro from"os";import cn from"axios";var A=process.env.MAGICPATH_API_URL??"https://api.magicpath.ai";function ke(e,n){return`${A}/${e}/${n}`}function Lt(e){return`${A}/v1/registry/${e}`}var Ao=process.env.MAGICPATH_WEB_URL??"https://www.magicpath.ai";function Pe(e){return`${Ao}${e}`}function Wt(e){return Pe(`/files/${e}`)}function Ae(e,n){return Pe(`/projects/${e}?guest=${encodeURIComponent(n)}`)}function Te(e){return`${A}/auth/${e}`}function tt(){return`${A}/v1/external-agent/components`}function nt(e){return`${A}/v1/external-agent/components/${e}/context`}function Ht(e){return`${A}/v1/external-agent/components/${e}/start`}function Gt(e){return`${A}/v1/external-agent/components/${e}/revisions`}function ot(e,n){return`${A}/v1/external-agent/components/${e}/revisions/${n}/files`}function rt(e){return`${A}/v1/external-agent/jobs/${e}`}function Q(){return`${A}/users/me`}function st(){return`${A}/users/me/projects`}function it(){return`${A}/users/me/skills`}function Vt(){return`${A}/users/me/skills/import`}function zt(){return`${A}/users/me/assets/upload-url`}function Jt(){return`${A}/projects`}function Ne(e){return`${A}/projects/${e}`}function Bt(e){return`${A}/projects/${e}/components`}function at(e){return`${A}/projects/${e}/images`}function Re(){return`${A}/users/me/design-systems`}function Kt(e){return`${A}/design-systems/${e}`}function re(){return`${A}/users/me/socket-rooms`}function qt(){return`${A}/liveblocks/auth`}function Xt(e){return`${A}/components/${e}`}function Yt(){return`${A}/components/search`}function Zt(e){return`${A}/organizations/${e}`}function ct(e){return`${A}/organizations/${e}/projects`}function lt(e){return`${A}/organizations/${e}/skills`}function Qt(e){return`${A}/organizations/${e}/skills/import`}function Oe(e){return`${A}/organizations/${e}/design-systems`}function mt(e){return`${A}/skills/${e}`}function en(e){return`${A}/skills/${e}/files`}function tn(e,n){return`${A}/skills/${e}/files/content?path=${encodeURIComponent(n)}`}var To=[{type:"claude-code",envVar:"CLAUDECODE"},{type:"cursor",envVar:"CURSOR_TRACE_ID"},{type:"cursor",envVar:"CURSOR_AGENT"},{type:"codex",envVar:"CODEX_SANDBOX"},{type:"codex",envVar:"CODEX_THREAD_ID"},{type:"codex",envVar:"CODEX_CI"},{type:"gemini",envVar:"GEMINI_CLI"},{type:"antigravity",envVar:"ANTIGRAVITY_AGENT"},{type:"augment",envVar:"AUGMENT_AGENT"},{type:"opencode",envVar:"OPENCODE_CLIENT"},{type:"copilot",envVar:"COPILOT_MODEL"},{type:"cline",envVar:"CLINE_ACTIVE"},{type:"replit",envVar:"REPL_ID"},{type:"goose",envVar:"GOOSE_TERMINAL"}],Ue={"claude-code":"claude-code",claude:"claude-code",cursor:"cursor","cursor-agent":"cursor",codex:"codex","codex-cli":"codex",gemini:"gemini","gemini-cli":"gemini",antigravity:"antigravity",augment:"augment",opencode:"opencode",copilot:"copilot","github-copilot":"copilot","github-copilot-cli":"copilot",cline:"cline",replit:"replit",v0:"v0",devin:"devin",aider:"aider",goose:"goose",amp:"amp"};function nn(e){let n=e.trim();if(!n)return null;let t=n.indexOf("@");if(t===-1)return{slug:n.toLowerCase()};let o=n.slice(0,t).trim().toLowerCase(),r=n.slice(t+1).trim()||void 0;return o?{slug:o,version:r}:null}function on(e){if(e in Ue)return Ue[e];for(let n of Object.keys(Ue))if(e.startsWith(`${n}_`)||e.startsWith(`${n}-`))return Ue[n];return e}var Fe;function rn(){return Fe||(Fe=No(),Fe)}function No(){let e=process.env.MAGICPATH_AGENT;if(e){let t=nn(e);if(t)return{kind:"known-agent",slug:on(t.slug),version:t.version}}for(let t of To){let o=process.env[t.envVar];if(o&&o!=="0"&&o.toLowerCase()!=="false")return{kind:"known-agent",slug:t.type}}let n=process.env.AI_AGENT;if(n){let t=nn(n);if(t)return{kind:"known-agent",slug:on(t.slug),version:t.version}}return process.stdin.isTTY?{kind:"interactive-human"}:{kind:"unknown-agent"}}function sn(e){switch(e.kind){case"known-agent":return{type:e.slug,version:e.version};case"interactive-human":return{type:"interactive"};case"unknown-agent":return{}}}var ln=an.join(Ro.homedir(),".magicpath"),Me=an.join(ln,"session.json");function ee(){try{if(!ye.existsSync(Me))return null;let e=ye.readJsonSync(Me);return e.accessToken&&(e.refreshToken||e.guest)?e:null}catch{return null}}function dt(e){ye.ensureDirSync(ln),ye.writeJsonSync(Me,e)}function pt(e,n){let t=ee();dt({accessToken:e,refreshToken:n,user:t==null?void 0:t.user})}function mn(e,n){dt({accessToken:e,guest:n})}function se(){let e=ee();return e?{accessToken:e.accessToken,refreshToken:e.refreshToken}:null}function De(){let e=ee();return(e==null?void 0:e.guest)??null}function dn(){let e=ee();return e!=null&&e.guest?Ae(e.guest.projectId,e.accessToken):null}function pn(){try{ye.removeSync(Me)}catch{}}function Oo(e){try{let n=ee();n&&(n.user=e,dt(n))}catch{}}function gn(){let e=ee();return(e==null?void 0:e.user)??null}function j(){let{type:e,version:n}=sn(rn()),t={"X-Client-Type":"cli","X-Client-Version":B};e&&(t["X-Agent-Type"]=e),n&&(t["X-Agent-Version"]=n);let o=process.env.MAGICPATH_TOKEN;if(o)return t.Authorization=`Bearer ${o}`,t;let r=ee();if(!r)throw new Error("Not logged in. Run `magicpath-ai login` first.");if(r.guest&&Date.parse(r.guest.expiresAt)<Date.now())throw new p("Your guest session has expired. Sign up at https://magicpath.ai to keep building.",{code:"GUEST_EXPIRED",suggestion:"Sign up at https://magicpath.ai or start a new guest project from the MagicPath site."});return t.Authorization=`Bearer ${r.accessToken}`,t}function Ie(e){var o,r;let n=(o=e.subscription)!=null&&o.active?(r=e.subscription.type)!=null&&r.startsWith("PRO")?"Pro":"Creator":"Free",t={name:e.name||e.firstName||e.displayName,email:e.email,plan:n};return Oo(t),t}async function gt(){let e=j(),n=await cn.get(Q(),{headers:e}),t=n.data.user??n.data;return Ie(t)}async function be(e){let n=await cn.get(Q(),{headers:e});return((n.data.user??n.data).organizationUsers??[]).map(r=>({id:String(r.organization.id),name:r.organization.name,role:r.role}))}async function _(e,n){let t=await be(n),o=t.find(i=>i.id===e);if(o)return{id:o.id,name:o.name};let r=e.toLowerCase(),s=t.find(i=>i.name.toLowerCase()===r);if(s)return{id:s.id,name:s.name};throw new p(`Team "${e}" not found.`,{code:"TEAM_NOT_FOUND",suggestion:"Run `magicpath-ai list-teams` to see your teams."})}var un=["#95D5B2","#74C69D","#52B788","#40916C","#2D6A4F","#1B4332"];function Uo(e){return ie.hex(un[Math.min(e,un.length-1)])}var ut=ie.hex("#2D6A4F"),Fo=ie.hex("#1B4332"),Mo=ie.hex("#E8F5E9"),ft=ie.hex("#888888"),Do=["\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557","\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D","\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 ","\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551 ","\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557","\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D"],_o=["\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551","\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551","\u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551","\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D"],Lo=Do.map((e,n)=>e+" "+_o[n]);function Wo(e){return e.map((n,t)=>{let o=Uo(t),r="";for(let s of n)r+=s===" "?s:o(s);return r})}function fn(e){let n=!!se(),t=n?gn():null;console.log();for(let s of Wo(Lo))console.log(s);if(console.log(),n&&t){let s=t.plan?` \xB7 ${t.plan}`:"";console.log(" "+ut("\u25CF")+" "+ie.bold(Mo(t.name??"MagicPath User"))+Fo(" "+(t.email??"")+s))}else console.log(" "+ft("\u25CB Not logged in \xB7 run")+" "+ut("magicpath-ai login"));console.log();let o=20,r=[["search <query>","Search components"],["add <name>","Add to project"],["list-projects","Your projects"],["setup-skills","Set up AI agents"]];for(let[s,i]of r)console.log(" "+ut(s.padEnd(o))+ft(i));console.log(),console.log(" "+ft(`v${e} \u2500 magicpath-ai --help`)),console.log()}import Le from"prompts";import Pn from"ora";import{z as le}from"zod";import me from"path";import Yo from"os";import yt from"fs-extra";import{pino as hn}from"pino";var ae=hn();function ce(){ae=hn({level:"debug"}),ae.debug({message:"DEBUG logger enabled. "})}var R={info:e=>{ae.info(e)},debug:e=>{ae.debug(e)},warn:e=>{ae.warn(e)},error:e=>{ae.error(e)}};import wn from"axios";import _e from"path";import Go from"os";import{Readable as Vo}from"stream";import $e from"fs-extra";import zo from"adm-zip";import{v4 as Jo}from"uuid";async function Bo(e){if(!(e instanceof Vo))return;let n=[];return new Promise((t,o)=>{e.on("data",r=>{n.push(Buffer.isBuffer(r)?r:Buffer.from(r))}),e.on("error",o),e.on("end",()=>t(Buffer.concat(n).toString("utf8")))})}async function Ko(e){var n;if(e instanceof p)return e;if(wn.isAxiosError(e)){let t=await Bo((n=e.response)==null?void 0:n.data);if(t)try{let o=JSON.parse(t);return M({...e,response:{...e.response,data:o},isAxiosError:!0})}catch{}return M(e)}return new p("Failed to download project. Make sure your key is valid.")}async function yn(e){let n=ke("v1","components/repository"),t=`${Jo()}.zip`,o=_e.join(Go.tmpdir(),t);try{let r=await wn({url:n,params:{key:e},method:"GET",responseType:"stream"});return await $e.ensureDir(_e.dirname(o)),await new Promise(async(s,i)=>{try{r.data.pipe($e.createWriteStream(o)).on("error",i).once("close",()=>s(o))}catch(c){i(c)}}),o}catch(r){throw await Ko(r)}}function ht(e){try{$e.removeSync(e)}catch{}}function In(e,n,t){try{let o=_e.join(t,n),r=1;for(;$e.existsSync(o);)r++,o=_e.join(t,`${n}-${r}`);return $e.mkdirSync(o,{recursive:!0}),new zo(e).extractAllTo(o,!0),ht(e),o}catch{throw new p("Failed to extract project. Please try again.")}}import{execSync as wt}from"child_process";import $n from"ora";import bn from"fs-extra";import qo from"path";function xn(){try{return wt("yarn --version",{stdio:"ignore"}),"yarn"}catch{return"npm"}}function vn(e){let n=xn(),t=$n(`\u{1F4E6} Installing dependencies using ${n}...`).start();try{wt(n==="yarn"?"yarn install":"npm install",{cwd:e,stdio:"ignore"}),t.succeed("Dependencies installed successfully!")}catch{throw t.fail("Failed to install dependencies"),new p("Failed to install dependencies. Please check your internet connection and try again.")}}function Xo(e){let n=qo.join(e,"package.json");if(!bn.existsSync(n))return new Set;try{let t=bn.readJsonSync(n),o=new Set;return t.dependencies&&Object.keys(t.dependencies).forEach(r=>o.add(r)),t.devDependencies&&Object.keys(t.devDependencies).forEach(r=>o.add(r)),o}catch{return new Set}}function Sn(e,n){if(e.length===0)return{installed:[],skipped:[]};let t=Xo(n),o=e.filter(c=>!t.has(c)),r=e.filter(c=>t.has(c));if(o.length===0)return R.debug("All dependencies already installed"),{installed:[],skipped:r};let s=xn(),i=$n(`\u{1F4E6} Installing ${o.length} package${o.length>1?"s":""} using ${s}...`).start();try{let c=o.join(" "),a=s==="yarn"?`yarn add ${c}`:`npm install ${c}`;return R.debug({command:a}),wt(a,{cwd:n,stdio:"ignore"}),i.succeed(`Installed ${o.length} package${o.length>1?"s":""}`),{installed:o,skipped:r}}catch{throw i.fail("Failed to install packages"),new p(`Failed to install packages: ${o.join(", ")}. Please install them manually.`)}}import{execSync as Cn}from"child_process";import jn from"ora";function En(e,n){let t={cursor:"Cursor",antigravity:"Antigravity",vscode:"VS Code",webstorm:"WebStorm"},o={cursor:["cursor","code"],antigravity:["agy","antigravity"],vscode:["code"],webstorm:["webstorm","web"]},r=jn(`\u{1F680} Opening project in ${t[n]}...`).start(),s=!1;try{for(let i of o[n]){if(s)break;try{Cn(`${i} .`,{cwd:e,stdio:"ignore"}),s=!0}catch{s=!1}}if(!s)throw new Error("Failed to open with command.");r.succeed(`Project opened in ${t[n]}!`)}catch{r.fail(`Failed to open ${t[n]}`);let i={cursor:`\u274C Cursor command not found!
3
3
 
4
4
  \u{1F527} To fix this, you need to install the Cursor command line tools:
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magicpath-ai",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "description": "Node CLI for MagicPath",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",