DEV Community

Zyrn
Zyrn

Posted on AI-assisted

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

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!


Quick Install in VS Code

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
Enter fullscreen mode Exit fullscreen mode

What Ghost Trace Does

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.

  1. Multi-File Tracing (Including Closed Files): In v0.3.0, you don't even need files open in editor tabs. Pin or attach one or more files in Copilot Chat (using #file or the paperclip icon), ask @trace or #ghostTrace to investigate, and it analyzes all of them together.
  2. Structured, Per-File Breakdowns: Instead of dumping a wall of text, Ghost Trace organizes its response under clean per-file sections covering Overview, Status, Root-Cause Location, Cascade Explanation, and Fix Guidance.
  3. Guidance-First, Zero Auto-Edits: Ghost Trace is strictly read-only—it never edits or applies changes to your workspace files. It shows you where and why the error cascaded so you fix it yourself and actually retain the skill.
  4. Cross-File Clickable Line-Jump Links & Follow-Ups: Referenced line numbers render as interactive [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.

Under the Hood: Bun + VS Code Language Model Tools

Since I dislike heavy npm/yarn boilerplate for developer tools, I built the entire project with Bun:

  • 10ms Builds: bun build bundles the TypeScript extension straight to CommonJS (--target=node --format=cjs --external=vscode) in milliseconds.
  • Modern Copilot Architecture: Alongside the @trace chat participant, Ghost Trace registers a native Language Model Tool (#ghostTrace / ghost_trace_diagnose) via 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:

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');
Enter fullscreen mode Exit fullscreen mode

Try It Out & Share Feedback

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!

Top comments (0)