mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
feat: 更新 CodexLens 项目状态获取逻辑,使用 'projects show' 命令并添加索引状态检查
This commit is contained in:
@@ -113,8 +113,8 @@ export async function handleCodexLensConfigRoutes(ctx: RouteContext): Promise<bo
|
|||||||
// Use path from query param, fallback to initialPath
|
// Use path from query param, fallback to initialPath
|
||||||
const projectPath = url.searchParams.get('path') || initialPath;
|
const projectPath = url.searchParams.get('path') || initialPath;
|
||||||
|
|
||||||
// Get project info for current workspace
|
// Get project info using 'projects show' command
|
||||||
const projectResult = await executeCodexLens(['projects', 'get', projectPath, '--json']);
|
const projectResult = await executeCodexLens(['projects', 'show', projectPath, '--json']);
|
||||||
|
|
||||||
if (!projectResult.success) {
|
if (!projectResult.success) {
|
||||||
// No index for this workspace
|
// No index for this workspace
|
||||||
@@ -150,17 +150,32 @@ export async function handleCodexLensConfigRoutes(ctx: RouteContext): Promise<bo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get index status for embeddings coverage using 'index status' command
|
||||||
|
const indexStatusResult = await executeCodexLens(['index', 'status', projectPath, '--json']);
|
||||||
|
|
||||||
|
let embeddingsData: any = null;
|
||||||
|
if (indexStatusResult.success && indexStatusResult.output) {
|
||||||
|
try {
|
||||||
|
const parsed = extractJSON(indexStatusResult.output);
|
||||||
|
if (parsed.success && parsed.result?.embeddings) {
|
||||||
|
embeddingsData = parsed.result.embeddings;
|
||||||
|
}
|
||||||
|
} catch (e: unknown) {
|
||||||
|
console.error('[CodexLens] Failed to parse index status:', e instanceof Error ? e.message : String(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate FTS and Vector percentages
|
// Calculate FTS and Vector percentages
|
||||||
const totalFiles = projectData.total_files || 0;
|
const totalFiles = projectData.total_files || 0;
|
||||||
const indexedFiles = projectData.indexed_files || projectData.total_files || 0;
|
const indexedFiles = projectData.total_files || 0; // All indexed files have FTS
|
||||||
const filesWithEmbeddings = projectData.files_with_embeddings || projectData.embedded_files || 0;
|
|
||||||
const totalChunks = projectData.total_chunks || projectData.embedded_chunks || 0;
|
|
||||||
|
|
||||||
// FTS percentage (all indexed files have FTS)
|
// Get embeddings data from index status
|
||||||
const ftsPercent = totalFiles > 0 ? Math.round((indexedFiles / totalFiles) * 100) : 0;
|
const filesWithEmbeddings = embeddingsData?.files_with_embeddings || 0;
|
||||||
|
const totalChunks = embeddingsData?.total_chunks || 0;
|
||||||
|
const vectorPercent = embeddingsData?.coverage_percent || 0;
|
||||||
|
|
||||||
// Vector percentage (files with embeddings)
|
// FTS percentage (all indexed files have FTS, so it's always 100% if indexed)
|
||||||
const vectorPercent = totalFiles > 0 ? Math.round((filesWithEmbeddings / totalFiles) * 1000) / 10 : 0;
|
const ftsPercent = totalFiles > 0 ? 100 : 0;
|
||||||
|
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||||
res.end(JSON.stringify({
|
res.end(JSON.stringify({
|
||||||
|
|||||||
Reference in New Issue
Block a user