Skip to content

Commit 6f820a4

Browse files
committed
fix: update AgentProfile type structure and Zod API
- Update code for AgentProfile type structure changes and Zod API updates - Change AgentProfile type structure (role as object, add description) - Update Zod API usage (result.error.errors → result.error.issues) - Update McpService to use new AgentProfile structure - Update test mock data to match new type structure refs #113
1 parent ac76090 commit 6f820a4

4 files changed

Lines changed: 23 additions & 14 deletions

File tree

apps/mcp-server/src/mcp/mcp.service.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ const createMockRulesService = (): Partial<RulesService> => ({
8181
.mockResolvedValue(['frontend-developer', 'code-reviewer']),
8282
getRuleContent: vi.fn().mockResolvedValue('# Core Rules\nSome content...'),
8383
getAgent: vi.fn().mockResolvedValue({
84-
id: 'frontend-developer',
8584
name: 'Frontend Developer',
86-
role: 'Frontend development specialist',
87-
goals: ['Write clean code', 'Follow best practices'],
88-
workflow: ['Analyze requirements', 'Implement solution'],
85+
description: 'Frontend development specialist',
86+
role: {
87+
title: 'Senior Frontend Developer',
88+
expertise: ['React', 'TypeScript'],
89+
responsibilities: ['Write clean code', 'Follow best practices'],
90+
},
8991
}),
9092
searchRules: vi.fn().mockResolvedValue([]),
9193
});

apps/mcp-server/src/mcp/mcp.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,17 @@ export class McpService implements OnModuleInit {
274274
const settings = await this.configService.getSettings();
275275
const projectContext = this.formatProjectContext(settings);
276276

277+
const expertise = agent.role.expertise.join(', ');
278+
const responsibilities =
279+
agent.role.responsibilities?.join('\n- ') ?? '';
280+
277281
return {
278282
messages: [
279283
{
280284
role: 'user',
281285
content: {
282286
type: 'text',
283-
text: `Activate Agent: ${agent.name}\n\nRole: ${agent.role}\n\nGoals:\n${agent.goals.join('\n')}\n\nWorkflow:\n${agent.workflow.join('\n')}\n\n${projectContext}\n\nCore Rules Context:\n${coreRules.substring(0, 1000)}... (truncated)`,
287+
text: `Activate Agent: ${agent.name}\n\nDescription: ${agent.description}\n\nRole: ${agent.role.title}\nExpertise: ${expertise}\n\nResponsibilities:\n- ${responsibilities}\n\n${projectContext}\n\nCore Rules Context:\n${coreRules.substring(0, 1000)}... (truncated)`,
284288
},
285289
},
286290
],

apps/mcp-server/src/rules/agent.schema.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ export function parseAgentProfile(data: unknown): ValidatedAgentProfile {
130130
const result = AgentProfileSchema.safeParse(data);
131131

132132
if (!result.success) {
133-
const errorMessage = result.error.errors
134-
.map(e => {
135-
const path = e.path.length > 0 ? e.path.join('.') : 'root';
136-
return `${path}: ${e.message}`;
133+
const errorMessage = result.error.issues
134+
.map(issue => {
135+
const pathStr = issue.path.length > 0 ? issue.path.join('.') : 'root';
136+
return `${pathStr}: ${issue.message}`;
137137
})
138138
.join(', ');
139139
throw new AgentSchemaError(

apps/mcp-server/src/rules/rules.types.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
export interface AgentProfile {
22
name: string;
3-
role: string;
4-
expertise: string[];
5-
goals: string[];
6-
workflow: string[];
7-
output_format: string;
3+
description: string;
4+
role: {
5+
title: string;
6+
expertise: string[];
7+
tech_stack_reference?: string;
8+
responsibilities?: string[];
9+
};
10+
[key: string]: unknown; // Allow additional fields (passthrough)
811
}
912

1013
export interface SearchResult {

0 commit comments

Comments
 (0)