Codespace support - #65
Closed
jmenestr wants to merge 15 commits into
Closed
Conversation
Adds `[codespace]` as a fourth delivery mode in data/projects.md. Crewmates SSH into the project's GitHub Codespace via `gh codespace ssh`, run treehouse worktrees there, and write status to `~/firstmate-state/<id>.status`. Firstmate supervises via a generated `state/<id>.check.sh` that polls the remote status file at FM_CHECK_INTERVAL cadence. Changes: - fm-project-mode.sh: recognise codespace as a valid mode - fm-spawn.sh: codespace spawn path (discover codespace, copy brief, SSH+treehouse+claude); mode resolution moved before window creation so codespace path can exit early - fm-brief.sh: codespace case writes to ~/firstmate-state/<id>.status and mkdir-ps it first - fm-teardown.sh: read codespace= from meta; remote dirty check when remote_worktree known; skip local fleet sync for codespace tasks - AGENTS.md: codespace entry in delivery mode table - README.md: document [codespace] registry format, discovery, FM_CODESPACE_REMOTE_STATE - tests/fm-codespace.test.sh: 5 tests covering mode parsing and spawn check.sh generation
…d robustness Complete the codespace delivery-mode adapter: - No local clone: derive owner/repo from the [codespace owner/repo] registry line via `fm-project-mode.sh --slug`, not a clone's origin remote. A codespace project registers with no clone at all. - Lease-based worktree: spawn polls for SSH-ready, then leases a worktree with `treehouse get --lease` (capturing its remote path) instead of fire-and-forget `sleep 8`s; the path is recorded in meta for teardown safety. - Scout + codespace end to end: a codespace scout brief writes its report and status to the remote firstmate-state dir; teardown copies the report back over SSH and applies the report-exists contract regardless of mode. - Teardown safety: ship teardown SSHes in and refuses on uncommitted/unpushed work; the worktree lease is released with `treehouse return`, and a failed return stops with state intact rather than leaking the lease. tests/fm-codespace.test.sh covers slug parsing, lease-path capture in meta, scout report-back, and the teardown checks.
… dedupe status check.sh
Add cursor-agent as a verified harness adapter: - launch_template cursor case (cursor-agent --force "$(cat brief)"); no turn-end hook (cursor has none), so supervision uses busy-signature + staleness + status writes - fm-harness.sh detects cursor (CURSOR_INVOKED_AS env marker + command name) - fm-watch.sh / fm-tmux-lib.sh busy regex add cursor's "ctrl+c to stop" footer - AGENTS.md section 4 cursor table (busy/exit/interrupt/skill, quirks) Make the codespace delivery path use a per-project configured harness: - registry bracket gains an optional harness: [codespace owner/repo <harness>], default claude, parsed via fm-project-mode.sh --codespace-harness - the codespace remote command launches the resolved harness (not hardcoded claude); meta and spawn summary record the real harness - codespace spawn idempotently bootstraps prerequisites before leasing (remote state dir + treehouse install when missing); fails with the one-time install command when treehouse cannot be made available Extend tests/fm-codespace.test.sh for harness parsing, configured-harness launch, and the prerequisite bootstrap (success + actionable failure).
Make the codespace delivery mode work against an older base image with no personal dotfiles, no non-interactive git auth, and a Cursor CLI installed under a different name, and surface codespace status to perch. - Gate on a treehouse that RUNS (treehouse --version), not just one on PATH; fall back to a go-install source build when the prebuilt binary crashes (e.g. GLIBC_2.34 on Debian 11 glibc 2.31). - Source login profiles + force PATH on every remote command, and resolve the cursor binary (cursor-agent or plain 'agent') at launch time. - Inject the Codespace GITHUB_TOKEN (guarded on the company secrets file) for both the lease and the launch so git fetch/push authenticate. - Mirror new remote status lines into local state/<id>.status for perch, deduped via check.last and stdout-silent to avoid a double-wake or loop. Extends tests/fm-codespace.test.sh to cover each fix; existing cases stay green.
The codespace lease ran 'treehouse get --lease' over 'gh codespace ssh', which starts in the session HOME, not the repo checkout. 'treehouse get' operates on the current git repo (git rev-parse --show-toplevel), so the lease failed with 'not in a git repository'. Prepend a cd into the codespace repo checkout (/workspaces/<repo-basename>, derived from the owner/repo slug) before the lease. If that path is not a git repo, fall back to the single git checkout under /workspaces/*; if none is found, fail with an actionable error instead of treehouse's cryptic one. Scoped to the lease step only: bootstrap, the launch (already cds into the leased worktree), and teardown's lease-release are unchanged. Adds tests asserting the lease cds into the derived checkout and exercising the fallback resolution logic.
… return in teardown
This was referenced Aug 9, 2026
This was referenced Aug 9, 2026
This was referenced Aug 10, 2026
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.
No description provided.