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
3 changes: 2 additions & 1 deletion .github/workflows/pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ jobs:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
with:
pr-number: ${{ github.event.pull_request.number }}
model: cloudflare-workers-ai/@cf/moonshotai/kimi-k2.6
# Kimi K2.6 was retired by Workers AI on 2026-11-20.
model: cloudflare-workers-ai/@cf/zai-org/glm-4.7-flash
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:

- uses: actions/setup-node@v4
with:
# Flue 0.11.1 requires Node >=22.18.0.
node-version: '22.18.0'
# Flue 2.3.1 requires Node >=22.19.0.
node-version: '22.19.0'
cache: pnpm

- name: Install dependencies
Expand All @@ -47,7 +47,7 @@ jobs:
run: npx -p typescript tsc --noEmit -p tsconfig.json

- name: Test
run: node --test test/
run: node --test test/*.test.mjs

- name: Build
run: pnpm build
Expand All @@ -60,7 +60,7 @@ jobs:
run: |
declared="v$(node -p 'require("./package.json").version')"
if [ "$declared" != "$TAG" ]; then
echo "package.json version ($declared) does not match tag ($TAG)." >&2
echo "Version mismatch: package.json=$declared, tag=$TAG" >&2
echo 'Bump package.json and re-tag.' >&2
exit 1
fi
Expand All @@ -80,4 +80,6 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: gh release create "$TAG" --title "$TAG" --generate-notes --verify-tag
run: >-
gh release create "$TAG" --title "$TAG"
--generate-notes --verify-tag
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
node_modules/
dist/
.flue-vite/
.flue-vite.wrangler.jsonc
*.log

# Local secrets — never commit. See .env.example.
Expand Down
20 changes: 10 additions & 10 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A pnpm-workspace monorepo of [Flue](https://flueframework.com) agents. Today it
holds one agent — a pull-request review agent — with room for more under
`workflows/`.

- **Runtime:** Flue `0.11.1`, TypeScript, Node `>=22.18.0`, pnpm.
- **Runtime:** Flue `2.3.1`, TypeScript, Node `>=22.19.0`, pnpm.
- **Layout:** root layout (agents in `./workflows`, not `./.agents`).

## Project map
Expand All @@ -21,8 +21,8 @@ holds one agent — a pull-request review agent — with room for more under
| `workflows/*.ts` | Agent entrypoints. Each file is one agent. |
| `skills/<name>/SKILL.md` | Global skills, statically imported and registered on an agent. |
| `prompts/*.md` | Global prompt guidance loaded at runtime. |
| `personas/*.ts` | `defineAgentProfile()` subagents, exported via `personas/index.ts`. |
| `app.ts` | Runtime app entry; exports `flue()`. Register extra model providers here. |
| `personas/*.ts` | `defineSubagent()` subagents, exported via `personas/index.ts`. |
| `app.ts` | HTTP app entry; intentionally exposes no agent routes. |
| `lib/model.ts` | `requireModel()` — every agent must be given a provider-qualified model; there is no default. |
| `actions/pr-review/` | Composite GitHub Action consuming repos use. |
| `CHANGELOG.md` | Release log. Both actions share one repo-level version. |
Expand All @@ -33,7 +33,7 @@ holds one agent — a pull-request review agent — with room for more under

```bash
pnpm install # install deps (uses pnpm-lock.yaml)
pnpm build # flue build -> dist/server.mjs
pnpm build # vite build -> dist/server.mjs
REVIEW_MODEL=cloudflare-workers-ai/@cf/moonshotai/kimi-k2.6 \
pnpm review -- --payload '{"prNumber":123,"repo":"owner/name"}' # run the agent locally
npx -p typescript tsc --noEmit -p tsconfig.json # type-check
Expand All @@ -47,17 +47,17 @@ finishing.
- **Adding an agent:** add `workflows/<name>.ts` (shares the globals here) or
promote it to its own package under `packages/*` and list it in
`pnpm-workspace.yaml`. Resolve its model with
`requireModel(ctx.env.<NAME>_MODEL, '<NAME>_MODEL')` — never hard-code one.
`requireModel(process.env.<NAME>_MODEL, '<NAME>_MODEL')` — never hard-code one.
- **Models:** no default model and no default provider. Each agent reads its own
`*_MODEL` env var (set by the composite action's required `model` input in CI,
or `.env` locally); provider credentials come from the environment.
- **Adding a global skill:** create `skills/<name>/SKILL.md`, import it in the
workflow with `… with { type: 'skill' }`, add it to the `skills` array.
- **Adding a global skill:** create `skills/<name>/SKILL.md`, import its
`SKILL.md` in the agent module and mount it with `useSkill()`.
- **Adding global prompts:** drop a `prompts/*.md` file — no code change.
- **Adding a persona:** create `personas/<name>.ts` exporting
`defineAgentProfile(...)` and add it to `personas/index.ts`.
- The `*.md` skill import is typed loosely in `flue-env.d.ts`; Flue's Vite build
resolves the real type. Don't tighten it unless Flue ships a proper type.
`defineSubagent(...)` and add it to `personas/index.ts`.
- `flue-env.d.ts` references Flue's shipped markdown and skill import types.
Vite resolves skill directories when loading workflows.

## Releasing

Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ refuses a tag that doesn't match `package.json`.
pi-ai's catalog (`cloudflare-workers-ai/*`, `anthropic/*`, …) need no
registration; anything else can be registered there.

### Changed

- Upgrade Flue from 0.11.1 to 2.3.1. Migrate both jobs to the standalone
Node API, with hook-based agents, validated result tools, and Vite builds.
- Local runs use `pnpm review` and `pnpm issue-health`; the removed
`flue run <workflow> --payload` command is no longer supported.
- Raise the Node minimum to 22.19.0. Both actions install that version.
Action inputs and provider credentials are unchanged.

### Added

- Tagged releases. `Release` (`.github/workflows/release.yml`) validates a
Expand Down
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ organization. It's one pnpm-workspace monorepo: each agent is a workflow in
skills / prompts / personas.

The current agents are **PR Review** and **Issue Health Check**. Local builds and
runs require Node 22.18.0 or newer (the Flue 0.11.1 runtime floor) and pnpm.
runs require Node 22.19.0 or newer (the Flue 2.3.1 runtime floor) and pnpm.

## Agents

Expand Down Expand Up @@ -40,7 +40,7 @@ agents/ # pnpm workspace root — a fleet of agents
consumer-workflow.yml # copy-paste workflows for consuming repos
issue-health-workflow.yml
sample-consumer/.agents/ # example per-repo overrides
app.ts # runtime entry (register extra model providers here)
app.ts # HTTP entry (no agent routes exposed)
flue.config.ts # default target (node)
.github/workflows/
pr-review.yml # dogfoods the action on this repo's PRs
Expand All @@ -50,13 +50,12 @@ agents/ # pnpm workspace root — a fleet of agents

Every agent here is assembled the same way — PR Review is the worked example:

- **Skills** are registered on the agent in `createAgent({ skills: [...] })`, so
they are part of the agent, not the payload. Add one: drop
`skills/<name>/SKILL.md`, import it in `workflows/pr-review.ts`, add it to the
`skills` array.
- **Skills** are mounted with `useSkill()`, so they are part of the agent,
not the payload. Add one: create `skills/<name>/SKILL.md`, import it in
`workflows/pr-review.ts`, and mount it in the agent function.
- **Prompts** in `prompts/*.md` are read by the `code-review` skill on every run
(filename order). Drop a file in — it applies to the next PR, no code change.
- **Personas** in `personas/*.ts` are registered as `subagents`, so the reviewer
- **Personas** in `personas/*.ts` are mounted with `useSubagent()`, so the reviewer
can delegate focused deep-dives (`security`, `correctness`, …) on any PR.
- **The reviewer's persona and standing rules** live in
`skills/code-review/SKILL.md` — that skill *is* the agent's behavior.
Expand All @@ -68,19 +67,19 @@ Every agent here is assembled the same way — PR Review is the worked example:
Skills only *analyze* and return structured data; workflows render comments,
post them with `gh`, and apply any labels from deterministic code paths.
(Smaller models can't be trusted to reliably run mutation steps.)
- **MCP tools** can be attached at runtime: `connectMcpServer(url)`, then pass
the connection's `tools` to `init(agent, { tools })`. PR Review connects the
Flipt docs MCP so it can ground reviews in the documentation.
- **MCP tools** can be attached at runtime with `createMcpConnection()` and
mounted with `useTool()`. PR Review connects the Flipt docs MCP so it can
ground reviews in the documentation.

The payload only ever carries *which artifact* to inspect (for example
`prNumber` or `issueNumber`, plus optional `repo`) — never the skills or
prompts.

## Subagents / personas

Flue supports subagents via `defineAgentProfile({ name, instructions })`,
registered in `createAgent({ subagents: [...] })` and invoked with
`session.task(text, { agent: 'name' })`. There is no markdown auto-discovery for
Flue supports subagents via `defineSubagent({ name, description, agent })`,
mounted with `useSubagent()` and invoked by the model's `task` tool.
There is no markdown auto-discovery for
personas (that exists only for skills), so each persona is a small TS module in
`personas/` exported through `personas/index.ts`. Add one and add it to that
array.
Expand All @@ -105,7 +104,7 @@ Neither needs an `app.ts` change: Flue resolves both through pi-ai's built-in
catalog. Reasoning models work over `cloudflare-workers-ai/*` because the
`openai-completions` adapter sends `max_completion_tokens` automatically when
the catalog marks a model as reasoning-capable. To use a provider pi-ai doesn't
know, register it in `app.ts`. See
know, register it in the workflow module before calling `start()`. See
[`actions/pr-review/README.md`](actions/pr-review/README.md#models).

## Versioning
Expand Down Expand Up @@ -195,11 +194,11 @@ agent, not just this one. The `override-mode` input controls whether those
```bash
cp .env.example .env # REVIEW_MODEL + its provider creds, GH_TOKEN for gh
pnpm install
pnpm exec flue run pr-review --payload '{"prNumber": 123, "repo": "owner/name"}'
pnpm review -- --payload '{"prNumber": 123, "repo": "owner/name"}'
```

`flue run` builds the project, invokes the workflow, and prints the structured
verdict as JSON.
`pnpm review` loads the workflow through Vite, runs it with Flue's standalone
Node API, and prints the structured verdict as JSON.

## The Issue Health Check agent

Expand Down Expand Up @@ -266,19 +265,18 @@ pnpm install
pnpm issue-health -- --payload '{"issueNumber":123,"repo":"owner/name"}'
```

`pnpm issue-health` runs the `flue run issue-health` package script, fetches the
`pnpm issue-health` runs the standalone Node workflow, fetches the
issue from `repo`, posts according to `ISSUE_HEALTH_COMMENT_MODE` (default
`always`), applies labels according to `ISSUE_HEALTH_LABEL_MODE` (default
`existing-only`), and prints the structured result as JSON.

## Adding an agent

Add `workflows/<name>.ts` — it shares everything above: the runtime entry in
`app.ts`, required model selection via `requireModel(ctx.env.<NAME>_MODEL, …)`,
and the skills / prompts / personas patterns. Give it its own skill(s) under `skills/`, prompt guidance under
`prompts/`, and personas under `personas/` as needed, then register them on the
agent. Run it with `flue run <name>`, and (if it should be consumable by other
repos) add an action under `actions/<name>/`.
Add a synchronous agent function using Flue's hooks and a deterministic job
under `workflows/<name>.ts`. Select the model with `requireModel`, mount skills
with `useSkill`, and keep GitHub writes outside the model. Add the job to
`scripts/run.mjs` and give it a package script. If other repositories need it,
add an action under `actions/<name>/`. `app.ts` deliberately exposes no HTTP routes.

For independent builds/deploys, promote an agent into its own package under
`packages/*` and list it in `pnpm-workspace.yaml`.
7 changes: 3 additions & 4 deletions actions/issue-health/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ The directory still uses the same shape (`prompts/`, `skills/`, `personas/`) as
The composite action resolves this agents repo, installs dependencies, and runs:

```bash
pnpm exec flue run issue-health --payload '{"issueNumber": 123, "repo": "owner/name"}'
pnpm issue-health -- --payload '{"issueNumber": 123, "repo": "owner/name"}'
```

It sets the `ISSUE_HEALTH_*` environment variables consumed by
Expand Down Expand Up @@ -142,7 +142,6 @@ the process environment, not from action inputs.
model: anthropic/claude-sonnet-4-6
```

Flue resolves both providers through pi-ai's built-in catalog; nothing needs
registering in the agents repo's `app.ts` unless you add a provider pi-ai
doesn't know. Locally, set `ISSUE_HEALTH_MODEL` plus that provider's
Flue resolves both providers through pi-ai's built-in catalog. For a provider
outside that catalog, register it in the workflow module before calling `start()`. Locally, set `ISSUE_HEALTH_MODEL` plus that provider's
credentials in `.env`.
6 changes: 3 additions & 3 deletions actions/issue-health/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ runs:

- uses: actions/setup-node@v4
with:
# Flue 0.11.1 requires Node >=22.18.0.
node-version: '22.18.0'
# Flue 2.3.1 requires Node >=22.19.0.
node-version: '22.19.0'
# No setup-node pnpm cache: when this action is consumed from another
# repo, the lockfile lives under _actions/ (outside the caller's
# workspace), which setup-node's cache globber can't resolve. The
Expand Down Expand Up @@ -110,4 +110,4 @@ runs:
}
process.stdout.write(JSON.stringify({ issueNumber, repo: process.env.ISSUE_REPO }));
')
pnpm exec flue run issue-health --payload "$payload"
pnpm issue-health -- --payload "$payload"
5 changes: 2 additions & 3 deletions actions/pr-review/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ The directory still uses the same shape (`prompts/`, `skills/`, `personas/`) as
The action runs in the consuming repo's CI. `github.action_path` is the
checked-out agents repo, so the agent's code, skills, and prompts come along for
free at the pinned ref. The action installs deps, then runs
`flue run pr-review`, passing the PR coordinates plus the paths to the central
`pnpm review`, passing the PR coordinates plus the paths to the central
config (`REVIEW_AGENT_DIR`), the consumer's checkout (`REVIEW_TARGET_DIR`), and
the selected local override directory (`REVIEW_LOCAL_CONFIG_DIR`, defaulting to
`.agents`). The `code-review` skill resolves the layered guidance, fetches the
Expand Down Expand Up @@ -152,8 +152,7 @@ as action inputs.
model: anthropic/claude-sonnet-4-6
```
- **Another provider.** Anything in pi-ai's catalog works by id. For a provider
it doesn't know, register it with `registerProvider(...)` in the agents repo's
`app.ts`.
it doesn't know, register it in the workflow module before calling `start()`.

Locally, set `REVIEW_MODEL` plus that provider's credentials in `.env`.

Expand Down
6 changes: 3 additions & 3 deletions actions/pr-review/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ runs:

- uses: actions/setup-node@v4
with:
# Flue 0.11.1 requires Node >=22.18.0.
node-version: '22.18.0'
# Flue 2.3.1 requires Node >=22.19.0.
node-version: '22.19.0'
# No setup-node pnpm cache: when this action is consumed from another
# repo, the lockfile lives under _actions/ (outside the caller's
# workspace), which setup-node's cache globber can't resolve. The
Expand Down Expand Up @@ -87,5 +87,5 @@ runs:
REVIEW_OVERRIDE_MODE: ${{ inputs.override-mode }}
REVIEW_MODEL: ${{ inputs.model }}
run: |
pnpm exec flue run pr-review \
pnpm review -- \
--payload "{\"prNumber\": ${{ inputs.pr-number }}, \"repo\": \"${{ inputs.repo }}\"}"
19 changes: 3 additions & 16 deletions app.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import { flue } from '@flue/runtime/routing';
import { Hono } from 'hono';

// Runtime app entry.
//
// No model provider is registered here and no provider is built in as a
// default: every agent in this repo requires the implementer to pick a
// provider-qualified model (see lib/model.ts) and supply that provider's
// credentials through the environment. Flue resolves the common providers —
// `cloudflare-workers-ai/*`, `anthropic/*`, `openai/*`, … — through pi-ai's
// built-in catalog, so nothing needs registering for those.
//
// To add a provider pi-ai doesn't know about, import `registerProvider` from
// '@flue/runtime' and register it here, before the export below; the
// registration runs as a module side effect, ahead of Flue serving the agent.

// Flue's built-in app (a Hono instance).
export default flue();
// Both agents are CI-only: deliberately expose no HTTP agent routes.
export default new Hono();
11 changes: 2 additions & 9 deletions flue-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
// Lets TypeScript understand Flue's static skill imports, e.g.
// import review from '../skills/review/SKILL.md' with { type: 'skill' };
// The Flue build (Vite) resolves the real SkillReference at build time; this
// ambient declaration just keeps the editor and `tsc` happy.
declare module '*.md' {
// Typed loosely on purpose so the value is assignable to Flue's `skills: [...]`.
const skill: any;
export default skill;
}
/// <reference path="./node_modules/@flue/runtime/types/skill-md.d.ts" />
/// <reference path="./node_modules/@flue/runtime/types/markdown-md.d.ts" />
2 changes: 1 addition & 1 deletion flue.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from '@flue/cli/config';
import { defineConfig } from '@flue/runtime/config';

export default defineConfig({
// Default build/run target. CLI `--target` flags still override this.
Expand Down
6 changes: 3 additions & 3 deletions lib/issue-health.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FlueSession } from '@flue/runtime';
import type { GitHubIo } from './runtime.ts';

export const ISSUE_HEALTH_MARKER = '<!-- flipt-issue-health-agent -->';
export const ISSUE_HEALTH_SUPPORT_FOOTER =
Expand Down Expand Up @@ -169,8 +169,8 @@ export function filterIssueHealthLabels(
return labels;
}

type IssueHealthShell = Pick<FlueSession, 'shell'>;
type IssueHealthShellFs = Pick<FlueSession, 'shell' | 'fs'>;
type IssueHealthShell = Pick<GitHubIo, 'shell'>;
type IssueHealthShellFs = Pick<GitHubIo, 'shell' | 'fs'>;

export async function fetchExistingIssueLabels(session: IssueHealthShell, repo: string): Promise<string[]> {
const { exitCode, stdout } = await session.shell(
Expand Down
8 changes: 4 additions & 4 deletions lib/review-comments.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FlueSession } from '@flue/runtime';
import type { GitHubIo } from './runtime.ts';

export const REVIEW_MARKER = '<!-- flipt-pr-review-agent -->';
export const REVIEW_FOOTER = '_🤖 Automated review by the Flipt [PR review agent](https://github.com/flipt-io/agents)._';
Expand Down Expand Up @@ -89,7 +89,7 @@ export function renderReview(r: ReviewResult): string {
}

async function fetchExistingReviewTarget(
session: FlueSession,
session: GitHubIo,
prNumber: number,
repo: string,
): Promise<ExistingReviewTarget | undefined> {
Expand All @@ -111,7 +111,7 @@ async function fetchExistingReviewTarget(
}

async function updateExistingReview(
session: FlueSession,
session: GitHubIo,
prNumber: number,
repo: string,
target: ExistingReviewTarget,
Expand All @@ -132,7 +132,7 @@ async function updateExistingReview(
}

export async function postReview(
session: FlueSession,
session: GitHubIo,
prNumber: number,
repo: string,
body: string,
Expand Down
Loading
Loading