-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Bug
When a user adds a rig connected to a repo with zero commits (freshly created, no initial commit), the mayor agent crashes. This is a common scenario — users create a new repo on GitHub and immediately connect it to Gastown to start building.
Likely Cause
The container's git setup (container/src/git-manager.ts) clones the repo and checks out the default branch. An empty repo has no branches, no HEAD, and git clone may succeed but leave the worktree in a detached/unborn state. Subsequent git operations that the mayor or its tools rely on (e.g., git log, git branch, git diff) fail because there are no commits to reference.
The kilo CLI itself (kilo serve) may also fail to initialize — it requires a git repo in the working directory (agent-runner.ts:366), and an empty repo with no commits may not satisfy whatever check it performs (e.g., git rev-parse HEAD fails with "fatal: ambiguous argument 'HEAD': unknown revision").
Expected Behavior
Empty repos should work. The mayor should start normally and be ready to accept tasks. The first polecat dispatched should be able to create an initial commit and push it. This is arguably the most natural onboarding path: "I just made a repo, now let Gastown build something in it."
Fix
Git manager
In container/src/git-manager.ts, handle the empty repo case in cloneRepo / createWorktree:
- Detect empty repo after clone (
git rev-parse HEADfails) - Create an initial empty commit:
git commit --allow-empty -m "Initial commit" - Push it:
git push origin HEAD - Proceed with normal worktree setup
Agent runner
In container/src/agent-runner.ts, the git repo init fallback (initGitRepo, line 366) may already handle this for the mayor's worktree. Verify it works for the case where the repo was cloned (not initialized locally) but has no commits.
Polecat system prompt
No changes needed — if the repo has the empty initial commit, everything works normally. The polecat creates files, commits, and pushes as usual.
Files
container/src/git-manager.ts—cloneRepo(),createWorktree()container/src/agent-runner.ts—initGitRepo()(line 366), worktree setup
Acceptance Criteria
- Connecting an empty repo (zero commits) to a rig does not crash the mayor
- Mayor starts and accepts tasks normally on an empty repo
- First polecat dispatched can create files, commit, and push
- Works for both GitHub and GitLab repos