Skip to content

Create VS Code extension #20

@janole

Description

@janole

Notes: Adding a VS Code Extension to Code Bandit

1. Approaches to Adding a VS Code Extension

a. Separate Extension Package

  • Recommended: Create a distinct VS Code extension project (e.g., in a vscode/ or packages/vscode-extension/ folder).
  • The extension acts as a client, calling Code Bandit’s core logic—either by invoking the CLI or, preferably, by reusing shared logic moved into a library.
  • The extension will have its own package.json (with VS Code-specific fields) and configuration.
  • Benefits: Clear separation, easier maintenance and publishing, avoids entangling VS Code-specific dependencies with the CLI.

b. Code Reuse

  • Refactor the core logic (AI interactions, file system routines, etc.) into a reusable package (e.g., core).
  • Both the CLI and VS Code extension import this core package to avoid code duplication.

2. Monorepo Migration

a. Advantages

  • Using a monorepo (via pnpm workspaces, Turborepo, Yarn workspaces, etc.) is advantageous when multiple packages exist:
    • CLI app (current)
    • VS Code extension
    • Shared logic packages (core)
    • Other future interfaces
  • Simplifies dependencies, versioning, and cross-project refactoring.
  • Makes testing and isolating packages easier.

b. Overhead

  • Slightly more setup and tooling, but well-supported for TypeScript/Node projects.
  • Provides clear structure as the project and its interfaces grow.

3. Direct Integration Into Current package.json

a. Problems

  • Mixing CLI and VS Code extension in the root package.json can cause:
    • Package bloat (unnecessary dependencies for each environment)
    • Conflicting fields (VS Code requires its own manifest fields)
    • Maintenance headaches as the project evolves

b. When It's Okay

  • Acceptable for rapid prototyping, but not advised for serious development or publishing.
  • Long-term, each interface (CLI, extension) should have its own manifest and configuration.

Recommendation

  • Adopt a monorepo (packages/cli/, packages/core/, packages/vscode-extension/) when developing a VS Code extension.
  • Move reusable parts to a core package for sharing between CLI and editor extension.
  • Keep package manifests separate (do not combine CLI and VS Code fields in one package.json).

Let me know if you need example directory scaffolding or extension manifests!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions