Skip to content

Commit 6f2f759

Browse files
authored
Clean up post-Hono references (#26903)
1 parent cddab63 commit 6f2f759

16 files changed

Lines changed: 92 additions & 738 deletions

File tree

bun.lock

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/console/function/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
"@ai-sdk/anthropic": "3.0.64",
2121
"@ai-sdk/openai": "3.0.48",
2222
"@ai-sdk/openai-compatible": "2.0.37",
23-
"@hono/zod-validator": "catalog:",
2423
"@opencode-ai/console-core": "workspace:*",
2524
"@opencode-ai/console-resource": "workspace:*",
2625
"@openauthjs/openauth": "0.0.0-20250322224806",
2726
"ai": "catalog:",
28-
"hono": "catalog:",
2927
"zod": "catalog:"
3028
}
3129
}

packages/opencode/specs/effect/errors.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ contracts.
2323
- Some services already use `Schema.TaggedErrorClass`, for example `Account`,
2424
`Auth`, `Permission`, `Question`, `Installation`, and parts of
2525
`Workspace`.
26-
- Legacy Hono error handling recognizes `NamedError`, `Session.BusyError`, and a
27-
few name-based cases, then emits the legacy `{ name, data }` JSON body.
26+
- The temporary HttpApi compatibility middleware recognizes `NamedError`,
27+
`Session.BusyError`, and a few name-based cases, then emits the legacy
28+
`{ name, data }` JSON body.
2829
- Effect `HttpApi` only knows how to encode errors that are declared on the
2930
endpoint, group, or middleware. Undeclared expected errors become defects and
3031
eventually fall through to generic HTTP handling.
@@ -127,7 +128,7 @@ Create an HttpApi-local error module, likely
127128
That module should provide:
128129

129130
- Legacy-compatible public schemas for `{ name, data }` error bodies that must
130-
remain SDK-compatible during the Hono migration.
131+
remain SDK-compatible while route groups declare typed errors.
131132
- Small constructors or mapping helpers for common API errors such as not found,
132133
bad request, conflict, and unknown internal errors.
133134
- Route-group-specific adapters only when they encode domain-specific public
@@ -173,7 +174,7 @@ Add the `httpapi/errors.ts` module before converting route groups.
173174
- Define a legacy `{ name, data }` body helper for SDK-compatible errors.
174175
- Define `UnknownError` for generic internal failures with a safe public message.
175176
- Define `BadRequestError` and `NotFoundError` equivalents only if the actual
176-
wire body must match the legacy Hono SDK surface.
177+
wire body must match the existing SDK surface.
177178
- Put the HTTP status on the public schema with `HttpApiSchema.status(...)` or
178179
`{ httpApiStatus: code }`; do not keep a separate name-to-status table.
179180
- Keep conversion helpers pure and small. They should not inspect `Cause` or
@@ -238,7 +239,7 @@ Suggested route order:
238239
2. `experimental` worktree mutations.
239240
3. `provider` auth and model selection errors.
240241
4. `mcp` OAuth and connection errors.
241-
5. Remaining route groups as Hono deletion work progresses.
242+
5. Remaining route groups as typed error contracts are declared.
242243

243244
### 6. Remove Defect Recovery
244245

@@ -286,8 +287,8 @@ For HttpApi conversions:
286287
errors.
287288
- Add a regression test that the temporary middleware is no longer needed for the
288289
migrated route.
289-
- Keep bridge/parity tests aligned with legacy Hono behavior until Hono is
290-
deleted or the SDK contract intentionally changes.
290+
- Keep compatibility tests aligned with the existing SDK contract until the
291+
public error shape intentionally changes.
291292

292293
## Verification Commands
293294

packages/opencode/specs/effect/routes.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,19 @@ This eliminates multiple `runPromise` round-trips and lets handlers compose natu
3939

4040
## Current route files
4141

42-
Current instance route files live under `src/server/routes/instance`.
43-
44-
Files that are already mostly on the intended service-yielding shape:
45-
46-
- [x] `server/routes/instance/question.ts` — handlers yield `Question.Service`
47-
- [x] `server/routes/instance/provider.ts` — handlers yield `Provider.Service`, `ProviderAuth.Service`, and `Config.Service`
48-
- [x] `server/routes/instance/permission.ts` — handlers yield `Permission.Service`
49-
- [x] `server/routes/instance/mcp.ts` — handlers mostly yield `MCP.Service`
50-
- [x] `server/routes/instance/pty.ts` — handlers yield `Pty.Service`
42+
Current instance route files live under `src/server/routes/instance/httpapi`.
43+
Most handlers already yield stable services at route-layer construction and then
44+
close over those services in endpoint implementations.
5145

5246
Files still worth tracking here:
5347

54-
- [ ] `server/routes/instance/session.ts` — still the heaviest mixed file; many handlers are composed, but the file still mixes patterns and has direct `Bus.publish(...)` / `Session.list(...)` usage
55-
- [ ] `server/routes/instance/index.ts` — mostly converted, but still has direct `Instance.dispose()` / `Instance.*` reads for `/instance/dispose` and `/path`
56-
- [ ] `server/routes/instance/file.ts` — most handlers yield services, but `/find` still passes `Instance.directory` directly into ripgrep and `/find/symbol` is still stubbed
57-
- [ ] `server/routes/instance/experimental.ts` — mixed state; many handlers are composed, but some still rely on `runRequest(...)` or direct `Instance.project` reads
58-
- [ ] `server/routes/instance/middleware.ts` — still enters the instance via `Instance.provide(...)`
59-
- [ ] `server/routes/global.ts` — still uses `Instance.disposeAll()` and remains partly outside the fully-composed style
48+
- [ ] `handlers/session.ts` — still the heaviest mixed file; some paths keep compatibility translations and direct event publication
49+
- [ ] `handlers/experimental.ts` — mixed state; some handlers still rely on request-local context reads
50+
- [ ] `middleware/*` — still contains compatibility policy for auth, compression, errors, instance context, and workspace routing
51+
- [ ] `public.ts` — still owns SDK/OpenAPI compatibility translation shims
52+
- [ ] raw route modules — WebSocket and catch-all routes should stay explicit and avoid rebuilding stable layers per request
6053

6154
## Notes
6255

63-
- Route conversion is now less about facade removal and more about removing the remaining direct `Instance.*` reads, `Instance.provide(...)` boundaries, and small Promise-style bridges inside route files.
64-
- `jsonRequest(...)` / `runRequest(...)` already provide a good intermediate shape for many handlers. The remaining cleanup is mostly consistency work in the heavier files.
56+
- Route conversion is now less about backend migration and more about removing the remaining direct `Instance.*` reads, request-local service plumbing, and OpenAPI compatibility shims.
57+
- Prefer route-layer service capture over rebuilding or providing stable layers inside individual handlers.

packages/opencode/specs/effect/schema.md

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -305,38 +305,18 @@ emitted JSON Schema must stay byte-identical.
305305

306306
### HTTP route boundaries
307307

308-
Every file in `src/server/routes/` uses hono-openapi with zod validators for
309-
route inputs/outputs. Migrating these individually is the last step; most
310-
will switch to `.zod` derived from the Schema-migrated domain types above,
311-
which means touching them is largely mechanical once the domain side is
312-
done.
313-
314-
- [ ] `src/server/error.ts`
315-
- [x] `src/server/event.ts`
316-
- [x] `src/server/projectors.ts`
317-
- [ ] `src/server/routes/control/index.ts`
318-
- [ ] `src/server/routes/control/workspace.ts`
319-
- [ ] `src/server/routes/global.ts`
320-
- [ ] `src/server/routes/instance/index.ts`
321-
- [ ] `src/server/routes/instance/config.ts`
322-
- [ ] `src/server/routes/instance/event.ts`
323-
- [ ] `src/server/routes/instance/experimental.ts`
324-
- [ ] `src/server/routes/instance/file.ts`
325-
- [ ] `src/server/routes/instance/mcp.ts`
326-
- [ ] `src/server/routes/instance/permission.ts`
327-
- [ ] `src/server/routes/instance/project.ts`
328-
- [ ] `src/server/routes/instance/provider.ts`
329-
- [ ] `src/server/routes/instance/pty.ts`
330-
- [ ] `src/server/routes/instance/question.ts`
331-
- [ ] `src/server/routes/instance/session.ts`
332-
- [ ] `src/server/routes/instance/sync.ts`
333-
- [ ] `src/server/routes/instance/tui.ts`
334-
335-
The bigger prize for this group is the `@effect/platform` HTTP migration
336-
described in `specs/effect/http-api.md`. Once that lands, every one of
337-
these files changes shape entirely (`HttpApi.endpoint(...)` and friends),
338-
so the Schema-first domain types become a prerequisite rather than a
339-
sibling task.
308+
The server route tree now lives under `src/server/routes/instance/httpapi` and
309+
uses Effect HttpApi contracts for request and response schemas. Remaining schema
310+
work is no longer a Hono route migration; it is compatibility cleanup around
311+
derived `.zod` statics, OpenAPI translation shims, and route groups that still
312+
need explicit SDK-visible error contracts.
313+
314+
Good follow-up targets:
315+
316+
- shrink `public.ts` legacy OpenAPI translation shims one SDK-compatible slice at a time
317+
- replace production `.zod.safeParse(...)` call sites with Effect Schema decoders
318+
- remove derived `.zod` statics after their production consumers are gone
319+
- declare route-group errors directly instead of relying on compatibility middleware
340320

341321
### Everything else
342322

0 commit comments

Comments
 (0)