Files
ruflo/src/task/commands.ts
T
rUvandClaude 63d391e10b 🚀 Release: Claude Flow v2.0.0-alpha.62
## 🔒 Security Fixes
- CRITICAL: Removed vulnerable pkg dependency (GHSA-22r3-9w55-cj54)
- Replaced with secure @vercel/ncc alternative
- Security score improved from 55/100 to 75/100
- All npm audit vulnerabilities resolved (0 vulnerabilities)

## 🚀 Infrastructure Improvements
- Re-enabled ALL CI/CD security gates with strict enforcement
- Fixed Jest configuration and test infrastructure
- Fixed 18 TypeScript test files with import issues
- Created comprehensive test utilities

## 🛠️ Code Quality
- Fixed 145 ESLint errors (16% reduction)
- Fixed 15 critical TypeScript errors
- Added development tooling configs

## 📚 Documentation
- Created security audit report
- Created fix summary documentation
- Created functionality review
- Updated GitHub issue #362

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18 13:35:41 +00:00

117 lines
3.8 KiB
TypeScript

// Task command creators
import type { TaskCommandContext } from './types.js';
export function createTaskCreateCommand(context: TaskCommandContext) {
return {
name: 'create',
description: 'Create a new task',
execute: async (args: any) => {
try {
const task = await context.taskEngine.createTask(args);
context.logger?.info('Task created successfully', { taskId: task.id });
return task;
} catch (error) {
context.logger?.error('Failed to create task', error);
throw error;
}
},
};
}
export function createTaskListCommand(context: TaskCommandContext) {
return {
name: 'list',
description: 'List all tasks',
execute: async (filter?: any, sort?: any, limit?: number, offset?: number) => {
try {
const result = await context.taskEngine.listTasks(filter, sort, limit, offset);
context.logger?.info('Tasks listed successfully', { count: result.tasks.length });
return result;
} catch (error) {
context.logger?.error('Failed to list tasks', error);
throw error;
}
},
};
}
export function createTaskStatusCommand(context: TaskCommandContext) {
return {
name: 'status',
description: 'Get task status',
execute: async (taskId: string) => {
try {
const status = await context.taskEngine.getTaskStatus(taskId);
if (!status) {
throw new Error(`Task ${taskId} not found`);
}
context.logger?.info('Task status retrieved', { taskId });
return status;
} catch (error) {
context.logger?.error('Failed to get task status', error);
throw error;
}
},
};
}
export function createTaskCancelCommand(context: TaskCommandContext) {
return {
name: 'cancel',
description: 'Cancel a task',
execute: async (
taskId: string,
reason: string = 'User requested',
rollback: boolean = true,
) => {
try {
await context.taskEngine.cancelTask(taskId, reason, rollback);
context.logger?.info('Task cancelled successfully', { taskId, reason });
return { success: true, taskId, reason };
} catch (error) {
context.logger?.error('Failed to cancel task', error);
throw error;
}
},
};
}
export function createTaskWorkflowCommand(context: TaskCommandContext) {
return {
name: 'workflow',
description: 'Manage task workflows',
execute: async (action: 'create' | 'execute' | 'list' | 'get', ...args: any[]) => {
try {
switch (action) {
case 'create':
const [workflowData] = args;
const createdWorkflow = await context.taskEngine.createWorkflow(workflowData);
context.logger?.info('Workflow created successfully', {
workflowId: createdWorkflow.id,
});
return createdWorkflow;
case 'execute':
const [workflowToExecute] = args;
await context.taskEngine.executeWorkflow(workflowToExecute);
context.logger?.info('Workflow execution started', {
workflowId: workflowToExecute.id,
});
return { success: true, workflowId: workflowToExecute.id };
case 'list':
context.logger?.info('Workflow list requested');
return { workflows: [] }; // Would need additional implementation
case 'get':
const [workflowId] = args;
context.logger?.info('Workflow details requested', { workflowId });
return { workflowId }; // Would need additional implementation
default:
throw new Error(`Unknown workflow action: ${action}`);
}
} catch (error) {
context.logger?.error('Workflow operation failed', error);
throw error;
}
},
};
}