UNPKG

mcp-adr-analysis-server

Version:

MCP server for analyzing Architectural Decision Records and project architecture

214 lines 7.15 kB
/** * MCP Tasks Integration for Bootstrap Validation Loop * * This module provides standardized task tracking for the bootstrap validation loop tool, * implementing ADR-020: MCP Tasks Integration Strategy. * * Key features: * - Creates MCP Tasks for bootstrap operations * - Tracks progress through phases (platform_detection, infrastructure, application, validation) * - Supports cancellation between phases * - Migrates from custom executionId to standardized taskId * * @see ADR-020: MCP Tasks Integration Strategy * @see https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/tasks */ import { type AdrTask, type TaskResult, type TaskManager } from './task-manager.js'; /** * Bootstrap phases that map to MCP Task phases */ export declare const BOOTSTRAP_PHASES: readonly ["platform_detection", "infrastructure_setup", "application_deployment", "validation", "cleanup"]; export type BootstrapPhase = (typeof BOOTSTRAP_PHASES)[number]; /** * Bootstrap task context for tracking state across iterations */ export interface BootstrapTaskContext { taskId: string; currentPhase: BootstrapPhase; iteration: number; maxIterations: number; cancelled: boolean; platformDetected?: string; infrastructureResult?: { success: boolean; executedTasks: string[]; failedTasks: string[]; }; } /** * Options for creating a bootstrap task */ export interface CreateBootstrapTaskOptions { projectPath: string; adrDirectory: string; targetEnvironment: string; maxIterations: number; autoFix: boolean; updateAdrsWithLearnings: boolean; } /** * Result from bootstrap task execution */ export interface BootstrapTaskResult extends TaskResult { data?: { success: boolean; iterations: number; platformDetected?: string; deploymentPlan?: unknown; adrUpdates?: unknown[]; learnings?: unknown[]; bootstrapAdrPath?: string; contextDocumentPath?: string; }; } /** * Bootstrap Task Manager - Provides MCP Tasks integration for bootstrap validation loop * * This class wraps the TaskManager to provide bootstrap-specific functionality: * - Creates tasks with bootstrap-specific phases * - Tracks iteration progress * - Supports cancellation checks between phases * - Converts between executionId and taskId patterns */ export declare class BootstrapTaskManager { private taskManager; private activeContexts; constructor(taskManager?: TaskManager); /** * Initialize the bootstrap task manager */ initialize(): Promise<void>; /** * Create a new bootstrap task * * @returns The created task and context */ createBootstrapTask(options: CreateBootstrapTaskOptions): Promise<{ task: AdrTask; context: BootstrapTaskContext; }>; /** * Get bootstrap task context */ getContext(taskId: string): BootstrapTaskContext | undefined; /** * Start a bootstrap phase */ startPhase(taskId: string, phase: BootstrapPhase, message?: string): Promise<void>; /** * Update phase progress */ updatePhaseProgress(taskId: string, phase: BootstrapPhase, phaseProgress: number, message?: string): Promise<void>; /** * Complete a bootstrap phase */ completePhase(taskId: string, phase: BootstrapPhase, _message?: string): Promise<void>; /** * Fail a bootstrap phase */ failPhase(taskId: string, phase: BootstrapPhase, error: string): Promise<void>; /** * Update iteration progress */ updateIteration(taskId: string, iteration: number): Promise<void>; /** * Store platform detection result */ storePlatformDetection(taskId: string, platform: string, confidence: number): Promise<void>; /** * Store infrastructure result */ storeInfrastructureResult(taskId: string, result: { success: boolean; executedTasks: string[]; failedTasks: string[]; }): Promise<void>; /** * Check if task is cancelled */ isCancelled(taskId: string): Promise<boolean>; /** * Cancel a bootstrap task */ cancelTask(taskId: string, reason?: string): Promise<void>; /** * Complete a bootstrap task successfully */ completeTask(taskId: string, result: BootstrapTaskResult): Promise<void>; /** * Fail a bootstrap task */ failTask(taskId: string, error: string): Promise<void>; /** * Get task status */ getTaskStatus(taskId: string): Promise<{ task: AdrTask | null; context: BootstrapTaskContext | undefined; }>; } export declare function getBootstrapTaskManager(): BootstrapTaskManager; /** * Reset the global BootstrapTaskManager (for testing) */ export declare function resetBootstrapTaskManager(): Promise<void>; /** * Helper function to wrap bootstrap execution with task tracking * * This can be used by the bootstrap_validation_loop tool to automatically * track progress through MCP Tasks. * * @example * ```typescript * const result = await executeWithTaskTracking( * { * projectPath: '/path/to/project', * adrDirectory: 'docs/adrs', * targetEnvironment: 'development', * maxIterations: 5, * autoFix: true, * updateAdrsWithLearnings: true, * }, * async (tracker) => { * // Platform detection phase * await tracker.startPhase('platform_detection'); * const platform = await detectPlatform(); * await tracker.storePlatformDetection(platform.name, platform.confidence); * await tracker.completePhase('platform_detection'); * * // Infrastructure phase * await tracker.startPhase('infrastructure_setup'); * const infraResult = await runInfrastructure(); * await tracker.storeInfrastructureResult(infraResult); * await tracker.completePhase('infrastructure_setup'); * * // Return final result * return { success: true, iterations: 3 }; * } * ); * ``` */ export declare function executeWithTaskTracking<T extends BootstrapTaskResult>(options: CreateBootstrapTaskOptions, executor: (tracker: TaskTracker) => Promise<T['data']>): Promise<{ taskId: string; result: T; }>; /** * Task tracker interface provided to bootstrap executor */ export interface TaskTracker { taskId: string; startPhase: (phase: BootstrapPhase, message?: string) => Promise<void>; updatePhaseProgress: (phase: BootstrapPhase, progress: number, message?: string) => Promise<void>; completePhase: (phase: BootstrapPhase, message?: string) => Promise<void>; failPhase: (phase: BootstrapPhase, error: string) => Promise<void>; updateIteration: (iteration: number) => Promise<void>; storePlatformDetection: (platform: string, confidence: number) => Promise<void>; storeInfrastructureResult: (result: { success: boolean; executedTasks: string[]; failedTasks: string[]; }) => Promise<void>; isCancelled: () => Promise<boolean>; getContext: () => BootstrapTaskContext; } //# sourceMappingURL=bootstrap-task-integration.d.ts.map