@markjaquith/agency 3.2.14 → 3.3.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 +20 -3
- package/cli-main.ts +1 -0
- package/package.json +7 -2
- package/src/cli-parser.ts +13 -0
- package/src/commands/work.ts +70 -2
- package/src/services/ReadinessService.ts +20 -0
- package/src/workbase/execution-contract.ts +10 -1
- package/src/workbase/schemas.ts +12 -0
- package/fixtures/protocol/orchestration-recipes.json +0 -53
- package/pi-extensions/agency.test.ts +0 -117
- package/src/check-commits.test.ts +0 -58
- package/src/cli-parser.test.ts +0 -945
- package/src/cli.test.ts +0 -1889
- package/src/commands/act.test.ts +0 -418
- package/src/commands/archive.test.ts +0 -236
- package/src/commands/context.test.ts +0 -711
- package/src/commands/description.test.ts +0 -103
- package/src/commands/doctor.test.ts +0 -185
- package/src/commands/epic.test.ts +0 -196
- package/src/commands/init.test.ts +0 -117
- package/src/commands/integration.test.ts +0 -165
- package/src/commands/pr.test.ts +0 -248
- package/src/commands/push.test.ts +0 -56
- package/src/commands/read-only.test.ts +0 -161
- package/src/commands/repo.test.ts +0 -199
- package/src/commands/restore.test.ts +0 -106
- package/src/commands/status.test.ts +0 -113
- package/src/commands/sync.test.ts +0 -200
- package/src/commands/task-phase.test.ts +0 -410
- package/src/commands/task.test.ts +0 -281
- package/src/commands/validate.test.ts +0 -186
- package/src/commands/work.test.ts +0 -1375
- package/src/commands/workbase.test.ts +0 -170
- package/src/graph-schema.test.ts +0 -124
- package/src/protocol.test.ts +0 -163
- package/src/readiness.test.ts +0 -105
- package/src/services/ArchiveBulkService.test.ts +0 -384
- package/src/services/ArchiveService.test.ts +0 -1092
- package/src/services/EpicService.test.ts +0 -74
- package/src/services/FileSystemService.test.ts +0 -81
- package/src/services/GraphMutationService.test.ts +0 -486
- package/src/services/GraphService.test.ts +0 -494
- package/src/services/IntegrationService.test.ts +0 -1091
- package/src/services/LifecycleTransaction.test.ts +0 -145
- package/src/services/PullRequestService.test.ts +0 -716
- package/src/services/PushService.test.ts +0 -408
- package/src/services/ReadinessService.test.ts +0 -290
- package/src/services/RepositoryService.test.ts +0 -789
- package/src/services/ReviewService.test.ts +0 -408
- package/src/services/SyncService.test.ts +0 -1377
- package/src/services/TaskPhaseService.test.ts +0 -852
- package/src/services/VersionControlService.test.ts +0 -62
- package/src/services/WorkbaseService.test.ts +0 -910
- package/src/services/WorktreeLock.test.ts +0 -205
- package/src/services/WorktreePerformance.test.ts +0 -71
- package/src/services/WorktreeService.test.ts +0 -2292
- package/src/test-utils.ts +0 -110
- package/src/usage-log.test.ts +0 -188
- package/src/utils/chooser.test.ts +0 -192
- package/src/utils/effect.test.ts +0 -30
- package/src/utils/interactive.pty.test.ts +0 -128
- package/src/utils/interactive.test.tsx +0 -860
- package/src/utils/process.test.ts +0 -132
- package/src/utils/progress.test.ts +0 -37
- package/src/work-view.test.ts +0 -151
- package/src/workbase/agent-command.test.ts +0 -128
- package/src/workbase/checkout-command.test.ts +0 -62
- package/src/workbase/delivery-command.test.ts +0 -180
- package/src/workbase/dependency-graph.test.ts +0 -50
- package/src/workbase/execution-contract.test.ts +0 -161
- package/src/workbase/frontmatter.test.ts +0 -67
- package/src/workbase/repository-reference.test.ts +0 -25
- package/src/workbase/schemas.test.ts +0 -543
- package/src/workbase/work-target.test.ts +0 -108
- package/src/workbase/worktree-command.test.ts +0 -61
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { findDependencyCycles, validateDependencies } from "./dependency-graph"
|
|
3
|
-
|
|
4
|
-
describe("dependency graph", () => {
|
|
5
|
-
test("accepts empty and acyclic dependency graphs", () => {
|
|
6
|
-
expect(validateDependencies([], "Tasks")).toBeUndefined()
|
|
7
|
-
expect(
|
|
8
|
-
validateDependencies(
|
|
9
|
-
[
|
|
10
|
-
{ id: "build" },
|
|
11
|
-
{ id: "test", dependsOn: ["build"] },
|
|
12
|
-
{ id: "ship", dependsOn: ["build", "test"] },
|
|
13
|
-
],
|
|
14
|
-
"Tasks",
|
|
15
|
-
),
|
|
16
|
-
).toBeUndefined()
|
|
17
|
-
expect(
|
|
18
|
-
findDependencyCycles([
|
|
19
|
-
{ id: "build" },
|
|
20
|
-
{ id: "test", dependsOn: ["build"] },
|
|
21
|
-
]),
|
|
22
|
-
).toEqual([])
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test("reports duplicate, self, and unknown dependencies precisely", () => {
|
|
26
|
-
expect(validateDependencies([{ id: "one" }, { id: "one" }], "Tasks")).toBe(
|
|
27
|
-
"Tasks IDs must be unique",
|
|
28
|
-
)
|
|
29
|
-
expect(
|
|
30
|
-
validateDependencies([{ id: "one", dependsOn: ["one"] }], "Tasks"),
|
|
31
|
-
).toBe("Task 'one' cannot depend on itself")
|
|
32
|
-
expect(
|
|
33
|
-
validateDependencies([{ id: "one", dependsOn: ["missing"] }], "Phases"),
|
|
34
|
-
).toBe("Unknown phase dependency 'missing'")
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
test("detects cycles deterministically across disconnected graphs", () => {
|
|
38
|
-
const nodes = [
|
|
39
|
-
{ id: "delta", dependsOn: ["charlie"] },
|
|
40
|
-
{ id: "bravo", dependsOn: ["alpha"] },
|
|
41
|
-
{ id: "charlie", dependsOn: ["delta"] },
|
|
42
|
-
{ id: "alpha", dependsOn: ["bravo"] },
|
|
43
|
-
]
|
|
44
|
-
|
|
45
|
-
expect(findDependencyCycles(nodes)).toEqual(["bravo", "delta"])
|
|
46
|
-
expect(validateDependencies(nodes, "Tasks")).toBe(
|
|
47
|
-
"Task dependency cycle includes 'bravo'",
|
|
48
|
-
)
|
|
49
|
-
})
|
|
50
|
-
})
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
|
|
2
|
-
import { mkdir } from "node:fs/promises"
|
|
3
|
-
import { dirname, join } from "node:path"
|
|
4
|
-
import { cleanupTempDir, createTempDir, runTestEffect } from "../test-utils"
|
|
5
|
-
import { documentRevision } from "./document-revision"
|
|
6
|
-
import {
|
|
7
|
-
assessValidationEvidence,
|
|
8
|
-
buildExecutionContract,
|
|
9
|
-
buildValidationEvidence,
|
|
10
|
-
EXECUTION_SOURCE_LOCATIONS,
|
|
11
|
-
normalizeRecalledContext,
|
|
12
|
-
parseValidationEvidence,
|
|
13
|
-
readValidationEvidence,
|
|
14
|
-
} from "./execution-contract"
|
|
15
|
-
|
|
16
|
-
describe("execution contract", () => {
|
|
17
|
-
let root: string
|
|
18
|
-
let taskPath: string
|
|
19
|
-
let taskContent: string
|
|
20
|
-
|
|
21
|
-
beforeEach(async () => {
|
|
22
|
-
root = await createTempDir()
|
|
23
|
-
taskPath = join(root, "tasks/example/TASK.md")
|
|
24
|
-
taskContent =
|
|
25
|
-
"---\nticketUrl: null\nrepo: agency\nbranch: task/example\nbase: main\npr: null\nstatus: open\n---\n\n# Example\n"
|
|
26
|
-
await mkdir(join(root, "repos/agency"), { recursive: true })
|
|
27
|
-
await mkdir(join(root, "tasks/example"), { recursive: true })
|
|
28
|
-
await Bun.write(join(root, "agency.json"), '{"version":2}\n')
|
|
29
|
-
await Bun.write(taskPath, taskContent)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
afterEach(async () => cleanupTempDir(root))
|
|
33
|
-
|
|
34
|
-
const createEvidence = () =>
|
|
35
|
-
runTestEffect(
|
|
36
|
-
buildValidationEvidence({
|
|
37
|
-
startPath: root,
|
|
38
|
-
target: "execution-unit:task/example",
|
|
39
|
-
documentPath: taskPath,
|
|
40
|
-
documentRevision: documentRevision(taskContent),
|
|
41
|
-
recalledContext: normalizeRecalledContext({
|
|
42
|
-
id: "example",
|
|
43
|
-
repo: "agency",
|
|
44
|
-
base: "main",
|
|
45
|
-
}),
|
|
46
|
-
}),
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
test("reuses evidence only for the same workbase and revision", async () => {
|
|
50
|
-
const evidence = await createEvidence()
|
|
51
|
-
expect(parseValidationEvidence(evidence)).toEqual(evidence)
|
|
52
|
-
const assessment = await runTestEffect(
|
|
53
|
-
assessValidationEvidence({
|
|
54
|
-
evidence,
|
|
55
|
-
startPath: root,
|
|
56
|
-
target: evidence.target,
|
|
57
|
-
documentPath: taskPath,
|
|
58
|
-
documentRevision: evidence.documentRevision,
|
|
59
|
-
}),
|
|
60
|
-
)
|
|
61
|
-
expect(assessment.disposition).toEqual({ status: "reused", reasons: [] })
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
test("treats legacy creation output as a validation refresh", async () => {
|
|
65
|
-
expect(
|
|
66
|
-
await runTestEffect(
|
|
67
|
-
readValidationEvidence(
|
|
68
|
-
JSON.stringify({ version: 1, ok: true, result: { id: "example" } }),
|
|
69
|
-
root,
|
|
70
|
-
),
|
|
71
|
-
),
|
|
72
|
-
).toBeUndefined()
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
test("refreshes evidence after document, config, mapping, or payload changes", async () => {
|
|
76
|
-
const evidence = await createEvidence()
|
|
77
|
-
const changedContent = `${taskContent}\nChanged\n`
|
|
78
|
-
await Bun.write(taskPath, changedContent)
|
|
79
|
-
await mkdir(join(root, "repos/other"), { recursive: true })
|
|
80
|
-
await Bun.write(
|
|
81
|
-
join(root, "agency.json"),
|
|
82
|
-
'{"version":2,"repositories":{"other":{"remote":"https://example.com/other.git"}}}\n',
|
|
83
|
-
)
|
|
84
|
-
const assessment = await runTestEffect(
|
|
85
|
-
assessValidationEvidence({
|
|
86
|
-
evidence: { ...evidence, digest: "0".repeat(64) },
|
|
87
|
-
startPath: root,
|
|
88
|
-
target: evidence.target,
|
|
89
|
-
documentPath: taskPath,
|
|
90
|
-
documentRevision: documentRevision(changedContent),
|
|
91
|
-
}),
|
|
92
|
-
)
|
|
93
|
-
expect(assessment.disposition.status).toBe("refreshed")
|
|
94
|
-
expect(assessment.disposition.reasons).toEqual(
|
|
95
|
-
expect.arrayContaining([
|
|
96
|
-
"digest-mismatch",
|
|
97
|
-
"document-revision-changed",
|
|
98
|
-
"workbase-revision-changed",
|
|
99
|
-
"configuration-changed",
|
|
100
|
-
"repository-mapping-changed",
|
|
101
|
-
]),
|
|
102
|
-
)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
test("describes prepared execution without prescribing orchestration", () => {
|
|
106
|
-
const checkoutPath = join(root, "tasks/example/code/agency")
|
|
107
|
-
const applied = buildExecutionContract({
|
|
108
|
-
workbaseRoot: root,
|
|
109
|
-
target: "execution-unit:task/example",
|
|
110
|
-
taskPath,
|
|
111
|
-
checkoutPath,
|
|
112
|
-
documentRevision: "a".repeat(64),
|
|
113
|
-
dryRun: false,
|
|
114
|
-
})
|
|
115
|
-
const phasePath = join(root, "tasks/example/phases/implementation/PHASE.md")
|
|
116
|
-
const preview = buildExecutionContract({
|
|
117
|
-
workbaseRoot: root,
|
|
118
|
-
target: "execution-unit:phase/example/implementation",
|
|
119
|
-
taskPath,
|
|
120
|
-
phasePath,
|
|
121
|
-
checkoutPath: join(
|
|
122
|
-
root,
|
|
123
|
-
"tasks/example/phases/implementation/code/agency",
|
|
124
|
-
),
|
|
125
|
-
documentRevision: "b".repeat(64),
|
|
126
|
-
dryRun: true,
|
|
127
|
-
})
|
|
128
|
-
expect(applied).toMatchObject({
|
|
129
|
-
capability: "agency-execution-v1",
|
|
130
|
-
mode: "applied",
|
|
131
|
-
workspace: {
|
|
132
|
-
state: "materialized",
|
|
133
|
-
checkoutPath,
|
|
134
|
-
},
|
|
135
|
-
commands: {
|
|
136
|
-
work: {
|
|
137
|
-
cwd: dirname(taskPath),
|
|
138
|
-
argv: ["agency", "work", ".", "--auto"],
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
})
|
|
142
|
-
expect(applied.sourceLocations).toEqual(EXECUTION_SOURCE_LOCATIONS)
|
|
143
|
-
expect(preview).toMatchObject({
|
|
144
|
-
mode: "preview",
|
|
145
|
-
workspace: { state: "planned" },
|
|
146
|
-
plannedActions: [{ kind: "workspace-materialization" }],
|
|
147
|
-
commands: {
|
|
148
|
-
context: { cwd: dirname(phasePath) },
|
|
149
|
-
},
|
|
150
|
-
})
|
|
151
|
-
expect(applied.executionIdentity.key).toBe(
|
|
152
|
-
buildExecutionContract({
|
|
153
|
-
workbaseRoot: root,
|
|
154
|
-
target: "execution-unit:task/example",
|
|
155
|
-
taskPath,
|
|
156
|
-
documentRevision: "a".repeat(64),
|
|
157
|
-
dryRun: true,
|
|
158
|
-
}).executionIdentity.key,
|
|
159
|
-
)
|
|
160
|
-
})
|
|
161
|
-
})
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { Effect } from "effect"
|
|
3
|
-
import { formatWorkDocumentBody, parseFrontmatter } from "./frontmatter"
|
|
4
|
-
|
|
5
|
-
describe("parseFrontmatter", () => {
|
|
6
|
-
test("parses YAML 1.2 frontmatter and body", async () => {
|
|
7
|
-
const parsed = await Effect.runPromise(
|
|
8
|
-
parseFrontmatter(
|
|
9
|
-
"---\nrepo: agency\npr: null\n---\n\n# Task\n",
|
|
10
|
-
"TASK.md",
|
|
11
|
-
),
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
expect(parsed.data).toEqual({ repo: "agency", pr: null })
|
|
15
|
-
expect(parsed.body).toBe("\n# Task\n")
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test("rejects duplicate keys", async () => {
|
|
19
|
-
await expect(
|
|
20
|
-
Effect.runPromise(
|
|
21
|
-
parseFrontmatter("---\nrepo: agency\nrepo: effect\n---\n", "TASK.md"),
|
|
22
|
-
),
|
|
23
|
-
).rejects.toThrow("Map keys must be unique")
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test("rejects anchors and aliases", async () => {
|
|
27
|
-
await expect(
|
|
28
|
-
Effect.runPromise(
|
|
29
|
-
parseFrontmatter(
|
|
30
|
-
"---\nrepo: &repo agency\nrepos:\n - *repo\n---\n",
|
|
31
|
-
"TASK.md",
|
|
32
|
-
),
|
|
33
|
-
),
|
|
34
|
-
).rejects.toThrow("not supported")
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
test("rejects custom tags", async () => {
|
|
38
|
-
await expect(
|
|
39
|
-
Effect.runPromise(
|
|
40
|
-
parseFrontmatter("---\nrepo: !custom agency\n---\n", "TASK.md"),
|
|
41
|
-
),
|
|
42
|
-
).rejects.toThrow()
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test("requires frontmatter at the start of the document", async () => {
|
|
46
|
-
await expect(
|
|
47
|
-
Effect.runPromise(parseFrontmatter("# Task\n", "TASK.md")),
|
|
48
|
-
).rejects.toThrow("must begin with YAML frontmatter")
|
|
49
|
-
})
|
|
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
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { parseRepositoryReferences } from "./repository-reference"
|
|
3
|
-
|
|
4
|
-
describe("repository references", () => {
|
|
5
|
-
test("parses alias and ref CLI values", () => {
|
|
6
|
-
expect(parseRepositoryReferences(["web:origin/main"])[0]).toEqual({
|
|
7
|
-
repo: "web",
|
|
8
|
-
ref: "origin/main",
|
|
9
|
-
})
|
|
10
|
-
expect(
|
|
11
|
-
parseRepositoryReferences(["web:main", "zenpayroll:v1.2.3"]),
|
|
12
|
-
).toEqual([
|
|
13
|
-
{ repo: "web", ref: "main" },
|
|
14
|
-
{ repo: "zenpayroll", ref: "v1.2.3" },
|
|
15
|
-
])
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test("rejects references without both parts", () => {
|
|
19
|
-
for (const value of ["web", ":main", "web:"]) {
|
|
20
|
-
expect(() => parseRepositoryReferences([value])).toThrow(
|
|
21
|
-
"expected <alias>:<ref>",
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
})
|