Bug
ao project add never inspects the repo's checked-out branch. The project's Config.DefaultBranch is left empty and WithDefaults() forces it to "main" (backend/internal/domain/projectconfig.go:48). For any repo whose default branch isn't literally main (e.g. master, develop, trunk), every subsequent ao spawn fails because the worktree base ref doesn't exist.
Analyzed against: 3e64c15 | Confidence: High
Reproduction
git init a repo (no -b, so on a host without init.defaultBranch it lands on master), add one commit.
ao project add --path <repo> --id x → ao project get x reports default branch: main. ❌ (the repo is on master)
ao spawn --project x --prompt hi →
BRANCH_NOT_FETCHED: "ao/x-1" has no local head, no remote, and no tag — run `git fetch` then retry
- The identical repo on
main spawns fine. ao project add exposes no --branch flag, so there is no CLI workaround.
Root Cause
backend/internal/service/project/service.go Add (single-repo path) registers the project without detecting the repo's branch, so Config.DefaultBranch stays empty → defaults to main.
- At spawn,
resolveBaseRef (backend/internal/adapters/workspace/gitworktree/workspace.go:253) tries origin/main, refs/heads/main, and tags; none exist on a master repo → errNoBaseRef → ErrBranchNotFetched.
- The surfaced message ("run
git fetch") is misleading: there is no remote, and the base branch name is simply wrong.
Fix
Detect the repo's current branch with git symbolic-ref --short HEAD at registration and store it as DefaultBranch when the user didn't configure one and it diverges from main. Best-effort: a detached HEAD or git error falls back to the existing main default, so add never fails on this account.
Impact
Breaks the README quickstart (project add → spawn) for every master / non-main repo — a large fraction of older and real-world repositories. No workaround via the CLI.
Bug
ao project addnever inspects the repo's checked-out branch. The project'sConfig.DefaultBranchis left empty andWithDefaults()forces it to"main"(backend/internal/domain/projectconfig.go:48). For any repo whose default branch isn't literallymain(e.g.master,develop,trunk), every subsequentao spawnfails because the worktree base ref doesn't exist.Analyzed against:
3e64c15| Confidence: HighReproduction
git inita repo (no-b, so on a host withoutinit.defaultBranchit lands onmaster), add one commit.ao project add --path <repo> --id x→ao project get xreportsdefault branch: main. ❌ (the repo is onmaster)ao spawn --project x --prompt hi→mainspawns fine.ao project addexposes no--branchflag, so there is no CLI workaround.Root Cause
backend/internal/service/project/service.goAdd(single-repo path) registers the project without detecting the repo's branch, soConfig.DefaultBranchstays empty → defaults tomain.resolveBaseRef(backend/internal/adapters/workspace/gitworktree/workspace.go:253) triesorigin/main,refs/heads/main, and tags; none exist on amasterrepo →errNoBaseRef→ErrBranchNotFetched.git fetch") is misleading: there is no remote, and the base branch name is simply wrong.Fix
Detect the repo's current branch with
git symbolic-ref --short HEADat registration and store it asDefaultBranchwhen the user didn't configure one and it diverges frommain. Best-effort: a detached HEAD or git error falls back to the existingmaindefault, soaddnever fails on this account.Impact
Breaks the README quickstart (
project add→spawn) for everymaster/ non-mainrepo — a large fraction of older and real-world repositories. No workaround via the CLI.