summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core/script/update-models.ts
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-11-21 12:50:51 -0500
committerFrank <[email protected]>2025-11-21 12:50:51 -0500
commit037e8d4555b770c7cf33dd10a5c9746c50d2f597 (patch)
treee232290a057c24033f88582353bb13d43398e1e1 /packages/console/core/script/update-models.ts
parent08a366c4dcd9fa2bbf95727850a2ee92055781b8 (diff)
downloadopencode-037e8d4555b770c7cf33dd10a5c9746c50d2f597.tar.gz
opencode-037e8d4555b770c7cf33dd10a5c9746c50d2f597.zip
wip: zen
Diffstat (limited to 'packages/console/core/script/update-models.ts')
-rwxr-xr-xpackages/console/core/script/update-models.ts29
1 files changed, 17 insertions, 12 deletions
diff --git a/packages/console/core/script/update-models.ts b/packages/console/core/script/update-models.ts
index 807d57826..a8523a5f2 100755
--- a/packages/console/core/script/update-models.ts
+++ b/packages/console/core/script/update-models.ts
@@ -9,21 +9,20 @@ const root = path.resolve(process.cwd(), "..", "..", "..")
const models = await $`bun sst secret list`.cwd(root).text()
// read the line starting with "ZEN_MODELS"
-const oldValue1 = models
- .split("\n")
- .find((line) => line.startsWith("ZEN_MODELS1"))
- ?.split("=")[1]
-const oldValue2 = models
- .split("\n")
- .find((line) => line.startsWith("ZEN_MODELS2"))
- ?.split("=")[1]
+const lines = models.split("\n")
+const oldValue1 = lines.find((line) => line.startsWith("ZEN_MODELS1"))?.split("=")[1]
+const oldValue2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[1]
+const oldValue3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
+const oldValue4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
if (!oldValue1) throw new Error("ZEN_MODELS1 not found")
if (!oldValue2) throw new Error("ZEN_MODELS2 not found")
+if (!oldValue3) throw new Error("ZEN_MODELS3 not found")
+if (!oldValue4) throw new Error("ZEN_MODELS4 not found")
// store the prettified json to a temp file
const filename = `models-${Date.now()}.json`
const tempFile = Bun.file(path.join(os.tmpdir(), filename))
-await tempFile.write(JSON.stringify(JSON.parse(oldValue1 + oldValue2), null, 2))
+await tempFile.write(JSON.stringify(JSON.parse(oldValue1 + oldValue2 + oldValue3 + oldValue4), null, 2))
console.log("tempFile", tempFile.name)
// open temp file in vim and read the file on close
@@ -32,6 +31,12 @@ const newValue = JSON.stringify(JSON.parse(await tempFile.text()))
ZenData.validate(JSON.parse(newValue))
// update the secret
-const mid = Math.floor(newValue.length / 2)
-await $`bun sst secret set ZEN_MODELS1 ${newValue.slice(0, mid)}`
-await $`bun sst secret set ZEN_MODELS2 ${newValue.slice(mid)}`
+const chunk = Math.ceil(newValue.length / 4)
+const newValue1 = newValue.slice(0, chunk)
+const newValue2 = newValue.slice(chunk, chunk * 2)
+const newValue3 = newValue.slice(chunk * 2, chunk * 3)
+const newValue4 = newValue.slice(chunk * 3)
+await $`bun sst secret set ZEN_MODELS1 ${newValue1}`
+await $`bun sst secret set ZEN_MODELS2 ${newValue2}`
+await $`bun sst secret set ZEN_MODELS3 ${newValue3}`
+await $`bun sst secret set ZEN_MODELS4 ${newValue4}`