# VS Code (/docs/apps/vscode)

The Kodwen extension for VS Code mirrors your GitHub Copilot Chat sessions to your watch, phone and desktop, so you can approve tools and answer questions from anywhere. Plus @codai in chat.

The **Kodwen** extension (`dragoscv.codai-vscode`) shares the GitHub Copilot Chat sessions you work in with your Kodwen account. They show up on your [Wear OS watch](./wear.mdx), in the [Android app](./android.mdx) and in the [desktop app](./desktop.mdx) like any other [shared session](../sessions/index.mdx). When Copilot's agent waits for you — _"Allow `run_in_terminal`?"_ or a question with options — the ask reaches every device, and your answer is applied in VS Code.

Works on VS Code 1.95+ (stable and Insiders), Windows, macOS and Linux. Cursor, Windsurf, VSCodium and Trae run part of it — see [Compatibility](#compatibility). The extension follows VS Code's display language (English or Romanian).

## Install [#install]

- **Marketplace**: search for **Kodwen** (extension id `dragoscv.codai-vscode`) in the Extensions view, or run `code --install-extension dragoscv.codai-vscode` (`code-insiders` for Insiders).
- **VSIX**: download the newest package from the [Marketplace download link](https://marketplace.visualstudio.com/_apis/public/gallery/publishers/dragoscv/vsextensions/codai-vscode/latest/vspackage) and use **Extensions → … → Install from VSIX**.
- **Open VSX**: not published yet. The release pipeline is ready and publishes the same package under the same id as soon as the Open VSX namespace is set up. Until then, use the VSIX in editors that read Open VSX.

### Other editors (Cursor, Windsurf, VSCodium, Trae) [#other-editors-cursor-windsurf-vscodium-trae]

These editors install extensions from Open VSX, so Kodwen does not show up in their search yet. Install it by hand:

1. Download the `.vsix` with the Marketplace download link above. Save it with the `.vsix` extension.
2. In the editor, open the Command Palette and run **Extensions: Install from VSIX…**, then pick the file. From a terminal: `cursor --install-extension codai-vscode.vsix`, `windsurf --install-extension codai-vscode.vsix` or `codium --install-extension codai-vscode.vsix`.
3. Run **Kodwen: Sign in**.

What changes outside VS Code:

- The editor must be based on VS Code 1.95 or newer; older builds refuse the package.
- The extension mirrors **GitHub Copilot Chat** sessions. Editors without Copilot Chat have nothing to mirror from there. In Cursor, the extension can show Cursor's own chats on your devices, read-only: you can follow them but not answer from another device.
- **Continue with GitHub** needs the editor's built-in GitHub sign-in. If it fails, use **Sign in in the browser** or an API key.
- Updates do not arrive on their own: install the new `.vsix` the same way.

## Sign in [#sign-in]

Run **Kodwen: Sign in** from the Command Palette and pick **Continue with GitHub**, **Sign in in the browser** or **Use an API key…**. With the browser option, `auth.codai.ro/device` opens with the code already filled in (it is also copied to the clipboard); approve it. VS Code never sees your password — it receives its own `codai_` key, kept in VS Code's secret storage and listed as a device in [hub.kodwen.com](https://hub.kodwen.com) → **Security → Devices**.

**Continue with GitHub** (also **Kodwen: Sign in with GitHub**) uses the GitHub account VS Code is already signed in to: no browser round trip, and it lands on the same Kodwen account as signing in with GitHub on the web. A brand-new account still goes through the browser once, to accept the Terms.

**Use an API key…** accepts a key you created yourself. Problems signing in: see [troubleshooting](../troubleshooting.mdx#vs-code).

## Use Kodwen models in Copilot Chat [#use-kodwen-models-in-copilot-chat]

**Kodwen: Add Kodwen models to Copilot Chat** puts `kodwen` in the Copilot Chat model picker. It downloads the Kodwen provider entry from `https://ai.codai.ro/vscode/chatLanguageModels.json` and adds it to your user `chatLanguageModels.json` (or updates it if it is already there), keeping every other provider. Before the first change the existing file is copied to `chatLanguageModels.json.bak-codai`.

Your key is never written to that file: the first time you pick a Kodwen model, VS Code asks for your Kodwen key once and keeps it in the OS keychain. After a sign-in in VS Code or Insiders the extension offers this command once; you can run it any time from the Command Palette.

## What your devices see [#what-your-devices-see]

| In Copilot Chat                       | On the watch / phone / desktop                       |
| ------------------------------------- | ---------------------------------------------------- |
| The chat title (or your first prompt) | The session title                                    |
| Each prompt you send                  | A user line                                          |
| Each finished tool call               | A tool line (tool name and its one-line description) |
| A tool waiting for confirmation       | An ask: **Allow** / **Deny**                         |
| A question carousel                   | An ask with the offered options, or a free answer    |
| The final answer of a request         | The assistant line                                   |
| A failed or cancelled request         | An error line                                        |

The status bar shows **Kodwen N** (sessions shared) and a bell with a count when something waits for you. Click it for the list, **Sync now**, the log and **Sign out**.

## Answering from another device [#answering-from-another-device]

- **Allow / Deny** on a tool ask confirms or skips the tool in that chat. VS Code applies a confirmation only to a chat that is open in a window, so with `codai.remote.revealSessions` (on by default) the extension opens the chat for you first.
- **Answer** a question with one of the options, its number, or free text (dictated on the watch). Every question of a carousel is shared and gets its own answer; `(skip)` leaves one for Copilot to treat as skipped.
- **Send** a new prompt to the session and it is submitted in that chat.
- **Stop** cancels the running request.

Answers reach VS Code within a few seconds (`codai.sessions.pollSeconds`).

<Callout type="warn">
  **New asks can take a minute or two to reach your watch.** VS Code writes chat sessions to disk on
  its own schedule, and the extension reads them from there. Answers in the other direction are
  fast.
</Callout>

## Pending prompts [#pending-prompts]

The **Pending prompts** view in the activity bar lists the [prompts saved for later](/docs/api/gateway/prompts) on any of your devices, and updates live when one changes elsewhere.

- **Open in chat**, **Copy**, **Snooze**, **Mark done**, **Dismiss**, **Delete**, and **Save selection as pending prompt** for new ones.
- **Detected automatically.** Paste a pending prompt into Copilot Chat in any VS Code window and it is marked **sent**, then **answered** when the response finishes. Nothing to click.
- **Verify prompt** / **Verify all prompts** ask Kodwen whether the chat really did the job, using the chat and the repository diff since the prompt was sent. You get a short report (what changed, what is still missing); a complete job is marked **verified**.

## @codai in chat [#codai-in-chat]

Type `@codai` in Copilot Chat to talk to the `kodwen` model directly (streamed, billed to your Kodwen account).

- `@codai /sessions` — your shared sessions on every device, with what waits for you.
- `@codai /asks` — only the open questions and approvals.

## Web search and deep research in agent mode [#web-search-and-deep-research-in-agent-mode]

From version 0.7.0 the extension adds three tools to Copilot agent mode, available to **every** model (including custom endpoints and BYOK models that have no built-in web search):

- `codai_web_search` (`#codaiWebSearch`) — verified web search: each result was fetched by Kodwen and its snippet found on the page, cited as `[S1]`..`[Sn]`. The agent can restrict sites (`include_domains` / `exclude_domains`), ask for recent pages (`freshness` `day`/`week`/`month`/`year`, `published_after` / `published_before`), go `deep` for hard questions or get a longer verified excerpt per result (`content_chars`). Language and market are inferred from the query unless the agent sets `lang` / `country`.
- `codai_web_fetch` (`#codaiWebFetch`) — reads a public URL: a page comes back as clean markdown (up to 40,000 characters, 8,000 by default; `focus` returns only the relevant paragraphs), and any other file — image, archive, binary, executable — is described instead of decoded, with `requires_consent` before anything runs it. The content is marked as untrusted.
- `codai_deep_research` (`#codaiDeepResearch`) — plans several searches, reads the best pages and returns a report where every claim cites its source. If the report is not ready within the wait window, the tool returns a job id and the agent calls it again with `job_id`.

They are the same tools, with the same schemas and output, as on desktop, phone, the headless CLI and the hosted MCP ([one contract](/docs/agents/tools#web-tools-one-contract-everywhere)). They use your Kodwen key (sign in first) and the API endpoints [`POST /v1/tools/search`](/docs/agents/tools), `POST /v1/tools/fetch` and [`POST /v1/research`](/docs/api/gateway/research). A refusal by one of your rules, a bad argument or a rate limit is shown to the model as an `ERROR` line and never silently retried. Searches and fetches are metered ([pricing](/docs/agents/tools#pricing)): the first 1,000 calls a month are free, and calls are free when `kodwen` is the chat model. Enable or disable them in the chat **Tools** picker, or reference them in a prompt with `#`.

## Sessions from other devices (Insiders) [#sessions-from-other-devices-insiders]

VS Code Insiders lists the sessions that run on your _other_ Kodwen devices in its own Sessions view. Opening one shows its history; a prompt typed there is sent to the device running it. This is on by default — turn it off with `codai.sessions.cloudProvider`. It uses a proposed VS Code API, so start Insiders with `--enable-proposed-api dragoscv.codai-vscode` (or add `"enable-proposed-api": ["dragoscv.codai-vscode"]` to `argv.json` via **Preferences: Configure Runtime Arguments**). Where that API is unavailable the extension registers nothing and says so in the Kodwen output channel.

## Open a cloud environment (Remote-SSH) [#open-a-cloud-environment-remote-ssh]

**Kodwen: Open the Workspace on a Cloud Environment** connects a new window to a Kodwen cloud environment: pick a target from the repo's `.codai/environments.json`, let `codaid env ssh-config <env> --install` mint a 12-hour certificate and write the `Host codai-<env>` block into `~/.ssh/config` (port 22 is tunnelled over the relay, so the machine needs no public IP), then pick the remote check-out to open.

`codaid` must be on `PATH`; point `codai.environments.codaidPath` at the executable if it is not. When `codaid` or `ssh` is missing the command hands you the exact line to run and still opens the window if the host block is already installed. Creating environments, `ssh <alias>` and opening ports are covered in `docs/runbooks/remote-dev-and-cloud-e2e.md` in the repository.

## Compatibility [#compatibility]

The extension needs VS Code 1.95 or newer. Some features use APIs that only VS Code itself provides; in other editors (and in VS Code versions without those APIs) the extension shows a one-time notice listing what is unavailable, and everything else keeps working.

| Editor                     | Install from                                                                                         | Works                                             | Does not work                                            |
| -------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------- | -------------------------------------------------------- |
| VS Code / VS Code Insiders | Visual Studio Marketplace                                                                            | Everything                                        | —                                                        |
| Cursor                     | Open VSX (`dragoscv.codai-vscode`) once published there; until then the VSIX from the GitHub release | Pending prompts, Transcripts, sign-in, status bar | Copilot session mirroring, `@codai` in chat, agent tools |
| Windsurf                   | Same as Cursor                                                                                       | Pending prompts, Transcripts, sign-in, status bar | Copilot session mirroring, `@codai` in chat, agent tools |
| VSCodium                   | Same as Cursor                                                                                       | Pending prompts, Transcripts, sign-in, status bar | Copilot session mirroring, `@codai` in chat, agent tools |
| Trae                       | Same as Cursor                                                                                       | Pending prompts, Transcripts, sign-in, status bar | Copilot session mirroring, `@codai` in chat, agent tools |

Why:

- **Copilot session mirroring** reads the chat files that GitHub Copilot Chat stores inside VS Code, so it works only in VS Code Stable and Insiders.
- **`@codai` in chat** needs the chat participant API (`vscode.chat.createChatParticipant`).
- **Agent tools** (`#codaiWebSearch`, the Studio tools, …) need `vscode.lm.registerTool`.

A fork that does provide the chat or tool APIs gets those features; the notice lists only what is actually missing. **Kodwen: Add Kodwen models to Copilot Chat** is offered only in VS Code and Insiders.

## Settings [#settings]

| Setting                                   | Default                                         | Meaning                                                                                                                                                    |
| ----------------------------------------- | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `codai.sessions.mirror`                   | `true`                                          | Share this window's Copilot Chat sessions. Set it per workspace to keep one project private.                                                               |
| `codai.sessions.activeMinutes`            | `120`                                           | Only sessions changed in the last N minutes are shared.                                                                                                    |
| `codai.sessions.mirrorAllWorkspaces`      | `true`                                          | One VS Code window per machine also shares the chats of every other workspace.                                                                             |
| `codai.sessions.terminalAgents`           | `true`                                          | Also share Copilot CLI, Claude Code and Codex CLI sessions started in a terminal, and Cursor chats, read-only. Needs `codai.sessions.mirrorAllWorkspaces`. |
| `codai.sessions.maxSessions`              | `40`                                            | Maximum sessions shared per source per poll.                                                                                                               |
| `codai.sessions.stubLimit`                | `200`                                           | Older chats are listed on your phone and in the hub by title only, up to this many; opening one loads it. `0` = only active chats.                         |
| `codai.sessions.askTimeoutMinutes`        | `0`                                             | Answer a question still open after N minutes with its recommended option. `0` = wait for you.                                                              |
| `codai.sessions.backfillRequests`         | `3`                                             | Past requests shown when a session is first shared.                                                                                                        |
| `codai.sessions.pollSeconds`              | `5`                                             | How often the extension checks for changes and remote answers.                                                                                             |
| `codai.remote.revealSessions`             | `true`                                          | Open the chat when an approval arrives from another device.                                                                                                |
| `codai.sessions.cloudProvider`            | `true`                                          | Sessions from other devices in the Sessions view (Insiders + proposed API).                                                                                |
| `codai.environments.codaidPath`           | `codaid`                                        | Path to the `codaid` executable used by **Open the Workspace on a Cloud Environment**.                                                                     |
| `codai.experimental.chatSessionsProvider` | `true`                                          | Deprecated alias of `codai.sessions.cloudProvider`, kept so an existing opt-out keeps working.                                                             |
| `codai.prompts.autoCapture`               | `true`                                          | Save handoff prompts (a `text` block in an answer that mentions a new chat) to Pending prompts.                                                            |
| `codai.prompts.autoDetect`                | `true`                                          | Mark a pending prompt **sent** / **answered** when you use it in Copilot Chat.                                                                             |
| `codai.prompts.scanAllWorkspaces`         | `true`                                          | Look in the chats of every VS Code window on this machine, not only this one.                                                                              |
| `codai.gatewayUrl` / `codai.authUrl`      | `https://ai.codai.ro` / `https://auth.codai.ro` | Only change these for a self-hosted Kodwen.                                                                                                                |
| `codai.telemetry`                         | `false`                                         | Send crash reports (opt-in; only while VS Code telemetry is also on).                                                                                      |
| `codai.osGate.enabled`                    | `true`                                          | Check this computer's minimum security protections and warn in the status bar when they are off. Runs locally; nothing is sent.                            |

## Privacy [#privacy]

The extension only **reads** the chat session files VS Code already keeps (`workspaceStorage/<id>/chatSessions/`, and for Copilot CLI chats in newer Insiders builds `globalStorage/agent-host.db` plus `~/.copilot/session-state/<id>/events.jsonl`, read from a private copy); it never modifies them. It sends to `ai.codai.ro`: the session title, your prompts without attached context, tool names and their one-line descriptions, the final answer text, and asks. It does **not** send file contents, attachments, tool results or edits. Each VS Code session maps to one Kodwen session keyed `vscode:<machine>:<session id>`; delete it from the hub or any app like any other session. See the [privacy policy](https://kodwen.com/privacy).

Titles and assistant text that arrive from your other devices are escaped before VS Code shows them, so they cannot inject links or commands, and remote images in mirrored answers are removed. Crash reports are opt-in (`codai.telemetry`); see [crash reports](https://kodwen.com/en/privacy#crash-reports).

## Troubleshooting [#troubleshooting]

| Symptom                                           | Fix                                                                                                                                                                                |
| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Status bar shows **Kodwen** with a slashed circle | Not signed in — click it.                                                                                                                                                          |
| A session does not appear on the watch            | It must have changed within `codai.sessions.activeMinutes`, and VS Code must have saved it (send one more message, or wait a minute). **Kodwen: Sync sessions now** forces a read. |
| An approval from the watch did nothing            | The chat was closed and `codai.remote.revealSessions` is off — open the chat, or turn the setting on.                                                                              |
| Another device runs the same session              | Only one device executes a session (the lease). The extension retries every minute; see the log (**Kodwen: Shared sessions… → Show log**).                                         |

<Cards>
  <Card
    title="Wear OS"
    href="./wear.mdx"
    description="Follow and answer sessions from the watch."
  />
  <Card
    title="Shared sessions"
    href="../sessions/index.mdx"
    description="The protocol every Kodwen client speaks."
  />
</Cards>
