feat(client): expose v2 project APIs (#34456)

This commit is contained in:
Kit Langton 2026-06-29 14:10:11 -04:00 committed by GitHub
commit 935ac2db91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 473 additions and 244 deletions

View file

@ -22,6 +22,7 @@ import { Authorization } from "./middleware/authorization"
import { LocationGroup } from "./groups/location"
import { IntegrationGroup } from "./groups/integration"
import { CredentialGroup } from "./groups/credential"
import { ProjectGroup } from "./groups/project"
import { ProjectCopyGroup } from "./groups/project-copy"
// Protocol owns middleware placement, while Server injects concrete keys so Core service identities stay downstream.
@ -47,6 +48,7 @@ const makeApiFromGroup = <
.add(ProviderGroup.middleware(locationMiddleware))
.add(IntegrationGroup.middleware(locationMiddleware))
.add(CredentialGroup.middleware(locationMiddleware))
.add(ProjectGroup.middleware(locationMiddleware))
.add(makePermissionGroup(locationMiddleware, sessionLocationMiddleware))
.add(FileSystemGroup.middleware(locationMiddleware))
.add(CommandGroup.middleware(locationMiddleware))

View file

@ -0,0 +1,42 @@
import { Project } from "@opencode-ai/schema/project"
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
import { LocationQuery, locationQueryOpenApi } from "./location"
const root = "/api/project"
export const ProjectGroup = HttpApiGroup.make("server.project")
.add(
HttpApiEndpoint.get("project.current", `${root}/current`, {
query: LocationQuery,
success: Project.Current,
})
.annotateMerge(locationQueryOpenApi)
.annotateMerge(
OpenApi.annotations({
identifier: "v2.project.current",
summary: "Get current project",
description: "Resolve the project for the requested location.",
}),
),
)
.add(
HttpApiEndpoint.get("project.directories", `${root}/:projectID/directories`, {
params: { projectID: Project.ID },
query: LocationQuery,
success: Project.Directories,
})
.annotateMerge(locationQueryOpenApi)
.annotateMerge(
OpenApi.annotations({
identifier: "v2.project.directories",
summary: "List project directories",
description: "List known local absolute directories for a project.",
}),
),
)
.annotateMerge(
OpenApi.annotations({
title: "projects",
description: "Location-scoped project routes.",
}),
)