diff --git a/llmhost/web/index.html b/llmhost/web/index.html index 0f235aa..b71e4ca 100644 --- a/llmhost/web/index.html +++ b/llmhost/web/index.html @@ -304,7 +304,9 @@ pre { placeholder="https://llm-api.example.com/v1" aria-label="API base URL">
  • Save the key where the provider reads it (paste it at the prompt; it stays out of your shell history):
  • -
  • Merge this into ~/.config/opencode/opencode.json, under "provider": +
  • Put this in ~/.config/opencode/opencode.json. If the file is empty or missing, paste the whole thing; + if it already has settings, add the entry under "provider" to its own "provider" + (and set "model" only if you want this as the default):
  • Pick in opencode's model list.
  • @@ -389,10 +391,17 @@ function renderOpencode() { block.options.baseURL = url || "https:///v1"; block.options.apiKey = `{file:${keyfile}}`; for (const m of Object.values(block.models || {})) if (m.name) m.name = m.name.replace("LABEL", label); - $("cx-block").textContent = JSON.stringify({ [prov]: block }, null, 2); + // A whole config, like `llmhost opencode-config` prints: it works as-is in an empty + // file, and its "provider" entry is what to merge into an existing one. + $("cx-block").textContent = JSON.stringify({ + $schema: "https://opencode.ai/config.json", + provider: { [prov]: block }, + model: `${prov}/${CONNECT.model}`, + }, null, 2); $("cx-keycmd").textContent = - `mkdir -p ~/.config/opencode && printf 'API key: ' && stty -echo && read -r k; stty echo; echo\n` + - `printf '%s\\n' "$k" > ${keyfile} && chmod 600 ${keyfile}; unset k`; + // One line: pasted as two, the first line's `read` would swallow the second as the key. + `mkdir -p ~/.config/opencode && printf 'API key: ' && stty -echo && read -r k; stty echo; echo; ` + + `[ -n "$k" ] && (umask 077 && printf '%s\\n' "$k" > ${keyfile}) && echo "saved ${keyfile}"; unset k`; $("cx-pick").textContent = `${block.name} → ${Object.values(block.models)[0]?.name || CONNECT.model}`; try { localStorage.setItem("llmhost-api-url", $("cx-url").value.trim()); } catch (e) {} }