@eliya-oss/agent-diff 0.1.0-alpha.1 → 0.1.0-alpha.10
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/.agents/prd/README.md +2 -2
- package/CHANGELOG.md +64 -0
- package/README.md +21 -11
- package/bin/adiff.js +76 -2
- package/dist/main.js +15039 -0
- package/package.json +8 -6
- package/skills/adiff/SKILL.md +40 -18
- package/src/cli/catalog.ts +0 -178
- package/src/cli/commands.ts +0 -335
- package/src/cli/error.ts +0 -44
- package/src/cli/index.ts +0 -24
- package/src/cli/parse.ts +0 -31
- package/src/cli/report.ts +0 -96
- package/src/cli/story.ts +0 -223
- package/src/domain/narrative/coverage.ts +0 -54
- package/src/domain/narrative/index.ts +0 -4
- package/src/domain/narrative/model.ts +0 -46
- package/src/domain/narrative/version.ts +0 -63
- package/src/domain/patch/anchor.ts +0 -40
- package/src/domain/patch/index.ts +0 -7
- package/src/domain/patch/model.ts +0 -54
- package/src/domain/patch/parse.ts +0 -106
- package/src/domain/patch/render.ts +0 -48
- package/src/domain/patch/sticky.ts +0 -39
- package/src/domain/review/index.ts +0 -4
- package/src/domain/review/lifecycle.ts +0 -45
- package/src/domain/review/model.ts +0 -23
- package/src/domain/review/vouch.ts +0 -15
- package/src/main.ts +0 -186
- package/src/service/git/error.ts +0 -16
- package/src/service/git/index.ts +0 -3
- package/src/service/git/model.ts +0 -13
- package/src/service/git/run.ts +0 -27
- package/src/service/git/service.ts +0 -133
- package/src/service/store/error.ts +0 -11
- package/src/service/store/index.ts +0 -5
- package/src/service/store/model.ts +0 -33
- package/src/service/store/paths.ts +0 -25
- package/src/service/store/service.ts +0 -154
- package/src/testing/agent-surface.test.ts +0 -92
- package/src/testing/batch.test.ts +0 -93
- package/src/testing/branch-state.test.ts +0 -99
- package/src/testing/chrome-tone.test.ts +0 -57
- package/src/testing/comment-block.test.ts +0 -84
- package/src/testing/comment-walk.test.ts +0 -96
- package/src/testing/compose-box.test.ts +0 -97
- package/src/testing/compose.test.ts +0 -67
- package/src/testing/context.test.ts +0 -77
- package/src/testing/cursor.test.ts +0 -49
- package/src/testing/delivery.test.ts +0 -94
- package/src/testing/domains/agent/driver.ts +0 -50
- package/src/testing/domains/agent/index.ts +0 -2
- package/src/testing/domains/app/driver.ts +0 -168
- package/src/testing/domains/app/index.ts +0 -2
- package/src/testing/domains/branch/driver.ts +0 -51
- package/src/testing/domains/branch/index.ts +0 -3
- package/src/testing/domains/branch/model.ts +0 -39
- package/src/testing/domains/screen/driver.ts +0 -241
- package/src/testing/domains/screen/index.ts +0 -2
- package/src/testing/driver.ts +0 -31
- package/src/testing/escape.test.ts +0 -56
- package/src/testing/focus.test.ts +0 -104
- package/src/testing/footer-chips.test.ts +0 -65
- package/src/testing/footer.test.ts +0 -64
- package/src/testing/gaps.test.ts +0 -47
- package/src/testing/highlight.test.ts +0 -49
- package/src/testing/home-screen.test.ts +0 -51
- package/src/testing/index.ts +0 -4
- package/src/testing/inline-comments.test.ts +0 -131
- package/src/testing/marks.test.ts +0 -49
- package/src/testing/mouse.test.ts +0 -87
- package/src/testing/navigate.test.ts +0 -73
- package/src/testing/palette.test.ts +0 -68
- package/src/testing/pending.test.ts +0 -70
- package/src/testing/pin-align.test.ts +0 -37
- package/src/testing/progress.test.ts +0 -88
- package/src/testing/report.test.ts +0 -83
- package/src/testing/resume.test.ts +0 -39
- package/src/testing/review.test.ts +0 -181
- package/src/testing/roundtrip.test.ts +0 -70
- package/src/testing/scale.test.ts +0 -55
- package/src/testing/scroll-feel.test.ts +0 -81
- package/src/testing/sent-comments.test.ts +0 -106
- package/src/testing/state.ts +0 -55
- package/src/testing/sticky-removed.test.ts +0 -67
- package/src/testing/sticky.test.ts +0 -90
- package/src/testing/story-rail.test.ts +0 -122
- package/src/testing/story.test.ts +0 -183
- package/src/testing/stress.test.ts +0 -74
- package/src/testing/tree-collapse.test.ts +0 -108
- package/src/testing/tree-rows.test.ts +0 -66
- package/src/testing/tree.test.ts +0 -91
- package/src/testing/tui.test.ts +0 -73
- package/src/testing/typing.test.ts +0 -65
- package/src/testing/vouch-next.test.ts +0 -65
- package/src/testing/vouch-tui.test.ts +0 -77
- package/src/testing/wash.test.ts +0 -32
- package/src/testing/width.test.ts +0 -62
- package/src/tui/app.ts +0 -467
- package/src/tui/command.ts +0 -390
- package/src/tui/diffview.ts +0 -333
- package/src/tui/index.ts +0 -9
- package/src/tui/marks.ts +0 -102
- package/src/tui/match.ts +0 -34
- package/src/tui/model.ts +0 -310
- package/src/tui/reduce.ts +0 -305
- package/src/tui/render.ts +0 -897
- package/src/tui/report.ts +0 -74
- package/src/tui/session.ts +0 -32
- package/src/tui/theme.ts +0 -61
- package/src/tui/tree.ts +0 -149
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
|
|
4
|
-
const oneFile = {
|
|
5
|
-
files: [
|
|
6
|
-
{ path: "src/api.ts", before: ["const keep = 0"], after: ["const keep = 0", "const a = 1"] },
|
|
7
|
-
],
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const indentOf = (row: string): number => row.length - row.trimStart().length
|
|
11
|
-
|
|
12
|
-
describe("how the chrome reads", () => {
|
|
13
|
-
it("draws footer keys brighter than what they do", async () => {
|
|
14
|
-
// ARRANGE
|
|
15
|
-
await using driver = await TestDriver.create()
|
|
16
|
-
await driver.branch.create(oneFile)
|
|
17
|
-
await driver.screen.open()
|
|
18
|
-
|
|
19
|
-
// ACT
|
|
20
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
21
|
-
|
|
22
|
-
// ASSERT
|
|
23
|
-
expect(await driver.screen.listForegroundsOn("v select")).toHaveLength(2)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it("draws the branch name brighter than the rest of the header", async () => {
|
|
27
|
-
// ARRANGE
|
|
28
|
-
await using driver = await TestDriver.create()
|
|
29
|
-
await driver.branch.create(oneFile)
|
|
30
|
-
await driver.screen.open()
|
|
31
|
-
|
|
32
|
-
// ACT
|
|
33
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
34
|
-
|
|
35
|
-
// ASSERT
|
|
36
|
-
expect(await driver.screen.listForegroundsOn("cdr-1-add-third src/api.ts")).toHaveLength(2)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
describe("how the screen breathes", () => {
|
|
41
|
-
it("keeps an even gutter down the left of every bar", async () => {
|
|
42
|
-
// ARRANGE
|
|
43
|
-
await using driver = await TestDriver.create()
|
|
44
|
-
await driver.branch.create(oneFile)
|
|
45
|
-
await driver.screen.open()
|
|
46
|
-
|
|
47
|
-
// ACT
|
|
48
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
49
|
-
|
|
50
|
-
// ASSERT
|
|
51
|
-
const rows = (await driver.screen.getFrame()).split("\n")
|
|
52
|
-
const header = rows.find((row) => row.includes("src/api.ts")) ?? ""
|
|
53
|
-
const footer = rows.findLast((row) => row.includes("select")) ?? ""
|
|
54
|
-
expect(indentOf(header)).toBeGreaterThan(0)
|
|
55
|
-
expect(indentOf(footer)).toBe(indentOf(header))
|
|
56
|
-
})
|
|
57
|
-
})
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
|
|
4
|
-
const oneFile = {
|
|
5
|
-
files: [
|
|
6
|
-
{
|
|
7
|
-
path: "src/api.ts",
|
|
8
|
-
before: ["const keep = 0"],
|
|
9
|
-
after: ["const keep = 0", "const first = 1", "const second = 2"],
|
|
10
|
-
},
|
|
11
|
-
],
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const long =
|
|
15
|
-
"Worth carrying the tenant here too, otherwise the log line is ambiguous and nobody reading it later can tell which tenant the failure belonged to."
|
|
16
|
-
|
|
17
|
-
const rowsWith = (frame: string, text: string): ReadonlyArray<string> =>
|
|
18
|
-
frame.split("\n").filter((line) => line.includes(text))
|
|
19
|
-
|
|
20
|
-
const rowWith = (frame: string, text: string): string => rowsWith(frame, text)[0] ?? ""
|
|
21
|
-
|
|
22
|
-
describe("how a comment sits in the diff", () => {
|
|
23
|
-
it("says whether it is staged or already sent", async () => {
|
|
24
|
-
// ARRANGE
|
|
25
|
-
await using driver = await TestDriver.create()
|
|
26
|
-
await driver.branch.create(oneFile)
|
|
27
|
-
await driver.screen.open()
|
|
28
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
29
|
-
await driver.screen.pressKeys(["j"])
|
|
30
|
-
|
|
31
|
-
// ACT
|
|
32
|
-
await driver.screen.pressKeys(["c"])
|
|
33
|
-
await driver.screen.typeText("short one")
|
|
34
|
-
await driver.screen.pressCtrl("a")
|
|
35
|
-
|
|
36
|
-
// ASSERT
|
|
37
|
-
const frame = await driver.screen.getFrame()
|
|
38
|
-
const lines = frame.split("\n")
|
|
39
|
-
const anchor = lines.findIndex((line) => line.includes("const first = 1"))
|
|
40
|
-
expect(lines[anchor + 1]).toContain("staged")
|
|
41
|
-
expect(lines[anchor + 2]).toContain("short one")
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it("wraps a long comment inside the diff instead of running off it", async () => {
|
|
45
|
-
// ARRANGE
|
|
46
|
-
await using driver = await TestDriver.create()
|
|
47
|
-
await driver.branch.create(oneFile)
|
|
48
|
-
await driver.screen.open()
|
|
49
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
50
|
-
await driver.screen.pressKeys(["j"])
|
|
51
|
-
|
|
52
|
-
// ACT
|
|
53
|
-
await driver.screen.pressKeys(["c"])
|
|
54
|
-
await driver.screen.typeText(long)
|
|
55
|
-
await driver.screen.pressCtrl("a")
|
|
56
|
-
|
|
57
|
-
// ASSERT
|
|
58
|
-
const frame = await driver.screen.getFrame()
|
|
59
|
-
expect(rowsWith(frame, "Worth carrying the tenant")).toHaveLength(1)
|
|
60
|
-
expect(frame).toContain("nobody reading it later")
|
|
61
|
-
expect(rowWith(frame, "Worth carrying the tenant").length).toBeLessThanOrEqual(
|
|
62
|
-
frame.split("\n")[0]?.length ?? 0,
|
|
63
|
-
)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it("runs a rule down the left of every line it takes up", async () => {
|
|
67
|
-
// ARRANGE
|
|
68
|
-
await using driver = await TestDriver.create()
|
|
69
|
-
await driver.branch.create(oneFile)
|
|
70
|
-
await driver.screen.open()
|
|
71
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
72
|
-
await driver.screen.pressKeys(["j"])
|
|
73
|
-
|
|
74
|
-
// ACT
|
|
75
|
-
await driver.screen.pressKeys(["c"])
|
|
76
|
-
await driver.screen.typeText(long)
|
|
77
|
-
await driver.screen.pressCtrl("a")
|
|
78
|
-
|
|
79
|
-
// ASSERT
|
|
80
|
-
const frame = await driver.screen.getFrame()
|
|
81
|
-
expect(rowWith(frame, "Worth carrying the tenant")).toContain("│")
|
|
82
|
-
expect(rowWith(frame, "nobody reading it later")).toContain("│")
|
|
83
|
-
})
|
|
84
|
-
})
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
|
|
4
|
-
const spread = {
|
|
5
|
-
files: [
|
|
6
|
-
{
|
|
7
|
-
path: "src/api.ts",
|
|
8
|
-
before: ["const keep = 0"],
|
|
9
|
-
after: ["const keep = 0", ...Array.from({ length: 30 }, (_, at) => `const step${at} = ${at}`)],
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
path: "src/other.ts",
|
|
13
|
-
before: ["const keep = 0"],
|
|
14
|
-
after: ["const keep = 0", "const late = 1"],
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const stage = async (driver: TestDriver, body: string): Promise<void> => {
|
|
20
|
-
await driver.screen.pressKeys(["c"])
|
|
21
|
-
await driver.screen.typeText(body)
|
|
22
|
-
await driver.screen.pressCtrl("a")
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const rowWith = (frame: string, text: string): string =>
|
|
26
|
-
frame.split("\n").find((line) => line.includes(text)) ?? ""
|
|
27
|
-
|
|
28
|
-
describe("walking between comments", () => {
|
|
29
|
-
it("jumps forward to the line the next comment sits on", async () => {
|
|
30
|
-
// ARRANGE
|
|
31
|
-
await using driver = await TestDriver.create()
|
|
32
|
-
await driver.branch.create(spread)
|
|
33
|
-
await driver.screen.open()
|
|
34
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
35
|
-
await driver.screen.pressKeys(["j", "j", "j", "j", "j"])
|
|
36
|
-
await stage(driver, "look at this")
|
|
37
|
-
await driver.screen.pressKeys(["g"])
|
|
38
|
-
|
|
39
|
-
// ACT
|
|
40
|
-
await driver.screen.pressKeys(["n"])
|
|
41
|
-
|
|
42
|
-
// ASSERT
|
|
43
|
-
expect(rowWith(await driver.screen.getFrame(), "const step4 = 4")).toContain("▎")
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it("jumps back to the comment above", async () => {
|
|
47
|
-
// ARRANGE
|
|
48
|
-
await using driver = await TestDriver.create()
|
|
49
|
-
await driver.branch.create(spread)
|
|
50
|
-
await driver.screen.open()
|
|
51
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
52
|
-
await driver.screen.pressKeys(["j", "j"])
|
|
53
|
-
await stage(driver, "the early one")
|
|
54
|
-
await driver.screen.pressKeys(["G"])
|
|
55
|
-
|
|
56
|
-
// ACT
|
|
57
|
-
await driver.screen.pressKeys(["N"])
|
|
58
|
-
|
|
59
|
-
// ASSERT
|
|
60
|
-
expect(rowWith(await driver.screen.getFrame(), "const step1 = 1")).toContain("▎")
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it("carries on into the next file that has one", async () => {
|
|
64
|
-
// ARRANGE
|
|
65
|
-
await using driver = await TestDriver.create()
|
|
66
|
-
await driver.branch.create(spread)
|
|
67
|
-
await driver.screen.open()
|
|
68
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
69
|
-
await driver.screen.pressKeys(["]"])
|
|
70
|
-
await driver.screen.pressKeys(["j"])
|
|
71
|
-
await stage(driver, "over here")
|
|
72
|
-
await driver.screen.pressKeys(["["])
|
|
73
|
-
|
|
74
|
-
// ACT
|
|
75
|
-
await driver.screen.pressKeys(["n"])
|
|
76
|
-
|
|
77
|
-
// ASSERT
|
|
78
|
-
const frame = await driver.screen.getFrame()
|
|
79
|
-
expect(frame).toContain("src/other.ts")
|
|
80
|
-
expect(rowWith(frame, "over here")).not.toHaveLength(0)
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
it("says so when there is nothing to walk to", async () => {
|
|
84
|
-
// ARRANGE
|
|
85
|
-
await using driver = await TestDriver.create()
|
|
86
|
-
await driver.branch.create(spread)
|
|
87
|
-
await driver.screen.open()
|
|
88
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
89
|
-
|
|
90
|
-
// ACT
|
|
91
|
-
await driver.screen.pressKeys(["n"])
|
|
92
|
-
|
|
93
|
-
// ASSERT
|
|
94
|
-
expect(await driver.screen.getFrame()).toContain("no comments yet")
|
|
95
|
-
})
|
|
96
|
-
})
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
|
|
4
|
-
const oneFile = {
|
|
5
|
-
files: [
|
|
6
|
-
{
|
|
7
|
-
path: "src/api.ts",
|
|
8
|
-
before: ["const keep = 0"],
|
|
9
|
-
after: ["const keep = 0", "const first = 1"],
|
|
10
|
-
},
|
|
11
|
-
],
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const rowWith = (frame: string, text: string): string =>
|
|
15
|
-
rowsOf(frame).find((row) => row.includes(text)) ?? ""
|
|
16
|
-
|
|
17
|
-
const boxHeight = (frame: string): number =>
|
|
18
|
-
rowsOf(frame).filter((row) => row.includes("┃")).length
|
|
19
|
-
|
|
20
|
-
const rowsOf = (frame: string): ReadonlyArray<string> => frame.split("\n")
|
|
21
|
-
|
|
22
|
-
describe("the box you write a comment in", () => {
|
|
23
|
-
it("is drawn as a panel with a bar down its edge, not a box", async () => {
|
|
24
|
-
// ARRANGE
|
|
25
|
-
await using driver = await TestDriver.create()
|
|
26
|
-
await driver.branch.create(oneFile)
|
|
27
|
-
await driver.screen.open()
|
|
28
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
29
|
-
|
|
30
|
-
// ACT
|
|
31
|
-
await driver.screen.pressKeys(["c"])
|
|
32
|
-
|
|
33
|
-
// ASSERT
|
|
34
|
-
const frame = await driver.screen.getFrame()
|
|
35
|
-
const panel = rowsOf(frame).filter((row) => row.includes("┃")).join("")
|
|
36
|
-
expect(frame).toContain("Comment on src/api.ts")
|
|
37
|
-
expect(panel).not.toContain("╭")
|
|
38
|
-
expect(panel).not.toContain("╰")
|
|
39
|
-
expect(rowWith(frame, "Comment on src/api.ts")).toContain("┃")
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it("ends just below what you have written", async () => {
|
|
43
|
-
// ARRANGE
|
|
44
|
-
await using driver = await TestDriver.create()
|
|
45
|
-
await driver.branch.create(oneFile)
|
|
46
|
-
await driver.screen.open()
|
|
47
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
48
|
-
await driver.screen.pressKeys(["c"])
|
|
49
|
-
|
|
50
|
-
// ACT
|
|
51
|
-
await driver.screen.typeText("one short remark")
|
|
52
|
-
|
|
53
|
-
// ASSERT
|
|
54
|
-
const rows = rowsOf(await driver.screen.getFrame())
|
|
55
|
-
const written = rows.findIndex((row) => row.includes("one short remark"))
|
|
56
|
-
const actions = rows.findIndex((row) => row.includes("cancel"))
|
|
57
|
-
expect(written).toBeGreaterThan(0)
|
|
58
|
-
expect(actions - written).toBe(2)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it("offers its actions on the box, with their keys", async () => {
|
|
62
|
-
// ARRANGE
|
|
63
|
-
await using driver = await TestDriver.create()
|
|
64
|
-
await driver.branch.create(oneFile)
|
|
65
|
-
await driver.screen.open()
|
|
66
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
67
|
-
|
|
68
|
-
// ACT
|
|
69
|
-
await driver.screen.pressKeys(["c"])
|
|
70
|
-
|
|
71
|
-
// ASSERT
|
|
72
|
-
const frame = await driver.screen.getFrame()
|
|
73
|
-
const actions = rowsOf(frame).find((row) => row.includes("cancel")) ?? ""
|
|
74
|
-
expect(actions).toContain("esc")
|
|
75
|
-
expect(actions).toContain("cancel")
|
|
76
|
-
expect(actions).toContain("add to review")
|
|
77
|
-
expect(actions).toContain("comment now")
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it("grows as the comment runs onto more lines", async () => {
|
|
81
|
-
// ARRANGE
|
|
82
|
-
await using driver = await TestDriver.create()
|
|
83
|
-
await driver.branch.create(oneFile)
|
|
84
|
-
await driver.screen.open()
|
|
85
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
86
|
-
await driver.screen.pressKeys(["c"])
|
|
87
|
-
await driver.screen.typeText("first line")
|
|
88
|
-
const before = boxHeight(await driver.screen.getFrame())
|
|
89
|
-
|
|
90
|
-
// ACT
|
|
91
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
92
|
-
await driver.screen.typeText("second line")
|
|
93
|
-
|
|
94
|
-
// ASSERT
|
|
95
|
-
expect(boxHeight(await driver.screen.getFrame())).toBe(before + 1)
|
|
96
|
-
})
|
|
97
|
-
})
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
|
|
4
|
-
const oneFile = {
|
|
5
|
-
files: [
|
|
6
|
-
{
|
|
7
|
-
path: "src/api.ts",
|
|
8
|
-
before: ["const keep = 0"],
|
|
9
|
-
after: ["const keep = 0", "const first = 1", "const second = 2"],
|
|
10
|
-
},
|
|
11
|
-
],
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
describe("writing a comment", () => {
|
|
15
|
-
it("shows the code the comment will be attached to", async () => {
|
|
16
|
-
// ARRANGE
|
|
17
|
-
await using driver = await TestDriver.create()
|
|
18
|
-
await driver.branch.create(oneFile)
|
|
19
|
-
await driver.screen.open()
|
|
20
|
-
await driver.screen.pressKeys(["RETURN", "j", "v", "j"])
|
|
21
|
-
|
|
22
|
-
// ACT
|
|
23
|
-
await driver.screen.pressKeys(["c"])
|
|
24
|
-
|
|
25
|
-
// ASSERT
|
|
26
|
-
const frame = await driver.screen.getFrame()
|
|
27
|
-
expect(frame).toContain("Comment on src/api.ts")
|
|
28
|
-
const echoed = frame.split("\n").filter((line) => line.includes("const first = 1"))
|
|
29
|
-
expect(echoed).toHaveLength(2)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it("takes more than one line of prose", async () => {
|
|
33
|
-
// ARRANGE
|
|
34
|
-
await using driver = await TestDriver.create()
|
|
35
|
-
await driver.branch.create(oneFile)
|
|
36
|
-
await driver.screen.open()
|
|
37
|
-
await driver.screen.pressKeys(["RETURN", "c"])
|
|
38
|
-
await driver.screen.typeText("first line")
|
|
39
|
-
|
|
40
|
-
// ACT
|
|
41
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
42
|
-
await driver.screen.typeText("second line")
|
|
43
|
-
|
|
44
|
-
// ASSERT
|
|
45
|
-
const lines = (await driver.screen.getFrame()).split("\n")
|
|
46
|
-
expect(lines.some((line) => line.includes("first line") && line.includes("second line"))).toBe(
|
|
47
|
-
false,
|
|
48
|
-
)
|
|
49
|
-
expect(lines.some((line) => line.includes("second line"))).toBe(true)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it("stages a comment for later instead of waking the agent now", async () => {
|
|
53
|
-
// ARRANGE
|
|
54
|
-
await using driver = await TestDriver.create()
|
|
55
|
-
const branch = await driver.branch.create(oneFile)
|
|
56
|
-
await driver.screen.open()
|
|
57
|
-
await driver.screen.pressKeys(["RETURN", "c"])
|
|
58
|
-
await driver.screen.typeText("hold this back")
|
|
59
|
-
|
|
60
|
-
// ACT
|
|
61
|
-
await driver.screen.pressCtrl("a")
|
|
62
|
-
|
|
63
|
-
// ASSERT
|
|
64
|
-
expect(await driver.agent.listBatches(branch.worktree)).toHaveLength(0)
|
|
65
|
-
expect(await driver.screen.getFrame()).toContain("1 staged")
|
|
66
|
-
})
|
|
67
|
-
})
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
import { palette } from "../tui/index.ts"
|
|
4
|
-
|
|
5
|
-
const around = (mark: string): ReadonlyArray<string> => [
|
|
6
|
-
...Array.from({ length: 12 }, (_, index) => `const above${index} = ${index}`),
|
|
7
|
-
`const changed = "${mark}"`,
|
|
8
|
-
...Array.from({ length: 12 }, (_, index) => `const below${index} = ${index}`),
|
|
9
|
-
]
|
|
10
|
-
|
|
11
|
-
const buried = {
|
|
12
|
-
files: [{ path: "src/api.ts", before: around("before"), after: around("after") }],
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
describe("asking for more of the file", () => {
|
|
16
|
-
it("shows only a little context to begin with", async () => {
|
|
17
|
-
// ARRANGE
|
|
18
|
-
await using driver = await TestDriver.create()
|
|
19
|
-
await driver.branch.create(buried)
|
|
20
|
-
await driver.screen.open()
|
|
21
|
-
|
|
22
|
-
// ACT
|
|
23
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
24
|
-
|
|
25
|
-
// ASSERT
|
|
26
|
-
const frame = await driver.screen.getFrame()
|
|
27
|
-
expect(frame).toContain("above11")
|
|
28
|
-
expect(frame).not.toContain("above2")
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it("widens the context when asked", async () => {
|
|
32
|
-
// ARRANGE
|
|
33
|
-
await using driver = await TestDriver.create()
|
|
34
|
-
await driver.branch.create(buried)
|
|
35
|
-
await driver.screen.open()
|
|
36
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
37
|
-
|
|
38
|
-
// ACT
|
|
39
|
-
await driver.screen.typeText("+")
|
|
40
|
-
|
|
41
|
-
// ASSERT
|
|
42
|
-
expect(await driver.screen.getFrame()).toContain("above2")
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it("narrows it again", async () => {
|
|
46
|
-
// ARRANGE
|
|
47
|
-
await using driver = await TestDriver.create()
|
|
48
|
-
await driver.branch.create(buried)
|
|
49
|
-
await driver.screen.open()
|
|
50
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
51
|
-
await driver.screen.typeText("+")
|
|
52
|
-
|
|
53
|
-
// ACT
|
|
54
|
-
await driver.screen.typeText("-")
|
|
55
|
-
|
|
56
|
-
// ASSERT
|
|
57
|
-
expect(await driver.screen.getFrame()).not.toContain("above2")
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it("keeps the cursor on the same line of the file", async () => {
|
|
61
|
-
// ARRANGE
|
|
62
|
-
await using driver = await TestDriver.create()
|
|
63
|
-
await driver.branch.create(buried)
|
|
64
|
-
await driver.screen.open()
|
|
65
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
66
|
-
await driver.screen.pressKeys(["j", "j", "j", "j"])
|
|
67
|
-
const before = await driver.screen.findHighlighted(palette.cursor)
|
|
68
|
-
expect(before.join(" ")).toContain("changed")
|
|
69
|
-
|
|
70
|
-
// ACT
|
|
71
|
-
await driver.screen.typeText("+")
|
|
72
|
-
|
|
73
|
-
// ASSERT
|
|
74
|
-
const after = await driver.screen.findHighlighted(palette.cursor)
|
|
75
|
-
expect(after.join(" ")).toContain("changed")
|
|
76
|
-
})
|
|
77
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
import { palette } from "../tui/index.ts"
|
|
4
|
-
|
|
5
|
-
const numbered = {
|
|
6
|
-
files: [
|
|
7
|
-
{
|
|
8
|
-
path: "src/steps.ts",
|
|
9
|
-
before: ["const zero = 0"],
|
|
10
|
-
after: ["const zero = 0", "const one = 1", "const two = 2", "const three = 3"],
|
|
11
|
-
},
|
|
12
|
-
],
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
describe("knowing which line you are on", () => {
|
|
16
|
-
it("highlights the line the cursor is on, and only that line", async () => {
|
|
17
|
-
// ARRANGE
|
|
18
|
-
await using driver = await TestDriver.create()
|
|
19
|
-
await driver.branch.create(numbered)
|
|
20
|
-
await driver.screen.open()
|
|
21
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
22
|
-
|
|
23
|
-
// ACT
|
|
24
|
-
await driver.screen.pressKeys(["j", "j"])
|
|
25
|
-
|
|
26
|
-
// ASSERT
|
|
27
|
-
const highlighted = await driver.screen.findHighlighted(palette.cursor)
|
|
28
|
-
expect(highlighted).toHaveLength(1)
|
|
29
|
-
expect(highlighted[0]).toContain("const two = 2")
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it("highlights every line of a selection", async () => {
|
|
33
|
-
// ARRANGE
|
|
34
|
-
await using driver = await TestDriver.create()
|
|
35
|
-
await driver.branch.create(numbered)
|
|
36
|
-
await driver.screen.open()
|
|
37
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
38
|
-
|
|
39
|
-
// ACT
|
|
40
|
-
await driver.screen.pressKeys(["j", "v", "j", "j"])
|
|
41
|
-
|
|
42
|
-
// ASSERT
|
|
43
|
-
const selected = await driver.screen.findHighlighted(palette.selection)
|
|
44
|
-
expect(selected.map((line) => line.trim())).toEqual(
|
|
45
|
-
expect.arrayContaining([expect.stringContaining("const one = 1")]),
|
|
46
|
-
)
|
|
47
|
-
expect(selected).toHaveLength(2)
|
|
48
|
-
})
|
|
49
|
-
})
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
|
|
4
|
-
describe("handing review comments to the agent", () => {
|
|
5
|
-
it("gives the agent every comment written since it last looked", async () => {
|
|
6
|
-
// ARRANGE
|
|
7
|
-
await using driver = await TestDriver.create()
|
|
8
|
-
const branch = await driver.branch.create()
|
|
9
|
-
await driver.app.runComment({
|
|
10
|
-
branch: branch.name,
|
|
11
|
-
file: "src/api.ts",
|
|
12
|
-
start: 4,
|
|
13
|
-
end: 4,
|
|
14
|
-
body: "why third",
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
// ACT
|
|
18
|
-
const result = await driver.app.runTake(branch.worktree)
|
|
19
|
-
|
|
20
|
-
// ASSERT
|
|
21
|
-
expect(result.envelope).toMatchObject({
|
|
22
|
-
ok: true,
|
|
23
|
-
comments: [{ body: "why third", file: "src/api.ts", side: "new", start: 4, end: 4 }],
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it("does not hand the same comment to the agent twice", async () => {
|
|
28
|
-
// ARRANGE
|
|
29
|
-
await using driver = await TestDriver.create()
|
|
30
|
-
const branch = await driver.branch.create()
|
|
31
|
-
await driver.app.runComment({
|
|
32
|
-
branch: branch.name,
|
|
33
|
-
file: "src/api.ts",
|
|
34
|
-
start: 4,
|
|
35
|
-
end: 4,
|
|
36
|
-
body: "why third",
|
|
37
|
-
})
|
|
38
|
-
await driver.app.runTake(branch.worktree)
|
|
39
|
-
|
|
40
|
-
// ACT
|
|
41
|
-
const result = await driver.app.runTake(branch.worktree)
|
|
42
|
-
|
|
43
|
-
// ASSERT
|
|
44
|
-
expect(result.envelope).toMatchObject({ ok: true, comments: [] })
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it("keeps handing over comments written after the agent caught up", async () => {
|
|
48
|
-
// ARRANGE
|
|
49
|
-
await using driver = await TestDriver.create()
|
|
50
|
-
const branch = await driver.branch.create()
|
|
51
|
-
await driver.app.runComment({
|
|
52
|
-
branch: branch.name,
|
|
53
|
-
file: "src/api.ts",
|
|
54
|
-
start: 4,
|
|
55
|
-
end: 4,
|
|
56
|
-
body: "first",
|
|
57
|
-
})
|
|
58
|
-
await driver.app.runTake(branch.worktree)
|
|
59
|
-
|
|
60
|
-
// ACT
|
|
61
|
-
await driver.app.runComment({
|
|
62
|
-
branch: branch.name,
|
|
63
|
-
file: "src/api.ts",
|
|
64
|
-
start: 5,
|
|
65
|
-
end: 5,
|
|
66
|
-
body: "second",
|
|
67
|
-
})
|
|
68
|
-
const result = await driver.app.runTake(branch.worktree)
|
|
69
|
-
|
|
70
|
-
// ASSERT
|
|
71
|
-
expect(result.envelope).toMatchObject({ ok: true, comments: [{ body: "second" }] })
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it("still remembers which files were vouched after the agent takes comments", async () => {
|
|
75
|
-
// ARRANGE
|
|
76
|
-
await using driver = await TestDriver.create()
|
|
77
|
-
const branch = await driver.branch.create()
|
|
78
|
-
await driver.app.runVouch({ branch: branch.name, file: "src/api.ts" })
|
|
79
|
-
await driver.app.runComment({
|
|
80
|
-
branch: branch.name,
|
|
81
|
-
file: "src/api.ts",
|
|
82
|
-
start: 4,
|
|
83
|
-
end: 4,
|
|
84
|
-
body: "why third",
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
// ACT
|
|
88
|
-
await driver.app.runTake(branch.worktree)
|
|
89
|
-
const result = await driver.app.runProgress(branch.name)
|
|
90
|
-
|
|
91
|
-
// ASSERT
|
|
92
|
-
expect(result.envelope).toMatchObject({ vouched: ["src/api.ts"], total: 1 })
|
|
93
|
-
})
|
|
94
|
-
})
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { readdir, readFile } from "node:fs/promises"
|
|
2
|
-
import { join } from "node:path"
|
|
3
|
-
import { Effect } from "effect"
|
|
4
|
-
import { reportsDir, Store, storeAt, type Batch } from "../../../service/store/index.ts"
|
|
5
|
-
import type { DriverState } from "../../state.ts"
|
|
6
|
-
|
|
7
|
-
export type DeliveredComment = {
|
|
8
|
-
readonly body: string
|
|
9
|
-
readonly file: string
|
|
10
|
-
readonly side: string
|
|
11
|
-
readonly start: number
|
|
12
|
-
readonly end: number
|
|
13
|
-
readonly snippet: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class AgentTestDriver {
|
|
17
|
-
private readonly state: DriverState
|
|
18
|
-
|
|
19
|
-
constructor(state: DriverState) {
|
|
20
|
-
this.state = state
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async listReports(): Promise<ReadonlyArray<string>> {
|
|
24
|
-
const directory = reportsDir(this.state.storeRoot)
|
|
25
|
-
const names = await readdir(directory).catch(() => [])
|
|
26
|
-
return Promise.all(names.map((name) => readFile(join(directory, name), "utf8")))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async listBatches(worktree: string): Promise<ReadonlyArray<Batch>> {
|
|
30
|
-
const read = Effect.gen(function* () {
|
|
31
|
-
const store = yield* Store
|
|
32
|
-
return yield* store.inbox(worktree)
|
|
33
|
-
})
|
|
34
|
-
return Effect.runPromise(read.pipe(Effect.provide(storeAt(this.state.storeRoot))))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async listComments(worktree: string): Promise<ReadonlyArray<DeliveredComment>> {
|
|
38
|
-
const batches = await this.listBatches(worktree)
|
|
39
|
-
return batches.flatMap((batch) =>
|
|
40
|
-
batch.comments.map((comment) => ({
|
|
41
|
-
body: comment.body,
|
|
42
|
-
file: comment.anchor.path,
|
|
43
|
-
side: comment.anchor.side,
|
|
44
|
-
start: comment.anchor.start,
|
|
45
|
-
end: comment.anchor.end,
|
|
46
|
-
snippet: comment.anchor.snippet,
|
|
47
|
-
})),
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
}
|