create-mastra 0.0.0-mssql-store-20250804200341 → 0.0.0-partial-response-backport-20251204204441

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 CHANGED
@@ -1,29 +1,29 @@
1
1
  #! /usr/bin/env node
2
2
  import { Command } from 'commander';
3
3
  import { randomUUID } from 'node:crypto';
4
- import * as fs4__default from 'node:fs';
5
- import fs4__default__default, { existsSync, readFileSync, writeFileSync } from 'node:fs';
4
+ import * as fs3__default from 'node:fs';
5
+ import fs3__default__default, { existsSync, readFileSync, writeFileSync } from 'node:fs';
6
6
  import os from 'node:os';
7
- import path3, { dirname } from 'node:path';
7
+ import path, { dirname } from 'node:path';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { PostHog } from 'posthog-node';
10
+ import fs4 from 'node:fs/promises';
10
11
  import util, { stripVTControlCharacters } from 'node:util';
11
12
  import y$1, { stdout, stdin } from 'node:process';
12
13
  import * as g from 'node:readline';
13
14
  import g__default from 'node:readline';
14
15
  import { Writable } from 'node:stream';
15
- import fs from 'node:fs/promises';
16
16
  import child_process from 'node:child_process';
17
17
  import tty from 'node:tty';
18
+ import fsExtra, { readJSON, ensureFile, writeJSON } from 'fs-extra/esm';
19
+ import prettier from 'prettier';
20
+ import { execa } from 'execa';
18
21
  import pino from 'pino';
19
22
  import pretty from 'pino-pretty';
20
- import { execa } from 'execa';
21
- import fsExtra3, { readJSON, ensureFile, writeJSON } from 'fs-extra/esm';
22
- import prettier from 'prettier';
23
- import fsExtra from 'fs-extra';
23
+ import fsExtra$1 from 'fs-extra';
24
24
 
25
25
  var __filename = fileURLToPath(import.meta.url);
26
- var __dirname = path3.dirname(__filename);
26
+ var __dirname = path.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 = path3.join(__dirname, "mastra-cli.json");
42
+ const cliConfigPath = path.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(path3.join(__dirname, "mastra-cli.json"), JSON.stringify({ distinctId, sessionId }));
70
+ writeFileSync(path.join(__dirname, "mastra-cli.json"), JSON.stringify({ distinctId, sessionId }));
71
71
  } catch {
72
72
  }
73
73
  }
@@ -422,7 +422,7 @@ ${color2.gray(d)} ${t}
422
422
  `):process.stdout.write(`${w} ${l}
423
423
  `),E(),s();};return {start:H,stop:N,message:(m="")=>{l=R(m??l);}}},Ce=async(t,n)=>{const r={},i=Object.keys(t);for(const s of i){const c=t[s],a=await c({results:r})?.catch(l=>{throw l});if(typeof n?.onCancel=="function"&&pD(a)){r[s]="canceled",n.onCancel({results:r});continue}r[s]=a;}return r};
424
424
 
425
- var shellQuote$1 = {};
425
+ var shellQuote = {};
426
426
 
427
427
  var quote;
428
428
  var hasRequiredQuote;
@@ -688,16 +688,16 @@ function requireParse () {
688
688
  var hasRequiredShellQuote;
689
689
 
690
690
  function requireShellQuote () {
691
- if (hasRequiredShellQuote) return shellQuote$1;
691
+ if (hasRequiredShellQuote) return shellQuote;
692
692
  hasRequiredShellQuote = 1;
693
693
 
694
- shellQuote$1.quote = requireQuote();
695
- shellQuote$1.parse = requireParse();
696
- return shellQuote$1;
694
+ shellQuote.quote = requireQuote();
695
+ shellQuote.parse = requireParse();
696
+ return shellQuote;
697
697
  }
698
698
 
699
699
  var shellQuoteExports = requireShellQuote();
700
- var shellQuote = /*@__PURE__*/getDefaultExportFromCjs(shellQuoteExports);
700
+ var shellQuote2 = /*@__PURE__*/getDefaultExportFromCjs(shellQuoteExports);
701
701
 
702
702
  // eslint-disable-next-line no-warning-comments
703
703
  // TODO: Use a better method when it's added to Node.js (https://github.com/nodejs/node/pull/40240)
@@ -724,13 +724,18 @@ const format = (open, close) => {
724
724
  // Handle nested colors.
725
725
 
726
726
  // We could have done this, but it's too slow (as of Node.js 22).
727
- // return openCode + string.replaceAll(closeCode, openCode) + closeCode;
727
+ // return openCode + string.replaceAll(closeCode, (close === 22 ? closeCode : '') + openCode) + closeCode;
728
728
 
729
729
  let result = openCode;
730
730
  let lastIndex = 0;
731
731
 
732
+ // SGR 22 resets both bold (1) and dim (2). When we encounter a nested
733
+ // close for styles that use 22, we need to re-open the outer style.
734
+ const reopenOnNestedClose = close === 22;
735
+ const replaceCode = (reopenOnNestedClose ? closeCode : '') + openCode;
736
+
732
737
  while (index !== -1) {
733
- result += string.slice(lastIndex, index) + openCode;
738
+ result += string.slice(lastIndex, index) + replaceCode;
734
739
  lastIndex = index + closeCode.length;
735
740
  index = string.indexOf(closeCode, lastIndex);
736
741
  }
@@ -1173,288 +1178,6 @@ var PinoLogger = class extends MastraLogger {
1173
1178
  }
1174
1179
  };
1175
1180
 
1176
- function getPackageManager() {
1177
- const userAgent = process.env.npm_config_user_agent || "";
1178
- const execPath = process.env.npm_execpath || "";
1179
- if (userAgent.includes("yarn")) {
1180
- return "yarn";
1181
- }
1182
- if (userAgent.includes("pnpm")) {
1183
- return "pnpm";
1184
- }
1185
- if (userAgent.includes("npm")) {
1186
- return "npm";
1187
- }
1188
- if (execPath.includes("yarn")) {
1189
- return "yarn";
1190
- }
1191
- if (execPath.includes("pnpm")) {
1192
- return "pnpm";
1193
- }
1194
- if (execPath.includes("npm")) {
1195
- return "npm";
1196
- }
1197
- return "npm";
1198
- }
1199
- function getPackageManagerInstallCommand(pm) {
1200
- switch (pm) {
1201
- case "npm":
1202
- return "install";
1203
- case "yarn":
1204
- return "add";
1205
- case "pnpm":
1206
- return "add";
1207
- default:
1208
- return "install";
1209
- }
1210
- }
1211
- var logger = new PinoLogger({
1212
- name: "Mastra CLI",
1213
- level: "info"
1214
- });
1215
- var exec = util.promisify(child_process.exec);
1216
- async function cloneTemplate(options) {
1217
- const { template, projectName, targetDir } = options;
1218
- const projectPath = targetDir ? path3.resolve(targetDir, projectName) : path3.resolve(projectName);
1219
- const spinner5 = yoctoSpinner({ text: `Cloning template "${template.title}"...` }).start();
1220
- try {
1221
- if (await directoryExists(projectPath)) {
1222
- spinner5.error(`Directory ${projectName} already exists`);
1223
- throw new Error(`Directory ${projectName} already exists`);
1224
- }
1225
- await cloneRepositoryWithoutGit(template.githubUrl, projectPath);
1226
- await updatePackageJson(projectPath, projectName);
1227
- const envExamplePath = path3.join(projectPath, ".env.example");
1228
- if (await fileExists(envExamplePath)) {
1229
- await fs.copyFile(envExamplePath, path3.join(projectPath, ".env"));
1230
- }
1231
- spinner5.success(`Template "${template.title}" cloned successfully to ${projectName}`);
1232
- return projectPath;
1233
- } catch (error) {
1234
- spinner5.error(`Failed to clone template: ${error instanceof Error ? error.message : "Unknown error"}`);
1235
- throw error;
1236
- }
1237
- }
1238
- async function directoryExists(dirPath) {
1239
- try {
1240
- const stat = await fs.stat(dirPath);
1241
- return stat.isDirectory();
1242
- } catch {
1243
- return false;
1244
- }
1245
- }
1246
- async function fileExists(filePath) {
1247
- try {
1248
- const stat = await fs.stat(filePath);
1249
- return stat.isFile();
1250
- } catch {
1251
- return false;
1252
- }
1253
- }
1254
- async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
1255
- await fs.mkdir(targetPath, { recursive: true });
1256
- try {
1257
- const degitRepo = repoUrl.replace("https://github.com/", "");
1258
- const degitCommand = shellQuote.quote(["npx", "degit", degitRepo, targetPath]);
1259
- await exec(degitCommand, {
1260
- cwd: process.cwd()
1261
- });
1262
- } catch {
1263
- try {
1264
- const gitCommand = shellQuote.quote(["git", "clone", repoUrl, targetPath]);
1265
- await exec(gitCommand, {
1266
- cwd: process.cwd()
1267
- });
1268
- const gitDir = path3.join(targetPath, ".git");
1269
- if (await directoryExists(gitDir)) {
1270
- await fs.rm(gitDir, { recursive: true, force: true });
1271
- }
1272
- } catch (gitError) {
1273
- throw new Error(`Failed to clone repository: ${gitError instanceof Error ? gitError.message : "Unknown error"}`);
1274
- }
1275
- }
1276
- }
1277
- async function updatePackageJson(projectPath, projectName) {
1278
- const packageJsonPath = path3.join(projectPath, "package.json");
1279
- try {
1280
- const packageJsonContent = await fs.readFile(packageJsonPath, "utf-8");
1281
- const packageJson = JSON.parse(packageJsonContent);
1282
- packageJson.name = projectName;
1283
- await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
1284
- } catch (error) {
1285
- logger.warn(`Could not update package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
1286
- }
1287
- }
1288
- async function installDependencies(projectPath, packageManager) {
1289
- const spinner5 = yoctoSpinner({ text: "Installing dependencies..." }).start();
1290
- try {
1291
- const pm = packageManager || getPackageManager();
1292
- const installCommand = shellQuote.quote([pm, "install"]);
1293
- await exec(installCommand, {
1294
- cwd: projectPath
1295
- });
1296
- spinner5.success("Dependencies installed successfully");
1297
- } catch (error) {
1298
- spinner5.error(`Failed to install dependencies: ${error instanceof Error ? error.message : "Unknown error"}`);
1299
- throw error;
1300
- }
1301
- }
1302
- var TEMPLATES_API_URL = process.env.MASTRA_TEMPLATES_API_URL || "https://mastra.ai/api/templates.json";
1303
- async function loadTemplates() {
1304
- try {
1305
- const response = await fetch(TEMPLATES_API_URL);
1306
- if (!response.ok) {
1307
- throw new Error(`Failed to fetch templates: ${response.statusText}`);
1308
- }
1309
- const templates = await response.json();
1310
- return templates;
1311
- } catch (error) {
1312
- console.error("Error loading templates:", error);
1313
- throw new Error("Failed to load templates. Please check your internet connection and try again.");
1314
- }
1315
- }
1316
- function pluralize(count, singular, plural) {
1317
- return count === 1 ? singular : plural || `${singular}s`;
1318
- }
1319
- async function selectTemplate(templates) {
1320
- const choices = templates.map((template) => {
1321
- const parts = [];
1322
- if (template.agents?.length) {
1323
- parts.push(`${template.agents.length} ${pluralize(template.agents.length, "agent")}`);
1324
- }
1325
- if (template.tools?.length) {
1326
- parts.push(`${template.tools.length} ${pluralize(template.tools.length, "tool")}`);
1327
- }
1328
- if (template.workflows?.length) {
1329
- parts.push(`${template.workflows.length} ${pluralize(template.workflows.length, "workflow")}`);
1330
- }
1331
- if (template.mcp?.length) {
1332
- parts.push(`${template.mcp.length} ${pluralize(template.mcp.length, "MCP server")}`);
1333
- }
1334
- if (template.networks?.length) {
1335
- parts.push(`${template.networks.length} ${pluralize(template.networks.length, "agent network")}`);
1336
- }
1337
- return {
1338
- value: template,
1339
- label: template.title,
1340
- hint: parts.join(", ") || "Template components"
1341
- };
1342
- });
1343
- const selected = await ve({
1344
- message: "Select a template:",
1345
- options: choices
1346
- });
1347
- if (pD(selected)) {
1348
- return null;
1349
- }
1350
- return selected;
1351
- }
1352
- function findTemplateByName(templates, templateName) {
1353
- let template = templates.find((t) => t.slug === templateName);
1354
- if (template) return template;
1355
- const slugWithPrefix = `template-${templateName}`;
1356
- template = templates.find((t) => t.slug === slugWithPrefix);
1357
- if (template) return template;
1358
- template = templates.find((t) => t.title.toLowerCase() === templateName.toLowerCase());
1359
- if (template) return template;
1360
- return null;
1361
- }
1362
- function getDefaultProjectName(template) {
1363
- return template.slug.replace(/^template-/, "");
1364
- }
1365
- var DepsService = class {
1366
- packageManager;
1367
- constructor() {
1368
- this.packageManager = this.getPackageManager();
1369
- }
1370
- findLockFile(dir) {
1371
- const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
1372
- for (const file of lockFiles) {
1373
- if (fs4__default__default.existsSync(path3.join(dir, file))) {
1374
- return file;
1375
- }
1376
- }
1377
- const parentDir = path3.resolve(dir, "..");
1378
- if (parentDir !== dir) {
1379
- return this.findLockFile(parentDir);
1380
- }
1381
- return null;
1382
- }
1383
- getPackageManager() {
1384
- const lockFile = this.findLockFile(process.cwd());
1385
- switch (lockFile) {
1386
- case "pnpm-lock.yaml":
1387
- return "pnpm";
1388
- case "package-lock.json":
1389
- return "npm";
1390
- case "yarn.lock":
1391
- return "yarn";
1392
- case "bun.lock":
1393
- return "bun";
1394
- default:
1395
- return "npm";
1396
- }
1397
- }
1398
- async installPackages(packages) {
1399
- let runCommand = this.packageManager;
1400
- if (this.packageManager === "npm") {
1401
- runCommand = `${this.packageManager} i`;
1402
- } else {
1403
- runCommand = `${this.packageManager} add`;
1404
- }
1405
- const packageList = packages.join(" ");
1406
- return execa(`${runCommand} ${packageList}`, {
1407
- all: true,
1408
- shell: true,
1409
- stdio: "inherit"
1410
- });
1411
- }
1412
- async checkDependencies(dependencies) {
1413
- try {
1414
- const packageJsonPath = path3.join(process.cwd(), "package.json");
1415
- try {
1416
- await fs.access(packageJsonPath);
1417
- } catch {
1418
- return "No package.json file found in the current directory";
1419
- }
1420
- const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
1421
- for (const dependency of dependencies) {
1422
- if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {
1423
- return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;
1424
- }
1425
- }
1426
- return "ok";
1427
- } catch (err) {
1428
- console.error(err);
1429
- return "Could not check dependencies";
1430
- }
1431
- }
1432
- async getProjectName() {
1433
- try {
1434
- const packageJsonPath = path3.join(process.cwd(), "package.json");
1435
- const packageJson = await fs.readFile(packageJsonPath, "utf-8");
1436
- const pkg = JSON.parse(packageJson);
1437
- return pkg.name;
1438
- } catch (err) {
1439
- throw err;
1440
- }
1441
- }
1442
- async getPackageVersion() {
1443
- const __filename = fileURLToPath(import.meta.url);
1444
- const __dirname = dirname(__filename);
1445
- const pkgJsonPath = path3.join(__dirname, "..", "package.json");
1446
- const content = await fsExtra3.readJSON(pkgJsonPath);
1447
- return content.version;
1448
- }
1449
- async addScriptsToPackageJson(scripts) {
1450
- const packageJson = JSON.parse(await fs.readFile("package.json", "utf-8"));
1451
- packageJson.scripts = {
1452
- ...packageJson.scripts,
1453
- ...scripts
1454
- };
1455
- await fs.writeFile("package.json", JSON.stringify(packageJson, null, 2));
1456
- }
1457
- };
1458
1181
  var args = ["-y", "@mastra/mcp-docs-server"];
1459
1182
  var createMcpConfig = (editor) => {
1460
1183
  if (editor === "vscode") {
@@ -1507,19 +1230,19 @@ async function writeMergedConfig(configPath, editor) {
1507
1230
  spaces: 2
1508
1231
  });
1509
1232
  }
1510
- var windsurfGlobalMCPConfigPath = path3.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
1511
- var cursorGlobalMCPConfigPath = path3.join(os.homedir(), ".cursor", "mcp.json");
1512
- path3.join(process.cwd(), ".vscode", "mcp.json");
1513
- var vscodeGlobalMCPConfigPath = path3.join(
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(
1514
1237
  os.homedir(),
1515
- 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")
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")
1516
1239
  );
1517
1240
  async function installMastraDocsMCPServer({ editor, directory }) {
1518
1241
  if (editor === `cursor`) {
1519
- await writeMergedConfig(path3.join(directory, ".cursor", "mcp.json"), "cursor");
1242
+ await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"), "cursor");
1520
1243
  }
1521
1244
  if (editor === `vscode`) {
1522
- await writeMergedConfig(path3.join(directory, ".vscode", "mcp.json"), "vscode");
1245
+ await writeMergedConfig(path.join(directory, ".vscode", "mcp.json"), "vscode");
1523
1246
  }
1524
1247
  if (editor === `cursor-global`) {
1525
1248
  const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
@@ -1567,25 +1290,121 @@ async function globalMCPIsAlreadyInstalled(editor) {
1567
1290
  return false;
1568
1291
  }
1569
1292
  }
1570
- var EnvService = class {
1571
- };
1572
- var FileEnvService = class extends EnvService {
1573
- filePath;
1574
- constructor(filePath) {
1575
- super();
1576
- this.filePath = filePath;
1293
+ function getPackageManagerAddCommand(pm) {
1294
+ switch (pm) {
1295
+ case "npm":
1296
+ return "install --audit=false --fund=false --loglevel=error --progress=false --update-notifier=false";
1297
+ case "yarn":
1298
+ return "add";
1299
+ case "pnpm":
1300
+ return "add --loglevel=error";
1301
+ case "bun":
1302
+ return "add";
1303
+ default:
1304
+ return "add";
1577
1305
  }
1578
- readFile(filePath) {
1579
- return new Promise((resolve, reject) => {
1580
- fs4__default.readFile(filePath, "utf8", (err, data) => {
1581
- if (err) reject(err);
1306
+ }
1307
+ var DepsService = class {
1308
+ packageManager;
1309
+ constructor() {
1310
+ this.packageManager = this.getPackageManager();
1311
+ }
1312
+ findLockFile(dir) {
1313
+ const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
1314
+ for (const file of lockFiles) {
1315
+ if (fs3__default__default.existsSync(path.join(dir, file))) {
1316
+ return file;
1317
+ }
1318
+ }
1319
+ const parentDir = path.resolve(dir, "..");
1320
+ if (parentDir !== dir) {
1321
+ return this.findLockFile(parentDir);
1322
+ }
1323
+ return null;
1324
+ }
1325
+ getPackageManager() {
1326
+ const lockFile = this.findLockFile(process.cwd());
1327
+ switch (lockFile) {
1328
+ case "pnpm-lock.yaml":
1329
+ return "pnpm";
1330
+ case "package-lock.json":
1331
+ return "npm";
1332
+ case "yarn.lock":
1333
+ return "yarn";
1334
+ case "bun.lock":
1335
+ return "bun";
1336
+ default:
1337
+ return "npm";
1338
+ }
1339
+ }
1340
+ async installPackages(packages) {
1341
+ const pm = this.packageManager;
1342
+ const installCommand = getPackageManagerAddCommand(pm);
1343
+ const packageList = packages.join(" ");
1344
+ return execa(`${pm} ${installCommand} ${packageList}`, {
1345
+ all: true,
1346
+ shell: true,
1347
+ stdio: "inherit"
1348
+ });
1349
+ }
1350
+ async checkDependencies(dependencies) {
1351
+ try {
1352
+ const packageJsonPath = path.join(process.cwd(), "package.json");
1353
+ try {
1354
+ await fs4.access(packageJsonPath);
1355
+ } catch {
1356
+ return "No package.json file found in the current directory";
1357
+ }
1358
+ const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf-8"));
1359
+ for (const dependency of dependencies) {
1360
+ if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {
1361
+ return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;
1362
+ }
1363
+ }
1364
+ return "ok";
1365
+ } catch (err) {
1366
+ console.error(err);
1367
+ return "Could not check dependencies";
1368
+ }
1369
+ }
1370
+ async getProjectName() {
1371
+ try {
1372
+ const packageJsonPath = path.join(process.cwd(), "package.json");
1373
+ const packageJson = await fs4.readFile(packageJsonPath, "utf-8");
1374
+ const pkg = JSON.parse(packageJson);
1375
+ return pkg.name;
1376
+ } catch (err) {
1377
+ throw err;
1378
+ }
1379
+ }
1380
+ async addScriptsToPackageJson(scripts) {
1381
+ const packageJson = JSON.parse(await fs4.readFile("package.json", "utf-8"));
1382
+ packageJson.scripts = {
1383
+ ...packageJson.scripts,
1384
+ ...scripts
1385
+ };
1386
+ await fs4.writeFile("package.json", JSON.stringify(packageJson, null, 2));
1387
+ }
1388
+ };
1389
+ var EnvService = class {
1390
+ };
1391
+ var FileEnvService = class extends EnvService {
1392
+ filePath;
1393
+ constructor(filePath) {
1394
+ super();
1395
+ this.filePath = filePath;
1396
+ }
1397
+ readFile(filePath) {
1398
+ return new Promise((resolve, reject) => {
1399
+ fs3__default.readFile(filePath, "utf8", (err, data) => {
1400
+ if (err) reject(err);
1582
1401
  else resolve(data);
1583
1402
  });
1584
1403
  });
1585
1404
  }
1586
1405
  writeFile({ filePath, data }) {
1587
1406
  return new Promise((resolve, reject) => {
1588
- fs4__default.writeFile(filePath, data, "utf8", (err) => {
1407
+ fs3__default.writeFile(filePath, data, "utf8", (err) => {
1589
1408
  if (err) reject(err);
1590
1409
  else resolve();
1591
1410
  });
@@ -1605,7 +1424,7 @@ var FileEnvService = class extends EnvService {
1605
1424
  ${key}=${value}`;
1606
1425
  }
1607
1426
  await this.writeFile({ filePath, data });
1608
- console.log(`${key} set to ${value} in ENV file.`);
1427
+ console.info(`${key} set to ${value} in ENV file.`);
1609
1428
  return data;
1610
1429
  }
1611
1430
  async getEnvValue(key) {
@@ -1638,25 +1457,25 @@ var FileService = class {
1638
1457
  */
1639
1458
  async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
1640
1459
  const __filename = fileURLToPath(import.meta.url);
1641
- const __dirname = path3.dirname(__filename);
1642
- const filePath = path3.resolve(__dirname, "starter-files", inputFile);
1643
- const fileString = fs4__default__default.readFileSync(filePath, "utf8");
1644
- if (fs4__default__default.existsSync(outputFilePath) && !replaceIfExists) {
1645
- console.log(`${outputFilePath} already exists`);
1460
+ const __dirname = path.dirname(__filename);
1461
+ const filePath = path.resolve(__dirname, "starter-files", inputFile);
1462
+ const fileString = fs3__default__default.readFileSync(filePath, "utf8");
1463
+ if (fs3__default__default.existsSync(outputFilePath) && !replaceIfExists) {
1464
+ console.info(`${outputFilePath} already exists`);
1646
1465
  return false;
1647
1466
  }
1648
- await fsExtra3.outputFile(outputFilePath, fileString);
1467
+ await fsExtra.outputFile(outputFilePath, fileString);
1649
1468
  return true;
1650
1469
  }
1651
1470
  async setupEnvFile({ dbUrl }) {
1652
- const envPath = path3.join(process.cwd(), ".env.development");
1653
- await fsExtra3.ensureFile(envPath);
1471
+ const envPath = path.join(process.cwd(), ".env.development");
1472
+ await fsExtra.ensureFile(envPath);
1654
1473
  const fileEnvService = new FileEnvService(envPath);
1655
1474
  await fileEnvService.setEnvValue("DB_URL", dbUrl);
1656
1475
  }
1657
1476
  getFirstExistingFile(files) {
1658
1477
  for (const f of files) {
1659
- if (fs4__default__default.existsSync(f)) {
1478
+ if (fs3__default__default.existsSync(f)) {
1660
1479
  return f;
1661
1480
  }
1662
1481
  }
@@ -1666,61 +1485,31 @@ var FileService = class {
1666
1485
  filePath,
1667
1486
  replacements
1668
1487
  }) {
1669
- let fileContent = fs4__default__default.readFileSync(filePath, "utf8");
1488
+ let fileContent = fs3__default__default.readFileSync(filePath, "utf8");
1670
1489
  replacements.forEach(({ search, replace }) => {
1671
1490
  fileContent = fileContent.replaceAll(search, replace);
1672
1491
  });
1673
- fs4__default__default.writeFileSync(filePath, fileContent);
1674
- }
1675
- };
1676
- var exec2 = util.promisify(child_process.exec);
1677
- var getAISDKPackageVersion = (llmProvider) => {
1678
- switch (llmProvider) {
1679
- case "cerebras":
1680
- return "^0.2.14";
1681
- default:
1682
- return "^1.0.0";
1492
+ fs3__default__default.writeFileSync(filePath, fileContent);
1683
1493
  }
1684
1494
  };
1685
- var getAISDKPackage = (llmProvider) => {
1686
- switch (llmProvider) {
1687
- case "openai":
1688
- return "@ai-sdk/openai";
1689
- case "anthropic":
1690
- return "@ai-sdk/anthropic";
1691
- case "groq":
1692
- return "@ai-sdk/groq";
1693
- case "google":
1694
- return "@ai-sdk/google";
1695
- case "cerebras":
1696
- return "@ai-sdk/cerebras";
1697
- default:
1698
- return "@ai-sdk/openai";
1699
- }
1700
- };
1701
- var getProviderImportAndModelItem = (llmProvider) => {
1702
- let providerImport = "";
1703
- let modelItem = "";
1495
+ var exec = util.promisify(child_process.exec);
1496
+ var getModelIdentifier = (llmProvider) => {
1704
1497
  if (llmProvider === "openai") {
1705
- providerImport = `import { openai } from '${getAISDKPackage(llmProvider)}';`;
1706
- modelItem = `openai('gpt-4o-mini')`;
1498
+ return `'openai/gpt-4o-mini'`;
1707
1499
  } else if (llmProvider === "anthropic") {
1708
- providerImport = `import { anthropic } from '${getAISDKPackage(llmProvider)}';`;
1709
- modelItem = `anthropic('claude-3-5-sonnet-20241022')`;
1500
+ return `'anthropic/claude-sonnet-4-5-20250929'`;
1710
1501
  } else if (llmProvider === "groq") {
1711
- providerImport = `import { groq } from '${getAISDKPackage(llmProvider)}';`;
1712
- modelItem = `groq('llama-3.3-70b-versatile')`;
1502
+ return `'groq/llama-3.3-70b-versatile'`;
1713
1503
  } else if (llmProvider === "google") {
1714
- providerImport = `import { google } from '${getAISDKPackage(llmProvider)}';`;
1715
- modelItem = `google('gemini-2.5-pro')`;
1504
+ return `'google/gemini-2.5-pro'`;
1716
1505
  } else if (llmProvider === "cerebras") {
1717
- providerImport = `import { cerebras } from '${getAISDKPackage(llmProvider)}';`;
1718
- modelItem = `cerebras('llama-3.3-70b')`;
1506
+ return `'cerebras/llama-3.3-70b'`;
1507
+ } else if (llmProvider === "mistral") {
1508
+ return `'mistral/mistral-medium-2508'`;
1719
1509
  }
1720
- return { providerImport, modelItem };
1721
1510
  };
1722
- async function writeAgentSample(llmProvider, destPath, addExampleTool) {
1723
- const { providerImport, modelItem } = getProviderImportAndModelItem(llmProvider);
1511
+ async function writeAgentSample(llmProvider, destPath, addExampleTool, addScorers) {
1512
+ const modelString = getModelIdentifier(llmProvider);
1724
1513
  const instructions = `
1725
1514
  You are a helpful weather assistant that provides accurate weather information and can help planning activities based on the weather.
1726
1515
 
@@ -1736,17 +1525,40 @@ async function writeAgentSample(llmProvider, destPath, addExampleTool) {
1736
1525
  ${addExampleTool ? "Use the weatherTool to fetch current weather data." : ""}
1737
1526
  `;
1738
1527
  const content = `
1739
- ${providerImport}
1740
1528
  import { Agent } from '@mastra/core/agent';
1741
1529
  import { Memory } from '@mastra/memory';
1742
1530
  import { LibSQLStore } from '@mastra/libsql';
1743
1531
  ${addExampleTool ? `import { weatherTool } from '../tools/weather-tool';` : ""}
1532
+ ${addScorers ? `import { scorers } from '../scorers/weather-scorer';` : ""}
1744
1533
 
1745
1534
  export const weatherAgent = new Agent({
1746
1535
  name: 'Weather Agent',
1747
1536
  instructions: \`${instructions}\`,
1748
- model: ${modelItem},
1537
+ model: ${modelString},
1749
1538
  ${addExampleTool ? "tools: { weatherTool }," : ""}
1539
+ ${addScorers ? `scorers: {
1540
+ toolCallAppropriateness: {
1541
+ scorer: scorers.toolCallAppropriatenessScorer,
1542
+ sampling: {
1543
+ type: 'ratio',
1544
+ rate: 1,
1545
+ },
1546
+ },
1547
+ completeness: {
1548
+ scorer: scorers.completenessScorer,
1549
+ sampling: {
1550
+ type: 'ratio',
1551
+ rate: 1,
1552
+ },
1553
+ },
1554
+ translation: {
1555
+ scorer: scorers.translationScorer,
1556
+ sampling: {
1557
+ type: 'ratio',
1558
+ rate: 1,
1559
+ },
1560
+ },
1561
+ },` : ""}
1750
1562
  memory: new Memory({
1751
1563
  storage: new LibSQLStore({
1752
1564
  url: "file:../mastra.db", // path is relative to the .mastra/output directory
@@ -1758,8 +1570,8 @@ export const weatherAgent = new Agent({
1758
1570
  parser: "typescript",
1759
1571
  singleQuote: true
1760
1572
  });
1761
- await fs.writeFile(destPath, "");
1762
- await fs.writeFile(destPath, formattedContent);
1573
+ await fs4.writeFile(destPath, "");
1574
+ await fs4.writeFile(destPath, formattedContent);
1763
1575
  }
1764
1576
  async function writeWorkflowSample(destPath) {
1765
1577
  const content = `import { createStep, createWorkflow } from '@mastra/core/workflows';
@@ -1952,44 +1764,139 @@ export { weatherWorkflow };`;
1952
1764
  semi: true,
1953
1765
  singleQuote: true
1954
1766
  });
1955
- await fs.writeFile(destPath, formattedContent);
1767
+ await fs4.writeFile(destPath, formattedContent);
1956
1768
  }
1957
1769
  async function writeToolSample(destPath) {
1958
1770
  const fileService = new FileService();
1959
1771
  await fileService.copyStarterFile("tools.ts", destPath);
1960
1772
  }
1773
+ async function writeScorersSample(llmProvider, destPath) {
1774
+ const modelString = getModelIdentifier(llmProvider);
1775
+ const content = `import { z } from 'zod';
1776
+ import { createToolCallAccuracyScorerCode } from '@mastra/evals/scorers/code';
1777
+ import { createCompletenessScorer } from '@mastra/evals/scorers/code';
1778
+ import { createScorer } from '@mastra/core/scores';
1779
+
1780
+ export const toolCallAppropriatenessScorer = createToolCallAccuracyScorerCode({
1781
+ expectedTool: 'weatherTool',
1782
+ strictMode: false,
1783
+ });
1784
+
1785
+ export const completenessScorer = createCompletenessScorer();
1786
+
1787
+ // Custom LLM-judged scorer: evaluates if non-English locations are translated appropriately
1788
+ export const translationScorer = createScorer({
1789
+ name: 'Translation Quality',
1790
+ description: 'Checks that non-English location names are translated and used correctly',
1791
+ type: 'agent',
1792
+ judge: {
1793
+ model: ${modelString},
1794
+ instructions:
1795
+ 'You are an expert evaluator of translation quality for geographic locations. ' +
1796
+ 'Determine whether the user text mentions a non-English location and whether the assistant correctly uses an English translation of that location. ' +
1797
+ 'Be lenient with transliteration differences and diacritics. ' +
1798
+ 'Return only the structured JSON matching the provided schema.',
1799
+ },
1800
+ })
1801
+ .preprocess(({ run }) => {
1802
+ const userText = (run.input?.inputMessages?.[0]?.content as string) || '';
1803
+ const assistantText = (run.output?.[0]?.content as string) || '';
1804
+ return { userText, assistantText };
1805
+ })
1806
+ .analyze({
1807
+ description: 'Extract location names and detect language/translation adequacy',
1808
+ outputSchema: z.object({
1809
+ nonEnglish: z.boolean(),
1810
+ translated: z.boolean(),
1811
+ confidence: z.number().min(0).max(1).default(1),
1812
+ explanation: z.string().default(''),
1813
+ }),
1814
+ createPrompt: ({ results }) => \`
1815
+ You are evaluating if a weather assistant correctly handled translation of a non-English location.
1816
+ User text:
1817
+ """
1818
+ \${results.preprocessStepResult.userText}
1819
+ """
1820
+ Assistant response:
1821
+ """
1822
+ \${results.preprocessStepResult.assistantText}
1823
+ """
1824
+ Tasks:
1825
+ 1) Identify if the user mentioned a location that appears non-English.
1826
+ 2) If non-English, check whether the assistant used a correct English translation of that location in its response.
1827
+ 3) Be lenient with transliteration differences (e.g., accents/diacritics).
1828
+ Return JSON with fields:
1829
+ {
1830
+ "nonEnglish": boolean,
1831
+ "translated": boolean,
1832
+ "confidence": number, // 0-1
1833
+ "explanation": string
1834
+ }
1835
+ \`,
1836
+ })
1837
+ .generateScore(({ results }) => {
1838
+ const r = (results as any)?.analyzeStepResult || {};
1839
+ if (!r.nonEnglish) return 1; // If not applicable, full credit
1840
+ if (r.translated) return Math.max(0, Math.min(1, 0.7 + 0.3 * (r.confidence ?? 1)));
1841
+ return 0; // Non-English but not translated
1842
+ })
1843
+ .generateReason(({ results, score }) => {
1844
+ const r = (results as any)?.analyzeStepResult || {};
1845
+ return \`Translation scoring: nonEnglish=\${r.nonEnglish ?? false}, translated=\${r.translated ?? false}, confidence=\${r.confidence ?? 0}. Score=\${score}. \${r.explanation ?? ''}\`;
1846
+ });
1847
+
1848
+ export const scorers = {
1849
+ toolCallAppropriatenessScorer,
1850
+ completenessScorer,
1851
+ translationScorer,
1852
+ };`;
1853
+ const formattedContent = await prettier.format(content, {
1854
+ parser: "typescript",
1855
+ singleQuote: true
1856
+ });
1857
+ await fs4.writeFile(destPath, formattedContent);
1858
+ }
1961
1859
  async function writeCodeSampleForComponents(llmprovider, component, destPath, importComponents) {
1962
1860
  switch (component) {
1963
1861
  case "agents":
1964
- return writeAgentSample(llmprovider, destPath, importComponents.includes("tools"));
1862
+ return writeAgentSample(
1863
+ llmprovider,
1864
+ destPath,
1865
+ importComponents.includes("tools"),
1866
+ importComponents.includes("scorers")
1867
+ );
1965
1868
  case "tools":
1966
1869
  return writeToolSample(destPath);
1967
1870
  case "workflows":
1968
1871
  return writeWorkflowSample(destPath);
1872
+ case "scorers":
1873
+ return writeScorersSample(llmprovider, destPath);
1969
1874
  default:
1970
1875
  return "";
1971
1876
  }
1972
1877
  }
1973
1878
  var createComponentsDir = async (dirPath, component) => {
1974
1879
  const componentPath = dirPath + `/${component}`;
1975
- await fsExtra3.ensureDir(componentPath);
1880
+ await fsExtra.ensureDir(componentPath);
1976
1881
  };
1977
1882
  var writeIndexFile = async ({
1978
1883
  dirPath,
1979
1884
  addAgent,
1980
1885
  addExample,
1981
- addWorkflow
1886
+ addWorkflow,
1887
+ addScorers
1982
1888
  }) => {
1983
1889
  const indexPath = dirPath + "/index.ts";
1984
- const destPath = path3.join(indexPath);
1890
+ const destPath = path.join(indexPath);
1985
1891
  try {
1986
- await fs.writeFile(destPath, "");
1892
+ await fs4.writeFile(destPath, "");
1987
1893
  const filteredExports = [
1988
1894
  addWorkflow ? `workflows: { weatherWorkflow },` : "",
1989
- addAgent ? `agents: { weatherAgent },` : ""
1895
+ addAgent ? `agents: { weatherAgent },` : "",
1896
+ addScorers ? `scorers: { toolCallAppropriatenessScorer, completenessScorer, translationScorer },` : ""
1990
1897
  ].filter(Boolean);
1991
1898
  if (!addExample) {
1992
- await fs.writeFile(
1899
+ await fs4.writeFile(
1993
1900
  destPath,
1994
1901
  `
1995
1902
  import { Mastra } from '@mastra/core';
@@ -1999,7 +1906,7 @@ export const mastra = new Mastra()
1999
1906
  );
2000
1907
  return;
2001
1908
  }
2002
- await fs.writeFile(
1909
+ await fs4.writeFile(
2003
1910
  destPath,
2004
1911
  `
2005
1912
  import { Mastra } from '@mastra/core/mastra';
@@ -2007,17 +1914,26 @@ import { PinoLogger } from '@mastra/loggers';
2007
1914
  import { LibSQLStore } from '@mastra/libsql';
2008
1915
  ${addWorkflow ? `import { weatherWorkflow } from './workflows/weather-workflow';` : ""}
2009
1916
  ${addAgent ? `import { weatherAgent } from './agents/weather-agent';` : ""}
1917
+ ${addScorers ? `import { toolCallAppropriatenessScorer, completenessScorer, translationScorer } from './scorers/weather-scorer';` : ""}
2010
1918
 
2011
1919
  export const mastra = new Mastra({
2012
1920
  ${filteredExports.join("\n ")}
2013
1921
  storage: new LibSQLStore({
2014
- // stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
1922
+ // stores observability, scores, ... into memory storage, if it needs to persist, change to file:../mastra.db
2015
1923
  url: ":memory:",
2016
1924
  }),
2017
1925
  logger: new PinoLogger({
2018
1926
  name: 'Mastra',
2019
1927
  level: 'info',
2020
1928
  }),
1929
+ telemetry: {
1930
+ // Telemetry is deprecated and will be removed in the Nov 4th release
1931
+ enabled: false,
1932
+ },
1933
+ observability: {
1934
+ // Enables DefaultExporter and CloudExporter for AI tracing
1935
+ default: { enabled: true },
1936
+ },
2021
1937
  });
2022
1938
  `
2023
1939
  );
@@ -2025,7 +1941,6 @@ export const mastra = new Mastra({
2025
1941
  throw err;
2026
1942
  }
2027
1943
  };
2028
- yoctoSpinner({ text: "Installing Mastra core dependencies\n" });
2029
1944
  var getAPIKey = async (provider) => {
2030
1945
  let key = "OPENAI_API_KEY";
2031
1946
  switch (provider) {
@@ -2041,27 +1956,28 @@ var getAPIKey = async (provider) => {
2041
1956
  case "cerebras":
2042
1957
  key = "CEREBRAS_API_KEY";
2043
1958
  return key;
1959
+ case "mistral":
1960
+ key = "MISTRAL_API_KEY";
1961
+ return key;
2044
1962
  default:
2045
1963
  return key;
2046
1964
  }
2047
1965
  };
2048
- var writeAPIKey = async ({
2049
- provider,
2050
- apiKey = "your-api-key"
2051
- }) => {
1966
+ var writeAPIKey = async ({ provider, apiKey }) => {
1967
+ const envFileName = apiKey ? ".env" : ".env.example";
2052
1968
  const key = await getAPIKey(provider);
2053
- const escapedKey = shellQuote.quote([key]);
2054
- const escapedApiKey = shellQuote.quote([apiKey]);
2055
- await exec2(`echo ${escapedKey}=${escapedApiKey} >> .env`);
1969
+ const escapedKey = shellQuote2.quote([key]);
1970
+ const escapedApiKey = shellQuote2.quote([apiKey ? apiKey : "your-api-key"]);
1971
+ await exec(`echo ${escapedKey}=${escapedApiKey} >> ${envFileName}`);
2056
1972
  };
2057
1973
  var createMastraDir = async (directory) => {
2058
1974
  let dir = directory.trim().split("/").filter((item) => item !== "");
2059
- const dirPath = path3.join(process.cwd(), ...dir, "mastra");
1975
+ const dirPath = path.join(process.cwd(), ...dir, "mastra");
2060
1976
  try {
2061
- await fs.access(dirPath);
1977
+ await fs4.access(dirPath);
2062
1978
  return { ok: false };
2063
1979
  } catch {
2064
- await fsExtra3.ensureDir(dirPath);
1980
+ await fsExtra.ensureDir(dirPath);
2065
1981
  return { ok: true, dirPath };
2066
1982
  }
2067
1983
  };
@@ -2073,8 +1989,19 @@ var writeCodeSample = async (dirPath, component, llmProvider, importComponents)
2073
1989
  throw err;
2074
1990
  }
2075
1991
  };
2076
- var interactivePrompt = async () => {
2077
- Ie(color2.inverse(" Mastra Init "));
1992
+ var LLM_PROVIDERS = [
1993
+ { value: "openai", label: "OpenAI", hint: "recommended" },
1994
+ { value: "anthropic", label: "Anthropic" },
1995
+ { value: "groq", label: "Groq" },
1996
+ { value: "google", label: "Google" },
1997
+ { value: "cerebras", label: "Cerebras" },
1998
+ { value: "mistral", label: "Mistral" }
1999
+ ];
2000
+ var interactivePrompt = async (args2 = {}) => {
2001
+ const { skip = {}, options: { showBanner = true } = {} } = args2;
2002
+ if (showBanner) {
2003
+ Ie(color2.inverse(" Mastra Init "));
2004
+ }
2078
2005
  const mastraProject = await Ce(
2079
2006
  {
2080
2007
  directory: () => he({
@@ -2082,19 +2009,15 @@ var interactivePrompt = async () => {
2082
2009
  placeholder: "src/",
2083
2010
  defaultValue: "src/"
2084
2011
  }),
2085
- llmProvider: () => ve({
2086
- message: "Select default provider:",
2087
- options: [
2088
- { value: "openai", label: "OpenAI", hint: "recommended" },
2089
- { value: "anthropic", label: "Anthropic" },
2090
- { value: "groq", label: "Groq" },
2091
- { value: "google", label: "Google" },
2092
- { value: "cerebras", label: "Cerebras" }
2093
- ]
2012
+ llmProvider: () => skip?.llmProvider ? void 0 : ve({
2013
+ message: "Select a default provider:",
2014
+ options: LLM_PROVIDERS
2094
2015
  }),
2095
2016
  llmApiKey: async ({ results: { llmProvider } }) => {
2017
+ if (skip?.llmApiKey) return void 0;
2018
+ const llmName = LLM_PROVIDERS.find((p6) => p6.value === llmProvider)?.label || "provider";
2096
2019
  const keyChoice = await ve({
2097
- message: `Enter your ${llmProvider} API key?`,
2020
+ message: `Enter your ${llmName} API key?`,
2098
2021
  options: [
2099
2022
  { value: "skip", label: "Skip for now", hint: "default" },
2100
2023
  { value: "enter", label: "Enter API key" }
@@ -2104,7 +2027,10 @@ var interactivePrompt = async () => {
2104
2027
  if (keyChoice === "enter") {
2105
2028
  return he({
2106
2029
  message: "Enter your API key:",
2107
- placeholder: "sk-..."
2030
+ placeholder: "sk-...",
2031
+ validate: (value) => {
2032
+ if (value.length === 0) return "API key cannot be empty";
2033
+ }
2108
2034
  });
2109
2035
  }
2110
2036
  return void 0;
@@ -2114,7 +2040,7 @@ var interactivePrompt = async () => {
2114
2040
  const cursorIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`cursor`);
2115
2041
  const vscodeIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`vscode`);
2116
2042
  const editor = await ve({
2117
- message: `Make your AI IDE into a Mastra expert? (installs Mastra docs MCP server)`,
2043
+ message: `Make your IDE into a Mastra expert? (Installs Mastra's MCP server)`,
2118
2044
  options: [
2119
2045
  { value: "skip", label: "Skip for now", hint: "default" },
2120
2046
  {
@@ -2158,19 +2084,19 @@ Note: you will need to go into Cursor Settings -> MCP Settings and manually enab
2158
2084
  );
2159
2085
  }
2160
2086
  if (editor === `cursor-global`) {
2161
- const confirm2 = await ve({
2087
+ const confirm = await ve({
2162
2088
  message: `Global install will add/update ${cursorGlobalMCPConfigPath} and make the Mastra docs MCP server available in all your Cursor projects. Continue?`,
2163
2089
  options: [
2164
2090
  { value: "yes", label: "Yes, I understand" },
2165
2091
  { value: "skip", label: "No, skip for now" }
2166
2092
  ]
2167
2093
  });
2168
- if (confirm2 !== `yes`) {
2094
+ if (confirm !== `yes`) {
2169
2095
  return void 0;
2170
2096
  }
2171
2097
  }
2172
2098
  if (editor === `windsurf`) {
2173
- const confirm2 = await ve({
2099
+ const confirm = await ve({
2174
2100
  message: `Windsurf only supports a global MCP config (at ${windsurfGlobalMCPConfigPath}) is it ok to add/update that global config?
2175
2101
  This means the Mastra docs MCP server will be available in all your Windsurf projects.`,
2176
2102
  options: [
@@ -2178,7 +2104,7 @@ This means the Mastra docs MCP server will be available in all your Windsurf pro
2178
2104
  { value: "skip", label: "No, skip for now" }
2179
2105
  ]
2180
2106
  });
2181
- if (confirm2 !== `yes`) {
2107
+ if (confirm !== `yes`) {
2182
2108
  return void 0;
2183
2109
  }
2184
2110
  }
@@ -2194,14 +2120,199 @@ This means the Mastra docs MCP server will be available in all your Windsurf pro
2194
2120
  );
2195
2121
  return mastraProject;
2196
2122
  };
2123
+ function getPackageManager() {
2124
+ const userAgent = process.env.npm_config_user_agent || "";
2125
+ const execPath = process.env.npm_execpath || "";
2126
+ if (userAgent.includes("bun")) {
2127
+ return "bun";
2128
+ }
2129
+ if (userAgent.includes("yarn")) {
2130
+ return "yarn";
2131
+ }
2132
+ if (userAgent.includes("pnpm")) {
2133
+ return "pnpm";
2134
+ }
2135
+ if (userAgent.includes("npm")) {
2136
+ return "npm";
2137
+ }
2138
+ if (execPath.includes("bun")) {
2139
+ return "bun";
2140
+ }
2141
+ if (execPath.includes("yarn")) {
2142
+ return "yarn";
2143
+ }
2144
+ if (execPath.includes("pnpm")) {
2145
+ return "pnpm";
2146
+ }
2147
+ if (execPath.includes("npm")) {
2148
+ return "npm";
2149
+ }
2150
+ return "npm";
2151
+ }
2152
+ var logger = createLogger(false);
2153
+ function createLogger(debug = false) {
2154
+ return new PinoLogger({
2155
+ name: "Mastra CLI",
2156
+ level: debug ? "debug" : "info"
2157
+ });
2158
+ }
2159
+ var exec2 = util.promisify(child_process.exec);
2160
+ async function cloneTemplate(options) {
2161
+ const { template, projectName, targetDir } = options;
2162
+ const projectPath = targetDir ? path.resolve(targetDir, projectName) : path.resolve(projectName);
2163
+ const spinner4 = yoctoSpinner({ text: `Cloning template "${template.title}"...` }).start();
2164
+ try {
2165
+ if (await directoryExists(projectPath)) {
2166
+ spinner4.error(`Directory ${projectName} already exists`);
2167
+ throw new Error(`Directory ${projectName} already exists`);
2168
+ }
2169
+ await cloneRepositoryWithoutGit(template.githubUrl, projectPath);
2170
+ await updatePackageJson(projectPath, projectName);
2171
+ const envExamplePath = path.join(projectPath, ".env.example");
2172
+ if (await fileExists(envExamplePath)) {
2173
+ await fs4.copyFile(envExamplePath, path.join(projectPath, ".env"));
2174
+ }
2175
+ spinner4.success(`Template "${template.title}" cloned successfully to ${projectName}`);
2176
+ return projectPath;
2177
+ } catch (error) {
2178
+ spinner4.error(`Failed to clone template: ${error instanceof Error ? error.message : "Unknown error"}`);
2179
+ throw error;
2180
+ }
2181
+ }
2182
+ async function directoryExists(dirPath) {
2183
+ try {
2184
+ const stat = await fs4.stat(dirPath);
2185
+ return stat.isDirectory();
2186
+ } catch {
2187
+ return false;
2188
+ }
2189
+ }
2190
+ async function fileExists(filePath) {
2191
+ try {
2192
+ const stat = await fs4.stat(filePath);
2193
+ return stat.isFile();
2194
+ } catch {
2195
+ return false;
2196
+ }
2197
+ }
2198
+ async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
2199
+ await fs4.mkdir(targetPath, { recursive: true });
2200
+ try {
2201
+ const degitRepo = repoUrl.replace("https://github.com/", "");
2202
+ const degitCommand = shellQuote2.quote(["npx", "degit", degitRepo, targetPath]);
2203
+ await exec2(degitCommand, {
2204
+ cwd: process.cwd()
2205
+ });
2206
+ } catch {
2207
+ try {
2208
+ const gitCommand = shellQuote2.quote(["git", "clone", repoUrl, targetPath]);
2209
+ await exec2(gitCommand, {
2210
+ cwd: process.cwd()
2211
+ });
2212
+ const gitDir = path.join(targetPath, ".git");
2213
+ if (await directoryExists(gitDir)) {
2214
+ await fs4.rm(gitDir, { recursive: true, force: true });
2215
+ }
2216
+ } catch (gitError) {
2217
+ throw new Error(`Failed to clone repository: ${gitError instanceof Error ? gitError.message : "Unknown error"}`);
2218
+ }
2219
+ }
2220
+ }
2221
+ async function updatePackageJson(projectPath, projectName) {
2222
+ const packageJsonPath = path.join(projectPath, "package.json");
2223
+ try {
2224
+ const packageJsonContent = await fs4.readFile(packageJsonPath, "utf-8");
2225
+ const packageJson = JSON.parse(packageJsonContent);
2226
+ packageJson.name = projectName;
2227
+ await fs4.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
2228
+ } catch (error) {
2229
+ logger.warn(`Could not update package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
2230
+ }
2231
+ }
2232
+ async function installDependencies(projectPath, packageManager) {
2233
+ const spinner4 = yoctoSpinner({ text: "Installing dependencies..." }).start();
2234
+ try {
2235
+ const pm = packageManager || getPackageManager();
2236
+ const installCommand = shellQuote2.quote([pm, "install"]);
2237
+ await exec2(installCommand, {
2238
+ cwd: projectPath
2239
+ });
2240
+ spinner4.success("Dependencies installed successfully");
2241
+ } catch (error) {
2242
+ spinner4.error(`Failed to install dependencies: ${error instanceof Error ? error.message : "Unknown error"}`);
2243
+ throw error;
2244
+ }
2245
+ }
2246
+ var TEMPLATES_API_URL = process.env.MASTRA_TEMPLATES_API_URL || "https://mastra.ai/api/templates.json";
2247
+ async function loadTemplates() {
2248
+ try {
2249
+ const response = await fetch(TEMPLATES_API_URL);
2250
+ if (!response.ok) {
2251
+ throw new Error(`Failed to fetch templates: ${response.statusText}`);
2252
+ }
2253
+ const templates = await response.json();
2254
+ return templates;
2255
+ } catch (error) {
2256
+ console.error("Error loading templates:", error);
2257
+ throw new Error("Failed to load templates. Please check your internet connection and try again.");
2258
+ }
2259
+ }
2260
+ function pluralize(count, singular, plural) {
2261
+ return count === 1 ? singular : plural || `${singular}s`;
2262
+ }
2263
+ async function selectTemplate(templates) {
2264
+ const choices = templates.map((template) => {
2265
+ const parts = [];
2266
+ if (template.agents?.length) {
2267
+ parts.push(`${template.agents.length} ${pluralize(template.agents.length, "agent")}`);
2268
+ }
2269
+ if (template.tools?.length) {
2270
+ parts.push(`${template.tools.length} ${pluralize(template.tools.length, "tool")}`);
2271
+ }
2272
+ if (template.workflows?.length) {
2273
+ parts.push(`${template.workflows.length} ${pluralize(template.workflows.length, "workflow")}`);
2274
+ }
2275
+ if (template.mcp?.length) {
2276
+ parts.push(`${template.mcp.length} ${pluralize(template.mcp.length, "MCP server")}`);
2277
+ }
2278
+ if (template.networks?.length) {
2279
+ parts.push(`${template.networks.length} ${pluralize(template.networks.length, "agent network")}`);
2280
+ }
2281
+ return {
2282
+ value: template,
2283
+ label: template.title,
2284
+ hint: parts.join(", ") || "Template components"
2285
+ };
2286
+ });
2287
+ const selected = await ve({
2288
+ message: "Select a template:",
2289
+ options: choices
2290
+ });
2291
+ if (pD(selected)) {
2292
+ return null;
2293
+ }
2294
+ return selected;
2295
+ }
2296
+ function findTemplateByName(templates, templateName) {
2297
+ let template = templates.find((t) => t.slug === templateName);
2298
+ if (template) return template;
2299
+ const slugWithPrefix = `template-${templateName}`;
2300
+ template = templates.find((t) => t.slug === slugWithPrefix);
2301
+ if (template) return template;
2302
+ template = templates.find((t) => t.title.toLowerCase() === templateName.toLowerCase());
2303
+ if (template) return template;
2304
+ return null;
2305
+ }
2306
+ function getDefaultProjectName(template) {
2307
+ return template.slug.replace(/^template-/, "");
2308
+ }
2197
2309
  var s = Y();
2198
- var exec3 = util.promisify(child_process.exec);
2199
2310
  var init = async ({
2200
- directory,
2201
- addExample = false,
2311
+ directory = "src/",
2202
2312
  components,
2203
2313
  llmProvider = "openai",
2204
2314
  llmApiKey,
2315
+ addExample = false,
2205
2316
  configureEditorWithDocsMCP
2206
2317
  }) => {
2207
2318
  s.start("Initializing Mastra");
@@ -2217,7 +2328,8 @@ var init = async ({
2217
2328
  dirPath,
2218
2329
  addExample,
2219
2330
  addWorkflow: components.includes("workflows"),
2220
- addAgent: components.includes("agents")
2331
+ addAgent: components.includes("agents"),
2332
+ addScorers: components.includes("scorers")
2221
2333
  }),
2222
2334
  ...components.map((component) => createComponentsDir(dirPath, component)),
2223
2335
  writeAPIKey({ provider: llmProvider, apiKey: llmApiKey })
@@ -2241,14 +2353,12 @@ var init = async ({
2241
2353
  if (needsLoggers) {
2242
2354
  await depService.installPackages(["@mastra/loggers"]);
2243
2355
  }
2356
+ const needsEvals = components.includes(`scorers`) && await depService.checkDependencies(["@mastra/evals"]) !== `ok`;
2357
+ if (needsEvals) {
2358
+ await depService.installPackages(["@mastra/evals"]);
2359
+ }
2244
2360
  }
2245
2361
  const key = await getAPIKey(llmProvider || "openai");
2246
- const aiSdkPackage = getAISDKPackage(llmProvider);
2247
- const aiSdkPackageVersion = getAISDKPackageVersion(llmProvider);
2248
- const depsService = new DepsService();
2249
- const pm = depsService.packageManager;
2250
- const installCommand = getPackageManagerInstallCommand(pm);
2251
- await exec3(`${pm} ${installCommand} ${aiSdkPackage}@${aiSdkPackageVersion}`);
2252
2362
  if (configureEditorWithDocsMCP) {
2253
2363
  await installMastraDocsMCPServer({
2254
2364
  editor: configureEditorWithDocsMCP,
@@ -2275,10 +2385,10 @@ var init = async ({
2275
2385
  return { success: false };
2276
2386
  }
2277
2387
  };
2278
- var exec4 = util.promisify(child_process.exec);
2388
+ var exec3 = util.promisify(child_process.exec);
2279
2389
  var execWithTimeout = async (command, timeoutMs) => {
2280
2390
  try {
2281
- const promise = exec4(command, { killSignal: "SIGTERM" });
2391
+ const promise = exec3(command, { killSignal: "SIGTERM" });
2282
2392
  if (!timeoutMs) {
2283
2393
  return await promise;
2284
2394
  }
@@ -2301,10 +2411,36 @@ var execWithTimeout = async (command, timeoutMs) => {
2301
2411
  throw error;
2302
2412
  }
2303
2413
  };
2414
+ async function getInitCommand(pm) {
2415
+ switch (pm) {
2416
+ case "npm":
2417
+ return "npm init -y";
2418
+ case "pnpm":
2419
+ return "pnpm init";
2420
+ case "yarn":
2421
+ return "yarn init -y";
2422
+ case "bun":
2423
+ return "bun init -y";
2424
+ default:
2425
+ return "npm init -y";
2426
+ }
2427
+ }
2428
+ async function initializePackageJson(pm) {
2429
+ const initCommand = await getInitCommand(pm);
2430
+ await exec3(initCommand);
2431
+ const packageJsonPath = path.join(process.cwd(), "package.json");
2432
+ const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf-8"));
2433
+ packageJson.type = "module";
2434
+ packageJson.engines = {
2435
+ ...packageJson.engines,
2436
+ node: ">=22.13.0"
2437
+ };
2438
+ await fs4.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
2439
+ }
2304
2440
  async function installMastraDependency(pm, dependency, versionTag, isDev, timeout) {
2305
- let installCommand = getPackageManagerInstallCommand(pm);
2441
+ let installCommand = getPackageManagerAddCommand(pm);
2306
2442
  if (isDev) {
2307
- installCommand = `${installCommand} --save-dev`;
2443
+ installCommand = `${installCommand} -D`;
2308
2444
  }
2309
2445
  try {
2310
2446
  await execWithTimeout(`${pm} ${installCommand} ${dependency}${versionTag}`, timeout);
@@ -2326,23 +2462,42 @@ async function installMastraDependency(pm, dependency, versionTag, isDev, timeou
2326
2462
  var createMastraProject = async ({
2327
2463
  projectName: name,
2328
2464
  createVersionTag,
2329
- timeout
2465
+ timeout,
2466
+ llmProvider,
2467
+ llmApiKey,
2468
+ needsInteractive
2330
2469
  }) => {
2331
2470
  Ie(color2.inverse(" Mastra Create "));
2332
2471
  const projectName = name ?? await he({
2333
2472
  message: "What do you want to name your project?",
2334
2473
  placeholder: "my-mastra-app",
2335
- defaultValue: "my-mastra-app"
2474
+ defaultValue: "my-mastra-app",
2475
+ validate: (value) => {
2476
+ if (value.length === 0) return "Project name cannot be empty";
2477
+ if (fs3__default__default.existsSync(value)) {
2478
+ return `A directory named "${value}" already exists. Please choose a different name.`;
2479
+ }
2480
+ }
2336
2481
  });
2337
2482
  if (pD(projectName)) {
2338
2483
  xe("Operation cancelled");
2339
2484
  process.exit(0);
2340
2485
  }
2486
+ let result;
2487
+ if (needsInteractive) {
2488
+ result = await interactivePrompt({
2489
+ options: { showBanner: false },
2490
+ skip: { llmProvider: llmProvider !== void 0, llmApiKey: llmApiKey !== void 0 }
2491
+ });
2492
+ }
2341
2493
  const s2 = Y();
2494
+ const originalCwd = process.cwd();
2495
+ let projectPath = null;
2342
2496
  try {
2343
2497
  s2.start("Creating project");
2344
2498
  try {
2345
- await fs.mkdir(projectName);
2499
+ await fs4.mkdir(projectName);
2500
+ projectPath = path.resolve(originalCwd, projectName);
2346
2501
  } catch (error) {
2347
2502
  if (error instanceof Error && "code" in error && error.code === "EEXIST") {
2348
2503
  s2.stop(`A directory named "${projectName}" already exists. Please choose a different name.`);
@@ -2354,12 +2509,10 @@ var createMastraProject = async ({
2354
2509
  }
2355
2510
  process.chdir(projectName);
2356
2511
  const pm = getPackageManager();
2357
- const installCommand = getPackageManagerInstallCommand(pm);
2512
+ const installCommand = getPackageManagerAddCommand(pm);
2358
2513
  s2.message("Initializing project structure");
2359
2514
  try {
2360
- await exec4(`npm init -y`);
2361
- await exec4(`npm pkg set type="module"`);
2362
- await exec4(`npm pkg set engines.node=">=20.9.0"`);
2515
+ await initializePackageJson(pm);
2363
2516
  const depsService = new DepsService();
2364
2517
  await depsService.addScriptsToPackageJson({
2365
2518
  dev: "mastra dev",
@@ -2374,9 +2527,9 @@ var createMastraProject = async ({
2374
2527
  s2.stop("Project structure created");
2375
2528
  s2.start(`Installing ${pm} dependencies`);
2376
2529
  try {
2377
- await exec4(`${pm} ${installCommand} zod@^3`);
2378
- await exec4(`${pm} ${installCommand} typescript @types/node --save-dev`);
2379
- await exec4(`echo '{
2530
+ await exec3(`${pm} ${installCommand} zod@^4`);
2531
+ await exec3(`${pm} ${installCommand} typescript @types/node --save-dev`);
2532
+ await exec3(`echo '{
2380
2533
  "compilerOptions": {
2381
2534
  "target": "ES2022",
2382
2535
  "module": "ES2022",
@@ -2398,15 +2551,15 @@ var createMastraProject = async ({
2398
2551
  );
2399
2552
  }
2400
2553
  s2.stop(`${pm} dependencies installed`);
2401
- s2.start("Installing mastra");
2554
+ s2.start("Installing Mastra CLI");
2402
2555
  const versionTag = createVersionTag ? `@${createVersionTag}` : "@latest";
2403
2556
  try {
2404
2557
  await installMastraDependency(pm, "mastra", versionTag, true, timeout);
2405
2558
  } catch (error) {
2406
2559
  throw new Error(`Failed to install Mastra CLI: ${error instanceof Error ? error.message : "Unknown error"}`);
2407
2560
  }
2408
- s2.stop("mastra installed");
2409
- s2.start("Installing dependencies");
2561
+ s2.stop("Mastra CLI installed");
2562
+ s2.start("Installing Mastra dependencies");
2410
2563
  try {
2411
2564
  await installMastraDependency(pm, "@mastra/core", versionTag, false, timeout);
2412
2565
  await installMastraDependency(pm, "@mastra/libsql", versionTag, false, timeout);
@@ -2419,45 +2572,58 @@ var createMastraProject = async ({
2419
2572
  s2.stop("Mastra dependencies installed");
2420
2573
  s2.start("Adding .gitignore");
2421
2574
  try {
2422
- await exec4(`echo output.txt >> .gitignore`);
2423
- await exec4(`echo node_modules >> .gitignore`);
2424
- await exec4(`echo dist >> .gitignore`);
2425
- await exec4(`echo .mastra >> .gitignore`);
2426
- await exec4(`echo .env.development >> .gitignore`);
2427
- await exec4(`echo .env >> .gitignore`);
2428
- await exec4(`echo *.db >> .gitignore`);
2429
- await exec4(`echo *.db-* >> .gitignore`);
2575
+ await exec3(`echo output.txt >> .gitignore`);
2576
+ await exec3(`echo node_modules >> .gitignore`);
2577
+ await exec3(`echo dist >> .gitignore`);
2578
+ await exec3(`echo .mastra >> .gitignore`);
2579
+ await exec3(`echo .env.development >> .gitignore`);
2580
+ await exec3(`echo .env >> .gitignore`);
2581
+ await exec3(`echo *.db >> .gitignore`);
2582
+ await exec3(`echo *.db-* >> .gitignore`);
2430
2583
  } catch (error) {
2431
2584
  throw new Error(`Failed to create .gitignore: ${error instanceof Error ? error.message : "Unknown error"}`);
2432
2585
  }
2433
2586
  s2.stop(".gitignore added");
2434
2587
  Se("Project created successfully");
2435
- console.log("");
2436
- return { projectName };
2588
+ console.info("");
2589
+ return { projectName, result };
2437
2590
  } catch (error) {
2438
2591
  s2.stop();
2439
2592
  const errorMessage = error instanceof Error ? error.message : "An unexpected error occurred";
2440
2593
  xe(`Project creation failed: ${errorMessage}`);
2594
+ if (projectPath && fs3__default__default.existsSync(projectPath)) {
2595
+ try {
2596
+ process.chdir(originalCwd);
2597
+ await fs4.rm(projectPath, { recursive: true, force: true });
2598
+ } catch (cleanupError) {
2599
+ console.error(
2600
+ `Warning: Failed to clean up project directory: ${cleanupError instanceof Error ? cleanupError.message : "Unknown error"}`
2601
+ );
2602
+ }
2603
+ }
2441
2604
  process.exit(1);
2442
2605
  }
2443
2606
  };
2444
2607
  var create = async (args2) => {
2445
2608
  if (args2.template !== void 0) {
2446
- await createFromTemplate(args2);
2609
+ await createFromTemplate({ ...args2, injectedAnalytics: args2.analytics });
2447
2610
  return;
2448
2611
  }
2449
- const { projectName } = await createMastraProject({
2612
+ const needsInteractive = args2.components === void 0 || args2.llmProvider === void 0 || args2.addExample === void 0;
2613
+ const { projectName, result } = await createMastraProject({
2450
2614
  projectName: args2?.projectName,
2451
2615
  createVersionTag: args2?.createVersionTag,
2452
- timeout: args2?.timeout
2616
+ timeout: args2?.timeout,
2617
+ llmProvider: args2?.llmProvider,
2618
+ llmApiKey: args2?.llmApiKey,
2619
+ needsInteractive
2453
2620
  });
2454
2621
  const directory = args2.directory || "src/";
2455
- if (args2.components === void 0 || args2.llmProvider === void 0 || args2.addExample === void 0) {
2456
- const result = await interactivePrompt();
2622
+ if (needsInteractive && result) {
2457
2623
  await init({
2458
2624
  ...result,
2459
2625
  llmApiKey: result?.llmApiKey,
2460
- components: ["agents", "tools", "workflows"],
2626
+ components: ["agents", "tools", "workflows", "scorers"],
2461
2627
  addExample: true
2462
2628
  });
2463
2629
  postCreate({ projectName });
@@ -2573,16 +2739,16 @@ async function createFromTemplate(args2) {
2573
2739
  selectedTemplate = selected;
2574
2740
  } else if (args2.template && typeof args2.template === "string") {
2575
2741
  if (isGitHubUrl(args2.template)) {
2576
- const spinner5 = Y();
2577
- spinner5.start("Validating GitHub repository...");
2742
+ const spinner4 = Y();
2743
+ spinner4.start("Validating GitHub repository...");
2578
2744
  const validation = await validateGitHubProject(args2.template);
2579
2745
  if (!validation.isValid) {
2580
- spinner5.stop("Validation failed");
2746
+ spinner4.stop("Validation failed");
2581
2747
  M.error("This does not appear to be a valid Mastra project:");
2582
2748
  validation.errors.forEach((error) => M.error(` - ${error}`));
2583
2749
  throw new Error("Invalid Mastra project");
2584
2750
  }
2585
- spinner5.stop("Valid Mastra project \u2713");
2751
+ spinner4.stop("Valid Mastra project \u2713");
2586
2752
  selectedTemplate = await createFromGitHubUrl(args2.template);
2587
2753
  } else {
2588
2754
  const templates = await loadTemplates();
@@ -2612,10 +2778,16 @@ async function createFromTemplate(args2) {
2612
2778
  }
2613
2779
  projectName = response;
2614
2780
  }
2781
+ let projectPath = null;
2615
2782
  try {
2616
- const analytics = getAnalytics();
2617
- if (analytics) ;
2618
- const projectPath = await cloneTemplate({
2783
+ const analytics = args2.injectedAnalytics || getAnalytics();
2784
+ if (analytics) {
2785
+ analytics.trackEvent("cli_template_used", {
2786
+ template_slug: selectedTemplate.slug,
2787
+ template_title: selectedTemplate.title
2788
+ });
2789
+ }
2790
+ projectPath = await cloneTemplate({
2619
2791
  template: selectedTemplate,
2620
2792
  projectName
2621
2793
  });
@@ -2623,11 +2795,22 @@ async function createFromTemplate(args2) {
2623
2795
  Me(`
2624
2796
  ${color2.green("Mastra template installed!")}
2625
2797
 
2626
- Add the necessary environment
2798
+ Add the necessary environment
2627
2799
  variables in your ${color2.cyan(".env")} file
2628
2800
  `);
2629
2801
  postCreate({ projectName });
2630
2802
  } catch (error) {
2803
+ if (projectPath) {
2804
+ try {
2805
+ if (fs3__default__default.existsSync(projectPath)) {
2806
+ await fs4.rm(projectPath, { recursive: true, force: true });
2807
+ }
2808
+ } catch (cleanupError) {
2809
+ console.error(
2810
+ `Warning: Failed to clean up project directory: ${cleanupError instanceof Error ? cleanupError.message : "Unknown error"}`
2811
+ );
2812
+ }
2813
+ }
2631
2814
  M.error(`Failed to create project from template: ${error instanceof Error ? error.message : "Unknown error"}`);
2632
2815
  throw error;
2633
2816
  }
@@ -2636,14 +2819,14 @@ async function createFromTemplate(args2) {
2636
2819
  async function getPackageVersion() {
2637
2820
  const __filename = fileURLToPath(import.meta.url);
2638
2821
  const __dirname = dirname(__filename);
2639
- const pkgJsonPath = path3.join(__dirname, "..", "package.json");
2640
- const content = await fsExtra.readJSON(pkgJsonPath);
2822
+ const pkgJsonPath = path.join(__dirname, "..", "package.json");
2823
+ const content = await fsExtra$1.readJSON(pkgJsonPath);
2641
2824
  return content.version;
2642
2825
  }
2643
2826
  async function getCreateVersionTag() {
2644
2827
  try {
2645
2828
  const pkgPath = fileURLToPath(import.meta.resolve("create-mastra/package.json"));
2646
- const json = await fsExtra.readJSON(pkgPath);
2829
+ const json = await fsExtra$1.readJSON(pkgPath);
2647
2830
  const { stdout } = await execa("npm", ["dist-tag", "create-mastra"]);
2648
2831
  const tagLine = stdout.split("\n").find((distLine) => distLine.endsWith(`: ${json.version}`));
2649
2832
  const tag = tagLine ? tagLine.split(":")[0].trim() : "latest";
@@ -2667,14 +2850,14 @@ program.version(`${version}`, "-v, --version").description(`create-mastra ${vers
2667
2850
  analytics.trackCommand({
2668
2851
  command: "version"
2669
2852
  });
2670
- console.log(`create-mastra ${version}`);
2853
+ console.info(`create-mastra ${version}`);
2671
2854
  } catch {
2672
2855
  }
2673
2856
  });
2674
2857
  program.name("create-mastra").description("Create a new Mastra project").argument("[project-name]", "Directory name of the project").option(
2675
2858
  "-p, --project-name <string>",
2676
2859
  "Project name that will be used in package.json and as the project directory name."
2677
- ).option("--default", "Quick start with defaults(src, OpenAI, 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/)").option("-m, --mcp <mcp>", "MCP Server for code editor (cursor, cursor-global, windsurf, vscode)").option(
2860
+ ).option("--default", "Quick start with defaults (src, OpenAI, examples)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows, scorers)").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/)").option("-m, --mcp <mcp>", "MCP Server for code editor (cursor, cursor-global, windsurf, vscode)").option(
2678
2861
  "--template [template-name]",
2679
2862
  "Create project from a template (use template name, public GitHub URL, or leave blank to select from list)"
2680
2863
  ).action(async (projectNameArg, args) => {
@@ -2682,14 +2865,15 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
2682
2865
  const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
2683
2866
  if (args.default) {
2684
2867
  await create({
2685
- components: ["agents", "tools", "workflows"],
2868
+ components: ["agents", "tools", "workflows", "scorers"],
2686
2869
  llmProvider: "openai",
2687
2870
  addExample: true,
2688
2871
  createVersionTag,
2689
2872
  timeout,
2690
2873
  mcpServer: args.mcp,
2691
2874
  directory: "src/",
2692
- template: args.template
2875
+ template: args.template,
2876
+ analytics
2693
2877
  });
2694
2878
  return;
2695
2879
  }
@@ -2697,13 +2881,14 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
2697
2881
  components: args.components ? args.components.split(",") : [],
2698
2882
  llmProvider: args.llm,
2699
2883
  addExample: args.example,
2700
- llmApiKey: args["llm-api-key"],
2884
+ llmApiKey: args.llmApiKey,
2701
2885
  createVersionTag,
2702
2886
  timeout,
2703
2887
  projectName,
2704
2888
  directory: args.dir,
2705
2889
  mcpServer: args.mcp,
2706
- template: args.template
2890
+ template: args.template,
2891
+ analytics
2707
2892
  });
2708
2893
  });
2709
2894
  program.parse(process.argv);