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
212 changes: 47 additions & 165 deletions AGENTS.md

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,8 @@ agents_surface_block() {
markers — edit the registry there and re-run. Checked by
`PyAutoBrain/bin/install.sh --check-agents-surface`. -->

The PyAuto **command surface** — every agent verb, runnable on any tool (Claude,
Codex, Cursor; CLI or web) as `bin/pyauto-brain <verb>`. This block lives once in
**PyAutoBrain**'s auto-loaded AGENTS.md, which is present in every session, so the
full verb set is always in context — no per-organ copy needed. Invoking a verb
runs its entrypoint here in PyAutoBrain. On Claude Code the same verbs are also
the `/<verb>` slash commands.
Run from the Brain checkout. Read the selected agent's `AGENTS.md` only when
invoking it; `bin/pyauto-brain help <verb>` exposes its full contract.

**Conductors** — front doors you drive (decide *and* act):

Expand Down
40 changes: 20 additions & 20 deletions bin/pyauto-brain
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,26 @@ declare -A AGENT_SCRIPT=(
[sizing]="$FACULTIES_DIR/sizing/sizing.sh"
)
declare -A AGENT_DESC=(
[intake]="Conceive a task: turn raw input into a formal, headed PyAutoMind prompt (files it; never starts dev)"
[batch]="Compose one unattended shift: the BatchDecision, planned against the slot's REVIEW-MINUTE budget rather than a task count — proposes, never dispatches; 'batch collect' scores what came back into the review packet and stamps the batch record"
[community]="The ears — the organism's receptive function: scan/triage the Discussions hub where users ask (PyAutoMind/policy/community_surface.md) plus user-filed GitHub issues + PRs and review requests across the repos; drafts stay human-gated, dev work routes via start_dev_for_user (never posts)"
[feature]="Reason over PyAutoMind feature tasks: select, size, phase, plan for start_dev"
[bug]="The immune system: classify a bug/regression/Heart finding, locate the fix, plan the repair"
[refactor]="The renewal function: plan behaviour-preserving restructuring — RefactorDecision; default-safe under --auto"
[workspace]="The voice — the organism's expressive function: plan/survey workspace + HowTo example authorship (workspace|howto registers) — WorkspaceDecision (never writes)"
[eyes]="The perceptive function — the organism's sense of its own appearance: survey/review a visualization workspace's figure surface, critiques route to intake/start_dev — EyesSurvey/EyesReviewSurface (never renders, never edits)"
[cortex]="The learning function — where the organism keeps track of what is true: the per-project science ledger over PyAutoCortex — 'cortex pull' on the laptop pulls every active project through its own sync CLI and shows where each run stands; 'cortex checkin' anywhere stamps, re-renders the board and pushes the ledger; it records cluster facts and the human's words, never a verdict of its own"
[profiling]="The proprioceptive function — the organism's sense of its own effort: campaign/ingest/triage plans over the autolens_profiling workspace — ProfilingDecision"
[hygiene]="The maintenance function — the organism's sense of its own upkeep: code-quality debt (dev-loop cost + tidiness), delegating fixes — HygieneDecision"
[clone]="The Mitosis Agent: partition the reference assistant, analyze the domain, emit the CloneDecision; --apply --mode lightweight-seed delegates the seed birth to Build; 'clone sync' patches the reference's generic-file diff onto the born siblings (dry run by default; rejected hunks are a human decision)"
[build]="Coordinate execution: consult the vitals faculty, then delegate to PyAutoHands"
[release]="Release door → the Build Agent release mode (single gate); 'release rehearse'/'release validate' drive release validation; 'release nightly' is the scheduled-nightly driver"
[health]="The organism's clinician: run the health loop with a human, dispatch by dispatch, toward green"
[vitals]="Read-only: read the Heart's pulse — the PyAutoHeart readiness verdict (consulted by the conductors)"
[review]="Read-only: prepare the branch ReviewSurface — the reviewing agent maps it to CLEAN/FINDINGS/BLOCKED (the ship gate's review leg)"
[memory]="Read-only: recall what the organism knows — a cited digest over PyAutoMemory, autolens_assistant and Mind history"
[samplers]="Read-only: the motor faculty — SamplerSurface digest over the sampler script tiers, the PyAutoFit search catalogue and the benchmark record"
[sizing]="Read-only: the SizingSurface — a difficulty estimate for a PyAutoMind prompt; the single heuristic the intake and feature conductors both consult"
[intake]="File classified prompts; never start development"
[batch]="Propose a review-budgeted batch; collect its results"
[community]="Triage community threads; human-approved replies and development handoffs"
[feature]="Select, size and plan features"
[bug]="Classify regressions and plan repairs"
[refactor]="Plan behavior-preserving restructuring"
[workspace]="Plan or survey examples and tutorials"
[eyes]="Survey figures and route accepted critiques"
[cortex]="Pull science runs and record human checkins"
[profiling]="Plan campaigns; ingest results; triage profiling drift"
[hygiene]="Prioritize upkeep and delegate fixes"
[clone]="Plan assistant births or synchronize generic files"
[build]="Consult vitals and coordinate Hands execution"
[release]="Coordinate release rehearsal, validation and nightly execution"
[health]="Assess health and route repairs"
[vitals]="Read authoritative Heart readiness"
[review]="Prepare independent CLEAN/FINDINGS/BLOCKED branch review"
[memory]="Recall cited scientific and task history"
[samplers]="Inspect sampler coverage, tiers and benchmarks"
[sizing]="Estimate task difficulty"
)
# Conductors are the front doors a human drives; faculties are consulted (and
# runnable read-only). Both are dispatchable, but the menu groups them by tier.
Expand Down
57 changes: 57 additions & 0 deletions bin/workspace_instructions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""Update only recognized workspace instruction sections, preserving local additions."""
import argparse
import json
from pathlib import Path
import sys

POLICY = Path(__file__).resolve().parents[1] / 'policy'


def render(text, sections, legacy):
"""Refuse unexpected edits instead of overwriting a user's instructions."""
replacements = []
for heading, body in sections.items():
lines = text.splitlines(keepends=True)
matches = [i for i, line in enumerate(lines) if line.rstrip() == heading]
if len(matches) != 1:
raise ValueError(f'expected one section: {heading}')
first = matches[0]
end = next((i for i in range(first + 1, len(lines))
if lines[i].startswith('## ')), len(lines))
current = ''.join(lines[first:end]).strip() + '\n'
if current not in (body.strip() + '\n', legacy[heading]):
raise ValueError(f'unrecognized local edits in {heading}; reconcile explicitly')
replacements.append((sum(map(len, lines[:first])),
sum(map(len, lines[:end])), body.rstrip() + '\n\n'))
for first, end, body in sorted(replacements, reverse=True):
text = text[:first] + body + text[end:]
return text.rstrip() + '\n'


def main(argv=None):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--root', type=Path, required=True)
parser.add_argument('--write', action='store_true', help='otherwise check only')
args = parser.parse_args(argv)
target = (args.root / 'AGENTS.md').resolve() # preserve a task-bundle symlink
try:
original = target.read_text()
updated = render(original, json.loads((POLICY / 'workspace_sections.json').read_text()),
json.loads((POLICY / 'workspace_sections_legacy.json').read_text()))
except (OSError, ValueError, KeyError) as exc:
print(f'workspace instructions: {exc}', file=sys.stderr)
return 2
if original == updated:
print(f'OK: {target}')
return 0
if not args.write:
print(f'DRIFT: {target}; run with --write after reviewing the change')
return 1
target.write_text(updated)
print(f'updated: {target}')
return 0


if __name__ == '__main__':
raise SystemExit(main())
147 changes: 147 additions & 0 deletions docs/agent_reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Agent architecture and command reference

Read when designing agents or changing command wiring, not at session startup.

## What this repo is

PyAutoBrain is the **reasoning layer** of the PyAuto ecosystem as it grows into a
software organism. It figures out *how* work should be done and coordinates the
organs that do it. It hosts specialist **reasoning agents** — each a documented
role plus a deterministic entrypoint script — that read intent (from PyAutoMind
and the developer), reason about it, and drive the health/execution machinery at
the right points.

PyAutoBrain owns **no state, no health checks, and no execution mechanics**. It
only *reasons* and *delegates*: it asks PyAutoHeart whether the organism is
healthy, decides whether and how to proceed, and tells PyAutoHands to execute
when it should.

## The organism

The organs, their boundaries, and the `Brain → Heart (gate) → Build (execute)`
call chain are defined **once** in [`ORGANISM.md`](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/ORGANISM.md) — this repo
hosts that canonical page; every other organ links to it. In one line: the
Mind decides *what*, the Brain (this repo) figures out *how*, the Heart gates,
the Hands build, Memory knows what the science says.

## Brain agents consult one another (a society of agents)

Brain agents are not limited to driving organs — they can **consult each other**.
The canonical example is the **Build Agent**, which does not query Heart directly:
it consults the **vitals faculty**, and only the vitals faculty talks to the Heart
organ. So the Build Agent's full chain is:

```
Mind → Build Agent → vitals faculty → Heart → GREEN/YELLOW/RED
→ Build Agent → Build (execute)
```

The consult graph is a DAG (see [`ORGANISM.md`](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/ORGANISM.md)): conductors
consult faculties; faculties read their sensor organ; a conductor never
consults another conductor — if it wants one's opinion, that opinion should be
a faculty. The Build Agent is the reusable template for this pattern.

How much human checkpointing a workflow run needs is defined once in
[`AUTONOMY.md`](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/AUTONOMY.md) — the autonomy contract mapping each Mind-prompt
`Autonomy:` level to behaviour at every checkpoint.

## Specialist reasoning agents

Agents live in **two tiers** under `agents/`, distinguished by one question —
*does it act, or only opine?*

- **Conductors** (`agents/conductors/<name>/`) — front-door agents a human
**drives**. They *decide **and** act*, delegating execution to the organs.
They have side effects in the world (a plan driven into dev, a build, a
release). This is the small, curated set of things you invoke and converse
with.
- **Faculties** (`agents/faculties/<name>/`) — read-only reasoning capabilities
the conductors **consult**. They *only opine* — return a judgment and stop;
they never dispatch or mutate. They are *sinks* in the consult graph
(everything reaches into them; they reach out only to their sensor organ). Not
chat-first surfaces, though they stay runnable for a quick read.

The rule of thumb: **keep the conductor set small and human-meaningful; let
faculties multiply behind them.** A side-effecting decider is a conductor; a
side-effect-free opinion is a faculty.

Each agent is a directory with an `AGENTS.md` (what it reasons about + how to run
it) and a deterministic entrypoint script (`*.sh` / `*.py`) — the part CI and
humans invoke identically, so behaviour isn't re-derived from prose each time.

New agents are added on **demonstrated need, never for symmetry**. Place by
tier: a side-effecting decider you drive → `agents/conductors/<name>/`; a
read-only opinion the conductors consult → `agents/faculties/<name>/`. Follow
the Build Agent's shape (a concise `AGENTS.md` opening with its `Tier:` line, a
deterministic entrypoint, and a capability audit of any organ it drives — the
Feature Agent's `MIND_TAXONOMY.md` is that audit for the PyAutoMind/PyAutoMemory
surface). Keep the conductor set small; prefer a faculty when the new thing
only reasons.

**Scaling invariant.** The per-agent roster is not maintained here. Adding an
agent touches only `bin/pyauto-brain` (the registry) and the agent's own
directory (`agents/<tier>/<name>/` with its `AGENTS.md` + entrypoint). The verb
tables below are **generated** from that registry by
`bin/install.sh --write-agents-surface` — never hand-edit this file's roster,
and read each agent's own `AGENTS.md` for its full role.


## The command surface (Brain implicit)

The verb table in [AGENTS.md](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/AGENTS.md) is the machinery; humans drive it through short commands
(`/intake`, `/feature`, …) in Claude Code, or discoverable skills in Claude and
Codex. The Brain stays **implicit** — you type a verb, or plain natural language
via `/route`, and it routes to the right agent; normal usage never says
"PyAutoBrain". A few commands are compositions rather than single agents:
`/docs` and `/research` route through the dev-flow with their PyAutoMind
work-type fixed (no dedicated conductor — added only on demonstrated need, never
for symmetry); `/prm` composes the
end-of-task close-out (CI green → merge → issue closed → Mind `active/` →
`complete/` → dashboard reconciled and regenerated → worktree and local branches
removed); `/brain
<agent>` is the raw passthrough. Every command routes **through** the Brain;
none replaces it.

The morning routine is not a command at all: the **Brain board**
(`board/_board.py`, published to the Brain's GitHub Pages URL each morning by
`brain_board.yml`) carries what `/wake_up` used to assemble — overnight runs,
readiness, community, resume, upkeep — as one-tap 📋 payloads, and
`bin/morning.sh` is the local sync/clean leg you run in a terminal.
`/wake_up` remains only as the fallback door when the board is unreachable.

The command bodies live in `skills/<verb>/<verb>.md`; thin `SKILL.md` wrappers
make the same canonical workflows discoverable to skill-aware harnesses.
`bin/install.sh` installs both surfaces without duplicating their bodies. Shared
architecture prose is in [`skills/COMMANDS.md`](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/skills/COMMANDS.md); the
work-type taxonomy the router uses is `PyAutoMind/ROUTING.md`.

## Chat register: concise by default

The default register for **chat replies** is concise — every harness and every
session (Claude Code CLI, web, mobile; Codex; Cursor). A reply is the smallest
thing that answers the question and says what changed. It is not a report on the
work.

- **Answer first.** Lead with the answer, the verdict, or what you did. No
preamble, no restatement of the request, no summary of the summary.
- **A few lines is the default length.** One line is a good answer. Prose
paragraphs, file-by-file inventories and "what I did / why / next steps"
scaffolding are opt-in, not the baseline.
- **Don't narrate the work.** Skip the tool-by-tool commentary, the list of
files read, and any recap of a diff the human can read on the branch or PR.
- **Link, don't paste.** Point at the file, the issue, the PR, the prompt under
`PyAutoMind/draft/`; quote only the lines being discussed.

Four things are never compressed: a **plan awaiting approval**, a **decision
surface** a human must judge, a **failure or blocker** (say exactly what broke
and where), and anything the human **asked to have explained**. Brevity is not a
licence to drop the detail a decision needs.

The escape hatch is a word — "expand", "in full", "explain" — and it applies to
that reply, not the session; the register comes back on the next turn.

Agent output is not chat and keeps its defined shape: a `*Decision`, a
`ReviewSurface`, a vitals verdict, the board digest are structured artefacts
this register does not trim. It governs the prose around them. On Claude Code
the same default can also be pinned per-tool with an output style, but the
register above is the portable one — it travels with the repo to every harness.
6 changes: 6 additions & 0 deletions docs/codex_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ Compare medians only across similar task types and report unknown sessions.
Treat the current Astra Medium configuration as the baseline; do not change
local model configuration merely to manufacture a comparison. Do not claim
savings until both usage and outcome/correction evidence support it.

## Static context budgets

Use [context_efficiency.md](context_efficiency.md) for the September follow-up,
Mind’s token-load checker and post-merge root activation. Static byte/line
reductions are not measured task-token savings.
Loading
Loading