MCPcopy
hub / github.com/codeaashu/claude-code / updateAgentFile

Function updateAgentFile

src/components/agents/agentFileUtils.ts:208–236  ·  view source on GitHub ↗
(
  agent: AgentDefinition,
  newWhenToUse: string,
  newTools: string[] | undefined,
  newSystemPrompt: string,
  newColor?: string,
  newModel?: string,
  newMemory?: AgentMemoryScope,
  newEffort?: EffortValue,
)

Source from the content-addressed store, hash-verified

206 * Updates an existing agent file
207 */
208export 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

Callers 1

AgentEditorFunction · 0.85

Calls 3

getActualAgentFilePathFunction · 0.85
formatAgentAsMarkdownFunction · 0.85
writeFileAndFlushFunction · 0.85

Tested by

no test coverage detected