UNPKG

agency-x

Version:

This project is a Claude-compatible, LLM-agnostic sub-agent framework that simulates a complete SaaS product team. It is delivered as a reusable, developer-ready NPM package.

38 lines (31 loc) 1.27 kB
import { createLogger } from '../utils/logger'; import { getContext, updateContext } from '../utils/contextStore'; import { getLlmClient } from '../llm/llmRouter'; import { aiPromptEngineerPrompt, jsonRepairPrompt } from '../utils/promptTemplates'; const logger = createLogger('aiPromptEngineer'); export const runAiPromptEngineer = async () => { logger.start(); const context = getContext(); const { spec } = context; const llmClient = getLlmClient(); const prompt = aiPromptEngineerPrompt.replace('{{spec}}', JSON.stringify(spec, null, 2)); let response = await llmClient.generate(prompt); let prompts; try { prompts = JSON.parse(response); } catch (error) { logger.error('Invalid JSON response from LLM. Attempting to repair...'); const repairPrompt = jsonRepairPrompt.replace('{{invalidJson}}', response); response = await llmClient.generate(repairPrompt); try { prompts = JSON.parse(response); } catch (error) { logger.error('Failed to repair JSON response. Skipping AI prompt generation.'); return; } } updateContext({ agents: { ...context.agents, aiPromptEngineer: { output: prompts, completed: true } } }); logger.stop(); logger.success('Generated AI prompts.'); return prompts; };