@mrclrchtr/supi-lsp 1.8.0 → 1.9.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 +20 -2
- package/node_modules/@mrclrchtr/supi-code-runtime/README.md +13 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +97 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +53 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +30 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +76 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config.ts +186 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +11 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-messages.ts +119 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-provider-registry.ts +36 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +31 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context.ts +16 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +255 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +30 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/path-utils.ts +40 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/path.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/project-roots.ts +170 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/project.ts +15 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +86 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/session-utils.ts +29 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/session.ts +4 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +15 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +41 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +226 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings.ts +9 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/substrate-types.ts +11 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/terminal.ts +60 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +116 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/types.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +40 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +35 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +68 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +31 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +110 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/context.ts +41 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +170 -0
- package/node_modules/@mrclrchtr/supi-core/README.md +3 -13
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -7
- package/package.json +9 -6
- package/src/handlers/session-lifecycle.ts +17 -7
- package/src/lsp.ts +3 -1
- package/src/manager/capability-index.ts +24 -0
- package/src/manager/client-pool.ts +33 -0
- package/src/manager/diagnostic-store.ts +51 -0
- package/src/manager/recovery-coordinator.ts +37 -0
- package/src/manager/workspace-router.ts +44 -0
- package/src/provider/lsp-semantic-provider.ts +156 -0
- package/src/session/runtime-registration.ts +39 -0
- package/src/tool/register-tools.ts +0 -1
- package/node_modules/@mrclrchtr/supi-core/src/extension.ts +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Workspace router — routes files to the correct LSP client based on project root.
|
|
2
|
+
|
|
3
|
+
import type { ProjectServerInfo } from "../config/server-config.ts";
|
|
4
|
+
import type { LspManager } from "./manager.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Routes file paths to the correct LSP client and tracks
|
|
8
|
+
* which project roots are known.
|
|
9
|
+
*/
|
|
10
|
+
export interface WorkspaceRouter {
|
|
11
|
+
/** Check whether a file can be served by any active server. */
|
|
12
|
+
canServeFile(filePath: string): boolean;
|
|
13
|
+
|
|
14
|
+
/** Check whether a source file type is supported. */
|
|
15
|
+
isSupportedSourceFile(filePath: string): boolean;
|
|
16
|
+
|
|
17
|
+
/** Get known project server info. */
|
|
18
|
+
getProjectServers(): ProjectServerInfo[];
|
|
19
|
+
|
|
20
|
+
/** Register detected servers from the workspace scan. */
|
|
21
|
+
registerDetectedServers(servers: Array<{ language: string; root: string }>): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create a WorkspaceRouter backed by LspManager.
|
|
26
|
+
*/
|
|
27
|
+
export function createWorkspaceRouter(manager: LspManager): WorkspaceRouter {
|
|
28
|
+
return {
|
|
29
|
+
canServeFile(filePath: string) {
|
|
30
|
+
return manager.canServeFile(filePath);
|
|
31
|
+
},
|
|
32
|
+
isSupportedSourceFile(filePath: string) {
|
|
33
|
+
return manager.isSupportedSourceFile(filePath);
|
|
34
|
+
},
|
|
35
|
+
getProjectServers(): ProjectServerInfo[] {
|
|
36
|
+
return manager.getKnownProjectServers([]);
|
|
37
|
+
},
|
|
38
|
+
registerDetectedServers(servers: Array<{ language: string; root: string }>) {
|
|
39
|
+
manager.registerDetectedServers(
|
|
40
|
+
servers as unknown as Parameters<typeof manager.registerDetectedServers>[0],
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// LSP semantic provider adapter — wraps SessionLspService into the shared
|
|
2
|
+
// SemanticProvider contract from supi-code-runtime.
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
CodeLocation,
|
|
6
|
+
CodePosition,
|
|
7
|
+
CodeSymbol,
|
|
8
|
+
SemanticProvider,
|
|
9
|
+
} from "@mrclrchtr/supi-code-runtime/api";
|
|
10
|
+
import type { DocumentSymbol, Location, LocationLink, SymbolInformation } from "../config/types.ts";
|
|
11
|
+
import type { SessionLspService } from "../session/service-registry.ts";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Create a SemanticProvider backed by a SessionLspService.
|
|
15
|
+
* Maps LSP types into the shared code-runtime types.
|
|
16
|
+
*/
|
|
17
|
+
export function createLspSemanticProvider(lsp: SessionLspService): SemanticProvider {
|
|
18
|
+
return {
|
|
19
|
+
async references(filePath: string, position: CodePosition): Promise<CodeLocation[] | null> {
|
|
20
|
+
const refResult = await lsp.references(filePath, position);
|
|
21
|
+
if (!refResult) return null;
|
|
22
|
+
const mapped: CodeLocation[] = [];
|
|
23
|
+
for (const item of refResult) {
|
|
24
|
+
const loc = toCodeLocation(item);
|
|
25
|
+
if (loc) mapped.push(loc);
|
|
26
|
+
}
|
|
27
|
+
return mapped;
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
async implementation(filePath: string, position: CodePosition): Promise<CodeLocation[] | null> {
|
|
31
|
+
const implResult = await lsp.implementation(filePath, position);
|
|
32
|
+
if (!implResult) return null;
|
|
33
|
+
const normalized = Array.isArray(implResult) ? implResult : [implResult];
|
|
34
|
+
const mapped: CodeLocation[] = [];
|
|
35
|
+
for (const item of normalized) {
|
|
36
|
+
const loc = toCodeLocation(item);
|
|
37
|
+
if (loc) mapped.push(loc);
|
|
38
|
+
}
|
|
39
|
+
return mapped;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
async documentSymbols(filePath: string): Promise<CodeSymbol[] | null> {
|
|
43
|
+
const symbols = await lsp.documentSymbols(filePath);
|
|
44
|
+
if (!symbols) return null;
|
|
45
|
+
return flattenDocumentSymbols(symbols, filePath);
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
async workspaceSymbols(query: string): Promise<CodeSymbol[] | null> {
|
|
49
|
+
const results = await lsp.workspaceSymbol(query);
|
|
50
|
+
if (!results) return null;
|
|
51
|
+
return results.map((sym) => toCodeSymbol(sym as SymbolInformation));
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ── Type conversion helpers ───────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
function toCodeLocation(item: Location | LocationLink): CodeLocation | null {
|
|
59
|
+
const loc = item as Record<string, unknown>;
|
|
60
|
+
const uri = loc.uri ?? loc.targetUri;
|
|
61
|
+
if (typeof uri !== "string") return null;
|
|
62
|
+
|
|
63
|
+
// Prefer targetSelectionRange > targetRange > range
|
|
64
|
+
const range = loc.targetSelectionRange ?? loc.targetRange ?? loc.range;
|
|
65
|
+
if (!range || typeof range !== "object") return null;
|
|
66
|
+
|
|
67
|
+
const r = range as { start: Record<string, unknown>; end: Record<string, unknown> };
|
|
68
|
+
const start = r.start;
|
|
69
|
+
const end = r.end;
|
|
70
|
+
if (!start || !end) return null;
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
uri,
|
|
74
|
+
range: {
|
|
75
|
+
start: { line: (start.line as number) ?? 0, character: (start.character as number) ?? 0 },
|
|
76
|
+
end: { line: (end.line as number) ?? 0, character: (end.character as number) ?? 0 },
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const SYMBOL_KIND_NAMES: Record<number, string> = {
|
|
82
|
+
1: "File",
|
|
83
|
+
2: "Module",
|
|
84
|
+
3: "Namespace",
|
|
85
|
+
4: "Package",
|
|
86
|
+
5: "Class",
|
|
87
|
+
6: "Method",
|
|
88
|
+
7: "Property",
|
|
89
|
+
8: "Field",
|
|
90
|
+
9: "Constructor",
|
|
91
|
+
10: "Enum",
|
|
92
|
+
11: "Interface",
|
|
93
|
+
12: "Function",
|
|
94
|
+
13: "Variable",
|
|
95
|
+
14: "Constant",
|
|
96
|
+
15: "String",
|
|
97
|
+
16: "Number",
|
|
98
|
+
17: "Boolean",
|
|
99
|
+
18: "Array",
|
|
100
|
+
19: "Object",
|
|
101
|
+
20: "Key",
|
|
102
|
+
21: "Null",
|
|
103
|
+
22: "EnumMember",
|
|
104
|
+
23: "Struct",
|
|
105
|
+
24: "Event",
|
|
106
|
+
25: "Operator",
|
|
107
|
+
26: "TypeParameter",
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
function symbolKindName(kind: number): string {
|
|
111
|
+
return SYMBOL_KIND_NAMES[kind] ?? "Unknown";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function flattenDocumentSymbols(
|
|
115
|
+
symbols: DocumentSymbol[] | SymbolInformation[],
|
|
116
|
+
filePath: string,
|
|
117
|
+
container: string | null = null,
|
|
118
|
+
): CodeSymbol[] {
|
|
119
|
+
const result: CodeSymbol[] = [];
|
|
120
|
+
|
|
121
|
+
for (const sym of symbols) {
|
|
122
|
+
// DocumentSymbol has selectionRange; SymbolInformation has location
|
|
123
|
+
const ds = sym as DocumentSymbol;
|
|
124
|
+
const si = sym as SymbolInformation;
|
|
125
|
+
const start = ds.selectionRange?.start ?? si.location?.range?.start;
|
|
126
|
+
if (!start) continue;
|
|
127
|
+
|
|
128
|
+
result.push({
|
|
129
|
+
name: sym.name,
|
|
130
|
+
kind: symbolKindName(sym.kind),
|
|
131
|
+
file: filePath,
|
|
132
|
+
line: start.line + 1,
|
|
133
|
+
character: start.character + 1,
|
|
134
|
+
container,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
if (Array.isArray(ds.children) && ds.children.length > 0) {
|
|
138
|
+
result.push(...flattenDocumentSymbols(ds.children, filePath, sym.name));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function toCodeSymbol(sym: SymbolInformation): CodeSymbol {
|
|
146
|
+
const uri = sym.location?.uri ?? "";
|
|
147
|
+
const start = sym.location?.range?.start;
|
|
148
|
+
return {
|
|
149
|
+
name: sym.name,
|
|
150
|
+
kind: symbolKindName(sym.kind),
|
|
151
|
+
file: uri.startsWith("file://") ? decodeURIComponent(uri.slice(7)) : uri,
|
|
152
|
+
line: start ? start.line + 1 : 0,
|
|
153
|
+
character: start ? start.character + 1 : 0,
|
|
154
|
+
container: sym.containerName ?? null,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LSP-to-runtime capability registration.
|
|
3
|
+
*
|
|
4
|
+
* Adapts a SessionLspService into the runtime's SemanticProvider interface
|
|
5
|
+
* and registers/unregisters it with the shared WorkspaceRuntime at session
|
|
6
|
+
* lifecycle boundaries.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { WorkspaceRuntime } from "@mrclrchtr/supi-code-runtime/api";
|
|
10
|
+
import { createLspSemanticProvider } from "../provider/lsp-semantic-provider.ts";
|
|
11
|
+
import type { SessionLspService } from "./service-registry.ts";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Register LSP capabilities for a workspace cwd.
|
|
15
|
+
*
|
|
16
|
+
* Wraps SessionLspService into a SemanticProvider via the existing
|
|
17
|
+
* semantic adapter and publishes it into the shared workspace runtime
|
|
18
|
+
* so that code-intelligence and other consumers can discover semantic
|
|
19
|
+
* analysis availability.
|
|
20
|
+
*/
|
|
21
|
+
export function registerLspCapabilities(
|
|
22
|
+
runtime: WorkspaceRuntime,
|
|
23
|
+
cwd: string,
|
|
24
|
+
service: SessionLspService,
|
|
25
|
+
): void {
|
|
26
|
+
const provider = createLspSemanticProvider(service);
|
|
27
|
+
runtime.registerSemantic(cwd, provider);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Unregister LSP capabilities for a workspace cwd.
|
|
32
|
+
*
|
|
33
|
+
* Clears only the semantic capability slot — structural (tree-sitter)
|
|
34
|
+
* state is left intact so that a later tree-sitter session_start does
|
|
35
|
+
* not needlessly wipe LSP state on its own restart path.
|
|
36
|
+
*/
|
|
37
|
+
export function unregisterLspCapabilities(runtime: WorkspaceRuntime, cwd: string): void {
|
|
38
|
+
runtime.clearSemantic(cwd);
|
|
39
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { registerSettingsCommand as default } from "./settings/settings-command.ts";
|