/** * Requirements and Validations Extractor - Tracks constraints, dependencies, and testing context. * * This extractor analyzes conversation messages and tool executions to identify: * - Requirements (dependencies, performance, compatibility, business constraints) * - Validations (test runs, results, and performance data) * * Helps document: * - What dependencies are required and why * - Performance requirements and constraints * - Compatibility requirements (versions, platforms) * - Business rules and limitations * - Test executions and their results * * @example * ```typescript * const extractor = new RequirementsExtractor(); * const requirements = extractor.extractRequirements(messages); * const validations = extractor.extractValidations(toolUses, toolResults, messages); * * console.log(`Found ${requirements.length} requirements`); * console.log(`Found ${validations.length} test validations`); * ``` */ import type { Message, ToolUse, ToolResult } from "./ConversationParser.js"; /** * Represents a requirement or constraint for the system. */ export interface Requirement { /** Unique requirement identifier */ id: string; /** Category of requirement */ type: "dependency" | "performance" | "compatibility" | "business"; /** Description of the requirement */ description: string; /** Why this requirement exists */ rationale?: string; /** Components affected by this requirement */ affects_components: string[]; /** Conversation where requirement was discussed */ conversation_id: string; /** Message containing the requirement */ message_id: string; /** When the requirement was documented */ timestamp: number; } /** * Represents a test validation or verification. */ export interface Validation { /** Unique validation identifier */ id: string; /** Conversation where test was run */ conversation_id: string; /** Description of what was tested */ what_was_tested: string; /** Command used to run the test */ test_command?: string; /** Test result status */ result: "passed" | "failed" | "error"; /** Performance metrics from the test */ performance_data?: Record; /** Files that were tested */ files_tested: string[]; /** When the test was run */ timestamp: number; } /** * Extracts requirements and validations from conversation history. * * Analyzes messages for requirement patterns and tool executions for test results. */ export declare class RequirementsExtractor { private readonly REQUIREMENT_PATTERNS; private readonly TEST_PATTERNS; /** * Get combined output from tool result (stdout + stderr + content) * Test output may go to either stdout or stderr depending on the tool */ private getToolOutput; /** * Extract requirements from conversation messages. * * Analyzes messages using pattern matching to identify four types of requirements: * - Dependency: Required libraries, packages, modules * - Performance: Speed, latency, throughput constraints * - Compatibility: Version requirements, platform support * - Business: Business rules, limitations, constraints * * @param messages - Array of conversation messages to analyze * @returns Array of extracted Requirement objects * * @example * ```typescript * const extractor = new RequirementsExtractor(); * const requirements = extractor.extractRequirements(messages); * * // Find all dependency requirements * const deps = requirements.filter(r => r.type === 'dependency'); * deps.forEach(d => console.log(`${d.description} - ${d.rationale}`)); * ``` */ extractRequirements(messages: Message[]): Requirement[]; /** * Extract validations from tool executions. * * Analyzes Bash tool uses to identify test command executions and their results. * Captures test runs including pass/fail status, performance data, and files tested. * * Recognized test commands: * - npm/yarn/pnpm test * - pytest * - jest/mocha * - cargo test (Rust) * - go test (Go) * * @param toolUses - Array of tool invocations * @param toolResults - Array of tool execution results * @param messages - Array of conversation messages for context * @returns Array of extracted Validation objects * * @example * ```typescript * const extractor = new RequirementsExtractor(); * const validations = extractor.extractValidations(toolUses, toolResults, messages); * * // Find failed tests * const failures = validations.filter(v => v.result === 'failed'); * console.log(`${failures.length} test failures found`); * ``` */ extractValidations(toolUses: ToolUse[], toolResults: ToolResult[], messages: Message[]): Validation[]; /** * Parse a requirement from pattern match */ private parseRequirement; /** * Extract rationale from requirement text */ private extractRationale; /** * Extract affected components from message metadata */ private extractAffectedComponents; /** * Extract what was tested from command and result */ private extractWhatWasTested; /** * Determine test result from tool result */ private determineTestResult; /** * Extract performance data from test results */ private extractPerformanceData; /** * Extract files that were tested */ private extractTestedFiles; /** * Deduplicate similar requirements */ private deduplicateRequirements; } //# sourceMappingURL=RequirementsExtractor.d.ts.map