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
43 changes: 33 additions & 10 deletions apps/server/src/pipelines/PipelineService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import * as TestClock from "effect/testing/TestClock";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import {
FEATURE_DELIVERY_PIPELINE,
PIPELINE_STARTERS,
PR_VISUAL_REVIEW_PIPELINE,
pipelineStarterFingerprint,
withStarterRuntimeMode,
type PipelineStarter,
Expand Down Expand Up @@ -194,7 +196,7 @@ it.effect("getRun, subscribeRun and run actions fail for a missing run", () =>

it.effect("seeds each starter once and never brings a deleted one back", () =>
Effect.gen(function* () {
const starters = [FEATURE_DELIVERY_PIPELINE];
const starters = [FEATURE_DELIVERY_PIPELINE, PR_VISUAL_REVIEW_PIPELINE];
// Each build is a server start over the same database.
const start = <A, E>(
starterList: ReadonlyArray<PipelineStarter>,
Expand All @@ -218,14 +220,24 @@ it.effect("seeds each starter once and never brings a deleted one back", () =>
"Feature delivery",
withStarterRuntimeMode(FEATURE_DELIVERY_PIPELINE.steps, "approval-required"),
],
[
"pipeline:starter:pr-visual-review",
"PR visual review",
withStarterRuntimeMode(PR_VISUAL_REVIEW_PIPELINE.steps, "approval-required"),
],
],
);

const second = yield* start(starters, (service) => service.list());
assert.deepStrictEqual(second.pipelines, first.pipelines);

yield* start(starters, (service) => service.delete({ id: first.pipelines[0]!.id }));
assert.deepStrictEqual((yield* start(starters, (service) => service.list())).pipelines, []);
assert.deepStrictEqual(
(yield* start(starters, (service) => service.list())).pipelines.map(
(pipeline) => pipeline.id,
),
["pipeline:starter:pr-visual-review"],
);

const added: PipelineStarter = {
...FEATURE_DELIVERY_PIPELINE,
Expand All @@ -235,7 +247,7 @@ it.effect("seeds each starter once and never brings a deleted one back", () =>
const afterRelease = yield* start([...starters, added], (service) => service.list());
assert.deepStrictEqual(
afterRelease.pipelines.map((pipeline) => pipeline.id),
["pipeline:starter:added-later"],
["pipeline:starter:added-later", "pipeline:starter:pr-visual-review"],
);
}).pipe(Effect.provide(storeLayer)),
);
Expand Down Expand Up @@ -304,12 +316,23 @@ it.effect("an unedited copy of an older starter version is upgraded; an edited o
}).pipe(Effect.provide(storeLayer)),
);

it("the shipped starter's previous step lists are recorded before its steps change", () => {
// Changing the starter's steps changes this fingerprint. Add the old value to the starter's
// previousFingerprints, so unedited copies upgrade, then update it here.
assert.strictEqual(pipelineStarterFingerprint(FEATURE_DELIVERY_PIPELINE.steps), "29vn25aijod");
assert.notInclude(
FEATURE_DELIVERY_PIPELINE.previousFingerprints ?? [],
pipelineStarterFingerprint(FEATURE_DELIVERY_PIPELINE.steps),
it("every shipped starter's previous step lists are recorded before its steps change", () => {
// Changing a starter's steps changes its fingerprint. Add the old value to the starter's
// previousFingerprints, so unedited copies upgrade, then update it here. A new starter adds its
// current fingerprint here.
const pinned: Record<string, string> = {
"feature-delivery": "29vn25aijod",
"pr-visual-review": "803581ncl2",
};
assert.deepStrictEqual(
PIPELINE_STARTERS.map((starter) => starter.key).toSorted(),
Object.keys(pinned).toSorted(),
);
for (const starter of PIPELINE_STARTERS) {
const current = pipelineStarterFingerprint(starter.steps);
assert.strictEqual(current, pinned[starter.key]);
for (const other of PIPELINE_STARTERS) {
assert.notInclude(other.previousFingerprints ?? [], current);
}
}
});
28 changes: 19 additions & 9 deletions docs/user/pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@ Pipelines need a T3 Code server that supports them. Update an older server befor
## Set up a pipeline

Define pipelines in **Settings → Pipelines**. Choose **New pipeline** and start from **Blank** or
from the **Feature delivery** template, a full feature-delivery flow from requirements to merge and
follow-through. Its last step waits until you start it, then merges the pull request and does the
post-merge work. Each step stops the dev servers, containers and other temporary resources it
started once no later step needs them, and the last step sweeps up anything left over from QA.
T3 Code adds it once. If you delete it, it stays deleted, and you can recreate it from the
template. While you have not edited a pipeline made from the template, it is updated to the latest
template when T3 Code updates. Once you edit it, or an agent edits it for you, it is yours and
stays as you left it.
from a template:

- **Feature delivery**: a full feature-delivery flow from requirements to merge and follow-through.
Its last step waits until you start it, then merges the pull request and does the post-merge
work. Each step stops the dev servers, containers and other temporary resources it started once no
later step needs them, and the last step sweeps up anything left over from QA.
- **PR visual review**: for reviewing someone else's work. Start it with a pull request link or
number. It reads the change, captures before and after screenshots, and builds a visual review
guide that ends with questions and concerns you can turn into review comments. Its steps are told
never to comment on, approve, change or merge the pull request. It runs the pull request's code
with your default permission mode, so for pull requests from people you don't trust, set its steps
to **Supervised**. Because it checks out the pull request's head commit, choose **New worktree**
when you start it so your own branch isn't switched.

T3 Code adds each template once. If you delete one, it stays deleted, and you can recreate it from
the template. While you have not edited a pipeline made from a template, it is updated to the
latest template when T3 Code updates. Once you edit it, or an agent edits it for you, it is yours
and stays as you left it.

Each step has a name, a provider and model, a prompt template, optional skills, and a
[permission mode](./permission-modes.md). Pipelines have no plan mode. The starter's steps use the
[permission mode](./permission-modes.md). Pipelines have no plan mode. The templates' steps use the
default runtime mode from your settings. You can also make a step wait for you before it starts.

You can also ask an agent to create or edit a pipeline for you. New steps use the agent's model
Expand Down
75 changes: 74 additions & 1 deletion packages/shared/src/pipelineStarters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,80 @@ Finish with a summary: the pull request URL and merge commit; the base branch's
],
};

export const PIPELINE_STARTERS: ReadonlyArray<PipelineStarter> = [FEATURE_DELIVERY_PIPELINE];
export const PR_VISUAL_REVIEW_PIPELINE: PipelineStarter = {
key: "pr-visual-review",
name: "PR visual review",
description: "Understand → Capture → Guide",
steps: [
step({
id: "understand",
name: "Understand the change",
modelSelection: claude("claude-opus-5-5", "medium"),
compactAfterHandoff: true,
promptTemplate: `You are the first step of a review pipeline. Someone else wrote this work and I review it. Later steps only see what you write.

What to review (a pull request link or number, a branch, or a description):
{{input}}

1. Find the work: the pull request, its description, comments, linked ticket, base branch and head commit. If you cannot tell which work I mean, ask me with your question tool and wait.
2. Check out the head commit in this checkout so later steps can run it. Do not commit, push or change files.
3. Read the full diff against its base, plus the code and docs it touches, and the repo's instructions (AGENTS.md, CLAUDE.md, CONTRIBUTING).
4. Read it critically: does it do what the description says, what is surprising, risky or missing, and what is not covered by tests.

This pipeline only prepares a review for me. Never comment on, approve, request changes on, merge or edit the pull request, the ticket or CI.

Finish with: pull request link, base branch and head commit, the author's intent in their own words, what changed grouped by area, every user-visible change with where to see it (URL, route, screen, command, setting), what stayed internal, open questions for the author, and risks or concerns with file and line.`,
}),
step({
id: "capture",
name: "Capture before and after",
modelSelection: claude("claude-sonnet-5-5", "medium"),
compactAfterHandoff: true,
promptTemplate: `Capture what this change looks like, before and after.

Change summary:
{{steps.understand.output}}

1. Run the app the way the repo documents it, isolated from production and personal data. Start long-running processes detached and record their PIDs and ports.
2. For every user-visible change, take a screenshot on the head commit and the same view on the base commit. Cover the main path, plus empty, error and narrow or mobile states where the change affects them, and dark mode if the app has one. Record a short video for motion or timing.
3. Save every capture outside the tracked tree (a gitignored or temp folder), named by change and before/after.
4. If something cannot be shown visually (backend, data, CI), capture the closest evidence instead: a log, a response, a test run.
5. Note anything that looks broken or off: spacing, overflow, contrast, wording, inconsistency with the rest of the app. Do not fix it.
6. Stop the processes you started, then check out the head commit again.

Do not change code, commit or push, and never comment on or edit the pull request.

Finish with: the capture folder, a list of captures (file, what it shows, before or after), what you could not capture and why, and the visual issues you noticed.`,
}),
step({
id: "guide",
name: "Visual review guide",
modelSelection: claude("claude-sonnet-5-5", "medium"),
compactAfterHandoff: true,
promptTemplate: `Prepare a visual review guide for me, as if the author walks me through their change at their desk.

Change summary:
{{steps.understand.output}}

Captures:
{{steps.capture.output}}

- Focus on what I can see: before and after screenshots side by side, simple diagrams of flows and how the pieces connect, and short, plain sentences. Keep the information density low: one idea per section.
- Show code only when it is essential to understand a decision, and keep it to a few lines.
- Order it as a walkthrough: what changed and why, each user-visible change, how it works behind the scenes, and what I should look at closely. End with the open questions for the author and the concerns found, each with file and line, so I can turn them into review comments myself.
- Make it one self-contained HTML page with the images embedded, saved outside the tracked tree. Show it with your HTML preview tool if you have one, and link the pull request.

Do not change code, and never comment on, approve or edit the pull request.

Finish with the path to the guide and a three-line summary.`,
}),
],
};

export const PIPELINE_STARTERS: ReadonlyArray<PipelineStarter> = [
FEATURE_DELIVERY_PIPELINE,
PR_VISUAL_REVIEW_PIPELINE,
];

export const withStarterRuntimeMode = (
steps: ReadonlyArray<PipelineStarterStep>,
Expand Down
Loading