@memory-bank/mcp
Version:
Memory-enabled Co-Pilot (MCP) server for managing project documentation and context
47 lines • 1.71 kB
JavaScript
import { ApplicationError, ApplicationErrorCodes, } from '../../../shared/errors/ApplicationError.js';
/**
* Use case for getting recent branches
*/
export class GetRecentBranchesUseCase {
branchRepository;
/**
* Constructor
* @param branchRepository Branch memory bank repository
*/
constructor(branchRepository) {
this.branchRepository = branchRepository;
}
/**
* Execute the use case
* @param input Input data
* @returns Promise resolving to output data
*/
async execute(input) {
try {
const limit = input.limit ?? 10;
if (limit < 1) {
throw new ApplicationError(ApplicationErrorCodes.INVALID_INPUT, 'Limit must be a positive number');
}
const recentBranches = await this.branchRepository.getRecentBranches(limit);
const branchDTOs = recentBranches.map((branch) => ({
name: branch.branchInfo.name,
lastModified: branch.lastModified.toISOString(),
summary: {
currentWork: branch.summary.currentWork,
recentChanges: branch.summary.recentChanges,
},
}));
return {
branches: branchDTOs,
total: branchDTOs.length,
};
}
catch (error) {
if (error instanceof ApplicationError) {
throw error;
}
throw new ApplicationError(ApplicationErrorCodes.USE_CASE_EXECUTION_FAILED, `Failed to get recent branches: ${error.message}`, { originalError: error });
}
}
}
//# sourceMappingURL=GetRecentBranchesUseCase.js.map