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

Function add

packages/shell/src/git/index.ts:130–152  ·  view source on GitHub ↗

git add (use "." for all)

(opts: { filepath: string; dir?: string })

Source from the content-addressed store, hash-verified

128
129 /** git add <filepath> (use "." for all) */
130 async add(opts: { filepath: string; dir?: string }) {
131 const d = resolveDir(opts.dir);
132
133 if (opts.filepath === ".") {
134 // Stage all changes
135 const matrix = await git.statusMatrix({ fs, dir: d });
136 for (const [filepath, head, workdir, stage] of matrix) {
137 const key = `${head}${workdir}${stage}`;
138 if (key === "111") continue; // unmodified
139
140 if (workdir === 0) {
141 // Deleted
142 await git.remove({ fs, dir: d, filepath: filepath as string });
143 } else {
144 await git.add({ fs, dir: d, filepath: filepath as string });
145 }
146 }
147 return { added: "." };
148 }
149
150 await git.add({ fs, dir: d, filepath: opts.filepath });
151 return { added: opts.filepath };
152 },
153
154 /** git rm <filepath> */
155 async rm(opts: { filepath: string; dir?: string }) {

Callers

nothing calls this directly

Calls 3

resolveDirFunction · 0.85
removeMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected