diff --git a/.changeset/hooked-worktrees.md b/.changeset/hooked-worktrees.md new file mode 100644 index 0000000..20be0d3 --- /dev/null +++ b/.changeset/hooked-worktrees.md @@ -0,0 +1,5 @@ +--- +"@northguild/worktree": minor +--- + +Add `worktree claude-hook`, so Claude Code's `--worktree`, subagent isolation and background sessions can create and remove worktrees through this tool (the `WorktreeCreate` and `WorktreeRemove` hooks), and copy the gitignored files a root `.worktreeinclude` names. diff --git a/README.md b/README.md index bec2e81..aadfb31 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ That will: 1. create a new branch from your configured source branch 2. add a Git worktree under `.worktrees/feature/improve-readme` -3. copy the gitignored env files from the main repository — `.env*`, `.dev.vars*` and `.envrc` — and any gitignored file `.worktree.yml` lists under `copy` +3. copy the gitignored env files from the main repository — `.env*`, `.dev.vars*` and `.envrc` — any gitignored file `.worktree.yml` lists under `copy`, and any gitignored file a root `.worktreeinclude` matches 4. install dependencies — by default when non-interactive, and on a terminal when `postCreate` is set or `--install` is given (`--no-install` skips it); the command is your `postCreate`, else the steps under `postCreate` in `.worktree.yml` (run in order, after you approve them: checked before anything is created, asked on a terminal, exit `2` with `missing_value` when nothing can be asked, so approve with `worktree config --approve` or skip with `--no-install`), else the `postCreate` steps in your user config file (no approval), else inferred from the lockfile (`pnpm-lock.yaml`, `package-lock.json`, `yarn.lock`, `bun.lock`); a failure stops the remaining steps, keeps the worktree, opens nothing and exits `1` 5. open the new worktree in your configured editor, if one is set — or as a Herdr space when `opener` is `herdr`, or as a Rex session when it is `rex`; with `auto`, in the Herdr or Rex the command runs inside, else the editor @@ -263,6 +263,7 @@ Only the owner of `linear.apiKey` (or the ids in `linear.agentAllow`) can start | `worktree remove [branch]` | Remove one or more worktrees | | `worktree cleanup` | Remove stale worktrees that are safe to delete | | `worktree linear-listen` | Start a worktree for each Linear agent delegation | +| `worktree claude-hook` | Make Claude Code create and remove worktrees with this tool | For command help at any time: diff --git a/context/stack.md b/context/stack.md index 766c938..0d34543 100644 --- a/context/stack.md +++ b/context/stack.md @@ -32,7 +32,7 @@ scripts/ version-sync script, run by `pnpm sync-version`; `release- .changeset/ Changesets config and pending release notes (`.changeset/.md`) skills/ the usage skill, `skills/worktree/SKILL.md`; hand-written, shipped inside the npm package (package.json `files`) and installable with `npx skills add`. Nothing on npm discovers it since TanStack Intent went (`skills add` reads GitHub); it stays in `files` so an `npm i -g` install has a copy matching its own version on disk docs/ Astro 7 + Starlight docs site, React 19 islands, Base UI; own package.json, `astro.config.mjs` -docs/src/content/docs/ Starlight pages (29 pages: `index.mdx` is the landing at `/worktree/`, `getting-started.mdx` is Getting Started at `/worktree/getting-started/`, plus `commands/` (9 command pages and an index), `guides/` (12 guides and an index), `configuration`, `project-configuration`, `faq` and `changelog`) +docs/src/content/docs/ Starlight pages (30 pages: `index.mdx` is the landing at `/worktree/`, `getting-started.mdx` is Getting Started at `/worktree/getting-started/`, plus `commands/` (10 command pages and an index), `guides/` (12 guides and an index), `configuration`, `project-configuration`, `faq` and `changelog`) docs/src/ chat client, site metadata, styles; the chat is the page `/dox` (`pages/dox.astro`, one React island, `chat/components/DoxPage.tsx`), reached by plain links only: the header's "Chat with Dox" crystal (`components/Header.astro`, repeated in the mobile menu by `components/MobileMenuFooter.astro`) and the landing's "Ask Dox" (`components/Hero.astro`); `components/DoxMark.astro` draws the crystal, and no page but `/dox` loads chat code; the header's right group ends with the settings gear (`components/SettingsControl.astro`, wired by `lib/settings-control.ts`: a native `[popover]` holding the "Dark theme" switch, whose rule is `lib/theme.ts`; it shows at every width, below 50rem as the only chip of the right group that does, and the mobile menu has no copy); sound is `lib/sound/` (GMT's engine, cut down: `settings.ts` is the reader's choice in the `dox:sound` key shared with GMT and northguild.dev, `cue.ts` is loaded on every page by `components/Head.astro`, and the engine is a chunk only its dynamic `import()` reaches, once a reader has unmuted, and on the landing alone it imports `lib/sound/leaves.ts`, the leaves' voices, driven by the last landing and the sampled landing places `hero/flight.ts` computes, only while sound is on, from the particles' own timings; no press makes a sound but the chat's Send and "Try again"); `components/Hero.astro` puts the landing's copy beside `HeroLeaves.astro` (the leaf-particle hero: a still SVG, a canvas and a small loader script; the effect itself, in `hero/` with OGL, is a chunk only the loader's dynamic `import()` reaches, so the landing alone ships hero script; its CSS is in the shared stylesheet); the share cards are made in the build: `pages/og/[...route].ts` writes `dist/og/site.png` and one PNG per page, `lib/og-cards.ts` decides the cards and their alt text, `lib/og-art.ts` draws one with CanvasKit (`lib/og-canvaskit.ts` loads it) over the committed `assets/og-art.png` in the Michroma TTF of `assets/og-fonts/`, `components/Head.astro` writes each page's share tags, and `lib/og-image-version.ts` is the integration that appends `?v=` to them after the build docs/src/styles/northguild/ the NorthGuild theme, vendored unedited from `northguild/northguild.dev` `packages/theme/` (each file's header names the commit); `docs/src/styles/theme.css` is this site's own `--gmt-*` → `--sl-*` mapping. To refresh, see `docs/README.md` (Theme) docs/wrangler.jsonc the docs site's Worker config (assets from `docs/.deploy`, the build staged under `worktree/` and `docs/deploy/_headers` at its root by `stage:deploy`); `docs/scripts/` holds `audit-dist.mjs`, `build-og-art.mjs` (draws the share cards' art into `docs/src/assets/og-art.png` by hand, never in the build), `theme-contrast.mjs` (measures the theme's contrast pairs), `build-legacy-pages.mjs` (writes the gitignored `docs/legacy/`), `deploy-smoke.mjs` and `web-vitals.mjs` (measures Core Web Vitals by hand, not a gate) @@ -86,7 +86,7 @@ untrue on one of these surfaces is fixed by the phase that makes it untrue, not | Surface | Who reads it | What has to reach it | |---|---|---| | [`README.md`](../README.md) | someone deciding whether to install; npm renders it as the package page | the fast path — a new command, a renamed flag, a change to what the tool is for | -| `docs/src/content/docs/` | users looking something up, at https://northguild.dev/worktree/ | any user-visible CLI behaviour. One page per command under `commands/` (9), plus `configuration.mdx`, `project-configuration.mdx`, `index.mdx` (the landing), `getting-started.mdx`, `faq.mdx`, and `guides/` (12) | +| `docs/src/content/docs/` | users looking something up, at https://northguild.dev/worktree/ | any user-visible CLI behaviour. One page per command under `commands/` (10), plus `configuration.mdx`, `project-configuration.mdx`, `index.mdx` (the landing), `getting-started.mdx`, `faq.mdx`, and `guides/` (12) | | [`docs/README.md`](../docs/README.md) | someone working on the docs app | how the docs app is run or built | | [`docs/worker/README.md`](../docs/worker/README.md) | someone working on the chat proxy | the Worker's routes, secrets or deploy | | [`docs/evals/README.md`](../docs/evals/README.md) | someone changing the Dox chat's docs, retrieval or prompt, or adding an eval case | how the offline evals run, how `baseline.json` is rewritten, how a case is added, and how to run the live evals, what they cost and which changes need a live run | diff --git a/context/verify.md b/context/verify.md index bafdc71..a168c86 100644 --- a/context/verify.md +++ b/context/verify.md @@ -101,19 +101,19 @@ pnpm docs:audit-dist ``` Runs after `pnpm docs:build` (Build above), because it reads `docs/dist/`; with no build it exits 1 saying it -cannot audit the directory (ENOENT). It asserts the SEO requirements of #235 over the built site: on each of the 29 pages a +cannot audit the directory (ENOENT). It asserts the SEO requirements of #235 over the built site: on each of the 30 pages a unique meta description of at most 155 characters, one canonical link in the form `https://northguild.dev/worktree//`, Open Graph and Twitter tags, JSON-LD of the right types, and a "Last updated" date equal to `git log --follow -1` for the page's source file (as a UTC date) — except the landing, which has no footer and so must carry no date; no page may carry an "Edit page" link into GitHub's editor (removed 2026-11-04; gmt's docs have none); no page may carry the project line the footer once had (licence, CLI version, maintainers); no page may show the northguild organisation's GitHub avatar (`github.com/northguild.png`), the second logo the footer once had, and no id may appear -twice on a page; across the site, a sitemap and an `llms.txt` (llmstxt.org format) each listing exactly those 29 +twice on a page; across the site, a sitemap and an `llms.txt` (llmstxt.org format) each listing exactly those 30 URLs, a `404.html` (with the site's search, a link to Getting Started at `/worktree/getting-started/`, and no canonical link or JSON-LD), a landing at the root (a heading, a "Get started" link to `/worktree/getting-started/`, one "Ask Dox" link to `/worktree/dox/` and no "Ask Dox" button, no second action and no section below the hero; the root alone may carry the site default description), and no `shuding/nextra` string. The date rule is only meaningful on full git history (CI uses `fetch-depth: 0`): on a shallow clone Starlight and the oracle both read the same truncated log. A page whose source file has no commit yet (a new or just-renamed one) fails the date rule with "no git history", so run the audit after committing it. It prints every failed rule, one line each, and exits 1 on any. To run it by hand: `pnpm docs:build && pnpm docs:audit-dist`, or point it at another build with `node docs/scripts/audit-dist.mjs `. It also checks accessible names on every page and the 404 (each button named, a name beside visible text containing it, each `