fix(server): load OpenCode workspace skills via SDK to avoid 64KB CLI pipe truncation #9585
main fromrefs/pull/9585/head·merged by maria-rcks View on GitHubWhat changed#
snapshotForCwd for the OpenCode driver now loads per-workspace skills through the shared SDK server (serverOwner.withServer + loadOpenCodeSkills with per-request directory: cwd) instead of shelling out to opencode debug skill (loadSkillsFromCli).
One file: apps/server/src/provider/Drivers/OpenCodeDriver.ts (+19/-5).
Why#
The Bun-compiled opencode binary does not flush more than one 64KB pipe buffer to a non-TTY stdout. With a realistic skill library the CLI emits ~750KB of JSON (47 skills here), but a piped child process delivers exactly 65536 bytes and the truncated JSON fails to parse:
- file redirect: 754586 bytes, 47 skills, valid JSON
- pipe: 65536 bytes,
JSONDecodeError: Unterminated string ... (char 64013)
parseSkillsCliOutput degrades that to a successful empty list, so snapshotForCwd published a ready snapshot with skills: []. The composer prefers the workspace snapshot over the machine snapshot (resolveProviderSkillsForCwd), so the $ picker permanently showed No skills found even though ~/.t3/caches/opencode.json correctly listed 43+ skills (populated via the SDK path in checkOpenCodeProviderStatus).
I verified the SDK app.skills endpoint honors the per-request directory: same server returned 47 skills (incl. repo-local test-t3-app) for the repo cwd and 43 (globals only) for an empty dir.
Related: #7807 (pipe truncation root cause), #2736 (OpenCode skills missing in composer).
Test evidence#
vp test runonOpenCodeProvider.test.ts,opencodeRuntime.inventory.test.ts,opencodeRuntime.cliParsers.test.ts: 3 files, 35 tests, all passvp run --filter t3 typecheck: 0 errorsvp lint: nothing on the changed file- Live: dev server from this branch, fresh draft thread,
$picker now lists all skills (before:No skills found)
Before / after#
- Before:
$in any OpenCode thread showsNo skills found. Try / to browse provider commands.despite skills existing on disk and in the provider cache. - After:
$lists the full workspace skill inventory (global~/.agents/skillsplus repo-local.agents/skills), e.g.test-t3-appappears when the thread cwd is this repo.
Note
Medium Risk
Changes how per-cwd skill inventory is loaded for local OpenCode instances; behavior should improve but depends on the shared server and SDK app.skills path instead of the CLI.
Overview
Per-workspace OpenCode skills in snapshotForCwd no longer use loadSkillsFromCli (opencode debug skill) when no remote serverUrl is configured. That path now reuses the shared local OpenCode server via serverOwner.withServer and fetches skills through the SDK (loadOpenCodeSkills with directory: cwd), matching the behavior already used when serverUrl is set.
This fixes workspace snapshots that were ready but carried skills: [] because piped CLI JSON was truncated at ~64KB and parsing fell back to an empty list—so the composer $ picker showed no skills even when the machine cache had them.
Note
Fix OpenCodeDriver.create local skill loading to avoid 64KB CLI pipe truncation#
- Updates local OpenCode skill discovery in
OpenCodeDriver.createto use the OpenCode SDK client instead of the CLI command, avoiding a 64KB pipe truncation issue with large skill lists - Passes the configured working directory per request and conditionally forwards the server password to authenticate with the shared SDK server
- Risk: local skill loading now requires a reachable shared SDK server when no explicit server URL is configured
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved at
c981dc9Macroscope's review found this PR approvable — This is a focused one-file bug fix that changes only local OpenCode workspace skill discovery, reusing established server and SDK infrastructure to avoid truncated CLI output. Existing remote-server behavior and broader provider operations remain unchanged.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).maria-rcks merged this2152d44
maria-rcks closed this
Sign in to join this conversation.
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.