@markjaquith/agency 2.60.0 → 2.61.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 +50 -0
- package/cli-main.ts +2 -0
- package/fixtures/protocol/orchestration-recipes.json +19 -0
- package/package.json +1 -1
- package/schemas/agency-graph-v1.schema.json +53 -0
- package/src/cli-parser.test.ts +49 -1
- package/src/cli-parser.ts +30 -1
- package/src/commands/task-phase.test.ts +49 -0
- package/src/commands/task.ts +47 -1
- package/src/graph-schema.test.ts +8 -0
- package/src/graph-schema.ts +7 -0
- package/src/services/ArchiveService.test.ts +18 -1
- package/src/services/GraphMutationService.test.ts +48 -0
- package/src/services/IntegrationService.test.ts +10 -0
- package/src/services/LifecycleTransaction.ts +12 -0
- package/src/services/PhaseService.ts +2 -0
- package/src/services/TaskPhaseService.test.ts +238 -0
- package/src/services/TaskService.ts +265 -6
- package/src/services/WorkbaseService.ts +30 -0
- package/src/workbase/AGENTS.md +25 -0
- package/src/workbase/frontmatter.test.ts +18 -1
- package/src/workbase/frontmatter.ts +29 -1
- package/src/workbase/opencode-file.ts +1 -1
- package/src/workbase/schemas.test.ts +36 -0
- package/src/workbase/schemas.ts +33 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test"
|
|
2
2
|
import { Effect } from "effect"
|
|
3
|
-
import { parseFrontmatter } from "./frontmatter"
|
|
3
|
+
import { formatWorkDocumentBody, parseFrontmatter } from "./frontmatter"
|
|
4
4
|
|
|
5
5
|
describe("parseFrontmatter", () => {
|
|
6
6
|
test("parses YAML 1.2 frontmatter and body", async () => {
|
|
@@ -48,3 +48,20 @@ describe("parseFrontmatter", () => {
|
|
|
48
48
|
).rejects.toThrow("must begin with YAML frontmatter")
|
|
49
49
|
})
|
|
50
50
|
})
|
|
51
|
+
|
|
52
|
+
describe("formatWorkDocumentBody", () => {
|
|
53
|
+
test("generates explicit investigation sections", () => {
|
|
54
|
+
const body = formatWorkDocumentBody(
|
|
55
|
+
"Investigate Checkout",
|
|
56
|
+
"task",
|
|
57
|
+
"investigation",
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
expect(body).toContain("## Investigation Boundary")
|
|
61
|
+
expect(body).toContain("## Evidence")
|
|
62
|
+
expect(body).toContain("## Findings")
|
|
63
|
+
expect(body).toContain("## Recommendation")
|
|
64
|
+
expect(body).toContain("## Implementation Handoff")
|
|
65
|
+
expect(body).not.toContain("Describe the task outcome")
|
|
66
|
+
})
|
|
67
|
+
})
|
|
@@ -85,7 +85,35 @@ export const formatMarkdownDocument = (data: object, body: string) =>
|
|
|
85
85
|
export const formatWorkDocumentBody = (
|
|
86
86
|
title: string,
|
|
87
87
|
kind: "epic" | "task" | "phase",
|
|
88
|
-
|
|
88
|
+
purpose?: "investigation" | "implementation",
|
|
89
|
+
) =>
|
|
90
|
+
purpose === "investigation"
|
|
91
|
+
? `# ${title}
|
|
92
|
+
|
|
93
|
+
## Investigation Boundary
|
|
94
|
+
|
|
95
|
+
State the question, scope, and implementation excluded from this investigation.
|
|
96
|
+
|
|
97
|
+
## Evidence
|
|
98
|
+
|
|
99
|
+
Record inspected sources, commands, observations, and supporting links.
|
|
100
|
+
|
|
101
|
+
## Findings
|
|
102
|
+
|
|
103
|
+
Record findings, confidence, uncertainty, and relevant constraints.
|
|
104
|
+
|
|
105
|
+
## Recommendation
|
|
106
|
+
|
|
107
|
+
Recommend implementation, no change, or further investigation.
|
|
108
|
+
|
|
109
|
+
## Implementation Handoff
|
|
110
|
+
|
|
111
|
+
Record any distinct implementation task created from this investigation.
|
|
112
|
+
|
|
113
|
+
## Important Decisions
|
|
114
|
+
|
|
115
|
+
Record consequential decisions and their rationale.`
|
|
116
|
+
: `# ${title}
|
|
89
117
|
|
|
90
118
|
## Outcome
|
|
91
119
|
|
|
@@ -10,7 +10,7 @@ const agencyPlanPrompt = `You are in Agency Plan mode. Think, read, search, and
|
|
|
10
10
|
|
|
11
11
|
Start with \`agency context . --json\`. Use its document paths and revisions, then inspect the graph, related epics, tasks, phases, linked tickets, and repository declarations needed to understand the work. Use machine-readable Agency output when available instead of inferring structure from directory names.
|
|
12
12
|
|
|
13
|
-
When planning an epic, decompose it into independently deliverable tasks with explicit dependencies. Add phases only when one task genuinely requires multiple ordered delivery units. Reuse or update existing work instead of creating duplicate tasks or phases.
|
|
13
|
+
When planning an epic, decompose it into independently deliverable tasks with explicit dependencies. Add phases only when one task genuinely requires multiple ordered delivery units. Reuse or update existing work instead of creating duplicate tasks or phases, except when the user explicitly requests a new, separate, or follow-up item. Explicit-new intent overrides reuse of active and archived work even when the subject or suggested ID matches.
|
|
14
14
|
|
|
15
15
|
Use the Agency CLI for full workbase orchestration when the plan requires it, including creating or updating related epics, tasks, and phases; moving tasks; maintaining dependencies; and changing lifecycle state. Use \`--if-revision\` with the revision returned by context for mutations that support it, and run \`agency validate\` after changing workbase structure. Use available ticket tools to inspect or update a linked external ticket when the plan requires it.
|
|
16
16
|
|
|
@@ -64,6 +64,42 @@ describe("portable repository declarations", () => {
|
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
describe("body-of-work descriptions", () => {
|
|
67
|
+
test("decodes strict task purpose and handoff provenance", () => {
|
|
68
|
+
const handoff = {
|
|
69
|
+
source: { kind: "phase", taskId: "investigate", phaseId: "evidence" },
|
|
70
|
+
sourceRevision: "a".repeat(64),
|
|
71
|
+
}
|
|
72
|
+
const task = Schema.decodeUnknownSync(TaskFrontmatter, {
|
|
73
|
+
onExcessProperty: "error",
|
|
74
|
+
})({
|
|
75
|
+
ticketUrl: null,
|
|
76
|
+
purpose: "implementation",
|
|
77
|
+
handoff,
|
|
78
|
+
repo: "agency",
|
|
79
|
+
branch: "task/implement",
|
|
80
|
+
base: "main",
|
|
81
|
+
pr: null,
|
|
82
|
+
})
|
|
83
|
+
expect(task).toMatchObject({ purpose: "implementation", handoff })
|
|
84
|
+
|
|
85
|
+
for (const invalid of [
|
|
86
|
+
{ ...handoff, sourceRevision: "short" },
|
|
87
|
+
{ ...handoff, source: { kind: "phase", taskId: "investigate" } },
|
|
88
|
+
{ ...handoff, source: { kind: "task", taskId: "../unsafe" } },
|
|
89
|
+
]) {
|
|
90
|
+
expect(() =>
|
|
91
|
+
Schema.decodeUnknownSync(TaskFrontmatter, {
|
|
92
|
+
onExcessProperty: "error",
|
|
93
|
+
})({
|
|
94
|
+
ticketUrl: null,
|
|
95
|
+
purpose: "implementation",
|
|
96
|
+
handoff: invalid,
|
|
97
|
+
phases: [],
|
|
98
|
+
}),
|
|
99
|
+
).toThrow()
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
67
103
|
test("decodes review tasks strictly and rejects writable execution fields", () => {
|
|
68
104
|
const review = {
|
|
69
105
|
ticketUrl: null,
|
package/src/workbase/schemas.ts
CHANGED
|
@@ -46,7 +46,9 @@ const IsoTimestamp = NonEmptyString.pipe(
|
|
|
46
46
|
|
|
47
47
|
const GitCommit = Schema.String.pipe(Schema.pattern(/^[a-f0-9]{40}$/))
|
|
48
48
|
|
|
49
|
-
const DocumentRevision = Schema.String.pipe(
|
|
49
|
+
export const DocumentRevision = Schema.String.pipe(
|
|
50
|
+
Schema.pattern(/^[a-f0-9]{64}$/),
|
|
51
|
+
)
|
|
50
52
|
|
|
51
53
|
export const ClaimRecord = Schema.Struct({
|
|
52
54
|
claimant: NonEmptyString,
|
|
@@ -155,6 +157,30 @@ const ExecutionUnit = {
|
|
|
155
157
|
completion: Schema.optional(CompletionRecord),
|
|
156
158
|
}
|
|
157
159
|
|
|
160
|
+
export const TaskPurpose = Schema.Literal("investigation", "implementation")
|
|
161
|
+
|
|
162
|
+
export const TaskHandoffSource = Schema.Union(
|
|
163
|
+
Schema.Struct({
|
|
164
|
+
kind: Schema.Literal("task"),
|
|
165
|
+
taskId: EntityId,
|
|
166
|
+
}),
|
|
167
|
+
Schema.Struct({
|
|
168
|
+
kind: Schema.Literal("phase"),
|
|
169
|
+
taskId: EntityId,
|
|
170
|
+
phaseId: EntityId,
|
|
171
|
+
}),
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
export const TaskHandoff = Schema.Struct({
|
|
175
|
+
source: TaskHandoffSource,
|
|
176
|
+
sourceRevision: DocumentRevision,
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
const TaskMetadata = {
|
|
180
|
+
purpose: Schema.optional(TaskPurpose),
|
|
181
|
+
handoff: Schema.optional(TaskHandoff),
|
|
182
|
+
}
|
|
183
|
+
|
|
158
184
|
export const EpicFrontmatter = Schema.Struct({
|
|
159
185
|
ticketUrl: Url,
|
|
160
186
|
description: Description,
|
|
@@ -166,6 +192,7 @@ const SinglePhaseTaskFrontmatter = Schema.Struct({
|
|
|
166
192
|
ticketUrl: Schema.NullOr(Url),
|
|
167
193
|
description: Description,
|
|
168
194
|
epic: Schema.optional(EntityId),
|
|
195
|
+
...TaskMetadata,
|
|
169
196
|
...ExecutionUnit,
|
|
170
197
|
})
|
|
171
198
|
|
|
@@ -173,6 +200,7 @@ const MultiPhaseTaskFrontmatter = Schema.Struct({
|
|
|
173
200
|
ticketUrl: Schema.NullOr(Url),
|
|
174
201
|
description: Description,
|
|
175
202
|
epic: Schema.optional(EntityId),
|
|
203
|
+
...TaskMetadata,
|
|
176
204
|
phases: Schema.Array(Dependency),
|
|
177
205
|
})
|
|
178
206
|
|
|
@@ -221,6 +249,7 @@ const ReviewTaskFrontmatter = Schema.Struct({
|
|
|
221
249
|
ticketUrl: Schema.NullOr(Url),
|
|
222
250
|
description: Description,
|
|
223
251
|
epic: Schema.optional(EntityId),
|
|
252
|
+
...TaskMetadata,
|
|
224
253
|
review: ReviewRecord,
|
|
225
254
|
status: Schema.optionalWith(WorkStatus, { default: () => "open" as const }),
|
|
226
255
|
claim: Schema.optional(ClaimRecord),
|
|
@@ -254,6 +283,9 @@ export type PullRequestRecord = Schema.Schema.Type<typeof PullRequestRecord>
|
|
|
254
283
|
export type ReviewSource = Schema.Schema.Type<typeof ReviewSource>
|
|
255
284
|
export type ReviewRecord = Schema.Schema.Type<typeof ReviewRecord>
|
|
256
285
|
export type CompletionRecord = Schema.Schema.Type<typeof CompletionRecord>
|
|
286
|
+
export type TaskPurpose = Schema.Schema.Type<typeof TaskPurpose>
|
|
287
|
+
export type TaskHandoffSource = Schema.Schema.Type<typeof TaskHandoffSource>
|
|
288
|
+
export type TaskHandoff = Schema.Schema.Type<typeof TaskHandoff>
|
|
257
289
|
export type EpicFrontmatter = Schema.Schema.Type<typeof EpicFrontmatter>
|
|
258
290
|
export type TaskFrontmatter = Schema.Schema.Type<typeof TaskFrontmatter>
|
|
259
291
|
export type PhaseFrontmatter = Schema.Schema.Type<typeof PhaseFrontmatter>
|