mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
feat: update CLI commands to new structure and enhance settings handling
This commit is contained in:
@@ -605,15 +605,16 @@ export async function handleCodexLensRoutes(ctx: RouteContext): Promise<boolean>
|
||||
}
|
||||
|
||||
// Build CLI arguments based on index type
|
||||
const args = ['init', targetPath, '--json'];
|
||||
// Use 'index init' subcommand (new CLI structure)
|
||||
const args = ['index', 'init', targetPath, '--json'];
|
||||
if (indexType === 'normal') {
|
||||
args.push('--no-embeddings');
|
||||
} else {
|
||||
// Add embedding model selection for vector index
|
||||
args.push('--embedding-model', embeddingModel);
|
||||
// Add embedding backend if not using default fastembed
|
||||
// Add embedding model selection for vector index (use --model, not --embedding-model)
|
||||
args.push('--model', embeddingModel);
|
||||
// Add embedding backend if not using default fastembed (use --backend, not --embedding-backend)
|
||||
if (embeddingBackend && embeddingBackend !== 'fastembed') {
|
||||
args.push('--embedding-backend', embeddingBackend);
|
||||
args.push('--backend', embeddingBackend);
|
||||
}
|
||||
// Add max workers for concurrent API calls (useful for litellm backend)
|
||||
if (maxWorkers && maxWorkers > 1) {
|
||||
@@ -786,7 +787,8 @@ export async function handleCodexLensRoutes(ctx: RouteContext): Promise<boolean>
|
||||
try {
|
||||
// Request more results to support split (full content + extra files)
|
||||
const totalToFetch = limit + extraFilesCount;
|
||||
const args = ['search', query, '--path', projectPath, '--limit', totalToFetch.toString(), '--mode', mode, '--json'];
|
||||
// Use --method instead of deprecated --mode
|
||||
const args = ['search', query, '--path', projectPath, '--limit', totalToFetch.toString(), '--method', mode, '--json'];
|
||||
|
||||
const result = await executeCodexLens(args, { cwd: projectPath });
|
||||
|
||||
@@ -853,7 +855,8 @@ export async function handleCodexLensRoutes(ctx: RouteContext): Promise<boolean>
|
||||
}
|
||||
|
||||
try {
|
||||
const args = ['search', query, '--path', projectPath, '--limit', limit.toString(), '--mode', mode, '--files-only', '--json'];
|
||||
// Use --method instead of deprecated --mode
|
||||
const args = ['search', query, '--path', projectPath, '--limit', limit.toString(), '--method', mode, '--files-only', '--json'];
|
||||
|
||||
const result = await executeCodexLens(args, { cwd: projectPath });
|
||||
|
||||
@@ -1681,7 +1684,8 @@ except Exception as e:
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await executeCodexLens(['splade-index', projectPath, '--rebuild'], {
|
||||
// Use 'index splade' instead of deprecated 'splade-index'
|
||||
const result = await executeCodexLens(['index', 'splade', projectPath, '--rebuild'], {
|
||||
cwd: projectPath,
|
||||
timeout: 1800000 // 30 minutes for large codebases
|
||||
});
|
||||
@@ -1769,12 +1773,39 @@ except Exception as e:
|
||||
envVars[key] = value;
|
||||
}
|
||||
|
||||
// Also read settings.json for current configuration
|
||||
const settingsPath = join(homedir(), '.codexlens', 'settings.json');
|
||||
let settings: Record<string, any> = {};
|
||||
try {
|
||||
const settingsContent = await readFile(settingsPath, 'utf-8');
|
||||
settings = JSON.parse(settingsContent);
|
||||
} catch (e) {
|
||||
// Settings file doesn't exist or is invalid, use empty
|
||||
}
|
||||
|
||||
// Map settings to env var format for defaults
|
||||
const settingsDefaults: Record<string, string> = {};
|
||||
if (settings.embedding?.backend) {
|
||||
settingsDefaults['CODEXLENS_EMBEDDING_BACKEND'] = settings.embedding.backend;
|
||||
}
|
||||
if (settings.embedding?.model) {
|
||||
settingsDefaults['CODEXLENS_EMBEDDING_MODEL'] = settings.embedding.model;
|
||||
}
|
||||
if (settings.reranker?.backend) {
|
||||
// Map 'api' to 'litellm' for UI consistency
|
||||
settingsDefaults['CODEXLENS_RERANKER_BACKEND'] = settings.reranker.backend === 'api' ? 'litellm' : settings.reranker.backend;
|
||||
}
|
||||
if (settings.reranker?.model) {
|
||||
settingsDefaults['CODEXLENS_RERANKER_MODEL'] = settings.reranker.model;
|
||||
}
|
||||
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({
|
||||
success: true,
|
||||
path: envPath,
|
||||
env: envVars,
|
||||
raw: content
|
||||
raw: content,
|
||||
settings: settingsDefaults
|
||||
}));
|
||||
} catch (err) {
|
||||
res.writeHead(500, { 'Content-Type': 'application/json' });
|
||||
|
||||
@@ -670,8 +670,8 @@ var ENV_VAR_GROUPS = {
|
||||
icon: 'hard-drive',
|
||||
showWhen: function(env) { return env['CODEXLENS_EMBEDDING_BACKEND'] !== 'litellm' || env['CODEXLENS_RERANKER_BACKEND'] !== 'litellm'; },
|
||||
vars: {
|
||||
'CODEXLENS_EMBEDDING_MODEL': { label: 'Embedding Model', placeholder: 'fast (code, base, minilm, multilingual, balanced)' },
|
||||
'CODEXLENS_RERANKER_MODEL': { label: 'Reranker Model', placeholder: 'Xenova/ms-marco-MiniLM-L-6-v2' }
|
||||
'CODEXLENS_EMBEDDING_MODEL': { label: 'Embedding Model', placeholder: 'fast (code, base, minilm, multilingual, balanced)', default: 'fast' },
|
||||
'CODEXLENS_RERANKER_MODEL': { label: 'Reranker Model', placeholder: 'Xenova/ms-marco-MiniLM-L-6-v2', default: 'Xenova/ms-marco-MiniLM-L-6-v2' }
|
||||
}
|
||||
},
|
||||
api: {
|
||||
@@ -747,6 +747,7 @@ async function loadEnvVariables() {
|
||||
}
|
||||
|
||||
var env = result.env || {};
|
||||
var settings = result.settings || {}; // Current settings from settings.json
|
||||
var html = '<div class="space-y-4">';
|
||||
|
||||
// Get available LiteLLM providers
|
||||
@@ -783,7 +784,8 @@ async function loadEnvVariables() {
|
||||
|
||||
for (var key in group.vars) {
|
||||
var config = group.vars[key];
|
||||
var value = env[key] || config.default || '';
|
||||
// Priority: env file > settings.json > hardcoded default
|
||||
var value = env[key] || settings[key] || config.default || '';
|
||||
|
||||
if (config.type === 'select') {
|
||||
html += '<div class="flex items-center gap-2">' +
|
||||
|
||||
@@ -939,9 +939,10 @@ async function executeCodexLens(args: string[], options: ExecuteOptions = {}): P
|
||||
async function initIndex(params: Params): Promise<ExecuteResult> {
|
||||
const { path = '.', languages } = params;
|
||||
|
||||
const args = ['init', path];
|
||||
// Use 'index init' subcommand (new CLI structure)
|
||||
const args = ['index', 'init', path];
|
||||
if (languages && languages.length > 0) {
|
||||
args.push('--languages', languages.join(','));
|
||||
args.push('--language', languages.join(','));
|
||||
}
|
||||
|
||||
return executeCodexLens(args, { cwd: path });
|
||||
|
||||
@@ -658,9 +658,10 @@ async function executeInitAction(params: Params): Promise<SearchResult> {
|
||||
}
|
||||
|
||||
// Build args with --no-embeddings for FTS-only index (faster)
|
||||
const args = ['init', path, '--no-embeddings'];
|
||||
// Use 'index init' subcommand (new CLI structure)
|
||||
const args = ['index', 'init', path, '--no-embeddings'];
|
||||
if (languages && languages.length > 0) {
|
||||
args.push('--languages', languages.join(','));
|
||||
args.push('--language', languages.join(','));
|
||||
}
|
||||
|
||||
// Track progress updates
|
||||
@@ -750,9 +751,10 @@ async function executeUpdateAction(params: Params): Promise<SearchResult> {
|
||||
}
|
||||
|
||||
// Build args for incremental init (without --force)
|
||||
const args = ['init', path];
|
||||
// Use 'index init' subcommand (new CLI structure)
|
||||
const args = ['index', 'init', path];
|
||||
if (languages && languages.length > 0) {
|
||||
args.push('--languages', languages.join(','));
|
||||
args.push('--language', languages.join(','));
|
||||
}
|
||||
|
||||
// Track progress updates
|
||||
@@ -2398,9 +2400,10 @@ export async function executeInitWithProgress(
|
||||
};
|
||||
}
|
||||
|
||||
const args = ['init', path];
|
||||
// Use 'index init' subcommand (new CLI structure)
|
||||
const args = ['index', 'init', path];
|
||||
if (languages && languages.length > 0) {
|
||||
args.push('--languages', languages.join(','));
|
||||
args.push('--language', languages.join(','));
|
||||
}
|
||||
|
||||
// Track progress updates
|
||||
|
||||
Reference in New Issue
Block a user