The plugin system is implemented as a modular architecture with the following components:
-
PluginManager (
src/plugins/PluginManager.ts):- Core class responsible for discovering, loading, and managing plugins
- Implements lifecycle hooks (init, beforeBuild, afterBuild, etc.)
- Provides plugin registration and configuration API
-
PluginEnabledFileContextBuilder (
src/plugins/PluginEnabledFileContextBuilder.ts):- Extension of the base FileContextBuilder that integrates with plugins
- Calls appropriate plugin hooks during the context building process
- Manages plugin-specific configuration
-
Plugin Types:
- Security Scanners: Detect security issues in files
- Output Renderers: Format context in different ways
- LLM Reviewers: Use language models for code analysis
-
CLI Implementation (
src/cli/index.ts):- Command-line interface built with Commander.js
- Implements commands for all major features
- Provides help documentation and examples
-
Studio UI (
src/cli/studio/index.tsandsrc/cli/studio/public/):- Express-based web server for the UI
- Client-side JavaScript for interactive features
- WebSocket communication for real-time updates
-
GitIgnore Integration (
src/security/GitIgnoreIntegration.ts):- Parses .gitignore files and applies rules to file collection
- Supports nested .gitignore files in subdirectories
- Provides both automatic and manual configuration options
-
Sensitive Data Detection:
- Uses regex patterns to identify potential sensitive data
- Configurable patterns for different types of sensitive information
- Options for redaction or exclusion of sensitive content
-
RegexPatternMatcher (
src/collector/RegexPatternMatcher.ts):- Advanced pattern matching with regex support
- Context-aware matching with line number information
- Configurable match options (case sensitivity, whole word, etc.)
-
WhitelistBlacklist (
src/collector/WhitelistBlacklist.ts):- Precise control over file inclusion and exclusion
- Support for glob patterns and regex
- Priority-based resolution for conflicting rules
-
ListOnlySupport (
src/collector/ListOnlySupport.ts):- Include files in the tree without their contents
- Pattern-based configuration for list-only files
- Special handling for binary files
-
MarkdownRenderer (
src/plugins/output-renderers/MarkdownRenderer.ts):- Generates Markdown with syntax highlighting
- Creates table of contents and navigation links
- Includes security warnings and metadata
-
HTMLRenderer (
src/plugins/output-renderers/HTMLRenderer.ts):- Creates interactive HTML with collapsible sections
- Includes syntax highlighting and search functionality
- Provides visual indicators for security issues
-
BaseLLMReviewer (
src/plugins/llm-reviewers/BaseLLMReviewer.ts):- Abstract base class for LLM-based code reviewers
- Defines common interface and utilities
- Handles prompt generation and response parsing
-
LocalLLMReviewer (
src/plugins/llm-reviewers/LocalLLMReviewer.ts):- Implementation for local LLMs (Ollama, Llama, GPT4All)
- Manages communication with local LLM servers
- Processes and formats review results
The following TypeScript errors were fixed to enable proper building:
-
JsonRenderer.ts:
- Updated the
renderToObjectmethod to explicitly returnFileContextJsontype - Changed the JSDoc comment to clarify that
renderreturns a string
- Updated the
-
example-usage.ts:
- Changed to use
renderToObjectmethod instead ofrenderto get the typed object
- Changed to use
-
src/cli/studio/index.ts:
- Removed the
limitparameter frombodyParser.json() - Added explicit type annotation for the
configsarray - Updated the express.d.ts file to include the
deletemethod and overloadedlistenmethod
- Removed the
-
src/collector/RegexPatternMatcher.ts:
- Added explicit type annotation for the
resultsarray infindMatchesWithContext
- Added explicit type annotation for the
-
src/types/other-modules.d.ts:
- Added the
commandsproperty andname()method to theCommandclass
- Added the
-
src/plugins/llm-reviewers/LocalLLMReviewer.ts:
- Added explicit type annotations for arrays in the
parseReviewResponsemethod
- Added explicit type annotations for arrays in the
-
src/tree/TreeView.ts:
- Changed
integrateTreeWithCollectorto be an async function that returnsPromise<FileCollectorConfig> - Fixed indentation in the function body
- Changed
src/cli/: Command-line interface codesrc/plugins/: Plugin system implementationsrc/security/: Security-related featuressrc/tree/: Tree view implementationdocs/: Documentation filesexamples/: Example usage filesimages/: Diagrams and visual assetsscripts/: Utility scripts
run-contextr.js: Script to run ContextR without buildingtsconfig.esm.json: TypeScript configuration for ESM output- Various type definition files in
src/types/ - Test files in
__tests__/
-
File Collection Optimization:
- Improved handling of large files with streaming where appropriate
- Better caching of file content to reduce disk I/O
- Parallel processing for certain operations
-
Memory Usage:
- More efficient data structures for storing file content
- Options to limit memory usage for large projects
- Improved garbage collection hints
-
Unit Tests:
- Tests for individual components and functions
- Mocking of file system and external dependencies
- Coverage for edge cases and error handling
-
Integration Tests:
- Tests for interaction between components
- End-to-end tests for major features
- CLI command testing
-
Test Documentation:
- Comprehensive documentation in
docs/testing.md - Examples and expected results for each test type
- Instructions for running tests and interpreting results
- Comprehensive documentation in
All changes maintain backward compatibility with previous versions:
-
API Compatibility:
- Existing methods and properties retain their signatures
- New features are added as extensions rather than modifications
- Default behavior matches previous versions
-
Configuration Compatibility:
- Existing configuration options continue to work
- New options have sensible defaults
- Deprecated options are handled gracefully
-
Installation:
- Standard npm installation process
- No additional dependencies required for core functionality
- Optional dependencies for specific features (e.g., local LLM integration)
-
Versioning:
- Semantic versioning (1.1.0)
- Clear release notes in RELEASE_NOTES.md
- Migration guide for users of previous versions (though not strictly necessary due to backward compatibility)
-
Documentation:
- Updated README.md with new features
- Examples for all major features
- API documentation with TypeScript types