Skip to content

Commit 7605acf

Browse files
authored
refactor(core): move server routes around to clarify workspacing (#23031)
1 parent e7f8f7f commit 7605acf

32 files changed

Lines changed: 1261 additions & 1274 deletions

packages/opencode/src/control-plane/workspace-context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { LocalContext } from "../util"
22
import type { WorkspaceID } from "../control-plane/schema"
33

44
export interface WorkspaceContext {
5-
workspaceID: WorkspaceID
5+
workspaceID: WorkspaceID | undefined
66
}
77

88
const context = LocalContext.create<WorkspaceContext>("instance")
99

1010
export const WorkspaceContext = {
11-
async provide<R>(input: { workspaceID: WorkspaceID; fn: () => R }): Promise<R> {
11+
async provide<R>(input: { workspaceID?: WorkspaceID; fn: () => R }): Promise<R> {
1212
return context.provide({ workspaceID: input.workspaceID }, () => input.fn())
1313
},
1414

packages/opencode/src/server/control/index.ts renamed to packages/opencode/src/server/routes/control/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import { ProviderID } from "@/provider/schema"
66
import { Hono } from "hono"
77
import { describeRoute, resolver, validator, openAPIRouteHandler } from "hono-openapi"
88
import z from "zod"
9-
import { errors } from "../error"
10-
import { GlobalRoutes } from "../instance/global"
9+
import { errors } from "../../error"
10+
import { WorkspaceRoutes } from "./workspace"
1111

1212
export function ControlPlaneRoutes(): Hono {
1313
const app = new Hono()
1414
return app
15-
.route("/global", GlobalRoutes())
1615
.put(
1716
"/auth/:providerID",
1817
describeRoute({
@@ -159,4 +158,5 @@ export function ControlPlaneRoutes(): Hono {
159158
return c.json(true)
160159
},
161160
)
161+
.route("/experimental/workspace", WorkspaceRoutes())
162162
}

packages/opencode/src/server/instance/workspace.ts renamed to packages/opencode/src/server/routes/control/workspace.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Hono } from "hono"
22
import { describeRoute, resolver, validator } from "hono-openapi"
33
import z from "zod"
4-
import { listAdaptors } from "../../control-plane/adaptors"
5-
import { Workspace } from "../../control-plane/workspace"
6-
import { Instance } from "../../project/instance"
7-
import { errors } from "../error"
8-
import { lazy } from "../../util/lazy"
4+
import { listAdaptors } from "@/control-plane/adaptors"
5+
import { Workspace } from "@/control-plane/workspace"
6+
import { Instance } from "@/project/instance"
7+
import { errors } from "../../error"
8+
import { lazy } from "@/util/lazy"
99
import { Log } from "@/util"
1010
import { errorData } from "@/util/error"
1111

File renamed without changes.

packages/opencode/src/server/instance/config.ts renamed to packages/opencode/src/server/routes/instance/config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Hono } from "hono"
22
import { describeRoute, validator, resolver } from "hono-openapi"
33
import z from "zod"
4-
import { Config } from "../../config"
5-
import { Provider } from "../../provider"
6-
import { errors } from "../error"
7-
import { lazy } from "../../util/lazy"
8-
import { AppRuntime } from "../../effect/app-runtime"
4+
import { Config } from "@/config"
5+
import { Provider } from "@/provider"
6+
import { errors } from "../../error"
7+
import { lazy } from "@/util/lazy"
8+
import { AppRuntime } from "@/effect/app-runtime"
99
import { jsonRequest } from "./trace"
1010

1111
export const ConfigRoutes = lazy(() =>

packages/opencode/src/server/instance/event.ts renamed to packages/opencode/src/server/routes/instance/event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { streamSSE } from "hono/streaming"
55
import { Log } from "@/util"
66
import { BusEvent } from "@/bus/bus-event"
77
import { Bus } from "@/bus"
8-
import { AsyncQueue } from "../../util/queue"
8+
import { AsyncQueue } from "@/util/queue"
99

1010
const log = Log.create({ service: "server" })
1111

packages/opencode/src/server/instance/experimental.ts renamed to packages/opencode/src/server/routes/instance/experimental.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
import { Hono } from "hono"
22
import { describeRoute, validator, resolver } from "hono-openapi"
33
import z from "zod"
4-
import { ProviderID, ModelID } from "../../provider/schema"
5-
import { ToolRegistry } from "../../tool"
6-
import { Worktree } from "../../worktree"
7-
import { Instance } from "../../project/instance"
8-
import { Project } from "../../project"
9-
import { MCP } from "../../mcp"
10-
import { Session } from "../../session"
11-
import { Config } from "../../config"
12-
import { ConsoleState } from "../../config/console-state"
13-
import { Account } from "../../account/account"
14-
import { AccountID, OrgID } from "../../account/schema"
15-
import { AppRuntime } from "../../effect/app-runtime"
16-
import { errors } from "../error"
17-
import { lazy } from "../../util/lazy"
4+
import { ProviderID, ModelID } from "@/provider/schema"
5+
import { ToolRegistry } from "@/tool"
6+
import { Worktree } from "@/worktree"
7+
import { Instance } from "@/project/instance"
8+
import { Project } from "@/project"
9+
import { MCP } from "@/mcp"
10+
import { Session } from "@/session"
11+
import { Config } from "@/config"
12+
import { ConsoleState } from "@/config/console-state"
13+
import { Account } from "@/account/account"
14+
import { AccountID, OrgID } from "@/account/schema"
15+
import { AppRuntime } from "@/effect/app-runtime"
16+
import { errors } from "../../error"
17+
import { lazy } from "@/util/lazy"
1818
import { Effect, Option } from "effect"
19-
import { WorkspaceRoutes } from "./workspace"
2019
import { Agent } from "@/agent/agent"
2120

2221
const ConsoleOrgOption = z.object({
@@ -231,7 +230,6 @@ export const ExperimentalRoutes = lazy(() =>
231230
)
232231
},
233232
)
234-
.route("/workspace", WorkspaceRoutes())
235233
.post(
236234
"/worktree",
237235
describeRoute({

packages/opencode/src/server/instance/file.ts renamed to packages/opencode/src/server/routes/instance/file.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { Hono } from "hono"
22
import { describeRoute, validator, resolver } from "hono-openapi"
33
import { Effect } from "effect"
44
import z from "zod"
5-
import { AppRuntime } from "../../effect/app-runtime"
6-
import { File } from "../../file"
7-
import { Ripgrep } from "../../file/ripgrep"
8-
import { LSP } from "../../lsp"
9-
import { Instance } from "../../project/instance"
10-
import { lazy } from "../../util/lazy"
5+
import { AppRuntime } from "@/effect/app-runtime"
6+
import { File } from "@/file"
7+
import { Ripgrep } from "@/file/ripgrep"
8+
import { LSP } from "@/lsp"
9+
import { Instance } from "@/project/instance"
10+
import { lazy } from "@/util/lazy"
1111

1212
export const FileRoutes = lazy(() =>
1313
new Hono()

packages/opencode/src/server/instance/httpapi/config.ts renamed to packages/opencode/src/server/routes/instance/httpapi/config.ts

File renamed without changes.

packages/opencode/src/server/instance/httpapi/permission.ts renamed to packages/opencode/src/server/routes/instance/httpapi/permission.ts

File renamed without changes.

0 commit comments

Comments
 (0)