@markjaquith/agency 2.9.0 → 2.11.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 CHANGED
@@ -231,12 +231,56 @@ agency repo link backend ~/Dev/backend
231
231
  agency task new
232
232
 
233
233
  agency validate
234
+ agency context tasks/refresh-copy --json
234
235
  agency work tasks/refresh-copy
235
236
  agency pr create refresh-copy
236
237
  ```
237
238
 
238
239
  ## Commands
239
240
 
241
+ ### Target Context
242
+
243
+ `agency context [target] --json` returns the complete bootstrap context for an
244
+ epic, task, or phase without modifying the workbase or fetching repositories.
245
+ The target defaults to the current directory; entity directories, document
246
+ paths, checkout descendants, and bare task IDs are accepted.
247
+
248
+ The result includes workbase and target identity, ancestor frontmatter and prose
249
+ with SHA-256 hashes, dependency and readiness state, aggregate status, writable
250
+ and reference authority, local checkout and resolved-commit state, recorded PR
251
+ state, and validation warnings. Only `done` satisfies a dependency; `dropped` is
252
+ terminal but remains a blocker.
253
+
254
+ Complete output is the default. Pass `--compact` explicitly to omit document
255
+ prose and low-level Git details while retaining identity, hashes, authority,
256
+ paths, graph state, materialization state, and validation warnings.
257
+
258
+ ### Workbase Graph
259
+
260
+ `agency graph --json` exports the complete workbase as graph contract version 1.
261
+ Nodes use stable IDs (`epic:<id>`, `task:<id>`, `phase:<task>/<phase>`,
262
+ `repository:<alias>`, and `execution-unit:<kind>/<id>`). Typed edges are `owns`,
263
+ `depends_on`, `writes`, and `references`.
264
+
265
+ Every work node includes status, readiness, blockers, reverse dependents, and
266
+ aggregate progress. Only `done` satisfies a dependency. The graph summary counts
267
+ the statuses of all execution units, independent of filters.
268
+
269
+ ```text
270
+ agency graph [--json | --jsonl] [--ready | --blocked]
271
+ [--status <status>...] [--repository <alias>...] [--kind <kind>...]
272
+ [--include <bodies|workspace|git|pr>...]
273
+ ```
274
+
275
+ Filters are applied after graph state is computed. Returned edges always have
276
+ both endpoints in the filtered node set. Durable frontmatter and document hashes
277
+ are always present; prose, absolute workspace paths, Git inspection, and live PR
278
+ inspection are opt-in include layers.
279
+
280
+ `--jsonl` emits a versioned `meta` record, one record per node and edge, then an
281
+ `end` record with counts. Combining the metadata with the streamed node and edge
282
+ records reconstructs the same result as `--json`.
283
+
240
284
  ### Workbase and Repositories
241
285
 
242
286
  ```text
@@ -257,7 +301,7 @@ repository. Alias names are then used by all documents and commands.
257
301
 
258
302
  Commands that print Agency-owned results accept `--json`, including initialization,
259
303
  integration inspection/sync, repository mutations, entity creation/list/show,
260
- status, validation, and PR creation.
304
+ status, validation, graph export, and PR creation.
261
305
 
262
306
  ### Epics
263
307
 
@@ -459,14 +503,16 @@ recovery action. Version 1 defines these codes:
459
503
  | `ARCHIVE_ERROR` | Archive operation failed |
460
504
  | `WORKTREE_ERROR` | Worktree operation failed |
461
505
  | `PULL_REQUEST_ERROR` | Pull request operation failed |
506
+ | `GRAPH_ERROR` | Workbase graph construction failed |
462
507
  | `PROCESS_ERROR` | A child process failed and may be retried |
463
508
  | `PROTOCOL_OUTPUT_ERROR` | A command violated the machine output contract |
464
509
  | `COMMAND_FAILED` | An otherwise unclassified command failure |
465
510
 
466
511
  The Effect schemas are exported from `@markjaquith/agency` and
467
- `@markjaquith/agency/protocol`. The distributable JSON Schema is exported as
468
- `@markjaquith/agency/schemas/agency-envelope-v1.json`. Representative payloads
469
- are exported as `@markjaquith/agency/fixtures/protocol/success.json` and
512
+ `@markjaquith/agency/protocol`. The distributable JSON Schemas are exported as
513
+ `@markjaquith/agency/schemas/agency-envelope-v1.json` and
514
+ `@markjaquith/agency/schemas/agency-graph-v1.json`. Representative envelope
515
+ payloads are exported as `@markjaquith/agency/fixtures/protocol/success.json` and
470
516
  `@markjaquith/agency/fixtures/protocol/error.json`.
471
517
 
472
518
  ## Agent Skill
package/cli.ts CHANGED
@@ -8,6 +8,8 @@ import { pr, help as prHelp } from "./src/commands/pr"
8
8
  import { work, help as workHelp } from "./src/commands/work"
9
9
  import { status, help as statusHelp } from "./src/commands/status"
10
10
  import { validate, help as validateHelp } from "./src/commands/validate"
11
+ import { context, help as contextHelp } from "./src/commands/context"
12
+ import { graph, help as graphHelp } from "./src/commands/graph"
11
13
  import { repo, help as repoHelp } from "./src/commands/repo"
12
14
  import { epic, help as epicHelp } from "./src/commands/epic"
13
15
  import { phase, help as phaseHelp } from "./src/commands/phase"
@@ -28,6 +30,8 @@ import { WorktreeService } from "./src/services/WorktreeService"
28
30
  import { PullRequestService } from "./src/services/PullRequestService"
29
31
  import { ArchiveService } from "./src/services/ArchiveService"
30
32
  import { IntegrationService } from "./src/services/IntegrationService"
33
+ import { ContextService } from "./src/services/ContextService"
34
+ import { GraphService } from "./src/services/GraphService"
31
35
  import {
32
36
  collectCommandResult,
33
37
  errorEnvelope,
@@ -47,6 +51,8 @@ const CliLayer = Layer.mergeAll(
47
51
  PullRequestService.Default,
48
52
  ArchiveService.Default,
49
53
  IntegrationService.Default,
54
+ ContextService.Default,
55
+ GraphService.Default,
50
56
  )
51
57
 
52
58
  /**
@@ -313,6 +319,45 @@ const commands: Record<string, Command> = {
313
319
  )
314
320
  },
315
321
  },
322
+ context: {
323
+ run: async (args: string[], options: Record<string, any>) => {
324
+ if (options.help) {
325
+ console.log(contextHelp)
326
+ return
327
+ }
328
+ await runCommand(
329
+ context({
330
+ target: args[0],
331
+ compact: options.compact,
332
+ json: options.json,
333
+ silent: options.silent,
334
+ verbose: options.verbose,
335
+ }),
336
+ )
337
+ },
338
+ },
339
+ graph: {
340
+ run: async (_args: string[], options: Record<string, any>) => {
341
+ if (options.help) {
342
+ console.log(graphHelp)
343
+ return
344
+ }
345
+ await runCommand(
346
+ graph({
347
+ json: options.json,
348
+ jsonl: options.jsonl,
349
+ ready: options.ready,
350
+ blocked: options.blocked,
351
+ statuses: options.status,
352
+ repositories: options.repository,
353
+ kinds: options.kind,
354
+ include: options.include,
355
+ silent: options.silent,
356
+ verbose: options.verbose,
357
+ }),
358
+ )
359
+ },
360
+ },
316
361
  }
317
362
 
318
363
  function showMainHelp() {
@@ -334,6 +379,8 @@ Commands:
334
379
  repo <subcommand> Manage workbase repositories
335
380
  status Show status for the current workbase
336
381
  validate [path] Validate a workbase
382
+ context [target] Return complete target context
383
+ graph Export the complete workbase graph
337
384
 
338
385
  Global Options:
339
386
  -h, --help Show help for a command
@@ -352,7 +399,9 @@ For more information about a command, run:
352
399
  `)
353
400
  }
354
401
 
355
- const machineMode = process.argv.slice(2).includes("--json")
402
+ const machineMode = process.argv
403
+ .slice(2)
404
+ .some((argument) => argument === "--json" || argument === "--jsonl")
356
405
 
357
406
  try {
358
407
  const args = process.argv.slice(2)
@@ -380,11 +429,13 @@ try {
380
429
  !values.json &&
381
430
  !values["no-input"] &&
382
431
  Boolean(process.stdin.isTTY && process.stderr.isTTY)
383
- if (values.json) {
432
+ if (values.json || (values.jsonl && values.help)) {
384
433
  const result = await collectCommandResult(() =>
385
434
  command.run(commandArgs, { ...values, inputAllowed }),
386
435
  )
387
436
  writeEnvelope(successEnvelope(result))
437
+ } else if (values.jsonl) {
438
+ await command.run(commandArgs, { ...values, inputAllowed: false })
388
439
  } else {
389
440
  await command.run(commandArgs, { ...values, inputAllowed })
390
441
  }
package/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./src/workbase/schemas"
2
2
  export * from "./src/protocol"
3
+ export * from "./src/graph-schema"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markjaquith/agency",
3
- "version": "2.9.0",
3
+ "version": "2.11.0",
4
4
  "description": "Manage agentic work across repositories with durable workbases",
5
5
  "keywords": [
6
6
  "agents",
@@ -41,6 +41,9 @@
41
41
  "./schemas/agency-envelope-v1.json": {
42
42
  "default": "./schemas/agency-envelope-v1.schema.json"
43
43
  },
44
+ "./schemas/agency-graph-v1.json": {
45
+ "default": "./schemas/agency-graph-v1.schema.json"
46
+ },
44
47
  "./fixtures/protocol/success.json": {
45
48
  "default": "./fixtures/protocol/success.json"
46
49
  },