summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core/script
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-11-03 15:43:52 -0500
committerFrank <[email protected]>2025-11-03 15:44:06 -0500
commit05232ead938b7cc7dcf75afa9470effef0ed4251 (patch)
tree6005e5686e1bd6a525d90387b8932d345d4846b1 /packages/console/core/script
parent7652a9606413f0d6e9af2c65aeee692c44996006 (diff)
downloadopencode-05232ead938b7cc7dcf75afa9470effef0ed4251.tar.gz
opencode-05232ead938b7cc7dcf75afa9470effef0ed4251.zip
zen: wip
Diffstat (limited to 'packages/console/core/script')
-rwxr-xr-xpackages/console/core/script/promote-models.ts16
-rwxr-xr-xpackages/console/core/script/update-models.ts22
2 files changed, 25 insertions, 13 deletions
diff --git a/packages/console/core/script/promote-models.ts b/packages/console/core/script/promote-models.ts
index 67c2b6f3e..717813e40 100755
--- a/packages/console/core/script/promote-models.ts
+++ b/packages/console/core/script/promote-models.ts
@@ -11,14 +11,20 @@ const root = path.resolve(process.cwd(), "..", "..", "..")
// read the secret
const ret = await $`bun sst secret list`.cwd(root).text()
-const value = ret
+const value1 = ret
.split("\n")
- .find((line) => line.startsWith("ZEN_MODELS"))
+ .find((line) => line.startsWith("ZEN_MODELS1"))
?.split("=")[1]
-if (!value) throw new Error("ZEN_MODELS not found")
+const value2 = ret
+ .split("\n")
+ .find((line) => line.startsWith("ZEN_MODELS2"))
+ ?.split("=")[1]
+if (!value1) throw new Error("ZEN_MODELS1 not found")
+if (!value2) throw new Error("ZEN_MODELS2 not found")
// validate value
-ZenData.validate(JSON.parse(value))
+ZenData.validate(JSON.parse(value1 + value2))
// update the secret
-await $`bun sst secret set ZEN_MODELS ${value} --stage ${stage}`
+await $`bun sst secret set ZEN_MODELS1 ${value1} --stage ${stage}`
+await $`bun sst secret set ZEN_MODELS2 ${value2} --stage ${stage}`
diff --git a/packages/console/core/script/update-models.ts b/packages/console/core/script/update-models.ts
index 939af616e..e7a245515 100755
--- a/packages/console/core/script/update-models.ts
+++ b/packages/console/core/script/update-models.ts
@@ -10,23 +10,29 @@ const models = await $`bun sst secret list`.cwd(root).text()
console.log("models", models)
// read the line starting with "ZEN_MODELS"
-const oldValue = models
+const oldValue1 = models
.split("\n")
- .find((line) => line.startsWith("ZEN_MODELS"))
+ .find((line) => line.startsWith("ZEN_MODELS1"))
?.split("=")[1]
-if (!oldValue) throw new Error("ZEN_MODELS not found")
-console.log("oldValue", oldValue)
+const oldValue2 = models
+ .split("\n")
+ .find((line) => line.startsWith("ZEN_MODELS2"))
+ ?.split("=")[1]
+if (!oldValue1) throw new Error("ZEN_MODELS1 not found")
+if (!oldValue2) throw new Error("ZEN_MODELS2 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(oldValue), null, 2))
+await tempFile.write(JSON.stringify(JSON.parse(oldValue1 + oldValue2), null, 2))
console.log("tempFile", tempFile.name)
// open temp file in vim and read the file on close
await $`vim ${tempFile.name}`
-const newValue = JSON.parse(await tempFile.text())
-ZenData.validate(newValue)
+const newValue = JSON.stringify(JSON.parse(await tempFile.text()))
+ZenData.validate(JSON.parse(newValue))
// update the secret
-await $`bun sst secret set ZEN_MODELS ${JSON.stringify(newValue)}`
+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)}`