MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / updateArtifact

Function updateArtifact

src/artifacts/store.ts:186–200  ·  view source on GitHub ↗
(cwd: string, input: UpdateInput, write: WriteFn, now = new Date().toISOString())

Source from the content-addressed store, hash-verified

184
185/** Update an artifact: writes a NEW version file + updated manifest. */
186export async function updateArtifact(cwd: string, input: UpdateInput, write: WriteFn, now = new Date().toISOString()): Promise<{ manifest: ArtifactManifest; absFile: string; version: number }> {
187 // Serialize the read-modify-write so concurrent updates to the SAME artifact
188 // don't both compute the same next version number and lose one.
189 return withLock(manifestLockPath(cwd, input.id), async () => {
190 const existing = await readManifest(cwd, input.id);
191 if (!existing) throw new Error(`Artifact "${input.id}" not found.`);
192 const v = nextVersionNumber(existing);
193 const rel = path.join(`v${v}`, entryFileName(existing.type));
194 const absFile = path.join(artifactDir(cwd, input.id), rel);
195 await write(absFile, input.content);
196 const manifest = addVersion(existing, rel, now, input.note);
197 await writeFileAtomic(manifestPath(cwd, input.id), JSON.stringify(manifest, null, 2));
198 return { manifest, absFile, version: v };
199 });
200}
201
202/** List all artifacts (newest-updated first). */
203export async function listArtifacts(cwd: string): Promise<ArtifactSummary[]> {

Callers 3

mainFunction · 0.90
executeMethod · 0.85

Calls 10

withLockFunction · 0.85
manifestLockPathFunction · 0.85
nextVersionNumberFunction · 0.85
entryFileNameFunction · 0.85
artifactDirFunction · 0.85
addVersionFunction · 0.85
writeFileAtomicFunction · 0.85
readManifestFunction · 0.70
manifestPathFunction · 0.70
writeFunction · 0.50

Tested by 1

mainFunction · 0.72