diff --git a/.gitignore b/.gitignore index 9c9f958..f8dd21e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ dist-server test-repo .superpowers wip-check.yml +test-repo.worktrees diff --git a/CLAUDE.md b/CLAUDE.md index 7664e1b..a6dca5a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -62,7 +62,7 @@ End-to-end verification (build, launch, drive with Playwright, API curl probes): - `~/.config/megit/config.json` is real user state. To drive the app without touching it (screenshots, probes), launch the server with an isolated `HOME`. - Design docs live in `docs/superpowers/specs/` — the *why* behind a feature, kept so decisions don't get re-litigated. Implementation plans are scratch: write them wherever, delete them once the feature ships. - Playwright MCP drops `.playwright-mcp/` artifacts into the CWD — keep them out of commits. -- `scripts/make-test-repo.sh` regenerates `test-repo/`: interleaved branches, merges, two stashes, dirty worktree. It is also the source of the README screenshots. +- `scripts/make-test-repo.sh` regenerates `test-repo/`: interleaved branches, merges, two stashes, dirty worktree. It is also the source of the README screenshots. `--worktrees` adds two linked worktrees (`test-repo.worktrees/`) for the worktree panel. ## Releasing diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 87ca981..f6d0f13 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ pnpm build # catches anything the dev server tolerates CI runs all of this on Linux, macOS and Windows, plus `pnpm build:server` and a smoke test of the CLI entrypoint. -`scripts/make-test-repo.sh` regenerates `test-repo/` — a throwaway fixture with interleaved branches, merges, two stashes and a dirty worktree. It is git-ignored, safe to delete, and is what the README screenshots are taken from. Note that vitest is configured to exclude it: the fixture contains a plausible-looking `test/renderer.test.ts` that would otherwise be collected into the real suite. +`scripts/make-test-repo.sh` regenerates `test-repo/` — a throwaway fixture with interleaved branches, merges, two stashes and a dirty worktree. It is git-ignored, safe to delete, and is what the README screenshots are taken from. `--worktrees` also creates two linked worktrees in `test-repo.worktrees/`, for the worktree panel screenshot. Note that vitest is configured to exclude it: the fixture contains a plausible-looking `test/renderer.test.ts` that would otherwise be collected into the real suite. ## Things worth knowing diff --git a/README.md b/README.md index 745dd9f..56c7eff 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,19 @@ Stashes appear as their own rows, attached to the commit they were taken from wi ### Worktrees -A repository with linked worktrees gets a panel beside the graph listing each one with its branch and changed-file count. Click a row to open it in its own purple `⎇` tab; counts update live, and a branch checked out elsewhere is marked on its chip and offers to open that tab instead of failing the checkout. Drag the panel's edge to resize it, collapse it to a rail that keeps the worktree count, and the trash icon on a row deletes that worktree (its branch stays). +A worktree is a second checkout of the same repository in its own folder, on its own branch — how coding agents (Claude Code, T3 Code, Codex) work in parallel without touching your checkout. megit doesn't create them; it shows the ones your tools made. + +![the worktree panel listing three worktrees with their changed-file counts, beside the graph](docs/worktrees.png) + +A repository with linked worktrees gets a panel beside the graph listing each one with its branch and a live count of changed files. Click a row to open that worktree in its own purple `⎇` tab. A branch checked out in another worktree carries a `⎇` on its chip, and checking it out offers to open that tab instead of failing. Drag the panel's edge to resize it, collapse it to a rail that keeps the count, and use the trash icon on a row to delete that worktree (its branch stays). + +To try it on any repository: + +```bash +git worktree add ../myapp-login -b fix/login # new folder, new branch +echo "// wip" >> ../myapp-login/src/app.ts # the panel's count goes to 1 +git worktree remove --force ../myapp-login # or the trash icon in megit +``` ### Diffs @@ -169,7 +181,7 @@ Ports come from `PORT` (API, default 3411) and `UI_PORT` (Vite dev server, defau In development the server runs its TypeScript directly via Node's native type-stripping — no build step. That does not work for a published package, because Node refuses to strip types under `node_modules`, so `pnpm build:server` compiles `server/` to `dist-server/` at publish time. -`scripts/make-test-repo.sh` generates `test-repo/` — a throwaway fixture with interleaved branches, merges, stashes and a dirty worktree, used for manual testing and for the screenshots above. +`scripts/make-test-repo.sh` generates `test-repo/` — a throwaway fixture with interleaved branches, merges, stashes and a dirty worktree, used for manual testing and for the screenshots above. `--worktrees` adds two linked worktrees with uncommitted work in `test-repo.worktrees/`. [`docs/architecture.md`](docs/architecture.md) explains how the two halves fit together and why the graph layout lives in a pure module. [CONTRIBUTING.md](CONTRIBUTING.md) has the setup and the house rules; [SECURITY.md](SECURITY.md) has the threat model. diff --git a/docs/worktrees.png b/docs/worktrees.png new file mode 100644 index 0000000..1c32c36 Binary files /dev/null and b/docs/worktrees.png differ diff --git a/scripts/make-test-repo.sh b/scripts/make-test-repo.sh index efd9944..ce1414b 100644 --- a/scripts/make-test-repo.sh +++ b/scripts/make-test-repo.sh @@ -4,9 +4,12 @@ # --date-order, so parallel branches only weave into visible lanes when their # timestamps overlap. Safe to delete and re-run. set -euo pipefail +# --worktrees also adds two linked worktrees in test-repo.worktrees/, as an agent +# tool would — for the README's worktree panel screenshot. Off by default: with +# them, every other screenshot would grow the panel too. cd "$(dirname "$0")/.." -rm -rf test-repo +rm -rf test-repo test-repo.worktrees mkdir test-repo cd test-repo @@ -242,4 +245,21 @@ cat > assets/star.svg <<'EOF' EOF # unstaged -echo "test-repo ready: $(git log --oneline --all | wc -l | tr -d ' ') commits, $(git branch | wc -l | tr -d ' ') branches, $(git stash list | wc -l | tr -d ' ') stashes, dirty worktree" +# ── linked worktrees (opt-in): two agents mid-task, both with uncommitted work ─ +if [[ "${1:-}" == "--worktrees" ]]; then + wt=../test-repo.worktrees + git worktree add -q "$wt/particles" feature/particles + printf '%s\n' "export const maxParticles = 2048" >> "$wt/particles/src/config.ts" + printf '%s\n' "// TODO: pool emitters" > "$wt/particles/src/emitter.ts" + + git worktree add -q -b agent/fps-overlay "$wt/fps-overlay" main + ( + cd "$wt/fps-overlay" + w src/overlay.ts "export const showFps = true" + commit "add fps overlay toggle" 09 10:00 "Claude" "agent@example.com" + printf '%s\n' "export const overlayCorner = 'top-right'" >> src/overlay.ts + printf '%s\n' "fps overlay: needs a design pass" > TODO.md + ) +fi + +echo "test-repo ready: $(git log --oneline --all | wc -l | tr -d ' ') commits, $(git branch | wc -l | tr -d ' ') branches, $(git stash list | wc -l | tr -d ' ') stashes, $(git worktree list | wc -l | tr -d ' ') worktrees, dirty"