@hmharness/lsp 0.23.24 → 0.23.25
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/dist/tools.d.ts +12 -1
- package/dist/tools.js +8 -0
- package/package.json +2 -2
- package/src/tools.ts +21 -1
package/dist/tools.d.ts
CHANGED
|
@@ -7,12 +7,23 @@
|
|
|
7
7
|
* proof (master prompt prohibition).
|
|
8
8
|
*/
|
|
9
9
|
import type { Tool } from '@hmharness/kernel';
|
|
10
|
-
import type { Diagnostic } from './protocol.js';
|
|
10
|
+
import type { Diagnostic, DocumentSymbol } from './protocol.js';
|
|
11
|
+
/** What a read-only tool observed — fed to the caller's Code World Model
|
|
12
|
+
* sink. Same posture as the extension onPageRead hook: observation only,
|
|
13
|
+
* best-effort, never able to fail the tool that observed. */
|
|
14
|
+
export interface LspObservation {
|
|
15
|
+
uri: string;
|
|
16
|
+
symbols?: DocumentSymbol[];
|
|
17
|
+
diagnostics?: Diagnostic[];
|
|
18
|
+
}
|
|
11
19
|
export interface LspToolContext {
|
|
12
20
|
workspaceRoot: string;
|
|
13
21
|
/** HMH_HOME — required by the source-trust guard (Capability OS slice);
|
|
14
22
|
* when absent PATH servers are refused honestly */
|
|
15
23
|
home?: string;
|
|
24
|
+
/** Observation sink: symbols/diagnostics pulled by the tools ride into
|
|
25
|
+
* the persisted Code World Model. Optional; sink errors are swallowed. */
|
|
26
|
+
onObserve?: (obs: LspObservation) => void;
|
|
16
27
|
}
|
|
17
28
|
/** Stop every client this module started (TUI/CLI shutdown path). */
|
|
18
29
|
export declare function shutdownLsp(): Promise<void>;
|
package/dist/tools.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { ProcessManager } from "./process-manager.js";
|
|
2
2
|
import { LspClient } from "./client.js";
|
|
3
3
|
import { discoverServers, serverForFile, fileToUri } from "./registry.js";
|
|
4
|
+
function emitObservation(ctx, obs) {
|
|
5
|
+
try {
|
|
6
|
+
ctx.onObserve?.(obs);
|
|
7
|
+
}
|
|
8
|
+
catch { /* an observation sink must never fail the tool that observed */ }
|
|
9
|
+
}
|
|
4
10
|
/** One live client per server for the lifetime of the context. */
|
|
5
11
|
const clients = new Map();
|
|
6
12
|
/** Sync last-resort kill on process exit (async shutdown may not run when
|
|
@@ -83,6 +89,7 @@ export function lspTools(ctx) {
|
|
|
83
89
|
const abs = resolveFile(ctx, String(args.file ?? ''));
|
|
84
90
|
const r = await withClient(String(args.file ?? ''), async (mc, uri) => {
|
|
85
91
|
const diags = mc.diagnostics.get(uri) ?? [];
|
|
92
|
+
emitObservation(ctx, { uri, diagnostics: diags });
|
|
86
93
|
return `[${mc.server.id}${mc.server.official ? '' : ' (community/unofficial)'}] ${uri}\n` + fmtDiags(diags);
|
|
87
94
|
});
|
|
88
95
|
return r;
|
|
@@ -122,6 +129,7 @@ export function lspTools(ctx) {
|
|
|
122
129
|
async execute(args) {
|
|
123
130
|
return withClient(String(args.file ?? ''), async (mc, uri) => {
|
|
124
131
|
const syms = await mc.client.documentSymbols({ uri });
|
|
132
|
+
emitObservation(ctx, { uri, symbols: syms });
|
|
125
133
|
const flat = [];
|
|
126
134
|
const walk = (ss, depth) => {
|
|
127
135
|
for (const s of ss.slice(0, 30)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/lsp",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.25",
|
|
4
4
|
"description": "hmharness LSP Client/Manager — drives external language servers (LSP 3.18 over stdio) for agent code intelligence. Client only: we never implement language servers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"build": "tsc -p tsconfig.build.json"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@hmharness/kernel": "0.23.
|
|
18
|
+
"@hmharness/kernel": "0.23.25"
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=22"
|
package/src/tools.ts
CHANGED
|
@@ -10,13 +10,31 @@ import type { Tool } from '@hmharness/kernel';
|
|
|
10
10
|
import { ProcessManager } from './process-manager.ts';
|
|
11
11
|
import { LspClient } from './client.ts';
|
|
12
12
|
import { discoverServers, serverForFile, fileToUri, type DiscoveredServer } from './registry.ts';
|
|
13
|
-
import type { Diagnostic } from './protocol.ts';
|
|
13
|
+
import type { Diagnostic, DocumentSymbol } from './protocol.ts';
|
|
14
|
+
|
|
15
|
+
/** What a read-only tool observed — fed to the caller's Code World Model
|
|
16
|
+
* sink. Same posture as the extension onPageRead hook: observation only,
|
|
17
|
+
* best-effort, never able to fail the tool that observed. */
|
|
18
|
+
export interface LspObservation {
|
|
19
|
+
uri: string;
|
|
20
|
+
symbols?: DocumentSymbol[];
|
|
21
|
+
diagnostics?: Diagnostic[];
|
|
22
|
+
}
|
|
14
23
|
|
|
15
24
|
export interface LspToolContext {
|
|
16
25
|
workspaceRoot: string;
|
|
17
26
|
/** HMH_HOME — required by the source-trust guard (Capability OS slice);
|
|
18
27
|
* when absent PATH servers are refused honestly */
|
|
19
28
|
home?: string;
|
|
29
|
+
/** Observation sink: symbols/diagnostics pulled by the tools ride into
|
|
30
|
+
* the persisted Code World Model. Optional; sink errors are swallowed. */
|
|
31
|
+
onObserve?: (obs: LspObservation) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function emitObservation(ctx: LspToolContext, obs: LspObservation): void {
|
|
35
|
+
try {
|
|
36
|
+
ctx.onObserve?.(obs);
|
|
37
|
+
} catch { /* an observation sink must never fail the tool that observed */ }
|
|
20
38
|
}
|
|
21
39
|
|
|
22
40
|
interface ManagedClient {
|
|
@@ -112,6 +130,7 @@ export function lspTools(ctx: LspToolContext): Tool[] {
|
|
|
112
130
|
const abs = resolveFile(ctx, String(args.file ?? ''));
|
|
113
131
|
const r = await withClient(String(args.file ?? ''), async (mc, uri) => {
|
|
114
132
|
const diags = mc.diagnostics.get(uri) ?? [];
|
|
133
|
+
emitObservation(ctx, { uri, diagnostics: diags });
|
|
115
134
|
return `[${mc.server.id}${mc.server.official ? '' : ' (community/unofficial)'}] ${uri}\n` + fmtDiags(diags);
|
|
116
135
|
});
|
|
117
136
|
return r;
|
|
@@ -149,6 +168,7 @@ export function lspTools(ctx: LspToolContext): Tool[] {
|
|
|
149
168
|
async execute(args) {
|
|
150
169
|
return withClient(String(args.file ?? ''), async (mc, uri) => {
|
|
151
170
|
const syms = await mc.client.documentSymbols({ uri });
|
|
171
|
+
emitObservation(ctx, { uri, symbols: syms });
|
|
152
172
|
const flat: string[] = [];
|
|
153
173
|
const walk = (ss: typeof syms, depth: number) => {
|
|
154
174
|
for (const s of ss.slice(0, 30)) {
|