refactor(core): consolidate references

This commit is contained in:
Dax Raad
2026-06-09 11:38:35 -04:00
parent 137992ca85
commit f76ca58a54
63 changed files with 683 additions and 2722 deletions
@@ -11,7 +11,7 @@ afterEach(async () => {
})
describe("reference HttpApi", () => {
test("lists presentation-safe references resolved in the server workspace", async () => {
test("lists usable references resolved in the server workspace", async () => {
await using tmp = await tmpdir({
config: {
formatter: false,
@@ -24,30 +24,31 @@ describe("reference HttpApi", () => {
},
})
const response = await Server.Default().app.request("/reference", {
const response = await Server.Default().app.request("/api/reference", {
headers: { "x-opencode-directory": tmp.path },
})
expect(response.status).toBe(200)
expect(await response.json()).toEqual([
{
name: "docs",
kind: "local",
path: path.join(tmp.path, "docs"),
},
{
name: "effect",
kind: "git",
repository: "Effect-TS/effect",
path: path.join(Global.Path.repos, "github.com", "Effect-TS", "effect"),
branch: "main",
},
{
name: "bad",
kind: "invalid",
repository: "not-a-repo",
message: "Repository must be a git URL, host/path reference, or GitHub owner/repo shorthand",
},
])
const body = await response.json()
expect(body).toMatchObject({ location: { directory: tmp.path } })
expect(body.data).toEqual([
{
name: "docs",
path: path.join(tmp.path, "docs"),
source: {
type: "local",
path: path.join(tmp.path, "docs"),
},
},
{
name: "effect",
path: path.join(Global.Path.repos, "github.com", "Effect-TS", "effect"),
source: {
type: "git",
repository: "Effect-TS/effect",
branch: "main",
},
},
])
})
})