Skip to content

Commit fb3f0d9

Browse files
committed
Revert "research: delete Hono backend (do not merge) (anomalyco#25667)" and cleanup
This reverts: - 0f0506a research: delete Hono backend (do not merge) (anomalyco#25667) - 4c88dad chore(server): clean up post-Hono-deletion scar tissue (anomalyco#26542) v1.14.42 broke startup for users with plugins that depend on the Hono wire format (most visibly opencode-gemini-auth, see anomalyco#26546). Restoring Hono as the default backend on stable channels while we investigate the actual plugin compatibility story. OPENCODE_EXPERIMENTAL_HTTPAPI flag and dual-backend selection come back. Stable installs default to Hono; dev/beta default to HTTP API. Conflict resolution: took the pre-deletion side for control-plane schemas and the seven test files where post-deletion follow-up PRs had also touched the conflicting lines. The HTTP API code added since the deletion (compression, cors-vary, fence, lifecycle log, account error mapping, etc.) is preserved as-is — those still apply on the HTTP API path for users on dev/beta channels.
1 parent 4000ccb commit fb3f0d9

84 files changed

Lines changed: 8039 additions & 226 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎bun.lock‎

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

‎packages/core/src/flag/flag.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Config } from "effect"
2+
import { InstallationChannel } from "../installation/version"
23

34
function truthy(key: string) {
45
const value = process.env[key]?.toLowerCase()
@@ -10,6 +11,10 @@ function falsy(key: string) {
1011
return value === "false" || value === "0"
1112
}
1213

14+
// Channels that default to the new effect-httpapi server backend. The legacy
15+
// hono backend remains the default for stable (`prod`/`latest`) installs.
16+
const HTTPAPI_DEFAULT_ON_CHANNELS = new Set(["dev", "beta", "local"])
17+
1318
function number(key: string) {
1419
const value = process.env[key]
1520
if (!value) return undefined
@@ -83,6 +88,14 @@ export const Flag = {
8388
OPENCODE_STRICT_CONFIG_DEPS: truthy("OPENCODE_STRICT_CONFIG_DEPS"),
8489

8590
OPENCODE_WORKSPACE_ID: process.env["OPENCODE_WORKSPACE_ID"],
91+
// Defaults to true on dev/beta/local channels so internal users exercise the
92+
// new effect-httpapi server backend. Stable (`prod`/`latest`) installs stay
93+
// on the legacy hono backend until the rollout is complete. An explicit env
94+
// var ("true"/"1" or "false"/"0") always wins, providing an opt-in for
95+
// stable users and an escape hatch for dev/beta users.
96+
OPENCODE_EXPERIMENTAL_HTTPAPI:
97+
truthy("OPENCODE_EXPERIMENTAL_HTTPAPI") ||
98+
(!falsy("OPENCODE_EXPERIMENTAL_HTTPAPI") && HTTPAPI_DEFAULT_ON_CHANNELS.has(InstallationChannel)),
8699
OPENCODE_EXPERIMENTAL_WORKSPACES: OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_WORKSPACES"),
87100
OPENCODE_EXPERIMENTAL_EVENT_SYSTEM: OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_EVENT_SYSTEM"),
88101

‎packages/opencode/package.json‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
"node": "./src/pty/pty.node.ts",
3434
"default": "./src/pty/pty.bun.ts"
3535
},
36+
"#hono": {
37+
"bun": "./src/server/adapter.bun.ts",
38+
"node": "./src/server/adapter.node.ts",
39+
"default": "./src/server/adapter.bun.ts"
40+
},
3641
"#httpapi-server": {
3742
"bun": "./src/server/httpapi-server.node.ts",
3843
"node": "./src/server/httpapi-server.node.ts",
@@ -69,7 +74,8 @@
6974
"prettier": "3.6.2",
7075
"typescript": "catalog:",
7176
"vscode-languageserver-types": "3.17.5",
72-
"why-is-node-running": "3.2.2"
77+
"why-is-node-running": "3.2.2",
78+
"zod-to-json-schema": "3.24.5"
7379
},
7480
"dependencies": {
7581
"@actions/core": "1.11.1",
@@ -100,6 +106,10 @@
100106
"@effect/opentelemetry": "catalog:",
101107
"@effect/platform-node": "catalog:",
102108
"@gitlab/opencode-gitlab-auth": "1.3.3",
109+
"@hono/node-server": "1.19.11",
110+
"@hono/node-ws": "1.3.0",
111+
"@hono/standard-validator": "0.1.5",
112+
"@hono/zod-validator": "catalog:",
103113
"@lydell/node-pty": "catalog:",
104114
"@modelcontextprotocol/sdk": "1.27.1",
105115
"@octokit/graphql": "9.0.2",
@@ -140,6 +150,8 @@
140150
"glob": "13.0.5",
141151
"google-auth-library": "10.5.0",
142152
"gray-matter": "4.0.3",
153+
"hono": "catalog:",
154+
"hono-openapi": "catalog:",
143155
"ignore": "7.0.5",
144156
"immer": "11.1.4",
145157
"jsonc-parser": "3.3.1",
@@ -165,7 +177,8 @@
165177
"which": "6.0.1",
166178
"xdg-basedir": "5.1.0",
167179
"yargs": "18.0.0",
168-
"zod": "catalog:"
180+
"zod": "catalog:",
181+
"zod-to-json-schema": "3.24.5"
169182
},
170183
"overrides": {
171184
"drizzle-orm": "catalog:"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
# Compare SDK types generated from Hono vs HttpApi specs.
3+
# Sorts types alphabetically so only meaningful body differences show.
4+
#
5+
# Usage: ./scripts/diff-sdk-types.sh # full diff
6+
# ./scripts/diff-sdk-types.sh --stat # summary only
7+
set -euo pipefail
8+
9+
DIR="$(cd "$(dirname "$0")/.." && pwd)"
10+
SDK="$(cd "$DIR/../sdk/js" && pwd)"
11+
12+
normalize() {
13+
python3 -c "
14+
import re, sys
15+
content = open(sys.argv[1]).read()
16+
blocks = re.split(r'(?=^export (?:type|function|const) )', content, flags=re.MULTILINE)
17+
header, body = blocks[0], blocks[1:]
18+
body.sort(key=lambda b: m.group(1) if (m := re.match(r'export \w+ (\w+)', b)) else '')
19+
sys.stdout.write(header + ''.join(body))
20+
" "$1"
21+
}
22+
23+
echo "Generating Hono SDK..." >&2
24+
(cd "$SDK" && bun run script/build.ts >/dev/null 2>&1)
25+
normalize "$SDK/src/v2/gen/types.gen.ts" > /tmp/sdk-types-hono.ts
26+
git -C "$SDK" checkout -- src/ 2>/dev/null
27+
28+
echo "Generating HttpApi SDK..." >&2
29+
(cd "$SDK" && OPENCODE_SDK_OPENAPI=httpapi bun run script/build.ts >/dev/null 2>&1)
30+
normalize "$SDK/src/v2/gen/types.gen.ts" > /tmp/sdk-types-httpapi.ts
31+
git -C "$SDK" checkout -- src/ 2>/dev/null
32+
33+
echo "" >&2
34+
if [[ "${1:-}" == "--stat" ]]; then
35+
diff_output=$(diff /tmp/sdk-types-hono.ts /tmp/sdk-types-httpapi.ts || true)
36+
honly=$(printf "%s\n" "$diff_output" | grep -c '^< export type' || true)
37+
aonly=$(printf "%s\n" "$diff_output" | grep -c '^> export type' || true)
38+
total=$(printf "%s\n" "$diff_output" | wc -l | tr -d ' ')
39+
echo "Hono-only: $honly types HttpApi-only: $aonly types Diff lines: $total"
40+
echo ""
41+
if [[ $honly -gt 0 ]]; then
42+
echo "=== Hono-only types ==="
43+
printf "%s\n" "$diff_output" | grep '^< export type' | sed 's/< export type //' | sed 's/[ =].*//' | sed 's/^/ /'
44+
echo ""
45+
fi
46+
if [[ $aonly -gt 0 ]]; then
47+
echo "=== HttpApi-only types ==="
48+
printf "%s\n" "$diff_output" | grep '^> export type' | sed 's/> export type //' | sed 's/[ =].*//' | sed 's/^/ /'
49+
fi
50+
else
51+
diff /tmp/sdk-types-hono.ts /tmp/sdk-types-httpapi.ts || true
52+
fi

0 commit comments

Comments
 (0)