@mrclrchtr/supi-code-intelligence 13.0.0 → 14.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/CHANGELOG.md +18 -0
- package/README.md +3 -3
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +59 -13
- package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
- package/node_modules/@mrclrchtr/supi-core/src/session.ts +2 -0
- package/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
- package/node_modules/@mrclrchtr/supi-core/src/spill.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/README.md +6 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +59 -13
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spill.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +14 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-typescript.ts +8 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +4 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +7 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +24 -8
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +64 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +27 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +16 -112
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +521 -83
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-symbol-collection.ts +163 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-symbol-row-limit.ts +72 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +36 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +59 -13
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spill.ts +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +2 -2
- package/package.json +5 -5
- package/src/analysis/health/server-status.ts +32 -9
- package/src/analysis/health/signals.ts +1 -0
- package/src/analysis/instruction-files.ts +11 -7
- package/src/analysis/search/exclusions.ts +18 -4
- package/src/analysis/target/file-outline-omissions.ts +17 -2
- package/src/analysis/target/symbol-selection.ts +100 -0
- package/src/analysis/target/symbol.ts +48 -8
- package/src/analysis/target/types.ts +8 -1
- package/src/app/app.ts +37 -21
- package/src/extension.ts +1 -2
- package/src/headless.ts +4 -2
- package/src/session/health-types.ts +2 -0
- package/src/session/orientation-types.ts +5 -0
- package/src/session/orientation-workflow.ts +13 -3
- package/src/session/target-workflow.ts +18 -12
- package/src/tool/code_find/render.ts +10 -11
- package/src/tool/code_find/result.ts +6 -1
- package/src/tool/code_graph/structured.ts +3 -0
- package/src/tool/code_health/markdown.ts +3 -1
- package/src/tool/code_health/structured-schema.ts +1 -0
- package/src/tool/code_health/structured.ts +2 -0
- package/src/tool/code_orientation/markdown.ts +6 -1
- package/src/tool/code_resolve/result.ts +2 -1
- package/src/tool/code_resolve/structured.ts +6 -1
- package/src/tool/result/candidate-selection.ts +17 -1
- package/src/ui/footer.ts +147 -42
- package/src/ui/status-overlay.ts +13 -8
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Side-run signal shared over `pi.events`.
|
|
2
|
+
//
|
|
3
|
+
// A side run is agent work whose result the session will not continue from,
|
|
4
|
+
// such as a run on a branch that is abandoned afterwards. Listeners use the
|
|
5
|
+
// signal to skip work tied to the run's result, for example prompt suggestions.
|
|
6
|
+
|
|
7
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
|
|
9
|
+
/** Event emitted on `pi.events` when a side run starts. Payload: {@link SideRunEvent}. */
|
|
10
|
+
export const SIDE_RUN_START_EVENT = "supi:side-run:start";
|
|
11
|
+
|
|
12
|
+
/** Event emitted on `pi.events` when a side run ends. Payload: {@link SideRunEvent}. */
|
|
13
|
+
export const SIDE_RUN_END_EVENT = "supi:side-run:end";
|
|
14
|
+
|
|
15
|
+
/** Payload of {@link SIDE_RUN_START_EVENT} and {@link SIDE_RUN_END_EVENT}. */
|
|
16
|
+
export interface SideRunEvent {
|
|
17
|
+
/** Emitting package, such as `supi-debug`. */
|
|
18
|
+
readonly source: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Run `run` as a side run: emit {@link SIDE_RUN_START_EVENT} before it and
|
|
23
|
+
* {@link SIDE_RUN_END_EVENT} after it, also when it throws.
|
|
24
|
+
*
|
|
25
|
+
* After a session replacement or reload the captured `pi` is stale and its
|
|
26
|
+
* `events.emit` throws. That end signal is dropped instead of masking the
|
|
27
|
+
* run's result; listeners reset their side-run state on `session_start` and
|
|
28
|
+
* `session_shutdown`.
|
|
29
|
+
*/
|
|
30
|
+
export async function runSideRun<T>(
|
|
31
|
+
pi: Pick<ExtensionAPI, "events">,
|
|
32
|
+
source: string,
|
|
33
|
+
run: () => Promise<T>,
|
|
34
|
+
): Promise<T> {
|
|
35
|
+
const payload: SideRunEvent = { source };
|
|
36
|
+
pi.events.emit(SIDE_RUN_START_EVENT, payload);
|
|
37
|
+
try {
|
|
38
|
+
return await run();
|
|
39
|
+
} finally {
|
|
40
|
+
try {
|
|
41
|
+
pi.events.emit(SIDE_RUN_END_EVENT, payload);
|
|
42
|
+
} catch {
|
|
43
|
+
// Stale extension instance after session replacement; see JSDoc.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -15,8 +15,8 @@ export interface SpillFileOptions {
|
|
|
15
15
|
owner: string;
|
|
16
16
|
/** Descriptive file name, e.g. `"snapshot.md"`. The content hash is inserted before the extension. */
|
|
17
17
|
name: string;
|
|
18
|
-
/** Full content to persist. */
|
|
19
|
-
content: string;
|
|
18
|
+
/** Full content to persist: text (written as UTF-8) or raw bytes. */
|
|
19
|
+
content: string | Uint8Array;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const SEGMENT = /^[a-z0-9][a-z0-9-]*$/;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-lsp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "Language Server Protocol runtime for SuPi code intelligence",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"vscode-jsonrpc": "10.0.0",
|
|
39
39
|
"vscode-languageserver-protocol": "3.18.5",
|
|
40
40
|
"vscode-languageserver-types": "3.18.5",
|
|
41
|
-
"@mrclrchtr/supi-
|
|
42
|
-
"@mrclrchtr/supi-
|
|
41
|
+
"@mrclrchtr/supi-code-runtime": "14.0.0",
|
|
42
|
+
"@mrclrchtr/supi-core": "14.0.0"
|
|
43
43
|
},
|
|
44
44
|
"bundledDependencies": [
|
|
45
45
|
"@mrclrchtr/supi-code-runtime",
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
9
9
|
import { fileToUri, uriToFile } from "@mrclrchtr/supi-core/path";
|
|
10
10
|
import type { TextDocumentIdentifier } from "../config/types.ts";
|
|
11
|
+
import type { RequestTimingBatch } from "../debug-telemetry.ts";
|
|
11
12
|
import {
|
|
12
13
|
type DiagnosticEvidenceSummary,
|
|
13
14
|
summarizeDiagnosticEvidence,
|
|
@@ -314,6 +315,7 @@ interface ClientDiagnosticRefreshOptions {
|
|
|
314
315
|
signal?: AbortSignal;
|
|
315
316
|
deadline?: number;
|
|
316
317
|
operationId?: string;
|
|
318
|
+
requestTimings?: RequestTimingBatch;
|
|
317
319
|
}) => Promise<boolean>;
|
|
318
320
|
readonly options: { maxWaitMs?: number; quietMs?: number } & CodeRequestControl;
|
|
319
321
|
/** Push-publication telemetry surface for this client. */
|
|
@@ -501,6 +503,7 @@ export async function refreshClientOpenDiagnostics(
|
|
|
501
503
|
synchronizations: requestSynchronizations,
|
|
502
504
|
syncStart,
|
|
503
505
|
maxWaitMs,
|
|
506
|
+
requestTimings: observer.requestTimings,
|
|
504
507
|
});
|
|
505
508
|
failedPullUris = new Set(request.failedPullUris);
|
|
506
509
|
const source = requestSourceFor(options.host, requestSynchronizations);
|
|
@@ -560,6 +563,7 @@ async function collectPullEvidenceForRefresh(options: {
|
|
|
560
563
|
synchronizations: readonly DiagnosticSynchronization[];
|
|
561
564
|
syncStart: number;
|
|
562
565
|
maxWaitMs: number;
|
|
566
|
+
requestTimings: RequestTimingBatch | undefined;
|
|
563
567
|
}): Promise<{ completed: boolean; failedPullUris: ReadonlySet<string>; timedOut: boolean }> {
|
|
564
568
|
const { options: refresh, synchronizations, syncStart, maxWaitMs } = options;
|
|
565
569
|
try {
|
|
@@ -577,6 +581,7 @@ async function collectPullEvidenceForRefresh(options: {
|
|
|
577
581
|
signal: pullOptions.signal,
|
|
578
582
|
deadline: pullOptions.deadline,
|
|
579
583
|
operationId: pullOptions.operationId,
|
|
584
|
+
requestTimings: options.requestTimings,
|
|
580
585
|
}),
|
|
581
586
|
});
|
|
582
587
|
const failedPullUris = new Set(result.failedUris);
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
throwIfCodeRequestInterrupted,
|
|
4
4
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
5
5
|
import type { DocumentDiagnosticReport } from "../config/types.ts";
|
|
6
|
+
import type { RequestTimingBatch } from "../debug-telemetry.ts";
|
|
6
7
|
import { raceRequestControl } from "../session/readiness.ts";
|
|
7
8
|
|
|
8
9
|
/** Evidence source used by an explicit diagnostic request. */
|
|
@@ -30,6 +31,8 @@ export interface DiagnosticPullRequest {
|
|
|
30
31
|
/** Adapter cancellation stops adapter work, not the owned transport. */
|
|
31
32
|
readonly signal?: AbortSignal;
|
|
32
33
|
readonly operationId?: string;
|
|
34
|
+
/** Batch that collects this request's completed protocol timings. */
|
|
35
|
+
readonly requestTimings?: RequestTimingBatch;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
/** Result returned by one request adapter. */
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
startDebugTimer,
|
|
4
4
|
truncateDebugIdentity as truncateIdentity,
|
|
5
5
|
} from "@mrclrchtr/supi-core/debug";
|
|
6
|
-
import { boundCwd } from "../debug-telemetry.ts";
|
|
6
|
+
import { boundCwd, RequestTimingBatch } from "../debug-telemetry.ts";
|
|
7
7
|
|
|
8
8
|
type DiagnosticCollection =
|
|
9
9
|
| "cache"
|
|
@@ -63,6 +63,12 @@ export interface DiagnosticTimingIdentity {
|
|
|
63
63
|
*/
|
|
64
64
|
export class DiagnosticObserver {
|
|
65
65
|
readonly #timer = startDebugTimer();
|
|
66
|
+
/**
|
|
67
|
+
* Completed protocol requests of a `refresh-open` pass. The pass sends one
|
|
68
|
+
* request per open document, so its event reports them as `requests` totals
|
|
69
|
+
* instead of one `request.timing` event each.
|
|
70
|
+
*/
|
|
71
|
+
readonly requestTimings: RequestTimingBatch | undefined;
|
|
66
72
|
#pull: "failed" | "not-supported" | "timed-out";
|
|
67
73
|
#requestSource: DiagnosticRequestSource | undefined;
|
|
68
74
|
#request: "failed" | "timed-out" | undefined;
|
|
@@ -74,6 +80,7 @@ export class DiagnosticObserver {
|
|
|
74
80
|
readonly identity?: DiagnosticTimingIdentity,
|
|
75
81
|
) {
|
|
76
82
|
this.#pull = hasDiagnosticRequestAdapter ? "failed" : "not-supported";
|
|
83
|
+
this.requestTimings = operation === "refresh-open" ? new RequestTimingBatch() : undefined;
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
synchronized(): void {
|
|
@@ -279,6 +286,7 @@ export class DiagnosticObserver {
|
|
|
279
286
|
data: {
|
|
280
287
|
operation: this.operation,
|
|
281
288
|
...data,
|
|
289
|
+
...requestTotals(this.requestTimings),
|
|
282
290
|
...(this.identity?.server !== undefined
|
|
283
291
|
? { server: truncateIdentity(this.identity.server) }
|
|
284
292
|
: {}),
|
|
@@ -292,6 +300,11 @@ export class DiagnosticObserver {
|
|
|
292
300
|
}
|
|
293
301
|
}
|
|
294
302
|
|
|
303
|
+
function requestTotals(batch: RequestTimingBatch | undefined): { requests?: object } {
|
|
304
|
+
const requests = batch?.snapshot();
|
|
305
|
+
return requests ? { requests } : {};
|
|
306
|
+
}
|
|
307
|
+
|
|
295
308
|
/** Return whether a diagnostic failure represents a timeout without retaining its message. */
|
|
296
309
|
export function isDiagnosticTimeout(error: unknown): boolean {
|
|
297
310
|
return error instanceof Error && /\btimed? ?out\b|\btimeout\b/i.test(error.message);
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
7
7
|
import { fileToUri, uriToFile } from "@mrclrchtr/supi-core/path";
|
|
8
8
|
import type { Diagnostic, Position } from "../config/types.ts";
|
|
9
|
+
import type { RequestTimingBatch } from "../debug-telemetry.ts";
|
|
9
10
|
import { raceRequestControl } from "../session/readiness.ts";
|
|
10
11
|
import type {
|
|
11
12
|
DiagnosticPullRequest,
|
|
@@ -38,7 +39,12 @@ export interface TypeScriptDiagnosticAdapterOptions {
|
|
|
38
39
|
readonly sendRequestOwned: (
|
|
39
40
|
method: string,
|
|
40
41
|
params: unknown,
|
|
41
|
-
options: {
|
|
42
|
+
options: {
|
|
43
|
+
timeoutMs: number;
|
|
44
|
+
deadline?: number;
|
|
45
|
+
operationId?: string;
|
|
46
|
+
requestTimings?: RequestTimingBatch;
|
|
47
|
+
},
|
|
42
48
|
) => OwnedRequest;
|
|
43
49
|
}
|
|
44
50
|
|
|
@@ -242,6 +248,7 @@ async function collectTypeScriptPhase(options: TypeScriptPhaseOptions): Promise<
|
|
|
242
248
|
timeoutMs: remaining,
|
|
243
249
|
deadline: collectionDeadline,
|
|
244
250
|
...(request.operationId !== undefined ? { operationId: request.operationId } : {}),
|
|
251
|
+
...(request.requestTimings ? { requestTimings: request.requestTimings } : {}),
|
|
245
252
|
},
|
|
246
253
|
);
|
|
247
254
|
options.setActiveSettled(execution.settled);
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
12
12
|
import { fileToUri, uriToFile } from "@mrclrchtr/supi-core/path";
|
|
13
13
|
import type { Diagnostic, TextDocumentItem } from "../config/types.ts";
|
|
14
|
+
import type { RequestTimingBatch } from "../debug-telemetry.ts";
|
|
14
15
|
import type { DiagnosticEvidenceSummary } from "../diagnostics/evidence.ts";
|
|
15
16
|
import { detectLanguageId } from "../utils.ts";
|
|
16
17
|
import { applyPushDiagnostics, buildClientDiagnosticSnapshot } from "./client-diagnostic-cache.ts";
|
|
@@ -722,6 +723,7 @@ export class ClientDiagnostics {
|
|
|
722
723
|
},
|
|
723
724
|
deadline: requestOptions.deadline,
|
|
724
725
|
operationId: requestOptions.operationId,
|
|
726
|
+
requestTimings: requestOptions.requestTimings,
|
|
725
727
|
}),
|
|
726
728
|
options,
|
|
727
729
|
publications: {
|
|
@@ -1082,6 +1084,7 @@ export class ClientDiagnostics {
|
|
|
1082
1084
|
control?: CodeRequestControl;
|
|
1083
1085
|
deadline?: number;
|
|
1084
1086
|
operationId?: string;
|
|
1087
|
+
requestTimings?: RequestTimingBatch;
|
|
1085
1088
|
}): Promise<boolean> {
|
|
1086
1089
|
const adapter = this.host.diagnosticRequestAdapter;
|
|
1087
1090
|
if (!adapter?.supports(options.request.uri)) return Promise.resolve(false);
|
|
@@ -1118,6 +1121,7 @@ export class ClientDiagnostics {
|
|
|
1118
1121
|
timeoutMs: ownerTimeoutMs,
|
|
1119
1122
|
signal: controller.signal,
|
|
1120
1123
|
operationId: options.operationId,
|
|
1124
|
+
requestTimings: options.requestTimings,
|
|
1121
1125
|
};
|
|
1122
1126
|
const execution = startDiagnosticEvidenceFromAdapter({
|
|
1123
1127
|
adapter,
|
|
@@ -4,7 +4,13 @@ import {
|
|
|
4
4
|
throwIfCodeRequestInterrupted,
|
|
5
5
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Waiting operations per client. First opens dispatch one at a time, so the
|
|
9
|
+
* bound limits memory for a stalled server, not server load. It must exceed
|
|
10
|
+
* the first opens of several concurrent tool calls: candidate lists open one
|
|
11
|
+
* file per candidate.
|
|
12
|
+
*/
|
|
13
|
+
export const MAX_PENDING_INPUT_OPERATIONS = 1024;
|
|
8
14
|
|
|
9
15
|
type InputOperationKind = "request" | "enrollment" | "request-enrollment";
|
|
10
16
|
|
|
@@ -1133,6 +1133,7 @@ export class LspClient {
|
|
|
1133
1133
|
timeoutMs: request.timeoutMs,
|
|
1134
1134
|
deadline: ownerDeadline,
|
|
1135
1135
|
...(request.operationId !== undefined ? { operationId: request.operationId } : {}),
|
|
1136
|
+
...(request.requestTimings ? { requestTimings: request.requestTimings } : {}),
|
|
1136
1137
|
},
|
|
1137
1138
|
);
|
|
1138
1139
|
activeSettled = owned.settled;
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
// and notification/request dispatching through vscode-jsonrpc's MessageConnection.
|
|
4
4
|
// biome-ignore-all lint/style/noExcessiveLinesPerFile: Transport lifetime and protocol handling stay together.
|
|
5
5
|
|
|
6
|
+
import { performance } from "node:perf_hooks";
|
|
6
7
|
import type { Readable, Writable } from "node:stream";
|
|
7
|
-
import {
|
|
8
|
-
type CodeRequestControl,
|
|
9
|
-
CodeRequestDeadlineError,
|
|
10
|
-
} from "@mrclrchtr/supi-code-runtime/api";
|
|
8
|
+
import { CodeRequestDeadlineError } from "@mrclrchtr/supi-code-runtime/api";
|
|
11
9
|
import {
|
|
12
10
|
startDebugTimer,
|
|
13
11
|
truncateDebugIdentity as truncateIdentity,
|
|
@@ -22,7 +20,11 @@ import {
|
|
|
22
20
|
StreamMessageReader,
|
|
23
21
|
StreamMessageWriter,
|
|
24
22
|
} from "vscode-jsonrpc/node";
|
|
25
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
type BatchedRequestControl,
|
|
25
|
+
boundCwd,
|
|
26
|
+
LSP_REQUEST_TIMEOUT_ERROR_CODE,
|
|
27
|
+
} from "../debug-telemetry.ts";
|
|
26
28
|
|
|
27
29
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
28
30
|
|
|
@@ -112,7 +114,7 @@ export class JsonRpcClient {
|
|
|
112
114
|
sendRequestOwned(
|
|
113
115
|
method: string,
|
|
114
116
|
params?: unknown,
|
|
115
|
-
options?: { timeoutMs?: number } &
|
|
117
|
+
options?: { timeoutMs?: number } & BatchedRequestControl,
|
|
116
118
|
): { result: Promise<unknown>; settled: Promise<void> } {
|
|
117
119
|
let settle!: () => void;
|
|
118
120
|
const settled = new Promise<void>((resolve) => {
|
|
@@ -133,12 +135,20 @@ export class JsonRpcClient {
|
|
|
133
135
|
return { result, settled };
|
|
134
136
|
}
|
|
135
137
|
|
|
136
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Send a request and wait for the correlated response, optionally overriding
|
|
140
|
+
* the timeout. With `requestTimings`, a completed request adds its duration
|
|
141
|
+
* to that batch instead of recording its own `request.timing` event.
|
|
142
|
+
*/
|
|
137
143
|
// biome-ignore lint/complexity/noExcessiveLinesPerFunction: Request timeout and cancellation races stay together.
|
|
138
144
|
sendRequest(
|
|
139
145
|
method: string,
|
|
140
146
|
params?: unknown,
|
|
141
|
-
options?: {
|
|
147
|
+
options?: {
|
|
148
|
+
timeoutMs?: number;
|
|
149
|
+
onSettled?: () => void;
|
|
150
|
+
owned?: boolean;
|
|
151
|
+
} & BatchedRequestControl,
|
|
142
152
|
): Promise<unknown> {
|
|
143
153
|
const timeoutMs = options?.timeoutMs ?? this.timeoutMs;
|
|
144
154
|
const owned = options?.owned === true;
|
|
@@ -147,6 +157,8 @@ export class JsonRpcClient {
|
|
|
147
157
|
const methodClass = classifyRequestMethod(method);
|
|
148
158
|
const boundedMethod = truncateIdentity(method);
|
|
149
159
|
const timer = startDebugTimer();
|
|
160
|
+
const requestTimings = timer.enabled ? options?.requestTimings : undefined;
|
|
161
|
+
const startedAt = requestTimings ? performance.now() : 0;
|
|
150
162
|
// A request cancelled before dispatch must not produce protocol traffic.
|
|
151
163
|
if (signal?.aborted) {
|
|
152
164
|
const result = rejectUndispatchedRequest(
|
|
@@ -259,6 +271,10 @@ export class JsonRpcClient {
|
|
|
259
271
|
])
|
|
260
272
|
.then(
|
|
261
273
|
(result) => {
|
|
274
|
+
if (requestTimings) {
|
|
275
|
+
requestTimings.add(boundedMethod, performance.now() - startedAt);
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
262
278
|
recordRequestTiming(
|
|
263
279
|
timer,
|
|
264
280
|
options?.operationId,
|
|
@@ -70,6 +70,11 @@ export interface ProjectServerInfo extends DetectedProjectServer {
|
|
|
70
70
|
openFiles: string[];
|
|
71
71
|
/** Whether the LSP server is currently not indexing and ready to serve queries. */
|
|
72
72
|
ready: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Present while the background warm-up loads the route's projects. The route
|
|
75
|
+
* answers queries; a symbol query waits for the pass.
|
|
76
|
+
*/
|
|
77
|
+
loadingProjects?: true;
|
|
73
78
|
/** Negotiated operation support, when the route has a capability snapshot. */
|
|
74
79
|
operationSupport?: ServerOperationSupportMap;
|
|
75
80
|
}
|
|
@@ -177,6 +177,9 @@ export function projectConfigIncludesFile(configPath: string, filePath: string):
|
|
|
177
177
|
return parsed !== null && decideFileScope(parsed, path.resolve(filePath)).included;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
/** Normalized paths of the files in a project config's program; undefined when it cannot be parsed. */
|
|
181
|
+
export const projectFileNames = (config: string) => parseProjectConfig(config)?.fileNames;
|
|
182
|
+
|
|
180
183
|
function isOutOfTree(cwd: string, absolutePath: string): boolean {
|
|
181
184
|
const relative = path.relative(path.resolve(cwd), absolutePath);
|
|
182
185
|
return relative.startsWith(`..${path.sep}`) || relative === "..";
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// identity for local protocol diagnosis. Each identity string and list uses
|
|
5
5
|
// the shared bounds.
|
|
6
6
|
|
|
7
|
+
import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
|
|
7
8
|
import { truncateDebugIdentity } from "@mrclrchtr/supi-core/debug";
|
|
8
9
|
|
|
9
10
|
/** Maximum number of server entries in one bounded LSP debug payload. */
|
|
@@ -29,3 +30,66 @@ export function boundCwd(cwd: string | undefined): string | undefined {
|
|
|
29
30
|
export function boundServerNames(names: readonly string[]): string[] {
|
|
30
31
|
return names.slice(0, MAX_SERVERS).map(truncateDebugIdentity);
|
|
31
32
|
}
|
|
33
|
+
|
|
34
|
+
/** Maximum number of distinct methods one batch reports by name. */
|
|
35
|
+
const MAX_BATCH_METHODS = 16;
|
|
36
|
+
const OTHER_BATCH_METHODS = "other";
|
|
37
|
+
|
|
38
|
+
/** Completed-request totals for one method of a batch operation. */
|
|
39
|
+
export interface RequestTimingTotals {
|
|
40
|
+
readonly count: number;
|
|
41
|
+
readonly totalMs: number;
|
|
42
|
+
readonly maxMs: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Completed-request timings of one batch operation, such as a diagnostic
|
|
47
|
+
* refresh over every open document or a workspace-symbol warm-up pass.
|
|
48
|
+
*
|
|
49
|
+
* A batch sends one request per document. Recording each as its own
|
|
50
|
+
* `request.timing` event fills the Debug buffer with near-identical events, so
|
|
51
|
+
* the transport adds completed requests here instead and the batch's summary
|
|
52
|
+
* event reports them through `snapshot()`. Failed, timed-out, and cancelled
|
|
53
|
+
* requests still record their own event. A request that completes after its
|
|
54
|
+
* batch reported is not recorded.
|
|
55
|
+
*/
|
|
56
|
+
export class RequestTimingBatch {
|
|
57
|
+
readonly #methods = new Map<string, { count: number; totalMs: number; maxMs: number }>();
|
|
58
|
+
|
|
59
|
+
/** Add one completed request. */
|
|
60
|
+
add(method: string, durationMs: number): void {
|
|
61
|
+
const known = this.#methods.has(method) || this.#methods.size < MAX_BATCH_METHODS;
|
|
62
|
+
const key = known ? method : OTHER_BATCH_METHODS;
|
|
63
|
+
const totals = this.#methods.get(key) ?? { count: 0, totalMs: 0, maxMs: 0 };
|
|
64
|
+
const elapsed = Number.isFinite(durationMs) ? Math.max(0, durationMs) : 0;
|
|
65
|
+
totals.count++;
|
|
66
|
+
totals.totalMs += elapsed;
|
|
67
|
+
totals.maxMs = Math.max(totals.maxMs, elapsed);
|
|
68
|
+
this.#methods.set(key, totals);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Totals by method, or `undefined` when no request completed. */
|
|
72
|
+
snapshot(): Record<string, RequestTimingTotals> | undefined {
|
|
73
|
+
if (this.#methods.size === 0) return undefined;
|
|
74
|
+
return Object.fromEntries(
|
|
75
|
+
Array.from(this.#methods, ([method, totals]) => [
|
|
76
|
+
method,
|
|
77
|
+
{
|
|
78
|
+
count: totals.count,
|
|
79
|
+
totalMs: roundDuration(totals.totalMs),
|
|
80
|
+
maxMs: roundDuration(totals.maxMs),
|
|
81
|
+
},
|
|
82
|
+
]),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Request control that also routes completed-request timings into a batch. */
|
|
88
|
+
export interface BatchedRequestControl extends CodeRequestControl {
|
|
89
|
+
/** Collects completed request timings instead of one event per request. */
|
|
90
|
+
readonly requestTimings?: RequestTimingBatch;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function roundDuration(value: number): number {
|
|
94
|
+
return Math.round(value * 10) / 10;
|
|
95
|
+
}
|
|
@@ -16,6 +16,8 @@ interface ProjectServerInfoInput {
|
|
|
16
16
|
statusReason?: ProjectServerStatusReason;
|
|
17
17
|
typescript?: TypeScriptSelection;
|
|
18
18
|
failureMessage?: string;
|
|
19
|
+
/** The background warm-up is loading this route's projects. */
|
|
20
|
+
loadingProjects?: boolean;
|
|
19
21
|
/** Filter files from ambient project status without changing explicit routing. */
|
|
20
22
|
includeOpenFile?: (file: string) => boolean;
|
|
21
23
|
}
|
|
@@ -51,6 +53,7 @@ export function buildProjectServerInfo(
|
|
|
51
53
|
.filter((file) => input.includeOpenFile?.(file) ?? true)
|
|
52
54
|
.map((file) => displayRelativeFilePath(file, cwd)) ?? [],
|
|
53
55
|
ready: input.client?.ready ?? false,
|
|
56
|
+
...(input.loadingProjects ? { loadingProjects: true as const } : {}),
|
|
54
57
|
operationSupport: getServerOperationSupport(input.client?.serverCapabilities ?? null),
|
|
55
58
|
};
|
|
56
59
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import { collectExtendedProjectConfigs } from "../config/tsconfig-extends.ts";
|
|
3
3
|
import { normalizeTsconfigPath } from "../config/tsconfig-path.ts";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getFileScopeDecision,
|
|
6
|
+
projectConfigIncludesFile,
|
|
7
|
+
projectFileNames,
|
|
8
|
+
} from "../config/tsconfig-scope.ts";
|
|
5
9
|
import { type AutomaticLspPathPolicy, walkAutomaticLspTree } from "../workspace-path-policy.ts";
|
|
6
10
|
|
|
7
11
|
/** Directory depth searched for project configs below a TypeScript route root. */
|
|
@@ -43,6 +47,9 @@ export function discoverTypeScriptProjectConfigs(
|
|
|
43
47
|
* Base configs extended by another discovered config are skipped: their
|
|
44
48
|
* default include usually spans the whole tree while they own only root
|
|
45
49
|
* tooling files, so counting them would mark nearly every answer partial.
|
|
50
|
+
*
|
|
51
|
+
* Projects that own no file are skipped too: their program holds only files of
|
|
52
|
+
* other projects, and no open file or answer could ever show them as loaded.
|
|
46
53
|
*/
|
|
47
54
|
export function findUnloadedTypeScriptProjects(options: {
|
|
48
55
|
readonly file: string;
|
|
@@ -64,11 +71,29 @@ export function findUnloadedTypeScriptProjects(options: {
|
|
|
64
71
|
return options.configs.filter((config) => {
|
|
65
72
|
const key = normalizeTsconfigPath(config);
|
|
66
73
|
return (
|
|
67
|
-
!loaded.has(key) &&
|
|
74
|
+
!loaded.has(key) &&
|
|
75
|
+
!baseConfigs.has(key) &&
|
|
76
|
+
projectConfigIncludesFile(config, options.file) &&
|
|
77
|
+
ownsProgramFile(config, options.cwd)
|
|
68
78
|
);
|
|
69
79
|
});
|
|
70
80
|
}
|
|
71
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Whether a project config is the nearest config of a file in its own program.
|
|
84
|
+
* A test config that includes `../src` before any test exists owns none.
|
|
85
|
+
*/
|
|
86
|
+
function ownsProgramFile(config: string, cwd: string): boolean {
|
|
87
|
+
const key = normalizeTsconfigPath(config);
|
|
88
|
+
// Program file names are normalized, so the tree root must be too.
|
|
89
|
+
const root = normalizeTsconfigPath(cwd);
|
|
90
|
+
for (const file of projectFileNames(config) ?? []) {
|
|
91
|
+
const nearest = getFileScopeDecision(file, root).configPath;
|
|
92
|
+
if (nearest && normalizeTsconfigPath(nearest) === key) return true;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
72
97
|
/**
|
|
73
98
|
* Other projects that tsserver's implementation search skips for `file`.
|
|
74
99
|
*
|