create-mastra 0.15.1 → 0.16.0-alpha.1
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 +28 -0
- package/README.md +10 -32
- package/dist/index.js +39 -72
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# create-mastra
|
|
2
2
|
|
|
3
|
+
## 0.16.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix auto tab for model picker in playground-ui, the UI no longer auto tabs to the next selector when selecting a model/provider. ([#8680](https://github.com/mastra-ai/mastra/pull/8680))
|
|
8
|
+
|
|
9
|
+
- Create unified Sidebar component to use on Playground and Cloud ([#8655](https://github.com/mastra-ai/mastra/pull/8655))
|
|
10
|
+
|
|
11
|
+
- Use only zod validation in dynamic form ([#8802](https://github.com/mastra-ai/mastra/pull/8802))
|
|
12
|
+
|
|
13
|
+
- Add div wrapper around entity tables to fix table vertical position ([#8758](https://github.com/mastra-ai/mastra/pull/8758))
|
|
14
|
+
|
|
15
|
+
- Customize AITraces type to seamlessly work on Cloud too ([#8759](https://github.com/mastra-ai/mastra/pull/8759))
|
|
16
|
+
|
|
17
|
+
- Stream finalResult from network loop ([#8795](https://github.com/mastra-ai/mastra/pull/8795))
|
|
18
|
+
|
|
19
|
+
- Improve README ([#8819](https://github.com/mastra-ai/mastra/pull/8819))
|
|
20
|
+
|
|
21
|
+
## 0.15.2-alpha.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Use model-router in create-mastra starter template ([#8631](https://github.com/mastra-ai/mastra/pull/8631))
|
|
26
|
+
|
|
27
|
+
- Adds reset button to model picker to reset to original model set on the agent. ([#8633](https://github.com/mastra-ai/mastra/pull/8633))
|
|
28
|
+
|
|
29
|
+
- Refactor EntryList component and Scorer and Observability pages ([#8652](https://github.com/mastra-ai/mastra/pull/8652))
|
|
30
|
+
|
|
3
31
|
## 0.15.1
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-mastra
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
|
|
4
|
+
|
|
5
|
+
It includes everything you need to go from early prototypes to production-ready applications. Mastra integrates with frontend and backend frameworks like React, Next.js, and Node, or you can deploy it anywhere as a standalone server. It's the easiest way to build, tune, and scale reliable AI products.
|
|
6
|
+
|
|
7
|
+
`create-mastra` is the **recommended** way to get started with Mastra. This CLI tool enables you to quickly start building a new Mastra application, with everything set up for you.
|
|
4
8
|
|
|
5
9
|
## Usage
|
|
6
10
|
|
|
11
|
+
> [!IMPORTANT]
|
|
12
|
+
> Make sure that you have Node.js 20 or later installed on your system.
|
|
13
|
+
|
|
7
14
|
Using npm:
|
|
8
15
|
|
|
9
16
|
```bash
|
|
@@ -22,33 +29,4 @@ Using pnpm:
|
|
|
22
29
|
pnpm create mastra
|
|
23
30
|
```
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- `--default` - Quick start with defaults (src directory, OpenAI, no examples)
|
|
28
|
-
- `-c, --components <components>` - Comma-separated list of components (agents, tools, workflows)
|
|
29
|
-
- `-l, --llm <model-provider>` - Default model provider (openai, anthropic, groq, google, or cerebras)
|
|
30
|
-
- `-e, --example` - Include example code
|
|
31
|
-
|
|
32
|
-
## Examples
|
|
33
|
-
|
|
34
|
-
Create a new project with default settings
|
|
35
|
-
npx create-mastra@latest --default
|
|
36
|
-
Create a project with specific components and LLM provider
|
|
37
|
-
npx create-mastra@latest -c agents,tools -l anthropic
|
|
38
|
-
Create a project with example code
|
|
39
|
-
npx create-mastra@latest --example
|
|
40
|
-
|
|
41
|
-
## What's included?
|
|
42
|
-
|
|
43
|
-
The generated project will have:
|
|
44
|
-
|
|
45
|
-
- A configured Mastra setup in the src directory
|
|
46
|
-
- Selected components (agents, tools, workflows)
|
|
47
|
-
- Environment configuration for your chosen LLM provider
|
|
48
|
-
- TypeScript configuration
|
|
49
|
-
- Example code (if selected)
|
|
50
|
-
|
|
51
|
-
## System Requirements
|
|
52
|
-
|
|
53
|
-
- Node.js 20 or later
|
|
54
|
-
- MacOS, Windows, and Linux are supported
|
|
32
|
+
Learn more about `create-mastra` in the [CLI reference documentation](https://mastra.ai/reference/cli/create-mastra).
|
package/dist/index.js
CHANGED
|
@@ -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) +
|
|
738
|
+
result += string.slice(lastIndex, index) + replaceCode;
|
|
734
739
|
lastIndex = index + closeCode.length;
|
|
735
740
|
index = string.indexOf(closeCode, lastIndex);
|
|
736
741
|
}
|
|
@@ -1196,10 +1201,13 @@ function getPackageManager() {
|
|
|
1196
1201
|
}
|
|
1197
1202
|
return "npm";
|
|
1198
1203
|
}
|
|
1199
|
-
var logger =
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1204
|
+
var logger = createLogger(false);
|
|
1205
|
+
function createLogger(debug = false) {
|
|
1206
|
+
return new PinoLogger({
|
|
1207
|
+
name: "Mastra CLI",
|
|
1208
|
+
level: debug ? "debug" : "info"
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1203
1211
|
var exec = util.promisify(child_process.exec);
|
|
1204
1212
|
async function cloneTemplate(options) {
|
|
1205
1213
|
const { template, projectName, targetDir } = options;
|
|
@@ -1665,56 +1673,23 @@ var FileService = class {
|
|
|
1665
1673
|
}
|
|
1666
1674
|
};
|
|
1667
1675
|
var exec2 = util.promisify(child_process.exec);
|
|
1668
|
-
var
|
|
1669
|
-
switch (llmProvider) {
|
|
1670
|
-
default:
|
|
1671
|
-
return "latest";
|
|
1672
|
-
}
|
|
1673
|
-
};
|
|
1674
|
-
var getAISDKPackage = (llmProvider) => {
|
|
1675
|
-
switch (llmProvider) {
|
|
1676
|
-
case "openai":
|
|
1677
|
-
return "@ai-sdk/openai";
|
|
1678
|
-
case "anthropic":
|
|
1679
|
-
return "@ai-sdk/anthropic";
|
|
1680
|
-
case "groq":
|
|
1681
|
-
return "@ai-sdk/groq";
|
|
1682
|
-
case "google":
|
|
1683
|
-
return "@ai-sdk/google";
|
|
1684
|
-
case "cerebras":
|
|
1685
|
-
return "@ai-sdk/cerebras";
|
|
1686
|
-
case "mistral":
|
|
1687
|
-
return "@ai-sdk/mistral";
|
|
1688
|
-
default:
|
|
1689
|
-
return "@ai-sdk/openai";
|
|
1690
|
-
}
|
|
1691
|
-
};
|
|
1692
|
-
var getProviderImportAndModelItem = (llmProvider) => {
|
|
1693
|
-
let providerImport = "";
|
|
1694
|
-
let modelItem = "";
|
|
1676
|
+
var getModelIdentifier = (llmProvider) => {
|
|
1695
1677
|
if (llmProvider === "openai") {
|
|
1696
|
-
|
|
1697
|
-
modelItem = `openai('gpt-4o-mini')`;
|
|
1678
|
+
return `'openai/gpt-4o-mini'`;
|
|
1698
1679
|
} else if (llmProvider === "anthropic") {
|
|
1699
|
-
|
|
1700
|
-
modelItem = `anthropic('claude-3-5-sonnet-20241022')`;
|
|
1680
|
+
return `'anthropic/claude-3-5-sonnet-20241022'`;
|
|
1701
1681
|
} else if (llmProvider === "groq") {
|
|
1702
|
-
|
|
1703
|
-
modelItem = `groq('llama-3.3-70b-versatile')`;
|
|
1682
|
+
return `'groq/llama-3.3-70b-versatile'`;
|
|
1704
1683
|
} else if (llmProvider === "google") {
|
|
1705
|
-
|
|
1706
|
-
modelItem = `google('gemini-2.5-pro')`;
|
|
1684
|
+
return `'google/gemini-2.5-pro'`;
|
|
1707
1685
|
} else if (llmProvider === "cerebras") {
|
|
1708
|
-
|
|
1709
|
-
modelItem = `cerebras('llama-3.3-70b')`;
|
|
1686
|
+
return `'cerebras/llama-3.3-70b'`;
|
|
1710
1687
|
} else if (llmProvider === "mistral") {
|
|
1711
|
-
|
|
1712
|
-
modelItem = `mistral('mistral-medium-2508')`;
|
|
1688
|
+
return `'mistral/mistral-medium-2508'`;
|
|
1713
1689
|
}
|
|
1714
|
-
return { providerImport, modelItem };
|
|
1715
1690
|
};
|
|
1716
1691
|
async function writeAgentSample(llmProvider, destPath, addExampleTool) {
|
|
1717
|
-
const
|
|
1692
|
+
const modelString = getModelIdentifier(llmProvider);
|
|
1718
1693
|
const instructions = `
|
|
1719
1694
|
You are a helpful weather assistant that provides accurate weather information and can help planning activities based on the weather.
|
|
1720
1695
|
|
|
@@ -1730,7 +1705,6 @@ async function writeAgentSample(llmProvider, destPath, addExampleTool) {
|
|
|
1730
1705
|
${addExampleTool ? "Use the weatherTool to fetch current weather data." : ""}
|
|
1731
1706
|
`;
|
|
1732
1707
|
const content = `
|
|
1733
|
-
${providerImport}
|
|
1734
1708
|
import { Agent } from '@mastra/core/agent';
|
|
1735
1709
|
import { Memory } from '@mastra/memory';
|
|
1736
1710
|
import { LibSQLStore } from '@mastra/libsql';
|
|
@@ -1739,7 +1713,7 @@ ${addExampleTool ? `import { weatherTool } from '../tools/weather-tool';` : ""}
|
|
|
1739
1713
|
export const weatherAgent = new Agent({
|
|
1740
1714
|
name: 'Weather Agent',
|
|
1741
1715
|
instructions: \`${instructions}\`,
|
|
1742
|
-
model: ${
|
|
1716
|
+
model: ${modelString},
|
|
1743
1717
|
${addExampleTool ? "tools: { weatherTool }," : ""}
|
|
1744
1718
|
memory: new Memory({
|
|
1745
1719
|
storage: new LibSQLStore({
|
|
@@ -2208,7 +2182,6 @@ This means the Mastra docs MCP server will be available in all your Windsurf pro
|
|
|
2208
2182
|
return mastraProject;
|
|
2209
2183
|
};
|
|
2210
2184
|
var s = Y();
|
|
2211
|
-
var exec3 = util.promisify(child_process.exec);
|
|
2212
2185
|
var init = async ({
|
|
2213
2186
|
directory,
|
|
2214
2187
|
addExample = false,
|
|
@@ -2256,12 +2229,6 @@ var init = async ({
|
|
|
2256
2229
|
}
|
|
2257
2230
|
}
|
|
2258
2231
|
const key = await getAPIKey(llmProvider || "openai");
|
|
2259
|
-
const aiSdkPackage = getAISDKPackage(llmProvider);
|
|
2260
|
-
const aiSdkPackageVersion = getAISDKPackageVersion(llmProvider);
|
|
2261
|
-
const depsService = new DepsService();
|
|
2262
|
-
const pm = depsService.packageManager;
|
|
2263
|
-
const installCommand = getPackageManagerAddCommand(pm);
|
|
2264
|
-
await exec3(`${pm} ${installCommand} ${aiSdkPackage}@${aiSdkPackageVersion}`);
|
|
2265
2232
|
if (configureEditorWithDocsMCP) {
|
|
2266
2233
|
await installMastraDocsMCPServer({
|
|
2267
2234
|
editor: configureEditorWithDocsMCP,
|
|
@@ -2288,10 +2255,10 @@ var init = async ({
|
|
|
2288
2255
|
return { success: false };
|
|
2289
2256
|
}
|
|
2290
2257
|
};
|
|
2291
|
-
var
|
|
2258
|
+
var exec3 = util.promisify(child_process.exec);
|
|
2292
2259
|
var execWithTimeout = async (command, timeoutMs) => {
|
|
2293
2260
|
try {
|
|
2294
|
-
const promise =
|
|
2261
|
+
const promise = exec3(command, { killSignal: "SIGTERM" });
|
|
2295
2262
|
if (!timeoutMs) {
|
|
2296
2263
|
return await promise;
|
|
2297
2264
|
}
|
|
@@ -2386,9 +2353,9 @@ var createMastraProject = async ({
|
|
|
2386
2353
|
const installCommand = getPackageManagerAddCommand(pm);
|
|
2387
2354
|
s2.message("Initializing project structure");
|
|
2388
2355
|
try {
|
|
2389
|
-
await
|
|
2390
|
-
await
|
|
2391
|
-
await
|
|
2356
|
+
await exec3(`npm init -y`);
|
|
2357
|
+
await exec3(`npm pkg set type="module"`);
|
|
2358
|
+
await exec3(`npm pkg set engines.node=">=20.9.0"`);
|
|
2392
2359
|
const depsService = new DepsService();
|
|
2393
2360
|
await depsService.addScriptsToPackageJson({
|
|
2394
2361
|
dev: "mastra dev",
|
|
@@ -2403,9 +2370,9 @@ var createMastraProject = async ({
|
|
|
2403
2370
|
s2.stop("Project structure created");
|
|
2404
2371
|
s2.start(`Installing ${pm} dependencies`);
|
|
2405
2372
|
try {
|
|
2406
|
-
await
|
|
2407
|
-
await
|
|
2408
|
-
await
|
|
2373
|
+
await exec3(`${pm} ${installCommand} zod@^3`);
|
|
2374
|
+
await exec3(`${pm} ${installCommand} typescript @types/node --save-dev`);
|
|
2375
|
+
await exec3(`echo '{
|
|
2409
2376
|
"compilerOptions": {
|
|
2410
2377
|
"target": "ES2022",
|
|
2411
2378
|
"module": "ES2022",
|
|
@@ -2448,14 +2415,14 @@ var createMastraProject = async ({
|
|
|
2448
2415
|
s2.stop("Mastra dependencies installed");
|
|
2449
2416
|
s2.start("Adding .gitignore");
|
|
2450
2417
|
try {
|
|
2451
|
-
await
|
|
2452
|
-
await
|
|
2453
|
-
await
|
|
2454
|
-
await
|
|
2455
|
-
await
|
|
2456
|
-
await
|
|
2457
|
-
await
|
|
2458
|
-
await
|
|
2418
|
+
await exec3(`echo output.txt >> .gitignore`);
|
|
2419
|
+
await exec3(`echo node_modules >> .gitignore`);
|
|
2420
|
+
await exec3(`echo dist >> .gitignore`);
|
|
2421
|
+
await exec3(`echo .mastra >> .gitignore`);
|
|
2422
|
+
await exec3(`echo .env.development >> .gitignore`);
|
|
2423
|
+
await exec3(`echo .env >> .gitignore`);
|
|
2424
|
+
await exec3(`echo *.db >> .gitignore`);
|
|
2425
|
+
await exec3(`echo *.db-* >> .gitignore`);
|
|
2459
2426
|
} catch (error) {
|
|
2460
2427
|
throw new Error(`Failed to create .gitignore: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2461
2428
|
}
|