Docs

Changes and git

Caret keeps track of what each turn changed, lets you review it and take it back, and runs the usual git steps from the thread: commit, push, pull requests and merging.

How checkpoints work

Before a thread's first turn and after every turn, the engine saves a checkpoint of the files in the thread's folder. A checkpoint is a hidden git ref (refs/caret/checkpoints/…) written with a scratch index: it never touches your branch, your index or your stash, and never runs your hooks. Untracked files over 50 MB are left out.

Checkpoints are what the diff scopes, Edit from here and moving threads are built on. They're removed when you delete the thread.

Review a turn's changes

Under each turn that changed something, a card says how much: "4 changed files +38 −12", with the files as a tree and each file's counts. Click Review, or a file to open Review at it.

Use Review

⌘D shows the latest turn's changes in Review, in the right panel, or hides them. The toolbar has:

  • The scope menu, which picks what the diff compares:
ScopeWhat it shows
AutomaticThe latest turn while it works; then the whole thread, or the branch once it's committed
Latest turn, Turn NOne turn's changes
Whole threadEverything since the thread started
UncommittedAgainst the last commit, untracked files too
BranchWhat the branch adds to its base
Remote onlyWhat the upstream has that the branch doesn't (fetched first)
CommitsOne of the repository's newest hundred commits

An edit's step in the transcript has its own Review, showing just that edit ("One edit").

  • Open every file or Fold every file.
  • Stacked or Split: old beside new, Wrap long lines, and the File tree.
  • ⋯: Find (⌘F while the panel has the keyboard), Hide whitespace changes, Hide tests, and Load again.

A file's row stays at the top of the list while its lines go by, and the file tree lights the file you're reading. Point at a file's row for Copy path.

Files start folded. Settings → Review sets the defaults, the colours (red and green, or blue and orange), and whether Review opens by itself when a turn finishes with changes.

A commit hash in a reply that's among the repository's newest hundred commits is a link that opens that commit in Review.

Comment on lines

Click the + in the diff's gutter, drag down the gutter, or ⇧-click to take in several lines. Type your comment and press Enter: it becomes a chip in the composer, and shows in the diff under its lines. Your next message carries each comment with the file, the lines and a fence of the diff.

In a File tab, select lines (or put the cursor on one), then click Comment in its toolbar or press ⌥⌘/. The comment goes into the composer the same way, with the lines as they are now.

Go back to an earlier point

Hover one of your messages and click Edit from here. Pick:

  • Revert and keep changes: the conversation goes back to before that message; your files stay as they are.
  • Revert files too: the files go back as well. This is offered only when the thread works in a worktree of its own.

If files changed since the last checkpoint (you edited them by hand, say), Caret lists them and asks: Revert anyway or Keep the files. Your message comes back into the composer, to edit and send again. The turns taken back stay in the transcript, dimmed under a "Rewound" divider.

To branch off instead of going back, use Fork from here on a reply (see Threads).

Work in a worktree

A worktree is a second checkout of your repository on its own branch, so a thread's work stays apart from yours and from other threads'. Pick where a new thread works in the context strip under the composer:

ChoiceKeysWhere the thread works
Current checkout⌘⇧XThe project's own folder, on its current branch
New worktree⌘⇧XA new worktree on a new branch, from the base you pick (⌘⇧G)
On a branch…⌘⇧GThat branch: where it's checked out, or a new worktree on it
An existing worktree⌘⇧L for the last oneA worktree the project's threads already use

New worktrees go in ~/.caret/engines/caret/worktrees/. The branch starts as caret/<id> and is renamed after the task once the first message is in (caret/fix-sidebar-scroll). Settings → Worktrees changes the location, the prefix and the naming, and whether to start from the remote's branch.

If the project has a setup script (caret.json, see Automations), it runs in each new worktree before the agent starts, shown as a card in the first turn.

To make a project's new threads use worktrees by default, set Settings → Threads → Workspace to New worktree for that project.

Clean up worktrees

Settings → Worktrees has the cleanup rules: when the thread is done or idle for a time, when its branch merged, when nothing was done in it, when its thread was deleted. Preview shows what they'd remove; Clean up now removes it, and Clean up by itself applies them every hour. A worktree with local changes (uncommitted or untracked) is always kept. Settings → Projects → Checkouts lists a project's worktrees with Remove.

Commit and push

The thread details card (⇧⌘B) has a git row. It does what's likely next for the branch:

It saysWhen
CommitThere are uncommitted changes
Publish branchThe branch has commits and no upstream
SyncThe branch is both ahead of and behind its upstream
PushThe branch is ahead
PullThe branch is behind
Create PRThe branch is in step and has no pull request

Its menu has every step: Commit, Commit & push, Commit, push & create PR, Push, Pull, Create PR, Publish branch, Sync, and Merge back. They're in ⌘K and the thread details card too.

  • Commit opens a dialog with the changed files, each ticked, and a message box. Leave the message empty and the agent writes one, following your recent commit subjects (Settings → Git → Writing style overrides that). Your git identity and hooks are used.
  • Pull only fast-forwards. If the branch and its upstream have diverged, it says so and changes nothing.
  • Sync replays the branch's own commits onto the upstream's, then pushes. A conflict stops it with nothing changed and names the files.

A toast shows each step as it goes, then what was done ("Committed be05e6e …, pushed to origin/x").

Open a pull request

Create PR pushes first, then opens the pull request through GitHub's gh (or a token, below). The dialog has an optional title and description (left empty, the agent writes them, following the repository's PR template) and Open it as a draft.

The pull request's badge shows on the thread's row, coloured by its state, and in the details card. Click it to open the pull request on the Pull requests page (or on GitHub, if you turn off Settings → Review → Open pull requests in the app). ⌘⇧K copies its number.

When the pull request merges, the thread moves to Done by itself, unless Settings → Git → Keep merged threads is on.

Merge a worktree back

Merge back (in the git button's menu, or ⌘K → Merge back into the base branch) merges a worktree thread's committed branch into its base on this machine. Nothing is pushed.

  • If the base hasn't moved, it's a fast-forward; otherwise it makes a merge commit.
  • Where the base is checked out (usually the project's own folder), the merge happens there, and that checkout must be clean.
  • Uncommitted work on the thread's branch, or a conflict, stops it with nothing changed and the files named.

Merge back doesn't remove the worktree or mark the thread done.

Review pull requests on the Pull requests page

Open it from the GitHub button at the bottom of the sidebar, or ⌘K → Open pull requests. It's a page in the main pane, and from a git repository it starts on that repository's pull requests; the menu beside the search goes to another, or All repositories, across every machine. Esc goes back.

It's in the right panel too: Pull requests in the panel's list (⌘T), filtered to the repository of what's open, with This thread beside it for the thread's own and linked ones.

What you last saw shows at once, and is brought up to date behind it. A first page is 30 pull requests; Show more at the bottom asks for 100.

  • Search narrows what's loaded as you type: its title, number, author, branch or labels.
  • Tabs: All, Mine, To review, Needs me, Drafts; beside them the state (and Hide drafts), and an icon for the author, label and order. Needs me is a review asked of you, or your own with changes requested, failing checks or conflicts.
  • A row says how it stands in a word or two, such as Checks failing or Approved. Hover it for Open on GitHub, Copy link and Work on PR.
  • On a pull request, the bar at the bottom says what's in the way of merging and has what you can do: Work on PR, Review (the review form), Merge… (asks how to merge) and ⋯: Open on GitHub, Copy link, Check out its branch, Edit the title or description, Back to draft or Ready for review, Close or Reopen.
  • The button beside the tabs (46 files +1783 −92) opens the code as a page of its own, with a file tree at the left. Click a folder to fold it, a file to go to it, or the tick beside a file to mark it viewed. The tree button in the toolbar folds the whole tree away. The back arrow or Esc returns you to where you were.
  • A pull request opens on tabs:
    • Summary: the description (editable), reviewers, labels and the merge box (readiness, the method, delete the branch, Merge, auto-merge).
    • Timeline: comments, with a box to add one and Edit on your own.
    • Code: the diff beside the files, with Viewed boxes. Gutter comments go into your review.
    • Checks.
  • The review form sends Approve, Comment or Request changes with your line comments.
  • Checkout puts the pull request's branch in the project's checkout. Work on PR opens a new thread on that branch, linked to the pull request.

Settings → Git → Default merge method picks what Merge uses first (Merge commit, Squash or Rebase), when the repository allows it.

A thread can have more than its own pull request. The right panel's Pull request tab lists the thread's pull requests, with a field to link one by URL or #number, and for each: Watch, Unlink, Open and GitHub, plus the picked one's checks, review state and Merge.

A watched pull request is looked at every two minutes. When its checks finish, a review or comment arrives, or it merges or closes, the thread gets a message about it, which wakes the agent. The watch ends when the pull request merges or closes.

The same actions are in ⌘K: Show linked pull requests, Link pull request to thread…, Copy PR link, Watch pull request and Unwatch pull request.

Sign in to GitHub

Caret uses GitHub's own CLI, gh, signed in as you. Settings → Git → GitHub says whether it's installed and signed in, with Check again. To sign in, run gh auth login in a terminal.

Without gh, add a token instead: Settings → Git → Fallback GitHub token. It's kept in the machine's secret store (the Keychain on a Mac), never in a settings file.

Use several accounts

Settings → Git → Accounts lists every account gh, glab and your tokens reach, on every host. Use picks the account a host's pull requests go as. To add one, pick GitHub or GitLab, fill in the host (empty means github.com or gitlab.com) and a token, and click Add. A project can use its own account: pick the project under Applying to, then its Account.

Use GitHub Enterprise

Add your hosts to Settings → Git → GitHub Enterprise hosts, comma-separated. Sign in with gh auth login --hostname <host>, or add a token for the host under Accounts.

Use GitLab

GitLab works through glab (signed in to the host) or a token. Add self-managed hosts to Settings → Git → GitLab hosts.

Today, for GitLab:

  • Create PR opens a merge request (a draft's title starts with Draft:). Its badge reads !7, and a merged one moves its thread to Done.
  • # finds merge requests and issues.
  • The Pull requests page lists merge requests, shows their description, comments, pipeline and diff, and can comment, merge, close, reopen and toggle draft.
  • Not yet: reviews and approvals, line comments, Viewed marks, auto-merge, Checkout, Work on PR, and linked or watched merge requests.