MCPcopy Create free account
hub / github.com/cloudflare/agents / appendFile

Method appendFile

packages/shell/src/workspace.ts:53–69  ·  view source on GitHub ↗
(path: string, content: string | Uint8Array)

Source from the content-addressed store, hash-verified

51 }
52
53 async appendFile(path: string, content: string | Uint8Array): Promise<void> {
54 if (typeof content === "string") {
55 await this.ws.appendFile(path, content);
56 return;
57 }
58
59 const existing = await this.ws.readFileBytes(path);
60 if (existing === null) {
61 await this.ws.writeFileBytes(path, content);
62 return;
63 }
64
65 const combined = new Uint8Array(existing.byteLength + content.byteLength);
66 combined.set(existing);
67 combined.set(content, existing.byteLength);
68 await this.ws.writeFileBytes(path, combined);
69 }
70
71 async exists(path: string): Promise<boolean> {
72 return this.ws.exists(path);

Callers

nothing calls this directly

Calls 4

appendFileMethod · 0.65
readFileBytesMethod · 0.65
writeFileBytesMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected