create-mastra 0.0.0-vnext-20251104230439 → 0.0.0-vnext-20251119160359
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/CHANGELOG.md +35 -1
- package/dist/index.js +272 -208
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
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 path3, { dirname } from 'node:path';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
9
|
import { PostHog } from 'posthog-node';
|
|
10
10
|
import util, { stripVTControlCharacters } from 'node:util';
|
|
@@ -23,7 +23,7 @@ import pretty from 'pino-pretty';
|
|
|
23
23
|
import fsExtra$1 from 'fs-extra';
|
|
24
24
|
|
|
25
25
|
var __filename = fileURLToPath(import.meta.url);
|
|
26
|
-
var __dirname =
|
|
26
|
+
var __dirname = path3.dirname(__filename);
|
|
27
27
|
var analyticsInstance = null;
|
|
28
28
|
function getAnalytics() {
|
|
29
29
|
return analyticsInstance;
|
|
@@ -39,7 +39,7 @@ var PosthogAnalytics = class {
|
|
|
39
39
|
host = "https://app.posthog.com"
|
|
40
40
|
}) {
|
|
41
41
|
this.version = version;
|
|
42
|
-
const cliConfigPath =
|
|
42
|
+
const cliConfigPath = path3.join(__dirname, "mastra-cli.json");
|
|
43
43
|
if (existsSync(cliConfigPath)) {
|
|
44
44
|
try {
|
|
45
45
|
const { distinctId, sessionId } = JSON.parse(readFileSync(cliConfigPath, "utf-8"));
|
|
@@ -67,7 +67,7 @@ var PosthogAnalytics = class {
|
|
|
67
67
|
}
|
|
68
68
|
writeCliConfig({ distinctId, sessionId }) {
|
|
69
69
|
try {
|
|
70
|
-
writeFileSync(
|
|
70
|
+
writeFileSync(path3.join(__dirname, "mastra-cli.json"), JSON.stringify({ distinctId, sessionId }));
|
|
71
71
|
} catch {
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -887,6 +887,7 @@ class YoctoSpinner {
|
|
|
887
887
|
#exitHandlerBound;
|
|
888
888
|
#isInteractive;
|
|
889
889
|
#lastSpinnerFrameTime = 0;
|
|
890
|
+
#isSpinning = false;
|
|
890
891
|
|
|
891
892
|
constructor(options = {}) {
|
|
892
893
|
const spinner = options.spinner ?? defaultSpinner;
|
|
@@ -908,13 +909,17 @@ class YoctoSpinner {
|
|
|
908
909
|
return this;
|
|
909
910
|
}
|
|
910
911
|
|
|
912
|
+
this.#isSpinning = true;
|
|
911
913
|
this.#hideCursor();
|
|
912
914
|
this.#render();
|
|
913
915
|
this.#subscribeToProcessEvents();
|
|
914
916
|
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
917
|
+
// Only start the timer in interactive mode
|
|
918
|
+
if (this.#isInteractive) {
|
|
919
|
+
this.#timer = setInterval(() => {
|
|
920
|
+
this.#render();
|
|
921
|
+
}, this.#interval);
|
|
922
|
+
}
|
|
918
923
|
|
|
919
924
|
return this;
|
|
920
925
|
}
|
|
@@ -924,8 +929,12 @@ class YoctoSpinner {
|
|
|
924
929
|
return this;
|
|
925
930
|
}
|
|
926
931
|
|
|
927
|
-
|
|
928
|
-
this.#timer
|
|
932
|
+
this.#isSpinning = false;
|
|
933
|
+
if (this.#timer) {
|
|
934
|
+
clearInterval(this.#timer);
|
|
935
|
+
this.#timer = undefined;
|
|
936
|
+
}
|
|
937
|
+
|
|
929
938
|
this.#showCursor();
|
|
930
939
|
this.clear();
|
|
931
940
|
this.#unsubscribeFromProcessEvents();
|
|
@@ -958,7 +967,7 @@ class YoctoSpinner {
|
|
|
958
967
|
}
|
|
959
968
|
|
|
960
969
|
get isSpinning() {
|
|
961
|
-
return this.#
|
|
970
|
+
return this.#isSpinning;
|
|
962
971
|
}
|
|
963
972
|
|
|
964
973
|
get text() {
|
|
@@ -1178,118 +1187,8 @@ var PinoLogger = class extends MastraLogger {
|
|
|
1178
1187
|
}
|
|
1179
1188
|
};
|
|
1180
1189
|
|
|
1181
|
-
var
|
|
1182
|
-
|
|
1183
|
-
if (editor === "vscode") {
|
|
1184
|
-
return {
|
|
1185
|
-
servers: {
|
|
1186
|
-
mastra: process.platform === `win32` ? {
|
|
1187
|
-
command: "cmd",
|
|
1188
|
-
args: ["/c", "npx", ...args],
|
|
1189
|
-
type: "stdio"
|
|
1190
|
-
} : {
|
|
1191
|
-
command: "npx",
|
|
1192
|
-
args,
|
|
1193
|
-
type: "stdio"
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
};
|
|
1197
|
-
}
|
|
1198
|
-
return {
|
|
1199
|
-
mcpServers: {
|
|
1200
|
-
mastra: {
|
|
1201
|
-
command: "npx",
|
|
1202
|
-
args
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
};
|
|
1206
|
-
};
|
|
1207
|
-
function makeConfig(original, editor) {
|
|
1208
|
-
if (editor === "vscode") {
|
|
1209
|
-
return {
|
|
1210
|
-
...original,
|
|
1211
|
-
servers: {
|
|
1212
|
-
...original?.servers || {},
|
|
1213
|
-
...createMcpConfig(editor).servers
|
|
1214
|
-
}
|
|
1215
|
-
};
|
|
1216
|
-
}
|
|
1217
|
-
return {
|
|
1218
|
-
...original,
|
|
1219
|
-
mcpServers: {
|
|
1220
|
-
...original?.mcpServers || {},
|
|
1221
|
-
...createMcpConfig(editor).mcpServers
|
|
1222
|
-
}
|
|
1223
|
-
};
|
|
1224
|
-
}
|
|
1225
|
-
async function writeMergedConfig(configPath, editor) {
|
|
1226
|
-
const configExists = existsSync(configPath);
|
|
1227
|
-
const config = makeConfig(configExists ? await readJSON(configPath) : {}, editor);
|
|
1228
|
-
await ensureFile(configPath);
|
|
1229
|
-
await writeJSON(configPath, config, {
|
|
1230
|
-
spaces: 2
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
1234
|
-
var cursorGlobalMCPConfigPath = path.join(os.homedir(), ".cursor", "mcp.json");
|
|
1235
|
-
path.join(process.cwd(), ".vscode", "mcp.json");
|
|
1236
|
-
var vscodeGlobalMCPConfigPath = path.join(
|
|
1237
|
-
os.homedir(),
|
|
1238
|
-
process.platform === "win32" ? path.join("AppData", "Roaming", "Code", "User", "settings.json") : process.platform === "darwin" ? path.join("Library", "Application Support", "Code", "User", "settings.json") : path.join(".config", "Code", "User", "settings.json")
|
|
1239
|
-
);
|
|
1240
|
-
async function installMastraDocsMCPServer({ editor, directory }) {
|
|
1241
|
-
if (editor === `cursor`) {
|
|
1242
|
-
await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"), "cursor");
|
|
1243
|
-
}
|
|
1244
|
-
if (editor === `vscode`) {
|
|
1245
|
-
await writeMergedConfig(path.join(directory, ".vscode", "mcp.json"), "vscode");
|
|
1246
|
-
}
|
|
1247
|
-
if (editor === `cursor-global`) {
|
|
1248
|
-
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
1249
|
-
if (alreadyInstalled) {
|
|
1250
|
-
return;
|
|
1251
|
-
}
|
|
1252
|
-
await writeMergedConfig(cursorGlobalMCPConfigPath, "cursor-global");
|
|
1253
|
-
}
|
|
1254
|
-
if (editor === `windsurf`) {
|
|
1255
|
-
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
1256
|
-
if (alreadyInstalled) {
|
|
1257
|
-
return;
|
|
1258
|
-
}
|
|
1259
|
-
await writeMergedConfig(windsurfGlobalMCPConfigPath, editor);
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
async function globalMCPIsAlreadyInstalled(editor) {
|
|
1263
|
-
let configPath = ``;
|
|
1264
|
-
if (editor === "windsurf") {
|
|
1265
|
-
configPath = windsurfGlobalMCPConfigPath;
|
|
1266
|
-
} else if (editor === "cursor-global") {
|
|
1267
|
-
configPath = cursorGlobalMCPConfigPath;
|
|
1268
|
-
} else if (editor === "vscode") {
|
|
1269
|
-
configPath = vscodeGlobalMCPConfigPath;
|
|
1270
|
-
}
|
|
1271
|
-
if (!configPath || !existsSync(configPath)) {
|
|
1272
|
-
return false;
|
|
1273
|
-
}
|
|
1274
|
-
try {
|
|
1275
|
-
const configContents = await readJSON(configPath);
|
|
1276
|
-
if (!configContents) return false;
|
|
1277
|
-
if (editor === "vscode") {
|
|
1278
|
-
if (!configContents.servers) return false;
|
|
1279
|
-
const hasMastraMCP2 = Object.values(configContents.servers).some(
|
|
1280
|
-
(server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
|
|
1281
|
-
);
|
|
1282
|
-
return hasMastraMCP2;
|
|
1283
|
-
}
|
|
1284
|
-
if (!configContents?.mcpServers) return false;
|
|
1285
|
-
const hasMastraMCP = Object.values(configContents.mcpServers).some(
|
|
1286
|
-
(server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
|
|
1287
|
-
);
|
|
1288
|
-
return hasMastraMCP;
|
|
1289
|
-
} catch {
|
|
1290
|
-
return false;
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1190
|
+
var package_default = {
|
|
1191
|
+
version: "1.0.0-beta.1"};
|
|
1293
1192
|
function getPackageManagerAddCommand(pm) {
|
|
1294
1193
|
switch (pm) {
|
|
1295
1194
|
case "npm":
|
|
@@ -1312,11 +1211,11 @@ var DepsService = class {
|
|
|
1312
1211
|
findLockFile(dir) {
|
|
1313
1212
|
const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
|
|
1314
1213
|
for (const file of lockFiles) {
|
|
1315
|
-
if (fs3__default__default.existsSync(
|
|
1214
|
+
if (fs3__default__default.existsSync(path3.join(dir, file))) {
|
|
1316
1215
|
return file;
|
|
1317
1216
|
}
|
|
1318
1217
|
}
|
|
1319
|
-
const parentDir =
|
|
1218
|
+
const parentDir = path3.resolve(dir, "..");
|
|
1320
1219
|
if (parentDir !== dir) {
|
|
1321
1220
|
return this.findLockFile(parentDir);
|
|
1322
1221
|
}
|
|
@@ -1349,7 +1248,7 @@ var DepsService = class {
|
|
|
1349
1248
|
}
|
|
1350
1249
|
async checkDependencies(dependencies) {
|
|
1351
1250
|
try {
|
|
1352
|
-
const packageJsonPath =
|
|
1251
|
+
const packageJsonPath = path3.join(process.cwd(), "package.json");
|
|
1353
1252
|
try {
|
|
1354
1253
|
await fs4.access(packageJsonPath);
|
|
1355
1254
|
} catch {
|
|
@@ -1369,7 +1268,7 @@ var DepsService = class {
|
|
|
1369
1268
|
}
|
|
1370
1269
|
async getProjectName() {
|
|
1371
1270
|
try {
|
|
1372
|
-
const packageJsonPath =
|
|
1271
|
+
const packageJsonPath = path3.join(process.cwd(), "package.json");
|
|
1373
1272
|
const packageJson = await fs4.readFile(packageJsonPath, "utf-8");
|
|
1374
1273
|
const pkg = JSON.parse(packageJson);
|
|
1375
1274
|
return pkg.name;
|
|
@@ -1457,8 +1356,8 @@ var FileService = class {
|
|
|
1457
1356
|
*/
|
|
1458
1357
|
async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
|
|
1459
1358
|
const __filename = fileURLToPath(import.meta.url);
|
|
1460
|
-
const __dirname =
|
|
1461
|
-
const filePath =
|
|
1359
|
+
const __dirname = path3.dirname(__filename);
|
|
1360
|
+
const filePath = path3.resolve(__dirname, "starter-files", inputFile);
|
|
1462
1361
|
const fileString = fs3__default__default.readFileSync(filePath, "utf8");
|
|
1463
1362
|
if (fs3__default__default.existsSync(outputFilePath) && !replaceIfExists) {
|
|
1464
1363
|
console.info(`${outputFilePath} already exists`);
|
|
@@ -1468,7 +1367,7 @@ var FileService = class {
|
|
|
1468
1367
|
return true;
|
|
1469
1368
|
}
|
|
1470
1369
|
async setupEnvFile({ dbUrl }) {
|
|
1471
|
-
const envPath =
|
|
1370
|
+
const envPath = path3.join(process.cwd(), ".env.development");
|
|
1472
1371
|
await fsExtra.ensureFile(envPath);
|
|
1473
1372
|
const fileEnvService = new FileEnvService(envPath);
|
|
1474
1373
|
await fileEnvService.setEnvValue("DB_URL", dbUrl);
|
|
@@ -1492,21 +1391,142 @@ var FileService = class {
|
|
|
1492
1391
|
fs3__default__default.writeFileSync(filePath, fileContent);
|
|
1493
1392
|
}
|
|
1494
1393
|
};
|
|
1394
|
+
var createArgs = (versionTag) => {
|
|
1395
|
+
const packageName = versionTag ? `@mastra/mcp-docs-server@${versionTag}` : "@mastra/mcp-docs-server";
|
|
1396
|
+
return ["-y", packageName];
|
|
1397
|
+
};
|
|
1398
|
+
var createMcpConfig = (editor, versionTag) => {
|
|
1399
|
+
const args = createArgs(versionTag);
|
|
1400
|
+
if (editor === "vscode") {
|
|
1401
|
+
return {
|
|
1402
|
+
servers: {
|
|
1403
|
+
mastra: process.platform === `win32` ? {
|
|
1404
|
+
command: "cmd",
|
|
1405
|
+
args: ["/c", "npx", ...args],
|
|
1406
|
+
type: "stdio"
|
|
1407
|
+
} : {
|
|
1408
|
+
command: "npx",
|
|
1409
|
+
args,
|
|
1410
|
+
type: "stdio"
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1415
|
+
return {
|
|
1416
|
+
mcpServers: {
|
|
1417
|
+
mastra: {
|
|
1418
|
+
command: "npx",
|
|
1419
|
+
args
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
};
|
|
1424
|
+
function makeConfig(original, editor, versionTag) {
|
|
1425
|
+
if (editor === "vscode") {
|
|
1426
|
+
return {
|
|
1427
|
+
...original,
|
|
1428
|
+
servers: {
|
|
1429
|
+
...original?.servers || {},
|
|
1430
|
+
...createMcpConfig(editor, versionTag).servers
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
return {
|
|
1435
|
+
...original,
|
|
1436
|
+
mcpServers: {
|
|
1437
|
+
...original?.mcpServers || {},
|
|
1438
|
+
...createMcpConfig(editor, versionTag).mcpServers
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
async function writeMergedConfig(configPath, editor, versionTag) {
|
|
1443
|
+
const configExists = existsSync(configPath);
|
|
1444
|
+
const config = makeConfig(configExists ? await readJSON(configPath) : {}, editor, versionTag);
|
|
1445
|
+
await ensureFile(configPath);
|
|
1446
|
+
await writeJSON(configPath, config, {
|
|
1447
|
+
spaces: 2
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
var windsurfGlobalMCPConfigPath = path3.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
1451
|
+
var cursorGlobalMCPConfigPath = path3.join(os.homedir(), ".cursor", "mcp.json");
|
|
1452
|
+
path3.join(process.cwd(), ".vscode", "mcp.json");
|
|
1453
|
+
var vscodeGlobalMCPConfigPath = path3.join(
|
|
1454
|
+
os.homedir(),
|
|
1455
|
+
process.platform === "win32" ? path3.join("AppData", "Roaming", "Code", "User", "settings.json") : process.platform === "darwin" ? path3.join("Library", "Application Support", "Code", "User", "settings.json") : path3.join(".config", "Code", "User", "settings.json")
|
|
1456
|
+
);
|
|
1457
|
+
async function installMastraDocsMCPServer({
|
|
1458
|
+
editor,
|
|
1459
|
+
directory,
|
|
1460
|
+
versionTag
|
|
1461
|
+
}) {
|
|
1462
|
+
if (editor === `cursor`) {
|
|
1463
|
+
await writeMergedConfig(path3.join(directory, ".cursor", "mcp.json"), "cursor", versionTag);
|
|
1464
|
+
}
|
|
1465
|
+
if (editor === `vscode`) {
|
|
1466
|
+
await writeMergedConfig(path3.join(directory, ".vscode", "mcp.json"), "vscode", versionTag);
|
|
1467
|
+
}
|
|
1468
|
+
if (editor === `cursor-global`) {
|
|
1469
|
+
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor, versionTag);
|
|
1470
|
+
if (alreadyInstalled) {
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
await writeMergedConfig(cursorGlobalMCPConfigPath, "cursor-global", versionTag);
|
|
1474
|
+
}
|
|
1475
|
+
if (editor === `windsurf`) {
|
|
1476
|
+
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor, versionTag);
|
|
1477
|
+
if (alreadyInstalled) {
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
await writeMergedConfig(windsurfGlobalMCPConfigPath, editor, versionTag);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
async function globalMCPIsAlreadyInstalled(editor, versionTag) {
|
|
1484
|
+
let configPath = ``;
|
|
1485
|
+
if (editor === "windsurf") {
|
|
1486
|
+
configPath = windsurfGlobalMCPConfigPath;
|
|
1487
|
+
} else if (editor === "cursor-global") {
|
|
1488
|
+
configPath = cursorGlobalMCPConfigPath;
|
|
1489
|
+
} else if (editor === "vscode") {
|
|
1490
|
+
configPath = vscodeGlobalMCPConfigPath;
|
|
1491
|
+
}
|
|
1492
|
+
if (!configPath || !existsSync(configPath)) {
|
|
1493
|
+
return false;
|
|
1494
|
+
}
|
|
1495
|
+
try {
|
|
1496
|
+
const configContents = await readJSON(configPath);
|
|
1497
|
+
if (!configContents) return false;
|
|
1498
|
+
const expectedPackage = versionTag ? `@mastra/mcp-docs-server@${versionTag}` : "@mastra/mcp-docs-server";
|
|
1499
|
+
if (editor === "vscode") {
|
|
1500
|
+
if (!configContents.servers) return false;
|
|
1501
|
+
const hasMastraMCP2 = Object.values(configContents.servers).some(
|
|
1502
|
+
(server) => server?.args?.find((arg) => arg === expectedPackage)
|
|
1503
|
+
);
|
|
1504
|
+
return hasMastraMCP2;
|
|
1505
|
+
}
|
|
1506
|
+
if (!configContents?.mcpServers) return false;
|
|
1507
|
+
const hasMastraMCP = Object.values(configContents.mcpServers).some(
|
|
1508
|
+
(server) => server?.args?.find((arg) => arg === expectedPackage)
|
|
1509
|
+
);
|
|
1510
|
+
return hasMastraMCP;
|
|
1511
|
+
} catch {
|
|
1512
|
+
return false;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1495
1515
|
var exec = util.promisify(child_process.exec);
|
|
1496
1516
|
var getModelIdentifier = (llmProvider) => {
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
return `'anthropic/claude-sonnet-4-5-20250929'`;
|
|
1517
|
+
let model = "openai/gpt-4o";
|
|
1518
|
+
if (llmProvider === "anthropic") {
|
|
1519
|
+
model = "anthropic/claude-sonnet-4-5";
|
|
1501
1520
|
} else if (llmProvider === "groq") {
|
|
1502
|
-
|
|
1521
|
+
model = "groq/llama-3.3-70b-versatile";
|
|
1503
1522
|
} else if (llmProvider === "google") {
|
|
1504
|
-
|
|
1523
|
+
model = "google/gemini-2.5-pro";
|
|
1505
1524
|
} else if (llmProvider === "cerebras") {
|
|
1506
|
-
|
|
1525
|
+
model = "cerebras/llama-3.3-70b";
|
|
1507
1526
|
} else if (llmProvider === "mistral") {
|
|
1508
|
-
|
|
1527
|
+
model = "mistral/mistral-medium-2508";
|
|
1509
1528
|
}
|
|
1529
|
+
return model;
|
|
1510
1530
|
};
|
|
1511
1531
|
async function writeAgentSample(llmProvider, destPath, addExampleTool, addScorers) {
|
|
1512
1532
|
const modelString = getModelIdentifier(llmProvider);
|
|
@@ -1535,7 +1555,7 @@ export const weatherAgent = new Agent({
|
|
|
1535
1555
|
id: 'weather-agent',
|
|
1536
1556
|
name: 'Weather Agent',
|
|
1537
1557
|
instructions: \`${instructions}\`,
|
|
1538
|
-
model: ${modelString},
|
|
1558
|
+
model: '${modelString}',
|
|
1539
1559
|
${addExampleTool ? "tools: { weatherTool }," : ""}
|
|
1540
1560
|
${addScorers ? `scorers: {
|
|
1541
1561
|
toolCallAppropriateness: {
|
|
@@ -1562,6 +1582,7 @@ export const weatherAgent = new Agent({
|
|
|
1562
1582
|
},` : ""}
|
|
1563
1583
|
memory: new Memory({
|
|
1564
1584
|
storage: new LibSQLStore({
|
|
1585
|
+
id: "memory-storage",
|
|
1565
1586
|
url: "file:../mastra.db", // path is relative to the .mastra/output directory
|
|
1566
1587
|
})
|
|
1567
1588
|
})
|
|
@@ -1776,6 +1797,7 @@ async function writeScorersSample(llmProvider, destPath) {
|
|
|
1776
1797
|
const content = `import { z } from 'zod';
|
|
1777
1798
|
import { createToolCallAccuracyScorerCode } from '@mastra/evals/scorers/prebuilt';
|
|
1778
1799
|
import { createCompletenessScorer } from '@mastra/evals/scorers/prebuilt';
|
|
1800
|
+
import { getAssistantMessageFromRunOutput, getUserMessageFromRunInput } from '@mastra/evals/scorers/utils';
|
|
1779
1801
|
import { createScorer } from '@mastra/core/evals';
|
|
1780
1802
|
|
|
1781
1803
|
export const toolCallAppropriatenessScorer = createToolCallAccuracyScorerCode({
|
|
@@ -1792,7 +1814,7 @@ export const translationScorer = createScorer({
|
|
|
1792
1814
|
description: 'Checks that non-English location names are translated and used correctly',
|
|
1793
1815
|
type: 'agent',
|
|
1794
1816
|
judge: {
|
|
1795
|
-
model: ${modelString},
|
|
1817
|
+
model: '${modelString}',
|
|
1796
1818
|
instructions:
|
|
1797
1819
|
'You are an expert evaluator of translation quality for geographic locations. ' +
|
|
1798
1820
|
'Determine whether the user text mentions a non-English location and whether the assistant correctly uses an English translation of that location. ' +
|
|
@@ -1801,8 +1823,8 @@ export const translationScorer = createScorer({
|
|
|
1801
1823
|
},
|
|
1802
1824
|
})
|
|
1803
1825
|
.preprocess(({ run }) => {
|
|
1804
|
-
const userText = (run.input
|
|
1805
|
-
const assistantText = (run.output
|
|
1826
|
+
const userText = getUserMessageFromRunInput(run.input) || '';
|
|
1827
|
+
const assistantText = getAssistantMessageFromRunOutput(run.output) || '';
|
|
1806
1828
|
return { userText, assistantText };
|
|
1807
1829
|
})
|
|
1808
1830
|
.analyze({
|
|
@@ -1889,7 +1911,7 @@ var writeIndexFile = async ({
|
|
|
1889
1911
|
addScorers
|
|
1890
1912
|
}) => {
|
|
1891
1913
|
const indexPath = dirPath + "/index.ts";
|
|
1892
|
-
const destPath =
|
|
1914
|
+
const destPath = path3.join(indexPath);
|
|
1893
1915
|
try {
|
|
1894
1916
|
await fs4.writeFile(destPath, "");
|
|
1895
1917
|
const filteredExports = [
|
|
@@ -1914,6 +1936,7 @@ export const mastra = new Mastra()
|
|
|
1914
1936
|
import { Mastra } from '@mastra/core/mastra';
|
|
1915
1937
|
import { PinoLogger } from '@mastra/loggers';
|
|
1916
1938
|
import { LibSQLStore } from '@mastra/libsql';
|
|
1939
|
+
import { Observability } from '@mastra/observability';
|
|
1917
1940
|
${addWorkflow ? `import { weatherWorkflow } from './workflows/weather-workflow';` : ""}
|
|
1918
1941
|
${addAgent ? `import { weatherAgent } from './agents/weather-agent';` : ""}
|
|
1919
1942
|
${addScorers ? `import { toolCallAppropriatenessScorer, completenessScorer, translationScorer } from './scorers/weather-scorer';` : ""}
|
|
@@ -1921,6 +1944,7 @@ ${addScorers ? `import { toolCallAppropriatenessScorer, completenessScorer, tran
|
|
|
1921
1944
|
export const mastra = new Mastra({
|
|
1922
1945
|
${filteredExports.join("\n ")}
|
|
1923
1946
|
storage: new LibSQLStore({
|
|
1947
|
+
id: "mastra-storage",
|
|
1924
1948
|
// stores observability, scores, ... into memory storage, if it needs to persist, change to file:../mastra.db
|
|
1925
1949
|
url: ":memory:",
|
|
1926
1950
|
}),
|
|
@@ -1928,10 +1952,10 @@ export const mastra = new Mastra({
|
|
|
1928
1952
|
name: 'Mastra',
|
|
1929
1953
|
level: 'info',
|
|
1930
1954
|
}),
|
|
1931
|
-
observability: {
|
|
1932
|
-
// Enables DefaultExporter and CloudExporter for
|
|
1955
|
+
observability: new Observability({
|
|
1956
|
+
// Enables DefaultExporter and CloudExporter for tracing
|
|
1933
1957
|
default: { enabled: true },
|
|
1934
|
-
|
|
1958
|
+
}),
|
|
1935
1959
|
});
|
|
1936
1960
|
`
|
|
1937
1961
|
);
|
|
@@ -1970,7 +1994,7 @@ var writeAPIKey = async ({ provider, apiKey }) => {
|
|
|
1970
1994
|
};
|
|
1971
1995
|
var createMastraDir = async (directory) => {
|
|
1972
1996
|
let dir = directory.trim().split("/").filter((item) => item !== "");
|
|
1973
|
-
const dirPath =
|
|
1997
|
+
const dirPath = path3.join(process.cwd(), ...dir, "mastra");
|
|
1974
1998
|
try {
|
|
1975
1999
|
await fs4.access(dirPath);
|
|
1976
2000
|
return { ok: false };
|
|
@@ -1995,8 +2019,8 @@ var LLM_PROVIDERS = [
|
|
|
1995
2019
|
{ value: "cerebras", label: "Cerebras" },
|
|
1996
2020
|
{ value: "mistral", label: "Mistral" }
|
|
1997
2021
|
];
|
|
1998
|
-
var interactivePrompt = async (
|
|
1999
|
-
const { skip = {}, options: { showBanner = true } = {} } =
|
|
2022
|
+
var interactivePrompt = async (args = {}) => {
|
|
2023
|
+
const { skip = {}, options: { showBanner = true } = {} } = args;
|
|
2000
2024
|
if (showBanner) {
|
|
2001
2025
|
Ie(color2.inverse(" Mastra Init "));
|
|
2002
2026
|
}
|
|
@@ -2034,46 +2058,29 @@ var interactivePrompt = async (args2 = {}) => {
|
|
|
2034
2058
|
return void 0;
|
|
2035
2059
|
},
|
|
2036
2060
|
configureEditorWithDocsMCP: async () => {
|
|
2037
|
-
const windsurfIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`windsurf`);
|
|
2038
|
-
const cursorIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`cursor`);
|
|
2039
|
-
const vscodeIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`vscode`);
|
|
2040
2061
|
const editor = await ve({
|
|
2041
2062
|
message: `Make your IDE into a Mastra expert? (Installs Mastra's MCP server)`,
|
|
2042
2063
|
options: [
|
|
2043
2064
|
{ value: "skip", label: "Skip for now", hint: "default" },
|
|
2044
2065
|
{
|
|
2045
2066
|
value: "cursor",
|
|
2046
|
-
label: "Cursor (project only)"
|
|
2047
|
-
hint: cursorIsAlreadyInstalled ? `Already installed globally` : void 0
|
|
2067
|
+
label: "Cursor (project only)"
|
|
2048
2068
|
},
|
|
2049
2069
|
{
|
|
2050
2070
|
value: "cursor-global",
|
|
2051
|
-
label: "Cursor (global, all projects)"
|
|
2052
|
-
hint: cursorIsAlreadyInstalled ? `Already installed` : void 0
|
|
2071
|
+
label: "Cursor (global, all projects)"
|
|
2053
2072
|
},
|
|
2054
2073
|
{
|
|
2055
2074
|
value: "windsurf",
|
|
2056
|
-
label: "Windsurf"
|
|
2057
|
-
hint: windsurfIsAlreadyInstalled ? `Already installed` : void 0
|
|
2075
|
+
label: "Windsurf"
|
|
2058
2076
|
},
|
|
2059
2077
|
{
|
|
2060
2078
|
value: "vscode",
|
|
2061
|
-
label: "VSCode"
|
|
2062
|
-
hint: vscodeIsAlreadyInstalled ? `Already installed` : void 0
|
|
2079
|
+
label: "VSCode"
|
|
2063
2080
|
}
|
|
2064
2081
|
]
|
|
2065
2082
|
});
|
|
2066
2083
|
if (editor === `skip`) return void 0;
|
|
2067
|
-
if (editor === `windsurf` && windsurfIsAlreadyInstalled) {
|
|
2068
|
-
M.message(`
|
|
2069
|
-
Windsurf is already installed, skipping.`);
|
|
2070
|
-
return void 0;
|
|
2071
|
-
}
|
|
2072
|
-
if (editor === `vscode` && vscodeIsAlreadyInstalled) {
|
|
2073
|
-
M.message(`
|
|
2074
|
-
VSCode is already installed, skipping.`);
|
|
2075
|
-
return void 0;
|
|
2076
|
-
}
|
|
2077
2084
|
if (editor === `cursor`) {
|
|
2078
2085
|
M.message(
|
|
2079
2086
|
`
|
|
@@ -2150,19 +2157,23 @@ function createLogger(debug = false) {
|
|
|
2150
2157
|
}
|
|
2151
2158
|
var exec2 = util.promisify(child_process.exec);
|
|
2152
2159
|
async function cloneTemplate(options) {
|
|
2153
|
-
const { template, projectName, targetDir } = options;
|
|
2154
|
-
const projectPath = targetDir ?
|
|
2160
|
+
const { template, projectName, targetDir, branch, llmProvider } = options;
|
|
2161
|
+
const projectPath = targetDir ? path3.resolve(targetDir, projectName) : path3.resolve(projectName);
|
|
2155
2162
|
const spinner4 = yoctoSpinner({ text: `Cloning template "${template.title}"...` }).start();
|
|
2156
2163
|
try {
|
|
2157
2164
|
if (await directoryExists(projectPath)) {
|
|
2158
2165
|
spinner4.error(`Directory ${projectName} already exists`);
|
|
2159
2166
|
throw new Error(`Directory ${projectName} already exists`);
|
|
2160
2167
|
}
|
|
2161
|
-
await cloneRepositoryWithoutGit(template.githubUrl, projectPath);
|
|
2168
|
+
await cloneRepositoryWithoutGit(template.githubUrl, projectPath, branch);
|
|
2162
2169
|
await updatePackageJson(projectPath, projectName);
|
|
2163
|
-
const envExamplePath =
|
|
2170
|
+
const envExamplePath = path3.join(projectPath, ".env.example");
|
|
2164
2171
|
if (await fileExists(envExamplePath)) {
|
|
2165
|
-
|
|
2172
|
+
const envPath = path3.join(projectPath, ".env");
|
|
2173
|
+
await fs4.copyFile(envExamplePath, envPath);
|
|
2174
|
+
if (llmProvider) {
|
|
2175
|
+
await updateEnvFile(envPath, llmProvider);
|
|
2176
|
+
}
|
|
2166
2177
|
}
|
|
2167
2178
|
spinner4.success(`Template "${template.title}" cloned successfully to ${projectName}`);
|
|
2168
2179
|
return projectPath;
|
|
@@ -2187,21 +2198,27 @@ async function fileExists(filePath) {
|
|
|
2187
2198
|
return false;
|
|
2188
2199
|
}
|
|
2189
2200
|
}
|
|
2190
|
-
async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
|
|
2201
|
+
async function cloneRepositoryWithoutGit(repoUrl, targetPath, branch) {
|
|
2191
2202
|
await fs4.mkdir(targetPath, { recursive: true });
|
|
2192
2203
|
try {
|
|
2193
2204
|
const degitRepo = repoUrl.replace("https://github.com/", "");
|
|
2194
|
-
const
|
|
2205
|
+
const degitRepoWithBranch = branch ? `${degitRepo}#${branch}` : degitRepo;
|
|
2206
|
+
const degitCommand = shellQuote2.quote(["npx", "degit", degitRepoWithBranch, targetPath]);
|
|
2195
2207
|
await exec2(degitCommand, {
|
|
2196
2208
|
cwd: process.cwd()
|
|
2197
2209
|
});
|
|
2198
2210
|
} catch {
|
|
2199
2211
|
try {
|
|
2200
|
-
const
|
|
2212
|
+
const gitArgs = ["git", "clone"];
|
|
2213
|
+
if (branch) {
|
|
2214
|
+
gitArgs.push("--branch", branch);
|
|
2215
|
+
}
|
|
2216
|
+
gitArgs.push(repoUrl, targetPath);
|
|
2217
|
+
const gitCommand = shellQuote2.quote(gitArgs);
|
|
2201
2218
|
await exec2(gitCommand, {
|
|
2202
2219
|
cwd: process.cwd()
|
|
2203
2220
|
});
|
|
2204
|
-
const gitDir =
|
|
2221
|
+
const gitDir = path3.join(targetPath, ".git");
|
|
2205
2222
|
if (await directoryExists(gitDir)) {
|
|
2206
2223
|
await fs4.rm(gitDir, { recursive: true, force: true });
|
|
2207
2224
|
}
|
|
@@ -2211,7 +2228,7 @@ async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
|
|
|
2211
2228
|
}
|
|
2212
2229
|
}
|
|
2213
2230
|
async function updatePackageJson(projectPath, projectName) {
|
|
2214
|
-
const packageJsonPath =
|
|
2231
|
+
const packageJsonPath = path3.join(projectPath, "package.json");
|
|
2215
2232
|
try {
|
|
2216
2233
|
const packageJsonContent = await fs4.readFile(packageJsonPath, "utf-8");
|
|
2217
2234
|
const packageJson = JSON.parse(packageJsonContent);
|
|
@@ -2221,6 +2238,22 @@ async function updatePackageJson(projectPath, projectName) {
|
|
|
2221
2238
|
logger.warn(`Could not update package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2222
2239
|
}
|
|
2223
2240
|
}
|
|
2241
|
+
async function updateEnvFile(envPath, llmProvider) {
|
|
2242
|
+
try {
|
|
2243
|
+
const envContent = await fs4.readFile(envPath, "utf-8");
|
|
2244
|
+
const modelString = getModelIdentifier(llmProvider);
|
|
2245
|
+
if (!modelString) {
|
|
2246
|
+
logger.warn(`Could not get model identifier for provider: ${llmProvider}`);
|
|
2247
|
+
return;
|
|
2248
|
+
}
|
|
2249
|
+
const modelValue = modelString.replace(/'/g, "");
|
|
2250
|
+
const updatedContent = envContent.replace(/^MODEL=.*/m, `MODEL=${modelValue}`);
|
|
2251
|
+
await fs4.writeFile(envPath, updatedContent, "utf-8");
|
|
2252
|
+
logger.info(`Updated MODEL in .env to ${modelValue}`);
|
|
2253
|
+
} catch (error) {
|
|
2254
|
+
logger.warn(`Could not update .env file: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2224
2257
|
async function installDependencies(projectPath, packageManager) {
|
|
2225
2258
|
const spinner4 = yoctoSpinner({ text: "Installing dependencies..." }).start();
|
|
2226
2259
|
try {
|
|
@@ -2360,7 +2393,8 @@ var init = async ({
|
|
|
2360
2393
|
if (configureEditorWithDocsMCP) {
|
|
2361
2394
|
await installMastraDocsMCPServer({
|
|
2362
2395
|
editor: configureEditorWithDocsMCP,
|
|
2363
|
-
directory: process.cwd()
|
|
2396
|
+
directory: process.cwd(),
|
|
2397
|
+
versionTag
|
|
2364
2398
|
});
|
|
2365
2399
|
}
|
|
2366
2400
|
s.stop();
|
|
@@ -2499,7 +2533,7 @@ var createMastraProject = async ({
|
|
|
2499
2533
|
s2.start(`Installing ${pm} dependencies`);
|
|
2500
2534
|
try {
|
|
2501
2535
|
await exec3(`${pm} ${installCommand} zod@^4`);
|
|
2502
|
-
await exec3(`${pm} ${installCommand} typescript @types/node
|
|
2536
|
+
await exec3(`${pm} ${installCommand} -D typescript @types/node`);
|
|
2503
2537
|
await exec3(`echo '{
|
|
2504
2538
|
"compilerOptions": {
|
|
2505
2539
|
"target": "ES2022",
|
|
@@ -2565,41 +2599,48 @@ var createMastraProject = async ({
|
|
|
2565
2599
|
process.exit(1);
|
|
2566
2600
|
}
|
|
2567
2601
|
};
|
|
2568
|
-
var
|
|
2569
|
-
|
|
2570
|
-
|
|
2602
|
+
var version$1 = package_default.version;
|
|
2603
|
+
var create = async (args) => {
|
|
2604
|
+
if (args.template !== void 0) {
|
|
2605
|
+
await createFromTemplate({
|
|
2606
|
+
projectName: args.projectName,
|
|
2607
|
+
template: args.template,
|
|
2608
|
+
timeout: args.timeout,
|
|
2609
|
+
injectedAnalytics: args.analytics,
|
|
2610
|
+
llmProvider: args.llmProvider
|
|
2611
|
+
});
|
|
2571
2612
|
return;
|
|
2572
2613
|
}
|
|
2573
|
-
const needsInteractive =
|
|
2614
|
+
const needsInteractive = args.components === void 0 || args.llmProvider === void 0 || args.addExample === void 0;
|
|
2574
2615
|
const { projectName, result } = await createMastraProject({
|
|
2575
|
-
projectName:
|
|
2576
|
-
createVersionTag:
|
|
2577
|
-
timeout:
|
|
2578
|
-
llmProvider:
|
|
2579
|
-
llmApiKey:
|
|
2616
|
+
projectName: args?.projectName,
|
|
2617
|
+
createVersionTag: args?.createVersionTag,
|
|
2618
|
+
timeout: args?.timeout,
|
|
2619
|
+
llmProvider: args?.llmProvider,
|
|
2620
|
+
llmApiKey: args?.llmApiKey,
|
|
2580
2621
|
needsInteractive
|
|
2581
2622
|
});
|
|
2582
|
-
const directory =
|
|
2623
|
+
const directory = args.directory || "src/";
|
|
2583
2624
|
if (needsInteractive && result) {
|
|
2584
2625
|
await init({
|
|
2585
2626
|
...result,
|
|
2586
2627
|
llmApiKey: result?.llmApiKey,
|
|
2587
2628
|
components: ["agents", "tools", "workflows", "scorers"],
|
|
2588
2629
|
addExample: true,
|
|
2589
|
-
versionTag:
|
|
2630
|
+
versionTag: args.createVersionTag
|
|
2590
2631
|
});
|
|
2591
2632
|
postCreate({ projectName });
|
|
2592
2633
|
return;
|
|
2593
2634
|
}
|
|
2594
|
-
const { components = [], llmProvider = "openai", addExample = false, llmApiKey } =
|
|
2635
|
+
const { components = [], llmProvider = "openai", addExample = false, llmApiKey } = args;
|
|
2595
2636
|
await init({
|
|
2596
2637
|
directory,
|
|
2597
2638
|
components,
|
|
2598
2639
|
llmProvider,
|
|
2599
2640
|
addExample,
|
|
2600
2641
|
llmApiKey,
|
|
2601
|
-
configureEditorWithDocsMCP:
|
|
2602
|
-
versionTag:
|
|
2642
|
+
configureEditorWithDocsMCP: args.mcpServer,
|
|
2643
|
+
versionTag: args.createVersionTag
|
|
2603
2644
|
});
|
|
2604
2645
|
postCreate({ projectName });
|
|
2605
2646
|
};
|
|
@@ -2690,9 +2731,9 @@ async function createFromGitHubUrl(url) {
|
|
|
2690
2731
|
workflows: []
|
|
2691
2732
|
};
|
|
2692
2733
|
}
|
|
2693
|
-
async function createFromTemplate(
|
|
2734
|
+
async function createFromTemplate(args) {
|
|
2694
2735
|
let selectedTemplate;
|
|
2695
|
-
if (
|
|
2736
|
+
if (args.template === true) {
|
|
2696
2737
|
const templates = await loadTemplates();
|
|
2697
2738
|
const selected = await selectTemplate(templates);
|
|
2698
2739
|
if (!selected) {
|
|
@@ -2700,11 +2741,11 @@ async function createFromTemplate(args2) {
|
|
|
2700
2741
|
return;
|
|
2701
2742
|
}
|
|
2702
2743
|
selectedTemplate = selected;
|
|
2703
|
-
} else if (
|
|
2704
|
-
if (isGitHubUrl(
|
|
2744
|
+
} else if (args.template && typeof args.template === "string") {
|
|
2745
|
+
if (isGitHubUrl(args.template)) {
|
|
2705
2746
|
const spinner4 = Y();
|
|
2706
2747
|
spinner4.start("Validating GitHub repository...");
|
|
2707
|
-
const validation = await validateGitHubProject(
|
|
2748
|
+
const validation = await validateGitHubProject(args.template);
|
|
2708
2749
|
if (!validation.isValid) {
|
|
2709
2750
|
spinner4.stop("Validation failed");
|
|
2710
2751
|
M.error("This does not appear to be a valid Mastra project:");
|
|
@@ -2712,14 +2753,14 @@ async function createFromTemplate(args2) {
|
|
|
2712
2753
|
throw new Error("Invalid Mastra project");
|
|
2713
2754
|
}
|
|
2714
2755
|
spinner4.stop("Valid Mastra project \u2713");
|
|
2715
|
-
selectedTemplate = await createFromGitHubUrl(
|
|
2756
|
+
selectedTemplate = await createFromGitHubUrl(args.template);
|
|
2716
2757
|
} else {
|
|
2717
2758
|
const templates = await loadTemplates();
|
|
2718
|
-
const found = findTemplateByName(templates,
|
|
2759
|
+
const found = findTemplateByName(templates, args.template);
|
|
2719
2760
|
if (!found) {
|
|
2720
|
-
M.error(`Template "${
|
|
2761
|
+
M.error(`Template "${args.template}" not found. Available templates:`);
|
|
2721
2762
|
templates.forEach((t) => M.info(` - ${t.title} (use: ${t.slug.replace("template-", "")})`));
|
|
2722
|
-
throw new Error(`Template "${
|
|
2763
|
+
throw new Error(`Template "${args.template}" not found`);
|
|
2723
2764
|
}
|
|
2724
2765
|
selectedTemplate = found;
|
|
2725
2766
|
}
|
|
@@ -2727,7 +2768,7 @@ async function createFromTemplate(args2) {
|
|
|
2727
2768
|
if (!selectedTemplate) {
|
|
2728
2769
|
throw new Error("No template selected");
|
|
2729
2770
|
}
|
|
2730
|
-
let projectName =
|
|
2771
|
+
let projectName = args.projectName;
|
|
2731
2772
|
if (!projectName) {
|
|
2732
2773
|
const defaultName = getDefaultProjectName(selectedTemplate);
|
|
2733
2774
|
const response = await he({
|
|
@@ -2741,17 +2782,40 @@ async function createFromTemplate(args2) {
|
|
|
2741
2782
|
}
|
|
2742
2783
|
projectName = response;
|
|
2743
2784
|
}
|
|
2785
|
+
let llmProvider = args.llmProvider;
|
|
2786
|
+
if (!llmProvider) {
|
|
2787
|
+
const providerResponse = await ve({
|
|
2788
|
+
message: "Select a default provider:",
|
|
2789
|
+
options: LLM_PROVIDERS
|
|
2790
|
+
});
|
|
2791
|
+
if (pD(providerResponse)) {
|
|
2792
|
+
M.info("Project creation cancelled.");
|
|
2793
|
+
return;
|
|
2794
|
+
}
|
|
2795
|
+
llmProvider = providerResponse;
|
|
2796
|
+
}
|
|
2744
2797
|
try {
|
|
2745
|
-
const analytics =
|
|
2798
|
+
const analytics = args.injectedAnalytics || getAnalytics();
|
|
2746
2799
|
if (analytics) {
|
|
2747
2800
|
analytics.trackEvent("cli_template_used", {
|
|
2748
2801
|
template_slug: selectedTemplate.slug,
|
|
2749
2802
|
template_title: selectedTemplate.title
|
|
2750
2803
|
});
|
|
2804
|
+
if (llmProvider) {
|
|
2805
|
+
analytics.trackEvent("cli_model_provider_selected", {
|
|
2806
|
+
provider: llmProvider,
|
|
2807
|
+
selection_method: args.llmProvider ? "cli_args" : "interactive"
|
|
2808
|
+
});
|
|
2809
|
+
}
|
|
2751
2810
|
}
|
|
2811
|
+
const isBeta = version$1?.includes("beta") ?? false;
|
|
2812
|
+
const isMastraTemplate = selectedTemplate.githubUrl.includes("github.com/mastra-ai/");
|
|
2813
|
+
const branch = isBeta && isMastraTemplate ? "beta" : void 0;
|
|
2752
2814
|
const projectPath = await cloneTemplate({
|
|
2753
2815
|
template: selectedTemplate,
|
|
2754
|
-
projectName
|
|
2816
|
+
projectName,
|
|
2817
|
+
branch,
|
|
2818
|
+
llmProvider
|
|
2755
2819
|
});
|
|
2756
2820
|
await installDependencies(projectPath);
|
|
2757
2821
|
Me(`
|
|
@@ -2770,7 +2834,7 @@ async function createFromTemplate(args2) {
|
|
|
2770
2834
|
async function getPackageVersion() {
|
|
2771
2835
|
const __filename = fileURLToPath(import.meta.url);
|
|
2772
2836
|
const __dirname = dirname(__filename);
|
|
2773
|
-
const pkgJsonPath =
|
|
2837
|
+
const pkgJsonPath = path3.join(__dirname, "..", "package.json");
|
|
2774
2838
|
const content = await fsExtra$1.readJSON(pkgJsonPath);
|
|
2775
2839
|
return content.version;
|
|
2776
2840
|
}
|