Refactor search modes and optimize embedding generation

- Updated the dashboard template to hide the Code Graph Explorer feature.
- Enhanced the `executeCodexLens` function to use `exec` for better cross-platform compatibility and improved command execution.
- Changed the default `maxResults` and `limit` parameters in the smart search tool to 10 for better performance.
- Introduced a new `priority` search mode in the smart search tool, replacing the previous `parallel` mode, which now follows a fallback strategy: hybrid -> exact -> ripgrep.
- Optimized the embedding generation process in the embedding manager by batching operations and using a cached embedder instance to reduce model loading overhead.
- Implemented a thread-safe singleton pattern for the embedder to improve performance across multiple searches.
This commit is contained in:
catlog22
2025-12-20 11:08:34 +08:00
parent 7adde91e9f
commit e1cac5dd50
16 changed files with 852 additions and 284 deletions

View File

@@ -5,6 +5,37 @@
// ========== HTML/Text Processing ==========
/**
* Encode JSON config data to Base64 for safe HTML attribute storage
* @param {Object} config - Configuration object to encode
* @returns {string} Base64 encoded JSON string
*/
function encodeConfigData(config) {
try {
const jsonStr = JSON.stringify(config);
return btoa(encodeURIComponent(jsonStr));
} catch (err) {
console.error('[Utils] Error encoding config data:', err);
return '';
}
}
/**
* Decode Base64 config data back to JSON object
* @param {string} encoded - Base64 encoded string
* @returns {Object|null} Decoded configuration object or null on error
*/
function decodeConfigData(encoded) {
try {
if (!encoded) return null;
const jsonStr = decodeURIComponent(atob(encoded));
return JSON.parse(jsonStr);
} catch (err) {
console.error('[Utils] Error decoding config data:', err);
return null;
}
}
/**
* Escape HTML special characters to prevent XSS attacks
* @param {string} str - String to escape