GeezerVison is showing github.com — tui: allow specifying custom models file path via OPENCODE_MODELS_PATH · koji/opencode@6ecd011
File tree
Expand 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: .github/workflows/test.yml -4Lines changed: 0 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
61 | 61 | printf '%s\n' "XDG_STATE_HOME=${{ runner.temp }}/opencode-e2e/state" >> "$GITHUB_ENV" |
62 | 62 | fi |
63 | 63 |
|
64 | | - - name: Copy models fixture |
65 | | - run: | |
66 | | - cp "${{ github.workspace }}/packages/opencode/test/tool/fixtures/models-api.json" "${{ github.workspace }}/packages/opencode/src/provider/models-snapshot.ts" |
67 | | -
|
68 | 64 | - name: Seed opencode data |
69 | 65 | if: matrix.settings.name != 'windows' |
70 | 66 | working-directory: packages/opencode |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/opencode/src/flag/flag.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,6 +47,7 @@ export namespace Flag { |
47 | 47 | export const OPENCODE_EXPERIMENTAL_PLAN_MODE = OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_PLAN_MODE") |
48 | 48 | export const OPENCODE_EXPERIMENTAL_MARKDOWN = truthy("OPENCODE_EXPERIMENTAL_MARKDOWN") |
49 | 49 | export const OPENCODE_MODELS_URL = process.env["OPENCODE_MODELS_URL"] |
| 50 | + export const OPENCODE_MODELS_PATH = process.env["OPENCODE_MODELS_PATH"] |
50 | 51 |
|
51 | 52 | function number(key: string) { |
52 | 53 | const value = process.env[key] |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/opencode/src/provider/models.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -85,9 +85,9 @@ export namespace ModelsDev { |
85 | 85 | } |
86 | 86 |
|
87 | 87 | export const Data = lazy(async () => { |
88 | | - const file = Bun.file(filepath) |
| 88 | + const file = Bun.file(Flag.OPENCODE_MODELS_PATH ?? filepath) |
89 | 89 | const result = await file.json().catch(() => {}) |
90 | | - if (result && typeof result === "object" && Object.keys(result).length > 0) return result |
| 90 | + if (result) return result |
91 | 91 | // @ts-ignore |
92 | 92 | const snapshot = await import("./models-snapshot") |
93 | 93 | .then((m) => m.snapshot as Record<string, unknown>) |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/opencode/test/preload.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,6 +25,7 @@ process.env["XDG_DATA_HOME"] = path.join(dir, "share") |
25 | 25 | process.env["XDG_CACHE_HOME"] = path.join(dir, "cache") |
26 | 26 | process.env["XDG_CONFIG_HOME"] = path.join(dir, "config") |
27 | 27 | process.env["XDG_STATE_HOME"] = path.join(dir, "state") |
| 28 | +process.env["OPENCODE_MODELS_PATH"] = path.join(import.meta.dir, "tool", "fixtures", "models-api.json") |
28 | 29 |
|
29 | 30 | // Write the cache version file to prevent global/index.ts from clearing the cache |
30 | 31 | const cacheDir = path.join(dir, "cache", "opencode") |
|