@markjaquith/agency 0.5.0 → 0.6.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 +15 -4
- package/cli.ts +35 -22
- package/package.json +5 -1
- package/src/commands/emit.test.ts +1 -1
- package/src/commands/emit.ts +16 -5
- package/src/commands/push.test.ts +1 -1
- package/src/commands/push.ts +8 -5
- package/src/commands/rebase.test.ts +521 -0
- package/src/commands/rebase.ts +243 -0
- package/src/commands/save.test.ts +8 -8
- package/src/commands/task-branching.test.ts +312 -13
- package/src/commands/task-continue.test.ts +311 -0
- package/src/commands/task-edit.test.ts +4 -4
- package/src/commands/task-main.test.ts +57 -32
- package/src/commands/task.ts +371 -79
- package/src/services/AgencyMetadataService.ts +9 -1
- package/src/services/GitService.ts +61 -1
- package/src/utils/glob.test.ts +154 -0
- package/src/utils/glob.ts +78 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { test, expect, describe, beforeEach, afterEach } from "bun:test"
|
|
2
|
+
import { join } from "path"
|
|
3
|
+
import { task } from "./task"
|
|
4
|
+
import {
|
|
5
|
+
createTempDir,
|
|
6
|
+
cleanupTempDir,
|
|
7
|
+
initGitRepo,
|
|
8
|
+
initAgency,
|
|
9
|
+
fileExists,
|
|
10
|
+
readFile,
|
|
11
|
+
runTestEffect,
|
|
12
|
+
getCurrentBranch,
|
|
13
|
+
} from "../test-utils"
|
|
14
|
+
|
|
15
|
+
describe("task --continue", () => {
|
|
16
|
+
let tempDir: string
|
|
17
|
+
let originalCwd: string
|
|
18
|
+
let originalConfigDir: string | undefined
|
|
19
|
+
|
|
20
|
+
beforeEach(async () => {
|
|
21
|
+
tempDir = await createTempDir()
|
|
22
|
+
originalCwd = process.cwd()
|
|
23
|
+
originalConfigDir = process.env.AGENCY_CONFIG_DIR
|
|
24
|
+
process.env.AGENCY_CONFIG_DIR = await createTempDir()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
afterEach(async () => {
|
|
28
|
+
process.chdir(originalCwd)
|
|
29
|
+
if (originalConfigDir !== undefined) {
|
|
30
|
+
process.env.AGENCY_CONFIG_DIR = originalConfigDir
|
|
31
|
+
} else {
|
|
32
|
+
delete process.env.AGENCY_CONFIG_DIR
|
|
33
|
+
}
|
|
34
|
+
if (
|
|
35
|
+
process.env.AGENCY_CONFIG_DIR &&
|
|
36
|
+
process.env.AGENCY_CONFIG_DIR !== originalConfigDir
|
|
37
|
+
) {
|
|
38
|
+
await cleanupTempDir(process.env.AGENCY_CONFIG_DIR)
|
|
39
|
+
}
|
|
40
|
+
await cleanupTempDir(tempDir)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test("fails when not on a branch with agency.json", async () => {
|
|
44
|
+
await initGitRepo(tempDir)
|
|
45
|
+
process.chdir(tempDir)
|
|
46
|
+
|
|
47
|
+
await initAgency(tempDir, "test")
|
|
48
|
+
|
|
49
|
+
// Try to continue without agency files
|
|
50
|
+
await expect(
|
|
51
|
+
runTestEffect(
|
|
52
|
+
task({ silent: true, continue: true, emit: "new-feature" }),
|
|
53
|
+
),
|
|
54
|
+
).rejects.toThrow("No agency.json found")
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test("fails when branch name not provided in silent mode", async () => {
|
|
58
|
+
await initGitRepo(tempDir)
|
|
59
|
+
process.chdir(tempDir)
|
|
60
|
+
|
|
61
|
+
await initAgency(tempDir, "test")
|
|
62
|
+
|
|
63
|
+
// First create a task branch with agency files
|
|
64
|
+
await runTestEffect(task({ silent: true, emit: "original-feature" }))
|
|
65
|
+
|
|
66
|
+
// Try to continue without branch name
|
|
67
|
+
await expect(
|
|
68
|
+
runTestEffect(task({ silent: true, continue: true })),
|
|
69
|
+
).rejects.toThrow("Branch name is required")
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test("creates new branch with agency files from current branch", async () => {
|
|
73
|
+
await initGitRepo(tempDir)
|
|
74
|
+
process.chdir(tempDir)
|
|
75
|
+
|
|
76
|
+
await initAgency(tempDir, "test")
|
|
77
|
+
|
|
78
|
+
// Create a task branch with agency files
|
|
79
|
+
await runTestEffect(
|
|
80
|
+
task({ silent: true, emit: "original-feature", task: "Original task" }),
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
// Verify we're on the source branch
|
|
84
|
+
const originalBranch = await getCurrentBranch(tempDir)
|
|
85
|
+
expect(originalBranch).toBe("agency/original-feature")
|
|
86
|
+
|
|
87
|
+
// Read the original TASK.md
|
|
88
|
+
const originalTaskContent = await readFile(join(tempDir, "TASK.md"))
|
|
89
|
+
expect(originalTaskContent).toContain("Original task")
|
|
90
|
+
|
|
91
|
+
// Now continue to a new branch
|
|
92
|
+
await runTestEffect(
|
|
93
|
+
task({
|
|
94
|
+
silent: true,
|
|
95
|
+
continue: true,
|
|
96
|
+
emit: "continued-feature",
|
|
97
|
+
}),
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
// Verify we're on the new branch
|
|
101
|
+
const newBranch = await getCurrentBranch(tempDir)
|
|
102
|
+
expect(newBranch).toBe("agency/continued-feature")
|
|
103
|
+
|
|
104
|
+
// Verify agency files were copied
|
|
105
|
+
expect(await fileExists(join(tempDir, "agency.json"))).toBe(true)
|
|
106
|
+
expect(await fileExists(join(tempDir, "TASK.md"))).toBe(true)
|
|
107
|
+
expect(await fileExists(join(tempDir, "AGENCY.md"))).toBe(true)
|
|
108
|
+
|
|
109
|
+
// Verify TASK.md content was preserved
|
|
110
|
+
const newTaskContent = await readFile(join(tempDir, "TASK.md"))
|
|
111
|
+
expect(newTaskContent).toContain("Original task")
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
test("updates emitBranch in agency.json", async () => {
|
|
115
|
+
await initGitRepo(tempDir)
|
|
116
|
+
process.chdir(tempDir)
|
|
117
|
+
|
|
118
|
+
await initAgency(tempDir, "test")
|
|
119
|
+
|
|
120
|
+
// Create a task branch
|
|
121
|
+
await runTestEffect(task({ silent: true, emit: "feature-v1" }))
|
|
122
|
+
|
|
123
|
+
// Read original agency.json
|
|
124
|
+
const originalAgencyJson = JSON.parse(
|
|
125
|
+
await readFile(join(tempDir, "agency.json")),
|
|
126
|
+
)
|
|
127
|
+
expect(originalAgencyJson.emitBranch).toBe("feature-v1")
|
|
128
|
+
|
|
129
|
+
// Continue to new branch
|
|
130
|
+
await runTestEffect(
|
|
131
|
+
task({ silent: true, continue: true, emit: "feature-v2" }),
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
// Read new agency.json
|
|
135
|
+
const newAgencyJson = JSON.parse(
|
|
136
|
+
await readFile(join(tempDir, "agency.json")),
|
|
137
|
+
)
|
|
138
|
+
expect(newAgencyJson.emitBranch).toBe("feature-v2")
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
test("fails when new branch already exists", async () => {
|
|
142
|
+
await initGitRepo(tempDir)
|
|
143
|
+
process.chdir(tempDir)
|
|
144
|
+
|
|
145
|
+
await initAgency(tempDir, "test")
|
|
146
|
+
|
|
147
|
+
// Create a task branch
|
|
148
|
+
await runTestEffect(task({ silent: true, emit: "feature-v1" }))
|
|
149
|
+
|
|
150
|
+
// Create another branch that would conflict
|
|
151
|
+
await Bun.spawn(["git", "branch", "agency/feature-v2"], {
|
|
152
|
+
cwd: tempDir,
|
|
153
|
+
stdout: "pipe",
|
|
154
|
+
stderr: "pipe",
|
|
155
|
+
}).exited
|
|
156
|
+
|
|
157
|
+
// Try to continue to the existing branch name
|
|
158
|
+
await expect(
|
|
159
|
+
runTestEffect(task({ silent: true, continue: true, emit: "feature-v2" })),
|
|
160
|
+
).rejects.toThrow("already exists")
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
test("copies injected files from metadata", async () => {
|
|
164
|
+
await initGitRepo(tempDir)
|
|
165
|
+
process.chdir(tempDir)
|
|
166
|
+
|
|
167
|
+
await initAgency(tempDir, "test")
|
|
168
|
+
|
|
169
|
+
// Create a task branch
|
|
170
|
+
await runTestEffect(task({ silent: true, emit: "feature-v1" }))
|
|
171
|
+
|
|
172
|
+
// Verify opencode.json exists (it's in injectedFiles)
|
|
173
|
+
expect(await fileExists(join(tempDir, "opencode.json"))).toBe(true)
|
|
174
|
+
|
|
175
|
+
// Continue to new branch
|
|
176
|
+
await runTestEffect(
|
|
177
|
+
task({ silent: true, continue: true, emit: "feature-v2" }),
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
// Verify opencode.json was copied
|
|
181
|
+
expect(await fileExists(join(tempDir, "opencode.json"))).toBe(true)
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
test("new branch is created from main", async () => {
|
|
185
|
+
await initGitRepo(tempDir)
|
|
186
|
+
process.chdir(tempDir)
|
|
187
|
+
|
|
188
|
+
await initAgency(tempDir, "test")
|
|
189
|
+
|
|
190
|
+
// Create a task branch and add a file
|
|
191
|
+
await runTestEffect(task({ silent: true, emit: "feature-v1" }))
|
|
192
|
+
|
|
193
|
+
// Add a file that's NOT in agency files
|
|
194
|
+
await Bun.write(join(tempDir, "feature-specific.txt"), "feature content")
|
|
195
|
+
await Bun.spawn(["git", "add", "feature-specific.txt"], {
|
|
196
|
+
cwd: tempDir,
|
|
197
|
+
stdout: "pipe",
|
|
198
|
+
stderr: "pipe",
|
|
199
|
+
}).exited
|
|
200
|
+
await Bun.spawn(
|
|
201
|
+
["git", "commit", "--no-verify", "-m", "Add feature file"],
|
|
202
|
+
{
|
|
203
|
+
cwd: tempDir,
|
|
204
|
+
stdout: "pipe",
|
|
205
|
+
stderr: "pipe",
|
|
206
|
+
},
|
|
207
|
+
).exited
|
|
208
|
+
|
|
209
|
+
// Continue to new branch
|
|
210
|
+
await runTestEffect(
|
|
211
|
+
task({ silent: true, continue: true, emit: "feature-v2" }),
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
// The new branch should be based on main, not on the old feature branch
|
|
215
|
+
// So feature-specific.txt should NOT exist
|
|
216
|
+
expect(await fileExists(join(tempDir, "feature-specific.txt"))).toBe(false)
|
|
217
|
+
|
|
218
|
+
// But agency files should exist
|
|
219
|
+
expect(await fileExists(join(tempDir, "agency.json"))).toBe(true)
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
test("supports --from flag to specify base branch", async () => {
|
|
223
|
+
await initGitRepo(tempDir)
|
|
224
|
+
process.chdir(tempDir)
|
|
225
|
+
|
|
226
|
+
// Create a develop branch
|
|
227
|
+
await Bun.spawn(["git", "checkout", "-b", "develop"], {
|
|
228
|
+
cwd: tempDir,
|
|
229
|
+
stdout: "pipe",
|
|
230
|
+
stderr: "pipe",
|
|
231
|
+
}).exited
|
|
232
|
+
|
|
233
|
+
// Add a file to develop
|
|
234
|
+
await Bun.write(join(tempDir, "develop-feature.txt"), "develop content")
|
|
235
|
+
await Bun.spawn(["git", "add", "develop-feature.txt"], {
|
|
236
|
+
cwd: tempDir,
|
|
237
|
+
stdout: "pipe",
|
|
238
|
+
stderr: "pipe",
|
|
239
|
+
}).exited
|
|
240
|
+
await Bun.spawn(
|
|
241
|
+
["git", "commit", "--no-verify", "-m", "Add develop file"],
|
|
242
|
+
{
|
|
243
|
+
cwd: tempDir,
|
|
244
|
+
stdout: "pipe",
|
|
245
|
+
stderr: "pipe",
|
|
246
|
+
},
|
|
247
|
+
).exited
|
|
248
|
+
|
|
249
|
+
// Go back to main
|
|
250
|
+
await Bun.spawn(["git", "checkout", "main"], {
|
|
251
|
+
cwd: tempDir,
|
|
252
|
+
stdout: "pipe",
|
|
253
|
+
stderr: "pipe",
|
|
254
|
+
}).exited
|
|
255
|
+
|
|
256
|
+
await initAgency(tempDir, "test")
|
|
257
|
+
|
|
258
|
+
// Create a task branch
|
|
259
|
+
await runTestEffect(task({ silent: true, emit: "feature-v1" }))
|
|
260
|
+
|
|
261
|
+
// Continue to new branch from develop
|
|
262
|
+
await runTestEffect(
|
|
263
|
+
task({
|
|
264
|
+
silent: true,
|
|
265
|
+
continue: true,
|
|
266
|
+
emit: "feature-v2",
|
|
267
|
+
from: "develop",
|
|
268
|
+
}),
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
// The new branch should be based on develop
|
|
272
|
+
// So develop-feature.txt should exist
|
|
273
|
+
expect(await fileExists(join(tempDir, "develop-feature.txt"))).toBe(true)
|
|
274
|
+
|
|
275
|
+
// And agency files should also exist
|
|
276
|
+
expect(await fileExists(join(tempDir, "agency.json"))).toBe(true)
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
test("preserves createdAt in agency.json but updates it", async () => {
|
|
280
|
+
await initGitRepo(tempDir)
|
|
281
|
+
process.chdir(tempDir)
|
|
282
|
+
|
|
283
|
+
await initAgency(tempDir, "test")
|
|
284
|
+
|
|
285
|
+
// Create a task branch
|
|
286
|
+
await runTestEffect(task({ silent: true, emit: "feature-v1" }))
|
|
287
|
+
|
|
288
|
+
// Read original agency.json
|
|
289
|
+
const originalAgencyJson = JSON.parse(
|
|
290
|
+
await readFile(join(tempDir, "agency.json")),
|
|
291
|
+
)
|
|
292
|
+
const originalCreatedAt = originalAgencyJson.createdAt
|
|
293
|
+
|
|
294
|
+
// Wait a bit to ensure time difference
|
|
295
|
+
await new Promise((resolve) => setTimeout(resolve, 10))
|
|
296
|
+
|
|
297
|
+
// Continue to new branch
|
|
298
|
+
await runTestEffect(
|
|
299
|
+
task({ silent: true, continue: true, emit: "feature-v2" }),
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
// Read new agency.json
|
|
303
|
+
const newAgencyJson = JSON.parse(
|
|
304
|
+
await readFile(join(tempDir, "agency.json")),
|
|
305
|
+
)
|
|
306
|
+
const newCreatedAt = newAgencyJson.createdAt
|
|
307
|
+
|
|
308
|
+
// createdAt should be updated (different from original)
|
|
309
|
+
expect(newCreatedAt).not.toBe(originalCreatedAt)
|
|
310
|
+
})
|
|
311
|
+
})
|
|
@@ -70,7 +70,7 @@ describe("edit command", () => {
|
|
|
70
70
|
// Initialize to create TASK.md
|
|
71
71
|
await initAgency(tempDir, "test-task")
|
|
72
72
|
|
|
73
|
-
await runTestEffect(task({ silent: true,
|
|
73
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
74
74
|
|
|
75
75
|
// Use a mock editor that just exits successfully
|
|
76
76
|
process.env.EDITOR = "true" // 'true' is a command that always exits with code 0
|
|
@@ -88,7 +88,7 @@ describe("edit command", () => {
|
|
|
88
88
|
// Initialize to create TASK.md
|
|
89
89
|
await initAgency(tempDir, "test-task")
|
|
90
90
|
|
|
91
|
-
await runTestEffect(task({ silent: true,
|
|
91
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
92
92
|
|
|
93
93
|
// Use 'true' command which exits successfully without doing anything
|
|
94
94
|
process.env.EDITOR = "true"
|
|
@@ -106,7 +106,7 @@ describe("edit command", () => {
|
|
|
106
106
|
// Initialize to create TASK.md
|
|
107
107
|
await initAgency(tempDir, "test-task")
|
|
108
108
|
|
|
109
|
-
await runTestEffect(task({ silent: true,
|
|
109
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
110
110
|
|
|
111
111
|
// Set VISUAL to 'true' and EDITOR to 'false'
|
|
112
112
|
// If VISUAL is used (correct), it should succeed
|
|
@@ -127,7 +127,7 @@ describe("edit command", () => {
|
|
|
127
127
|
// Initialize to create TASK.md
|
|
128
128
|
await initAgency(tempDir, "test-task")
|
|
129
129
|
|
|
130
|
-
await runTestEffect(task({ silent: true,
|
|
130
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
131
131
|
|
|
132
132
|
// Clear VISUAL to ensure EDITOR is used
|
|
133
133
|
delete process.env.VISUAL
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
fileExists,
|
|
11
11
|
readFile,
|
|
12
12
|
runTestEffect,
|
|
13
|
+
runGitCommand,
|
|
14
|
+
getCurrentBranch,
|
|
13
15
|
} from "../test-utils"
|
|
14
16
|
|
|
15
17
|
describe("task command", () => {
|
|
@@ -48,7 +50,7 @@ describe("task command", () => {
|
|
|
48
50
|
|
|
49
51
|
await initAgency(tempDir, "test")
|
|
50
52
|
|
|
51
|
-
await runTestEffect(task({ silent: true,
|
|
53
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
52
54
|
|
|
53
55
|
expect(await fileExists(join(tempDir, "AGENTS.md"))).toBe(true)
|
|
54
56
|
})
|
|
@@ -59,7 +61,7 @@ describe("task command", () => {
|
|
|
59
61
|
|
|
60
62
|
await initAgency(tempDir, "test")
|
|
61
63
|
|
|
62
|
-
await runTestEffect(task({ silent: true,
|
|
64
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
63
65
|
|
|
64
66
|
const content = await readFile(join(tempDir, "AGENTS.md"))
|
|
65
67
|
expect(content).toContain("Repo Instructions")
|
|
@@ -73,7 +75,7 @@ describe("task command", () => {
|
|
|
73
75
|
|
|
74
76
|
await initAgency(tempDir, "test")
|
|
75
77
|
|
|
76
|
-
await runTestEffect(task({ silent: true,
|
|
78
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
77
79
|
|
|
78
80
|
expect(await fileExists(join(tempDir, "AGENTS.md"))).toBe(true)
|
|
79
81
|
expect(await fileExists(join(subdir, "AGENTS.md"))).toBe(false)
|
|
@@ -88,7 +90,7 @@ describe("task command", () => {
|
|
|
88
90
|
|
|
89
91
|
await initAgency(tempDir, "test")
|
|
90
92
|
|
|
91
|
-
await runTestEffect(task({ silent: true,
|
|
93
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
92
94
|
|
|
93
95
|
const content = await readFile(join(tempDir, "AGENTS.md"))
|
|
94
96
|
expect(content).toBe(existingContent)
|
|
@@ -112,7 +114,7 @@ describe("task command", () => {
|
|
|
112
114
|
task({
|
|
113
115
|
path: tempDir,
|
|
114
116
|
silent: true,
|
|
115
|
-
|
|
117
|
+
emit: "test-feature",
|
|
116
118
|
}),
|
|
117
119
|
)
|
|
118
120
|
|
|
@@ -144,7 +146,7 @@ describe("task command", () => {
|
|
|
144
146
|
task({
|
|
145
147
|
path: "..",
|
|
146
148
|
silent: true,
|
|
147
|
-
|
|
149
|
+
emit: "test-feature",
|
|
148
150
|
}),
|
|
149
151
|
)
|
|
150
152
|
|
|
@@ -159,7 +161,7 @@ describe("task command", () => {
|
|
|
159
161
|
|
|
160
162
|
await initAgency(tempDir, "test")
|
|
161
163
|
|
|
162
|
-
await runTestEffect(task({ silent: true,
|
|
164
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
163
165
|
|
|
164
166
|
expect(await fileExists(join(tempDir, "opencode.json"))).toBe(true)
|
|
165
167
|
})
|
|
@@ -170,7 +172,7 @@ describe("task command", () => {
|
|
|
170
172
|
|
|
171
173
|
await initAgency(tempDir, "test")
|
|
172
174
|
|
|
173
|
-
await runTestEffect(task({ silent: true,
|
|
175
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
174
176
|
|
|
175
177
|
const content = await readFile(join(tempDir, "opencode.json"))
|
|
176
178
|
const parsed = JSON.parse(content)
|
|
@@ -193,7 +195,7 @@ describe("task command", () => {
|
|
|
193
195
|
|
|
194
196
|
await initAgency(tempDir, "test")
|
|
195
197
|
|
|
196
|
-
await runTestEffect(task({ silent: true,
|
|
198
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
197
199
|
|
|
198
200
|
const content = await readFile(join(tempDir, "opencode.json"))
|
|
199
201
|
const parsed = JSON.parse(content)
|
|
@@ -228,7 +230,7 @@ describe("task command", () => {
|
|
|
228
230
|
await runTestEffect(
|
|
229
231
|
task({
|
|
230
232
|
silent: true,
|
|
231
|
-
|
|
233
|
+
emit: "test-feature",
|
|
232
234
|
}),
|
|
233
235
|
)
|
|
234
236
|
|
|
@@ -251,7 +253,7 @@ describe("task command", () => {
|
|
|
251
253
|
|
|
252
254
|
await initAgency(tempDir, "test")
|
|
253
255
|
|
|
254
|
-
await runTestEffect(task({ silent: true,
|
|
256
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
255
257
|
|
|
256
258
|
// Should update opencode.jsonc, not create opencode.json
|
|
257
259
|
expect(await fileExists(join(tempDir, "opencode.jsonc"))).toBe(true)
|
|
@@ -291,7 +293,7 @@ describe("task command", () => {
|
|
|
291
293
|
|
|
292
294
|
await initAgency(tempDir, "test")
|
|
293
295
|
|
|
294
|
-
await runTestEffect(task({ silent: true,
|
|
296
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
295
297
|
|
|
296
298
|
// Should merge with opencode.jsonc (not opencode.json)
|
|
297
299
|
const jsoncContent = await readFile(join(tempDir, "opencode.jsonc"))
|
|
@@ -320,7 +322,7 @@ describe("task command", () => {
|
|
|
320
322
|
|
|
321
323
|
await initAgency(tempDir, "test")
|
|
322
324
|
|
|
323
|
-
await runTestEffect(task({ silent: true,
|
|
325
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
324
326
|
|
|
325
327
|
const content = await readFile(join(tempDir, "opencode.jsonc"))
|
|
326
328
|
const parsed = JSON.parse(content)
|
|
@@ -355,7 +357,7 @@ describe("task command", () => {
|
|
|
355
357
|
|
|
356
358
|
await initAgency(tempDir, "test")
|
|
357
359
|
|
|
358
|
-
await runTestEffect(task({ silent: true,
|
|
360
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
359
361
|
|
|
360
362
|
// Should update .opencode/opencode.json, not create root opencode.json
|
|
361
363
|
expect(await fileExists(join(dotOpencodeDir, "opencode.json"))).toBe(true)
|
|
@@ -393,7 +395,7 @@ describe("task command", () => {
|
|
|
393
395
|
|
|
394
396
|
await initAgency(tempDir, "test")
|
|
395
397
|
|
|
396
|
-
await runTestEffect(task({ silent: true,
|
|
398
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
397
399
|
|
|
398
400
|
// Should update .opencode/opencode.jsonc, not create root opencode.json
|
|
399
401
|
expect(await fileExists(join(dotOpencodeDir, "opencode.jsonc"))).toBe(
|
|
@@ -441,7 +443,7 @@ describe("task command", () => {
|
|
|
441
443
|
|
|
442
444
|
await initAgency(tempDir, "test")
|
|
443
445
|
|
|
444
|
-
await runTestEffect(task({ silent: true,
|
|
446
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
445
447
|
|
|
446
448
|
// Should merge with .opencode/opencode.jsonc (not root opencode.json)
|
|
447
449
|
const dotDirContent = await readFile(
|
|
@@ -486,7 +488,7 @@ describe("task command", () => {
|
|
|
486
488
|
|
|
487
489
|
await initAgency(tempDir, "test")
|
|
488
490
|
|
|
489
|
-
await runTestEffect(task({ silent: true,
|
|
491
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
490
492
|
|
|
491
493
|
// Should merge with .opencode/opencode.json (not root opencode.jsonc)
|
|
492
494
|
const dotDirContent = await readFile(
|
|
@@ -520,7 +522,7 @@ describe("task command", () => {
|
|
|
520
522
|
|
|
521
523
|
await initAgency(tempDir, "test")
|
|
522
524
|
|
|
523
|
-
await runTestEffect(task({ silent: true,
|
|
525
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
524
526
|
|
|
525
527
|
// Check agency.json to verify .opencode/opencode.json is in injectedFiles
|
|
526
528
|
const agencyJsonContent = await readFile(join(tempDir, "agency.json"))
|
|
@@ -537,7 +539,7 @@ describe("task command", () => {
|
|
|
537
539
|
|
|
538
540
|
await initAgency(tempDir, "test")
|
|
539
541
|
|
|
540
|
-
await runTestEffect(task({ silent: true,
|
|
542
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
541
543
|
|
|
542
544
|
expect(await fileExists(join(tempDir, "TASK.md"))).toBe(true)
|
|
543
545
|
})
|
|
@@ -548,7 +550,7 @@ describe("task command", () => {
|
|
|
548
550
|
|
|
549
551
|
await initAgency(tempDir, "test")
|
|
550
552
|
|
|
551
|
-
await runTestEffect(task({ silent: true,
|
|
553
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
552
554
|
|
|
553
555
|
const content = await readFile(join(tempDir, "TASK.md"))
|
|
554
556
|
expect(content).toContain("{task}")
|
|
@@ -563,7 +565,7 @@ describe("task command", () => {
|
|
|
563
565
|
task({
|
|
564
566
|
silent: true,
|
|
565
567
|
task: "Build new feature",
|
|
566
|
-
|
|
568
|
+
emit: "test-feature",
|
|
567
569
|
}),
|
|
568
570
|
)
|
|
569
571
|
|
|
@@ -582,7 +584,7 @@ describe("task command", () => {
|
|
|
582
584
|
await initAgency(tempDir, "test")
|
|
583
585
|
|
|
584
586
|
// Should succeed but skip TASK.md
|
|
585
|
-
await runTestEffect(task({ silent: true,
|
|
587
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
586
588
|
|
|
587
589
|
// TASK.md should not be overwritten
|
|
588
590
|
const content = await readFile(join(tempDir, "TASK.md"))
|
|
@@ -611,7 +613,7 @@ describe("task command", () => {
|
|
|
611
613
|
await runTestEffect(
|
|
612
614
|
task({
|
|
613
615
|
silent: true,
|
|
614
|
-
|
|
616
|
+
emit: "test-feature",
|
|
615
617
|
}),
|
|
616
618
|
)
|
|
617
619
|
|
|
@@ -632,7 +634,7 @@ describe("task command", () => {
|
|
|
632
634
|
|
|
633
635
|
await initAgency(tempDir, "test")
|
|
634
636
|
|
|
635
|
-
await runTestEffect(task({ silent: true,
|
|
637
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
636
638
|
|
|
637
639
|
console.log = originalLog
|
|
638
640
|
|
|
@@ -662,7 +664,7 @@ describe("task command", () => {
|
|
|
662
664
|
task({
|
|
663
665
|
silent: false,
|
|
664
666
|
task: "Test task",
|
|
665
|
-
|
|
667
|
+
emit: "test-feature",
|
|
666
668
|
}),
|
|
667
669
|
)
|
|
668
670
|
|
|
@@ -690,7 +692,7 @@ describe("task command", () => {
|
|
|
690
692
|
|
|
691
693
|
await initAgency(tempDir, "test")
|
|
692
694
|
|
|
693
|
-
await runTestEffect(task({ silent: true,
|
|
695
|
+
await runTestEffect(task({ silent: true, emit: "my-feature" }))
|
|
694
696
|
|
|
695
697
|
// Verify we're now on the new branch
|
|
696
698
|
const proc = Bun.spawn(["git", "branch", "--show-current"], {
|
|
@@ -731,7 +733,7 @@ describe("task command", () => {
|
|
|
731
733
|
return await runTestEffect(
|
|
732
734
|
task({
|
|
733
735
|
silent: true,
|
|
734
|
-
|
|
736
|
+
emit: "existing-branch",
|
|
735
737
|
task: "This should not be asked for",
|
|
736
738
|
}),
|
|
737
739
|
)
|
|
@@ -753,7 +755,7 @@ describe("task command", () => {
|
|
|
753
755
|
// Should succeed without needing branch option
|
|
754
756
|
await initAgency(tempDir, "test")
|
|
755
757
|
|
|
756
|
-
await runTestEffect(task({ silent: true,
|
|
758
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
757
759
|
|
|
758
760
|
expect(await fileExists(join(tempDir, "AGENTS.md"))).toBe(true)
|
|
759
761
|
})
|
|
@@ -796,7 +798,7 @@ describe("task command", () => {
|
|
|
796
798
|
|
|
797
799
|
await initAgency(tempDir, "custom")
|
|
798
800
|
|
|
799
|
-
await runTestEffect(task({ silent: true,
|
|
801
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
800
802
|
|
|
801
803
|
const content = await readFile(join(tempDir, "AGENTS.md"))
|
|
802
804
|
expect(content).toBe(sourceContent)
|
|
@@ -811,7 +813,7 @@ describe("task command", () => {
|
|
|
811
813
|
await runTestEffect(
|
|
812
814
|
task({
|
|
813
815
|
silent: true,
|
|
814
|
-
|
|
816
|
+
emit: "test-feature",
|
|
815
817
|
}),
|
|
816
818
|
)
|
|
817
819
|
|
|
@@ -829,7 +831,7 @@ describe("task command", () => {
|
|
|
829
831
|
await runTestEffect(
|
|
830
832
|
task({
|
|
831
833
|
silent: true,
|
|
832
|
-
|
|
834
|
+
emit: "test-feature",
|
|
833
835
|
}),
|
|
834
836
|
)
|
|
835
837
|
|
|
@@ -854,7 +856,7 @@ describe("task command", () => {
|
|
|
854
856
|
await runTestEffect(
|
|
855
857
|
task({
|
|
856
858
|
silent: true,
|
|
857
|
-
|
|
859
|
+
emit: "test-feature",
|
|
858
860
|
}),
|
|
859
861
|
)
|
|
860
862
|
|
|
@@ -868,5 +870,28 @@ describe("task command", () => {
|
|
|
868
870
|
// opencode.json should be in injectedFiles
|
|
869
871
|
expect(metadata.injectedFiles).toContain("opencode.json")
|
|
870
872
|
})
|
|
873
|
+
|
|
874
|
+
test("supports deprecated --branch flag for backward compatibility", async () => {
|
|
875
|
+
await initGitRepo(tempDir)
|
|
876
|
+
process.chdir(tempDir)
|
|
877
|
+
|
|
878
|
+
await initAgency(tempDir, "test")
|
|
879
|
+
|
|
880
|
+
// Use deprecated --branch flag instead of --emit
|
|
881
|
+
await runTestEffect(
|
|
882
|
+
task({
|
|
883
|
+
silent: true,
|
|
884
|
+
branch: "backward-compat-test",
|
|
885
|
+
}),
|
|
886
|
+
)
|
|
887
|
+
|
|
888
|
+
// Should have created the branch with agency/ prefix
|
|
889
|
+
const currentBranch = await getCurrentBranch(tempDir)
|
|
890
|
+
expect(currentBranch).toBe("agency/backward-compat-test")
|
|
891
|
+
|
|
892
|
+
// Should have correct emitBranch in agency.json
|
|
893
|
+
const metadata = JSON.parse(await readFile(join(tempDir, "agency.json")))
|
|
894
|
+
expect(metadata.emitBranch).toBe("backward-compat-test")
|
|
895
|
+
})
|
|
871
896
|
})
|
|
872
897
|
})
|