mcp-ai-agent-guidelines
Version:
A comprehensive Model Context Protocol server providing advanced tools, resources, and prompts for implementing AI agent best practices
100 lines • 3.43 kB
TypeScript
/**
* Output Selector - Intelligent strategy selection based on context
*
* Analyzes context signals to recommend the most appropriate output strategy.
* Provides automatic selection with confidence scoring and reasoning.
*
* @module gateway/output-selector
*/
import { OutputApproach } from "../strategies/output-strategy.js";
/**
* Context signals used to determine the appropriate output strategy.
*
* @interface ContextSignals
*/
export interface ContextSignals {
/** Keywords extracted from context or user input (expected to be normalized to lowercase) */
keywords: string[];
/** Optional domain type identifier (e.g., "PromptResult", "SessionState") */
domainType?: string;
/** Whether the context references a constitution or constraint document */
hasConstitution?: boolean;
}
/**
* Result of output strategy recommendation.
*
* @interface RecommendationResult
*/
export interface RecommendationResult {
/** Recommended output approach */
approach: OutputApproach;
/** Confidence score (0-100) */
confidence: number;
/** Human-readable reasoning for the recommendation */
reasoning: string;
}
/**
* Extract keywords from context text.
*
* Simple extraction that splits on whitespace and punctuation,
* filters out common stop words, and normalizes to lowercase.
* Preserves file extensions like .md in filenames.
*
* @param context - Input text to analyze
* @returns Array of extracted keywords
*/
export declare function extractKeywords(context: string): string[];
/**
* Select the appropriate output approach based on context signals.
*
* Decision logic:
* 1. If constitution is referenced → SPECKIT (high confidence)
* 2. If ≥2 Spec-Kit signals detected → SPECKIT
* 3. Otherwise → CHAT (default)
*
* @param signals - Context signals for strategy selection
* @returns Recommended output approach
*/
export declare function selectApproach(signals: ContextSignals): OutputApproach;
/**
* Calculate confidence score for a recommendation.
*
* Confidence scoring:
* - Constitution present: 95%
* - 3+ Spec-Kit signals: 90%
* - 2 Spec-Kit signals: 75%
* - Default (CHAT): 60%
*
* @param signals - Context signals
* @param approach - Selected approach
* @returns Confidence score (0-100)
*/
export declare function calculateConfidence(signals: ContextSignals, approach: OutputApproach): number;
/**
* Generate human-readable reasoning for the recommendation.
*
* @param signals - Context signals
* @param approach - Selected approach
* @returns Reasoning explanation
*/
export declare function generateReasoning(signals: ContextSignals, approach: OutputApproach): string;
/**
* Recommend an output approach based on context analysis.
*
* This is the main entry point for strategy selection. It:
* 1. Extracts keywords from context
* 2. Detects constitution references
* 3. Selects appropriate approach
* 4. Calculates confidence and generates reasoning
*
* @param context - Input context text to analyze
* @returns Recommendation with approach, confidence, and reasoning
*
* @example
* ```typescript
* const result = recommendApproach('Create a spec.md and plan.md for the project');
* // Returns: { approach: OutputApproach.SPECKIT, confidence: 75, reasoning: "..." }
* ```
*/
export declare function recommendApproach(context: string): RecommendationResult;
//# sourceMappingURL=output-selector.d.ts.map