@wrongstack/plug-lsp 0.265.1 → 0.267.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +223 -27
- package/dist/index.js +828 -500
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,23 +1,136 @@
|
|
|
1
1
|
# @wrongstack/plug-lsp
|
|
2
2
|
|
|
3
|
-
Language Server Protocol
|
|
3
|
+
Language Server Protocol (LSP) integration for WrongStack. Provides a unified
|
|
4
|
+
`/lsp` command to install, run, and manage LSP servers, plus 4 LSP-backed tools
|
|
5
|
+
for the agent (diagnostics, definition, rename, codebase search).
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
### 1. Enable the plugin
|
|
10
|
+
|
|
11
|
+
Add to your WrongStack config (`~/.config/wrongstack/config.json` or project `.wrongstack/config.json`):
|
|
7
12
|
|
|
8
13
|
```json
|
|
9
14
|
{
|
|
10
15
|
"features": { "plugins": true },
|
|
11
|
-
"plugins": ["@wrongstack/plug-lsp"]
|
|
16
|
+
"plugins": ["@wrongstack/plug-lsp"]
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 2. Install a language server
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
/lsp install typescript
|
|
24
|
+
/lsp install python
|
|
25
|
+
/lsp install go
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 3. Add to config and start
|
|
29
|
+
|
|
30
|
+
After installation, add the server to your config:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
12
34
|
"extensions": {
|
|
13
35
|
"@wrongstack/plug-lsp": {
|
|
14
|
-
"autoStart": "lazy",
|
|
15
36
|
"servers": {
|
|
16
37
|
"typescript": {
|
|
17
38
|
"command": "typescript-language-server",
|
|
18
39
|
"args": ["--stdio"],
|
|
19
40
|
"languages": ["typescript", "typescriptreact", "javascript", "javascriptreact"],
|
|
20
|
-
"rootPatterns": ["tsconfig.json"
|
|
41
|
+
"rootPatterns": ["tsconfig.json"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Then restart your WrongStack session and run:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
/lsp start typescript
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## `/lsp` Command
|
|
56
|
+
|
|
57
|
+
The primary interface for all LSP operations:
|
|
58
|
+
|
|
59
|
+
| Command | Description |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `/lsp` | List all configured servers and their states |
|
|
62
|
+
| `/lsp list` | Same as `/lsp` |
|
|
63
|
+
| `/lsp status` | Detailed status with failed server errors and active file count |
|
|
64
|
+
| `/lsp install <lang>` | Install the LSP server for a language |
|
|
65
|
+
| `/lsp start [name]` | Start all servers, or a specific one |
|
|
66
|
+
| `/lsp stop [name]` | Stop all servers, or a specific one |
|
|
67
|
+
| `/lsp restart [name]` | Restart all servers, or a specific one |
|
|
68
|
+
| `/lsp diagnostics [file]` | Show diagnostics for a file or workspace |
|
|
69
|
+
| `/lsp help` | Show full help |
|
|
70
|
+
|
|
71
|
+
### Available Languages for `/lsp install`
|
|
72
|
+
|
|
73
|
+
| Language | Server | Install Method |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| `typescript` | `typescript-language-server` | npm |
|
|
76
|
+
| `python` | `pyright-langserver` | npm |
|
|
77
|
+
| `json` | `vscode-json-language-server` | npm |
|
|
78
|
+
| `html` | `vscode-html-language-server` | npm |
|
|
79
|
+
| `css` | `vscode-css-language-server` | npm |
|
|
80
|
+
| `yaml` | `yaml-language-server` | npm |
|
|
81
|
+
| `shell` | `bash-language-server` | npm |
|
|
82
|
+
| `go` | `gopls` | Go toolchain |
|
|
83
|
+
| `rust` | `rust-analyzer` | Rust toolchain |
|
|
84
|
+
| `ruby` | `ruby-lsp` | RubyGems |
|
|
85
|
+
|
|
86
|
+
## Registered Tools
|
|
87
|
+
|
|
88
|
+
The plugin registers 4 tools into WrongStack's tool system. These are kept because
|
|
89
|
+
LSP provides genuinely unique data or capability the agent cannot replicate with
|
|
90
|
+
basic tools (read, grep, edit) at comparable cost.
|
|
91
|
+
|
|
92
|
+
| Tool | Permission | Description |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| `lsp_diagnostics` | `auto` | Get type/lint diagnostics for a file or whole workspace |
|
|
95
|
+
| `lsp_definition` | `auto` | Jump to the definition of a symbol (more precise than grep) |
|
|
96
|
+
| `lsp_rename` | `confirm` | Safe semantic rename across the workspace |
|
|
97
|
+
| `codebase-lsp-search` | `auto` | Fast symbol search via WrongStack's index, with LSP fallback |
|
|
98
|
+
|
|
99
|
+
The following LSP tools are intentionally excluded: `lsp_references` (returns
|
|
100
|
+
positions the agent still has to read), `lsp_hover` (usually confirms what
|
|
101
|
+
reading the definition already showed), `lsp_symbols` (a symbol tree is less
|
|
102
|
+
useful than reading the file), and `lsp_code_actions` (high noise-to-signal in
|
|
103
|
+
well-maintained codebases).
|
|
104
|
+
|
|
105
|
+
**Positions use 1-based line numbers and 1-based UTF-8 byte columns** — matching
|
|
106
|
+
WrongStack's grep tool convention, not LSP's 0-based UTF-16 code units.
|
|
107
|
+
|
|
108
|
+
## Configuration Reference
|
|
109
|
+
|
|
110
|
+
Full configuration options under `extensions["@wrongstack/plug-lsp"]`:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"extensions": {
|
|
115
|
+
"@wrongstack/plug-lsp": {
|
|
116
|
+
"autoStart": "lazy",
|
|
117
|
+
"diagnosticsAfterEdit": "background",
|
|
118
|
+
"diagnosticsWaitMs": 1500,
|
|
119
|
+
"severityFilter": ["error", "warning"],
|
|
120
|
+
"maxDiagnosticsPerFile": 5,
|
|
121
|
+
"maxDiagnosticsTotal": 50,
|
|
122
|
+
"autoDiscover": true,
|
|
123
|
+
"logServerOutput": false,
|
|
124
|
+
"servers": {
|
|
125
|
+
"typescript": {
|
|
126
|
+
"command": "typescript-language-server",
|
|
127
|
+
"args": ["--stdio"],
|
|
128
|
+
"languages": ["typescript", "typescriptreact"],
|
|
129
|
+
"rootPatterns": ["tsconfig.json"],
|
|
130
|
+
"initializationOptions": {},
|
|
131
|
+
"settings": {},
|
|
132
|
+
"startupTimeoutMs": 15000,
|
|
133
|
+
"enabled": true
|
|
21
134
|
}
|
|
22
135
|
}
|
|
23
136
|
}
|
|
@@ -25,36 +138,119 @@ configuration from `extensions["@wrongstack/plug-lsp"]`.
|
|
|
25
138
|
}
|
|
26
139
|
```
|
|
27
140
|
|
|
28
|
-
|
|
141
|
+
### Options
|
|
142
|
+
|
|
143
|
+
| Option | Default | Description |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| `autoStart` | `"lazy"` | `"lazy"` = start on first file access; `"eager"` = all at session start; `"never"` = manual only |
|
|
146
|
+
| `diagnosticsAfterEdit` | `"background"` | `"background"` = fetch after edits; `"manual"` = on request only |
|
|
147
|
+
| `diagnosticsWaitMs` | `1500` | Milliseconds to wait after an edit before fetching diagnostics |
|
|
148
|
+
| `severityFilter` | `["error","warning"]` | Which diagnostic severities to return |
|
|
149
|
+
| `maxDiagnosticsPerFile` | `5` | Maximum diagnostics per file |
|
|
150
|
+
| `maxDiagnosticsTotal` | `50` | Maximum diagnostics total |
|
|
151
|
+
| `autoDiscover` | `true` | Auto-discover servers on PATH or `node_modules/.bin` |
|
|
152
|
+
| `logServerOutput` | `false` | Log server stderr to WrongStack log |
|
|
153
|
+
|
|
154
|
+
## Auto-Discovery
|
|
155
|
+
|
|
156
|
+
With `autoDiscover: true` (the default), the plugin searches for servers in:
|
|
157
|
+
|
|
158
|
+
1. **`PATH`** — any command on the system PATH is used
|
|
159
|
+
2. **`node_modules/.bin`** — npm-installed binaries in the project
|
|
160
|
+
|
|
161
|
+
This means a minimal config is often sufficient:
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"features": { "plugins": true },
|
|
166
|
+
"plugins": ["@wrongstack/plug-lsp"]
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
If `typescript-language-server` is in your project's `node_modules/.bin`, it is
|
|
171
|
+
automatically discovered and started on first file access.
|
|
172
|
+
|
|
173
|
+
## Server Lifecycle
|
|
29
174
|
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
- `lsp_references`
|
|
33
|
-
- `lsp_hover`
|
|
34
|
-
- `lsp_symbols`
|
|
35
|
-
- `lsp_rename`
|
|
36
|
-
- `lsp_code_actions`
|
|
175
|
+
Each server runs as a separate child process communicating via JSON-RPC over stdio.
|
|
176
|
+
The plugin handles:
|
|
37
177
|
|
|
38
|
-
|
|
39
|
-
|
|
178
|
+
- **Initialization handshake** — sends `initialize` → waits for `InitializeResult` → sends `initialized`
|
|
179
|
+
- **Document tracking** — sends `textDocument/didOpen` on first read, `textDocument/didChange` after edits
|
|
180
|
+
- **Crash recovery** — 3 restart attempts with exponential backoff (1s, 4s, 16s)
|
|
181
|
+
- **Graceful shutdown** — sends `shutdown` then `exit` on session end
|
|
40
182
|
|
|
41
|
-
|
|
183
|
+
States: `disabled` → `starting` → `initializing` → `ready` → `shutting_down` → `exited`
|
|
42
184
|
|
|
43
|
-
|
|
44
|
-
|
|
185
|
+
## Custom Server Configuration
|
|
186
|
+
|
|
187
|
+
For languages not in the preset list, add manually to your config:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
"servers": {
|
|
191
|
+
"myserver": {
|
|
192
|
+
"command": "my-language-server",
|
|
193
|
+
"args": ["--stdio"],
|
|
194
|
+
"languages": ["mylang"],
|
|
195
|
+
"rootPatterns": ["mylang.config"],
|
|
196
|
+
"startupTimeoutMs": 20000
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## CLI Setup Command
|
|
202
|
+
|
|
203
|
+
For CI/CD or scripted installation, use the setup CLI directly:
|
|
45
204
|
|
|
46
205
|
```sh
|
|
47
|
-
|
|
206
|
+
# Install all preset servers (npm-based only)
|
|
48
207
|
pnpm --filter @wrongstack/plug-lsp setup -- --cwd /path/to/project
|
|
208
|
+
|
|
209
|
+
# Install specific servers
|
|
210
|
+
pnpm --filter @wrongstack/plug-lsp setup -- --cwd . --languages typescript,python,go
|
|
211
|
+
|
|
212
|
+
# Dry run
|
|
213
|
+
pnpm --filter @wrongstack/plug-lsp setup -- --dry-run --languages typescript
|
|
49
214
|
```
|
|
50
215
|
|
|
51
|
-
|
|
52
|
-
`node_modules/.bin`, so the same flow works on Windows, macOS, and Linux.
|
|
216
|
+
## Troubleshooting
|
|
53
217
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
requested explicitly:
|
|
218
|
+
**Server shows as "failed"**: Check the server binary is on PATH and starts correctly.
|
|
219
|
+
Run `/lsp status` to see the error message from the server's stderr.
|
|
57
220
|
|
|
58
|
-
|
|
59
|
-
|
|
221
|
+
**No diagnostics**: Open the file first (LSP servers report diagnostics for open files).
|
|
222
|
+
Run `/lsp diagnostics <file>` after reading the file.
|
|
223
|
+
|
|
224
|
+
**Wrong language detected**: Set the `languages` array explicitly in the server config
|
|
225
|
+
to include the language ID for your file (e.g., `"python"` for Python files).
|
|
226
|
+
|
|
227
|
+
## Architecture
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
packages/plug-lsp/src/
|
|
231
|
+
├── slash-commands/
|
|
232
|
+
│ ├── lsp.ts — unified /lsp command dispatcher
|
|
233
|
+
│ ├── install.ts — language server installation logic
|
|
234
|
+
│ ├── list/start/stop/restart/diagnostics.ts — individual commands
|
|
235
|
+
├── server/
|
|
236
|
+
│ ├── lsp-server.ts — per-server LSP client (one process per server)
|
|
237
|
+
│ ├── connection.ts — JSON-RPC 2.0 over stdio transport
|
|
238
|
+
│ └── lifecycle.ts — state machine for server lifecycle
|
|
239
|
+
├── tools/ — 4 LSP-backed agent tools (diagnostics, definition, rename, codebase-search)
|
|
240
|
+
├── registry.ts — manages all server instances
|
|
241
|
+
├── document-tracker.ts — tracks open/edited files across sessions
|
|
242
|
+
├── auto-discover.ts — PATH and node_modules discovery
|
|
243
|
+
└── presets.ts — built-in server configurations
|
|
60
244
|
```
|
|
245
|
+
|
|
246
|
+
## Plugin Command Names
|
|
247
|
+
|
|
248
|
+
The plugin registers slash commands with the `@wrongstack/plug-lsp` namespace:
|
|
249
|
+
|
|
250
|
+
- `/@wrongstack/plug-lsp:list`
|
|
251
|
+
- `/@wrongstack/plug-lsp:start`
|
|
252
|
+
- `/@wrongstack/plug-lsp:stop`
|
|
253
|
+
- `/@wrongstack/plug-lsp:restart`
|
|
254
|
+
- `/@wrongstack/plug-lsp:diagnostics`
|
|
255
|
+
|
|
256
|
+
These are also available as the short form **`/lsp`**, **`/lsp list`**, etc.
|