/** * Contract Extractor for MAMA v2 (TypeScript Port) * * Extracts API contracts, function signatures, and type definitions * from code changes using simple pattern matching. * * Design Philosophy: * - Simple regex patterns for common cases (80% coverage) * - Main Claude handles complex cases (20%) * - Transparent: All extractions visible to Main Claude * * Ported from: packages/claude-code-plugin/src/core/contract-extractor.js */ export interface ExtractedContract { type: 'api_endpoint' | 'function_signature' | 'type_definition' | 'sql_schema' | 'graphql_schema'; confidence: number; file: string; method?: string; path?: string; request?: string; response?: string; snippet?: string; name?: string; params?: string[]; returnType?: string; line?: number; language?: string; kind?: string; fields?: string[]; operation?: string; table?: string; columns?: string[]; } export interface ExtractionResult { apiEndpoints: ExtractedContract[]; functionSignatures: ExtractedContract[]; typeDefinitions: ExtractedContract[]; sqlSchemas: ExtractedContract[]; graphqlSchemas: ExtractedContract[]; } export interface MamaDecisionFormat { type: 'decision'; topic: string; decision: string; reasoning: string; confidence: number; } /** Tools that trigger auto-save consideration */ export declare const EDIT_TOOLS: readonly string[]; /** Maximum number of contracts to save per extraction */ export declare const CONTRACT_SAVE_LIMIT = 20; /** Similarity threshold for auto-save suggestion */ export declare const SIMILARITY_THRESHOLD = 0.75; /** Files/paths that don't need contract tracking */ export declare const LOW_PRIORITY_PATTERNS: readonly RegExp[]; /** * Check if a file path matches low-priority patterns (docs, tests, config, etc.) */ export declare function isLowPriorityPath(filePath: string): boolean; /** * Extract API endpoint contracts from code * * Detects patterns like: * - app.post('/api/auth/register', ...) * - router.get('/users/:id', ...) * - @PostMapping("/api/users") */ export declare function extractApiContracts(code: string, filePath?: string): ExtractedContract[]; /** * Extract function signatures from code * * Detects patterns like: * - function createUser(email, password) { ... } * - const validateEmail = (email) => { ... } * - async def process_order(order_id): ... */ export declare function extractFunctionSignatures(code: string, filePath?: string): ExtractedContract[]; /** * Extract type definitions from code * * Detects patterns like: * - interface User { ... } * - type LoginRequest = { ... } * - class UserDTO { ... } */ export declare function extractTypeDefinitions(code: string, filePath?: string): ExtractedContract[]; /** * Extract SQL schemas from code * * Detects patterns like: * - CREATE TABLE users (id INT, email VARCHAR(255), ...) * - ALTER TABLE users ADD COLUMN name VARCHAR(255) */ export declare function extractSqlSchemas(code: string, filePath?: string): ExtractedContract[]; /** * Extract GraphQL schemas from code * * Detects patterns like: * - type User { id: ID!, email: String!, ... } * - input CreateUserInput { email: String!, password: String! } * - interface Node { id: ID! } */ export declare function extractGraphQLSchemas(code: string, filePath?: string): ExtractedContract[]; /** * Extract Go function signatures from code * * Detects patterns like: * - func CreateUser(email string, password string) (*User, error) * - func (s *Server) HandleLogin(w http.ResponseWriter, r *http.Request) */ export declare function extractGoSignatures(code: string, filePath?: string): ExtractedContract[]; /** * Extract Rust function signatures from code * * Detects patterns like: * - fn create_user(email: String, password: String) -> Result * - pub async fn login(credentials: LoginCredentials) -> Result */ export declare function extractRustSignatures(code: string, filePath?: string): ExtractedContract[]; /** * Extract all contracts from code */ export declare function extractContracts(code: string, filePath?: string): ExtractionResult; /** * Format contract for MAMA decision */ export declare function formatContractForMama(contract: ExtractedContract): MamaDecisionFormat | null; //# sourceMappingURL=contract-extractor.d.ts.map