mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-14 02:42:04 +08:00
Refactor Codex Lens config handling and CLI tools status checks
- Updated Codex Lens config handler to extract embeddings data from the new response structure, including coverage percentage and total files with embeddings. - Enhanced CLI tools status function to handle different tool types (builtin, cli-wrapper, api-endpoint) with improved logic for checking availability based on configuration. - Removed obsolete test files and directories that are no longer needed.
This commit is contained in:
1848
Install-Claude.sh
1848
Install-Claude.sh
File diff suppressed because it is too large
Load Diff
@@ -170,9 +170,13 @@ export async function handleCodexLensConfigRoutes(ctx: RouteContext): Promise<bo
|
|||||||
const indexedFiles = projectData.total_files || 0; // All indexed files have FTS
|
const indexedFiles = projectData.total_files || 0; // All indexed files have FTS
|
||||||
|
|
||||||
// Get embeddings data from index status
|
// Get embeddings data from index status
|
||||||
const filesWithEmbeddings = embeddingsData?.files_with_embeddings || 0;
|
// The response structure is: { total_indexes, indexes_with_embeddings, total_chunks, indexes: [{coverage_percent, total_files, ...}] }
|
||||||
|
const indexesWithEmbeddings = embeddingsData?.indexes_with_embeddings || 0;
|
||||||
const totalChunks = embeddingsData?.total_chunks || 0;
|
const totalChunks = embeddingsData?.total_chunks || 0;
|
||||||
const vectorPercent = embeddingsData?.coverage_percent || 0;
|
// coverage_percent is in the indexes array - get the first one (for single project query)
|
||||||
|
const indexEntry = embeddingsData?.indexes?.[0];
|
||||||
|
const vectorPercent = indexEntry?.coverage_percent || 0;
|
||||||
|
const filesWithEmbeddings = indexEntry?.total_files || 0;
|
||||||
|
|
||||||
// FTS percentage (all indexed files have FTS, so it's always 100% if indexed)
|
// FTS percentage (all indexed files have FTS, so it's always 100% if indexed)
|
||||||
const ftsPercent = totalFiles > 0 ? 100 : 0;
|
const ftsPercent = totalFiles > 0 ? 100 : 0;
|
||||||
|
|||||||
@@ -1184,21 +1184,42 @@ export {
|
|||||||
/**
|
/**
|
||||||
* Get status of all CLI tools
|
* Get status of all CLI tools
|
||||||
* Dynamically reads tools from config file
|
* Dynamically reads tools from config file
|
||||||
|
* Handles different tool types:
|
||||||
|
* - builtin: Check system PATH availability
|
||||||
|
* - cli-wrapper: Check CLI Settings configuration exists
|
||||||
|
* - api-endpoint: Check LiteLLM endpoint configuration exists
|
||||||
*/
|
*/
|
||||||
export async function getCliToolsStatus(): Promise<Record<string, ToolAvailability>> {
|
export async function getCliToolsStatus(): Promise<Record<string, ToolAvailability>> {
|
||||||
// Default built-in tools
|
// Default built-in tools
|
||||||
const builtInTools = ['gemini', 'qwen', 'codex', 'claude', 'opencode'];
|
const builtInTools = ['gemini', 'qwen', 'codex', 'claude', 'opencode'];
|
||||||
|
|
||||||
// Try to get tools from config
|
// Try to get tools from config with their types
|
||||||
let tools = builtInTools;
|
interface ToolInfo {
|
||||||
|
name: string;
|
||||||
|
type?: 'builtin' | 'cli-wrapper' | 'api-endpoint';
|
||||||
|
enabled?: boolean;
|
||||||
|
id?: string; // For api-endpoint type
|
||||||
|
}
|
||||||
|
let toolsInfo: ToolInfo[] = builtInTools.map(name => ({ name, type: 'builtin' }));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Dynamic import to avoid circular dependencies
|
// Dynamic import to avoid circular dependencies
|
||||||
const { loadClaudeCliTools } = await import('./claude-cli-tools.js');
|
const { loadClaudeCliTools } = await import('./claude-cli-tools.js');
|
||||||
const config = loadClaudeCliTools(configBaseDir);
|
const config = loadClaudeCliTools(configBaseDir);
|
||||||
if (config.tools && typeof config.tools === 'object') {
|
if (config.tools && typeof config.tools === 'object') {
|
||||||
// Merge built-in tools with config tools to ensure all are checked
|
// Build complete tool info list from config
|
||||||
const configTools = Object.keys(config.tools);
|
const configToolsInfo: ToolInfo[] = Object.entries(config.tools).map(([name, toolConfig]) => ({
|
||||||
tools = [...new Set([...builtInTools, ...configTools])];
|
name,
|
||||||
|
type: toolConfig.type || 'builtin',
|
||||||
|
enabled: toolConfig.enabled !== false,
|
||||||
|
id: toolConfig.id
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Merge: config tools take precedence over built-in defaults
|
||||||
|
const toolsMap = new Map<string, ToolInfo>();
|
||||||
|
toolsInfo.forEach(t => toolsMap.set(t.name, t));
|
||||||
|
configToolsInfo.forEach(t => toolsMap.set(t.name, t));
|
||||||
|
toolsInfo = Array.from(toolsMap.values());
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Fallback to built-in tools if config load fails
|
// Fallback to built-in tools if config load fails
|
||||||
@@ -1207,8 +1228,49 @@ export async function getCliToolsStatus(): Promise<Record<string, ToolAvailabili
|
|||||||
|
|
||||||
const results: Record<string, ToolAvailability> = {};
|
const results: Record<string, ToolAvailability> = {};
|
||||||
|
|
||||||
await Promise.all(tools.map(async (tool) => {
|
await Promise.all(toolsInfo.map(async (toolInfo) => {
|
||||||
results[tool] = await checkToolAvailability(tool);
|
const { name, type, enabled, id } = toolInfo;
|
||||||
|
|
||||||
|
// Check availability based on tool type
|
||||||
|
if (type === 'cli-wrapper') {
|
||||||
|
// For cli-wrapper: check if CLI Settings configuration exists
|
||||||
|
try {
|
||||||
|
const { findEndpoint } = await import('../config/cli-settings-manager.js');
|
||||||
|
const endpoint = findEndpoint(name);
|
||||||
|
if (endpoint && endpoint.enabled) {
|
||||||
|
results[name] = {
|
||||||
|
available: true,
|
||||||
|
path: `cli-settings:${endpoint.id}` // Virtual path indicating CLI Settings source
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
results[name] = { available: false, path: null };
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debugLog('cli-executor', `Failed to check cli-wrapper ${name}: ${(e as Error).message}`);
|
||||||
|
results[name] = { available: false, path: null };
|
||||||
|
}
|
||||||
|
} else if (type === 'api-endpoint') {
|
||||||
|
// For api-endpoint: check if LiteLLM endpoint configuration exists
|
||||||
|
try {
|
||||||
|
const { findEndpointById } = await import('../config/litellm-api-config-manager.js');
|
||||||
|
const endpointId = id || name;
|
||||||
|
const endpoint = findEndpointById(configBaseDir, endpointId);
|
||||||
|
if (endpoint && enabled !== false) {
|
||||||
|
results[name] = {
|
||||||
|
available: true,
|
||||||
|
path: `litellm:${endpointId}` // Virtual path indicating LiteLLM source
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
results[name] = { available: false, path: null };
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debugLog('cli-executor', `Failed to check api-endpoint ${name}: ${(e as Error).message}`);
|
||||||
|
results[name] = { available: false, path: null };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// For builtin: check system PATH availability
|
||||||
|
results[name] = await checkToolAvailability(name);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
import '../ccw/tests/integration/cli-executor/setup.test.ts';
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# Test README\n\nThis is a test file for vector indexing.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
// Test file for embedding generation\nfunction testEmbedding() {\n console.log('Hello world');\n}\n\nexport default testEmbedding;
|
|
||||||
Reference in New Issue
Block a user