feat(project): support project metadata updates

This commit is contained in:
Brendan Allan 2026-07-21 19:02:33 +08:00
commit 9afd059fa1
No known key found for this signature in database
GPG key ID: 41E835AEA046A32E
13 changed files with 111 additions and 2 deletions

View file

@ -3,10 +3,26 @@ import { Project } from "@opencode-ai/core/project"
import { Effect } from "effect"
import { HttpApiBuilder } from "effect/unstable/httpapi"
import { Api } from "../api"
import { ProjectNotFoundError } from "@opencode-ai/protocol/errors"
export const ProjectHandler = HttpApiBuilder.group(Api, "server.project", (handlers) =>
handlers
.handle("project.list", () => Project.Service.use((project) => project.list()))
.handle("project.update", (ctx) =>
Effect.gen(function* () {
const project = yield* Project.Service
return yield* project.update(ctx.params.projectID, ctx.payload).pipe(
Effect.catchTag(
"Project.NotFoundError",
() =>
new ProjectNotFoundError({
projectID: ctx.params.projectID,
message: `Project not found: ${ctx.params.projectID}`,
}),
),
)
}),
)
.handle("project.current", () =>
Location.Service.use((location) =>
Effect.succeed({ id: location.project.id, directory: location.project.directory }),