History

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

Barry committed 2 months ago

Commit 2152d441 parent 70623151 file · +19 −5Browse files

Unified · Split

apps/server/src/provider/Drivers/OpenCodeDriver.ts+19−5
@@ -149,6 +149,14 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv> · 148 unmodified lines
149 Effect.provideService(OpenCodeServerOwner.OpenCodeServerOwner, serverOwner),149 Effect.provideService(OpenCodeServerOwner.OpenCodeServerOwner, serverOwner),
150 Effect.provideService(OpenCodeRuntime, openCodeRuntime),150 Effect.provideService(OpenCodeRuntime, openCodeRuntime),
151 );151 );
152 // NOTE: the local branch intentionally uses the shared SDK server
153 // instead of `opencode debug skill` (loadSkillsFromCli). The CLI writes
154 // its full JSON inventory to stdout, but the Bun-compiled binary does
155 // not flush more than one 64KB pipe buffer to a non-TTY stdout, so the
156 // piped output arrives truncated and unparseable — which degrades to an
157 // empty skill list and poisons the workspace snapshot the `$` picker
158 // reads. The SDK `app.skills` endpoint honors the per-request directory
159 // and returns complete results regardless of size.
152 const loadSkillsForCwd = (cwd: string) =>160 const loadSkillsForCwd = (cwd: string) =>
153 effectiveConfig.serverUrl.trim().length > 0161 effectiveConfig.serverUrl.trim().length > 0
154 ? Effect.scoped(162 ? Effect.scoped(
@@ -172,11 +180,17 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv> · 17 unmodified lines
172 return yield* openCodeRuntime.loadOpenCodeSkills(client);180 return yield* openCodeRuntime.loadOpenCodeSkills(client);
173 }),181 }),
174 )182 )
175 : openCodeRuntime.loadSkillsFromCli({183 : serverOwner.withServer((server) =>
176 binaryPath: effectiveConfig.binaryPath,184 openCodeRuntime.loadOpenCodeSkills(
177 cwd,185 openCodeRuntime.createOpenCodeSdkClient({
178 environment: processEnv,186 baseUrl: server.url,
179 });187 directory: cwd,
188 ...(server.serverPassword !== undefined
189 ? { serverPassword: server.serverPassword }
190 : {}),
191 }),
192 ),
193 );
180 194
181 const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings);195 const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings);
182 const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<OpenCodeSettings>>(196 const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<OpenCodeSettings>>(