From d75430c4d862bc878678a92e60cdfc5b21fe25c9 Mon Sep 17 00:00:00 2001 From: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com> Date: Tue, 7 Oct 2025 18:52:33 +0200 Subject: [PATCH] fix: resolve TypeScript typecheck errors in Phase 0 implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix git-utils import in PreflightChecker using require() with type casting - Fix ConfigManager initialization in TaskLoaderService (use async factory) - Fix TaskService.getTask return type (returns Task | null directly) - Export PreflightChecker and TaskLoaderService from @tm/core - Fix unused parameter and type annotations in autopilot command - Add boolean fallback for optional dryRun parameter All turbo:typecheck errors resolved. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/cli/src/commands/autopilot.command.ts | 11 ++++----- packages/tm-core/src/index.ts | 11 +++++++++ .../src/services/preflight-checker.service.ts | 18 +++++++++++---- .../src/services/task-loader.service.ts | 23 ++++++++++++++----- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/apps/cli/src/commands/autopilot.command.ts b/apps/cli/src/commands/autopilot.command.ts index 3cf0c53a..112847cf 100644 --- a/apps/cli/src/commands/autopilot.command.ts +++ b/apps/cli/src/commands/autopilot.command.ts @@ -97,7 +97,7 @@ export class AutopilotCommand extends Command { spinner.succeed(`Task ${taskId} loaded`); // Display task information - this.displayTaskInfo(task, options.dryRun); + this.displayTaskInfo(task, options.dryRun || false); // Execute autopilot logic (placeholder for now) const result = await this.performAutopilot(taskId, task, options); @@ -260,7 +260,7 @@ export class AutopilotCommand extends Command { console.log(); // Display subtasks - orderedSubtasks.forEach((subtask, index) => { + orderedSubtasks.forEach((subtask: any, index: number) => { console.log( chalk.yellow( `${index + 1}. ${validationResult.task!.id}.${subtask.id}: ${subtask.title}` @@ -337,7 +337,7 @@ export class AutopilotCommand extends Command { case 'text': default: - this.displayTextResult(result, options); + this.displayTextResult(result); break; } } @@ -352,10 +352,7 @@ export class AutopilotCommand extends Command { /** * Display result in text format */ - private displayTextResult( - result: AutopilotCommandResult, - options: AutopilotCommandOptions - ): void { + private displayTextResult(result: AutopilotCommandResult): void { if (result.success) { console.log( boxen( diff --git a/packages/tm-core/src/index.ts b/packages/tm-core/src/index.ts index 0f96f694..a8517d0c 100644 --- a/packages/tm-core/src/index.ts +++ b/packages/tm-core/src/index.ts @@ -72,3 +72,14 @@ export { type ComplexityAnalysis, type TaskComplexityData } from './reports/index.js'; + +// Re-export services +export { + PreflightChecker, + TaskLoaderService, + type CheckResult, + type PreflightResult, + type TaskValidationResult, + type ValidationErrorType, + type DependencyIssue +} from './services/index.js'; diff --git a/packages/tm-core/src/services/preflight-checker.service.ts b/packages/tm-core/src/services/preflight-checker.service.ts index 4eae7daa..62e9b074 100644 --- a/packages/tm-core/src/services/preflight-checker.service.ts +++ b/packages/tm-core/src/services/preflight-checker.service.ts @@ -6,13 +6,21 @@ import { readFileSync } from 'fs'; import { join } from 'path'; import { execSync } from 'child_process'; -import { - isGitRepository, - isGhCliAvailable, - getDefaultBranch -} from '../../../../scripts/modules/utils/git-utils.js'; import { getLogger } from '../logger/factory.js'; +// Import git utilities (JS module without type definitions) +// eslint-disable-next-line @typescript-eslint/no-var-requires +const gitUtils = require('../../../../scripts/modules/utils/git-utils.js'); +const isGitRepository = gitUtils.isGitRepository as ( + projectRoot: string +) => Promise; +const isGhCliAvailable = gitUtils.isGhCliAvailable as ( + projectRoot: string +) => Promise; +const getDefaultBranch = gitUtils.getDefaultBranch as ( + projectRoot: string +) => Promise; + const logger = getLogger('PreflightChecker'); /** diff --git a/packages/tm-core/src/services/task-loader.service.ts b/packages/tm-core/src/services/task-loader.service.ts index d377f634..675280e8 100644 --- a/packages/tm-core/src/services/task-loader.service.ts +++ b/packages/tm-core/src/services/task-loader.service.ts @@ -57,7 +57,7 @@ export interface DependencyIssue { * TaskLoaderService loads and validates tasks for autopilot execution */ export class TaskLoaderService { - private taskService: TaskService; + private taskService: TaskService | null = null; private projectRoot: string; constructor(projectRoot: string) { @@ -65,10 +65,17 @@ export class TaskLoaderService { throw new Error('projectRoot is required for TaskLoaderService'); } this.projectRoot = projectRoot; + } - // Initialize TaskService with ConfigManager - const configManager = new ConfigManager(projectRoot); + /** + * Ensure TaskService is initialized + */ + private async ensureInitialized(): Promise { + if (this.taskService) return; + + const configManager = await ConfigManager.create(this.projectRoot); this.taskService = new TaskService(configManager); + await this.taskService.initialize(); } /** @@ -126,8 +133,11 @@ export class TaskLoaderService { */ private async loadTask(taskId: string): Promise { try { - const result = await this.taskService.getTask(taskId); - return result.task || null; + await this.ensureInitialized(); + if (!this.taskService) { + throw new Error('TaskService initialization failed'); + } + return await this.taskService.getTask(taskId); } catch (error) { logger.error(`Failed to load task ${taskId}:`, error); return null; @@ -384,6 +394,7 @@ export class TaskLoaderService { * Clean up resources */ async cleanup(): Promise { - await this.taskService.close(); + // TaskService doesn't require explicit cleanup + // Resources are automatically released when instance is garbage collected } }