@markjaquith/agency 2.28.0 → 2.28.1
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 +42 -24
- package/fixtures/protocol/orchestration-recipes.json +59 -0
- package/package.json +1 -1
- package/skills/agency/SKILL.md +112 -331
- package/skills/agency/references/commands.md +161 -0
- package/skills/agency/references/contracts.md +288 -0
- package/skills/agency/references/recipes.md +219 -0
- package/src/cli-parser.test.ts +7 -0
- package/src/cli.test.ts +28 -4
- package/src/commands/init.test.ts +8 -4
- package/src/commands/init.ts +3 -0
- package/src/commands/work.test.ts +20 -0
- package/src/commands/work.ts +3 -0
- package/src/services/IntegrationService.test.ts +80 -3
- package/src/services/IntegrationService.ts +2 -2
- package/src/workbase/AGENTS.md +53 -19
- package/src/workbase/opencode-file.ts +7 -8
package/README.md
CHANGED
|
@@ -73,9 +73,14 @@ workbase/
|
|
|
73
73
|
Agency keeps discovery and other observational commands read-only. Run
|
|
74
74
|
`agency integration status` to inspect `AGENTS.md` and
|
|
75
75
|
`.opencode/opencode.jsonc`, then `agency integration sync` to create missing
|
|
76
|
-
files or refresh checksum-safe managed files.
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
files or refresh checksum-safe managed files. Customized files are reported but
|
|
77
|
+
never overwritten.
|
|
78
|
+
|
|
79
|
+
The OpenCode config advertises only the task and epic directories as documented
|
|
80
|
+
references. OpenCode automatically grants those references scoped
|
|
81
|
+
external-directory access, so Agency does not add blanket permission rules that
|
|
82
|
+
could hide missing tool permissions. References provide context and never expand
|
|
83
|
+
the write authority reported by `agency context`.
|
|
79
84
|
|
|
80
85
|
Repository metadata comes directly from Git under `repos/{alias}`. Workbase
|
|
81
86
|
configuration may provide a custom writable-worktree creation command.
|
|
@@ -707,27 +712,34 @@ Every error contains a stable `code`, human-readable `message`, structured
|
|
|
707
712
|
`fields`, and `retryable`. `remediation` is included when Agency knows a specific
|
|
708
713
|
recovery action. Version 1 defines these codes:
|
|
709
714
|
|
|
710
|
-
| Code | Meaning
|
|
711
|
-
| ------------------------- |
|
|
712
|
-
| `CLI_USAGE` | Invalid command, option, argument, or option combination
|
|
713
|
-
| `WORKBASE_NOT_FOUND` | No workbase could be resolved
|
|
714
|
-
| `WORKBASE_CONFIG_INVALID` | Invalid workbase configuration
|
|
715
|
-
| `WORKBASE_REGISTRY_ERROR` | Invalid or inaccessible workbase registry
|
|
716
|
-
| `FILE_NOT_FOUND` | A required path does not exist
|
|
717
|
-
| `FILESYSTEM_ERROR` | A filesystem operation failed
|
|
718
|
-
| `FRONTMATTER_INVALID` | A durable document has invalid frontmatter
|
|
719
|
-
| `VALIDATION_FAILED` | Workbase validation reported issues
|
|
720
|
-
| `REPOSITORY_ERROR` | Repository operation failed
|
|
721
|
-
| `EPIC_ERROR` | Epic operation failed
|
|
722
|
-
| `TASK_ERROR` | Task operation failed
|
|
723
|
-
| `PHASE_ERROR` | Phase operation failed
|
|
724
|
-
| `
|
|
725
|
-
| `
|
|
726
|
-
| `
|
|
727
|
-
| `
|
|
728
|
-
| `
|
|
729
|
-
| `
|
|
730
|
-
| `
|
|
715
|
+
| Code | Meaning |
|
|
716
|
+
| ------------------------- | --------------------------------------------------------- |
|
|
717
|
+
| `CLI_USAGE` | Invalid command, option, argument, or option combination |
|
|
718
|
+
| `WORKBASE_NOT_FOUND` | No workbase could be resolved |
|
|
719
|
+
| `WORKBASE_CONFIG_INVALID` | Invalid workbase configuration |
|
|
720
|
+
| `WORKBASE_REGISTRY_ERROR` | Invalid or inaccessible workbase registry |
|
|
721
|
+
| `FILE_NOT_FOUND` | A required path does not exist |
|
|
722
|
+
| `FILESYSTEM_ERROR` | A filesystem operation failed |
|
|
723
|
+
| `FRONTMATTER_INVALID` | A durable document has invalid frontmatter |
|
|
724
|
+
| `VALIDATION_FAILED` | Workbase validation reported issues |
|
|
725
|
+
| `REPOSITORY_ERROR` | Repository operation failed |
|
|
726
|
+
| `EPIC_ERROR` | Epic operation failed |
|
|
727
|
+
| `TASK_ERROR` | Task operation failed |
|
|
728
|
+
| `PHASE_ERROR` | Phase operation failed |
|
|
729
|
+
| `CLAIM_ERROR` | Claim input or lifecycle state is invalid |
|
|
730
|
+
| `CLAIM_CONFLICT` | Active or legacy ownership conflicts with an operation |
|
|
731
|
+
| `REVISION_CONFLICT` | A durable document changed since inspection |
|
|
732
|
+
| `CLAIM_OWNERSHIP` | The session does not own the active claim |
|
|
733
|
+
| `ARCHIVE_ERROR` | Archive operation failed |
|
|
734
|
+
| `WORKTREE_ERROR` | Worktree operation failed |
|
|
735
|
+
| `PULL_REQUEST_ERROR` | Pull request operation failed |
|
|
736
|
+
| `CONTEXT_ERROR` | A context target or required document is invalid |
|
|
737
|
+
| `GRAPH_ERROR` | Workbase graph construction failed |
|
|
738
|
+
| `EXECUTION_BLOCKED` | Readiness or lifecycle blockers prevent execution |
|
|
739
|
+
| `SYNC_ERROR` | Reconciliation validation, inspection, or provider failed |
|
|
740
|
+
| `PROCESS_ERROR` | A child process failed and may be retried |
|
|
741
|
+
| `PROTOCOL_OUTPUT_ERROR` | A command violated the machine output contract |
|
|
742
|
+
| `COMMAND_FAILED` | An otherwise unclassified command failure |
|
|
731
743
|
|
|
732
744
|
The Effect schemas are exported from `@markjaquith/agency` and
|
|
733
745
|
`@markjaquith/agency/protocol`. The distributable JSON Schemas are exported as
|
|
@@ -736,6 +748,12 @@ The Effect schemas are exported from `@markjaquith/agency` and
|
|
|
736
748
|
payloads are exported as `@markjaquith/agency/fixtures/protocol/success.json` and
|
|
737
749
|
`@markjaquith/agency/fixtures/protocol/error.json`.
|
|
738
750
|
|
|
751
|
+
Success, help, and version output exit `0`; usage and command failures exit `1`.
|
|
752
|
+
There are no error-specific exit statuses. `graph --jsonl` streams versioned
|
|
753
|
+
records on success instead of wrapping them in an envelope; JSONL failures still
|
|
754
|
+
use one error envelope. See `skills/agency/references/contracts.md` for revision,
|
|
755
|
+
selector, projection, retry, and capability details.
|
|
756
|
+
|
|
739
757
|
## Agent Skill
|
|
740
758
|
|
|
741
759
|
`skills/agency/SKILL.md` contains an agent-oriented operating guide for Agency.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[
|
|
2
|
+
["context", "--task", "checkout", "--phase", "ui", "--json"],
|
|
3
|
+
["worktree", "inspect", "checkout", "ui", "--json"],
|
|
4
|
+
["next", "--json"],
|
|
5
|
+
["graph", "--ready", "--json"],
|
|
6
|
+
[
|
|
7
|
+
"claim",
|
|
8
|
+
"checkout",
|
|
9
|
+
"ui",
|
|
10
|
+
"--claimant",
|
|
11
|
+
"orchestrator-1",
|
|
12
|
+
"--runner",
|
|
13
|
+
"opencode",
|
|
14
|
+
"--session-id",
|
|
15
|
+
"session-123",
|
|
16
|
+
"--revision",
|
|
17
|
+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
18
|
+
"--json"
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
"work",
|
|
22
|
+
"prepare",
|
|
23
|
+
"--task",
|
|
24
|
+
"checkout",
|
|
25
|
+
"--phase",
|
|
26
|
+
"ui",
|
|
27
|
+
"--dry-run",
|
|
28
|
+
"--json"
|
|
29
|
+
],
|
|
30
|
+
["work", "prepare", "--task", "checkout", "--phase", "ui", "--json"],
|
|
31
|
+
["work", "tasks/checkout/phases/ui", "--runner", "opencode"],
|
|
32
|
+
["sync", "--dry-run", "--json"],
|
|
33
|
+
["sync", "--apply", "--json"],
|
|
34
|
+
["pr", "create", "checkout", "ui", "--json"],
|
|
35
|
+
[
|
|
36
|
+
"finish",
|
|
37
|
+
"checkout",
|
|
38
|
+
"ui",
|
|
39
|
+
"--session-id",
|
|
40
|
+
"session-123",
|
|
41
|
+
"--revision",
|
|
42
|
+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
43
|
+
"--outcome",
|
|
44
|
+
"done",
|
|
45
|
+
"--json"
|
|
46
|
+
],
|
|
47
|
+
["doctor", "--json"],
|
|
48
|
+
["worktree", "repair", "checkout", "ui", "--dry-run", "--json"],
|
|
49
|
+
[
|
|
50
|
+
"release",
|
|
51
|
+
"checkout",
|
|
52
|
+
"ui",
|
|
53
|
+
"--session-id",
|
|
54
|
+
"session-123",
|
|
55
|
+
"--revision",
|
|
56
|
+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
57
|
+
"--json"
|
|
58
|
+
]
|
|
59
|
+
]
|
package/package.json
CHANGED
package/skills/agency/SKILL.md
CHANGED
|
@@ -1,353 +1,134 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agency
|
|
3
3
|
description: >
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
coordinate work across repositories; materialize task worktrees; or create a
|
|
8
|
-
PR through Agency.
|
|
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.
|
|
9
7
|
license: MIT
|
|
10
|
-
compatibility: Requires the agency CLI and Git
|
|
8
|
+
compatibility: Requires the agency CLI and Git. Agent launch requires a configured runner; GitHub pull requests require gh.
|
|
11
9
|
---
|
|
12
10
|
|
|
13
11
|
# Agency
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
Agency keeps plans and lifecycle state in durable Markdown documents. Git
|
|
14
|
+
checkouts under `code/` are materialized local state. Treat the documents as the
|
|
15
|
+
source of truth and Agency commands as the safe way to mutate their structure.
|
|
18
16
|
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
- A **workbase** is the root containing `agency.json`, `repos/`, `epics/`, and
|
|
22
|
-
`tasks/`.
|
|
23
|
-
- A repository alias is a bare Git repository or symlink at `repos/{alias}`.
|
|
24
|
-
- An **epic** orchestrates tasks and only reads repositories.
|
|
25
|
-
- A **task** describes one durable outcome. It may be standalone or belong to an
|
|
26
|
-
epic.
|
|
27
|
-
- A **phase** belongs to a multi-phase task and corresponds to one PR or intended
|
|
28
|
-
PR.
|
|
29
|
-
- An **execution unit** is either a single-phase task or a phase. It has one
|
|
30
|
-
writable `repo`, optional read-only `repos`, one branch, one base, and one
|
|
31
|
-
`pr` value.
|
|
32
|
-
|
|
33
|
-
IDs are directory names. Do not repeat IDs in document frontmatter.
|
|
34
|
-
|
|
35
|
-
## Start By Inspecting
|
|
36
|
-
|
|
37
|
-
From anywhere beneath a workbase, run:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
agency status --json
|
|
41
|
-
agency validate --json
|
|
42
|
-
agency integration status --json
|
|
43
|
-
agency repo list --json
|
|
44
|
-
agency epic list --json
|
|
45
|
-
agency task list --json
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Use `show` before changing an existing entity:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
agency epic show <epic-id> --json
|
|
52
|
-
agency task show <task-id> --json
|
|
53
|
-
agency phase show <task-id> <phase-id> --json
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
If no workbase is found, do not initialize one without user intent. When asked:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
agency init [path]
|
|
60
|
-
agency integration sync
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Register and name known workbases so commands can select one from anywhere:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
agency workbase add <path> [--name <name>]
|
|
67
|
-
agency workbase list
|
|
68
|
-
agency workbase show <id|name|path>
|
|
69
|
-
agency workbase name <id|name|path> <name> | --clear
|
|
70
|
-
agency workbase default [<id|name|path> | --clear]
|
|
71
|
-
agency workbase remove <id|name|path>
|
|
72
|
-
agency workbase prune
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Use `--workbase <id|name|path>` to bypass cwd inference, or `--cwd <path>` to
|
|
76
|
-
infer context from a specific directory. The options are mutually exclusive.
|
|
77
|
-
|
|
78
|
-
## Repository Aliases
|
|
79
|
-
|
|
80
|
-
Add a remote as an Agency-managed bare repository:
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
agency repo add <alias> <git-remote>
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Link an existing local Git repository:
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
agency repo link <alias> <path>
|
|
90
|
-
agency repo show <alias>
|
|
91
|
-
agency repo fetch <alias>
|
|
92
|
-
agency repo remove <alias>
|
|
93
|
-
agency repo unlink <alias>
|
|
94
|
-
agency repo rename <alias> <new-alias>
|
|
95
|
-
agency repo remote <alias> [remote]
|
|
96
|
-
agency repo verify <alias>
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Use aliases, never absolute paths or Git URLs, in epic/task/phase frontmatter.
|
|
100
|
-
|
|
101
|
-
## Choose The Correct Work Shape
|
|
102
|
-
|
|
103
|
-
Use a single-phase task when one PR in one writable repository can deliver the
|
|
104
|
-
outcome. Use a multi-phase task when the outcome requires multiple intended PRs,
|
|
105
|
-
possibly across repositories or with sequencing dependencies. Use an epic when
|
|
106
|
-
several independently meaningful tasks need orchestration.
|
|
107
|
-
|
|
108
|
-
If phases are known up front, create a multi-phase task. To add a phase later,
|
|
109
|
-
use `--first-phase <id>` to name the phase created from the task's existing
|
|
110
|
-
execution fields and worktrees.
|
|
111
|
-
|
|
112
|
-
## Create Epics
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
agency epic create <id> \
|
|
116
|
-
--ticket-url <url> \
|
|
117
|
-
[--description <text>] \
|
|
118
|
-
--repo <read-only-alias>:<ref> \
|
|
119
|
-
[--repo <another-alias>:<ref>]
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Epic task ordering and dependencies live in `EPIC.md`. Creating a task with
|
|
123
|
-
`--epic` automatically writes both sides of the epic/task relationship.
|
|
124
|
-
|
|
125
|
-
## Create Single-Phase Tasks
|
|
126
|
-
|
|
127
|
-
For guided creation, run `agency task new`. It prompts for text input, uses fzf
|
|
128
|
-
for known choices, and allows optional inputs to be skipped. It requires a TTY
|
|
129
|
-
and fails when `--no-input` is set. `task create` never prompts and is the command
|
|
130
|
-
to use from agents and scripts.
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
agency task create <id> \
|
|
134
|
-
[--ticket-url <url>] \
|
|
135
|
-
[--description <text>] \
|
|
136
|
-
[--epic <epic-id>] \
|
|
137
|
-
--repo <writable-alias> \
|
|
138
|
-
[--reference <read-only-alias>:<ref>] \
|
|
139
|
-
[--branch <branch>] \
|
|
140
|
-
[--base <base>]
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
The branch defaults to `task/<id>` and the base defaults to `main`.
|
|
144
|
-
|
|
145
|
-
The task itself is the execution unit. Its worktrees live under
|
|
146
|
-
`tasks/{id}/code/{alias}`.
|
|
147
|
-
|
|
148
|
-
## Create Multi-Phase Tasks
|
|
149
|
-
|
|
150
|
-
Create the task container:
|
|
17
|
+
## Start With Context
|
|
151
18
|
|
|
152
|
-
|
|
153
|
-
agency task create <id> \
|
|
154
|
-
[--ticket-url <url>] \
|
|
155
|
-
[--description <text>] \
|
|
156
|
-
[--epic <epic-id>] \
|
|
157
|
-
--multi-phase
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Then create each phase:
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
agency phase create <task-id> <phase-id> \
|
|
164
|
-
[--description <text>] \
|
|
165
|
-
--repo <writable-alias> \
|
|
166
|
-
[--reference <read-only-alias>:<ref>] \
|
|
167
|
-
--branch <branch> \
|
|
168
|
-
--base <base> \
|
|
169
|
-
[--depends-on <phase-id>]
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
Repeat `--reference` and `--depends-on` when needed. Phase worktrees live under
|
|
173
|
-
`tasks/{task-id}/phases/{phase-id}/code/{alias}`.
|
|
174
|
-
|
|
175
|
-
Convert an existing single-phase task while adding another phase:
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
agency phase create <task-id> <new-phase-id> \
|
|
179
|
-
--first-phase <existing-phase-id> \
|
|
180
|
-
--repo <writable-alias> \
|
|
181
|
-
--branch <new-branch> \
|
|
182
|
-
--base <base> \
|
|
183
|
-
[--depends-on <existing-phase-id>]
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
The conversion preserves task-level metadata and prose, moves execution metadata
|
|
187
|
-
into the named existing phase, and relocates any materialized worktrees.
|
|
188
|
-
|
|
189
|
-
## Frontmatter Rules
|
|
190
|
-
|
|
191
|
-
Agency documents use YAML 1.2 frontmatter:
|
|
192
|
-
|
|
193
|
-
```yaml
|
|
194
|
-
---
|
|
195
|
-
ticketUrl: https://example.com/tickets/example
|
|
196
|
-
description: Deliver the example outcome.
|
|
197
|
-
repo: application
|
|
198
|
-
repos:
|
|
199
|
-
- repo: api
|
|
200
|
-
ref: main
|
|
201
|
-
branch: task/example
|
|
202
|
-
base: main
|
|
203
|
-
pr: null
|
|
204
|
-
status: open
|
|
205
|
-
---
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
Follow these invariants:
|
|
209
|
-
|
|
210
|
-
- `ticketUrl` belongs to epics and tasks, not phases.
|
|
211
|
-
- `description` is an optional non-empty summary on epics, tasks, and phases.
|
|
212
|
-
- `repo` is the one writable repository for an execution unit.
|
|
213
|
-
- `repos` contains `{ repo, ref }` read-only references and must not repeat `repo`.
|
|
214
|
-
- Epics may declare `repos` but never `repo`.
|
|
215
|
-
- A writable `(repo, branch)` pair belongs to exactly one task or phase.
|
|
216
|
-
- Use a commit SHA for a read-only `ref` when reproducibility matters.
|
|
217
|
-
|
|
218
|
-
Commands that print Agency-owned results accept `--json` for machine-readable
|
|
219
|
-
output, including mutations, entity inspection, status, validation, and PR creation.
|
|
220
|
-
|
|
221
|
-
Use `agency graph --json` to load the complete, versioned workbase graph without
|
|
222
|
-
walking directories. Filter it with repeatable `--status`, `--repository`, and
|
|
223
|
-
`--kind` options or with `--ready`/`--blocked`. Add durable prose and observational
|
|
224
|
-
details explicitly with `--include bodies|workspace|git|pr`. For large workbases,
|
|
225
|
-
`--jsonl` streams equivalent versioned metadata, node, edge, and end records.
|
|
226
|
-
|
|
227
|
-
- Multi-phase task frontmatter owns the phase dependency graph.
|
|
228
|
-
- Epic frontmatter owns the child-task dependency graph.
|
|
229
|
-
- `pr` is either a GitHub PR URL string or `null`.
|
|
230
|
-
- Execution-unit `status` is `open`, `working`, `delegated`, `done`, or `dropped`.
|
|
231
|
-
New work starts open, and an active claim sets it working before agent launch.
|
|
232
|
-
`delegated` is readable legacy state; distinct claimant and runner identities
|
|
233
|
-
now represent delegation.
|
|
234
|
-
- Keep directory IDs stable; encode sequencing with `dependsOn`, not numeric
|
|
235
|
-
directory prefixes.
|
|
236
|
-
- Do not use YAML duplicate keys, anchors, aliases, or custom tags.
|
|
237
|
-
|
|
238
|
-
Prefer Agency commands for creation. When manually editing dependencies or
|
|
239
|
-
prose, preserve backlinks and run validation immediately afterward.
|
|
240
|
-
|
|
241
|
-
Update execution status with:
|
|
242
|
-
|
|
243
|
-
```bash
|
|
244
|
-
agency task status <task-id> <open|done|dropped>
|
|
245
|
-
agency phase status <task-id> <phase-id> <open|done|dropped>
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Coordinate execution ownership with a document revision from `agency context`
|
|
249
|
-
or `agency graph`:
|
|
250
|
-
|
|
251
|
-
```bash
|
|
252
|
-
agency claim <task-id> [phase-id] --claimant <id> --runner <id> --session-id <id> --revision <sha256>
|
|
253
|
-
agency release <task-id> [phase-id] --session-id <id> --revision <sha256>
|
|
254
|
-
agency finish <task-id> [phase-id] --session-id <id> --revision <sha256> --outcome <done|dropped>
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
## Archive Completed Work
|
|
258
|
-
|
|
259
|
-
```bash
|
|
260
|
-
agency archive list
|
|
261
|
-
agency archive show <epic|task> <id>
|
|
262
|
-
agency archive epic <epic-id>
|
|
263
|
-
agency archive task <task-id>
|
|
264
|
-
agency archive phase <task-id> <phase-id>
|
|
265
|
-
agency restore epic <epic-id>
|
|
266
|
-
agency restore task <task-id>
|
|
267
|
-
agency restore phase <task-id> <phase-id>
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
Use these commands instead of moving work item folders manually. Agency mirrors
|
|
271
|
-
their hierarchy under `archive/`, removes registered worktrees first, and keeps
|
|
272
|
-
branches. It refuses dirty worktrees and active sibling dependencies. Use
|
|
273
|
-
`--dry-run` to preflight archive or restore. Restore uses lifecycle provenance to
|
|
274
|
-
recreate parent declarations and rejects ID, backlink, dependency, and destination
|
|
275
|
-
conflicts. Archived IDs remain reserved until restored.
|
|
276
|
-
|
|
277
|
-
## Validate Every Structural Change
|
|
278
|
-
|
|
279
|
-
```bash
|
|
280
|
-
agency validate [path]
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
Use `--json` when diagnostics will be consumed programmatically. Resolve all
|
|
284
|
-
validation errors before materializing worktrees or creating PRs. Validation
|
|
285
|
-
checks schemas, aliases, backlinks, phase directories, duplicate references,
|
|
286
|
-
duplicate writable branch ownership, unknown dependencies, and dependency cycles.
|
|
287
|
-
Outside a workbase, Agency uses the configured default or opens the registered
|
|
288
|
-
workbase picker. With `--no-input` or without a TTY, pass `--workbase` or `--cwd`.
|
|
289
|
-
|
|
290
|
-
## Worktrees And Agent Launch
|
|
19
|
+
For an entity target, the first inspection command is:
|
|
291
20
|
|
|
292
21
|
```bash
|
|
293
|
-
agency
|
|
294
|
-
agency work <directory>
|
|
295
|
-
agency work --epic <epic-id>
|
|
296
|
-
agency work --task <task-id> [--phase <phase-id>] --workbase <selector>
|
|
22
|
+
agency context . --json
|
|
297
23
|
```
|
|
298
24
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
without launching. This command fetches
|
|
303
|
-
repositories for execution targets, creates or reuses their worktrees, and
|
|
304
|
-
replaces the current process with the selected agent. With no directory it opens
|
|
305
|
-
an `fzf` picker containing the workbase hierarchy. Pass `.`, or another
|
|
306
|
-
directory, to infer the nearest epic, task, or phase.
|
|
307
|
-
Outside a workbase, it first opens a picker containing registered workbases.
|
|
308
|
-
With `--no-input` or without a TTY, provide an explicit workbase or cwd and an
|
|
309
|
-
`--epic`, `--task`, or `--task` plus `--phase` selector so no picker is needed.
|
|
310
|
-
|
|
311
|
-
Epic and multi-phase task targets are orchestration sessions launched beside
|
|
312
|
-
their documents. Single-phase tasks and phases are execution sessions launched
|
|
313
|
-
in their writable checkout.
|
|
314
|
-
|
|
315
|
-
The workbase may delegate writable checkout creation through
|
|
316
|
-
`worktreeCreateCommand` in `agency.json`. Do not bypass that command or create a
|
|
317
|
-
parallel worktree manually. Supplemental read-only checkouts are still detached
|
|
318
|
-
Git worktrees managed directly by Agency at their declared refs.
|
|
25
|
+
It identifies the target and ancestors, document revisions, dependency
|
|
26
|
+
readiness, write authority, checkout state, PR state, and validation warnings.
|
|
27
|
+
Use its paths and IDs instead of inferring them from the process cwd.
|
|
319
28
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
out elsewhere, choose a different branch or remove the conflicting worktree;
|
|
324
|
-
never force a second checkout of the branch.
|
|
29
|
+
At the workbase root, context cannot infer one entity from `.`. Use
|
|
30
|
+
`agency next --json` or `agency graph --json` to choose a target, then pass that
|
|
31
|
+
target to `agency context <target> --json`.
|
|
325
32
|
|
|
326
|
-
|
|
327
|
-
explicitly wants to launch a nested/replacement agent process. If already
|
|
328
|
-
working in an Agency checkout, read the owning `TASK.md` and optional `PHASE.md`
|
|
329
|
-
directly instead.
|
|
330
|
-
|
|
331
|
-
## Create Pull Requests
|
|
332
|
-
|
|
333
|
-
Only create a PR when the user explicitly requests it:
|
|
33
|
+
For broader orchestration, load the graph and discover available capabilities:
|
|
334
34
|
|
|
335
35
|
```bash
|
|
336
|
-
agency
|
|
36
|
+
agency graph --json
|
|
37
|
+
agency doctor --json
|
|
38
|
+
agency --help
|
|
39
|
+
agency <command> --help
|
|
337
40
|
```
|
|
338
41
|
|
|
339
|
-
|
|
340
|
-
`
|
|
341
|
-
|
|
42
|
+
Use `agency next --json` when choosing ready execution work. Read
|
|
43
|
+
[`references/contracts.md`](references/contracts.md) when consuming machine
|
|
44
|
+
output or editing documents.
|
|
342
45
|
|
|
343
|
-
##
|
|
46
|
+
## Mental Model
|
|
344
47
|
|
|
345
|
-
-
|
|
346
|
-
-
|
|
347
|
-
-
|
|
348
|
-
|
|
349
|
-
-
|
|
350
|
-
-
|
|
351
|
-
|
|
352
|
-
-
|
|
353
|
-
`
|
|
48
|
+
- A **workbase** contains durable epics, tasks, phases, and repository aliases.
|
|
49
|
+
- An **epic** coordinates tasks. It may inspect repositories but never writes code.
|
|
50
|
+
- A **task** is one durable outcome. It is either an execution unit itself or a
|
|
51
|
+
container for phases.
|
|
52
|
+
- A **phase** is one execution unit within a multi-phase task, normally one PR.
|
|
53
|
+
- An **execution unit** has exactly one writable `repo`, optional read-only
|
|
54
|
+
`repos`, one branch, one base, and one recorded PR value.
|
|
55
|
+
- `open` is available, `working` is actively owned, and `done` or `dropped` is
|
|
56
|
+
terminal. Only `done` satisfies a dependency.
|
|
57
|
+
|
|
58
|
+
The `authority` returned by context is decisive. Write only through
|
|
59
|
+
`authority.writable.checkoutPath`. Every entry in `authority.references` is
|
|
60
|
+
read-only, even if filesystem permissions permit writes.
|
|
61
|
+
|
|
62
|
+
## Decide Before Acting
|
|
63
|
+
|
|
64
|
+
Require explicit user intent before:
|
|
65
|
+
|
|
66
|
+
- initializing a workbase;
|
|
67
|
+
- adding, linking, renaming, or removing a repository alias;
|
|
68
|
+
- launching another agent with `agency work` from an active agent session;
|
|
69
|
+
- creating a pull request;
|
|
70
|
+
- archiving, restoring, dropping, or reopening work; or
|
|
71
|
+
- using `--force` to override readiness.
|
|
72
|
+
|
|
73
|
+
Use a single-phase task for one outcome delivered by one PR. Use phases when an
|
|
74
|
+
outcome needs multiple PRs or ordered execution units. Use an epic when several
|
|
75
|
+
independently meaningful tasks need coordination.
|
|
76
|
+
|
|
77
|
+
## Safety Invariants
|
|
78
|
+
|
|
79
|
+
- Keep task-wide decisions in `TASK.md` and phase delivery details in `PHASE.md`.
|
|
80
|
+
- Never write through plural `repos` references.
|
|
81
|
+
- Never edit bare repositories or repository symlinks under `repos/`.
|
|
82
|
+
- Never manually create, move, or remove generated `code/` worktrees.
|
|
83
|
+
- Never invent IDs, revisions, PR URLs, dependency completion, or checkout state.
|
|
84
|
+
- Preserve parent backlinks and dependency declarations; use Agency mutations
|
|
85
|
+
instead of hand-editing structural frontmatter.
|
|
86
|
+
- Run `agency validate` before worktree or PR operations and after structural edits.
|
|
87
|
+
- Do not bypass dirty-worktree, active-claim, revision, readiness, or failed-check
|
|
88
|
+
protections.
|
|
89
|
+
|
|
90
|
+
## Operating Protocol
|
|
91
|
+
|
|
92
|
+
### Start
|
|
93
|
+
|
|
94
|
+
1. Run `agency context . --json`.
|
|
95
|
+
2. Confirm `target`, `graph.readiness`, `authority`, `workspace`, and `validation`.
|
|
96
|
+
3. Read the returned task and phase document paths for prose requirements.
|
|
97
|
+
4. Stop on validation errors, blockers, an unexpected writable repository, or a
|
|
98
|
+
conflicting active owner.
|
|
99
|
+
|
|
100
|
+
### Work
|
|
101
|
+
|
|
102
|
+
1. Change files only in the declared writable checkout.
|
|
103
|
+
2. Keep durable status and decisions current as the work changes.
|
|
104
|
+
3. Validate structure after Agency document mutations.
|
|
105
|
+
4. Run repository-specific formatting, type checks, builds, dead-code checks,
|
|
106
|
+
and focused tests before committing.
|
|
107
|
+
5. Review the diff and commit according to the repository's instructions.
|
|
108
|
+
|
|
109
|
+
### Finish
|
|
110
|
+
|
|
111
|
+
1. Re-run `agency validate` and repository checks.
|
|
112
|
+
2. Create a PR only when requested: `agency pr create <task> [phase]`.
|
|
113
|
+
3. Record terminal state only when the requested outcome is true. A created PR
|
|
114
|
+
alone does not make work `done` if completion requires merge.
|
|
115
|
+
4. If the session has a claim, use revision-guarded `agency finish`; otherwise
|
|
116
|
+
use the task or phase status command. Use `dropped` only for intentionally
|
|
117
|
+
abandoned work.
|
|
118
|
+
5. Report the durable status and PR URL. Do not manually remove the worktree.
|
|
119
|
+
|
|
120
|
+
## Human Launch vs Active Agent
|
|
121
|
+
|
|
122
|
+
`agency work` is a human/orchestrator launch flow. It selects work, checks
|
|
123
|
+
readiness, materializes managed checkouts, claims the execution unit, marks it
|
|
124
|
+
working, and starts the configured runner.
|
|
125
|
+
|
|
126
|
+
An agent already running in an Agency checkout must not call `agency work` to
|
|
127
|
+
start itself again. It should inspect context, perform the assigned work, and
|
|
128
|
+
finish or release its existing claim. Launch a nested or replacement agent only
|
|
129
|
+
when the user explicitly asks.
|
|
130
|
+
|
|
131
|
+
Use [`references/recipes.md`](references/recipes.md) for human setup, agent
|
|
132
|
+
execution, claim, PR, conversion, and recovery workflows. Use
|
|
133
|
+
[`references/commands.md`](references/commands.md) only when exact command syntax
|
|
134
|
+
is needed.
|