cli-lsp-client 1.3.0 → 1.5.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/LICENSE +1 -1
- package/README.md +45 -7
- package/cli-lsp-client +0 -0
- package/package.json +3 -2
- package/src/cli.ts +20 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ CLI tool for getting LSP diagnostics. Uses a background daemon to keep LSP serve
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- Get diagnostics from LSP servers
|
|
8
|
+
- Get hover information for symbols (functions, variables, types)
|
|
8
9
|
- Background daemon for fast repeated requests
|
|
9
10
|
- Built in Claude Code hook to provide feedback on file edit tool calls
|
|
10
11
|
- Comprehensive daemon management (`list`, `stop-all` commands)
|
|
@@ -52,7 +53,7 @@ Configure Claude Code to use the built-in hook command:
|
|
|
52
53
|
"hooks": [
|
|
53
54
|
{
|
|
54
55
|
"type": "command",
|
|
55
|
-
"command": "npx -y cli-lsp-client
|
|
56
|
+
"command": "npx -y cli-lsp-client start"
|
|
56
57
|
}
|
|
57
58
|
]
|
|
58
59
|
}
|
|
@@ -74,7 +75,7 @@ Configure Claude Code to use the built-in hook command:
|
|
|
74
75
|
|
|
75
76
|
#### How It Works
|
|
76
77
|
|
|
77
|
-
- **SessionStart**: Automatically
|
|
78
|
+
- **SessionStart**: Automatically starts LSP servers when Claude Code starts for faster initial diagnostics
|
|
78
79
|
- **PostToolUse**: Runs diagnostics after each file edit (Edit, MultiEdit, Write tools)
|
|
79
80
|
- Built-in file filtering for all supported languages (11 file types)
|
|
80
81
|
- Shows errors, warnings, and hints inline
|
|
@@ -117,10 +118,28 @@ ERROR at line 5, column 20:
|
|
|
117
118
|
Code: 2345
|
|
118
119
|
```
|
|
119
120
|
|
|
121
|
+
### Get Hover Information
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Get hover info for a function
|
|
125
|
+
npx cli-lsp-client hover src/main.ts myFunction
|
|
126
|
+
|
|
127
|
+
# Get hover info for a variable or type
|
|
128
|
+
npx cli-lsp-client hover app.py MyClass
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
$ npx cli-lsp-client hover src/client.ts runCommand
|
|
133
|
+
Location: src/client.ts:370:17
|
|
134
|
+
```typescript
|
|
135
|
+
export function runCommand(command: string, commandArgs: string[]): Promise<void>
|
|
136
|
+
```
|
|
137
|
+
```
|
|
138
|
+
|
|
120
139
|
### Daemon Management
|
|
121
140
|
|
|
122
141
|
```bash
|
|
123
|
-
# Check daemon status and
|
|
142
|
+
# Check daemon status with uptime and running language servers
|
|
124
143
|
npx cli-lsp-client status
|
|
125
144
|
|
|
126
145
|
# List all running daemons across directories
|
|
@@ -139,6 +158,22 @@ npx cli-lsp-client --version
|
|
|
139
158
|
npx cli-lsp-client help
|
|
140
159
|
```
|
|
141
160
|
|
|
161
|
+
The `status` command shows the current daemon's uptime and running language servers:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
$ npx cli-lsp-client status
|
|
165
|
+
LSP Daemon Status
|
|
166
|
+
================
|
|
167
|
+
PID: 33502
|
|
168
|
+
Uptime: 1m 38s
|
|
169
|
+
|
|
170
|
+
Language Servers:
|
|
171
|
+
- typescript (.) - running 1m 33s
|
|
172
|
+
- pyright (.) - running 1m 10s
|
|
173
|
+
|
|
174
|
+
Total: 2 language servers running
|
|
175
|
+
```
|
|
176
|
+
|
|
142
177
|
The `list` command shows all running daemon instances with their working directories, PIDs, and status:
|
|
143
178
|
|
|
144
179
|
```bash
|
|
@@ -205,11 +240,11 @@ For detailed setup instructions, see the [official Eclipse JDT.LS documentation]
|
|
|
205
240
|
### Additional Commands
|
|
206
241
|
|
|
207
242
|
```bash
|
|
208
|
-
#
|
|
209
|
-
npx cli-lsp-client
|
|
243
|
+
# Start LSP servers for current directory (faster subsequent requests)
|
|
244
|
+
npx cli-lsp-client start
|
|
210
245
|
|
|
211
|
-
#
|
|
212
|
-
npx cli-lsp-client
|
|
246
|
+
# Start servers for specific directory
|
|
247
|
+
npx cli-lsp-client start /path/to/project
|
|
213
248
|
|
|
214
249
|
# View daemon logs
|
|
215
250
|
npx cli-lsp-client logs
|
|
@@ -221,6 +256,9 @@ npx cli-lsp-client logs
|
|
|
221
256
|
# Check a specific file
|
|
222
257
|
npx cli-lsp-client diagnostics src/main.ts
|
|
223
258
|
|
|
259
|
+
# Get hover info for a symbol
|
|
260
|
+
npx cli-lsp-client hover src/main.ts myFunction
|
|
261
|
+
|
|
224
262
|
# List all daemon instances
|
|
225
263
|
npx cli-lsp-client list
|
|
226
264
|
|
package/cli-lsp-client
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cli-lsp-client",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "CLI tool for fast LSP diagnostics with background daemon and multi-project support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/cli.ts",
|
|
7
|
+
"license": "MIT",
|
|
7
8
|
"bin": {
|
|
8
9
|
"cli-lsp-client": "cli-lsp-client"
|
|
9
10
|
},
|
package/src/cli.ts
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { startDaemon } from './daemon.js';
|
|
5
|
-
import { runCommand } from './client.js';
|
|
5
|
+
import { runCommand, sendToExistingDaemon } from './client.js';
|
|
6
6
|
import { formatDiagnosticsPlain } from './lsp/formatter.js';
|
|
7
7
|
import type { Diagnostic } from './lsp/types.js';
|
|
8
8
|
import { HELP_MESSAGE } from './constants.js';
|
|
9
|
+
import { ensureDaemonRunning } from './utils.js';
|
|
9
10
|
import packageJson from '../package.json' with { type: 'json' };
|
|
10
11
|
|
|
11
|
-
export async function handleClaudeCodeHook(filePath: string): Promise<{ hasIssues: boolean; output: string }> {
|
|
12
|
+
export async function handleClaudeCodeHook(filePath: string): Promise<{ hasIssues: boolean; output: string; daemonFailed?: boolean }> {
|
|
12
13
|
// Check if file exists
|
|
13
14
|
if (!await Bun.file(filePath).exists()) {
|
|
14
15
|
return { hasIssues: false, output: '' };
|
|
@@ -34,7 +35,18 @@ export async function handleClaudeCodeHook(filePath: string): Promise<{ hasIssue
|
|
|
34
35
|
|
|
35
36
|
// Get diagnostics (suppress errors to stdout)
|
|
36
37
|
try {
|
|
37
|
-
|
|
38
|
+
// Ensure daemon is running
|
|
39
|
+
const daemonStarted = await ensureDaemonRunning();
|
|
40
|
+
|
|
41
|
+
if (!daemonStarted) {
|
|
42
|
+
// Failed to start daemon - return with flag so caller can handle
|
|
43
|
+
return {
|
|
44
|
+
hasIssues: false,
|
|
45
|
+
output: 'Failed to start LSP daemon. Please try running "cli-lsp-client stop" and retry.',
|
|
46
|
+
daemonFailed: true
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
38
50
|
const result = await sendToExistingDaemon('diagnostics', [filePath]);
|
|
39
51
|
|
|
40
52
|
// The diagnostics command returns an array of diagnostics
|
|
@@ -109,6 +121,11 @@ async function run(): Promise<void> {
|
|
|
109
121
|
}
|
|
110
122
|
|
|
111
123
|
const result = await handleClaudeCodeHook(filePath);
|
|
124
|
+
if (result.daemonFailed) {
|
|
125
|
+
// Daemon failed to start - exit with status 1 to show error to user
|
|
126
|
+
console.error(result.output);
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
112
129
|
if (result.hasIssues) {
|
|
113
130
|
console.error(result.output);
|
|
114
131
|
process.exit(2);
|