diff --git a/.claude/settings.json b/.claude/settings.json index 6575a2bc3fe..2d105c725d5 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -10,6 +10,46 @@ } ] } + ], + "WorktreeCreate": [ + { + "hooks": [ + { + "type": "command", + "command": "nix run \"${CLAUDE_PROJECT_DIR}#quest\" -- worktree hook" + } + ] + } + ], + "WorktreeRemove": [ + { + "hooks": [ + { + "type": "command", + "command": "nix run \"${CLAUDE_PROJECT_DIR}#quest\" -- worktree hook" + } + ] + } + ], + "SubagentStart": [ + { + "hooks": [ + { + "type": "command", + "command": "nix run \"${CLAUDE_PROJECT_DIR}#quest\" -- worktree hook" + } + ] + } + ], + "SubagentStop": [ + { + "hooks": [ + { + "type": "command", + "command": "nix run \"${CLAUDE_PROJECT_DIR}#quest\" -- worktree hook" + } + ] + } ] }, "permissions": { diff --git a/.claude/skills/quest-merge/SKILL.md b/.claude/skills/quest-merge/SKILL.md index c03a0d84973..156d4aba306 100644 --- a/.claude/skills/quest-merge/SKILL.md +++ b/.claude/skills/quest-merge/SKILL.md @@ -1,6 +1,6 @@ --- name: quest-merge -description: Queue a reviewed PR to land, or send it to /quest-iterate. +description: Queue a PR to land, running /quest-iterate first when it needs work. --- Run `quest skill merge` and follow its output. diff --git a/.gitignore b/.gitignore index b4aa4e2515c..b3ef8e75a69 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,10 @@ /.claude/cache/ /.claude/tmp/ /.claude/worktrees/ +# quest's own checkouts (`quest worktree create`, /quest-spawn, and its Claude +# Code worktree hooks) live under the main checkout's .worktrees/, for the same +# reason. +/.worktrees/ # Per-checkout scratch output, such as benchmark logs and agent notes. /.tmp/ diff --git a/AGENTS.md b/AGENTS.md index 26a26952d5b..37e66aec2db 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -102,6 +102,7 @@ These diff the branch against its base and only run the affected packages. Quests: before starting work, run `quest guide` and follow it. The `quest` binary comes from the moq-dev/quest flake input and serves the quest skills; change them upstream and bump the input. +Claude Code's worktree hooks run that pinned `quest` through `nix run`, because hooks don't see the dev shell; `quest init` refuses them, so drop them for its run and restore `.claude/settings.json` afterwards. # Cross-Package Sync diff --git a/flake.lock b/flake.lock index b5e2c97c919..b086087c5a3 100644 --- a/flake.lock +++ b/flake.lock @@ -77,28 +77,28 @@ "quest-pinned": "quest-pinned" }, "locked": { - "lastModified": 1793656089, - "narHash": "sha256-QsOBS3Md96SVAwwGsmWWmZLJQcWymHPdDdyy2UvqKFg=", + "lastModified": 1793732323, + "narHash": "sha256-rmhEvaqsKShdBJ+8WbXmDj9HkHIr5GEMfs2lDTxTnD4=", "owner": "moq-dev", "repo": "quest", - "rev": "5e66075d5acc397e400094ea4f53f7db45e351ce", + "rev": "36d0429cce0d540ad90f6c1a006a9ca1659b0696", "type": "github" }, "original": { "owner": "moq-dev", "repo": "quest", - "rev": "5e66075d5acc397e400094ea4f53f7db45e351ce", + "rev": "36d0429cce0d540ad90f6c1a006a9ca1659b0696", "type": "github" } }, "quest-pinned": { "flake": false, "locked": { - "lastModified": 1793505952, - "narHash": "sha256-jDq0fsxzLGIu6FsFfIsnUgvb23Pb+Rja4KZwIxGa34I=", + "lastModified": 1793721754, + "narHash": "sha256-pPsXWcv0LdYqW5bRYx7Av6urjcRTC3bGRWh8BGwO0Ug=", "owner": "moq-dev", "repo": "quest", - "rev": "7a191e6197c691f477b4c55edba34cc425c3e77c", + "rev": "2aa60a2d6676147314e725b0410882128eacea49", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 616ca64a9ff..09c3ccfd3dd 100644 --- a/flake.nix +++ b/flake.nix @@ -32,7 +32,7 @@ # The quest CLI, which also serves the quest guide and skills the stubs in # .claude/skills call. Bump the rev to upgrade them. quest = { - url = "github:moq-dev/quest/5e66075d5acc397e400094ea4f53f7db45e351ce"; + url = "github:moq-dev/quest/36d0429cce0d540ad90f6c1a006a9ca1659b0696"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; diff --git a/quest/m0/README.md b/quest/m0/README.md index 55bddeb5c1f..25a135c7f0d 100644 --- a/quest/m0/README.md +++ b/quest/m0/README.md @@ -38,5 +38,5 @@ since cutting segments from first-frame pts waits on nothing in m1. - [Backport the relay and auth hardening to release](/quest/m0/backport-release-hardening.md) - `release`'s relay refuses dot-segment paths, serves its HTTP routes with main's response hardening, and withdraws advertisements a peer starves of send credit; its auth client refuses redirects - [Release's MKV importer bounds what it buffers](/quest/m0/backport-mkv-buffer.md) - on `release`, an MKV input that declares a huge element and trickles its bytes no longer grows the importer's memory without limit - [HLS export on a declared grid](/quest/m0/hls-media-grid.md) - the catalog's `hls` field and record tracks go away, and the export numbers segments on `media.join.interval` from media tracks -- [Agents use quest's worktree hooks](/quest/m0/quest-worktree-hooks.md) - adopt `quest worktree hook` once it's shown to coexist with T3 Code's worktrees +- [quest init keeps moq's nix-wrapped worktree hooks](/quest/m0/quest-worktree-hooks.md) - quest pin bumps keep the hooks that run moq's pinned `quest` - [HLS lists contributions](/quest/m0/hls-contributions.md) - an HLS master lists each catalog contribution's renditions, and a contribution's media is subscribed only while players fetch it diff --git a/quest/m0/quest-worktree-hooks.md b/quest/m0/quest-worktree-hooks.md index 59c519d7eb8..50c2c67fd0b 100644 --- a/quest/m0/quest-worktree-hooks.md +++ b/quest/m0/quest-worktree-hooks.md @@ -1,20 +1,46 @@ -# [S] Agents use quest's worktree hooks +# [XS] quest init keeps moq's nix-wrapped worktree hooks ## Goal -moq's `.claude/settings.json` carries the `WorktreeCreate`, `WorktreeRemove`, -`SubagentStart` and `SubagentStop` hooks that `quest init` installs (running -`quest worktree hook`), so agent worktrees are created and cleaned up the way -quest expects, without breaking T3 Code's own worktree management. +moq's Claude Code worktree hooks, which run the `quest` moq pins through nix, +survive quest pin bumps: `quest init` leaves them alone instead of refusing +them. ## Plan -Planned 2026-11-02 (maintainer, /quest-unblock), from -[moq-dev/moq#7644](https://github.com/moq-dev/moq/pull/7644): the quest pin bump -left the hooks out because they change how agent worktrees are made here, and -moq never adopted them after moq-dev/quest#350. +Decided 2026-11-03 (maintainer, on +[moq-dev/moq#7674](https://github.com/moq-dev/moq/pull/7674)): ✅ the hooks +reach `quest` through nix (or a submodule) long-term, so they run moq's pin. +A host-wide `quest` on `PATH` is acceptable only as a temporary bridge. +Rejected: relying on an installed `quest`, `direnv exec`, adopting the bare +`quest worktree hook` now, and dropping the quest. -- First confirm the hooks coexist with T3 Code's worktree threads and its - isolated delegate checkouts (create, hand off, and clean up one of each with - the hooks on). If they conflict, stop and report rather than adopting. -- Then add them with `quest init` and document the behavior in AGENTS.md. +Decided 2026-11-03 (maintainer, on +[moq-dev/moq#7674](https://github.com/moq-dev/moq/pull/7674)): ✅ ask +moq-dev/quest to have `quest init` treat any command hook whose arguments end +in `worktree hook` as its own. Rejected: a configured hook command, and not +asking. + +[moq-dev/moq#7674](https://github.com/moq-dev/moq/pull/7674) installed the four +hooks as `nix run "${CLAUDE_PROJECT_DIR}#quest" -- worktree hook`. That command +takes 0.1–0.5 s warm and 1.5–3 s with a cold nix cache, and builds a new pin in +about 6 s. It also bumped the pin past +[moq-dev/quest#425](https://github.com/moq-dev/quest/pull/425), so +`--worktree '#123'` starts at the PR head and workflow agents' checkouts get +released, and checked live that the hooks coexist with T3 Code's worktree +threads and isolated delegates. What remains: + +- `quest init` matches only the literal `quest worktree hook`, so it refuses a + wrapped `WorktreeCreate`/`WorktreeRemove` command (exit 1, nothing written) + and would add duplicate subagent hooks. Until quest recognizes a wrapped + command, a pin bump drops the four entries for its `quest init` run and + restores `.claude/settings.json` afterwards, as AGENTS.md says. Once + quest recognizes them, bump the pin, check that `quest init` is a + no-op here, and drop that AGENTS.md sentence. + +## Waiting + +- moq-dev/quest: land `quest init` and `quest uninstall` treating a command + hook whose arguments end in `worktree hook` as Quest's own (being planned + there as of 2026-11-03). Check: with this repository's hooks in place, the + pinned `quest init` exits 0 and leaves `.claude/settings.json` unchanged.