#!/usr/bin/env node
import * as _codemcp_workflows_core from '@codemcp/workflows-core';
import { YamlState, TaskBackendConfig, ConversationManager, TransitionEngine, IPlanManager, IInstructionGenerator, WorkflowManager, InteractionLogger, LoggerFactory, IPersistence, ILogger, ConversationContext as ConversationContext$1, YamlStateMachine } from '@codemcp/workflows-core';
import * as _modelcontextprotocol_sdk_server_mcp_js from '@modelcontextprotocol/sdk/server/mcp.js';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';

/**
 * Plugin system interfaces for extending the workflows server
 *
 * Core Principle: Plugins receive only read-only context data and cannot
 * directly manipulate core server components. They extend behavior through
 * semantic lifecycle hooks only.
 */

/**
 * Plugin interface - all plugins must implement this
 */
interface IPlugin {
    /** Unique plugin name */
    getName(): string;
    /** Execution sequence (lower numbers execute first) */
    getSequence(): number;
    /** Whether plugin is enabled (typically based on environment) */
    isEnabled(): boolean;
    /** Lifecycle hooks this plugin provides */
    getHooks(): PluginHooks;
}
/**
 * Lifecycle hooks that plugins can implement
 * All hooks receive standardized PluginHookContext as first parameter
 */
interface PluginHooks {
    /** Called before development workflow starts */
    beforeStartDevelopment?: (context: PluginHookContext, args: StartDevelopmentArgs$1) => Promise<void>;
    /** Called after development workflow has started */
    afterStartDevelopment?: (context: PluginHookContext, args: StartDevelopmentArgs$1, result: StartDevelopmentResult$1) => Promise<void>;
    /** Called after plan file is created - can modify content */
    afterPlanFileCreated?: (context: PluginHookContext, planFilePath: string, content: string) => Promise<string>;
    /** Called before phase transition (can block by throwing) */
    beforePhaseTransition?: (context: PluginHookContext, currentPhase: string, targetPhase: string) => Promise<void>;
    /** Called after instructions are generated - can modify them */
    afterInstructionsGenerated?: (context: PluginHookContext, instructions: GeneratedInstructions) => Promise<GeneratedInstructions>;
}
/**
 * Standardized context provided to all plugin hooks
 * Contains ONLY read-only data - no server components
 */
interface PluginHookContext {
    /** Current conversation ID */
    conversationId: string;
    /** Path to the plan file */
    planFilePath: string;
    /** Current development phase */
    currentPhase: string;
    /** Active workflow name */
    workflow: string;
    /** Project directory path */
    projectPath: string;
    /** Git branch name */
    gitBranch: string;
    /** Whether the plan file exists at the time of instruction generation */
    planFileExists: boolean;
    /** Target phase (only available in phase transitions) */
    targetPhase?: string;
    /** Workflow state machine definition (read-only) - available in afterStartDevelopment */
    stateMachine?: {
        readonly name: string;
        readonly description: string;
        readonly initial_state: string;
        readonly states: Record<string, YamlState>;
    };
}
/**
 * Plugin registry interface for managing and executing plugins
 */
interface IPluginRegistry {
    /** Register a plugin */
    registerPlugin(plugin: IPlugin): void;
    /** Get all enabled plugins sorted by sequence */
    getEnabledPlugins(): IPlugin[];
    /** Execute a specific hook on all plugins that implement it */
    executeHook<T extends keyof PluginHooks>(hookName: T, ...args: Parameters<NonNullable<PluginHooks[T]>>): Promise<unknown>;
    /** Check if any plugin has a specific hook */
    hasHook(hookName: keyof PluginHooks): boolean;
    /** Get names of all registered plugins */
    getPluginNames(): string[];
    /** Clear all plugins (mainly for testing) */
    clear(): void;
}
interface StartDevelopmentArgs$1 {
    workflow: string;
    require_reviews?: boolean;
    project_path?: string;
}
interface StartDevelopmentResult$1 {
    conversationId: string;
    planFilePath: string;
    phase: string;
    workflow: string;
}
interface GeneratedInstructions {
    instructions: string;
    planFilePath: string;
    phase: string;
    /** Source of the instruction generation */
    instructionSource?: 'whats_next' | 'proceed_to_phase' | 'start_development';
}

/**
 * Core types and interfaces for the refactored server architecture
 */

/**
 * Session metadata linking workflow state to an external session/context
 */
interface SessionMetadata {
    referenceId: string;
    createdAt: string;
}
/**
 * Server context shared across all handlers
 * Contains all the core dependencies needed by tool and resource handlers
 */
interface ServerContext {
    conversationManager: ConversationManager;
    transitionEngine: TransitionEngine;
    planManager: IPlanManager;
    instructionGenerator: IInstructionGenerator;
    workflowManager: WorkflowManager;
    interactionLogger?: InteractionLogger;
    projectPath: string;
    pluginRegistry?: IPluginRegistry;
    /** Logger factory for creating component loggers - if not provided, handlers use global createLogger */
    loggerFactory?: LoggerFactory;
    /** Session metadata linking workflow state to external session context */
    sessionMetadata?: SessionMetadata;
}
/**
 * Standard result format for all handler operations
 * Separates business logic results from MCP protocol concerns
 */
interface HandlerResult<T = unknown> {
    success: boolean;
    data?: T;
    error?: string;
    metadata?: Record<string, unknown>;
}
/**
 * Resource content structure
 */
interface ResourceContent {
    uri: string;
    text: string;
    mimeType: string;
}
/**
 * MCP Tool Response format (compatible with MCP SDK)
 */
interface McpToolResponse {
    [x: string]: unknown;
    content: Array<{
        type: 'text';
        text: string;
    }>;
    isError?: boolean;
}
/**
 * MCP Resource Response format (compatible with MCP SDK)
 */
interface McpResourceResponse {
    [x: string]: unknown;
    contents: Array<{
        uri: string;
        text: string;
        mimeType: string;
    }>;
}
/**
 * Tool handler interface
 * All tool handlers must implement this interface
 */
interface ToolHandler<TArgs = unknown, TResult = unknown> {
    handle(args: TArgs, context: ServerContext): Promise<HandlerResult<TResult>>;
}
/**
 * Resource handler interface
 * All resource handlers must implement this interface
 */
interface ResourceHandler {
    handle(uri: URL, context: ServerContext): Promise<HandlerResult<ResourceContent>>;
}
/**
 * Response renderer interface
 * Handles translation between domain results and MCP protocol responses
 */
interface ResponseRenderer {
    renderToolResponse<T>(result: HandlerResult<T>): McpToolResponse;
    renderResourceResponse(result: HandlerResult<ResourceContent>): McpResourceResponse;
    renderError(error: Error | string): McpToolResponse;
}
/**
 * Tool registry interface
 * Manages registration and lookup of tool handlers
 */
interface ToolRegistry {
    register<T extends ToolHandler>(name: string, handler: T): void;
    get(name: string): ToolHandler | undefined;
    list(): string[];
}
/**
 * Resource registry interface
 * Manages registration and lookup of resource handlers
 */
interface ResourceRegistry {
    register(pattern: string, handler: ResourceHandler): void;
    resolve(uri: string): ResourceHandler | undefined;
}
/**
 * Server configuration options
 */
interface ServerConfig {
    /** Project path to operate on (defaults to process.cwd()) */
    projectPath?: string;
    /** Database path override */
    databasePath?: string;
    /** Enable interaction logging */
    enableLogging?: boolean;
    /** Task backend configuration override (for testing) */
    taskBackend?: TaskBackendConfig;
}

/**
 * Server Configuration
 *
 * Handles server configuration, component initialization, and MCP server setup.
 * Centralizes the configuration logic that was previously scattered in the main server class.
 */

/**
 * Server component container
 * Holds all the initialized server components
 */
interface ServerComponents {
    mcpServer: McpServer;
    database: IPersistence;
    context: ServerContext;
    toolRegistry: ToolRegistry;
    resourceRegistry: ResourceRegistry;
    responseRenderer: ResponseRenderer;
}

/**
 * Base Tool Handler
 *
 * Provides common functionality for all tool handlers including
 * error handling, logging, and conversation state management.
 */

/**
 * Abstract base class for tool handlers
 * Provides common functionality and enforces consistent patterns
 */
declare abstract class BaseToolHandler<TArgs = unknown, TResult = unknown> implements ToolHandler<TArgs, TResult> {
    protected logger: ILogger;
    constructor();
    /**
     * Main handler method - implements consistent error handling and logging
     */
    handle(args: TArgs, context: ServerContext): Promise<HandlerResult<TResult>>;
    /**
     * Abstract method that subclasses must implement
     * Contains the actual business logic for the tool
     */
    protected abstract executeHandler(args: TArgs, context: ServerContext): Promise<TResult>;
    /**
     * Helper method to get conversation context with proper error handling
     */
    protected getConversationContext(context: ServerContext): Promise<ConversationContext$1>;
    /**
     * Helper method to ensure state machine is loaded for a project
     */
    protected ensureStateMachineForProject(context: ServerContext, projectPath: string, workflowName?: string): void;
    /**
     * Helper method to log interactions if logger is available
     */
    protected logInteraction(context: ServerContext, conversationId: string, toolName: string, args: unknown, response: unknown, phase: string): Promise<void>;
}
/**
 * Base class for tool handlers that require an existing conversation
 * Automatically handles the conversation-not-found case
 */
declare abstract class ConversationRequiredToolHandler<TArgs = unknown, TResult = unknown> extends BaseToolHandler<TArgs, TResult> {
    protected executeHandler(args: TArgs, context: ServerContext): Promise<TResult>;
    /**
     * Abstract method for handlers that need conversation context
     */
    protected abstract executeWithConversation(args: TArgs, context: ServerContext, conversationContext: ConversationContext$1): Promise<TResult>;
}

/**
 * WhatsNext Tool Handler
 *
 * Handles the whats_next tool which analyzes conversation context and
 * determines the next development phase with specific instructions for the LLM.
 */

/**
 * Arguments for the whats_next tool
 */
interface WhatsNextArgs {
    context?: string;
    user_input?: string;
    conversation_summary?: string;
    recent_messages?: Array<{
        role: 'user' | 'assistant';
        content: string;
    }>;
}
/**
 * Response from the whats_next tool
 */
interface WhatsNextResult {
    phase: string;
    instructions: string;
    plan_file_path: string;
    /**
     * Glob patterns for files allowed to be edited in this phase.
     * Defaults to ['**\/*'] (all files) if not restricted.
     */
    allowed_file_patterns: string[];
}
/**
 * WhatsNext tool handler implementation
 */
declare class WhatsNextHandler extends ConversationRequiredToolHandler<WhatsNextArgs, WhatsNextResult> {
    protected executeHandler(args: WhatsNextArgs, context: ServerContext): Promise<WhatsNextResult>;
    protected executeWithConversation(args: WhatsNextArgs, context: ServerContext, conversationContext: ConversationContext$1): Promise<WhatsNextResult>;
    /**
     * Determines whether conversation state should be updated for a phase transition
     */
    private shouldUpdateConversationState;
}

/**
 * ProceedToPhase Tool Handler
 *
 * Handles explicit transitions to specific development phases when the current
 * phase is complete or when a direct phase change is needed.
 */

/**
 * Arguments for the proceed_to_phase tool
 */
interface ProceedToPhaseArgs {
    target_phase: string;
    reason?: string;
    review_state: 'not-required' | 'pending' | 'performed';
}
/**
 * Response from the proceed_to_phase tool
 */
interface ProceedToPhaseResult {
    phase: string;
    instructions: string;
    plan_file_path: string;
    transition_reason: string;
    /**
     * Glob patterns for files allowed to be edited in this phase.
     * Defaults to ['**\/*'] (all files) if not restricted.
     */
    allowed_file_patterns: string[];
}
/**
 * ProceedToPhase tool handler implementation
 */
declare class ProceedToPhaseHandler extends ConversationRequiredToolHandler<ProceedToPhaseArgs, ProceedToPhaseResult> {
    protected executeWithConversation(args: ProceedToPhaseArgs, context: ServerContext, conversationContext: ConversationContext$1): Promise<ProceedToPhaseResult>;
    /**
     * Validate review state for transitions that require reviews
     */
    private validateReviewState;
    /**
     * Validate that the agent's role allows this phase transition (for crowd workflows)
     */
    private validateAgentRole;
}

/**
 * ConductReview Tool Handler
 *
 * Handles review requests before phase transitions. Adapts to MCP environment
 * capabilities - returns automated review results if sampling available,
 * otherwise returns instructions for LLM to conduct guided review.
 */

/**
 * Arguments for the conduct_review tool
 */
interface ConductReviewArgs {
    target_phase: string;
}
/**
 * Response from the conduct_review tool
 */
interface ConductReviewResult {
    instructions: string;
    perspectives: Array<{
        name: string;
        prompt: string;
    }>;
}
/**
 * ConductReview tool handler implementation
 */
declare class ConductReviewHandler extends ConversationRequiredToolHandler<ConductReviewArgs, ConductReviewResult> {
    protected executeWithConversation(args: ConductReviewArgs, context: ServerContext, conversationContext: ConversationContext$1): Promise<ConductReviewResult>;
    /**
     * Get transition configuration from workflow
     */
    private getTransitionConfig;
    /**
     * Check if MCP environment supports sampling capabilities
     */
    private checkSamplingCapability;
    /**
     * Conduct automated review using LLM tools (when sampling is available)
     */
    private conductAutomatedReview;
    /**
     * Generate instructions for LLM to conduct guided review
     */
    private generateReviewInstructions;
}

/**
 * StartDevelopment Tool Handler
 *
 * Handles initialization of development workflow and transition to the initial
 * development phase. Allows users to choose from predefined workflows or use a custom workflow.
 */

/**
 * Arguments for the start_development tool
 */
interface StartDevelopmentArgs {
    workflow: string;
    require_reviews?: boolean;
    project_path?: string;
}
/**
 * Response from the start_development tool
 */
interface StartDevelopmentResult {
    phase: string;
    instructions: string;
    plan_file_path: string;
    workflowDocumentationUrl?: string;
    /**
     * Glob patterns for files allowed to be edited in this phase.
     * Defaults to ['**\/*'] (all files) if not restricted.
     */
    allowed_file_patterns: string[];
}
/**
 * StartDevelopment tool handler implementation
 */
declare class StartDevelopmentHandler extends BaseToolHandler<StartDevelopmentArgs, StartDevelopmentResult> {
    private projectDocsManager;
    private getProjectDocsManager;
    protected executeHandler(args: StartDevelopmentArgs, context: ServerContext): Promise<StartDevelopmentResult>;
    /**
     * Check if project documentation artifacts exist and provide setup guidance if needed
     * Dynamically analyzes the selected workflow to determine which documents are referenced
     * Blocks workflow start if the workflow requires documentation
     */
    private checkProjectArtifacts;
    /**
     * Analyze workflow content to detect document variable references
     */
    private analyzeWorkflowDocumentReferences;
    /**
     * Determine which referenced documents are missing
     */
    private getMissingReferencedDocuments;
    /**
     * Generate guidance for setting up missing project artifacts
     */
    private generateArtifactSetupGuidance;
    /**
     * Generate workflow documentation URL for predefined workflows
     * Returns undefined for custom workflows
     */
    private generateWorkflowDocumentationUrl;
    /**
     * Get the current git branch for a project
     * Uses the same logic as ConversationManager but locally accessible
     */
    private getCurrentGitBranch;
    /**
     * Generate a suggested branch name for feature development
     */
    private generateBranchSuggestion;
    /**
     * Ensure .gitignore exists in .vibe folder to exclude SQLite files
     * This function is idempotent and self-contained within the .vibe directory
     */
    private ensureGitignoreEntry;
}

/**
 * ResumeWorkflow Tool Handler
 *
 * Handles resuming development workflow after conversation compression.
 * Returns comprehensive project context, current state, system prompt instructions,
 * and next steps to seamlessly continue development.
 */

/**
 * Arguments for the resume_workflow tool
 */
interface ResumeWorkflowArgs {
    include_system_prompt?: boolean;
}
/**
 * Plan file analysis result
 */
interface PlanAnalysis {
    sections: string[];
    tasks_completed: number;
    tasks_total: number;
    key_decisions: string[];
    recent_updates: string[];
    active_tasks?: string[];
    completed_tasks?: string[];
}
/**
 * Conversation context for resume workflow
 */
interface ConversationContext {
    conversationId: string;
    currentPhase: string;
    projectPath: string;
    workflowName: string;
    gitBranch: string;
    planFilePath: string;
    current_phase?: string;
    workflow_name?: string;
    project_context?: string;
    recent_activity?: string[];
}
/**
 * Response from the resume_workflow tool
 */
interface ResumeWorkflowResult {
    workflow_status: {
        current_phase: string;
        project_path: string;
        git_branch: string;
        state_machine: YamlStateMachine;
    };
    plan_status: {
        exists: boolean;
        path: string;
        analysis?: PlanAnalysis | null;
    };
    system_prompt?: string | null;
    recommendations: {
        immediate_actions: string[];
        phase_guidance: string;
        potential_issues: string[];
    };
    generated_at: string;
    tool_version: string;
}
/**
 * ResumeWorkflow tool handler implementation
 */
declare class ResumeWorkflowHandler extends ConversationRequiredToolHandler<ResumeWorkflowArgs, ResumeWorkflowResult> {
    protected executeWithConversation(args: ResumeWorkflowArgs, context: ServerContext, conversationContext: ConversationContext): Promise<ResumeWorkflowResult>;
    /**
     * Analyze plan file content to extract key information
     */
    private analyzePlanFile;
    /**
     * Get state machine information
     */
    private getStateMachineInfo;
    /**
     * Generate recommendations for next steps based on state machine transitions
     */
    private generateRecommendations;
}

/**
 * ResetDevelopment Tool Handler
 *
 * Handles resetting conversation state and development progress.
 * This permanently deletes conversation state and plan file, while
 * soft-deleting interaction logs for audit trail.
 */

/**
 * Arguments for the reset_development tool
 */
interface ResetDevelopmentArgs {
    confirm: boolean;
    reason?: string;
}
/**
 * Response from the reset_development tool
 */
interface ResetDevelopmentResult {
    success: boolean;
    resetItems: string[];
    message: string;
}
/**
 * ResetDevelopment tool handler implementation
 */
declare class ResetDevelopmentHandler extends BaseToolHandler<ResetDevelopmentArgs, ResetDevelopmentResult> {
    protected executeHandler(args: ResetDevelopmentArgs, context: ServerContext): Promise<ResetDevelopmentResult>;
}

/**
 * List Workflows Tool Handler
 *
 * Provides an overview of all available workflows with their descriptions
 * and resource URIs for detailed information.
 */

/**
 * Schema for list_workflows tool arguments
 */
declare const ListWorkflowsArgsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
type ListWorkflowsArgs = z.infer<typeof ListWorkflowsArgsSchema>;
/**
 * Response format for workflow information
 */
interface WorkflowOverview {
    name: string;
    displayName: string;
    description: string;
    resourceUri: string;
}
interface ListWorkflowsResponse {
    workflows: WorkflowOverview[];
}
/**
 * Tool handler for listing available workflows
 */
declare class ListWorkflowsHandler extends BaseToolHandler<ListWorkflowsArgs, ListWorkflowsResponse> {
    protected readonly argsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
    executeHandler(_args: ListWorkflowsArgs, context: ServerContext): Promise<ListWorkflowsResponse>;
}

/**
 * Get Tool Info Handler
 *
 * Provides comprehensive information about the workflows development
 * workflow tools for better tool discoverability and AI integration.
 */

/**
 * Schema for get_tool_info tool arguments
 */
declare const GetToolInfoArgsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
type GetToolInfoArgs = z.infer<typeof GetToolInfoArgsSchema>;
/**
 * Tool information structure
 */
interface ToolInfo {
    name: string;
    description: string;
    parameters: string[];
    schema?: {
        required: string[];
        optional: string[];
    };
}
/**
 * Workflow information structure
 */
interface WorkflowInfo {
    name: string;
    displayName: string;
    description: string;
    phases?: string[];
}
/**
 * Complete tool information response
 */
interface GetToolInfoResponse {
    tool_name: string;
    version: string;
    purpose: string;
    description: string;
    available_tools: ToolInfo[];
    available_workflows: WorkflowInfo[];
    core_concepts: {
        phase_management: string;
        plan_file_tracking: string;
        conversation_context: string;
        workflow_guidance: string;
    };
    usage_guidelines: {
        required_pattern: string;
        phase_transitions: string;
        context_requirements: string;
        plan_file_management: string;
    };
    workflow_states?: {
        current_phase?: string;
        plan_file_path?: string;
    };
}
/**
 * Tool handler for providing comprehensive tool information
 */
declare class GetToolInfoHandler extends BaseToolHandler<GetToolInfoArgs, GetToolInfoResponse> {
    protected readonly argsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
    executeHandler(_args: GetToolInfoArgs, context: ServerContext): Promise<GetToolInfoResponse>;
    /**
     * Extract phase names from a workflow configuration
     */
    private extractWorkflowPhases;
}

/**
 * Setup Project Docs Handler
 *
 * Creates project documentation artifacts (architecture.md, requirements.md, design.md)
 * using configurable templates OR by linking existing files via symlinks.
 * Supports different template formats for each document type and file path linking.
 */

interface SetupProjectDocsArgs {
    architecture: string;
    requirements: string;
    design: string;
    project_path?: string;
}
interface SetupProjectDocsResult {
    success: boolean;
    created: string[];
    linked: string[];
    skipped: string[];
    paths: {
        architecture: string;
        requirements: string;
        design: string;
    };
    message: string;
}
declare class SetupProjectDocsHandler extends BaseToolHandler<SetupProjectDocsArgs, SetupProjectDocsResult> {
    private projectDocsManager;
    private getProjectDocsManager;
    protected executeHandler(args: SetupProjectDocsArgs, context: ServerContext): Promise<SetupProjectDocsResult>;
    /**
     * Validate and process arguments to determine templates vs file paths
     */
    private validateAndProcessArgs;
}

/**
 * No Idea Tool Handler
 *
 * Provides instructions for LLMs to acknowledge knowledge gaps
 * instead of hallucinating responses.
 */

/**
 * Schema for no_idea tool arguments
 */
declare const NoIdeaArgsSchema: z.ZodObject<{
    context: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
    context?: string | undefined;
}, {
    context?: string | undefined;
}>;
type NoIdeaArgs = z.infer<typeof NoIdeaArgsSchema>;
/**
 * Response format for no_idea tool
 */
interface NoIdeaResponse {
    instructions: string;
}
/**
 * Tool handler for acknowledging knowledge gaps
 */
declare class NoIdeaHandler extends BaseToolHandler<NoIdeaArgs, NoIdeaResponse> {
    protected readonly argsSchema: z.ZodObject<{
        context: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        context?: string | undefined;
    }, {
        context?: string | undefined;
    }>;
    executeHandler(args: NoIdeaArgs, _context: ServerContext): Promise<NoIdeaResponse>;
}

/**
 * Tool Handler Registry
 *
 * Central registry for all tool handlers. Provides registration and lookup
 * functionality for tool handlers used by the MCP server.
 */

/**
 * Default implementation of ToolRegistry
 */
declare class DefaultToolRegistry implements ToolRegistry {
    private handlers;
    register<T extends ToolHandler>(name: string, handler: T): void;
    get(name: string): ToolHandler | undefined;
    list(): string[];
}
/**
 * Create and configure the default tool registry with all standard handlers
 */
declare function createToolRegistry(): ToolRegistry;

/**
 * Factory function to create a server with real components
 */
declare function createResponsibleVibeMCPServer(config?: ServerConfig): Promise<ResponsibleVibeMCPServer>;
/**
 * Main server class that orchestrates all components
 * Can be used both as a standalone process and in-process for testing
 */
declare class ResponsibleVibeMCPServer {
    private config;
    private serverComponents;
    private components;
    constructor(config: ServerConfig, serverComponents: ServerComponents);
    /**
     * Initialize the server and all its components
     */
    initialize(): Promise<void>;
    /**
     * Get the underlying MCP server instance
     * This allows for both transport-based and direct testing
     */
    getMcpServer(): _modelcontextprotocol_sdk_server_mcp_js.McpServer;
    /**
     * Get project path
     */
    getProjectPath(): string;
    /**
     * Get conversation manager (for testing)
     */
    getConversationManager(): _codemcp_workflows_core.ConversationManager;
    /**
     * Get plan manager (for testing)
     */
    getPlanManager(): _codemcp_workflows_core.IPlanManager;
    /**
     * Direct access to tool handlers for testing
     */
    handleWhatsNext(args: unknown): Promise<unknown>;
    /**
     * Direct access to tool handlers for testing
     */
    handleProceedToPhase(args: ProceedToPhaseArgs): Promise<ProceedToPhaseResult>;
    /**
     * Direct access to tool handlers for testing
     */
    handleStartDevelopment(args: StartDevelopmentArgs): Promise<StartDevelopmentResult>;
    /**
     * Direct access to tool handlers for testing
     */
    handleResumeWorkflow(args: ResumeWorkflowArgs): Promise<ResumeWorkflowResult>;
    /**
     * Direct access to tool handlers for testing
     */
    handleResetDevelopment(args: ResetDevelopmentArgs): Promise<ResetDevelopmentResult>;
    /**
     * Cleanup server resources
     */
    cleanup(): Promise<void>;
}

/**
 * Core PluginRegistry implementation for managing plugins and executing lifecycle hooks
 */

declare class PluginRegistry implements IPluginRegistry {
    private plugins;
    /**
     * Register a plugin.
     *
     * Note: Plugins are always registered regardless of isEnabled() state.
     * The isEnabled() check happens at hook execution time in getEnabledPlugins().
     * This allows plugins to activate/deactivate dynamically based on conditions
     * that may change after registration (e.g., backend availability).
     */
    registerPlugin(plugin: IPlugin): void;
    /**
     * Get all enabled plugins sorted by execution sequence
     */
    getEnabledPlugins(): IPlugin[];
    /**
     * Execute a specific hook on all plugins that implement it
     * Plugins are executed in sequence order
     *
     * Error Handling Strategy:
     * - Validation hooks (beforePhaseTransition): Always re-throw to block invalid transitions
     * - Critical startup hooks: Re-throw to fail fast and show critical errors
     * - Non-critical hooks: Log error and continue execution to enable graceful degradation
     * - Multiple plugins: If one plugin fails on non-critical hook, continue with next plugin
     */
    executeHook<T extends keyof PluginHooks>(hookName: T, ...args: Parameters<NonNullable<PluginHooks[T]>>): Promise<unknown>;
    /**
     * Type-safe hook execution dispatcher
     * Handles the differences in hook signatures without type coercion
     */
    private executeTypedHook;
    /**
     * Check if any enabled plugin implements a specific hook
     */
    hasHook(hookName: keyof PluginHooks): boolean;
    /**
     * Get names of all registered plugins (for debugging)
     */
    getPluginNames(): string[];
    /**
     * Clear all plugins (mainly for testing)
     */
    clear(): void;
}

/**
 * Beads Plugin Implementation
 *
 * Plugin that integrates beads task management system with the workflows server.
 * Encapsulates ALL beads-specific functionality to maintain zero core application
 * coupling as specified in plugin architecture design.
 *
 * Core Principle: This plugin must be completely self-contained and the core
 * application must have ZERO knowledge of beads functionality.
 */

/**
 * BeadsPlugin class implementing the IPlugin interface
 *
 * Activation: When beads backend is detected (either via TASK_BACKEND=beads env var
 *             or auto-detection when bd CLI is available)
 * Priority: Sequence 100 (middle priority)
 * Encapsulation: All beads functionality contained within this plugin
 */
declare class BeadsPlugin implements IPlugin {
    private projectPath;
    private beadsStateManager;
    private beadsTaskBackendClient;
    private planManager;
    private logger;
    private loggerFactory?;
    constructor(options: {
        projectPath: string;
        loggerFactory?: LoggerFactory;
    });
    getName(): string;
    getSequence(): number;
    isEnabled(): boolean;
    getHooks(): PluginHooks;
    /**
     * Handle beforePhaseTransition hook
     * Replaces validateBeadsTaskCompletion() method from proceed-to-phase.ts
     */
    private handleBeforePhaseTransition;
    /**
     * Handle afterStartDevelopment hook
     * Replaces setupBeadsIntegration() method from start-development.ts
     * Implements graceful degradation: continues app operation even if beads operations fail
     */
    private handleAfterStartDevelopment;
    /**
     * Handle afterPlanFileCreated hook
     * Enhances the plan file with beads-specific templates and placeholders
     *
     * This hook is called after a plan file is created. For beads integration,
     * it ensures the plan file has TBD placeholders for phase task IDs that
     * will be filled in later by afterStartDevelopment.
     *
     * Note: Task IDs themselves are created in afterStartDevelopment, not here.
     * This hook ensures the plan has the proper structure to receive them.
     */
    private handleAfterPlanFileCreated;
    /**
     * Handle afterInstructionsGenerated hook
     * Enriches instructions with beads-specific task management guidance
     */
    private handleAfterInstructionsGenerated;
    /**
     * Generate beads-specific task management guidance
     */
    private generateBeadsGuidance;
    /**
     * Extract phase task ID from plan file
     */
    private extractPhaseTaskIdFromPlanFile;
    /**
     * Capitalize phase name for display
     */
    private capitalizePhase;
    /**
     * Validate beads task completion before phase transition
     * Implements graceful error handling: logs errors but continues on non-validation failures
     */
    private validateBeadsTaskCompletion;
    /**
     * Extract Goal section content from plan file
     * Returns the goal content if it exists and is meaningful, otherwise undefined
     */
    private extractGoalFromPlan;
    /**
     * Update plan file to include beads phase task IDs in comments
     * Implements graceful degradation: logs errors but continues app operation if update fails
     */
    private updatePlanFileWithPhaseTaskIds;
}

/**
 * Vibe Feature MCP Server Entry Point
 *
 * Starts the MCP server with stdio transport for process-based usage.
 * The core server logic is in server.ts for better testability.
 */

/**
 * Main entry point for the MCP server process
 */
declare function main(): Promise<void>;

export { BaseToolHandler, BeadsPlugin, type ConductReviewArgs, ConductReviewHandler, type ConductReviewResult, ConversationRequiredToolHandler, DefaultToolRegistry, type GetToolInfoArgs, GetToolInfoHandler, type GetToolInfoResponse, type HandlerResult, ListWorkflowsHandler, type NoIdeaArgs, NoIdeaHandler, type NoIdeaResponse, PluginRegistry, type ProceedToPhaseArgs, ProceedToPhaseHandler, type ProceedToPhaseResult, type ResetDevelopmentArgs, ResetDevelopmentHandler, type ResetDevelopmentResult, ResponsibleVibeMCPServer, type ResumeWorkflowArgs, ResumeWorkflowHandler, type ResumeWorkflowResult, type ServerContext, type SessionMetadata, type SetupProjectDocsArgs, SetupProjectDocsHandler, type SetupProjectDocsResult, type StartDevelopmentArgs, StartDevelopmentHandler, type StartDevelopmentResult, type WhatsNextArgs, WhatsNextHandler, type WhatsNextResult, createResponsibleVibeMCPServer, createToolRegistry, main as startMcpServer };
