diff --git a/.agents/README.md b/.agents/README.md new file mode 100644 index 00000000..d0da12f0 --- /dev/null +++ b/.agents/README.md @@ -0,0 +1,10 @@ +# Agent tooling + +Vendored skills live in `.agents/skills/`; invoke as each skill's frontmatter allows: + +- `code-review` — review since a fixed point, Standards + Spec axes. +- `documentation-writer` — every docs/prose task. +- `emil-design-eng` — building or reviewing UI. +- `visual-pr` — PR bodies (policy in `AGENTS.md`). +- `to-spec`, `to-tickets`, `triage`, `wayfinder` — tracker-backed workflow (see `docs/agents/issue-tracker.md`). +- `review-animations` — reviewing motion code; defaults to flagging. diff --git a/.agents/skills/setup-matt-pocock-skills/SKILL.md b/.agents/skills/setup-matt-pocock-skills/SKILL.md deleted file mode 100644 index 7f6f576e..00000000 --- a/.agents/skills/setup-matt-pocock-skills/SKILL.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -name: setup-matt-pocock-skills -description: "Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills." -disable-model-invocation: true ---- - -# Setup Matt Pocock's Skills - -Scaffold the per-repo configuration that the engineering skills assume: - -- **Issue tracker**: where issues live (GitHub by default; local markdown is also supported out of the box) -- **Triage labels**: the strings used for the five canonical triage roles -- **Domain docs**: where `CONTEXT.md` and ADRs live, and the consumer rules for reading them - -This is a prompt-driven skill, not a deterministic script. Explore, present what you found, confirm with the user, then write. - -## Process - -### 1. Explore - -Look at the current repo to understand its starting state. Read whatever exists; don't assume: - -- `git remote -v` and `.git/config`: is this a GitHub repo? Which one? -- `AGENTS.md` and `CLAUDE.md` at the repo root: does either exist? Is there already an `## Agent skills` section in either? -- `CONTEXT.md` and `CONTEXT-MAP.md` at the repo root -- `docs/adr/` and any `src/*/docs/adr/` directories -- `docs/agents/`: does this skill's prior output already exist? -- `.scratch/`: a sign that a local-markdown issue tracker convention is already in use -- Is the `triage` skill installed? (a `triage` skill folder alongside this one, or `triage` in your available skills.) This decides whether Section B runs at all. -- Monorepo signals: a `pnpm-workspace.yaml`, a `workspaces` field in `package.json`, or a populated `packages/*` with its own `src/`. These are present only in a genuinely large multi-package repo; their absence means single-context, which is almost every repo. - -### 2. Present findings and ask - -Summarise what's present and what's missing. Then take the sections in order. One section, one answer, then the next. - -Lead each section with the recommended answer so the user can accept it in a word. Give a one-line explainer only when the choice genuinely branches; skip the section entirely when exploration already settled it (Section B when `triage` isn't installed, Section C when there's no monorepo). - -**Section A: Issue tracker.** - -> Explainer: The "issue tracker" is where issues live for this repo. Skills like `to-tickets`, `triage`, and `to-spec` read from and write to it. They need to know whether to call `gh issue create`, write a markdown file under `.scratch/`, or follow some other workflow you describe. Pick the place you actually track work for this repo. - -Default posture: these skills were designed for GitHub. If a `git remote` points at GitHub, propose that. If a `git remote` points at GitLab (`gitlab.com` or a self-hosted host), propose GitLab. Otherwise (or if the user prefers), offer: - -- **GitHub**: issues live in the repo's GitHub Issues (uses the `gh` CLI) -- **GitLab**: issues live in the repo's GitLab Issues (uses the [`glab`](https://gitlab.com/gitlab-org/cli) CLI) -- **Local markdown**: issues live as files under `.scratch//` in this repo (good for solo projects or repos without a remote) -- **Other** (Jira, Linear, etc.): ask the user to describe the workflow in one paragraph; the skill will record it as freeform prose - -Record the choice in `docs/agents/issue-tracker.md`. The GitHub and GitLab templates carry a "PRs as a request surface" flag, defaulted **off**. Leave it off and don't raise it: a user who wants external PRs in the triage queue can flip the flag in the file later. - -**Section B: Triage label vocabulary.** Skip this section entirely if the `triage` skill isn't installed (exploration told you), since an uninstalled skill needs no labels. - -If it is installed, ask exactly one question: - -> Do you want to keep the default triage labels? (recommended: **yes**) - -The defaults are the five canonical roles, each label string equal to its name: `needs-triage`, `needs-info`, `ready-for-agent`, `ready-for-human`, `wontfix`. On **yes**, write them as-is. Only if the user says no, usually because their tracker already uses other names (e.g. `bug:triage` for `needs-triage`), collect the overrides so `triage` applies existing labels instead of creating duplicates. - -**Section C: Domain docs.** Default to **single-context** (one `CONTEXT.md` + `docs/adr/` at the repo root). This fits almost every repo; write it without asking. - -Offer **multi-context** (a root `CONTEXT-MAP.md` pointing to per-context `CONTEXT.md` files) only when exploration found monorepo signals. Then confirm which layout they want. - -### 3. Confirm and edit - -Show the user a draft of: - -- The `## Agent skills` block to add to whichever of `CLAUDE.md` / `AGENTS.md` is being edited (see step 4 for selection rules) -- The contents of `docs/agents/issue-tracker.md`, `docs/agents/domain.md`, and `docs/agents/triage-labels.md` (the last only when `triage` is installed) - -Let them edit before writing. - -### 4. Write - -**Pick the file to edit:** - -- If `CLAUDE.md` exists, edit it. -- Else if `AGENTS.md` exists, edit it. -- If neither exists, ask the user which one to create; don't pick for them. - -Never create `AGENTS.md` when `CLAUDE.md` already exists (or vice versa); always edit the one that's already there. - -If an `## Agent skills` block already exists in the chosen file, update its contents in-place rather than appending a duplicate. Don't overwrite user edits to the surrounding sections. - -The block: - -```markdown -## Agent skills - -### Issue tracker - -[one-line summary of where issues are tracked]. See `docs/agents/issue-tracker.md`. - -### Triage labels - -[one-line summary of the label vocabulary]. See `docs/agents/triage-labels.md`. - -### Domain docs - -[one-line summary of layout: "single-context" or "multi-context"]. See `docs/agents/domain.md`. -``` - -Include the `### Triage labels` sub-block, and write `docs/agents/triage-labels.md`, only when `triage` is installed and Section B ran. When it isn't, both are omitted. - -Then write the docs files using the seed templates in this skill folder as a starting point: - -- [issue-tracker-github.md](./issue-tracker-github.md): GitHub issue tracker -- [issue-tracker-gitlab.md](./issue-tracker-gitlab.md): GitLab issue tracker -- [issue-tracker-local.md](./issue-tracker-local.md): local-markdown issue tracker -- [triage-labels.md](./triage-labels.md): label mapping (only if `triage` is installed) -- [domain.md](./domain.md): domain doc consumer rules + layout - -For "other" issue trackers, write `docs/agents/issue-tracker.md` from scratch using the user's description. - -### 5. Done - -Tell the user the setup is complete and which engineering skills will now read from these files. Mention they can edit `docs/agents/*.md` directly later; re-running this skill is only necessary if they want to switch issue trackers or restart from scratch. diff --git a/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml b/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml deleted file mode 100644 index 65a0da81..00000000 --- a/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml +++ /dev/null @@ -1,5 +0,0 @@ -interface: - display_name: "Setup Matt Pocock Skills" - short_description: "Configure a repo for the skills" -policy: - allow_implicit_invocation: false diff --git a/.agents/skills/setup-matt-pocock-skills/domain.md b/.agents/skills/setup-matt-pocock-skills/domain.md deleted file mode 100644 index 35249041..00000000 --- a/.agents/skills/setup-matt-pocock-skills/domain.md +++ /dev/null @@ -1,51 +0,0 @@ -# Domain Docs - -How the engineering skills should consume this repo's domain documentation when exploring the codebase. - -## Before exploring, read these - -- **`CONTEXT.md`** at the repo root, or -- **`CONTEXT-MAP.md`** at the repo root if it exists: it points at one `CONTEXT.md` per context. Read each one relevant to the topic. -- **`docs/adr/`**: read ADRs that touch the area you're about to work in. In multi-context repos, also check `src//docs/adr/` for context-scoped decisions. - -If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The `/domain-modeling` skill (reached via `/grill-with-docs` and `/improve-codebase-architecture`) creates them lazily when terms or decisions actually get resolved. - -## File structure - -Single-context repo (most repos): - -``` -/ -├── CONTEXT.md -├── docs/adr/ -│ ├── 0001-event-sourced-orders.md -│ └── 0002-postgres-for-write-model.md -└── src/ -``` - -Multi-context repo (presence of `CONTEXT-MAP.md` at the root): - -``` -/ -├── CONTEXT-MAP.md -├── docs/adr/ ← system-wide decisions -└── src/ - ├── ordering/ - │ ├── CONTEXT.md - │ └── docs/adr/ ← context-specific decisions - └── billing/ - ├── CONTEXT.md - └── docs/adr/ -``` - -## Use the glossary's vocabulary - -When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `CONTEXT.md`. Don't drift to synonyms the glossary explicitly avoids. - -If the concept you need isn't in the glossary yet, that's a signal: either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/domain-modeling`). - -## Flag ADR conflicts - -If your output contradicts an existing ADR, surface it explicitly rather than silently overriding: - -> _Contradicts ADR-0007 (event-sourced orders), but worth reopening because…_ diff --git a/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md b/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md deleted file mode 100644 index b258aeb3..00000000 --- a/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +++ /dev/null @@ -1,45 +0,0 @@ -# Issue tracker: GitHub - -Issues and specs for this repo live as GitHub issues. Use the `gh` CLI for all operations. - -## Conventions - -- **Create an issue**: `gh issue create --title "..." --body "..."`. Use a heredoc for multi-line bodies. -- **Read an issue**: `gh issue view --comments`, filtering comments by `jq` and also fetching labels. -- **List issues**: `gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'` with appropriate `--label` and `--state` filters. -- **Comment on an issue**: `gh issue comment --body "..."` -- **Apply / remove labels**: `gh issue edit --add-label "..."` / `--remove-label "..."` -- **Close**: `gh issue close --comment "..."` - -Infer the repo from `git remote -v`; `gh` does this automatically when run inside a clone. - -## Pull requests as a triage surface - -**PRs as a request surface: no.** _(Set to `yes` if this repo treats external PRs as feature requests; `/triage` reads this flag.)_ - -When set to `yes`, PRs run through the same labels and states as issues, using the `gh pr` equivalents: - -- **Read a PR**: `gh pr view --comments` and `gh pr diff ` for the diff. -- **List external PRs for triage**: `gh pr list --state open --json number,title,body,labels,author,authorAssociation,comments` then keep only `authorAssociation` of `CONTRIBUTOR`, `FIRST_TIME_CONTRIBUTOR`, or `NONE` (drop `OWNER`/`MEMBER`/`COLLABORATOR`). -- **Comment / label / close**: `gh pr comment`, `gh pr edit --add-label`/`--remove-label`, `gh pr close`. - -GitHub shares one number space across issues and PRs, so a bare `#42` may be either: resolve with `gh pr view 42` and fall back to `gh issue view 42`. - -## When a skill says "publish to the issue tracker" - -Create a GitHub issue. - -## When a skill says "fetch the relevant ticket" - -Run `gh issue view --comments`. - -## Wayfinding operations - -Used by `/wayfinder`. The **map** is a single issue with **child** issues as tickets. - -- **Map**: a single issue labelled `wayfinder:map`, holding the Notes / Decisions-so-far / Fog body. `gh issue create --label wayfinder:map`. -- **Child ticket**: an issue linked to the map as a GitHub sub-issue (`gh api` on the sub-issues endpoint). Where sub-issues aren't enabled, add the child to a task list in the map body and put `Part of #` at the top of the child body. Labels: `wayfinder:` (`research`/`prototype`/`grilling`/`task`). Once claimed, the ticket is assigned to the driving dev. -- **Blocking**: GitHub's **native issue dependencies**, the canonical, UI-visible representation. Add an edge with `gh api --method POST repos///issues//dependencies/blocked_by -F issue_id=`, where `` is the blocker's numeric **database id** (`gh api repos///issues/ --jq .id`, _not_ the `#number` or `node_id`). GitHub reports `issue_dependencies_summary.blocked_by` (open blockers only, the live gate). Where dependencies aren't available, fall back to a `Blocked by: #, #` line at the top of the child body. A ticket is unblocked when every blocker is closed. -- **Frontier query**: list the map's open children (`gh issue list --state open`, scoped to the map's sub-issues / task list), drop any with an open blocker (`issue_dependencies_summary.blocked_by > 0`, or an open issue in the `Blocked by` line) or an assignee; first in map order wins. -- **Claim**: `gh issue edit --add-assignee @me`, the session's first write. -- **Resolve**: `gh issue comment --body ""`, then `gh issue close `, then append a context pointer (gist + link) to the map's Decisions-so-far. diff --git a/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md b/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md deleted file mode 100644 index 251035a6..00000000 --- a/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +++ /dev/null @@ -1,46 +0,0 @@ -# Issue tracker: GitLab - -Issues and specs for this repo live as GitLab issues. Use the [`glab`](https://gitlab.com/gitlab-org/cli) CLI for all operations. - -## Conventions - -- **Create an issue**: `glab issue create --title "..." --description "..."`. Use a heredoc for multi-line descriptions. Pass `--description -` to open an editor. -- **Read an issue**: `glab issue view --comments`. Use `-F json` for machine-readable output. -- **List issues**: `glab issue list -F json` with appropriate `--label` filters. -- **Comment on an issue**: `glab issue note --message "..."`. GitLab calls comments "notes". -- **Apply / remove labels**: `glab issue update --label "..."` / `--unlabel "..."`. Multiple labels can be comma-separated or by repeating the flag. -- **Close**: `glab issue close `. `glab issue close` does not accept a closing comment, so post the explanation first with `glab issue note --message "..."`, then close. -- **Merge requests**: GitLab calls PRs "merge requests". Use `glab mr create`, `glab mr view`, `glab mr note`, etc., the same shape as `gh pr ...` with `mr` in place of `pr` and `note`/`--message` in place of `comment`/`--body`. - -Infer the repo from `git remote -v`; `glab` does this automatically when run inside a clone. - -## Merge requests as a triage surface - -**MRs as a request surface: no.** _(Set to `yes` if this repo treats external merge requests as feature requests; `/triage` reads this flag.)_ - -When set to `yes`, MRs run through the same labels and states as issues, using the `glab mr` equivalents: - -- **Read an MR**: `glab mr view --comments` and `glab mr diff ` for the diff. -- **List external MRs for triage**: `glab mr list -F json`, then keep only MRs whose author is not a project member/owner (a contributor's MR, not a maintainer's in-flight work). -- **Comment / label / close**: `glab mr note`, `glab mr update --label`/`--unlabel`, `glab mr close`. - -Unlike GitHub, GitLab numbers issues and MRs separately, so `#42` is unambiguous once you know which surface the maintainer means. - -## When a skill says "publish to the issue tracker" - -Create a GitLab issue. - -## When a skill says "fetch the relevant ticket" - -Run `glab issue view --comments`. - -## Wayfinding operations - -Used by `/wayfinder`. The **map** is a single issue with **child** issues as tickets. - -- **Map**: a single issue labelled `wayfinder:map`, holding the Notes / Decisions-so-far / Fog body. `glab issue create --label wayfinder:map`. (On GitLab tiers with native epics, an epic may hold the map instead; a labelled issue works everywhere.) -- **Child ticket**: an issue carrying `Part of #` at the top of its description and labels `wayfinder:` (`research`/`prototype`/`grilling`/`task`). Once claimed, the ticket is assigned to the driving dev. -- **Blocking**: GitLab's **native blocking link**, the canonical, UI-visible representation. Add it with the `/blocked_by #` quick action, posted as a note (`glab issue note --message "/blocked_by #"`). Native blocking links are a Premium/Ultimate feature; on the free tier (or where unavailable) fall back to a `Blocked by: #, #` line at the top of the description. A ticket is unblocked when every blocker is closed. -- **Frontier query**: `glab issue list -F json` scoped to the map's children, drop any with an open blocker: a native `blocked_by` link to an open issue (`glab api projects/:id/issues/:iid/links`), or an open issue in the `Blocked by` line, or an assignee; first in map order wins. -- **Claim**: `glab issue update --assignee @me`, the session's first write. -- **Resolve**: `glab issue note --message ""`, then `glab issue close `, then append a context pointer (gist + link) to the map's Decisions-so-far. diff --git a/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md b/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md deleted file mode 100644 index 0209a19a..00000000 --- a/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +++ /dev/null @@ -1,30 +0,0 @@ -# Issue tracker: Local Markdown - -Issues and specs for this repo live as markdown files in `.scratch/`. - -## Conventions - -- One feature per directory: `.scratch//` -- The spec is `.scratch//spec.md` -- Implementation issues are one file per ticket at `.scratch//issues/-.md`, numbered from `01`, never a single combined tickets file -- Triage state is recorded as a `Status:` line near the top of each issue file (see `triage-labels.md` for the role strings) -- Comments and conversation history append to the bottom of the file under a `## Comments` heading - -## When a skill says "publish to the issue tracker" - -Create a new file under `.scratch//` (creating the directory if needed). - -## When a skill says "fetch the relevant ticket" - -Read the file at the referenced path. The user will normally pass the path or the issue number directly. - -## Wayfinding operations - -Used by `/wayfinder`. The **map** is a file with one **child** file per ticket. - -- **Map**: `.scratch//map.md` (the Notes / Decisions-so-far / Fog body). -- **Child ticket**: `.scratch//issues/NN-.md`, numbered from `01`, with the question in the body. A `Type:` line records the ticket type (`research`/`prototype`/`grilling`/`task`); a `Status:` line records `claimed`/`resolved`. -- **Blocking**: a `Blocked by: NN, NN` line near the top. A ticket is unblocked when every file it lists is `resolved`. -- **Frontier**: scan `.scratch//issues/` for files that are open, unblocked, and unclaimed; first by number wins. -- **Claim**: set `Status: claimed` and save before any work. -- **Resolve**: append the answer under an `## Answer` heading, set `Status: resolved`, then append a context pointer (gist + link) to the map's Decisions-so-far in `map.md`. diff --git a/.agents/skills/setup-matt-pocock-skills/triage-labels.md b/.agents/skills/setup-matt-pocock-skills/triage-labels.md deleted file mode 100644 index b716855d..00000000 --- a/.agents/skills/setup-matt-pocock-skills/triage-labels.md +++ /dev/null @@ -1,15 +0,0 @@ -# Triage Labels - -The skills speak in terms of five canonical triage roles. This file maps those roles to the actual label strings used in this repo's issue tracker. - -| Label in mattpocock/skills | Label in our tracker | Meaning | -| -------------------------- | -------------------- | ---------------------------------------- | -| `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue | -| `needs-info` | `needs-info` | Waiting on reporter for more information | -| `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent | -| `ready-for-human` | `ready-for-human` | Requires human implementation | -| `wontfix` | `wontfix` | Will not be actioned | - -When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table. - -Edit the right-hand column to match whatever vocabulary you actually use. diff --git a/AGENTS.md b/AGENTS.md index d2cd3587..3f01c826 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -31,50 +31,12 @@ bun run db:migrate # runtime migrator (apps/server; same as boot) - `apps/cli` — `sprout` CLI (uses api-client) - `packages/api-client` — typed Eden client against `@sprout/server/api-type` - `packages/preview-db` — shared Postgres catalog DDL (ensure-role, worktree provision/drop) -- `packages/preview-env` — preview wire grammar: PG* env remap (ADR-0007), hostname templates, health request-shape +- `packages/preview-env` — preview wire grammar: PG* env remap, hostname templates, health request-shape -## Style +## Conventions -- Plain functions, no classes. -- Periodic work uses `Bun.cron`, never `setTimeout`/`setInterval`. -- Keep modules small and focused. -- Fail fast at config load for required env vars. -- DB schema lives in `apps/server/src/infrastructure/db/`; migrations in `apps/server/drizzle/`. - -## Comment style - -Comments state the why only — never tickets, history, or restatements. -See `docs/agents/comment-style.md`. - -## Agent skills - -### Issue tracker - -Issues are tracked as GitHub issues on `simpros/sprout`, via the `gh` CLI. See `docs/agents/issue-tracker.md`. - -### Triage labels - -Default label vocabulary (`needs-triage`, `needs-info`, `ready-for-agent`, `ready-for-human`, `wontfix`). See `docs/agents/triage-labels.md`. - -### Domain docs - -Single-context: one `CONTEXT.md` + `docs/adr/` at the repo root. See `docs/agents/domain.md`. - -### Pull requests - -Open and describe every PR with the `visual-pr` skill vendored in this repo at -`.agents/skills/visual-pr/` — Why in one sentence, 1-3 special notes, and a -structural Change outline. Its frontmatter says explicit-invoke-only; that -default is overridden here: use it for every PR body. See -`docs/agents/pull-requests.md` for the publishing steps and the show-me-comment -rule. - -### Vendored skills - -- `documentation-writer` (`.agents/skills/documentation-writer/`) — every docs or - prose task: Diátaxis page types (tutorial / how-to / reference / explanation) and - its clarify → outline → write workflow. -- `emil-design-eng` (`.agents/skills/emil-design-eng/`) — building or reviewing UI: - animation decisions, easing and duration, component feel, motion performance, a11y. -- `review-animations` (`.agents/skills/review-animations/`) — reviewing animation and - motion code against the craft bar; it defaults to flagging. +- Code and comment style: `CODE-STYLE.md`. +- Domain vocabulary: `CONTEXT.md`. Decisions: `docs/adr/` (only hard-to-reverse, hard-to-understand ones). +- Issues: GitHub issues on `simpros/sprout` via `gh`; tracker spec and triage labels: `docs/agents/issue-tracker.md`. +- PRs: always describe with the `visual-pr` skill (`.agents/skills/visual-pr/`). `show-me` goes in a comment, never the body. +- Agent tooling (vendored skill index): `.agents/README.md`. diff --git a/CODE-STYLE.md b/CODE-STYLE.md new file mode 100644 index 00000000..848d6f11 --- /dev/null +++ b/CODE-STYLE.md @@ -0,0 +1,20 @@ +# Code style + +- Plain functions, no classes. +- Periodic work uses `Bun.cron`, never `setTimeout`/`setInterval`. +- Keep modules small and focused. +- Fail fast at the boundary that owns the value: boot for gateway-scope config, the deploy route for per-repo provider config (a sqlite-only gateway boots with no Postgres env). +- DB schema lives in `apps/server/src/infrastructure/db/`; migrations in `apps/server/drizzle/`. + +## Comments + +State the why only, and only when the code cannot say it. + +- No restating code, signatures or types. +- No tickets, PRs, review feedback or people. No history ("previously", "now uses"). +- No ADR numbers in comments or test names; if the deviation matters, name the deviation. +- No commented-out code. No "hack" / "for now" / emoji. +- Keep real whys: invariants, ordering/locking, observed external behaviour, + security tradeoffs, magic constants. +- Inline comments: one claim; wrap as needed. Module/function docstrings: one invariant, no headings or bullet lists. Longer reasoning is a decision: put it in `CONTEXT.md` or an ADR. +- A comment that contradicts the code is a bug; fix one of them. diff --git a/CONTEXT.md b/CONTEXT.md index eea634bd..1710ce70 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -125,4 +125,3 @@ _Avoid_: Root token, master key ## See also - The normative v0.1 specification (tracked in the GitHub issue tracker) -- `docs/agents/` — how agents consume this documentation diff --git a/apps/cli/src/worktree-db/env-file.test.ts b/apps/cli/src/worktree-db/env-file.test.ts index 6e136f2e..faa7e130 100644 --- a/apps/cli/src/worktree-db/env-file.test.ts +++ b/apps/cli/src/worktree-db/env-file.test.ts @@ -70,7 +70,7 @@ describe("parseEnvRenames", () => { expect(parseEnvRenames(["databaseUrl=X"]).ok).toBe(false); }); - test("rejects target collisions (ADR-0007)", () => { + test("rejects target collisions", () => { const result = parseEnvRenames(["PGHOST=FOO", "PGUSER=FOO"]); expect(result.ok).toBe(false); if (result.ok) throw new Error("expected failure"); diff --git a/apps/server/src/preview-db/names.ts b/apps/server/src/preview-db/names.ts index 533092f8..3ec26ba0 100644 --- a/apps/server/src/preview-db/names.ts +++ b/apps/server/src/preview-db/names.ts @@ -50,6 +50,7 @@ export function validatePreviewIdentity( return null; } +/** Reads take no mode: a row created while `single` may run to `PG_IDENT_MAX`, so list/teardown must accept the full budget or a later flip to `dual` strands it. */ export function isPreviewDbName(dbName: string): boolean { return ( PREVIEW_DB_NAME_RE.test(dbName) && @@ -63,6 +64,7 @@ export function assertPreviewDbName(dbName: string): void { } } +/** Same permissive budget as isPreviewDbName (see above): reads take no mode. */ export function parsePreviewDatabaseName( datname: string, ): { slug: string; prId: number } | null { diff --git a/docs/adr/0002-shared-logical-databases.md b/docs/adr/0002-shared-logical-databases.md index f7b58d61..ac3802ae 100644 --- a/docs/adr/0002-shared-logical-databases.md +++ b/docs/adr/0002-shared-logical-databases.md @@ -1,6 +1,6 @@ # Shared instance with logical per-PR databases -Each preview gets its own **logical database** (`prev__pr`) on one +Each preview gets its own **logical database** (`sprout__pr`) on one shared Postgres instance. sprout does not spawn Postgres containers per PR in v0.1. diff --git a/docs/adr/0006-sprout-durable-identity.md b/docs/adr/0006-sprout-durable-identity.md index 2cf58766..23be2efc 100644 --- a/docs/adr/0006-sprout-durable-identity.md +++ b/docs/adr/0006-sprout-durable-identity.md @@ -1,12 +1,7 @@ -# Product `sprout*` durable runtime identity +# Durable runtime identity is `sprout*` -**Status:** accepted, implemented. - -Durable runtime identity uses the product name `sprout` — compose project, -networks, SQLite path, Postgres roles, preview container names -`sprout--pr-`, preview databases `sprout__pr` — -replacing the legacy opaque `preview-buddy` / `pb` / `prev_` prefixes kept -after the package rename. Operators upgrading from those defaults wipe -volumes/networks/state and redeploy; there is no migrator (v0.1 pre-release). - -Adopter-configurable injection names are a separate decision (ADR-0007). +Compose project, networks, SQLite path, Postgres roles, container names +(`sprout--pr-`) and preview databases (`sprout__pr`) all +carry the product name, replacing the legacy `preview-buddy` / `pb` / `prev_` +prefixes. These names are persisted in operator state, so renaming again means +wiping volumes, networks and state; there is no migrator. diff --git a/docs/adr/0007-preview-env-injection-names.md b/docs/adr/0007-preview-env-injection-names.md deleted file mode 100644 index df9931a0..00000000 --- a/docs/adr/0007-preview-env-injection-names.md +++ /dev/null @@ -1,34 +0,0 @@ -# Adopter-configurable injection env names (`preview.env`) - -**Status:** accepted, implemented. - -Adopters remap the canonical connection env names the gateway injects -into preview app and seed containers via optional `preview.env` in -`.sprout.yaml` (keys `PGHOST`…`PGDATABASE`, plus companion -`PGAPPUSER` / `PGAPPPASSWORD` → adopter names). Unmapped keys still -inject under their canonical names. Remapping replaces the name (no dual -alias). - -Owner values (`PGUSER` / `PGPASSWORD`) come from the gateway's static -preview login. Companion values are a per-preview-DB restricted LOGIN -(`_app`) with a password derived from the owner preview password -— dual-role / RLS apps use the companion for runtime queries and the -owner for migrations. Product durable identity rename is a separate -decision (ADR-0006). - -Mail follows the same grammar: canonical `MAILHOST`…`MAILREPLYTO` keys are -injected into app, companion service and seed containers and remappable -through `preview.env` with the same replace-not-alias rule. `MAILFROM` / -`MAILREPLYTO` carry the per-preview send-from identity -(`-pr@`), `MAILFROMNAME` its display -label; a `mail.from` `{pr_id}` template overrides the address. - -## Amendment 2026-09-24: companion keys are dual-only (ADR-0012) - -The companion `PGAPPUSER` / `PGAPPPASSWORD` keys above are canonical -only for `dual` previews. Since ADR-0012 the restricted companion role -is opt-in via `db.roles` (`single` | `dual`, Postgres only; default -`dual` when `preview.env` remaps a companion key, else `single`): -`single` previews inject no `PGAPP*` names anywhere, and an explicit -`db.roles: single` plus a companion remap fails fast at manifest parse -and at the deploy route. diff --git a/docs/adr/0008-preview-db-providers.md b/docs/adr/0008-preview-db-providers.md index 8778c891..dc9006e1 100644 --- a/docs/adr/0008-preview-db-providers.md +++ b/docs/adr/0008-preview-db-providers.md @@ -1,66 +1,27 @@ -# Preview database providers: Postgres + SQLite behind one port +# Preview database providers: Postgres, SQLite, none -**Status:** accepted, implemented. +*Folds ADR-0009: `none` is the third provider value below.* -## The noun +`db.provider` in `.sprout.yaml` (`postgres` default | `sqlite` | `none`) selects +the backend per repo, not per gateway, so one gateway serves mixed fleets and a +sqlite-only gateway boots without Postgres env. The deploy route resolves the +provider once into a materialization plan; lifecycle and app-deployment consume +the plan and never branch on provider. -`provider` now names the preview-database axis only: the value of -`db.provider` in `.sprout.yaml` (`postgres` | `sqlite`). It never -describes the app-deployment module — the CONTEXT.md avoid list for that -module still stands. At the deploy boundary the axis is resolved once -into a concrete materialization plan (`provider`, `gatewayEnv`, -`volumes`, `appNetworks`, `seedNetworks`); lifecycle and -app-deployment consume the plan and never see raw `DbSpec`. The two -backends are the Postgres adapter and the SQLite volume adapter behind -the `PreviewDb` port, selected up front by the router. +- The provider is stored on the preview row. Teardown and sweep drop via the + stored provider; only row-less orphans fall back to broadcast. +- `previews.db_name` is nullable for `none`. A sentinel name would leak into + every read and could collide with the catalog namespace. +- Contradictory manifests (`seed` or DB env remaps with `none`, `PG*` with + `sqlite`) fail fast at manifest parse and at the deploy route. +- Switching provider redeploys as a fresh generation: the old backend is dropped + before the new one is created. -## Decision - -- The manifest owns provider selection (`db:` block, default `postgres`), - not a gateway-wide env switch. One gateway serves both backends at - once: mixed fleets deploy without operator reconfiguration, and a - sqlite-only gateway boots with no Postgres env at all. -- `PreviewDb` stays provider-agnostic (`createDatabase(dbName)`). - `createRoutingPreviewDb.forCreate(provider)` is the sole selector; - adapters trust the router instead of re-validating dispatch. - `sqlite.ts` implements the port over one named Docker volume per - preview (`sprout--pr--sqlite`), derived from the logical - database name. The `index.ts` wiring is the single place that decides - which adapters exist. A literal single static selection in `index.ts` - would be a gateway-wide switch, which the manifest-owned selection - above rules out. -- Provider is state: the preview row carries `db_provider` (default - `"postgres"`), written at claim time. Teardown and sweep route drops - from the stored provider (`forDrop`); only row-less sweep orphans - fall back to broadcast, which aggregates real failures instead of - surfacing the first. The merged catalog dedups on `dbName`, since - both backends share one name space. A provider switch redeploys as a - fresh generation: bring-up drops the old backend first, then creates - the new one, so no resource strands. -- The canonical SQLite key is `DATABASE_URL` with value - `file:/`, remappable through `preview.env` under the - ADR-0007 grammar (remap replaces the name, no dual alias). SQLite - previews mount the volume at `db.path` in app, service, and seed - containers and join the Traefik network only; no `PG*` keys are - injected for them. -- Gateway boot requires only the Traefik network. Postgres config is an - all-or-nothing optional (`config.postgres`); a partial Postgres env - fails boot instead of limping. A `postgres` deploy on a gateway - without Postgres env fails fast at the deploy route with - `postgres_not_configured`, naming the repo, the provider, and the - missing variables. The check lives at deploy time rather than boot - time because repos onboard dynamically through the API — boot cannot - know which providers will be declared, and a sqlite-only gateway must - boot clean. `preview.env` keys are validated against the provider at - manifest parse and at the deploy route (`PG*` needs `postgres`, - `DATABASE_URL` needs `sqlite`) through one shared preview-env entry - point. - -## Consequences - -- Existing manifests behave exactly as before (default `postgres`, same - container env, DB names, and networks). -- An app-image replace keeps the SQLite volume (data survives); - teardown removes it on the same paths that drop a Postgres database. -- `sprout worktree-db` stays Postgres-only; previews without a database - are a separate change on top of this seam. +`db.roles` selects the Postgres credential axis (`single` | `dual`; contract in +`docs/adopting-a-repo.md`, derivation in `@sprout/preview-env` `resolveDbRoles`). +Name validation is mode-scoped — `dual` reserves budget for the `_app` +companion role — while catalog reads (`isPreviewDbName`/`parsePreviewDatabaseName`) +take no mode and accept the full identifier budget: a row created while `single` +may run to `PG_IDENT_MAX`, so a later flip to `dual` must not make it unlistable. +Teardown drops the companion role unconditionally, so a preview created while +`dual` still cleans up after the repo flips to `single`. diff --git a/docs/adr/0009-preview-db-provider-none.md b/docs/adr/0009-preview-db-provider-none.md deleted file mode 100644 index 167f404b..00000000 --- a/docs/adr/0009-preview-db-provider-none.md +++ /dev/null @@ -1,55 +0,0 @@ -# Previews without a database: `db.provider: none` - -**Status:** accepted, implemented. - -## The noun - -`none` is the third value of the preview-database axis (`db.provider` in -`.sprout.yaml`: `postgres` | `sqlite` | `none`), reusing the provider seam -from the SQLite change. It never describes the app-deployment module — -the CONTEXT.md avoid list for that module still stands. A `none` preview -is app container + optional companion services + routing + health, with -no database at all. - -## Decision - -- The manifest owns the choice (`db.provider: none`, default stays - `postgres`), not a gateway-wide switch and not a parallel flag. The - deploy boundary resolves `none` into a concrete materialization plan - with empty `gatewayEnv`/`volumes` and Traefik-only networks; lifecycle - and app-deployment consume the plan and never branch on the provider. - `forCreate("none")` throws (there is no backend to select), so the - deploy path calling it is a bug; `forDrop("none")` is a no-op safety - net, but teardown skips the catalog lock and the drop call entirely. -- `previews.db_name` is **nullable**, not a reserved sentinel. A sentinel - keeps `NOT NULL` but leaks a fake name into every `db_name` read - (snapshots, list, sweep, doctor) and risks colliding with the catalog - namespace; `NULL` renders cleanly (`db_name: null`) and can never match - a `sprout__pr` catalog entry, so sweep TTL, PR-close, status, - and orphan planning keep working with null-aware comparisons. The - migration rebuilds the table with `db_name` nullable and copies rows - verbatim. -- Contradictory combinations fail fast with named errors rather than - silent no-ops: a `seed:` block or any `preview.env` database-key remap - combined with `none` is rejected at manifest parse and at the gateway - deploy route (`seed requires db.provider postgres or sqlite - (db.provider is none)`; `preview.env. requires db.provider - `), and `-s` / `--reseed` / `sprout ci reseed -s …` fail fast on - the CLI before any network call. The seed gate reads the provider, so - no seed phase ever runs for `none`. -- Gateway boot is unchanged (Traefik network only): a gateway whose - repos are all `none` needs no `SPROUT_*PG*` / - `SPROUT_POSTGRES_NETWORK`; a `postgres` deploy without them still fails - fast with `postgres_not_configured`. Provider switching redeploys as a - fresh generation — the claim intent preserves the old name through the - switch so bring-up drops the old backend before nulling the column. - -## Consequences - -- `postgres` and `sqlite` paths are untouched: same container env, DB - names, volumes, and networks. Companion services work as today minus - the database env. -- No new CLI flags; `sprout list` and the status endpoint render - `db_name: null` for `none` previews. -- A test with a throwing `PreviewDb` port proves zero database calls on - the `none` deploy path by construction, not by review. diff --git a/docs/adr/0010-preview-label-ownership.md b/docs/adr/0010-preview-label-ownership.md deleted file mode 100644 index 593252d4..00000000 --- a/docs/adr/0010-preview-label-ownership.md +++ /dev/null @@ -1,23 +0,0 @@ -# Preview label ownership (`preview.labels`) - -**Status:** accepted, implemented. - -Container labels on a preview have two owners. The gateway owns the -Traefik routing set it emits per container (`traefik.enable`, the router -rule, the loadbalancer server port, plus the TLS and forwardAuth keys -when that gateway configures them). The adopting repo owns everything -else via optional `preview.labels` (app container and every service -container) and `preview.services[].labels` (that service container -only), merged verbatim — `traefik.*` keys included, so a preview can -attach to a router or middleware defined outside the gateway. - -A silently overridden rule, port, or TLS label is how a preview goes -dark with no error, so collision fails fast instead: the gateway -computes its own label set for each container first and rejects any -adopter key already present in it (`reserved_preview_label`, quoting -the manifest path). The reserved set is derived from the emission -itself, never a hard-coded list, so it tracks the gateway's TLS and -forwardAuth policy without drifting. - -Label values are literal (no `{pr_id}` interpolation); the seed -container is a one-shot job and carries no adopter labels. diff --git a/docs/adr/0011-agent-first-docs.md b/docs/adr/0011-agent-first-docs.md deleted file mode 100644 index ece6b9c6..00000000 --- a/docs/adr/0011-agent-first-docs.md +++ /dev/null @@ -1,44 +0,0 @@ -# Agent-first multi-page docs + onboarding prompt - -**Status:** accepted, implemented. - -## Context - -Two long guides carried the whole contract. Agents are the primary consumer -now and there was nothing agent-shaped: no per-topic pages, no index, no -machine-readable catalogue, no paste-into-a-harness prompt. - -## Decision - -- Markdown stays canonical under `docs/`: one topic per page with a stable - URL (`getting-started`, `adopting-a-repo`, `ci-integration`, - `operator-deploy`, `previews`, `cli-reference`, `troubleshooting`, - `onboarding-prompt`; `herdr-integration` joins the same section). -- `docs/site/assemble.ts` renders each page markdown to HTML at assemble - time; both `.md` (agents) and `.html` (humans) ship from one source, and - the link gate runs over the whole artifact. -- `docs/index.html` lists every page with its one-line description. - `llms.txt` at the site root lists every page with its canonical URL and - marks the onboarding prompt as the entry point. -- `docs/onboarding-prompt.md` is one copy-paste block: fetch index then - config then CI docs, inspect the repo, confirm slug and hostname template - with the user, write only `.sprout.yaml` / optional `Dockerfile.seed` / - the CI file, name the masked variables the user sets, verify with the CLI - loader, next step `sprout doctor` / first `sprout ci preview`. - -## Consequences - -- New pages join `publishFiles` in `docs/site/assemble.ts`; the assemble - and check suites assert the page set and the render step. -- Inbound references point at the real pages; the removed thin maps - (`docs/adoption.md`, `docs/deploy.md`) are gone, so their old anchors 404. -- Published pages never carry maintainer internals; the gate enforces it on - markdown sources and rendered HTML alike. - -## Amendment 2026-09-23: legacy moved-content pages removed - -The thin landing pages (`adoption.md` and `deploy.md`) are deleted -along with the `legacy` manifest branch and the "Legacy entry points" -index paragraph. There is no redirect shim: `docs/deploy.html` and -`docs/adoption.html` now 404, and all inbound references point at -`docs/operator-deploy.md` / `docs/adopting-a-repo.md`. diff --git a/docs/adr/0012-preview-db-roles-opt-in.md b/docs/adr/0012-preview-db-roles-opt-in.md deleted file mode 100644 index 22867d30..00000000 --- a/docs/adr/0012-preview-db-roles-opt-in.md +++ /dev/null @@ -1,76 +0,0 @@ -# Preview DB roles: restricted companion opt-in (`db.roles`) - -**Status:** accepted, implemented. - -## The noun - -`roles` names the Postgres preview-database credential axis only: the -value of `db.roles` in `.sprout.yaml` (`single` | `dual`, Postgres -only). It never describes the app-deployment module or the companion -**service** containers — the CONTEXT.md avoid lists for both still -stand. A `single` preview is one Postgres LOGIN (the static preview -owner); a `dual` preview adds the per-database restricted companion -LOGIN (`_app`) exactly as before. - -## Decision - -- The manifest owns the choice (`db.roles`, Postgres only), not a - gateway-wide switch and not a parallel flag. `dual` is byte-for-byte - today's contract: one role named `_app`, the same HMAC-derived - password, the same `GRANT CONNECT` + schema `USAGE`, the same - `PGAPPUSER` / `PGAPPPASSWORD` names injected into app, - companion-service, and seed containers, remappable via `preview.env`. - `single` provisions no companion role and injects no `PGAPPUSER` / - `PGAPPPASSWORD` anywhere. -- The default is derived by one rule, not two mechanisms: `dual` when - `preview.env` remaps `PGAPPUSER` or `PGAPPPASSWORD`, otherwise - `single`. An explicit `db.roles` wins over the derivation. The - resolver lives in `@sprout/preview-env` (`resolveDbRoles`) and both - the CLI manifest parse and the gateway deploy route call it — the - shared-package pattern the provider guard already uses. -- Contradictory combinations fail fast with named errors rather than - silent disagreement: explicit `db.roles: single` plus a `preview.env` - entry for a companion key is rejected at manifest parse and at the - gateway deploy route - (`preview.env. conflicts with db.roles single (remove the remap - or use db.roles dual)`), naming both sides. The remap is the adopter - literally saying "I use this credential", so the two must never - disagree silently. `db.roles` on `sqlite` / `none` is rejected like an - out-of-scope env key - (`db.roles requires db.provider postgres`). -- The role lifecycle follows the resolved mode: `createDatabase` - provisions the companion only in `dual`, taking the mode as an - explicit options argument (per-repo manifest state resolved at deploy - time, never module state). Teardown keeps calling `DROP ROLE IF - EXISTS` unconditionally so a preview created while dual still cleans - up after the repo flips to single. -- Env injection follows the resolved mode in `pgConnectionEnv`; the - `withGatewayConnectionEnv` reservation set is unchanged (every - `PREVIEW_ENV_KEYS` name stays stripped from adopter env in both - modes). -- The name budget follows the mode at the deploy boundary only: - `validatePreviewIdentity` allows db names up to `PG_IDENT_MAX` in - `single` and stays at `PG_IDENT_MAX - len("_app")` in `dual`. The - catalog read path (`isPreviewDbName` / `parsePreviewDatabaseName`, - which list/teardown/sweep run over historical rows) stays permissive - at `PG_IDENT_MAX` so flipping a repo never makes an existing preview - unlistable or unremovable. - -## Consequences - -- Adopters who never mention the companion get none: no role - create/sync per deploy, no `PGAPP*` names in container env, no - per-migration `GRANT` obligation, and four more characters of db-name - budget. Adopters who remap a companion key keep working with zero - config change (derived `dual`). -- No `dual`/`legacy` alias for the injected names; no change to the - `mail.*` grammar, hostname templates, or `preview.env` keys beyond - the new guard. Automatically `GRANT`ing table privileges / - `ALTER DEFAULT PRIVILEGES` stays a separate change. -- Amends ADR-0007: the companion `PGAPPUSER` / `PGAPPPASSWORD` keys are - canonical only for `dual` previews (see the amendment note there). - -## Amendment 2026-09-24: see ADR-0007 amendment - -ADR-0007 carries the one-line amendment pointing at this decision; this -file stays the record of the roles axis itself. diff --git a/docs/adr/0013-preview-access-gate.md b/docs/adr/0013-preview-access-gate.md index 37abf433..968759d6 100644 --- a/docs/adr/0013-preview-access-gate.md +++ b/docs/adr/0013-preview-access-gate.md @@ -1,37 +1,15 @@ -# Preview access gate (`preview.auth`) +# Preview access gate is gateway-native (`preview.auth`) -**Status:** accepted, implemented. +Previews are open by default (`preview.auth: none`); `basic` | `link` gates one +preview via a per-preview Traefik middleware on the app router only. -Previews are open by design, so sharing one preview means gating one -preview: `preview.auth` (`none` default, `basic`, `link`) attaches a -per-preview Traefik middleware to the app router only. Companion -services are never double-gated, and reset/reseed/teardown bypass the -gate because they act through the gateway and the forge, not the gated -host. +The gate lives in the gateway, not an external forward-auth service. That was +tried and abandoned: every Cloudflare path rewrites `X-Forwarded-Host`, and the +service rebuilt its URL from that header, hit its self-request shortcut, and +authorised everything. -The gate is gateway-native. An external forward-auth service was tried -and abandoned for two structural reasons: there is no Cloudflare-free -path from the preview edge to that service, and every Cloudflare path -rewrites `X-Forwarded-Host`, so the service rebuilt its URL from the -header, took its self-request shortcut, and authorised everything. The -`link` forwardAuth address is therefore the gateway's in-network name, -which the operator configures as `SPROUT_PREVIEW_AUTH_ADDRESS` next to -the token-signing root `SPROUT_PREVIEW_AUTH_SECRET` (partial sets fail -boot). - -Two postures, two mechanisms. `basic` is a gateway-generated credential -enforced by Traefik's `basicAuth` middleware with the htpasswd entry -inline in the label — there is no volume shared with Traefik for a file, -so a file path would be fiction. `link` is a token (repository, PR id, -expiry, per-preview version, HMAC-signed) consumed at -`/__sprout/auth?t=` on the preview's own host: the forwardAuth handler -answers that path with a `302` plus a host-scoped cookie, and checks the -cookie or Basic credentials on every other request. Revocation rotates -the per-preview version, which invalidates outstanding links with no -redeploy; basic password rotation lands on the next deploy because the -hash is label-embedded. - -Wire contract: by default the app receives no identity header at all — -the gate either keeps traffic out or passes it through unmodified. This -adds no app env and changes no injection names, so the preview wire -grammar is unchanged. +- `basic`: gateway-generated credential, htpasswd entry inline in the label (no + volume is shared with Traefik). +- `link`: HMAC-signed token with a per-preview version; revoking rotates the + version, no redeploy needed. +- The app receives no identity header and no new env. diff --git a/docs/adr/README.md b/docs/adr/README.md index 128eb9f6..cfc3ad1e 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -1,8 +1,8 @@ # Architecture decision records -Flat numbering. All three ADR criteria (hard to reverse, surprising, real -trade-off) were applied — most v0.1 choices are documented in the normative spec issue -only. +Record a decision here only when it is hard to reverse *and* hard to +understand — everything else lives in `CONTEXT.md`, code docstrings, or the +normative spec issue. ADR numbers are immutable: never reuse a number. | ADR | Decision | |---|---| @@ -11,11 +11,11 @@ only. | [0003](0003-seed-as-user-image.md) | Seeding via user-built one-shot seed image, no gateway clone | | [0004](0004-ci-driven-lifecycle-no-webhooks.md) | Symmetric CI lifecycle; no forge webhooks in v0.1 | | [0005](0005-self-made-bearer-tokens.md) | Self-made bearer tokens in SQLite, not better-auth | -| [0006](0006-sprout-durable-identity.md) | `sprout*` durable identity (accepted, implemented) | -| [0007](0007-preview-env-injection-names.md) | Adopter `preview.env` remaps injection names (accepted, implemented) | -| [0008](0008-preview-db-providers.md) | Preview database providers: Postgres + SQLite behind one port (accepted, implemented) | -| [0009](0009-preview-db-provider-none.md) | Previews without a database: `db.provider: none` (accepted, implemented) | -| [0010](0010-preview-label-ownership.md) | Preview label ownership: gateway Traefik set vs adopter `preview.labels`, fail-fast collision (accepted, implemented) | -| [0011](0011-agent-first-docs.md) | Agent-first multi-page docs + onboarding prompt (accepted, implemented) | -| [0012](0012-preview-db-roles-opt-in.md) | Preview DB roles: restricted companion opt-in (`db.roles`) | -| [0013](0013-preview-access-gate.md) | Preview access gate: per-preview `basic` / `link`, gateway-native (`preview.auth`) | +| [0006](0006-sprout-durable-identity.md) | `sprout*` durable identity | +| 0007 | Retired → `docs/adopting-a-repo.md` (`preview.env` remap grammar) | +| [0008](0008-preview-db-providers.md) | Preview database providers: Postgres, SQLite, none (folds 0009) | +| 0009 | Retired → ADR-0008 | +| 0010 | Retired → `docs/previews.md` (Preview labels: reserved set derived from the gateway's label emission) | +| 0011 | Retired → `docs/onboarding-prompt.md` (page set lives in `docs/site/assemble.ts` `publishFiles`) | +| 0012 | Retired → ADR-0008 (`db.roles` invariant) and `docs/adopting-a-repo.md` (`db.roles` contract) | +| [0013](0013-preview-access-gate.md) | Preview access gate: per-preview `none` default \| `basic` \| `link`, gateway-native | diff --git a/docs/agents/comment-style.md b/docs/agents/comment-style.md deleted file mode 100644 index dea27544..00000000 --- a/docs/agents/comment-style.md +++ /dev/null @@ -1,29 +0,0 @@ -# Comment style - -1. **A comment earns its place only when the code cannot say it.** If the line below - already says it, delete the comment: no restating signatures, types or obvious - control flow. -2. **Never cite tickets, issues, PRs/MRs, review feedback or people** — no `PRO-12`, - `#128`, `issue #92`, "per review", "per the ticket". The tracker and git history - hold that; the code holds the *reason*. -3. **No history narration.** "Previously…", "now uses X after the refactor", "fixed in - v0.6.0" — git remembers; the file should read as the current truth. -4. **No commented-out code.** Git is the archive. -5. **An ADR reference is allowed only to mark a deliberate deviation/exception**, and the - deviation must be named in the same line ("exempt from ADR-0007 because …"). Never as a - substitute for stating the reason. -6. **Keep the why when it is real:** invariants, ordering/locking requirements, observed - external behaviour and workarounds (say what was observed), security/privacy decisions, - performance or safety tradeoffs, back-compat and migration constraints, unexplained - magic constants. -7. **Public API docs keep the contract, drop the echo.** Keep non-obvious parameters, - invariants, thrown errors and side effects; delete restatements of the signature and of - the types. -8. **Banner/section comments only where they name a boundary the code cannot.** One-line - module header is fine; a table of contents is not. -9. **One line beats three.** If the explanation needs a paragraph it is a decision → put it - in `CONTEXT.md` / `docs/adr/` and leave at most a one-line pointer in the code. -10. **A comment that contradicts the code is a bug** — fix one of the two in the same - change; never leave both standing. -11. **No editorializing or decoration:** no "ugly hack", "for now", "should be fine", no - changelog notes, no emoji. diff --git a/docs/agents/domain.md b/docs/agents/domain.md deleted file mode 100644 index b548c538..00000000 --- a/docs/agents/domain.md +++ /dev/null @@ -1,51 +0,0 @@ -# Domain Docs - -How the engineering skills should consume this repo's domain documentation when exploring the codebase. - -## Before exploring, read these - -- **`CONTEXT.md`** at the repo root, or -- **`CONTEXT-MAP.md`** at the repo root if it exists — it points at one `CONTEXT.md` per context. Read each one relevant to the topic. -- **`docs/adr/`** — read ADRs that touch the area you're about to work in. In multi-context repos, also check `src//docs/adr/` for context-scoped decisions. - -If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The `/domain-modeling` skill (reached via `/grill-with-docs` and `/improve-codebase-architecture`) creates them lazily when terms or decisions actually get resolved. - -## File structure - -Single-context repo (most repos): - -``` -/ -├── CONTEXT.md -├── docs/adr/ -│ ├── 0001-event-sourced-orders.md -│ └── 0002-postgres-for-write-model.md -└── src/ -``` - -Multi-context repo (presence of `CONTEXT-MAP.md` at the root): - -``` -/ -├── CONTEXT-MAP.md -├── docs/adr/ ← system-wide decisions -└── src/ - ├── ordering/ - │ ├── CONTEXT.md - │ └── docs/adr/ ← context-specific decisions - └── billing/ - ├── CONTEXT.md - └── docs/adr/ -``` - -## Use the glossary's vocabulary - -When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `CONTEXT.md`. Don't drift to synonyms the glossary explicitly avoids. - -If the concept you need isn't in the glossary yet, that's a signal — either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/domain-modeling`). - -## Flag ADR conflicts - -If your output contradicts an existing ADR, surface it explicitly rather than silently overriding: - -> _Contradicts ADR-0007 (event-sourced orders) — but worth reopening because…_ diff --git a/docs/agents/issue-tracker.md b/docs/agents/issue-tracker.md index b812b355..66e082c8 100644 --- a/docs/agents/issue-tracker.md +++ b/docs/agents/issue-tracker.md @@ -1,45 +1,19 @@ # Issue tracker: GitHub -Issues and PRDs for this repo live as GitHub issues on `simpros/sprout`. Use the `gh` CLI for all operations. +This file is what `/setup-matt-pocock-skills` would have generated; when a skill asks for that setup, read this file instead. -## Conventions +Issues for this repo live as GitHub issues on `simpros/sprout`. Use `gh` for all operations. -- **Create an issue**: `gh issue create --title "..." --body "..."`. Use a heredoc for multi-line bodies. -- **Read an issue**: `gh issue view --comments`, filtering comments by `jq` and also fetching labels. -- **List issues**: `gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'` with appropriate `--label` and `--state` filters. -- **Comment on an issue**: `gh issue comment --body "..."` -- **Apply / remove labels**: `gh issue edit --add-label "..."` / `--remove-label "..."` -- **Close**: `gh issue close --comment "..."` +PRs as a request surface: no. Triage labels: `needs-triage`, `needs-info`, `ready-for-agent`, `ready-for-human`, `wontfix`. -Infer the repo from `git remote -v` — `gh` does this automatically when run inside a clone. - -## Pull requests as a triage surface - -**PRs as a request surface: no.** _(Set to `yes` if this repo treats external PRs as feature requests; `/triage` reads this flag.)_ - -When set to `yes`, PRs run through the same labels and states as issues, using the `gh pr` equivalents: - -- **Read a PR**: `gh pr view --comments` and `gh pr diff ` for the diff. -- **List external PRs for triage**: `gh pr list --state open --json number,title,body,labels,author,authorAssociation,comments` then keep only `authorAssociation` of `CONTRIBUTOR`, `FIRST_TIME_CONTRIBUTOR`, or `NONE` (drop `OWNER`/`MEMBER`/`COLLABORATOR`). -- **Comment / label / close**: `gh pr comment`, `gh pr edit --add-label`/`--remove-label`, `gh pr close`. - -GitHub shares one number space across issues and PRs, so a bare `#42` may be either — resolve with `gh pr view 42` and fall back to `gh issue view 42`. - -## When a skill says "publish to the issue tracker" - -Create a GitHub issue. - -## When a skill says "fetch the relevant ticket" - -Run `gh issue view --comments`. +Operations: `gh issue view|comment|close|edit`; tickets = `gh issue create`. ## Wayfinding operations -Used by `/wayfinder`. The **map** is a single issue with **child** issues as tickets. - -- **Map**: a single issue labelled `wayfinder:map`, holding the Notes / Decisions-so-far / Fog body. `gh issue create --label wayfinder:map`. -- **Child ticket**: an issue linked to the map as a GitHub sub-issue (`gh api` on the sub-issues endpoint). Where sub-issues aren't enabled, add the child to a task list in the map body and put `Part of #` at the top of the child body. Labels: `wayfinder:` (`research`/`prototype`/`grilling`/`task`). Once claimed, the ticket is assigned to the driving dev. -- **Blocking**: GitHub's **native issue dependencies** — the canonical, UI-visible representation. Add an edge with `gh api --method POST repos///issues//dependencies/blocked_by -F issue_id=`, where `` is the blocker's numeric **database id** (`gh api repos///issues/ --jq .id`, _not_ the `#number` or `node_id`). GitHub reports `issue_dependencies_summary.blocked_by` (open blockers only — the live gate). Where dependencies aren't available, fall back to a `Blocked by: #, #` line at the top of the child body. A ticket is unblocked when every blocker is closed. -- **Frontier query**: list the map's open children (`gh issue list --state open`, scoped to the map's sub-issues / task list), drop any with an open blocker (`issue_dependencies_summary.blocked_by > 0`, or an open issue in the `Blocked by` line) or an assignee; first in map order wins. -- **Claim**: `gh issue edit --add-assignee @me` — the session's first write. -- **Resolve**: `gh issue comment --body ""`, then `gh issue close `, then append a context pointer (gist + link) to the map's Decisions-so-far. +- Parent map = one open issue titled `Map: `. +- The skill's `wayfinder:map` and `wayfinder:` labels do not exist in this repo — omit `--label`, name the ticket type in the body instead. +- Child = issue with `Part of #` in the body. +- Blocking = `Blocked by: #` line in the body (not a comment). +- Frontier = open unassigned child with no open issue in its `Blocked by` line. +- Claim = assign to yourself first. +- Resolve = comment the answer, close, append a pointer to the map's Decisions-so-far. diff --git a/docs/agents/pull-requests.md b/docs/agents/pull-requests.md deleted file mode 100644 index 337e53a9..00000000 --- a/docs/agents/pull-requests.md +++ /dev/null @@ -1,51 +0,0 @@ -# Pull requests - -Every pull request is opened and described with the `visual-pr` skill vendored at -`.agents/skills/visual-pr/` (from [`humanlayer/skills`](https://github.com/humanlayer/skills), -pinned commit `ca7c8088`). The skill is the source of truth for the body shape; -this file carries the publishing steps and the fallback template. - -The skill is the source of truth, not a copy of it: -`npx skills add humanlayer/skills --skill visual-pr`, then invoke `/visual-pr` -(or read `plugins/visual-pr/skills/visual-pr/SKILL.md` in -[`humanlayer/skills`](https://github.com/humanlayer/skills) at commit `ca7c8088`). -The skill owns the body template (`references/pr_description_template.md`) and the -visuals (`references/show-me.md`). Do not reimplement that template here — this -file's template is only the fallback for when the skill is unavailable. - -## Body template - -**Why the change** — one sentence. A reviewer reads it first and it decides -whether the rest is worth reading. - -**Special things to note** — 1-3 bullets: reviewer warnings, migrations, compat -constraints, things deliberately left out, surprising decisions. `- None.` when -there are none. - -**Change outline** — a compact structural view of the change, not prose and not a -file-by-file changelog. Use only the views that explain this pull request: - -- call tree or component tree for a new flow, -- shallow file tree with responsibilities for a broad change, -- SQL schema and endpoint contract changes, -- key type changes, -- control/data flow pseudocode, -- `diff` blocks when an existing shape changes. - -## Publishing - -Save the description to `.humanlayer/tasks/{task-slug}/pr-description.md` when -that task directory exists, otherwise -`.humanlayer/tasks/pr-{number}/description.md`, then publish and re-read it: - -```bash -gh pr edit --body-file # GitHub -glab mr update --description-file # GitLab -``` - -## show-me is a comment, never a body section - -`show-me` (same source repo) is used only when a pull request's design moves -**dramatically** after it was opened — a structural redesign, not local fixes — -and then **as a comment**. The body is never rewritten: it records the design the -pull request opened with. diff --git a/docs/agents/triage-labels.md b/docs/agents/triage-labels.md deleted file mode 100644 index b716855d..00000000 --- a/docs/agents/triage-labels.md +++ /dev/null @@ -1,15 +0,0 @@ -# Triage Labels - -The skills speak in terms of five canonical triage roles. This file maps those roles to the actual label strings used in this repo's issue tracker. - -| Label in mattpocock/skills | Label in our tracker | Meaning | -| -------------------------- | -------------------- | ---------------------------------------- | -| `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue | -| `needs-info` | `needs-info` | Waiting on reporter for more information | -| `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent | -| `ready-for-human` | `ready-for-human` | Requires human implementation | -| `wontfix` | `wontfix` | Will not be actioned | - -When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table. - -Edit the right-hand column to match whatever vocabulary you actually use. diff --git a/skills-lock.json b/skills-lock.json index 3e7163d7..005ed04f 100644 --- a/skills-lock.json +++ b/skills-lock.json @@ -85,12 +85,6 @@ "skillPath": "skills/review-animations/SKILL.md", "computedHash": "b4e5f0f4fe3e2743c85bf7354108f48a0b9d502cb20ef5c4a9c195da91f93736" }, - "setup-matt-pocock-skills": { - "source": "mattpocock/skills", - "sourceType": "github", - "skillPath": "skills/engineering/setup-matt-pocock-skills/SKILL.md", - "computedHash": "552b0f48b9fe054aa93c5d432fefbd7bd9645e3f2d20b4e22432453a81800b21" - }, "tdd": { "source": "mattpocock/skills", "sourceType": "github",