pi-agent-ide 1.0.0 → 1.0.1
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 +10 -0
- package/dist/{chunk-LG22ELG4.js → chunk-26SMC6OS.js} +1 -1
- package/dist/{chunk-QC6VFZSB.js → chunk-3BRGWFEI.js} +1 -1
- package/dist/chunk-3JBQYLJ4.js +5 -0
- package/dist/{chunk-LRAMFOUP.js → chunk-3KM5DSWL.js} +1 -1
- package/dist/{chunk-FVWMI4GP.js → chunk-7OAAM5FL.js} +1 -1
- package/dist/{chunk-X4CU7CMR.js → chunk-C327T6YP.js} +1 -1
- package/dist/{chunk-WZ7MNISG.js → chunk-KM4NOIOB.js} +1 -1
- package/dist/{chunk-NGWQRV25.js → chunk-L2YDUMZC.js} +1 -1
- package/dist/chunk-MCHU3BLO.js +53 -0
- package/dist/{chunk-AKUBFJAR.js → chunk-NSBRKTZ7.js} +1 -1
- package/dist/{chunk-SKHD2QIT.js → chunk-QUK5ZEYX.js} +1 -1
- package/dist/{chunk-E6G3UVS7.js → chunk-RYJEEBET.js} +1 -1
- package/dist/chunk-UN3XLVPR.js +18 -0
- package/dist/{chunk-KJ6HZC6L.js → chunk-VQ2RA43A.js} +1 -1
- package/dist/{chunk-HUICUICD.js → chunk-VWYI4WF7.js} +1 -1
- package/dist/{chunk-UHGHVYAW.js → chunk-W25HNEMR.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-94.js +1 -1
- package/dist/pi-agent-ide.js +1 -1
- package/docs/nightly.md +7 -1
- package/docs/releases.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +13 -13
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/package.json +12 -12
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +28 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/corrected-names.ts +16 -5
- package/node_modules/pi-agent-ide-lsp/src/lsp/declaration-scan.ts +116 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/initialization-options.ts +37 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +138 -128
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +1 -24
- package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +40 -12
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +98 -40
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +48 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +61 -0
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +51 -2
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-search/package.json +4 -4
- package/node_modules/pi-agent-search/src/api/structured-result.ts +28 -4
- package/node_modules/pi-agent-search-text/package.json +10 -10
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +8 -8
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +35 -35
- package/src/composite/script-values/lsp-search.ts +56 -12
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-search/package.json +4 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +10 -10
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +28 -4
- package/src/extensions/pi-agent-text-editor/package.json +8 -8
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/package.json +12 -12
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +28 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/corrected-names.ts +16 -5
- package/src/plugins/pi-agent-ide-lsp/src/lsp/declaration-scan.ts +116 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/initialization-options.ts +37 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +138 -128
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +1 -24
- package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +40 -12
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +98 -40
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +48 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +61 -0
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +51 -2
- package/dist/chunk-4AEYLVSR.js +0 -5
- package/dist/chunk-DSB6A5P5.js +0 -53
- package/dist/chunk-YSGPCH52.js +0 -18
|
@@ -18,6 +18,7 @@ import { requireReferenceReply, requestReferences, type LspLocation } from "./na
|
|
|
18
18
|
import { lspRangeMatch } from "./range-match.ts";
|
|
19
19
|
import { diagnosticErrors, withoutCorrectedNames } from "./corrected-names.ts";
|
|
20
20
|
import { isMissingSource } from "./missing-sources.ts";
|
|
21
|
+
import { hasTypeScriptProjectQueries } from "./project.ts";
|
|
21
22
|
import type { LspPosition } from "./types.ts";
|
|
22
23
|
import {
|
|
23
24
|
clangCoverage,
|
|
@@ -27,9 +28,9 @@ import {
|
|
|
27
28
|
type ClangCoverage,
|
|
28
29
|
} from "./clang-coverage.ts";
|
|
29
30
|
import { requestWorkspaceSymbols, requestDocumentSymbols } from "./symbols.ts";
|
|
31
|
+
import { exactIdentifier, scanDeclarations } from "./declaration-scan.ts";
|
|
30
32
|
import {
|
|
31
|
-
|
|
32
|
-
declarationsNamed,
|
|
33
|
+
declarationsForWorkspaceSymbol,
|
|
33
34
|
normalizeDocumentSymbols,
|
|
34
35
|
preferredDeclaration,
|
|
35
36
|
type LspCodeSymbol,
|
|
@@ -112,6 +113,18 @@ interface Snapshot {
|
|
|
112
113
|
readonly version: string;
|
|
113
114
|
}
|
|
114
115
|
|
|
116
|
+
/** A workspace symbol with no usable declaration anchor in the current file. */
|
|
117
|
+
export interface SkippedSymbol {
|
|
118
|
+
readonly name: string;
|
|
119
|
+
readonly source: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** A server returned at least its known workspace/symbol candidate limit. */
|
|
123
|
+
export interface WorkspaceSymbolCandidateLimit {
|
|
124
|
+
readonly server: string;
|
|
125
|
+
readonly limit: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
115
128
|
/** Symbols found by {@link searchSymbols}. */
|
|
116
129
|
export interface SymbolSearchResult {
|
|
117
130
|
readonly hits: SymbolHit[];
|
|
@@ -128,6 +141,8 @@ export interface SymbolSearchResult {
|
|
|
128
141
|
* listed; their places are left out. Present only when there are such files.
|
|
129
142
|
*/
|
|
130
143
|
readonly missing?: readonly string[];
|
|
144
|
+
readonly skipped?: readonly SkippedSymbol[];
|
|
145
|
+
readonly candidateLimits?: readonly WorkspaceSymbolCandidateLimit[];
|
|
131
146
|
}
|
|
132
147
|
|
|
133
148
|
/** Search workspace declarations/references, keeping real provider ranges and honest completeness. */
|
|
@@ -187,6 +202,17 @@ async function searchSymbolsOnce(
|
|
|
187
202
|
return read;
|
|
188
203
|
};
|
|
189
204
|
const readText = async (file: string) => (await snapshotOf(sourceOf(file, cwd))).document.content;
|
|
205
|
+
const outlines = new Map<LspClient, Map<string, Promise<LspCodeSymbol[]>>>();
|
|
206
|
+
const outlineOf = (client: LspClient, uri: string) => {
|
|
207
|
+
const byUri = outlines.get(client) ?? new Map<string, Promise<LspCodeSymbol[]>>();
|
|
208
|
+
outlines.set(client, byUri);
|
|
209
|
+
let outline = byUri.get(uri);
|
|
210
|
+
if (outline === undefined) {
|
|
211
|
+
outline = requestDocumentSymbols(client, uri, signal).then(normalizeDocumentSymbols);
|
|
212
|
+
byUri.set(uri, outline);
|
|
213
|
+
}
|
|
214
|
+
return outline;
|
|
215
|
+
};
|
|
190
216
|
const roots = resultScope?.targets.map((target) => target.source) ??
|
|
191
217
|
scope.paths ?? [scope.path ?? cwd];
|
|
192
218
|
const clients = new Set(
|
|
@@ -208,6 +234,22 @@ async function searchSymbolsOnce(
|
|
|
208
234
|
throw new Error(
|
|
209
235
|
"LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.",
|
|
210
236
|
);
|
|
237
|
+
// An exact name is looked up in the files that write it, whatever the servers' indexes hold.
|
|
238
|
+
const word = exactIdentifier(query);
|
|
239
|
+
const scan =
|
|
240
|
+
word === undefined
|
|
241
|
+
? undefined
|
|
242
|
+
: await scanDeclarations({
|
|
243
|
+
manager,
|
|
244
|
+
cwd,
|
|
245
|
+
roots,
|
|
246
|
+
word,
|
|
247
|
+
accepts: (source) => withinScope(source, cwd, scope),
|
|
248
|
+
readText,
|
|
249
|
+
outlineOf,
|
|
250
|
+
...(signal && { signal }),
|
|
251
|
+
});
|
|
252
|
+
for (const client of scan?.declarations.keys() ?? []) clients.add(client);
|
|
211
253
|
// The result scope as the text each hit was read from. Another session may have written the file
|
|
212
254
|
// since the scope was resolved, before or while the server answered; the scope follows its
|
|
213
255
|
// region through unchanged lines, and the call fails when the region is gone.
|
|
@@ -322,6 +364,7 @@ async function searchSymbolsOnce(
|
|
|
322
364
|
// The server's index can keep places in files deleted since, such as another session's scratch
|
|
323
365
|
// copy of a source. The search leaves them out and names the files it could have listed.
|
|
324
366
|
const missing = new Set<string>();
|
|
367
|
+
const skipped = new Map<string, SkippedSymbol>();
|
|
325
368
|
const exists = async (source: string): Promise<boolean> => {
|
|
326
369
|
try {
|
|
327
370
|
await snapshotOf(source);
|
|
@@ -332,55 +375,57 @@ async function searchSymbolsOnce(
|
|
|
332
375
|
return false;
|
|
333
376
|
}
|
|
334
377
|
};
|
|
335
|
-
const coverages: (ClangCoverage | undefined)[] = [];
|
|
378
|
+
const coverages: (ClangCoverage | undefined)[] = [scan?.coverage];
|
|
379
|
+
const candidateLimits: WorkspaceSymbolCandidateLimit[] = [];
|
|
336
380
|
// Declarations already listed, by file and the name position of their first entry.
|
|
337
|
-
const listed = new Set<string
|
|
338
|
-
const outlines = new Map<string, Promise<LspCodeSymbol[]>>();
|
|
339
|
-
const outlineOf = (client: LspClient, uri: string) => {
|
|
340
|
-
let outline = outlines.get(uri);
|
|
341
|
-
if (outline === undefined) {
|
|
342
|
-
outline = requestDocumentSymbols(client, uri, signal).then(normalizeDocumentSymbols);
|
|
343
|
-
outlines.set(uri, outline);
|
|
344
|
-
}
|
|
345
|
-
return outline;
|
|
346
|
-
};
|
|
381
|
+
const listed = new Map<LspClient, Set<string>>();
|
|
347
382
|
for (const client of clients) {
|
|
383
|
+
const typescript = hasTypeScriptProjectQueries(client);
|
|
348
384
|
signal?.throwIfAborted();
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
385
|
+
const indexed = await requestWorkspaceSymbols(client, query, Number.MAX_SAFE_INTEGER, signal);
|
|
386
|
+
// Count the raw reply. Candidates omitted here could have had declarations or references
|
|
387
|
+
// inside the scope. The exact-name scan cannot recover all of the server's fuzzy matches.
|
|
388
|
+
const candidateLimit = client.workspaceSymbolCandidateLimit;
|
|
389
|
+
if (candidateLimit !== undefined && indexed.length >= candidateLimit)
|
|
390
|
+
candidateLimits.push({ server: client.commandName, limit: candidateLimit });
|
|
391
|
+
const definitions = [...indexed, ...(scan?.declarations.get(client) ?? [])];
|
|
355
392
|
for (const definition of definitions) {
|
|
356
393
|
signal?.throwIfAborted();
|
|
357
|
-
|
|
358
|
-
if (!(
|
|
394
|
+
const source = sourceOf(definition.location.uri, cwd);
|
|
395
|
+
if (!withinScope(source, cwd, {})) continue;
|
|
396
|
+
if (!(await exists(source))) continue;
|
|
359
397
|
const workspaceMatch = await toMatch(definition.location, client).catch((error: unknown) => {
|
|
360
398
|
if ((error as { code?: unknown } | null)?.code === "SOURCE_CHANGED") return undefined;
|
|
361
399
|
throw error;
|
|
362
400
|
});
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
401
|
+
// The Vue-backed TypeScript project can see references that the plain TS server cannot.
|
|
402
|
+
const extension = path.extname(decodeURIComponent(new URL(definition.location.uri).pathname));
|
|
403
|
+
const opened = typescript
|
|
404
|
+
? await manager.openClientFile(
|
|
405
|
+
client,
|
|
406
|
+
source,
|
|
407
|
+
manager.languageId(extension),
|
|
408
|
+
signal,
|
|
409
|
+
readText,
|
|
410
|
+
)
|
|
411
|
+
: await manager.openFile(source, cwd, "symbols", signal, readText);
|
|
370
412
|
if (opened === null)
|
|
371
413
|
throw new Error("LSP references are unavailable for a discovered declaration.");
|
|
372
414
|
// The server's symbol index can lag behind edits, so its range may belong to an older text.
|
|
373
415
|
// The file's current symbols then name every declaration with that name, each overload
|
|
374
416
|
// apart; a prototype and its definition are one declaration.
|
|
375
417
|
const outline = await outlineOf(opened.client, opened.uri);
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
418
|
+
const declarations = declarationsForWorkspaceSymbol(
|
|
419
|
+
outline,
|
|
420
|
+
definition.name,
|
|
421
|
+
definition.location.range,
|
|
422
|
+
workspaceMatch?.matchedText,
|
|
423
|
+
);
|
|
424
|
+
if (declarations.length === 0) {
|
|
425
|
+
// Without an anchor we cannot ask for its references or rule out a hit inside the scope.
|
|
426
|
+
skipped.set(JSON.stringify([source, definition.name]), { name: definition.name, source });
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
384
429
|
for (const entries of declarations) {
|
|
385
430
|
signal?.throwIfAborted();
|
|
386
431
|
// A declaration's references and renames are the same from each of its entries; its
|
|
@@ -401,11 +446,17 @@ async function searchSymbolsOnce(
|
|
|
401
446
|
opened.uri,
|
|
402
447
|
(entries?.[0]?.selectionRange ?? definition.location.range).start,
|
|
403
448
|
]);
|
|
404
|
-
|
|
405
|
-
listed.
|
|
449
|
+
const seenDeclarations = listed.get(opened.client) ?? new Set<string>();
|
|
450
|
+
listed.set(opened.client, seenDeclarations);
|
|
451
|
+
if (seenDeclarations.has(identity)) continue;
|
|
452
|
+
seenDeclarations.add(identity);
|
|
406
453
|
const declared = await toMatch(location, opened.client);
|
|
407
454
|
const symbol: SearchSymbol = {
|
|
408
|
-
id: JSON.stringify([
|
|
455
|
+
id: JSON.stringify([
|
|
456
|
+
typescript ? "typescript" : client.serverId,
|
|
457
|
+
declared.source,
|
|
458
|
+
location.range,
|
|
459
|
+
]),
|
|
409
460
|
name: entry?.name ?? definition.name,
|
|
410
461
|
kind: String(entry?.kind ?? definition.kind),
|
|
411
462
|
...(entry !== undefined && { selector: entry.selector }),
|
|
@@ -535,7 +586,14 @@ async function searchSymbolsOnce(
|
|
|
535
586
|
contents: new Map(
|
|
536
587
|
returned.map((hit) => [hit.source, requiredValue(mappedOnto.get(hit.source))]),
|
|
537
588
|
),
|
|
538
|
-
complete:
|
|
589
|
+
complete:
|
|
590
|
+
(resultScope?.complete ?? true) &&
|
|
591
|
+
kept.length <= limit &&
|
|
592
|
+
coverageComplete(coverage) &&
|
|
593
|
+
skipped.size === 0 &&
|
|
594
|
+
candidateLimits.length === 0,
|
|
595
|
+
...(candidateLimits.length > 0 && { candidateLimits }),
|
|
596
|
+
...(skipped.size > 0 && { skipped: [...skipped.values()] }),
|
|
539
597
|
...(coverage !== undefined && !coverageComplete(coverage) && { coverage }),
|
|
540
598
|
...(missing.size > 0 && { missing: [...missing].sort() }),
|
|
541
599
|
};
|
|
@@ -130,6 +130,54 @@ export function declarationsNamed(
|
|
|
130
130
|
return groupDeclarations(named(symbols));
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
/**
|
|
134
|
+
* The declarations of one workspace symbol in the current outline of its file.
|
|
135
|
+
*
|
|
136
|
+
* A server can spell the symbol's name differently in its index and in its outline, such as gopls
|
|
137
|
+
* with `Engine.Start` and `(*Engine).Start`, while both ranges select the identifier `Start`. When
|
|
138
|
+
* the text at the indexed `range` is the name or its last identifier, the declaration whose name
|
|
139
|
+
* range is `range` is the symbol, provided its qualified name agrees. Otherwise the index may
|
|
140
|
+
* describe an older text, and the declarations with the same qualified name are the candidates.
|
|
141
|
+
* An empty result means the outline has no such declaration. An undefined entry is a fresh range
|
|
142
|
+
* that no outline entry names; the workspace location then stands for the declaration.
|
|
143
|
+
*/
|
|
144
|
+
export function declarationsForWorkspaceSymbol(
|
|
145
|
+
outline: readonly LspCodeSymbol[],
|
|
146
|
+
name: string,
|
|
147
|
+
range: LspRange,
|
|
148
|
+
textAtRange: string | undefined,
|
|
149
|
+
): (readonly LspCodeSymbol[] | undefined)[] {
|
|
150
|
+
const qualified = qualifiedName(name);
|
|
151
|
+
const tail = qualified.split(/[.:]+/u).at(-1);
|
|
152
|
+
if (textAtRange === name) return [declarationAt(outline, range)];
|
|
153
|
+
if (textAtRange !== undefined && textAtRange === tail) {
|
|
154
|
+
const found = declarationAt(outline, range);
|
|
155
|
+
if (found === undefined) return [undefined];
|
|
156
|
+
if (found[0] !== undefined && isQualifiedAs(found[0], qualified)) return [found];
|
|
157
|
+
}
|
|
158
|
+
const all = (items: readonly LspCodeSymbol[]): LspCodeSymbol[] =>
|
|
159
|
+
items.flatMap((symbol) => [symbol, ...all(symbol.children)]);
|
|
160
|
+
return groupDeclarations(all(outline).filter((symbol) => isQualifiedAs(symbol, qualified)));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** A name without receiver parentheses, pointer stars, type arguments and spaces. */
|
|
164
|
+
function qualifiedName(name: string): string {
|
|
165
|
+
return name.replace(/\[[^\]]*\]/gu, "").replace(/[()*\s]/gu, "");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Whether `qualified` names the symbol the way a server's index does: by its own name, as gopls
|
|
170
|
+
* spells a method `(*Engine).Start`, or by the names on its path, as gopls lists a struct field
|
|
171
|
+
* `Holder.Value` in the index and `Value` under `Holder` in the outline. A server that matches a
|
|
172
|
+
* fuzzy query against the full name may put the package first, as in `pkg.Holder.Value`; a name
|
|
173
|
+
* with a container tolerates such a prefix, a bare name cannot tell it from a container.
|
|
174
|
+
*/
|
|
175
|
+
function isQualifiedAs(symbol: LspCodeSymbol, qualified: string): boolean {
|
|
176
|
+
return [qualifiedName(symbol.name), symbol.selector.map(qualifiedName).join(".")].some(
|
|
177
|
+
(name) => qualified === name || (name.includes(".") && qualified.endsWith(`.${name}`)),
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
133
181
|
/** The declaration entries that contain `range` as their name range. */
|
|
134
182
|
export function declarationAt(
|
|
135
183
|
symbols: readonly LspCodeSymbol[],
|
|
@@ -8,6 +8,7 @@ import type { LspClient } from "./client.ts";
|
|
|
8
8
|
import type { LspManager } from "./manager.ts";
|
|
9
9
|
import type { LspRange } from "./types.ts";
|
|
10
10
|
import { sourceChanged } from "./source-changes.ts";
|
|
11
|
+
import { hasTypeScriptProjectQueries, requestTsserver } from "./project.ts";
|
|
11
12
|
|
|
12
13
|
// ── Types ────────────────────────────────────────────────────────────
|
|
13
14
|
|
|
@@ -97,6 +98,64 @@ export interface LspWorkspaceSymbol {
|
|
|
97
98
|
containerName?: string;
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
interface TsNavigateToItem {
|
|
102
|
+
readonly name: string;
|
|
103
|
+
readonly kind: string;
|
|
104
|
+
readonly file: string;
|
|
105
|
+
readonly start: { readonly line: number; readonly offset: number };
|
|
106
|
+
readonly end: { readonly line: number; readonly offset: number };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Match typescript-language-server's SymbolKind conversion when no outline entry is available.
|
|
110
|
+
const TS_SYMBOL_KIND = new Map([
|
|
111
|
+
["file", 1],
|
|
112
|
+
["module", 2],
|
|
113
|
+
["class", 5],
|
|
114
|
+
["local class", 5],
|
|
115
|
+
["method", 6],
|
|
116
|
+
["getter", 6],
|
|
117
|
+
["setter", 6],
|
|
118
|
+
["property", 7],
|
|
119
|
+
["JSX attribute", 7],
|
|
120
|
+
["field", 8],
|
|
121
|
+
["constructor", 9],
|
|
122
|
+
["enum", 10],
|
|
123
|
+
["interface", 11],
|
|
124
|
+
["function", 12],
|
|
125
|
+
["local function", 12],
|
|
126
|
+
["const", 14],
|
|
127
|
+
["enum member", 14],
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
async function requestTypeScriptSymbols(
|
|
131
|
+
client: LspClient,
|
|
132
|
+
query: string,
|
|
133
|
+
signal?: AbortSignal,
|
|
134
|
+
): Promise<LspWorkspaceSymbol[]> {
|
|
135
|
+
// TLS passes its first open file to navto, which can select an unrelated project or a
|
|
136
|
+
// document retained by another session. Omitting file searches all of its loaded projects.
|
|
137
|
+
const items = await requestTsserver<TsNavigateToItem[]>(
|
|
138
|
+
client,
|
|
139
|
+
["navto", { searchValue: query }],
|
|
140
|
+
signal,
|
|
141
|
+
);
|
|
142
|
+
const position = ({ line, offset }: TsNavigateToItem["start"]) => ({
|
|
143
|
+
line: line - 1,
|
|
144
|
+
character: offset - 1,
|
|
145
|
+
});
|
|
146
|
+
// LSP erases tsserver's distinction between import aliases and real declarations.
|
|
147
|
+
return (items ?? [])
|
|
148
|
+
.filter(({ kind }) => kind !== "alias")
|
|
149
|
+
.map((item) => ({
|
|
150
|
+
name: item.name,
|
|
151
|
+
kind: TS_SYMBOL_KIND.get(item.kind) ?? 13,
|
|
152
|
+
location: {
|
|
153
|
+
uri: client.serverPathToDocumentUri(item.file),
|
|
154
|
+
range: { start: position(item.start), end: position(item.end) },
|
|
155
|
+
},
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
|
|
100
159
|
/**
|
|
101
160
|
Request workspace symbols from one native LSP server.
|
|
102
161
|
*/
|
|
@@ -106,6 +165,8 @@ export async function requestWorkspaceSymbols(
|
|
|
106
165
|
limit = 100,
|
|
107
166
|
signal?: AbortSignal,
|
|
108
167
|
): Promise<LspWorkspaceSymbol[]> {
|
|
168
|
+
if (hasTypeScriptProjectQueries(client))
|
|
169
|
+
return (await requestTypeScriptSymbols(client, query, signal)).slice(0, limit);
|
|
109
170
|
const result = await client.sendRequest<LspWorkspaceSymbol[] | null>(
|
|
110
171
|
"workspace/symbol",
|
|
111
172
|
{
|
|
@@ -17,7 +17,7 @@ import type { LspClient } from "./lsp/client.ts";
|
|
|
17
17
|
import type { LspPosition, LspTextEdit } from "./lsp/types.ts";
|
|
18
18
|
import { documentUri } from "./lsp/document-uri.ts";
|
|
19
19
|
import { assertLspLines } from "./lsp/line-breaks.ts";
|
|
20
|
-
import { loadQueryProject } from "./lsp/
|
|
20
|
+
import { loadQueryProject } from "./lsp/project.ts";
|
|
21
21
|
import { diagnosticErrors, textInRange, withoutCorrectedNames } from "./lsp/corrected-names.ts";
|
|
22
22
|
import {
|
|
23
23
|
CLANG_LANGUAGES,
|
|
@@ -26,7 +26,12 @@ import {
|
|
|
26
26
|
import { coverageNotes, mergeCoverage, type ClangCoverage } from "./lsp/clang-coverage.ts";
|
|
27
27
|
import { missingSourcesNotes } from "./lsp/missing-sources.ts";
|
|
28
28
|
import type { LspManager } from "./lsp/manager.ts";
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
searchSymbols,
|
|
31
|
+
type SkippedSymbol,
|
|
32
|
+
type SymbolHit,
|
|
33
|
+
type WorkspaceSymbolCandidateLimit,
|
|
34
|
+
} from "./lsp/symbol-search.ts";
|
|
30
35
|
import { withLspDocuments } from "./lsp/document-leases.ts";
|
|
31
36
|
import { retryWhileSourceChanges, sourceChanged } from "./lsp/source-changes.ts";
|
|
32
37
|
import { lspRangeMatch } from "./lsp/range-match.ts";
|
|
@@ -58,6 +63,8 @@ type Payload =
|
|
|
58
63
|
readonly coverage?: ClangCoverage;
|
|
59
64
|
/** Files the server reported places in that no longer exist. */
|
|
60
65
|
readonly missing?: readonly string[];
|
|
66
|
+
readonly skipped?: readonly SkippedSymbol[];
|
|
67
|
+
readonly candidateLimits?: readonly WorkspaceSymbolCandidateLimit[];
|
|
61
68
|
readonly references: boolean;
|
|
62
69
|
readonly data: unknown;
|
|
63
70
|
}
|
|
@@ -340,6 +347,8 @@ export function createLspSearchResolver(
|
|
|
340
347
|
let complete = scope?.complete ?? true;
|
|
341
348
|
const coverages: (ClangCoverage | undefined)[] = [];
|
|
342
349
|
const missing = new Set<string>();
|
|
350
|
+
const skipped = new Map<string, SkippedSymbol>();
|
|
351
|
+
const candidateLimits = new Map<string, WorkspaceSymbolCandidateLimit>();
|
|
343
352
|
for (const [manager, { targets, paths }] of groups) {
|
|
344
353
|
const found = await backend.searchSymbols(
|
|
345
354
|
query,
|
|
@@ -366,7 +375,11 @@ export function createLspSearchResolver(
|
|
|
366
375
|
}
|
|
367
376
|
complete = complete && found.complete;
|
|
368
377
|
coverages.push(found.coverage);
|
|
378
|
+
for (const cap of found.candidateLimits ?? [])
|
|
379
|
+
candidateLimits.set(JSON.stringify([cap.server, cap.limit]), cap);
|
|
369
380
|
for (const source of found.missing ?? []) missing.add(source);
|
|
381
|
+
for (const candidate of found.skipped ?? [])
|
|
382
|
+
skipped.set(JSON.stringify([candidate.source, candidate.name]), candidate);
|
|
370
383
|
}
|
|
371
384
|
for (const source of conflicting) contents.delete(source);
|
|
372
385
|
// The search session keeps these hits and its refresh closure for as long as its anchors
|
|
@@ -378,7 +391,13 @@ export function createLspSearchResolver(
|
|
|
378
391
|
hits: hits.slice(0, limit),
|
|
379
392
|
complete: complete && hits.length <= limit,
|
|
380
393
|
...(coverage && { coverage }),
|
|
394
|
+
...(candidateLimits.size > 0 && { candidateLimits: [...candidateLimits.values()] }),
|
|
381
395
|
...(missing.size > 0 && { missing: [...missing].sort() }),
|
|
396
|
+
...(skipped.size > 0 && {
|
|
397
|
+
skipped: [...skipped.values()].sort(
|
|
398
|
+
(a, b) => a.source.localeCompare(b.source) || a.name.localeCompare(b.name),
|
|
399
|
+
),
|
|
400
|
+
}),
|
|
382
401
|
}),
|
|
383
402
|
contents,
|
|
384
403
|
};
|
|
@@ -412,9 +431,13 @@ export function createLspSearchResolver(
|
|
|
412
431
|
complete: found.complete,
|
|
413
432
|
...(found.coverage && { coverage: found.coverage }),
|
|
414
433
|
...(found.missing && { missing: found.missing }),
|
|
434
|
+
...(found.candidateLimits && { candidateLimits: found.candidateLimits }),
|
|
435
|
+
...(found.skipped && { skipped: found.skipped }),
|
|
415
436
|
references,
|
|
416
437
|
data: {
|
|
417
438
|
...data,
|
|
439
|
+
...(found.candidateLimits && { candidateLimits: found.candidateLimits }),
|
|
440
|
+
...(found.skipped && { skipped: found.skipped }),
|
|
418
441
|
matches: data.matches.map((match, index) => ({
|
|
419
442
|
...match,
|
|
420
443
|
role: found.hits[index]?.role,
|
|
@@ -458,7 +481,9 @@ export function createLspSearchResolver(
|
|
|
458
481
|
[
|
|
459
482
|
...(data.references ? ["LSP reference navigation · may leave input scope"] : []),
|
|
460
483
|
...coverageNotes(data.coverage, (source) => displaySource(source, data.cwd)),
|
|
484
|
+
...candidateLimitNotes(data.candidateLimits),
|
|
461
485
|
...missingSourcesNotes(data.missing ?? [], (source) => displaySource(source, data.cwd)),
|
|
486
|
+
...skippedSymbolNotes(data.skipped, (source) => displaySource(source, data.cwd)),
|
|
462
487
|
],
|
|
463
488
|
data.hits.map((hit) => `${hit.role} ${hit.symbol.name}`),
|
|
464
489
|
);
|
|
@@ -500,7 +525,7 @@ export function createLspSearchResolver(
|
|
|
500
525
|
: "LSP symbols inside scope";
|
|
501
526
|
const lines =
|
|
502
527
|
result.hits.length === 0
|
|
503
|
-
? ["No symbols found."]
|
|
528
|
+
? [result.skipped ? "No resolvable symbols found." : "No symbols found."]
|
|
504
529
|
: result.hits.slice(0, 100).map(
|
|
505
530
|
(hit, index) =>
|
|
506
531
|
`SEARCH#${result.sessionId}:${index + 1}:match ${display(hit.source)}:${hit.lineNumber}:${hit.startColumn + 1} ${hit.role} ${hit.symbol.name} · ${
|
|
@@ -514,7 +539,9 @@ export function createLspSearchResolver(
|
|
|
514
539
|
lines.unshift(`SEARCH#${result.sessionId}:all:match selects all exact symbol matches.`);
|
|
515
540
|
if (result.hits.length > 100) lines.push("Preview shortened; full source targets retained.");
|
|
516
541
|
lines.push(...coverageNotes(result.coverage, display));
|
|
542
|
+
lines.push(...candidateLimitNotes(result.candidateLimits));
|
|
517
543
|
lines.push(...missingSourcesNotes(result.missing ?? [], display));
|
|
544
|
+
lines.push(...skippedSymbolNotes(result.skipped, display));
|
|
518
545
|
return {
|
|
519
546
|
content: [{ type: "text", text: [heading, ...lines].join("\n") }],
|
|
520
547
|
details: { ...result, cwd: context.cwd },
|
|
@@ -523,6 +550,28 @@ export function createLspSearchResolver(
|
|
|
523
550
|
};
|
|
524
551
|
}
|
|
525
552
|
|
|
553
|
+
function candidateLimitNotes(limits: readonly WorkspaceSymbolCandidateLimit[] = []): string[] {
|
|
554
|
+
return limits.map(
|
|
555
|
+
({ server, limit }) =>
|
|
556
|
+
`${server} reached its workspace symbol limit (${limit}) before scope filtering. Try a narrower query.`,
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** Show why coverage is incomplete without letting a large index reply dominate the preview. */
|
|
561
|
+
function skippedSymbolNotes(
|
|
562
|
+
skipped: readonly SkippedSymbol[] | undefined,
|
|
563
|
+
display: (source: string) => string,
|
|
564
|
+
): string[] {
|
|
565
|
+
if (!skipped?.length) return [];
|
|
566
|
+
const limit = 8;
|
|
567
|
+
const shown = skipped
|
|
568
|
+
.slice(0, limit)
|
|
569
|
+
.map(({ name, source }) => `${name} in ${display(source)}`)
|
|
570
|
+
.join(", ");
|
|
571
|
+
const more = skipped.length > limit ? ` (and ${skipped.length - limit} more)` : "";
|
|
572
|
+
return [`Skipped symbols with no declaration anchor: ${shown}${more}.`];
|
|
573
|
+
}
|
|
574
|
+
|
|
526
575
|
/** A source as the result names it: relative to the workspace, or its ssh:// URI. */
|
|
527
576
|
function displaySource(source: string, cwd: string): string {
|
|
528
577
|
return source.startsWith("ssh://") ? source : path.relative(cwd, source);
|
package/dist/chunk-4AEYLVSR.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as D,b as M}from"./chunk-PS2B6THP.js";import{D as F,la as E,pa as N}from"./chunk-OEEE5BLN.js";import{a as s}from"./chunk-EI7MMDWY.js";function K(e,t,n){return{limit:e??(t&&n==="matches"?Number.MAX_SAFE_INTEGER:void 0),audience:t?"script":"agent",uncappedFiles:t&&n==="files"}}s(K,"searchCallPolicy");import{Type as u}from"typebox";var I="File, directory, URL (no read needed first), docs:all for all packaged guide bodies, docs:<id> for one guide, unchanged Read/Search/edit result or its UUID, or an array of file and directory paths or of results. Use literal text or regex: for docs: sources. Results select only their registered ranges.",m=u.Object({query:u.String({minLength:1,description:"Text to find, matched literally, quotes included. Uppercase AND, OR, NOT, || or a spaced | make it a Boolean expression, where quotes group literal text. Use regex:<pattern> for regular expressions."}),path:u.Optional(u.Union(E.anyOf,{description:I})),include:u.Optional(u.String({description:"Optional include glob for local or SSH files"})),exclude:u.Optional(u.String({description:"Optional exclude glob for local or SSH files"})),caseSensitive:u.Optional(u.Boolean({description:"Match letter case"})),wholeWord:u.Optional(u.Boolean({description:"Match complete words"})),multiline:u.Optional(u.Boolean({description:"Let text or regex:<pattern> match across lines; . also matches line breaks. Local or SSH files and result scopes only."})),limit:u.Optional(u.Integer({minimum:1,maximum:1e3,description:"Maximum displayed items, including compact file summaries (default 50)."}))},{additionalProperties:!1});function Ce(e){let t=[...new Set(e.flatMap(o=>o.split(`
|
|
2
|
-
`)))].filter(o=>o.trim()!=="");if(t.length===0)return m;let n=s(o=>({...o,description:[I,...t].join(`
|
|
3
|
-
`)}),"describe");return{...m,properties:{...m.properties,path:n(m.properties.path)}}}s(Ce,"describeSearchParameters");import S from"node:path";import{pathToFileURL as Y}from"node:url";function ee(e,t,n,o,i,l=[],c=[]){let d=l.map(a=>({kind:"note",text:a}));d.push(...M(e.flatMap(a=>{let z=S.isAbsolute(a.source),X=z&&i?S.relative(i,a.source)||S.basename(a.source):a.source,L=z?Y(a.source).href:/^https?:/iu.test(a.source)?a.source:void 0,P=a.endLineNumber??a.lineNumber;return(P===a.lineNumber?[a.lineText]:[a.lineText,...a.matchedText.split(`
|
|
4
|
-
`).slice(1)]).slice(0,20).map(($,w)=>({source:a.source,label:X,...L===void 0?{}:{link:L},...z?{}:{badge:a.source.startsWith("docs:")?"DOC":/^https?:/iu.test(a.source)?"WEB":"SH"},lineNumber:a.lineNumber+w,text:$,ranges:[{from:w?0:a.startColumn,to:a.lineNumber+w===P?a.endColumn:$.length}]}))}))),e.length||d.push({kind:"note",text:"No matches found"}),e.some(a=>(a.endLineNumber??a.lineNumber)-a.lineNumber>=20)&&d.push({kind:"note",text:"\u2026 source preview shortened"}),d.push(...c.map(a=>({kind:"note",text:a,expandedOnly:!0})));let g=`${e.length}${t?"":"+"}`,R=new Set(e.map(a=>a.source)),J=e.length>0&&e.every(a=>S.isAbsolute(a.source));return new D({summary:`${g} ${e.length===1?"match":"matches"} in ${R.size} ${J?R.size===1?"file":"files":R.size===1?"source":"sources"}`,rows:d},n,o)}s(ee,"renderSearchMatches");var y=class extends Error{static{s(this,"SearchScopeChangedError")}code="SCOPE_CHANGED";constructor(t,n){super(`The scope this search ran in is no longer in its file (${t}). Run the search again from a current Read or Search result.`,n),this.name="SearchScopeChangedError"}};async function te(e,t){if(e.scope!==void 0)try{return e.rescope!==void 0?await e.rescope(t):(await N(e.scope,t),e.scope)}catch(n){throw t?.aborted===!0||n instanceof y?n:new y(n instanceof Error?n.message:String(n),{cause:n})}}s(te,"currentScope");function ne(e,t){return e.targets.some(n=>n.source===t.source&&n.ranges.some(o=>(o.start.lineNumber<t.lineNumber||o.start.lineNumber===t.lineNumber&&o.start.column<=t.startColumn)&&(o.end.lineNumber>(t.endLineNumber??t.lineNumber)||o.end.lineNumber===(t.endLineNumber??t.lineNumber)&&o.end.column>=t.endColumn)))}s(ne,"containsSearchMatch");function re(e){if(e===void 0)return[];let t=[],n=0,o="";for(let i of e){if(i==="{"?n+=1:i==="}"&&(n=Math.max(0,n-1)),n===0&&(i===","||/\s/u.test(i))){o.length>0&&(t.push(o),o="");continue}o+=i}return o.length>0&&t.push(o),t}s(re,"splitGlobList");var h=class extends Error{static{s(this,"SearchCaptureLimitError")}constructor(t="the query"){super(`Search capture exceeded its safety budget. Narrow path, include/exclude globs, or ${t} and retry. limit only controls presentation; no complete result or edit scope was captured.`),this.name="SearchCaptureLimitError"}},v=class{constructor(t){this.query=t}static{s(this,"SearchCaptureGuard")}outputBytes=0;textBytes=0;matches=0;addOutput(t){if(this.outputBytes+=t,this.outputBytes>67108864)throw new h(this.query)}addText(t){if(this.textBytes+=t*2,this.textBytes>67108864)throw new h(this.query)}addMatch(t){this.addLine(t.source),this.addText(t.matchedText.length+t.lineText.length+(t.linesText?.length??0))}addLine(t){if(this.matches++,this.matches>5e4)throw new h(this.query);this.addText(t.length)}};var x="\0null";function oe(e,t){if(typeof e!="object"||e===null||Array.isArray(e))return e;let n=Object.entries(e).filter(([,l])=>l===null);if(n.length===0)return e;let o=t.properties??{},i={...e};for(let[l]of n){let c=o[l];if(c===void 0||!j(c))throw new Error(`${l} is null. Omit ${l} instead; a null here usually means the call that produced it failed or selected no text.`);i[l]=x}return i}s(oe,"markNullFields");function ie(e){let t=Object.entries(e).filter(([,o])=>o===x).map(([o])=>o);return t.length===0?void 0:`${t.length===1?`${t[0]} is`:`${t.join(", ")} are`} null: the call that produced the value probably failed or selected no text. Omit the field to leave it unset; an omitted path searches the working directory.`}s(ie,"nullFieldsMessage");function j(e){let{type:t,anyOf:n}=e;return t==="string"||(n?.some(j)??!1)}s(j,"acceptsString");import se from"node:path";var ae=/^(?:RESULT#|SEARCH#|<system-result\b)|^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/u;function k(e){return typeof e!="string"||ae.test(e)}s(k,"isResultReference");function le(e){let t=e.filter(n=>!k(n));if(t.length!==0){if(t.length<e.length)throw new Error("A path list holds either file and directory paths or Read/Search/edit results and their UUIDs, not both. Search them in separate calls.");for(let n of t){if(n.trim().length===0)throw new Error("A path in a path list must not be empty.");if(/^[a-z][a-z\d+.-]+:/iu.test(n)&&!n.startsWith("ssh://"))throw new Error(`A path list takes local or ssh:// file and directory paths. Search ${n} in a separate call.`)}return t}}s(le,"plainPathList");function ce(e,t){let n=new Set;return e.filter(o=>{let i=B(o,t);return n.has(i)?!1:(n.add(i),!0)})}s(ce,"uniquePaths");function ue(e,t){let n=B(e,t);if(!n.includes("://"))return"local";let o=new URL(n);return`${o.protocol}//${o.host}`}s(ue,"pathMachine");function de(e){return typeof e=="string"?e===x?"null":e:Array.isArray(e)&&e.length>0&&!e.some(k)?e.join(", "):"result scope"}s(de,"describePathArgument");function B(e,t){return e.includes("://")?e.replace(/\/+$/u,""):t.includes("://")?new URL(e,t.endsWith("/")?t:`${t}/`).href.replace(/\/+$/u,""):se.resolve(t,e)}s(B,"absoluteSource");import{Type as r}from"typebox";var _=r.Object({startLine:r.Integer(),startColumn:r.Integer(),endLine:r.Integer(),endColumn:r.Integer()},{additionalProperties:!1}),H=r.Object({line:r.Optional(r.String()),match:r.Optional(r.String())},{additionalProperties:!1}),U={source:r.String(),target:r.Optional(r.String()),range:_,matchedText:r.Optional(r.String()),lineText:r.Optional(r.String()),textTruncated:r.Optional(r.Boolean()),references:r.Optional(H)},pe=r.Object({...U,captures:r.Optional(r.Record(r.String(),r.Array(r.Object(U,{additionalProperties:!1})))),role:r.Optional(r.Union([r.Literal("definition"),r.Literal("reference")])),symbol:r.Optional(r.Object({id:r.String(),name:r.String(),kind:r.String(),selector:r.Optional(r.Array(r.String())),source:r.String(),range:_},{additionalProperties:!1}))},{additionalProperties:!1}),Z={target:r.Optional(r.String()),kind:r.Literal("matches"),truncated:r.Optional(r.Boolean()),fullResult:r.Optional(r.String()),complete:r.Boolean(),matches:r.Array(pe),all:r.Optional(H),notices:r.Optional(r.Array(r.String())),editWarning:r.Optional(r.String()),fallback:r.Optional(r.Union([r.Literal("regex"),r.Literal("words")]))},C=r.Object({status:r.Union([r.Literal("ready"),r.Literal("skipped")]),message:r.Optional(r.String()),candidates:r.Array(r.Object({identifier:r.String(),kind:r.Union([r.Literal("normalized"),r.Literal("component"),r.Literal("typo")]),reason:r.String(),matchCount:r.Integer(),fileCount:r.Integer(),selection:r.Object(Z,{additionalProperties:!1})},{additionalProperties:!1}))},{additionalProperties:!1}),W=r.Union([r.Object({...Z,fuzzy:r.Optional(C)},{additionalProperties:!1}),r.Object({kind:r.Literal("files"),complete:r.Boolean(),files:r.Array(r.String())},{additionalProperties:!1}),r.Object({kind:r.Literal("custom"),resolverId:r.String(),value:r.Unknown()},{additionalProperties:!1})]),he=F(W);function A(e,t,n,o){return{kind:"matches",...o?.target===void 0?{}:{target:o.target},complete:t,matches:e.map((i,l)=>{let c=i.linesText??((i.endLineNumber??i.lineNumber)===i.lineNumber?i.lineText:void 0);return{source:i.source,...o?.matchTargets?.[l]===void 0?{}:{target:o.matchTargets[l]},range:{startLine:i.lineNumber,startColumn:i.startColumn,endLine:i.endLineNumber??i.lineNumber,endColumn:i.endColumn},matchedText:i.matchedText,...c===void 0?{}:{lineText:c},...n===void 0?{}:{references:{line:`SEARCH#${n}:${l+1}:line`,match:`SEARCH#${n}:${l+1}:match`}}}}),...t&&n!==void 0?{all:{line:`SEARCH#${n}:all:line`,match:`SEARCH#${n}:all:match`}}:{}}}s(A,"selectionData");var T={matches:100,textBytes:4096};function fe(e){if(f(e)&&e.kind==="custom"&&f(e.value))return{...e,value:Object.fromEntries(Object.entries(e.value).map(([n,o])=>[n,fe(o)]))};if(!f(e)||e.kind!=="matches"||!Array.isArray(e.matches))return e;let t=e.matches;return{...e,...t.length>T.matches&&{truncated:!0},matches:t.slice(0,T.matches).map(n=>{if(!f(n))return n;let o=f(n.captures)?Object.fromEntries(Object.entries(n.captures).map(([i,l])=>[i,Array.isArray(l)?l.map(c=>f(c)?q(c):c):l])):void 0;return{...q(n),...o!==void 0&&{captures:o}}})}}s(fe,"selectionPreview");function q(e){let t={...e};for(let n of["matchedText","lineText"])typeof t[n]=="string"&&Buffer.byteLength(t[n])>T.textBytes&&(delete t[n],t.textTruncated=!0);return t}s(q,"previewText");function f(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(f,"isRecord");import{Value as ge}from"typebox/value";var p={candidates:5,previewMatches:3,identifiers:2e4,identifierLength:80,vocabularyBytes:8*1024*1024,matchesPerCandidate:200,verificationBytes:4*1024*1024,timeoutMs:2e3};function me(e){return ge.Check(C,e)}s(me,"isFuzzyResultData");function b(e){return e.length>=5&&e.length<=p.identifierLength&&/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)&&/[A-Za-z]/u.test(e)}s(b,"isFuzzyQuery");var O=class{static{s(this,"FuzzyVocabulary")}names=new Set;bytes=0;limited=!1;account(t){return this.bytes+=t,this.bytes>p.vocabularyBytes&&(this.limited=!0),!this.limited}add(t){if(!(this.limited||!b(t)||this.names.has(t))){if(this.names.size===p.identifiers){this.limited=!0;return}this.names.add(t)}}addText(t){if(this.account(Buffer.byteLength(t))){for(let n of t.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/gu))if(this.add(n[0]),this.limited)break}}};function V(e){return e.replace(/([A-Z]+)([A-Z][a-z])/gu,"$1 $2").replace(/([a-z0-9])([A-Z])/gu,"$1 $2").split(/[^A-Za-z0-9]+/u).filter(Boolean).map(t=>t.toLowerCase())}s(V,"splitName");function G(e,t){return e.length===t.length&&e.every((n,o)=>n===t[o])}s(G,"same");function ye(e,t){if(e.length<5||t.length<5||Math.abs(e.length-t.length)>1||/\d/u.test(e+t))return!1;let n=0;for(;n<Math.min(e.length,t.length)&&e[n]===t[n];)n++;if(e.length===t.length)return e.slice(n+1)===t.slice(n+1)||e[n]===t[n+1]&&e[n+1]===t[n]&&e.slice(n+2)===t.slice(n+2);let o=e.length<t.length?e:t,i=e.length<t.length?t:e;return o.slice(n)===i.slice(n+1)}s(ye,"oneTypo");function Se(e,t){if(e.join("")===t.join(""))return{kind:"normalized",reason:"same spelling with different case or separators"};let n=e.length<t.length?e:t,o=e.length<t.length?t:e;if(o.length===n.length+1&&n.length>=2&&n.every(c=>c.length>=3)){let c=G(n,o.slice(1)),d=G(n,o.slice(0,-1));if(c||d)return{kind:"component",reason:`${e.length>t.length?"remove":"add"} ${c?"leading":"trailing"} component '${c?o[0]:o.at(-1)}'`}}if(e.length!==t.length)return;let i=e.flatMap((c,d)=>{let g=t[d];return g!==void 0&&c!==g?[{word:c,other:g}]:[]}),l=i[0];if(!(i.length!==1||!l||!ye(l.word,l.other)))return{kind:"typo",reason:`one character edit: '${l.word}' \u2192 '${l.other}'`}}s(Se,"relation");var Q={normalized:0,component:1,typo:2};function xe(e,t){if(!b(e))return[];let n=V(e);if(n.length===0)return[];let o=[];for(let i of new Set(t)){if(i===e||!b(i))continue;let l=Se(n,V(i));l&&o.push({identifier:i,...l})}return o.sort((i,l)=>Q[i.kind]-Q[l.kind]||(i.identifier<l.identifier?-1:i.identifier>l.identifier?1:0)).slice(0,p.candidates)}s(xe,"rankFuzzyIdentifiers");function be(e,t,n){return{identifier:e.identifier,kind:e.kind,reason:e.reason,matchCount:e.matches.length,fileCount:new Set(e.matches.map(o=>o.source)).size,selection:{...A(e.matches.slice(0,p.previewMatches),e.complete,t,n),truncated:e.matches.length>p.previewMatches}}}s(be,"fuzzyCandidateData");function Re(e){let t=e.selection.complete?"":"+",n=e.selection.all?.line??e.selection.matches[0]?.references?.line,o=e.selection.matches[0],i=n??o?.source;return[`Possible name: ${e.identifier} (${e.reason})`,`${e.matchCount}${t} ${e.matchCount===1&&e.selection.complete?"match":"matches"} in ${e.fileCount}${t} ${e.fileCount===1&&e.selection.complete?"file":"files"}`,`Exact alternative: ${JSON.stringify(e.identifier)} (case-sensitive, whole identifier)`,...e.selection.complete?[]:["Capture limit reached; no complete all reference. Inspect the returned location; do not treat this candidate as a complete match set."],...i?[`Read: ${i}${n||!o?"":` \xB7 line ${o.range.startLine}`}`]:[]].join(`
|
|
5
|
-
`)}s(Re,"formatFuzzyCandidate");export{W as a,he as b,A as c,fe as d,oe as e,ie as f,k as g,le as h,ce as i,ue as j,de as k,K as l,m,Ce as n,ee as o,y as p,te as q,ne as r,re as s,h as t,v as u,p as v,me as w,b as x,O as y,xe as z,be as A,Re as B};
|