@mastra/mcp-docs-server 1.1.1-alpha.1 → 1.1.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.
@@ -24,21 +24,11 @@ export const agent = new Agent({
24
24
  });
25
25
  ```
26
26
 
27
- That's it. The agent now has humanlike long-term memory that persists across conversations. Setting `observationalMemory: true` uses `google/gemini-2.5-flash` by default. To use a different model or customize thresholds, pass a config object instead:
28
-
29
- ```typescript
30
- const memory = new Memory({
31
- options: {
32
- observationalMemory: {
33
- model: "deepseek/deepseek-reasoner",
34
- },
35
- },
36
- });
37
- ```
27
+ That's it. The agent now has humanlike long-term memory that persists across conversations.
38
28
 
39
29
  See [configuration options](https://mastra.ai/reference/memory/observational-memory) for full API details.
40
30
 
41
- > **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, and `@mastra/mongodb` storage adapters. It uses background agents for managing memory. When using `observationalMemory: true`, the default model is `google/gemini-2.5-flash`. When passing a config object, a `model` must be explicitly set.
31
+ > **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, and `@mastra/mongodb` storage adapters. It also uses background agents for managing memory. The default model (configurable) is `google/gemini-2.5-flash` as it's the one we've tested the most.
42
32
 
43
33
  ## Benefits
44
34
 
@@ -87,9 +77,7 @@ The result is a three-tier system:
87
77
 
88
78
  The Observer and Reflector run in the background. Any model that works with Mastra's model routing (e.g. `openai/...`, `google/...`, `deepseek/...`) can be used.
89
79
 
90
- When using `observationalMemory: true`, the default model is `google/gemini-2.5-flash`. When passing a config object, a `model` must be explicitly set.
91
-
92
- We recommend `google/gemini-2.5-flash` — it works well for both observation and reflection, and its 1M token context window gives the Reflector headroom.
80
+ The default is `google/gemini-2.5-flash` it works well for both observation and reflection, and its 1M token context window gives the Reflector headroom.
93
81
 
94
82
  We've also tested `deepseek`, `qwen3`, and `glm-4.7` for the Observer. For the Reflector, make sure the model's context window can fit all observations. Note that Claude 4.5 models currently don't work well as observer or reflector.
95
83
 
@@ -112,14 +100,9 @@ See [model configuration](https://mastra.ai/reference/memory/observational-memor
112
100
  Each thread has its own observations.
113
101
 
114
102
  ```typescript
115
- const memory = new Memory({
116
- options: {
117
- observationalMemory: {
118
- model: "google/gemini-2.5-flash",
119
- scope: "thread",
120
- },
121
- },
122
- });
103
+ observationalMemory: {
104
+ scope: "thread",
105
+ }
123
106
  ```
124
107
 
125
108
  ### Resource scope
@@ -127,14 +110,9 @@ const memory = new Memory({
127
110
  Observations are shared across all threads for a resource (typically a user). Enables cross-conversation memory.
128
111
 
129
112
  ```typescript
130
- const memory = new Memory({
131
- options: {
132
- observationalMemory: {
133
- model: "google/gemini-2.5-flash",
134
- scope: "resource",
135
- },
136
- },
137
- });
113
+ observationalMemory: {
114
+ scope: "resource",
115
+ }
138
116
  ```
139
117
 
140
118
  > **Warning:** In resource scope, unobserved messages across _all_ threads are processed together. For users with many existing threads, this can be slow. Use thread scope for existing apps.
@@ -147,7 +125,6 @@ OM uses token thresholds to decide when to observe and reflect. See [token budge
147
125
  const memory = new Memory({
148
126
  options: {
149
127
  observationalMemory: {
150
- model: "google/gemini-2.5-flash",
151
128
  observation: {
152
129
  // when to run the Observer (default: 30,000)
153
130
  messageTokens: 30_000,
@@ -157,58 +134,12 @@ const memory = new Memory({
157
134
  observationTokens: 40_000,
158
135
  },
159
136
  // let message history borrow from observation budget
160
- // requires bufferTokens: false (temporary limitation)
161
137
  shareTokenBudget: false,
162
138
  },
163
139
  },
164
140
  });
165
141
  ```
166
142
 
167
- ## Async Buffering
168
-
169
- Without async buffering, the Observer runs synchronously when the message threshold is reached — the agent pauses mid-conversation while the Observer LLM call completes. With async buffering (enabled by default), observations are pre-computed in the background as the conversation grows. When the threshold is hit, buffered observations activate instantly with no pause.
170
-
171
- ### How it works
172
-
173
- As the agent converses, message tokens accumulate. At regular intervals (`bufferTokens`), a background Observer call runs without blocking the agent. Each call produces a "chunk" of observations that's stored in a buffer.
174
-
175
- When message tokens reach the `messageTokens` threshold, buffered chunks activate: their observations move into the active observation log, and the corresponding raw messages are removed from the context window. The agent never pauses.
176
-
177
- If the agent produces messages faster than the Observer can process them, a `blockAfter` safety threshold forces a synchronous observation as a last resort.
178
-
179
- Reflection works similarly — the Reflector runs in the background when observations reach a fraction of the reflection threshold.
180
-
181
- ### Settings
182
-
183
- | Setting | Default | What it controls |
184
- | ------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
185
- | `observation.bufferTokens` | `0.2` | How often to buffer. `0.2` means every 20% of `messageTokens` — with the default 30k threshold, that's roughly every 6k tokens. Can also be an absolute token count (e.g. `5000`). |
186
- | `observation.bufferActivation` | `0.8` | How aggressively to clear the message window on activation. `0.8` means remove enough messages to keep only 20% of `messageTokens` remaining. Lower values keep more message history. |
187
- | `observation.blockAfter` | `1.2` | Safety threshold as a multiplier of `messageTokens`. At `1.2`, synchronous observation is forced at 36k tokens (1.2 × 30k). Only matters if buffering can't keep up. |
188
- | `reflection.bufferActivation` | `0.5` | When to start background reflection. `0.5` means reflection begins when observations reach 50% of the `observationTokens` threshold. |
189
- | `reflection.blockAfter` | `1.2` | Safety threshold for reflection, same logic as observation. |
190
-
191
- ### Disabling
192
-
193
- To disable async buffering and use synchronous observation/reflection instead:
194
-
195
- ```typescript
196
- const memory = new Memory({
197
- options: {
198
- observationalMemory: {
199
- model: "google/gemini-2.5-flash",
200
- observation: {
201
- bufferTokens: false,
202
- },
203
- },
204
- },
205
- });
206
- ```
207
-
208
- Setting `bufferTokens: false` disables both observation and reflection async buffering. See [async buffering configuration](https://mastra.ai/reference/memory/observational-memory) for the full API.
209
-
210
- > **Note:** Async buffering is not supported with `scope: 'resource'`. It is automatically disabled in resource scope.
211
-
212
143
  ## Migrating existing threads
213
144
 
214
145
  No manual migration needed. OM reads existing messages and observes them lazily when thresholds are exceeded.
@@ -0,0 +1,221 @@
1
+ # Building a Code Review Bot
2
+
3
+ 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 learn how to create a workspace with a skills directory, define an [Agent Skill](https://agentskills.io) with review instructions and reference files, and connect it to an agent that performs automated reviews.
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js `v22.13.0` or later installed
8
+ - An API key from a supported [Model Provider](https://mastra.ai/models)
9
+ - An existing Mastra project (Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) to set up a new project)
10
+
11
+ ## Create the workspace
12
+
13
+ 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`.
14
+
15
+ ```typescript
16
+ import { Mastra } from '@mastra/core';
17
+ import { resolve } from 'node:path';
18
+ import { Workspace, LocalFilesystem } from '@mastra/core/workspace';
19
+
20
+ const workspace = new Workspace({
21
+ filesystem: new LocalFilesystem({
22
+ basePath: resolve(import.meta.dirname, '../../workspace'),
23
+ }),
24
+ skills: ['/skills'],
25
+ });
26
+
27
+ export const mastra = new Mastra({
28
+ workspace,
29
+ });
30
+ ```
31
+
32
+ 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.
33
+
34
+ ## Create the code standards skill
35
+
36
+ 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.
37
+
38
+ Inside `workspace/skills`, create a new folder called `code-standards`. Create a file called `SKILL.md` and add the review instructions.
39
+
40
+ ```markdown
41
+ ---
42
+ name: code-standards
43
+ description: Automated code review standards and checks
44
+ ---
45
+
46
+ # Code Review Standards
47
+
48
+ Review code systematically using these steps:
49
+
50
+ 1. **Critical Issues**: Security vulnerabilities, memory leaks, logic bugs, missing error handling
51
+ 2. **Code Quality**: Functions over 50 lines, code duplication, confusing names, missing types
52
+ 3. **Style Guide**: Check references/style-guide.md for naming and organization
53
+ 4. **Linting**: Flag common issues like use of `var`, leftover `console.log` statements, and `debugger` statements
54
+
55
+ Provide feedback in this format:
56
+
57
+ **Summary**: One sentence overview
58
+
59
+ **Critical Issues**: List with line numbers
60
+
61
+ **Suggestions**: Improvements that would help
62
+
63
+ **Positive Notes**: What the code does well
64
+ ```
65
+
66
+ 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`.
67
+
68
+ ````markdown
69
+ # Style Guide
70
+
71
+ ## Naming
72
+
73
+ - Variables/Functions: `camelCase`
74
+ - Constants: `UPPER_SNAKE_CASE`
75
+ - Files: `kebab-case.ts`
76
+ - Booleans: Start with `is`, `has`, `should`
77
+
78
+ ## Code Organization
79
+
80
+ ```typescript
81
+ // 1. Imports
82
+ import { foo } from 'bar';
83
+
84
+ // 2. Constants
85
+ const MAX_SIZE = 100;
86
+
87
+ // 3. Types
88
+ interface User { id: string; }
89
+
90
+ // 4. Functions
91
+ function doSomething() {}
92
+
93
+ // 5. Exports
94
+ export { doSomething };
95
+ ```
96
+
97
+ ## Error Handling
98
+
99
+ Always handle errors explicitly - never silently catch.
100
+
101
+ ## Comments
102
+
103
+ Write "why" not "what".
104
+ ````
105
+
106
+ ## Create the review agent
107
+
108
+ 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:
109
+
110
+ ```typescript
111
+ import { Agent } from '@mastra/core/agent';
112
+
113
+ export const codeReviewer = new Agent({
114
+ id: 'code-reviewer',
115
+ name: 'Code Review Bot',
116
+ instructions: `You are an automated code reviewer.
117
+
118
+ When asked to review code:
119
+ 1. Activate the 'code-standards' skill
120
+ 2. Follow the review process from the skill
121
+ 3. Check against the style guide in skill references
122
+ 4. Be constructive and specific with line numbers`,
123
+ model: 'openai/gpt-4o',
124
+ });
125
+ ```
126
+
127
+ Define the agent by importing it inside `src/mastra/index.ts` and registering it with the `Mastra` instance:
128
+
129
+ ```typescript
130
+ import { Mastra } from '@mastra/core';
131
+ import { resolve } from 'node:path';
132
+ import { Workspace, LocalFilesystem } from '@mastra/core/workspace';
133
+ import { codeReviewer } from './agents/code-reviewer';
134
+
135
+ const workspace = new Workspace({
136
+ filesystem: new LocalFilesystem({
137
+ basePath: resolve(import.meta.dirname, '../../workspace'),
138
+ }),
139
+ skills: ['/skills'],
140
+ });
141
+
142
+ export const mastra = new Mastra({
143
+ workspace,
144
+ agents: { codeReviewer },
145
+ });
146
+ ```
147
+
148
+ ## Test the bot
149
+
150
+ Start Mastra Studio and interact with the code review bot to see it in action.
151
+
152
+ **npm**:
153
+
154
+ ```bash
155
+ npm run dev
156
+ ```
157
+
158
+ **pnpm**:
159
+
160
+ ```bash
161
+ pnpm run dev
162
+ ```
163
+
164
+ **Yarn**:
165
+
166
+ ```bash
167
+ yarn dev
168
+ ```
169
+
170
+ **Bun**:
171
+
172
+ ```bash
173
+ bun run dev
174
+ ```
175
+
176
+ Open [localhost:4111](http://localhost:4111) and navigate to the code reviewer agent.
177
+
178
+ Inside the chat input, provide a code snippet for review, such as:
179
+
180
+ ```text
181
+ Review this code:
182
+
183
+ function getData(id) {
184
+ var result = fetch('/api/data/' + id);
185
+ console.log(result);
186
+ return result;
187
+ }
188
+ ```
189
+
190
+ 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:
191
+
192
+ ```md
193
+ **Summary**: Function has several issues with variable declaration,
194
+ debugging statements, and missing error handling.
195
+
196
+ **Critical Issues**:
197
+ - Missing error handling for fetch (line 2)
198
+ - No async/await for asynchronous operation (line 2)
199
+
200
+ **Suggestions**:
201
+ - Use const instead of var (line 2)
202
+ - Remove console.log before committing (line 3)
203
+ - Add TypeScript type for id parameter
204
+ - Use template literals instead of concatenation
205
+
206
+ **Positive Notes**:
207
+ - Function name is clear and descriptive
208
+ ```
209
+
210
+ ## Next steps
211
+
212
+ You can extend this bot to:
213
+
214
+ - Add skills for different languages or frameworks
215
+ - Create skills for security checks and performance reviews
216
+ - Integrate with GitHub Actions for automatic PR reviews
217
+ - Build a PR comment bot that leaves inline feedback
218
+
219
+ Learn more:
220
+
221
+ - [Agent Skills spec](https://agentskills.io)
@@ -0,0 +1,304 @@
1
+ # Building a Dev Assistant
2
+
3
+ In this guide, you'll build a complete development assistant that combines all workspace features:
4
+
5
+ - [Filesystem](https://mastra.ai/docs/workspace/filesystem) for file management
6
+ - [Sandbox](https://mastra.ai/docs/workspace/sandbox) for code execution
7
+ - [Skills](https://mastra.ai/docs/workspace/skills) for coding standards
8
+ - [Search](https://mastra.ai/docs/workspace/search) for finding examples
9
+
10
+ You'll set up a workspace with a sample project, add coding standards as a skill, and create an agent that writes code following TDD practices. By the end, you'll have an agent that can read existing code, write new implementations, run tests in a sandbox, and iterate based on results.
11
+
12
+ ## Prerequisites
13
+
14
+ - Node.js `v22.13.0` or later installed
15
+ - An API key from a supported [Model Provider](https://mastra.ai/models)
16
+ - An existing Mastra project (Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) to set up a new project)
17
+
18
+ ### Install vitest
19
+
20
+ The dev assistant will use [Vitest](https://vitest.dev/) to run tests inside the workspace sandbox. Install it as a dev dependency in your project:
21
+
22
+ **npm**:
23
+
24
+ ```bash
25
+ npm install -D vitest
26
+ ```
27
+
28
+ **pnpm**:
29
+
30
+ ```bash
31
+ pnpm add -D vitest
32
+ ```
33
+
34
+ **Yarn**:
35
+
36
+ ```bash
37
+ yarn add --dev vitest
38
+ ```
39
+
40
+ **Bun**:
41
+
42
+ ```bash
43
+ bun add --dev vitest
44
+ ```
45
+
46
+ ## Set up the workspace
47
+
48
+ The workspace uses a local filesystem to manage documentation files. The agent reads and writes files within the workspace directory. In your `src/mastra/index.ts` file, import the [`Workspace`](https://mastra.ai/reference/workspace/workspace-class), [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem), and [`LocalSandbox`](https://mastra.ai/reference/workspace/local-sandbox) classes.
49
+
50
+ Additionally, enable BM25 search indexing and load skills from the `skills` directory.
51
+
52
+ ```typescript
53
+ import { Mastra } from '@mastra/core';
54
+ import { resolve } from 'node:path';
55
+ import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace';
56
+
57
+ const workspace = new Workspace({
58
+ filesystem: new LocalFilesystem({ basePath: resolve(import.meta.dirname, '../../workspace') }),
59
+ sandbox: new LocalSandbox({ workingDirectory: resolve(import.meta.dirname, '../../workspace') }),
60
+ skills: ['/skills'],
61
+ bm25: true,
62
+ autoIndexPaths: ['/docs', '/src'],
63
+ });
64
+
65
+ export const mastra = new Mastra({
66
+ workspace,
67
+ });
68
+ ```
69
+
70
+ At the root of your project, create a new folder called `workspace`. This is where all files will be stored and managed by the agent.
71
+
72
+ ## Add sample project files
73
+
74
+ The workspace uses the following folder structure:
75
+
76
+ - `workspace/src/`: Source code for the sample project
77
+ - `workspace/tests/`: Test files
78
+ - `workspace/docs/`: Project documentation
79
+ - `workspace/skills/`: Coding standards and guidelines as [Agent Skills](https://agentskills.io)
80
+
81
+ Get started by creating a `workspace/src/utils/string-helpers.ts` file with some utility functions, and a corresponding test file in `workspace/tests/string-helpers.test.ts`.
82
+
83
+ ```typescript
84
+ export function capitalize(str: string): string {
85
+ if (!str) return str;
86
+ return str.charAt(0).toUpperCase() + str.slice(1);
87
+ }
88
+
89
+ export function slugify(str: string): string {
90
+ return str
91
+ .toLowerCase()
92
+ .replace(/[^\w\s-]/g, '')
93
+ .replace(/\s+/g, '-');
94
+ }
95
+ ```
96
+
97
+ ```typescript
98
+ import { describe, it, expect } from 'vitest';
99
+ import { capitalize, slugify } from '../src/utils/string-helpers';
100
+
101
+ describe('String Helpers', () => {
102
+ describe('capitalize', () => {
103
+ it('capitalizes first letter', () => {
104
+ expect(capitalize('hello')).toBe('Hello');
105
+ });
106
+ });
107
+
108
+ describe('slugify', () => {
109
+ it('converts to lowercase and replaces spaces', () => {
110
+ expect(slugify('Hello World')).toBe('hello-world');
111
+ });
112
+ });
113
+ });
114
+ ```
115
+
116
+ Create a skill definition at `workspace/skills/coding-standards/SKILL.md`. This tells the agent how to write and test code:
117
+
118
+ ```markdown
119
+ ---
120
+ name: coding-standards
121
+ description: Project coding standards and testing guidelines
122
+ ---
123
+
124
+ # Coding Standards
125
+
126
+ ## Code Quality
127
+ - Functions under 50 lines
128
+ - Use descriptive variable names
129
+ - Always add TypeScript types
130
+
131
+ ## Testing
132
+ - Test all exported functions
133
+ - Use AAA pattern: Arrange, Act, Assert
134
+ - Cover happy paths and edge cases
135
+
136
+ ## Before Committing
137
+ 1. Write implementation
138
+ 2. Write comprehensive tests
139
+ 3. Run tests: `npm test`
140
+ 4. All tests must pass
141
+ ```
142
+
143
+ Create a reference file at `workspace/skills/coding-standards/references/testing-guide.md` with detailed testing patterns:
144
+
145
+ ````markdown
146
+ # Testing Guide
147
+
148
+ ## AAA Pattern
149
+
150
+ ```typescript
151
+ it('descriptive test name', () => {
152
+ // Arrange: Set up test data
153
+ const input = 'test';
154
+
155
+ // Act: Execute the function
156
+ const result = doSomething(input);
157
+
158
+ // Assert: Verify the result
159
+ expect(result).toBe('expected');
160
+ });
161
+ ```
162
+
163
+ ## What to Test
164
+
165
+ - Happy paths (normal inputs)
166
+ - Edge cases (empty, null, boundary values)
167
+ - Error cases (invalid inputs, exceptions)
168
+ ````
169
+
170
+ ## Create the dev assistant
171
+
172
+ With the workspace set up, it's time to create the development assistant agent. This agent will have instructions for adding new features using test-driven development (TDD).
173
+
174
+ Create a new file `src/mastra/agents/dev-assistant.ts` and define the agent:
175
+
176
+ ```typescript
177
+ import { Agent } from '@mastra/core/agent';
178
+
179
+ export const devAssistant = new Agent({
180
+ id: 'dev-assistant',
181
+ name: 'Dev Assistant',
182
+ instructions: `You are a development assistant.
183
+
184
+ When adding features:
185
+ 1. Activate 'coding-standards' skill
186
+ 2. Search workspace for similar code examples
187
+ 3. Write the implementation following standards
188
+ 4. Write comprehensive tests. Leave existing tests in place, only add your new tests
189
+ 5. Execute the command \`npx vitest run\` to validate that all tests pass
190
+ 6. Update documentation if needed
191
+
192
+ For every new feature: Write code → Write tests → Run tests → Update docs
193
+
194
+ Always explain your reasoning and steps.`,
195
+ model: 'openai/gpt-4o',
196
+ });
197
+ ```
198
+
199
+ Define the agent by importing it inside `src/mastra/index.ts` and registering it with the `Mastra` instance:
200
+
201
+ ```typescript
202
+ import { Mastra } from '@mastra/core';
203
+ import { resolve } from 'node:path';
204
+ import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace';
205
+ import { devAssistant } from './agents/dev-assistant';
206
+
207
+ const workspace = new Workspace({
208
+ filesystem: new LocalFilesystem({ basePath: resolve(import.meta.dirname, '../../workspace') }),
209
+ sandbox: new LocalSandbox({ workingDirectory: resolve(import.meta.dirname, '../../workspace') }),
210
+ skills: ['/skills'],
211
+ bm25: true,
212
+ autoIndexPaths: ['/docs', '/src'],
213
+ });
214
+
215
+ export const mastra = new Mastra({
216
+ workspace,
217
+ agents: { devAssistant },
218
+ });
219
+ ```
220
+
221
+ ## Test the assistant
222
+
223
+ Start Mastra Studio and interact with the agent to see it in action.
224
+
225
+ **npm**:
226
+
227
+ ```bash
228
+ npm run dev
229
+ ```
230
+
231
+ **pnpm**:
232
+
233
+ ```bash
234
+ pnpm run dev
235
+ ```
236
+
237
+ **Yarn**:
238
+
239
+ ```bash
240
+ yarn dev
241
+ ```
242
+
243
+ **Bun**:
244
+
245
+ ```bash
246
+ bun run dev
247
+ ```
248
+
249
+ Open [localhost:4111](http://localhost:4111) and navigate to the dev assistant.
250
+
251
+ Try asking the agent to add a new function using TDD:
252
+
253
+ ```text
254
+ Add a 'truncate' function to string-helpers.ts that shortens strings to a max length. Add '...' if truncated.
255
+
256
+ Follow TDD: write tests first, then implementation.
257
+ ```
258
+
259
+ Since agent responses are non-deterministic, the exact output will vary. However, you should see the agent follow a process similar to this:
260
+
261
+ 1. Activate the coding-standards skill
262
+
263
+ 2. Search the workspace for similar code patterns
264
+
265
+ 3. Write tests first, for example:
266
+
267
+ ```typescript
268
+ describe('truncate', () => {
269
+ it('truncates long strings', () => {
270
+ expect(truncate('Hello World', 5)).toBe('He...');
271
+ });
272
+
273
+ it('keeps short strings unchanged', () => {
274
+ expect(truncate('Hi', 10)).toBe('Hi');
275
+ });
276
+
277
+ it('handles edge cases', () => {
278
+ expect(truncate('', 5)).toBe('');
279
+ });
280
+ });
281
+ ```
282
+
283
+ 4. Write the implementation, for example:
284
+
285
+ ```typescript
286
+ export function truncate(str: string, maxLength: number): string {
287
+ if (!str || maxLength < 0) return str;
288
+ if (str.length <= maxLength) return str;
289
+ if (maxLength === 0) return '...';
290
+ return str.slice(0, maxLength - 3) + '...';
291
+ }
292
+ ```
293
+
294
+ 5. Run tests and verify they pass
295
+
296
+ ## Next steps
297
+
298
+ You can extend this assistant to:
299
+
300
+ - Add more skills for different languages or frameworks
301
+ - Create specialized agents for backend, frontend, or DevOps
302
+ - Integrate with GitHub for automated PR reviews
303
+ - Build CI/CD automation
304
+ - Add multi-agent workflows