GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(core): drop the legacy Console config path (#59595) · abn/opencode@5e31344

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/core
    • src
      • config/plugin
        • policy.ts
      • plugin/provider
        • opencode-legacy.ts
        • opencode.ts
    • test/plugin
      • provider-opencode.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/core/src/config/plugin/policy.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/config/plugin/policy.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export const Plugin = define({
2222
Effect.forkScoped({ startImmediately: true }),
2323
)
2424
// Documents reverse so earlier-loaded policy wins: managed policy, then a Console config document, then user
25-
// and project files. Statements from a Console serving the legacy format follow every document and have the
26-
// final say.
25+
// and project files. ManagedPolicy statements follow every document and have the final say; the Console no longer
26+
// sets any, since it serves its policy as a config document.
2727
const policies = () => ManagedPolicy.statements(loaded.entries, managed.current())
2828
const runSync = Effect.runSyncWith(yield* Effect.context())
2929
yield* ctx.provider.transform((providers) => {
Collapse file

‎packages/core/src/plugin/provider/opencode-legacy.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/plugin/provider/opencode-legacy.ts
-191Lines changed: 0 additions & 191 deletions
This file was deleted.
Collapse file

‎packages/core/src/plugin/provider/opencode.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/plugin/provider/opencode.ts
+23-60Lines changed: 23 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
import {
2-
Clock,
3-
Duration,
4-
Effect,
5-
Equal,
6-
FiberHandle,
7-
Option,
8-
Predicate,
9-
Schema,
10-
Scope,
11-
Semaphore,
12-
Stream,
13-
} from "effect"
1+
import { Clock, Duration, Effect, Equal, FiberHandle, Option, Schema, Scope, Semaphore, Stream } from "effect"
142
import type { IntegrationOAuthMethodRegistration } from "@opencode/plugin/effect/integration"
153
import { define } from "@opencode/plugin/effect/plugin"
164
import type { SessionHttpResponse } from "@opencode/plugin/effect/session"
@@ -27,7 +15,6 @@ import { IntegrationConnection } from "../../integration/connection.js"
2715
import { ManagedPolicy } from "../../managed-policy.js"
2816
import { Provider } from "../../provider.js"
2917
import { WebSearch } from "../../websearch.js"
30-
import { OpencodeLegacy } from "./opencode-legacy.js"
3118

3219
const clientID = "opencode-cli"
3320
const methodID = Integration.MethodID.make("device")
@@ -173,9 +160,8 @@ export const OpencodePlugin = define<
173160
const loading = Semaphore.makeUnsafe(1)
174161
type ActiveConnection = Effect.Success<ReturnType<typeof ctx.integration.connection.active>>
175162
let snapshot: {
176-
// The Console response in one of its two formats: a regular OpenCode config, merged as an integration config
177-
// layer, or the legacy response, which OpencodeLegacy applies directly.
178-
remote: { type: "config"; info: ConfigIntegration.Remote } | OpencodeLegacy.Snapshot | undefined
163+
// The Console's regular OpenCode config, merged as an integration config layer.
164+
remote: ConfigIntegration.Remote | undefined
179165
connection: ActiveConnection
180166
organization: string | undefined
181167
} = { remote: undefined, connection: undefined, organization: undefined }
@@ -202,10 +188,7 @@ export const OpencodePlugin = define<
202188
return Effect.succeed({ remote: undefined, connection, organization: undefined })
203189
return fetchConfig(http, credential).pipe(
204190
Effect.map((remote) => ({
205-
remote:
206-
remote?.type === "legacy"
207-
? OpencodeLegacy.make(remote.response, ConsoleAccess.headers(credential))
208-
: remote,
191+
remote,
209192
connection,
210193
organization: organizationName(credential),
211194
})),
@@ -228,7 +211,7 @@ export const OpencodePlugin = define<
228211
)
229212
})
230213
// The Console document as config layered it. Its providers apply at this plugin's position in the provider chain,
231-
// where the legacy overlay applies, while the rest of the document merges through config.
214+
// while the rest of the document merges through config.
232215
let integrated: ConfigIntegration.Document | undefined
233216
const integrate = Effect.fnUntraced(function* (document: ConfigIntegration.Document | undefined) {
234217
yield* config.integration?.(Integration.ID.make("opencode"), document) ?? Effect.void
@@ -239,30 +222,21 @@ export const OpencodePlugin = define<
239222
})
240223
// Policies and providers ride on the snapshot, so a credential switch, disconnect, or 404 replaces them too.
241224
const publish = Effect.fnUntraced(function* (next: typeof snapshot) {
242-
switch (next.remote?.type) {
243-
// A regular config merges as one integration document, which config loads right after managed policies,
244-
// so its policies reach ManagedPolicy through config rather than as Console statements.
245-
case "config":
246-
yield* managed.set({ statements: [], organization: next.organization })
247-
return yield* integrate(
248-
next.connection &&
249-
ConfigIntegration.make({
250-
integrationID: Integration.ID.make("opencode"),
251-
connection:
252-
next.connection.type === "credential"
253-
? { ...next.connection, id: Credential.ID.make(next.connection.id) }
254-
: next.connection,
255-
organization: next.organization,
256-
info: next.remote.info,
257-
}),
258-
)
259-
case "legacy":
260-
yield* managed.set({ statements: OpencodeLegacy.statements(next.remote), organization: next.organization })
261-
return yield* integrate(undefined)
262-
default:
263-
yield* managed.set({ statements: [], organization: next.organization })
264-
return yield* integrate(undefined)
265-
}
225+
yield* managed.set({ statements: [], organization: next.organization })
226+
// The config merges as one integration document, which config loads right after managed policies.
227+
yield* integrate(
228+
next.remote &&
229+
next.connection &&
230+
ConfigIntegration.make({
231+
integrationID: Integration.ID.make("opencode"),
232+
connection:
233+
next.connection.type === "credential"
234+
? { ...next.connection, id: Credential.ID.make(next.connection.id) }
235+
: next.connection,
236+
organization: next.organization,
237+
info: next.remote,
238+
}),
239+
)
266240
})
267241
const search = (providerID: WebSearch.ID, connection: NonNullable<ActiveConnection>) => ({
268242
id: providerID,
@@ -324,7 +298,6 @@ export const OpencodePlugin = define<
324298

325299
snapshot = yield* load()
326300
yield* publish(snapshot)
327-
yield* OpencodeLegacy.register(ctx, () => snapshot, search)
328301
yield* ctx.provider.transform((providers) => {
329302
if (integrated) ConfigProviderPlugin.integrate(providers, integrated)
330303
})
@@ -360,12 +333,7 @@ export const OpencodePlugin = define<
360333
// config, where the user's own choice wins.
361334
yield* ctx.websearch.transform((editor) => {
362335
const provider = WebSearch.ID.make("opencode")
363-
if (
364-
snapshot.remote?.type === "config" &&
365-
snapshot.remote.info.websearch &&
366-
snapshot.remote.info.websearch.provider === provider &&
367-
snapshot.connection
368-
)
336+
if (snapshot.remote?.websearch && snapshot.remote.websearch.provider === provider && snapshot.connection)
369337
editor.add(search(provider, snapshot.connection))
370338
})
371339

@@ -418,9 +386,7 @@ export const OpencodePlugin = define<
418386
next.connection
419387
? new Set([
420388
Provider.ID.opencode,
421-
...(next.remote?.type === "config"
422-
? Object.keys(next.remote.info.providers ?? {})
423-
: OpencodeLegacy.providerIDs(next.remote)),
389+
...Object.keys(next.remote?.providers ?? {}),
424390
])
425391
: [],
426392
(providerID) => ctx.session.hook("http.response", explain, { providerID }).pipe(Scope.provide(scope)),
@@ -473,10 +439,7 @@ function fetchConfig(http: HttpClient.HttpClient, value: Credential.Key | Creden
473439
})
474440
}
475441
const body = yield* HttpClientResponse.filterStatusOk(response).pipe(Effect.flatMap((ok) => ok.json))
476-
// A Console that serves a regular OpenCode config marks it with `$schema`; any other body is the legacy response.
477-
if (Predicate.hasProperty(body, "$schema"))
478-
return { type: "config" as const, info: yield* Schema.decodeUnknownEffect(ConfigIntegration.Remote)(body) }
479-
return { type: "legacy" as const, response: yield* Schema.decodeUnknownEffect(OpencodeLegacy.Response)(body) }
442+
return yield* Schema.decodeUnknownEffect(ConfigIntegration.Remote)(body)
480443
}),
481444
),
482445
Effect.scoped,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.