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
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ agentkit (alias ak); skills agentkit, agentkit-setup, agentkit-orchestrate
| Path | What |
| --- | --- |
| `bin/ak`, `bin/agentkit` | one byte-identical bash launcher: sources the env file, exec's the python core |
| `lib/ak.py` + `lib/*.py` | the python3 stdlib core: `launch` (dispatcher), `kinds` (+ `tomlmini`, `writers`), `profiles`, `run`, `envcmd`, `doctor`, `usage`, `pick` (`ak pick`, the account-selection policy over the usage rows), `capacity` (`ak capacity`, one account's room and verdict, pick's arithmetic), `state` (the machine state dir: usage cache, atomic 0600 writes), `lease` (`ak lease`, advisory account leases), `setup`, `aliases`, `installer`, `update` (`ak update`, the verified vendor update: discover, install, resolve, re-pin; `docs/update.md`), `hooks`, `common` |
| `lib/ak.py` + `lib/*.py` | the python3 stdlib core: `launch` (dispatcher), `kinds` (+ `tomlmini`, `writers`), `profiles`, `run`, `envcmd`, `doctor`, `usage`, `pick` (`ak pick`, the account-selection policy over the usage rows), `capacity` (`ak capacity`, one account's room and verdict, pick's arithmetic), `state` (the machine state dir: usage cache, atomic 0600 writes), `lease` (`ak lease`, advisory account leases), `setup`, `aliases`, `installer`, `update` (`ak update`, the verified vendor update: discover, install, resolve, re-pin; `docs/update.md`), `sessions` (the record every interactive launch leaves and `ak ps`, the running sessions joined to their account; `docs/ps.md`), `fanout` (`ak fanout`: N tasks in N git worktrees over the accounts `ak pick` chooses, one `fanout-v1` result; `docs/fanout.md`), `hooks`, `common` |
| `lib/common.sh`, `lib/env.template` | the launcher's shell half; the env file template |
| `providers.toml` | the kinds model as data (CLIs, providers, kinds) — see `docs/kinds.md` |
| `skills/agentkit/` | the bundled skill (`ak --skill`): `SKILL.md` + `references/` (`accounts.md`, `usage.md`) |
| `skills/agentkit-setup/` | the configurator skill (`ak --skill setup`): `SKILL.md` + `references/`; executable documentation, see `docs/setup.md` |
| `skills/agentkit-orchestrate/` | the orchestration skill (`ak --skill orchestrate`): several agents over several accounts; see `docs/orchestration.md` |
| `install.sh`, `install.ps1`, `win/*.cmd` | installers (POSIX, Windows) and Windows shims |
| `tests/run.sh`, `tests/scopes/`, `tests/fakes/`, `tests/py/` | the suite: sandbox HOME, fake CLIs, one scope per surface |
| `docs/` | user docs, `SECURITY.md`, `TESTING_GUIDE.md`, `schema/doctor-v1.json`, `schema/usage-v1.json`, `schema/pick-v1.json`, `schema/capacity-v1.json`, `schema/leases-v1.json`, `schema/profiles-v1.json`, `schema/setup-probe-v1.json`, `schema/setup-verify-v1.json`, `accounts.md`, `orchestration.md`, `setup.md`, `usage.md` |
| `docs/` | user docs, `SECURITY.md`, `TESTING_GUIDE.md`, `schema/doctor-v1.json`, `schema/usage-v1.json`, `schema/pick-v1.json`, `schema/capacity-v1.json`, `schema/leases-v1.json`, `schema/profiles-v1.json`, `schema/setup-probe-v1.json`, `schema/setup-verify-v1.json`, `schema/sessions-v1.json`, `schema/fanout-v1.json`, `ps.md`, `fanout.md`, `accounts.md`, `orchestration.md`, `setup.md`, `usage.md` |
| `scripts/` | maintainer tooling: `check-public-hygiene.sh`, `release.sh`, `update-pins.sh` |
| `.agents/` (+ `.claude`, `.cursor` symlinks) | the agent kit for working on this repo: personas, `dwp-*` delegators, vendored skills, catalog in `.agents/docs/` |

Interface 1 (`ak doctor --json`, `ak env`, `ak run`) is consumed by other tools: a change to it is a breaking change (see `docs/doctor.md`, `docs/run.md`). `ak usage --json` (schema `usage-v1`, `docs/usage.md`), `ak pick --json` (schema `pick-v1`, `docs/usage.md#choosing-an-account`), `ak capacity --json` (schema `capacity-v1`), `ak lease ls --json` (schema `leases-v1`), `ak profiles --json` (schema `profiles-v1`, `docs/profiles.md`) and `ak setup probe|verify --json` (schemas `setup-probe-v1`, `setup-verify-v1`, `docs/setup.md`) are additive, separately versioned surfaces; `ak usage`, `ak pick` and `ak capacity` read logins and query vendors (and keep a cache of usage numbers), `ak lease` keeps a lease store, and `ak setup` guides machine changes, so their rules are in `docs/SECURITY.md`.
Interface 1 (`ak doctor --json`, `ak env`, `ak run`) is consumed by other tools: a change to it is a breaking change (see `docs/doctor.md`, `docs/run.md`). `ak usage --json` (schema `usage-v1`, `docs/usage.md`), `ak pick --json` (schema `pick-v1`, `docs/usage.md#choosing-an-account`), `ak capacity --json` (schema `capacity-v1`), `ak lease ls --json` (schema `leases-v1`), `ak profiles --json` (schema `profiles-v1`, `docs/profiles.md`), `ak ps --json` (schema `sessions-v1`, `docs/ps.md`), `ak fanout run --json` (schema `fanout-v1`, `docs/fanout.md`) and `ak setup probe|verify --json` (schemas `setup-probe-v1`, `setup-verify-v1`, `docs/setup.md`) are additive, separately versioned surfaces; `ak usage`, `ak pick` and `ak capacity` read logins and query vendors (and keep a cache of usage numbers), `ak lease` keeps a lease store, and `ak setup` guides machine changes, so their rules are in `docs/SECURITY.md`.

## Quick commands

Expand Down
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,71 @@ permission posture changes.

## [Unreleased]

### Added

- **`ak usage` keeps showing an account it cannot read now.** A row that is
`expired`, `no_scope`, `no_login` or `error` used to be a status and a hint
with nothing else. When the kit's usage cache still holds an earlier
reading of that account, at most seven days old, the table now lists that
reading's windows under the status line, dimmed and dated (`last read 3h 0m
ago`), and `ak usage --json` carries it as the additive `last_known` block
(`read_at`, `age_s`, `plan`, `windows`, each window with `reset`). A window
whose reset time has passed is marked reset and carries no number. The row
is still a problem row: its status, its empty `windows` and the exit code
are unchanged, and `ak pick` and `ak capacity` never choose an account or
report room from it. Showing it makes no request and writes nothing.
Interface stays **1**; `usage-v1` gains one optional key.
- **`ak ps [--json]`: the sessions that are running, joined to their
account.** Every interactive `ak <kind> [@profile]` now leaves one record
in the kit's state directory (`sessions/`, one `0600` file per session,
best effort — a failed write never changes a launch): the process id and
its start time, kind, CLI, provider, profile, directory, launch time,
posture and, inside Herdr, the pane id. `ak ps` lists the ones still
running, oldest first, and removes the records of those that ended; a
session counts as running only while its process id is alive with the
recorded start time. Each is joined to its account's capacity from the
usage cache alone (verdict, free share, reset, and the reading's age): no
vendor is queried and no login is touched. `--json` is the new, separately
versioned `sessions-v1` schema. An agent started without `ak`, and a
headless `ak run`, have no entry. Interface stays **1**; a launch's argv
and environment are unchanged. See [`docs/ps.md`](docs/ps.md).
- **`ak run --pick`: the run chooses its account, and can fail over.**
`ak run <kind> --pick` runs on the account `ak pick <kind>` names (one
shared choice). With `--failover N` (0–3) it moves to another account, and
with `--fallback KIND,KIND` to another kind, on two triggers only: the
attempt never started (exit 3), or it ended with exit 1 or 4 and a fresh
reading of that account's usage shows it spent. The agent's words are
never matched, and a plain failure or timeout is not retried. After an
attempt that started, the run moves only when `--cwd` is a git work tree
left exactly as it was; `ak run` never resets or cleans a workspace.
`--owner ADDR` holds a lease for each attempt; `--exclude @profile` leaves
an account out. With `--pick` the JSON envelope gains `attempts` and
`failover`; without it the envelope, the argv each CLI receives and the
exit codes are unchanged. Interface stays **1**.
- **`ak fanout`: N tasks, N lanes, one result.** `ak fanout run --tasks
FILE|-` runs each task of a list as its own agent, in its own git worktree
on its own new branch (`ak/<run-id>/<task-id>`), on an account `ak pick`
chooses, in parallel, and prints one result (`--json`: the new, separately
versioned `fanout-v1` schema). Lanes start one at a time so the choice
spreads them over the accounts; an exclusive account (Codex) carries one
lane at a time. A lane survives a spent account also when the agent had
already written: its own worktree is reset to the base and the task runs
again, within `--failover`. A bad task list is refused before anything is
created. SIGTERM stops every lane and releases the leases (exit 5).
`ak fanout ls` lists the runs on record; `ak fanout clean <run-id>`
removes a run's worktrees, branches and record, keeps uncommitted work and
unmerged commits unless `--discard`, and removes a worktree only when it is
provably that run's. It never merges, pushes or rebases. See
[`docs/fanout.md`](docs/fanout.md).

### Changed

- The `agentkit-orchestrate` skill and [`docs/orchestration.md`](docs/orchestration.md)
teach `ak fanout run` and `ak run --pick --failover` in place of the loop
run by hand (pick, worktree, run, discard, re-pick). The rules the commands
do not enforce stay the lead's: run the gate in each worktree, merge only
what passes, never use an account the user did not offer.

## [1.5.2] - 2026-11-19

A patch release with no runtime change: `ak` behaves exactly as in 1.5.1, and
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The same CLIs, routed to another model provider with one key per account:
| **Several accounts** | `ak claude @work`, `ak codex @client-x`: each profile has its own login, sessions, settings and keys, side by side. |
| **Quota of every account** | `ak usage` (or `ak status`) lists every account of every CLI in one table, `ak pick` names the one with the most room, `ak capacity` judges one. |
| **Headless runs** | `ak run` runs any kind non-interactively and returns one JSON result — the transport other tools and agents use. |
| **Agents launching agents** | `ak pick --count N`, leases and the `agentkit-orchestrate` skill spread lanes over accounts and vendors. |
| **Agents launching agents** | `ak run --pick --failover` chooses the account and moves on when it is spent; `ak fanout run` runs a list of tasks in parallel, each in its own git worktree on its own account; the `agentkit-orchestrate` skill teaches both. |
| **Autonomy by default** | each CLI's own autonomy flag on every launch, with an opt-out that always wins: `--ask` or `AGENTKIT_PERMISSIONS=ask`. Meant for disposable or sandboxed environments. |
| **Keys stay in one file** | `~/.config/agentkit/env` (mode 600); no key lands in a config file, a log or an output. |
| **Set up by an agent** | the `agentkit-setup` skill and the read-only `ak setup probe \| verify \| docker` install and repair the kit on any host or container. |
Expand Down Expand Up @@ -138,6 +138,7 @@ ak claude-glm # Claude Code routed to Z.AI GLM (key from ~/.config/
ak claude --ask # opt out for this launch: the CLI asks before acting
ak claude -- @src/app.ts # `--` sends everything after it to the CLI untouched
ak usage # quota and usage of every account, one row each
ak ps # the sessions ak launched that are still running, with their account
ak run codex --cwd ~/src/api --timeout 900 --output-format json -- "fix the failing test"
```

Expand Down Expand Up @@ -262,10 +263,12 @@ the threat model is [docs/SECURITY.md](docs/SECURITY.md).
- [Accounts](docs/accounts.md) — the account model: per-CLI table, lifecycle, keys, macOS and Windows, troubleshooting
- [Profiles](docs/profiles.md) — accounts per CLI, keys per profile, Herdr hooks
- [Permissions](docs/permissions.md) — autonomy by default, the `--ask` opt-out, the `classic` and `providers` aliases
- [`ak run`](docs/run.md) — the headless contract, exit codes, the JSON envelope
- [`ak run`](docs/run.md) — the headless contract, exit codes, the JSON envelope; `--pick` and `--failover`
- [`ak fanout`](docs/fanout.md) — N tasks in N git worktrees over your accounts, one result ([schema](docs/schema/fanout-v1.json))
- [Set up on any machine or container](docs/setup.md) — `ak setup`, the `agentkit-setup` skill, container recipes
- [`ak usage`, `ak pick`, `ak capacity` and `ak lease`](docs/usage.md) — quota per account, reading the table, choosing an account, one account's room, the usage cache, leases ([usage-v1](docs/schema/usage-v1.json), [pick-v1](docs/schema/pick-v1.json), [capacity-v1](docs/schema/capacity-v1.json), [leases-v1](docs/schema/leases-v1.json))
- [Orchestration](docs/orchestration.md) — several agents over several accounts: worktrees, failover, Herdr, Deep Work Plans
- [`ak ps`](docs/ps.md) — the sessions that are running: account, posture, Herdr pane and capacity of each ([schema](docs/schema/sessions-v1.json))
- [`ak doctor` and `ak env`](docs/doctor.md) — interface 1 outputs ([schema](docs/schema/doctor-v1.json))
- [Install, `ak install`, aliases](docs/install.md)
- [Threat model](docs/SECURITY.md) · [Testing](docs/TESTING_GUIDE.md) · [Changelog](CHANGELOG.md)
Expand Down
31 changes: 30 additions & 1 deletion docs/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,34 @@ profile and its headroom, nothing else.
(no read-modify-write, safe under concurrent runs), pruned past the newest
5000 per account. Read only by `ak usage` for its `advisory` block, which
never reaches the usage cache, `ak capacity` or `ak pick`.
- **Last known reading:** for a row it cannot read now (`expired`,
`no_scope`, `no_login`, `error`), `ak usage` shows the reading already in
the usage cache when it is at most seven days old (`last_known`). It is
read from the kit's own file: no request, no login touched, nothing
written, and it holds usage numbers only. `ak capacity` and `ak pick`
never read a reading that old, so no account is chosen on it.
- **Session records** (`<state>/sessions/`, `0600` files in a `0700`
directory): written by an interactive launch, read and pruned by `ak ps`.
They hold names, a directory, times, a process id and the host's name — never a key, a
token, a session id, an account identity or the CLI's environment. `ak ps`
joins them to the usage cache only: it makes no request, refreshes no
login and writes nothing but the removal of ended records. The pane id is
taken from `HERDR_PANE_ID` only when `HERDR_ENV=1` and only when it has
the form of one.
- **Fan-out** (`ak fanout`, `<state>/fanout/<run-id>/`: `run.json` and one
transcript per lane, `0600`): each lane is one `ak run` child started with
an argv list (the prompt is one argument after `--`; no shell), in a git
worktree of its own, so no lane writes into the repository it was started
from. The task list is validated in full before anything is created. The
kit removes a worktree in two places only — a lane's reset after a spent
account, and `ak fanout clean` — and only when the path is in the run's
record, has the place and name the run gives its lanes, is a linked
worktree of the recorded repository and is its own git top level; the
branch it deletes is computed from the run and the lane, never read from
the record. A branch that holds commits is never reset, and is deleted
only with `--discard`. It never merges, pushes or rebases. A lane's
transcript holds whatever its CLI printed: treat the log files like the
CLI's own session files.
- **Accounts:** work moves only among the accounts you declared for the work,
within each vendor's terms; no agent creates an account, renews a login or
spends a Codex reset.
Expand Down Expand Up @@ -231,10 +259,11 @@ paths.
| `~/.config/agentkit/env` (`AGENTKIT_ENV`) | your keys and settings (created once, never overwritten) | 600 |
| `~/.config/agentkit/aliases.json` | alias definitions | 600 |
| your shell rc | one guarded block (PATH + aliases) | unchanged |
| `~/.local/state/agentkit/` (`AGENTKIT_STATE_DIR`) | `usage-cache/<cli>@<profile>.json` (usage numbers only), `leases/leases.json`, `launches.json` (per working directory: the kind, profile and posture of the last interactive launch, for `ak last`) | dirs 700, files 600 |
| `~/.local/state/agentkit/` (`AGENTKIT_STATE_DIR`) | `usage-cache/<cli>@<profile>.json` (usage numbers only), `leases/leases.json`, `fanout/<run-id>/` (a fan-out run's record and its lanes' transcripts and, by default, their worktrees), `launches.json` (per working directory: the kind, profile and posture of the last interactive launch, for `ak last`), `sessions/<pid>-<time>.json` (one per running interactive session, for `ak ps`: process id and start time, kind, CLI, provider, profile, directory, time, posture, Herdr pane id; removed when the session has ended) | dirs 700, files 600 |
| a CLI's own config | Codex overlay `<provider>.config.toml`, one provider in OpenCode's `opencode.json` / Pi's `models.json` — only when you launch that provider kind, inside the profile when one is used; one-time `.agentkit.bak` before the first change | 600 for files it creates |

`ak usage`, `ak pick` and `ak capacity` write nothing but the usage cache;
`ak ps` only removes the records of sessions that have ended;
`ak lease` writes only the lease store. Neither do `ak setup probe`, `verify` and
`docker` (stdout only); `docker --out FILE` creates one new file, mode 644.

Expand Down
Loading
Loading