@ghostbuster/lsp
v1.0.8
Published
Language Server for PromptShield
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
[!TIP] This package (@ghostbuster/lsp) is an official alias of @promptshield/lsp.
We provide this package to offer shorter import paths and improved discoverability. While both packages provide identical functionality, @promptshield/lsp is the primary source of truth.
- Use @ghostbuster/lsp if you prefer the shorter name or specific branding or ESM Only.
- Use @promptshield/lsp for the most stable long-term reference and standard alignment.
| Feature | @promptshield/lsp | @ghostbuster/lsp | | --- | --- | --- | | Source Code | ✅ Primary | 🔗 Proxy | | Updates | Immediate | Synchronized (Immediately) | | Bundle Size | 100% | 100% (Zero overhead) | | Format | ESM + CJS | ESM Only | | Maintenance | ✅ Primary | 🔗 Proxy (inherits) | | Security | ✅ Primary | 🔗 Proxy (inherits) |
Security: Security audits are performed on the canonical package; this alias inherits all security patches automatically.
$ 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.
