create-mastra 0.0.0-vnextAgentNetwork-20250602084555 → 0.0.0-vnextAgentNetwork-20250602134426
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 +48 -22
- package/dist/index.js.map +1 -1
- package/dist/templates/dev.entry.js +0 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
4
4
|
import * as fs3__default from 'node:fs';
|
|
5
5
|
import fs3__default__default, { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
6
6
|
import os from 'node:os';
|
|
7
|
-
import
|
|
7
|
+
import path2, { dirname } from 'node:path';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
9
|
import { PostHog } from 'posthog-node';
|
|
10
10
|
import h, { stdin, stdout } from 'node:process';
|
|
@@ -22,7 +22,7 @@ import pretty from 'pino-pretty';
|
|
|
22
22
|
import fsExtra from 'fs-extra';
|
|
23
23
|
|
|
24
24
|
var __filename = fileURLToPath(import.meta.url);
|
|
25
|
-
var __dirname =
|
|
25
|
+
var __dirname = path2.dirname(__filename);
|
|
26
26
|
var PosthogAnalytics = class {
|
|
27
27
|
sessionId;
|
|
28
28
|
client;
|
|
@@ -34,7 +34,7 @@ var PosthogAnalytics = class {
|
|
|
34
34
|
host = "https://app.posthog.com"
|
|
35
35
|
}) {
|
|
36
36
|
this.version = version;
|
|
37
|
-
const cliConfigPath =
|
|
37
|
+
const cliConfigPath = path2.join(__dirname, "mastra-cli.json");
|
|
38
38
|
if (existsSync(cliConfigPath)) {
|
|
39
39
|
try {
|
|
40
40
|
const { distinctId, sessionId } = JSON.parse(readFileSync(cliConfigPath, "utf-8"));
|
|
@@ -62,7 +62,7 @@ var PosthogAnalytics = class {
|
|
|
62
62
|
}
|
|
63
63
|
writeCliConfig({ distinctId, sessionId }) {
|
|
64
64
|
try {
|
|
65
|
-
writeFileSync(
|
|
65
|
+
writeFileSync(path2.join(__dirname, "mastra-cli.json"), JSON.stringify({ distinctId, sessionId }));
|
|
66
66
|
} catch {
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -1151,11 +1151,11 @@ var DepsService = class {
|
|
|
1151
1151
|
findLockFile(dir) {
|
|
1152
1152
|
const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
|
|
1153
1153
|
for (const file of lockFiles) {
|
|
1154
|
-
if (fs3__default__default.existsSync(
|
|
1154
|
+
if (fs3__default__default.existsSync(path2.join(dir, file))) {
|
|
1155
1155
|
return file;
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
|
-
const parentDir =
|
|
1158
|
+
const parentDir = path2.resolve(dir, "..");
|
|
1159
1159
|
if (parentDir !== dir) {
|
|
1160
1160
|
return this.findLockFile(parentDir);
|
|
1161
1161
|
}
|
|
@@ -1192,7 +1192,7 @@ var DepsService = class {
|
|
|
1192
1192
|
}
|
|
1193
1193
|
async checkDependencies(dependencies) {
|
|
1194
1194
|
try {
|
|
1195
|
-
const packageJsonPath =
|
|
1195
|
+
const packageJsonPath = path2.join(process.cwd(), "package.json");
|
|
1196
1196
|
try {
|
|
1197
1197
|
await fs4.access(packageJsonPath);
|
|
1198
1198
|
} catch {
|
|
@@ -1212,7 +1212,7 @@ var DepsService = class {
|
|
|
1212
1212
|
}
|
|
1213
1213
|
async getProjectName() {
|
|
1214
1214
|
try {
|
|
1215
|
-
const packageJsonPath =
|
|
1215
|
+
const packageJsonPath = path2.join(process.cwd(), "package.json");
|
|
1216
1216
|
const packageJson = await fs4.readFile(packageJsonPath, "utf-8");
|
|
1217
1217
|
const pkg = JSON.parse(packageJson);
|
|
1218
1218
|
return pkg.name;
|
|
@@ -1223,7 +1223,7 @@ var DepsService = class {
|
|
|
1223
1223
|
async getPackageVersion() {
|
|
1224
1224
|
const __filename = fileURLToPath(import.meta.url);
|
|
1225
1225
|
const __dirname = dirname(__filename);
|
|
1226
|
-
const pkgJsonPath =
|
|
1226
|
+
const pkgJsonPath = path2.join(__dirname, "..", "package.json");
|
|
1227
1227
|
const content = await fsExtra3.readJSON(pkgJsonPath);
|
|
1228
1228
|
return content.version;
|
|
1229
1229
|
}
|
|
@@ -1326,15 +1326,19 @@ async function writeMergedConfig(configPath, editor) {
|
|
|
1326
1326
|
spaces: 2
|
|
1327
1327
|
});
|
|
1328
1328
|
}
|
|
1329
|
-
var windsurfGlobalMCPConfigPath =
|
|
1330
|
-
var cursorGlobalMCPConfigPath =
|
|
1331
|
-
|
|
1329
|
+
var windsurfGlobalMCPConfigPath = path2.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
1330
|
+
var cursorGlobalMCPConfigPath = path2.join(os.homedir(), ".cursor", "mcp.json");
|
|
1331
|
+
path2.join(process.cwd(), ".vscode", "mcp.json");
|
|
1332
|
+
var vscodeGlobalMCPConfigPath = path2.join(
|
|
1333
|
+
os.homedir(),
|
|
1334
|
+
process.platform === "win32" ? path2.join("AppData", "Roaming", "Code", "User", "settings.json") : process.platform === "darwin" ? path2.join("Library", "Application Support", "Code", "User", "settings.json") : path2.join(".config", "Code", "User", "settings.json")
|
|
1335
|
+
);
|
|
1332
1336
|
async function installMastraDocsMCPServer({ editor, directory }) {
|
|
1333
1337
|
if (editor === `cursor`) {
|
|
1334
|
-
await writeMergedConfig(
|
|
1338
|
+
await writeMergedConfig(path2.join(directory, ".cursor", "mcp.json"), "cursor");
|
|
1335
1339
|
}
|
|
1336
1340
|
if (editor === `vscode`) {
|
|
1337
|
-
await writeMergedConfig(
|
|
1341
|
+
await writeMergedConfig(path2.join(directory, ".vscode", "mcp.json"), "vscode");
|
|
1338
1342
|
}
|
|
1339
1343
|
if (editor === `cursor-global`) {
|
|
1340
1344
|
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
@@ -1357,12 +1361,21 @@ async function globalMCPIsAlreadyInstalled(editor) {
|
|
|
1357
1361
|
configPath = windsurfGlobalMCPConfigPath;
|
|
1358
1362
|
} else if (editor === "cursor-global") {
|
|
1359
1363
|
configPath = cursorGlobalMCPConfigPath;
|
|
1364
|
+
} else if (editor === "vscode") {
|
|
1365
|
+
configPath = vscodeGlobalMCPConfigPath;
|
|
1360
1366
|
}
|
|
1361
1367
|
if (!configPath || !existsSync(configPath)) {
|
|
1362
1368
|
return false;
|
|
1363
1369
|
}
|
|
1364
1370
|
try {
|
|
1365
1371
|
const configContents = await readJSON(configPath);
|
|
1372
|
+
if (editor === "vscode") {
|
|
1373
|
+
if (!configContents?.servers) return false;
|
|
1374
|
+
const hasMastraMCP2 = Object.values(configContents.servers).some(
|
|
1375
|
+
(server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
|
|
1376
|
+
);
|
|
1377
|
+
return hasMastraMCP2;
|
|
1378
|
+
}
|
|
1366
1379
|
if (!configContents?.mcpServers) return false;
|
|
1367
1380
|
const hasMastraMCP = Object.values(configContents.mcpServers).some(
|
|
1368
1381
|
(server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
|
|
@@ -1444,8 +1457,8 @@ var FileService = class {
|
|
|
1444
1457
|
*/
|
|
1445
1458
|
async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
|
|
1446
1459
|
const __filename = fileURLToPath(import.meta.url);
|
|
1447
|
-
const __dirname =
|
|
1448
|
-
const filePath =
|
|
1460
|
+
const __dirname = path2.dirname(__filename);
|
|
1461
|
+
const filePath = path2.resolve(__dirname, "starter-files", inputFile);
|
|
1449
1462
|
const fileString = fs3__default__default.readFileSync(filePath, "utf8");
|
|
1450
1463
|
if (fs3__default__default.existsSync(outputFilePath) && !replaceIfExists) {
|
|
1451
1464
|
console.log(`${outputFilePath} already exists`);
|
|
@@ -1455,7 +1468,7 @@ var FileService = class {
|
|
|
1455
1468
|
return true;
|
|
1456
1469
|
}
|
|
1457
1470
|
async setupEnvFile({ dbUrl }) {
|
|
1458
|
-
const envPath =
|
|
1471
|
+
const envPath = path2.join(process.cwd(), ".env.development");
|
|
1459
1472
|
await fsExtra3.ensureFile(envPath);
|
|
1460
1473
|
const fileEnvService = new FileEnvService(envPath);
|
|
1461
1474
|
await fileEnvService.setEnvValue("DB_URL", dbUrl);
|
|
@@ -1696,6 +1709,7 @@ const fetchWeather = createStep({
|
|
|
1696
1709
|
(acc, curr) => Math.max(acc, curr),
|
|
1697
1710
|
0
|
|
1698
1711
|
),
|
|
1712
|
+
location: name
|
|
1699
1713
|
}
|
|
1700
1714
|
|
|
1701
1715
|
return forecast;
|
|
@@ -1729,7 +1743,7 @@ const planActivities = createStep({
|
|
|
1729
1743
|
]);
|
|
1730
1744
|
|
|
1731
1745
|
let activitiesText = '';
|
|
1732
|
-
|
|
1746
|
+
|
|
1733
1747
|
for await (const chunk of response.textStream) {
|
|
1734
1748
|
process.stdout.write(chunk);
|
|
1735
1749
|
activitiesText += chunk;
|
|
@@ -1790,7 +1804,7 @@ var writeIndexFile = async ({
|
|
|
1790
1804
|
addWorkflow
|
|
1791
1805
|
}) => {
|
|
1792
1806
|
const indexPath = dirPath + "/index.ts";
|
|
1793
|
-
const destPath =
|
|
1807
|
+
const destPath = path2.join(indexPath);
|
|
1794
1808
|
try {
|
|
1795
1809
|
await fs4.writeFile(destPath, "");
|
|
1796
1810
|
const filteredExports = [
|
|
@@ -1865,7 +1879,7 @@ var writeAPIKey = async ({
|
|
|
1865
1879
|
};
|
|
1866
1880
|
var createMastraDir = async (directory) => {
|
|
1867
1881
|
let dir = directory.trim().split("/").filter((item) => item !== "");
|
|
1868
|
-
const dirPath =
|
|
1882
|
+
const dirPath = path2.join(process.cwd(), ...dir, "mastra");
|
|
1869
1883
|
try {
|
|
1870
1884
|
await fs4.access(dirPath);
|
|
1871
1885
|
return { ok: false };
|
|
@@ -1939,6 +1953,7 @@ var interactivePrompt = async () => {
|
|
|
1939
1953
|
configureEditorWithDocsMCP: async () => {
|
|
1940
1954
|
const windsurfIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`windsurf`);
|
|
1941
1955
|
const cursorIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`cursor`);
|
|
1956
|
+
const vscodeIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`vscode`);
|
|
1942
1957
|
const editor = await le({
|
|
1943
1958
|
message: `Make your AI IDE into a Mastra expert? (installs Mastra docs MCP server)`,
|
|
1944
1959
|
options: [
|
|
@@ -1957,6 +1972,11 @@ var interactivePrompt = async () => {
|
|
|
1957
1972
|
value: "windsurf",
|
|
1958
1973
|
label: "Windsurf",
|
|
1959
1974
|
hint: windsurfIsAlreadyInstalled ? `Already installed` : void 0
|
|
1975
|
+
},
|
|
1976
|
+
{
|
|
1977
|
+
value: "vscode",
|
|
1978
|
+
label: "VSCode",
|
|
1979
|
+
hint: vscodeIsAlreadyInstalled ? `Already installed` : void 0
|
|
1960
1980
|
}
|
|
1961
1981
|
]
|
|
1962
1982
|
});
|
|
@@ -1966,6 +1986,11 @@ var interactivePrompt = async () => {
|
|
|
1966
1986
|
Windsurf is already installed, skipping.`);
|
|
1967
1987
|
return void 0;
|
|
1968
1988
|
}
|
|
1989
|
+
if (editor === `vscode` && vscodeIsAlreadyInstalled) {
|
|
1990
|
+
v.message(`
|
|
1991
|
+
VSCode is already installed, skipping.`);
|
|
1992
|
+
return void 0;
|
|
1993
|
+
}
|
|
1969
1994
|
if (editor === `cursor`) {
|
|
1970
1995
|
v.message(
|
|
1971
1996
|
`
|
|
@@ -2172,7 +2197,8 @@ var createMastraProject = async ({
|
|
|
2172
2197
|
const depsService = new DepsService();
|
|
2173
2198
|
await depsService.addScriptsToPackageJson({
|
|
2174
2199
|
dev: "mastra dev",
|
|
2175
|
-
build: "mastra build"
|
|
2200
|
+
build: "mastra build",
|
|
2201
|
+
start: "mastra start"
|
|
2176
2202
|
});
|
|
2177
2203
|
s2.stop("Project created");
|
|
2178
2204
|
s2.start(`Installing ${pm} dependencies`);
|
|
@@ -2258,7 +2284,7 @@ var postCreate = ({ projectName }) => {
|
|
|
2258
2284
|
async function getPackageVersion() {
|
|
2259
2285
|
const __filename = fileURLToPath(import.meta.url);
|
|
2260
2286
|
const __dirname = dirname(__filename);
|
|
2261
|
-
const pkgJsonPath =
|
|
2287
|
+
const pkgJsonPath = path2.join(__dirname, "..", "package.json");
|
|
2262
2288
|
const content = await fsExtra.readJSON(pkgJsonPath);
|
|
2263
2289
|
return content.version;
|
|
2264
2290
|
}
|