@markjaquith/agency 2.47.3 → 2.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/package.json +1 -2
- package/src/cli-parser.test.ts +0 -7
- package/src/commands/init.test.ts +5 -1
- package/src/services/IntegrationService.test.ts +41 -2
- package/src/workbase/AGENTS.md +31 -2
- package/fixtures/protocol/skill-setup-commands.json +0 -18
- package/skills/agency/SKILL.md +0 -151
- package/skills/agency/references/commands.md +0 -188
- package/skills/agency/references/contracts.md +0 -322
- package/skills/agency/references/recipes.md +0 -264
package/README.md
CHANGED
|
@@ -90,6 +90,12 @@ checksum-safe managed files. Customized files are reported but never
|
|
|
90
90
|
overwritten. The root
|
|
91
91
|
`AGENTS.md` is user-owned and is not inspected or modified by Agency.
|
|
92
92
|
|
|
93
|
+
The managed `.agency/AGENTS.md` is the complete in-workbase operating contract
|
|
94
|
+
for agents. It is created by `agency init`, updated by checksum-safe integration
|
|
95
|
+
sync, and requires no separately installed Agency skill. CLI help remains the
|
|
96
|
+
source of truth for exact command syntax; this README provides the detailed
|
|
97
|
+
product and protocol reference.
|
|
98
|
+
|
|
93
99
|
When upgrading an existing workbase, synchronization moves a checksum-valid
|
|
94
100
|
Agency-managed root `AGENTS.md` to `.agency/AGENTS.md` once the OpenCode config
|
|
95
101
|
can load the hidden file. A customized root file, including a symlink, is
|
|
@@ -882,14 +888,10 @@ payloads are exported as `@markjaquith/agency/fixtures/protocol/success.json` an
|
|
|
882
888
|
Success, help, and version output exit `0`; usage and command failures exit `1`.
|
|
883
889
|
There are no error-specific exit statuses. `graph --jsonl` streams versioned
|
|
884
890
|
records on success instead of wrapping them in an envelope; JSONL failures still
|
|
885
|
-
use one error envelope.
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
`skills/agency/SKILL.md` contains an agent-oriented operating guide for Agency.
|
|
891
|
-
Install or link that directory into your agent's skill location when you want
|
|
892
|
-
Agency workflows to be discovered automatically.
|
|
891
|
+
use one error envelope. Revision and concurrency behavior is documented under
|
|
892
|
+
Tasks, Phases, and Claims; selector behavior under Noninteractive Use; projection
|
|
893
|
+
behavior under Target Context and Workbase Graph; and retry behavior in the
|
|
894
|
+
machine error contract above.
|
|
893
895
|
|
|
894
896
|
## Development
|
|
895
897
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markjaquith/agency",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.48.0",
|
|
4
4
|
"description": "Manage agentic work across repositories with durable workbases",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"src",
|
|
24
24
|
"schemas",
|
|
25
25
|
"fixtures/protocol",
|
|
26
|
-
"skills",
|
|
27
26
|
"README.md",
|
|
28
27
|
"LICENSE"
|
|
29
28
|
],
|
package/src/cli-parser.test.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test"
|
|
2
2
|
import orchestrationRecipes from "../fixtures/protocol/orchestration-recipes.json"
|
|
3
|
-
import skillSetupCommands from "../fixtures/protocol/skill-setup-commands.json"
|
|
4
3
|
import { parseCli } from "./cli-parser"
|
|
5
4
|
|
|
6
5
|
const expectUsageError = (args: string[], usage: string) => {
|
|
@@ -14,12 +13,6 @@ describe("strict CLI parsing", () => {
|
|
|
14
13
|
}
|
|
15
14
|
})
|
|
16
15
|
|
|
17
|
-
test("accepts every documented skill setup command", () => {
|
|
18
|
-
for (const args of skillSetupCommands) {
|
|
19
|
-
expect(() => parseCli(args)).not.toThrow()
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
|
|
23
16
|
test("rejects misspelled and command-inapplicable options", () => {
|
|
24
17
|
expectUsageError(["task", "list", "--josn"], "agency task")
|
|
25
18
|
expectUsageError(
|
|
@@ -34,7 +34,11 @@ describe("init command", () => {
|
|
|
34
34
|
"/repos/\n/tasks/*/code/\n/tasks/*/phases/*/code/\n",
|
|
35
35
|
)
|
|
36
36
|
expect(await Bun.file(join(root, "AGENTS.md")).exists()).toBe(false)
|
|
37
|
-
|
|
37
|
+
const agents = await Bun.file(join(root, ".agency/AGENTS.md")).text()
|
|
38
|
+
expect(agents).toContain("agency context . --json")
|
|
39
|
+
expect(agents).toContain("## Consent Boundaries")
|
|
40
|
+
expect(agents).toContain("## Execution")
|
|
41
|
+
expect(agents).not.toContain("SKILL.md")
|
|
38
42
|
const opencode = await Bun.file(
|
|
39
43
|
join(root, ".opencode/opencode.jsonc"),
|
|
40
44
|
).text()
|
|
@@ -291,9 +291,21 @@ describe("IntegrationService", () => {
|
|
|
291
291
|
const body = managedBody(managedWorkbaseAgents)
|
|
292
292
|
|
|
293
293
|
expect(body).toContain("agency context . --json")
|
|
294
|
+
expect(body).toContain("agency next --json")
|
|
295
|
+
expect(body).toContain("agency <command> --help")
|
|
294
296
|
expect(body).toContain("authority.writable.checkoutPath")
|
|
295
|
-
expect(body).toContain("
|
|
296
|
-
expect(body).toContain("
|
|
297
|
+
expect(body).toContain("Only `done` satisfies a dependency")
|
|
298
|
+
expect(body).toContain("Require explicit user intent")
|
|
299
|
+
expect(body).toContain("changing repository")
|
|
300
|
+
expect(body).toMatch(/archiving, restoring,\s+dropping, or/)
|
|
301
|
+
expect(body).toContain("Never invent entity IDs")
|
|
302
|
+
expect(body).toContain("Preserve parent backlinks")
|
|
303
|
+
expect(body).toContain("dirty-worktree, active-claim, revision")
|
|
304
|
+
expect(body).toContain("`agency work` is the human launch flow")
|
|
305
|
+
expect(body).toContain("marks execution work")
|
|
306
|
+
expect(body).toContain("without creating a claim")
|
|
307
|
+
expect(body).toContain("formatting, type checks, build, dead-code checks")
|
|
308
|
+
expect(body).toContain("Review and commit the diff")
|
|
297
309
|
expect(body).toContain("Run `agency validate`")
|
|
298
310
|
expect(body).toContain("only with explicit user intent")
|
|
299
311
|
expect(body).toContain("An execution unit remains `working`")
|
|
@@ -309,6 +321,8 @@ describe("IntegrationService", () => {
|
|
|
309
321
|
expect(body).toContain("PR state, current head, diff summary")
|
|
310
322
|
expect(body).toContain("Run `agency validate` before reporting completion")
|
|
311
323
|
expect(body).toContain("agency integration status")
|
|
324
|
+
expect(body).not.toContain("SKILL.md")
|
|
325
|
+
expect(body).not.toContain("~/.agents")
|
|
312
326
|
expect(body).toContain(".opencode/command/agency.md")
|
|
313
327
|
})
|
|
314
328
|
|
|
@@ -480,6 +494,31 @@ describe("IntegrationService", () => {
|
|
|
480
494
|
)
|
|
481
495
|
})
|
|
482
496
|
|
|
497
|
+
test("upgrades prior managed instructions without changing owner instructions", async () => {
|
|
498
|
+
const ownerInstructions = "# User-owned workbase instructions\n"
|
|
499
|
+
const priorInstructions = managed(
|
|
500
|
+
"<!-- agency-managed: sha256=",
|
|
501
|
+
"# Previous Agency instructions\n",
|
|
502
|
+
" -->",
|
|
503
|
+
)
|
|
504
|
+
await write(root, "AGENTS.md", ownerInstructions)
|
|
505
|
+
await write(root, ".agency/AGENTS.md", priorInstructions)
|
|
506
|
+
|
|
507
|
+
const result = await sync(root)
|
|
508
|
+
|
|
509
|
+
expect(result.files[0]).toMatchObject({
|
|
510
|
+
name: "agents",
|
|
511
|
+
state: "managed",
|
|
512
|
+
changed: true,
|
|
513
|
+
})
|
|
514
|
+
expect(await Bun.file(join(root, ".agency/AGENTS.md")).text()).toBe(
|
|
515
|
+
managedWorkbaseAgents,
|
|
516
|
+
)
|
|
517
|
+
expect(await Bun.file(join(root, "AGENTS.md")).text()).toBe(
|
|
518
|
+
ownerInstructions,
|
|
519
|
+
)
|
|
520
|
+
})
|
|
521
|
+
|
|
483
522
|
test("preserves user-owned checkout-skill plugins at either supported path", async () => {
|
|
484
523
|
const custom = "export default async () => ({})\n"
|
|
485
524
|
await write(root, ".opencode/plugins/agency-repository-skills.ts", custom)
|
package/src/workbase/AGENTS.md
CHANGED
|
@@ -16,6 +16,10 @@ Use the returned target, document paths and revisions, dependency readiness,
|
|
|
16
16
|
authority, checkout state, PR state, and validation result. Do not infer these
|
|
17
17
|
from directory names or stale prose.
|
|
18
18
|
|
|
19
|
+
At the workbase root, use `agency next --json` or `agency graph --json` to choose
|
|
20
|
+
work, then inspect the returned document path or explicit entity selectors. Use
|
|
21
|
+
`agency --help` and `agency <command> --help` for exact command syntax.
|
|
22
|
+
|
|
19
23
|
If context or doctor reports a declared but missing repository, run
|
|
20
24
|
`agency repo setup --dry-run` and obtain explicit approval before
|
|
21
25
|
`agency repo setup --apply`. Missing declared aliases are setup state, not a
|
|
@@ -25,27 +29,52 @@ reason to edit `agency.json` or `repos/` by hand.
|
|
|
25
29
|
|
|
26
30
|
- An epic or multi-phase task is orchestration context and has no implementation
|
|
27
31
|
write authority.
|
|
32
|
+
- A single-phase task or phase is an execution unit with one writable `repo` and
|
|
33
|
+
optional read-only `repos`. Only `done` satisfies a dependency; `dropped` is
|
|
34
|
+
terminal but leaves dependents blocked.
|
|
28
35
|
- For an execution unit, write code only at
|
|
29
36
|
`authority.writable.checkoutPath`. Every `authority.references` checkout is
|
|
30
37
|
read-only, even if filesystem permissions allow writes.
|
|
31
38
|
- Keep task-wide decisions in `TASK.md` and phase-specific delivery context in
|
|
32
39
|
`PHASE.md`. Use Agency commands for structural frontmatter mutations.
|
|
33
40
|
|
|
41
|
+
## Consent Boundaries
|
|
42
|
+
|
|
43
|
+
Require explicit user intent before initializing a workbase; changing repository
|
|
44
|
+
aliases or applying repository setup or workbase sync changes; launching another
|
|
45
|
+
agent from an active agent session; creating a pull request; archiving, restoring,
|
|
46
|
+
dropping, or reopening work; or using `--force` to override readiness.
|
|
47
|
+
|
|
34
48
|
## Safety
|
|
35
49
|
|
|
36
50
|
- Stop on validation errors, dependency blockers, an unexpected writable
|
|
37
51
|
repository, or a conflicting active claim.
|
|
38
|
-
- `agency work` is the local launch flow and marks execution units `working`
|
|
39
|
-
without claiming them. External orchestrators claim before launching runners.
|
|
40
52
|
- Do not manually create, move, or remove worktrees under `code/`.
|
|
41
53
|
- Use `agency archive`, rather than moving work item folders manually.
|
|
42
54
|
- Do not edit bare repositories or repository symlinks under `repos/`.
|
|
55
|
+
- Never invent entity IDs, revisions, PR state, dependency completion, or
|
|
56
|
+
checkout state. Preserve parent backlinks and dependency declarations.
|
|
57
|
+
- Do not bypass dirty-worktree, active-claim, revision, or readiness protections.
|
|
43
58
|
- Do not run `agency work` from an active agent session unless the user
|
|
44
59
|
explicitly asks to launch another agent.
|
|
45
60
|
- Run `agency validate` before worktree or pull-request operations.
|
|
46
61
|
- Create a pull request only with explicit user intent, using
|
|
47
62
|
`agency pr create <task> [phase]` so the URL is recorded durably.
|
|
48
63
|
|
|
64
|
+
## Execution
|
|
65
|
+
|
|
66
|
+
For implementation work, read the task and phase prose returned by context,
|
|
67
|
+
change only the writable checkout, keep durable decisions current, and run the
|
|
68
|
+
repository's formatting, type checks, build, dead-code checks, and focused tests.
|
|
69
|
+
Review and commit the diff according to the repository's instructions.
|
|
70
|
+
|
|
71
|
+
`agency work` is the human launch flow: it reconciles managed integration,
|
|
72
|
+
selects work, checks readiness, prepares checkouts, marks execution work
|
|
73
|
+
`working` without creating a claim, and starts the runner. Epic and multi-phase
|
|
74
|
+
task launches remain orchestration-only. External orchestrators instead claim
|
|
75
|
+
an execution unit, launch and monitor their runner separately, and finish or
|
|
76
|
+
release the claim with the current document revision.
|
|
77
|
+
|
|
49
78
|
## Closeout
|
|
50
79
|
|
|
51
80
|
An execution unit remains `working` after implementation is committed and while
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
["init", "/work/agency", "--json"],
|
|
3
|
-
["workbase", "init", "/work/agency", "--json"],
|
|
4
|
-
["repo", "add", "agency", "git@example.com:owner/agency.git", "--json"],
|
|
5
|
-
["repo", "setup", "--dry-run", "--json"],
|
|
6
|
-
["repo", "setup", "--apply", "--json"],
|
|
7
|
-
["repo", "link", "agency", "/work/agency-repository", "--json"],
|
|
8
|
-
[
|
|
9
|
-
"--workbase",
|
|
10
|
-
"/work/agency",
|
|
11
|
-
"repo",
|
|
12
|
-
"link",
|
|
13
|
-
"agency",
|
|
14
|
-
"/work/agency-repository"
|
|
15
|
-
],
|
|
16
|
-
["validate", "/work/agency"],
|
|
17
|
-
["--workbase", "/work/agency", "repo", "verify", "agency"]
|
|
18
|
-
]
|
package/skills/agency/SKILL.md
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: agency
|
|
3
|
-
description: >
|
|
4
|
-
Operate Agency workbases, epics, tasks, phases, execution worktrees, claims,
|
|
5
|
-
and pull requests. Use when inspecting or changing Agency-managed work,
|
|
6
|
-
coordinating dependencies, launching agents, or finishing an execution unit.
|
|
7
|
-
license: MIT
|
|
8
|
-
compatibility: Requires the agency CLI and Git. Agent launch requires OpenCode, Claude, or a configured runner; default GitHub delivery requires gh.
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# Agency
|
|
12
|
-
|
|
13
|
-
Agency keeps plans and lifecycle state in durable Markdown documents and keeps
|
|
14
|
-
portable repository aliases in `agency.json`. Bare repositories under `repos/`
|
|
15
|
-
and Git checkouts under `code/` are ignored local materializations. Treat tracked
|
|
16
|
-
workbase state as authoritative and Agency commands as the safe mutation path.
|
|
17
|
-
|
|
18
|
-
## Start With Context
|
|
19
|
-
|
|
20
|
-
For an entity target, the first inspection command is:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
agency context . --json
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
It identifies the target and ancestors, document revisions, dependency
|
|
27
|
-
readiness, write authority, checkout state, PR state, and validation warnings.
|
|
28
|
-
Use its paths and IDs instead of inferring them from the process cwd.
|
|
29
|
-
|
|
30
|
-
At the workbase root, context cannot infer one entity from `.`. Use
|
|
31
|
-
`agency next --json` or `agency graph --json` to choose a target, then inspect it
|
|
32
|
-
with explicit `--epic`, `--task`, and `--phase` selectors or its returned document
|
|
33
|
-
path. Do not pass a graph node key as a positional context target.
|
|
34
|
-
|
|
35
|
-
For broader orchestration, load the graph and discover available capabilities:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
agency graph --json
|
|
39
|
-
agency doctor --json
|
|
40
|
-
agency --help
|
|
41
|
-
agency <command> --help
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Use `agency next --json` when choosing ready execution work. Read
|
|
45
|
-
[`references/contracts.md`](references/contracts.md) when consuming machine
|
|
46
|
-
output or editing documents.
|
|
47
|
-
|
|
48
|
-
## Mental Model
|
|
49
|
-
|
|
50
|
-
- A **workbase** contains durable epics, tasks, phases, and repository aliases.
|
|
51
|
-
- A repository declaration stores an alias and credential-free canonical fetch
|
|
52
|
-
remote; local bare clones and linked checkouts are replaceable machine state.
|
|
53
|
-
- An **epic** coordinates tasks. It may inspect repositories but never writes code.
|
|
54
|
-
- A **task** is one durable outcome. It is either an execution unit itself or a
|
|
55
|
-
container for phases.
|
|
56
|
-
- A **phase** is one execution unit within a multi-phase task, normally one PR.
|
|
57
|
-
- An **execution unit** has exactly one writable `repo`, optional read-only
|
|
58
|
-
`repos`, one branch, one base, and one recorded PR value.
|
|
59
|
-
- `open` is eligible for readiness evaluation, `working` is actively owned, and
|
|
60
|
-
`done` or `dropped` is terminal. An open unit may still be blocked; only `done`
|
|
61
|
-
satisfies a dependency.
|
|
62
|
-
|
|
63
|
-
The `authority` returned by context is decisive. Write only through
|
|
64
|
-
`authority.writable.checkoutPath`. Every entry in `authority.references` is
|
|
65
|
-
read-only, even if filesystem permissions permit writes.
|
|
66
|
-
|
|
67
|
-
## Decide Before Acting
|
|
68
|
-
|
|
69
|
-
Require explicit user intent before:
|
|
70
|
-
|
|
71
|
-
- initializing a workbase;
|
|
72
|
-
- adding, linking, renaming, or removing a repository alias;
|
|
73
|
-
- applying repository setup or sync changes;
|
|
74
|
-
- launching another agent with `agency work` from an active agent session;
|
|
75
|
-
- creating a pull request;
|
|
76
|
-
- archiving, restoring, dropping, or reopening work; or
|
|
77
|
-
- using `--force` to override readiness.
|
|
78
|
-
|
|
79
|
-
Use a single-phase task for one outcome delivered by one PR. Use phases when an
|
|
80
|
-
outcome needs multiple PRs or ordered execution units. Use an epic when several
|
|
81
|
-
independently meaningful tasks need coordination.
|
|
82
|
-
|
|
83
|
-
## Safety Invariants
|
|
84
|
-
|
|
85
|
-
- Keep task-wide decisions in `TASK.md` and phase delivery details in `PHASE.md`.
|
|
86
|
-
- Never write through plural `repos` references.
|
|
87
|
-
- Never edit bare repositories or repository symlinks under `repos/`.
|
|
88
|
-
- Never persist local paths, symlink targets, worktrees, or credentials as
|
|
89
|
-
repository remotes.
|
|
90
|
-
- Never manually create, move, or remove generated `code/` worktrees.
|
|
91
|
-
- Never invent IDs, revisions, PR URLs, dependency completion, or checkout state.
|
|
92
|
-
- Preserve parent backlinks and dependency declarations; use Agency mutations
|
|
93
|
-
instead of hand-editing structural frontmatter.
|
|
94
|
-
- Run `agency validate` before worktree or PR operations and after structural edits.
|
|
95
|
-
- Do not bypass dirty-worktree, active-claim, revision, or readiness protections.
|
|
96
|
-
|
|
97
|
-
## Operating Protocol
|
|
98
|
-
|
|
99
|
-
### Start
|
|
100
|
-
|
|
101
|
-
1. Run `agency context . --json`.
|
|
102
|
-
2. Confirm `target`, `graph.readiness`, `authority`, `workspace`, and `validation`.
|
|
103
|
-
3. Read the returned task and phase document paths for prose requirements.
|
|
104
|
-
4. Stop on validation errors, dependency blockers, an unexpected writable
|
|
105
|
-
repository, or a conflicting active owner. A local `agency work` launch has
|
|
106
|
-
no claim; an externally assigned agent must own the active claim.
|
|
107
|
-
|
|
108
|
-
### Work
|
|
109
|
-
|
|
110
|
-
1. Change files only in the declared writable checkout.
|
|
111
|
-
2. Keep durable status and decisions current as the work changes.
|
|
112
|
-
3. Validate structure after Agency document mutations.
|
|
113
|
-
4. Run repository-specific formatting, type checks, builds, dead-code checks,
|
|
114
|
-
and focused tests before committing.
|
|
115
|
-
5. Review the diff and commit according to the repository's instructions.
|
|
116
|
-
|
|
117
|
-
### Finish
|
|
118
|
-
|
|
119
|
-
1. Re-run `agency validate` and repository checks.
|
|
120
|
-
2. Create a PR only when requested: `agency pr create <task> [phase]`.
|
|
121
|
-
3. Keep committed work `working` while its pull request is open. After the
|
|
122
|
-
authoritative pull request merges, use `agency sync --apply` to reconcile it
|
|
123
|
-
to `done`.
|
|
124
|
-
4. If the session has a claim, use revision-guarded `agency finish`; a successful
|
|
125
|
-
claim outcome closes ownership without marking unmerged work `done`. Use
|
|
126
|
-
`dropped` only for intentionally abandoned work.
|
|
127
|
-
5. Report the durable status and PR URL. Do not manually remove the worktree.
|
|
128
|
-
|
|
129
|
-
## Human Launch vs Active Agent
|
|
130
|
-
|
|
131
|
-
`agency work` is a human/orchestrator launch flow. It first reconciles managed
|
|
132
|
-
integration files, then selects work and checks readiness. For an execution unit,
|
|
133
|
-
it materializes managed checkouts, marks it working without a claim, and starts
|
|
134
|
-
the selected built-in or configured runner. Epic and multi-phase task launches
|
|
135
|
-
start in orchestration context without materializing execution work. The runner
|
|
136
|
-
opens without a prompt unless the human explicitly selects `--auto`.
|
|
137
|
-
OpenCode launches expose the managed config file and inject runtime-only access
|
|
138
|
-
rules scoped to the workbase. These grant visibility from orchestration
|
|
139
|
-
directories and nested execution checkouts while denying direct edits outside
|
|
140
|
-
the writable checkout. They do not make the Git-synced config machine-specific
|
|
141
|
-
or replace write authority from `agency context`.
|
|
142
|
-
|
|
143
|
-
An agent already running in an Agency checkout must not call `agency work` to
|
|
144
|
-
start itself again. It should inspect context, perform the assigned work, and
|
|
145
|
-
finish its claim or update unclaimed status directly. Launch a nested or
|
|
146
|
-
replacement agent only when the user explicitly asks.
|
|
147
|
-
|
|
148
|
-
Use [`references/recipes.md`](references/recipes.md) for human setup, agent
|
|
149
|
-
execution, claim, PR, conversion, and recovery workflows. Use
|
|
150
|
-
[`references/commands.md`](references/commands.md) only when exact command syntax
|
|
151
|
-
is needed.
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
# Agency Command Reference
|
|
2
|
-
|
|
3
|
-
Use this reference after `agency context . --json` identifies the target. The
|
|
4
|
-
forms below are exact for this Agency release. Run `agency <command> --help` when
|
|
5
|
-
using an option not shown here or when the installed CLI version differs.
|
|
6
|
-
Commands that return Agency-owned data accept `--json` unless noted otherwise.
|
|
7
|
-
|
|
8
|
-
## Discovery And Health
|
|
9
|
-
|
|
10
|
-
```text
|
|
11
|
-
agency context [target] [--json] [--compact | --full]
|
|
12
|
-
agency graph [--json | --jsonl] [--ready | --blocked]
|
|
13
|
-
[--status <status>...] [--repository <alias>...] [--kind <kind>...]
|
|
14
|
-
[--include <bodies|workspace|git|pr>...]
|
|
15
|
-
agency next [--select] [--json]
|
|
16
|
-
agency status [filters] [--json]
|
|
17
|
-
agency validate [path] [--json]
|
|
18
|
-
agency doctor [--json]
|
|
19
|
-
agency sync [--dry-run | --apply] [--json]
|
|
20
|
-
agency integration status [--json]
|
|
21
|
-
agency integration sync [--json]
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
`context` defaults to cwd and accepts the workbase root, entity directories,
|
|
25
|
-
document paths, checkout descendants, or a task ID. Root context catalogs all
|
|
26
|
-
epics, tasks, and phases in compact form and hints that `--full` includes prose.
|
|
27
|
-
Entity context is complete by default; `--compact` intentionally omits prose and
|
|
28
|
-
low-level Git details. `graph` computes readiness before applying filters.
|
|
29
|
-
`doctor` discovers required tools, integrations, repositories, refs, worktrees,
|
|
30
|
-
permissions, drift, and optional runner capabilities. `sync` is
|
|
31
|
-
observational unless `--apply` is explicit. Integration status includes safe
|
|
32
|
-
remediation when customized OpenCode config prevents Agency from guaranteeing
|
|
33
|
-
whole-workbase access.
|
|
34
|
-
|
|
35
|
-
Where `[filters]` appears, use repeatable `--status <status>` and `--repository
|
|
36
|
-
<alias>`, plus `--ready` or `--blocked` and `--pr` or `--no-pr`. Each pair is
|
|
37
|
-
mutually exclusive.
|
|
38
|
-
|
|
39
|
-
## Workbase And Repositories
|
|
40
|
-
|
|
41
|
-
```text
|
|
42
|
-
agency workbase init [path] [--json]
|
|
43
|
-
agency init [path] [--json] # Alias
|
|
44
|
-
agency workbase add <path> [--name <name>] [--json]
|
|
45
|
-
agency workbase list [--json]
|
|
46
|
-
agency workbase show <id|name|path> [--json]
|
|
47
|
-
agency workbase name <id|name|path> (<name> | --clear) [--json]
|
|
48
|
-
agency workbase default [<id|name|path> | --clear] [--json]
|
|
49
|
-
agency workbase remove <id|name|path> [--json]
|
|
50
|
-
agency workbase prune [--json]
|
|
51
|
-
agency repo setup [--dry-run | --apply] [--json]
|
|
52
|
-
agency repo add <alias> <remote> [--json]
|
|
53
|
-
agency repo link <alias> <path> [--json]
|
|
54
|
-
agency repo list [--json]
|
|
55
|
-
agency repo show <alias> [--json]
|
|
56
|
-
agency repo fetch <alias> [--json]
|
|
57
|
-
agency repo remote <alias> [remote] [--json]
|
|
58
|
-
agency repo verify <alias> [--json]
|
|
59
|
-
agency repo rename <alias> <new-alias> [--json]
|
|
60
|
-
agency repo remove <alias> [--json]
|
|
61
|
-
agency repo unlink <alias> [--json]
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
`repo setup` defaults to an observational dry-run. Apply clones declared missing
|
|
65
|
-
repositories and adopts legacy materializations only when their portable origin
|
|
66
|
-
is unambiguous. Invalid paths and remote drift remain unresolved.
|
|
67
|
-
|
|
68
|
-
`repo add` creates a declaration and bare clone. `repo link` creates a local
|
|
69
|
-
symlink while retaining or inferring a credential-free portable remote.
|
|
70
|
-
`repo remove` removes both the declaration and unused local materialization;
|
|
71
|
-
`repo unlink` removes only this machine's symlink and retains the declaration.
|
|
72
|
-
Removal and rename refuse active references or linked worktree conflicts.
|
|
73
|
-
|
|
74
|
-
## Epics, Tasks, And Phases
|
|
75
|
-
|
|
76
|
-
```text
|
|
77
|
-
agency epic create <id> --ticket-url <url> [--description <text>]
|
|
78
|
-
--repo <alias>:<ref>... [--json]
|
|
79
|
-
agency epic list [filters] [--json]
|
|
80
|
-
agency epic show <id> [--json]
|
|
81
|
-
agency epic update <id> [metadata options] [--if-revision <hash>] [--json]
|
|
82
|
-
agency epic rename <id> <new-id> [--if-revision <hash>] [--json]
|
|
83
|
-
|
|
84
|
-
agency task new [id]
|
|
85
|
-
agency task create <id> --repo <alias> [--ticket-url <url>]
|
|
86
|
-
[--description <text>] [--epic <id>] [--reference <alias>:<ref>...]
|
|
87
|
-
[--branch <name>] [--base <name>] [--json]
|
|
88
|
-
agency task create <id> --multi-phase [--ticket-url <url>]
|
|
89
|
-
[--description <text>] [--epic <id>] [--json]
|
|
90
|
-
agency task list [filters] [--json]
|
|
91
|
-
agency task show <id> [--json]
|
|
92
|
-
agency task status <id> <open|working|dropped> [--json]
|
|
93
|
-
agency task update <id> [metadata options] [--if-revision <hash>] [--json]
|
|
94
|
-
agency task rename <id> <new-id> [--if-revision <hash>] [--json]
|
|
95
|
-
agency task move <id> (--epic <epic-id> | --no-epic)
|
|
96
|
-
[--if-revision <hash>] [--json]
|
|
97
|
-
agency task dependency <add|remove> <task-id> <dependency-id>
|
|
98
|
-
[--if-revision <hash>] [--json]
|
|
99
|
-
|
|
100
|
-
agency phase create <task-id> <phase-id> --repo <alias> --branch <name>
|
|
101
|
-
--base <name> [--description <text>] [--reference <alias>:<ref>...]
|
|
102
|
-
[--depends-on <phase-id>...] [--first-phase <phase-id>] [--json]
|
|
103
|
-
agency phase list <task-id> [filters] [--json]
|
|
104
|
-
agency phase show <task-id> <phase-id> [--json]
|
|
105
|
-
agency phase status <task-id> <phase-id> <open|working|dropped> [--json]
|
|
106
|
-
agency phase update <task-id> <phase-id> [metadata options]
|
|
107
|
-
[--if-revision <hash>] [--json]
|
|
108
|
-
agency phase rename <task-id> <phase-id> <new-id>
|
|
109
|
-
[--if-revision <hash>] [--json]
|
|
110
|
-
agency phase dependency <add|remove> <task-id> <phase-id> <dependency-id>
|
|
111
|
-
[--if-revision <hash>] [--json]
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
`task new` uses the OpenTUI Solid footer and requires a TTY. A sole repository is
|
|
115
|
-
selected automatically. Agents and scripts use noninteractive `task create`.
|
|
116
|
-
Mutation commands that accept `--if-revision`
|
|
117
|
-
return a revision conflict instead of overwriting changed documents.
|
|
118
|
-
|
|
119
|
-
## Ownership And Lifecycle
|
|
120
|
-
|
|
121
|
-
```text
|
|
122
|
-
agency claim <task-id> [phase-id] --claimant <id> --runner <id>
|
|
123
|
-
--session-id <id> --revision <sha256> [--expires-at <timestamp>] [--json]
|
|
124
|
-
agency release <task-id> [phase-id] --session-id <id>
|
|
125
|
-
--revision <sha256> [--json]
|
|
126
|
-
agency finish <task-id> [phase-id] --session-id <id>
|
|
127
|
-
--revision <sha256> --outcome <done|dropped> [--json]
|
|
128
|
-
|
|
129
|
-
agency archive list [--kind <kind>] [--status <status>]
|
|
130
|
-
[--repository <alias>]
|
|
131
|
-
agency archive show <epic|task> <id>
|
|
132
|
-
agency archive show phase <task-id> <phase-id>
|
|
133
|
-
agency archive epic <epic-id> [--dry-run] [--json]
|
|
134
|
-
agency archive task <task-id> [--dry-run] [--json]
|
|
135
|
-
agency archive phase <task-id> <phase-id> [--dry-run] [--json]
|
|
136
|
-
agency restore epic <epic-id> [--dry-run] [--json]
|
|
137
|
-
agency restore task <task-id> [--dry-run] [--json]
|
|
138
|
-
agency restore phase <task-id> <phase-id> [--dry-run] [--json]
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Claim mutations require the current execution-document revision. Archive and
|
|
142
|
-
restore preflight graph and destination safety, remove registered clean
|
|
143
|
-
worktrees when needed, preserve branches, and retain lifecycle provenance.
|
|
144
|
-
|
|
145
|
-
## Worktrees, Launch, And Pull Requests
|
|
146
|
-
|
|
147
|
-
```text
|
|
148
|
-
agency work [<directory-or-task-id> | --epic <id> | --task <id> [--phase <id>]]
|
|
149
|
-
[--runner <name> | --opencode | --claude] [--auto] [--print-command] [--force]
|
|
150
|
-
agency work prepare [target] [--dry-run] [--json]
|
|
151
|
-
agency worktree list [--json]
|
|
152
|
-
agency worktree inspect <task-id> [phase-id] [--json]
|
|
153
|
-
agency worktree prepare <task-id> [phase-id] [--dry-run] [--json]
|
|
154
|
-
agency worktree remove <task-id> [phase-id] [--dry-run] [--json]
|
|
155
|
-
agency worktree rebuild <task-id> [phase-id] [--dry-run] [--json]
|
|
156
|
-
agency worktree repair <task-id> [phase-id] [--dry-run] [--json]
|
|
157
|
-
agency pr create <task-id> [phase-id] [--draft] [--force] [--json]
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
`work` is a local launch flow, not an active-agent step. It synchronizes managed
|
|
161
|
-
integration files before launch. Execution targets are materialized and marked
|
|
162
|
-
working without a claim; epics and multi-phase tasks launch in orchestration
|
|
163
|
-
context without those steps. Unclaimed working targets can be launched again.
|
|
164
|
-
The runner opens without a generated prompt unless `--auto` is set.
|
|
165
|
-
The OpenCode runner receives a runtime managed-config path plus absolute access
|
|
166
|
-
and edit rules scoped to the workbase; none are persisted, and `context` still
|
|
167
|
-
defines write authority.
|
|
168
|
-
`--print-command` materializes execution targets but does not launch or change
|
|
169
|
-
status. `work prepare` materializes without launching or changing status.
|
|
170
|
-
Destructive remove and rebuild operations refuse dirty or conflicting state.
|
|
171
|
-
Conservative repair may correct registration while preserving dirty files, but
|
|
172
|
-
never discards changes.
|
|
173
|
-
`pr create` materializes a missing workspace, requires the resulting writable
|
|
174
|
-
checkout to be clean, pushes the declared branch, invokes the configured delivery
|
|
175
|
-
provider or falls back to `gh pr create --fill`, and records the returned pull
|
|
176
|
-
request record.
|
|
177
|
-
|
|
178
|
-
## Noninteractive Selection
|
|
179
|
-
|
|
180
|
-
Use global `--workbase <id|name|path>` outside a workbase. A path may identify a
|
|
181
|
-
registered workbase or an existing workbase directly. Use `--cwd <path>` to
|
|
182
|
-
perform cwd inference elsewhere. Targeted commands accept `--epic`, `--task`,
|
|
183
|
-
and, with a task, `--phase`. `--json`, `--no-input`, or non-TTY execution disables
|
|
184
|
-
prompts; provide all selectors and required inputs explicitly.
|
|
185
|
-
|
|
186
|
-
Selectors are only a resolution mechanism. There is no `assign` command. Use
|
|
187
|
-
`work` for a local human launch, or use `claim` and manage an external runner
|
|
188
|
-
separately.
|
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
# Agency Data Contracts
|
|
2
|
-
|
|
3
|
-
Use Agency JSON output instead of scraping human tables. Entity IDs are directory
|
|
4
|
-
names; they are not duplicated in frontmatter.
|
|
5
|
-
|
|
6
|
-
## Context Contract
|
|
7
|
-
|
|
8
|
-
`agency context . --json` returns a versioned success envelope whose result
|
|
9
|
-
contains:
|
|
10
|
-
|
|
11
|
-
- `projection`: `compact` for root discovery by default, otherwise `complete`
|
|
12
|
-
unless compact entity context was explicitly requested;
|
|
13
|
-
- `workbase`: root, config path, and config version;
|
|
14
|
-
- `target`: resolved workbase, epic, task, or phase identity;
|
|
15
|
-
- `discovery`: at the workbase root, all valid epic, task, and phase documents;
|
|
16
|
-
- `documents`: ancestor frontmatter, paths, SHA-256 revisions, and prose;
|
|
17
|
-
- `graph`: parent, dependencies, dependents, readiness blockers, and progress;
|
|
18
|
-
- `authority`: `orchestration` or `execution`, one writable checkout or none,
|
|
19
|
-
and read-only references;
|
|
20
|
-
- `workspace`: code path, materialization and registration state, commits, and
|
|
21
|
-
inspection warnings;
|
|
22
|
-
- `pr`: recorded provider-neutral pull request identity and state; and
|
|
23
|
-
- `validation`: validity and issues.
|
|
24
|
-
|
|
25
|
-
Compact context retains identity, revisions, authority, paths, graph state,
|
|
26
|
-
materialization, and warnings while omitting prose and low-level Git details.
|
|
27
|
-
|
|
28
|
-
## Repository Declarations
|
|
29
|
-
|
|
30
|
-
Tracked `agency.json` may contain portable repository declarations:
|
|
31
|
-
|
|
32
|
-
```json
|
|
33
|
-
{
|
|
34
|
-
"version": 2,
|
|
35
|
-
"repositories": {
|
|
36
|
-
"frontend": { "remote": "git@example.com:team/frontend.git" }
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Remotes are provider-neutral network Git remotes. Local paths, file URLs, and
|
|
42
|
-
credential-bearing HTTP URLs are invalid. `repos/`, task and phase `code/`, and
|
|
43
|
-
symlink targets are local-only and never part of this contract.
|
|
44
|
-
|
|
45
|
-
Repository inspection returns `declaredRemote`, the actual local `remote`, and
|
|
46
|
-
orthogonal `states`: `declared`, `materialized`, `linked`, `missing`, `invalid`,
|
|
47
|
-
and `remote-drifted`. Setup JSON contains `mode`, `actions`, `unresolved`, and the
|
|
48
|
-
post-operation `repositories`. Actions are `materialize` or `adopt`, with
|
|
49
|
-
`planned` or `applied` status. Dry-run never mutates. Apply never overwrites a
|
|
50
|
-
link or path and never repairs drift without an explicit remote choice.
|
|
51
|
-
|
|
52
|
-
## Frontmatter Shapes
|
|
53
|
-
|
|
54
|
-
### Epic
|
|
55
|
-
|
|
56
|
-
```yaml
|
|
57
|
-
---
|
|
58
|
-
ticketUrl: https://example.com/tickets/checkout
|
|
59
|
-
description: Coordinate checkout delivery.
|
|
60
|
-
repos:
|
|
61
|
-
- repo: frontend
|
|
62
|
-
ref: main
|
|
63
|
-
tasks:
|
|
64
|
-
- id: api
|
|
65
|
-
- id: ui
|
|
66
|
-
dependsOn:
|
|
67
|
-
- api
|
|
68
|
-
---
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Epics have read-only `repos`, never a writable `repo`. Their `tasks` list owns
|
|
72
|
-
task ordering and task dependencies.
|
|
73
|
-
|
|
74
|
-
### Single-Phase Task
|
|
75
|
-
|
|
76
|
-
```yaml
|
|
77
|
-
---
|
|
78
|
-
ticketUrl: null
|
|
79
|
-
description: Refresh checkout copy.
|
|
80
|
-
epic: checkout
|
|
81
|
-
repo: frontend
|
|
82
|
-
repos:
|
|
83
|
-
- repo: backend
|
|
84
|
-
ref: main
|
|
85
|
-
branch: task/refresh-copy
|
|
86
|
-
base: main
|
|
87
|
-
pr: null
|
|
88
|
-
status: open
|
|
89
|
-
---
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Multi-Phase Task
|
|
93
|
-
|
|
94
|
-
```yaml
|
|
95
|
-
---
|
|
96
|
-
ticketUrl: null
|
|
97
|
-
description: Deliver checkout.
|
|
98
|
-
epic: checkout
|
|
99
|
-
phases:
|
|
100
|
-
- id: api
|
|
101
|
-
- id: ui
|
|
102
|
-
dependsOn:
|
|
103
|
-
- api
|
|
104
|
-
---
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
The task's `phases` list owns phase ordering and dependencies. Execution fields
|
|
108
|
-
belong in each phase document.
|
|
109
|
-
|
|
110
|
-
### Phase
|
|
111
|
-
|
|
112
|
-
```yaml
|
|
113
|
-
---
|
|
114
|
-
description: Build the checkout UI.
|
|
115
|
-
repo: frontend
|
|
116
|
-
repos:
|
|
117
|
-
- repo: backend
|
|
118
|
-
ref: main
|
|
119
|
-
branch: task/checkout-ui
|
|
120
|
-
base: task/checkout-api
|
|
121
|
-
pr: null
|
|
122
|
-
status: open
|
|
123
|
-
---
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
`ticketUrl` belongs to tasks and epics, not phases. `description` is optional but
|
|
127
|
-
must be non-empty when present. `pr` is `null`, a legacy GitHub PR URL, or a
|
|
128
|
-
provider-neutral record containing `provider`, `repository`, `identifier`, `url`,
|
|
129
|
-
`state`, `draft`, `merged`, and optional `mergeable`. Mergeability is `true`,
|
|
130
|
-
`false`, or `null` when the provider cannot determine it. New PR creation writes
|
|
131
|
-
the structured record.
|
|
132
|
-
Status is `open`, `working`, `delegated`, `done`, or `dropped`; `delegated` is
|
|
133
|
-
readable legacy state but cannot be newly assigned.
|
|
134
|
-
|
|
135
|
-
## Structural Invariants
|
|
136
|
-
|
|
137
|
-
- An execution unit has one writable `repo`; plural `repos` are read-only
|
|
138
|
-
`{ repo, ref }` entries and cannot repeat the writable alias.
|
|
139
|
-
- A writable `(repo, branch)` pair belongs to exactly one active execution unit.
|
|
140
|
-
- `done` represents an authoritative merged pull request and is reconciled by
|
|
141
|
-
`agency sync --apply`; committed or review-ready work remains `working`.
|
|
142
|
-
- Only `done` satisfies dependencies. `dropped` is terminal but blocks dependents.
|
|
143
|
-
- Epic task dependencies live in `EPIC.md`; phase dependencies live in `TASK.md`.
|
|
144
|
-
- IDs remain stable; use `dependsOn`, not numeric directory prefixes, for order.
|
|
145
|
-
- YAML duplicate keys, anchors, aliases, and custom tags are invalid.
|
|
146
|
-
- Use a commit SHA as a reference `ref` when reproducibility is required.
|
|
147
|
-
|
|
148
|
-
## Graph Contract
|
|
149
|
-
|
|
150
|
-
`agency graph --json` emits graph contract version 1. Stable node IDs are
|
|
151
|
-
`epic:<id>`, `task:<id>`, `phase:<task>/<phase>`,
|
|
152
|
-
`repository:<alias>`, and `execution-unit:<kind>/<id>`. Edge types are `owns`,
|
|
153
|
-
`depends_on`, `writes`, and `references`.
|
|
154
|
-
|
|
155
|
-
Every work node includes status, readiness, `blockedBy`, detailed blockers,
|
|
156
|
-
terminal state, reverse dependents, and aggregate progress. Filters run after
|
|
157
|
-
state computation. `--jsonl` emits a versioned `meta` record, node and edge
|
|
158
|
-
records, then an `end` record; together they reconstruct the JSON result.
|
|
159
|
-
|
|
160
|
-
## Machine Envelope
|
|
161
|
-
|
|
162
|
-
The published success fixture is normalized from
|
|
163
|
-
`agency init /work/agency --json`:
|
|
164
|
-
|
|
165
|
-
```json
|
|
166
|
-
{
|
|
167
|
-
"version": 1,
|
|
168
|
-
"ok": true,
|
|
169
|
-
"result": {
|
|
170
|
-
"root": "/work/agency"
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
The published error fixture is the output of `agency unknown --json`:
|
|
176
|
-
|
|
177
|
-
```json
|
|
178
|
-
{
|
|
179
|
-
"version": 1,
|
|
180
|
-
"ok": false,
|
|
181
|
-
"error": {
|
|
182
|
-
"code": "CLI_USAGE",
|
|
183
|
-
"message": "Unknown command 'unknown'.\n\nUsage: agency <command> [options]",
|
|
184
|
-
"fields": {
|
|
185
|
-
"detail": "Unknown command 'unknown'.",
|
|
186
|
-
"usage": "agency <command> [options]"
|
|
187
|
-
},
|
|
188
|
-
"retryable": false,
|
|
189
|
-
"remediation": "Correct the arguments using the usage value in error.fields."
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
These examples are exported from `fixtures/protocol/` and tested against real
|
|
195
|
-
CLI subprocess output. The Effect schemas are exported by the package and by
|
|
196
|
-
`@markjaquith/agency/protocol`. The distributable JSON Schemas are exported as
|
|
197
|
-
`@markjaquith/agency/schemas/agency-envelope-v1.json` and
|
|
198
|
-
`@markjaquith/agency/schemas/agency-graph-v1.json`.
|
|
199
|
-
|
|
200
|
-
Only the envelope and graph result have published JSON Schemas. The envelope's
|
|
201
|
-
`result` is intentionally unconstrained. Context, next, claim, prepare, sync,
|
|
202
|
-
repository setup, and PR result shapes are exercised by CLI tests but do not have independent
|
|
203
|
-
published schemas.
|
|
204
|
-
|
|
205
|
-
### Output And Exit Guarantees
|
|
206
|
-
|
|
207
|
-
- `--json` writes exactly one newline-terminated envelope to stdout on success
|
|
208
|
-
or failure. It disables interactive selection and takes precedence over
|
|
209
|
-
`--silent`; explicit entity selectors remain valid.
|
|
210
|
-
- Human output is not a machine contract. Do not parse tables, progress text, or
|
|
211
|
-
diagnostic wording.
|
|
212
|
-
- Progress and verbose diagnostics use stderr. Structured command warnings stay
|
|
213
|
-
inside the stdout result. Successful JSON mode does not promise empty stderr
|
|
214
|
-
when `--verbose` is requested.
|
|
215
|
-
- Success, help, and version output exit `0`. Usage errors and every command
|
|
216
|
-
failure exit `1`. Version 1 has no error-specific exit statuses; branch on
|
|
217
|
-
`error.code`.
|
|
218
|
-
- `graph --jsonl` is the one streaming exception. On success it writes a `meta`
|
|
219
|
-
record, node and edge records, and an `end` record rather than an envelope. A
|
|
220
|
-
JSONL failure still writes one error envelope and exits `1`.
|
|
221
|
-
- A command that emits zero machine results succeeds with `result: null`.
|
|
222
|
-
Multiple results are a `PROTOCOL_OUTPUT_ERROR`.
|
|
223
|
-
|
|
224
|
-
### Error Codes
|
|
225
|
-
|
|
226
|
-
| Code | Meaning |
|
|
227
|
-
| ------------------------- | -------------------------------------------------------------- |
|
|
228
|
-
| `CLI_USAGE` | Invalid command, option, argument, or combination |
|
|
229
|
-
| `WORKBASE_NOT_FOUND` | No workbase could be resolved |
|
|
230
|
-
| `WORKBASE_CONFIG_INVALID` | Invalid workbase configuration |
|
|
231
|
-
| `WORKBASE_REGISTRY_ERROR` | Invalid or inaccessible workbase registry |
|
|
232
|
-
| `FILE_NOT_FOUND` | A required path does not exist |
|
|
233
|
-
| `FILESYSTEM_ERROR` | A filesystem operation failed |
|
|
234
|
-
| `FRONTMATTER_INVALID` | Durable document frontmatter is invalid |
|
|
235
|
-
| `VALIDATION_FAILED` | Workbase validation reported issues |
|
|
236
|
-
| `REPOSITORY_ERROR` | Repository operation failed |
|
|
237
|
-
| `EPIC_ERROR` | Epic operation failed |
|
|
238
|
-
| `TASK_ERROR` | Task operation failed |
|
|
239
|
-
| `PHASE_ERROR` | Phase operation failed |
|
|
240
|
-
| `CLAIM_ERROR` | Claim input or lifecycle state is invalid |
|
|
241
|
-
| `CLAIM_CONFLICT` | Active or legacy ownership conflicts with an operation |
|
|
242
|
-
| `REVISION_CONFLICT` | A durable document changed since inspection |
|
|
243
|
-
| `CLAIM_OWNERSHIP` | The session does not own the active claim |
|
|
244
|
-
| `ARCHIVE_ERROR` | Archive or restore operation failed |
|
|
245
|
-
| `WORKTREE_ERROR` | Worktree operation failed |
|
|
246
|
-
| `PULL_REQUEST_ERROR` | Pull request operation failed |
|
|
247
|
-
| `CONTEXT_ERROR` | A context target or required document is invalid |
|
|
248
|
-
| `GRAPH_ERROR` | Graph construction or filtering failed |
|
|
249
|
-
| `EXECUTION_BLOCKED` | Readiness or lifecycle blockers prevent execution |
|
|
250
|
-
| `SYNC_ERROR` | Reconciliation validation, inspection, or provider data failed |
|
|
251
|
-
| `PROCESS_ERROR` | A child process failed |
|
|
252
|
-
| `PROTOCOL_OUTPUT_ERROR` | A command violated the one-result machine contract |
|
|
253
|
-
| `COMMAND_FAILED` | An otherwise unclassified failure |
|
|
254
|
-
|
|
255
|
-
`CLAIM_CONFLICT`, `REVISION_CONFLICT`, and `PROCESS_ERROR` are retryable in the
|
|
256
|
-
v1 metadata. Retryable means new evidence may change the result, not that blind
|
|
257
|
-
or non-idempotent retries are safe. Inspect `fields` and apply `remediation`
|
|
258
|
-
before retrying.
|
|
259
|
-
|
|
260
|
-
## Revisions And Concurrency
|
|
261
|
-
|
|
262
|
-
A document revision is the lowercase SHA-256 hash of the complete Markdown file,
|
|
263
|
-
including frontmatter and prose. It is per document, not a workbase-wide graph
|
|
264
|
-
revision. Context, graph, and entity reads expose revisions.
|
|
265
|
-
|
|
266
|
-
`claim`, `release`, and `finish` require `--revision <sha256>`. They lock and
|
|
267
|
-
recheck the execution document before an atomic replacement, then return
|
|
268
|
-
`previousRevision` and the new `revision`. Use the returned revision or inspect
|
|
269
|
-
again before the next mutation. Claim conflicts include the current revision and
|
|
270
|
-
ownership evidence in `error.fields`; revision conflicts include ownership only
|
|
271
|
-
when claim evidence applies.
|
|
272
|
-
|
|
273
|
-
Structural update, rename, move, and dependency commands accept optional
|
|
274
|
-
`--if-revision <sha256>`. Machine orchestrators should provide it. Multi-document
|
|
275
|
-
mutations recheck every affected file while holding the graph mutation lock.
|
|
276
|
-
|
|
277
|
-
## Selectors And Projections
|
|
278
|
-
|
|
279
|
-
`--workbase <id|name|path>` selects a registered workbase by ID, name, or path;
|
|
280
|
-
an existing path may also resolve an unregistered workbase directly. `--cwd
|
|
281
|
-
<path>` asks Agency to perform target inference as if invoked there. They are
|
|
282
|
-
mutually exclusive. Targeted commands accept `--epic`, `--task`, and `--phase`
|
|
283
|
-
where applicable; phase requires task, and entity selectors cannot be combined
|
|
284
|
-
with a positional target ID. Non-target positional values, such as a status
|
|
285
|
-
outcome, remain valid where the command syntax requires them.
|
|
286
|
-
|
|
287
|
-
`--json`, `--no-input`, and non-TTY execution disable interactive prompts and
|
|
288
|
-
selection. Supply every required value or explicit entity selector. Global
|
|
289
|
-
`--cwd` and `--workbase` selectors apply to `next` as they do to other discovery
|
|
290
|
-
commands.
|
|
291
|
-
|
|
292
|
-
At a workbase root, context defaults to a compact discovery catalog of epics,
|
|
293
|
-
tasks, and phases, includes no writable authority, and provides a hint for
|
|
294
|
-
requesting `--full`. Entity context defaults to the `complete` projection.
|
|
295
|
-
`--compact` omits prose and low-level Git details but retains identity, document
|
|
296
|
-
hashes, authority, paths, graph state, materialization, and validation warnings.
|
|
297
|
-
|
|
298
|
-
Graph projections are opt-in with repeatable
|
|
299
|
-
`--include <bodies|workspace|git|pr>`. Filters such as `--ready`, `--blocked`,
|
|
300
|
-
`--status`, `--repository`, and `--kind` are applied after readiness and graph
|
|
301
|
-
state are computed; returned edges always have both endpoints in the filtered
|
|
302
|
-
node set.
|
|
303
|
-
|
|
304
|
-
## Capability Boundaries
|
|
305
|
-
|
|
306
|
-
- There is no atomic find-ready-and-claim operation. `next` is observational,
|
|
307
|
-
and `claim` does not enforce dependency readiness. Inspect readiness, then
|
|
308
|
-
claim with the observed revision and handle conflicts.
|
|
309
|
-
- There is no `assign` command, remote queue, scheduler, heartbeat, claim renewal,
|
|
310
|
-
runner monitor, or cancellation API. `work` launches one local built-in or
|
|
311
|
-
configured runner without a claim; it is a process-launching, non-JSON flow
|
|
312
|
-
rather than a machine assignment API. External orchestrators claim with
|
|
313
|
-
claimant and runner IDs, then manage their runner themselves.
|
|
314
|
-
- Agency does not edit code, create commits, run repository checks, wait for PR
|
|
315
|
-
checks, merge PRs, or verify that a requested completion condition is true.
|
|
316
|
-
`finish` records the caller's asserted outcome after ownership checks.
|
|
317
|
-
- Reconciliation never discards changes, switches branches, resets reference
|
|
318
|
-
commits, moves conflicting worktrees, chooses among multiple PRs, or bypasses
|
|
319
|
-
active claims. Such conditions remain unresolved for a human or orchestrator.
|
|
320
|
-
- `delegated` is readable legacy state but cannot be newly assigned. `--force`
|
|
321
|
-
only overrides readiness for `work` and `pr create`; it is not general
|
|
322
|
-
reconciliation authority.
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
# Agency Recipes
|
|
2
|
-
|
|
3
|
-
For an entity target, run `agency context . --json` before selecting a recipe.
|
|
4
|
-
At the workbase root, use `agency next --json` or `agency graph --json` to choose
|
|
5
|
-
a target, then inspect it with explicit `--epic`, `--task`, and `--phase`
|
|
6
|
-
selectors or its returned document path. Graph node keys such as `task/<id>` and
|
|
7
|
-
`phase/<task>/<phase>` are not positional context targets.
|
|
8
|
-
|
|
9
|
-
The machine-orchestration forms in the inspect-through-recover recipes are
|
|
10
|
-
captured in `fixtures/protocol/orchestration-recipes.json` and tested against the
|
|
11
|
-
real CLI parser. Their lifecycle behavior is covered by CLI and service fixtures.
|
|
12
|
-
Replace angle-bracket placeholders with values from context or a prior machine
|
|
13
|
-
result; never scrape them from human output.
|
|
14
|
-
|
|
15
|
-
## Initialize A Workbase
|
|
16
|
-
|
|
17
|
-
For an existing local checkout, initialize the workbase and link the repository:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
agency init <workbase-path>
|
|
21
|
-
agency --workbase <workbase-path> repo link <alias> <repository-path>
|
|
22
|
-
agency validate <workbase-path>
|
|
23
|
-
agency --workbase <workbase-path> repo verify <alias>
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Use `repo add <alias> <remote>` instead when Agency should create and manage a
|
|
27
|
-
bare clone from a remote. Initialization and repository registration require
|
|
28
|
-
explicit user intent.
|
|
29
|
-
|
|
30
|
-
## Restore A Workbase On A New Machine
|
|
31
|
-
|
|
32
|
-
After cloning the tracked workbase, inspect repository setup before applying it:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
agency repo setup --dry-run --json
|
|
36
|
-
agency repo setup --apply --json
|
|
37
|
-
agency validate
|
|
38
|
-
agency doctor --json
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Apply clones only declared missing repositories. It does not overwrite linked
|
|
42
|
-
checkouts, repair invalid paths, or choose between drifted remotes. Resolve those
|
|
43
|
-
states explicitly, then rerun setup. A machine may replace an unused managed
|
|
44
|
-
clone with `repo link`; the portable declaration remains available to every
|
|
45
|
-
other machine.
|
|
46
|
-
|
|
47
|
-
## Inspect A Target
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
agency context --task <task-id> --phase <phase-id> --json
|
|
51
|
-
agency worktree inspect <task-id> <phase-id> --json
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Confirm the target, current document revision, readiness, authority, checkout,
|
|
55
|
-
claim, PR, and validation state. Use `--compact` only when prose and detailed Git
|
|
56
|
-
evidence are not needed.
|
|
57
|
-
|
|
58
|
-
## Find Ready Work
|
|
59
|
-
|
|
60
|
-
Run this from the intended workbase:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
agency next --json
|
|
64
|
-
agency graph --ready --json
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
`next` ranks ready execution units and explains every excluded unit. It does not
|
|
68
|
-
reserve work. Another orchestrator may claim the same candidate before you do,
|
|
69
|
-
so always handle `CLAIM_CONFLICT` or `REVISION_CONFLICT`.
|
|
70
|
-
|
|
71
|
-
## Human: Create And Launch Work
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
agency task create refresh-copy --repo frontend --branch task/refresh-copy --base main
|
|
75
|
-
agency validate
|
|
76
|
-
agency work tasks/refresh-copy
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
For a multi-PR outcome:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
agency task create checkout --multi-phase
|
|
83
|
-
agency phase create checkout api --repo backend --branch task/checkout-api --base main
|
|
84
|
-
agency phase create checkout ui --repo frontend --branch task/checkout-ui \
|
|
85
|
-
--base main --reference backend:main --depends-on api
|
|
86
|
-
agency validate
|
|
87
|
-
agency work tasks/checkout/phases/api
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
`agency work` is intentionally last: it synchronizes managed integration files,
|
|
91
|
-
checks readiness, materializes worktrees, marks this execution unit working
|
|
92
|
-
without a claim, and launches the runner. Run it again to relaunch unclaimed
|
|
93
|
-
working work. The runner opens without a prompt by default; add `--auto` only
|
|
94
|
-
when the generated context prompt should start autonomous execution.
|
|
95
|
-
OpenCode receives whole-workbase visibility through the managed project plugin;
|
|
96
|
-
this does not expand the writable checkout reported by `agency context`.
|
|
97
|
-
|
|
98
|
-
## Active Agent: Execute Assigned Work
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
agency context . --json
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
1. Verify context reports the expected execution target, valid structure, and
|
|
105
|
-
the current checkout as `authority.writable.checkoutPath`. Reject dependency
|
|
106
|
-
or validation blockers and conflicting active claims.
|
|
107
|
-
2. Read `TASK.md`, and `PHASE.md` for phase work.
|
|
108
|
-
3. Implement only in the writable checkout; treat all reference checkouts as
|
|
109
|
-
read-only.
|
|
110
|
-
4. Run repository formatting, checks, build, and focused tests.
|
|
111
|
-
5. Review and commit the diff.
|
|
112
|
-
6. If requested, run `agency validate`, then
|
|
113
|
-
`agency pr create <task-id> [phase-id]`.
|
|
114
|
-
7. Finish an active claim after its completion condition is true; otherwise set
|
|
115
|
-
the task or phase status directly.
|
|
116
|
-
|
|
117
|
-
Never invoke `agency work` merely because an execution checkout already exists;
|
|
118
|
-
that would start another agent rather than continue the current assignment.
|
|
119
|
-
|
|
120
|
-
## Claim Ready Work
|
|
121
|
-
|
|
122
|
-
Get the current document revision from context. Use stable claimant, runner, and
|
|
123
|
-
session IDs:
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
agency claim checkout ui \
|
|
127
|
-
--claimant orchestrator-1 --runner opencode --session-id session-123 \
|
|
128
|
-
--revision <sha256> --json
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
Claim records ownership and sets status to `working`; it does not launch a runner
|
|
132
|
-
or recheck dependency readiness. A machine orchestrator must launch and monitor
|
|
133
|
-
its runner separately. There is no atomic find-and-claim or `assign` command.
|
|
134
|
-
|
|
135
|
-
## Prepare Checkouts
|
|
136
|
-
|
|
137
|
-
Preview and then materialize without claiming, launching, or changing status:
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
agency work prepare --task checkout --phase ui --dry-run --json
|
|
141
|
-
agency work prepare --task checkout --phase ui --json
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Use the returned checkout paths and resolved commits. Do not create or move
|
|
145
|
-
worktrees manually.
|
|
146
|
-
|
|
147
|
-
## Assign A Runner
|
|
148
|
-
|
|
149
|
-
For a human-operated local launch, Agency combines readiness checks, prepare,
|
|
150
|
-
status mutation, and runner launch without creating a claim:
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
agency work tasks/checkout/phases/ui --runner opencode
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
This is not a JSON assignment API. An external orchestrator instead claims with
|
|
157
|
-
its own `claimant`, `runner`, and `session-id`, starts the runner outside Agency,
|
|
158
|
-
and passes it the target and claim result. Agency has no queue, heartbeat,
|
|
159
|
-
monitoring, cancellation, or automatic claim-renewal service.
|
|
160
|
-
|
|
161
|
-
## Reconcile Durable And Local State
|
|
162
|
-
|
|
163
|
-
```bash
|
|
164
|
-
agency sync --dry-run --json
|
|
165
|
-
agency sync --apply --json
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
The first command is observational. Apply may materialize an unconflicted missing
|
|
169
|
-
checkout, release an expired claim, record one unambiguous matching PR, or mark
|
|
170
|
-
unclaimed work done after its authoritative PR merges. Review `warnings` and
|
|
171
|
-
`unresolved`; apply never discards or resets work and never chooses among
|
|
172
|
-
ambiguous PRs.
|
|
173
|
-
|
|
174
|
-
## Release Interrupted Work
|
|
175
|
-
|
|
176
|
-
After every claim mutation, use the returned revision or inspect again. Release
|
|
177
|
-
interrupted work back to open:
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
agency release checkout ui --session-id session-123 \
|
|
181
|
-
--revision <current-sha256> --json
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## Finish Verified Work
|
|
185
|
-
|
|
186
|
-
After the claimed run completes successfully:
|
|
187
|
-
|
|
188
|
-
```bash
|
|
189
|
-
agency finish checkout ui --session-id session-123 \
|
|
190
|
-
--revision <current-sha256> --outcome done --json
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
Do not substitute a phase status mutation for `finish`; `finish` preserves
|
|
194
|
-
ownership history and revision safety. A `done` claim outcome leaves unmerged
|
|
195
|
-
execution work `working`. After the authoritative pull request merges, use
|
|
196
|
-
`agency sync --apply` to reconcile the execution unit to `done`.
|
|
197
|
-
|
|
198
|
-
## Create A Pull Request
|
|
199
|
-
|
|
200
|
-
```bash
|
|
201
|
-
agency validate
|
|
202
|
-
agency pr create checkout ui --json
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
Agency materializes a missing workspace, then requires the writable worktree to
|
|
206
|
-
be clean. It pushes the declared branch, invokes the configured delivery
|
|
207
|
-
provider's create command or falls back to `gh pr create --fill`, and records the
|
|
208
|
-
returned pull request record. Do not manually write a URL or record if creation
|
|
209
|
-
fails. A PR being open is not equivalent to completion when the assigned outcome
|
|
210
|
-
requires merge.
|
|
211
|
-
|
|
212
|
-
Agency does not create commits, run tests, wait for checks, merge the PR, or
|
|
213
|
-
verify completion. Those remain orchestrator responsibilities.
|
|
214
|
-
|
|
215
|
-
## Convert A Task To Phases
|
|
216
|
-
|
|
217
|
-
Name the phase that inherits the existing task's execution metadata:
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
agency phase create refresh-copy verification \
|
|
221
|
-
--first-phase implementation \
|
|
222
|
-
--repo frontend --branch task/refresh-copy-verification --base main \
|
|
223
|
-
--depends-on implementation
|
|
224
|
-
agency validate
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
Agency converts the task shape, creates both phase documents, and relocates
|
|
228
|
-
materialized worktrees. Do not perform those moves manually.
|
|
229
|
-
|
|
230
|
-
## Recover From Interrupted State
|
|
231
|
-
|
|
232
|
-
Inspect before applying changes:
|
|
233
|
-
|
|
234
|
-
```bash
|
|
235
|
-
agency doctor --json
|
|
236
|
-
agency sync --dry-run --json
|
|
237
|
-
agency worktree inspect <task-id> [phase-id] --json
|
|
238
|
-
agency worktree repair <task-id> [phase-id] --dry-run --json
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
Use `agency sync --apply` only with explicit user intent. It may safely
|
|
242
|
-
materialize an unconflicted missing checkout, release an expired claim, record a
|
|
243
|
-
single matching PR, refresh recorded PR state and mergeability, or mark work done
|
|
244
|
-
after its authoritative PR merged and no claim remains. It never modifies dirty
|
|
245
|
-
checkouts, switches branches, resets
|
|
246
|
-
references, chooses among PRs, or bypasses active claims.
|
|
247
|
-
|
|
248
|
-
For a worktree-specific issue, use `worktree repair --dry-run` before repair.
|
|
249
|
-
Repair is conservative and never discards work. Use remove or rebuild only after
|
|
250
|
-
reviewing the dry run and confirming every checkout is clean.
|
|
251
|
-
|
|
252
|
-
## Archive Or Restore
|
|
253
|
-
|
|
254
|
-
```bash
|
|
255
|
-
agency archive phase checkout ui --dry-run --json
|
|
256
|
-
agency archive phase checkout ui
|
|
257
|
-
agency restore phase checkout ui --dry-run --json
|
|
258
|
-
agency restore phase checkout ui
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
As an operating policy, archive only terminal work and only with explicit intent;
|
|
262
|
-
the CLI also permits safe archival of nonterminal work. Agency preserves the
|
|
263
|
-
branch and lifecycle provenance while enforcing graph, worktree, and destination
|
|
264
|
-
safety. Never move archived directories by hand.
|