Remove outdated tests for CodexLens and LiteLLM client, refactor Smart Search MCP usage tests to use new command structure, and clean up unified vector index tests.

This commit is contained in:
catlog22
2026-03-18 11:35:51 +08:00
parent ad9d3f94e0
commit df69f997e4
45 changed files with 64 additions and 11170 deletions

View File

@@ -3,7 +3,6 @@ import { URL } from 'url';
import { getCoreMemoryStore } from '../core-memory-store.js';
import type { CoreMemory, SessionCluster, ClusterMember, ClusterRelation } from '../core-memory-store.js';
import { getEmbeddingStatus, generateEmbeddings } from '../memory-embedder-bridge.js';
import { checkSemanticStatus } from '../../tools/codex-lens.js';
import { MemoryJobScheduler } from '../memory-job-scheduler.js';
import type { JobStatus } from '../memory-job-scheduler.js';
import { StoragePaths } from '../../config/storage-paths.js';
@@ -781,8 +780,8 @@ export async function handleCoreMemoryRoutes(ctx: RouteContext): Promise<boolean
const projectPath = url.searchParams.get('path') || initialPath;
try {
// Check semantic status using CodexLens's check (same as status page)
const semanticStatus = await checkSemanticStatus();
// Semantic status: codexlens v1 removed, always unavailable via this path
const semanticStatus = { available: false, error: 'Use codexlens MCP server instead' };
if (!semanticStatus.available) {
res.writeHead(200, { 'Content-Type': 'application/json' });
@@ -825,8 +824,7 @@ export async function handleCoreMemoryRoutes(ctx: RouteContext): Promise<boolean
const basePath = projectPath || initialPath;
try {
// Check semantic status using CodexLens's check
const semanticStatus = await checkSemanticStatus();
const semanticStatus = { available: false, error: 'Use codexlens MCP server instead' };
if (!semanticStatus.available) {
return { error: semanticStatus.error || 'Semantic search not available. Install it from CLI > CodexLens > Semantic page.', status: 503 };
}

View File

@@ -1084,7 +1084,35 @@ function isRecord(value: unknown): value is Record<string, unknown> {
* Handle MCP routes
* @returns true if route was handled, false otherwise
*/
// Seed built-in MCP templates once
let _templateSeeded = false;
function seedBuiltinTemplates(): void {
if (_templateSeeded) return;
_templateSeeded = true;
try {
McpTemplatesDb.saveTemplate({
name: 'codexlens',
description: 'CodexLens semantic code search (vector + FTS + reranking)',
serverConfig: {
command: 'uvx',
args: ['--from', 'codexlens-search[mcp]', 'codexlens-mcp'],
env: {
CODEXLENS_EMBED_API_URL: '',
CODEXLENS_EMBED_API_KEY: '',
CODEXLENS_EMBED_API_MODEL: 'text-embedding-3-small',
CODEXLENS_EMBED_DIM: '1536',
},
},
category: 'code-search',
tags: ['search', 'semantic', 'code-intelligence'],
});
} catch {
// Template may already exist — ignore upsert errors
}
}
export async function handleMcpRoutes(ctx: RouteContext): Promise<boolean> {
seedBuiltinTemplates();
const { pathname, url, req, res, initialPath, handlePostRequest, broadcastToClients } = ctx;
// API: Get MCP configuration (includes both Claude and Codex)
@@ -1230,13 +1258,13 @@ export async function handleMcpRoutes(ctx: RouteContext): Promise<boolean> {
const enabledToolsRaw = envInput.enabledTools;
let enabledToolsEnv: string;
if (enabledToolsRaw === undefined || enabledToolsRaw === null) {
enabledToolsEnv = 'write_file,edit_file,read_file,core_memory,ask_question,smart_search';
enabledToolsEnv = 'write_file,edit_file,read_file,core_memory,ask_question';
} else if (Array.isArray(enabledToolsRaw)) {
enabledToolsEnv = enabledToolsRaw.filter((t): t is string => typeof t === 'string').join(',');
} else if (typeof enabledToolsRaw === 'string') {
enabledToolsEnv = enabledToolsRaw;
} else {
enabledToolsEnv = 'write_file,edit_file,read_file,core_memory,ask_question,smart_search';
enabledToolsEnv = 'write_file,edit_file,read_file,core_memory,ask_question';
}
const projectRoot = typeof envInput.projectRoot === 'string' ? envInput.projectRoot : undefined;

View File

@@ -10,8 +10,8 @@ import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import { getAllToolSchemas, executeTool, executeToolWithProgress } from '../tools/index.js';
import type { ToolSchema, ToolResult } from '../types/tool.js';
import { getAllToolSchemas, executeTool } from '../tools/index.js';
import type { ToolSchema } from '../types/tool.js';
import { getProjectRoot, getAllowedDirectories, isSandboxEnabled } from '../utils/path-validator.js';
const SERVER_NAME = 'ccw-tools';
@@ -23,7 +23,7 @@ const ENV_ALLOWED_DIRS = 'CCW_ALLOWED_DIRS';
const STDIO_DISCONNECT_ERROR_CODES = new Set(['EPIPE', 'ERR_STREAM_DESTROYED']);
// Default enabled tools (core set - file operations, core memory, and smart search)
const DEFAULT_TOOLS: string[] = ['write_file', 'edit_file', 'read_file', 'read_many_files', 'read_outline', 'core_memory', 'smart_search'];
const DEFAULT_TOOLS: string[] = ['write_file', 'edit_file', 'read_file', 'read_many_files', 'read_outline', 'core_memory'];
/**
* Get list of enabled tools from environment or defaults
@@ -151,19 +151,7 @@ function createServer(): Server {
}
try {
// For smart_search init action, use progress-aware execution
const isInitAction = name === 'smart_search' && args?.action === 'init';
let result: ToolResult;
if (isInitAction) {
// Execute with progress callback that writes to stderr
result = await executeToolWithProgress(name, args || {}, (progress) => {
// Output progress to stderr (visible in terminal, doesn't interfere with JSON-RPC)
console.error(`[Progress] ${progress.percent}% - ${progress.message}`);
});
} else {
result = await executeTool(name, args || {});
}
const result = await executeTool(name, args || {});
if (!result.success) {
return {

View File

@@ -1,213 +0,0 @@
/**
* CodexLens Tool - STUB (v1 removed)
*
* The v1 Python bridge has been removed. This module provides no-op stubs
* so that existing consumers compile without errors.
* Semantic search is now handled entirely by codexlens-search v2.
*/
import type { ToolSchema, ToolResult } from '../types/tool.js';
// ---------------------------------------------------------------------------
// Types (kept for backward compatibility)
// ---------------------------------------------------------------------------
interface ReadyStatus {
ready: boolean;
installed: boolean;
error?: string;
version?: string;
pythonVersion?: string;
venvPath?: string;
}
interface SemanticStatus {
available: boolean;
backend?: string;
accelerator?: string;
providers?: string[];
litellmAvailable?: boolean;
error?: string;
}
interface BootstrapResult {
success: boolean;
message?: string;
error?: string;
details?: {
pythonVersion?: string;
venvPath?: string;
packagePath?: string;
installer?: 'uv' | 'pip';
editable?: boolean;
};
}
interface ExecuteResult {
success: boolean;
output?: string;
error?: string;
message?: string;
warning?: string;
results?: unknown;
files?: unknown;
symbols?: unknown;
}
interface ExecuteOptions {
timeout?: number;
cwd?: string;
onProgress?: (progress: ProgressInfo) => void;
}
interface ProgressInfo {
stage: string;
message: string;
percent: number;
filesProcessed?: number;
totalFiles?: number;
}
type GpuMode = 'cpu' | 'cuda' | 'directml';
interface PythonEnvInfo {
version: string;
majorMinor: string;
architecture: number;
compatible: boolean;
error?: string;
}
// ---------------------------------------------------------------------------
// No-op implementations
// ---------------------------------------------------------------------------
const V1_REMOVED = 'CodexLens v1 has been removed. Use codexlens-search v2.';
async function ensureReady(): Promise<ReadyStatus> {
return { ready: false, installed: false, error: V1_REMOVED };
}
async function executeCodexLens(_args: string[], _options: ExecuteOptions = {}): Promise<ExecuteResult> {
return { success: false, error: V1_REMOVED };
}
async function checkVenvStatus(_force?: boolean): Promise<ReadyStatus> {
return { ready: false, installed: false, error: V1_REMOVED };
}
async function bootstrapVenv(): Promise<BootstrapResult> {
return { success: false, error: V1_REMOVED };
}
async function checkSemanticStatus(_force?: boolean): Promise<SemanticStatus> {
return { available: false, error: V1_REMOVED };
}
async function ensureLiteLLMEmbedderReady(): Promise<BootstrapResult> {
return { success: false, error: V1_REMOVED };
}
async function installSemantic(_gpuMode: GpuMode = 'cpu'): Promise<BootstrapResult> {
return { success: false, error: V1_REMOVED };
}
async function detectGpuSupport(): Promise<{ mode: GpuMode; available: GpuMode[]; info: string; pythonEnv?: PythonEnvInfo }> {
return { mode: 'cpu', available: ['cpu'], info: V1_REMOVED };
}
async function uninstallCodexLens(): Promise<BootstrapResult> {
return { success: false, error: V1_REMOVED };
}
function cancelIndexing(): { success: boolean; message?: string; error?: string } {
return { success: false, error: V1_REMOVED };
}
function isIndexingInProgress(): boolean {
return false;
}
async function bootstrapWithUv(_gpuMode: GpuMode = 'cpu'): Promise<BootstrapResult> {
return { success: false, error: V1_REMOVED };
}
async function installSemanticWithUv(_gpuMode: GpuMode = 'cpu'): Promise<BootstrapResult> {
return { success: false, error: V1_REMOVED };
}
function useCodexLensV2(): boolean {
return true; // v2 is now the only option
}
function isCodexLensV2Installed(): boolean {
return false;
}
async function bootstrapV2WithUv(): Promise<BootstrapResult> {
return { success: false, error: V1_REMOVED };
}
function getVenvPythonPath(): string {
return 'python';
}
// ---------------------------------------------------------------------------
// Tool schema / handler (no-op)
// ---------------------------------------------------------------------------
export const schema: ToolSchema = {
name: 'codex_lens',
description: '[REMOVED] CodexLens v1 tool has been removed. Use smart_search instead.',
inputSchema: {
type: 'object',
properties: {
action: { type: 'string', description: 'Action (v1 removed)' },
},
},
};
export async function handler(_params: Record<string, unknown>): Promise<ToolResult<ExecuteResult>> {
return {
success: false,
error: V1_REMOVED,
result: { success: false, error: V1_REMOVED },
};
}
// ---------------------------------------------------------------------------
// Exports
// ---------------------------------------------------------------------------
export type { ProgressInfo, ExecuteOptions, GpuMode, PythonEnvInfo };
export {
ensureReady,
executeCodexLens,
checkVenvStatus,
bootstrapVenv,
checkSemanticStatus,
ensureLiteLLMEmbedderReady,
installSemantic,
detectGpuSupport,
uninstallCodexLens,
cancelIndexing,
isIndexingInProgress,
bootstrapWithUv,
installSemanticWithUv,
useCodexLensV2,
isCodexLensV2Installed,
bootstrapV2WithUv,
getVenvPythonPath,
};
export const __testables = {};
export const codexLensTool = {
name: schema.name,
description: schema.description,
parameters: schema.inputSchema,
execute: async (_params: Record<string, unknown>) => {
return { success: false, error: V1_REMOVED };
},
};

View File

@@ -18,10 +18,7 @@ import * as generateDddDocsMod from './generate-ddd-docs.js';
import * as convertTokensToCssMod from './convert-tokens-to-css.js';
import * as sessionManagerMod from './session-manager.js';
import * as cliExecutorMod from './cli-executor.js';
import * as smartSearchMod from './smart-search.js';
import { executeInitWithProgress } from './smart-search.js';
// codex_lens removed - functionality integrated into smart_search
// codex_lens_lsp removed - v1 LSP bridge removed
// codex_lens / smart_search removed - use codexlens MCP server instead
import * as readFileMod from './read-file.js';
import * as readManyFilesMod from './read-many-files.js';
import * as readOutlineMod from './read-outline.js';
@@ -30,7 +27,7 @@ import * as contextCacheMod from './context-cache.js';
import * as skillContextLoaderMod from './skill-context-loader.js';
import * as askQuestionMod from './ask-question.js';
import * as teamMsgMod from './team-msg.js';
import type { ProgressInfo } from './codex-lens.js';
// Import legacy JS tools
import { uiGeneratePreviewTool } from './ui-generate-preview.js';
@@ -272,60 +269,6 @@ function sanitizeResult(result: unknown): unknown {
return result;
}
/**
* Execute a tool with progress callback (for init actions)
*/
export async function executeToolWithProgress(
name: string,
params: Record<string, unknown> = {},
onProgress?: (progress: ProgressInfo) => void
): Promise<{
success: boolean;
result?: unknown;
error?: string;
}> {
// For smart_search init, use special progress-aware execution
if (name === 'smart_search' && params.action === 'init') {
try {
// Notify dashboard - execution started
notifyDashboard({
toolName: name,
status: 'started',
params: sanitizeParams(params)
});
const result = await executeInitWithProgress(params, onProgress);
// Notify dashboard - execution completed
notifyDashboard({
toolName: name,
status: 'completed',
result: sanitizeResult(result)
});
return {
success: result.success,
result,
error: result.error
};
} catch (error) {
notifyDashboard({
toolName: name,
status: 'failed',
error: (error as Error).message || 'Tool execution failed'
});
return {
success: false,
error: (error as Error).message || 'Tool execution failed'
};
}
}
// Fall back to regular execution for other tools
return executeTool(name, params);
}
/**
* Get tool schema in MCP-compatible format
*/
@@ -363,9 +306,7 @@ registerTool(toLegacyTool(generateDddDocsMod));
registerTool(toLegacyTool(convertTokensToCssMod));
registerTool(toLegacyTool(sessionManagerMod));
registerTool(toLegacyTool(cliExecutorMod));
registerTool(toLegacyTool(smartSearchMod));
// codex_lens removed - functionality integrated into smart_search
// codex_lens_lsp removed - v1 LSP bridge removed
// codex_lens / smart_search removed - use codexlens MCP server instead
registerTool(toLegacyTool(readFileMod));
registerTool(toLegacyTool(readManyFilesMod));
registerTool(toLegacyTool(readOutlineMod));

View File

@@ -4,7 +4,9 @@
* Auto-generates contextual file references for CLI execution
*/
import { executeCodexLens, ensureReady as ensureCodexLensReady } from './codex-lens.js';
// codex-lens v1 removed — no-op stubs for backward compatibility
async function ensureCodexLensReady(): Promise<{ ready: boolean }> { return { ready: false }; }
async function executeCodexLens(_args: string[], _opts?: { cwd?: string }): Promise<{ success: boolean; output?: string }> { return { success: false }; }
// Options for smart context generation
export interface SmartContextOptions {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff