(params)
| 15 | * @returns {Promise<{projects: string[], multipleFound: boolean}>} - Information about found projects |
| 16 | */ |
| 17 | export async function listProjects(params) { |
| 18 | // Mark that list-projects has been called |
| 19 | setListProjectsCalled() |
| 20 | |
| 21 | const { workspaceRoots, userConfirmed } = params |
| 22 | |
| 23 | // Check if user has confirmed |
| 24 | if (!userConfirmed) { |
| 25 | return { |
| 26 | content: [ |
| 27 | { |
| 28 | type: 'text', |
| 29 | text: |
| 30 | '⚠️⚠️⚠️ ERROR: USER CONFIRMATION REQUIRED ⚠️⚠️⚠️\n\n' + |
| 31 | 'You MUST explicitly ask the user for permission before searching for projects.\n\n' + |
| 32 | 'Required workflow:\n' + |
| 33 | '1. Ask the user: "Should I search for serverless projects in the following workspace paths: ' + |
| 34 | JSON.stringify(workspaceRoots) + |
| 35 | '?"\n' + |
| 36 | '2. Wait for explicit user confirmation\n' + |
| 37 | '3. If user confirms, call this tool again with userConfirmed=true\n' + |
| 38 | '4. If user does NOT confirm, ask for the FULL ABSOLUTE PATH to the project directory\n' + |
| 39 | '5. Once the user provides a specific path, replace workspaceRoots with ONLY that path', |
| 40 | }, |
| 41 | ], |
| 42 | isError: true, |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | if ( |
| 47 | !workspaceRoots || |
| 48 | !Array.isArray(workspaceRoots) || |
| 49 | workspaceRoots.length === 0 |
| 50 | ) { |
| 51 | return { |
| 52 | content: [ |
| 53 | { |
| 54 | type: 'text', |
| 55 | text: 'Error: workspaceRoots parameter is required and must be a non-empty array of directory paths', |
| 56 | }, |
| 57 | ], |
| 58 | isError: true, |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | try { |
| 63 | // Get information about serverless projects in all workspace roots |
| 64 | let allProjects = [] |
| 65 | |
| 66 | // Process each workspace root |
| 67 | for (const workspaceRoot of workspaceRoots) { |
| 68 | const projectsInfo = await getServerlessProjectsInfo(workspaceRoot) |
| 69 | allProjects = [...allProjects, ...projectsInfo.projects] |
| 70 | } |
| 71 | |
| 72 | // Remove any duplicate projects (in case of overlapping workspace roots) |
| 73 | // Since projects are now objects with paths, we need to deduplicate by path |
| 74 | const uniquePaths = new Set() |
no test coverage detected
searching dependent graphs…