(args: z.infer<typeof UpdateArgs>, ctx: ToolContext)
| 80 | description = 'Save a new version of an existing artifact. Previous versions are preserved (use artifact_rollback to go back). Pass the FULL new content, not a diff.'; |
| 81 | argsSchema = UpdateArgs; |
| 82 | isReadOnly = false; |
| 83 | isDestructive = false; |
| 84 | |
| 85 | async execute(args: z.infer<typeof UpdateArgs>, ctx: ToolContext): Promise<ToolResult> { |
| 86 | try { |
| 87 | const { manifest, absFile, version } = await updateArtifact( |
| 88 | ctx.cwd, |
| 89 | { id: resolveArtifactId(args), content: args.content, note: args.note }, |
| 90 | (p, c) => ctx.transaction.write(p, c), |
| 91 | ); |
| 92 | ctx.emit({ type: 'progress', message: `Updated artifact "${manifest.id}" → v${version}` }); |
| 93 | return { |
| 94 | content: `Saved "${manifest.id}" v${version} at ${absFile}. It now has ${manifest.versions.length} version(s).`, |
| 95 | metadata: { artifactId: manifest.id, version, type: manifest.type, path: absFile }, |
| 96 | }; |
| 97 | } catch (e: any) { |
| 98 | return { content: e?.message ?? String(e), isError: true }; |
| 99 | } |
| 100 | } |
nothing calls this directly
no test coverage detected