-
Notifications
You must be signed in to change notification settings - Fork 5
Add Mastra system-prompt example wrapper #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Mastra system-prompt example wrapper #40
Conversation
- Convert Mastra Harry Potter character agent to Agentuity wrapper - Preserve all original Mastra framework code and patterns - Add welcome() function with character prompts - Implement proper error handling with ctx.logger - Follow existing frameworks/ directory conventions Co-Authored-By: Dhilan Fye <dfye@agentuity.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
WalkthroughIntroduces a new Mastra-based “system-prompt” example wrapped with Agentuity. Adds project scaffolding and configs, a startup runner that validates environment variables and boots the Agentuity runner, a HarryPotterAgent implementing character-based responses via Mastra/Anthropic, and documentation describing setup and usage. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Agentuity as Agentuity Runner
participant HPAgent as HarryPotterAgent
participant Mastra as Mastra Agent
participant LLM as Anthropic Claude
User->>Agentuity: AgentRequest (text)
Agentuity->>HPAgent: Invoke handler(req, resp, ctx)
HPAgent->>HPAgent: Parse input / fallback sample
HPAgent->>Mastra: Construct Agent (model: Claude, instructions)
Mastra->>LLM: Generate(text, maxSteps=3)
LLM-->>Mastra: Result (text)
Mastra-->>HPAgent: result.text or undefined
alt result.text present
HPAgent->>Agentuity: resp.text(result)
else error or missing text
HPAgent->>Agentuity: resp.text(fallback/error)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (7)
frameworks/mastra/system-prompt/biome.json (1)
12-15: Lock formatter width for deterministic diffs.Set
indentWidthto avoid editor defaults drifting formatting."formatter": { "enabled": true, - "indentStyle": "space" + "indentStyle": "space", + "indentWidth": 2 },frameworks/mastra/system-prompt/tsconfig.json (1)
10-11: Composite + noEmit is unusual here.
"composite": trueis mainly for project references and typically paired with emitting declarations. If this package isn’t referenced by others via TS project refs, consider disabling to simplify.- "composite": true, + "composite": false,frameworks/mastra/system-prompt/index.ts (1)
16-29: Use yellow for warnings to distinguish from errors.ANSI 33 (yellow) is clearer for warnings than 31 (red).
- '\x1b[31m[WARN] You are running this agent outside of the Agentuity environment. Any automatic Agentuity features will be disabled.\x1b[0m' + '\x1b[33m[WARN] You are running this agent outside of the Agentuity environment. Any automatic Agentuity features will be disabled.\x1b[0m' ... - '\x1b[31m[WARN] Recommend running `agentuity dev` to run your project locally instead of bun run start.\x1b[0m' + '\x1b[33m[WARN] Recommend running `agentuity dev` to run your project locally instead of bun run start.\x1b[0m' ... - '\x1b[31m[WARN] Recommend running `agentuity dev` to run your project locally instead of npm start.\x1b[0m' + '\x1b[33m[WARN] Recommend running `agentuity dev` to run your project locally instead of npm start.\x1b[0m'frameworks/mastra/system-prompt/package.json (1)
1-31: Declare Bun engine for clarity.Since
startrequires Bun, add an engines field."private": true, + "engines": { + "bun": ">=1.1.0" + },frameworks/mastra/system-prompt/src/agents/HarryPotterAgent/index.ts (2)
28-29: Confirm model slug availability.Validate that
anthropic('claude-3-7-sonnet-latest')is a valid identifier in your deployed environment/SDK version; consider making it configurable via env for easier upgrades.
51-53: Improve error logging for debuggability.Prefer structured logging to preserve stack/fields rather than string interpolation.
-} catch (error) { - ctx.logger.error(`HarryPotterAgent Error: ${error}`); +} catch (error) { + ctx.logger.error({ error }, 'HarryPotterAgent error');frameworks/mastra/system-prompt/README.md (1)
11-15: Tighten list punctuation and step formatting.Minor Markdown/grammar nits to improve readability.
- - **Character-based responses**: The agent can respond as Harry Potter, Hermione Granger, or Ron Weasley - - **System prompt demonstration**: Shows how Mastra's system prompts can change agent behavior - - **Preserved framework code**: All original Mastra Agent creation and configuration is maintained - - **Agentuity integration**: Proper error handling, logging, and response formatting + - **Character-based responses**: The agent can respond as Harry Potter, Hermione Granger, or Ron Weasley. + - **System prompt demonstration**: Shows how Mastra's system prompts can change agent behavior. + - **Preserved framework code**: All original Mastra Agent creation and configuration is maintained. + - **Agentuity integration**: Proper error handling, logging, and response formatting. -1. Receives input through Agentuity's `AgentRequest` -2. Creates a Mastra `Agent` with character-specific instructions -3. Generates a response using the original Mastra framework -4. Returns the result through Agentuity's `AgentResponse` +1. Receives input through Agentuity's `AgentRequest`. +2. Creates a Mastra `Agent` with character-specific instructions. +3. Generates a response using the original Mastra framework. +4. Returns the result through Agentuity's `AgentResponse`. - - Uses `@mastra/core/agent` for agent creation - - Preserves the original `Agent` constructor with `name`, `model`, and `instructions` - - Keeps the original `agent.generate()` method call - - Maintains all Mastra-specific configuration and behavior + - Uses `@mastra/core/agent` for agent creation. + - Preserves the original `Agent` constructor with `name`, `model`, and `instructions`. + - Keeps the original `agent.generate()` method call. + - Maintains all Mastra-specific configuration and behavior. - - `@mastra/core`: Core Mastra framework - - `@ai-sdk/anthropic`: Anthropic AI SDK for Claude models - - `@agentuity/sdk`: Agentuity SDK for wrapper functionality + - `@mastra/core`: Core Mastra framework. + - `@ai-sdk/anthropic`: Anthropic AI SDK for Claude models. + - `@agentuity/sdk`: Agentuity SDK for wrapper functionality.Also applies to: 20-24, 35-39, 61-64
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
frameworks/mastra/system-prompt/bun.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
frameworks/mastra/system-prompt/.gitignore(1 hunks)frameworks/mastra/system-prompt/README.md(1 hunks)frameworks/mastra/system-prompt/agentuity.yaml(1 hunks)frameworks/mastra/system-prompt/biome.json(1 hunks)frameworks/mastra/system-prompt/index.ts(1 hunks)frameworks/mastra/system-prompt/package.json(1 hunks)frameworks/mastra/system-prompt/src/agents/HarryPotterAgent/index.ts(1 hunks)frameworks/mastra/system-prompt/tsconfig.json(1 hunks)
🧰 Additional context used
🧠 Learnings (19)
📚 Learning: 2025-07-17T13:38:58.657Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/Startup_News_Scraper/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-07-17T13:38:58.657Z
Learning: Applies to agents/Startup_News_Scraper/**/src/agents/**/index.ts : Prefer loading types from the node modules package `agentuity/sdk` in the node_modules folder
Applied to files:
frameworks/mastra/system-prompt/index.ts
📚 Learning: 2025-06-23T17:15:21.314Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/mastra/basic/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:15:21.314Z
Learning: For best practices in Agentuity SDK projects, use TypeScript for type safety, import types from agentuity/sdk, use structured error handling with try/catch, leverage the provided logger, use storage APIs for data persistence, and consider agent communication for complex workflows.
Applied to files:
frameworks/mastra/system-prompt/index.ts
📚 Learning: 2025-06-23T17:16:49.315Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/vercel/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:16:49.315Z
Learning: When writing an Agent in TypeScript for Agentuity, always use the types provided by the `agentuity/sdk` package for AgentRequest, AgentResponse, and AgentContext to ensure type safety and compatibility.
Applied to files:
frameworks/mastra/system-prompt/src/agents/HarryPotterAgent/index.ts
📚 Learning: 2025-06-23T17:14:39.393Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langgraph/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:14:39.393Z
Learning: In Agentuity AI Agent files (`**/src/agents/**/index.ts`), the default export should be an async function that handles the agent logic, typically accepting parameters `(req: AgentRequest, resp: AgentResponse, ctx: AgentContext)`.
Applied to files:
frameworks/mastra/system-prompt/src/agents/HarryPotterAgent/index.ts
📚 Learning: 2025-06-23T17:16:08.480Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/openai/from-oai-typescript/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:16:08.480Z
Learning: In the Agentuity JavaScript SDK, the main handler for an agent should implement the AgentHandler type: (request: AgentRequest, response: AgentResponse, context: AgentContext) => Promise<AgentResponseType>.
Applied to files:
frameworks/mastra/system-prompt/src/agents/HarryPotterAgent/index.ts
📚 Learning: 2025-06-23T17:15:21.314Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/mastra/basic/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:15:21.314Z
Learning: In the Agentuity JavaScript SDK, the main handler for an agent should implement the AgentHandler type: a function that takes (request: AgentRequest, response: AgentResponse, context: AgentContext) and returns a Promise of AgentResponseType.
Applied to files:
frameworks/mastra/system-prompt/src/agents/HarryPotterAgent/index.ts
📚 Learning: 2025-06-23T17:14:46.802Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langgraph/basic/.cursor/rules/sdk.mdc:0-0
Timestamp: 2025-06-23T17:14:46.802Z
Learning: The Agentuity JavaScript SDK provides core interfaces such as AgentHandler, AgentRequest, AgentResponse, and AgentContext for building AI agents in TypeScript or JavaScript.
Applied to files:
frameworks/mastra/system-prompt/src/agents/HarryPotterAgent/index.ts
📚 Learning: 2025-06-23T17:15:12.561Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/mastra/basic/.cursor/rules/agent.mdc:0-0
Timestamp: 2025-06-23T17:15:12.561Z
Learning: In Agentuity AI Agent files (`**/src/agents/**/index.ts`), import types such as `AgentRequest`, `AgentResponse`, and `AgentContext` from the `agentuity/sdk` package to ensure type safety and consistency.
Applied to files:
frameworks/mastra/system-prompt/src/agents/HarryPotterAgent/index.ts
📚 Learning: 2025-06-23T17:16:33.550Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/pydantic/basic/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:16:33.550Z
Learning: The agentuity.yaml file is a configuration file used by Agentuity to configure the AI Agent project and should not be edited or suggested for edits during code review.
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
📚 Learning: 2025-06-23T17:16:16.519Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/openai/from-oai/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:16:16.519Z
Learning: The Agentuity configuration file (agentuity.yaml) is reserved for configuring the AI Agent project and should not be edited or suggested for edits during code review.
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
📚 Learning: 2025-06-23T17:13:52.368Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/crewai/socialagent/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:13:52.368Z
Learning: The 'agentuity.yaml' file is a configuration file used by Agentuity to configure the AI Agent project and should not be edited or suggested for edits.
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
📚 Learning: 2025-06-23T17:14:18.092Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/langchain/basic/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:14:18.092Z
Learning: The file 'agentuity.yaml' is used to configure the Agentuity AI Agent project and should not be edited or suggested for edits.
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
📚 Learning: 2025-06-23T17:15:46.735Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/miscellaneous/mem0/mem0demo/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:15:46.735Z
Learning: The Agentuity configuration file (agentuity.yaml) is used to configure the AI Agent project and should not be edited or suggested for edits.
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
📚 Learning: 2025-06-23T17:15:30.804Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/miscellaneous/grokLiveSearch/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:15:30.804Z
Learning: In the context of Agentuity AI projects, the 'agentuity.yaml' file is a configuration file that should not be edited or suggested for edits during code review.
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
📚 Learning: 2025-07-17T13:41:01.314Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/agno/from_agno/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-07-17T13:41:01.314Z
Learning: Applies to frameworks/agno/from_agno/**/agentuity.yaml : Do not suggest edits to the Agentuity AI Configuration file (agentuity.yaml)
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
📚 Learning: 2025-07-17T13:39:39.665Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/composio/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-07-17T13:39:39.665Z
Learning: Applies to agents/composio/**/agentuity.yaml : Do NOT suggest edits to the Agentuity AI Configuration file (agentuity.yaml)
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
📚 Learning: 2025-07-17T13:39:58.483Z
Learnt from: CR
PR: agentuity/examples#0
File: agents/deep-research-js/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-07-17T13:39:58.483Z
Learning: Applies to agents/deep-research-js/**/agentuity.yaml : Do not suggest edits to the agentuity.yaml configuration file
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
📚 Learning: 2025-06-23T17:17:12.992Z
Learnt from: CR
PR: agentuity/examples#0
File: patterns/llmAsJury/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:17:12.992Z
Learning: In the context of Agentuity AI projects, the agentuity.yaml file is a configuration file that should not be edited or suggested for edits during code review.
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
📚 Learning: 2025-06-23T17:16:02.063Z
Learnt from: CR
PR: agentuity/examples#0
File: frameworks/openai/from-oai-typescript/.cursor/rules/agentuity.mdc:0-0
Timestamp: 2025-06-23T17:16:02.063Z
Learning: The Agentuity AI Configuration file (agentuity.yaml) is used to configure the AI Agent project and should not be edited or suggested for edits.
Applied to files:
frameworks/mastra/system-prompt/agentuity.yaml
🪛 LanguageTool
frameworks/mastra/system-prompt/README.md
[grammar] ~20-~20: There might be a mistake here.
Context: ... 1. Receives input through Agentuity's AgentRequest 2. Creates a Mastra Agent with character-...
(QB_NEW_EN)
[grammar] ~21-~21: There might be a mistake here.
Context: ...nt` with character-specific instructions 3. Generates a response using the original ...
(QB_NEW_EN)
[grammar] ~22-~22: There might be a mistake here.
Context: ...onse using the original Mastra framework 4. Returns the result through Agentuity's `...
(QB_NEW_EN)
[grammar] ~35-~35: There might be a mistake here.
Context: ... @mastra/core/agent for agent creation - Preserves the original Agent construct...
(QB_NEW_EN)
[grammar] ~36-~36: There might be a mistake here.
Context: ...constructor withname, model, and instructions- Keeps the originalagent.generate()` me...
(QB_NEW_EN)
[grammar] ~37-~37: There might be a mistake here.
Context: ... original agent.generate() method call - Maintains all Mastra-specific configurat...
(QB_NEW_EN)
[grammar] ~61-~61: There might be a mistake here.
Context: ... - @mastra/core: Core Mastra framework - @ai-sdk/anthropic: Anthropic AI SDK for Claude models - `...
(QB_NEW_EN)
[grammar] ~62-~62: There might be a mistake here.
Context: ...pic: Anthropic AI SDK for Claude models - @agentuity/sdk`: Agentuity SDK for wrapper functionalit...
(QB_NEW_EN)
🔇 Additional comments (7)
frameworks/mastra/system-prompt/index.ts (2)
1-1: LGTM on using the SDK runner.Import path and usage align with other examples; error handling is present.
31-39: Confirmed runner signature and baseDir usage
- frameworks/mastra/system-prompt/package.json (line 24) is pinned to
@agentuity/sdk@^0.0.116.- frameworks/mastra/system-prompt/index.ts (line 31) invokes
runner(true, import.meta.dirname), i.e. abooleanand the example’s root directory.No changes required.
frameworks/mastra/system-prompt/.gitignore (1)
132-134: Nice: Agentuity artifacts ignored.Including
.agentuity/prevents noise and accidental commits.frameworks/mastra/system-prompt/package.json (2)
6-13: Scripts align with Agentuity/Bun flow.Build/dev/bundle/start look consistent for this example.
24-29: Dependency versions are already alignedAll five dependencies in
frameworks/mastra/system-prompt/package.jsonmatch exactly with those inframeworks/mastra/basic/package.json, so no further changes are needed.frameworks/mastra/system-prompt/src/agents/HarryPotterAgent/index.ts (1)
5-14: Helper looks good and is useful for UX.
welcome()is concise and aligns with the example prompts.frameworks/mastra/system-prompt/agentuity.yaml (1)
1-74: Config acknowledged (no edits suggested).Per project guidelines, not suggesting changes to Agentuity config. Looks consistent with the new agent.
| "vcs": { | ||
| "enabled": false, | ||
| "clientKind": "git", | ||
| "useIgnoreFile": false | ||
| }, | ||
| "files": { | ||
| "ignoreUnknown": false, | ||
| "ignore": [] | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Biome isn’t honoring .gitignore; add VCS ignores or explicit ignores to avoid linting .agentuity output.
With vcs.enabled: false and useIgnoreFile: false, Biome will not respect .gitignore. Once agentuity bundle creates .agentuity/, biome lint . may scan it and produce noise. Recommend enabling VCS ignores or explicitly ignoring build artifacts (at least .agentuity, dist, coverage).
Apply:
"vcs": {
- "enabled": false,
+ "enabled": true,
"clientKind": "git",
- "useIgnoreFile": false
+ "useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
- "ignore": []
+ "ignore": [".agentuity", "dist", "coverage"]
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "vcs": { | |
| "enabled": false, | |
| "clientKind": "git", | |
| "useIgnoreFile": false | |
| }, | |
| "files": { | |
| "ignoreUnknown": false, | |
| "ignore": [] | |
| }, | |
| "vcs": { | |
| "enabled": true, | |
| "clientKind": "git", | |
| "useIgnoreFile": true | |
| }, | |
| "files": { | |
| "ignoreUnknown": false, | |
| "ignore": [".agentuity", "dist", "coverage"] | |
| }, |
🤖 Prompt for AI Agents
frameworks/mastra/system-prompt/biome.json lines 3-11: Biome is configured with
vcs.enabled: false and useIgnoreFile: false so it will not respect .gitignore
and may lint generated artifacts like .agentuity; update the configuration to
either enable VCS ignore handling (set "vcs.enabled": true or "useIgnoreFile":
true) or add explicit ignores (add ".agentuity", "dist", "coverage" to the
"files.ignore" array) so those build/test artifacts are excluded from linting.
| const cmd = process.env._ || ''; | ||
| if (cmd.endsWith('node')) { | ||
| console.error( | ||
| '\x1b[31m[ERROR] Re-run the command with `node --env-file .env index.ts`\x1b[0m' | ||
| ); | ||
| } | ||
| process.exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect recovery tip: Node can’t run TypeScript directly.
The suggestion to re-run with node --env-file .env index.ts won’t work without a loader (tsx/ts-node). Provide actionable guidance that matches this repo’s flow.
- const cmd = process.env._ || '';
- if (cmd.endsWith('node')) {
- console.error(
- '\x1b[31m[ERROR] Re-run the command with `node --env-file .env index.ts`\x1b[0m'
- );
- }
+ console.error(
+ '\x1b[31m[ERROR] Use `agentuity dev` (recommended) or `bun --env-file .env run index.ts`.\x1b[0m'
+ );📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const cmd = process.env._ || ''; | |
| if (cmd.endsWith('node')) { | |
| console.error( | |
| '\x1b[31m[ERROR] Re-run the command with `node --env-file .env index.ts`\x1b[0m' | |
| ); | |
| } | |
| process.exit(1); | |
| console.error( | |
| '\x1b[31m[ERROR] Use `agentuity dev` (recommended) or `bun --env-file .env run index.ts`.\x1b[0m' | |
| ); | |
| process.exit(1); |
🤖 Prompt for AI Agents
In frameworks/mastra/system-prompt/index.ts around lines 7 to 13, the error
message suggests re-running Node on a .ts file directly which is invalid; update
the message to provide actionable, repo-accurate guidance: replace the current
tip with one that tells users to either run the TypeScript with the project’s
supported loader (e.g., tsx or ts-node) or run the compiled JavaScript (e.g.,
node dist/index.js), and/or invoke the repository’s provided script
(npm/yarn/pnpm start or dev) — keep the exit(1) but ensure the message
references the supported run options used by this repo.
| runner(true, import.meta.dirname).catch((err) => { | ||
| if (err instanceof Error) { | ||
| console.error(err.message); | ||
| console.error(err.stack); | ||
| } else { | ||
| console.error(err); | ||
| } | ||
| process.exit(1); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Make import.meta dirname cross-runtime safe (Bun and Node ESM).
import.meta.dirname is Bun-specific. Outside Bun, prefer fileURLToPath(import.meta.url).
+import { fileURLToPath } from 'node:url';
+import path from 'node:path';
@@
-runner(true, import.meta.dirname).catch((err) => {
+const baseDir =
+ typeof (import.meta as any).dirname === 'string'
+ ? (import.meta as any).dirname
+ : path.dirname(fileURLToPath(import.meta.url));
+
+runner(true, baseDir).catch((err) => {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| runner(true, import.meta.dirname).catch((err) => { | |
| if (err instanceof Error) { | |
| console.error(err.message); | |
| console.error(err.stack); | |
| } else { | |
| console.error(err); | |
| } | |
| process.exit(1); | |
| }); | |
| import { fileURLToPath } from 'node:url'; | |
| import path from 'node:path'; | |
| const baseDir = | |
| typeof (import.meta as any).dirname === 'string' | |
| ? (import.meta as any).dirname | |
| : path.dirname(fileURLToPath(import.meta.url)); | |
| runner(true, baseDir).catch((err) => { | |
| if (err instanceof Error) { | |
| console.error(err.message); | |
| console.error(err.stack); | |
| } else { | |
| console.error(err); | |
| } | |
| process.exit(1); | |
| }); |
🤖 Prompt for AI Agents
In frameworks/mastra/system-prompt/index.ts around lines 31 to 39, the code uses
Bun-only import.meta.dirname which breaks on other ESM runtimes; replace it with
a cross-runtime solution that falls back to Node-compatible file URL conversion:
compute a dirname by using import.meta.dirname when defined, otherwise derive it
with path.dirname(fileURLToPath(import.meta.url)); ensure you import
fileURLToPath from 'url' and path from 'path' at the top, then pass that dirname
into runner(true, dirname).
| @@ -0,0 +1,55 @@ | |||
| import type { AgentContext, AgentRequest, AgentResponse } from '@agentuity/sdk'; | |||
| import { anthropic } from '@ai-sdk/anthropic'; | |||
| import { Agent } from '@mastra/core/agent'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix symbol shadowing: function name ‘Agent’ collides with imported class ‘Agent’.
At runtime, new Agent(...) would reference the function, not the Mastra class. Alias the import (or rename the function) to avoid a hard failure.
-import { Agent } from '@mastra/core/agent';
+import { Agent as MastraAgent } from '@mastra/core/agent';
@@
- const agent = new Agent({
+ const agent = new MastraAgent({Also applies to: 27-27
🤖 Prompt for AI Agents
In frameworks/mastra/system-prompt/src/agents/HarryPotterAgent/index.ts around
lines 3 and 27, the local function named "Agent" shadows the imported class
Agent causing new Agent(...) to reference the function rather than the class;
rename one of them to avoid collision (for example alias the import: import {
Agent as MastraAgent } from '@mastra/core/agent' and update usages that should
instantiate the class to MastraAgent, or rename the local function to clarifying
name) and run a quick search/replace to update all references accordingly so
instantiation and type references point to the correct symbol.
|
Closing due to inactivity for more than 30 days. Configure here. |
Add Mastra system-prompt example wrapper
Summary
This PR adds a new Mastra framework example that demonstrates system prompts by implementing a Harry Potter character agent. The agent can respond as different characters (Harry, Hermione, Ron) with their distinctive personalities, showcasing how Mastra's system prompts can change agent behavior.
Key changes:
frameworks/mastra/system-prompt/directory with complete project structureHarryPotterAgentthat preserves ALL original Mastra framework codewelcome()function and proper error handlingThe implementation converts the Mastra system-prompt example into an Agentuity wrapper while preserving the original framework patterns:
@mastra/core/agentfor agent creationAgentconstructor withname,model,instructionsagent.generate()method callReview & Testing Checklist for Human
agentuity devand verifying the agent responds correctly to character-specific promptsNotes
frameworks/mastra/basic/example for consistencySession requested by: Dhilan Fye (dfye@agentuity.com)
Link to Devin run: https://app.devin.ai/sessions/9476b6e4087942e1b116279d7fb2a98f
Summary by CodeRabbit
New Features
Documentation
Chores