# Repo

> Repos: git repositories for the code your agents and apps write.

```python
repo = noclick.Repo.from_name("agent-tools", create_if_missing=True)
repo.commit({"src/index.ts": source}, message="Add the lookup route")
repo.commit({"index.html": {"url": "https://example.com/page.html"}}, message="Publish the page")
print(repo.read("src/index.ts").decode())
print(repo.clone_url())   # plain git over HTTPS, a short-lived token inside

site = noclick.Repo.create("site", from_url="https://github.com/acme/site").wait()   # a copy, history and all
```

A repo is plain git: clone it, push to it, copy one in from a public URL, or move it to GitHub whole.
A project (`noclick.Project`) deploys one to a URL.

## noclick.Repo

```python
class Repo
```

A git repository NoClick hosts. `Repo.from_name("agent-tools", create_if_missing=True)` is lazy; commit to it from code, or clone it and
push with plain git.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str` |  |
| `default_branch` | `str` | The branch a project deploys to production (`main` unless set). |
| `size_bytes` | `int | None` |  |
| `last_commit` | `Commit | None` | The newest commit on the default branch (None in an empty repo). |
| `used_by` | `list[dict[str, Any]]` | The apps that deploy it: `kind` (`project`), `id` and `name`. |
| `user_id` | `str | None` |  |
| `created_at` | `Any` |  |
| `forked_from` | `dict[str, Any] | None` | `{"address": ...}`: the public work on NoClick it was copied from; else None. |
| `public` | `PublicCode | None` | A space template's code, while it's public (`make_public()`); None while it's private. An app's code is public as its app (`Project.public`). |

### Repo.create

```python
noclick.Repo.create(
    name, *, default_branch=None, from_url=None, ref=None, allow_existing=False,
    user=..., client=None
) -> Repo | RepoImport
```

Create a repo called `name` (unique per user; a duplicate raises
`noclick.Conflict` with `existing_id`, or with `allow_existing=True`
returns the repo already there, commits and all): empty, or with
`from_url` a copy of a public git repository, history and all.

`from_url` is the https URL you'd `git clone`, with no login in it.
Every branch and tag is copied, and the repo's default branch is the
source's own unless `default_branch` names another of its branches.
`ref` copies one branch, tag or commit (its full sha) instead, with its
history, as the repo's one branch: named `default_branch`, else the
branch's own name, else `main`. Submodules and LFS files aren't copied
(their pointers are, as committed). The copy takes up to 5 GiB of history
and 15 minutes. That size is measured as git transfers the history
(compressed), which isn't the same figure as the repo's `size_bytes`
afterwards. The copy is charged what it uses: its seconds of compute and the
bytes it stores, at NoClick's vendors' prices. An import always makes a new
repo, so `allow_existing` doesn't apply to it.

`from_url` may also be the address of an app whose code is public on NoClick (`pilot-hub.noclick.site`,
a custom domain it serves): its published code is forked inside NoClick (`forked_from`), and the result
says what a deploy of it asks for. An address with no public work raises `noclick.InvalidRequest`
(`not_public`).

Parameters:

- `name` (`str`, required)
- `default_branch` (`str | None`, default `None`)
- `from_url` (`str | None`, default `None`)
- `ref` (`str | None`, default `None`)
- `allow_existing` (`bool`, default `False`)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Repo | RepoImport` The new repo, loaded, with no commits yet; with `from_url`, a
`RepoImport`: the operation doing the copy, whose `wait()` gives
the repo once it's copied.

Usage:

Create one for your account's own code:

```python
repo = noclick.Repo.create("agent-tools")
print(repo.name, repo.default_branch)   # agent-tools main
```

Inside `as_user` it's that user's, and bills to them:

```python
with noclick.as_user("user_42"):
    site = noclick.Repo.create("portfolio", default_branch="production")
```

Copy a public repository, then deploy it:

```python
copy = noclick.Repo.create("blog", from_url="https://github.com/acme/blog")
repo = copy.wait()
print(repo.default_branch, repo.last_commit.sha)
app = noclick.Project.create("blog", repo=repo)
```

Copy one release of it, as the branch `main`:

```python
repo = noclick.Repo.create("blog-v2", from_url="https://github.com/acme/blog", ref="v2.0.0").wait()
```

A source NoClick can't copy raises from `wait()`, and the repo is deleted:

```python
try:
    noclick.Repo.create("private", from_url="https://github.com/acme/private").wait()
except noclick.InvalidRequest as refused:
    print(refused.message)   # ... asked for a sign-in: NoClick copies public repositories only.
```

### Repo.from_name

```python
noclick.Repo.from_name(
    name, *, create_if_missing=False, default_branch=None, user=..., client=None
) -> Repo
```

A lazy reference to the repo called `name` in the current (or
given) user. With `create_if_missing=True` it's created, empty, on
first use; an existing repo is used as it is.

Parameters:

- `name` (`str`, required)
- `create_if_missing` (`bool`, default `False`)
- `default_branch` (`str | None`, default `None`)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Repo` A repo that loads, or is created, the first time it's used. Nothing is sent yet.

Usage:

The same line works on the first run and every run after:

```python
repo = noclick.Repo.from_name("agent-tools", create_if_missing=True)
repo.commit({"README.md": "# Agent tools\n"}, message="Start the repo")
```

Without `create_if_missing` a missing repo raises `noclick.NotFound` at first use:

```python
repo = noclick.Repo.from_name("booking", user="acme")
print(repo.last_commit)
```

### Repo.from_id

```python
noclick.Repo.from_id(repo_id, *, client=None, user=...) -> Repo
```

A lazy reference to a repo by id.

Parameters:

- `repo_id` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).

Returns: `Repo` A repo that loads the first time you read a field. Nothing is sent yet.

Usage:

```python
repo = noclick.Repo.from_id("c4e1a7b2-5d3f-4a8e-9b6c-1f2d3e4a5b60")
for branch in repo.branches():
    print(branch.name, branch.head)
```

### Repo.get

```python
noclick.Repo.get(repo_id, *, user=..., client=None) -> Repo
```

Load a repo by id now; an unknown id raises `noclick.NotFound`.

Parameters:

- `repo_id` (`str`, required)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Repo` The repo, loaded.

Usage:

```python
repo = noclick.Repo.get("c4e1a7b2-5d3f-4a8e-9b6c-1f2d3e4a5b60")
print(repo.name, repo.size_bytes, repo.last_commit)
```

### Repo.list

```python
noclick.Repo.list(*, limit=None, user_filter=None, user=..., client=None) -> list[Repo]
```

The current user's repos (the account's own outside `as_user`, or those `user_filter` covers).

Parameters:

- `limit` (`int | None`, default `None`): Return at most this many.
- `user_filter` (`Any`, default `None`): Which users a read covers: `noclick.ALL_USERS`, `noclick.NO_USER`, a `User`, or your id for one. It filters without acting as that user.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `list[Repo]` Every matching repo, newest first, fetched page by page.

Usage:

```python
for repo in noclick.Repo.list():
    print(repo.name, repo.default_branch, repo.size_bytes)

everyone = noclick.Repo.list(user_filter=noclick.ALL_USERS)   # every user's, plus your account's
```

### Repo.list_page

```python
noclick.Repo.list_page(
    *, cursor=None, limit=None, user_filter=None, user=..., client=None
) -> Page
```

One page of repos; pass `next_cursor` back as `cursor`.

Parameters:

- `cursor` (`str | None`, default `None`): The `next_cursor` of the page before; omit it for the first page.
- `limit` (`int | None`, default `None`): Return at most this many.
- `user_filter` (`Any`, default `None`): Which users a read covers: `noclick.ALL_USERS`, `noclick.NO_USER`, a `User`, or your id for one. It filters without acting as that user.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Page` A page whose `data` holds the repos and whose `next_cursor` is `None` on the last page.

Usage:

```python
page = noclick.Repo.list_page(limit=50)
while True:
    for repo in page.data:
        print(repo.name)
    if page.next_cursor is None:
        break
    page = noclick.Repo.list_page(limit=50, cursor=page.next_cursor)
```

### Repo.clone_url

```python
repo.clone_url(*, write=False, ttl_s=None) -> str
```

A git URL with a short-lived token inside, for `git clone`,
`fetch` and, with `write=True`, `push`. `ttl_s` is 3,600 by
default, at most 86,400; the token stops working after it. The token
reaches this repo only. Clones and pushes cost nothing extra, within fair
use. An agent's writing URL (asked for through NoClick's MCP server, by
the coordinator or by a platform agent) goes through NoClick, which never
lets it force-push or delete the default branch, and keeps the old head of
any other branch its push rewrites or deletes (`backups`).

Parameters:

- `write` (`bool`, default `False`)
- `ttl_s` (`int | None`, default `None`)

Returns: `str` An `https://` URL that plain git accepts as it is. Treat it as a secret until it expires.

Usage:

Clone the repo on a build machine:

```python
import subprocess

repo = noclick.Repo.from_name("agent-tools")
subprocess.run(["git", "clone", repo.clone_url(), "agent-tools"], check=True)
```

Let a sandbox push for the next ten minutes:

```python
repo = noclick.Repo.from_name("agent-tools")
url = repo.clone_url(write=True, ttl_s=600)
with noclick.Sandbox.create(network=True) as sb:
    sb.exec(["git", "clone", url, "/workspace/agent-tools"])
```

### Repo.checkout

```python
repo.checkout(*, branch=None, path=None, push=None) -> RepoCheckout
```

This repo checked out in an agent's workspace, for `Agent(repos=[...])`:
cloned into `/workspace/<path>` (the repo's name when omitted) at a
conversation's first turn, on `branch` (the default branch when omitted).
`push` is the branches the agent may push to, exact or `prefix/*`;
without it the checkout is read-only. The repo must be in the agent's own
scope (the account's for an account agent, a user's for that user's), and
the agent's commits name it as their author. Sends nothing.

Parameters:

- `branch` (`str | None`, default `None`)
- `path` (`str | None`, default `None`)
- `push` (`str | Sequence[str] | None`, default `None`)

Returns: `RepoCheckout` A `RepoCheckout` to list in an agent's `repos`.

Usage:

Let an agent change the site on branches of its own, for review:

```python
site = noclick.Repo.from_name("booking")
builder = noclick.Agent.from_name(
    "site-builder",
    create_if_missing=True,
    instructions="You make the changes asked for in /workspace/booking, on a new branch, and push it.",
    repos=[site.checkout(push="agent/*")],
)
```

### Repo.commit

```python
repo.commit(files, *, message, branch=None, author=None, exclude=()) -> Commit | None
```

Commit `files` in one commit: each path maps to its new content
(text, or bytes for binary files) or to `None` to delete it. The commit
goes on `branch` (the default branch when omitted), which is created
from the default branch's head if it doesn't exist yet. At most 1,000
files and 50 MB in one commit.

A file NoClick can reach goes by reference instead, and NoClick reads it
byte for byte, so it never passes through your code: one of the account's
files (an `Attachment` from `noclick.attachments()`, or
`{"attachment_id": ...}`, which also names a file this key uploaded to an
agent or a channel before a message sends it), `{"url": "https://..."}`,
or a bucket's file, `{"bucket_id": bucket, "key": "fonts/a.woff2"}`. Those
bytes count toward the 50 MB too.

`files` may instead be a folder on disk: the branch's tree is made to match
it, and only what changed is sent (new and changed files written, files the
folder no longer has deleted), so running it again after no change commits
nothing. `.git` is skipped, and so is any path matching one of the
`exclude` globs (`["node_modules", "*.log"]`), which also keeps the repo's
own copies of those paths.

Parameters:

- `files` (`Mapping[str, str | bytes | Attachment | Mapping[str, Any] | None] | str | os.PathLike[str]`, required)
- `message` (`str`, required)
- `branch` (`str | None`, default `None`)
- `author` (`str | None`, default `None`)
- `exclude` (`Sequence[str]`, default `()`)

Returns: `Commit | None` The new commit, with its `sha`; for a folder with nothing changed, `None`. Files
given that change nothing (each already holds what it's given) raise `noclick.Conflict`
(409), naming the commit that holds them.

Usage:

Write two files and delete one, as one commit:

```python
repo = noclick.Repo.from_name("agent-tools", create_if_missing=True)
commit = repo.commit(
    {"src/index.ts": "export const lookup = () => 42;\n", "package.json": '{"name": "agent-tools"}', "old.txt": None},
    message="Add the lookup route",
)
print(commit.sha, commit.files_changed)
```

Commit to a branch of its own, for a preview deployment, and name the author:

```python
repo = noclick.Repo.from_name("booking")
repo.commit(
    {"app/routes/book.tsx": "export default function Book() { return null; }\n"},
    message="Try the new booking form",
    branch="new-form",
    author="support-bot <support-bot@agents.noclick.app>",
)
```

Publish a page someone sent the account as it is, without reading it:

```python
[page] = noclick.attachments(query="game.html")
site = noclick.Repo.from_name("game", create_if_missing=True)
commit = site.commit({"index.html": page, "logo.png": {"url": "https://example.com/logo.png"}},
                     message="Publish the game")
```

Commit a folder a build wrote, sending only what changed since the last run:

```python
site = noclick.Repo.from_name("marketing-site", create_if_missing=True)
commit = site.commit("./dist", message="Rebuild the site", exclude=["*.map"])
print(commit.sha if commit else "nothing changed")
```

### Repo.read

```python
repo.read(path, *, ref=None) -> bytes
```

Read one file at `ref` (a branch, tag or commit sha; the default
branch's head when omitted). A missing path raises `noclick.NotFound`.
A link is never followed: its path reads as the path it points to.

Parameters:

- `path` (`str`, required)
- `ref` (`str | None`, default `None`)

Returns: `bytes` The file's bytes exactly as committed; decode text yourself.

Usage:

```python
repo = noclick.Repo.from_name("booking")
manifest = repo.read("package.json", ref="main").decode()
print(manifest)
```

### Repo.files

```python
repo.files(prefix='', *, ref=None, recursive=False) -> list[RepoFile]
```

What's in the directory `prefix` (the root when empty) at `ref`.
`recursive=True` lists every file below it instead, without the directories.
A symbolic link is one entry of `type` `link`, whatever it points to.

Parameters:

- `prefix` (`str`, default `''`)
- `ref` (`str | None`, default `None`)
- `recursive` (`bool`, default `False`)

Returns: `list[RepoFile]` Its files and directories, directories first, each by path from the repo's root.

Usage:

Walk the tree one level at a time:

```python
repo = noclick.Repo.from_name("booking")
for entry in repo.files("app/", ref="main"):
    print(entry.type, entry.path, entry.size)
```

Or read every file under a directory:

```python
repo = noclick.Repo.from_name("booking")
for entry in repo.files("app/routes/", recursive=True):
    print(entry.path, len(repo.read(entry.path)))
```

### Repo.branches

```python
repo.branches() -> list[Branch]
```

The repo's branches, the default one first.

Returns: `list[Branch]` Each branch with its `head` sha and when it last moved.

Usage:

```python
repo = noclick.Repo.from_name("booking")
for branch in repo.branches():
    print(branch.name, branch.head, branch.updated_at)
```

### Repo.backups

```python
repo.backups(*, branch=None, limit=50) -> list[RepoBackup]
```

The branches agents' pushes rewrote or deleted, as NoClick kept them first: newest first, each for
30 days. Through NoClick an agent never force-pushes or deletes the default branch at all.

Parameters:

- `branch` (`str | None`, default `None`)
- `limit` (`int | None`, default `50`): Return at most this many.

Returns: `list[RepoBackup]` Up to `limit` backups (`None` for all of them), of `branch` alone when it's given.

Usage:

```python
repo = noclick.Repo.from_name("booking")
for backup in repo.backups(branch="agent/new-form"):
    print(backup.reason, backup.sha[:7], backup.created_at)
```

### Repo.restore_backup

```python
repo.restore_backup(backup) -> Branch
```

Make a backup's branch again at the commit it was kept at (`backup`: a `RepoBackup` or its id).
When the repo has a branch by that name again, the backup comes back as `<branch>-restored-<time>`
instead; nothing that's there moves.

Parameters:

- `backup` (`RepoBackup | str`, required)

Returns: `Branch` The branch made, with its `head`.

Usage:

```python
repo = noclick.Repo.from_name("booking")
[latest] = repo.backups(branch="agent/new-form", limit=1)
print(repo.restore_backup(latest).name)
```

### Repo.commits

```python
repo.commits(*, branch=None, limit=20) -> list[Commit]
```

The history of `branch` (the default branch when omitted), newest first.

Parameters:

- `branch` (`str | None`, default `None`)
- `limit` (`int | None`, default `20`): Return at most this many.

Returns: `list[Commit]` Up to `limit` commits (20 by default; `None` for the whole history), fetched page by page.

Usage:

```python
repo = noclick.Repo.from_name("booking")
for commit in repo.commits(branch="main", limit=5):
    print(commit.sha[:7], commit.author, commit.message)
```

### Repo.commits_page

```python
repo.commits_page(*, branch=None, cursor=None, limit=None) -> Page
```

One page of `commits`, newest first; pass `next_cursor` back as `cursor`.

Parameters:

- `branch` (`str | None`, default `None`)
- `cursor` (`str | None`, default `None`): The `next_cursor` of the page before; omit it for the first page.
- `limit` (`int | None`, default `None`): Return at most this many.

Returns: `Page` A page whose `data` holds `Commit`s and whose `next_cursor` is `None` on the last page.

Usage:

```python
repo = noclick.Repo.from_name("booking")
page = repo.commits_page(branch="main", limit=50)
while True:
    for commit in page.data:
        print(commit.sha[:7], commit.message)
    if page.next_cursor is None:
        break
    page = repo.commits_page(branch="main", limit=50, cursor=page.next_cursor)
```

### Repo.diff

```python
repo.diff(sha) -> CommitDiff
```

What the commit `sha` (full or short) changed against its first parent. An unknown commit
raises `noclick.NotFound`.

Parameters:

- `sha` (`str`, required)

Returns: `CommitDiff` The commit with each file it changed, the file's status, the lines it added and deleted and
its patch in git's unified format.

Usage:

```python
repo = noclick.Repo.from_name("booking")
[latest] = repo.commits(limit=1)
changes = repo.diff(latest.sha)
print(f"+{changes.additions} -{changes.deletions}")
for file in changes.files:
    print(file.status, file.path)
    print(file.patch or "(not shown)")
```

### Repo.make_public

```python
repo.make_public(*, dry_run=False, transfer_cap_usd=None) -> PublicCode
```

Make a space template public (a repo holding a `space.json` at its default branch's head, as
`Workspace.save_as_template` writes one): anyone can then clone it from its `origin_url` and add it from
that address. What's public is a copy of that commit's files, never earlier history or other branches; one
file that looks like a secret refuses it all, naming each (`noclick.InvalidRequest`, reason
`secrets_found`), as does a space file that doesn't read (reason `not_a_template`). Called again, it
publishes the head as it is then. `dry_run` changes nothing; `transfer_cap_usd` bounds what clones cost
you a month ($5 unless set). Through MCP a first publish waits for the account's owner; a key needs
`projects:publish`, which `*` holds only when named. An app's repo goes public as its app
(`Project.make_public`).

Parameters:

- `dry_run` (`bool`, default `False`)
- `transfer_cap_usd` (`float | None`, default `None`)

Returns: `PublicCode` Its `PublicCode`.

Usage:

```python
saved = noclick.Workspace.from_name("Social media").save_as_template()
print(saved.repo.make_public().origin_url)
```

### Repo.make_private

```python
repo.make_private() -> PublicCode
```

Nobody can clone the template from now on. Copies people already cloned or added stay theirs.

Returns: `PublicCode` Its `PublicCode`, `public=False`, its `summary` saying so.

Usage:

```python
noclick.Repo.from_name("social-media-template").make_private()
```

### Repo.export

```python
repo.export() -> Operation
```

Package the repo to take elsewhere: every branch and its history as a git bundle.

Returns: `Operation` An operation whose `.wait()` gives an `noclick.ExportBundle`: a zip at `url`
(a link that expires) holding the bundle, which `git clone` reads as it is.

Usage:

```python
repo = noclick.Repo.from_name("agent-tools")
bundle = repo.export().wait()
print(bundle.url, bundle.expires_at)
```

### Repo.export_to_github

```python
repo.export_to_github(*, connection, owner, name=None, private=True) -> Operation
```

Copy the repo, every branch and tag with its history, into a new
GitHub repository `owner/name` (`name` defaults to this repo's),
through `connection`: a GitHub connection (a `Connection` or its
name) of the repo's user, or of the account. `owner` is the connected
account's own login or an organization it may create repositories in.
The NoClick repo stays as it was.

A connection with no GitHub account connected yet raises
`noclick.NeedsConnection`, whose `connect_url` connects it. The
operation fails with `noclick.Conflict` when GitHub already has
`owner/name`, and `noclick.PermissionDenied` when the connected
account can't create repositories there.

Parameters:

- `connection` (`Any`, required)
- `owner` (`str`, required)
- `name` (`str | None`, default `None`)
- `private` (`bool`, default `True`)

Returns: `Operation` An operation whose `.wait()` gives the new GitHub repository's URL.

Usage:

Hand a repo to its owner's GitHub organization:

```python
repo = noclick.Repo.from_name("agent-tools")
try:
    url = repo.export_to_github(connection="github", owner="acme").wait()
    print(url)   # https://github.com/acme/agent-tools
except noclick.NeedsConnection as needed:
    print("Connect GitHub first:", needed.connect_url)
```

### Repo.delete

```python
repo.delete() -> TrashItem
```

Delete the repo and its history: it goes to the trash, restorable for 30 days. A repo an app deploys
from (see `used_by`) is refused with `noclick.Conflict`; delete that app first.

Returns: `TrashItem` Its `TrashItem`: `restore()` puts it back, history and all.

Usage:

```python
repo = noclick.Repo.from_name("scratch")
repo.delete()
```

## noclick.Commit

```python
class Commit
```

One commit: its `sha`, `message` and `author`, the `branch` it was
made on, and `files_changed`, how many files it added, changed or deleted.
A branch's history (`commits()`) names that branch and counts no files
(`files_changed` is None); `diff()` counts them and names no branch.

| Attribute | Type | Description |
| --- | --- | --- |
| `sha` | `str` |  |
| `message` | `str` |  |
| `author` | `str | None` |  |
| `branch` | `str | None` |  |
| `created_at` | `Any` |  |
| `files_changed` | `int | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.CommitDiff

```python
class CommitDiff
```

What one commit changed against its first parent: the `commit`, its `parents` (none for the
first commit), the lines it added and deleted in all, and each file it changed.

| Attribute | Type | Description |
| --- | --- | --- |
| `commit` | `Commit` |  |
| `parents` | `list[str]` |  |
| `additions` | `int` |  |
| `deletions` | `int` |  |
| `files` | `list[FileChange]` |  |

## noclick.FileChange

```python
class FileChange
```

One file a commit changed: its `path` (and `old_path` when it was renamed), its `status`
(`added`, `modified`, `deleted`, `renamed`, `copied` or `type_changed`), the lines it added
and deleted, its `size` in bytes, and `patch`, its unified diff in git's format. `patch` (and the
line counts) are None for a file that isn't shown: one that isn't text, or is too large.

| Attribute | Type | Description |
| --- | --- | --- |
| `path` | `str` |  |
| `status` | `str` |  |
| `additions` | `int | None` |  |
| `deletions` | `int | None` |  |
| `size` | `int | None` |  |
| `patch` | `str | None` |  |
| `old_path` | `str | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.Branch

```python
class Branch
```

A branch: its `name`, the sha of its `head` commit, and when it last moved.

| Attribute | Type | Description |
| --- | --- | --- |
| `name` | `str` |  |
| `head` | `str | None` |  |
| `updated_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.RepoBackup

```python
class RepoBackup
```

A branch's old head NoClick kept before an agent's push rewrote it (`reason` `"rewritten"`: a
force-push) or deleted it (`"deleted"`): the `branch`, the commit `sha` it was at, the platform agent
whose push it was (`agent_id`, else None), and when it was kept. It's kept 30 days, until
`expires_at`, out of the branch list and clones; `Repo.restore_backup` makes the branch again.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `branch` | `str` |  |
| `sha` | `str` |  |
| `reason` | `str` |  |
| `agent_id` | `str | None` |  |
| `created_at` | `Any` |  |
| `expires_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.RepoFile

```python
class RepoFile
```

An entry in a repo's tree: its `path` from the root, its `type`
(`file`, `dir` or `link`) and, for a file, its `size` in bytes and `sha`,
git's blob id for its content (it changes whenever the content does). A `link`
is a symbolic link someone committed: listed as the entry it is, with no size
or sha, and never followed.

| Attribute | Type | Description |
| --- | --- | --- |
| `path` | `str` |  |
| `type` | `str` |  |
| `size` | `int | None` |  |
| `sha` | `str | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.RepoCheckout

```python
class RepoCheckout
```

A git repository an agent works in, for `Agent(repos=[...])`: a
connection's repository (`connection.checkout("acme/docs")`) or a NoClick
repo of the agent's scope (`repo.checkout()`). NoClick clones it into
`/workspace/<path>` (the repository's name when `path` is omitted) at a
conversation's first turn, and the agent's git reaches that repository only,
through NoClick, with a key made for its sandbox; the connection's own token
never enters it. `push` lists the branches it may push to: exact names, or a
prefix ending in `/*` (`"noclick/*"` reaches `noclick/fix` and
`noclick/a/b`); NoClick's git endpoint refuses any other push, and with no
`push` the checkout is read-only. Whatever `push` allows, the agent can't
force-push or delete the repository's default branch, and before its push
rewrites or deletes any other branch NoClick keeps the old head as a backup
for 30 days (on a git host, `refs/noclick/backups/<branch>/<time>` in the
repository, which you push back to restore; on a NoClick repo, `repo.backups()`
and `repo.restore_backup()`). A policy can't do this job: a coding
harness runs `git push` in its own shell, which is no tool call for a
policy to judge. `gh` only reads the repository there.

| Attribute | Type | Description |
| --- | --- | --- |
| `repository` | `str | None` | `owner/name` on the connection's service (None for a NoClick repo). |
| `connection` | `Any` |  |
| `repo` | `Any` |  |
| `branch` | `str | None` | The branch it checks out (the repository's default when None). |
| `path` | `str | None` | The folder under `/workspace` it's cloned into. |
| `push` | `list[str] | None` | Branches it may push to, exact or `prefix/*` (None: read-only). |

## noclick.RepoImport

```python
class RepoImport(Operation)
```

A public git repository being copied, history and all, into a new repo: the operation
`Repo.create(..., from_url=...)` returns. The repo is listed at once (`repo`) but takes no
commits or pushes until the copy succeeds. `wait()` gives the `Repo` then: its
`default_branch` is the source's own (or the one you named) and its `last_commit` that branch's
head. A copy that can't finish (no repository at the URL, one that asks for a sign-in, over 5 GiB
of history as git transfers it, which isn't the repo's `size_bytes` afterwards, longer than 15
minutes) raises from `wait()` saying why, and the repo is deleted; so is one you `cancel()`.
`progress` shows how far it got.

| Attribute | Type | Description |
| --- | --- | --- |
| `repo_id` | `str | None` | The new repo's id. |
| `repo` | `Repo` | The new repo: it reads while the copy runs, and takes writes once `wait()` returns. |
