Repository navigation
feat(bin): seed the first commit of a brand-new empty GitHub repo - #1608
Open
ConcosleyMedia wants to merge 3 commits into
Open
ConcosleyMedia wants to merge 3 commits into
ConcosleyMedia wants to merge 3 commits into
Conversation
…commit Git cannot create a worktree for a branch with zero commits, so a just-created empty GitHub repo (gh-axi repo create does not auto-initialize) was a dead end no crewmate could reach and firstmate was not allowed to write to either. bin/fm-seed-empty-repo.sh is the sixth sanctioned exception to hard rule kunchenguid#1: it verifies live against the GitHub API, never a flag or argument, that the repo genuinely has zero commits on every branch, then pushes a single empty commit and nothing else.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Add a narrow, scripted sixth exception to firstmate's hard rule #1 ('never write to a project'), covering exactly one case: seeding the very first commit of a genuinely brand-new, zero-commit GitHub repo, so its default branch exists and a crewmate can get a worktree at all. Git cannot create a worktree for a branch with zero commits - that is a git limitation, not a firstmate policy - so a just-created empty repo (gh-axi repo create does not auto-initialize with a README) was previously a dead end: no crewmate could touch it and firstmate was not allowed to either. This happened for real with a project called promo-reel-forge.
Built bin/fm-seed-empty-repo.sh (takes a project dir or registry name), following the existing patterns in bin/fm-project-mode.sh and bin/fm-fleet-sync.sh for resolving a project's dir/registry entry and origin remote. Deliberate design decisions:
Added a colocated test suite at tests/fm-seed-empty-repo.test.sh (11 cases) following the repo's tests/lib.sh conventions: a fake gh-axi in a per-case fakebin controls the three API responses via env vars, and real local git objects are used throughout, including for the one happy-path test where the origin remote is a real local bare repo whose path deliberately contains a github.com/owner/repo segment so the script's github.com URL-parsing regex sees a valid slug while the actual git push stays fully local (no network). Both the script and the test file are shellcheck-clean under the repo's pinned shellcheck 0.11.0 via bin/fm-lint.sh, and bin/fm-doc-audience-check.sh passes.
Updated AGENTS.md per the coding-guidelines skill's decision tree (detailed procedure belongs in the owning skill, not inline in AGENTS.md):
This is firstmate's own tracked repository, so I (a firstmate crewmate) was authorized to edit AGENTS.md, bin/, and .agents/skills/ directly per the task brief; ran bin/fm-ensure-agents-md.sh afterward per the brief's project-memory instructions and confirmed it was a no-op (AGENTS.md's "Maintaining this file" section was already present).
Note on this run: two earlier runs against this same branch content failed for reasons unrelated to the code under review - one hit a 403 push failure because origin was read-only and a writable fork remote had not yet been registered (now fixed via
no-mistakes init --fork-url), and after that a stray empty commit I had accidentally created via a malformed shell command was surgically removed from branch history viagit rebase --onto(verified byte-identical tree content before/after, both fix commits preserved), and the most recent attempt's review step failed only because the reviewing agent's own OAuth session had expired mid-run, not because of any issue with the change itself.What Changed
bin/fm-seed-empty-repo.sh, a guarded script that resolves a project's directory/registry entry and origin remote, performs a live GitHub API check (repo size 0, empty branches list, and a commits-API call that fails with the expected "Git Repository is empty" signature) as the safety net, then pushes exactly one empty "Initial commit" to the default branch so a crewmate can obtain a worktree against a repo git otherwise cannot branch.gh-axi, distinguishing safety-net verification failures (REFUSED:) from ordinary precondition failures (error:).tests/fm-seed-empty-repo.test.sh) using a fakegh-axito control the three API responses and real local git objects throughout, and isolatedFM_STATE_OVERRIDEhandling in those tests to prevent cross-test state leakage.AGENTS.md, the initialization procedure in.agents/skills/project-management/SKILL.md, and added the script to thebin/toolbelt reference table indocs/scripts.md.Risk Assessment
✅ Low: A narrow, well-isolated addition (new script + colocated tests + doc pointers) with no changes to existing behavior; the safety net (triple live-verified GitHub API check before any commit/push, no force-push, fails closed on any ambiguous signal) is sound, its output parsing matches gh-axi's actual API response format (verified live against a real GitHub repo), and all 11 tests exercise the refusal paths that matter.
Testing
Ran the full colocated test suite (11/11 passing) and performed manual end-to-end verification with real local git objects (no network) that reproduces the exact promo-reel-forge scenario: seeding a genuinely empty repo succeeds and unblocks
git worktree addthat previously failed with git's own limitation, while an inconclusive GitHub API failure is refused loudly with zero commits created, confirming the safety-net design decision works as intended.Evidence: End-to-end CLI transcript: seed happy path, worktree-add before/after payoff, and inconclusive-failure refusal
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 1 issue found → auto-fixed ✅
AGENTS.md- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-seed-empty-repo.test.sh— all 11 cases pass (happy path, non-zero size, non-empty branches, commits-API success, inconclusive commits-API failure, no origin, non-GitHub origin, dirty tree, already-seeded, branch mismatch, gh-axi missing)Manual E2E: built a real local bare 'GitHub' remote at a github.com/owner/repo-shaped path with zero commits, ranbin/fm-seed-empty-repo.shagainst a real clone of it with a gh-axi stub answering size=0/branches=[]/commits=409-empty, confirmed the script pushed exactly one 'Initial commit' to both local and remoteManual E2E payoff check: confirmedgit worktree add -b task/demo wt mainfails withfatal: not a valid object name: 'main'against the unseeded repo, and succeeds after seeding — demonstrating the actual crewmate-dispatch blocker the change fixesManual E2E safety-net check: ran the script against a live-shaped inconclusive commits-API failure (403 rate limit, not the 'Git Repository is empty' signature) and confirmed it printedREFUSED: could not confirm ... failed for an unexpected reasonand created no commitReviewed AGENTS.md, .agents/skills/project-management/SKILL.md, and docs/scripts.md diffs against the described intent (sixth hard-rule-1 exception, section 6 pointer, toolbelt table entry)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.