create-mastra 0.2.0-alpha.1 → 0.2.0

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/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import child_process from 'node:child_process';
15
15
  import util from 'node:util';
16
16
  import fs4 from 'node:fs/promises';
17
17
  import { execa } from 'execa';
18
- import fsExtra3 from 'fs-extra/esm';
18
+ import fsExtra3, { readJSON, ensureFile, writeJSON } from 'fs-extra/esm';
19
19
  import prettier from 'prettier';
20
20
  import { Transform } from 'node:stream';
21
21
  import pino from 'pino';
@@ -352,14 +352,14 @@ function q({onlyFirst:e=false}={}){const F=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(
352
352
  `).map(t=>oD(t,u,F)).join(`
353
353
  `)}var nD=Object.defineProperty,aD=(e,u,F)=>u in e?nD(e,u,{enumerable:true,configurable:true,writable:true,value:F}):e[u]=F,a$1=(e,u,F)=>(aD(e,typeof u!="symbol"?u+"":u,F),F);function hD(e,u){if(e===u)return;const F=e.split(`
354
354
  `),t=u.split(`
355
- `),s=[];for(let C=0;C<Math.max(F.length,t.length);C++)F[C]!==t[C]&&s.push(C);return s}const V$1=Symbol("clack:cancel");function lD(e){return e===V$1}function v(e,u){e.isTTY&&e.setRawMode(u);}const z=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),xD=new Set(["up","down","left","right","space","enter"]);class x{constructor({render:u,input:F=stdin,output:t=stdout,...s},C=true){a$1(this,"input"),a$1(this,"output"),a$1(this,"rl"),a$1(this,"opts"),a$1(this,"_track",false),a$1(this,"_render"),a$1(this,"_cursor",0),a$1(this,"state","initial"),a$1(this,"value"),a$1(this,"error",""),a$1(this,"subscribers",new Map),a$1(this,"_prevFrame",""),this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=u.bind(this),this._track=C,this.input=F,this.output=t;}prompt(){const u=new WriteStream(0);return u._write=(F,t,s)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),s();},this.input.pipe(u),this.rl=f__default.createInterface({input:this.input,output:u,tabSize:2,prompt:"",escapeCodeTimeout:50}),f__default.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),v(this.input,true),this.output.on("resize",this.render),this.render(),new Promise((F,t)=>{this.once("submit",()=>{this.output.write(srcExports.cursor.show),this.output.off("resize",this.render),v(this.input,false),F(this.value);}),this.once("cancel",()=>{this.output.write(srcExports.cursor.show),this.output.off("resize",this.render),v(this.input,false),F(V$1);});})}on(u,F){const t=this.subscribers.get(u)??[];t.push({cb:F}),this.subscribers.set(u,t);}once(u,F){const t=this.subscribers.get(u)??[];t.push({cb:F,once:true}),this.subscribers.set(u,t);}emit(u,...F){const t=this.subscribers.get(u)??[],s=[];for(const C of t)C.cb(...F),C.once&&s.push(()=>t.splice(t.indexOf(C),1));for(const C of s)C();}unsubscribe(){this.subscribers.clear();}onKeypress(u,F){if(this.state==="error"&&(this.state="active"),F?.name&&!this._track&&z.has(F.name)&&this.emit("cursor",z.get(F.name)),F?.name&&xD.has(F.name)&&this.emit("cursor",F.name),u&&(u.toLowerCase()==="y"||u.toLowerCase()==="n")&&this.emit("confirm",u.toLowerCase()==="y"),u===" "&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),u&&this.emit("key",u.toLowerCase()),F?.name==="return"){if(this.opts.validate){const t=this.opts.validate(this.value);t&&(this.error=t,this.state="error",this.rl.write(this.value));}this.state!=="error"&&(this.state="submit");}u===""&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close();}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
356
- `),v(this.input,false),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe();}restoreCursor(){const u=R$1(this._prevFrame,process.stdout.columns,{hard:true}).split(`
355
+ `),s=[];for(let C=0;C<Math.max(F.length,t.length);C++)F[C]!==t[C]&&s.push(C);return s}const V$1=Symbol("clack:cancel");function lD(e){return e===V$1}function v$1(e,u){e.isTTY&&e.setRawMode(u);}const z=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),xD=new Set(["up","down","left","right","space","enter"]);class x{constructor({render:u,input:F=stdin,output:t=stdout,...s},C=true){a$1(this,"input"),a$1(this,"output"),a$1(this,"rl"),a$1(this,"opts"),a$1(this,"_track",false),a$1(this,"_render"),a$1(this,"_cursor",0),a$1(this,"state","initial"),a$1(this,"value"),a$1(this,"error",""),a$1(this,"subscribers",new Map),a$1(this,"_prevFrame",""),this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=u.bind(this),this._track=C,this.input=F,this.output=t;}prompt(){const u=new WriteStream(0);return u._write=(F,t,s)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),s();},this.input.pipe(u),this.rl=f__default.createInterface({input:this.input,output:u,tabSize:2,prompt:"",escapeCodeTimeout:50}),f__default.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),v$1(this.input,true),this.output.on("resize",this.render),this.render(),new Promise((F,t)=>{this.once("submit",()=>{this.output.write(srcExports.cursor.show),this.output.off("resize",this.render),v$1(this.input,false),F(this.value);}),this.once("cancel",()=>{this.output.write(srcExports.cursor.show),this.output.off("resize",this.render),v$1(this.input,false),F(V$1);});})}on(u,F){const t=this.subscribers.get(u)??[];t.push({cb:F}),this.subscribers.set(u,t);}once(u,F){const t=this.subscribers.get(u)??[];t.push({cb:F,once:true}),this.subscribers.set(u,t);}emit(u,...F){const t=this.subscribers.get(u)??[],s=[];for(const C of t)C.cb(...F),C.once&&s.push(()=>t.splice(t.indexOf(C),1));for(const C of s)C();}unsubscribe(){this.subscribers.clear();}onKeypress(u,F){if(this.state==="error"&&(this.state="active"),F?.name&&!this._track&&z.has(F.name)&&this.emit("cursor",z.get(F.name)),F?.name&&xD.has(F.name)&&this.emit("cursor",F.name),u&&(u.toLowerCase()==="y"||u.toLowerCase()==="n")&&this.emit("confirm",u.toLowerCase()==="y"),u===" "&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),u&&this.emit("key",u.toLowerCase()),F?.name==="return"){if(this.opts.validate){const t=this.opts.validate(this.value);t&&(this.error=t,this.state="error",this.rl.write(this.value));}this.state!=="error"&&(this.state="submit");}u===""&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close();}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
356
+ `),v$1(this.input,false),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe();}restoreCursor(){const u=R$1(this._prevFrame,process.stdout.columns,{hard:true}).split(`
357
357
  `).length-1;this.output.write(srcExports.cursor.move(-999,u*-1));}render(){const u=R$1(this._render(this)??"",process.stdout.columns,{hard:true});if(u!==this._prevFrame){if(this.state==="initial")this.output.write(srcExports.cursor.hide);else {const F=hD(this._prevFrame,u);if(this.restoreCursor(),F&&F?.length===1){const t=F[0];this.output.write(srcExports.cursor.move(0,t)),this.output.write(srcExports.erase.lines(1));const s=u.split(`
358
358
  `);this.output.write(s[t]),this._prevFrame=u,this.output.write(srcExports.cursor.move(0,s.length-t-1));return}else if(F&&F?.length>1){const t=F[0];this.output.write(srcExports.cursor.move(0,t)),this.output.write(srcExports.erase.down());const s=u.split(`
359
359
  `).slice(t);this.output.write(s.join(`
360
360
  `)),this._prevFrame=u;return}this.output.write(srcExports.erase.down());}this.output.write(u),this.state==="initial"&&(this.state="active"),this._prevFrame=u;}}}class BD extends x{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(u){super(u,false),this.value=!!u.initialValue,this.on("value",()=>{this.value=this._value;}),this.on("confirm",F=>{this.output.write(srcExports.cursor.move(0,-1)),this.value=F,this.state="submit",this.close();}),this.on("cursor",()=>{this.value=!this.value;});}}var fD=Object.defineProperty,gD=(e,u,F)=>u in e?fD(e,u,{enumerable:true,configurable:true,writable:true,value:F}):e[u]=F,K$1=(e,u,F)=>(gD(e,typeof u!="symbol"?u+"":u,F),F);let vD=class extends x{constructor(u){super(u,false),K$1(this,"options"),K$1(this,"cursor",0),this.options=u.options,this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:F})=>F===u.cursorAt),0),this.on("key",F=>{F==="a"&&this.toggleAll();}),this.on("cursor",F=>{switch(F){case "left":case "up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case "down":case "right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case "space":this.toggleValue();break}});}get _value(){return this.options[this.cursor].value}toggleAll(){const u=this.value.length===this.options.length;this.value=u?[]:this.options.map(F=>F.value);}toggleValue(){const u=this.value.includes(this._value);this.value=u?this.value.filter(F=>F!==this._value):[...this.value,this._value];}};var wD=Object.defineProperty,yD=(e,u,F)=>u in e?wD(e,u,{enumerable:true,configurable:true,writable:true,value:F}):e[u]=F,Z=(e,u,F)=>(yD(e,typeof u!="symbol"?u+"":u,F),F);let $D=class extends x{constructor(u){super(u,false),Z(this,"options"),Z(this,"cursor",0),this.options=u.options,this.cursor=this.options.findIndex(({value:F})=>F===u.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",F=>{switch(F){case "left":case "up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case "down":case "right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue();});}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value;}};var TD=Object.defineProperty,jD=(e,u,F)=>u in e?TD(e,u,{enumerable:true,configurable:true,writable:true,value:F}):e[u]=F,MD=(e,u,F)=>(jD(e,u+"",F),F);class PD extends x{constructor(u){super(u),MD(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=u.defaultValue),this.valueWithCursor=this.value;}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${color2.inverse(color2.hidden("_"))}`;else {const F=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor);this.valueWithCursor=`${F}${color2.inverse(t[0])}${t.slice(1)}`;}});}get cursor(){return this._cursor}}const WD=globalThis.process.platform.startsWith("win");function OD({input:e=stdin,output:u=stdout,overwrite:F=true,hideCursor:t=true}={}){const s=f.createInterface({input:e,output:u,prompt:"",tabSize:1});f.emitKeypressEvents(e,s),e.isTTY&&e.setRawMode(true);const C=(D,{name:i})=>{if(String(D)===""){t&&u.write(srcExports.cursor.show),process.exit(0);return}if(!F)return;let n=i==="return"?0:-1,E=i==="return"?-1:0;f.moveCursor(u,n,E,()=>{f.clearLine(u,1,()=>{e.once("keypress",C);});});};return t&&u.write(srcExports.cursor.hide),e.once("keypress",C),()=>{e.off("keypress",C),t&&u.write(srcExports.cursor.show),e.isTTY&&!WD&&e.setRawMode(false),s.terminal=false,s.close();}}
361
361
 
362
- function K(){return h.platform!=="win32"?h.env.TERM!=="linux":!!h.env.CI||!!h.env.WT_SESSION||!!h.env.TERMINUS_SUBLIME||h.env.ConEmuTask==="{cmd::Cmder}"||h.env.TERM_PROGRAM==="Terminus-Sublime"||h.env.TERM_PROGRAM==="vscode"||h.env.TERM==="xterm-256color"||h.env.TERM==="alacritty"||h.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const C=K(),u=(s,n)=>C?s:n,Y=u("\u25C6","*"),P=u("\u25A0","x"),V=u("\u25B2","x"),M=u("\u25C7","o"),Q=u("\u250C","T"),a=u("\u2502","|"),$=u("\u2514","\u2014"),I=u("\u25CF",">"),T=u("\u25CB"," "),j=u("\u25FB","[\u2022]"),b=u("\u25FC","[+]"),B=u("\u25FB","[ ]"),G=u("\u2500","-"),H=u("\u256E","+"),ee=u("\u251C","+"),te=u("\u256F","+"),y=s=>{switch(s){case "initial":case "active":return color2.cyan(Y);case "cancel":return color2.red(P);case "error":return color2.yellow(V);case "submit":return color2.green(M)}},E=s=>{const{cursor:n,options:t,style:i}=s,r=s.maxItems??1/0,o=Math.max(process.stdout.rows-4,0),c=Math.min(o,Math.max(r,5));let l=0;n>=l+c-3?l=Math.max(Math.min(n-c+3,t.length-c),0):n<l+2&&(l=Math.max(n-2,0));const d=c<t.length&&l>0,p=c<t.length&&l+c<t.length;return t.slice(l,l+c).map((S,f,x)=>{const g=f===0&&d,m=f===x.length-1&&p;return g||m?color2.dim("..."):i(S,f+l===n)})},ae=s=>new PD({validate:s.validate,placeholder:s.placeholder,defaultValue:s.defaultValue,initialValue:s.initialValue,render(){const n=`${color2.gray(a)}
362
+ function K(){return h.platform!=="win32"?h.env.TERM!=="linux":!!h.env.CI||!!h.env.WT_SESSION||!!h.env.TERMINUS_SUBLIME||h.env.ConEmuTask==="{cmd::Cmder}"||h.env.TERM_PROGRAM==="Terminus-Sublime"||h.env.TERM_PROGRAM==="vscode"||h.env.TERM==="xterm-256color"||h.env.TERM==="alacritty"||h.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const C=K(),u=(s,n)=>C?s:n,Y=u("\u25C6","*"),P=u("\u25A0","x"),V=u("\u25B2","x"),M=u("\u25C7","o"),Q=u("\u250C","T"),a=u("\u2502","|"),$=u("\u2514","\u2014"),I=u("\u25CF",">"),T=u("\u25CB"," "),j=u("\u25FB","[\u2022]"),b=u("\u25FC","[+]"),B=u("\u25FB","[ ]"),G=u("\u2500","-"),H=u("\u256E","+"),ee=u("\u251C","+"),te=u("\u256F","+"),se=u("\u25CF","\u2022"),re=u("\u25C6","*"),ie=u("\u25B2","!"),ne=u("\u25A0","x"),y=s=>{switch(s){case "initial":case "active":return color2.cyan(Y);case "cancel":return color2.red(P);case "error":return color2.yellow(V);case "submit":return color2.green(M)}},E=s=>{const{cursor:n,options:t,style:i}=s,r=s.maxItems??1/0,o=Math.max(process.stdout.rows-4,0),c=Math.min(o,Math.max(r,5));let l=0;n>=l+c-3?l=Math.max(Math.min(n-c+3,t.length-c),0):n<l+2&&(l=Math.max(n-2,0));const d=c<t.length&&l>0,p=c<t.length&&l+c<t.length;return t.slice(l,l+c).map((S,f,x)=>{const g=f===0&&d,m=f===x.length-1&&p;return g||m?color2.dim("..."):i(S,f+l===n)})},ae=s=>new PD({validate:s.validate,placeholder:s.placeholder,defaultValue:s.defaultValue,initialValue:s.initialValue,render(){const n=`${color2.gray(a)}
363
363
  ${y(this.state)} ${s.message}
364
364
  `,t=s.placeholder?color2.inverse(s.placeholder[0])+color2.dim(s.placeholder.slice(1)):color2.inverse(color2.hidden("_")),i=this.value?this.valueWithCursor:t;switch(this.state){case "error":return `${n.trim()}
365
365
  ${color2.yellow(a)} ${i}
@@ -404,7 +404,10 @@ ${color2.gray(ee+G.repeat(r+2)+te)}
404
404
  `);},ge=(s="")=>{process.stdout.write(`${color2.gray(a)}
405
405
  ${color2.gray($)} ${s}
406
406
 
407
- `);},_=()=>{const s=C?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=C?80:120;let t,i,r=false,o="";const c=g=>{const m=g>1?"Something went wrong":"Canceled";r&&x(m,g);},l=()=>c(2),d=()=>c(1),p=()=>{process.on("uncaughtExceptionMonitor",l),process.on("unhandledRejection",l),process.on("SIGINT",d),process.on("SIGTERM",d),process.on("exit",c);},S=()=>{process.removeListener("uncaughtExceptionMonitor",l),process.removeListener("unhandledRejection",l),process.removeListener("SIGINT",d),process.removeListener("SIGTERM",d),process.removeListener("exit",c);},f=(g="")=>{r=true,t=OD(),o=g.replace(/\.+$/,""),process.stdout.write(`${color2.gray(a)}
407
+ `);},v={message:(s="",{symbol:n=color2.gray(a)}={})=>{const t=[`${color2.gray(a)}`];if(s){const[i,...r]=s.split(`
408
+ `);t.push(`${n} ${i}`,...r.map(o=>`${color2.gray(a)} ${o}`));}process.stdout.write(`${t.join(`
409
+ `)}
410
+ `);},info:s=>{v.message(s,{symbol:color2.blue(se)});},success:s=>{v.message(s,{symbol:color2.green(re)});},step:s=>{v.message(s,{symbol:color2.green(M)});},warn:s=>{v.message(s,{symbol:color2.yellow(ie)});},warning:s=>{v.warn(s);},error:s=>{v.message(s,{symbol:color2.red(ne)});}},_=()=>{const s=C?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=C?80:120;let t,i,r=false,o="";const c=g=>{const m=g>1?"Something went wrong":"Canceled";r&&x(m,g);},l=()=>c(2),d=()=>c(1),p=()=>{process.on("uncaughtExceptionMonitor",l),process.on("unhandledRejection",l),process.on("SIGINT",d),process.on("SIGTERM",d),process.on("exit",c);},S=()=>{process.removeListener("uncaughtExceptionMonitor",l),process.removeListener("unhandledRejection",l),process.removeListener("SIGINT",d),process.removeListener("SIGTERM",d),process.removeListener("exit",c);},f=(g="")=>{r=true,t=OD(),o=g.replace(/\.+$/,""),process.stdout.write(`${color2.gray(a)}
408
411
  `);let m=0,w=0;p(),i=setInterval(()=>{const L=color2.magenta(s[m]),O=".".repeat(Math.floor(w)).slice(0,3);process.stdout.write(srcExports.cursor.move(-999,0)),process.stdout.write(srcExports.erase.down(1)),process.stdout.write(`${L} ${o}${O}`),m=m+1<s.length?m+1:0,w=w<s.length?w+.125:0;},n);},x=(g="",m=0)=>{o=g??o,r=false,clearInterval(i);const w=m===0?color2.green(M):m===1?color2.red(P):color2.red(V);process.stdout.write(srcExports.cursor.move(-999,0)),process.stdout.write(srcExports.erase.down(1)),process.stdout.write(`${w} ${o}
409
412
  `),S(),t();};return {start:f,stop:x,message:(g="")=>{o=g??o;}}};function ye(){const s=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(s,"g")}const ve=async(s,n)=>{const t={},i=Object.keys(s);for(const r of i){const o=s[r],c=await o({results:t})?.catch(l=>{throw l});if(typeof n?.onCancel=="function"&&lD(c)){t[r]="canceled",n.onCancel({results:t});continue}t[r]=c;}return t};
410
413
 
@@ -992,6 +995,62 @@ function getPackageManagerInstallCommand(pm) {
992
995
  return "install";
993
996
  }
994
997
  }
998
+ function installMastraDocsMCPServer({
999
+ editor,
1000
+ directory
1001
+ }) {
1002
+ if (!editor) return;
1003
+ if (editor === `cursor`) return installCursorMCP(directory);
1004
+ if (editor === `windsurf`) return installWindsurfMCP();
1005
+ }
1006
+ var args = ["-y", "@mastra/mcp-docs-server@latest"];
1007
+ var mcpConfig = {
1008
+ mcpServers: {
1009
+ mastra: process.platform === `win32` ? {
1010
+ command: "cmd",
1011
+ args: ["/c", "npx", ...args]
1012
+ } : {
1013
+ command: "npx",
1014
+ args
1015
+ }
1016
+ }
1017
+ };
1018
+ function makeConfig(original) {
1019
+ return {
1020
+ ...original,
1021
+ mcpServers: {
1022
+ ...original?.mcpServers || {},
1023
+ ...mcpConfig.mcpServers
1024
+ }
1025
+ };
1026
+ }
1027
+ async function writeMergedConfig(configPath) {
1028
+ const configExists = existsSync(configPath);
1029
+ const config = makeConfig(configExists ? await readJSON(configPath) : {});
1030
+ await ensureFile(configPath);
1031
+ await writeJSON(configPath, config, {
1032
+ spaces: 2
1033
+ });
1034
+ }
1035
+ async function installCursorMCP(directory) {
1036
+ const configPath = path.join(directory, ".cursor", "mcp.json");
1037
+ await writeMergedConfig(configPath);
1038
+ }
1039
+ async function installWindsurfMCP() {
1040
+ const configPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
1041
+ const confirm2 = await le({
1042
+ message: `Windsurf only supports a global MCP config (at ${configPath}) is it ok to add/update that global config?
1043
+ This means the Mastra docs MCP server will be available in all your Windsurf projects.`,
1044
+ options: [
1045
+ { value: "skip", label: "No, skip for now" },
1046
+ { value: "yes", label: "Yes, I understand" }
1047
+ ]
1048
+ });
1049
+ if (confirm2 !== `yes`) {
1050
+ return void 0;
1051
+ }
1052
+ await writeMergedConfig(configPath);
1053
+ }
995
1054
  var EnvService = class {
996
1055
  };
997
1056
  var FileEnvService = class extends EnvService {
@@ -1531,7 +1590,26 @@ var interactivePrompt = async () => {
1531
1590
  addExample: () => ce({
1532
1591
  message: "Add example",
1533
1592
  initialValue: false
1534
- })
1593
+ }),
1594
+ configureEditorWithDocsMCP: async () => {
1595
+ const editor = await le({
1596
+ message: `Make your AI IDE into a Mastra expert? (installs Mastra docs MCP server)`,
1597
+ options: [
1598
+ { value: "skip", label: "Skip for now", hint: "default" },
1599
+ { value: "cursor", label: "Cursor" },
1600
+ { value: "windsurf", label: "Windsurf" }
1601
+ ]
1602
+ });
1603
+ if (editor === `skip`) return void 0;
1604
+ if (editor === `cursor`) {
1605
+ v.message(
1606
+ `
1607
+ Note: you will need to go into Cursor Settings -> MCP Settings and manually enable the installed Mastra MCP server.
1608
+ `
1609
+ );
1610
+ }
1611
+ return editor;
1612
+ }
1535
1613
  },
1536
1614
  {
1537
1615
  onCancel: () => {
@@ -1551,7 +1629,8 @@ var init = async ({
1551
1629
  addExample = false,
1552
1630
  components,
1553
1631
  llmProvider = "openai",
1554
- llmApiKey
1632
+ llmApiKey,
1633
+ configureEditorWithDocsMCP
1555
1634
  }) => {
1556
1635
  s.start("Initializing Mastra");
1557
1636
  try {
@@ -1584,6 +1663,12 @@ var init = async ({
1584
1663
  const pm = depsService.packageManager;
1585
1664
  const installCommand = getPackageManagerInstallCommand(pm);
1586
1665
  await exec2(`${pm} ${installCommand} ${aiSdkPackage}`);
1666
+ if (configureEditorWithDocsMCP) {
1667
+ await installMastraDocsMCPServer({
1668
+ editor: configureEditorWithDocsMCP,
1669
+ directory: process.cwd()
1670
+ });
1671
+ }
1587
1672
  s.stop();
1588
1673
  if (!llmApiKey) {
1589
1674
  me(`
@@ -1714,14 +1799,14 @@ var createMastraProject = async ({
1714
1799
  console.log("");
1715
1800
  return { projectName };
1716
1801
  };
1717
- var create = async (args) => {
1802
+ var create = async (args2) => {
1718
1803
  const { projectName } = await createMastraProject({
1719
- projectName: args?.projectName,
1720
- createVersionTag: args?.createVersionTag,
1721
- timeout: args?.timeout
1804
+ projectName: args2?.projectName,
1805
+ createVersionTag: args2?.createVersionTag,
1806
+ timeout: args2?.timeout
1722
1807
  });
1723
1808
  const directory = "/src";
1724
- if (!args.components || !args.llmProvider || !args.addExample) {
1809
+ if (!args2.components || !args2.llmProvider || !args2.addExample) {
1725
1810
  const result = await interactivePrompt();
1726
1811
  await init({
1727
1812
  ...result,
@@ -1730,7 +1815,7 @@ var create = async (args) => {
1730
1815
  postCreate({ projectName });
1731
1816
  return;
1732
1817
  }
1733
- const { components = [], llmProvider = "openai", addExample = false, llmApiKey } = args;
1818
+ const { components = [], llmProvider = "openai", addExample = false, llmApiKey } = args2;
1734
1819
  await init({
1735
1820
  directory,
1736
1821
  components,