Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

![CodeTide in Action](https://raw.githubusercontent.com/BrunoV21/CodeTide-vsExtension/main/assets/codetide-demo.gif)

*(Example GIF showing context selection and Copilot integration)*

## Key Features

- **Automatic Codebase Parsing** - Intelligently indexes your entire project structure
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"main": "./dist/extension.js",
"files": [
"dist",
"python",
"assets"
],
"activationEvents": [
Expand Down
1 change: 0 additions & 1 deletion python/requirements.txt

This file was deleted.

90 changes: 0 additions & 90 deletions python/tide.py

This file was deleted.

151 changes: 133 additions & 18 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,146 @@
import { FuzzyAutocomplete } from './fuzzyAutoComplete';
import { RunPythonCommand } from './runPythonCommand';
import { PythonEnvironmentManager } from './pythonEnvironmentManager';
// import { PythonEnvironmentManager } from './pythonEnvironmentManager';
import { UVManager } from './uvManager';
import * as vscode from 'vscode';

let pythonEnvManager: PythonEnvironmentManager;
// let pythonEnvManager: PythonEnvironmentManager;
let uvManager: UVManager;

export async function activate(context: vscode.ExtensionContext) {
try {
// Initialize Python Environment Manager with extension ID
const extensionId = 'your.publisher.codetide'; // Replace with your actual extension ID
pythonEnvManager = new PythonEnvironmentManager(context, extensionId);
uvManager = new UVManager(context);

// Check Python installation and setup virtual environment
await pythonEnvManager.setupPythonEnvironment();
// Ensure UVX is available
vscode.window.showInformationMessage('CodeTide: Checking UV installation...');
const uvxPath = await uvManager.ensureUVX();

// Register Python environment management commands
const envCommands = pythonEnvManager.registerCommands();
context.subscriptions.push(...envCommands);
if (uvxPath) {
vscode.window.showInformationMessage(`CodeTide: UV is ready at ${uvxPath}`);
} else {
vscode.window.showWarningMessage('CodeTide: UV is not available. Some features may not work.');
}

// Initialize the main extension functionality
initializeExtension(context);
// Register UV-related commands
registerUVCommands(context);

// Show success message
vscode.window.showInformationMessage('CodeTide Extension activated successfully!');

} catch (error) {
vscode.window.showErrorMessage(`CodeTide Extension failed to initialize: ${error}`);
registerUVCommands(context);
return;
}
}

function registerUVCommands(context: vscode.ExtensionContext) {
// Command to check UV status
context.subscriptions.push(vscode.commands.registerCommand('codetide.checkUVStatus', async () => {
if (!uvManager) {
vscode.window.showErrorMessage('UV Manager not initialized');
return;
}

const uvxPath = await uvManager.findUVX();
const uvPath = await uvManager.getUVPath();
const config = uvManager.getConfig();

// Still register basic commands even if Python setup fails
const envCommands = pythonEnvManager?.registerCommands() || [];
context.subscriptions.push(...envCommands);
const statusMessage = `UV Status:
UVX: ${uvxPath || 'Not found'}
UV: ${uvPath || 'Not found'}
Custom Path: ${config.customInstallPath || 'None'}`;

return;
vscode.window.showInformationMessage(statusMessage);
}));

// Command to reinstall/setup UV
context.subscriptions.push(vscode.commands.registerCommand('codetide.setupUV', async () => {
if (!uvManager) {
vscode.window.showErrorMessage('UV Manager not initialized');
return;
}

try {
vscode.window.showInformationMessage('Setting up UV...');
const uvxPath = await uvManager.ensureUVX();

if (uvxPath) {
vscode.window.showInformationMessage(`UV setup successful! Located at: ${uvxPath}`);
} else {
vscode.window.showWarningMessage('UV setup completed but UVX path not found.');
}
} catch (error) {
vscode.window.showErrorMessage(`UV setup failed: ${error}`);
}
}));

// Command to reset UV configuration
context.subscriptions.push(vscode.commands.registerCommand('codetide.resetUVConfig', async () => {
if (!uvManager) {
vscode.window.showErrorMessage('UV Manager not initialized');
return;
}

const result = await vscode.window.showWarningMessage(
'This will reset all UV configuration. Continue?',
{ modal: true },
'Yes',
'No'
);

if (result === 'Yes') {
uvManager.resetConfig();
vscode.window.showInformationMessage('UV configuration reset successfully.');
}
}));

// Command to run UV commands directly
context.subscriptions.push(vscode.commands.registerCommand('codetide.runUVCommand', async () => {
if (!uvManager) {
vscode.window.showErrorMessage('UV Manager not initialized');
return;
}

const uvxPath = await uvManager.findUVX();
if (!uvxPath) {
vscode.window.showErrorMessage('UVX not found. Please run "CodeTide: Setup UV" first.');
return;
}

const command = await vscode.window.showInputBox({
prompt: 'Enter UV command (e.g., "run python --version")',
placeHolder: 'run python --version'
});

if (command) {
const workspacePath = getWorkspacePath();
if (!workspacePath) return;

// You can modify RunPythonCommand to accept uvx path, or create a new function
// For now, showing how you might integrate it:
vscode.window.showInformationMessage(`Running: uvx ${command}`);
// Implementation depends on how you want to execute uvx commands
}
}));
}

// Helper function to get UVX path for use in other parts of your extension
export async function getUVXPath(): Promise<string | null> {
if (!uvManager) {
return null;
}
return await uvManager.findUVX();
}

// Helper function to get UV path for use in other parts of your extension
export async function getUVPath(): Promise<string | null> {
if (!uvManager) {
return null;
}
return await uvManager.getUVPath();
}

function initializeExtension(context: vscode.ExtensionContext) {
Expand All @@ -48,10 +156,11 @@ function initializeExtension(context: vscode.ExtensionContext) {
return workspacePath;
};

// Project parser command
context.subscriptions.push(vscode.commands.registerCommand('extension.runParser', () => {
// Modified project parser command to potentially use UV
context.subscriptions.push(vscode.commands.registerCommand('extension.runParser', async () => {
const workspacePath = getWorkspacePath();
if (!workspacePath) return;

RunPythonCommand('project', [workspacePath], 'CodeTide: Initialize Project');
}));

Expand Down Expand Up @@ -282,8 +391,14 @@ function initializeExtension(context: vscode.ExtensionContext) {
}));
}

export function getPythonEnvironmentManager(): PythonEnvironmentManager {
return pythonEnvManager;
// Helper function to get workspace path (moved here to be accessible by UV commands)
function getWorkspacePath(): string | null {
const workspacePath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
if (!workspacePath) {
vscode.window.showErrorMessage("No workspace is open.");
return null;
}
return workspacePath;
}

export function deactivate() {
Expand Down
Loading
Loading