Repository navigation
v0.3.0
This release closes a gap an agent could not see from inside: when the harness, not the agent, decides to use a git worktree, jj silently answers for the wrong repository.
Harness-created git worktrees (worktree-shadowed)
The skill assumed the agent chooses whether to use a git worktree. It does not. Claude Code's EnterWorktree, --worktree, isolation: "worktree" on a subagent, and background sessions all create a plain git worktree at .claude/worktrees/<name> inside the repo, before the agent has any say. That worktree has no .jj/, so jj walks up, finds the parent repo's .jj/, and answers for the parent workspace.
Reported by @plttn in #18 — including the discard_changes: true trap below, which is what makes the state destructive rather than merely confusing — and fixed in #19 by @CybotTM.
What it costs, all reproduced on jj 0.43.0:
- Reads lie.
jj statusprintsThe working copy has no changes.over a modified and an untracked file. - Writes hit the wrong repo.
jj describe -mfrom the worktree committed the parent checkout's unrelated in-progress edit under the agent's message, andjj newadvanced the parent's working copy. The worktree's own edits were never touched. - The detector endorsed it.
detect_jj_state.shreportedmode: colocatedwith a working-copy state read from the wrong workspace. It computed both roots and never compared them.
Neither conversion repairs the directory in place: jj git init --colocate refuses inside a git worktree, and jj workspace add refuses a non-empty destination.
What changed
detect_jj_state.shgains aworktree-shadowedmode and exits 3. Detection is structural — git's own gitdir differs from the common dir andjj rootis not the worktree root — not a.claude/worktrees/*path glob, so it holds for harnesses that use other directories. Working-copy state comes from git in that mode, and thejj statusprobe is skipped because it answers for the parent.agent-safety.md§7: run no jj command in this state, reads included.git-interop.md: the full failure mode, and thediscard_changes: truetrap named explicitly.ExitWorktreerefuses to remove a worktree with uncommitted files; that check is at the git level and is correct. The failure sequence is jj reporting clean → the agent believing jj over the tool → passingdiscard_changes: true→ the work gone, with no operation log to recover from because jj never recorded it.recovery-playbook.md: recovering the parent repo after jj already ran from a shadowed worktree, and what is not recoverable at all.
A data-loss recipe removed
git-interop.md previously offered jj git init --git-repo=… as the fallback for the worktree case. In a dirty worktree that command succeeds, prints Added 0 files, modified 1 files, removed 1 files, and silently reverts the modified file and deletes the untracked one — no prompt, no operation-log entry to undo from. It is now marked as destructive, with a git status --short precondition. This affected anyone in a bare-repo + worktree layout, independent of the harness topic.
Also fixed: detect_jj_state.sh --json emitted string fields unescaped, so a repo path containing a double quote produced unparseable output — which would have broken the very guard this release adds.
Distribution and CI
- Portable Agent Plugins 1.0.0 manifest (
plugin.json) in #17 by @CybotTM, alongside the existing.claude-plugin/plugin.json. - Adopted the shared Netresearch skill-repo template in #16;
validate.ymldropped in favour of the template'slint.yml. - Secret and workflow scanning added to
security.ymlin #15; jj evals now run via the shared script-check reusable in #14.
Upgrading
No breaking changes. Agents in a normal colocated repo, a jj workspace, or a bare-repo worktree layout see no behaviour change — all three were verified not to trigger the new mode. The one contract change: detect_jj_state.sh now exits 3 in the shadowed state, so a caller running it under set -e will abort there. That is the intent.
Full Changelog: v0.2.0...v0.3.0