create-mastra 0.0.0-wrapping-tooltip-provider-runtime-context-20250716134707 → 0.0.0-zod-v4-compat-part-2-20250822105954
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 +123 -19
- package/dist/index.js.map +1 -1
- package/dist/starter-files/config.d.ts +26 -0
- package/dist/starter-files/config.d.ts.map +1 -0
- package/dist/starter-files/tools.d.ts +79 -0
- package/dist/starter-files/tools.d.ts.map +1 -0
- package/dist/templates/dev.entry.d.ts +2 -0
- package/dist/templates/dev.entry.d.ts.map +1 -0
- package/dist/templates/dev.entry.js +7 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1216,10 +1216,10 @@ var exec = util.promisify(child_process.exec);
|
|
|
1216
1216
|
async function cloneTemplate(options) {
|
|
1217
1217
|
const { template, projectName, targetDir } = options;
|
|
1218
1218
|
const projectPath = targetDir ? path3.resolve(targetDir, projectName) : path3.resolve(projectName);
|
|
1219
|
-
const
|
|
1219
|
+
const spinner5 = yoctoSpinner({ text: `Cloning template "${template.title}"...` }).start();
|
|
1220
1220
|
try {
|
|
1221
1221
|
if (await directoryExists(projectPath)) {
|
|
1222
|
-
|
|
1222
|
+
spinner5.error(`Directory ${projectName} already exists`);
|
|
1223
1223
|
throw new Error(`Directory ${projectName} already exists`);
|
|
1224
1224
|
}
|
|
1225
1225
|
await cloneRepositoryWithoutGit(template.githubUrl, projectPath);
|
|
@@ -1228,10 +1228,10 @@ async function cloneTemplate(options) {
|
|
|
1228
1228
|
if (await fileExists(envExamplePath)) {
|
|
1229
1229
|
await fs.copyFile(envExamplePath, path3.join(projectPath, ".env"));
|
|
1230
1230
|
}
|
|
1231
|
-
|
|
1231
|
+
spinner5.success(`Template "${template.title}" cloned successfully to ${projectName}`);
|
|
1232
1232
|
return projectPath;
|
|
1233
1233
|
} catch (error) {
|
|
1234
|
-
|
|
1234
|
+
spinner5.error(`Failed to clone template: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1235
1235
|
throw error;
|
|
1236
1236
|
}
|
|
1237
1237
|
}
|
|
@@ -1286,16 +1286,16 @@ async function updatePackageJson(projectPath, projectName) {
|
|
|
1286
1286
|
}
|
|
1287
1287
|
}
|
|
1288
1288
|
async function installDependencies(projectPath, packageManager) {
|
|
1289
|
-
const
|
|
1289
|
+
const spinner5 = yoctoSpinner({ text: "Installing dependencies..." }).start();
|
|
1290
1290
|
try {
|
|
1291
1291
|
const pm = packageManager || getPackageManager();
|
|
1292
1292
|
const installCommand = shellQuote.quote([pm, "install"]);
|
|
1293
1293
|
await exec(installCommand, {
|
|
1294
1294
|
cwd: projectPath
|
|
1295
1295
|
});
|
|
1296
|
-
|
|
1296
|
+
spinner5.success("Dependencies installed successfully");
|
|
1297
1297
|
} catch (error) {
|
|
1298
|
-
|
|
1298
|
+
spinner5.error(`Failed to install dependencies: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1299
1299
|
throw error;
|
|
1300
1300
|
}
|
|
1301
1301
|
}
|
|
@@ -1674,6 +1674,14 @@ var FileService = class {
|
|
|
1674
1674
|
}
|
|
1675
1675
|
};
|
|
1676
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";
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1677
1685
|
var getAISDKPackage = (llmProvider) => {
|
|
1678
1686
|
switch (llmProvider) {
|
|
1679
1687
|
case "openai":
|
|
@@ -1704,7 +1712,7 @@ var getProviderImportAndModelItem = (llmProvider) => {
|
|
|
1704
1712
|
modelItem = `groq('llama-3.3-70b-versatile')`;
|
|
1705
1713
|
} else if (llmProvider === "google") {
|
|
1706
1714
|
providerImport = `import { google } from '${getAISDKPackage(llmProvider)}';`;
|
|
1707
|
-
modelItem = `google('gemini-2.5-pro
|
|
1715
|
+
modelItem = `google('gemini-2.5-pro')`;
|
|
1708
1716
|
} else if (llmProvider === "cerebras") {
|
|
1709
1717
|
providerImport = `import { cerebras } from '${getAISDKPackage(llmProvider)}';`;
|
|
1710
1718
|
modelItem = `cerebras('llama-3.3-70b')`;
|
|
@@ -2236,10 +2244,11 @@ var init = async ({
|
|
|
2236
2244
|
}
|
|
2237
2245
|
const key = await getAPIKey(llmProvider || "openai");
|
|
2238
2246
|
const aiSdkPackage = getAISDKPackage(llmProvider);
|
|
2247
|
+
const aiSdkPackageVersion = getAISDKPackageVersion(llmProvider);
|
|
2239
2248
|
const depsService = new DepsService();
|
|
2240
2249
|
const pm = depsService.packageManager;
|
|
2241
2250
|
const installCommand = getPackageManagerInstallCommand(pm);
|
|
2242
|
-
await exec3(`${pm} ${installCommand} ${aiSdkPackage}`);
|
|
2251
|
+
await exec3(`${pm} ${installCommand} ${aiSdkPackage}@${aiSdkPackageVersion}`);
|
|
2243
2252
|
if (configureEditorWithDocsMCP) {
|
|
2244
2253
|
await installMastraDocsMCPServer({
|
|
2245
2254
|
editor: configureEditorWithDocsMCP,
|
|
@@ -2474,21 +2483,116 @@ var postCreate = ({ projectName }) => {
|
|
|
2474
2483
|
${color2.cyan(`${packageManager} run dev`)}
|
|
2475
2484
|
`);
|
|
2476
2485
|
};
|
|
2486
|
+
function isGitHubUrl(url) {
|
|
2487
|
+
try {
|
|
2488
|
+
const parsedUrl = new URL(url);
|
|
2489
|
+
return parsedUrl.hostname === "github.com" && parsedUrl.pathname.split("/").length >= 3;
|
|
2490
|
+
} catch {
|
|
2491
|
+
return false;
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
async function validateGitHubProject(githubUrl) {
|
|
2495
|
+
const errors = [];
|
|
2496
|
+
try {
|
|
2497
|
+
const urlParts = new URL(githubUrl).pathname.split("/").filter(Boolean);
|
|
2498
|
+
const owner = urlParts[0];
|
|
2499
|
+
const repo = urlParts[1]?.replace(".git", "");
|
|
2500
|
+
if (!owner || !repo) {
|
|
2501
|
+
throw new Error("Invalid GitHub URL format");
|
|
2502
|
+
}
|
|
2503
|
+
const branches = ["main", "master"];
|
|
2504
|
+
let packageJsonContent = null;
|
|
2505
|
+
let indexContent = null;
|
|
2506
|
+
for (const branch of branches) {
|
|
2507
|
+
try {
|
|
2508
|
+
const packageJsonUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/package.json`;
|
|
2509
|
+
const packageJsonResponse = await fetch(packageJsonUrl);
|
|
2510
|
+
if (packageJsonResponse.ok) {
|
|
2511
|
+
packageJsonContent = await packageJsonResponse.text();
|
|
2512
|
+
const indexUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/src/mastra/index.ts`;
|
|
2513
|
+
const indexResponse = await fetch(indexUrl);
|
|
2514
|
+
if (indexResponse.ok) {
|
|
2515
|
+
indexContent = await indexResponse.text();
|
|
2516
|
+
}
|
|
2517
|
+
break;
|
|
2518
|
+
}
|
|
2519
|
+
} catch {
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
if (!packageJsonContent) {
|
|
2523
|
+
errors.push("Could not fetch package.json from repository");
|
|
2524
|
+
return { isValid: false, errors };
|
|
2525
|
+
}
|
|
2526
|
+
try {
|
|
2527
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
2528
|
+
const hasMastraCore = packageJson.dependencies?.["@mastra/core"] || packageJson.devDependencies?.["@mastra/core"] || packageJson.peerDependencies?.["@mastra/core"];
|
|
2529
|
+
if (!hasMastraCore) {
|
|
2530
|
+
errors.push("Missing @mastra/core dependency in package.json");
|
|
2531
|
+
}
|
|
2532
|
+
} catch {
|
|
2533
|
+
errors.push("Invalid package.json format");
|
|
2534
|
+
}
|
|
2535
|
+
if (!indexContent) {
|
|
2536
|
+
errors.push("Missing src/mastra/index.ts file");
|
|
2537
|
+
} else {
|
|
2538
|
+
const hasMastraExport = indexContent.includes("export") && (indexContent.includes("new Mastra") || indexContent.includes("Mastra("));
|
|
2539
|
+
if (!hasMastraExport) {
|
|
2540
|
+
errors.push("src/mastra/index.ts does not export a Mastra instance");
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
return { isValid: errors.length === 0, errors };
|
|
2544
|
+
} catch (error) {
|
|
2545
|
+
errors.push(`Failed to validate GitHub repository: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2546
|
+
return { isValid: false, errors };
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
async function createFromGitHubUrl(url) {
|
|
2550
|
+
const urlParts = new URL(url).pathname.split("/").filter(Boolean);
|
|
2551
|
+
const owner = urlParts[0] || "unknown";
|
|
2552
|
+
const repo = urlParts[1] || "unknown";
|
|
2553
|
+
return {
|
|
2554
|
+
githubUrl: url,
|
|
2555
|
+
title: `${owner}/${repo}`,
|
|
2556
|
+
slug: repo,
|
|
2557
|
+
agents: [],
|
|
2558
|
+
mcp: [],
|
|
2559
|
+
tools: [],
|
|
2560
|
+
networks: [],
|
|
2561
|
+
workflows: []
|
|
2562
|
+
};
|
|
2563
|
+
}
|
|
2477
2564
|
async function createFromTemplate(args2) {
|
|
2478
|
-
const templates = await loadTemplates();
|
|
2479
2565
|
let selectedTemplate;
|
|
2480
2566
|
if (args2.template === true) {
|
|
2481
|
-
|
|
2482
|
-
|
|
2567
|
+
const templates = await loadTemplates();
|
|
2568
|
+
const selected = await selectTemplate(templates);
|
|
2569
|
+
if (!selected) {
|
|
2483
2570
|
M.info("No template selected. Exiting.");
|
|
2484
2571
|
return;
|
|
2485
2572
|
}
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
if (
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2573
|
+
selectedTemplate = selected;
|
|
2574
|
+
} else if (args2.template && typeof args2.template === "string") {
|
|
2575
|
+
if (isGitHubUrl(args2.template)) {
|
|
2576
|
+
const spinner5 = Y();
|
|
2577
|
+
spinner5.start("Validating GitHub repository...");
|
|
2578
|
+
const validation = await validateGitHubProject(args2.template);
|
|
2579
|
+
if (!validation.isValid) {
|
|
2580
|
+
spinner5.stop("Validation failed");
|
|
2581
|
+
M.error("This does not appear to be a valid Mastra project:");
|
|
2582
|
+
validation.errors.forEach((error) => M.error(` - ${error}`));
|
|
2583
|
+
throw new Error("Invalid Mastra project");
|
|
2584
|
+
}
|
|
2585
|
+
spinner5.stop("Valid Mastra project \u2713");
|
|
2586
|
+
selectedTemplate = await createFromGitHubUrl(args2.template);
|
|
2587
|
+
} else {
|
|
2588
|
+
const templates = await loadTemplates();
|
|
2589
|
+
const found = findTemplateByName(templates, args2.template);
|
|
2590
|
+
if (!found) {
|
|
2591
|
+
M.error(`Template "${args2.template}" not found. Available templates:`);
|
|
2592
|
+
templates.forEach((t) => M.info(` - ${t.title} (use: ${t.slug.replace("template-", "")})`));
|
|
2593
|
+
throw new Error(`Template "${args2.template}" not found`);
|
|
2594
|
+
}
|
|
2595
|
+
selectedTemplate = found;
|
|
2492
2596
|
}
|
|
2493
2597
|
}
|
|
2494
2598
|
if (!selectedTemplate) {
|
|
@@ -2572,7 +2676,7 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
|
|
|
2572
2676
|
"Project name that will be used in package.json and as the project directory name."
|
|
2573
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(
|
|
2574
2678
|
"--template [template-name]",
|
|
2575
|
-
"Create project from a template (use template name or leave blank to select from list)"
|
|
2679
|
+
"Create project from a template (use template name, public GitHub URL, or leave blank to select from list)"
|
|
2576
2680
|
).action(async (projectNameArg, args) => {
|
|
2577
2681
|
const projectName = projectNameArg || args.projectName;
|
|
2578
2682
|
const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
|