diff --git a/.agents/skills/check-this-repo/SKILL.md b/.agents/skills/check-this-repo/SKILL.md index f16338bff..8eb4ae9b0 100644 --- a/.agents/skills/check-this-repo/SKILL.md +++ b/.agents/skills/check-this-repo/SKILL.md @@ -44,8 +44,10 @@ repo. ## What it is safe to fix on its own -- **Re-run the installer**, `python3 scripts/skills_install.py`, from that same `main` checkout, - when `--report` exits non-zero. +- **Re-run the installer**, `python3 scripts/skills_install.py --snapshot-only`, from that same + `main` checkout, when `--report` exits non-zero. `--snapshot-only` refreshes the copy and leaves + the Claude Code registration alone, since a fetched checkout is not one that registration should + load from. This is a per-machine, local-only change, nothing in it touches this repo's git history or needs a review. diff --git a/.agents/skills/merge-and-release/SKILL.md b/.agents/skills/merge-and-release/SKILL.md index 0b586c1fe..6263eeb41 100644 --- a/.agents/skills/merge-and-release/SKILL.md +++ b/.agents/skills/merge-and-release/SKILL.md @@ -120,37 +120,20 @@ skill covers all of it, scoped down by what the maintainer actually asks for. Report a timeout separately from a completed run's own conclusion, the tag or version it produced. A run that fails, times out, or never starts is reported, never silently retried. -7. In the hub, when the chosen scope includes a release, bring this checkout to the merged - content without discarding or mixing in anything local. First assert `git status --porcelain - --untracked-files=all --ignored -- .agents/skills/ .claude-plugin/` is empty, and stop and - report rather than proceeding over any uncommitted content there, tracked, untracked, or - gitignored, since `skills_install.py` reads both paths: `shutil.copytree()` installs each - `.agents/skills/` skill directory for Codex/opencode, and `claude plugin marketplace add` - installs from `.claude-plugin/` for Claude Code, so a gitignored stray file under either rides - along the same as any other, and the plain porcelain form (silent on ignored paths) would pass - this preflight while one still rides into an install. Scoped to those two paths rather than - the whole tree, matching `skills_install.py`'s own `source_ref()` dirty check (`watched = - [SKILLS_SRC, CLAUDE_PLUGIN_DIR]`), since an ignored file elsewhere in the checkout (a build - cache, a lockfile) is not this preflight's concern and should not block the refresh on it. - Then `git fetch origin main`, `git checkout main` - (or `git checkout -b main origin/main` the first time this checkout carries no local `main` at - all, `checkout` rather than `switch` since the fleet's own `git` floor is undeclared and - `checkout` needs no minimum version for this), and `git merge --ff-only origin/main`. - `checkout` still refuses a `main` checked out in another worktree, and `--ff-only` refuses - anything but a clean fast-forward, so either stops and reports on top of what the preflight - already ruled out, per Repository Boundaries and Write Safety. `--ff-only` does not fail when - local `main` is already ahead of `origin/main`, since a strict superset needs no fast-forward - and reports up to date, so assert `git rev-parse main` equals `git rev-parse origin/main` - afterward and stop and report on a mismatch, a local-only commit this checkout never pushed is - exactly the case a bare "up to date" would hide. `skills_install.py` stamps and installs from - whatever this checkout's HEAD already is, so running it against a stale, unrefreshed, or - locally-diverged `main` skips the refresh silently. Only then run `python3 scripts/skills_install.py --report`, then - `python3 scripts/skills_install.py` to install, and confirm `--report`'s snapshot now reads - current. The two channels hold different things. The Codex and opencode copy keeps the - revision it was taken from, the promoted `main` here. The Claude Code channel loads the - registered checkout in place, the one `--report` names under `live`, and serves whatever it - holds at read time. Where that is this checkout, once step 8 returns it to `develop`, Claude - Code sessions on this machine load `develop`. `--report` exits on the snapshot alone. This step runs whether step 5 +7. In the hub, when the chosen scope includes a release, refresh this machine's Codex and opencode + copy from the promoted `main` in a detached worktree of its own, never by switching an existing + checkout to `main`, since the checkout Claude Code loads in place would move with it. Run `git fetch origin main`, then `git worktree add --detach + origin/main` at a new path in the fleet worktree layout, and from that worktree run + `python3 scripts/skills_install.py --snapshot-only`, then `python3 scripts/skills_install.py + --report`, and confirm its snapshot reads current. A fresh worktree holds nothing uncommitted + or ignored under `.agents/skills/` or `.claude-plugin/`, the two paths the installer reads, so + the copy holds exactly the promoted commit. `--snapshot-only` leaves the Claude Code + registration untouched, and that channel needs no refresh here: it loads the registered + checkout in place, the one `--report` names under `live`, and serves whatever it holds at read + time, so where that is the primary checkout on `develop`, Claude Code sessions on this machine + load `develop`. Then remove the worktree with + `git worktree remove `, whatever the report said, and report a snapshot that does not + read current. `--report` exits on the snapshot alone. This step runs whether step 5 or 6 dispatched, skipped, or failed a release, since it is gated only on the chosen scope, never on the release outcome. This refreshes only the machine running this session, per skill-lifecycle, every other machine still refreshes on its own next run or @@ -159,10 +142,12 @@ skill covers all of it, scoped down by what the maintainer actually asks for. failure, an ambiguous run match, a timeout, a failed run, or a hub Skills refresh all still reach this step, the merge in step 3 already landed by then. Two parts, both required, neither optional: - - The promotion PR's own worktree: fetch and prune, remove the worktree, then fast-forward the - base clone to `develop`. Removing first, not after, matters: the base clone cannot check out - `develop` while the promotion worktree still has it checked out, one branch checked out in - two worktrees at once is refused outright. Never delete `develop`, it is the promotion PR's + - The promotion PR's own worktree: fetch and prune, remove the worktree, then bring the base + clone to current `develop`, checking `develop` out first only where it sits on another + branch, and fast-forwarding it with `git merge --ff-only origin/develop`. Where that checkout + is needed, removing first, not after, matters: the base clone cannot check out `develop` + while the promotion worktree still has it checked out, one branch checked out in two + worktrees at once is refused outright. Never delete `develop`, it is the promotion PR's own head, and the repo's auto-delete-head-branches setting is kept off fleet-wide for exactly this reason, so nothing does this automatically. - A defensive sweep for anything drive-pr's own cleanup should already have removed but might diff --git a/.agents/skills/skill-lifecycle/SKILL.md b/.agents/skills/skill-lifecycle/SKILL.md index 912ef51c9..79f5c590b 100644 --- a/.agents/skills/skill-lifecycle/SKILL.md +++ b/.agents/skills/skill-lifecycle/SKILL.md @@ -32,7 +32,7 @@ A skill surfaces at a trigger moment. A rule that binds every action all the tim 5. **Apply the doc-packaging pattern below in the same change** when the skill packages a law doc or one of its sections. 6. **Regenerate and commit all trees together**: `python3 scripts/build_dist.py`, then, once authorized, commit the source and both generated trees in one commit, per `git-commit-conventions`. CI runs `--check` on every pull request and fails a desynced distribution. `python3 tests/test_build_dist.py` covers the generator itself. 7. **Record the surfacing**: annotate the `AGENTS.md` "Where the Rules Live" row when the skill packages a GOVERNANCE section, or its closing paragraph when the skill is new content, so the map stays the one place coverage is read from. -8. **Refresh the machines after promotion**: re-run `python3 scripts/skills_install.py` per machine, from a freshly fetched `main`, the cadence `docs/host-setup.md` "Fleet Skills Install" states. Until then each machine's Codex and opencode copy holds the previous skill set, which `--report` says, while Claude Code serves whatever the hub checkout holds. +8. **Refresh the machines after promotion**: re-run `python3 scripts/skills_install.py --snapshot-only` per machine, from a freshly fetched `main`, the cadence `docs/host-setup.md` "Fleet Skills Install" states. Until then each machine's Codex and opencode copy holds the previous skill set, which `--report` says, while Claude Code serves whatever the hub checkout holds. ## Changing or Retiring a Skill diff --git a/.claude-plugin/fleet-skills/.source-digests/check-this-repo b/.claude-plugin/fleet-skills/.source-digests/check-this-repo index aa1093ec9..3596947ad 100644 --- a/.claude-plugin/fleet-skills/.source-digests/check-this-repo +++ b/.claude-plugin/fleet-skills/.source-digests/check-this-repo @@ -1 +1 @@ -f5075baedbd8a74f +e44aa4df6a065a72 diff --git a/.claude-plugin/fleet-skills/.source-digests/merge-and-release b/.claude-plugin/fleet-skills/.source-digests/merge-and-release index 4db276472..e3b05edf8 100644 --- a/.claude-plugin/fleet-skills/.source-digests/merge-and-release +++ b/.claude-plugin/fleet-skills/.source-digests/merge-and-release @@ -1 +1 @@ -44482374472578a4 +b9f81e4bef9bcdea diff --git a/.claude-plugin/fleet-skills/.source-digests/skill-lifecycle b/.claude-plugin/fleet-skills/.source-digests/skill-lifecycle index b19b8cc6e..1150444f9 100644 --- a/.claude-plugin/fleet-skills/.source-digests/skill-lifecycle +++ b/.claude-plugin/fleet-skills/.source-digests/skill-lifecycle @@ -1 +1 @@ -68cf8fa202007b97 +22bb56c8d9fe6fec diff --git a/.claude-plugin/fleet-skills/skills/check-this-repo/SKILL.md b/.claude-plugin/fleet-skills/skills/check-this-repo/SKILL.md index f16338bff..8eb4ae9b0 100644 --- a/.claude-plugin/fleet-skills/skills/check-this-repo/SKILL.md +++ b/.claude-plugin/fleet-skills/skills/check-this-repo/SKILL.md @@ -44,8 +44,10 @@ repo. ## What it is safe to fix on its own -- **Re-run the installer**, `python3 scripts/skills_install.py`, from that same `main` checkout, - when `--report` exits non-zero. +- **Re-run the installer**, `python3 scripts/skills_install.py --snapshot-only`, from that same + `main` checkout, when `--report` exits non-zero. `--snapshot-only` refreshes the copy and leaves + the Claude Code registration alone, since a fetched checkout is not one that registration should + load from. This is a per-machine, local-only change, nothing in it touches this repo's git history or needs a review. diff --git a/.claude-plugin/fleet-skills/skills/merge-and-release/SKILL.md b/.claude-plugin/fleet-skills/skills/merge-and-release/SKILL.md index 0b586c1fe..6263eeb41 100644 --- a/.claude-plugin/fleet-skills/skills/merge-and-release/SKILL.md +++ b/.claude-plugin/fleet-skills/skills/merge-and-release/SKILL.md @@ -120,37 +120,20 @@ skill covers all of it, scoped down by what the maintainer actually asks for. Report a timeout separately from a completed run's own conclusion, the tag or version it produced. A run that fails, times out, or never starts is reported, never silently retried. -7. In the hub, when the chosen scope includes a release, bring this checkout to the merged - content without discarding or mixing in anything local. First assert `git status --porcelain - --untracked-files=all --ignored -- .agents/skills/ .claude-plugin/` is empty, and stop and - report rather than proceeding over any uncommitted content there, tracked, untracked, or - gitignored, since `skills_install.py` reads both paths: `shutil.copytree()` installs each - `.agents/skills/` skill directory for Codex/opencode, and `claude plugin marketplace add` - installs from `.claude-plugin/` for Claude Code, so a gitignored stray file under either rides - along the same as any other, and the plain porcelain form (silent on ignored paths) would pass - this preflight while one still rides into an install. Scoped to those two paths rather than - the whole tree, matching `skills_install.py`'s own `source_ref()` dirty check (`watched = - [SKILLS_SRC, CLAUDE_PLUGIN_DIR]`), since an ignored file elsewhere in the checkout (a build - cache, a lockfile) is not this preflight's concern and should not block the refresh on it. - Then `git fetch origin main`, `git checkout main` - (or `git checkout -b main origin/main` the first time this checkout carries no local `main` at - all, `checkout` rather than `switch` since the fleet's own `git` floor is undeclared and - `checkout` needs no minimum version for this), and `git merge --ff-only origin/main`. - `checkout` still refuses a `main` checked out in another worktree, and `--ff-only` refuses - anything but a clean fast-forward, so either stops and reports on top of what the preflight - already ruled out, per Repository Boundaries and Write Safety. `--ff-only` does not fail when - local `main` is already ahead of `origin/main`, since a strict superset needs no fast-forward - and reports up to date, so assert `git rev-parse main` equals `git rev-parse origin/main` - afterward and stop and report on a mismatch, a local-only commit this checkout never pushed is - exactly the case a bare "up to date" would hide. `skills_install.py` stamps and installs from - whatever this checkout's HEAD already is, so running it against a stale, unrefreshed, or - locally-diverged `main` skips the refresh silently. Only then run `python3 scripts/skills_install.py --report`, then - `python3 scripts/skills_install.py` to install, and confirm `--report`'s snapshot now reads - current. The two channels hold different things. The Codex and opencode copy keeps the - revision it was taken from, the promoted `main` here. The Claude Code channel loads the - registered checkout in place, the one `--report` names under `live`, and serves whatever it - holds at read time. Where that is this checkout, once step 8 returns it to `develop`, Claude - Code sessions on this machine load `develop`. `--report` exits on the snapshot alone. This step runs whether step 5 +7. In the hub, when the chosen scope includes a release, refresh this machine's Codex and opencode + copy from the promoted `main` in a detached worktree of its own, never by switching an existing + checkout to `main`, since the checkout Claude Code loads in place would move with it. Run `git fetch origin main`, then `git worktree add --detach + origin/main` at a new path in the fleet worktree layout, and from that worktree run + `python3 scripts/skills_install.py --snapshot-only`, then `python3 scripts/skills_install.py + --report`, and confirm its snapshot reads current. A fresh worktree holds nothing uncommitted + or ignored under `.agents/skills/` or `.claude-plugin/`, the two paths the installer reads, so + the copy holds exactly the promoted commit. `--snapshot-only` leaves the Claude Code + registration untouched, and that channel needs no refresh here: it loads the registered + checkout in place, the one `--report` names under `live`, and serves whatever it holds at read + time, so where that is the primary checkout on `develop`, Claude Code sessions on this machine + load `develop`. Then remove the worktree with + `git worktree remove `, whatever the report said, and report a snapshot that does not + read current. `--report` exits on the snapshot alone. This step runs whether step 5 or 6 dispatched, skipped, or failed a release, since it is gated only on the chosen scope, never on the release outcome. This refreshes only the machine running this session, per skill-lifecycle, every other machine still refreshes on its own next run or @@ -159,10 +142,12 @@ skill covers all of it, scoped down by what the maintainer actually asks for. failure, an ambiguous run match, a timeout, a failed run, or a hub Skills refresh all still reach this step, the merge in step 3 already landed by then. Two parts, both required, neither optional: - - The promotion PR's own worktree: fetch and prune, remove the worktree, then fast-forward the - base clone to `develop`. Removing first, not after, matters: the base clone cannot check out - `develop` while the promotion worktree still has it checked out, one branch checked out in - two worktrees at once is refused outright. Never delete `develop`, it is the promotion PR's + - The promotion PR's own worktree: fetch and prune, remove the worktree, then bring the base + clone to current `develop`, checking `develop` out first only where it sits on another + branch, and fast-forwarding it with `git merge --ff-only origin/develop`. Where that checkout + is needed, removing first, not after, matters: the base clone cannot check out `develop` + while the promotion worktree still has it checked out, one branch checked out in two + worktrees at once is refused outright. Never delete `develop`, it is the promotion PR's own head, and the repo's auto-delete-head-branches setting is kept off fleet-wide for exactly this reason, so nothing does this automatically. - A defensive sweep for anything drive-pr's own cleanup should already have removed but might diff --git a/.claude-plugin/fleet-skills/skills/skill-lifecycle/SKILL.md b/.claude-plugin/fleet-skills/skills/skill-lifecycle/SKILL.md index 912ef51c9..79f5c590b 100644 --- a/.claude-plugin/fleet-skills/skills/skill-lifecycle/SKILL.md +++ b/.claude-plugin/fleet-skills/skills/skill-lifecycle/SKILL.md @@ -32,7 +32,7 @@ A skill surfaces at a trigger moment. A rule that binds every action all the tim 5. **Apply the doc-packaging pattern below in the same change** when the skill packages a law doc or one of its sections. 6. **Regenerate and commit all trees together**: `python3 scripts/build_dist.py`, then, once authorized, commit the source and both generated trees in one commit, per `git-commit-conventions`. CI runs `--check` on every pull request and fails a desynced distribution. `python3 tests/test_build_dist.py` covers the generator itself. 7. **Record the surfacing**: annotate the `AGENTS.md` "Where the Rules Live" row when the skill packages a GOVERNANCE section, or its closing paragraph when the skill is new content, so the map stays the one place coverage is read from. -8. **Refresh the machines after promotion**: re-run `python3 scripts/skills_install.py` per machine, from a freshly fetched `main`, the cadence `docs/host-setup.md` "Fleet Skills Install" states. Until then each machine's Codex and opencode copy holds the previous skill set, which `--report` says, while Claude Code serves whatever the hub checkout holds. +8. **Refresh the machines after promotion**: re-run `python3 scripts/skills_install.py --snapshot-only` per machine, from a freshly fetched `main`, the cadence `docs/host-setup.md` "Fleet Skills Install" states. Until then each machine's Codex and opencode copy holds the previous skill set, which `--report` says, while Claude Code serves whatever the hub checkout holds. ## Changing or Retiring a Skill diff --git a/.github/skills/check-this-repo/SKILL.md b/.github/skills/check-this-repo/SKILL.md index f16338bff..8eb4ae9b0 100644 --- a/.github/skills/check-this-repo/SKILL.md +++ b/.github/skills/check-this-repo/SKILL.md @@ -44,8 +44,10 @@ repo. ## What it is safe to fix on its own -- **Re-run the installer**, `python3 scripts/skills_install.py`, from that same `main` checkout, - when `--report` exits non-zero. +- **Re-run the installer**, `python3 scripts/skills_install.py --snapshot-only`, from that same + `main` checkout, when `--report` exits non-zero. `--snapshot-only` refreshes the copy and leaves + the Claude Code registration alone, since a fetched checkout is not one that registration should + load from. This is a per-machine, local-only change, nothing in it touches this repo's git history or needs a review. diff --git a/.github/skills/merge-and-release/SKILL.md b/.github/skills/merge-and-release/SKILL.md index 0b586c1fe..6263eeb41 100644 --- a/.github/skills/merge-and-release/SKILL.md +++ b/.github/skills/merge-and-release/SKILL.md @@ -120,37 +120,20 @@ skill covers all of it, scoped down by what the maintainer actually asks for. Report a timeout separately from a completed run's own conclusion, the tag or version it produced. A run that fails, times out, or never starts is reported, never silently retried. -7. In the hub, when the chosen scope includes a release, bring this checkout to the merged - content without discarding or mixing in anything local. First assert `git status --porcelain - --untracked-files=all --ignored -- .agents/skills/ .claude-plugin/` is empty, and stop and - report rather than proceeding over any uncommitted content there, tracked, untracked, or - gitignored, since `skills_install.py` reads both paths: `shutil.copytree()` installs each - `.agents/skills/` skill directory for Codex/opencode, and `claude plugin marketplace add` - installs from `.claude-plugin/` for Claude Code, so a gitignored stray file under either rides - along the same as any other, and the plain porcelain form (silent on ignored paths) would pass - this preflight while one still rides into an install. Scoped to those two paths rather than - the whole tree, matching `skills_install.py`'s own `source_ref()` dirty check (`watched = - [SKILLS_SRC, CLAUDE_PLUGIN_DIR]`), since an ignored file elsewhere in the checkout (a build - cache, a lockfile) is not this preflight's concern and should not block the refresh on it. - Then `git fetch origin main`, `git checkout main` - (or `git checkout -b main origin/main` the first time this checkout carries no local `main` at - all, `checkout` rather than `switch` since the fleet's own `git` floor is undeclared and - `checkout` needs no minimum version for this), and `git merge --ff-only origin/main`. - `checkout` still refuses a `main` checked out in another worktree, and `--ff-only` refuses - anything but a clean fast-forward, so either stops and reports on top of what the preflight - already ruled out, per Repository Boundaries and Write Safety. `--ff-only` does not fail when - local `main` is already ahead of `origin/main`, since a strict superset needs no fast-forward - and reports up to date, so assert `git rev-parse main` equals `git rev-parse origin/main` - afterward and stop and report on a mismatch, a local-only commit this checkout never pushed is - exactly the case a bare "up to date" would hide. `skills_install.py` stamps and installs from - whatever this checkout's HEAD already is, so running it against a stale, unrefreshed, or - locally-diverged `main` skips the refresh silently. Only then run `python3 scripts/skills_install.py --report`, then - `python3 scripts/skills_install.py` to install, and confirm `--report`'s snapshot now reads - current. The two channels hold different things. The Codex and opencode copy keeps the - revision it was taken from, the promoted `main` here. The Claude Code channel loads the - registered checkout in place, the one `--report` names under `live`, and serves whatever it - holds at read time. Where that is this checkout, once step 8 returns it to `develop`, Claude - Code sessions on this machine load `develop`. `--report` exits on the snapshot alone. This step runs whether step 5 +7. In the hub, when the chosen scope includes a release, refresh this machine's Codex and opencode + copy from the promoted `main` in a detached worktree of its own, never by switching an existing + checkout to `main`, since the checkout Claude Code loads in place would move with it. Run `git fetch origin main`, then `git worktree add --detach + origin/main` at a new path in the fleet worktree layout, and from that worktree run + `python3 scripts/skills_install.py --snapshot-only`, then `python3 scripts/skills_install.py + --report`, and confirm its snapshot reads current. A fresh worktree holds nothing uncommitted + or ignored under `.agents/skills/` or `.claude-plugin/`, the two paths the installer reads, so + the copy holds exactly the promoted commit. `--snapshot-only` leaves the Claude Code + registration untouched, and that channel needs no refresh here: it loads the registered + checkout in place, the one `--report` names under `live`, and serves whatever it holds at read + time, so where that is the primary checkout on `develop`, Claude Code sessions on this machine + load `develop`. Then remove the worktree with + `git worktree remove `, whatever the report said, and report a snapshot that does not + read current. `--report` exits on the snapshot alone. This step runs whether step 5 or 6 dispatched, skipped, or failed a release, since it is gated only on the chosen scope, never on the release outcome. This refreshes only the machine running this session, per skill-lifecycle, every other machine still refreshes on its own next run or @@ -159,10 +142,12 @@ skill covers all of it, scoped down by what the maintainer actually asks for. failure, an ambiguous run match, a timeout, a failed run, or a hub Skills refresh all still reach this step, the merge in step 3 already landed by then. Two parts, both required, neither optional: - - The promotion PR's own worktree: fetch and prune, remove the worktree, then fast-forward the - base clone to `develop`. Removing first, not after, matters: the base clone cannot check out - `develop` while the promotion worktree still has it checked out, one branch checked out in - two worktrees at once is refused outright. Never delete `develop`, it is the promotion PR's + - The promotion PR's own worktree: fetch and prune, remove the worktree, then bring the base + clone to current `develop`, checking `develop` out first only where it sits on another + branch, and fast-forwarding it with `git merge --ff-only origin/develop`. Where that checkout + is needed, removing first, not after, matters: the base clone cannot check out `develop` + while the promotion worktree still has it checked out, one branch checked out in two + worktrees at once is refused outright. Never delete `develop`, it is the promotion PR's own head, and the repo's auto-delete-head-branches setting is kept off fleet-wide for exactly this reason, so nothing does this automatically. - A defensive sweep for anything drive-pr's own cleanup should already have removed but might diff --git a/.github/skills/skill-lifecycle/SKILL.md b/.github/skills/skill-lifecycle/SKILL.md index 912ef51c9..79f5c590b 100644 --- a/.github/skills/skill-lifecycle/SKILL.md +++ b/.github/skills/skill-lifecycle/SKILL.md @@ -32,7 +32,7 @@ A skill surfaces at a trigger moment. A rule that binds every action all the tim 5. **Apply the doc-packaging pattern below in the same change** when the skill packages a law doc or one of its sections. 6. **Regenerate and commit all trees together**: `python3 scripts/build_dist.py`, then, once authorized, commit the source and both generated trees in one commit, per `git-commit-conventions`. CI runs `--check` on every pull request and fails a desynced distribution. `python3 tests/test_build_dist.py` covers the generator itself. 7. **Record the surfacing**: annotate the `AGENTS.md` "Where the Rules Live" row when the skill packages a GOVERNANCE section, or its closing paragraph when the skill is new content, so the map stays the one place coverage is read from. -8. **Refresh the machines after promotion**: re-run `python3 scripts/skills_install.py` per machine, from a freshly fetched `main`, the cadence `docs/host-setup.md` "Fleet Skills Install" states. Until then each machine's Codex and opencode copy holds the previous skill set, which `--report` says, while Claude Code serves whatever the hub checkout holds. +8. **Refresh the machines after promotion**: re-run `python3 scripts/skills_install.py --snapshot-only` per machine, from a freshly fetched `main`, the cadence `docs/host-setup.md` "Fleet Skills Install" states. Until then each machine's Codex and opencode copy holds the previous skill set, which `--report` says, while Claude Code serves whatever the hub checkout holds. ## Changing or Retiring a Skill diff --git a/docs/host-setup.md b/docs/host-setup.md index 40700fb10..f8ccdbce2 100644 --- a/docs/host-setup.md +++ b/docs/host-setup.md @@ -282,12 +282,13 @@ opencode does not read Codex's `config.toml`. Keep its permission mode in openco ## Fleet Skills Install -The fleet's agent skills are hand-authored in the hub at `.agents/skills/` and installed per user by [`scripts/skills_install.py`][skills-install]: an overlay copy into `~/.agents/skills/` for Codex and opencode, and a user-scope Claude Code plugin install where the `claude` CLI is present. Every run stamps the hub commit it installed from into `~/.agents/skills-install-stamp.json`. The copy keeps the revision it was taken from, while the Claude Code plugin loads the hub checkout in place and serves whatever it holds at read time. `--report` answers each by name: which commit the copy came from, judged against the promoted `main` as last fetched (or `--intended `, or on a bootstrapped host the commit its loader resolved), and which branch and commit the registered checkout is serving now. It exits non-zero when the copy is not current, and the live channel following its checkout is the design rather than a fault. +The fleet's agent skills are hand-authored in the hub at `.agents/skills/` and installed per user by [`scripts/skills_install.py`][skills-install]: an overlay copy into `~/.agents/skills/` for Codex and opencode, and a user-scope Claude Code plugin install where the `claude` CLI is present. Every run stamps the hub commit it installed from into `~/.agents/skills-install-stamp.json`. The copy keeps the revision it was taken from, while the Claude Code plugin loads the hub checkout in place and serves whatever it holds at read time. `--report` answers each by name: which commit the copy came from, judged against the promoted `main` as last fetched (or `--intended `, or on a bootstrapped host the commit its loader resolved), and which branch and commit the registered checkout is serving now. It exits non-zero when the copy is not current, and the live channel following its checkout is the design rather than a fault. An install leaves a registration from another existing directory where it is and prints the command that moves it, and `--snapshot-only` refreshes the copy without touching the registration at all. Install from a hub checkout, once per machine: ```shell python3 scripts/skills_install.py # or the scripts/skills_install.sh / .ps1 wrapper +python3 scripts/skills_install.py --snapshot-only # the Codex/opencode copy alone python3 scripts/skills_install.py --report # read-only: what does each channel hold? ``` diff --git a/host-setup/README.md b/host-setup/README.md index cc1575c8c..980dcd34f 100644 --- a/host-setup/README.md +++ b/host-setup/README.md @@ -100,7 +100,7 @@ Reaching `spec/audit.py` and `scripts/carry.py` from outside a hub checkout mean ## Where the Tree Lives -A run that installs the skills, `--host`, `--dev`, or `--skills`, keeps its tree, because the Claude Code plugin it registers loads that directory in place rather than copying it. Removing the tree would leave the plugin registered against a directory that no longer exists. The kept tree sits at `skills-tree` under `${XDG_DATA_HOME:-~/.local/share}/host-setup` on Linux and under `%LOCALAPPDATA%\host-setup` on Windows, or under `--dir` where one is given. It carries the commit the run resolved, which is what `skills_install.py --report` names for it, since a tarball has no git to ask. The next such run extracts beside it and swaps the new tree in immediately before the skills step, moving the old one aside first and removing it last. A run that fails before that step, a failed download or a failed tools step alike, therefore leaves the plugin loading what it loaded before. Every other action, and a dry run of these three, extracts a transient tree under another name, which it removes on exit unless `--keep` is given. The installer never replaces an existing registration, so a host whose plugin already names a hub checkout keeps that checkout, and `skills_install.py --report` names the directory the plugin actually loads. +A run that installs the skills, `--host`, `--dev`, or `--skills`, keeps its tree, because the Claude Code plugin it registers loads that directory in place rather than copying it. Removing the tree would leave the plugin registered against a directory that no longer exists. The kept tree sits at `skills-tree` under `${XDG_DATA_HOME:-~/.local/share}/host-setup` on Linux and under `%LOCALAPPDATA%\host-setup` on Windows, or under `--dir` where one is given. It carries the commit the run resolved, which is what `skills_install.py --report` names for it, since a tarball has no git to ask. The next such run extracts beside it and swaps the new tree in immediately before the skills step, moving the old one aside first and removing it last. A run that fails before that step, a failed download or a failed tools step alike, therefore leaves the plugin loading what it loaded before. Every other action, and a dry run of these three, extracts a transient tree under another name, which it removes on exit unless `--keep` is given. The installer never moves a registration whose directory still exists, so a host whose plugin already names a hub checkout keeps that checkout, and `skills_install.py --report` names the directory the plugin actually loads. The kept tree is never a git checkout, which is what keeps the loader's two properties: it needs no git, and it never modifies a checkout that belongs to somebody else. diff --git a/scripts/README.md b/scripts/README.md index 0470c6e72..0bbffb187 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -347,7 +347,7 @@ The target is required to be clean, with no owned root exempted from the unrelat ## `skills_install.py` -Installs the fleet's Skills for the current machine, cross-platform and idempotent, mirroring [`host-setup/agent-safety/claude/install.py`][agent-safety-install]'s shape: `skills_install.sh` and `skills_install.ps1` are thin wrappers that locate a Python 3 interpreter and hand off, so every OS runs one tested code path. Two independent things happen on a run, since the three tools this fleet targets discover skills differently: `.agents/skills/` is materialized (not symlinked) to `$HOME/.agents/skills/`, so Codex and opencode's global scan covers every repo on the machine rather than only the one that happens to be open, and this repo's marketplace is registered with the `claude` CLI (`claude plugin marketplace add`, `claude plugin install`) so Claude Code loads the same content the other two read directly. The marketplace/plugin registration goes through the `claude` CLI's own commands rather than writing its internal `known_marketplaces.json` by hand, because that file's shape is the CLI's state, not a documented contract, and a hand-written copy risks drifting from what the CLI expects on its next release. +Installs the fleet's Skills for the current machine, cross-platform and idempotent, mirroring [`host-setup/agent-safety/claude/install.py`][agent-safety-install]'s shape: `skills_install.sh` and `skills_install.ps1` are thin wrappers that locate a Python 3 interpreter and hand off, so every OS runs one tested code path. Two independent things happen on a run, since the three tools this fleet targets discover skills differently: `.agents/skills/` is materialized (not symlinked) to `$HOME/.agents/skills/`, so Codex and opencode's global scan covers every repo on the machine rather than only the one that happens to be open, and this repo's marketplace is registered with the `claude` CLI (`claude plugin marketplace add`, `claude plugin install`) so Claude Code loads the same content the other two read directly. The marketplace/plugin registration goes through the `claude` CLI's own commands rather than writing its internal `known_marketplaces.json` by hand, because that file's shape is the CLI's state, not a documented contract, and a hand-written copy risks drifting from what the CLI expects on its next release. `claude plugin marketplace add` re-points an existing registration without failing, so the installer reads the CLI's listing first and moves a registration only where it is a directory source whose directory no longer exists, saying so. Any other existing registration is left in place, and the run prints the command that moves it. Where the CLI gives no listing, the run registers nothing and exits non-zero. `--snapshot-only` refreshes the Codex and opencode copy and its stamp without touching the registration at all. The two channels hold different things: the Codex and opencode copy keeps the revision it was taken from, while the Claude Code marketplace is a directory source that loads the hub checkout in place and serves whatever it holds at read time. `--report` reads the stamp a prior run wrote (`$HOME/.agents/skills-install-stamp.json`, naming the hub commit installed) and answers each channel by name, without installing anything. The copy is judged against the promoted `main` as last fetched, or `--intended ` in a git checkout, or on a bootstrapped tarball tree the commit its loader resolved, where `--intended` is refused. The live channel reports the branch, commit, and dirty state of the checkout the marketplace registers. The exit code is the copy's verdict alone. Where no intended revision resolves, the copy is not asserted current and the snapshot's `reason` says it cannot be judged, which a re-install does not fix. A repository whose `AGENTS.md` keeps needing a rule restated is usually this: the machine was never installed, or was installed from an older commit. diff --git a/scripts/skills_install.py b/scripts/skills_install.py index 0c2079075..914288205 100755 --- a/scripts/skills_install.py +++ b/scripts/skills_install.py @@ -26,6 +26,7 @@ the snapshot's verdict alone, since the live channel following its checkout is the design. Usage: python3 scripts/skills_install.py (installs) + python3 scripts/skills_install.py --snapshot-only (refreshes the Codex/opencode copy alone) python3 scripts/skills_install.py --report (read-only: what does each channel hold?) python3 scripts/skills_install.py --report --intended (judge the snapshot against ) AGENTS_HOME=/x python3 scripts/skills_install.py (override the global skills target, for testing) @@ -38,6 +39,7 @@ import os import shutil import socket +import stat import subprocess import sys from pathlib import Path @@ -84,7 +86,10 @@ def git_in(root, *args): def is_bootstrap_tree(root): """Whether `root` is a tree the bootstrap extracted, which carries the marker it writes.""" - return (root / BOOTSTRAP_OWNED_MARKER).is_file() + try: + return (root / BOOTSTRAP_OWNED_MARKER).is_file() + except (OSError, ValueError): + return False def bootstrap_tree_commit(root): @@ -223,6 +228,46 @@ def entry_location(entry): return location if isinstance(location, str) and location else None +def same_directory(a, b): + """Whether two paths name one directory, however each is spelled, False where either cannot be resolved.""" + try: + return os.path.normcase(Path(a).resolve()) == os.path.normcase(Path(b).resolve()) + except (OSError, RuntimeError, ValueError): + return False + + +def directory_gone(location): + """Whether nothing is at `location` to serve, judged by stat so an unreadable path is never gone.""" + try: + return not stat.S_ISDIR(os.stat(location).st_mode) + except (FileNotFoundError, NotADirectoryError): + return True + except (OSError, ValueError): + return False + + +def existing_registration(): + """This marketplace's current registration, as (where it is, whether an add may move it). + + `claude plugin marketplace add` re-points an existing registration at the new directory + without failing, so running it from a worktree would leave Claude Code loading a tree that is + about to be removed. Only a directory registration whose directory is gone may be moved, since + it serves nothing. A directory that cannot be read is kept, as a present one is. Returns None + where nothing is registered, and raises LookupError where the CLI gives no listing. + """ + entry = marketplace_entry() + if entry is None: + raise LookupError("`claude plugin marketplace list --json` gave no listing") + if not entry: + return None + if entry.get("source") != "directory": + return f"a {entry.get('source') or 'non-directory'} source", False + location = entry_location(entry) + if location is None: + return "a directory source naming no directory", False + return location, directory_gone(location) or same_directory(location, ROOT) + + def register_claude_marketplace(): """Add this repo's marketplace and install its plugin via the `claude` CLI. @@ -230,7 +275,36 @@ def register_claude_marketplace(): ~/.claude/plugins/known_marketplaces.json directly: that file's shape is the CLI's own internal state, not a documented contract, so writing it by hand risks silently drifting from whatever the CLI actually expects on the next release. + + An existing registration the add would move is left in place, with a warning naming the command + that moves it, unless its directory is gone, where the move is made and announced. """ + try: + existing = existing_registration() + except LookupError as exc: + print( + f"{exc}, so whether registering here would move an existing registration is unknown. " + "Not registering.", + file=sys.stderr, + ) + return False + if existing: + location, movable = existing + if not movable: + print( + f"Claude Code marketplace '{MARKETPLACE_NAME}' is registered from {location}, " + "left in place. To load it from this checkout instead, run: " + f'claude plugin marketplace add "{ROOT}"', + file=sys.stderr, + ) + return install_claude_plugin() + if not same_directory(location, ROOT): + print( + f"Claude Code marketplace '{MARKETPLACE_NAME}' was registered from {location}, " + f"which no longer exists. Registering it from {ROOT}.", + file=sys.stderr, + ) + marketplace_add = subprocess.run( ["claude", "plugin", "marketplace", "add", str(ROOT)], capture_output=True, @@ -247,7 +321,11 @@ def register_claude_marketplace(): ): print(marketplace_add.stdout, marketplace_add.stderr, file=sys.stderr) return False + return install_claude_plugin() + +def install_claude_plugin(): + """Install this marketplace's plugin at user scope, from wherever the marketplace is registered.""" install = subprocess.run( ["claude", "plugin", "install", f"{PLUGIN_NAME}@{MARKETPLACE_NAME}", "--scope", "user"], capture_output=True, @@ -322,7 +400,7 @@ def live_channel(): if location is None: return {"registered": True, "reason": "the listing names no location"} root = Path(location) - if not root.is_dir(): + if directory_gone(root): return { "registered": True, "checkout": str(root), @@ -418,9 +496,16 @@ def main(): metavar="REV", help="with --report: the revision the snapshot should hold (default: the promoted main)", ) + parser.add_argument( + "--snapshot-only", + action="store_true", + help="refresh only the Codex/opencode copy, leaving the Claude Code registration untouched", + ) args = parser.parse_args() if args.intended and not args.report: parser.error("--intended only applies with --report") + if args.snapshot_only and args.report: + parser.error("--snapshot-only installs, and --report changes nothing") if args.intended and is_bootstrap_tree(ROOT): parser.error( "--intended needs a git checkout, and this is a bootstrap tree, which is judged against the commit its loader resolved" @@ -438,6 +523,13 @@ def main(): print(exc, file=sys.stderr) return 1 + if args.snapshot_only: + home.mkdir(parents=True, exist_ok=True) + stamp_path.write_text(json.dumps(build_stamp(None), indent=2) + "\n", encoding="utf-8") + print(f"Skills materialized to {home / 'skills'}.") + print("Claude Code marketplace left untouched (--snapshot-only).") + return 0 + claude_present = claude_available() claude_registered = register_claude_marketplace() if claude_present else False if not claude_present: diff --git a/tests/test_skills_install.py b/tests/test_skills_install.py index e7dadb24e..4e1c2ed07 100755 --- a/tests/test_skills_install.py +++ b/tests/test_skills_install.py @@ -507,6 +507,46 @@ def test_a_missing_registered_checkout_says_it_serves_nothing(self) -> None: self.assertIn("does not exist", live["reason"]) self.assertNotIn("commit", live) + def registered_live(self, location: Path) -> dict[str, object]: + self.listing( + json.dumps( + [ + { + "name": skills_install.MARKETPLACE_NAME, + "source": "directory", + "path": str(location), + } + ] + ) + ) + with mock.patch("skills_install.git_in", return_value=None): + return skills_install.live_channel() + + def test_a_symlink_loop_is_judged_as_the_installer_judges_it(self) -> None: + loop = Path(self.enterContext(tempfile.TemporaryDirectory())) / "loop" + try: + loop.symlink_to(loop) + except OSError: + self.skipTest("symlinks unavailable") + self.assertFalse(skills_install.directory_gone(loop)) + live = self.registered_live(loop) + self.assertNotIn("reason", live) + self.assertIsNone(live["commit"]) + + @unittest.skipIf( + sys.platform == "win32" or os.geteuid() == 0, + "needs POSIX permissions that bind the running user", + ) + def test_an_unreadable_registered_checkout_is_reported_rather_than_crashing(self) -> None: + locked = Path(self.enterContext(tempfile.TemporaryDirectory())) / "locked" + (locked / "checkout").mkdir(parents=True) + locked.chmod(0) + self.addCleanup(locked.chmod, 0o700) + live = self.registered_live(locked / "checkout") + self.assertTrue(live["registered"]) + self.assertNotIn("reason", live) + self.assertIsNone(live["commit"]) + def test_the_registered_checkout_is_the_one_measured(self) -> None: self.listing( json.dumps( @@ -522,7 +562,7 @@ def fake(root, *args): with ( mock.patch("skills_install.git_in", side_effect=fake), - mock.patch("pathlib.Path.is_dir", return_value=True), + mock.patch("skills_install.directory_gone", return_value=False), ): live = skills_install.live_channel() self.assertEqual( @@ -553,7 +593,7 @@ def fake(_root, *args): with ( mock.patch("skills_install.git_in", side_effect=fake), - mock.patch("pathlib.Path.is_dir", return_value=True), + mock.patch("skills_install.directory_gone", return_value=False), ): skills_install.live_channel() status = next(c for c in calls if c[0] == "status") @@ -569,7 +609,7 @@ def test_a_failed_status_reads_as_unknown_rather_than_clean(self) -> None: answers = {"symbolic-ref": None, "rev-parse": "sha", "status": None} with ( mock.patch("skills_install.git_in", side_effect=lambda _r, *a: answers[a[0]]), - mock.patch("pathlib.Path.is_dir", return_value=True), + mock.patch("skills_install.directory_gone", return_value=False), ): live = skills_install.live_channel() self.assertIsNone(live["dirty"]) @@ -651,6 +691,143 @@ def test_skills_and_marketplace_outcomes_print_on_separate_lines(self) -> None: self.assertIn(f"Skills materialized to {self.tmp / 'skills'}.", lines) self.assertIn("Claude Code marketplace registered: True.", lines) + def test_snapshot_only_never_touches_the_claude_registration(self) -> None: + mock.patch("sys.argv", ["skills_install.py", "--snapshot-only"]).start() + mock.patch("skills_install.claude_available", return_value=True).start() + register = mock.patch("skills_install.register_claude_marketplace").start() + with contextlib.redirect_stdout(io.StringIO()): + self.assertEqual(skills_install.main(), 0) + register.assert_not_called() + stamp = json.loads((self.tmp / "skills-install-stamp.json").read_text(encoding="utf-8")) + self.assertIsNone(stamp["claudeRegistered"]) + + def test_snapshot_only_is_refused_with_report(self) -> None: + mock.patch("sys.argv", ["skills_install.py", "--snapshot-only", "--report"]).start() + with contextlib.redirect_stderr(io.StringIO()), self.assertRaises(SystemExit) as caught: + skills_install.main() + self.assertEqual(caught.exception.code, 2) + + +class RegisterCase(unittest.TestCase): + """`claude plugin marketplace add` moves an existing registration without failing, so the + installer decides from the listing whether an add would move one.""" + + def setUp(self) -> None: + self.addCleanup(mock.patch.stopall) + self.elsewhere = Path(self.enterContext(tempfile.TemporaryDirectory())) + self.calls: list[list[str]] = [] + self.entries: list[dict[str, str]] | None = [] + + def run_register(self) -> bool: + def fake_run(cmd: list[str], **_: object) -> mock.Mock: + self.calls.append(cmd) + if cmd[1:4] == ["plugin", "marketplace", "list"]: + if self.entries is None: + return mock.Mock(returncode=1, stdout="", stderr="") + return mock.Mock(returncode=0, stdout=json.dumps(self.entries), stderr="") + return mock.Mock(returncode=0, stdout="", stderr="") + + mock.patch("subprocess.run", side_effect=fake_run).start() + with contextlib.redirect_stderr(io.StringIO()) as err: + result = skills_install.register_claude_marketplace() + self.stderr = err.getvalue() + return result + + def registered_at(self, location: Path) -> None: + self.entries = [ + {"name": skills_install.MARKETPLACE_NAME, "source": "directory", "path": str(location)} + ] + + def added(self) -> bool: + return any(cmd[1:4] == ["plugin", "marketplace", "add"] for cmd in self.calls) + + def installed(self) -> bool: + return any(cmd[1:3] == ["plugin", "install"] for cmd in self.calls) + + def test_an_unregistered_marketplace_is_added_and_installed(self) -> None: + self.assertTrue(self.run_register()) + self.assertTrue(self.added()) + self.assertTrue(self.installed()) + + def test_a_registration_from_this_checkout_is_re_added(self) -> None: + self.registered_at(skills_install.ROOT) + self.assertTrue(self.run_register()) + self.assertTrue(self.added()) + + def test_a_registration_from_another_checkout_is_left_in_place(self) -> None: + self.registered_at(self.elsewhere) + self.assertTrue(self.run_register()) + self.assertFalse(self.added()) + self.assertTrue(self.installed()) + self.assertIn(str(self.elsewhere), self.stderr) + self.assertIn("claude plugin marketplace add", self.stderr) + + def test_a_registration_whose_directory_is_gone_is_replaced_and_says_so(self) -> None: + self.registered_at(self.elsewhere / "removed") + self.assertTrue(self.run_register()) + self.assertTrue(self.added()) + self.assertIn(str(self.elsewhere / "removed"), self.stderr) + self.assertIn("no longer exists", self.stderr) + + @unittest.skipIf( + sys.platform == "win32" or os.geteuid() == 0, + "needs POSIX permissions that bind the running user", + ) + def test_a_registration_whose_directory_cannot_be_read_is_left_in_place(self) -> None: + locked = self.elsewhere / "locked" + (locked / "checkout").mkdir(parents=True) + locked.chmod(0) + self.addCleanup(locked.chmod, 0o700) + self.registered_at(locked / "checkout") + self.assertTrue(self.run_register()) + self.assertFalse(self.added()) + + def test_a_registration_on_a_symlink_loop_is_left_in_place(self) -> None: + loop = self.elsewhere / "loop" + try: + loop.symlink_to(loop) + except OSError: + self.skipTest("symlinks unavailable") + self.registered_at(loop) + self.assertTrue(self.run_register()) + self.assertFalse(self.added()) + + def test_a_registration_naming_an_impossible_path_is_left_in_place(self) -> None: + self.registered_at(self.elsewhere / "nul\0byte") + self.assertTrue(self.run_register()) + self.assertFalse(self.added()) + + def test_a_registration_on_a_file_is_replaced(self) -> None: + stray = self.elsewhere / "stray" + stray.write_text("", encoding="utf-8") + self.registered_at(stray) + self.assertTrue(self.run_register()) + self.assertTrue(self.added()) + + def test_a_github_registration_is_left_in_place_whether_or_not_its_cache_exists( + self, + ) -> None: + for location in (self.elsewhere, self.elsewhere / "cleared"): + with self.subTest(location=location): + self.calls.clear() + self.entries = [ + { + "name": skills_install.MARKETPLACE_NAME, + "source": "github", + "repo": "example/marketplace", + "installLocation": str(location), + } + ] + self.assertTrue(self.run_register()) + self.assertFalse(self.added()) + self.assertIn("github source", self.stderr) + + def test_no_listing_registers_nothing_and_fails(self) -> None: + self.entries = None + self.assertFalse(self.run_register()) + self.assertFalse(self.added()) + self.assertFalse(self.installed()) + class IntendedInBootstrapTreeCase(unittest.TestCase): """A named revision is resolved by git, which inside a bootstrap tree answers for whatever