Co-authored-by: Max Tuzzolino <maxtuzz@Maxs-MacBook-Pro.local>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Max Tuzzolino <max.tuzsmith@gmail.com>
Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com>
This commit is contained in:
Eyal Toledano
2025-09-19 18:08:20 -04:00
committed by GitHub
parent 4e126430a0
commit fce841490a
55 changed files with 3559 additions and 693 deletions

View File

@@ -8,6 +8,12 @@ import {
type TaskListResult as ListTasksResult,
type GetTaskListOptions
} from './services/task-service.js';
import {
TaskExecutionService,
type StartTaskOptions,
type StartTaskResult,
type ConflictCheckResult
} from './services/task-execution-service.js';
import { ERROR_CODES, TaskMasterError } from './errors/task-master-error.js';
import type { IConfiguration } from './interfaces/configuration.interface.js';
import type {
@@ -16,6 +22,12 @@ import type {
TaskFilter,
StorageType
} from './types/index.js';
import {
ExecutorService,
type ExecutorServiceOptions,
type ExecutionResult,
type ExecutorType
} from './executors/index.js';
/**
* Options for creating TaskMasterCore instance
@@ -26,10 +38,15 @@ export interface TaskMasterCoreOptions {
}
/**
* Re-export result types from TaskService
* Re-export result types from services
*/
export type { TaskListResult as ListTasksResult } from './services/task-service.js';
export type { GetTaskListOptions } from './services/task-service.js';
export type {
StartTaskOptions,
StartTaskResult,
ConflictCheckResult
} from './services/task-execution-service.js';
/**
* TaskMasterCore facade class
@@ -38,6 +55,8 @@ export type { GetTaskListOptions } from './services/task-service.js';
export class TaskMasterCore {
private configManager: ConfigManager;
private taskService: TaskService;
private taskExecutionService: TaskExecutionService;
private executorService: ExecutorService | null = null;
/**
* Create and initialize a new TaskMasterCore instance
@@ -60,6 +79,7 @@ export class TaskMasterCore {
// Services will be initialized in the initialize() method
this.configManager = null as any;
this.taskService = null as any;
this.taskExecutionService = null as any;
}
/**
@@ -86,6 +106,9 @@ export class TaskMasterCore {
// Create task service
this.taskService = new TaskService(this.configManager);
await this.taskService.initialize();
// Create task execution service
this.taskExecutionService = new TaskExecutionService(this.taskService);
} catch (error) {
throw new TaskMasterError(
'Failed to initialize TaskMasterCore',
@@ -175,6 +198,85 @@ export class TaskMasterCore {
await this.configManager.setActiveTag(tag);
}
// ==================== Task Execution Methods ====================
/**
* Start working on a task with comprehensive business logic
*/
async startTask(
taskId: string,
options: StartTaskOptions = {}
): Promise<StartTaskResult> {
return this.taskExecutionService.startTask(taskId, options);
}
/**
* Check if a task can be started (no conflicts)
*/
async canStartTask(taskId: string, force = false): Promise<boolean> {
return this.taskExecutionService.canStartTask(taskId, force);
}
/**
* Check for existing in-progress tasks and determine conflicts
*/
async checkInProgressConflicts(
targetTaskId: string
): Promise<ConflictCheckResult> {
return this.taskExecutionService.checkInProgressConflicts(targetTaskId);
}
/**
* Get task with subtask resolution
*/
async getTaskWithSubtask(
taskId: string
): Promise<{ task: Task | null; subtask?: any; subtaskId?: string }> {
return this.taskExecutionService.getTaskWithSubtask(taskId);
}
/**
* Get the next available task to start
*/
async getNextAvailableTask(): Promise<string | null> {
return this.taskExecutionService.getNextAvailableTask();
}
// ==================== Executor Service Methods ====================
/**
* Initialize executor service (lazy initialization)
*/
private getExecutorService(): ExecutorService {
if (!this.executorService) {
const executorOptions: ExecutorServiceOptions = {
projectRoot: this.configManager.getProjectRoot()
};
this.executorService = new ExecutorService(executorOptions);
}
return this.executorService;
}
/**
* Execute a task
*/
async executeTask(
task: Task,
executorType?: ExecutorType
): Promise<ExecutionResult> {
const executor = this.getExecutorService();
return executor.executeTask(task, executorType);
}
/**
* Stop the current task execution
*/
async stopCurrentTask(): Promise<void> {
if (this.executorService) {
await this.executorService.stopCurrentTask();
}
}
/**
* Update task status
*/
@@ -195,6 +297,10 @@ export class TaskMasterCore {
* Close and cleanup resources
*/
async close(): Promise<void> {
// Stop any running executors
if (this.executorService) {
await this.executorService.stopCurrentTask();
}
// TaskService handles storage cleanup internally
}
}