Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ out/
.DS_Store
scripts/validate-models.mjs
scripts/validate-models.mjs.map
tmp/
12 changes: 12 additions & 0 deletions .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"config": {
"MD013": false,
"MD024": {
"siblings_only": true,
},
"MD033": false,
"MD041": false,
"MD060": false,
},
"gitignore": true,
}
9 changes: 0 additions & 9 deletions .markdownlint.json

This file was deleted.

3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.gitignore
.github/**
.husky/**
.markdownlint.json
.markdownlint-cli2.jsonc
.prettierrc.json
.vscode/**
.vscode-test/**
Expand All @@ -23,3 +23,4 @@ src/**
tsconfig.json
package-lock.json
media/opencodego.svg
tmp/**
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to the **OpenCode Go BYOK Provider** extension are documente

## [Unreleased]

### Added

- **`[VS Code]` Remove OpenCode Go / OpenCode Zen from Language Models.** Providers can now be removed from the Language Models list and every model picker like in GitHub Copilot's Manage Language Models: new `opencodego.enabled` / `opencodezen.enabled` settings (with matching `when` clauses on the vendor contributions) skip provider registration, plus `OpenCode Go/Zen: Remove/Re-add Provider in Language Models` commands and a **Remove from Language Models** action in the Manage Provider QuickPick. API keys and BYOK group settings are kept so re-enabling restores the provider unchanged. A window reload is required after toggling.
- **`[Agents]` OpenCode Go/Zen in the VS Code Agents window (#122).** VS Code ≥1.129 runs the Agents window in a separate agent host process and keeps the two mechanisms this feature depends on off by default: the experimental BYOK model bridge (`chat.agentHost.byokModels.enabled`) that mirrors extension BYOK models into agent-host sessions, and `extensions.supportAgentsWindow`, without which code extensions are disabled in the Agents window process entirely — so OpenCode Go/Zen were missing from both the Agents window model picker and its "+ Add Models" vendor list. The extension now auto-enables both settings on activation (gated by the new `opencodego.autoEnableAgentsWindow` setting, default `true`, merging with any existing user values), records what it flipped, and offers a reload button the first time. When the user disables `opencodego.agentsWindow` afterwards, only the settings the extension itself enabled are reverted. The legacy agent-host providers (`targetChatSessionType: "copilotcli"`) remain registered for VS Code 1.125–1.128, where the bridge does not exist.

### Fixed

- **`[VS Code]` Provider context menu unresponsive; "+ Add Models" dead; leftover groups undeletable (#121).** The `languageModelChatProviders` contributions declared both `managementCommand` and a `configuration` schema. VS Code's native BYOK flow (`configureLanguageModelsProviderGroup`) short-circuits on `managementCommand` — it re-resolves models and returns without prompting for a group name or API key — so a BYOK group could never be created through "+ Add Models", and every built-in context-menu action (Rename Group, Update API Key, Delete, Open in Language Models (JSON)) throws "group not found", failing silently. Dropped `managementCommand` from the `opencodego`, `opencodezen`, and agent-variant contributions; "+ Add Models" now runs the native prompt flow, the context-menu actions work against the created group, and leftover groups (e.g. created by per-model configuration) can finally be deleted. The extension's own commands (`OpenCode Go: Manage Provider`, `Set API Key`, etc.) remain available in the Command Palette and keep working as a legacy fallback.
Expand Down
59 changes: 37 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
| 📊 **Live usage tracking** | Status bar shows Go subscription burn-rate across 5h / weekly / monthly tiers |
| 🔌 **Dual providers** | OpenCode **Go** ($10/mo subscription) + OpenCode **Zen** (free + paid models) — run both at once, switch instantly |
| 🎯 **Smart routing** | Each model family auto-routes to its native transport (`/responses`, `/messages`, `streamGenerateContent`, `/chat/completions`) |
| 🖼️ **Vision + PDF + Audio** | Multimodal models pass through image, PDF, audio, and video inputs. Oversized images auto-resize to 2000×2000 / 5MB to match the gateway contract. |
| 🖼️ **Vision + PDF + Audio** | Multimodal models pass through image, PDF, audio, and video inputs. Oversized images auto-resize to 2000×2000 / 5MB to match the gateway contract. |
| 📐 **Context-size picker** | Kimi K3 and other tiered-context models expose `256K` vs full-window selection in the per-model configuration, with the cheaper tier selected by default. |
| 🔒 **Your key, your control** | API key stored in VS Code SecretStorage — never leaves your machine |

Expand Down Expand Up @@ -270,43 +270,58 @@ Delete Active Profile` help you manage your profiles. The label you give

### 🪟 Agents Window (Copilot CLI) Support

OpenCode models appear in the VS Code **Agents window** model picker when starting a Copilot CLI / Background agent session — not just the regular Chat view. Two sets of models are available:
OpenCode models appear in the VS Code **Agents window** model picker when starting a Copilot CLI / Background agent session — not just the regular Chat view:

| Provider | Appears under | Notes |
| ---------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `opencodego` / `opencodezen` | **Local** | Normal models, no `targetChatSessionType`. From VS Code ≥1.126 they appear naturally in the Local section (once the extension loads in the sessions window). |
| `opencodego-agent` / `opencodezen-agent` | **Copilot** | Agent variants with `targetChatSessionType: "copilotcli"`. Picked up by `CopilotChatSessionsProvider` for agent sessions. |
| Provider | Appears under | Notes |
| ---------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `opencodego` / `opencodezen` | **Local** | Normal models, no `targetChatSessionType`. On VS Code 1.129+ they reach agent-host sessions through VS Code's BYOK model bridge. |
| `opencodego-agent` / `opencodezen-agent` | **Copilot** | Agent variants with `targetChatSessionType: "copilotcli"`. Picked up by `CopilotChatSessionsProvider` for legacy agent sessions (VS Code ≤1.128). |

**How it works:**

| Setting | Default | What it controls |
| ----------------------------------------- | ------- | ------------------------------------------------------- |
| `opencodego.agentsWindow` | `true` | Registers agent-host providers at runtime |
| `opencodego.showAgentModelsInManagePanel` | `false` | Shows agent vendors in the Manage Language Models panel |
VS Code ≥1.129 runs the Agents window in a separate agent host process and keeps two knobs **off by default** that this extension depends on:

**Setup:**
1. `chat.agentHost.byokModels.enabled` (experimental) — the BYOK language-model bridge that mirrors extension-provided BYOK models into agent-host sessions.
2. `extensions.supportAgentsWindow` — without it, code extensions are **disabled in the Agents window process**, so OpenCode Go/Zen don't appear in the Agents window picker nor in its **+ Add Models** list.

1. Agent models are enabled by default (`agentsWindow: true`). No changes needed for basic usage.
2. Add this to your VS Code `settings.json` to enable the extension in the Agents window process:
The extension auto-enables both when `agentsWindow` is on:

```json
"extensions.supportAgentsWindow": {
"ltmoerdani.opencode-copilot-chat": true
}
```
| Setting | Default | What it controls |
| ----------------------------------------- | ------- | ------------------------------------------------------------------------------------------------- |
| `opencodego.agentsWindow` | `true` | Master switch for Agents window support |
| `opencodego.autoEnableAgentsWindow` | `true` | Auto-manage the two VS Code core settings above (and revert them when `agentsWindow` is disabled) |
| `opencodego.showAgentModelsInManagePanel` | `false` | Shows agent vendors in the Manage Language Models panel |

3. Reload the window (`Developer: Reload Window`).
4. Open the **Agents window** → start a new session → select **Copilot CLI** as the agent type.
5. Open the model picker — OpenCode models appear under **Local** (normal models) and **Copilot** (agent-host variants).
**Setup:**

Normal OpenCode models (`opencodego`, `opencodezen`) appear in the **Local** section of the Agents window picker from VS Code ≥1.126 onwards. On ≤1.125 they may require the `supportAgentsWindow` setting. Agent-host variants (`opencodego-agent`, `opencodezen-agent`) appear under **Copilot** because they carry `targetChatSessionType: "copilotcli"` and are matched by `CopilotChatSessionsProvider`.
1. Agent models are enabled by default (`agentsWindow: true`). The extension auto-enables the required VS Code settings on first activation and offers a **Reload Now** button — a window reload is required for them to take effect.
2. Reload the window (`Developer: Reload Window`) if you haven't been prompted.
3. Open the **Agents window** → start a new session → select **Copilot CLI** as the agent type.
4. Open the model picker — OpenCode models appear under their provider; the **+ Add Models** list in the Agents window's Language Models view now includes **OpenCode Go** and **OpenCode Zen**.

To manage agent API keys separately or see agent vendors in the Manage panel, enable:

```json
"opencodego.showAgentModelsInManagePanel": true
```

#### ❌ Removing a provider from Language Models

Like deleting a provider in GitHub Copilot's Manage Language Models, you can
remove **OpenCode Go** or **OpenCode Zen** from the Language Models list and
every model picker:

- **Command Palette** — `OpenCode Go: Remove/Re-add Provider in Language
Models` (same for Zen), or use **Manage Provider → Remove from Language
Models**.
- **Settings** — set `opencodego.enabled` / `opencodezen.enabled` to `false`.

The provider's vendor row and models disappear from the Manage Language
Models view, the `+ Add Models` list, the Chat picker, and the Agents window.
Your API key and BYOK group settings are kept, so re-enabling (or the
`Re-add to Language Models` action) restores everything. A window reload is
required after toggling.

### 🛠️ Smart Routing & Reliability

- **Native endpoint routing** per family (see [Models](#-models) table)
Expand Down
11 changes: 4 additions & 7 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { readFileSync } from "node:fs";
import tseslint from "typescript-eslint";

const gitignore = readFileSync(new URL(".gitignore", import.meta.url), "utf8")
.split(/\r?\n/)
.map((line) => line.trim())
.filter((line) => line && !line.startsWith("#") && !line.startsWith("!"));
import { readGitignorePatterns } from "./scripts/gitignore-patterns.mjs";

export default tseslint.config(
{
ignores: gitignore,
// Ignore everything `.gitignore` ignores (tmp/, out/, generated scripts,
// …) so linting stays in sync with the repo's ignore rules at runtime.
ignores: readGitignorePatterns(),
},
...tseslint.configs.recommended,
{
Expand Down
35 changes: 30 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
"command": "opencodego.setApiKey",
"title": "OpenCode Go: Set API Key"
},
{
"command": "opencodego.toggleProvider",
"title": "OpenCode Go: Remove/Re-add Provider in Language Models"
},
{
"command": "opencodego.refreshModels",
"title": "OpenCode Go: Refresh Models"
Expand All @@ -90,6 +94,10 @@
"command": "opencodezen.manage",
"title": "OpenCode Zen: Manage Provider"
},
{
"command": "opencodezen.toggleProvider",
"title": "OpenCode Zen: Remove/Re-add Provider in Language Models"
},
{
"command": "opencodezen.refreshModels",
"title": "OpenCode Zen: Refresh Models"
Expand Down Expand Up @@ -186,10 +194,25 @@
"default": true,
"description": "When enabled, only free OpenCode Zen models are shown in the Copilot model selector. Disable to include paid Zen models as well."
},
"opencodego.enabled": {
"type": "boolean",
"default": true,
"markdownDescription": "Register the OpenCode Go provider. Set to `false` to remove OpenCode Go from the Language Models list and all model pickers (like deleting the provider in GitHub Copilot's Manage Language Models). Models you previously configured stay in your language-models config so they come back if you re-enable. Requires a window reload to take effect."
},
"opencodezen.enabled": {
"type": "boolean",
"default": true,
"markdownDescription": "Register the OpenCode Zen provider. Set to `false` to remove OpenCode Zen from the Language Models list and all model pickers (like deleting the provider in GitHub Copilot's Manage Language Models). Models you previously configured stay in your language-models config so they come back if you re-enable. Requires a window reload to take effect."
},
"opencodego.agentsWindow": {
"type": "boolean",
"default": true,
"markdownDescription": "Register separate agent-host providers for the Copilot Agents window. Disable to hide the Agents section entirely. Requires a window reload to take effect."
"markdownDescription": "Enable OpenCode models in the VS Code Agents window. On VS Code 1.129+ this enables VS Code's BYOK model bridge (`chat.agentHost.byokModels.enabled`) so OpenCode Go/Zen models run in agent-host sessions; on all versions it also opts the extension in to run in the Agents window process (`extensions.supportAgentsWindow`) so OpenCode Go/Zen appear in the Agents window's '+ Add Models' list. Both core settings are auto-managed (see `#opencodego.autoEnableAgentsWindow#`). Disable to hide the Agents section entirely and revert the auto-managed settings. Requires a window reload to take effect."
},
"opencodego.autoEnableAgentsWindow": {
"type": "boolean",
"default": true,
"markdownDescription": "When `#opencodego.agentsWindow#` is on, automatically enable the VS Code core settings the Agents window support depends on: `chat.agentHost.byokModels.enabled` (BYOK model bridge, experimental, off by default) and `extensions.supportAgentsWindow: { \"ltmoerdani.opencode-copilot-chat\": true }` (without this the extension is disabled in the Agents window process and its providers, including the '+ Add Models' vendors, are missing). The extension records the values it flips and reverts them when `agentsWindow` is disabled. A window reload is required after the first auto-enable. Disable to manage those settings manually."
},
"opencodego.showAgentModelsInManagePanel": {
"type": "boolean",
Expand Down Expand Up @@ -285,6 +308,7 @@
{
"vendor": "opencodego",
"displayName": "OpenCode Go",
"when": "config.opencodego.enabled",
"configuration": {
"type": "object",
"required": [
Expand All @@ -303,6 +327,7 @@
{
"vendor": "opencodezen",
"displayName": "OpenCode Zen",
"when": "config.opencodezen.enabled",
"configuration": {
"type": "object",
"required": [
Expand Down Expand Up @@ -334,10 +359,10 @@
"lint": "npm run lint:js && npm run lint:md",
"lint:js": "eslint .",
"lint:fix": "eslint . --fix",
"lint:md": "markdownlint-cli2 --config .markdownlint.json \"**/*.md\" \"#node_modules\" \"#docs/**\"",
"lint:md:all": "markdownlint-cli2 --config .markdownlint.json \"**/*.md\" \"#node_modules\"",
"format": "npx prettier --write .",
"format:check": "npx prettier --check .",
"lint:md": "markdownlint-cli2 --config .markdownlint-cli2.jsonc \"**/*.md\" \"#docs/**\"",
"lint:md:all": "markdownlint-cli2 --config .markdownlint-cli2.jsonc \"**/*.md\"",
"format": "npx prettier --write . --ignore-path .gitignore",
"format:check": "npx prettier --check . --ignore-path .gitignore",
"clean": "node -e \"require('node:fs').rmSync('out', { recursive: true, force: true })\"",
"compile": "npm run clean && tsc -p ./",
"test": "npm run compile && node scripts/run-unit-tests.mjs",
Expand Down
31 changes: 31 additions & 0 deletions scripts/gitignore-patterns.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { readFileSync } from "node:fs";

/**
* Read `.gitignore` and return its patterns as an array suitable for tools
* that accept gitignore-style patterns (ESLint flat config `ignores`).
*
* This is the single source of truth for "which files are temporary /
* generated / excluded", so every linter and formatter that supports
* gitignore-style patterns should derive its ignores from here (or point
* straight at `.gitignore` itself) instead of maintaining a parallel,
* drifting ignore list:
*
* - ESLint: `ignores: readGitignorePatterns()` (this module).
* - Prettier: `--ignore-path .gitignore` (native gitignore parsing).
* - markdownlint-cli2: `gitignore: true` in `.markdownlint-cli2.jsonc`
* (native gitignore parsing, including nested `.gitignore` files).
*
* CONTRACT:
* - Blank lines and `#` comments are dropped.
* - `!` negations are dropped: ESLint's flat-config `ignores` handles them
* differently from git (relative vs. anchored semantics), and this
* repository's `.gitignore` does not use negations.
* - Lines are trimmed so accidental leading/trailing whitespace can't
* silently disable an ignore rule.
*/
export function readGitignorePatterns(file = ".gitignore") {
return readFileSync(new URL(`../${file}`, import.meta.url), "utf8")
.split(/\r?\n/)
.map((line) => line.trim())
.filter((line) => line && !line.startsWith("#") && !line.startsWith("!"));
}
Loading
Loading