Cheatsheet¶
Everything on one page, for lookup. Each section links to the page that explains it.
Install and load¶
Command |
What it does |
|---|---|
|
the library, for your own scripts (Node 23.6 or later, no build step) |
|
the extension, its agents and its flows, loaded into every pi session |
|
the same from a clone, for this session only |
|
the offline suite, from a clone |
See Quickstart and Extension.
Commands in pi¶
Command |
What it does |
|---|---|
|
runs a flow in |
|
carries on the newest run here that can go on, or the one named |
|
lists the flows, as |
|
lists the flows: source, worst case in turns and time, description, refused files |
|
prints one flow’s plan, node by node; spawns nothing |
|
lists the agents, grouped by where they come from |
|
runs one stage on the previous step’s output, kept out of the session |
|
lists the steps walked so far, or starts a new chain |
|
puts one step into the conversation, the last one by default |
|
several copies of one agent on one job, with a board between them |
|
turns a vague request into a brief, one question at a time |
|
stops the selected subagent, the one named, or the whole run |
|
gives every subagent its own herdr split; alone, says where it stands |
Flags¶
Flags come before the text, in any order, written --name value or --name=value. A
value with spaces goes in double quotes. A line may end on \ and go on below. /run
also reads its two flags at the end of the line. A flag without a value, like --agent,
is written alone, =true or =false. A count <n> is a whole number of at least 1.
Any other value is refused and nothing runs.
Command |
Flag |
Default |
Meaning |
|---|---|---|---|
|
|
none |
the model of every agent turn; refused on a resume |
|
|
none |
the bound of one agent turn: |
|
|
|
which step’s output is carried in |
|
|
none |
the model of the stage |
|
|
off |
run the agent of that name when a flow has it too |
|
|
|
how many copies |
|
|
|
the agent copied |
|
|
|
the most rounds |
|
|
none |
things leased one owner at a time; done when each is reported on |
|
|
none |
the most claims one member may hold |
|
|
off |
done when every member votes the same way |
|
|
none |
the model of every member |
|
|
none |
the interviewer’s model |
|
|
|
the most questions asked |
Keys during a run¶
Key |
What it does |
|---|---|
|
stops every subagent of the run |
|
selects one subagent in the list above the prompt |
|
stops the selected one |
See Extension, Walk a chain by hand, Swarms and Display.
The subagent tool¶
The model calls it; you ask for it in plain words.
> use subagent to review src/usage.ts with coder then reviewer, looping until LGTM
> use subagent with scope "project" and agent "scout" to find the auth code
> use subagent to run the interview flow on "add a --verbose flag"
With no mode, the fields given pick it, in this order: flow, then candidates
(orchestrate beside concurrency, maxTasks or reduceWith, route otherwise),
reduceWith (reduce), until or maxIterations (loop), steps (chain), tasks
(parallel), else single.
Param |
Used by |
Default |
Meaning |
|---|---|---|---|
|
all |
inferred |
|
|
single, parallel, route, orchestrate, reduce |
agent name |
|
|
all but parallel |
the task; the input of a flow |
|
|
parallel, reduce |
independent tasks |
|
|
chain, loop |
agent names, in order |
|
|
route, orchestrate |
agents the router or planner may pick |
|
|
reduce, orchestrate |
agent that merges the results into one answer |
|
|
loop |
a word alone on a line that ends the loop: |
|
|
loop |
|
loop cap |
|
orchestrate |
|
most subtasks a plan may hold |
|
parallel, reduce, orchestrate |
|
branches at once |
|
all but flow |
the agent’s, else |
|
|
flow |
a flow name; takes only |
|
|
all |
one model for every subagent of the call |
|
|
all |
none |
deadline per turn |
|
all |
|
agents from |
|
all but flow |
|
how deep a subagent may delegate |
|
all but flow |
a herdr split per subagent |
|
|
all |
a split for every subagent, not only those that ask |
|
|
all but flow |
transcripts and |
See Extension.
An agent¶
A Markdown file: frontmatter, then the system prompt.
---
name: tester
description: Runs the project's tests and says what failed
tools: read, grep, find, ls, bash
model: anthropic/claude-sonnet-5
lifetime: workflow
openInHerdr: true
---
Run the tests. Report each failure as file:line and one sentence.
Key |
Default |
Meaning |
|---|---|---|
|
required |
how every caller names it; a file without one is ignored |
|
required |
one line; |
|
|
the allowlist, a YAML list or one comma-separated line |
|
none |
skills it may load, by name; needs |
|
pi’s settings |
a model pattern |
|
|
what |
|
children at once, for an agent whose |
|
|
a herdr split for it by default |
Three tools are combo’s, not pi’s: subagent (delegate to children), board (a swarm’s
board) and verdict, which a flow node adds itself and a definition never names.
Where |
Source |
Loaded |
|---|---|---|
|
|
by the extension always; by the library with |
|
|
by default |
|
|
with scope |
The later row wins a name. A skill is looked up in agents/<name>/skills/, then
.pi/skills/, then ~/.pi/agent/skills/. See Agents.
A flow¶
YAML for the structure, one ## <id> section per agent node for the prose. Saved as
.pi/flows/fix.md:
---
name: fix
description: Plan a change, code and review each task, test, then commit if asked
input: string
timeout: 10m
nodes:
- id: plan
agent: planner
reads: [input]
output: { tasks: [{ text: string }] }
retry: 1
- id: work
map-from: plan.output.tasks
max: 4
do:
- id: pair
loop: review.output.approved
max: 3
ledger: pair
on-fail: continue
do:
- id: code
agent: coder
memory: pair
reads: [item.text, pair.ledger]
- id: review
agent: reviewer
memory: pair
verdict: pair
reads: [item.text, diff]
- id: tests
check: .pi/checks/test.sh
timeout: 5m
- id: go
ask: "Commit this?"
confirm: true
default: false
reads: [tests.output.report]
- id: gate
choice:
- when: tests.output.passed && go.output.yes
do:
- id: message
agent: committer
reads: [input, diff]
- id: commit
commit: message
default: []
---
## plan
Split the request into tasks a coder can do one at a time.
## code
Do the task under `item.text`, and close what `pair.ledger` still holds.
## review
Review the change under `diff` against the task.
## message
Write the commit message for the change under `diff`.
The file¶
Key |
Required |
Meaning |
|---|---|---|
|
yes |
the file name without |
|
yes |
one line |
|
yes |
|
|
no |
the model of every agent turn, and of callees that set none |
|
no |
the bound of one agent turn, here and in callees that set none |
|
yes |
the root sequence, run in order |
Flows are found like agents: the package’s flows/, then ~/.pi/agent/flows/, then
.pi/flows/, the later one winning a name.
Nodes¶
A node is id: plus exactly one kind key. A -from key takes an address where its twin
takes a literal.
Kind key |
Runs |
Output |
Other keys |
|---|---|---|---|
|
one agent turn |
its text, or the |
|
|
the first case whose |
|
|
|
named branches at once |
|
|
|
|
|
|
|
|
|
|
|
a project script, with |
|
|
|
commits the tree on |
|
none |
|
a question card |
by form, below |
|
|
another flow, whole |
the callee’s last root node |
|
Every kind takes on-fail: continue: a failure stops at that node, and later nodes read
x.ok and x.error. retry: is on agent nodes only.
Key |
Meaning |
|---|---|
|
addresses handed to the turn, in order, each under |
|
the turn answers through a |
|
nodes naming the same agent and scope resume one subagent |
|
the turn decides with the |
|
|
|
the bound of one attempt, or of a check or a card |
|
each branch works in its own copy of the repository |
|
what |
|
Form |
Output |
|---|---|---|
|
a choice |
|
|
yes or no |
|
neither |
free text |
a |
Addresses, schemas, conditions¶
Address |
What it is |
|---|---|
|
the node’s output: text, or a typed value |
|
whether it ran, and why not |
|
a field of a typed output |
|
the run’s input, the |
|
inside a loop or ledger |
Schema |
Type |
|---|---|
|
a scalar |
|
an enum |
|
a list |
|
an object, |
|
what an |
A condition (loop:, when:, give-up:) is a subset of CEL: literals, addresses,
== != < <= > >=, && || !, in, size(), has(), all, exists. No arithmetic.
Guard a read that may fail: audit.ok && audit.output.approved.
See Flows for every key, the run directory and the faults, and From pipelines to flows for a pipeline of your own.
The library¶
One agent, one task:
import { findAgent, loadAgents, run } from "@ai-for-dev/combo";
const agents = loadAgents({ scope: "both", builtin: true });
const scout = findAgent(agents, "scout");
const result = await run(scout, "Find the authentication code", { timeoutMs: 120_000 });
result.ok; // false on a model failure, never a throw
result.output; // the last assistant text
result.usage; // turns, tokens, cost, time
A subagent that remembers:
const coder = await spawn(findAgent(agents, "coder"), { lifetime: "workflow" });
try {
await coder.ask("Implement the parser");
await coder.ask("Apply the review remarks"); // it remembers the first turn
} finally {
await coder.close(); // whoever opens, closes
}
Combinators¶
Call |
Shape |
|---|---|
|
each output is the next input |
|
N tasks at once, results in task order |
|
again until |
|
N results into one answer |
|
a classifier picks who does it |
|
a planner splits the work, |
|
questions for the user, then a brief |
|
members share a board, 3 rounds |
Each also takes lifetime, signal, timeoutMs, model, openInHerdr, onEvent,
bus, cwd, sessionDir, exportDir and spawn. timeoutMs has no default. See
Workflows and Lifetime.
Flows from code¶
import { bashCheck, checkFlow, checkRun, createRunDir, gitPort,
loadFlowCatalogue, measuredRun, resumeFlow, runFlow } from "@ai-for-dev/combo";
const catalogue = loadFlowCatalogue({ cwd, scope: "both", builtin: true });
const flow = checkFlow("build", catalogue); // the file, its callees, its agents
if (!flow.ok) throw new Error(flow.faults.map((fault) => fault.message).join("\n"));
const ports = { check: bashCheck(), git: gitPort() };
// the run stage: the tree, the scripts, git, whether somebody is there
const launch = await checkRun(flow.flow, { cwd, ports, somebodyThere: false });
if (!launch.ok) throw new Error(launch.faults.map((fault) => fault.message).join("\n"));
const runDir = createRunDir(); // runs/<timestamp>/
const measured = measuredRun({ dir: runDir });
const done = await runFlow(launch.run, "add a cache", {
runDir,
onEvent: measured.onEvent,
});
measured.finish(); // writes usage.json
if (!done.ok) await resumeFlow(runDir, { ports, somebodyThere: false });
A dry run answers every turn from a script and touches nothing:
const explore = checkFlow("explore", loadFlowCatalogue({ builtin: true }));
if (!explore.ok) throw new Error("explore does not check");
const dry = await dryRunFlow(explore.flow, "where is usage measured?", {
"look/find": "src/usage.ts",
answer: "In src/usage.ts.",
});
dry.ok; // true, with zero tokens spent
Experiments and stopping¶
const report = await experiment({
models: ["anthropic/claude-sonnet-5", "local/qwen/qwen3-coder-next"],
repetitions: 3,
run: async (cell) => {
const steps = [coder, reviewer];
const result = await loop({ ...cell.options, steps, input, until });
return { ok: result.ok, converged: result.converged };
},
});
const stop = stopSwitch(); // pass stop.signal and stop.spawn to a workflow or runFlow
stop.one("scout#2"); // one subagent
stop.all(); // the whole run
See Experiments and the API reference.
The model and the deadline¶
The nearest setting wins. No environment variable is read.
Model, nearest first |
Set with |
|---|---|
the call |
|
the flow |
its |
the agent |
its frontmatter |
pi |
|
Deadline of one agent turn in a flow, nearest first |
Set with |
|---|---|
the run |
|
the node |
its |
the flow |
its |
the default |
30 minutes |
A check takes its own timeout: or two minutes, and an ask card only its own
timeout:. Outside a flow, timeoutMs has no default. /interview gives each turn five
minutes.
On disk¶
Path |
Written by |
Holds |
|---|---|---|
|
|
one run; |
|
a flow run |
the flow and its callees, agents, check scripts, input, settings: what a resume runs |
|
a flow run |
one fact per line, appended; what a resume reads |
|
a flow run, while it runs |
the pid and host of its runner |
|
each subagent, as it closes |
its transcript, under its memory scope or visit path |
|
a delegating subagent |
its children’s transcripts |
|
a flow run |
copies of the skills its agents declare |
|
any export |
the pi sessions behind the transcripts |
|
the extension |
the parent pi session |
|
|
time and tokens per subagent; a flow run adds |
|
|
the event stream |
|
|
one folder per step of a chain |
|
|
the table, and one directory per cell |
See Export, The run directory and Measurements.
Shipped agents¶
Agent |
Tools beyond |
Lifetime |
What it does |
|---|---|---|---|
|
|
locates the code relevant to a question and reports where it lives |
|
|
|
|
answers by splitting the reading across scouts, three at once |
|
|
splits work into independent subtasks and assigns each one |
|
|
|
picks which agent should handle a task |
|
|
|
|
implements a change, and applies review remarks across iterations |
|
|
reviews code and returns at most five actionable remarks, or |
|
|
|
reads the finished work as a whole, says what still has to change, or |
|
|
|
merges the findings of several subagents into one answer |
|
|
|
turns a vague request into a specification, one question at a time |
|
|
|
writes the commit message for finished work |
|
|
|
|
works one job beside other members of a swarm |
|
|
|
argues one side beside other debaters, and votes every turn until they all agree |
None names a model:. A file of the same name in ~/.pi/agent/agents/ or .pi/agents/
replaces one.
Shipped flows¶
The worst case is what /flows prints.
Flow |
Worst case |
What it does |
|---|---|---|
8 turns, 2h |
three scouts read the code in parallel, then one agent answers |
|
12 turns, 4h |
a planner splits a read-only question between a scout and a reviewer, then one answer |
|
14 turns, 7h and a person’s answers |
asks one question at a time, then writes a specification |
|
154 turns, 41h20m |
locates, splits, codes in reviewed pairs, runs |
|
170 turns, 49h20m and a person’s answers |
interviews, asks “Build this?”, builds, commits on the run’s branch |
Every agent node of these flows has retry: 1. See Deliver a
change.