Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 84 additions & 26 deletions .skills/doctor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -789,40 +789,98 @@ env_value() {
printf '%s' "$found"
}

check_pr_mode_gh_token() {
local wt block entry dirs primary knob line words word="" count=0 env_file=".env"
# git without an inherited GIT_DIR or GIT_WORK_TREE, as the hook's reader
# resolves the primary (CR 1895): GIT_DIR beats -C, so asked for a
# submodule's work tree git named the entry itself.
local -a g=(env -u GIT_DIR -u GIT_WORK_TREE git)
[ -e .claude/hooks/skills-submodule-update.sh ] || return 0
# Read from the primary checkout, resolved as the hook's _read_merge_mode
# resolves it (CR 1893): the first `git worktree list` block, whose entry
# is a git dir for a bare primary (`repo.git`, whose knob can only be this
# checkout's) and in a submodule (`<super>/.git/modules/<n>`, asked for its
# work tree). A `--separate-git-dir` primary's store names no work tree;
# from that primary it is this checkout (CR 1892). A primary that cannot
# be resolved is silent here, not a note: the hook then reads the knob as
# unusable and says so itself on every run, which is the one place that
# failure is stated, as for any other unusable knob.
wt="$("${g[@]}" worktree list --porcelain 2>/dev/null)" || return 0
# >>> resolve_primary: one body in nine readers (#612), held byte-identical
# by tests/structural/test_primary_checkout_copies.py. Change every copy.
#
# resolve_primary <dir>: the primary checkout of the repository at <dir>,
# where its untracked .skills/ knobs live. Prints nothing.
# 0: RP_TREE is the primary's work tree. For a bare primary RP_BARE is 1
# and RP_TREE is <dir>'s own top level, empty when <dir> has none.
# 1: RP_ERR says what failed and what to run; RP_REASON is git's own
# stderr, whole, which a caller that refuses aloud prints above it.
# Git is asked without an inherited GIT_DIR, GIT_WORK_TREE or GIT_COMMON_DIR:
# git exports GIT_DIR to every hook, and each of them beats -C (CR 1895).
# 1. From the primary itself (its git dir is the common dir), its own top
# level, asked first: a --separate-git-dir store whose path ends in
# /.git is listed as the directory above it, a work tree to git.
# 2. Else the first `git worktree list --porcelain` block. Its `bare` line
# counts once git confirms it (the shared core.bare, read from here, as
# a store git refuses for its owner still has; else the entry's own
# answer): below git 2.25 a --separate-git-dir store is listed bare too.
# Where that store is this checkout's git dir, this is the primary.
# 3. Any other entry is asked for its work tree (a submodule's through
# core.worktree). That failing is a refusal, never a fallback (CR 1858).
# An empty top level is none: inside a git dir git 2.17 prints nothing, at
# exit 0, where later git refuses.
resolve_primary() {
local dir=$1 dirs wt block entry gd ver
local -a g=(env -u GIT_DIR -u GIT_WORK_TREE -u GIT_COMMON_DIR git -C "$dir")
RP_TREE="" RP_BARE=0 RP_ERR="" RP_REASON=""
dirs=$("${g[@]}" rev-parse --path-format=absolute --git-dir --git-common-dir 2>/dev/null) || dirs=""
if [ -n "$dirs" ] && [ "${dirs%%$'\n'*}" = "${dirs#*$'\n'}" ] &&
RP_TREE=$("${g[@]}" rev-parse --show-toplevel 2>/dev/null) && [ -n "$RP_TREE" ]; then
return 0
fi
RP_TREE=""
if ! wt=$("${g[@]}" worktree list --porcelain 2>/dev/null); then
RP_REASON=$("${g[@]}" worktree list --porcelain 2>&1 >/dev/null) || true
RP_REASON=${RP_REASON:-git printed no reason}
RP_ERR="git worktree list failed in '$dir', so the primary checkout is unknown"
return 1
fi
block=${wt%%$'\n\n'*}
entry=${block%%$'\n'*}
entry=${entry#worktree }
case $'\n'"$block"$'\n' in
*$'\n'bare$'\n'*)
primary="$("${g[@]}" rev-parse --show-toplevel 2>/dev/null)" || return 0
;;
*)
if ! primary="$("${g[@]}" -C "$entry" rev-parse --show-toplevel 2>/dev/null)"; then
dirs="$("${g[@]}" rev-parse --path-format=absolute --git-dir --git-common-dir 2>/dev/null)" || return 0
if [ -z "$dirs" ] || [ "${dirs%%$'\n'*}" != "${dirs#*$'\n'}" ]; then
return 0
fi
primary="$("${g[@]}" rev-parse --show-toplevel 2>/dev/null)" || return 0
if [ "$("${g[@]}" config --bool core.bare 2>/dev/null)" = true ] ||
[ "$("${g[@]}" -C "$entry" rev-parse --is-bare-repository 2>/dev/null)" = true ]; then
RP_BARE=1
RP_TREE=$("${g[@]}" rev-parse --show-toplevel 2>/dev/null) || RP_TREE=""
return 0
fi
gd=$("${g[@]}" rev-parse --git-dir 2>/dev/null) &&
gd=$(CDPATH='' cd -- "$dir" && CDPATH='' cd -- "$gd" && pwd -P) || gd=""
if [ -n "$gd" ] && [ "$gd" = "$(CDPATH='' cd -- "$entry" 2>/dev/null && pwd -P)" ] &&
RP_TREE=$("${g[@]}" rev-parse --show-toplevel 2>/dev/null) && [ -n "$RP_TREE" ]; then
return 0
fi
RP_TREE=""
;;
esac
if RP_TREE=$("${g[@]}" -C "$entry" rev-parse --show-toplevel 2>/dev/null) && [ -n "$RP_TREE" ]; then
return 0
fi
RP_TREE=""
RP_REASON=$("${g[@]}" -C "$entry" rev-parse --show-toplevel 2>&1 >/dev/null) || true
RP_REASON=${RP_REASON:-git printed no reason}
RP_ERR="could not resolve the primary checkout's work tree from $entry"
if [ "$("${g[@]}" -C "$entry" rev-parse --is-inside-git-dir 2>/dev/null)" = true ]; then
RP_ERR="$RP_ERR; it is a git dir with no work tree, as a primary whose .git is a file makes it (git init --separate-git-dir), and"
if [ "${dirs%%$'\n'*}" = --path-format=absolute ]; then
ver=$(git --version 2>/dev/null) || ver=""
ver=${ver#git version }
RP_ERR="$RP_ERR git ${ver:-(unknown version)} predates 2.31, which this layout needs to tell its primary from a linked worktree: upgrade git (from a linked worktree, then run from the primary checkout)"
else
RP_ERR="$RP_ERR only that primary knows its work tree, so run this from the primary checkout"
fi
fi
return 1
}
# <<< resolve_primary

check_pr_mode_gh_token() {
local primary knob line words word="" count=0 env_file=".env"
[ -e .claude/hooks/skills-submodule-update.sh ] || return 0
# Read from the primary checkout, resolved by the block above as the
# hook's _read_merge_mode resolves it (CR 1893, #612). A bare primary's
# knob is this checkout's. A primary that cannot be resolved is silent
# here, not a note: the hook then reads the knob as unusable and says so
# itself on every run, which is the one place that failure is stated, as
# for any other unusable knob.
resolve_primary . || return 0
primary=$RP_TREE
[ "$RP_BARE" = 0 ] || [ -n "$primary" ] || return 0
# merge_mode's grammar (docs/KNOBS.md): one word, blank lines and
# whole-line comments ignored. Only an exact `pr` speaks here; anything
# else the hook reads as direct or names as unusable itself.
Expand Down
2 changes: 1 addition & 1 deletion skills-vendor/gregoryfoster-skills
Submodule gregoryfoster-skills updated 71 files
+2 −0 .skills/context-loss-ok
+1 −0 .skills/context-metrics.jsonl
+6 −6 .skills/context-token-counts
+1 −1 .skills/context-token-ratio
+2 −2 docs/KNOBS.md
+117 −33 scripts/_typesafe.py
+3 −1 skills/coordinating-epics/references/check-in.md
+3 −1 skills/coordinating-epics/references/close-out.md
+1 −0 skills/coordinating-epics/references/hand-off.md
+2 −0 skills/coordinating-epics/references/process-log.md
+59 −0 skills/coordinating-epics/references/process-log/2026/2026-11-16-replicator.md
+1 −0 skills/coordinating-epics/references/process-log/2026/index.md
+1 −1 skills/coordinating-epics/references/siblings.md
+115 −4 skills/coordinating-epics/scripts/_epic_edit.py
+170 −7 skills/coordinating-epics/scripts/_scan.py
+117 −33 skills/coordinating-epics/scripts/_typesafe.py
+7 −3 skills/curating-context/references/budget-and-metrics.md
+27 −1 skills/curating-context/references/cadence.md
+6 −1 skills/curating-context/references/continuous-surfaces.md
+35 −0 skills/curating-context/references/seam-accounting.md
+18 −0 skills/curating-context/references/validation-gate.md
+117 −33 skills/curating-context/scripts/_typesafe.py
+246 −10 skills/curating-context/scripts/check-seams.sh
+75 −17 skills/curating-context/scripts/context-delta.sh
+260 −90 skills/curating-context/scripts/install-cadence.sh
+157 −31 skills/curating-context/scripts/measure-context.sh
+224 −10 skills/curating-context/scripts/prove-no-loss.sh
+2 −1 skills/managing-skills/SKILL.md
+7 −1 skills/managing-skills/references/auto-refresh-hook.md
+34 −0 skills/managing-skills/references/auto-refresh-hook/rendered-artifacts.md
+5 −1 skills/managing-skills/references/auto-refresh-hook/timeout-budget.md
+84 −26 skills/managing-skills/scripts/doctor.sh
+184 −45 skills/managing-skills/scripts/skills-submodule-update.sh
+3 −3 skills/shipping-work/SKILL.md
+7 −3 skills/shipping-work/references/deploy-command.md
+88 −53 skills/shipping-work/scripts/_command-knob.sh
+65 −1 skills/shipping-work/scripts/doc-check.sh
+91 −46 skills/shipping-work/scripts/merge-mode.sh
+88 −45 skills/shipping-work/scripts/read-next-steps.sh
+11 −0 skills/shipping-work/scripts/run-deploy-command.sh
+6 −11 skills/using-git-worktrees/SKILL.md
+58 −0 skills/using-git-worktrees/references/main-checkout.md
+2 −1 skills/using-git-worktrees/references/pr-mode.md
+91 −46 skills/using-git-worktrees/scripts/merge-mode.sh
+27 −9 skills/using-git-worktrees/scripts/resolve-worktree-root.sh
+90 −48 skills/using-git-worktrees/scripts/worktree-create.sh
+114 −45 skills/using-git-worktrees/scripts/worktree-destroy.sh
+24 −7 skills/writing-plans/scripts/resolve-plans-dir.sh
+2 −1 tests/structural/coordinating_epics_rig.py
+113 −1 tests/structural/merge_mode_layouts.py
+218 −0 tests/structural/test_bare_default_branch.py
+259 −0 tests/structural/test_cadence_keeps_schedule.py
+200 −0 tests/structural/test_cadence_rerender_check.py
+167 −0 tests/structural/test_context_anchors.py
+240 −0 tests/structural/test_context_delta_paths.py
+19 −0 tests/structural/test_coordinating_epics_also.py
+32 −0 tests/structural/test_coordinating_epics_scan.py
+217 −0 tests/structural/test_coordinating_epics_sibling.py
+288 −0 tests/structural/test_coordinating_epics_subjects.py
+120 −0 tests/structural/test_doc_check_knob_render.py
+8 −1 tests/structural/test_doctor_pr_mode_gh_token.py
+554 −0 tests/structural/test_ledger_run_groups.py
+166 −0 tests/structural/test_main_checkout_instructions.py
+657 −0 tests/structural/test_primary_checkout_copies.py
+15 −3 tests/structural/test_primary_checkout_layouts.py
+1 −0 tests/structural/test_refresh_hook_pr_gh_auth.py
+7 −3 tests/structural/test_refresh_hook_pr_mode.py
+290 −0 tests/structural/test_refresh_hook_render_drift.py
+96 −0 tests/structural/test_seam_sweep.py
+232 −0 tests/structural/test_typesafe_primary_checkout.py
+5 −1 tests/structural/test_worktree_destroy_base.py