Skip to content

feat(vscode): Rewrite extension as LSP client#29

Merged
EffortlessSteven merged 5 commits intomainfrom
feat/vscode-lsp-client-rewrite
Apr 7, 2026
Merged

feat(vscode): Rewrite extension as LSP client#29
EffortlessSteven merged 5 commits intomainfrom
feat/vscode-lsp-client-rewrite

Conversation

@EffortlessSteven
Copy link
Copy Markdown
Member

Closes #28

What Changed

Rewrites the VS Code extension from a custom diagnostic implementation to a standard Language Server Protocol (LSP) client using v9 Executable API.

Extension Rewrite (extension.js)

  • Replaced custom logic with from
  • Extension now launches as a child process and communicates via LSP over stdio
  • Configurable server path via setting (default: )
  • Graceful error handling: user-friendly error message when the LSP binary is not found (ENOENT/not found/cannot find)
  • Server runs in with document selector for all files ()

Package & Manifest Updates (package.json)

  • Version bumped to 0.2.0
  • Added ^9.0.1 as dependency
  • Added as devDependency
  • Added configuration contribution: (string, default )
  • Updated activation events and command contributions
  • Repository URL updated to

New Files

  • and for extension debugging
  • to exclude node_modules and dev files from VSIX
  • with v0.2.0 release notes
  • (MIT)
  • 5 test suites with 52 assertions covering extension structure, activation, manifest, package.json, and edge cases

Why

The previous implementation used a custom diagnostic collection approach that was tightly coupled and limited. Moving to LSP provides:

  • Standard protocol compliance with the broader LSP ecosystem
  • Better separation of concerns (analysis engine vs editor integration)
  • Foundation for supporting additional editors (e.g., Neovim, Emacs)
  • Real-time diagnostics via the LSP server lifecycle

Test Results

All 5/5 test suites pass (52 assertions):

  • validate-extension-js: Extension structure and LSP client setup
  • validate-files: Required files present
  • validate-manifest: VSIX manifest correctness
  • validate-package-json: Package.json schema compliance
  • validate-edge-cases: Error handling and boundary conditions

Key Decisions

  1. v9 Executable API over older transport: Uses with / executables for robust process management
  2. **** setting: Allows users to specify custom binary location without code changes
  3. No language activation event: Extension activates on since DiffGuard analyzes all file types for PII/secrets
  4. Error message extraction: Clean variable for readability in error handler

- Rewrite extension.js to use vscode-languageclient LSP client (v9 Executable API)
- Update package.json: version 0.2.0, repository, commands, configuration settings
- Add LICENSE, .vscodeignore, CHANGELOG.md
- Add .vscode/launch.json and .vscode/tasks.json
- Update README.md with LSP configuration docs
- Install dependencies: vscode-languageclient ^9, @vscode/vsce

All 4/4 red test suites pass.
- Add 5 test suites (52 assertions) validating the LSP client rewrite
- Clean up extension.js: remove unused path import, extract error message variable
- Tests cover: extension activation, file structure, manifest, package.json, edge cases
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

Warning

Rate limit exceeded

@EffortlessSteven has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 39 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 39 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0203ab44-9c73-4327-996b-23d6294e8196

📥 Commits

Reviewing files that changed from the base of the PR and between b596c29 and 04b0064.

⛔ Files ignored due to path filters (1)
  • editors/vscode-diffguard/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (19)
  • docs/postmortems/work-ea424433-vscode-lsp-rewrite.md
  • editors/vscode-diffguard/.gitignore
  • editors/vscode-diffguard/.vscode/launch.json
  • editors/vscode-diffguard/.vscode/tasks.json
  • editors/vscode-diffguard/.vscodeignore
  • editors/vscode-diffguard/CHANGELOG.md
  • editors/vscode-diffguard/LICENSE
  • editors/vscode-diffguard/README.md
  • editors/vscode-diffguard/extension.js
  • editors/vscode-diffguard/package.json
  • tests/vscode-extension/helpers.js
  • tests/vscode-extension/package.json
  • tests/vscode-extension/run-all.js
  • tests/vscode-extension/validate-edge-cases.js
  • tests/vscode-extension/validate-extension-js.js
  • tests/vscode-extension/validate-files.js
  • tests/vscode-extension/validate-manifest.js
  • tests/vscode-extension/validate-package-json.js
  • wisdom.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/vscode-lsp-client-rewrite

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diffguard found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the DiffGuard VS Code extension to utilize the Language Server Protocol (LSP), providing real-time diagnostics and new configuration options. A major issue was noted regarding the accidental inclusion of the node_modules directory in the repository. Key feedback includes suggestions to exclude the entire node_modules folder in .vscodeignore to optimize package size, add support for unsaved files in the documentSelector, and use more reliable error code checking when verifying the presence of the language server binary.

.vscode/
.gitignore
*.vsix
node_modules/.cache/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The .vscodeignore file should exclude the entire node_modules/ directory rather than just the cache. Including node_modules in the extension package (VSIX) significantly increases its size and can lead to installation issues. If you are not using a bundler, vsce will automatically include only production dependencies if node_modules is ignored correctly.

node_modules/

@@ -0,0 +1 @@
../glob/dist/esm/bin.mjs No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

It appears that the node_modules directory has been committed to the repository. This is generally discouraged as it bloats the repository size and can cause platform-specific issues with binary dependencies. Dependencies should be managed via package.json and ignored by git. Please remove the node_modules directory from the repository and ensure it is added to your .gitignore file.

};

const clientOptions = {
documentSelector: [{ scheme: "file" }],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The documentSelector is currently restricted to the file scheme. Since DiffGuard is intended to analyze all file types for PII and secrets, it should also include the untitled scheme to provide diagnostics for new, unsaved files. This ensures that users get real-time feedback even before saving a file for the first time.

Suggested change
documentSelector: [{ scheme: "file" }],
documentSelector: [{ scheme: "file" }, { scheme: "untitled" }],


client.start().then(null, (err) => {
const errMsg = String(err);
if (errMsg.includes("ENOENT") || errMsg.includes("not found") || errMsg.includes("cannot find")) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Checking for a missing binary using string matching on the error message is brittle and may fail depending on the platform or system locale (e.g., localized error messages). It is more reliable to check the error code (e.g., err?.code === 'ENOENT') if the error object provides it.

Suggested change
if (errMsg.includes("ENOENT") || errMsg.includes("not found") || errMsg.includes("cannot find")) {
if (err?.code === "ENOENT" || errMsg.includes("ENOENT") || errMsg.includes("not found") || errMsg.includes("cannot find")) {

@chatgpt-codex-connector
Copy link
Copy Markdown

💡 Codex Review

"command": "diffguard.explainRule",
"title": "DiffGuard: Explain Rule"

P2 Badge Stop exposing explainRule without collecting its required arg

The manifest advertises diffguard.explainRule as a Command Palette command, but palette execution provides no arguments; in crates/diffguard-lsp/src/server.rs, handle_execute_command_request rejects this command when arg 0 is missing ("missing rule ID argument"). That means users can invoke a documented command that deterministically fails. Either register a local VS Code command handler that prompts for a rule ID before forwarding to LSP, or keep this command out of contributed commands and use it only from code actions where arguments are supplied.


"type": "number",
"default": 100,

P2 Badge Restrict maxFindings setting to integer values

diffguard.maxFindings is declared as number, so users can set decimals, but the server parses max_findings as Option<usize> and parse_init_options falls back to defaults when deserialization fails. A value like 10.5 therefore causes the whole initialization-options object to be dropped (including other options such as configPath), which is hard to diagnose. Use an integer schema type to prevent invalid values from reaching the server.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Full post-mortem covering gate-by-gate assessment, design quality analysis,
and 5 specific conveyor pipeline fixes needed. Updated wisdom.md with
concise learnings pointing to the detailed doc.
@EffortlessSteven EffortlessSteven merged commit 1b9f47e into main Apr 7, 2026
10 checks passed
@EffortlessSteven EffortlessSteven deleted the feat/vscode-lsp-client-rewrite branch April 7, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ship VS Code extension to marketplace

2 participants