Skip to content

fix(server): load OpenCode workspace skills via SDK to avoid 64KB CLI pipe truncation - #9585

Merged
maria-rcks merged 1 commit into
pingdotgg:mainfrom
Agile-Flimflam:fix/opencode-skills-sdk-snapshot
Sep 4, 2026
Merged

fix(server): load OpenCode workspace skills via SDK to avoid 64KB CLI pipe truncation#9585
maria-rcks merged 1 commit into
pingdotgg:mainfrom
Agile-Flimflam:fix/opencode-skills-sdk-snapshot

Conversation

@BarryHenryJr

@BarryHenryJr BarryHenryJr commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

What 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 run on OpenCodeProvider.test.ts, opencodeRuntime.inventory.test.ts, opencodeRuntime.cliParsers.test.ts: 3 files, 35 tests, all pass
  • vp run --filter t3 typecheck: 0 errors
  • vp 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 shows No 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/skills plus repo-local .agents/skills), e.g. test-t3-app appears 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.

Reviewed by Cursor Bugbot for commit c981dc9. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix OpenCodeDriver.create local skill loading to avoid 64KB CLI pipe truncation

  • Updates local OpenCode skill discovery in OpenCodeDriver.create to 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

Macroscope summarized c981dc9.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 4, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at c981dc9

Macroscope'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.

@maria-rcks
maria-rcks merged commit 2152d44 into pingdotgg:main Sep 4, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants