UNPKG

adpa-enterprise-framework-automation

Version:

Modular, standards-compliant Node.js/TypeScript automation framework for enterprise requirements, project, and data management. Provides CLI and API for BABOK v3, PMBOK 7th Edition, and DMBOK 2.0 (in progress). Production-ready Express.js API with TypeSpe

74 lines (70 loc) 2.93 kB
import { AIProcessor } from '../../ai/AIProcessor.js'; import { CorevaluesTemplate } from '../basic-docs/CorevaluesTemplate.js'; class ExpectedError extends Error { constructor(message) { super(message); this.name = 'ExpectedError'; } } /** * Processor for the Corevalues document. */ export class CorevaluesProcessor { aiProcessor; constructor() { this.aiProcessor = AIProcessor.getInstance(); } async process(context) { try { const prompt = this.createPrompt(context); const content = await this.aiProcessor.makeAICall([ { role: 'system', content: 'You are an expert consultant specializing in basic docs documentation. Generate comprehensive, professional content based on the project context.' }, { role: 'user', content: prompt } ]).then(res => typeof res === 'string' ? res : res.content); await this.validateOutput(content); return { title: 'Corevalues', content }; } catch (error) { if (error instanceof ExpectedError) { console.warn('Expected error in Corevalues processing:', error.message); throw new Error(`Failed to generate Corevalues: ${error.message}`); } else { console.error('Unexpected error in Corevalues processing:', error); throw new Error('An unexpected error occurred while generating Corevalues'); } } } createPrompt(context) { // Get the template as an example structure const template = new CorevaluesTemplate(context); const exampleStructure = template.generateContent(); return `Based on the following project context, generate a comprehensive Corevalues document. Project Context: - Name: ${context.projectName || 'Untitled Project'} - Type: ${context.projectType || 'Not specified'} - Description: ${context.description || 'No description provided'} Use this structure as a reference (but customize the content for the specific project): ${exampleStructure} Important Instructions: - Make the content specific to the project context provided - Ensure the language is professional and appropriate for the document type - Include practical guidance where applicable - Focus on what makes this project unique - Use markdown formatting for proper structure - Keep content concise but comprehensive`; } async validateOutput(content) { if (!content || content.trim().length === 0) { throw new ExpectedError('Generated content is empty'); } // Basic validation - ensure content has some structure if (!content.includes('#')) { throw new ExpectedError('Generated content lacks proper markdown structure'); } } } //# sourceMappingURL=CorevaluesProcessor.js.map