@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,199 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
|
|
2
|
-
import { mkdir } from "node:fs/promises"
|
|
3
|
-
import { join } from "node:path"
|
|
4
|
-
import {
|
|
5
|
-
captureLogs,
|
|
6
|
-
cleanupTempDir,
|
|
7
|
-
createTempDir,
|
|
8
|
-
runTestEffect,
|
|
9
|
-
} from "../test-utils"
|
|
10
|
-
import { repo } from "./repo"
|
|
11
|
-
|
|
12
|
-
describe("repo command", () => {
|
|
13
|
-
let root: string
|
|
14
|
-
|
|
15
|
-
beforeEach(async () => {
|
|
16
|
-
root = await createTempDir()
|
|
17
|
-
await Bun.write(join(root, "agency.json"), '{"version":2}\n')
|
|
18
|
-
await mkdir(join(root, "repos/agency"), { recursive: true })
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
afterEach(async () => cleanupTempDir(root))
|
|
22
|
-
|
|
23
|
-
test("requires a subcommand", async () => {
|
|
24
|
-
await expect(
|
|
25
|
-
runTestEffect(repo({ args: [], silent: true })),
|
|
26
|
-
).rejects.toThrow(
|
|
27
|
-
"Available subcommands: setup, add, link, materialize, list",
|
|
28
|
-
)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test("requires add arguments", async () => {
|
|
32
|
-
await expect(
|
|
33
|
-
runTestEffect(
|
|
34
|
-
repo({ subcommand: "add", args: ["agency"], silent: true }),
|
|
35
|
-
),
|
|
36
|
-
).rejects.toThrow("Usage: agency repo add")
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
test("requires a materialize alias", async () => {
|
|
40
|
-
await expect(
|
|
41
|
-
runTestEffect(
|
|
42
|
-
repo({ subcommand: "materialize", args: [], silent: true }),
|
|
43
|
-
),
|
|
44
|
-
).rejects.toThrow("Usage: agency repo materialize <alias>")
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test("lists repository metadata as JSON", async () => {
|
|
48
|
-
const logs = await captureLogs(() =>
|
|
49
|
-
runTestEffect(
|
|
50
|
-
repo({ subcommand: "list", args: [], cwd: root, json: true }),
|
|
51
|
-
),
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
expect(JSON.parse(logs[0]!)).toEqual([
|
|
55
|
-
{
|
|
56
|
-
alias: "agency",
|
|
57
|
-
path: join(root, "repos/agency"),
|
|
58
|
-
kind: "repository",
|
|
59
|
-
remote: null,
|
|
60
|
-
declaredRemote: null,
|
|
61
|
-
target: null,
|
|
62
|
-
states: ["materialized", "invalid"],
|
|
63
|
-
},
|
|
64
|
-
])
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test("shows a repository by alias as JSON", async () => {
|
|
68
|
-
const logs = await captureLogs(() =>
|
|
69
|
-
runTestEffect(
|
|
70
|
-
repo({
|
|
71
|
-
subcommand: "show",
|
|
72
|
-
args: ["agency"],
|
|
73
|
-
cwd: root,
|
|
74
|
-
json: true,
|
|
75
|
-
}),
|
|
76
|
-
),
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
expect(JSON.parse(logs[0]!).alias).toBe("agency")
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
test("outputs a linked repository as JSON", async () => {
|
|
83
|
-
const target = join(root, "source")
|
|
84
|
-
await mkdir(target)
|
|
85
|
-
const git = Bun.spawn(["git", "init", target], {
|
|
86
|
-
stdout: "ignore",
|
|
87
|
-
stderr: "ignore",
|
|
88
|
-
})
|
|
89
|
-
expect(await git.exited).toBe(0)
|
|
90
|
-
const remote = Bun.spawn(
|
|
91
|
-
[
|
|
92
|
-
"git",
|
|
93
|
-
"-C",
|
|
94
|
-
target,
|
|
95
|
-
"remote",
|
|
96
|
-
"add",
|
|
97
|
-
"origin",
|
|
98
|
-
"https://example.com/linked.git",
|
|
99
|
-
],
|
|
100
|
-
{ stdout: "ignore", stderr: "ignore" },
|
|
101
|
-
)
|
|
102
|
-
expect(await remote.exited).toBe(0)
|
|
103
|
-
|
|
104
|
-
const logs = await captureLogs(() =>
|
|
105
|
-
runTestEffect(
|
|
106
|
-
repo({
|
|
107
|
-
subcommand: "link",
|
|
108
|
-
args: ["linked", target],
|
|
109
|
-
cwd: root,
|
|
110
|
-
json: true,
|
|
111
|
-
}),
|
|
112
|
-
),
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
expect(JSON.parse(logs[0]!)).toEqual({
|
|
116
|
-
alias: "linked",
|
|
117
|
-
path: join(root, "repos/linked"),
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
test("unlinks a linked repository by alias", async () => {
|
|
122
|
-
const target = join(root, "unlink-source")
|
|
123
|
-
await mkdir(target)
|
|
124
|
-
const git = Bun.spawn(["git", "init", target], {
|
|
125
|
-
stdout: "ignore",
|
|
126
|
-
stderr: "ignore",
|
|
127
|
-
})
|
|
128
|
-
expect(await git.exited).toBe(0)
|
|
129
|
-
const remote = Bun.spawn(
|
|
130
|
-
[
|
|
131
|
-
"git",
|
|
132
|
-
"-C",
|
|
133
|
-
target,
|
|
134
|
-
"remote",
|
|
135
|
-
"add",
|
|
136
|
-
"origin",
|
|
137
|
-
"https://example.com/unlink.git",
|
|
138
|
-
],
|
|
139
|
-
{ stdout: "ignore", stderr: "ignore" },
|
|
140
|
-
)
|
|
141
|
-
expect(await remote.exited).toBe(0)
|
|
142
|
-
await runTestEffect(
|
|
143
|
-
repo({
|
|
144
|
-
subcommand: "link",
|
|
145
|
-
args: ["linked", target],
|
|
146
|
-
cwd: root,
|
|
147
|
-
silent: true,
|
|
148
|
-
}),
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
await runTestEffect(
|
|
152
|
-
repo({
|
|
153
|
-
subcommand: "unlink",
|
|
154
|
-
args: ["linked"],
|
|
155
|
-
cwd: root,
|
|
156
|
-
silent: true,
|
|
157
|
-
}),
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
expect(await Bun.file(join(target, ".git/HEAD")).exists()).toBe(true)
|
|
161
|
-
expect(await Bun.file(join(root, "repos/linked")).exists()).toBe(false)
|
|
162
|
-
const logs = await captureLogs(() =>
|
|
163
|
-
runTestEffect(
|
|
164
|
-
repo({ subcommand: "list", args: [], cwd: root, json: true }),
|
|
165
|
-
),
|
|
166
|
-
)
|
|
167
|
-
expect(
|
|
168
|
-
JSON.parse(logs[0]!).map(({ alias }: { alias: string }) => alias),
|
|
169
|
-
).toEqual(["agency", "linked"])
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
test("reports setup plans as JSON without mutating", async () => {
|
|
173
|
-
await Bun.write(
|
|
174
|
-
join(root, "agency.json"),
|
|
175
|
-
JSON.stringify({
|
|
176
|
-
version: 2,
|
|
177
|
-
repositories: {
|
|
178
|
-
missing: { remote: "https://example.com/missing.git" },
|
|
179
|
-
},
|
|
180
|
-
}),
|
|
181
|
-
)
|
|
182
|
-
const logs = await captureLogs(() =>
|
|
183
|
-
runTestEffect(
|
|
184
|
-
repo({ subcommand: "setup", args: [], cwd: root, json: true }),
|
|
185
|
-
),
|
|
186
|
-
)
|
|
187
|
-
const result = JSON.parse(logs[0]!)
|
|
188
|
-
expect(result.mode).toBe("dry-run")
|
|
189
|
-
expect(result.actions).toEqual([
|
|
190
|
-
{
|
|
191
|
-
kind: "materialize",
|
|
192
|
-
alias: "missing",
|
|
193
|
-
remote: "https://example.com/missing.git",
|
|
194
|
-
status: "planned",
|
|
195
|
-
},
|
|
196
|
-
])
|
|
197
|
-
expect(await Bun.file(join(root, "repos/missing")).exists()).toBe(false)
|
|
198
|
-
})
|
|
199
|
-
})
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
|
|
2
|
-
import { join } from "node:path"
|
|
3
|
-
import {
|
|
4
|
-
captureLogs,
|
|
5
|
-
cleanupTempDir,
|
|
6
|
-
createTempDir,
|
|
7
|
-
runTestEffect,
|
|
8
|
-
} from "../test-utils"
|
|
9
|
-
import { archive } from "./archive"
|
|
10
|
-
import { restore } from "./restore"
|
|
11
|
-
import { task } from "./task"
|
|
12
|
-
|
|
13
|
-
describe("restore command", () => {
|
|
14
|
-
let root: string
|
|
15
|
-
|
|
16
|
-
beforeEach(async () => {
|
|
17
|
-
root = await createTempDir()
|
|
18
|
-
await Bun.write(join(root, "agency.json"), '{"version":2}\n')
|
|
19
|
-
const initialized = Bun.spawnSync([
|
|
20
|
-
"git",
|
|
21
|
-
"init",
|
|
22
|
-
"--bare",
|
|
23
|
-
join(root, "repos/agency"),
|
|
24
|
-
])
|
|
25
|
-
if (initialized.exitCode !== 0)
|
|
26
|
-
throw new Error(new TextDecoder().decode(initialized.stderr))
|
|
27
|
-
await runTestEffect(
|
|
28
|
-
task({
|
|
29
|
-
subcommand: "create",
|
|
30
|
-
args: ["example"],
|
|
31
|
-
repo: "agency",
|
|
32
|
-
branch: "task/example",
|
|
33
|
-
base: "main",
|
|
34
|
-
cwd: root,
|
|
35
|
-
silent: true,
|
|
36
|
-
}),
|
|
37
|
-
)
|
|
38
|
-
await runTestEffect(
|
|
39
|
-
task({
|
|
40
|
-
subcommand: "status",
|
|
41
|
-
args: ["example", "dropped"],
|
|
42
|
-
cwd: root,
|
|
43
|
-
silent: true,
|
|
44
|
-
}),
|
|
45
|
-
)
|
|
46
|
-
await runTestEffect(
|
|
47
|
-
archive({ type: "task", args: ["example"], cwd: root, silent: true }),
|
|
48
|
-
)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
afterEach(async () => cleanupTempDir(root))
|
|
52
|
-
|
|
53
|
-
test("dry-runs then restores an archived task", async () => {
|
|
54
|
-
const preview = await captureLogs(() =>
|
|
55
|
-
runTestEffect(
|
|
56
|
-
restore({
|
|
57
|
-
type: "task",
|
|
58
|
-
args: ["example"],
|
|
59
|
-
cwd: root,
|
|
60
|
-
dryRun: true,
|
|
61
|
-
}),
|
|
62
|
-
),
|
|
63
|
-
)
|
|
64
|
-
expect(preview[0]).toContain("Would restore task 'example'")
|
|
65
|
-
expect(await Bun.file(join(root, "tasks/example/TASK.md")).exists()).toBe(
|
|
66
|
-
false,
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
const logs = await captureLogs(() =>
|
|
70
|
-
runTestEffect(
|
|
71
|
-
restore({ type: "task", args: ["example"], cwd: root, json: true }),
|
|
72
|
-
),
|
|
73
|
-
)
|
|
74
|
-
expect(JSON.parse(logs[0]!)).toMatchObject({
|
|
75
|
-
operation: "restore",
|
|
76
|
-
kind: "task",
|
|
77
|
-
id: "example",
|
|
78
|
-
dryRun: false,
|
|
79
|
-
})
|
|
80
|
-
expect(await Bun.file(join(root, "tasks/example/TASK.md")).exists()).toBe(
|
|
81
|
-
true,
|
|
82
|
-
)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test("lists and shows archived work", async () => {
|
|
86
|
-
const listed = await captureLogs(() =>
|
|
87
|
-
runTestEffect(
|
|
88
|
-
archive({
|
|
89
|
-
type: "list",
|
|
90
|
-
args: [],
|
|
91
|
-
kinds: ["task"],
|
|
92
|
-
repositories: ["agency"],
|
|
93
|
-
cwd: root,
|
|
94
|
-
}),
|
|
95
|
-
),
|
|
96
|
-
)
|
|
97
|
-
expect(listed).toEqual(["task\texample"])
|
|
98
|
-
|
|
99
|
-
const shown = await captureLogs(() =>
|
|
100
|
-
runTestEffect(
|
|
101
|
-
archive({ type: "show", args: ["task", "example"], cwd: root }),
|
|
102
|
-
),
|
|
103
|
-
)
|
|
104
|
-
expect(shown[0]).toContain("# Example")
|
|
105
|
-
})
|
|
106
|
-
})
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
|
|
2
|
-
import { mkdir } from "node:fs/promises"
|
|
3
|
-
import { join } from "node:path"
|
|
4
|
-
import {
|
|
5
|
-
captureLogs,
|
|
6
|
-
cleanupTempDir,
|
|
7
|
-
createTempDir,
|
|
8
|
-
runTestEffect,
|
|
9
|
-
} from "../test-utils"
|
|
10
|
-
import { status } from "./status"
|
|
11
|
-
import { task } from "./task"
|
|
12
|
-
|
|
13
|
-
describe("status command", () => {
|
|
14
|
-
let root: string
|
|
15
|
-
|
|
16
|
-
beforeEach(async () => {
|
|
17
|
-
root = await createTempDir()
|
|
18
|
-
await Bun.write(join(root, "agency.json"), '{"version":2}\n')
|
|
19
|
-
await mkdir(join(root, "repos/agency"), { recursive: true })
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
afterEach(async () => cleanupTempDir(root))
|
|
23
|
-
|
|
24
|
-
test("outputs status and repository metadata as JSON", async () => {
|
|
25
|
-
const logs = await captureLogs(() =>
|
|
26
|
-
runTestEffect(status({ cwd: root, json: true })),
|
|
27
|
-
)
|
|
28
|
-
const output = JSON.parse(logs[0]!)
|
|
29
|
-
|
|
30
|
-
expect(output).toMatchObject({
|
|
31
|
-
root,
|
|
32
|
-
issues: [],
|
|
33
|
-
epicCount: 0,
|
|
34
|
-
taskCount: 0,
|
|
35
|
-
phaseCount: 0,
|
|
36
|
-
valid: true,
|
|
37
|
-
})
|
|
38
|
-
expect(output.repositories).toEqual([
|
|
39
|
-
{
|
|
40
|
-
alias: "agency",
|
|
41
|
-
path: join(root, "repos/agency"),
|
|
42
|
-
kind: "repository",
|
|
43
|
-
remote: null,
|
|
44
|
-
declaredRemote: null,
|
|
45
|
-
target: null,
|
|
46
|
-
states: ["materialized", "invalid"],
|
|
47
|
-
},
|
|
48
|
-
])
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test("renders and filters the execution dashboard", async () => {
|
|
52
|
-
await runTestEffect(
|
|
53
|
-
task({
|
|
54
|
-
subcommand: "create",
|
|
55
|
-
args: ["example"],
|
|
56
|
-
repo: "agency",
|
|
57
|
-
branch: "feat/example",
|
|
58
|
-
base: "main",
|
|
59
|
-
cwd: root,
|
|
60
|
-
silent: true,
|
|
61
|
-
}),
|
|
62
|
-
)
|
|
63
|
-
await runTestEffect(
|
|
64
|
-
task({
|
|
65
|
-
subcommand: "create",
|
|
66
|
-
args: ["finished"],
|
|
67
|
-
repo: "agency",
|
|
68
|
-
branch: "feat/finished",
|
|
69
|
-
base: "main",
|
|
70
|
-
cwd: root,
|
|
71
|
-
silent: true,
|
|
72
|
-
}),
|
|
73
|
-
)
|
|
74
|
-
await runTestEffect(
|
|
75
|
-
task({
|
|
76
|
-
subcommand: "status",
|
|
77
|
-
args: ["finished", "dropped"],
|
|
78
|
-
cwd: root,
|
|
79
|
-
silent: true,
|
|
80
|
-
}),
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
const logs = await captureLogs(() =>
|
|
84
|
-
runTestEffect(
|
|
85
|
-
status({ cwd: root, repositories: ["agency"], ready: true, pr: false }),
|
|
86
|
-
),
|
|
87
|
-
)
|
|
88
|
-
expect(logs).toContain("Repositories: 1")
|
|
89
|
-
expect(logs.at(-1)).toContain(
|
|
90
|
-
"KIND WORK PARENT STATUS READINESS REPOSITORIES BRANCH",
|
|
91
|
-
)
|
|
92
|
-
expect(logs.at(-1)).toContain(
|
|
93
|
-
"task example - open ready agency feat/example absent absent",
|
|
94
|
-
)
|
|
95
|
-
expect(logs.at(-1)).not.toContain("finished")
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
test("reports validation issues without requiring a decodable graph", async () => {
|
|
99
|
-
await mkdir(join(root, "tasks/broken"), { recursive: true })
|
|
100
|
-
await Bun.write(
|
|
101
|
-
join(root, "tasks/broken/TASK.md"),
|
|
102
|
-
"---\nrepo: agency\nstatus: invalid\n---\n",
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
const logs = await captureLogs(() =>
|
|
106
|
-
runTestEffect(status({ cwd: root, json: true })),
|
|
107
|
-
)
|
|
108
|
-
const output = JSON.parse(logs[0]!)
|
|
109
|
-
expect(output.valid).toBe(false)
|
|
110
|
-
expect(output.issues.length).toBeGreaterThan(0)
|
|
111
|
-
expect(output.work).toEqual([])
|
|
112
|
-
})
|
|
113
|
-
})
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
|
|
2
|
-
import { Effect } from "effect"
|
|
3
|
-
import { chmod, mkdir } from "node:fs/promises"
|
|
4
|
-
import { join } from "node:path"
|
|
5
|
-
import { TaskService } from "../services/TaskService"
|
|
6
|
-
import {
|
|
7
|
-
captureLogs,
|
|
8
|
-
cleanupTempDir,
|
|
9
|
-
createTempDir,
|
|
10
|
-
runTestEffect,
|
|
11
|
-
} from "../test-utils"
|
|
12
|
-
import type { Progress } from "../utils/progress"
|
|
13
|
-
import { sync } from "./sync"
|
|
14
|
-
|
|
15
|
-
const git = async (args: string[], cwd: string) => {
|
|
16
|
-
const process = Bun.spawn(["git", ...args], {
|
|
17
|
-
cwd,
|
|
18
|
-
stdout: "pipe",
|
|
19
|
-
stderr: "pipe",
|
|
20
|
-
})
|
|
21
|
-
await process.exited
|
|
22
|
-
if (process.exitCode !== 0) {
|
|
23
|
-
throw new Error(await new Response(process.stderr).text())
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
describe("sync command", () => {
|
|
28
|
-
let root: string
|
|
29
|
-
|
|
30
|
-
beforeEach(async () => {
|
|
31
|
-
root = await createTempDir()
|
|
32
|
-
const source = join(root, "source")
|
|
33
|
-
await mkdir(source)
|
|
34
|
-
await git(["init", "--initial-branch=main"], source)
|
|
35
|
-
await git(["config", "user.email", "test@example.com"], source)
|
|
36
|
-
await git(["config", "user.name", "Test"], source)
|
|
37
|
-
await Bun.write(join(source, "README.md"), "example\n")
|
|
38
|
-
await git(["add", "README.md"], source)
|
|
39
|
-
await git(["-c", "commit.gpgsign=false", "commit", "-m", "initial"], source)
|
|
40
|
-
await mkdir(join(root, "repos"))
|
|
41
|
-
await git(["clone", "--bare", source, join(root, "repos/agency")], root)
|
|
42
|
-
await Bun.write(join(root, "agency.json"), '{"version":2}\n')
|
|
43
|
-
await runTestEffect(
|
|
44
|
-
TaskService.pipe(
|
|
45
|
-
Effect.flatMap((service) =>
|
|
46
|
-
service.create(
|
|
47
|
-
{
|
|
48
|
-
id: "example",
|
|
49
|
-
ticketUrl: null,
|
|
50
|
-
repo: "agency",
|
|
51
|
-
branch: "task/example",
|
|
52
|
-
base: "main",
|
|
53
|
-
},
|
|
54
|
-
root,
|
|
55
|
-
),
|
|
56
|
-
),
|
|
57
|
-
),
|
|
58
|
-
)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
afterEach(async () => cleanupTempDir(root))
|
|
62
|
-
|
|
63
|
-
test("applies safe reconciliation by default", async () => {
|
|
64
|
-
const logs = await captureLogs(() => runTestEffect(sync({ cwd: root })))
|
|
65
|
-
|
|
66
|
-
expect(
|
|
67
|
-
await Bun.file(join(root, "tasks/example/code/agency/README.md")).text(),
|
|
68
|
-
).toBe("example\n")
|
|
69
|
-
expect(logs).toContainEqual(
|
|
70
|
-
expect.stringContaining("Applied materialize-workspace 'task:example'"),
|
|
71
|
-
)
|
|
72
|
-
expect(() => JSON.parse(logs.join("\n"))).toThrow()
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
test("keeps explicit dry-run observational", async () => {
|
|
76
|
-
await runTestEffect(sync({ cwd: root, dryRun: true, silent: true }))
|
|
77
|
-
|
|
78
|
-
expect(
|
|
79
|
-
await Bun.file(
|
|
80
|
-
join(root, "tasks/example/code/agency/README.md"),
|
|
81
|
-
).exists(),
|
|
82
|
-
).toBe(false)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test("scopes reconciliation to one task", async () => {
|
|
86
|
-
await runTestEffect(
|
|
87
|
-
TaskService.pipe(
|
|
88
|
-
Effect.flatMap((service) =>
|
|
89
|
-
service.create(
|
|
90
|
-
{
|
|
91
|
-
id: "second",
|
|
92
|
-
ticketUrl: null,
|
|
93
|
-
repo: "agency",
|
|
94
|
-
branch: "task/second",
|
|
95
|
-
base: "main",
|
|
96
|
-
},
|
|
97
|
-
root,
|
|
98
|
-
),
|
|
99
|
-
),
|
|
100
|
-
),
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
const logs = await captureLogs(() =>
|
|
104
|
-
runTestEffect(sync({ cwd: root, taskId: "example", json: true })),
|
|
105
|
-
)
|
|
106
|
-
const result = JSON.parse(logs[0]!)
|
|
107
|
-
expect(result.executions.map((execution: any) => execution.target)).toEqual(
|
|
108
|
-
["task:example"],
|
|
109
|
-
)
|
|
110
|
-
expect(
|
|
111
|
-
await Bun.file(
|
|
112
|
-
join(root, "tasks/example/code/agency/README.md"),
|
|
113
|
-
).exists(),
|
|
114
|
-
).toBe(true)
|
|
115
|
-
expect(
|
|
116
|
-
await Bun.file(join(root, "tasks/second/code/agency/README.md")).exists(),
|
|
117
|
-
).toBe(false)
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
test("preserves structured output behind --json", async () => {
|
|
121
|
-
const logs = await captureLogs(() =>
|
|
122
|
-
runTestEffect(sync({ cwd: root, dryRun: true, json: true })),
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
expect(logs).toHaveLength(1)
|
|
126
|
-
expect(JSON.parse(logs[0]!)).toMatchObject({
|
|
127
|
-
mode: "dry-run",
|
|
128
|
-
changes: [
|
|
129
|
-
expect.objectContaining({
|
|
130
|
-
kind: "materialize-workspace",
|
|
131
|
-
status: "planned",
|
|
132
|
-
}),
|
|
133
|
-
],
|
|
134
|
-
})
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
test("groups repeated human-readable warnings by affected target", async () => {
|
|
138
|
-
await runTestEffect(
|
|
139
|
-
TaskService.pipe(
|
|
140
|
-
Effect.flatMap((service) =>
|
|
141
|
-
service.create(
|
|
142
|
-
{
|
|
143
|
-
id: "second",
|
|
144
|
-
ticketUrl: null,
|
|
145
|
-
repo: "agency",
|
|
146
|
-
branch: "task/second",
|
|
147
|
-
base: "main",
|
|
148
|
-
},
|
|
149
|
-
root,
|
|
150
|
-
),
|
|
151
|
-
),
|
|
152
|
-
),
|
|
153
|
-
)
|
|
154
|
-
const originalPath = process.env.PATH
|
|
155
|
-
const bin = join(root, "bin")
|
|
156
|
-
await mkdir(bin)
|
|
157
|
-
await Bun.write(
|
|
158
|
-
join(bin, "gh"),
|
|
159
|
-
'#!/bin/sh\necho "provider unavailable" >&2\nexit 1\n',
|
|
160
|
-
)
|
|
161
|
-
await chmod(join(bin, "gh"), 0o755)
|
|
162
|
-
process.env.PATH = `${bin}:${originalPath}`
|
|
163
|
-
try {
|
|
164
|
-
const logs = await captureLogs(() =>
|
|
165
|
-
runTestEffect(sync({ cwd: root, dryRun: true })),
|
|
166
|
-
)
|
|
167
|
-
expect(
|
|
168
|
-
logs.filter((line) => line.includes("provider unavailable")),
|
|
169
|
-
).toEqual(["Warning 'task:example', 'task:second': provider unavailable"])
|
|
170
|
-
} finally {
|
|
171
|
-
process.env.PATH = originalPath
|
|
172
|
-
}
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
test("reports human-readable progress without polluting JSON output", async () => {
|
|
176
|
-
const updates: string[] = []
|
|
177
|
-
const progress: Progress = {
|
|
178
|
-
start: (message) => updates.push(`start:${message}`),
|
|
179
|
-
succeed: (message) => updates.push(`succeed:${message}`),
|
|
180
|
-
fail: (message) => updates.push(`fail:${message}`),
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
await captureLogs(() =>
|
|
184
|
-
runTestEffect(sync({ cwd: root, silent: false }, progress)),
|
|
185
|
-
)
|
|
186
|
-
expect(updates).toEqual([
|
|
187
|
-
"start:Validating workbase",
|
|
188
|
-
"start:Inspected 1 repositories",
|
|
189
|
-
"start:Queried pull requests 1/1 (task:example)",
|
|
190
|
-
"start:Reconciled execution units 1/1 (task:example)",
|
|
191
|
-
"succeed:Synchronized 1 execution units",
|
|
192
|
-
])
|
|
193
|
-
|
|
194
|
-
updates.length = 0
|
|
195
|
-
await captureLogs(() =>
|
|
196
|
-
runTestEffect(sync({ cwd: root, dryRun: true, json: true }, progress)),
|
|
197
|
-
)
|
|
198
|
-
expect(updates).toEqual([])
|
|
199
|
-
})
|
|
200
|
-
})
|