Working folders and git
A bot works in a folder on your computer. In its own folder, Codync uses Git to keep a version before and after each turn. In a project folder, when the bot runs several threads at once, Git decides whether they can stay out of each other's way. This page says where each one works, what Codync leaves behind, and what to do when the folder isn't a Git repository or Git isn't installed.
A bot's working folder
Every bot has one folder it starts in. You choose it under Workspace in the bot's Settings:
- Own folder (the default): a folder Codync makes for the bot, inside
~/.codync/bots/. - Choose project folder…: a folder of yours, such as a project's Git repository.
How to pick one is in Workspace: its own folder or a project.
Versions of a bot's own folder
When Git is installed, a bot's own folder is a Git repository that Codync keeps for it:
- Before each turn that works there, Codync saves the folder as it is, named
Before:and the first line of what the bot was asked. - After the turn, it saves what the turn did, under that first line.
- Nothing is saved when nothing changed. A file over 50 MB stays out of the versions, and so do the files you send the bot (its
uploadsfolder). So do folders that tools fill again by themselves, such asnode_modulesand build output: they are listed in the folder's.gitignore, where you can add your own.
The bot knows this. Ask it what a turn changed, or to bring back a file as it was before, and it looks through the versions with Git. Your Settings show Git repository under the folder.
The versions stay on your computer. A project folder never gets them: its history is yours. Neither does an own folder that was already a Git repository (one you or the bot made in it before).
All the bot's threads work in its own folder, side by side, so two of them can change the same file. When one overwrites another's work, ask the bot to bring it back from a version.
Where threads work in a project folder
A thread is another session of the same bot that works away from the chat.
- The first one works in the bot's folder, as the chat does.
- Each further one that starts while another is still working gets its own copy, when the folder is in a Git repository and Worktree per thread is on. The copy is a Git worktree: a separate checkout under
~/.codync/worktrees, on a new branch namedcodync/and the thread's title (for examplecodync/fix-login), started from the commit your folder is on. The threads never overwrite each other, and none of them touches your folder.
A copy holds what is committed. Changes in your folder that aren't committed aren't in it, and neither is what Git ignores there, such as installed packages.
Worktree per thread is under Workspace in the bot's Settings. It shows only when a project folder is in a Git repository, and is on unless you turn it off. With it off, every thread works in the bot's folder.
Routine runs and other bots' requests always work in the bot's folder.
What happens to the copies
When a thread ends, Codync looks at its copy:
- Nothing changed: no changed or new files and no commits. The copy is removed, with its branch.
- Something changed: the copy and its branch stay, and the bot tells you the branch and where the copy is.
- You merged it since: each time Codync starts on the computer (after an update, say), it looks at the copies it kept. One with no uncommitted changes whose commits are in your folder's branch is removed, with its branch.
Codync never merges, rebases or deletes a branch that has work on it. Bringing the work in is yours to do, or the bot's when you ask it.
Bring the work in yourself
In your own folder, merge the branch, then remove the copy and the branch:
cd ~/projects/my-app
git merge codync/fix-login
git worktree list # shows where each copy is
git worktree remove ~/.codync/worktrees/…/…
git branch -d codync/fix-login
git merge brings in commits only. If the thread left changes it didn't commit, commit them in the copy first. Git refuses to remove a copy that still has uncommitted changes, and git branch -d refuses a branch that isn't merged, so nothing is lost by accident.
Without git
Codync can keep versions and give threads their own copies only with Git. In both cases below, every thread of the bot writes in the same folder, and two that work at the same time can overwrite each other's files.
The folder isn't a Git repository
A project folder may not be a Git repository. (A bot's own folder becomes one by itself once Git is installed.) Choose one of these:
- Keep to one at a time. Set Threads at once, under Workspace in the bot's Settings, to 1. Further threads wait their turn.
- Make the folder a repository. A copy starts from a commit, so the folder needs at least one:
cd ~/projects/my-folder
git init
git add -A
git commit -m "First commit"
Be careful with that first commit: git add -A takes every file in the folder. List what should stay out (passwords, keys, large files, installed packages) in a .gitignore file before you run it.
Git isn't installed
Without Git on the computer the bot runs on, a repository gives no copies either: threads work as in a folder that isn't one. Install Git there:
| Computer | Command |
|---|---|
| macOS | xcode-select --install, or brew install git with Homebrew |
| Debian, Ubuntu | sudo apt install git |
| Fedora | sudo dnf install git |
| Windows | winget install Git.Git, or the installer from git-scm.com |
Then restart Codync on that computer, so it finds Git.
Where the apps show it
- Under each thread that is or was worked on, in the bot's Details and in Work, a line says where it works: the folder when it works in the bot's folder, the branch when it has a copy of its own. Your home folder is written as
~. On the desktop, hold the pointer over the line to see the full path. - At the top of a thread (tap or click its row), the same line is a button: tap or click it to copy the full path. It reads Path copied for a moment.
- Settings > Workspace says under the folder which case the bot is in: Git repository, Not a git repository or Git isn't installed on this computer. On iPhone, Android and the desktop, the information button beside it opens this page. It describes the folder the bot has saved.
- Terminal UI: the same words are in dim text under Workspace in the bot's settings, with no button. A thread's row has no such line; the heading of its steps shows its branch or folder, and doesn't copy.