UNPKG

claude-flow-novice

Version:

Claude Flow Novice - Advanced orchestration platform for multi-agent AI workflows with CFN Loop architecture Includes Local RuVector Accelerator and all CFN skills for complete functionality.

72 lines (71 loc) 2.01 kB
/** * File Processor - Extracts indexable text from source files */ import * as fs from 'fs/promises'; import * as path from 'path'; const LANGUAGE_MAP = { '.ts': 'typescript', '.tsx': 'typescript', '.js': 'javascript', '.jsx': 'javascript', '.mjs': 'javascript', '.py': 'python', '.rb': 'ruby', '.go': 'go', '.rs': 'rust', '.java': 'java', '.kt': 'kotlin', '.swift': 'swift', '.c': 'c', '.cpp': 'cpp', '.h': 'c', '.hpp': 'cpp', '.cs': 'csharp', '.php': 'php', '.md': 'markdown', '.mdx': 'markdown', '.json': 'json', '.yaml': 'yaml', '.yml': 'yaml', '.html': 'html', '.css': 'css', '.scss': 'scss', '.sql': 'sql', '.sh': 'shell', '.bash': 'shell' }; export class SourceFileProcessor { maxFileSize; constructor(maxFileSize = 100 * 1024){ this.maxFileSize = maxFileSize; } canProcess(filePath) { const ext = path.extname(filePath).toLowerCase(); return ext in LANGUAGE_MAP; } async process(filePath) { try { const stats = await fs.stat(filePath); if (stats.size > this.maxFileSize || !stats.isFile()) return null; const content = await fs.readFile(filePath, 'utf-8'); const ext = path.extname(filePath).toLowerCase(); const language = LANGUAGE_MAP[ext] ?? 'unknown'; let processed = content.replace(/\n{3,}/g, '\n\n'); const maxChars = 8000; if (processed.length > maxChars) { processed = processed.slice(0, maxChars) + '\n[truncated]'; } return { path: filePath, content: processed.trim(), language, size: stats.size }; } catch { return null; } } } export function createFileProcessor(maxFileSize) { return new SourceFileProcessor(maxFileSize); } //# sourceMappingURL=file-processor.js.map