feat(ipuaro): implement indexer module (v0.3.0)

Add complete indexer infrastructure:
- FileScanner: recursive scanning with gitignore support
- ASTParser: tree-sitter based TS/JS/TSX/JSX parsing
- MetaAnalyzer: complexity metrics, dependency analysis
- IndexBuilder: symbol index and dependency graph
- Watchdog: file watching with chokidar and debouncing

321 tests, 96.38% coverage
This commit is contained in:
imfozilbek
2025-11-30 01:24:21 +05:00
parent 225480c806
commit d0c1ddc22e
20 changed files with 4249 additions and 16 deletions

View File

@@ -5,6 +5,73 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] - 0.3.0 Indexer (complete)
### Added
- **FileScanner (0.3.1)**
- Recursive directory scanning with async generator
- `.gitignore` support via `globby` (replaced `ignore` package for ESM compatibility)
- Filters: binary files, node_modules, dist, default ignore patterns
- Progress callback for UI integration
- `isTextFile()` and `readFileContent()` static utilities
- 22 unit tests
- **ASTParser (0.3.2)**
- Tree-sitter based parsing for TS, TSX, JS, JSX
- Extracts: imports, exports, functions, classes, interfaces, type aliases
- Import classification: internal, external, builtin (using `node:module` builtinModules)
- Graceful error handling with partial AST on syntax errors
- 30 unit tests
- **MetaAnalyzer (0.3.3)**
- Complexity metrics: LOC (excluding comments), nesting depth, cyclomatic complexity, overall score
- Dependency resolution: internal imports resolved to absolute file paths
- Dependents calculation: reverse dependency lookup across all project files
- File type classification: source, test, config, types, unknown
- Entry point detection: index files, main/app/cli/server patterns, files with no dependents
- Hub detection: files with >5 dependents
- Batch analysis via `analyzeAll()` method
- 54 unit tests
- **IndexBuilder (0.3.4)**
- SymbolIndex: maps symbol names to locations for quick lookup (functions, classes, interfaces, types, variables)
- Qualified names for class methods: `ClassName.methodName`
- DepsGraph: bidirectional import mapping (`imports` and `importedBy`)
- Import resolution: handles `.js``.ts`, index.ts, directory imports
- `findSymbol()`: exact symbol lookup
- `searchSymbols()`: regex-based symbol search
- `findCircularDependencies()`: detect import cycles
- `getStats()`: comprehensive index statistics (symbols by type, hubs, orphans)
- 35 unit tests
- **Watchdog (0.3.5)**
- File watching with chokidar (native events + polling fallback)
- Debounced change handling (configurable, default 500ms)
- Event types: add, change, unlink
- Extension filtering (default: SUPPORTED_EXTENSIONS)
- Ignore patterns (default: DEFAULT_IGNORE_PATTERNS)
- Multiple callback support
- `flushAll()` for immediate processing
- Silent error handling for stability
- 21 unit tests
- **Infrastructure Constants**
- `tree-sitter-types.ts`: NodeType and FieldName constants for tree-sitter
- Eliminates magic strings in ASTParser
- **Dependencies**
- Added `globby` for ESM-native file globbing
- Removed `ignore` package (CJS incompatibility with nodenext)
### Changed
- Refactored ASTParser to use constants instead of magic strings
- Total tests: 321
- Coverage: 96.43%
---
## [0.2.0] - 2025-01-30
### Added