diff --git a/.changeset/quiet-trackers-name.md b/.changeset/quiet-trackers-name.md new file mode 100644 index 00000000..293d85f1 --- /dev/null +++ b/.changeset/quiet-trackers-name.md @@ -0,0 +1,5 @@ +--- +"@northguild/worktree": minor +--- + +Added `--issue`, which names a branch from your own issue tracker through a command you configure as `issueProvider`; `--assign` and `--start` work through it too. diff --git a/README.md b/README.md index 5d6ef6cc..bec2e81c 100644 --- a/README.md +++ b/README.md @@ -95,10 +95,12 @@ The setup flow can configure: - `postCreate` for a command to run in each new worktree, such as `pnpm install` (otherwise the steps in `.worktree.yml`, which you approve first with `worktree config --approve`, then the steps in your user config file, else inferred from the lockfile) - `linear.agentToken`, `linear.webhookSecret`, `linear.agentAllow` and `linear.agentContext` for a Linear agent that starts worktrees: the app's OAuth token and the webhook signing secret (both secret, shown as `***` by `worktree config --list`), the Linear user ids allowed to delegate an issue to it, and `true` to also hand the issue's text to the agent (off by default). `worktree linear-listen` reads them; the wizard never asks for any of them, and a `.worktree.yml` cannot set them +The wizard never asks for `issueProvider.command`, the command that reads issues from your own tracker; set it by name, such as `worktree config issueProvider.command "verk-provider --json"` (from a `.worktree.yml` it needs your approval first, with `worktree config --approve`; from your git config or user config file it needs none). + A repository can also commit a `.worktree.yml` that supplies the team's `defaultSourceBranch`, `branchPrefix.*`, -`jira.host`, `jira.deployment`, `clickup.workspaceId`, `github.repository` and `github.host`, read from the default branch; your own git config overrides it. The +`jira.host`, `jira.deployment`, `clickup.workspaceId`, `github.repository`, `github.host`, `issueProvider.name` and `issueProvider.command`, read from the default branch; your own git config overrides it. The wizard skips what the file answers, `worktree config --list` marks each value `(.worktree.yml)` or -`(overrides .worktree.yml: )`, and `worktree config --project` writes a `.worktree.yml` from the +`(overrides .worktree.yml: )` (an `issueProvider.name` is read from the same place as its command, so one from another place is listed as not in effect), and `worktree config --project` writes a `.worktree.yml` from the team keys in your git config (never a personal or secret one), uncommitted. See [Project Configuration](https://northguild.dev/worktree/project-configuration/). @@ -106,7 +108,7 @@ A user config file, `~/.config/worktree/config.yml` (or `$XDG_CONFIG_HOME/worktr `WORKTREE_USER_CONFIG`), holds your personal keys and a fallback for the team keys, for every repository; write it with `worktree config --user `. It ranks below `.worktree.yml`: the order is a flag, git config, `.worktree.yml`, the user file, then the built-in default. `worktree config --list` marks its values -`(user config)` or `(overrides user config: )`, and `worktree config ` prints the resolved value. A +`(user config)` or `(overrides user config: )`, and `worktree config ` prints the resolved value (for `issueProvider.name`, the one in effect). A secret in it is refused with exit `2`. Its `postCreate` steps run without approval, so keep the file as private as a shell profile, and mind what a dotfiles sync carries into it. See [Configuration](https://northguild.dev/worktree/configuration/#user-config-file). @@ -273,7 +275,7 @@ worktree help branch Configuration is stored in Git config under the `northguild.worktree.*` namespace. A committed `.worktree.yml` can supply the team keys (`defaultSourceBranch`, `branchPrefix.*`, `jira.host`, `jira.deployment`, -`clickup.workspaceId`, `github.repository`, `github.host`); your git config wins over it, and it wins over your user config file and the built-in default. A file's +`clickup.workspaceId`, `github.repository`, `github.host`, `issueProvider.name`, `issueProvider.command`); your git config wins over it, and it wins over your user config file and the built-in default. A file's `jira.host` receives every teammate's Jira credentials, so review a change to it like code. See [Project Configuration](https://northguild.dev/worktree/project-configuration/). @@ -330,26 +332,28 @@ line, `worktree: no default for ; pass `. | `--no-open` | `branch` | create the worktree and print its path; call none of Herdr, Rex or the editor | | `--no-agent` | `branch` | open as usual, start no agent | | `--install` / `--no-install` | `branch` | force the dependency install on or off for this run | -| `--assign` / `--no-assign` | `branch` | assign the `--github`, `--jira` or `--clickup` issue to you, or not (a Jira issue someone else holds is left alone; a ClickUp task keeps its other assignees) | -| `--start` / `--no-start` | `branch` | move the `--linear` issue to its team's started state, the `--clickup` task to its List's first in-progress status, or the `--jira` issue through its workflow's in-progress transition (the one to the status named In Progress where there are several), once the worktree exists, or not; only a backlog or unstarted Linear issue, an open-status ClickUp task and a Jira issue in the To Do category move (one already in progress is reported, a finished one is left alone, and a Jira workflow with no in-progress status, or several with none named In Progress, is left alone with a warning), and it needs a key with the Write permission (Linear), edit access to the task (ClickUp) or the Transition Issues permission (Jira); a `--start` with no issue flag exits `2` | +| `--issue ` (`-i`) | `branch` | name the branch from an issue in your own tracker: runs the `issueProvider.command` you configured, passes it the reference on stdin and reads the issue it prints; a command from `.worktree.yml` needs your approval first; cannot be combined with `--github`, `--jira`, `--linear` or `--clickup` | +| `--assign` / `--no-assign` | `branch` | assign the `--github`, `--jira` or `--clickup` issue to you, or not (a Jira issue someone else holds is left alone; a ClickUp task keeps its other assignees); with `--issue` it asks your provider, when the provider says it can assign, and warns and does nothing when it cannot | +| `--start` / `--no-start` | `branch` | move the `--linear` issue to its team's started state, the `--clickup` task to its List's first in-progress status, or the `--jira` issue through its workflow's in-progress transition (the one to the status named In Progress where there are several), once the worktree exists, or not; only a backlog or unstarted Linear issue, an open-status ClickUp task and a Jira issue in the To Do category move (one already in progress is reported, a finished one is left alone, and a Jira workflow with no in-progress status, or several with none named In Progress, is left alone with a warning), and it needs a key with the Write permission (Linear), edit access to the task (ClickUp) or the Transition Issues permission (Jira); a `--start` with no issue flag exits `2`; with `--issue` it asks your provider, when the provider says it can start an issue, and warns and does nothing when it cannot | | `--linear` with no identifier | `branch` | list your own unstarted and started Linear issues (title and state, escaped) and pick one, then carry on as if you had typed its identifier; it needs a terminal, so `--json`, `--yes`, `--non-interactive`, CI, no terminal and `--dry-run` refuse with exit `2` and `missing_value` before any request | | `--dry-run` | `branch` | with an issue flag (a `--linear` needs its identifier): print the branch name, the rule behind its prefix and the issue's fields with ids and paste-ready `when:` lines, and create, assign, save and ask nothing; `--json` prints its own document (`dryRun`, `branch`, `issue`, `kind`, `match`, `fields`, `warnings`) | | `-f`, `--force` | `remove` | skip the confirmation; required when non-interactive | ### Defaults when non-interactive -- **Branch name** from `--github`: by default `-` (a `branchName` template in `.worktree.yml` changes the shape), the slug cut to 48 characters at the last dash. +- **Branch name** from `--github` (or `--issue`, whose provider supplies the key and title): by default `-` (a `branchName` template in `.worktree.yml` changes the shape), the slug cut to 48 characters at the last dash. With no issue, the name is required. -- **Assignment:** `--assign`/`--no-assign`, then `github.autoAssign`, `jira.autoAssign` or `clickup.autoAssign`, then assign. The default is never saved. -- **Start (Linear, ClickUp, Jira):** `--start`/`--no-start`, then `linear.autoStart`, `clickup.autoStart` or `jira.autoStart`, then start: a non-interactive `--linear` run moves a backlog or unstarted issue to started, a non-interactive `--clickup` run moves an open-status task to the List's first in-progress status, and a non-interactive `--jira` run moves a To Do issue to its in-progress status, unless `--no-start` or the key is `false`. The default is never saved, and a failed move warns and changes no exit code. +- **Assignment:** `--assign`/`--no-assign`, then `github.autoAssign`, `jira.autoAssign`, `clickup.autoAssign` or `issueProvider.autoAssign`, then assign. The default is never saved. +- **Start (Linear, ClickUp, Jira, your provider):** `--start`/`--no-start`, then `linear.autoStart`, `clickup.autoStart`, `jira.autoStart` or `issueProvider.autoStart`, then start: a non-interactive `--linear` run moves a backlog or unstarted issue to started, a non-interactive `--clickup` run moves an open-status task to the List's first in-progress status, and a non-interactive `--jira` run moves a To Do issue to its in-progress status, unless `--no-start` or the key is `false`. The default is never saved, and a failed move warns and changes no exit code. - **Install:** on. The command is your `postCreate`, else the steps under `postCreate` in `.worktree.yml`, else the steps in your user config file (no approval), else inferred from the lockfile (`pnpm-lock.yaml`, `package-lock.json`, `yarn.lock`, `bun.lock`). Steps from the file need your approval first; unapproved, a non-interactive run exits `2` (`missing_value`) before anything is created, naming `worktree config --approve` (in a terminal) and `--no-install`. It never prints a value to approve with. With nothing to run it says so and carries on. A failure keeps the worktree, starts nothing and exits `1`. +- **Issue provider command:** a command from `.worktree.yml` runs only once you have approved that exact command line, with `worktree config --approve` in a terminal. Unapproved, a non-interactive run and `--dry-run` exit `2` (`missing_value`) before the provider starts, naming `worktree config --approve` and printing no value to approve with. A command from your git config or user config file needs no approval. - **Source branch:** `defaultSourceBranch` (git config, else `.worktree.yml`, else your user config file), else `origin/main` with a warning. - **Removal** has no default: `remove -f`. -- **Bounded calls:** GitHub, Jira, Linear and ClickUp requests 15 s, `git fetch` 60 s, `gh auth token` and the session listing +- **Bounded calls:** GitHub, Jira, Linear and ClickUp requests 15 s, an `--issue` provider call 15 s (and at most 1 MiB of output), `git fetch` 60 s, `gh auth token` and the session listing 10 s, the install 10 min. A command still running at its bound is sent SIGTERM, then SIGKILL 2 s later, so one that ignores SIGTERM cannot hold the run open. @@ -373,8 +377,8 @@ worktree branch --github 42 --json --agent-file brief.md "warnings":[]} ``` -- `issue` is `{provider:"github",number,url}`, `{provider:"jira",key,url}`, `{provider:"linear",key,url}`, `{provider:"clickup",key,url}`, or `null`. -- `assigned` is `true` when the issue is yours after the run, `false` when it is not (the attempt failed, a Jira issue is held by someone else, or Jira does not show a Jira issue's assignee), and `null` when no assignment was attempted. `started` is `true` when the `--linear` issue, `--clickup` task or `--jira` issue is in a started state after the run (moved, or already there), `false` when it is not (left alone, no started state to move to, or the attempt failed), and `null` when none was attempted. `herdr`, `rex` and `agent` are `null` when skipped (`rex` is `{session,block}`, with `block` `null` when the session was found rather than reported by `rex new`: one that was already open, or one whose `rex new` timed out and turned up after; `agent` says whether an agent started), and +- `issue` is `{provider:"github",number,url}`, `{provider:"jira",key,url}`, `{provider:"linear",key,url}`, `{provider:"clickup",key,url}`, `{provider:"custom",name,key,url}` (`--issue`; `name` is `issueProvider.name` or `null`), or `null`. +- `assigned` is `true` when the issue is yours after the run (assigned, or already yours), `false` when it is not (the attempt failed, an issue is held by someone else, or Jira does not show a Jira issue's assignee), and `null` when no assignment was attempted (no issue, `--no-assign`, a configured `false`, or a `--issue` provider that does not assign). `started` is `true` when the `--linear` issue, `--clickup` task, `--jira` issue or `--issue` issue is in a started state after the run (moved, or already there), `false` when it is not (left alone, no started state to move to, or the attempt failed), and `null` when none was attempted (no issue flag that starts, `--no-start`, a configured `false`, a `--issue` provider that does not start, or a declined prompt). `herdr`, `rex` and `agent` are `null` when skipped (`rex` is `{session,block}`, with `block` `null` when the session was found rather than reported by `rex new`: one that was already open, or one whose `rex new` timed out and turned up after; `agent` says whether an agent started), and `agent.command` leaves the brief out. `agent.name` is `null` where this CLI named nothing (a detached start). - `installed` is `{ran:false,reason}` when skipped. `steps` are the commands that ran, in order; `command` is the one that failed, else the last that ran; `from` is `"git-config"`, `"project"`, `"user"` or `"lockfile"`. A failed install still prints the whole document, with @@ -533,3 +537,4 @@ MIT - [x] Integrate with JIRA for automated branch naming - [x] Integrate with Linear for automated branch naming - [x] Integrate with ClickUp for automated branch naming +- [x] Integrate with your own issue tracker through a custom issue provider command (`--issue`; the [guide](https://northguild.dev/worktree/guides/custom-issue-provider/) is its contract) diff --git a/context/stack.md b/context/stack.md index 7806e4b4..88024a45 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 (28 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/` (11 guides and an index), `configuration`, `project-configuration`, `faq` and `changelog`) +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/ 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) 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`, `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) @@ -84,7 +84,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/` (11) | +| `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/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 | | `skills/worktree/SKILL.md` | agents that install the skill with `npx skills add`; shipped in the npm package; its sections are also the docs chat's vocabulary, searched per question | a command or flag change that the skill describes — **but see the caveat below** | diff --git a/context/verify.md b/context/verify.md index 7fe890b4..dfd0377c 100644 --- a/context/verify.md +++ b/context/verify.md @@ -100,19 +100,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 28 pages a +cannot audit the directory (ENOENT). It asserts the SEO requirements of #235 over the built site: on each of the 29 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 28 +twice on a page; across the site, a sitemap and an `llms.txt` (llmstxt.org format) each listing exactly those 29 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 `