@markjaquith/agency 1.9.5 → 1.9.6
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/package.json +1 -1
- package/src/commands/emit.test.ts +30 -0
- package/src/commands/emit.ts +25 -0
- package/src/commands/push.test.ts +17 -0
package/package.json
CHANGED
|
@@ -326,6 +326,36 @@ describe("emit command", () => {
|
|
|
326
326
|
clearCapturedFilterRepoCalls()
|
|
327
327
|
})
|
|
328
328
|
|
|
329
|
+
test("throws when emitted CLAUDE.md references AGENCY.md", async () => {
|
|
330
|
+
await checkoutBranch(tempDir, "main")
|
|
331
|
+
await createBranch(tempDir, "agency--claude-reference-test")
|
|
332
|
+
|
|
333
|
+
await Bun.write(
|
|
334
|
+
join(tempDir, "agency.json"),
|
|
335
|
+
JSON.stringify({
|
|
336
|
+
version: 1,
|
|
337
|
+
injectedFiles: ["AGENTS.md"],
|
|
338
|
+
template: "test",
|
|
339
|
+
createdAt: new Date().toISOString(),
|
|
340
|
+
}),
|
|
341
|
+
)
|
|
342
|
+
await Bun.write(
|
|
343
|
+
join(tempDir, "CLAUDE.md"),
|
|
344
|
+
"# Instructions\n\n@AGENCY.md\n",
|
|
345
|
+
)
|
|
346
|
+
await addAndCommit(
|
|
347
|
+
tempDir,
|
|
348
|
+
["agency.json", "CLAUDE.md"],
|
|
349
|
+
"Add Claude agency reference",
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
await expect(
|
|
353
|
+
runTestEffectWithMockFilterRepo(emit({ silent: true })),
|
|
354
|
+
).rejects.toThrow(
|
|
355
|
+
"CLAUDE.md on emitted branch claude-reference-test still references @AGENCY.md",
|
|
356
|
+
)
|
|
357
|
+
})
|
|
358
|
+
|
|
329
359
|
test("constructs correct filter-repo arguments", async () => {
|
|
330
360
|
// Set up fresh branch with agency.json
|
|
331
361
|
await checkoutBranch(tempDir, "main")
|
package/src/commands/emit.ts
CHANGED
|
@@ -248,9 +248,34 @@ export const emitCore = (gitRoot: string, options: EmitOptions) =>
|
|
|
248
248
|
enabled: !options.silent && !verbose,
|
|
249
249
|
})
|
|
250
250
|
|
|
251
|
+
yield* validateClaudeDoesNotReferenceAgency(gitRoot, emitBranchName)
|
|
252
|
+
|
|
251
253
|
log(done(`Emitted ${highlight.branch(emitBranchName)}`))
|
|
252
254
|
})
|
|
253
255
|
|
|
256
|
+
const validateClaudeDoesNotReferenceAgency = (
|
|
257
|
+
gitRoot: string,
|
|
258
|
+
emitBranchName: string,
|
|
259
|
+
) =>
|
|
260
|
+
Effect.gen(function* () {
|
|
261
|
+
const git = yield* GitService
|
|
262
|
+
const claudeContents = yield* git.getFileAtRef(
|
|
263
|
+
gitRoot,
|
|
264
|
+
emitBranchName,
|
|
265
|
+
"CLAUDE.md",
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
if (!claudeContents?.includes("@AGENCY.md")) {
|
|
269
|
+
return
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return yield* Effect.fail(
|
|
273
|
+
new Error(
|
|
274
|
+
`CLAUDE.md on emitted branch ${emitBranchName} still references @AGENCY.md. Remove the agency file reference before emitting.`,
|
|
275
|
+
),
|
|
276
|
+
)
|
|
277
|
+
})
|
|
278
|
+
|
|
254
279
|
const logFilterPreflight = (
|
|
255
280
|
gitRoot: string,
|
|
256
281
|
forkPoint: string,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
addAndCommit,
|
|
14
14
|
renameBranch,
|
|
15
15
|
runTestEffect,
|
|
16
|
+
runTestEffectWithMockFilterRepo,
|
|
16
17
|
} from "../test-utils"
|
|
17
18
|
|
|
18
19
|
async function setupAgencyJson(gitRoot: string): Promise<void> {
|
|
@@ -187,6 +188,22 @@ describe("push command", () => {
|
|
|
187
188
|
})
|
|
188
189
|
|
|
189
190
|
describe("error handling", () => {
|
|
191
|
+
test("throws when emitted CLAUDE.md references AGENCY.md", async () => {
|
|
192
|
+
await Bun.write(
|
|
193
|
+
join(tempDir, "CLAUDE.md"),
|
|
194
|
+
"# Instructions\n\n@AGENCY.md\n",
|
|
195
|
+
)
|
|
196
|
+
await addAndCommit(tempDir, "CLAUDE.md", "Add Claude agency reference")
|
|
197
|
+
|
|
198
|
+
await expect(
|
|
199
|
+
runTestEffectWithMockFilterRepo(
|
|
200
|
+
push({ baseBranch: "main", silent: true }),
|
|
201
|
+
),
|
|
202
|
+
).rejects.toThrow(
|
|
203
|
+
"Failed to create emit branch: CLAUDE.md on emitted branch feature still references @AGENCY.md",
|
|
204
|
+
)
|
|
205
|
+
})
|
|
206
|
+
|
|
190
207
|
test("switches to source branch when run from emit branch", async () => {
|
|
191
208
|
// First create the emit branch from source branch
|
|
192
209
|
await runTestEffect(
|