present_workspace_choice
Displays a list of detected workspaces and prompts the user to select one for further operations.
Instructions
Present detected workspaces to user for selection
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main handler function for the present_workspace_choice tool. It delegates to smartWorkspaceInit() which detects VS Code workspaces and presents them to the user for selection.
async presentWorkspaceChoice(): Promise<ToolResult> { return this.smartWorkspaceInit(); } - src/toolDefinitions.ts:47-54 (schema)Tool definition/schema for present_workspace_choice. It takes no input parameters and is used to present detected VS Code workspaces to the user for selection.
{ name: 'present_workspace_choice', description: 'Present detected workspaces to user for selection', inputSchema: { type: 'object', properties: {}, }, }, - src/index.ts:147-150 (registration)Registration of the 'present_workspace_choice' tool in the server's executeToolCommand switch statement. It first runs detectWorkspaces() then calls presentWorkspaceChoice() on the VSCodeDetectionService.
case 'present_workspace_choice': // For now, just call the method without args since it doesn't need them const detectionResult = await this.vsCodeDetectionService.detectWorkspaces(); return await this.vsCodeDetectionService.presentWorkspaceChoice(); - Helper function called by presentWorkspaceChoice(). Performs full VS Code workspace detection and formats the results into a user-friendly selection prompt with numbered options.
async smartWorkspaceInit(): Promise<ToolResult> { try { // First, try to detect workspaces const detection = await this._performDetection(); if (detection.totalWorkspaces === 0) { return { content: [{ type: 'text', text: `🔍 **No VS Code workspaces detected** I couldn't find any open VS Code windows or recent workspaces. Here are your options: 1. Open VS Code with a project folder, then ask me to detect workspaces again 2. **Tell me the path** to your project (e.g., "/Users/yourname/projects/myproject") 3. **Create a new project** - just tell me what type of project you want to create What would you like to do?`, }], }; } // Format workspaces for user selection let response = `🎯 **VS Code Workspace Detection**\n\nI found the following workspaces:\n\n`; // Show currently open workspaces first if (detection.instances.length > 0) { response += `**🟢 Currently Open in VS Code:**\n`; let index = 1; for (const instance of detection.instances) { for (const workspace of instance.workspaces) { response += `${index}. ${workspace.name}\n 📁 ${workspace.path}\n`; index++; } } response += '\n'; } // Show recent workspaces if (detection.recentWorkspaces.length > 0) { response += `**📂 Recent Workspaces:**\n`; let index = detection.instances.flatMap(i => i.workspaces).length + 1; const recentToShow = detection.recentWorkspaces.slice(0, 5); for (const workspace of recentToShow) { response += `${index}. ${workspace.name}\n 📁 ${workspace.path}\n`; if (workspace.lastAccessed) { response += ` 🕒 Last used: ${this._formatDate(workspace.lastAccessed)}\n`; } index++; } } response += `\n**To select a workspace:** • Tell me the number (e.g., "use workspace 1") • Or tell me to use the first/most recent one • Or provide a different path Which workspace would you like to use?`; return { content: [{ type: 'text', text: response, }], }; } catch (error) { return { isError: true, content: [{ type: 'text', text: `Failed to detect workspaces: ${error instanceof Error ? error.message : 'Unknown error'}`, }], }; } }