# VS Code

### [Marketplace](https://marketplace.visualstudio.com/items?itemName=Cosine.cosine-vscode)

### Overview

* The VS Code extension is a companion to the Cosine CLI. The CLI must be installed and available.
* The extension auto-discovers the CLI, streams “Cosine Changes” into VS Code, and provides inline actions to open files and diffs.

{% embed url="<https://youtu.be/944Cs5wvkoY>" %}

### What it does

* Shares lightweight editor context (active file and selection) so Genie can respond more precisely.
* Adds a “✦ Cosine Changes” tree in the Explorer to track files with live previews or SCM changes; click items to open diffs or previews.
* Launches a “Cosine” terminal and runs the CLI for you (configurable).
* Streams in code changes for quicker validation and diff viewing

### Requirements

* Cosine CLI installed and on PATH (`cos --version`)
* VS Code 1.105.0 or later

### Install

#### 1) Install the VS Code extension

* From VS Code: open Extensions (Ctrl/Cmd+Shift+X), search for “Cosine”, and install.
* Direct link: <https://marketplace.visualstudio.com/items?itemName=Cosine.cosine-vscode>

#### 2) Install the Cosine CLI

<https://cosine.sh/cli>

```bash
cos --version
```

### Quick start

1. Install the CLI and verify `cos --version`.
2. Install the VS Code extension.
3. Open a project in VS Code and reload the window.
4. The extension will start a “Cosine” terminal and run `cos` (if auto-start is enabled).
5. Use the “✦ Cosine Changes” view in the Explorer to preview live updates; open diffs when coding streams complete.

<figure><img src="https://2537874235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJjYsV6DXCvFPeCUEBwo5%2Fuploads%2F2oniyT5VG1HGLNoT7s4j%2FScreenshot%202025-10-20%20at%2017.20.11.jpg?alt=media&#x26;token=a494d07b-5fe7-4033-b446-4c9db3cbc1bc" alt=""><figcaption></figcaption></figure>

### How to use it

* Sign in: if the terminal shows “You are not logged in”, run `cos login` and complete auth in your browser.
* Start the CLI: it auto-starts by default; otherwise run “Cosine: Start CLI”. Use “Cosine: Focus CLI Terminal” to bring it to front.
* Provide context: open a file or select a block of code. The extension shares the active file/selection with Genie.
* Ask Genie: type your request in the CLI prompt (e.g., “refactor this function”, “add tests for X”, “fix lint errors”). Watch live previews stream in the “Cosine Changes” view.
* Review diffs: when a stream ends, a native diff opens (configurable via settings). Use inline actions to open Working, Live, or Diff for each item.
* Apply/commit: the CLI writes changes to your repo. Review them in Git and commit as usual. The extension is visual-only for previews/diffs.

<figure><img src="https://2537874235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJjYsV6DXCvFPeCUEBwo5%2Fuploads%2FbPWkbWQxvcrqr5adSOUs%2FScreenshot%202025-10-20%20at%2017.10.21.jpg?alt=media&#x26;token=33d99226-645f-4935-aa42-cda8aa7de16c" alt=""><figcaption></figcaption></figure>

### Troubleshooting

* CLI not found:
  * Check `cos --version`. If not found, install the CLI or add its install directory to your PATH.
  * In VS Code, set “Cosine: CLI Path” (e.g., `/usr/local/bin/cos`).
* Bridge not connected:
  * Check status bar. Run “Cosine: Start VS Code Bridge”.
  * Verify the CLI is running in the “Cosine” terminal.

### Uninstall

* Extension: uninstall from VS Code Extensions.
* CLI: remove the `cos` binary from its install location (e.g., `/usr/local/bin/cos` or your user bin dir).

### FAQ

* Do I need the CLI for the extension to work?
  * Yes. The extension is a companion to the CLI and depends on it.
* How do I update the CLI?
  * Re-run the install script or install a newer release. Then verify with `cos --version`.
* Where do I see changes?
  * Use the “✦ Cosine Changes” view to preview and open diffs as Genie streams updates.
