@eliya-oss/agent-diff 0.1.0-alpha.1 → 0.1.0-alpha.100
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/adr/README.md +3 -0
- package/.agents/prd/README.md +2 -2
- package/CHANGELOG.md +666 -0
- package/README.md +37 -79
- package/bin/adiff.js +80 -2
- package/dist/main.js +17611 -0
- package/package.json +14 -10
- package/skills/adiff/SKILL.md +140 -26
- 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,106 +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 rowWith = (frame: string, text: string): string =>
|
|
15
|
-
frame.split("\n").find((line) => line.includes(text)) ?? ""
|
|
16
|
-
|
|
17
|
-
describe("comments that have already gone to the agent", () => {
|
|
18
|
-
it("stays in the diff after it is sent", async () => {
|
|
19
|
-
// ARRANGE
|
|
20
|
-
await using driver = await TestDriver.create()
|
|
21
|
-
await driver.branch.create(oneFile)
|
|
22
|
-
await driver.screen.open()
|
|
23
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
24
|
-
await driver.screen.pressKeys(["j"])
|
|
25
|
-
await driver.screen.pressKeys(["c"])
|
|
26
|
-
await driver.screen.typeText("already said this")
|
|
27
|
-
|
|
28
|
-
// ACT
|
|
29
|
-
await driver.screen.pressCtrl("s")
|
|
30
|
-
|
|
31
|
-
// ASSERT
|
|
32
|
-
const frame = await driver.screen.getFrame()
|
|
33
|
-
const lines = frame.split("\n")
|
|
34
|
-
const anchor = lines.findIndex((line) => line.includes("const first = 1"))
|
|
35
|
-
expect(lines[anchor + 1]).toContain("✓ sent")
|
|
36
|
-
expect(lines.findIndex((line) => line.includes("already said this"))).toBe(anchor + 2)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it("comes back when the review is reopened", async () => {
|
|
40
|
-
// ARRANGE
|
|
41
|
-
await using driver = await TestDriver.create()
|
|
42
|
-
const branch = await driver.branch.create(oneFile)
|
|
43
|
-
await driver.screen.open()
|
|
44
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
45
|
-
await driver.screen.pressKeys(["j"])
|
|
46
|
-
await driver.screen.pressKeys(["c"])
|
|
47
|
-
await driver.screen.typeText("said this last time")
|
|
48
|
-
await driver.screen.pressCtrl("s")
|
|
49
|
-
await driver.agent.listComments(branch.worktree)
|
|
50
|
-
await driver.screen.pressEscape()
|
|
51
|
-
|
|
52
|
-
// ACT
|
|
53
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
54
|
-
|
|
55
|
-
// ASSERT
|
|
56
|
-
expect(rowWith(await driver.screen.getFrame(), "said this last time")).not.toHaveLength(0)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it("is marked as gone, not waiting to go", async () => {
|
|
60
|
-
// ARRANGE
|
|
61
|
-
await using driver = await TestDriver.create()
|
|
62
|
-
await driver.branch.create(oneFile)
|
|
63
|
-
await driver.screen.open()
|
|
64
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
65
|
-
await driver.screen.pressKeys(["j"])
|
|
66
|
-
await driver.screen.pressKeys(["c"])
|
|
67
|
-
await driver.screen.typeText("sent one")
|
|
68
|
-
await driver.screen.pressCtrl("s")
|
|
69
|
-
await driver.screen.pressKeys(["j"])
|
|
70
|
-
await driver.screen.pressKeys(["c"])
|
|
71
|
-
await driver.screen.typeText("staged one")
|
|
72
|
-
await driver.screen.pressCtrl("a")
|
|
73
|
-
|
|
74
|
-
// ASSERT
|
|
75
|
-
const frame = await driver.screen.getFrame()
|
|
76
|
-
const lines = frame.split("\n")
|
|
77
|
-
const goneAt = lines.findIndex((line) => line.includes("sent one"))
|
|
78
|
-
const waitingAt = lines.findIndex((line) => line.includes("staged one"))
|
|
79
|
-
expect(lines[goneAt - 1]).toContain("✓ sent")
|
|
80
|
-
expect(lines[waitingAt - 1]).toContain("○ staged")
|
|
81
|
-
const gone = await driver.screen.listForegroundsOn("sent one")
|
|
82
|
-
const waiting = await driver.screen.listForegroundsOn("staged one")
|
|
83
|
-
expect(gone).not.toEqual(waiting)
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
describe("walking past comments already sent", () => {
|
|
88
|
-
it("stops on a sent comment too", async () => {
|
|
89
|
-
// ARRANGE
|
|
90
|
-
await using driver = await TestDriver.create()
|
|
91
|
-
await driver.branch.create(oneFile)
|
|
92
|
-
await driver.screen.open()
|
|
93
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
94
|
-
await driver.screen.pressKeys(["j", "j"])
|
|
95
|
-
await driver.screen.pressKeys(["c"])
|
|
96
|
-
await driver.screen.typeText("gone already")
|
|
97
|
-
await driver.screen.pressCtrl("s")
|
|
98
|
-
await driver.screen.pressKeys(["g"])
|
|
99
|
-
|
|
100
|
-
// ACT
|
|
101
|
-
await driver.screen.pressKeys(["n"])
|
|
102
|
-
|
|
103
|
-
// ASSERT
|
|
104
|
-
expect(rowWith(await driver.screen.getFrame(), "const second = 2")).toContain("▎")
|
|
105
|
-
})
|
|
106
|
-
})
|
package/src/testing/state.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process"
|
|
2
|
-
import { mkdtemp, rm } from "node:fs/promises"
|
|
3
|
-
import { tmpdir } from "node:os"
|
|
4
|
-
import { join } from "node:path"
|
|
5
|
-
import { promisify } from "node:util"
|
|
6
|
-
|
|
7
|
-
const exec = promisify(execFile)
|
|
8
|
-
|
|
9
|
-
export type DriverOptions = { readonly remember?: boolean }
|
|
10
|
-
|
|
11
|
-
export type DriverState = {
|
|
12
|
-
readonly repo: string
|
|
13
|
-
readonly sessionPath: string | undefined
|
|
14
|
-
readonly storeRoot: string
|
|
15
|
-
readonly git: (cwd: string, args: ReadonlyArray<string>) => Promise<string>
|
|
16
|
-
readonly dispose: () => Promise<void>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const IDENTITY = [
|
|
20
|
-
["config", "user.email", "driver@adiff.test"],
|
|
21
|
-
["config", "user.name", "adiff driver"],
|
|
22
|
-
["config", "commit.gpgsign", "false"],
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
export const series = async <A>(
|
|
26
|
-
items: ReadonlyArray<A>,
|
|
27
|
-
run: (item: A) => Promise<unknown>,
|
|
28
|
-
): Promise<void> => {
|
|
29
|
-
const [head, ...rest] = items
|
|
30
|
-
if (head === undefined) return
|
|
31
|
-
await run(head)
|
|
32
|
-
await series(rest, run)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const createDriverState = async (options: DriverOptions = {}): Promise<DriverState> => {
|
|
36
|
-
const workspace = await mkdtemp(join(tmpdir(), "adiff-"))
|
|
37
|
-
const repo = join(workspace, "repo")
|
|
38
|
-
const storeRoot = join(workspace, "store")
|
|
39
|
-
|
|
40
|
-
const git = async (cwd: string, args: ReadonlyArray<string>): Promise<string> => {
|
|
41
|
-
const { stdout } = await exec("git", [...args], { cwd, encoding: "utf8" })
|
|
42
|
-
return stdout
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
await exec("git", ["init", "-q", "-b", "master", repo], { cwd: workspace })
|
|
46
|
-
await series(IDENTITY, (args) => git(repo, args))
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
repo,
|
|
50
|
-
sessionPath: options.remember === true ? join(workspace, "session.json") : undefined,
|
|
51
|
-
storeRoot,
|
|
52
|
-
git,
|
|
53
|
-
dispose: () => rm(workspace, { recursive: true, force: true }),
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
|
|
4
|
-
const steps = (count: number, mark: string): ReadonlyArray<string> =>
|
|
5
|
-
Array.from({ length: count }, (_, index) => ` const step${index} = ${mark}(${index})`)
|
|
6
|
-
|
|
7
|
-
const shaped = (mark: string): ReadonlyArray<string> => [
|
|
8
|
-
"import { logger } from './logger'",
|
|
9
|
-
"",
|
|
10
|
-
"export type ClientInput = {",
|
|
11
|
-
" readonly tenant: string",
|
|
12
|
-
"}",
|
|
13
|
-
"",
|
|
14
|
-
"export const client = async (input: ClientInput) => {",
|
|
15
|
-
...steps(40, mark),
|
|
16
|
-
" return input",
|
|
17
|
-
"}",
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
const file = { files: [{ path: "src/client.ts", before: shaped("settle"), after: shaped("resolve") }] }
|
|
21
|
-
|
|
22
|
-
const pinnedRows = (frame: string): ReadonlyArray<string> =>
|
|
23
|
-
frame
|
|
24
|
-
.split("\n")
|
|
25
|
-
.slice(1)
|
|
26
|
-
.map((line) => line.slice(36).trim())
|
|
27
|
-
.filter((line) => line.startsWith("export "))
|
|
28
|
-
|
|
29
|
-
describe("pinning the scope you are actually inside", () => {
|
|
30
|
-
it("names the enclosing function, not a type declared above it", async () => {
|
|
31
|
-
// ARRANGE
|
|
32
|
-
await using driver = await TestDriver.create()
|
|
33
|
-
await driver.branch.create(file)
|
|
34
|
-
await driver.screen.open()
|
|
35
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
36
|
-
|
|
37
|
-
// ACT
|
|
38
|
-
await driver.screen.scroll("down", 6)
|
|
39
|
-
|
|
40
|
-
// ASSERT
|
|
41
|
-
const shown = pinnedRows(await driver.screen.getFrame())
|
|
42
|
-
expect(shown[0]).toContain("export const client = async")
|
|
43
|
-
expect(shown[0]).not.toContain("ClientInput = {")
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
describe("lining up the sign column", () => {
|
|
48
|
-
it("starts context and changed code in the same column", async () => {
|
|
49
|
-
// ARRANGE
|
|
50
|
-
await using driver = await TestDriver.create()
|
|
51
|
-
await driver.branch.create(file)
|
|
52
|
-
await driver.screen.open()
|
|
53
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
54
|
-
|
|
55
|
-
// ACT
|
|
56
|
-
const rows = (await driver.screen.getFrame()).split("\n")
|
|
57
|
-
|
|
58
|
-
// ASSERT
|
|
59
|
-
const context = rows.find((line) => line.includes("export const client = async"))
|
|
60
|
-
const changed = rows.find((line) => line.includes("const step0 = "))
|
|
61
|
-
expect(context).toBeDefined()
|
|
62
|
-
expect(changed).toBeDefined()
|
|
63
|
-
expect((changed ?? "").indexOf("const step0")).toBe(
|
|
64
|
-
(context ?? "").indexOf("export const client") + 4,
|
|
65
|
-
)
|
|
66
|
-
})
|
|
67
|
-
})
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
|
|
4
|
-
const kept = Array.from({ length: 20 }, (_, index) => ` const kept${index} = ${index}`)
|
|
5
|
-
|
|
6
|
-
const body = (mark: string): ReadonlyArray<string> =>
|
|
7
|
-
Array.from({ length: 40 }, (_, index) => ` step${index}("${mark}")`)
|
|
8
|
-
|
|
9
|
-
const nested = (mark: string): ReadonlyArray<string> => [
|
|
10
|
-
"export function outer(input: string) {",
|
|
11
|
-
" if (ready(input)) {",
|
|
12
|
-
...kept,
|
|
13
|
-
...body(mark),
|
|
14
|
-
" }",
|
|
15
|
-
"}",
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
const deep = { files: [{ path: "src/deep.ts", before: nested("before"), after: nested("after") }] }
|
|
19
|
-
|
|
20
|
-
const pinned = (frame: string): ReadonlyArray<string> =>
|
|
21
|
-
frame
|
|
22
|
-
.split("\n")
|
|
23
|
-
.slice(1)
|
|
24
|
-
.map((line) => line.slice(36).trim())
|
|
25
|
-
.filter((line) => /^(export function outer|if \(ready)/.test(line))
|
|
26
|
-
|
|
27
|
-
describe("keeping the enclosing scope on screen", () => {
|
|
28
|
-
it("pins the whole chain once you are inside it", async () => {
|
|
29
|
-
// ARRANGE
|
|
30
|
-
await using driver = await TestDriver.create()
|
|
31
|
-
await driver.branch.create(deep)
|
|
32
|
-
await driver.screen.open()
|
|
33
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
34
|
-
|
|
35
|
-
// ACT
|
|
36
|
-
await driver.screen.pressKeys(["G"])
|
|
37
|
-
|
|
38
|
-
// ASSERT
|
|
39
|
-
const shown = pinned(await driver.screen.getFrame())
|
|
40
|
-
expect(shown).toHaveLength(2)
|
|
41
|
-
expect(shown[0]).toContain("export function outer")
|
|
42
|
-
expect(shown[1]).toContain("if (ready")
|
|
43
|
-
expect(driver.screen.renderCrashes()).toEqual([])
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it("pins nothing when the first line of the file is on screen", async () => {
|
|
47
|
-
// ARRANGE
|
|
48
|
-
await using driver = await TestDriver.create()
|
|
49
|
-
await driver.branch.create({
|
|
50
|
-
files: [
|
|
51
|
-
{
|
|
52
|
-
path: "src/top.ts",
|
|
53
|
-
before: ["export function outer(input: string) {", " if (ready(input)) {", " }", "}"],
|
|
54
|
-
after: [
|
|
55
|
-
"export function outer(input: string) {",
|
|
56
|
-
" if (ready(input)) {",
|
|
57
|
-
" added()",
|
|
58
|
-
" }",
|
|
59
|
-
"}",
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
})
|
|
64
|
-
await driver.screen.open()
|
|
65
|
-
|
|
66
|
-
// ACT
|
|
67
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
68
|
-
|
|
69
|
-
// ASSERT
|
|
70
|
-
expect(pinned(await driver.screen.getFrame())).toHaveLength(0)
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
describe("the pin looks like the code it names", () => {
|
|
75
|
-
it("highlights the pinned line the same way the diff does", async () => {
|
|
76
|
-
// ARRANGE
|
|
77
|
-
await using driver = await TestDriver.create()
|
|
78
|
-
await driver.branch.create(deep)
|
|
79
|
-
await driver.screen.open()
|
|
80
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
81
|
-
|
|
82
|
-
// ACT
|
|
83
|
-
await driver.screen.pressKeys(["G"])
|
|
84
|
-
|
|
85
|
-
// ASSERT
|
|
86
|
-
const keyword = await driver.screen.findForeground("#bb9af7")
|
|
87
|
-
const pinnedRow = keyword.find((line) => line.includes("export function outer"))
|
|
88
|
-
expect(pinnedRow).toBeDefined()
|
|
89
|
-
})
|
|
90
|
-
})
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
import type { StoryInput } from "./index.ts"
|
|
4
|
-
|
|
5
|
-
const change = (path: string, name: string) => ({
|
|
6
|
-
path,
|
|
7
|
-
before: [`const ${name} = 1`],
|
|
8
|
-
after: [`const ${name} = 1`, `const ${name}Added = 2`],
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
const threeFiles = {
|
|
12
|
-
files: [
|
|
13
|
-
change("src/model.ts", "model"),
|
|
14
|
-
change("src/api.ts", "api"),
|
|
15
|
-
change("src/ui/Panel.tsx", "panel"),
|
|
16
|
-
],
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const story: StoryInput = {
|
|
20
|
-
summary: "Invitations, end to end",
|
|
21
|
-
steps: [
|
|
22
|
-
{
|
|
23
|
-
title: "Add the invitation data model",
|
|
24
|
-
spans: [{ path: "src/model.ts", start: 1, end: 2 }],
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
title: "Add the invitation API",
|
|
28
|
-
spans: [{ path: "src/api.ts", start: 1, end: 2 }],
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const paneOf = (frame: string): string =>
|
|
34
|
-
frame
|
|
35
|
-
.split("\n")
|
|
36
|
-
.slice(1)
|
|
37
|
-
.map((line) => line.slice(0, 32))
|
|
38
|
-
.join("\n")
|
|
39
|
-
|
|
40
|
-
describe("walking a review by the argument instead of the filesystem", () => {
|
|
41
|
-
it("lists the story's steps, numbered and counted, in place of the file tree", async () => {
|
|
42
|
-
// ARRANGE
|
|
43
|
-
await using driver = await TestDriver.create()
|
|
44
|
-
const branch = await driver.branch.create(threeFiles)
|
|
45
|
-
await driver.app.runStorySet(branch.worktree, story)
|
|
46
|
-
await driver.screen.open()
|
|
47
|
-
|
|
48
|
-
// ACT
|
|
49
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
50
|
-
|
|
51
|
-
// ASSERT
|
|
52
|
-
const pane = paneOf(await driver.screen.getFrame())
|
|
53
|
-
expect(pane).toContain("1. Add the invitation data")
|
|
54
|
-
expect(pane).toContain("2. Add the invitation API")
|
|
55
|
-
expect(pane).not.toContain("Panel.tsx")
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it("puts the files no step claims in a group of their own, so nothing hides", async () => {
|
|
59
|
-
// ARRANGE
|
|
60
|
-
await using driver = await TestDriver.create()
|
|
61
|
-
const branch = await driver.branch.create(threeFiles)
|
|
62
|
-
await driver.app.runStorySet(branch.worktree, story)
|
|
63
|
-
await driver.screen.open()
|
|
64
|
-
|
|
65
|
-
// ACT
|
|
66
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
67
|
-
|
|
68
|
-
// ASSERT
|
|
69
|
-
expect(paneOf(await driver.screen.getFrame())).toContain("not in any step")
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it("scopes the diff to the step the reviewer is standing on", async () => {
|
|
73
|
-
// ARRANGE
|
|
74
|
-
await using driver = await TestDriver.create()
|
|
75
|
-
const branch = await driver.branch.create(threeFiles)
|
|
76
|
-
await driver.app.runStorySet(branch.worktree, story)
|
|
77
|
-
await driver.screen.open()
|
|
78
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
79
|
-
expect(await driver.screen.getFrame()).toContain("src/model.ts")
|
|
80
|
-
|
|
81
|
-
// ACT
|
|
82
|
-
await driver.screen.pressKeys(["TAB", "j"])
|
|
83
|
-
|
|
84
|
-
// ASSERT
|
|
85
|
-
const frame = await driver.screen.getFrame()
|
|
86
|
-
expect(frame).toContain("src/api.ts")
|
|
87
|
-
expect(frame).toContain("apiAdded")
|
|
88
|
-
expect(frame).not.toContain("modelAdded")
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it("goes back to the file tree when the reviewer asks for it", async () => {
|
|
92
|
-
// ARRANGE
|
|
93
|
-
await using driver = await TestDriver.create()
|
|
94
|
-
const branch = await driver.branch.create(threeFiles)
|
|
95
|
-
await driver.app.runStorySet(branch.worktree, story)
|
|
96
|
-
await driver.screen.open()
|
|
97
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
98
|
-
|
|
99
|
-
// ACT
|
|
100
|
-
await driver.screen.pressKeys(["s"])
|
|
101
|
-
|
|
102
|
-
// ASSERT
|
|
103
|
-
const pane = paneOf(await driver.screen.getFrame())
|
|
104
|
-
expect(pane).toContain("Panel.tsx")
|
|
105
|
-
expect(pane).not.toContain("1. Add the invitation data")
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it("shows the file tree when the branch has no story at all", async () => {
|
|
109
|
-
// ARRANGE
|
|
110
|
-
await using driver = await TestDriver.create()
|
|
111
|
-
await driver.branch.create(threeFiles)
|
|
112
|
-
await driver.screen.open()
|
|
113
|
-
|
|
114
|
-
// ACT
|
|
115
|
-
await driver.screen.pressKeys(["RETURN"])
|
|
116
|
-
|
|
117
|
-
// ASSERT
|
|
118
|
-
const pane = paneOf(await driver.screen.getFrame())
|
|
119
|
-
expect(pane).toContain("Panel.tsx")
|
|
120
|
-
expect(pane).not.toContain("not in any step")
|
|
121
|
-
})
|
|
122
|
-
})
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { TestDriver } from "./index.ts"
|
|
3
|
-
import type { StoryInput } from "./index.ts"
|
|
4
|
-
|
|
5
|
-
const twoFiles = {
|
|
6
|
-
files: [
|
|
7
|
-
{
|
|
8
|
-
path: "src/model.ts",
|
|
9
|
-
before: ["const model = 1"],
|
|
10
|
-
after: ["const model = 1", "const invite = 2"],
|
|
11
|
-
},
|
|
12
|
-
{ path: "src/api.ts", before: ["const api = 1"], after: ["const api = 1", "const post = 2"] },
|
|
13
|
-
],
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const wholeStory: StoryInput = {
|
|
17
|
-
summary: "Invitations, end to end",
|
|
18
|
-
steps: [
|
|
19
|
-
{
|
|
20
|
-
title: "Add the invitation data model",
|
|
21
|
-
note: "The record every later step leans on",
|
|
22
|
-
spans: [{ path: "src/model.ts", start: 1, end: 2 }],
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
title: "Add the invitation API",
|
|
26
|
-
spans: [{ path: "src/api.ts", start: 1, end: 2 }],
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const halfStory: StoryInput = {
|
|
32
|
-
summary: "Half a change",
|
|
33
|
-
steps: [
|
|
34
|
-
{
|
|
35
|
-
title: "Add the invitation data model",
|
|
36
|
-
spans: [{ path: "src/model.ts", start: 1, end: 2 }],
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
type Report = {
|
|
42
|
-
readonly version: number
|
|
43
|
-
readonly parent?: number
|
|
44
|
-
readonly stale: boolean
|
|
45
|
-
readonly summary: string
|
|
46
|
-
readonly covered: number
|
|
47
|
-
readonly total: number
|
|
48
|
-
readonly uncovered: ReadonlyArray<{ readonly path: string }>
|
|
49
|
-
readonly vanished: ReadonlyArray<string>
|
|
50
|
-
readonly steps: ReadonlyArray<{ readonly title: string; readonly files: ReadonlyArray<string> }>
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const storyOf = (envelope: unknown): Report => (envelope as { story: Report }).story
|
|
54
|
-
|
|
55
|
-
describe("reading a diff in the order the agent built it", () => {
|
|
56
|
-
it("hands the reviewer the steps the agent wrote, in the agent's order", async () => {
|
|
57
|
-
// ARRANGE
|
|
58
|
-
await using driver = await TestDriver.create()
|
|
59
|
-
const branch = await driver.branch.create(twoFiles)
|
|
60
|
-
await driver.app.runStorySet(branch.worktree, wholeStory)
|
|
61
|
-
|
|
62
|
-
// ACT
|
|
63
|
-
const result = await driver.app.runStoryShow(branch.worktree)
|
|
64
|
-
|
|
65
|
-
// ASSERT
|
|
66
|
-
expect(result.code).toBe(0)
|
|
67
|
-
const story = storyOf(result.envelope)
|
|
68
|
-
expect(story.summary).toBe("Invitations, end to end")
|
|
69
|
-
expect(story.steps.map((step) => step.title)).toEqual([
|
|
70
|
-
"Add the invitation data model",
|
|
71
|
-
"Add the invitation API",
|
|
72
|
-
])
|
|
73
|
-
expect(story.steps.map((step) => step.files)).toEqual([["src/model.ts"], ["src/api.ts"]])
|
|
74
|
-
expect(story.covered).toBe(story.total)
|
|
75
|
-
expect(story.uncovered).toEqual([])
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it("reports the hunks no step claims, so a story cannot hide code", async () => {
|
|
79
|
-
// ARRANGE
|
|
80
|
-
await using driver = await TestDriver.create()
|
|
81
|
-
const branch = await driver.branch.create(twoFiles)
|
|
82
|
-
|
|
83
|
-
// ACT
|
|
84
|
-
const written = await driver.app.runStorySet(branch.worktree, halfStory)
|
|
85
|
-
|
|
86
|
-
// ASSERT
|
|
87
|
-
const story = storyOf(written.envelope)
|
|
88
|
-
expect(story.covered).toBe(1)
|
|
89
|
-
expect(story.total).toBe(2)
|
|
90
|
-
expect(story.uncovered.map((span) => span.path)).toEqual(["src/api.ts"])
|
|
91
|
-
const shown = storyOf((await driver.app.runStoryShow(branch.worktree)).envelope)
|
|
92
|
-
expect(shown.uncovered.map((span) => span.path)).toEqual(["src/api.ts"])
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it("supersedes the story it replaces instead of losing the earlier version", async () => {
|
|
96
|
-
// ARRANGE
|
|
97
|
-
await using driver = await TestDriver.create()
|
|
98
|
-
const branch = await driver.branch.create(twoFiles)
|
|
99
|
-
await driver.app.runStorySet(branch.worktree, halfStory)
|
|
100
|
-
|
|
101
|
-
// ACT
|
|
102
|
-
await driver.app.runStorySet(branch.worktree, wholeStory)
|
|
103
|
-
|
|
104
|
-
// ASSERT
|
|
105
|
-
const story = storyOf((await driver.app.runStoryShow(branch.worktree)).envelope)
|
|
106
|
-
expect(story.version).toBe(2)
|
|
107
|
-
expect(story.parent).toBe(1)
|
|
108
|
-
expect(story.stale).toBe(false)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
it("says a story is stale once the branch moves past the commit it describes", async () => {
|
|
112
|
-
// ARRANGE
|
|
113
|
-
await using driver = await TestDriver.create()
|
|
114
|
-
const branch = await driver.branch.create(twoFiles)
|
|
115
|
-
await driver.app.runStorySet(branch.worktree, wholeStory)
|
|
116
|
-
|
|
117
|
-
// ACT
|
|
118
|
-
await driver.branch.commitAll(branch, "ship the invitations")
|
|
119
|
-
|
|
120
|
-
// ASSERT
|
|
121
|
-
const story = storyOf((await driver.app.runStoryShow(branch.worktree)).envelope)
|
|
122
|
-
expect(story.stale).toBe(true)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it("returns only the asked-for fields, so a caller pays for what it reads", async () => {
|
|
126
|
-
// ARRANGE
|
|
127
|
-
await using driver = await TestDriver.create()
|
|
128
|
-
const branch = await driver.branch.create(twoFiles)
|
|
129
|
-
await driver.app.runStorySet(branch.worktree, wholeStory)
|
|
130
|
-
|
|
131
|
-
// ACT
|
|
132
|
-
const result = await driver.app.runStoryShow(branch.worktree, ["--fields", "covered,total"])
|
|
133
|
-
|
|
134
|
-
// ASSERT
|
|
135
|
-
expect(result.envelope).toEqual({ ok: true, story: { covered: 2, total: 2 } })
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
it("says there is no story rather than pretending the diff has one", async () => {
|
|
139
|
-
// ARRANGE
|
|
140
|
-
await using driver = await TestDriver.create()
|
|
141
|
-
const branch = await driver.branch.create(twoFiles)
|
|
142
|
-
|
|
143
|
-
// ACT
|
|
144
|
-
const result = await driver.app.runStoryShow(branch.worktree)
|
|
145
|
-
|
|
146
|
-
// ASSERT
|
|
147
|
-
expect(result.code).toBe(3)
|
|
148
|
-
expect(result.stdout).toBe("")
|
|
149
|
-
expect(result.envelope).toMatchObject({ ok: false, error: { type: "NoStory" } })
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
it("refuses a story whose steps say nothing, and says what a story looks like", async () => {
|
|
153
|
-
// ARRANGE
|
|
154
|
-
await using driver = await TestDriver.create()
|
|
155
|
-
const branch = await driver.branch.create(twoFiles)
|
|
156
|
-
|
|
157
|
-
// ACT
|
|
158
|
-
const result = await driver.app.runStorySet(branch.worktree, '{"steps":[{"title":""}]}')
|
|
159
|
-
|
|
160
|
-
// ASSERT
|
|
161
|
-
expect(result.code).toBe(2)
|
|
162
|
-
expect(result.envelope).toMatchObject({
|
|
163
|
-
ok: false,
|
|
164
|
-
error: { type: "MalformedStory", retriable: false },
|
|
165
|
-
})
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
it("names the files a step points at that the branch no longer changes", async () => {
|
|
169
|
-
// ARRANGE
|
|
170
|
-
await using driver = await TestDriver.create()
|
|
171
|
-
const branch = await driver.branch.create(twoFiles)
|
|
172
|
-
|
|
173
|
-
// ACT
|
|
174
|
-
const result = await driver.app.runStorySet(branch.worktree, {
|
|
175
|
-
steps: [
|
|
176
|
-
{ title: "Touch a file that is not here", spans: [{ path: "src/gone.ts", start: 1, end: 2 }] },
|
|
177
|
-
],
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
// ASSERT
|
|
181
|
-
expect(storyOf(result.envelope).vanished).toEqual(["src/gone.ts"])
|
|
182
|
-
})
|
|
183
|
-
})
|