@markjaquith/agency 1.6.2 → 1.6.3
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/task-main.test.ts +79 -0
- package/src/commands/task.ts +25 -1
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { test, expect, describe, beforeEach, afterEach } from "bun:test"
|
|
2
2
|
import { join } from "path"
|
|
3
|
+
import { symlink } from "fs/promises"
|
|
3
4
|
import { task } from "../commands/task"
|
|
4
5
|
import {
|
|
5
6
|
createTempDir,
|
|
@@ -12,6 +13,8 @@ import {
|
|
|
12
13
|
runTestEffect,
|
|
13
14
|
runGitCommand,
|
|
14
15
|
getCurrentBranch,
|
|
16
|
+
getGitOutput,
|
|
17
|
+
addAndCommit,
|
|
15
18
|
} from "../test-utils"
|
|
16
19
|
|
|
17
20
|
describe("task command", () => {
|
|
@@ -937,4 +940,80 @@ describe("task command", () => {
|
|
|
937
940
|
expect(metadata.emitBranch).toBe("backward-compat-test")
|
|
938
941
|
})
|
|
939
942
|
})
|
|
943
|
+
|
|
944
|
+
describe("CLAUDE.md symlink handling", () => {
|
|
945
|
+
test("commits CLAUDE.md modification when it is a symlink to another file", async () => {
|
|
946
|
+
await initGitRepo(tempDir)
|
|
947
|
+
process.chdir(tempDir)
|
|
948
|
+
|
|
949
|
+
// Create a pre-existing AGENTS.md and CLAUDE.md as a symlink to it
|
|
950
|
+
await Bun.write(
|
|
951
|
+
join(tempDir, "AGENTS.md"),
|
|
952
|
+
"# Agents\n\nOriginal content",
|
|
953
|
+
)
|
|
954
|
+
await symlink("AGENTS.md", join(tempDir, "CLAUDE.md"))
|
|
955
|
+
await addAndCommit(
|
|
956
|
+
tempDir,
|
|
957
|
+
["AGENTS.md", "CLAUDE.md"],
|
|
958
|
+
"Add AGENTS.md and CLAUDE.md symlink",
|
|
959
|
+
)
|
|
960
|
+
|
|
961
|
+
await initAgency(tempDir, "test")
|
|
962
|
+
|
|
963
|
+
// Run task - this will modify CLAUDE.md (which is a symlink to AGENTS.md)
|
|
964
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
965
|
+
|
|
966
|
+
// Check that the commit was created and includes both files
|
|
967
|
+
const commitLog = await getGitOutput(tempDir, [
|
|
968
|
+
"log",
|
|
969
|
+
"--oneline",
|
|
970
|
+
"-n",
|
|
971
|
+
"2",
|
|
972
|
+
])
|
|
973
|
+
|
|
974
|
+
// Should have the CLAUDE.md edit commit
|
|
975
|
+
expect(commitLog).toContain("agency edit CLAUDE.md")
|
|
976
|
+
|
|
977
|
+
// Verify that both AGENTS.md and CLAUDE.md were staged in the CLAUDE.md commit
|
|
978
|
+
// by checking the diff of the last commit
|
|
979
|
+
const lastCommitDiff = await getGitOutput(tempDir, [
|
|
980
|
+
"diff-tree",
|
|
981
|
+
"--no-commit-id",
|
|
982
|
+
"--name-only",
|
|
983
|
+
"-r",
|
|
984
|
+
"HEAD",
|
|
985
|
+
])
|
|
986
|
+
|
|
987
|
+
// The CLAUDE.md commit should include AGENTS.md (the symlink target)
|
|
988
|
+
expect(lastCommitDiff.trim().split("\n")).toContain("AGENTS.md")
|
|
989
|
+
})
|
|
990
|
+
|
|
991
|
+
test("commits CLAUDE.md modification normally when not a symlink", async () => {
|
|
992
|
+
await initGitRepo(tempDir)
|
|
993
|
+
process.chdir(tempDir)
|
|
994
|
+
|
|
995
|
+
// Create a pre-existing CLAUDE.md (not a symlink)
|
|
996
|
+
await Bun.write(
|
|
997
|
+
join(tempDir, "CLAUDE.md"),
|
|
998
|
+
"# Claude\n\nOriginal content",
|
|
999
|
+
)
|
|
1000
|
+
await addAndCommit(tempDir, "CLAUDE.md", "Add CLAUDE.md")
|
|
1001
|
+
|
|
1002
|
+
await initAgency(tempDir, "test")
|
|
1003
|
+
|
|
1004
|
+
// Run task - this will modify CLAUDE.md
|
|
1005
|
+
await runTestEffect(task({ silent: true, emit: "test-feature" }))
|
|
1006
|
+
|
|
1007
|
+
// Check that the commit was created
|
|
1008
|
+
const commitLog = await getGitOutput(tempDir, [
|
|
1009
|
+
"log",
|
|
1010
|
+
"--oneline",
|
|
1011
|
+
"-n",
|
|
1012
|
+
"2",
|
|
1013
|
+
])
|
|
1014
|
+
|
|
1015
|
+
// Should have the CLAUDE.md edit commit
|
|
1016
|
+
expect(commitLog).toContain("agency edit CLAUDE.md")
|
|
1017
|
+
})
|
|
1018
|
+
})
|
|
940
1019
|
})
|
package/src/commands/task.ts
CHANGED
|
@@ -847,7 +847,31 @@ export const task = (options: TaskOptions = {}) =>
|
|
|
847
847
|
// This commit will be completely removed during emission
|
|
848
848
|
if (claudeModifiedExisting) {
|
|
849
849
|
yield* Effect.gen(function* () {
|
|
850
|
-
|
|
850
|
+
// Check if CLAUDE.md is a symlink - if so, we need to add both the symlink
|
|
851
|
+
// and its target file, since git add on a symlink only stages the symlink itself
|
|
852
|
+
const claudePath = resolve(targetPath, "CLAUDE.md")
|
|
853
|
+
const filesToAdd = ["CLAUDE.md"]
|
|
854
|
+
|
|
855
|
+
const symlinkTarget = yield* fs.readSymlinkTarget(claudePath)
|
|
856
|
+
if (symlinkTarget) {
|
|
857
|
+
// Symlink target can be relative or absolute
|
|
858
|
+
// If relative, resolve it relative to the symlink's directory
|
|
859
|
+
const resolvedTarget = symlinkTarget.startsWith("/")
|
|
860
|
+
? symlinkTarget
|
|
861
|
+
: resolve(targetPath, symlinkTarget)
|
|
862
|
+
|
|
863
|
+
// Make the path relative to targetPath for git add
|
|
864
|
+
const relativeTarget = resolvedTarget.startsWith(targetPath)
|
|
865
|
+
? resolvedTarget.slice(targetPath.length + 1)
|
|
866
|
+
: resolvedTarget
|
|
867
|
+
|
|
868
|
+
filesToAdd.push(relativeTarget)
|
|
869
|
+
verboseLog(
|
|
870
|
+
`CLAUDE.md is a symlink to ${relativeTarget}, adding both files`,
|
|
871
|
+
)
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
yield* git.gitAdd(filesToAdd, targetPath)
|
|
851
875
|
// The AGENCY_REMOVE_COMMIT marker in the commit body tells emit to drop this commit entirely
|
|
852
876
|
const commitMessage = `chore: agency edit CLAUDE.md\n\nAGENCY_REMOVE_COMMIT`
|
|
853
877
|
yield* git.gitCommit(commitMessage, targetPath, {
|