( ide: IDE, assistantPath: string | undefined, )
| 40 | `; |
| 41 | |
| 42 | export async function createNewAssistantFile( |
| 43 | ide: IDE, |
| 44 | assistantPath: string | undefined, |
| 45 | ): Promise<void> { |
| 46 | const workspaceDirs = await ide.getWorkspaceDirs(); |
| 47 | if (workspaceDirs.length === 0) { |
| 48 | throw new Error( |
| 49 | "No workspace directories found. Make sure you've opened a folder in your IDE.", |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | const baseDirUri = joinPathsToUri( |
| 54 | workspaceDirs[0], |
| 55 | assistantPath ?? ".continue/agents", |
| 56 | ); |
| 57 | |
| 58 | // Find the first available filename |
| 59 | let counter = 0; |
| 60 | let assistantFileUri: string; |
| 61 | do { |
| 62 | const suffix = counter === 0 ? "" : `-${counter}`; |
| 63 | assistantFileUri = joinPathsToUri(baseDirUri, `new-config${suffix}.yaml`); |
| 64 | counter++; |
| 65 | } while (await ide.fileExists(assistantFileUri)); |
| 66 | |
| 67 | await ide.writeFile(assistantFileUri, DEFAULT_ASSISTANT_FILE); |
| 68 | await ide.openFile(assistantFileUri); |
| 69 | } |
no test coverage detected