MCPcopy
hub / github.com/continuedev/continue / createNewAssistantFile

Function createNewAssistantFile

core/config/createNewAssistantFile.ts:42–69  ·  view source on GitHub ↗
(
  ide: IDE,
  assistantPath: string | undefined,
)

Source from the content-addressed store, hash-verified

40`;
41
42export 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}

Callers 1

Calls 5

joinPathsToUriFunction · 0.90
getWorkspaceDirsMethod · 0.65
fileExistsMethod · 0.65
writeFileMethod · 0.65
openFileMethod · 0.65

Tested by

no test coverage detected