todo_management
Manage tasks for SRT subtitle processing workflows. Create, update, and track tasks across parsing, translation, and quality check stages to monitor progress.
Instructions
Manage tasks for SRT processing workflows.
WHAT IT DOES:
Create, update, and track tasks during SRT processing
Monitor progress across different processing stages
Manage task priorities and dependencies
ACTIONS:
create: Create a new task
update: Update task status
complete: Mark task as completed
list: List all tasks
get_status: Get overall task status
TASK TYPES:
srt_parse: Parse and validate SRT file
conversation_detect: Detect conversation chunks
chunk_optimize: Optimize chunks for AI processing
ai_process: Process with AI model
translate: Translate content
quality_check: Quality assurance
output_generate: Generate final output
EXAMPLE USAGE:
Create task: {"action": "create", "taskType": "srt_parse", "title": "Parse SRT file", "priority": "high"}
Update status: {"action": "update", "taskId": "task-123", "status": "completed"}
List tasks: {"action": "list"}
Get status: {"action": "get_status"}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Todo action to perform | |
| taskType | No | Type of task | |
| title | No | Task title | |
| description | No | Task description | |
| priority | No | Task priority | medium |
| taskId | No | Task ID (for update/complete actions) | |
| status | No | Task status (for update action) | |
| metadata | No | Additional task metadata |
Implementation Reference
- src/mcp/server.ts:309-382 (registration)Tool registration including name, description, and input schema definition for todo_management.{ name: 'todo_management', description: `Manage tasks for SRT processing workflows. WHAT IT DOES: - Create, update, and track tasks during SRT processing - Monitor progress across different processing stages - Manage task priorities and dependencies ACTIONS: - create: Create a new task - update: Update task status - complete: Mark task as completed - list: List all tasks - get_status: Get overall task status TASK TYPES: - srt_parse: Parse and validate SRT file - conversation_detect: Detect conversation chunks - chunk_optimize: Optimize chunks for AI processing - ai_process: Process with AI model - translate: Translate content - quality_check: Quality assurance - output_generate: Generate final output EXAMPLE USAGE: 1. Create task: {"action": "create", "taskType": "srt_parse", "title": "Parse SRT file", "priority": "high"} 2. Update status: {"action": "update", "taskId": "task-123", "status": "completed"} 3. List tasks: {"action": "list"} 4. Get status: {"action": "get_status"}`, inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['create', 'update', 'complete', 'list', 'get_status'], description: 'Todo action to perform', }, taskType: { type: 'string', enum: ['srt_parse', 'conversation_detect', 'chunk_optimize', 'ai_process', 'translate', 'quality_check', 'output_generate'], description: 'Type of task', }, title: { type: 'string', description: 'Task title', }, description: { type: 'string', description: 'Task description', }, priority: { type: 'string', enum: ['low', 'medium', 'high', 'urgent'], description: 'Task priority', default: 'medium', }, taskId: { type: 'string', description: 'Task ID (for update/complete actions)', }, status: { type: 'string', enum: ['pending', 'in_progress', 'completed', 'failed', 'cancelled'], description: 'Task status (for update action)', }, metadata: { type: 'object', description: 'Additional task metadata', }, }, required: ['action'], }, },
- src/mcp/server.ts:725-806 (handler)Main handler function that processes todo_management tool calls by dispatching to different actions using the todoManager.private async handleTodoManagement(args: any) { const { action, taskType, title, description, priority, taskId, status, metadata } = args; switch (action) { case 'create': if (!taskType || !title) { throw new Error('taskType and title are required for create action'); } const todo = await this.todoManager.createSRTProcessingTodos( title, 1, 'translation' ); return { content: [ { type: 'text', text: JSON.stringify({ success: true, todo }, null, 2), }, ], }; case 'update': if (!taskId || !status) { throw new Error('taskId and status are required for update action'); } // Note: SRTProcessingTodoManager doesn't have direct update method // This is a placeholder for the actual implementation console.log(`Updating todo ${taskId} to status ${status}`); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: 'Todo updated' }, null, 2), }, ], }; case 'complete': if (!taskId) { throw new Error('taskId is required for complete action'); } // Note: SRTProcessingTodoManager doesn't have direct complete method // This is a placeholder for the actual implementation console.log(`Completing todo ${taskId}`); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: 'Todo completed' }, null, 2), }, ], }; case 'list': // Use the todo manager's getTodosByStage method const todos = await this.todoManager.getTodosByStage('all'); return { content: [ { type: 'text', text: JSON.stringify({ success: true, todos }, null, 2), }, ], }; case 'get_status': // Use the todo manager's getProcessingStatistics method const statistics = await this.todoManager.getProcessingStatistics(); return { content: [ { type: 'text', text: JSON.stringify({ success: true, status: statistics }, null, 2), }, ], }; default: throw new Error(`Unknown action: ${action}`); } }
- SRTProcessingTodoManager class providing methods like createSRTProcessingTodos, getTodosByStage, getProcessingStatistics used by the todo_management handler.export class SRTProcessingTodoManager { private todoTool: TodoToolInterface; private modelType: string; constructor(modelType: string) { this.modelType = modelType; this.todoTool = TodoToolFactory.createTodoTool(modelType); } /** * Create comprehensive SRT processing todos */ async createSRTProcessingTodos( fileName: string, chunkCount: number, processingType: 'translation' | 'analysis' | 'conversation-detection', targetLanguage?: string ): Promise<TodoListResult> { const todos: Omit<TodoItem, 'id' | 'createdAt' | 'updatedAt'>[] = []; // Add file analysis todos todos.push(...SRTTodoTemplates.createFileAnalysisTodos(fileName)); // Add chunk detection todos todos.push(...SRTTodoTemplates.createChunkDetectionTodos(chunkCount)); // Add chunk optimization todos todos.push(...SRTTodoTemplates.createChunkOptimizationTodos(chunkCount, this.modelType)); // Add processing-specific todos switch (processingType) { case 'translation': if (targetLanguage) { todos.push(...SRTTodoTemplates.createTranslationTodos(chunkCount, targetLanguage)); } break; case 'analysis': todos.push(...SRTTodoTemplates.createAnalysisTodos(chunkCount)); break; case 'conversation-detection': // Already covered by chunk detection todos break; } // Add validation todos todos.push(...SRTTodoTemplates.createValidationTodos(chunkCount)); return this.todoTool.createTodoList(todos as TodoItem[]); } /** * Update processing progress */ async updateProcessingProgress( stage: 'file-analysis' | 'chunk-detection' | 'chunk-optimization' | 'processing' | 'validation', status: TodoStatus ): Promise<void> { const todos = await this.todoTool.getTodoList(); const stageTodos = todos.filter(todo => todo.metadata?.processingContext?.processingType === stage ); for (const todo of stageTodos) { await this.todoTool.updateTodoStatus(todo.id, status); } } /** * Get processing statistics */ async getProcessingStatistics(): Promise<TodoStatistics> { return this.todoTool.getTodoStatistics(); } /** * Get todos by processing stage */ async getTodosByStage(stage: string): Promise<TodoItem[]> { const todos = await this.todoTool.getTodoList(); if (stage === 'all') { return todos; } return todos.filter(todo => todo.metadata?.processingContext?.processingType === stage ); } }
- UniversalTodoTool implementing the core in-memory todo storage and operations (Map-based), used by SRTProcessingTodoManager.export class UniversalTodoTool implements TodoToolInterface { private todos: Map<string, TodoItem> = new Map(); private todoCounter = 0; private modelType: string; constructor(modelType: string = 'generic') { this.modelType = modelType; } /** * Create todo list */ async createTodoList(todos: TodoItem[]): Promise<TodoListResult> { const todoIds: string[] = []; const warnings: string[] = []; for (const todo of todos) { try { const createdTodo = await this.addTodo(todo); todoIds.push(createdTodo.id); } catch (error) { warnings.push(`Failed to create todo: ${error instanceof Error ? error.message : 'Unknown error'}`); } } return { success: todoIds.length > 0, todoIds, message: `Created ${todoIds.length} todos for ${this.modelType}`, warnings: warnings.length > 0 ? warnings : undefined }; } /** * Add single todo */ async addTodo(todo: Omit<TodoItem, 'id' | 'createdAt' | 'updatedAt'>): Promise<TodoItem> { const id = `${this.modelType}-todo-${++this.todoCounter}`; const now = new Date(); const newTodo: TodoItem = { ...todo, id, createdAt: now, updatedAt: now }; this.todos.set(id, newTodo); console.log(`[DEBUG] Added todo ${id}, total todos: ${this.todos.size}`); return newTodo; } /** * Update todo status */ async updateTodoStatus(todoId: string, status: TodoStatus): Promise<boolean> { const todo = this.todos.get(todoId); if (!todo) return false; todo.status = status; todo.updatedAt = new Date(); if (status === 'completed') { todo.completedAt = new Date(); } this.todos.set(todoId, todo); return true; } /** * Get todo list */ async getTodoList(): Promise<TodoItem[]> { console.log(`[DEBUG] getTodoList called, todos count: ${this.todos.size}`); const todos = Array.from(this.todos.values()); console.log(`[DEBUG] returning ${todos.length} todos`); return todos; } /** * Mark todo as complete */ async markTodoComplete(todoId: string): Promise<boolean> { return this.updateTodoStatus(todoId, 'completed'); } /** * Get todo by ID */ async getTodoById(todoId: string): Promise<TodoItem | null> { return this.todos.get(todoId) || null; } /** * Delete todo */ async deleteTodo(todoId: string): Promise<boolean> { return this.todos.delete(todoId); } /** * Update todo */ async updateTodo(todoId: string, updates: Partial<TodoItem>): Promise<TodoItem | null> { const todo = this.todos.get(todoId); if (!todo) return null; const updatedTodo = { ...todo, ...updates, id: todoId, // Preserve ID updatedAt: new Date() }; this.todos.set(todoId, updatedTodo); return updatedTodo; } /** * Search todos */ async searchTodos(query: string): Promise<TodoItem[]> { const allTodos = Array.from(this.todos.values()); const searchTerm = query.toLowerCase(); return allTodos.filter(todo => todo.content.toLowerCase().includes(searchTerm) || todo.category.toLowerCase().includes(searchTerm) || (todo.tags && todo.tags.some(tag => tag.toLowerCase().includes(searchTerm))) ); } /** * Get todos by category */ async getTodosByCategory(category: string): Promise<TodoItem[]> { const allTodos = Array.from(this.todos.values()); return allTodos.filter(todo => todo.category === category); } /** * Get todos by status */ async getTodosByStatus(status: TodoStatus): Promise<TodoItem[]> { const allTodos = Array.from(this.todos.values()); return allTodos.filter(todo => todo.status === status); } /** * Get todos by priority */ async getTodosByPriority(priority: TodoPriority): Promise<TodoItem[]> { const allTodos = Array.from(this.todos.values()); return allTodos.filter(todo => todo.priority === priority); } /** * Get todo statistics */ async getTodoStatistics(): Promise<TodoStatistics> { const allTodos = Array.from(this.todos.values()); const stats: TodoStatistics = { total: allTodos.length, pending: allTodos.filter(t => t.status === 'pending').length, inProgress: allTodos.filter(t => t.status === 'in_progress').length, completed: allTodos.filter(t => t.status === 'completed').length, cancelled: allTodos.filter(t => t.status === 'cancelled').length, blocked: allTodos.filter(t => t.status === 'blocked').length, byPriority: { low: allTodos.filter(t => t.priority === 'low').length, medium: allTodos.filter(t => t.priority === 'medium').length, high: allTodos.filter(t => t.priority === 'high').length, critical: allTodos.filter(t => t.priority === 'critical').length }, byCategory: {} }; // Calculate category distribution const categories = [...new Set(allTodos.map(t => t.category))]; categories.forEach(category => { stats.byCategory[category] = allTodos.filter(t => t.category === category).length; }); // Calculate completion rate if (stats.total > 0) { stats.completionRate = stats.completed / stats.total; } // Calculate average completion time for completed todos const completedTodos = allTodos.filter(t => t.status === 'completed' && t.completedAt); if (completedTodos.length > 0) { const totalTime = completedTodos.reduce((sum, todo) => { if (todo.completedAt && todo.createdAt) { return sum + (todo.completedAt.getTime() - todo.createdAt.getTime()); } return sum; }, 0); stats.averageCompletionTime = totalTime / completedTodos.length; } return stats; } }