( ide: IDE, promptPath: string | undefined, )
| 36 | const DEFAULT_PROMPT_FILE = ""; |
| 37 | |
| 38 | export async function createNewPromptFileV2( |
| 39 | ide: IDE, |
| 40 | promptPath: string | undefined, |
| 41 | ): Promise<void> { |
| 42 | const workspaceDirs = await ide.getWorkspaceDirs(); |
| 43 | if (workspaceDirs.length === 0) { |
| 44 | throw new Error( |
| 45 | "No workspace directories found. Make sure you've opened a folder in your IDE.", |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | const baseDirUri = joinPathsToUri( |
| 50 | workspaceDirs[0], |
| 51 | promptPath ?? ".continue/prompts", |
| 52 | ); |
| 53 | |
| 54 | // Find the first available filename |
| 55 | let counter = 0; |
| 56 | let promptFileUri: string; |
| 57 | do { |
| 58 | const suffix = counter === 0 ? "" : `-${counter}`; |
| 59 | promptFileUri = joinPathsToUri( |
| 60 | baseDirUri, |
| 61 | `new-prompt-file${suffix}.prompt`, |
| 62 | ); |
| 63 | counter++; |
| 64 | } while (await ide.fileExists(promptFileUri)); |
| 65 | |
| 66 | const globalContext = new GlobalContext(); |
| 67 | const PROMPT_FILE = |
| 68 | globalContext.get("hasAlreadyCreatedAPromptFile") === true |
| 69 | ? DEFAULT_PROMPT_FILE |
| 70 | : FIRST_TIME_DEFAULT_PROMPT_FILE; |
| 71 | |
| 72 | globalContext.update("hasAlreadyCreatedAPromptFile", true); |
| 73 | |
| 74 | await ide.writeFile(promptFileUri, PROMPT_FILE); |
| 75 | await ide.openFile(promptFileUri); |
| 76 | } |
no test coverage detected