git-worktrees 0.13.3__tar.gz → 0.14.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. git_worktrees-0.14.0/.agents/plugins/marketplace.json +20 -0
  2. git_worktrees-0.14.0/.claude-plugin/marketplace.json +15 -0
  3. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/.github/workflows/publish.yml +30 -5
  4. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/AGENTS.md +57 -17
  5. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/CHANGELOG.md +56 -0
  6. git_worktrees-0.14.0/PKG-INFO +335 -0
  7. git_worktrees-0.14.0/README.md +308 -0
  8. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/completions/gw.fish +2 -2
  9. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/conf.d/worktrees.fish +1 -1
  10. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/DEVELOPMENT.md +16 -5
  11. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/REFERENCE.md +132 -10
  12. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/fast-forward.md +4 -1
  13. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/list.md +5 -0
  14. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/push.md +10 -0
  15. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/.claude-plugin/plugin.json +1 -1
  16. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/.codex-plugin/plugin.json +1 -1
  17. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/README.md +13 -0
  18. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/plugin.json +1 -1
  19. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/describe-pr/SKILL.md +1 -1
  20. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/describe-pr/format.md +1 -1
  21. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/fast-forward/SKILL.md +2 -1
  22. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/prune/SKILL.md +9 -4
  23. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/ship-it/SKILL.md +1 -1
  24. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/pyproject.toml +1 -1
  25. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/branch_forge.py +13 -2
  26. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/cli.py +20 -6
  27. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/fast_forward.py +9 -5
  28. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/git.py +43 -3
  29. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/merged.py +17 -3
  30. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/pick.py +2 -2
  31. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/pr_merge.py +10 -8
  32. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/progress.py +3 -1
  33. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/prune.py +10 -3
  34. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/push.py +15 -8
  35. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/render.py +25 -0
  36. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/repo.py +10 -6
  37. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/sync.py +109 -24
  38. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/verdicts.py +77 -13
  39. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/worktree.py +22 -8
  40. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_assessment.py +211 -6
  41. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_branches.py +6 -3
  42. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_completions.py +35 -12
  43. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_fast_forward.py +22 -0
  44. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_gates.py +40 -1
  45. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_plugin.py +24 -0
  46. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_push.py +32 -0
  47. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_removal.py +22 -0
  48. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_render.py +19 -0
  49. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_sync.py +119 -0
  50. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/uv.lock +1 -1
  51. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/completions/_gw +2 -2
  52. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/worktrees.plugin.zsh +1 -1
  53. git_worktrees-0.13.3/PKG-INFO +0 -748
  54. git_worktrees-0.13.3/README.md +0 -721
  55. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/.claude/settings.json +0 -0
  56. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/.codex/config.toml +0 -0
  57. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/.github/workflows/codeql.yml +0 -0
  58. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/.github/workflows/testpypi.yml +0 -0
  59. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/.github/workflows/tests.yml +0 -0
  60. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/.gitignore +0 -0
  61. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/.pre-commit-config.yaml +0 -0
  62. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/.python-version +0 -0
  63. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/.releasetools.yaml +0 -0
  64. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/LICENSE +0 -0
  65. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/Makefile +0 -0
  66. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/completions/worktrees.fish +0 -0
  67. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/BENCHMARK.md +0 -0
  68. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/add.md +0 -0
  69. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/branch-create.md +0 -0
  70. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/branch-prune.md +0 -0
  71. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/branch-status.md +0 -0
  72. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/ci-checks.md +0 -0
  73. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/merge.md +0 -0
  74. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/preflight.md +0 -0
  75. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/commands/stack-link.md +0 -0
  76. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/docs/plans/2026-11-05-worktree-pruning-design.md +0 -0
  77. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gw.fish +0 -0
  78. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwa.fish +0 -0
  79. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwbc.fish +0 -0
  80. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwbp.fish +0 -0
  81. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwbs.fish +0 -0
  82. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwff.fish +0 -0
  83. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwl.fish +0 -0
  84. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwm.fish +0 -0
  85. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwp!.fish +0 -0
  86. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwp.fish +0 -0
  87. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwpa!.fish +0 -0
  88. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwpa.fish +0 -0
  89. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwpu.fish +0 -0
  90. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwr!.fish +0 -0
  91. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwr.fish +0 -0
  92. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gwrk!.fish +0 -0
  93. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/functions/gws.fish +0 -0
  94. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/hatch_build.py +0 -0
  95. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/hooks/codex.json +0 -0
  96. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/hooks/hooks.json +0 -0
  97. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/session.md +0 -0
  98. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/ci-checks/SKILL.md +0 -0
  99. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/preflight/SKILL.md +0 -0
  100. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/preflight/agents/openai.yaml +0 -0
  101. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/preflight/config.toml +0 -0
  102. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/preflight/merge_codex_rules.py +0 -0
  103. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/preflight/project.json +0 -0
  104. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/preflight/rules.json +0 -0
  105. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/preflight/worktrees.rules +0 -0
  106. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/plugin/skills/ship-it/rights.md +0 -0
  107. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/renovate.json +0 -0
  108. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/scripts/README.md +0 -0
  109. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/scripts/benchmark.py +0 -0
  110. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/scripts/bump_version.py +0 -0
  111. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/scripts/verify-publish.bash +0 -0
  112. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/__init__.py +0 -0
  113. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/audit.py +0 -0
  114. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/branch_cli.py +0 -0
  115. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/branches.py +0 -0
  116. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/ci.py +0 -0
  117. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/errors.py +0 -0
  118. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/forge.py +0 -0
  119. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/layout.py +0 -0
  120. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/new_branch.py +0 -0
  121. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/preflight.py +0 -0
  122. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/src/worktrees/stack_link.py +0 -0
  123. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/audit_schema.py +0 -0
  124. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/conftest.py +0 -0
  125. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_audit.py +0 -0
  126. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_benchmark.py +0 -0
  127. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_branch_forge.py +0 -0
  128. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_ci.py +0 -0
  129. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_cli.py +0 -0
  130. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_command_defaults.py +0 -0
  131. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_fixture.py +0 -0
  132. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_forge.py +0 -0
  133. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_git_records.py +0 -0
  134. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_new_branch.py +0 -0
  135. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_partial_clone.py +0 -0
  136. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_path_boundaries.py +0 -0
  137. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_pr_merge.py +0 -0
  138. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_preflight.py +0 -0
  139. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_shims.py +0 -0
  140. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_spec.py +0 -0
  141. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_stack_link.py +0 -0
  142. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_version.py +0 -0
  143. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/tests/test_worktree.py +0 -0
  144. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gw +0 -0
  145. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwa +0 -0
  146. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwbc +0 -0
  147. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwbp +0 -0
  148. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwbs +0 -0
  149. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwff +0 -0
  150. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwl +0 -0
  151. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwm +0 -0
  152. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwp +0 -0
  153. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwp! +0 -0
  154. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwpa +0 -0
  155. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwpa! +0 -0
  156. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwpu +0 -0
  157. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwr +0 -0
  158. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwr! +0 -0
  159. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gwrk! +0 -0
  160. {git_worktrees-0.13.3 → git_worktrees-0.14.0}/zsh/plugins/worktrees/functions/gws +0 -0
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "worktrees",
3
+ "interface": {
4
+ "displayName": "worktrees"
5
+ },
6
+ "plugins": [
7
+ {
8
+ "name": "worktrees",
9
+ "source": {
10
+ "source": "local",
11
+ "path": "./plugin"
12
+ },
13
+ "policy": {
14
+ "installation": "AVAILABLE",
15
+ "authentication": "ON_INSTALL"
16
+ },
17
+ "category": "Developer Tools"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "worktrees",
3
+ "owner": {
4
+ "name": "Mihai Bojin",
5
+ "url": "https://github.com/MihaiBojin"
6
+ },
7
+ "description": "The worktrees agent plugin, from the repository that holds its CLI",
8
+ "plugins": [
9
+ {
10
+ "name": "worktrees",
11
+ "source": "./plugin",
12
+ "description": "Read CI, rebase onto the head branch, describe, ship and merge pull requests, and prune finished worktrees through the worktrees CLI"
13
+ }
14
+ ]
15
+ }
@@ -402,7 +402,7 @@ jobs:
402
402
 
403
403
  # signed-push commits onto a branch that exists, so the branch starts at
404
404
  # the marketplace's main. A rerun finds it: with its pull request open
405
- # there is nothing left to do, and without one a person decides.
405
+ # it goes on to the merge, and without one a person decides.
406
406
  - name: Create the branch
407
407
  id: branch
408
408
  if: steps.bump.outputs.changed == 'true'
@@ -418,6 +418,7 @@ jobs:
418
418
  if [ -n "$open" ]; then
419
419
  echo "$branch already has a pull request: $open" >&2
420
420
  echo "action=none" >>"$GITHUB_OUTPUT"
421
+ echo "pr=$open" >>"$GITHUB_OUTPUT"
421
422
  exit 0
422
423
  fi
423
424
  echo "::error::$MARKETPLACE has a branch $branch with no open pull request. Open one for it or delete it, then re-run this job."
@@ -443,9 +444,9 @@ jobs:
443
444
  prune: "false"
444
445
  token: ${{ steps.app-token.outputs.token }}
445
446
 
446
- # Opened as the App, so the marketplace's own checks run on it. Merging
447
- # is left to a person.
447
+ # Opened as the App, so the marketplace's own checks run on it.
448
448
  - name: Open the pull request
449
+ id: open
449
450
  if: steps.branch.outputs.action == 'commit'
450
451
  env:
451
452
  GH_TOKEN: ${{ steps.app-token.outputs.token }}
@@ -455,5 +456,29 @@ jobs:
455
456
  body="$(printf '%s\n\n%s\n' \
456
457
  "The \`worktrees\` listing installs the plugin from its $TAG tag." \
457
458
  "Opened by [$GITHUB_REPOSITORY's publish run]($RUN).")"
458
- gh pr create --repo "$MARKETPLACE" --base main --head "$BRANCH" \
459
- --title "chore(worktrees): List $TAG" --body "$body"
459
+ url="$(gh pr create --repo "$MARKETPLACE" --base main --head "$BRANCH" \
460
+ --title "chore(worktrees): List $TAG" --body "$body")"
461
+ echo "$url"
462
+ echo "pr=$url" >>"$GITHUB_OUTPUT"
463
+
464
+ # The marketplace's main requires no checks, so the job waits for them
465
+ # itself. They register a few seconds after the pull request opens, and
466
+ # `gh pr checks` reports none until then. A failed check, or none after
467
+ # five minutes, fails the job and leaves the pull request to a person.
468
+ # The squash is pinned to the head the checks ran on.
469
+ - name: Merge the pull request once its checks pass
470
+ if: steps.open.outputs.pr != '' || steps.branch.outputs.pr != ''
471
+ timeout-minutes: 30
472
+ env:
473
+ GH_TOKEN: ${{ steps.app-token.outputs.token }}
474
+ PR: ${{ steps.open.outputs.pr || steps.branch.outputs.pr }}
475
+ run: |
476
+ set -euo pipefail
477
+ head="$(gh pr view "$PR" --json headRefOid --jq .headRefOid)"
478
+ for _ in $(seq 60); do
479
+ count="$(gh pr checks "$PR" --json name --jq length 2>/dev/null || true)"
480
+ if [ -n "$count" ] && [ "$count" != 0 ]; then break; fi
481
+ sleep 5
482
+ done
483
+ gh pr checks "$PR" --watch --fail-fast --interval 10
484
+ gh pr merge "$PR" --squash --match-head-commit "$head"
@@ -146,7 +146,8 @@ leaves the open request on that finished branch, where a merge never
146
146
  reaches the head branch. `_retarget` moves its base to the head branch,
147
147
  the one forge write `gw fast-forward` makes on its own, and `_publish`
148
148
  pushes the branch under a lease once it is level; a branch with an open
149
- request that dropped a parent's merged commits is pushed the same way.
149
+ request that dropped a parent's merged commits is pushed the same way,
150
+ `stash-conflict` included, since only the uncommitted work failed there.
150
151
  Commits the finished branch gained after its merge that the head ref
151
152
  lacks, by `merged.change_in`, go first: `_rescue` copies them without a
152
153
  checkout onto a dated branch from the head ref, pushes it and opens its
@@ -176,7 +177,9 @@ that neither the branch nor the head ref holds by sha or patch-id, outside
176
177
  the copy's own `merged.merged_part`. A merge or an empty commit has no
177
178
  patch-id in this comparison and stays in that list without another proof.
178
179
  Any that `push.made_here` does not find through the branch's reflog is a
179
- refusal that `--replace` lifts. `merged.merged_part` of the branch itself,
180
+ refusal that `--replace` lifts. An entry counts only the commits it made,
181
+ never what it built on: a rebase's `onto` commit, which `git rebase
182
+ origin/BRANCH` makes another clone's tip, and a committed merge's parents. `merged.merged_part` of the branch itself,
180
183
  the commits the head ref already has by the proofs `gw prune` reads, is a
181
184
  refusal nothing lifts, and names `gw fast-forward`. `--force-if-includes` is not passed: git
182
185
  ignores it beside an explicit lease, and the first check asks what it
@@ -251,7 +254,7 @@ assumes a plugin root or a checkout at a known path.
251
254
 
252
255
  `describe-pr` and `ship-it` share `describe-pr/format.md`: the
253
256
  review's title and body are the squash commit's subject and body, so one set
254
- of rules writes both. When the agent has the technical-writing plugin's
257
+ of rules writes both. When the agent has the technical-writer plugin's
255
258
  `pr-description` skill, both write the title and the body in that skill's
256
259
  format, and `format.md` keeps what to preserve, the auto-resolution block
257
260
  and the four ways a description is wrong. `tests/test_plugin.py` holds every skill's
@@ -320,6 +323,13 @@ The plugin carries the release version in three manifests, and
320
323
  portable manifest, the Claude one with only the fields Agent Plugins v1 names;
321
324
  the same test holds it to that.
322
325
 
326
+ The repository root is a marketplace named `worktrees`, one catalog a
327
+ client, whose one entry is `./plugin`: `worktrees@worktrees`. Neither
328
+ catalog names a version or a tag, so a release stamps nothing there, and
329
+ `tests/test_plugin.py` holds both to that. `MihaiBojin/agent-plugins` lists
330
+ the same plugin as `worktrees@mihaibojin`, pinned to a release tag that the
331
+ `list` job in `publish.yml` moves; preflight sets up that one.
332
+
323
333
  ## The picker is Python's, and there is no fzf
324
334
 
325
335
  Building the candidate list, matching a query against it, ranking, deciding
@@ -372,8 +382,9 @@ does: the command exits 0 and deletes nothing.
372
382
  The list is redrawn in place when stderr is a terminal that can move its
373
383
  cursor: the cursor climbs over the frame drawn last and erases everything
374
384
  under it, since the filter makes the list longer or shorter. The climb counts
375
- lines, so the frame fits the screen: each row is cut to the terminal's width,
376
- and the rows shown are a window as tall as the screen that follows the
385
+ lines, so the frame fits the screen: each row is cut to the terminal's width
386
+ by `render.fit`, which counts a wide character as two columns and a
387
+ combining mark as none, and the rows shown are a window as tall as the screen that follows the
377
388
  highlight. On `TERM=dumb`,
378
389
  or a stderr that is not a terminal, the list is printed once, each move
379
390
  prints the row it lands on, and each change to the filter prints the rows it
@@ -497,8 +508,9 @@ call site that formats a table, and neither path passes a code to one.
497
508
  `progress.py` draws a spinner on stderr and one line per running thread
498
509
  saying what it is checking, while `gw sync`, `gw prune`, `gw remove`,
499
510
  `gw branch status` and `gw branch prune` assess or mutate. A thread's line
500
- goes when the thread ends, and every line is cut to the terminal width so
501
- the redraw can count its rows. It runs only when stderr is a terminal that
511
+ goes when the thread ends, and every line is cut to the terminal width by
512
+ `render.fit` so the redraw can count its rows: a branch named in CJK takes
513
+ two columns a character, and cutting it by `len` wraps the line. It runs only when stderr is a terminal that
502
514
  can clear a line, and never under `-q` or `-v`, since the verbose log writes
503
515
  to the lines it redraws. Anything else printed on stderr while it spins goes
504
516
  through `progress.line`, which clears the spinner first.
@@ -579,11 +591,19 @@ branches. Git refusing a moved tag is a warning; any other refused ref fails
579
591
  that remote. The fetch runs in the C locale so sync can read which it was. The
580
592
  shared `git-worktrees-sync.json` cache in the Git common directory records
581
593
  remote name/URL, successful sync times and source-tip forge evidence. Sync
582
- replaces it atomically. Remote identity changes invalidate it; malformed or
583
- mismatched evidence is never proof.
594
+ replaces it atomically, through `sync._update`, which reads the file again
595
+ under `git-worktrees-sync.lock` and builds the new one from that read: a
596
+ read taken before the fetch would write back a proof another worktree's
597
+ sync dropped meanwhile. The lock covers the read and the write and never a
598
+ network call; its holder's pid is in the file, the spinner names it while
599
+ another process waits, and a wait past `_LOCK_WAIT` leaves the cache
600
+ unsaved. Remote identity changes invalidate it; malformed or mismatched
601
+ evidence is never proof. `branch_forge.request_for` reads it once per
602
+ assessment, under a lock, since its rows start together on eight threads.
584
603
 
585
604
  `sync._FRESH` is 10 minutes. Warnings compare the oldest non-null component
586
- time, with exactly 10 minutes still fresh. The never-synced line goes to
605
+ time, with exactly 10 minutes still fresh. A time after now is a clock that
606
+ moved back: `sync.due` says due and `sync.freshness` warns. The never-synced line goes to
587
607
  stderr under `-q` and `--json` as well, because a caller acting on the
588
608
  verdicts needs to hear that no sync stands behind them. Quiet and JSON
589
609
  suppress every other warning, the inferred-head notice included; a removal's
@@ -611,7 +631,9 @@ a ref an earlier removal moved refuses the later one, and
611
631
  `git worktree remove` refuses a checkout dirtied since. What the wider gap
612
632
  leaves open is an ignored path written between the batch recheck and that
613
633
  target's removal. A single target, as `gw remove` has, is rechecked as it
614
- is removed.
634
+ is removed, and its record is compared both before that assessment and
635
+ after it: the assessment takes seconds, and a commit made on a detached
636
+ HEAD meanwhile leaves the tree clean and is reachable from nothing else.
615
637
 
616
638
  An assessment asks every worktree the same questions about the head, so
617
639
  `merged.reuse()` keeps the answers that name objects by full SHA for the
@@ -627,7 +649,10 @@ atomically when the assessment ends. They have no TTL, since neither commit
627
649
  changes; the file holds one head's answers and starts again when the head
628
650
  moves, which bounds it. A partial clone saves only a yes, because a fetch
629
651
  can bring the object a no lacked without moving the head, and an entry that
630
- is not the shape `merged.py` wrote is asked again. Nothing a checkout holds
652
+ is not the shape `merged.py` wrote is asked again. The file carries
653
+ `merged._RULES`, and a file under any other value is read as empty, so a
654
+ change to how a proof is reached invalidates every answer the old rule
655
+ gave. Nothing a checkout holds
631
656
  is saved: `git status`, submodules, an operation in progress, reflogs and
632
657
  stashes are read on every run, since they are what stops a worktree with
633
658
  work in it being offered.
@@ -780,12 +805,15 @@ both ways was 18 of an assessment's 35 calls over nine worktrees.
780
805
  `guard()` runs on the resolved argv inside the wrapper, not at declaration, so
781
806
  no call site can assemble its way past it. `reset --hard`, a forced `checkout`
782
807
  or `switch`, `clean -f`, a bare `push --force`, `worktree remove --force`,
783
- `branch -D` and an `update-ref` delete that names no full sha are refused
784
- absolutely. There is no flag, and `--yes` least of all. `gw remove` prints
808
+ `branch -D`, an `update-ref` delete that names no full sha and a forced
809
+ fetch into a local ref are refused absolutely. The push rule counts a `+`
810
+ refspec as `--force`, the branch rule counts `-d` with `-f` in any spelling,
811
+ and the fetch rule reads only refspecs on the command line, since sync
812
+ checks the configured ones before it fetches. There is no flag, and `--yes` least of all. `gw remove` prints
785
813
  `git worktree remove --force PATH` beside a dirty target's refusal, for a
786
814
  person who has looked to run; nothing here runs it.
787
815
 
788
- Those seven are `RULES`, a tuple, each row carrying the name `--explain`
816
+ Those eight are `RULES`, a tuple, each row carrying the name `--explain`
789
817
  prints, the clause the refusal ends with, and the test. The footer `--explain`
790
818
  prints is built from it. A rule written in one place and described in another
791
819
  is a rule that goes quiet: the hand-written footer fell a rule behind the
@@ -814,7 +842,14 @@ Removing a worktree deletes its HEAD reflog and deleting a branch its
814
842
  reflog. `merged.reflog_only` lists the commits only those reach, by
815
843
  `rev-list --not --all`, and keeps each whose own patch-id the head lacks;
816
844
  they hold the row back until `--delete reflog`, which `--delete all`
817
- includes and which is the one value `--keep-branch` takes.
845
+ includes and which `--keep-branch` takes, as it takes `--delete stale-lock`.
846
+
847
+ Patch-ids come from `git patch-id --verbatim`, Git 2.39 onward, which
848
+ counts whitespace: a change that differs from a head commit only in
849
+ indentation is a different program in Python or YAML, so it is neither a
850
+ squash proof nor a reflog commit the head already has. `fast_forward` and
851
+ `push` read the same ids. On older Git the call exits 129, which the
852
+ assessment reports and which deletes nothing.
818
853
 
819
854
  Content proof compares changed paths, modes and deletions against the head.
820
855
  It cannot settle a stacked branch whose intermediate content the head later
@@ -828,7 +863,12 @@ unmerged requests are never proof.
828
863
  `prune.removable()` selects only eligible rows. `main`, `master` and the
829
864
  head branch are protected. Locked or dirty worktrees, untracked files,
830
865
  initialized submodules and a submodule store left by `deinit` block removal;
831
- `git worktree remove` refuses each. A locked worktree whose directory is away
866
+ `git worktree remove` refuses each. A lock whose reason names a process
867
+ that has exited, `claude agent ID (pid N)` as a crashed Claude Code session
868
+ leaves it, is `stale-lock` instead, which `--delete stale-lock` lifts by
869
+ running `git worktree unlock` before the removal; every other lock names
870
+ the unlock for a person to run once they have checked it. The lock's reason
871
+ is pinned with the record. A locked worktree whose directory is away
832
872
  is assessed from its record. Empty branches and matching stashes require
833
873
  their own permission; ignored paths go with the worktree, listed in the
834
874
  disclosure first. `--yes` grants neither. A protection a value lifts ends
@@ -17,6 +17,62 @@ not in here, whatever it cost to build.
17
17
  A release closes with a `### Choices` section when a decision in it is worth
18
18
  the reader's time: what was chosen, and what the alternative failed to do.
19
19
 
20
+ ## 0.14.0 - 2026-11-22
21
+
22
+ ### Added
23
+
24
+ `gw prune` and `gw remove` take `--delete stale-lock`, which unlocks and
25
+ removes a worktree whose lock names a process that has exited, as a
26
+ crashed Claude Code session leaves. Any other lock still blocks removal,
27
+ and its protection names the `git worktree unlock` to run by hand.
28
+
29
+ This repository is a plugin marketplace named `worktrees`, so the agent
30
+ plugin installs from it as `worktrees@worktrees`. That install follows
31
+ `main`, which can be ahead of the released CLI; `worktrees@mihaibojin`
32
+ from `MihaiBojin/agent-plugins` stays pinned to a release tag.
33
+
34
+ ## 0.13.4 - 2026-11-22
35
+
36
+ ### Fixed
37
+
38
+ A branch whose only change after its squash merge was whitespace, such as
39
+ re-indenting a Python block, is no longer proved merged, so `gw prune` and
40
+ `gw branch prune` keep it. The same holds for a commit only a reflog still
41
+ reaches. Squash proof needs Git 2.39 or newer; on older Git an assessment
42
+ that needs one exits 1 and deletes nothing. Proofs saved by earlier
43
+ releases are checked again on the first run.
44
+
45
+ `gw remove` keeps a detached worktree in which a commit was made while its
46
+ recheck ran, and refuses with `worktree changed after assessment`.
47
+
48
+ `gw push` refuses to replace another clone's commit that reached the
49
+ branch through `git rebase origin/BRANCH` or a conflicted merge and was
50
+ then dropped locally. Before, the push went ahead without `--replace`.
51
+
52
+ `gw fast-forward --autostash` pushes a stacked branch whose request it
53
+ retargeted when only the uncommitted changes failed to re-apply. The
54
+ result is still `stash-conflict` at exit 1, with `pushed` or `unpushed`
55
+ set.
56
+
57
+ The guard refuses three more ways to lose work, whichever command would
58
+ issue them: a `git push` with a `+` refspec, `git branch -d` combined with
59
+ `-f` or `--force` in any spelling, and a `git fetch` whose refspec forces
60
+ a local branch or tag. `gw --explain` lists the new rule.
61
+
62
+ Two worktrees syncing at once no longer undo each other: a sync re-reads
63
+ the shared cache under a lock just before it writes. While another process
64
+ holds the lock, the spinner reads `waiting for the sync cache lock, held by
65
+ pid N`; after 30 seconds the sync reports `cannot save sync evidence` and
66
+ leaves the cache as it was.
67
+
68
+ A last sync dated after the machine's clock counts as stale, so the next
69
+ command syncs first and warns `Last sync is dated after this machine's
70
+ clock`.
71
+
72
+ The spinner and the `gw list` picker no longer leave stale lines on the
73
+ screen when a branch or path holds wide characters, such as a branch
74
+ named in Chinese or Japanese: each row is cut by the columns it takes.
75
+
20
76
  ## 0.13.3 - 2026-11-22
21
77
 
22
78
  ### Fixed
@@ -0,0 +1,335 @@
1
+ Metadata-Version: 2.5
2
+ Name: git-worktrees
3
+ Version: 0.14.0
4
+ Summary: Git worktree commands that refuse to lose work.
5
+ Project-URL: Bug reports, https://github.com/MihaiBojin/worktrees/issues/new
6
+ Project-URL: Source, https://github.com/MihaiBojin/worktrees
7
+ Author-email: Mihai Bojin <557584+MihaiBojin@users.noreply.github.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: cli,git,worktree
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Natural Language :: English
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Requires-Python: >=3.11
21
+ Provides-Extra: dev
22
+ Requires-Dist: hatchling==1.28.0; extra == 'dev'
23
+ Requires-Dist: pre-commit==4.6.1; extra == 'dev'
24
+ Requires-Dist: pytest-xdist==3.8.0; extra == 'dev'
25
+ Requires-Dist: pytest==9.1.1; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # worktrees
29
+
30
+ [![Tests](https://github.com/MihaiBojin/worktrees/actions/workflows/tests.yml/badge.svg)](https://github.com/MihaiBojin/worktrees/actions/workflows/tests.yml)
31
+ [![PyPI](https://img.shields.io/pypi/v/git-worktrees)](https://pypi.org/project/git-worktrees/)
32
+
33
+ `gw` creates Git worktrees and removes finished branches after checking for
34
+ unmerged work. It recognizes squash merges and lists ignored files before
35
+ deleting a checkout. The fish and zsh plugins let you switch worktrees
36
+ without typing paths.
37
+
38
+ ## Install
39
+
40
+ Install [uv](https://docs.astral.sh/uv/getting-started/installation/), then
41
+ install the commands:
42
+
43
+ ```console
44
+ uv tool install git-worktrees
45
+ ```
46
+
47
+ The package requires Python 3.11 or newer and has no Python runtime
48
+ dependencies. Use Git 2.39 or newer for squash-merge detection. Partial
49
+ clones have [additional Git version requirements](docs/REFERENCE.md#sync-cache).
50
+
51
+ The install provides `gw` and its long name, `worktrees`. If uv reports that
52
+ its executable directory is missing from `PATH`, run `uv tool update-shell`
53
+ and restart your shell. Upgrade the commands with `uv tool upgrade git-worktrees`.
54
+
55
+ The commands work from any shell. Install the matching fish or zsh plugin
56
+ for completions, shortcuts and directory changes. Pin the plugin to the
57
+ release that `gw version` reports; an unpinned plugin follows `main`, which
58
+ can contain unreleased changes.
59
+
60
+ ### fish
61
+
62
+ With [Fisher](https://github.com/jorgebucaran/fisher) installed, run:
63
+
64
+ ```fish
65
+ fisher install MihaiBojin/worktrees@v0.14.0
66
+ ```
67
+
68
+ To change release, edit the tag in `$__fish_config_dir/fish_plugins`, then
69
+ run `fisher update`. Use the same procedure to pin an untagged installation.
70
+
71
+ ### zsh
72
+
73
+ With [Antidote](https://antidote.sh/) installed, add this line to its plugin
74
+ list, normally `~/.zsh_plugins.txt`, and open a new shell:
75
+
76
+ ```text
77
+ MihaiBojin/worktrees branch:v0.14.0 path:zsh/plugins/worktrees
78
+ ```
79
+
80
+ Completion needs `compinit`. If your shell configuration does not run it,
81
+ add this after the plugin loads:
82
+
83
+ ```zsh
84
+ autoload -Uz compinit && compinit
85
+ ```
86
+
87
+ To change the tag, first remove Antidote's clone:
88
+
89
+ ```zsh
90
+ antidote purge MihaiBojin/worktrees
91
+ ```
92
+
93
+ Then edit the tag in the plugin list and open a new shell. Editing the list
94
+ after the purge makes Antidote rebuild its generated bundle.
95
+
96
+ ### Check the installation
97
+
98
+ Run `gw --help`. With matching command and shell releases, its output
99
+ includes:
100
+
101
+ ```console
102
+ worktrees 0.14.0: git worktree commands that refuse to lose work
103
+ The shell plugin here is 0.14.0, the same release as these commands.
104
+ ```
105
+
106
+ Upgrade the commands and the shell plugin together. For development from a
107
+ clone, see [Working on a checkout](docs/DEVELOPMENT.md#working-on-a-checkout).
108
+
109
+ ## Quickstart
110
+
111
+ Run commands inside the repository you want to manage. The repository must
112
+ have a commit and a resolvable [head branch](docs/REFERENCE.md#head-and-evidence),
113
+ usually the default remote's default branch, or local `main` or `master`.
114
+
115
+ Create a worktree on a new branch named `fix-parser`. This example works in
116
+ bash and zsh with or without the shell plugin:
117
+
118
+ ```sh
119
+ cd "$(command gw add fix-parser -q)"
120
+ git branch --show-current
121
+ ```
122
+
123
+ The second command prints:
124
+
125
+ ```text
126
+ fix-parser
127
+ ```
128
+
129
+ For a main checkout at `/path/to/repo`, the new checkout is at
130
+ `/path/to/.worktrees/fix-parser/repo`. With the fish or zsh plugin loaded,
131
+ `gw add fix-parser` creates the checkout and changes directory in one call.
132
+ If the branch already exists, `gw add` uses it; a branch that exists only
133
+ on the remote needs confirmation or `--yes`.
134
+
135
+ Use `gw list` to choose another worktree. Type to filter, use the arrow keys
136
+ to move, and press enter to select. `gw list fix-parser` selects a unique
137
+ match directly. Without a terminal, `gw list` prints metadata. The shell
138
+ plugin performs the directory change.
139
+
140
+ ## Commands
141
+
142
+ `gw --help` lists every command and shortcut. Each command's `--help`
143
+ describes its flags. The guides cover these tasks:
144
+
145
+ | Command | Task |
146
+ | --- | --- |
147
+ | [`gw add NAME [BASE]`](docs/commands/add.md) | Create a worktree for a new or existing branch |
148
+ | [`gw list [QUERY]`](docs/commands/list.md) | Choose a worktree or list matching checkouts |
149
+ | [`gw select-main`](docs/commands/list.md#select-main) | Go to the worktree on the head branch |
150
+ | [`gw sync`](#head-and-synchronization) | Refresh remote refs and GitHub or GitLab evidence |
151
+ | [`gw prune`](#assess-and-remove) | Assess worktrees and remove eligible ones after confirmation |
152
+ | [`gw remove [NAME\|PATH]`](#assess-and-remove) | Assess or remove one worktree |
153
+ | [`gw branch status [NAME ...]`](docs/commands/branch-status.md) | Assess branches without worktrees |
154
+ | [`gw branch prune [NAME ...]`](docs/commands/branch-prune.md) | Delete eligible branches without worktrees |
155
+ | [`gw branch create NAME`](docs/commands/branch-create.md) | Start a branch in the current checkout |
156
+ | [`gw fast-forward [NAME]`](docs/commands/fast-forward.md) | Update a branch, or continue from a finished branch on a new one |
157
+ | [`gw push`](docs/commands/push.md) | Push with checks for remote work and previously merged commits |
158
+ | [`gw ci-checks [NUMBER]`](docs/commands/ci-checks.md) | Read or wait for checks on a GitHub pull request or GitLab merge request |
159
+ | [`gw merge NUMBER...`](docs/commands/merge.md) | Squash checked GitHub pull requests, including native stacks |
160
+ | [`gw stack-link NUMBER NUMBER ...`](docs/commands/stack-link.md) | Link GitHub pull requests into a native stack |
161
+ | [`gw preflight`](docs/commands/preflight.md) | Check repository and plugin setup |
162
+ | `gw version` | Print the installed version |
163
+
164
+ A shortcut such as `gwa` is a shell function that calls `gw add`. Only `gw`
165
+ and `worktrees` are installed as executables.
166
+
167
+ ## Assess and remove
168
+
169
+ Preview worktree removal as JSON:
170
+
171
+ ```console
172
+ gw prune --json
173
+ ```
174
+
175
+ The `verdicts` array gives each worktree's `reason`, `eligible` status and
176
+ `protections`. Use `eligible` to decide whether removal is permitted.
177
+ `gw prune --table` prints the assessment as text. Neither preview removes
178
+ worktrees or branches; assessments can save proof caches and sync first.
179
+
180
+ WARNING: Copy any ignored files that you need before removal. Removing a
181
+ worktree deletes its ignored files, including virtual environments and
182
+ build output. Git cannot restore those files.
183
+
184
+ On a terminal, assess and confirm eligible removals with:
185
+
186
+ ```console
187
+ gw prune
188
+ ```
189
+
190
+ The command lists each checkout, ignored path and branch that it will
191
+ delete. It prints restore commands for branches and approved stashes.
192
+ Press `y` to confirm; any other key cancels. The command reassesses before
193
+ removal and refuses targets that changed.
194
+
195
+ `gw remove NAME` applies the same checks to one worktree. Use a quoted
196
+ absolute path when names are ambiguous. Without a terminal, or with
197
+ `--json` or `--table`, both commands assess only. `--yes` approves removal
198
+ but grants no additional deletion permission. Removing the current
199
+ worktree always needs a second terminal confirmation.
200
+
201
+ The main checkout and dirty worktrees stay. Untracked files, active
202
+ operations and submodule stores also block removal. The branches `main`,
203
+ `master` and the head branch cannot be deleted. Other protections require
204
+ explicit permission:
205
+
206
+ | Flag | Permits |
207
+ | --- | --- |
208
+ | `--delete empty` | An unused branch and its checkout |
209
+ | `--delete closed` | A branch whose request closed without merging its current tip |
210
+ | `--delete stashes` | Stashes associated with the branch |
211
+ | `--delete reflog` | Commits held only by reflogs that removal deletes |
212
+ | `--delete stale-lock` | Unlocking a worktree whose recorded process has exited |
213
+ | `--delete all` | All the categories above |
214
+
215
+ Repeat `--delete` to combine categories. `--keep-branch` retains the branch
216
+ and its stashes while removing an otherwise unprotected checkout. It
217
+ accepts only `--delete reflog` and `--delete stale-lock`; a detached
218
+ checkout still needs proof that its commits are finished.
219
+
220
+ See [protections and permissions](docs/REFERENCE.md#protections-and-permissions)
221
+ for the checks, and [deletion and recovery](docs/REFERENCE.md#deletion-and-recovery)
222
+ for partial failures and restore commands. Restore branches or stashes
223
+ before Git garbage collection removes their unreachable commits.
224
+
225
+ ### Shortcuts
226
+
227
+ The shell plugins provide these removal shortcuts:
228
+
229
+ | Shortcut | Runs |
230
+ | --- | --- |
231
+ | `gwp` | `gw prune` |
232
+ | `gwp!` | `gw prune --yes` |
233
+ | `gwpa` | `gw prune --delete all` |
234
+ | `gwpa!` | `gw prune --delete all --yes` |
235
+ | `gwr` | `gw remove` |
236
+ | `gwr!` | `gw remove --yes` |
237
+ | `gwrk!` | `gw remove --keep-branch --yes` |
238
+
239
+ ## Head and synchronization
240
+
241
+ `gw sync` fetches every remote and asks GitHub or GitLab about local branch
242
+ tips. GitHub needs an authenticated `gh`; GitLab needs an authenticated
243
+ `glab`. With several remotes, set Git's `checkout.defaultRemote` to select
244
+ the remote used for assessments.
245
+
246
+ Assessments sync first when the default remote has never synced or its
247
+ last sync is at least 300 seconds old. `WORKTREES_SYNC_TTL` changes that
248
+ interval in whole seconds. A failed sync warns and the assessment proceeds
249
+ with available evidence. `gw list` reads local worktree records without
250
+ syncing.
251
+
252
+ `gw fast-forward` fetches the default remote when sync is due and reads
253
+ fresh request evidence when needed. It can fetch again when a merged
254
+ request names a commit missing locally. `gw push` fetches on every run.
255
+ Both refuse when a required fetch or request query fails.
256
+
257
+ Set `WORKTREES_OFFLINE=1` to prevent network access. Local assessment and
258
+ navigation still work; commands that require the network refuse. See
259
+ [head and evidence](docs/REFERENCE.md#head-and-evidence) and
260
+ [sync cache](docs/REFERENCE.md#sync-cache) for fallback rules and partial
261
+ sync outcomes.
262
+
263
+ ## Output and JSON
264
+
265
+ Results go to stdout; diagnostics and prompts go to stderr. JSON results
266
+ are objects with `head` and `lastSync`. Worktree and branch assessments put
267
+ rows in `verdicts`; navigation puts rows in `worktrees`.
268
+
269
+ With [jq](https://jqlang.org/) installed, list paths or select eligible rows:
270
+
271
+ ```console
272
+ gw list --json | jq -r '.worktrees[].path'
273
+ gw prune --json | jq '.verdicts[] | select(.eligible)'
274
+ ```
275
+
276
+ The first command prints one path per worktree. The second prints eligible
277
+ assessment rows and removes nothing. JSON preserves paths as strings;
278
+ keep paths quoted when passing them to a command.
279
+
280
+ `--json` disables colour. `-q` suppresses summaries where supported, while
281
+ `-v` traces subprocesses on stderr. See [JSON and streams](docs/REFERENCE.md#json-and-streams)
282
+ for fields and the commands that accept each flag.
283
+
284
+ Commands append an [audit log](docs/REFERENCE.md#audit-log) under
285
+ `~/.local/state/worktrees`, or `$XDG_STATE_HOME/worktrees` when set.
286
+ `WORKTREES_AUDIT_DIR` changes the directory; `WORKTREES_AUDIT=off` disables
287
+ logging. Help and completion record nothing.
288
+
289
+ ## What it refuses
290
+
291
+ The CLI refuses these Git operations regardless of command flags:
292
+
293
+ ```
294
+ reset --hard
295
+ a forced checkout or switch
296
+ clean -f
297
+ push --force
298
+ worktree remove --force
299
+ branch -D
300
+ an update-ref delete that names no full sha
301
+ a forced fetch into a local ref
302
+ ```
303
+
304
+ `gw --explain` lists the Git commands that the CLI can run and the guard
305
+ rules that apply to them.
306
+
307
+ ## Agent plugin
308
+
309
+ The [agent plugin](plugin/README.md) provides six skills for Claude Code
310
+ and Codex. They update branches through conflicts, inspect checks, maintain
311
+ pull request descriptions, ship changes through merge, prune approved
312
+ worktrees and configure permissions.
313
+
314
+ Install the plugin from the `mihaibojin` marketplace as its README
315
+ describes, then run `gw preflight` inside each repository. The
316
+ [preflight guide](docs/commands/preflight.md) explains each check and how
317
+ to install the current client's permission rules. The skills use the
318
+ checkout assigned to the session.
319
+
320
+ ## Migration
321
+
322
+ See the [migration table](docs/REFERENCE.md#migration) for renamed commands
323
+ and flags. Scripts that act on assessments must check `eligible` before
324
+ removal; a `remove` verdict alone does not grant permission.
325
+
326
+ ## Contributing
327
+
328
+ [DEVELOPMENT.md](docs/DEVELOPMENT.md) lists the setup and checks for a
329
+ contribution. Report bugs through [GitHub issues](https://github.com/MihaiBojin/worktrees/issues).
330
+ The [reference](docs/REFERENCE.md) documents shared rules and links to
331
+ every command guide.
332
+
333
+ ## Licence
334
+
335
+ Apache-2.0, Mihai Bojin. See [LICENSE](LICENSE).