Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .agents/finalizer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: finalizer
description: Closes a @northguild/gmt story after tdd-dev and tester — TanStack Intent skills, the changeset, READMEs, the dox reference corpus and stats, the tracker Status, validate — and drafts the commit message and PR description for the owner. Never commits, opens PRs, versions or publishes.
description: Closes a @northguild/gmt story after tdd-dev and tester — TanStack Intent skills, the changeset, READMEs, the dox reference corpus and stats, the tracker Status, validate — and drafts the commit message and PR description for the owner. Merges `origin/main` in and labels an open PR; otherwise never commits, opens PRs, versions or publishes.
model: sonnet
disallowedTools: Agent
---
Expand All @@ -13,7 +13,7 @@ You are the Finalizer for the `@northguild/gmt` project. You close stories by ha

**Temporal type system:** Full working knowledge across all GMT types and their public string contracts.

**GMT rules:** [AGENTS.md § Core Rules](../AGENTS.md#core-rules-quick-reference) and [§ Git — Only on an Explicit Instruction](../AGENTS.md#git--only-on-an-explicit-instruction). You do not stage, commit, push, branch or open a PR unless the user asks you to.
**GMT rules:** [AGENTS.md § Core Rules](../AGENTS.md#core-rules-quick-reference) and [§ Git — Only on an Explicit Instruction](../AGENTS.md#git--only-on-an-explicit-instruction). You do not stage, commit, push, branch or open a PR unless the user asks you to. The two standing instructions there are yours to carry out: merge `origin/main` in (step 1) and label an open PR (step 11).

**Release workflow:** Deep familiarity with `PUBLISHING.md`. This agent's release output is exactly one thing: a well-written `.changeset/*.md` on the feature branch. Versioning and publishing are both `release.yml`'s job — never run `changeset version`, `npm publish`, `changeset publish`, or `gh release create`.

Expand All @@ -23,11 +23,21 @@ You are the Finalizer for the `@northguild/gmt` project. You close stories by ha

## Role

Story closer. Called after `tdd-dev` (and optionally `tester`) complete. Produces all release-intent artifacts and hands off. It never publishes — see step 11.
Story closer. Called after `tdd-dev` (and optionally `tester`) complete. Produces all release-intent artifacts and hands off. It never publishes — see step 12.

## Workflow

1. **Read `context/domination/tracker.md`** to identify the current story, its GitHub issue number, and its row. No release decision is yours to make — see step 11.
1. **Bring in `main`, before you edit anything.** As [AGENTS.md § Git](../AGENTS.md#git--only-on-an-explicit-instruction)
says: `git fetch origin main`, then `git merge origin/main` if the branch is behind. Resolve
each conflict so both sides' changes survive, and commit the merge (the merge only, never the
story's work). Do not run `validate` before this commit: the published figures are synced
only at step 4 (`pnpm stats:sync`), so on a story with new tests `stats check` fails here for
a reason the merge did not cause. Step 9's `validate` checks the merged tree. The merge comes first because steps 4 and 7 edit the READMEs and the tracker, which
`main` changes most often; once those are edited, git refuses the merge. If git refuses here,
the story's own uncommitted changes touch the incoming files: stop and name those files to
the main session.

Then **read `context/domination/tracker.md`** to identify the current story, its GitHub issue number, and its row. No release decision is yours to make — see step 12.

2. **If public API surface changed:** update the TanStack Intent agent skills in `packages/gmt/skills/` (new functions, renamed functions, new options, new domain concept). See `PUBLISHING.md` contributor flow step 2.

Expand Down Expand Up @@ -120,7 +130,7 @@ Story closer. Called after `tdd-dev` (and optionally `tester`) complete. Produce
- Report each item to the main session, so the fix loops back through `tdd-dev`.
- Never describe a known defect in a changeset, issue file, JSDoc, README or PR description as something that ships. It gets fixed instead.

9. **Verify before handing off.** `node scripts/verdict.mjs validate` must print PASS — it is the
9. **Verify before handing off.** `main` came in at step 1. `node scripts/verdict.mjs validate` must print PASS — it is the
epic's Definition of Done. It runs the same checks as `pnpm run validate`: every check that
reads a file the branch changed, against `origin/main`, one row each; `--full` runs them all.
Do not report a story closed on a run that stopped early.
Expand Down Expand Up @@ -160,7 +170,11 @@ Story closer. Called after `tdd-dev` (and optionally `tester`) complete. Produce
of `plan_gate.py`'s tests use the deleted spec, and run `pnpm run validate` again: a comment
edit can still break a file's syntax.

11. **Stop.** There is no publish step to run. Merging the feature PR publishes
11. **Label the PR.** If the branch has an open PR, run `node scripts/pr-meta.mjs --apply`: it
adds the labels, the milestone and the other collaborator as reviewer. With no PR yet, run it
without `--apply` and put its plan in the hand-off, so whoever opens the PR applies it.

12. **Stop.** There is no publish step to run. Merging the feature PR publishes
nothing; the changeset sits on `main` until a human opens a release PR
carrying the output of `pnpm run changeset:version`, and merging that PR is
what ships to npm.
Expand Down
5 changes: 4 additions & 1 deletion .agents/skills/pipeline/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ disputed reading of a standard. Say so in the report. The agent files' defaults
refuses to close a story that carries one ([Core Rule 12](../../../AGENTS.md#core-rules-quick-reference)).
4. **Escalate blockers** — an ambiguous spec, a design conflict, tests that cannot pass: stop
and report to the user with full context. No step fails or is skipped silently.
5. **Nothing is committed.** The pipeline ends with unstaged changes plus drafted commit and PR
5. **Nothing is committed** but a merge from `main`. Bring `origin/main` in when the story starts
and again as `finalizer`'s first step ([AGENTS.md § Git](../../../AGENTS.md#git--only-on-an-explicit-instruction)
has the two standing instructions); `finalizer` labels an open PR with `scripts/pr-meta.mjs`.
The pipeline ends with unstaged changes plus drafted commit and PR
text for the owner. Never run `changeset version`, `changeset publish`, `npm publish` or
`gh release create` (see `PUBLISHING.md`).

Expand Down
6 changes: 4 additions & 2 deletions .agents/skills/pipeline/references/inline-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ finding is open, return to Step 2 with the list.

## Step 4 — Story closure

Adopt the [`finalizer`](../../../finalizer.md) role and follow its workflow: skills, changeset
Adopt the [`finalizer`](../../../finalizer.md) role and follow its workflow: merge `origin/main`
in first and commit that merge (a standing instruction in
[AGENTS.md § Git](../../../../AGENTS.md#git--only-on-an-explicit-instruction)), then skills, changeset
(per the [changeset rule](../../../../context/coding-standards.md#changesets)), READMEs, dox
corpus and stats, tracker `Status` + `pnpm deps:sync`, `pnpm run validate`. Draft a commit
message with `/commit-message` and a PR description with `/pr-desc` **for the owner to use** —
never commit or open the PR.
never commit the story's work or open the PR.

## Context files per role

Expand Down
2 changes: 1 addition & 1 deletion .agents/skills/pr-desc/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The changeset(s) in `.changeset/` and their bump level, per [coding-standards §

## Delivery

Output the full description in a plain fenced code block (no language tag) so it can be copied. Do not write it to a file unless the user asks for one and names the path. Never create the PR yourself — the repository owner opens every PR.
Output the full description in a plain fenced code block (no language tag) so it can be copied. Do not write it to a file unless the user asks for one and names the path. Never create the PR yourself — the repository owner opens every PR. End with the output of `node scripts/pr-meta.mjs` (labels, milestone, reviewer); once the PR exists, `node scripts/pr-meta.mjs --apply` sets them.

## Rules

Expand Down
3 changes: 2 additions & 1 deletion .agents/skills/release/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ Node, so it catches a failure that only happens in CI (#453).
is in the tree and has not been pushed.
- **`gh pr create --base main --head release/<name> --title "<subject>" --label release
--body-file <file>`**, with the body file outside the tree. If the label does not exist, open the
PR without it and say so.
PR without it and say so. Then run `node scripts/pr-meta.mjs --apply` to ask the other
collaborator for review.

Write the body in plain English (the [`plain-english` skill](../plain-english/SKILL.md)):

Expand Down
25 changes: 23 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ Read these before working in the repo. Each is scoped — load only what you nee
**The default is always: finish the work, leave it unstaged in the working tree,
and say it is ready.** Do not stage, commit, branch, push or open a pull request
on your own initiative — not as a checkpoint, not "so nothing is lost", not
because the work looks finished.
because the work looks finished. The only exceptions are the two standing
instructions at the end of this section.

**Do them when the user tells you to, in plain words, in the current session.**
"Commit this", "push the branch", "open the PR" are instructions: carry them out
and report what you did. An instruction covers the operation it names for the
work in hand. It is not a standing licence — a later, separate write needs its
own instruction. Typing a skill whose job is one of these operations is the
own instruction, unless it is one of the two standing instructions below. Typing a skill whose job is one of these operations is the
instruction for that run: `/release` commits, pushes and opens its release PR.

**Never infer the permission.** It has to come from the user, about this
Expand All @@ -58,6 +59,26 @@ does not authorise force-pushing it.
If one of these seems genuinely necessary and nobody has asked for it, stop and
ask in plain words.

**Two standing instructions from the owner.** These need no new word each time:
Comment thread
baldurpan marked this conversation as resolved.
Resolved

- **Keep the branch up to date with `main`.** Do this when work on a branch starts, as
`finalizer`'s first step (before it edits the READMEs or the tracker), and before any push.
Commit the merge only, never the story's own work. Run `git fetch origin main`, then
`git merge origin/main` when the branch is behind. Never rebase, because the branch is
published. Resolve every conflict so both sides' changes survive, run
`node scripts/verdict.mjs validate`, and commit the merge. At `finalizer`'s first step, commit
the resolved merge without `validate`: the story's published figures are synced only at its
step 4, so `validate` would fail for a reason the merge did not cause, and its step 9 runs
`validate` on the merged tree before hand-off. If uncommitted work touches the
incoming files, git refuses the merge. Do not stash (the stash is shared): name the files to
the owner and merge once the work is committed. Pushing the merge still needs the owner's word.
On an open PR, `gh pr view --json mergeable` shows whether GitHub sees a conflict.
- **A PR gets its labels, milestone and reviewer.** Run `node scripts/pr-meta.mjs --apply` right
after a PR is opened, and when `finalizer` closes a story whose PR is already open. It only
adds: labels from the commit types and changed paths, the closed issue's milestone (else the
story's tracker), and the other collaborator as reviewer. A run without `--apply` changes
nothing and shows the plan.

## Core Rules (Quick Reference)

These are the non-negotiables. Full detail is in the context files above.
Expand Down
4 changes: 4 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Copyright (c) 2026 NorthGuild. All rights reserved under [`.agents/LICENSE`](.ag
initiative.** Finish the work, leave it **unstaged in the working tree**, and say
it is ready.

**Two standing exceptions** need no new word each time: merge `origin/main` into
the branch and commit that merge (never the story's work, and never push it), and
run `node scripts/pr-meta.mjs --apply` on an open PR. AGENTS.md § Git says when.

**Do it when the user explicitly tells you to** — "commit this", "push it",
"open the PR" — in plain words, in this session. Then do it and report back.

Expand Down
219 changes: 219 additions & 0 deletions apps/dox/scripts/pr-meta/plan.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
import { execFileSync } from "node:child_process";
import { fileURLToPath } from "node:url";

import { describe, expect, it } from "vitest";

import {
PATH_RULES,
planMeta,
storyIdOf,
} from "../../../../scripts/lib/pr-meta-plan.mjs";

/** The pure planner behind `scripts/pr-meta.mjs`. Branches and paths are from merged northguild/gmt PRs. */

const TRACKERS = {
"context/dox/tracker.md": "| DOX-G6 | Done | #448 |\n",
"context/domination/tracker.md":
"| SPA-46 | Done | #227 |\n| CORE-105 | Done | #437 |\n",
};

const facts = (over: Partial<Parameters<typeof planMeta>[0]>) => ({
branch: "x",
subjects: [],
paths: [],
closingIssues: [],
trackers: TRACKERS,
milestones: ["Dox", "Domination", "Ultimation"],
viewer: "craig-o-curtis",
author: null,
collaborators: ["baldurpan", "craig-o-curtis"],
...over,
});

describe("storyIdOf", () => {
it.each([
["448-dox-g6-research-and-improve-how-search-engines", "DOX-G6"],
["feature/227-spa-46-tai64-text-labels", "SPA-46"],
["core-109-hero-sun-one-camera", "CORE-109"],
["437-core-105-split-zonedwallclockdiffere", "CORE-105"],
["447-featdox-unify-entrance-of-gmt-docs-w", null],
["chore/add-worktree-config", null],
["release/2026-11-03", null],
])("%s → %s", (branch, id) => {
expect(storyIdOf(branch)).toBe(id);
});
});

describe("planMeta labels", () => {
it("reads commit types and paths, as #476 (feat, library, Intent skills, docs) was labelled", () => {
const plan = planMeta(
facts({
branch: "feature/227-spa-46-tai64-text-labels",
subjects: [
"feat(domination): TAI64N text labels, toTai64n and fromTai64n (SPA-46)",
],
paths: [
"packages/gmt/src/timescale/convert/toTai64n.ts",
"packages/gmt/skills/gmt-timescale/SKILL.md",
"context/domination/tracker.md",
"apps/dox/src/content/docs/guides/tai64.mdx",
],
}),
);
expect(plan.labels).toEqual([
"documentation",
"enhancement",
"gmt",
"skills",
]);
});

it("labels workflows pipes, tooling gmt monorepo and agent files ai skills, as #439 was", () => {
const plan = planMeta(
facts({
branch: "chore/add-release-skill",
subjects: ["chore: add the release skill"],
paths: [
".agents/skills/release/SKILL.md",
"AGENTS.md",
".github/workflows/release.yml",
"scripts/changelog.mjs",
],
}),
);
expect(plan.labels).toEqual(["ai skills", "gmt monorepo", "pipes"]);
});

it("counts Dox build scripts as tooling, not documentation", () => {
const plan = planMeta(
facts({
paths: [
"apps/dox/scripts/pr-meta/plan.test.ts",
"apps/dox/src/pages/index.astro",
],
}),
);
expect(plan.labels).toEqual(["documentation", "gmt monorepo"]);
expect(
planMeta(facts({ paths: ["apps/dox/scripts/build-guides.mjs"] })).labels,
).toEqual(["gmt monorepo"]);
});

it.each([
["oxlint.config.mts", "gmt monorepo"],
[".fallowrc.jsonc", "gmt monorepo"],
[".node-version", "gmt monorepo"],
["pyproject.toml", "gmt monorepo"],
["uv.lock", "gmt monorepo"],
["skills-lock.json", "gmt monorepo"],
["context7.json", "gmt monorepo"],
[".vscode/settings.json", "gmt monorepo"],
[".github/ISSUE_TEMPLATE/bug.yml", "gmt monorepo"],
[".github/PULL_REQUEST_TEMPLATE.md", "gmt monorepo"],
[".changeset/config.json", "gmt monorepo"],
["docs/dst-disambiguation.md", "documentation"],
["LICENSE", "documentation"],
["apps/LICENSE", "documentation"],
])("labels %s alone %s", (path, label) => {
expect(planMeta(facts({ paths: [path] })).labels).toEqual([label]);
});

it("gives every tracked path a label, except a changeset entry", () => {
const tracked = execFileSync("git", ["ls-files"], {
cwd: fileURLToPath(new URL("../../../..", import.meta.url)),
encoding: "utf8",
})
.split("\n")
.filter(Boolean);
const unlabelled = tracked.filter(
(path) =>
!PATH_RULES.some((rule) => rule.test.test(path)) &&
!/^\.changeset\/(?!config\.json$|README\.md$)[^/]+\.md$/.test(path),
);
expect(tracked.length).toBeGreaterThan(1000);
expect(unlabelled).toEqual([]);
});

it("gives a changeset entry no label of its own", () => {
expect(
planMeta(facts({ paths: [".changeset/tai64n-text-labels.md"] })).labels,
).toEqual([]);
});

it("gives a fix bug, and a breaking feat! enhancement", () => {
expect(
planMeta(facts({ subjects: ["fix(dox): one option per unit"] })).labels,
).toEqual(["bug"]);
expect(
planMeta(facts({ subjects: ["feat(gmt)!: split the type"] })).labels,
).toEqual(["enhancement"]);
});

it("gives a release branch only `release`, whatever it touches", () => {
const plan = planMeta(
facts({
branch: "release/2026-11-03",
subjects: ["release: v1.21.0"],
paths: ["packages/gmt/CHANGELOG.md"],
}),
);
expect(plan.labels).toEqual(["release"]);
});
});

describe("planMeta milestone", () => {
it("takes the closed issue's milestone first", () => {
const plan = planMeta(
facts({
branch: "448-dox-g6-x",
closingIssues: [
{ number: 456, milestone: null },
{ number: 448, milestone: "Dox" },
],
}),
);
expect([plan.milestone, plan.milestoneFrom]).toEqual(["Dox", "#448"]);
});

it("falls back to the tracker that holds the story's row", () => {
const plan = planMeta(
facts({
branch: "437-core-105-split",
closingIssues: [{ number: 437, milestone: null }],
}),
);
expect([plan.milestone, plan.milestoneFrom]).toEqual([
"Domination",
"context/domination/tracker.md",
]);
});

it("is none for a branch with no story and no milestoned issue", () => {
expect(
planMeta(facts({ branch: "chore/add-worktree-config" })).milestone,
).toBeNull();
});

it("leaves off a milestone that is not open", () => {
const plan = planMeta(
facts({
closingIssues: [{ number: 1, milestone: "Dox" }],
milestones: ["Domination"],
}),
);
expect(plan.milestone).toBeNull();
expect(plan.milestoneFrom).toContain("not an open milestone");
});
});

describe("planMeta reviewer", () => {
it("asks the other collaborator: baldurpan for the viewer's new PR", () => {
expect(planMeta(facts({})).reviewers).toEqual(["baldurpan"]);
});

it("follows the PR's author, not the viewer, once the PR exists", () => {
expect(planMeta(facts({ author: "baldurpan" })).reviewers).toEqual([
"craig-o-curtis",
]);
});
});
2 changes: 1 addition & 1 deletion scripts/lib/affected.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export const RULES = [
checks: ["typecheck:dox", ...SCRIPT_TESTS],
},
{
test: /^scripts\/(?:verdict|lib\/(?:verdict-(?:format|parse)|pr-status-plan))\.mjs$/,
test: /^scripts\/(?:verdict|pr-meta|lib\/(?:verdict-(?:format|parse)|pr-status-plan|pr-meta-plan))\.mjs$/,
checks: ["typecheck:dox", ...SCRIPT_TESTS],
},
{
Expand Down
Loading
Loading