create-mastra 0.0.0-revert-schema-20250416221206 → 0.0.0-separate-trace-data-from-component-20250501042644
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 +88 -14
- package/dist/index.js.map +1 -1
- package/dist/templates/dev.entry.js +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1030,20 +1030,41 @@ async function writeMergedConfig(configPath) {
|
|
|
1030
1030
|
});
|
|
1031
1031
|
}
|
|
1032
1032
|
var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
1033
|
+
var cursorGlobalMCPConfigPath = path.join(os.homedir(), ".cursor", "mcp.json");
|
|
1033
1034
|
async function installMastraDocsMCPServer({
|
|
1034
1035
|
editor,
|
|
1035
1036
|
directory
|
|
1036
1037
|
}) {
|
|
1037
|
-
if (editor === `cursor`)
|
|
1038
|
-
|
|
1039
|
-
|
|
1038
|
+
if (editor === `cursor`) {
|
|
1039
|
+
await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"));
|
|
1040
|
+
}
|
|
1041
|
+
if (editor === `cursor-global`) {
|
|
1042
|
+
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
1043
|
+
if (alreadyInstalled) {
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
await writeMergedConfig(cursorGlobalMCPConfigPath);
|
|
1047
|
+
}
|
|
1048
|
+
if (editor === `windsurf`) {
|
|
1049
|
+
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
1050
|
+
if (alreadyInstalled) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
await writeMergedConfig(windsurfGlobalMCPConfigPath);
|
|
1054
|
+
}
|
|
1040
1055
|
}
|
|
1041
|
-
async function
|
|
1042
|
-
|
|
1056
|
+
async function globalMCPIsAlreadyInstalled(editor) {
|
|
1057
|
+
let configPath = ``;
|
|
1058
|
+
if (editor === "windsurf") {
|
|
1059
|
+
configPath = windsurfGlobalMCPConfigPath;
|
|
1060
|
+
} else if (editor === "cursor-global") {
|
|
1061
|
+
configPath = cursorGlobalMCPConfigPath;
|
|
1062
|
+
}
|
|
1063
|
+
if (!configPath || !existsSync(configPath)) {
|
|
1043
1064
|
return false;
|
|
1044
1065
|
}
|
|
1045
1066
|
try {
|
|
1046
|
-
const configContents = await readJSON(
|
|
1067
|
+
const configContents = await readJSON(configPath);
|
|
1047
1068
|
if (!configContents?.mcpServers) return false;
|
|
1048
1069
|
const hasMastraMCP = Object.values(configContents.mcpServers).some(
|
|
1049
1070
|
(server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
|
|
@@ -1219,6 +1240,7 @@ async function writeAgentSample(llmProvider, destPath, addExampleTool) {
|
|
|
1219
1240
|
const content = `
|
|
1220
1241
|
${providerImport}
|
|
1221
1242
|
import { Agent } from '@mastra/core/agent';
|
|
1243
|
+
import { Memory } from '@mastra/memory';
|
|
1222
1244
|
${addExampleTool ? `import { weatherTool } from '../tools';` : ""}
|
|
1223
1245
|
|
|
1224
1246
|
export const weatherAgent = new Agent({
|
|
@@ -1226,6 +1248,15 @@ export const weatherAgent = new Agent({
|
|
|
1226
1248
|
instructions: \`${instructions}\`,
|
|
1227
1249
|
model: ${modelItem},
|
|
1228
1250
|
${addExampleTool ? "tools: { weatherTool }," : ""}
|
|
1251
|
+
memory: new Memory({
|
|
1252
|
+
options: {
|
|
1253
|
+
lastMessages: 10,
|
|
1254
|
+
semanticRecall: false,
|
|
1255
|
+
threads: {
|
|
1256
|
+
generateTitle: false
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
})
|
|
1229
1260
|
});
|
|
1230
1261
|
`;
|
|
1231
1262
|
const formattedContent = await prettier.format(content, {
|
|
@@ -1480,11 +1511,16 @@ export const mastra = new Mastra()
|
|
|
1480
1511
|
`
|
|
1481
1512
|
import { Mastra } from '@mastra/core/mastra';
|
|
1482
1513
|
import { createLogger } from '@mastra/core/logger';
|
|
1514
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
1483
1515
|
${addWorkflow ? `import { weatherWorkflow } from './workflows';` : ""}
|
|
1484
1516
|
${addAgent ? `import { weatherAgent } from './agents';` : ""}
|
|
1485
1517
|
|
|
1486
1518
|
export const mastra = new Mastra({
|
|
1487
1519
|
${filteredExports.join("\n ")}
|
|
1520
|
+
storage: new LibSQLStore({
|
|
1521
|
+
// stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
|
|
1522
|
+
url: ":memory:",
|
|
1523
|
+
}),
|
|
1488
1524
|
logger: createLogger({
|
|
1489
1525
|
name: 'Mastra',
|
|
1490
1526
|
level: 'info',
|
|
@@ -1597,12 +1633,22 @@ var interactivePrompt = async () => {
|
|
|
1597
1633
|
initialValue: false
|
|
1598
1634
|
}),
|
|
1599
1635
|
configureEditorWithDocsMCP: async () => {
|
|
1600
|
-
const windsurfIsAlreadyInstalled = await
|
|
1636
|
+
const windsurfIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`windsurf`);
|
|
1637
|
+
const cursorIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`cursor`);
|
|
1601
1638
|
const editor = await le({
|
|
1602
1639
|
message: `Make your AI IDE into a Mastra expert? (installs Mastra docs MCP server)`,
|
|
1603
1640
|
options: [
|
|
1604
1641
|
{ value: "skip", label: "Skip for now", hint: "default" },
|
|
1605
|
-
{
|
|
1642
|
+
{
|
|
1643
|
+
value: "cursor",
|
|
1644
|
+
label: "Cursor (project only)",
|
|
1645
|
+
hint: cursorIsAlreadyInstalled ? `Already installed globally` : void 0
|
|
1646
|
+
},
|
|
1647
|
+
{
|
|
1648
|
+
value: "cursor-global",
|
|
1649
|
+
label: "Cursor (global, all projects)",
|
|
1650
|
+
hint: cursorIsAlreadyInstalled ? `Already installed` : void 0
|
|
1651
|
+
},
|
|
1606
1652
|
{
|
|
1607
1653
|
value: "windsurf",
|
|
1608
1654
|
label: "Windsurf",
|
|
@@ -1623,6 +1669,18 @@ Note: you will need to go into Cursor Settings -> MCP Settings and manually enab
|
|
|
1623
1669
|
`
|
|
1624
1670
|
);
|
|
1625
1671
|
}
|
|
1672
|
+
if (editor === `cursor-global`) {
|
|
1673
|
+
const confirm2 = await le({
|
|
1674
|
+
message: `Global install will add/update ${cursorGlobalMCPConfigPath} and make the Mastra docs MCP server available in all your Cursor projects. Continue?`,
|
|
1675
|
+
options: [
|
|
1676
|
+
{ value: "yes", label: "Yes, I understand" },
|
|
1677
|
+
{ value: "skip", label: "No, skip for now" }
|
|
1678
|
+
]
|
|
1679
|
+
});
|
|
1680
|
+
if (confirm2 !== `yes`) {
|
|
1681
|
+
return void 0;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1626
1684
|
if (editor === `windsurf`) {
|
|
1627
1685
|
const confirm2 = await le({
|
|
1628
1686
|
message: `Windsurf only supports a global MCP config (at ${windsurfGlobalMCPConfigPath}) is it ok to add/update that global config?
|
|
@@ -1684,6 +1742,15 @@ var init = async ({
|
|
|
1684
1742
|
(component) => writeCodeSample(dirPath, component, llmProvider, components)
|
|
1685
1743
|
)
|
|
1686
1744
|
]);
|
|
1745
|
+
const depService = new DepsService();
|
|
1746
|
+
const needsLibsql = await depService.checkDependencies(["@mastra/libsql"]) !== `ok`;
|
|
1747
|
+
if (needsLibsql) {
|
|
1748
|
+
await depService.installPackages(["@mastra/libsql"]);
|
|
1749
|
+
}
|
|
1750
|
+
const needsMemory = components.includes(`agents`) && await depService.checkDependencies(["@mastra/memory"]) !== `ok`;
|
|
1751
|
+
if (needsMemory) {
|
|
1752
|
+
await depService.installPackages(["@mastra/memory"]);
|
|
1753
|
+
}
|
|
1687
1754
|
}
|
|
1688
1755
|
const key = await getAPIKey(llmProvider || "openai");
|
|
1689
1756
|
const aiSdkPackage = getAISDKPackage(llmProvider);
|
|
@@ -1823,9 +1890,11 @@ var createMastraProject = async ({
|
|
|
1823
1890
|
const versionTag = createVersionTag ? `@${createVersionTag}` : "@latest";
|
|
1824
1891
|
await installMastraDependency(pm, "mastra", versionTag, true, timeout);
|
|
1825
1892
|
s2.stop("mastra installed");
|
|
1826
|
-
s2.start("Installing
|
|
1893
|
+
s2.start("Installing dependencies");
|
|
1827
1894
|
await installMastraDependency(pm, "@mastra/core", versionTag, false, timeout);
|
|
1828
|
-
|
|
1895
|
+
await installMastraDependency(pm, "@mastra/libsql", versionTag, false, timeout);
|
|
1896
|
+
await installMastraDependency(pm, "@mastra/memory", versionTag, false, timeout);
|
|
1897
|
+
s2.stop("Dependencies installed");
|
|
1829
1898
|
s2.start("Adding .gitignore");
|
|
1830
1899
|
await exec3(`echo output.txt >> .gitignore`);
|
|
1831
1900
|
await exec3(`echo node_modules >> .gitignore`);
|
|
@@ -1846,8 +1915,8 @@ var create = async (args2) => {
|
|
|
1846
1915
|
createVersionTag: args2?.createVersionTag,
|
|
1847
1916
|
timeout: args2?.timeout
|
|
1848
1917
|
});
|
|
1849
|
-
const directory = "/
|
|
1850
|
-
if (
|
|
1918
|
+
const directory = args2.directory || "src/";
|
|
1919
|
+
if (args2.components === void 0 || args2.llmProvider === void 0 || args2.addExample === void 0) {
|
|
1851
1920
|
const result = await interactivePrompt();
|
|
1852
1921
|
await init({
|
|
1853
1922
|
...result,
|
|
@@ -1913,7 +1982,11 @@ program.version(`${version}`, "-v, --version").description(`create-mastra ${vers
|
|
|
1913
1982
|
} catch {
|
|
1914
1983
|
}
|
|
1915
1984
|
});
|
|
1916
|
-
program.name("create-mastra").description("Create a new Mastra project").argument("[project-name]", "Directory name of the project").option(
|
|
1985
|
+
program.name("create-mastra").description("Create a new Mastra project").argument("[project-name]", "Directory name of the project").option(
|
|
1986
|
+
"-p, --project-name <string>",
|
|
1987
|
+
"Project name that will be used in package.json and as the project directory name."
|
|
1988
|
+
).option("--default", "Quick start with defaults(src, OpenAI, no examples)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows)").option("-l, --llm <model-provider>", "Default model provider (openai, anthropic, groq, google, or cerebras)").option("-k, --llm-api-key <api-key>", "API key for the model provider").option("-e, --example", "Include example code").option("-n, --no-example", "Do not include example code").option("-t, --timeout [timeout]", "Configurable timeout for package installation, defaults to 60000 ms").option("-d, --dir <directory>", "Target directory for Mastra source code (default: src/)").action(async (projectNameArg, args) => {
|
|
1989
|
+
const projectName = projectNameArg || args.projectName;
|
|
1917
1990
|
const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
|
|
1918
1991
|
if (args.default) {
|
|
1919
1992
|
await create({
|
|
@@ -1932,7 +2005,8 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
|
|
|
1932
2005
|
llmApiKey: args["llm-api-key"],
|
|
1933
2006
|
createVersionTag,
|
|
1934
2007
|
timeout,
|
|
1935
|
-
projectName
|
|
2008
|
+
projectName,
|
|
2009
|
+
directory: args.dir
|
|
1936
2010
|
});
|
|
1937
2011
|
});
|
|
1938
2012
|
program.parse(process.argv);
|