| 1 | import { IDE } from ".."; |
| 2 | import { joinPathsToUri } from "../util/uri"; |
| 3 | |
| 4 | const DEFAULT_ASSISTANT_FILE = `# This is an example agent configuration file |
| 5 | # It is used to define custom AI agents within Continue |
| 6 | # Each agent file can be accessed by selecting it from the agent dropdown |
| 7 | |
| 8 | # To learn more, see the full config.yaml reference: https://docs.continue.dev/reference |
| 9 | |
| 10 | name: Example Agent |
| 11 | version: 1.0.0 |
| 12 | schema: v1 |
| 13 | |
| 14 | # Models define which AI models this agent can use |
| 15 | # https://docs.continue.dev/customization/models |
| 16 | models: |
| 17 | - name: my gpt-5 |
| 18 | provider: openai |
| 19 | model: gpt-5 |
| 20 | apiKey: YOUR_OPENAI_API_KEY_HERE |
| 21 | - uses: ollama/qwen2.5-coder-7b |
| 22 | - uses: anthropic/claude-4-sonnet |
| 23 | with: |
| 24 | ANTHROPIC_API_KEY: \${{ secrets.ANTHROPIC_API_KEY }} |
| 25 | |
| 26 | # MCP Servers the agent can use |
| 27 | # https://docs.continue.dev/customization/mcp-tools |
| 28 | mcpServers: |
| 29 | - uses: anthropic/memory-mcp |
| 30 | `; |
| 31 | |
| 32 | export async function createNewAssistantFile( |
| 33 | ide: IDE, |
| 34 | assistantPath: string | undefined, |
| 35 | ): Promise<void> { |
| 36 | const workspaceDirs = await ide.getWorkspaceDirs(); |
| 37 | if (workspaceDirs.length === 0) { |
| 38 | throw new Error( |
| 39 | "No workspace directories found. Make sure you've opened a folder in your IDE.", |
| 40 | ); |
| 41 | } |
| 42 | |
| 43 | const baseDirUri = joinPathsToUri( |
| 44 | workspaceDirs[0], |
| 45 | assistantPath ?? ".continue/agents", |
| 46 | ); |
| 47 | |
| 48 | // Find the first available filename |
| 49 | let counter = 0; |
| 50 | let assistantFileUri: string; |
| 51 | do { |
| 52 | const suffix = counter === 0 ? "" : `-${counter}`; |
| 53 | assistantFileUri = joinPathsToUri(baseDirUri, `new-agent${suffix}.yaml`); |
| 54 | counter++; |
| 55 | } while (await ide.fileExists(assistantFileUri)); |
| 56 | |
| 57 | await ide.writeFile(assistantFileUri, DEFAULT_ASSISTANT_FILE); |
| 58 | await ide.openFile(assistantFileUri); |
| 59 | } |