magicpath-ai 2.1.0 → 2.1.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.
Files changed (2) hide show
  1. package/dist/cli.js +1 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -116,7 +116,7 @@ ${u.message}`),process.exit(1)),u}})}import{z as d}from"zod";import{z as _}from"
116
116
  Component: ${s.name}`),console.log(` Files: ${s.files.map(l=>l.path).join(", ")}`),console.log(` Dependencies: ${s.dependencies.join(", ")||"none"}`),i&&console.log(` Import: ${i}`);for(let l of s.files)console.log(`
117
117
  ${"\u2500".repeat(60)}`),console.log(` ${l.path}`),console.log(`${"\u2500".repeat(60)}`),console.log(l.content)}catch(o){throw j()&&T(o),o instanceof p&&(console.error(`
118
118
  ${o.message}`),process.exit(1)),o}})}var Gn=d.object({generatedName:d.string().describe("The generated name of the component (e.g., wispy-river-5234)"),yes:d.boolean().default(!1).describe("Skip confirmation prompts"),overwrite:d.boolean().default(!1).describe("Overwrite existing files"),path:d.string().optional().describe("Custom path for components (default: src/components/magicpath)"),dryRun:d.boolean().default(!1).describe("Show what would happen without writing files")}),Vn=d.object({component:d.string().describe("Component display name"),generatedName:d.string().describe("Component generated name"),filesWritten:d.array(d.string()).describe("Paths of files written"),dependenciesInstalled:d.array(d.string()).describe("Packages installed"),importStatement:d.string().optional().describe("Import statement for the component"),usage:d.string().optional().describe("JSX usage example"),dryRun:d.boolean().describe("Whether this was a dry run")}),zn=d.object({key:d.string().describe("One-time access key"),dir:d.string().describe("Target directory"),name:d.string().describe("Project name")}),Jn=d.object({projectDir:d.string().describe("Path to the created project")}),Bn=d.object({id:d.string().optional(),displayName:d.string().optional(),email:d.string().optional()}),Kn=d.object({team:d.string().optional().describe("Team name or ID to filter by"),personal:d.boolean().optional().describe("Show only personal projects")}),Xn=d.object({projects:d.array(d.object({id:d.string(),name:d.string(),isLibrary:d.boolean(),isSharingEnabled:d.boolean(),allowPublicListing:d.boolean(),createdAt:d.string(),updatedAt:d.string(),componentCount:d.number(),owner:d.object({displayName:d.string(),email:d.string()}).nullable(),isActive:d.boolean(),isDefaultLibrary:d.boolean(),ownerType:d.string().optional().describe('"personal" or "team"'),ownerName:d.string().optional().describe("User email for personal, team name for team projects")})),pagination:d.object({total:d.number(),limit:d.number(),offset:d.number(),hasMore:d.boolean()})}),qn=d.object({teams:d.array(d.object({id:d.string(),name:d.string(),role:d.string()}))}),Zn=d.object({team:d.string().describe("Team name or ID (required)")}),Yn=d.object({team:d.object({id:d.string(),name:d.string()}),members:d.array(d.object({id:d.string(),displayName:d.string().nullable(),email:d.string().nullable(),role:d.string()}))}),Qn=d.object({projectId:d.string().describe("The project ID"),createdBy:d.string().optional().describe("Filter to components created or edited by this user ID")}),er=d.object({components:d.array(d.object({id:d.string(),name:d.string(),generatedName:d.string(),createdAt:d.string(),updatedAt:d.string(),parentId:d.string().nullable(),revisionCount:d.number(),viewCount:d.number(),likeCount:d.number(),remixCount:d.number(),previewImageUrl:d.string().nullable(),lastEditedBy:d.object({id:d.string(),displayName:d.string()}).nullable().optional().describe("User who last edited this component")})),pagination:d.object({limit:d.number(),hasNext:d.boolean(),lastId:d.string().nullable()})}),tr=d.object({generatedName:d.string().describe("The generated name of the component")}),or=d.object({url:d.string().describe("Preview URL to open in a browser"),generatedName:d.string()}),nr=d.object({themes:d.array(d.object({id:d.string(),name:d.string(),isPublic:d.boolean(),createdAt:d.string(),updatedAt:d.string()}))}),rr=d.object({themeIdOrName:d.string().describe("Theme ID (numeric) or name (case-insensitive match)")}),sr=d.object({id:d.string(),name:d.string(),theme:d.object({light:d.record(d.string(),d.string()),dark:d.record(d.string(),d.string())}),defaultTheme:d.string(),prompt:d.string().optional().describe("Styling instructions for AI agents"),fonts:d.record(d.string(),d.object({source:d.string(),weights:d.record(d.string(),d.object({fontId:d.string(),url:d.string(),format:d.string()})).optional()})).optional(),version:d.number()}),De={view:{description:"Get the preview URL for a MagicPath component",input:tr,output:or},add:{description:"Add a MagicPath component to your project",input:Gn,output:Vn},inspect:{description:"Inspect a MagicPath component's source code without installing",input:jo,output:$o},clone:{description:"Clone/download a MagicPath project",input:zn,output:Jn},whoami:{description:"Show the currently authenticated user",output:Bn},"list-projects":{description:"List all projects (personal and team)",input:Kn,output:Xn},"list-teams":{description:"List teams you belong to",output:qn},"list-members":{description:"List members of a team",input:Zn,output:Yn},"list-components":{description:"List components in a project",input:Qn,output:er},"list-themes":{description:"List all themes (design systems) for the current user",output:nr},"get-theme":{description:"Get a theme definition with CSS variables, fonts, and styling prompt",input:rr,output:sr},selection:{description:"Get the currently selected component(s) from the web app canvas",output:d.object({components:d.array(d.object({id:d.string(),name:d.string(),generatedName:d.string().nullable(),clientId:d.string(),projectId:d.string(),projectName:d.string()}))})}};function _e(e){return ve(e)}function ve(e){let n=e._def;if(!n)return{};let t=n.typeName,o={};switch(n.description&&(o.description=n.description),t){case"ZodString":o.type="string";break;case"ZodNumber":o.type="number";break;case"ZodBoolean":o.type="boolean";break;case"ZodOptional":return ve(n.innerType);case"ZodDefault":return{...ve(n.innerType),default:n.defaultValue()};case"ZodArray":o.type="array",o.items=ve(n.type);break;case"ZodObject":{o.type="object",o.properties={};let r=[],s=n.shape();for(let[a,c]of Object.entries(s)){o.properties[a]=ve(c);let i=c._def;(i==null?void 0:i.typeName)!=="ZodOptional"&&(i==null?void 0:i.typeName)!=="ZodDefault"&&r.push(a)}r.length>0&&(o.required=r);break}default:o.type="string"}return o}function So(e){e.command("schema").description("Show JSON Schema for a command's input/output").argument("[command]","Command name (e.g., add, view)").option("--all","Show schemas for all commands").action((n,t)=>{if(t!=null&&t.all){let s={};for(let[a,c]of Object.entries(De))s[a]={description:c.description,input:c.input?_e(c.input):void 0,output:c.output?_e(c.output):void 0};console.log(JSON.stringify(s,null,2));return}if(!n){console.log("Available commands:",Object.keys(De).join(", ")),console.log(`
119
- Usage: magicpath-ai schema <command>`),console.log(" magicpath-ai schema --all");return}let o=De[n];o||(console.error(`Unknown command: ${n}`),console.error("Available:",Object.keys(De).join(", ")),process.exit(1));let r={command:n,description:o.description};o.input&&(r.input=_e(o.input)),o.output&&(r.output=_e(o.output)),console.log(JSON.stringify(r,null,2))})}import{execSync as ir}from"child_process";function Eo(e){e.command("setup-skills").description("Set up MagicPath for AI agents").action(async()=>{console.log("Installing MagicPath skills..."),ir("npx skills add https://github.com/MagicPathAI/agent-skills/tree/beta --skill magicpath -y",{stdio:"inherit"})})}import{exec as ar}from"child_process";function cr(e){return ne("v1",e)}function To(e){e.command("view").alias("view-component").description("Open a component preview in the browser").argument("<generatedName>","The generated name of the component (e.g., wispy-river-5234)").action(n=>{let t=cr(n);j()&&x({url:t,generatedName:n});let o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";ar(`${o} ${t}`),console.log(`Opening ${t}`)})}function lr(e){return ne("v1",e)}function Ao(e){e.command("share").description("Get a shareable preview URL for a component").argument("<generatedName>","The generated name of the component (e.g., wispy-river-5234)").action(n=>{let t=lr(n);if(j()){x({url:t,generatedName:n});return}console.log(t)})}import mr from"axios";function Po(e){e.command("info").description("Show project and auth status (useful for agent context injection)").action(async()=>{let n=j();try{let t=null,o=!1,r=null;process.env.MAGICPATH_TOKEN?(t="environment",o=!0,r=E()):ee()&&(t="stored",o=!0,r=E());let s=null,a=null;if(o&&r)try{let m=await mr.get(Q(),{headers:r}),u=m.data.user??m.data,l=he(u);s={id:u.id,name:l.name??"Unknown",email:l.email??""},a=(u.organizationUsers??[]).map(g=>({id:String(g.organization.id),name:g.organization.name,role:g.role}))}catch{}let c=null;if(o&&r)try{c=(await J(r)).map(u=>{var l;return{id:u.id,name:u.name,componentCount:u.componentCount??((l=u._count)==null?void 0:l.components)??0,ownerType:u.ownerType,ownerName:u.ownerName}})}catch{}if(n&&x({auth:{authenticated:o,method:t,user:s},teams:a,projects:c,cli:{version:K,commands:["add","view","search","inspect","list-projects","list-components","list-teams","list-members","list-themes","get-theme","list-installed","selection","active-project","code","login","logout","whoami","info","clone","setup-skills","schema"]}}),console.log(""),console.log(` MagicPath CLI v${K}`),console.log(""),o&&s?(console.log(` Authenticated: yes (${t})`),console.log(` User: ${s.name} <${s.email}>`)):o?(console.log(` Authenticated: yes (${t})`),console.log(" User: (could not fetch)")):(console.log(" Authenticated: no"),console.log(" Run `magicpath-ai login` to authenticate.")),a&&a.length>0){console.log(""),console.log(` Teams: ${a.length}`);for(let m of a)console.log(` - ${m.name} (${m.role.toLowerCase()})`)}if(console.log(""),c&&c.length>0){console.log(` Projects: ${c.length}`);for(let m of c){let u=m.ownerType==="personal"?"":` [${m.ownerName}]`;console.log(` - ${m.name} (${m.componentCount} components)${u}`)}}else o&&console.log(" Projects: none");console.log("")}catch(t){n&&T(t),console.error(`Error: ${t instanceof Error?t.message:String(t)}`),process.exit(1)}})}import No from"axios";function Ro(e){e.command("search").description("Search component names across all projects").argument("<query>","Search query (case-insensitive substring match)").option("--limit <n>","Maximum number of results","20").option("--team <nameOrId>","Search only within a specific team").option("--personal","Search only personal projects").action(async(n,t)=>{var s,a;let o=j(),r=parseInt(t.limit,10)||20;try{if(t.team&&t.personal)throw new p("Cannot use --team and --personal together.",{code:"INVALID_OPTIONS",suggestion:"Use --team to filter by team, or --personal for personal projects only."});let c;try{c=E()}catch{throw new p("Not authenticated. Set MAGICPATH_TOKEN or run `magicpath-ai login`.",{code:"NOT_AUTHENTICATED",suggestion:"Run `magicpath-ai login` or set the MAGICPATH_TOKEN environment variable."})}let i=o?null:P("Searching components...").start();try{let m;if(t.personal)m={personal:!0};else if(t.team){let f=await V(t.team,c);m={orgId:f.id,orgName:f.name}}let u=await J(c,m);if(u.length===0){i==null||i.succeed("No projects found"),o&&x([]),console.log(`
119
+ Usage: magicpath-ai schema <command>`),console.log(" magicpath-ai schema --all");return}let o=De[n];o||(console.error(`Unknown command: ${n}`),console.error("Available:",Object.keys(De).join(", ")),process.exit(1));let r={command:n,description:o.description};o.input&&(r.input=_e(o.input)),o.output&&(r.output=_e(o.output)),console.log(JSON.stringify(r,null,2))})}import{execSync as ir}from"child_process";function Eo(e){e.command("setup-skills").description("Set up MagicPath for AI agents").action(async()=>{console.log("Installing MagicPath skills..."),ir("npx skills add https://github.com/MagicPathAI/agent-skills --skill magicpath -y",{stdio:"inherit"})})}import{exec as ar}from"child_process";function cr(e){return ne("v1",e)}function To(e){e.command("view").alias("view-component").description("Open a component preview in the browser").argument("<generatedName>","The generated name of the component (e.g., wispy-river-5234)").action(n=>{let t=cr(n);j()&&x({url:t,generatedName:n});let o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";ar(`${o} ${t}`),console.log(`Opening ${t}`)})}function lr(e){return ne("v1",e)}function Ao(e){e.command("share").description("Get a shareable preview URL for a component").argument("<generatedName>","The generated name of the component (e.g., wispy-river-5234)").action(n=>{let t=lr(n);if(j()){x({url:t,generatedName:n});return}console.log(t)})}import mr from"axios";function Po(e){e.command("info").description("Show project and auth status (useful for agent context injection)").action(async()=>{let n=j();try{let t=null,o=!1,r=null;process.env.MAGICPATH_TOKEN?(t="environment",o=!0,r=E()):ee()&&(t="stored",o=!0,r=E());let s=null,a=null;if(o&&r)try{let m=await mr.get(Q(),{headers:r}),u=m.data.user??m.data,l=he(u);s={id:u.id,name:l.name??"Unknown",email:l.email??""},a=(u.organizationUsers??[]).map(g=>({id:String(g.organization.id),name:g.organization.name,role:g.role}))}catch{}let c=null;if(o&&r)try{c=(await J(r)).map(u=>{var l;return{id:u.id,name:u.name,componentCount:u.componentCount??((l=u._count)==null?void 0:l.components)??0,ownerType:u.ownerType,ownerName:u.ownerName}})}catch{}if(n&&x({auth:{authenticated:o,method:t,user:s},teams:a,projects:c,cli:{version:K,commands:["add","view","search","inspect","list-projects","list-components","list-teams","list-members","list-themes","get-theme","list-installed","selection","active-project","code","login","logout","whoami","info","clone","setup-skills","schema"]}}),console.log(""),console.log(` MagicPath CLI v${K}`),console.log(""),o&&s?(console.log(` Authenticated: yes (${t})`),console.log(` User: ${s.name} <${s.email}>`)):o?(console.log(` Authenticated: yes (${t})`),console.log(" User: (could not fetch)")):(console.log(" Authenticated: no"),console.log(" Run `magicpath-ai login` to authenticate.")),a&&a.length>0){console.log(""),console.log(` Teams: ${a.length}`);for(let m of a)console.log(` - ${m.name} (${m.role.toLowerCase()})`)}if(console.log(""),c&&c.length>0){console.log(` Projects: ${c.length}`);for(let m of c){let u=m.ownerType==="personal"?"":` [${m.ownerName}]`;console.log(` - ${m.name} (${m.componentCount} components)${u}`)}}else o&&console.log(" Projects: none");console.log("")}catch(t){n&&T(t),console.error(`Error: ${t instanceof Error?t.message:String(t)}`),process.exit(1)}})}import No from"axios";function Ro(e){e.command("search").description("Search component names across all projects").argument("<query>","Search query (case-insensitive substring match)").option("--limit <n>","Maximum number of results","20").option("--team <nameOrId>","Search only within a specific team").option("--personal","Search only personal projects").action(async(n,t)=>{var s,a;let o=j(),r=parseInt(t.limit,10)||20;try{if(t.team&&t.personal)throw new p("Cannot use --team and --personal together.",{code:"INVALID_OPTIONS",suggestion:"Use --team to filter by team, or --personal for personal projects only."});let c;try{c=E()}catch{throw new p("Not authenticated. Set MAGICPATH_TOKEN or run `magicpath-ai login`.",{code:"NOT_AUTHENTICATED",suggestion:"Run `magicpath-ai login` or set the MAGICPATH_TOKEN environment variable."})}let i=o?null:P("Searching components...").start();try{let m;if(t.personal)m={personal:!0};else if(t.team){let f=await V(t.team,c);m={orgId:f.id,orgName:f.name}}let u=await J(c,m);if(u.length===0){i==null||i.succeed("No projects found"),o&&x([]),console.log(`
120
120
  No projects found.`);return}let l=await Promise.all(u.map(async f=>{var w;try{let I=`${Ce(f.id)}?limit=100&revisionStatus=COMPLETED`,A=await No.get(I,{headers:c}),F=((w=A.data.data)==null?void 0:w.components)??A.data.components??A.data;return{project:f,components:Array.isArray(F)?F:[]}}catch{return{project:f,components:[]}}})),h=n.toLowerCase(),g=[];for(let{project:f,components:w}of l){for(let I of w){if(g.length>=r)break;(I.name||"").toLowerCase().includes(h)&&g.push({name:I.name,generatedName:I.generatedName,id:I.id,projectName:f.name,projectId:f.id,previewImageUrl:I.previewImageUrl??null,ownerType:f.ownerType,ownerName:f.ownerName})}if(g.length>=r)break}if(i==null||i.succeed(`Found ${g.length} match(es) for "${n}"`),o&&x(g),g.length===0){console.log(`
121
121
  No components matching "${n}".`);return}console.log("");let v=Math.max(4,...g.map(f=>f.name.length)),b=Math.max(13,...g.map(f=>f.generatedName.length)),$=Math.max(7,...g.map(f=>f.projectName.length)),y=Math.max(9,...g.map(f=>f.ownerType==="personal"?8:f.ownerName.length));console.log(` ${"Name".padEnd(v)} ${"Generated Name".padEnd(b)} ${"Project".padEnd($)} ${"Workspace".padEnd(y)}`),console.log(` ${"\u2500".repeat(v)} ${"\u2500".repeat(b)} ${"\u2500".repeat($)} ${"\u2500".repeat(y)}`);for(let f of g){let w=f.ownerType==="personal"?"Personal":f.ownerName;console.log(` ${f.name.padEnd(v)} ${f.generatedName.padEnd(b)} ${f.projectName.padEnd($)} ${w.padEnd(y)}`)}}catch(m){throw i==null||i.fail("Search failed"),m instanceof p?m:No.isAxiosError(m)?((s=m.response)==null?void 0:s.status)===401?new p("Token is invalid or expired. Run `magicpath-ai login`."):new p(`API error: ${(a=m.response)==null?void 0:a.status}`):m}}catch(c){throw o&&T(c),c instanceof p&&(console.error(`
122
122
  ${c.message}`),process.exit(1)),c}})}import oe from"path";import pe from"fs-extra";function dr(e,n){if(!pe.existsSync(e))return[];let t=pe.readdirSync(e,{withFileTypes:!0}),o=[];for(let r of t){if(!r.isDirectory())continue;let s=oe.join(e,r.name),a=pe.readdirSync(s).filter(u=>!pe.statSync(oe.join(s,u)).isDirectory()),c=a.find(u=>(u.endsWith(".tsx")||u.endsWith(".ts"))&&u!=="usage.md"&&!u.includes(".test.")&&!u.includes(".spec.")),i=null,m=null;if(c)try{let u=pe.readFileSync(oe.join(s,c),"utf8"),l=te(u);if(l){i=l.name;let h=c.replace(/\.tsx?$/,""),g=`@/components/magicpath/${r.name}/${h}`;l.isDefault?m=`import ${l.name} from '${g}';`:m=`import { ${l.name} } from '${g}';`}}catch{}o.push({name:i||r.name,folder:r.name,path:oe.relative(n,s),files:a.filter(u=>u!=="usage.md"),exportName:i,importStatement:m})}return o}function ko(e){e.command("list-installed").description("List MagicPath components installed in the current project").option("-p, --path <path>",`Custom components path (default: ${Ie})`).action(async n=>{let t=j();try{let o=process.cwd(),r=Me(n.path,o);if(!pe.existsSync(r)){t&&x({components:[],total:0}),console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magicpath-ai",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Node CLI for MagicPath",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",