mastra 0.4.3-alpha.0 → 0.4.3-alpha.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
2
|
import color2 from 'picocolors';
|
|
3
3
|
import child_process from 'node:child_process';
|
|
4
4
|
import util from 'node:util';
|
|
@@ -145,14 +145,6 @@ function getPackageManagerInstallCommand(pm) {
|
|
|
145
145
|
return "install";
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
function installMastraDocsMCPServer({
|
|
149
|
-
editor,
|
|
150
|
-
directory
|
|
151
|
-
}) {
|
|
152
|
-
if (!editor) return;
|
|
153
|
-
if (editor === `cursor`) return installCursorMCP(directory);
|
|
154
|
-
if (editor === `windsurf`) return installWindsurfMCP();
|
|
155
|
-
}
|
|
156
148
|
var args = ["-y", "@mastra/mcp-docs-server@latest"];
|
|
157
149
|
var mcpConfig = {
|
|
158
150
|
mcpServers: {
|
|
@@ -182,24 +174,30 @@ async function writeMergedConfig(configPath) {
|
|
|
182
174
|
spaces: 2
|
|
183
175
|
});
|
|
184
176
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
177
|
+
var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
178
|
+
async function installMastraDocsMCPServer({
|
|
179
|
+
editor,
|
|
180
|
+
directory
|
|
181
|
+
}) {
|
|
182
|
+
if (editor === `cursor`) await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"));
|
|
183
|
+
const windsurfIsInstalled = await globalWindsurfMCPIsAlreadyInstalled();
|
|
184
|
+
if (editor === `windsurf` && !windsurfIsInstalled) await writeMergedConfig(windsurfGlobalMCPConfigPath);
|
|
188
185
|
}
|
|
189
|
-
async function
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
186
|
+
async function globalWindsurfMCPIsAlreadyInstalled() {
|
|
187
|
+
if (!existsSync(windsurfGlobalMCPConfigPath)) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
const configContents = await readJSON(windsurfGlobalMCPConfigPath);
|
|
192
|
+
if (!configContents?.mcpServers) return false;
|
|
193
|
+
const hasMastraMCP = Object.values(configContents.mcpServers).some(
|
|
194
|
+
(server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
|
|
195
|
+
);
|
|
196
|
+
return hasMastraMCP;
|
|
197
|
+
} catch (e) {
|
|
198
|
+
console.error(e);
|
|
199
|
+
return false;
|
|
201
200
|
}
|
|
202
|
-
await writeMergedConfig(configPath);
|
|
203
201
|
}
|
|
204
202
|
|
|
205
203
|
// src/services/service.env.ts
|
|
@@ -660,16 +658,16 @@ var checkAndInstallCoreDeps = async () => {
|
|
|
660
658
|
var spinner = yoctoSpinner({ text: "Installing Mastra core dependencies\n" });
|
|
661
659
|
async function installCoreDeps() {
|
|
662
660
|
try {
|
|
663
|
-
const confirm2 = await
|
|
661
|
+
const confirm2 = await p.confirm({
|
|
664
662
|
message: "You do not have the @mastra/core package installed. Would you like to install it?",
|
|
665
663
|
initialValue: false
|
|
666
664
|
});
|
|
667
|
-
if (
|
|
668
|
-
|
|
665
|
+
if (p.isCancel(confirm2)) {
|
|
666
|
+
p.cancel("Installation Cancelled");
|
|
669
667
|
process.exit(0);
|
|
670
668
|
}
|
|
671
669
|
if (!confirm2) {
|
|
672
|
-
|
|
670
|
+
p.cancel("Installation Cancelled");
|
|
673
671
|
process.exit(0);
|
|
674
672
|
}
|
|
675
673
|
spinner.start();
|
|
@@ -726,15 +724,15 @@ var writeCodeSample = async (dirPath, component, llmProvider, importComponents)
|
|
|
726
724
|
}
|
|
727
725
|
};
|
|
728
726
|
var interactivePrompt = async () => {
|
|
729
|
-
|
|
730
|
-
const mastraProject = await
|
|
727
|
+
p.intro(color2.inverse("Mastra Init"));
|
|
728
|
+
const mastraProject = await p.group(
|
|
731
729
|
{
|
|
732
|
-
directory: () =>
|
|
730
|
+
directory: () => p.text({
|
|
733
731
|
message: "Where should we create the Mastra files? (default: src/)",
|
|
734
732
|
placeholder: "src/",
|
|
735
733
|
defaultValue: "src/"
|
|
736
734
|
}),
|
|
737
|
-
components: () =>
|
|
735
|
+
components: () => p.multiselect({
|
|
738
736
|
message: "Choose components to install:",
|
|
739
737
|
options: [
|
|
740
738
|
{ value: "agents", label: "Agents", hint: "recommended" },
|
|
@@ -744,11 +742,11 @@ var interactivePrompt = async () => {
|
|
|
744
742
|
}
|
|
745
743
|
]
|
|
746
744
|
}),
|
|
747
|
-
shouldAddTools: () =>
|
|
745
|
+
shouldAddTools: () => p.confirm({
|
|
748
746
|
message: "Add tools?",
|
|
749
747
|
initialValue: false
|
|
750
748
|
}),
|
|
751
|
-
llmProvider: () =>
|
|
749
|
+
llmProvider: () => p.select({
|
|
752
750
|
message: "Select default provider:",
|
|
753
751
|
options: [
|
|
754
752
|
{ value: "openai", label: "OpenAI", hint: "recommended" },
|
|
@@ -759,7 +757,7 @@ var interactivePrompt = async () => {
|
|
|
759
757
|
]
|
|
760
758
|
}),
|
|
761
759
|
llmApiKey: async ({ results: { llmProvider } }) => {
|
|
762
|
-
const keyChoice = await
|
|
760
|
+
const keyChoice = await p.select({
|
|
763
761
|
message: `Enter your ${llmProvider} API key?`,
|
|
764
762
|
options: [
|
|
765
763
|
{ value: "skip", label: "Skip for now", hint: "default" },
|
|
@@ -768,40 +766,63 @@ var interactivePrompt = async () => {
|
|
|
768
766
|
initialValue: "skip"
|
|
769
767
|
});
|
|
770
768
|
if (keyChoice === "enter") {
|
|
771
|
-
return
|
|
769
|
+
return p.text({
|
|
772
770
|
message: "Enter your API key:",
|
|
773
771
|
placeholder: "sk-..."
|
|
774
772
|
});
|
|
775
773
|
}
|
|
776
774
|
return void 0;
|
|
777
775
|
},
|
|
778
|
-
addExample: () =>
|
|
776
|
+
addExample: () => p.confirm({
|
|
779
777
|
message: "Add example",
|
|
780
778
|
initialValue: false
|
|
781
779
|
}),
|
|
782
780
|
configureEditorWithDocsMCP: async () => {
|
|
783
|
-
const
|
|
781
|
+
const windsurfIsAlreadyInstalled = await globalWindsurfMCPIsAlreadyInstalled();
|
|
782
|
+
const editor = await p.select({
|
|
784
783
|
message: `Make your AI IDE into a Mastra expert? (installs Mastra docs MCP server)`,
|
|
785
784
|
options: [
|
|
786
785
|
{ value: "skip", label: "Skip for now", hint: "default" },
|
|
787
786
|
{ value: "cursor", label: "Cursor" },
|
|
788
|
-
{
|
|
787
|
+
{
|
|
788
|
+
value: "windsurf",
|
|
789
|
+
label: "Windsurf",
|
|
790
|
+
hint: windsurfIsAlreadyInstalled ? `Already installed` : void 0
|
|
791
|
+
}
|
|
789
792
|
]
|
|
790
793
|
});
|
|
791
794
|
if (editor === `skip`) return void 0;
|
|
795
|
+
if (editor === `windsurf` && windsurfIsAlreadyInstalled) {
|
|
796
|
+
p.log.message(`
|
|
797
|
+
Windsurf is already installed, skipping.`);
|
|
798
|
+
return void 0;
|
|
799
|
+
}
|
|
792
800
|
if (editor === `cursor`) {
|
|
793
|
-
|
|
801
|
+
p.log.message(
|
|
794
802
|
`
|
|
795
803
|
Note: you will need to go into Cursor Settings -> MCP Settings and manually enable the installed Mastra MCP server.
|
|
796
804
|
`
|
|
797
805
|
);
|
|
798
806
|
}
|
|
807
|
+
if (editor === `windsurf`) {
|
|
808
|
+
const confirm2 = await p.select({
|
|
809
|
+
message: `Windsurf only supports a global MCP config (at ${windsurfGlobalMCPConfigPath}) is it ok to add/update that global config?
|
|
810
|
+
This means the Mastra docs MCP server will be available in all your Windsurf projects.`,
|
|
811
|
+
options: [
|
|
812
|
+
{ value: "yes", label: "Yes, I understand" },
|
|
813
|
+
{ value: "skip", label: "No, skip for now" }
|
|
814
|
+
]
|
|
815
|
+
});
|
|
816
|
+
if (confirm2 !== `yes`) {
|
|
817
|
+
return void 0;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
799
820
|
return editor;
|
|
800
821
|
}
|
|
801
822
|
},
|
|
802
823
|
{
|
|
803
824
|
onCancel: () => {
|
|
804
|
-
|
|
825
|
+
p.cancel("Operation cancelled.");
|
|
805
826
|
process.exit(0);
|
|
806
827
|
}
|
|
807
828
|
}
|
|
@@ -828,7 +849,7 @@ var checkPkgJson = async () => {
|
|
|
828
849
|
};
|
|
829
850
|
|
|
830
851
|
// src/commands/init/init.ts
|
|
831
|
-
var s =
|
|
852
|
+
var s = p.spinner();
|
|
832
853
|
var exec2 = util.promisify(child_process.exec);
|
|
833
854
|
var init = async ({
|
|
834
855
|
directory,
|
|
@@ -877,14 +898,14 @@ var init = async ({
|
|
|
877
898
|
}
|
|
878
899
|
s.stop();
|
|
879
900
|
if (!llmApiKey) {
|
|
880
|
-
|
|
901
|
+
p.note(`
|
|
881
902
|
${color2.green("Mastra initialized successfully!")}
|
|
882
903
|
|
|
883
904
|
Add your ${color2.cyan(key)} as an environment variable
|
|
884
905
|
in your ${color2.cyan(".env.development")} file
|
|
885
906
|
`);
|
|
886
907
|
} else {
|
|
887
|
-
|
|
908
|
+
p.note(`
|
|
888
909
|
${color2.green("Mastra initialized successfully!")}
|
|
889
910
|
`);
|
|
890
911
|
}
|
|
@@ -927,17 +948,17 @@ var createMastraProject = async ({
|
|
|
927
948
|
createVersionTag,
|
|
928
949
|
timeout
|
|
929
950
|
}) => {
|
|
930
|
-
|
|
931
|
-
const projectName = name ?? await
|
|
951
|
+
p.intro(color2.inverse("Mastra Create"));
|
|
952
|
+
const projectName = name ?? await p.text({
|
|
932
953
|
message: "What do you want to name your project?",
|
|
933
954
|
placeholder: "my-mastra-app",
|
|
934
955
|
defaultValue: "my-mastra-app"
|
|
935
956
|
});
|
|
936
|
-
if (
|
|
937
|
-
|
|
957
|
+
if (p.isCancel(projectName)) {
|
|
958
|
+
p.cancel("Operation cancelled");
|
|
938
959
|
process.exit(0);
|
|
939
960
|
}
|
|
940
|
-
const s2 =
|
|
961
|
+
const s2 = p.spinner();
|
|
941
962
|
s2.start("Creating project");
|
|
942
963
|
try {
|
|
943
964
|
await fs4.mkdir(projectName);
|
|
@@ -1001,7 +1022,7 @@ var createMastraProject = async ({
|
|
|
1001
1022
|
await exec3(`echo .env >> .gitignore`);
|
|
1002
1023
|
await exec3(`echo *.db >> .gitignore`);
|
|
1003
1024
|
s2.stop(".gitignore added");
|
|
1004
|
-
|
|
1025
|
+
p.outro("Project created successfully");
|
|
1005
1026
|
console.log("");
|
|
1006
1027
|
return { projectName };
|
|
1007
1028
|
};
|
|
@@ -1034,7 +1055,7 @@ var create = async (args2) => {
|
|
|
1034
1055
|
postCreate({ projectName });
|
|
1035
1056
|
};
|
|
1036
1057
|
var postCreate = ({ projectName }) => {
|
|
1037
|
-
|
|
1058
|
+
p.outro(`
|
|
1038
1059
|
${color2.green("To start your project:")}
|
|
1039
1060
|
|
|
1040
1061
|
${color2.cyan("cd")} ${projectName}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { create } from '../../chunk-
|
|
1
|
+
export { create } from '../../chunk-4QQ2IFQI.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import { PosthogAnalytics } from './chunk-SLGHDOYI.js';
|
|
3
3
|
export { PosthogAnalytics } from './chunk-SLGHDOYI.js';
|
|
4
|
-
import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, logger, FileService as FileService$1 } from './chunk-
|
|
5
|
-
export { create } from './chunk-
|
|
4
|
+
import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, logger, FileService as FileService$1 } from './chunk-4QQ2IFQI.js';
|
|
5
|
+
export { create } from './chunk-4QQ2IFQI.js';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
7
|
import { join as join$1, dirname, basename } from 'node:path';
|
|
8
8
|
import { getWatcherInputOptions, writeTelemetryConfig, createWatcher, FileService as FileService$2 } from '@mastra/deployer/build';
|