import { Command } from 'commander'; import { BaseCommand } from './BaseCommand'; import { MentorFeedbackUseCaseImpl } from '../../domain/usecases/MentorFeedbackUseCase'; export class MentorCommand extends BaseCommand { constructor() { super('mentor', 'Provide educational feedback and mentorship'); this.option('--tone ', 'Feedback tone (mentor,strict,friendly,technical)', 'mentor') .option('--level ', 'Developer level (beginner,intermediate,advanced)', 'intermediate') .option('--focus ', 'Focus areas (code-quality,best-practices,architecture,testing,security,performance)') .option('--include-examples', 'Include code examples in feedback') .option('--include-learning-resources', 'Include learning resources and references') .option('--max-feedback ', 'Maximum number of feedback items', '20'); } protected async execute(options: any, command: Command): Promise { const useCase = new MentorFeedbackUseCaseImpl( this.gitAdapter, this.llmAdapter, this.outputAdapter ); const mentorOptions: any = { baseRef: options.baseRef, headRef: options.headRef, includeStaged: options.staged, includeUnstaged: options.unstaged, filePatterns: this.parseFilePatterns(options.filePatterns) || [], excludePatterns: this.parseExcludePatterns(options.excludePatterns) || [], outputFormat: this.getOutputFormat(options) as 'html' | 'json' | 'markdown' | 'console' | 'file', tone: options.tone, level: options.level, focus: options.focus ? options.focus.split(',') : undefined, includeExamples: options.includeExamples, includeLearningResources: options.includeLearningResources, }; const outputPath = this.getOutputPath(options); if (outputPath) { mentorOptions.outputPath = outputPath; } if (this.isVerbose(options)) { console.log('Generating mentor feedback...'); console.log('Options:', mentorOptions); } try { const feedback = await useCase.execute(mentorOptions); if (this.isVerbose(options)) { console.log(`Generated ${feedback.length} mentor feedback items.`); } } catch (error) { throw new Error(`Mentor feedback generation failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } } }