@mastra/mcp-docs-server 1.2.15 → 1.2.16-alpha.3
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/.docs/docs/agents/agent-approval.md +5 -5
- package/.docs/docs/agents/overview.md +4 -4
- package/.docs/docs/browser/overview.md +1 -1
- package/.docs/docs/capabilities/channels.md +5 -5
- package/.docs/docs/capabilities/subagents.md +1 -1
- package/.docs/docs/connections/overview.md +1 -1
- package/.docs/docs/datasets/overview.md +1 -1
- package/.docs/docs/deployment/cloud-providers.md +4 -2
- package/.docs/docs/deployment/mastra-server.md +1 -1
- package/.docs/docs/deployment/monorepo.md +1 -1
- package/.docs/docs/deployment/overview.md +4 -1
- package/.docs/docs/deployment/sandbox.md +1 -1
- package/.docs/docs/deployment/web-framework.md +1 -1
- package/.docs/docs/deployment/workers.md +248 -2
- package/.docs/docs/evals/overview.md +1 -1
- package/.docs/docs/evals/quick-checks.md +1 -1
- package/.docs/docs/guides/multi-agent-systems.md +1 -1
- package/.docs/docs/harness/agent-controller.md +5 -5
- package/.docs/docs/harness/overview.md +1 -1
- package/.docs/docs/index.md +3 -3
- package/.docs/docs/long-running-agents/signal-providers.md +2 -2
- package/.docs/docs/mastra-platform/deploy.md +1 -1
- package/.docs/docs/mastra-platform/observability.md +63 -18
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/mcp/overview.md +1 -1
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +2 -2
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/metrics/overview.md +1 -1
- package/.docs/docs/observability/overview.md +1 -5
- package/.docs/docs/observability/tracing/overview.md +3 -6
- package/.docs/docs/server/auth/workers.md +1 -1
- package/.docs/docs/server/auth.md +5 -5
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/storage/overview.md +7 -6
- package/.docs/docs/workflows/human-in-the-loop.md +2 -2
- package/.docs/docs/workflows/overview.md +2 -2
- package/.docs/docs/workspace/lsp.md +27 -0
- package/.docs/docs/workspace/sandbox.md +11 -12
- package/.docs/integrations/agentic-ui/ai-sdk-ui.md +1 -1
- package/.docs/integrations/agentic-ui/assistant-ui.md +1 -1
- package/.docs/integrations/agentic-ui/copilotkit.md +1 -1
- package/.docs/integrations/agentic-ui/openui.md +1 -1
- package/.docs/integrations/databases/postgresql.md +8 -8
- package/.docs/integrations/deploy/amazon-ec2.md +2 -2
- package/.docs/integrations/deploy/aws-bedrock-agentcore.md +1 -1
- package/.docs/integrations/deploy/aws-lambda.md +2 -2
- package/.docs/integrations/deploy/azure-app-services.md +2 -2
- package/.docs/integrations/deploy/cloudflare.md +2 -2
- package/.docs/integrations/deploy/digital-ocean.md +2 -2
- package/.docs/integrations/deploy/inngest.md +1 -1
- package/.docs/integrations/deploy/kubernetes.md +2 -3
- package/.docs/integrations/deploy/netlify.md +2 -2
- package/.docs/integrations/deploy/temporal.md +1 -1
- package/.docs/integrations/deploy/vercel.md +2 -2
- package/.docs/integrations/file-storage/agentfs.md +1 -1
- package/.docs/integrations/file-storage/amazon-s3.md +1 -1
- package/.docs/integrations/file-storage/archil.md +1 -1
- package/.docs/integrations/file-storage/azure-blob.md +1 -1
- package/.docs/integrations/file-storage/google-cloud-storage.md +1 -1
- package/.docs/integrations/file-storage/google-drive.md +1 -1
- package/.docs/integrations/file-storage/mesa.md +1 -1
- package/.docs/integrations/file-storage/vercel-files.md +1 -1
- package/.docs/integrations/frameworks/astro.md +1 -1
- package/.docs/integrations/frameworks/electron.md +1 -1
- package/.docs/integrations/frameworks/express.md +1 -1
- package/.docs/integrations/frameworks/hono.md +1 -1
- package/.docs/integrations/frameworks/nestjs.md +1 -1
- package/.docs/integrations/frameworks/next-js.md +1 -1
- package/.docs/integrations/frameworks/nuxt.md +1 -1
- package/.docs/integrations/frameworks/sveltekit.md +1 -1
- package/.docs/integrations/frameworks/vite-react.md +1 -1
- package/.docs/integrations/sandboxes/agentcore.md +1 -1
- package/.docs/integrations/sandboxes/apple-container.md +1 -1
- package/.docs/integrations/sandboxes/blaxel.md +1 -1
- package/.docs/integrations/sandboxes/daytona.md +1 -1
- package/.docs/integrations/sandboxes/docker.md +1 -1
- package/.docs/integrations/sandboxes/e2b.md +1 -1
- package/.docs/integrations/sandboxes/modal.md +1 -1
- package/.docs/integrations/sandboxes/railway.md +1 -1
- package/.docs/integrations/sandboxes/vercel.md +3 -1
- package/.docs/integrations/tools/firecrawl.md +2 -2
- package/.docs/integrations/voice/livekit.md +3 -3
- package/.docs/integrations.md +108 -108
- package/.docs/models/environment-variables.md +2 -0
- package/.docs/models/gateways/openrouter.md +5 -1
- package/.docs/models/gateways/vercel.md +3 -2
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/aiand.md +3 -2
- package/.docs/models/providers/digitalocean.md +3 -2
- package/.docs/models/providers/edenai.md +88 -0
- package/.docs/models/providers/hyper.md +3 -3
- package/.docs/models/providers/inceptron.md +8 -9
- package/.docs/models/providers/kilo.md +11 -6
- package/.docs/models/providers/llmgateway.md +3 -1
- package/.docs/models/providers/merge-gateway.md +262 -0
- package/.docs/models/providers/nano-gpt.md +13 -37
- package/.docs/models/providers/opencode.md +2 -2
- package/.docs/models/providers/tinfoil.md +9 -8
- package/.docs/models/providers/xai.md +2 -1
- package/.docs/models/providers.md +2 -0
- package/.docs/reference/agents/getVoice.md +1 -1
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/index.md +5 -1
- package/.docs/reference/manual-install.md +1 -1
- package/.docs/reference/migrations/network-to-supervisor.md +1 -1
- package/.docs/reference/migrations/upgrade-to-v1/tracing.md +1 -3
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +0 -1
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +0 -1
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +0 -1
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +0 -1
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +0 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +111 -99
- package/.docs/reference/observability/tracing/span-filtering.md +1 -1
- package/.docs/reference/storage/overview.md +1 -1
- package/.docs/reference/templates/overview.md +1 -1
- package/.docs/{guides → reference}/voice/overview.md +3 -3
- package/.docs/{guides → reference}/voice/speech-to-speech.md +1 -1
- package/.docs/{guides → reference}/voice/speech-to-text.md +1 -1
- package/.docs/{guides → reference}/voice/text-to-speech.md +2 -2
- package/CHANGELOG.md +14 -0
- package/package.json +4 -4
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +0 -201
- package/.docs/docs/observability/integrations/overview.md +0 -47
- package/.docs/docs/observability/integrations/processors/sensitive-data-filter.md +0 -302
- package/.docs/guides/deployment/mastra-workers.md +0 -578
- package/.docs/guides/getting-started/quickstart.md +0 -88
- package/.docs/guides/guide/ai-recruiter.md +0 -228
- package/.docs/guides/guide/code-review-bot.md +0 -228
- package/.docs/guides/guide/coding-agent.md +0 -392
- package/.docs/guides/guide/dev-assistant.md +0 -309
- package/.docs/guides/guide/docs-manager.md +0 -240
- package/.docs/guides/guide/github-actions-pr-description.md +0 -238
- package/.docs/guides/guide/notes-mcp-server.md +0 -418
- package/.docs/guides/guide/research-assistant.md +0 -350
- package/.docs/guides/guide/research-coordinator.md +0 -418
- package/.docs/guides/guide/signal-provider.md +0 -221
- package/.docs/guides/index.md +0 -24
- /package/.docs/{reference → docs}/mastra-platform/api.md +0 -0
- /package/.docs/{guides/agent-frameworks/ai-sdk.md → reference/ai-sdk/overview.md} +0 -0
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
-
|
|
3
|
-
# Building an AI recruiter
|
|
4
|
-
|
|
5
|
-
In this guide, you'll learn how Mastra helps you build workflows with LLMs.
|
|
6
|
-
|
|
7
|
-
You'll create a workflow that gathers information from a candidate's resume, then branches to either a technical or behavioral question based on the candidate's profile. Along the way, you'll see how to structure workflow steps, handle branching, and integrate LLM calls.
|
|
8
|
-
|
|
9
|
-
## Prerequisites
|
|
10
|
-
|
|
11
|
-
- Node.js `v22.13.0` or later installed
|
|
12
|
-
- An API key from a supported [Model Provider](https://mastra.ai/models)
|
|
13
|
-
- An existing Mastra project (Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) to set up a new project)
|
|
14
|
-
|
|
15
|
-
## Building the workflow
|
|
16
|
-
|
|
17
|
-
Set up the Workflow, define steps to extract and classify candidate data, and then ask suitable follow-up questions.
|
|
18
|
-
|
|
19
|
-
1. Create a new file `src/mastra/workflows/candidate-workflow.ts` and define your workflow:
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
import { createWorkflow, createStep } from '@mastra/core/workflows'
|
|
23
|
-
import { z } from 'zod'
|
|
24
|
-
|
|
25
|
-
export const candidateWorkflow = createWorkflow({
|
|
26
|
-
id: 'candidate-workflow',
|
|
27
|
-
inputSchema: z.object({
|
|
28
|
-
resumeText: z.string(),
|
|
29
|
-
}),
|
|
30
|
-
outputSchema: z.object({
|
|
31
|
-
askAboutSpecialty: z.object({
|
|
32
|
-
question: z.string(),
|
|
33
|
-
}),
|
|
34
|
-
askAboutRole: z.object({
|
|
35
|
-
question: z.string(),
|
|
36
|
-
}),
|
|
37
|
-
}),
|
|
38
|
-
}).commit()
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
2. You want to extract candidate details from the resume text and classify the person as "technical" or "non-technical". This step calls an LLM to parse the resume and returns structured JSON, including the name, technical status, specialty, and the original resume text. Defined through the `inputSchema` you get access to the `resumeText` inside `execute()`. Use it to prompt an LLM and return the organized fields.
|
|
42
|
-
|
|
43
|
-
To the existing `src/mastra/workflows/candidate-workflow.ts` file add the following:
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
import { Agent } from '@mastra/core/agent'
|
|
47
|
-
|
|
48
|
-
const recruiter = new Agent({
|
|
49
|
-
id: 'recruiter-agent',
|
|
50
|
-
name: 'Recruiter Agent',
|
|
51
|
-
instructions: `You are a recruiter.`,
|
|
52
|
-
model: 'openai/gpt-5.6-sol',
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const gatherCandidateInfo = createStep({
|
|
56
|
-
id: 'gatherCandidateInfo',
|
|
57
|
-
inputSchema: z.object({
|
|
58
|
-
resumeText: z.string(),
|
|
59
|
-
}),
|
|
60
|
-
outputSchema: z.object({
|
|
61
|
-
candidateName: z.string(),
|
|
62
|
-
isTechnical: z.boolean(),
|
|
63
|
-
specialty: z.string(),
|
|
64
|
-
resumeText: z.string(),
|
|
65
|
-
}),
|
|
66
|
-
execute: async ({ inputData }) => {
|
|
67
|
-
const resumeText = inputData?.resumeText
|
|
68
|
-
|
|
69
|
-
const prompt = `Extract details from the resume text:
|
|
70
|
-
"${resumeText}"`
|
|
71
|
-
|
|
72
|
-
const res = await recruiter.generate(prompt, {
|
|
73
|
-
structuredOutput: {
|
|
74
|
-
schema: z.object({
|
|
75
|
-
candidateName: z.string(),
|
|
76
|
-
isTechnical: z.boolean(),
|
|
77
|
-
specialty: z.string(),
|
|
78
|
-
resumeText: z.string(),
|
|
79
|
-
}),
|
|
80
|
-
},
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
return res.object
|
|
84
|
-
},
|
|
85
|
-
})
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Since you're using a Recruiter agent inside `execute()` you need to define it above the step and add the necessary imports.
|
|
89
|
-
|
|
90
|
-
3. This step prompts a candidate who is identified as "technical" for more information about how they got into their specialty. It uses the entire resume text so the LLM can craft a relevant follow-up question.
|
|
91
|
-
|
|
92
|
-
To the existing `src/mastra/workflows/candidate-workflow.ts` file add the following:
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
const askAboutSpecialty = createStep({
|
|
96
|
-
id: 'askAboutSpecialty',
|
|
97
|
-
inputSchema: z.object({
|
|
98
|
-
candidateName: z.string(),
|
|
99
|
-
isTechnical: z.boolean(),
|
|
100
|
-
specialty: z.string(),
|
|
101
|
-
resumeText: z.string(),
|
|
102
|
-
}),
|
|
103
|
-
outputSchema: z.object({
|
|
104
|
-
question: z.string(),
|
|
105
|
-
}),
|
|
106
|
-
execute: async ({ inputData: candidateInfo }) => {
|
|
107
|
-
const prompt = `You are a recruiter. Given the resume below, craft a short question
|
|
108
|
-
for ${candidateInfo?.candidateName} about how they got into "${candidateInfo?.specialty}".
|
|
109
|
-
Resume: ${candidateInfo?.resumeText}`
|
|
110
|
-
const res = await recruiter.generate(prompt)
|
|
111
|
-
|
|
112
|
-
return { question: res?.text?.trim() || '' }
|
|
113
|
-
},
|
|
114
|
-
})
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
4. If the candidate is "non-technical", you want a different follow-up question. This step asks what interests them most about the role, again referencing their complete resume text. The `execute()` function solicits a role-focused query from the LLM.
|
|
118
|
-
|
|
119
|
-
To the existing `src/mastra/workflows/candidate-workflow.ts` file add the following:
|
|
120
|
-
|
|
121
|
-
```ts
|
|
122
|
-
const askAboutRole = createStep({
|
|
123
|
-
id: 'askAboutRole',
|
|
124
|
-
inputSchema: z.object({
|
|
125
|
-
candidateName: z.string(),
|
|
126
|
-
isTechnical: z.boolean(),
|
|
127
|
-
specialty: z.string(),
|
|
128
|
-
resumeText: z.string(),
|
|
129
|
-
}),
|
|
130
|
-
outputSchema: z.object({
|
|
131
|
-
question: z.string(),
|
|
132
|
-
}),
|
|
133
|
-
execute: async ({ inputData: candidateInfo }) => {
|
|
134
|
-
const prompt = `You are a recruiter. Given the resume below, craft a short question
|
|
135
|
-
for ${candidateInfo?.candidateName} asking what interests them most about this role.
|
|
136
|
-
Resume: ${candidateInfo?.resumeText}`
|
|
137
|
-
const res = await recruiter.generate(prompt)
|
|
138
|
-
return { question: res?.text?.trim() || '' }
|
|
139
|
-
},
|
|
140
|
-
})
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
5. You now combine the steps to implement branching logic based on the candidate's technical status. The workflow first gathers candidate data, then either asks about their specialty or about their role, depending on `isTechnical`. This is done by chaining `gatherCandidateInfo` with `askAboutSpecialty` and `askAboutRole`.
|
|
144
|
-
|
|
145
|
-
To the existing `src/mastra/workflows/candidate-workflow.ts` file change the `candidateWorkflow` like so:
|
|
146
|
-
|
|
147
|
-
```ts
|
|
148
|
-
export const candidateWorkflow = createWorkflow({
|
|
149
|
-
id: 'candidate-workflow',
|
|
150
|
-
inputSchema: z.object({
|
|
151
|
-
resumeText: z.string(),
|
|
152
|
-
}),
|
|
153
|
-
outputSchema: z.object({
|
|
154
|
-
askAboutSpecialty: z.object({
|
|
155
|
-
question: z.string(),
|
|
156
|
-
}),
|
|
157
|
-
askAboutRole: z.object({
|
|
158
|
-
question: z.string(),
|
|
159
|
-
}),
|
|
160
|
-
}),
|
|
161
|
-
})
|
|
162
|
-
.then(gatherCandidateInfo)
|
|
163
|
-
.branch([
|
|
164
|
-
[async ({ inputData: { isTechnical } }) => isTechnical, askAboutSpecialty],
|
|
165
|
-
[async ({ inputData: { isTechnical } }) => !isTechnical, askAboutRole],
|
|
166
|
-
])
|
|
167
|
-
.commit()
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
6. In your `src/mastra/index.ts` file, register the workflow:
|
|
171
|
-
|
|
172
|
-
```ts
|
|
173
|
-
import { Mastra } from '@mastra/core'
|
|
174
|
-
import { candidateWorkflow } from './workflows/candidate-workflow'
|
|
175
|
-
|
|
176
|
-
export const mastra = new Mastra({
|
|
177
|
-
workflows: { candidateWorkflow },
|
|
178
|
-
})
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Testing the workflow
|
|
182
|
-
|
|
183
|
-
You can test your workflow inside [Studio](https://mastra.ai/docs/studio/overview) by starting the development server:
|
|
184
|
-
|
|
185
|
-
```bash
|
|
186
|
-
mastra dev
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
In the sidebar, navigate to **Workflows** and select **candidate-workflow**. In the middle you'll see a graph view of your workflow and on the right sidebar the **Run** tab is selected by default. Inside this tab you can enter a resume text, for example:
|
|
190
|
-
|
|
191
|
-
```text
|
|
192
|
-
Knowledgeable Software Engineer with more than 10 years of experience in software development. Proven expertise in the design and development of software databases and optimization of user interfaces.
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
After entering the resume text, press the **Run** button. You should now see two status boxes (`GatherCandidateInfo` and `AskAboutSpecialty`) which contain the output of the workflow steps.
|
|
196
|
-
|
|
197
|
-
You can also test the workflow programmatically by calling [`.createRun()`](https://mastra.ai/reference/workflows/workflow-methods/create-run) and [`.start()`](https://mastra.ai/reference/workflows/run-methods/start). Create a new file `src/test-workflow.ts` and add the following:
|
|
198
|
-
|
|
199
|
-
```ts
|
|
200
|
-
import { mastra } from './mastra'
|
|
201
|
-
|
|
202
|
-
const run = await mastra.getWorkflow('candidateWorkflow').createRun()
|
|
203
|
-
|
|
204
|
-
const res = await run.start({
|
|
205
|
-
inputData: {
|
|
206
|
-
resumeText:
|
|
207
|
-
'Knowledgeable Software Engineer with more than 10 years of experience in software development. Proven expertise in the design and development of software databases and optimization of user interfaces.',
|
|
208
|
-
},
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
// Dump the complete workflow result (includes status, steps and result)
|
|
212
|
-
console.log(JSON.stringify(res, null, 2))
|
|
213
|
-
|
|
214
|
-
// Get the workflow output value
|
|
215
|
-
if (res.status === 'success') {
|
|
216
|
-
const question = res.result.askAboutRole?.question ?? res.result.askAboutSpecialty?.question
|
|
217
|
-
|
|
218
|
-
console.log(`Output value: ${question}`)
|
|
219
|
-
}
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
Now, run the workflow and get output in your terminal:
|
|
223
|
-
|
|
224
|
-
```bash
|
|
225
|
-
npx tsx src/test-workflow.ts
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
You've built a workflow to parse a resume and decide which question to ask based on the candidate's technical abilities. Congrats and happy hacking!
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
-
|
|
3
|
-
# Building a code review bot
|
|
4
|
-
|
|
5
|
-
In this guide, you'll build a code review bot that automatically reviews pull requests using workspace skills. The bot loads coding standards from skill files and provides structured feedback. You'll create a workspace with a skills directory and define an [Agent Skill](https://agentskills.io) with review instructions and reference files. Then you'll connect the skill to an agent that performs automated reviews.
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
- Node.js `v22.13.0` or later installed
|
|
10
|
-
- An API key from a supported [Model Provider](https://mastra.ai/models)
|
|
11
|
-
- An existing Mastra project (Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) to set up a new project)
|
|
12
|
-
|
|
13
|
-
## Create the workspace
|
|
14
|
-
|
|
15
|
-
In your `src/mastra/index.ts` file, import the [`Workspace`](https://mastra.ai/reference/workspace/workspace-class) and [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem) classes. On the `Workspace` instance, configure the `skills` option to point to a skills directory. The `skills` directory will live inside the filesystem's `basePath`.
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
import { Mastra } from '@mastra/core'
|
|
19
|
-
import { resolve } from 'node:path'
|
|
20
|
-
import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
|
|
21
|
-
|
|
22
|
-
const workspace = new Workspace({
|
|
23
|
-
filesystem: new LocalFilesystem({
|
|
24
|
-
basePath: resolve(import.meta.dirname, '../../workspace'),
|
|
25
|
-
}),
|
|
26
|
-
skills: ['skills'],
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
export const mastra = new Mastra({
|
|
30
|
-
workspace,
|
|
31
|
-
})
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
At the root of your project, create a new folder called `workspace`. Inside that, create a `skills` folder. This is where you'll define the code standards skill in the next step.
|
|
35
|
-
|
|
36
|
-
## Create the code standards skill
|
|
37
|
-
|
|
38
|
-
Skills are structured directories containing a `SKILL.md` file with instructions for the agent. The code standards skill defines the review process and references a style guide.
|
|
39
|
-
|
|
40
|
-
Inside `workspace/skills`, create a new folder called `code-standards`. Create a file called `SKILL.md` and add the review instructions.
|
|
41
|
-
|
|
42
|
-
```markdown
|
|
43
|
-
---
|
|
44
|
-
name: code-standards
|
|
45
|
-
description: Automated code review standards and checks
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
# Code Review Standards
|
|
49
|
-
|
|
50
|
-
Review code systematically using these steps:
|
|
51
|
-
|
|
52
|
-
1. **Critical Issues**: Security vulnerabilities, memory leaks, logic bugs, missing error handling
|
|
53
|
-
2. **Code Quality**: Functions over 50 lines, code duplication, confusing names, missing types
|
|
54
|
-
3. **Style Guide**: Check references/style-guide.md for naming and organization
|
|
55
|
-
4. **Linting**: Flag common issues like use of `var`, leftover `console.log` statements, and `debugger` statements
|
|
56
|
-
|
|
57
|
-
Provide feedback in this format:
|
|
58
|
-
|
|
59
|
-
**Summary**: One sentence overview
|
|
60
|
-
|
|
61
|
-
**Critical Issues**: List with line numbers
|
|
62
|
-
|
|
63
|
-
**Suggestions**: Improvements that would help
|
|
64
|
-
|
|
65
|
-
**Positive Notes**: What the code does well
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
Inside `workspace/skills/code-standards`, create a `references` folder to hold reference materials for the skill. Author a style guide file that outlines the project's coding conventions with the file name `style-guide.md`.
|
|
69
|
-
|
|
70
|
-
````markdown
|
|
71
|
-
# Style Guide
|
|
72
|
-
|
|
73
|
-
## Naming
|
|
74
|
-
|
|
75
|
-
- Variables/Functions: `camelCase`
|
|
76
|
-
- Constants: `UPPER_SNAKE_CASE`
|
|
77
|
-
- Files: `kebab-case.ts`
|
|
78
|
-
- Booleans: Start with `is`, `has`, `should`
|
|
79
|
-
|
|
80
|
-
## Code organization
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
// 1. Imports
|
|
84
|
-
import { foo } from 'bar'
|
|
85
|
-
|
|
86
|
-
// 2. Constants
|
|
87
|
-
const MAX_SIZE = 100
|
|
88
|
-
|
|
89
|
-
// 3. Types
|
|
90
|
-
interface User {
|
|
91
|
-
id: string
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// 4. Functions
|
|
95
|
-
function doSomething() {}
|
|
96
|
-
|
|
97
|
-
// 5. Exports
|
|
98
|
-
export { doSomething }
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## Error handling
|
|
102
|
-
|
|
103
|
-
Always handle errors explicitly - never silently catch.
|
|
104
|
-
|
|
105
|
-
## Comments
|
|
106
|
-
|
|
107
|
-
Write "why" not "what".
|
|
108
|
-
````
|
|
109
|
-
|
|
110
|
-
## Create the review agent
|
|
111
|
-
|
|
112
|
-
Now it's time to create the code review bot agent that uses the code-standards skill. Create a new file at `src/mastra/agents/code-reviewer.ts` and define the agent:
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
import { Agent } from '@mastra/core/agent'
|
|
116
|
-
|
|
117
|
-
export const codeReviewer = new Agent({
|
|
118
|
-
id: 'code-reviewer',
|
|
119
|
-
name: 'Code Review Bot',
|
|
120
|
-
instructions: `You are an automated code reviewer.
|
|
121
|
-
|
|
122
|
-
When asked to review code:
|
|
123
|
-
1. Activate the 'code-standards' skill
|
|
124
|
-
2. Follow the review process from the skill
|
|
125
|
-
3. Check against the style guide in skill references
|
|
126
|
-
4. Be constructive and specific with line numbers`,
|
|
127
|
-
model: 'openai/gpt-5.6-sol',
|
|
128
|
-
})
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
Define the agent by importing it inside `src/mastra/index.ts` and registering it with the `Mastra` instance:
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
import { Mastra } from '@mastra/core'
|
|
135
|
-
import { resolve } from 'node:path'
|
|
136
|
-
import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
|
|
137
|
-
import { codeReviewer } from './agents/code-reviewer'
|
|
138
|
-
|
|
139
|
-
const workspace = new Workspace({
|
|
140
|
-
filesystem: new LocalFilesystem({
|
|
141
|
-
basePath: resolve(import.meta.dirname, '../../workspace'),
|
|
142
|
-
}),
|
|
143
|
-
skills: ['skills'],
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
export const mastra = new Mastra({
|
|
147
|
-
workspace,
|
|
148
|
-
agents: { codeReviewer },
|
|
149
|
-
})
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## Test the bot
|
|
153
|
-
|
|
154
|
-
Start [Studio](https://mastra.ai/docs/studio/overview) and interact with the code review bot to see it in action.
|
|
155
|
-
|
|
156
|
-
**npm**:
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
npm run dev
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
**pnpm**:
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
pnpm run dev
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
**Yarn**:
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
yarn dev
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
**Bun**:
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
bun run dev
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Open [localhost:4111](http://localhost:4111) and navigate to the code reviewer agent.
|
|
181
|
-
|
|
182
|
-
Inside the chat input, provide a code snippet for review, such as:
|
|
183
|
-
|
|
184
|
-
```text
|
|
185
|
-
Review this code:
|
|
186
|
-
|
|
187
|
-
function getData(id) {
|
|
188
|
-
var result = fetch('/api/data/' + id);
|
|
189
|
-
console.log(result);
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
The bot should activate the `code-standards` skill and provide structured feedback. Since agent responses are non-deterministic, your output may vary, but you should see something similar to:
|
|
195
|
-
|
|
196
|
-
```md
|
|
197
|
-
**Summary**: Function has several issues with variable declaration,
|
|
198
|
-
debugging statements, and missing error handling.
|
|
199
|
-
|
|
200
|
-
**Critical Issues**:
|
|
201
|
-
|
|
202
|
-
- Missing error handling for fetch (line 2)
|
|
203
|
-
- No async/await for asynchronous operation (line 2)
|
|
204
|
-
|
|
205
|
-
**Suggestions**:
|
|
206
|
-
|
|
207
|
-
- Use const instead of var (line 2)
|
|
208
|
-
- Remove console.log before committing (line 3)
|
|
209
|
-
- Add TypeScript type for id parameter
|
|
210
|
-
- Use template literals instead of concatenation
|
|
211
|
-
|
|
212
|
-
**Positive Notes**:
|
|
213
|
-
|
|
214
|
-
- Function name is clear and descriptive
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
## Next steps
|
|
218
|
-
|
|
219
|
-
You can extend this bot to:
|
|
220
|
-
|
|
221
|
-
- Add skills for different languages or frameworks
|
|
222
|
-
- Create skills for security checks and performance reviews
|
|
223
|
-
- Integrate with GitHub Actions for automatic PR reviews
|
|
224
|
-
- Build a PR comment bot that leaves inline feedback
|
|
225
|
-
|
|
226
|
-
Learn more:
|
|
227
|
-
|
|
228
|
-
- [Agent Skills spec](https://agentskills.io)
|