create-mastra 0.0.0-mastra-2973-fast-mcp-removal-20250409163028 → 0.0.0-mastra-3338-mastra-memory-pinecone-20250507174328
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/{LICENSE → LICENSE.md} +3 -1
- package/README.md +0 -1
- package/dist/index.js +123 -66
- package/dist/index.js.map +1 -1
- package/dist/templates/dev.entry.js +7 -5
- package/package.json +6 -5
package/{LICENSE → LICENSE.md}
RENAMED
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -71,7 +71,8 @@ var PosthogAnalytics = class {
|
|
|
71
71
|
this.client = new PostHog(apiKey, {
|
|
72
72
|
host,
|
|
73
73
|
flushAt: 1,
|
|
74
|
-
flushInterval: 0
|
|
74
|
+
flushInterval: 0,
|
|
75
|
+
disableGeoip: false
|
|
75
76
|
});
|
|
76
77
|
this.captureSessionStart();
|
|
77
78
|
process.on("exit", () => {
|
|
@@ -97,8 +98,7 @@ var PosthogAnalytics = class {
|
|
|
97
98
|
platform: process.arch,
|
|
98
99
|
session_id: this.sessionId,
|
|
99
100
|
cli_version: this.version || "unknown",
|
|
100
|
-
machine_id: os.hostname()
|
|
101
|
-
geoip_disable: false
|
|
101
|
+
machine_id: os.hostname()
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
captureSessionStart() {
|
|
@@ -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,8 @@ 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';
|
|
1244
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
1222
1245
|
${addExampleTool ? `import { weatherTool } from '../tools';` : ""}
|
|
1223
1246
|
|
|
1224
1247
|
export const weatherAgent = new Agent({
|
|
@@ -1226,6 +1249,18 @@ export const weatherAgent = new Agent({
|
|
|
1226
1249
|
instructions: \`${instructions}\`,
|
|
1227
1250
|
model: ${modelItem},
|
|
1228
1251
|
${addExampleTool ? "tools: { weatherTool }," : ""}
|
|
1252
|
+
memory: new Memory({
|
|
1253
|
+
storage: new LibSQLStore({
|
|
1254
|
+
url: "file:../mastra.db", // path is relative to the .mastra/output directory
|
|
1255
|
+
}),
|
|
1256
|
+
options: {
|
|
1257
|
+
lastMessages: 10,
|
|
1258
|
+
semanticRecall: false,
|
|
1259
|
+
threads: {
|
|
1260
|
+
generateTitle: false
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
})
|
|
1229
1264
|
});
|
|
1230
1265
|
`;
|
|
1231
1266
|
const formattedContent = await prettier.format(content, {
|
|
@@ -1480,11 +1515,16 @@ export const mastra = new Mastra()
|
|
|
1480
1515
|
`
|
|
1481
1516
|
import { Mastra } from '@mastra/core/mastra';
|
|
1482
1517
|
import { createLogger } from '@mastra/core/logger';
|
|
1518
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
1483
1519
|
${addWorkflow ? `import { weatherWorkflow } from './workflows';` : ""}
|
|
1484
1520
|
${addAgent ? `import { weatherAgent } from './agents';` : ""}
|
|
1485
1521
|
|
|
1486
1522
|
export const mastra = new Mastra({
|
|
1487
1523
|
${filteredExports.join("\n ")}
|
|
1524
|
+
storage: new LibSQLStore({
|
|
1525
|
+
// stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
|
|
1526
|
+
url: ":memory:",
|
|
1527
|
+
}),
|
|
1488
1528
|
logger: createLogger({
|
|
1489
1529
|
name: 'Mastra',
|
|
1490
1530
|
level: 'info',
|
|
@@ -1597,12 +1637,22 @@ var interactivePrompt = async () => {
|
|
|
1597
1637
|
initialValue: false
|
|
1598
1638
|
}),
|
|
1599
1639
|
configureEditorWithDocsMCP: async () => {
|
|
1600
|
-
const windsurfIsAlreadyInstalled = await
|
|
1640
|
+
const windsurfIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`windsurf`);
|
|
1641
|
+
const cursorIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`cursor`);
|
|
1601
1642
|
const editor = await le({
|
|
1602
1643
|
message: `Make your AI IDE into a Mastra expert? (installs Mastra docs MCP server)`,
|
|
1603
1644
|
options: [
|
|
1604
1645
|
{ value: "skip", label: "Skip for now", hint: "default" },
|
|
1605
|
-
{
|
|
1646
|
+
{
|
|
1647
|
+
value: "cursor",
|
|
1648
|
+
label: "Cursor (project only)",
|
|
1649
|
+
hint: cursorIsAlreadyInstalled ? `Already installed globally` : void 0
|
|
1650
|
+
},
|
|
1651
|
+
{
|
|
1652
|
+
value: "cursor-global",
|
|
1653
|
+
label: "Cursor (global, all projects)",
|
|
1654
|
+
hint: cursorIsAlreadyInstalled ? `Already installed` : void 0
|
|
1655
|
+
},
|
|
1606
1656
|
{
|
|
1607
1657
|
value: "windsurf",
|
|
1608
1658
|
label: "Windsurf",
|
|
@@ -1623,6 +1673,18 @@ Note: you will need to go into Cursor Settings -> MCP Settings and manually enab
|
|
|
1623
1673
|
`
|
|
1624
1674
|
);
|
|
1625
1675
|
}
|
|
1676
|
+
if (editor === `cursor-global`) {
|
|
1677
|
+
const confirm2 = await le({
|
|
1678
|
+
message: `Global install will add/update ${cursorGlobalMCPConfigPath} and make the Mastra docs MCP server available in all your Cursor projects. Continue?`,
|
|
1679
|
+
options: [
|
|
1680
|
+
{ value: "yes", label: "Yes, I understand" },
|
|
1681
|
+
{ value: "skip", label: "No, skip for now" }
|
|
1682
|
+
]
|
|
1683
|
+
});
|
|
1684
|
+
if (confirm2 !== `yes`) {
|
|
1685
|
+
return void 0;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1626
1688
|
if (editor === `windsurf`) {
|
|
1627
1689
|
const confirm2 = await le({
|
|
1628
1690
|
message: `Windsurf only supports a global MCP config (at ${windsurfGlobalMCPConfigPath}) is it ok to add/update that global config?
|
|
@@ -1684,6 +1746,15 @@ var init = async ({
|
|
|
1684
1746
|
(component) => writeCodeSample(dirPath, component, llmProvider, components)
|
|
1685
1747
|
)
|
|
1686
1748
|
]);
|
|
1749
|
+
const depService = new DepsService();
|
|
1750
|
+
const needsLibsql = await depService.checkDependencies(["@mastra/libsql"]) !== `ok`;
|
|
1751
|
+
if (needsLibsql) {
|
|
1752
|
+
await depService.installPackages(["@mastra/libsql"]);
|
|
1753
|
+
}
|
|
1754
|
+
const needsMemory = components.includes(`agents`) && await depService.checkDependencies(["@mastra/memory"]) !== `ok`;
|
|
1755
|
+
if (needsMemory) {
|
|
1756
|
+
await depService.installPackages(["@mastra/memory"]);
|
|
1757
|
+
}
|
|
1687
1758
|
}
|
|
1688
1759
|
const key = await getAPIKey(llmProvider || "openai");
|
|
1689
1760
|
const aiSdkPackage = getAISDKPackage(llmProvider);
|
|
@@ -1744,6 +1815,21 @@ var execWithTimeout = async (command, timeoutMs) => {
|
|
|
1744
1815
|
throw error;
|
|
1745
1816
|
}
|
|
1746
1817
|
};
|
|
1818
|
+
async function installMastraDependency(pm, dependency, versionTag, isDev, timeout) {
|
|
1819
|
+
let installCommand = getPackageManagerInstallCommand(pm);
|
|
1820
|
+
if (isDev) {
|
|
1821
|
+
installCommand = `${installCommand} --save-dev`;
|
|
1822
|
+
}
|
|
1823
|
+
try {
|
|
1824
|
+
await execWithTimeout(`${pm} ${installCommand} ${dependency}${versionTag}`, timeout);
|
|
1825
|
+
} catch (err) {
|
|
1826
|
+
console.log("err", err);
|
|
1827
|
+
if (versionTag === "@latest") {
|
|
1828
|
+
throw err;
|
|
1829
|
+
}
|
|
1830
|
+
await execWithTimeout(`${pm} ${installCommand} ${dependency}@latest`, timeout);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1747
1833
|
var createMastraProject = async ({
|
|
1748
1834
|
projectName: name,
|
|
1749
1835
|
createVersionTag,
|
|
@@ -1780,12 +1866,13 @@ var createMastraProject = async ({
|
|
|
1780
1866
|
await exec3(`npm pkg set type="module"`);
|
|
1781
1867
|
const depsService = new DepsService();
|
|
1782
1868
|
await depsService.addScriptsToPackageJson({
|
|
1783
|
-
dev: "mastra dev"
|
|
1869
|
+
dev: "mastra dev",
|
|
1870
|
+
build: "mastra build"
|
|
1784
1871
|
});
|
|
1785
1872
|
s2.stop("Project created");
|
|
1786
1873
|
s2.start(`Installing ${pm} dependencies`);
|
|
1787
1874
|
await exec3(`${pm} ${installCommand} zod`);
|
|
1788
|
-
await exec3(`${pm} ${installCommand} typescript
|
|
1875
|
+
await exec3(`${pm} ${installCommand} typescript @types/node --save-dev`);
|
|
1789
1876
|
await exec3(`echo '{
|
|
1790
1877
|
"compilerOptions": {
|
|
1791
1878
|
"target": "ES2022",
|
|
@@ -1795,25 +1882,23 @@ var createMastraProject = async ({
|
|
|
1795
1882
|
"forceConsistentCasingInFileNames": true,
|
|
1796
1883
|
"strict": true,
|
|
1797
1884
|
"skipLibCheck": true,
|
|
1885
|
+
"noEmit": true,
|
|
1798
1886
|
"outDir": "dist"
|
|
1799
1887
|
},
|
|
1800
1888
|
"include": [
|
|
1801
1889
|
"src/**/*"
|
|
1802
|
-
],
|
|
1803
|
-
"exclude": [
|
|
1804
|
-
"node_modules",
|
|
1805
|
-
"dist",
|
|
1806
|
-
".mastra"
|
|
1807
1890
|
]
|
|
1808
1891
|
}' > tsconfig.json`);
|
|
1809
1892
|
s2.stop(`${pm} dependencies installed`);
|
|
1810
1893
|
s2.start("Installing mastra");
|
|
1811
1894
|
const versionTag = createVersionTag ? `@${createVersionTag}` : "@latest";
|
|
1812
|
-
await
|
|
1895
|
+
await installMastraDependency(pm, "mastra", versionTag, true, timeout);
|
|
1813
1896
|
s2.stop("mastra installed");
|
|
1814
|
-
s2.start("Installing
|
|
1815
|
-
await
|
|
1816
|
-
|
|
1897
|
+
s2.start("Installing dependencies");
|
|
1898
|
+
await installMastraDependency(pm, "@mastra/core", versionTag, false, timeout);
|
|
1899
|
+
await installMastraDependency(pm, "@mastra/libsql", versionTag, false, timeout);
|
|
1900
|
+
await installMastraDependency(pm, "@mastra/memory", versionTag, false, timeout);
|
|
1901
|
+
s2.stop("Dependencies installed");
|
|
1817
1902
|
s2.start("Adding .gitignore");
|
|
1818
1903
|
await exec3(`echo output.txt >> .gitignore`);
|
|
1819
1904
|
await exec3(`echo node_modules >> .gitignore`);
|
|
@@ -1834,8 +1919,8 @@ var create = async (args2) => {
|
|
|
1834
1919
|
createVersionTag: args2?.createVersionTag,
|
|
1835
1920
|
timeout: args2?.timeout
|
|
1836
1921
|
});
|
|
1837
|
-
const directory = "/
|
|
1838
|
-
if (
|
|
1922
|
+
const directory = args2.directory || "src/";
|
|
1923
|
+
if (args2.components === void 0 || args2.llmProvider === void 0 || args2.addExample === void 0) {
|
|
1839
1924
|
const result = await interactivePrompt();
|
|
1840
1925
|
await init({
|
|
1841
1926
|
...result,
|
|
@@ -1870,48 +1955,14 @@ async function getPackageVersion() {
|
|
|
1870
1955
|
const content = await fsExtra.readJSON(pkgJsonPath);
|
|
1871
1956
|
return content.version;
|
|
1872
1957
|
}
|
|
1873
|
-
async function tryReadPackageJson(paths) {
|
|
1874
|
-
let lastError;
|
|
1875
|
-
for (const path2 of paths) {
|
|
1876
|
-
try {
|
|
1877
|
-
const content = await fsExtra.readJSON(path2);
|
|
1878
|
-
if (content.name === "create-mastra") {
|
|
1879
|
-
return content;
|
|
1880
|
-
}
|
|
1881
|
-
} catch (err) {
|
|
1882
|
-
lastError = err;
|
|
1883
|
-
continue;
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
throw lastError || new Error("Could not find create-mastra package.json in any of the expected locations");
|
|
1887
|
-
}
|
|
1888
1958
|
async function getCreateVersionTag() {
|
|
1889
1959
|
try {
|
|
1890
|
-
const
|
|
1891
|
-
const
|
|
1892
|
-
const
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
path.join(binDir, "..", "..", "..", "package.json"),
|
|
1897
|
-
path.join(binDir, "..", "..", "..", "..", "package.json"),
|
|
1898
|
-
// Standard node_modules paths
|
|
1899
|
-
path.join(binDir, "..", "create-mastra", "package.json"),
|
|
1900
|
-
path.join(binDir, "..", "..", "create-mastra", "package.json"),
|
|
1901
|
-
path.join(binDir, "..", "..", "..", "create-mastra", "package.json"),
|
|
1902
|
-
path.join(binDir, "..", "..", "..", "..", "create-mastra", "package.json"),
|
|
1903
|
-
// pnpm specific paths (.pnpm directory)
|
|
1904
|
-
path.join(binDir, "..", ".pnpm", "create-mastra@*", "node_modules", "create-mastra", "package.json"),
|
|
1905
|
-
path.join(binDir, "..", "..", ".pnpm", "create-mastra@*", "node_modules", "create-mastra", "package.json"),
|
|
1906
|
-
// pnpm dlx specific path
|
|
1907
|
-
path.join(binDir, "..", "..", "package.json"),
|
|
1908
|
-
path.join(binDir, "..", "..", "node_modules", "create-mastra", "package.json")
|
|
1909
|
-
];
|
|
1910
|
-
const content = await tryReadPackageJson(possiblePaths);
|
|
1911
|
-
if (content.version?.includes("-")) {
|
|
1912
|
-
const tag = content.version.split("-")[1].split(".")[0];
|
|
1913
|
-
return tag;
|
|
1914
|
-
}
|
|
1960
|
+
const pkgPath = fileURLToPath(import.meta.resolve("create-mastra/package.json"));
|
|
1961
|
+
const json = await fsExtra.readJSON(pkgPath);
|
|
1962
|
+
const { stdout } = await execa("npm", ["dist-tag", "create-mastra"]);
|
|
1963
|
+
const tagLine = stdout.split("\n").find((distLine) => distLine.includes(`: ${json.version}`));
|
|
1964
|
+
const tag = tagLine ? tagLine.split(":")[0].trim() : "latest";
|
|
1965
|
+
return tag;
|
|
1915
1966
|
} catch {
|
|
1916
1967
|
console.error('We could not resolve the create-mastra version tag, falling back to "latest"');
|
|
1917
1968
|
}
|
|
@@ -1935,7 +1986,11 @@ program.version(`${version}`, "-v, --version").description(`create-mastra ${vers
|
|
|
1935
1986
|
} catch {
|
|
1936
1987
|
}
|
|
1937
1988
|
});
|
|
1938
|
-
program.name("create-mastra").description("Create a new Mastra project").
|
|
1989
|
+
program.name("create-mastra").description("Create a new Mastra project").argument("[project-name]", "Directory name of the project").option(
|
|
1990
|
+
"-p, --project-name <string>",
|
|
1991
|
+
"Project name that will be used in package.json and as the project directory name."
|
|
1992
|
+
).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) => {
|
|
1993
|
+
const projectName = projectNameArg || args.projectName;
|
|
1939
1994
|
const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
|
|
1940
1995
|
if (args.default) {
|
|
1941
1996
|
await create({
|
|
@@ -1953,7 +2008,9 @@ program.name("create-mastra").description("Create a new Mastra project").option(
|
|
|
1953
2008
|
addExample: args.example,
|
|
1954
2009
|
llmApiKey: args["llm-api-key"],
|
|
1955
2010
|
createVersionTag,
|
|
1956
|
-
timeout
|
|
2011
|
+
timeout,
|
|
2012
|
+
projectName,
|
|
2013
|
+
directory: args.dir
|
|
1957
2014
|
});
|
|
1958
2015
|
});
|
|
1959
2016
|
program.parse(process.argv);
|