refactor(core): consolidate references
This commit is contained in:
parent
137992ca85
commit
f76ca58a54
63 changed files with 683 additions and 2722 deletions
|
|
@ -12,6 +12,7 @@ import { EventGroup } from "./groups/event"
|
|||
import { AgentGroup } from "./groups/agent"
|
||||
import { HealthGroup } from "./groups/health"
|
||||
import { QuestionGroup } from "./groups/question"
|
||||
import { ReferenceGroup } from "./groups/reference"
|
||||
import { Authorization } from "./middleware/authorization"
|
||||
|
||||
export const Api = HttpApi.make("server")
|
||||
|
|
@ -27,6 +28,7 @@ export const Api = HttpApi.make("server")
|
|||
.add(SkillGroup)
|
||||
.add(EventGroup)
|
||||
.add(QuestionGroup)
|
||||
.add(ReferenceGroup)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
title: "opencode HttpApi",
|
||||
|
|
|
|||
|
|
@ -8,13 +8,11 @@ import { LocationQuery, locationQueryOpenApi, LocationMiddleware } from "./locat
|
|||
const ReadQuery = Schema.Struct({
|
||||
...LocationQuery.fields,
|
||||
path: RelativePath,
|
||||
reference: Schema.String.pipe(Schema.optional),
|
||||
})
|
||||
|
||||
const ListQuery = Schema.Struct({
|
||||
...LocationQuery.fields,
|
||||
path: RelativePath.pipe(Schema.optional),
|
||||
reference: Schema.String.pipe(Schema.optional),
|
||||
})
|
||||
|
||||
export const FileSystemGroup = HttpApiGroup.make("server.fs")
|
||||
|
|
|
|||
28
packages/server/src/groups/reference.ts
Normal file
28
packages/server/src/groups/reference.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { Location } from "@opencode-ai/core/location"
|
||||
import { Reference } from "@opencode-ai/core/reference"
|
||||
import { Schema } from "effect"
|
||||
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
|
||||
import { LocationMiddleware, LocationQuery, locationQueryOpenApi } from "./location"
|
||||
|
||||
export const ReferenceGroup = HttpApiGroup.make("server.reference")
|
||||
.add(
|
||||
HttpApiEndpoint.get("reference.list", "/api/reference", {
|
||||
query: LocationQuery,
|
||||
success: Location.response(Schema.Array(Reference.Info)),
|
||||
})
|
||||
.annotateMerge(locationQueryOpenApi)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "v2.reference.list",
|
||||
summary: "List references",
|
||||
description: "List references available in the requested location.",
|
||||
}),
|
||||
),
|
||||
)
|
||||
.annotateMerge(
|
||||
OpenApi.annotations({
|
||||
title: "reference",
|
||||
description: "Location-scoped project references.",
|
||||
}),
|
||||
)
|
||||
.middleware(LocationMiddleware)
|
||||
|
|
@ -16,6 +16,7 @@ import { EventHandler } from "./handlers/event"
|
|||
import { AgentHandler } from "./handlers/agent"
|
||||
import { HealthHandler } from "./handlers/health"
|
||||
import { QuestionHandler } from "./handlers/question"
|
||||
import { ReferenceHandler } from "./handlers/reference"
|
||||
import * as SessionExecutionLocal from "@opencode-ai/core/session/execution/local"
|
||||
|
||||
export const handlers = Layer.mergeAll(
|
||||
|
|
@ -31,6 +32,7 @@ export const handlers = Layer.mergeAll(
|
|||
SkillHandler,
|
||||
EventHandler,
|
||||
QuestionHandler,
|
||||
ReferenceHandler,
|
||||
).pipe(
|
||||
Layer.provide(sessionLocationLayer),
|
||||
Layer.provide(locationLayer),
|
||||
|
|
|
|||
8
packages/server/src/handlers/reference.ts
Normal file
8
packages/server/src/handlers/reference.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { Reference } from "@opencode-ai/core/reference"
|
||||
import { HttpApiBuilder } from "effect/unstable/httpapi"
|
||||
import { Api } from "../api"
|
||||
import { response } from "../groups/location"
|
||||
|
||||
export const ReferenceHandler = HttpApiBuilder.group(Api, "server.reference", (handlers) =>
|
||||
handlers.handle("reference.list", () => response(Reference.Service.use((reference) => reference.list()))),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue