( agent: AgentDefinition, newWhenToUse: string, newTools: string[] | undefined, newSystemPrompt: string, newColor?: string, newModel?: string, newMemory?: AgentMemoryScope, newEffort?: EffortValue, )
| 206 | * Updates an existing agent file |
| 207 | */ |
| 208 | export async function updateAgentFile( |
| 209 | agent: AgentDefinition, |
| 210 | newWhenToUse: string, |
| 211 | newTools: string[] | undefined, |
| 212 | newSystemPrompt: string, |
| 213 | newColor?: string, |
| 214 | newModel?: string, |
| 215 | newMemory?: AgentMemoryScope, |
| 216 | newEffort?: EffortValue, |
| 217 | ): Promise<void> { |
| 218 | if (agent.source === 'built-in') { |
| 219 | throw new Error('Cannot update built-in agents') |
| 220 | } |
| 221 | |
| 222 | const filePath = getActualAgentFilePath(agent) |
| 223 | |
| 224 | const content = formatAgentAsMarkdown( |
| 225 | agent.agentType, |
| 226 | newWhenToUse, |
| 227 | newTools, |
| 228 | newSystemPrompt, |
| 229 | newColor, |
| 230 | newModel, |
| 231 | newMemory, |
| 232 | newEffort, |
| 233 | ) |
| 234 | |
| 235 | await writeFileAndFlush(filePath, content) |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Deletes an agent file |
no test coverage detected