@promptshield/lsp
v1.0.2
Published
Language Server for PromptShield
Downloads
339
Maintainers
Readme
@promptshield/lsp
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
The server is built on vscode-languageserver and orchestrates:
- Document Lifecycle: Tracks open files and changes via
TextDocuments. - Validation Loop:
- Debounces input (default 300ms).
- Calls
@promptshield/coreto scan text. - Filters false positives via
@promptshield/ignore. - Publishes
Diagnostic[]back to the client.
- Code Action Provider:
- Generates
WorkspaceEditobjects to surgically repair text.
- Generates
🔌 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.
