MCPcopy Create free account
hub / github.com/Autonoma-AI/autonoma / clone

Method clone

packages/diffs/src/codebase/codebase.ts:34–67  ·  view source on GitHub ↗

* Shells out to `cloneRepository()` from `@autonoma/github` and returns a * `Codebase` rooted at `targetDir`. Clears `targetDir` first so a dangling * tree from a previous crashed run never interferes with the fresh clone. * Throws on any failure (removing the partially-populated `tar

(
        githubClient: GitHubInstallationClient,
        targetDir: string,
        opts: { repoName: string; commitSha: string; baseSha?: string },
    )

Source from the content-addressed store, hash-verified

32 * is a parent directory holding the primary repo plus every dependency as named
33 * sibling directories. The `bash` tool runs in `root` either way, so a
34 * single-repo checkout behaves exactly as before, while a multi-repo workspace
35 * lets the agent reach every repo by its sibling directory name.
36 *
37 * Get one via `Codebase.clone(...)` (single repo) or `Codebase.cloneWorkspace(...)`
38 * (multi-repo), or construct directly (`new Codebase(path)`) when you already
39 * have a populated single-repo tree (tests). Reuse across operations is the
40 * default; call `dispose()` explicitly to remove the whole workspace.
41 *
42 * The research agents read the tree through the read-only `bash` tool, which
43 * runs shell commands with `root` as its working directory - the `Codebase`
44 * itself no longer offers file/search helpers. The agent is trusted internal
45 * code reading the user's own repo, so traversal is not sandboxed: a command
46 * that escapes `root` (absolute paths, symlinks) gets whatever the shell
47 * returns, same as running it yourself.
48 */
49export class Codebase {
50 private readonly logger: Logger;
51
52 /** Every repo checked out in this workspace, primary first. */
53 public readonly repos: RepoCheckout[];
54 /** Dependencies that were expected but could not be checked out. */
55 public readonly unavailableRepos: UnavailableRepo[];
56
57 constructor(
58 public readonly root: string,
59 repos?: RepoCheckout[],
60 unavailableRepos?: UnavailableRepo[],
61 ) {
62 this.repos = repos ?? [{ name: "primary", role: "primary", relPath: ".", dir: root, headSha: "" }];
63 this.unavailableRepos = unavailableRepos ?? [];
64 this.logger = rootLogger.child({ name: this.constructor.name, root });
65 }
66
67 /** The primary repo checkout (the application's own repo). */
68 get primary(): RepoCheckout {
69 const primary = this.repos.find((r) => r.role === "primary");
70 if (primary == null) throw new Error("Codebase has no primary repo");

Callers 4

codebase.test.tsFile · 0.80
createApiAppFunction · 0.80
cloneResolvedFunction · 0.80
withSnapshotContextFunction · 0.80

Calls 4

warnMethod · 0.80
cloneRepositoryMethod · 0.65
childMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected