@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,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CodeQueryPartialMetadata,
|
|
3
|
+
type CodeQueryResult,
|
|
4
|
+
type CodeRequestControl,
|
|
5
|
+
completedCodeQuery,
|
|
6
|
+
partialCodeQuery,
|
|
7
|
+
unavailableCodeQuery,
|
|
8
|
+
} from "@mrclrchtr/supi-code-runtime/api";
|
|
9
|
+
import type { LspClient } from "../client/client.ts";
|
|
10
|
+
import type { SymbolInformation, WorkspaceSymbol } from "../config/types.ts";
|
|
11
|
+
import { nativeTypeScriptRowLimit } from "./workspace-symbol-row-limit.ts";
|
|
12
|
+
|
|
13
|
+
type WorkspaceSymbolLike = SymbolInformation | WorkspaceSymbol;
|
|
14
|
+
|
|
15
|
+
export interface WorkspaceSymbolCollection {
|
|
16
|
+
results: WorkspaceSymbolLike[];
|
|
17
|
+
hasSupport: boolean;
|
|
18
|
+
completedClientCount: number;
|
|
19
|
+
failures: string[];
|
|
20
|
+
/** Results removed by the automatic path policy. */
|
|
21
|
+
excludedCount?: number;
|
|
22
|
+
/** Bounded paths removed by the automatic path policy. */
|
|
23
|
+
excludedExamples?: string[];
|
|
24
|
+
/** Known coverage limits: the server may not have loaded every project in scope. */
|
|
25
|
+
coverageGap?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Row-limit reasons whose cut answers still hold every exact-name declaration.
|
|
28
|
+
* Unlike `failures`, they leave exact-name selection sound.
|
|
29
|
+
*/
|
|
30
|
+
exactNameLimits?: string[];
|
|
31
|
+
/** At least one client's answer was cut at its row limit. */
|
|
32
|
+
rowLimited?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Mark a collection whose warm-up never reached a configured project.
|
|
37
|
+
* The server answered only from inferred projects of the opened probe files,
|
|
38
|
+
* so an empty or short result does not prove a symbol is absent.
|
|
39
|
+
*/
|
|
40
|
+
export function workspaceSymbolCoverageGap(
|
|
41
|
+
collection: WorkspaceSymbolCollection,
|
|
42
|
+
inferredProbeCount: number,
|
|
43
|
+
): WorkspaceSymbolCollection {
|
|
44
|
+
const noun = `file${inferredProbeCount === 1 ? "" : "s"}`;
|
|
45
|
+
return {
|
|
46
|
+
...collection,
|
|
47
|
+
coverageGap:
|
|
48
|
+
`Workspace-symbol coverage is limited: ${inferredProbeCount} opened warm-up ${noun} ` +
|
|
49
|
+
"loaded only inferred projects, not a configured project. Open a project source file and retry.",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Collect workspace symbols from every running client that supports them.
|
|
55
|
+
*
|
|
56
|
+
* @param scoped - the caller already limits results to a scope, so the
|
|
57
|
+
* row-limit advice must not suggest adding one.
|
|
58
|
+
*/
|
|
59
|
+
export async function collectWorkspaceSymbols(
|
|
60
|
+
clients: Iterable<LspClient>,
|
|
61
|
+
query: string,
|
|
62
|
+
control?: CodeRequestControl,
|
|
63
|
+
scoped = false,
|
|
64
|
+
): Promise<WorkspaceSymbolCollection> {
|
|
65
|
+
const results: WorkspaceSymbolLike[] = [];
|
|
66
|
+
const failures: string[] = [];
|
|
67
|
+
const exactNameLimits: string[] = [];
|
|
68
|
+
let rowLimited = false;
|
|
69
|
+
let hasSupport = false;
|
|
70
|
+
let completedClientCount = 0;
|
|
71
|
+
|
|
72
|
+
for (const client of clients) {
|
|
73
|
+
if (client.status !== "running" || !client.serverCapabilities?.workspaceSymbolProvider) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
hasSupport = true;
|
|
77
|
+
const result = await client.workspaceSymbol(query, control);
|
|
78
|
+
if (result.kind === "unavailable") {
|
|
79
|
+
failures.push(result.reason);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
completedClientCount++;
|
|
83
|
+
const rows = result.data ?? [];
|
|
84
|
+
results.push(...rows);
|
|
85
|
+
if (result.kind === "partial") failures.push(result.reason);
|
|
86
|
+
const limit = nativeTypeScriptRowLimit(client, rows, query, scoped);
|
|
87
|
+
rowLimited ||= limit !== null;
|
|
88
|
+
if (limit?.exactNamesComplete) exactNameLimits.push(limit.reason);
|
|
89
|
+
else if (limit) failures.push(limit.reason);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
results,
|
|
94
|
+
hasSupport,
|
|
95
|
+
completedClientCount,
|
|
96
|
+
failures,
|
|
97
|
+
...(exactNameLimits.length > 0 ? { exactNameLimits } : {}),
|
|
98
|
+
...(rowLimited ? { rowLimited } : {}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Join partial-result reasons into one message. A reason that already ends a
|
|
104
|
+
* sentence is followed by a space, so the message never reads `.;`.
|
|
105
|
+
*/
|
|
106
|
+
export function joinWorkspaceSymbolReasons(
|
|
107
|
+
reasons: readonly (string | null | undefined)[],
|
|
108
|
+
): string {
|
|
109
|
+
return reasons
|
|
110
|
+
.filter((reason): reason is string => Boolean(reason))
|
|
111
|
+
.reduce((joined, reason) => {
|
|
112
|
+
if (!joined) return reason;
|
|
113
|
+
return `${joined}${/[.!?]$/.test(joined) ? " " : "; "}${reason}`;
|
|
114
|
+
}, "");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function workspaceSymbolExclusionReason(collection: WorkspaceSymbolCollection): string | null {
|
|
118
|
+
const excludedCount = collection.excludedCount ?? 0;
|
|
119
|
+
if (excludedCount === 0) return null;
|
|
120
|
+
const noun = `workspace-symbol result${excludedCount === 1 ? "" : "s"}`;
|
|
121
|
+
// Paths belong to typed metadata so consumers can distinguish observed aliases from navigation.
|
|
122
|
+
return `Automatic path policy excluded ${excludedCount} ${noun}.`;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Project one multi-client collection into the shared typed query contract. */
|
|
126
|
+
export function workspaceSymbolCollectionResult(
|
|
127
|
+
collection: WorkspaceSymbolCollection,
|
|
128
|
+
): CodeQueryResult<WorkspaceSymbolLike[]> {
|
|
129
|
+
if (!collection.hasSupport) {
|
|
130
|
+
return unavailableCodeQuery("No active LSP client supports workspace-symbol requests.");
|
|
131
|
+
}
|
|
132
|
+
if (collection.completedClientCount === 0) {
|
|
133
|
+
return unavailableCodeQuery(
|
|
134
|
+
joinWorkspaceSymbolReasons(collection.failures) || "No workspace-symbol request completed.",
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
const exclusion = workspaceSymbolExclusionReason(collection);
|
|
138
|
+
const exactNameLimits = collection.exactNameLimits ?? [];
|
|
139
|
+
const reason = joinWorkspaceSymbolReasons([
|
|
140
|
+
...collection.failures,
|
|
141
|
+
...exactNameLimits,
|
|
142
|
+
collection.coverageGap,
|
|
143
|
+
exclusion,
|
|
144
|
+
]);
|
|
145
|
+
if (!reason) return completedCodeQuery(collection.results);
|
|
146
|
+
// Without failures or coverage gaps, the remaining reasons keep in-scope selection sound.
|
|
147
|
+
const sound = collection.failures.length === 0 && !collection.coverageGap;
|
|
148
|
+
const excludedCount = collection.excludedCount ?? 0;
|
|
149
|
+
const metadata: CodeQueryPartialMetadata = {
|
|
150
|
+
...(excludedCount > 0 && {
|
|
151
|
+
automaticPathExclusion: { excludedCount, examples: [...(collection.excludedExamples ?? [])] },
|
|
152
|
+
}),
|
|
153
|
+
...(collection.rowLimited && {
|
|
154
|
+
rowLimit: { exactNamesComplete: sound && exactNameLimits.length > 0 },
|
|
155
|
+
}),
|
|
156
|
+
...(sound && exactNameLimits.length === 0 && { exclusionOnly: true }),
|
|
157
|
+
};
|
|
158
|
+
return partialCodeQuery(
|
|
159
|
+
collection.results,
|
|
160
|
+
reason,
|
|
161
|
+
Object.keys(metadata).length > 0 ? metadata : undefined,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { LspClient } from "../client/client.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rows the native TypeScript server returns at most per query; it sorts by match
|
|
5
|
+
* quality and drops the rest. tsserver behind typescript-language-server has no limit.
|
|
6
|
+
*
|
|
7
|
+
* A cut answer has exactly this many rows. Newer servers skip rows whose name has no
|
|
8
|
+
* single-segment source mapping, which only content-mapped files produce; content
|
|
9
|
+
* mappers need `--runExternalCode`, which the automatic launch does not pass.
|
|
10
|
+
*/
|
|
11
|
+
const NATIVE_TYPESCRIPT_WORKSPACE_SYMBOL_LIMIT = 256;
|
|
12
|
+
|
|
13
|
+
/** A TypeScript answer that may be cut at the native server's row limit. */
|
|
14
|
+
export interface WorkspaceSymbolRowLimit {
|
|
15
|
+
readonly reason: string;
|
|
16
|
+
/**
|
|
17
|
+
* The cut answer still holds every declaration whose name equals the query
|
|
18
|
+
* (ignoring case), so only partial-name matches may be missing.
|
|
19
|
+
*/
|
|
20
|
+
readonly exactNamesComplete: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Describe a TypeScript answer that may be cut at the native server's row limit,
|
|
25
|
+
* or `null` when it is not. An unknown backend (manual launch) counts as possibly
|
|
26
|
+
* native; more rows than the limit prove it is not.
|
|
27
|
+
*/
|
|
28
|
+
export function nativeTypeScriptRowLimit(
|
|
29
|
+
client: LspClient,
|
|
30
|
+
rows: readonly { readonly name: string }[],
|
|
31
|
+
query: string,
|
|
32
|
+
scoped: boolean,
|
|
33
|
+
): WorkspaceSymbolRowLimit | null {
|
|
34
|
+
if (
|
|
35
|
+
client.name !== "typescript" ||
|
|
36
|
+
client.typescriptSelection?.backend === "tsserver" ||
|
|
37
|
+
rows.length !== NATIVE_TYPESCRIPT_WORKSPACE_SYMBOL_LIMIT
|
|
38
|
+
) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const prefix = `The TypeScript server returned its limit of ${NATIVE_TYPESCRIPT_WORKSPACE_SYMBOL_LIMIT} workspace symbols`;
|
|
42
|
+
if (exactNamesFirst(rows, query)) {
|
|
43
|
+
return {
|
|
44
|
+
reason: `${prefix}; it includes every declaration named \`${query}\`, but more partial-name matches may exist.`,
|
|
45
|
+
exactNamesComplete: true,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// The limit applies before scope filtering, so a scope cannot be narrowed around it.
|
|
49
|
+
const next = scoped
|
|
50
|
+
? "Use a more specific query, or pass an anchor target (file, line, character)."
|
|
51
|
+
: "Use a more specific query or a scope.";
|
|
52
|
+
return {
|
|
53
|
+
reason: `${prefix}; more matches may exist. ${next}`,
|
|
54
|
+
exactNamesComplete: false,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* True when the cut answer provably holds every name equal to the query.
|
|
60
|
+
*
|
|
61
|
+
* typescript-go (`internal/ls/symbols.go`) sorts by match score, then by
|
|
62
|
+
* case-insensitive name, before it cuts. A name equal to the query scores 0 and
|
|
63
|
+
* sorts before every longer score-0 name, which starts with the query. So when
|
|
64
|
+
* all equal names lead the answer and the last row differs, none were cut. An
|
|
65
|
+
* answer in another order proves nothing.
|
|
66
|
+
*/
|
|
67
|
+
function exactNamesFirst(rows: readonly { readonly name: string }[], query: string): boolean {
|
|
68
|
+
const folded = query.toLowerCase();
|
|
69
|
+
const equal = (row: { readonly name: string }) => row.name.toLowerCase() === folded;
|
|
70
|
+
const firstOther = rows.findIndex((row) => !equal(row));
|
|
71
|
+
return firstOther >= 0 && !rows.slice(firstOther).some(equal);
|
|
72
|
+
}
|
|
@@ -210,6 +210,14 @@ export class LspRuntimeController {
|
|
|
210
210
|
this.#capabilityRuntime = runtime;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Latest published aggregate transition, including transitions published while pending.
|
|
215
|
+
* Read this snapshot instead of recomputing project-server status on every render.
|
|
216
|
+
*/
|
|
217
|
+
get latestLifecycleTransition(): LspRuntimeTransition | null {
|
|
218
|
+
return this.#latestLifecycleTransition;
|
|
219
|
+
}
|
|
220
|
+
|
|
213
221
|
/**
|
|
214
222
|
* Subscribe to aggregate runtime transitions.
|
|
215
223
|
*
|
|
@@ -367,6 +375,9 @@ export class LspRuntimeController {
|
|
|
367
375
|
return supersededStartResult();
|
|
368
376
|
}
|
|
369
377
|
|
|
378
|
+
// Not awaited: the pass loads TypeScript projects for the first symbol query.
|
|
379
|
+
void manager.startWorkspaceSymbolWarmup();
|
|
380
|
+
|
|
370
381
|
const runtimeOwner = createWorkspaceLspRuntimeOwner(manager);
|
|
371
382
|
const workspaceRuntime = runtimeOwner.runtime;
|
|
372
383
|
setWorkspaceLspRuntimeState(this.#cwd, { kind: "ready", runtime: workspaceRuntime });
|
|
@@ -114,8 +114,17 @@ function isRange(value: Position | Range): value is Range {
|
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
/** Name the open failure when a route exists; otherwise report the missing route. */
|
|
118
|
+
function unavailableFileQuery<T>(
|
|
119
|
+
operation: string,
|
|
120
|
+
file: string,
|
|
121
|
+
openFailure?: string,
|
|
122
|
+
): CodeQueryResult<T> {
|
|
123
|
+
return unavailableCodeQuery(
|
|
124
|
+
openFailure
|
|
125
|
+
? `LSP could not open ${file} for ${operation}: ${openFailure}`
|
|
126
|
+
: `No routed LSP client could complete ${operation} for ${file}.`,
|
|
127
|
+
);
|
|
119
128
|
}
|
|
120
129
|
|
|
121
130
|
function hasProcessCrashRecovery(report: ProcessCrashRecoveryReport): boolean {
|
|
@@ -172,12 +181,16 @@ class DefaultWorkspaceLspRuntime implements WorkspaceLspRuntime {
|
|
|
172
181
|
control?: CodeRequestControl,
|
|
173
182
|
): Promise<CodeQueryResult<Hover | null>> {
|
|
174
183
|
const resolvedPath = this.resolveFilePath(filePath);
|
|
184
|
+
let openFailure: string | undefined;
|
|
175
185
|
const client = await this.manager.ensureFileOpen(resolvedPath, {
|
|
176
186
|
recoverProcessCrash: true,
|
|
177
187
|
protectInputs: true,
|
|
178
188
|
control,
|
|
189
|
+
onOpenFailure: (reason) => {
|
|
190
|
+
openFailure = reason;
|
|
191
|
+
},
|
|
179
192
|
});
|
|
180
|
-
if (!client) return unavailableFileQuery("hover", resolvedPath);
|
|
193
|
+
if (!client) return unavailableFileQuery("hover", resolvedPath, openFailure);
|
|
181
194
|
return client.hover(resolvedPath, position, control);
|
|
182
195
|
}
|
|
183
196
|
|
|
@@ -187,12 +200,16 @@ class DefaultWorkspaceLspRuntime implements WorkspaceLspRuntime {
|
|
|
187
200
|
control?: CodeRequestControl,
|
|
188
201
|
): Promise<CodeQueryResult<Location | Location[] | LocationLink[] | null>> {
|
|
189
202
|
const resolvedPath = this.resolveFilePath(filePath);
|
|
203
|
+
let openFailure: string | undefined;
|
|
190
204
|
const client = await this.manager.ensureFileOpen(resolvedPath, {
|
|
191
205
|
recoverProcessCrash: true,
|
|
192
206
|
protectInputs: true,
|
|
193
207
|
control,
|
|
208
|
+
onOpenFailure: (reason) => {
|
|
209
|
+
openFailure = reason;
|
|
210
|
+
},
|
|
194
211
|
});
|
|
195
|
-
if (!client) return unavailableFileQuery("definition", resolvedPath);
|
|
212
|
+
if (!client) return unavailableFileQuery("definition", resolvedPath, openFailure);
|
|
196
213
|
return client.definition(resolvedPath, position, control);
|
|
197
214
|
}
|
|
198
215
|
|
|
@@ -202,12 +219,16 @@ class DefaultWorkspaceLspRuntime implements WorkspaceLspRuntime {
|
|
|
202
219
|
control?: CodeRequestControl,
|
|
203
220
|
): Promise<CodeQueryResult<Location[]>> {
|
|
204
221
|
const resolvedPath = this.resolveFilePath(filePath);
|
|
222
|
+
let openFailure: string | undefined;
|
|
205
223
|
const client = await this.manager.ensureFileOpen(resolvedPath, {
|
|
206
224
|
recoverProcessCrash: true,
|
|
207
225
|
protectInputs: true,
|
|
208
226
|
control,
|
|
227
|
+
onOpenFailure: (reason) => {
|
|
228
|
+
openFailure = reason;
|
|
229
|
+
},
|
|
209
230
|
});
|
|
210
|
-
if (!client) return unavailableFileQuery("references", resolvedPath);
|
|
231
|
+
if (!client) return unavailableFileQuery("references", resolvedPath, openFailure);
|
|
211
232
|
return this.withProjectCoverage(
|
|
212
233
|
client,
|
|
213
234
|
{ file: resolvedPath, position },
|
|
@@ -225,12 +246,16 @@ class DefaultWorkspaceLspRuntime implements WorkspaceLspRuntime {
|
|
|
225
246
|
control?: CodeRequestControl,
|
|
226
247
|
): Promise<CodeQueryResult<Location | Location[] | LocationLink[] | null>> {
|
|
227
248
|
const resolvedPath = this.resolveFilePath(filePath);
|
|
249
|
+
let openFailure: string | undefined;
|
|
228
250
|
const client = await this.manager.ensureFileOpen(resolvedPath, {
|
|
229
251
|
recoverProcessCrash: true,
|
|
230
252
|
protectInputs: true,
|
|
231
253
|
control,
|
|
254
|
+
onOpenFailure: (reason) => {
|
|
255
|
+
openFailure = reason;
|
|
256
|
+
},
|
|
232
257
|
});
|
|
233
|
-
if (!client) return unavailableFileQuery("implementation", resolvedPath);
|
|
258
|
+
if (!client) return unavailableFileQuery("implementation", resolvedPath, openFailure);
|
|
234
259
|
return this.withProjectCoverage(
|
|
235
260
|
client,
|
|
236
261
|
{ file: resolvedPath, position },
|
|
@@ -262,12 +287,16 @@ class DefaultWorkspaceLspRuntime implements WorkspaceLspRuntime {
|
|
|
262
287
|
control?: CodeRequestControl,
|
|
263
288
|
): Promise<CodeQueryResult<DocumentSymbol[] | SymbolInformation[]>> {
|
|
264
289
|
const resolvedPath = this.resolveFilePath(filePath);
|
|
290
|
+
let openFailure: string | undefined;
|
|
265
291
|
const client = await this.manager.ensureFileOpen(resolvedPath, {
|
|
266
292
|
recoverProcessCrash: true,
|
|
267
293
|
protectInputs: true,
|
|
268
294
|
control,
|
|
295
|
+
onOpenFailure: (reason) => {
|
|
296
|
+
openFailure = reason;
|
|
297
|
+
},
|
|
269
298
|
});
|
|
270
|
-
if (!client) return unavailableFileQuery("document symbols", resolvedPath);
|
|
299
|
+
if (!client) return unavailableFileQuery("document symbols", resolvedPath, openFailure);
|
|
271
300
|
return mapCodeQueryResult(
|
|
272
301
|
await client.documentSymbols(resolvedPath, control),
|
|
273
302
|
(data) => data ?? [],
|
|
@@ -14,6 +14,16 @@ export interface CodeQueryPartialMetadata {
|
|
|
14
14
|
* answer.
|
|
15
15
|
*/
|
|
16
16
|
readonly exclusionOnly?: boolean;
|
|
17
|
+
/** A provider cut its answer at a row limit; a narrower scope cannot avoid it. */
|
|
18
|
+
readonly rowLimit?: {
|
|
19
|
+
/**
|
|
20
|
+
* True when every declaration whose name equals the query is still in the
|
|
21
|
+
* result, though partial-name matches may be missing: the provider sorted
|
|
22
|
+
* exact names first. Set only when no provider failed and no coverage gap
|
|
23
|
+
* was observed, so exact-name selection stays sound.
|
|
24
|
+
*/
|
|
25
|
+
readonly exactNamesComplete: boolean;
|
|
26
|
+
};
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
/**
|
|
@@ -16,7 +16,10 @@ export interface DebugRegistryConfig {
|
|
|
16
16
|
agentAccess: DebugAgentAccess;
|
|
17
17
|
/** Whether Agent Run retrospective capture is explicitly enabled. */
|
|
18
18
|
agentRunRetrospectivesEnabled: boolean;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Maximum number of session-local events to keep in memory. `debug` events
|
|
21
|
+
* are evicted first; higher levels keep at most half of the buffer.
|
|
22
|
+
*/
|
|
20
23
|
maxEvents: number;
|
|
21
24
|
/**
|
|
22
25
|
* Minimum level forwarded to persistence sinks. Lower-level events stay in the
|
|
@@ -146,12 +149,51 @@ function normalizeMaxEvents(value: number): number {
|
|
|
146
149
|
return Math.floor(value);
|
|
147
150
|
}
|
|
148
151
|
|
|
152
|
+
function isSummary(event: DebugEvent): boolean {
|
|
153
|
+
return event.level !== "debug";
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function groupKey(event: DebugEvent): string {
|
|
157
|
+
return `${event.source}\u0000${event.category}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Return the index of the oldest event in the largest source/category group of
|
|
162
|
+
* one tier, so a high-volume category evicts its own events before rare ones.
|
|
163
|
+
*/
|
|
164
|
+
function evictionIndex(events: readonly DebugEvent[], summaryTier: boolean): number {
|
|
165
|
+
const counts = new Map<string, number>();
|
|
166
|
+
let largest = 0;
|
|
167
|
+
for (const event of events) {
|
|
168
|
+
if (isSummary(event) !== summaryTier) continue;
|
|
169
|
+
const key = groupKey(event);
|
|
170
|
+
const count = (counts.get(key) ?? 0) + 1;
|
|
171
|
+
counts.set(key, count);
|
|
172
|
+
largest = Math.max(largest, count);
|
|
173
|
+
}
|
|
174
|
+
return events.findIndex(
|
|
175
|
+
(event) => isSummary(event) === summaryTier && counts.get(groupKey(event)) === largest,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Evict down to `maxEvents`. A `debug` event goes first, so high-volume
|
|
181
|
+
* timings cannot push out a summary recorded moments earlier. Higher-level
|
|
182
|
+
* events keep at most half the buffer; past that one of them goes instead, so
|
|
183
|
+
* recent `debug` events stay visible too. Within the chosen tier, the oldest
|
|
184
|
+
* event of the largest source/category group goes, so one flooding category
|
|
185
|
+
* such as `request.timing` cannot push out every other category.
|
|
186
|
+
*/
|
|
149
187
|
function trimToMaxEvents(state: DebugRegistryState): void {
|
|
150
188
|
const maxEvents = normalizeMaxEvents(state.config.maxEvents);
|
|
151
|
-
|
|
152
|
-
|
|
189
|
+
const summaryShare = Math.floor(maxEvents / 2);
|
|
190
|
+
let summaries = state.events.filter(isSummary).length;
|
|
191
|
+
while (state.events.length > maxEvents) {
|
|
192
|
+
const evictSummary = summaries > summaryShare;
|
|
193
|
+
const index = evictionIndex(state.events, evictSummary);
|
|
194
|
+
if (evictSummary) summaries--;
|
|
195
|
+
state.events.splice(Math.max(index, 0), 1);
|
|
153
196
|
}
|
|
154
|
-
state.events.splice(0, state.events.length - maxEvents);
|
|
155
197
|
}
|
|
156
198
|
|
|
157
199
|
/** Return whether a debug level is recognized by the registry. */
|
|
@@ -226,18 +268,22 @@ export function isDebugRegistryEnabled(): boolean {
|
|
|
226
268
|
}
|
|
227
269
|
|
|
228
270
|
/**
|
|
229
|
-
* Return whether
|
|
271
|
+
* Return whether an event at `level` would reach the session file now: Debug
|
|
230
272
|
* must be enabled, at least one persistence sink must be registered, and the
|
|
231
|
-
* persistence threshold must admit
|
|
273
|
+
* persistence threshold must admit the level.
|
|
232
274
|
*/
|
|
233
|
-
export function
|
|
275
|
+
export function canPersistDebugEvent(level: DebugLevel = "info"): boolean {
|
|
234
276
|
const state = getState();
|
|
235
|
-
return (
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
277
|
+
return state.config.enabled && state.persistenceSinks.size > 0 && shouldPersist(state, level);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Return whether a retrospective can be captured: an `info` event must be
|
|
282
|
+
* persistable (see {@link canPersistDebugEvent}) and the explicit Agent Run
|
|
283
|
+
* retrospective opt-in must be enabled.
|
|
284
|
+
*/
|
|
285
|
+
export function canRecordAgentRunRetrospective(): boolean {
|
|
286
|
+
return getState().config.agentRunRetrospectivesEnabled && canPersistDebugEvent("info");
|
|
241
287
|
}
|
|
242
288
|
|
|
243
289
|
/** Best-effort redaction helper for data exposed through sanitized debug views. */
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// Shared footer contribution registry for SuPi extensions.
|
|
2
2
|
//
|
|
3
|
-
// Extensions register
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// alongside the built-in metrics. Extensions can use PI's status API as a
|
|
3
|
+
// Extensions register text chunks with a placement hint. The custom footer in
|
|
4
|
+
// supi-extras reads these contributions and renders them alongside the
|
|
5
|
+
// built-in metrics. Extensions can use PI's status API with the same key as a
|
|
7
6
|
// fallback when the custom footer is not installed.
|
|
8
7
|
|
|
9
8
|
import { createRegistry } from "./registry-utils.ts";
|
|
@@ -11,8 +10,33 @@ import { createRegistry } from "./registry-utils.ts";
|
|
|
11
10
|
/** Event emitted when a dynamic footer contribution needs a new render. */
|
|
12
11
|
export const FOOTER_INVALIDATE_EVENT = "supi:footer:invalidate";
|
|
13
12
|
|
|
14
|
-
/**
|
|
15
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Where the contribution should appear in the footer.
|
|
15
|
+
*
|
|
16
|
+
* - `path-end`: right side of the workspace line (path and Git), for workspace state
|
|
17
|
+
* - `stats`: inside the cache section of the session line
|
|
18
|
+
* - `stats-end`: own sections after context usage on the session line
|
|
19
|
+
* - `model-start`: right side of the session line, before the model name
|
|
20
|
+
* - `status`: extension status line below the footer
|
|
21
|
+
*/
|
|
22
|
+
export type FooterPlacement = "path-end" | "stats" | "stats-end" | "model-start" | "status";
|
|
23
|
+
|
|
24
|
+
/** Icon set selected by the footer `icons` setting. */
|
|
25
|
+
export type FooterGlyphMode = "nerd" | "unicode" | "ascii";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Theme color names accepted by {@link FooterRenderContext.style}.
|
|
29
|
+
* Matches the Pi `ThemeColor` names SuPi contributions use.
|
|
30
|
+
*/
|
|
31
|
+
export type FooterColor = "accent" | "dim" | "muted" | "text" | "success" | "warning" | "error";
|
|
32
|
+
|
|
33
|
+
/** Render inputs supplied by the custom footer. */
|
|
34
|
+
export interface FooterRenderContext {
|
|
35
|
+
/** Apply a theme color. */
|
|
36
|
+
style: (color: FooterColor, text: string) => string;
|
|
37
|
+
/** Resolved icon mode; contributions choose matching glyphs. */
|
|
38
|
+
glyphMode: FooterGlyphMode;
|
|
39
|
+
}
|
|
16
40
|
|
|
17
41
|
/** A single footer contribution registered by an extension. */
|
|
18
42
|
export interface FooterContribution {
|
|
@@ -21,15 +45,18 @@ export interface FooterContribution {
|
|
|
21
45
|
* A same-key Pi status is treated as this contribution's built-in-footer fallback.
|
|
22
46
|
*/
|
|
23
47
|
key: string;
|
|
24
|
-
/** Which footer
|
|
48
|
+
/** Which footer area this belongs to. */
|
|
25
49
|
placement: FooterPlacement;
|
|
26
50
|
/**
|
|
27
51
|
* Sort order within the placement (lower values render further left). Default: 100.
|
|
28
52
|
* Priority 0 is reserved for the turn cache-hit part so it stays adjacent to CH.
|
|
29
53
|
*/
|
|
30
54
|
priority?: number;
|
|
31
|
-
/**
|
|
32
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Return the text for this contribution; empty hides it. Called on every render.
|
|
57
|
+
* Callers without a footer context (for example tests) may omit `ctx`.
|
|
58
|
+
*/
|
|
59
|
+
render: (ctx?: FooterRenderContext) => string;
|
|
33
60
|
}
|
|
34
61
|
|
|
35
62
|
const registry = createRegistry<FooterContribution>("footer-contributions");
|
|
@@ -57,6 +84,11 @@ export const footerContributions = {
|
|
|
57
84
|
.sort(sortByPriority);
|
|
58
85
|
},
|
|
59
86
|
|
|
87
|
+
/** Get every registered contribution regardless of placement. */
|
|
88
|
+
getAll(): FooterContribution[] {
|
|
89
|
+
return registry.getAll();
|
|
90
|
+
},
|
|
91
|
+
|
|
60
92
|
/** Remove all contributions (primarily for tests). */
|
|
61
93
|
clear(): void {
|
|
62
94
|
registry.clear();
|
package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts
CHANGED
|
@@ -57,3 +57,5 @@ export {
|
|
|
57
57
|
getActiveBranchEntries,
|
|
58
58
|
} from "./session-utils.ts";
|
|
59
59
|
export { BSD_SED_HINT, BSD_SED_HINT_MARKER, registerShellHints } from "./shell-hints.ts";
|
|
60
|
+
export type { SideRunEvent } from "./side-run.ts";
|
|
61
|
+
export { runSideRun, SIDE_RUN_END_EVENT, SIDE_RUN_START_EVENT } from "./side-run.ts";
|
package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/side-run.ts
ADDED
|
@@ -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
|
+
}
|
package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spill.ts
CHANGED
|
@@ -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-tree-sitter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "Structural AST analysis for SuPi code intelligence",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"jiti": "2.7.0",
|
|
38
38
|
"web-tree-sitter": "0.27.2",
|
|
39
|
-
"@mrclrchtr/supi-code-runtime": "
|
|
40
|
-
"@mrclrchtr/supi-core": "
|
|
39
|
+
"@mrclrchtr/supi-code-runtime": "14.0.0",
|
|
40
|
+
"@mrclrchtr/supi-core": "14.0.0"
|
|
41
41
|
},
|
|
42
42
|
"bundledDependencies": [
|
|
43
43
|
"@mrclrchtr/supi-code-runtime",
|