feat: real agent execution + real skill execution (system-prompt-driven)
- delegate_agent: now makes actual AI call with role-specific system prompts (coder=code review, architect=system design, devops=infrastructure) - run_skill: now makes actual AI call with skill-specific system prompts (code_review, bug_fix, refactor, documentation, testing) - Both return structured AI-generated results instead of placeholder text
This commit is contained in:
@@ -563,12 +563,50 @@ export async function initBot(config, api, tools, skills, agents) {
|
||||
delegate_agent: async (args) => {
|
||||
const agent = svc.agents.find(a => a.id === args.agent_id);
|
||||
if (!agent) return `❌ Agent not found: ${args.agent_id}`;
|
||||
return `✅ Delegated to **${agent.name}**: "${args.task}"`;
|
||||
|
||||
// Actually execute the task with an agent-specific system prompt
|
||||
const agentPrompts = {
|
||||
coder: 'You are an expert code reviewer. Analyze the code for bugs, security issues, performance problems, and style improvements. Be specific and actionable.',
|
||||
architect: 'You are a system architect. Analyze the request from an architecture perspective — patterns, scalability, maintainability, trade-offs. Provide clear recommendations.',
|
||||
devops: 'You are a DevOps engineer. Focus on deployment, CI/CD, infrastructure, monitoring, and reliability. Provide practical, copy-paste-ready solutions.',
|
||||
};
|
||||
|
||||
try {
|
||||
const systemMsg = agentPrompts[agent.id] || `You are ${agent.name}. ${agent.description}`;
|
||||
const agentMessages = [
|
||||
{ role: 'system', content: systemMsg },
|
||||
{ role: 'user', content: args.task },
|
||||
];
|
||||
const result = await chatWithAI(agentMessages, { maxTokens: 4096 });
|
||||
return `🤖 **${agent.name}**:\n${result}`;
|
||||
} catch (e) {
|
||||
return `❌ Agent ${agent.name} error: ${e.message}`;
|
||||
}
|
||||
},
|
||||
run_skill: async (args) => {
|
||||
const skill = svc.skills.find(s => s.name === args.skill);
|
||||
if (!skill) return `❌ Skill not found: ${args.skill}`;
|
||||
return `✅ Skill **${skill.name}** queued: ${args.input || '(none)'}`;
|
||||
|
||||
// Execute skill with a specialized system prompt
|
||||
const skillPrompts = {
|
||||
code_review: 'You are a code review expert. Analyze the provided code for: bugs, security vulnerabilities, performance issues, style problems, and improvements. Structure your review with severity levels (critical/warning/info).',
|
||||
bug_fix: 'You are a debugging expert. Analyze the bug report and code, identify root cause, and provide a specific fix with explanation. Include edge cases.',
|
||||
refactor: 'You are a refactoring specialist. Improve code quality while preserving behavior. Focus on: readability, DRY, SOLID principles, naming, and structure. Show before/after.',
|
||||
documentation: 'You are a technical writer. Generate clear, comprehensive documentation from the provided code. Include: purpose, parameters, return values, examples, and edge cases.',
|
||||
testing: 'You are a testing expert. Generate thorough tests for the provided code. Include: unit tests, edge cases, error cases. Use assertions with clear descriptions.',
|
||||
};
|
||||
|
||||
try {
|
||||
const systemMsg = skillPrompts[skill.name] || `You are a ${skill.name} expert. ${skill.description}`;
|
||||
const skillMessages = [
|
||||
{ role: 'system', content: systemMsg },
|
||||
{ role: 'user', content: args.input || 'Please analyze the code and provide your expert review.' },
|
||||
];
|
||||
const result = await chatWithAI(skillMessages, { maxTokens: 4096 });
|
||||
return `📚 **${skill.name}**:\n${result}`;
|
||||
} catch (e) {
|
||||
return `❌ Skill ${skill.name} error: ${e.message}`;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user