allow selecting model and continuing previous session for opencode run

This commit is contained in:
Dax Raad
2025-06-19 12:29:34 -04:00
parent 24c0ce6e53
commit 7d1a1663c8
3 changed files with 48 additions and 5 deletions

View File

@@ -272,9 +272,14 @@ export namespace Provider {
export async function defaultModel() {
const cfg = await Config.get()
if (cfg.model) return parseModel(cfg.model)
const provider = await list()
.then((val) => Object.values(val))
.then((x) => x.find((p) => !cfg.provider || Object.keys(cfg.provider).includes(p.info.id)))
.then((x) =>
x.find(
(p) => !cfg.provider || Object.keys(cfg.provider).includes(p.info.id),
),
)
if (!provider) throw new Error("no providers found")
const [model] = sort(Object.values(provider.info.models))
if (!model) throw new Error("no models found")
@@ -284,6 +289,14 @@ export namespace Provider {
}
}
export function parseModel(model: string) {
const [providerID, ...rest] = model.split("/")
return {
providerID: providerID,
modelID: rest.join("/"),
}
}
const TOOLS = [
BashTool,
EditTool,