Repository navigation
Expand file tree
/
Copy pathorient.test.ts
More file actions
115 lines (105 loc) · 4.71 KB
/
Copy pathorient.test.ts
File metadata and controls
115 lines (105 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { describe, expect } from "bun:test"
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
import { Effect, Layer } from "effect"
import { Command } from "../../src/command"
import { TestInstance, testInstanceStoreLayer } from "../fixture/fixture"
import { testEffect } from "../lib/effect"
const it = testEffect(
Layer.mergeAll(LayerNode.compile(Command.node), LayerNode.compile(CrossSpawnSpawner.node), testInstanceStoreLayer),
)
// Acceptance criteria from issue #7:
// 1. /orient shows up in the help list
// 2. a repo with a README gets a 3 to 5 sentence summary of the project's purpose
// 3. a repo with no README still gets a summary from the manifest and directory structure
// 4. the command does not create or modify any files
describe("/orient command", () => {
it.instance("is registered as a built-in command", () =>
Effect.gen(function* () {
const command = yield* Command.Service
const names = (yield* command.list()).map((item) => item.name)
expect(names).toContain(Command.Default.ORIENT)
}),
)
it.instance("shows a description in the help list", () =>
Effect.gen(function* () {
const command = yield* Command.Service
const orient = yield* command.get(Command.Default.ORIENT)
expect(orient?.description).toBe("summarize what this project is and does")
expect(orient?.source).toBe("command")
}),
)
it.instance("runs under the read-only orient agent so it cannot edit files", () =>
Effect.gen(function* () {
const command = yield* Command.Service
const orient = yield* command.get(Command.Default.ORIENT)
expect(orient?.agent).toBe("orient")
}),
)
it.instance(
"points the prompt at the current repo",
() =>
Effect.gen(function* () {
const test = yield* TestInstance
const command = yield* Command.Service
const orient = yield* command.get(Command.Default.ORIENT)
const template = yield* Effect.promise(async () => orient!.template)
expect(template).toContain(test.directory)
expect(template).not.toContain("${path}")
}),
{ git: true },
)
it.instance("asks for a 3 to 5 sentence summary of the project's purpose", () =>
Effect.gen(function* () {
const command = yield* Command.Service
const orient = yield* command.get(Command.Default.ORIENT)
const template = yield* Effect.promise(async () => orient!.template)
expect(template).toContain("3 to 5 sentence summary")
expect(template).toContain("what this project is and what it does")
expect(template).toContain("Exactly 3 to 5 sentences of prose")
}),
)
it.instance("reads the README first", () =>
Effect.gen(function* () {
const command = yield* Command.Service
const orient = yield* command.get(Command.Default.ORIENT)
const template = yield* Effect.promise(async () => orient!.template)
expect(template).toContain("1. `README*` at the repository root")
}),
)
it.instance("falls back to the manifest and then the directory structure when there is no README", () =>
Effect.gen(function* () {
const command = yield* Command.Service
const orient = yield* command.get(Command.Default.ORIENT)
const template = yield* Effect.promise(async () => orient!.template)
const readme = template.indexOf("1. `README*`")
const manifest = template.indexOf("2. If there is no README")
const structure = template.indexOf("3. If there is still no clear picture")
expect(readme).toBeGreaterThan(-1)
expect(manifest).toBeGreaterThan(readme)
expect(structure).toBeGreaterThan(manifest)
for (const file of ["package.json", "pyproject.toml", "Cargo.toml", "go.mod"]) {
expect(template).toContain(file)
}
expect(template).toContain("list the top-level directories")
expect(template).toContain("If the repository has no README and no manifest, say so plainly")
}),
)
it.instance("forbids creating, editing, or deleting files", () =>
Effect.gen(function* () {
const command = yield* Command.Service
const orient = yield* command.get(Command.Default.ORIENT)
const template = yield* Effect.promise(async () => orient!.template)
expect(template).toContain("This is a read-only task")
expect(template).toContain("Do not create, edit, or delete any files")
expect(template).toContain("Do not run the build or tests")
}),
)
it.instance("accepts an optional focus argument", () =>
Effect.gen(function* () {
const command = yield* Command.Service
const orient = yield* command.get(Command.Default.ORIENT)
expect(orient?.hints).toEqual(["$ARGUMENTS"])
}),
)
})