GeezerVison is showing github.com — fix(core): accept deprecated reference config key (#31659) · maximkr/opencode@90fb32b
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .opencode/opencode.jsonc +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | "$schema": "https://opencode.ai/config.json", | 3 | 3 | "provider": {}, | 4 | 4 | "permission": {}, | 5 | | - "references": { | | 5 | + // TODO: flip back to `references` once a release containing the v1 `reference` migration ships. | | 6 | + // The release pipeline runs the latest published opencode against this file, which only knows `reference`. | | 7 | + "reference": { | 6 | 8 | "effect": { | 7 | 9 | "repository": "github.com/Effect-TS/effect-smol", | 8 | 10 | "description": "Use for Effect v4 and effect-smol implementation details", | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/src/v1/config/config.ts +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,6 +45,9 @@ export const Info = Schema.Struct({ | 45 | 45 | references: Schema.optional(ConfigReference.Info).annotate({ | 46 | 46 | description: "Named git or local directory references", | 47 | 47 | }), | | 48 | + reference: Schema.optional(ConfigReference.Info).annotate({ | | 49 | + description: "@deprecated Use 'references' field instead. Named git or local directory references", | | 50 | + }), | 48 | 51 | watcher: Schema.optional(Schema.Struct({ ignore: Schema.optional(Schema.mutable(Schema.Array(Schema.String))) })), | 49 | 52 | snapshot: Schema.optional(Schema.Boolean).annotate({ | 50 | 53 | description: | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/src/v1/config/migrate.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,6 +12,7 @@ const keys = new Set([ | 12 | 12 | "logLevel", | 13 | 13 | "server", | 14 | 14 | "command", | | 15 | + "reference", | 15 | 16 | "snapshot", | 16 | 17 | "plugin", | 17 | 18 | "autoshare", | @@ -62,7 +63,7 @@ export function migrate(info: typeof ConfigV1.Info.Type) { | 62 | 63 | skills: info.skills && [...(info.skills.paths ?? []), ...(info.skills.urls ?? [])], | 63 | 64 | commands: info.command, | 64 | 65 | instructions: info.instructions, | 65 | | - references: info.references, | | 66 | + references: info.references ?? info.reference, | 66 | 67 | plugins: info.plugin?.map((plugin) => | 67 | 68 | typeof plugin === "string" ? plugin : { package: plugin[0], options: plugin[1] }, | 68 | 69 | ), | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/test/config/config.test.ts +38Lines changed: 38 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -70,7 +70,9 @@ describe("Config", () => { | 70 | 70 | Effect.sync(() => { | 71 | 71 | expect(ConfigMigrateV1.isV1({ snapshot: false })).toBe(true) | 72 | 72 | expect(ConfigMigrateV1.isV1({ snapshot: false, agents: {} })).toBe(true) | | 73 | + expect(ConfigMigrateV1.isV1({ reference: {} })).toBe(true) | 73 | 74 | expect(ConfigMigrateV1.isV1({ shell: "/bin/zsh", model: "anthropic/claude" })).toBe(false) | | 75 | + expect(ConfigMigrateV1.isV1({ references: {} })).toBe(false) | 74 | 76 | }), | 75 | 77 | ) | 76 | 78 |
| @@ -431,6 +433,42 @@ describe("Config", () => { | 431 | 433 | ), | 432 | 434 | ) | 433 | 435 |
| | 436 | + it.live("migrates the deprecated reference key into references", () => | | 437 | + Effect.acquireRelease( | | 438 | + Effect.promise(() => tmpdir()), | | 439 | + (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()), | | 440 | + ).pipe( | | 441 | + Effect.flatMap((tmp) => | | 442 | + Effect.gen(function* () { | | 443 | + yield* Effect.promise(() => | | 444 | + fs.writeFile( | | 445 | + path.join(tmp.path, "opencode.json"), | | 446 | + JSON.stringify({ | | 447 | + reference: { | | 448 | + local: { path: "../library" }, | | 449 | + sdk: { repository: "github.com/example/sdk", branch: "main" }, | | 450 | + shorthand: "github.com/example/docs", | | 451 | + }, | | 452 | + }), | | 453 | + ), | | 454 | + ) | | 455 | + | | 456 | + return yield* Effect.gen(function* () { | | 457 | + const config = yield* Config.Service | | 458 | + const documents = (yield* config.entries()).filter((entry) => entry.type === "document") | | 459 | + | | 460 | + expect(documents).toHaveLength(1) | | 461 | + expect(documents[0]?.info.references).toEqual({ | | 462 | + local: { path: "../library" }, | | 463 | + sdk: { repository: "github.com/example/sdk", branch: "main" }, | | 464 | + shorthand: "github.com/example/docs", | | 465 | + }) | | 466 | + }).pipe(Effect.provide(testLayer(tmp.path))) | | 467 | + }), | | 468 | + ), | | 469 | + ), | | 470 | + ) | | 471 | + | 434 | 472 | it.live("migrates v1 configuration when a v1-only key is present", () => | 435 | 473 | Effect.acquireRelease( | 436 | 474 | Effect.promise(() => tmpdir()), | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/test/config/config.test.ts +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -722,6 +722,26 @@ it.instance("migrates mode field to agent field", () => | 722 | 722 | }), | 723 | 723 | ) | 724 | 724 |
| | 725 | +it.instance("accepts the deprecated reference field", () => | | 726 | + Effect.gen(function* () { | | 727 | + const test = yield* TestInstance | | 728 | + yield* writeConfigEffect(test.directory, { | | 729 | + $schema: "https://opencode.ai/config.json", | | 730 | + reference: { | | 731 | + local: { path: "../library" }, | | 732 | + sdk: { repository: "github.com/example/sdk", branch: "main" }, | | 733 | + shorthand: "github.com/example/docs", | | 734 | + }, | | 735 | + }) | | 736 | + const config = yield* Config.use.get() | | 737 | + expect(config.reference).toEqual({ | | 738 | + local: { path: "../library" }, | | 739 | + sdk: { repository: "github.com/example/sdk", branch: "main" }, | | 740 | + shorthand: "github.com/example/docs", | | 741 | + }) | | 742 | + }), | | 743 | +) | | 744 | + | 725 | 745 | it.instance("loads config from .opencode directory", () => | 726 | 746 | Effect.gen(function* () { | 727 | 747 | const test = yield* TestInstance | |
Collapse file Copy file name to clipboardExpand all lines: packages/sdk/js/src/v2/gen/types.gen.ts +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1931,6 +1931,9 @@ export type Config = { | 1931 | 1931 | references?: { | 1932 | 1932 | [key: string]: string | ConfigV2ReferenceGit | ConfigV2ReferenceLocal | 1933 | 1933 | } | | 1934 | + reference?: { | | 1935 | + [key: string]: string | ConfigV2ReferenceGit | ConfigV2ReferenceLocal | | 1936 | + } | 1934 | 1937 | watcher?: { | 1935 | 1938 | ignore?: Array<string> | 1936 | 1939 | } | |
|