Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
- [ ] Modify `src/agent.js` to detect and read `Coderrr.md` file
- [ ] Integrate custom prompt content into enhanced prompt in chat method
- [ ] Test the feature with a sample Coderrr.md file
- [ ] Ensure backward compatibility when no Coderrr.md exists
=======
# TODO: Implement Coderrr.md Custom System Prompt Feature

- [x] Modify `src/agent.js` to detect and read `Coderrr.md` file
- [x] Integrate custom prompt content into enhanced prompt in chat method
- [ ] Test the feature with a sample Coderrr.md file
- [ ] Ensure backward compatibility when no Coderrr.md exists
# Refactor CodebaseScanner - Break into Smaller Classes

## Overview
The CodebaseScanner class is too large (500+ lines) and has multiple responsibilities. Refactor into smaller, focused classes while maintaining backward compatibility.

## Classes to Create
- [x] FileScanner: Directory scanning, file discovery, filtering
- [x] CacheManager: Caching of scan results
- [x] SearchEngine: Semantic, regex, fuzzy search functionality
- [x] ContentProcessor: Content chunking for large files
- [x] Refactor CodebaseScanner: Make it a facade orchestrating the above classes

## Implementation Steps
1. [x] Create FileScanner class in src/fileScanner.js
2. [x] Create CacheManager class in src/cacheManager.js
3. [x] Create SearchEngine class in src/searchEngine.js
4. [x] Create ContentProcessor class in src/contentProcessor.js
5. [x] Update CodebaseScanner to use the new classes
6. [x] Test the refactored code

## Files to Modify
- [x] src/codebaseScanner.js (refactor to use new classes)
- [x] Create: src/fileScanner.js
- [x] Create: src/cacheManager.js
- [x] Create: src/searchEngine.js
- [x] Create: src/contentProcessor.js
12 changes: 4 additions & 8 deletions src/agent.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
const axios = require('axios');
const fs = require('fs');
const path = require('path');
const ui = require('./ui');
const FileOperations = require('./fileOps');
const CommandExecutor = require('./executor').CommandExecutor;
const TodoManager = require('./todoManager');
const GitOperations = require('./gitOps');
=======
const CodebaseScanner = require('./codebaseScanner');
const SearchUtils = require('./searchUtils');
const GitOperations = require('./gitOps');
const { sanitizeAxiosError, formatUserError, createSafeError, isNetworkError } = require('./errorHandler');
const configManager = require('./configManager');
Expand Down Expand Up @@ -970,4 +966,4 @@ Current State:
}
}

module.exports = Agent;
module.exports = Agent;
56 changes: 56 additions & 0 deletions src/cacheManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* CacheManager - Handles caching of scan results
* Provides simple time-based caching with configurable duration
*/

class CacheManager {
constructor(cacheDuration = 60000) { // 1 minute default
this.cache = null;
this.cacheTimestamp = null;
this.cacheDuration = cacheDuration;
}

/**
* Check if cache is valid (not expired)
*/
isCacheValid() {
if (!this.cache || !this.cacheTimestamp) {
return false;
}

const now = Date.now();
return (now - this.cacheTimestamp) < this.cacheDuration;
}

/**
* Get cached data if valid
*/
get() {
return this.isCacheValid() ? this.cache : null;
}

/**
* Set cache data with current timestamp
*/
set(data) {
this.cache = data;
this.cacheTimestamp = Date.now();
}

/**
* Clear the cache
*/
clear() {
this.cache = null;
this.cacheTimestamp = null;
}

/**
* Set cache duration
*/
setCacheDuration(duration) {
this.cacheDuration = duration;
}
}

module.exports = CacheManager;
Loading
Loading