@mrclrchtr/supi-lsp 1.16.1 → 2.0.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 +44 -56
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +6 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +3 -2
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +7 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +56 -2
- package/node_modules/@mrclrchtr/supi-code-runtime/src/evidence-badge.ts +40 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +5 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +76 -3
- package/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +37 -2
- package/node_modules/@mrclrchtr/supi-core/package.json +6 -1
- package/node_modules/@mrclrchtr/supi-core/src/abort-utils.ts +31 -0
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +8 -0
- package/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +10 -4
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +1 -0
- package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/index.ts +6 -0
- package/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +9 -2
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +109 -4
- package/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +5 -1
- package/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
- package/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
- package/package.json +4 -31
- package/src/api.ts +27 -0
- package/src/client/client-refresh.ts +5 -0
- package/src/client/client.ts +246 -1
- package/src/client/transport.ts +4 -0
- package/src/config/capabilities.ts +3 -0
- package/src/config/config.ts +4 -2
- package/src/config/lsp-settings.ts +102 -0
- package/src/config/server-actions.ts +59 -0
- package/src/config/server-config.ts +4 -0
- package/src/index.ts +11 -0
- package/src/manager/capability-index.ts +1 -1
- package/src/manager/manager-project-info.ts +2 -1
- package/src/manager/manager.ts +115 -26
- package/src/provider/lsp-semantic-provider.ts +177 -134
- package/src/provider/refactor-planning.ts +214 -0
- package/src/session/runtime-controller.ts +320 -0
- package/src/session/runtime-registration.ts +26 -5
- package/src/session/service-registry.ts +81 -4
- package/src/summary.ts +2 -0
- package/src/extension.ts +0 -1
- package/src/format.ts +0 -373
- package/src/handlers/diagnostic-injection.ts +0 -182
- package/src/handlers/session-lifecycle.ts +0 -149
- package/src/handlers/status-command.ts +0 -38
- package/src/handlers/workspace-recovery.ts +0 -92
- package/src/lsp.ts +0 -37
- package/src/session/lsp-state.ts +0 -93
- package/src/session/settings-registration.ts +0 -296
- package/src/session/tree-persist.ts +0 -75
- package/src/tool/guidance.ts +0 -69
- package/src/tool/names.ts +0 -27
- package/src/tool/overrides.ts +0 -204
- package/src/tool/register-tools.ts +0 -69
- package/src/tool/service-actions.ts +0 -399
- package/src/tool/tool-specs.ts +0 -248
- package/src/ui/renderer.ts +0 -120
- package/src/ui/ui.ts +0 -360
- package/src/workspace-change.ts +0 -40
package/src/tool/tool-specs.ts
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { type TSchema, Type } from "typebox";
|
|
2
|
-
import type { ServerCapabilities } from "../config/types.ts";
|
|
3
|
-
import type { SessionLspService } from "../session/service-registry.ts";
|
|
4
|
-
import {
|
|
5
|
-
LSP_CODE_ACTIONS_TOOL,
|
|
6
|
-
LSP_DEFINITION_TOOL,
|
|
7
|
-
LSP_DIAGNOSTICS_TOOL,
|
|
8
|
-
LSP_DOCUMENT_SYMBOLS_TOOL,
|
|
9
|
-
LSP_HOVER_TOOL,
|
|
10
|
-
LSP_IMPLEMENTATION_TOOL,
|
|
11
|
-
LSP_RECOVER_TOOL,
|
|
12
|
-
LSP_REFERENCES_TOOL,
|
|
13
|
-
LSP_RENAME_TOOL,
|
|
14
|
-
LSP_WORKSPACE_SYMBOLS_TOOL,
|
|
15
|
-
type LspToolName,
|
|
16
|
-
} from "./names.ts";
|
|
17
|
-
import {
|
|
18
|
-
executeCodeActions,
|
|
19
|
-
executeDefinition,
|
|
20
|
-
executeDiagnostics,
|
|
21
|
-
executeDocumentSymbols,
|
|
22
|
-
executeHover,
|
|
23
|
-
executeImplementation,
|
|
24
|
-
executeRecover,
|
|
25
|
-
executeReferences,
|
|
26
|
-
executeRename,
|
|
27
|
-
executeWorkspaceSymbols,
|
|
28
|
-
} from "./service-actions.ts";
|
|
29
|
-
|
|
30
|
-
// Shared parameter builders
|
|
31
|
-
const FileParam = Type.String({ description: "File path" });
|
|
32
|
-
const LineParam = Type.Number({ description: "1-based line", minimum: 1 });
|
|
33
|
-
const CharacterParam = Type.Number({ description: "1-based column", minimum: 1 });
|
|
34
|
-
const QueryParam = Type.String({ description: "Symbol query" });
|
|
35
|
-
const NewNameParam = Type.String({ description: "New name" });
|
|
36
|
-
|
|
37
|
-
// Parameter schemas
|
|
38
|
-
const PositionParams = Type.Object(
|
|
39
|
-
{ file: FileParam, line: LineParam, character: CharacterParam },
|
|
40
|
-
{ additionalProperties: false },
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const RenameParams = Type.Object(
|
|
44
|
-
{ file: FileParam, line: LineParam, character: CharacterParam, newName: NewNameParam },
|
|
45
|
-
{ additionalProperties: false },
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const DocumentSymbolsParameters = Type.Object({ file: FileParam }, { additionalProperties: false });
|
|
49
|
-
|
|
50
|
-
const WorkspaceSymbolsParameters = Type.Object(
|
|
51
|
-
{ query: QueryParam },
|
|
52
|
-
{ additionalProperties: false },
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const DiagnosticsParameters = Type.Object(
|
|
56
|
-
{ file: Type.Optional(FileParam) },
|
|
57
|
-
{ additionalProperties: false },
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const RecoverParameters = Type.Object({}, { additionalProperties: false });
|
|
61
|
-
|
|
62
|
-
export interface LspToolDefinitionSpec {
|
|
63
|
-
name: LspToolName;
|
|
64
|
-
label: string;
|
|
65
|
-
description: string;
|
|
66
|
-
promptSnippet: string;
|
|
67
|
-
basePromptGuidelines: string[];
|
|
68
|
-
parameters: TSchema;
|
|
69
|
-
run: (service: SessionLspService, cwd: string, params: unknown) => Promise<string>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export const LSP_TOOL_DEFINITION_SPECS = [
|
|
73
|
-
{
|
|
74
|
-
name: LSP_HOVER_TOOL,
|
|
75
|
-
label: "LSP Hover",
|
|
76
|
-
description: "Semantic hover/type info at a file position.",
|
|
77
|
-
promptSnippet: "lsp_hover — hover/type info",
|
|
78
|
-
basePromptGuidelines: ["Use lsp_hover(file,line,character) for semantic hover/type info."],
|
|
79
|
-
parameters: PositionParams,
|
|
80
|
-
run: (service, cwd, params) =>
|
|
81
|
-
executeHover(service, cwd, params as Parameters<typeof executeHover>[2]),
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: LSP_DEFINITION_TOOL,
|
|
85
|
-
label: "LSP Definition",
|
|
86
|
-
description: "Jump to a symbol definition at a file position.",
|
|
87
|
-
promptSnippet: "lsp_definition — jump to definition",
|
|
88
|
-
basePromptGuidelines: [
|
|
89
|
-
"Use lsp_definition(file,line,character) to jump to a symbol definition.",
|
|
90
|
-
],
|
|
91
|
-
parameters: PositionParams,
|
|
92
|
-
run: (service, cwd, params) =>
|
|
93
|
-
executeDefinition(service, cwd, params as Parameters<typeof executeDefinition>[2]),
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: LSP_REFERENCES_TOOL,
|
|
97
|
-
label: "LSP References",
|
|
98
|
-
description: "Find semantic references to a symbol at a file position.",
|
|
99
|
-
promptSnippet: "lsp_references — semantic references",
|
|
100
|
-
basePromptGuidelines: ["Use lsp_references(file,line,character) for semantic references."],
|
|
101
|
-
parameters: PositionParams,
|
|
102
|
-
run: (service, cwd, params) =>
|
|
103
|
-
executeReferences(service, cwd, params as Parameters<typeof executeReferences>[2]),
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
name: LSP_IMPLEMENTATION_TOOL,
|
|
107
|
-
label: "LSP Implementation",
|
|
108
|
-
description: "Find implementations from a file position.",
|
|
109
|
-
promptSnippet: "lsp_implementation — implementations",
|
|
110
|
-
basePromptGuidelines: ["Use lsp_implementation(file,line,character) for implementations."],
|
|
111
|
-
parameters: PositionParams,
|
|
112
|
-
run: (service, cwd, params) =>
|
|
113
|
-
executeImplementation(service, cwd, params as Parameters<typeof executeImplementation>[2]),
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: LSP_DOCUMENT_SYMBOLS_TOOL,
|
|
117
|
-
label: "LSP Document Symbols",
|
|
118
|
-
description: "List semantic declarations in one file.",
|
|
119
|
-
promptSnippet: "lsp_document_symbols — one-file semantic outline",
|
|
120
|
-
basePromptGuidelines: ["Use lsp_document_symbols(file) for one-file semantic declarations."],
|
|
121
|
-
parameters: DocumentSymbolsParameters,
|
|
122
|
-
run: (service, cwd, params) =>
|
|
123
|
-
executeDocumentSymbols(service, cwd, params as Parameters<typeof executeDocumentSymbols>[2]),
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: LSP_WORKSPACE_SYMBOLS_TOOL,
|
|
127
|
-
label: "LSP Workspace Symbols",
|
|
128
|
-
description: "Find symbol declarations by name across the project.",
|
|
129
|
-
promptSnippet: "lsp_workspace_symbols — project symbol lookup",
|
|
130
|
-
basePromptGuidelines: ["Use lsp_workspace_symbols(query) to find declarations by name."],
|
|
131
|
-
parameters: WorkspaceSymbolsParameters,
|
|
132
|
-
run: (service, cwd, params) =>
|
|
133
|
-
executeWorkspaceSymbols(
|
|
134
|
-
service,
|
|
135
|
-
cwd,
|
|
136
|
-
params as Parameters<typeof executeWorkspaceSymbols>[2],
|
|
137
|
-
),
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: LSP_DIAGNOSTICS_TOOL,
|
|
141
|
-
label: "LSP Diagnostics",
|
|
142
|
-
description: "Show semantic diagnostics for one file or the workspace.",
|
|
143
|
-
promptSnippet: "lsp_diagnostics — semantic diagnostics",
|
|
144
|
-
basePromptGuidelines: ["Use lsp_diagnostics(file?) for semantic diagnostics."],
|
|
145
|
-
parameters: DiagnosticsParameters,
|
|
146
|
-
run: (service, cwd, params) =>
|
|
147
|
-
executeDiagnostics(service, cwd, params as Parameters<typeof executeDiagnostics>[2]),
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: LSP_RENAME_TOOL,
|
|
151
|
-
label: "LSP Rename",
|
|
152
|
-
description: "Plan a semantic rename from a file position.",
|
|
153
|
-
promptSnippet: "lsp_rename — semantic rename plan",
|
|
154
|
-
basePromptGuidelines: [
|
|
155
|
-
"Use lsp_rename(file,line,character,newName) to plan a semantic rename.",
|
|
156
|
-
],
|
|
157
|
-
parameters: RenameParams,
|
|
158
|
-
run: (service, cwd, params) =>
|
|
159
|
-
executeRename(service, cwd, params as Parameters<typeof executeRename>[2]),
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: LSP_CODE_ACTIONS_TOOL,
|
|
163
|
-
label: "LSP Code Actions",
|
|
164
|
-
description: "List code fixes/refactors at a file position.",
|
|
165
|
-
promptSnippet: "lsp_code_actions — quick fixes/refactors",
|
|
166
|
-
basePromptGuidelines: ["Use lsp_code_actions(file,line,character) for quick fixes/refactors."],
|
|
167
|
-
parameters: PositionParams,
|
|
168
|
-
run: (service, cwd, params) =>
|
|
169
|
-
executeCodeActions(service, cwd, params as Parameters<typeof executeCodeActions>[2]),
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
name: LSP_RECOVER_TOOL,
|
|
173
|
-
label: "LSP Recover",
|
|
174
|
-
description: "Refresh LSP diagnostics after workspace changes.",
|
|
175
|
-
promptSnippet: "lsp_recover — refresh stale diagnostics",
|
|
176
|
-
basePromptGuidelines: [
|
|
177
|
-
"Use lsp_recover() when diagnostics look stale after workspace changes.",
|
|
178
|
-
],
|
|
179
|
-
parameters: RecoverParameters,
|
|
180
|
-
run: (service) => executeRecover(service),
|
|
181
|
-
},
|
|
182
|
-
] as const satisfies readonly LspToolDefinitionSpec[];
|
|
183
|
-
|
|
184
|
-
const LSP_TOOL_SPEC_MAP = new Map<LspToolName, LspToolDefinitionSpec>(
|
|
185
|
-
LSP_TOOL_DEFINITION_SPECS.map((spec) => [spec.name, spec]),
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
export function getLspToolDefinitionSpec(toolName: LspToolName): LspToolDefinitionSpec {
|
|
189
|
-
const spec = LSP_TOOL_SPEC_MAP.get(toolName);
|
|
190
|
-
if (!spec) {
|
|
191
|
-
throw new Error(`Unknown LSP tool: ${toolName}`);
|
|
192
|
-
}
|
|
193
|
-
return spec;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
interface LspServerSupportedActionSpec {
|
|
197
|
-
label: string;
|
|
198
|
-
isSupported: (capabilities: ServerCapabilities | null | undefined) => boolean;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const LSP_SERVER_SUPPORTED_ACTION_SPECS: readonly LspServerSupportedActionSpec[] = [
|
|
202
|
-
{
|
|
203
|
-
label: "diagnostics [optional file]",
|
|
204
|
-
isSupported: () => true,
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
label: "hover(file,line,char)",
|
|
208
|
-
isSupported: (capabilities) => Boolean(capabilities?.hoverProvider),
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
label: "definition(file,line,char)",
|
|
212
|
-
isSupported: (capabilities) => Boolean(capabilities?.definitionProvider),
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
label: "references(file,line,char)",
|
|
216
|
-
isSupported: (capabilities) => Boolean(capabilities?.referencesProvider),
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
label: "implementation(file,line,char)",
|
|
220
|
-
isSupported: (capabilities) => Boolean(capabilities?.implementationProvider),
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
label: "symbols(file)",
|
|
224
|
-
isSupported: (capabilities) => Boolean(capabilities?.documentSymbolProvider),
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
label: "workspace_symbols(query)",
|
|
228
|
-
isSupported: (capabilities) => Boolean(capabilities?.workspaceSymbolProvider),
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
label: "rename(file,line,char,newName)",
|
|
232
|
-
isSupported: (capabilities) => Boolean(capabilities?.renameProvider),
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
label: "code_actions(file,line,char)",
|
|
236
|
-
isSupported: (capabilities) => Boolean(capabilities?.codeActionProvider),
|
|
237
|
-
},
|
|
238
|
-
] as const;
|
|
239
|
-
|
|
240
|
-
export function getSupportedLspServerActions(
|
|
241
|
-
capabilities: ServerCapabilities | null | undefined,
|
|
242
|
-
): string[] {
|
|
243
|
-
if (!capabilities) return [];
|
|
244
|
-
|
|
245
|
-
return LSP_SERVER_SUPPORTED_ACTION_SPECS.filter((spec) => spec.isSupported(capabilities)).map(
|
|
246
|
-
(spec) => spec.label,
|
|
247
|
-
);
|
|
248
|
-
}
|
package/src/ui/renderer.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import type { ThemeColor } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { Box, Text } from "@earendil-works/pi-tui";
|
|
3
|
-
|
|
4
|
-
interface LspContextDetails {
|
|
5
|
-
contextToken?: string;
|
|
6
|
-
inlineSeverity?: number;
|
|
7
|
-
staleWarning?: string | null;
|
|
8
|
-
diagnostics?: Array<{
|
|
9
|
-
file: string;
|
|
10
|
-
errors: number;
|
|
11
|
-
warnings: number;
|
|
12
|
-
information: number;
|
|
13
|
-
hints: number;
|
|
14
|
-
}>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type DiagnosticEntry = NonNullable<LspContextDetails["diagnostics"]>[number];
|
|
18
|
-
type DiagnosticCounts = Pick<DiagnosticEntry, "errors" | "warnings" | "information" | "hints">;
|
|
19
|
-
|
|
20
|
-
function formatDiagnosticCounts(
|
|
21
|
-
totals: DiagnosticCounts,
|
|
22
|
-
theme: { fg: (color: ThemeColor, text: string) => string },
|
|
23
|
-
): string {
|
|
24
|
-
const parts: string[] = [];
|
|
25
|
-
if (totals.errors > 0)
|
|
26
|
-
parts.push(theme.fg("error", `${totals.errors} error${totals.errors === 1 ? "" : "s"}`));
|
|
27
|
-
if (totals.warnings > 0)
|
|
28
|
-
parts.push(
|
|
29
|
-
theme.fg("warning", `${totals.warnings} warning${totals.warnings === 1 ? "" : "s"}`),
|
|
30
|
-
);
|
|
31
|
-
if (totals.information > 0)
|
|
32
|
-
parts.push(
|
|
33
|
-
theme.fg("accent", `${totals.information} info${totals.information === 1 ? "" : "s"}`),
|
|
34
|
-
);
|
|
35
|
-
if (totals.hints > 0)
|
|
36
|
-
parts.push(theme.fg("dim", `${totals.hints} hint${totals.hints === 1 ? "" : "s"}`));
|
|
37
|
-
return parts.join(", ");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function hasDiagnosticCounts(totals: DiagnosticCounts): boolean {
|
|
41
|
-
return totals.errors > 0 || totals.warnings > 0 || totals.information > 0 || totals.hints > 0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function buildLspContextCollapsed(
|
|
45
|
-
diagnostics: LspContextDetails["diagnostics"],
|
|
46
|
-
totals: DiagnosticCounts | undefined,
|
|
47
|
-
staleWarning: string | null | undefined,
|
|
48
|
-
theme: { fg: (color: ThemeColor, text: string) => string },
|
|
49
|
-
): string {
|
|
50
|
-
const icon = theme.fg("accent", "\u{1F527}");
|
|
51
|
-
let summary: string;
|
|
52
|
-
if (!diagnostics || !totals) {
|
|
53
|
-
summary = `${icon} LSP diagnostics injected`;
|
|
54
|
-
} else if (!hasDiagnosticCounts(totals)) {
|
|
55
|
-
summary = `${icon} LSP diagnostics injected ${theme.fg("success", "\u2713")}`;
|
|
56
|
-
} else {
|
|
57
|
-
summary = `${icon} LSP diagnostics injected (${formatDiagnosticCounts(totals, theme)})`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (!staleWarning) return summary;
|
|
61
|
-
return `${summary}\n${theme.fg("warning", staleWarning)}`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function formatFileDiagnosticEntry(d: DiagnosticCounts): string {
|
|
65
|
-
return formatDiagnosticCounts(d, { fg: (_color, text) => text });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function formatExpandedDetails(
|
|
69
|
-
diagnostics: LspContextDetails["diagnostics"],
|
|
70
|
-
token: string | undefined,
|
|
71
|
-
staleWarning: string | null | undefined,
|
|
72
|
-
theme: { fg: (color: ThemeColor, text: string) => string },
|
|
73
|
-
): string {
|
|
74
|
-
const lines: string[] = [];
|
|
75
|
-
if (staleWarning) {
|
|
76
|
-
lines.push(theme.fg("warning", ` ${staleWarning}`));
|
|
77
|
-
}
|
|
78
|
-
if (diagnostics && diagnostics.length > 0) {
|
|
79
|
-
for (const d of diagnostics) {
|
|
80
|
-
lines.push(theme.fg("dim", ` ${d.file}: ${formatFileDiagnosticEntry(d)}`));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (token) {
|
|
84
|
-
lines.push(theme.fg("dim", ` token: ${token}`));
|
|
85
|
-
}
|
|
86
|
-
return lines.join("\n");
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export type { LspContextDetails };
|
|
90
|
-
|
|
91
|
-
export function registerLspMessageRenderer(
|
|
92
|
-
pi: import("@earendil-works/pi-coding-agent").ExtensionAPI,
|
|
93
|
-
): void {
|
|
94
|
-
pi.registerMessageRenderer("lsp-context", (message, { expanded }, theme) => {
|
|
95
|
-
const details = message.details as LspContextDetails | undefined;
|
|
96
|
-
const diagnostics = details?.diagnostics;
|
|
97
|
-
const token = details?.contextToken;
|
|
98
|
-
|
|
99
|
-
const totals = diagnostics?.reduce(
|
|
100
|
-
(acc, d) => ({
|
|
101
|
-
errors: acc.errors + d.errors,
|
|
102
|
-
warnings: acc.warnings + d.warnings,
|
|
103
|
-
information: acc.information + d.information,
|
|
104
|
-
hints: acc.hints + d.hints,
|
|
105
|
-
}),
|
|
106
|
-
{ errors: 0, warnings: 0, information: 0, hints: 0 },
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const staleWarning = details?.staleWarning;
|
|
110
|
-
const collapsed = buildLspContextCollapsed(diagnostics, totals, staleWarning, theme);
|
|
111
|
-
const expandedDetails = expanded
|
|
112
|
-
? formatExpandedDetails(diagnostics, token, staleWarning, theme)
|
|
113
|
-
: "";
|
|
114
|
-
const fullText = expandedDetails ? `${collapsed}\n${expandedDetails}` : collapsed;
|
|
115
|
-
|
|
116
|
-
const box = new Box(1, 1, (t) => theme.bg("customMessageBg", t));
|
|
117
|
-
box.addChild(new Text(fullText, 0, 0));
|
|
118
|
-
return box;
|
|
119
|
-
});
|
|
120
|
-
}
|