@markjaquith/agency 2.47.3 → 2.48.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.
@@ -1,4 +1,5 @@
1
1
  import { Effect } from "effect"
2
+ import { createHash } from "node:crypto"
2
3
  import { join } from "node:path"
3
4
  import { FileSystemService } from "./FileSystemService"
4
5
  import { WorkbaseService } from "./WorkbaseService"
@@ -10,10 +11,6 @@ import {
10
11
  canUpdateManagedWorkbaseOpencode,
11
12
  managedWorkbaseOpencode,
12
13
  } from "../workbase/opencode-file"
13
- import {
14
- canUpdateManagedWorkbaseOpencodeCommand,
15
- managedWorkbaseOpencodeCommand,
16
- } from "../workbase/opencode-command-file"
17
14
  import {
18
15
  canUpdateManagedWorkbaseOpencodePlugin,
19
16
  managedWorkbaseOpencodePlugin,
@@ -33,7 +30,6 @@ interface IntegrationFileStatus {
33
30
  readonly name:
34
31
  | "agents"
35
32
  | "opencode"
36
- | "opencode-command"
37
33
  | "opencode-plugin"
38
34
  | "opencode-tui"
39
35
  | "opencode-tui-plugin"
@@ -74,25 +70,6 @@ const describe = (
74
70
  "Run 'agency integration sync' to install Agency instructions and whole-workbase OpenCode access.",
75
71
  }
76
72
  }
77
- if (name === "opencode-command") {
78
- return state === "managed"
79
- ? {
80
- diagnostic: "Agency's managed OpenCode /agency command is current.",
81
- remediation: null,
82
- }
83
- : state === "customized"
84
- ? {
85
- diagnostic:
86
- "A user-owned OpenCode /agency command is present and was preserved.",
87
- remediation: null,
88
- }
89
- : {
90
- diagnostic:
91
- "The managed OpenCode /agency command needs synchronization.",
92
- remediation:
93
- "Run 'agency integration sync' to install the managed /agency command.",
94
- }
95
- }
96
73
  if (name === "opencode-plugin") {
97
74
  return state === "managed"
98
75
  ? {
@@ -202,8 +179,6 @@ const inspect = (root: string) =>
202
179
  const opencodeJsonPath = join(opencodeDirectory, "opencode.json")
203
180
  const tuiPath = join(opencodeDirectory, "tui.jsonc")
204
181
  const tuiJsonPath = join(opencodeDirectory, "tui.json")
205
- const commandPath = join(opencodeDirectory, "command", "agency.md")
206
- const pluralCommandPath = join(opencodeDirectory, "commands", "agency.md")
207
182
  const pluginPath = join(
208
183
  opencodeDirectory,
209
184
  "plugin",
@@ -252,29 +227,6 @@ const inspect = (root: string) =>
252
227
  files.push(fileStatus("opencode", opencodePath, "missing"))
253
228
  }
254
229
 
255
- if ((yield* fs.readSymlinkTarget(commandPath)) !== null) {
256
- files.push(fileStatus("opencode-command", commandPath, "customized"))
257
- } else if (
258
- (yield* fs.readSymlinkTarget(pluralCommandPath)) !== null ||
259
- (yield* fs.exists(pluralCommandPath))
260
- ) {
261
- files.push(
262
- fileStatus("opencode-command", pluralCommandPath, "customized"),
263
- )
264
- } else if (yield* fs.exists(commandPath)) {
265
- files.push(
266
- classify(
267
- "opencode-command",
268
- commandPath,
269
- yield* fs.readFile(commandPath),
270
- managedWorkbaseOpencodeCommand,
271
- canUpdateManagedWorkbaseOpencodeCommand,
272
- ),
273
- )
274
- } else {
275
- files.push(fileStatus("opencode-command", commandPath, "missing"))
276
- }
277
-
278
230
  if ((yield* fs.readSymlinkTarget(pluginPath)) !== null) {
279
231
  files.push(fileStatus("opencode-plugin", pluginPath, "customized"))
280
232
  } else if (
@@ -348,6 +300,25 @@ const canRemoveLegacyAgents = (root: string) =>
348
300
  return canUpdateManagedWorkbaseAgents(yield* fs.readFile(path))
349
301
  })
350
302
 
303
+ const canRemoveLegacyOpencodeCommand = (root: string) =>
304
+ Effect.gen(function* () {
305
+ const fs = yield* FileSystemService
306
+ const path = join(root, ".opencode", "command", "agency.md")
307
+ if (
308
+ (yield* fs.readSymlinkTarget(path)) !== null ||
309
+ !(yield* fs.exists(path))
310
+ )
311
+ return false
312
+
313
+ const content = yield* fs.readFile(path)
314
+ const header = /^---\r?\n# agency-managed: sha256=([a-f0-9]{64})\r?\n/
315
+ const match = content.match(header)
316
+ if (!match?.[1]) return false
317
+
318
+ const canonical = content.replace(header, "---\n")
319
+ return createHash("sha256").update(canonical).digest("hex") === match[1]
320
+ })
321
+
351
322
  export class IntegrationService extends Effect.Service<IntegrationService>()(
352
323
  "IntegrationService",
353
324
  {
@@ -370,6 +341,8 @@ export class IntegrationService extends Effect.Service<IntegrationService>()(
370
341
  (status) =>
371
342
  status.name === "opencode" && status.state !== "customized",
372
343
  ) && (yield* canRemoveLegacyAgents(root))
344
+ const removeLegacyOpencodeCommand =
345
+ yield* canRemoveLegacyOpencodeCommand(root)
373
346
  const files: IntegrationSyncFile[] = []
374
347
 
375
348
  for (const status of statuses) {
@@ -382,9 +355,6 @@ export class IntegrationService extends Effect.Service<IntegrationService>()(
382
355
  } else if (status.name === "opencode") {
383
356
  yield* fs.createDirectory(join(root, ".opencode"))
384
357
  yield* fs.writeFile(status.path, managedWorkbaseOpencode)
385
- } else if (status.name === "opencode-command") {
386
- yield* fs.createDirectory(join(root, ".opencode", "command"))
387
- yield* fs.writeFile(status.path, managedWorkbaseOpencodeCommand)
388
358
  } else if (status.name === "opencode-plugin") {
389
359
  yield* fs.createDirectory(join(root, ".opencode", "plugin"))
390
360
  yield* fs.writeFile(status.path, managedWorkbaseOpencodePlugin)
@@ -411,6 +381,11 @@ export class IntegrationService extends Effect.Service<IntegrationService>()(
411
381
  }
412
382
 
413
383
  if (removeLegacyAgents) yield* fs.deleteFile(join(root, "AGENTS.md"))
384
+ if (removeLegacyOpencodeCommand) {
385
+ yield* fs.deleteFile(
386
+ join(root, ".opencode", "command", "agency.md"),
387
+ )
388
+ }
414
389
 
415
390
  return { root, files }
416
391
  }),
@@ -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
@@ -71,15 +100,15 @@ a refinement loop, or pausing or handing off completed implementation work):
71
100
  `agency integration status` reports `managed`, `drifted`, `customized`, or
72
101
  `missing` generated files. Agency keeps these instructions in
73
102
  `.agency/AGENTS.md`, and its managed OpenCode config loads them automatically.
74
- It also installs `.opencode/command/agency.md`, which provides safe `/agency`
75
- workflows for active OpenCode sessions, a managed server plugin that exposes
76
- skills from the authoritative writable checkout, and an explicitly registered
77
- TUI companion providing `/agency-debug` without submitting an LLM prompt.
103
+ It also installs a managed server plugin that exposes skills from the
104
+ authoritative writable checkout and an explicitly registered TUI companion
105
+ providing `/agency-debug` without submitting an LLM prompt.
78
106
  The workbase-root `AGENTS.md`, when present, belongs entirely to the workbase
79
107
  owner and composes with these instructions through OpenCode's normal discovery.
80
108
  `agency integration sync` updates only missing or checksum-safe drifted managed
81
- files and preserves user-customized files. `agency init` creates the managed
82
- files, and `agency work` reconciles them before launching an agent.
109
+ files, removes checksum-valid retired artifacts, and preserves user-customized
110
+ files. `agency init` creates the managed files, and `agency work` reconciles them
111
+ before launching an agent.
83
112
 
84
113
  OpenCode can access the complete workbase tree, but this filesystem permission
85
114
  does not expand Agency write authority beyond the checkout reported by
@@ -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
- ]
@@ -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.