# I Built a VS Code Copilot Extension with Bun That Refuses to Write Code For Me

> Source: <https://dev.to/zyrndotio/i-built-a-vs-code-copilot-extension-with-bun-that-refuses-to-write-code-for-me-16o5>
> Published: 2026-12-01 23:09:29+00:00

**Key takeaway:** Ghost Trace registers a vscode.lm tool that passes numbered file lines plus live diagnostics to Copilot, letting the model map cascading errors to their root-cause line instead of auto-fixing code.

Every developer knows this exact headache: your compiler throws a red squiggle on **Line 38**, you jump down to Line 38, and... it’s completely blank. Or it’s a single closing `}` that looks totally fine.

Nine times out of ten, the real culprit is a missing brace, an unclosed parenthesis, or a forgotten `</div>` 25 lines higher up that cascaded all the way down the file.

I wanted a fast way to hunt down these "phantom" errors inside VS Code without scrolling up and down counting brackets—**but I didn't want another AI tool that silently rewrites my code for me.**

Lately, I've been focusing on sharpening my web development fundamentals (`TypeScript`, `JavaScript`, `HTML`, `CSS`, `Java`). When you're actively building and retaining your coding skills, letting an AI auto-fix every syntax slip robs you of the debugging intuition you actually need.

So I built **Ghost Trace** (`#ghostTrace` / `@trace`)—and **v0.3.0** is now live on the Visual Studio Code Marketplace!

Search **`ghost-trace`** (` Zyrndotio`) directly in your VS Code Extensions sidebar, or press `Ctrl + P` (`Cmd + P` on macOS) and run:

```
ext install Zyrndotio.ghost-trace
```

**Ghost Trace** hooks into GitHub Copilot Chat to trace cascading syntax and structural bugs back to their true origin—across any language supported by VS Code diagnostics.

`#file` or the paperclip icon), ask `@trace` or `#ghostTrace` to investigate, and it analyzes all of them together.`[Line X]` links. Clicking one opens that file (even if it was closed), jumps your cursor straight to the root-cause line, and briefly highlights it—followed by one-click learning prompts about error cascades and prevention.
Since I dislike heavy `npm`/` yarn` boilerplate for developer tools, I built the entire project with **Bun**:

`bun build` bundles the TypeScript extension straight to CommonJS (`--target=node --format=cjs --external=vscode`) in milliseconds.` ghost_trace_diagnose`)` vscode.lm.registerTool` so VS Code's Copilot Agent harness can invoke it directly—supporting optional `filePaths` (workspace-relative or absolute) and `targetLine` inputs.
Here is a look at how Ghost Trace captures numbered file contents alongside live diagnostics before handing context to the model:

``` js
const diagnostics = vscode.languages.getDiagnostics(doc.uri);
const errorList = diagnostics.length > 0
  ? diagnostics.map(d => `- Line ${d.range.start.line + 1}: [${d.source || 'Compiler'}] ${d.message}`).join('\n')
  : 'No active compiler errors detected in this file.';

const numberedCode = doc.getText()
  .split('\n')
  .map((lineText, idx) => `${idx + 1}: ${lineText}`)
  .join('\n');
```

Ghost Trace is open source under the **MIT License**, and I'm planning to keep expanding it with editor gutter markers and targeted structural checks in future releases.

If you've ever wasted ten minutes hunting down a missing `}` or `</div>` on a blank line, install it, give it a spin, and let me know in the comments what features or languages I should tackle next!
