mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-28 09:23:08 +08:00
feat(codexlens): enhance bootstrapVenv with warning handling for UV and pip fallback
This commit is contained in:
@@ -952,16 +952,34 @@ async function installSemantic(gpuMode: GpuMode = 'cpu'): Promise<BootstrapResul
|
|||||||
* @returns Bootstrap result
|
* @returns Bootstrap result
|
||||||
*/
|
*/
|
||||||
async function bootstrapVenv(): Promise<BootstrapResult> {
|
async function bootstrapVenv(): Promise<BootstrapResult> {
|
||||||
|
const warnings: string[] = [];
|
||||||
|
|
||||||
// Prefer UV if available (faster package resolution and installation)
|
// Prefer UV if available (faster package resolution and installation)
|
||||||
if (await isUvAvailable()) {
|
if (await isUvAvailable()) {
|
||||||
console.log('[CodexLens] Using UV for bootstrap...');
|
console.log('[CodexLens] Using UV for bootstrap...');
|
||||||
return bootstrapWithUv();
|
try {
|
||||||
|
const uvResult = await bootstrapWithUv();
|
||||||
|
if (uvResult.success) {
|
||||||
|
return uvResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[CodexLens] UV bootstrap failed, falling back to pip:', uvResult.error);
|
||||||
|
warnings.push(`UV bootstrap failed: ${uvResult.error || 'Unknown error'}`);
|
||||||
|
} catch (uvErr) {
|
||||||
|
const message = uvErr instanceof Error ? uvErr.message : String(uvErr);
|
||||||
|
console.log('[CodexLens] UV bootstrap error, falling back to pip:', message);
|
||||||
|
warnings.push(`UV bootstrap error: ${message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pre-flight: verify Python is available and compatible
|
// Pre-flight: verify Python is available and compatible
|
||||||
const preFlightError = preFlightCheck();
|
const preFlightError = preFlightCheck();
|
||||||
if (preFlightError) {
|
if (preFlightError) {
|
||||||
return { success: false, error: `Pre-flight failed: ${preFlightError}` };
|
return {
|
||||||
|
success: false,
|
||||||
|
error: `Pre-flight failed: ${preFlightError}`,
|
||||||
|
warnings: warnings.length > 0 ? warnings : undefined,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-repair corrupted venv before proceeding
|
// Auto-repair corrupted venv before proceeding
|
||||||
@@ -982,7 +1000,11 @@ async function bootstrapVenv(): Promise<BootstrapResult> {
|
|||||||
const pythonCmd = getSystemPython();
|
const pythonCmd = getSystemPython();
|
||||||
execSync(`${pythonCmd} -m venv "${venvDir}"`, { stdio: 'inherit', timeout: EXEC_TIMEOUTS.PROCESS_SPAWN });
|
execSync(`${pythonCmd} -m venv "${venvDir}"`, { stdio: 'inherit', timeout: EXEC_TIMEOUTS.PROCESS_SPAWN });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return { success: false, error: `Failed to create venv: ${(err as Error).message}` };
|
return {
|
||||||
|
success: false,
|
||||||
|
error: `Failed to create venv: ${(err as Error).message}`,
|
||||||
|
warnings: warnings.length > 0 ? warnings : undefined,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1006,9 +1028,13 @@ async function bootstrapVenv(): Promise<BootstrapResult> {
|
|||||||
// Clear cache after successful installation
|
// Clear cache after successful installation
|
||||||
clearVenvStatusCache();
|
clearVenvStatusCache();
|
||||||
clearSemanticStatusCache();
|
clearSemanticStatusCache();
|
||||||
return { success: true };
|
return { success: true, warnings: warnings.length > 0 ? warnings : undefined };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return { success: false, error: `Failed to install codex-lens: ${(err as Error).message}` };
|
return {
|
||||||
|
success: false,
|
||||||
|
error: `Failed to install codex-lens: ${(err as Error).message}`,
|
||||||
|
warnings: warnings.length > 0 ? warnings : undefined,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user