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

This commit is contained in:
Barry authored and GitHub committed 2026-09-04 03:58:56 -04:00
1 parent 706231535c
commit 2152d44de2
1 file changed
+19 -5
@@ -149,6 +149,14 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv>
Effect.provideService(OpenCodeServerOwner.OpenCodeServerOwner, serverOwner),
Effect.provideService(OpenCodeRuntime, openCodeRuntime),
);
// NOTE: the local branch intentionally uses the shared SDK server
// instead of `opencode debug skill` (loadSkillsFromCli). The CLI writes
// its full JSON inventory to stdout, but the Bun-compiled binary does
// not flush more than one 64KB pipe buffer to a non-TTY stdout, so the
// piped output arrives truncated and unparseable — which degrades to an
// empty skill list and poisons the workspace snapshot the `$` picker
// reads. The SDK `app.skills` endpoint honors the per-request directory
// and returns complete results regardless of size.
const loadSkillsForCwd = (cwd: string) =>
effectiveConfig.serverUrl.trim().length > 0
? Effect.scoped(
@@ -172,11 +180,17 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv>
return yield* openCodeRuntime.loadOpenCodeSkills(client);
}),
)
: openCodeRuntime.loadSkillsFromCli({
binaryPath: effectiveConfig.binaryPath,
cwd,
environment: processEnv,
});
: serverOwner.withServer((server) =>
openCodeRuntime.loadOpenCodeSkills(
openCodeRuntime.createOpenCodeSdkClient({
baseUrl: server.url,
directory: cwd,
...(server.serverPassword !== undefined
? { serverPassword: server.serverPassword }
: {}),
}),
),
);
const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings);
const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<OpenCodeSettings>>(