mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-12 02:37:45 +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
|
// 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') {
|
if (indexType === 'normal') {
|
||||||
args.push('--no-embeddings');
|
args.push('--no-embeddings');
|
||||||
} else {
|
} else {
|
||||||
// Add embedding model selection for vector index
|
// Add embedding model selection for vector index (use --model, not --embedding-model)
|
||||||
args.push('--embedding-model', embeddingModel);
|
args.push('--model', embeddingModel);
|
||||||
// Add embedding backend if not using default fastembed
|
// Add embedding backend if not using default fastembed (use --backend, not --embedding-backend)
|
||||||
if (embeddingBackend && embeddingBackend !== 'fastembed') {
|
if (embeddingBackend && embeddingBackend !== 'fastembed') {
|
||||||
args.push('--embedding-backend', embeddingBackend);
|
args.push('--backend', embeddingBackend);
|
||||||
}
|
}
|
||||||
// Add max workers for concurrent API calls (useful for litellm backend)
|
// Add max workers for concurrent API calls (useful for litellm backend)
|
||||||
if (maxWorkers && maxWorkers > 1) {
|
if (maxWorkers && maxWorkers > 1) {
|
||||||
@@ -786,7 +787,8 @@ export async function handleCodexLensRoutes(ctx: RouteContext): Promise<boolean>
|
|||||||
try {
|
try {
|
||||||
// Request more results to support split (full content + extra files)
|
// Request more results to support split (full content + extra files)
|
||||||
const totalToFetch = limit + extraFilesCount;
|
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 });
|
const result = await executeCodexLens(args, { cwd: projectPath });
|
||||||
|
|
||||||
@@ -853,7 +855,8 @@ export async function handleCodexLensRoutes(ctx: RouteContext): Promise<boolean>
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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 });
|
const result = await executeCodexLens(args, { cwd: projectPath });
|
||||||
|
|
||||||
@@ -1681,7 +1684,8 @@ except Exception as e:
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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,
|
cwd: projectPath,
|
||||||
timeout: 1800000 // 30 minutes for large codebases
|
timeout: 1800000 // 30 minutes for large codebases
|
||||||
});
|
});
|
||||||
@@ -1769,12 +1773,39 @@ except Exception as e:
|
|||||||
envVars[key] = value;
|
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.writeHead(200, { 'Content-Type': 'application/json' });
|
||||||
res.end(JSON.stringify({
|
res.end(JSON.stringify({
|
||||||
success: true,
|
success: true,
|
||||||
path: envPath,
|
path: envPath,
|
||||||
env: envVars,
|
env: envVars,
|
||||||
raw: content
|
raw: content,
|
||||||
|
settings: settingsDefaults
|
||||||
}));
|
}));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.writeHead(500, { 'Content-Type': 'application/json' });
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
||||||
|
|||||||
@@ -670,8 +670,8 @@ var ENV_VAR_GROUPS = {
|
|||||||
icon: 'hard-drive',
|
icon: 'hard-drive',
|
||||||
showWhen: function(env) { return env['CODEXLENS_EMBEDDING_BACKEND'] !== 'litellm' || env['CODEXLENS_RERANKER_BACKEND'] !== 'litellm'; },
|
showWhen: function(env) { return env['CODEXLENS_EMBEDDING_BACKEND'] !== 'litellm' || env['CODEXLENS_RERANKER_BACKEND'] !== 'litellm'; },
|
||||||
vars: {
|
vars: {
|
||||||
'CODEXLENS_EMBEDDING_MODEL': { label: 'Embedding Model', placeholder: 'fast (code, base, minilm, multilingual, balanced)' },
|
'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' }
|
'CODEXLENS_RERANKER_MODEL': { label: 'Reranker Model', placeholder: 'Xenova/ms-marco-MiniLM-L-6-v2', default: 'Xenova/ms-marco-MiniLM-L-6-v2' }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
api: {
|
api: {
|
||||||
@@ -747,6 +747,7 @@ async function loadEnvVariables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var env = result.env || {};
|
var env = result.env || {};
|
||||||
|
var settings = result.settings || {}; // Current settings from settings.json
|
||||||
var html = '<div class="space-y-4">';
|
var html = '<div class="space-y-4">';
|
||||||
|
|
||||||
// Get available LiteLLM providers
|
// Get available LiteLLM providers
|
||||||
@@ -783,7 +784,8 @@ async function loadEnvVariables() {
|
|||||||
|
|
||||||
for (var key in group.vars) {
|
for (var key in group.vars) {
|
||||||
var config = group.vars[key];
|
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') {
|
if (config.type === 'select') {
|
||||||
html += '<div class="flex items-center gap-2">' +
|
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> {
|
async function initIndex(params: Params): Promise<ExecuteResult> {
|
||||||
const { path = '.', languages } = params;
|
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) {
|
if (languages && languages.length > 0) {
|
||||||
args.push('--languages', languages.join(','));
|
args.push('--language', languages.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
return executeCodexLens(args, { cwd: path });
|
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)
|
// 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) {
|
if (languages && languages.length > 0) {
|
||||||
args.push('--languages', languages.join(','));
|
args.push('--language', languages.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track progress updates
|
// Track progress updates
|
||||||
@@ -750,9 +751,10 @@ async function executeUpdateAction(params: Params): Promise<SearchResult> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build args for incremental init (without --force)
|
// 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) {
|
if (languages && languages.length > 0) {
|
||||||
args.push('--languages', languages.join(','));
|
args.push('--language', languages.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track progress updates
|
// 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) {
|
if (languages && languages.length > 0) {
|
||||||
args.push('--languages', languages.join(','));
|
args.push('--language', languages.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track progress updates
|
// Track progress updates
|
||||||
|
|||||||
Reference in New Issue
Block a user