GeezerVison is showing github.com — chore: sync upstream/dev (Hono migration, LSP fix, OpenTUI 0.1.97) by terisuke · Pull Request #133 · Cor-Incorporated/opencode
Conversation
Summary
- Merge 9 upstream commits from anomalyco/opencode dev branch
- Key changes: Bun.serve → @hono/node-server migration, PTY abstraction layer (bun-pty/node-pty), LSP TypeScript memory leak fix, OpenTUI 0.1.97, chat.params maxOutputTokens hook parameter
- Update guardrail.ts chat.params
_out type to include maxOutputTokens: number | undefined
- Zero conflicts — guardrails package is fully isolated from upstream server changes
Upstream Commits Included
Test plan
-
bun install — 20 packages installed
-
bun turbo build — 10/10 tasks successful
-
bun turbo typecheck — 13/13 tasks successful
-
bun turbo test:ci — 2041/2043 pass (2 known upstream failures: LSP npm install, prompt-during-run timing)
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…el as copilot cli, also fix qwen incorrectly having variants (anomalyco#21212)
Merge 9 upstream commits: Bun.serve → @hono/node-server migration,
PTY abstraction layer, LSP memory leak fix, chat.params maxOutputTokens,
plugin Bun.$ guard. Update guardrail.ts chat.params type to match.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
This PR doesn't fully meet our contributing guidelines and PR template.
What needs to be fixed:
- PR description is missing required template sections. Please use the PR template.
Please edit this PR description to address the above within 2 hours, or it will be automatically closed.
If you believe this was flagged incorrectly, please let a maintainer know.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for your contribution!
This PR doesn't have a linked issue. All PRs must reference an existing issue.
Please:
- Open an issue describing the bug/feature (if one doesn't exist)
- Add
Fixes #<number> or Closes #<number> to this PR description
See CONTRIBUTING.md for details.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
New PR opened -- automated review will run on the next push.
To trigger a manual review, comment /review on this PR.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate:
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Syncs upstream/dev into this repo, bringing in the Node/Hono server migration, PTY abstraction, LSP TypeScript spawn fixes, OpenTUI 0.1.97 updates, and a new chat.params hook parameter (maxOutputTokens).
Changes:
- Migrate server/websocket handling from
Bun.serve + hono/bun to @hono/node-server + @hono/node-ws, updating routing to pass websocket upgrade handlers through.
- Introduce a runtime-selected PTY layer (
#pty export) supporting Bun (bun-pty) and Node (@lydell/node-pty), plus postinstall scripting to address PTY helper permissions.
- Fix/adjust TypeScript LSP spawning args to reduce TS server overhead (log verbosity off, explicit tsserver path,
--ignore-node-modules when no config).
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 6 comments.
Show a summary per file
| File |
Description |
| packages/web/src/content/docs/providers.mdx |
Updates Cloudflare provider setup steps (more /connect-driven flow + env var alternative). |
| packages/web/src/content/docs/ecosystem.mdx |
Adds new community ecosystem entries. |
| packages/plugin/src/index.ts |
Extends chat.params hook output typing with maxOutputTokens. |
| packages/plugin/package.json |
Bumps OpenTUI peer/dev deps to 0.1.97. |
| packages/opencode/test/session/llm.test.ts |
Updates provider/model fixture used in LLM streaming test. |
| packages/opencode/test/lsp/index.test.ts |
Adds tests asserting TS LSP spawn args and --ignore-node-modules behavior. |
| packages/opencode/src/session/llm.ts |
Plumbs maxOutputTokens through chat.params hook and into model invocation. |
| packages/opencode/src/server/server.ts |
Replaces Bun server with Hono Node adaptor + Node WS injection; changes listen() to async and returns a new Listener. |
| packages/opencode/src/server/routes/pty.ts |
Refactors PTY routes to accept a websocket upgrade handler (non-Bun runtime). |
| packages/opencode/src/server/router.ts |
Changes workspace router middleware into a factory requiring websocket upgrade support. |
| packages/opencode/src/server/instance.ts |
Threads websocket upgrade handler into instance routes (PTY route now requires it). |
| packages/opencode/src/pty/pty.ts |
Adds a minimal PTY interface type layer (Proc, Opts, etc.). |
| packages/opencode/src/pty/pty.node.ts |
Implements #pty spawn via @lydell/node-pty for Node builds. |
| packages/opencode/src/pty/pty.bun.ts |
Implements #pty spawn via bun-pty for Bun runtime. |
| packages/opencode/src/pty/index.ts |
Switches PTY implementation to import #pty and updates subscriber tracking logic. |
| packages/opencode/src/provider/transform.ts |
Expands provider option transforms (e.g., allow qwen in one branch; adjust Copilot Claude effort mapping). |
| packages/opencode/src/plugin/index.ts |
Makes plugin $ shell access conditional on Bun presence (now possibly undefined). |
| packages/opencode/src/plugin/codex.ts |
Migrates OAuth callback server from Bun.serve to Node http.createServer. |
| packages/opencode/src/mcp/oauth-callback.ts |
Migrates MCP OAuth callback server from Bun.serve to Node http.createServer; refactors state cleanup. |
| packages/opencode/src/lsp/server.ts |
Adds TS language server args (--tsserver-path, verbosity off, ignore node_modules when no config). |
| packages/opencode/src/cli/cmd/web.ts |
Awaits async Server.listen(). |
| packages/opencode/src/cli/cmd/serve.ts |
Awaits async Server.listen(). |
| packages/opencode/src/cli/cmd/acp.ts |
Awaits async Server.listen(). |
| packages/opencode/script/fix-node-pty.ts |
Adds a helper to chmod PTY spawn-helper binaries after install. |
| packages/opencode/script/build-node.ts |
Detects Bun linker layout and installs @lydell/node-pty before Node build; enables linked sourcemaps. |
| packages/opencode/package.json |
Adds fix-node-pty script; adds conditional #pty export mapping; bumps OpenTUI deps; adds new deps for Hono + node-pty. |
| packages/guardrails/profile/plugins/guardrail.ts |
Updates chat.params hook typing to include maxOutputTokens. |
| packages/app/script/e2e-local.ts |
Awaits async Server.listen() and adjusts stop() signature usage. |
| package.json |
Adds root postinstall running fix-node-pty; adds node-pty to trustedDependencies. |
| nix/hashes.json |
Updates nix node_modules hashes. |
| bun.lock |
Lockfile updates for new deps (Hono node server/ws, OpenTUI 0.1.97, @lydell/node-pty, etc.). |
Comments suppressed due to low confidence (1)
packages/opencode/src/mcp/oauth-callback.ts:160
waitForCallback() records mcpName → oauthState in mcpNameToState, but cancelPending(mcpName) later falls back to using mcpName as the pendingAuths key when the reverse lookup is missing. Since pendingAuths is keyed by oauthState, that fallback won't cancel anything. Consider making cancellation depend solely on the reverse index (return early if no state is found), or changing the data structures so the same key is used consistently.
export function waitForCallback(oauthState: string, mcpName?: string): Promise<string> {
if (mcpName) mcpNameToState.set(mcpName, oauthState)
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+281
to
+299
|
|
const start = (port: number) =>
|
|
|
new Promise<ServerType>((resolve, reject) => {
|
|
|
const server = createAdaptorServer({ fetch: built.app.fetch })
|
|
|
built.ws.injectWebSocket(server)
|
|
|
const fail = (err: Error) => {
|
|
|
cleanup()
|
|
|
reject(err)
|
|
|
}
|
|
|
const ready = () => {
|
|
|
cleanup()
|
|
|
resolve(server)
|
|
|
}
|
|
|
const cleanup = () => {
|
|
|
server.off("error", fail)
|
|
|
server.off("listening", ready)
|
|
|
}
|
|
|
server.once("error", fail)
|
|
|
server.once("listening", ready)
|
|
|
server.listen(port, opts.hostname)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Server.listen() now creates a Node http.Server but doesn't configure Node timeouts. Node's default requestTimeout/headersTimeout can terminate long-lived streaming endpoints (e.g. /event, /global/event) after a few minutes, whereas the previous Bun.serve({ idleTimeout: 0 }) behavior effectively disabled timeouts. Consider explicitly setting server.requestTimeout = 0 (and adjusting headersTimeout/keepAliveTimeout as appropriate) after creating the adaptor server to avoid breaking SSE/streaming clients.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot uses AI. Check for mistakes.
Comment on lines
129
to
135
|
|
directory: ctx.directory,
|
|
|
get serverUrl(): URL {
|
|
|
return Server.url ?? new URL("http://localhost:4096")
|
|
|
},
|
|
|
$: Bun.$,
|
|
|
// @ts-expect-error
|
|
|
$: typeof Bun === "undefined" ? undefined : Bun.$,
|
|
|
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PluginInput.$ is typed as required BunShell in @opencode-ai/plugin, but here it's set to undefined when running outside Bun (and suppressed with @ts-expect-error). This is a breaking runtime change for plugins that assume $ exists. Either provide a cross-runtime shell implementation, or update the shared PluginInput type/contract to make $ optional (and document/guard its usage).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot uses AI. Check for mistakes.
Comment on lines
+12
to
+14
|
|
const root = path.join(dir, "node_modules", "node-pty", "prebuilds")
|
|
|
const dirs = await fs.readdir(root, { withFileTypes: true }).catch(() => [])
|
|
|
const files = dirs.filter((x) => x.isDirectory()).map((x) => path.join(root, x.name, "spawn-helper"))
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script targets .../node_modules/node-pty/prebuilds/.../spawn-helper, but this PR adds @lydell/node-pty (and the lockfile does not include node-pty). As written, the postinstall hook is likely a no-op and won’t fix the intended permissions. Update the script to point at the actual installed PTY package(s) (and consider hoisted vs isolated layouts, similar to build-node.ts).
|
const root = path.join(dir, "node_modules", "node-pty", "prebuilds") |
|
const dirs = await fs.readdir(root, { withFileTypes: true }).catch(() => []) |
|
const files = dirs.filter((x) => x.isDirectory()).map((x) => path.join(root, x.name, "spawn-helper")) |
|
const workspaceRoot = path.resolve(dir, "..", "..") |
|
const roots = [ |
|
path.join(dir, "node_modules", "@lydell", "node-pty", "prebuilds"), |
|
path.join(dir, "node_modules", "node-pty", "prebuilds"), |
|
path.join(workspaceRoot, "node_modules", "@lydell", "node-pty", "prebuilds"), |
|
path.join(workspaceRoot, "node_modules", "node-pty", "prebuilds"), |
|
] |
|
|
|
const fileGroups = await Promise.all( |
|
roots.map(async (root) => { |
|
const dirs = await fs.readdir(root, { withFileTypes: true }).catch(() => []) |
|
return dirs.filter((x) => x.isDirectory()).map((x) => path.join(root, x.name, "spawn-helper")) |
|
}), |
|
) |
|
|
|
const files = [...new Set(fileGroups.flat())] |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot uses AI. Check for mistakes.
|
|
const stat = await fs.stat(file).catch(() => undefined)
|
|
|
if (!stat) return
|
|
|
if ((stat.mode & 0o111) === 0o111) return
|
|
|
await fs.chmod(file, stat.mode | 0o755)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The permission check/modification is overly broad: (stat.mode & 0o111) === 0o111 only skips when all execute bits are set, and chmod(file, stat.mode | 0o755) forces read permissions too. If the intent is just to ensure executability, prefer checking (stat.mode & 0o111) !== 0o111 and only OR-ing 0o111 (execute bits) to avoid widening permissions unnecessarily.
|
await fs.chmod(file, stat.mode | 0o755) |
|
await fs.chmod(file, stat.mode | 0o111) |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot uses AI. Check for mistakes.
|
|
@@ -1,15 +1,14 @@ |
|
|
import { Hono } from "hono"
|
|
|
import { Hono, type MiddlewareHandler } from "hono"
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import: MiddlewareHandler is imported but never referenced in this module. Removing it avoids dead code and keeps the import list accurate.
|
import { Hono, type MiddlewareHandler } from "hono" |
|
import { Hono } from "hono" |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot uses AI. Check for mistakes.
Comment on lines
+15
to
18
|
|
"postinstall": "bun run --cwd packages/opencode fix-node-pty",
|
|
|
"prepare": "husky",
|
|
|
"random": "echo 'Random script'",
|
|
|
"hello": "echo 'Hello World!'",
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trustedDependencies and the new postinstall hook reference node-pty, but this PR introduces @lydell/node-pty instead. Align the trusted dependency name (and any install-script allowances) with the actual package being installed, otherwise the policy entry is misleading and may not have the intended effect.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot uses AI. Check for mistakes.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Apr 6, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|