summaryrefslogtreecommitdiff
path: root/admin-panel/src/server/agents/critic.ts
diff options
context:
space:
mode:
Diffstat (limited to 'admin-panel/src/server/agents/critic.ts')
-rw-r--r--admin-panel/src/server/agents/critic.ts55
1 files changed, 55 insertions, 0 deletions
diff --git a/admin-panel/src/server/agents/critic.ts b/admin-panel/src/server/agents/critic.ts
new file mode 100644
index 0000000..b0613fb
--- /dev/null
+++ b/admin-panel/src/server/agents/critic.ts
@@ -0,0 +1,55 @@
+import { BaseAgent, type AgentContext, type AgentResult } from './base-agent.js';
+import type { ClaudeResponse } from '../services/claude.service.js';
+
+export class CriticAgent extends BaseAgent {
+ name = 'critic';
+ templateFile = 'critic.md';
+ model = 'claude-sonnet-4-20250514';
+
+ protected getSystemPrompt(): string {
+ return 'You are a thorough plan reviewer. Be constructive but rigorous. Approve plans that are solid enough to implement, reject plans with significant gaps or flaws.';
+ }
+
+ protected parseResponse(response: ClaudeResponse, ctx: AgentContext): AgentResult {
+ const content = response.content;
+ const firstLine = content.split('\n')[0].trim().toUpperCase();
+ const approved = firstLine.includes('APPROVE');
+ const rejected = firstLine.includes('REJECT');
+ const verdict: 'approve' | 'reject' = approved ? 'approve' : 'reject';
+
+ // Build review entry
+ const reviewEntry = {
+ agent: 'critic',
+ verdict,
+ content,
+ timestamp: new Date().toISOString(),
+ };
+
+ const updates: Record<string, unknown> = {};
+ const currentReviews = ctx.reviewComments ? JSON.parse(ctx.reviewComments || '[]') : [];
+ currentReviews.push(reviewEntry);
+ updates.plan_review_comments = JSON.stringify(currentReviews);
+
+ if (approved) {
+ updates.status = 'impl';
+ updates.plan_review_count = (ctx as unknown as Record<string, number>).plan_review_count
+ ? (ctx as unknown as Record<string, number>).plan_review_count + 1
+ : 1;
+ } else if (rejected) {
+ updates.status = 'plan'; // Send back to planning
+ updates.plan_review_count = (ctx as unknown as Record<string, number>).plan_review_count
+ ? (ctx as unknown as Record<string, number>).plan_review_count + 1
+ : 1;
+ }
+
+ return {
+ success: true,
+ content,
+ tokensUsed: response.tokensUsed,
+ model: response.model,
+ updates,
+ verdict,
+ message: `Plan review: ${verdict.toUpperCase()}`,
+ };
+ }
+}