PromptShield logo PromptShield
PromptShield LSP

Overview

PromptShield Banner

CIcodecovnpm versionnpm downloadsnpm bundle sizelicense

The Brain of PromptShield. A fully compliant Language Server Protocol (LSP) implementation that provides threat detection, diagnostics, and remediation for any editor.

✨ Features

  • Universal Compatibility: Works with VS Code, Neovim, Sublime Text, IntelliJ, and more.
  • Real-Time Analysis: Debounced scanning of documents as you type.
  • Code Actions:
    • Quick Fix: Remove invisible characters or fix BIDI overrides.
    • Fix All: Apply all safe fixes in the document.
  • Diagnostics: Publishes standard LSP diagnostics for detected threats.
  • Hover Support: detailed explanation of threats when hovering over underlined text.
  • Workspace Scanning: Capability to scan entire project trees.

📦 Installation

$ pnpm add @promptshield/lsp

🏗️ internal Architecture

View internal architecture and integration details

The server is built on vscode-languageserver and orchestrates:

  1. Document Lifecycle: Tracks open files and changes via TextDocuments.
  2. Validation Loop:
    • Debounces input (default 300ms).
    • Calls @promptshield/core to scan text.
    • Filters false positives via @promptshield/ignore.
    • Publishes Diagnostic[] back to the client.
  3. Code Action Provider:
    • Generates WorkspaceEdit objects to surgically repair text.

🔌 Integration

To use this with a custom LSP client:

import { startLspServer } from "@promptshield/lsp";

// Start scanning on stdio (default)
startLspServer();

Or connect via IPC/Socket depending on your host environment.

📚 Deep Dives: To understand exactly how "Fix with AI" or full Workspace Scanning operates inside the LSP Server, see the Documentation section.

License

This library is licensed under the MIT open-source license.


with 💖 by Mayank Kumar Chaudhari

On this page