Skip to content

Commit 915fc83

Browse files
committed
feat: update dependencies and add new workflows
- Updated dependencies in package.json for various packages including @ai-sdk/google-vertex, @ai-sdk/openai, framer-motion, motion, react-resizable-panels, and streamdown to their latest versions. - Added new workflows to the coding A2A Coordinator: - **safeRefactoringWorkflow**: Refactors code with E2B sandbox verification. - **testGenerationWorkflow**: Generates and runs tests for given code files. - **dataAnalysisWorkflow**: Conducts production-grade data analysis using coding agents and E2B sandboxes. - **automatedReportingWorkflow**: Gathers multi-section research and synthesizes it into a professional report. - Updated the codingTeamNetwork to include new workflows and improved documentation for agent delegation. - Enhanced the mastra index to include new workflows for better orchestration. - Improved logging and error handling across new workflows to ensure better traceability and debugging.
1 parent fb2a3a4 commit 915fc83

11 files changed

Lines changed: 1358 additions & 183 deletions

AGENTS.md

Lines changed: 228 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- AGENTS-META {"title":"Mastra Root","version":"2.3.0","applies_to":"/","last_updated":"2025-12-11T00:00:00Z","status":"stable"} -->
1+
<!-- AGENTS-META {"title":"Mastra Root","version":"2.4.0","applies_to":"/","last_updated":"2025-12-15T00:00:00Z","status":"stable"} -->
22

33
# AGENTS
44

@@ -86,7 +86,210 @@ NEXT_PUBLIC_MASTRA_API_URL=http://localhost:4111
8686
- Build: `npm run build`
8787
- Start production server: `npm run start`
8888
- Run tests: `npm test` (Vitest)
89-
- Run linters/formatting: `npx eslint "src/**/*.{ts,tsx}" --max-warnings=0` and `npx prettier --write .`
89+
- Run linters/formatting: `npm run lint` and `npm run format`
90+
- Type checking: `npm run typecheck`
91+
92+
## Code Style Guidelines
93+
94+
### Build & Test Commands
95+
96+
**Building:**
97+
98+
- `npm run build` - Concurrent build (Next.js + Mastra)
99+
- `npm run build:next` - Next.js build only
100+
- `npm run build:mastra` - Mastra build only
101+
102+
**Development:**
103+
104+
- `npm run dev` - Concurrent dev servers (Next.js + Mastra)
105+
- `npm run dev:next` - Next.js dev server only
106+
- `npm run dev:mastra` - Mastra dev server only
107+
108+
**Testing:**
109+
110+
- `npm test` - Run all tests (Vitest)
111+
- `npm run coverage` - Run tests with coverage report
112+
- `npx vitest -t "pattern"` - Run tests matching pattern
113+
- `npx vitest src/mastra/tools/tests/your-test-file.test.ts` - Run specific test file
114+
115+
**Linting & Formatting:**
116+
117+
- `npm run lint` - ESLint check
118+
- `npm run lint:fix` - ESLint with auto-fix
119+
- `npm run format` - Prettier formatting
120+
- `npm run typecheck` - TypeScript type checking
121+
122+
### Import Organization
123+
124+
```typescript
125+
// 1. External framework imports (React, Next.js, Mastra)
126+
import { createTool } from '@mastra/core/tools'
127+
import { z } from 'zod'
128+
129+
// 2. Type imports (always use type-only imports)
130+
import type { RuntimeContext } from '@mastra/core/runtime-context'
131+
import type { WeatherToolContext } from './types'
132+
133+
// 3. Internal imports (config, tools, utils)
134+
import { log } from '../config/logger'
135+
import { pgQueryTool } from '../config/pg-storage'
136+
```
137+
138+
### TypeScript Conventions
139+
140+
- **Strict mode enabled**: No implicit any, strict null checks
141+
- **Type definitions**: Use `interface` for public APIs, `type` for internal
142+
- **Explicit return types**: Required for public functions
143+
- **No `any`**: Use `unknown` or proper types
144+
- **Optional chaining**: Use `?.` for nullable access
145+
- **Nullish coalescing**: Use `??` for defaults
146+
- **Consistent imports**: `import type { T } from "module"`
147+
148+
### Naming Conventions
149+
150+
- **Functions/Tools**: `camelCase` (e.g., `weatherTool`, `getUserData`)
151+
- **Classes/Types/Interfaces**: `PascalCase` (e.g., `WeatherToolContext`, `UserProfile`)
152+
- **Constants**: `UPPER_SNAKE_CASE` (e.g., `API_TIMEOUT`, `MAX_RETRIES`)
153+
- **Files**: `kebab-case` (e.g., `weather-tool.ts`, `user-profile.tsx`)
154+
- **Directories**: `kebab-case` or `camelCase` based on convention
155+
156+
### Formatting (Prettier)
157+
158+
```javascript
159+
// prettier.config.js
160+
{
161+
trailingComma: 'es5',
162+
tabWidth: 4,
163+
semi: false,
164+
singleQuote: true
165+
}
166+
```
167+
168+
### ESLint Rules
169+
170+
**Critical Rules:**
171+
172+
- `eqeqeq: ['error', 'always']` - Strict equality
173+
- `curly: ['error', 'all']` - Required braces
174+
- `@typescript-eslint/no-unused-vars: ['warn', {}]` - No unused variables
175+
- `@typescript-eslint/no-explicit-any: 'warn'` - Avoid any types
176+
177+
**Style Rules:**
178+
179+
- `object-shorthand: 'error'` - Use shorthand syntax
180+
- `prefer-arrow-callback: 'error'` - Arrow functions preferred
181+
- `prefer-const: 'warn'` - Const when possible
182+
- `@typescript-eslint/consistent-type-definitions: ['error', 'interface']` - Interfaces preferred
183+
184+
### Error Handling
185+
186+
```typescript
187+
// ✅ GOOD: Structured error handling
188+
try {
189+
const result = await riskyOperation()
190+
return { data: result, error: null }
191+
} catch (error) {
192+
log.error('Operation failed', { error, context })
193+
return { data: null, error: error.message }
194+
}
195+
196+
// ❌ BAD: Silent failures or generic errors
197+
try {
198+
// ...
199+
} catch (e) {
200+
// pass
201+
}
202+
```
203+
204+
### Testing Standards
205+
206+
**Test Structure:**
207+
208+
```typescript
209+
import { describe, it, expect, vi } from 'vitest'
210+
211+
describe('weatherTool', () => {
212+
it('should return weather data for valid location', async () => {
213+
// Arrange
214+
const mockContext = { location: 'London' }
215+
216+
// Act
217+
const result = await weatherTool.execute({ context: mockContext })
218+
219+
// Assert
220+
expect(result.data).toBeDefined()
221+
expect(result.error).toBeNull()
222+
})
223+
})
224+
```
225+
226+
**Testing Rules:**
227+
228+
- 97% coverage target
229+
- Mock external dependencies
230+
- Test success and error paths
231+
- Use descriptive test names
232+
- Co-locate tests with implementation
233+
- `beforeEach` for setup/cleanup
234+
235+
### Tool Implementation Pattern
236+
237+
```typescript
238+
import { createTool } from '@mastra/core/tools'
239+
import { z } from 'zod'
240+
import { log } from '../config/logger'
241+
242+
// Context schema (optional)
243+
const toolContextSchema = z.object({
244+
timeout: z.number().default(5000),
245+
})
246+
247+
export type ToolContext = z.infer<typeof toolContextSchema>
248+
249+
export const myTool = createTool({
250+
id: 'my-tool',
251+
description: 'Clear description of what the tool does',
252+
inputSchema: z.object({
253+
param: z.string().describe('Parameter description'),
254+
}),
255+
outputSchema: z.object({
256+
data: z.any(),
257+
error: z.string().optional(),
258+
}),
259+
execute: async ({ context, runtimeContext }) => {
260+
try {
261+
// Tool logic here
262+
log.info('Tool executed', { context })
263+
264+
return { data: result, error: undefined }
265+
} catch (error) {
266+
log.error('Tool error', { error, context })
267+
return { data: null, error: error.message }
268+
}
269+
},
270+
})
271+
```
272+
273+
### Agent Implementation Pattern
274+
275+
```typescript
276+
import { Agent } from '@mastra/core/agent'
277+
import { googleAI } from '../config/google'
278+
import { pgMemory } from '../config/pg-storage'
279+
280+
export const myAgent = new Agent({
281+
id: 'my-agent',
282+
name: 'My Agent',
283+
description: 'What this agent does',
284+
instructions: 'Instructions for the agent...',
285+
model: googleAI,
286+
tools: {
287+
tool1,
288+
tool2,
289+
},
290+
memory: pgMemory,
291+
})
292+
```
90293

91294
## Architecture & conventions
92295

@@ -118,6 +321,19 @@ NEXT_PUBLIC_MASTRA_API_URL=http://localhost:4111
118321
- Use `.env` locally and secure env variables in CI/CD (e.g., GitHub Actions Secrets).
119322
- Mask secrets in logs and use `maskSensitiveMessageData()` helper from `src/mastra/config/pg-storage.ts` where needed.
120323

324+
## Cursor/Copilot Rules
325+
326+
Located in `.github/copilot-instructions.md`:
327+
328+
- 🧠 Read `/memory-bank/memory-bank-instructions.md` first
329+
- 🗂 Load all `/memory-bank/*.md` before any task
330+
- 🚦 Use the Kiro-Lite workflow: PRD → Design → Tasks → Code
331+
- 🔒 Follow security & style rules in `copilot-rules.md`
332+
- 📝 Update memory bank after significant changes
333+
- ✅ Confirm memory bank loaded with `[Memory Bank: Active]`
334+
- 🎯 Use problem-solving tools for debugging
335+
- 🛠 Use Mastra tools for documentation and examples
336+
121337
## Where to look for more info
122338

123339
- `app/AGENTS.md`: Next.js App Router pages and layouts
@@ -143,12 +359,12 @@ NEXT_PUBLIC_MASTRA_API_URL=http://localhost:4111
143359
- `app/tools/AGENTS.md`: Tool documentation and execution
144360
- `app/workflows/AGENTS.md`: Interactive workflow visualization with AI Elements (Canvas, Node, Edge, Panel)
145361
- `lib/`: Shared utilities
146-
- `hooks/`: React hooks for data fetching and state management
147-
- `use-dashboard-queries.ts`: TanStack Query hooks for agents, workflows, tools, traces, threads, messages
148-
- `use-mastra.ts`: Generic fetch hook with loading/error states for MastraClient data
149-
- `types/`: TypeScript type definitions
150-
- `mastra-api.ts`: Zod schemas and types for Agent, Workflow, Tool, MemoryThread, Message, VectorQueryResult
151-
- Core utilities: `a2a.ts` (agent coordination), `auth.ts` (authentication), `client-stream-to-ai-sdk.ts` (streaming), `mastra-client.ts` (client), `utils.ts`
362+
- `hooks/`: React hooks for data fetching and state management
363+
- `use-dashboard-queries.ts`: TanStack Query hooks for agents, workflows, tools, traces, threads, messages
364+
- `use-mastra.ts`: Generic fetch hook with loading/error states for MastraClient data
365+
- `types/`: TypeScript type definitions
366+
- `mastra-api.ts`: Zod schemas and types for Agent, Workflow, Tool, MemoryThread, Message, VectorQueryResult
367+
- Core utilities: `a2a.ts` (agent coordination), `auth.ts` (authentication), `client-stream-to-ai-sdk.ts` (streaming), `mastra-client.ts` (client), `utils.ts`
152368
- `ui/AGENTS.md`: shadcn/ui base components (34 components)
153369
- `src/components/ai-elements/AGENTS.md`: AI Elements library (30 components)
154370
- `src/mastra/AGENTS.md`: top-level code-agent focused docs (this file is mirrored to subfolders)
@@ -239,17 +455,17 @@ graph TB
239455
- `testSetup.ts`: Test setup with mocks, environment variables, and global type declarations
240456
- `postcss.config.mjs`: PostCSS configuration with Tailwind CSS plugin
241457
- `mdx-components.tsx`: Custom MDX components for styling headings, links, code blocks, tables, and images
242-
- `eslint.config.cjs`: ESLint configuration with TypeScript rules, Prettier integration, and extensive ignore patterns
458+
- `eslint.config.js`: ESLint configuration with TypeScript rules, Prettier integration, and extensive ignore patterns
243459
- `prettier.config.js`: Prettier configuration with ES5 trailing commas, 4-space tabs, and single quotes
244460
- `components.json`: shadcn/ui configuration with New York style, Tailwind CSS, Lucide icons, and component aliases
245461
- `.eslintignore`: ESLint ignore patterns for node_modules, build artifacts, memory-bank, docs, and other non-source directories
246462
- `.markdownlint.json`: Markdown linting configuration with relaxed rules for line length, headings, and formatting
247463
- `src/cli/`: CLI tooling for Governed RAG
248-
- `index.ts`: CLI commands for document indexing, querying RAG, and usage statistics
249-
- `AGENTS.md`: CLI documentation and usage patterns
464+
- `index.ts`: CLI commands for document indexing, querying RAG, and usage statistics
465+
- `AGENTS.md`: CLI documentation and usage patterns
250466

251467
If you need more details for a subdirectory, open the folder-specific `AGENTS.md` which contains persona, purpose, and actionable commands.
252468

253469
---
254470

255-
Last updated: 2025-12-15
471+
Last updated: 2025-12-15

0 commit comments

Comments
 (0)