@mrclrchtr/supi-code-intelligence 11.3.0 → 12.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 +33 -0
- package/README.md +15 -9
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +64 -28
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/README.md +22 -17
- 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/api.ts +3 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +64 -28
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +30 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +13 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +25 -9
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +7 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-edit-capture.ts +258 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +64 -11
- package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +48 -79
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +118 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +67 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +87 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +21 -35
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-command-capture.ts +139 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +202 -47
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +22 -17
- package/node_modules/@mrclrchtr/supi-lsp/src/session/route-boundary.ts +26 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +106 -16
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +22 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -1
- 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/api.ts +3 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +64 -28
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/coordinates.ts +16 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +3 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-errors.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-range.ts +94 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +26 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +6 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +13 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +1 -9
- package/package.json +5 -5
- package/src/analysis/health/server-status.ts +41 -12
- package/src/analysis/helpers.ts +0 -7
- package/src/analysis/relations/implementations.ts +5 -0
- package/src/analysis/relations/references.ts +5 -0
- package/src/analysis/target/anchored-structural.ts +4 -1
- package/src/analysis/target/file-merge.ts +162 -0
- package/src/analysis/target/file-outline-omissions.ts +146 -0
- package/src/analysis/target/file-refinement.ts +7 -7
- package/src/analysis/target/file.ts +44 -156
- package/src/analysis/target/symbol.ts +5 -1
- package/src/analysis/target/types.ts +32 -6
- package/src/api.ts +1 -1
- package/src/app/app.ts +9 -3
- package/src/session/find-types.ts +8 -4
- package/src/session/find-workflow.ts +11 -16
- package/src/session/graph/collect.ts +2 -0
- package/src/session/graph-types.ts +3 -1
- package/src/session/graph-workflow.ts +5 -4
- package/src/session/input/health-refactor.ts +48 -34
- package/src/session/input/workflows.ts +45 -46
- package/src/session/inspect/file-point.ts +2 -2
- package/src/session/inspect-types.ts +1 -1
- package/src/session/inspect-workflow.ts +3 -3
- package/src/session/orientation/workspace-context.ts +3 -0
- package/src/session/orientation-workflow.ts +6 -3
- package/src/session/refactor-file-actions.ts +122 -0
- package/src/session/refactor-plan-pipeline.ts +152 -0
- package/src/session/refactor-plans.ts +18 -15
- package/src/session/refactor-types.ts +24 -12
- package/src/session/refactor-workflow.ts +70 -244
- package/src/session/session.ts +87 -12
- package/src/session/target-workflow.ts +23 -21
- package/src/tool/code_find/execute.ts +6 -7
- package/src/tool/code_find/spec.ts +9 -16
- package/src/tool/code_find/tui.ts +12 -6
- package/src/tool/code_graph/section.ts +4 -0
- package/src/tool/code_graph/spec.ts +6 -0
- package/src/tool/code_health/spec.ts +6 -0
- package/src/tool/code_health/structured-schema.ts +4 -4
- package/src/tool/code_health/structured.ts +15 -17
- package/src/tool/code_inspect/execute.ts +1 -1
- package/src/tool/code_inspect/markdown.ts +33 -6
- package/src/tool/code_inspect/result.ts +1 -1
- package/src/tool/code_inspect/spec.ts +14 -6
- package/src/tool/code_inspect/structured.ts +2 -2
- package/src/tool/code_inspect/tui.ts +2 -2
- package/src/tool/code_orientation/directory-navigation.ts +20 -31
- package/src/tool/code_orientation/spec.ts +8 -0
- package/src/tool/code_orientation/workspace-output.ts +40 -13
- package/src/tool/code_orientation/workspace-sections.ts +45 -2
- package/src/tool/code_refactor_apply/result.ts +2 -1
- package/src/tool/code_refactor_apply/spec.ts +7 -0
- package/src/tool/code_refactor_plan/execute.ts +0 -2
- package/src/tool/code_refactor_plan/result.ts +23 -13
- package/src/tool/code_refactor_plan/spec.ts +8 -2
- package/src/tool/code_refactor_plan/structured.ts +59 -12
- package/src/tool/code_refactor_plan/tui.ts +14 -17
- package/src/tool/code_resolve/guidance.ts +1 -1
- package/src/tool/code_resolve/markdown.ts +121 -34
- package/src/tool/code_resolve/result.ts +18 -15
- package/src/tool/code_resolve/spec.ts +6 -0
- package/src/tool/code_resolve/structured.ts +43 -10
- package/src/tool/namespace.ts +14 -0
- package/src/tool/refactor-markdown.ts +55 -15
- package/src/tool/register.ts +3 -0
- package/src/tool/result/model-budget.ts +2 -2
- package/src/tool/result/refactor-preview.ts +118 -0
- package/src/tool/result/refactor-unavailable.ts +16 -0
- package/src/tool/result/refactor.ts +8 -2
- package/src/tool/result/types.ts +13 -10
- package/src/tool/schemas.ts +63 -20
- package/src/tool/specs.ts +3 -0
- package/src/ui/status-overlay.ts +1 -1
- package/src/ui/tui/common.ts +10 -10
package/src/session/session.ts
CHANGED
|
@@ -17,8 +17,13 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { realpathSync } from "node:fs";
|
|
20
|
+
import * as os from "node:os";
|
|
20
21
|
import * as path from "node:path";
|
|
21
|
-
import type {
|
|
22
|
+
import type {
|
|
23
|
+
ReadToolDetails,
|
|
24
|
+
SessionEntry,
|
|
25
|
+
ToolResultEvent,
|
|
26
|
+
} from "@earendil-works/pi-coding-agent";
|
|
22
27
|
import {
|
|
23
28
|
type AutomaticLspPathPolicy,
|
|
24
29
|
createDefaultAutomaticLspPathPolicy,
|
|
@@ -164,6 +169,9 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
164
169
|
/** Absolute directories whose instruction files were already surfaced by code_orientation. */
|
|
165
170
|
readonly #surfacedInstructionDirs = new Set<string>();
|
|
166
171
|
|
|
172
|
+
/** Absolute files the agent read in full with `read` since the latest compaction. */
|
|
173
|
+
readonly #fullyReadPaths = new Set<string>();
|
|
174
|
+
|
|
167
175
|
/**
|
|
168
176
|
* Optional LSP controller reference — attached by LSP lifecycle module
|
|
169
177
|
* for Capability Warning evaluation and server management.
|
|
@@ -348,6 +356,7 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
348
356
|
{
|
|
349
357
|
...this.targetWorkflowDeps(),
|
|
350
358
|
nativeInstructionPaths: this.#nativeInstructionPaths,
|
|
359
|
+
fullyReadPaths: this.#fullyReadPaths,
|
|
351
360
|
surfacedInstructionDirs: this.#surfacedInstructionDirs,
|
|
352
361
|
gradleObserver: this.#gradleObserver,
|
|
353
362
|
projectTrusted: this.#projectTrusted,
|
|
@@ -408,15 +417,39 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
408
417
|
|
|
409
418
|
/** Remember instruction/context file paths already loaded by PI natively. */
|
|
410
419
|
captureNativeInstructionPaths(files: Array<{ path: string }>): void {
|
|
411
|
-
for (const file of files)
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
+
for (const file of files) this.#nativeInstructionPaths.add(this.#realPath(file.path));
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Record a model-issued `read` that returned a whole file, so code_orientation
|
|
425
|
+
* does not embed it again as an instruction file until the next compaction.
|
|
426
|
+
* Reads issued by another tool (e.g. a codemode script) are ignored: their
|
|
427
|
+
* results reach only the calling tool, not the model, and are not in the
|
|
428
|
+
* transcript used for branch reconstruction.
|
|
429
|
+
*/
|
|
430
|
+
recordToolResult(event: ToolResultEvent): void {
|
|
431
|
+
if (event.toolName !== "read" || event.parentToolCallId !== undefined) return;
|
|
432
|
+
if (isFullRead(event.input, event.isError, event.details))
|
|
433
|
+
this.#markFileReadInFull(event.input.path);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
#markFileReadInFull(filePath: string): void {
|
|
437
|
+
this.#fullyReadPaths.add(this.#realPath(filePath));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Resolve like Pi's read tool (`@` prefix, `~`), then to the real path so
|
|
441
|
+
// dedup aligns with the realpath-aware lookup in findInstructionFilesForDirectory.
|
|
442
|
+
#realPath(filePath: string): string {
|
|
443
|
+
const unprefixed = filePath.replace(/^@/, "");
|
|
444
|
+
const expanded =
|
|
445
|
+
unprefixed === "~" || unprefixed.startsWith("~/")
|
|
446
|
+
? path.join(os.homedir(), unprefixed.slice(1))
|
|
447
|
+
: unprefixed;
|
|
448
|
+
const resolved = path.resolve(this.cwd, expanded);
|
|
449
|
+
try {
|
|
450
|
+
return path.resolve(realpathSync(resolved));
|
|
451
|
+
} catch {
|
|
452
|
+
return resolved;
|
|
420
453
|
}
|
|
421
454
|
}
|
|
422
455
|
|
|
@@ -427,20 +460,23 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
427
460
|
}
|
|
428
461
|
}
|
|
429
462
|
|
|
430
|
-
/** Clear instruction-file dedup state after compaction. */
|
|
431
|
-
|
|
463
|
+
/** Clear instruction-file dedup state (surfaced directories, full reads) after compaction. */
|
|
464
|
+
resetInstructionDedup(): void {
|
|
432
465
|
this.#surfacedInstructionDirs.clear();
|
|
466
|
+
this.#fullyReadPaths.clear();
|
|
433
467
|
}
|
|
434
468
|
|
|
435
469
|
/** Reconstruct surfaced instruction directories from branch tool-result details after compaction. */
|
|
436
470
|
reconstructInstructionState(branch: SessionEntry[]): void {
|
|
437
471
|
this.#surfacedInstructionDirs.clear();
|
|
472
|
+
this.#fullyReadPaths.clear();
|
|
438
473
|
const entries = entriesAfterLatestCompaction(branch);
|
|
439
474
|
for (const entry of entries) {
|
|
440
475
|
for (const directory of extractInstructionDirectories(entry)) {
|
|
441
476
|
this.#surfacedInstructionDirs.add(path.resolve(this.cwd, directory));
|
|
442
477
|
}
|
|
443
478
|
}
|
|
479
|
+
for (const filePath of extractFullReadPaths(entries)) this.#markFileReadInFull(filePath);
|
|
444
480
|
}
|
|
445
481
|
|
|
446
482
|
// ── Private session stores ───────────────────────────────────────
|
|
@@ -472,6 +508,7 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
472
508
|
this.#refactorPlans.clear();
|
|
473
509
|
this.#workflowTargets.clear();
|
|
474
510
|
this.#surfacedInstructionDirs.clear();
|
|
511
|
+
this.#fullyReadPaths.clear();
|
|
475
512
|
this.#nativeInstructionPaths.clear();
|
|
476
513
|
this.#maintenanceState = createLspMaintenanceState();
|
|
477
514
|
this.#lspController = null;
|
|
@@ -505,3 +542,41 @@ function extractInstructionDirectories(entry: SessionEntry): string[] {
|
|
|
505
542
|
.map((file) => file.directory)
|
|
506
543
|
.filter((directory): directory is string => typeof directory === "string");
|
|
507
544
|
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Whether a `read` call returned the whole file: no `offset`/`limit`, no error,
|
|
548
|
+
* and no output truncation.
|
|
549
|
+
*/
|
|
550
|
+
function isFullRead(
|
|
551
|
+
input: Record<string, unknown> | undefined,
|
|
552
|
+
isError: boolean,
|
|
553
|
+
details: unknown,
|
|
554
|
+
): input is { path: string } {
|
|
555
|
+
if (isError || typeof input?.path !== "string") return false;
|
|
556
|
+
if (input.offset !== undefined || input.limit !== undefined) return false;
|
|
557
|
+
return (details as ReadToolDetails | undefined)?.truncation?.truncated !== true;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function extractFullReadPaths(entries: SessionEntry[]): string[] {
|
|
561
|
+
const calls = new Map<string, Record<string, unknown>>();
|
|
562
|
+
const paths: string[] = [];
|
|
563
|
+
for (const entry of entries) {
|
|
564
|
+
if (entry.type !== "message") continue;
|
|
565
|
+
const message = entry.message;
|
|
566
|
+
if (message.role === "assistant") collectReadCalls(message.content, calls);
|
|
567
|
+
if (message.role !== "toolResult" || message.toolName !== "read") continue;
|
|
568
|
+
const input = calls.get(message.toolCallId);
|
|
569
|
+
if (isFullRead(input, message.isError, message.details)) paths.push(input.path);
|
|
570
|
+
}
|
|
571
|
+
return paths;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function collectReadCalls(
|
|
575
|
+
content: ReadonlyArray<{ type: string; id?: string; name?: string; arguments?: unknown }>,
|
|
576
|
+
calls: Map<string, Record<string, unknown>>,
|
|
577
|
+
): void {
|
|
578
|
+
for (const item of content) {
|
|
579
|
+
if (item.type !== "toolCall" || item.name !== "read" || typeof item.id !== "string") continue;
|
|
580
|
+
calls.set(item.id, item.arguments as Record<string, unknown>);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
@@ -10,15 +10,15 @@ import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
|
|
|
10
10
|
import { withSemanticRequestControl, withStructuralRequestControl } from "../analysis/provider.ts";
|
|
11
11
|
import { normalizePath, resolveScope } from "../analysis/search/paths.ts";
|
|
12
12
|
import { resolveAnchoredSymbolTarget } from "../analysis/target/anchored.ts";
|
|
13
|
-
import {
|
|
13
|
+
import { resolveFileOutline, validateFileTargetDiscovery } from "../analysis/target/file.ts";
|
|
14
14
|
import {
|
|
15
15
|
canonicalDeclarationKind,
|
|
16
16
|
refineTargetOutcomeIdentity,
|
|
17
17
|
} from "../analysis/target/identity.ts";
|
|
18
18
|
import { resolveSymbolTarget } from "../analysis/target/symbol.ts";
|
|
19
19
|
import type {
|
|
20
|
+
FileOutlineData,
|
|
20
21
|
ResolvedTargetData,
|
|
21
|
-
ResolvedTargetGroupData,
|
|
22
22
|
TargetCandidateCompleteness,
|
|
23
23
|
TargetOutcome,
|
|
24
24
|
} from "../analysis/target/types.ts";
|
|
@@ -58,15 +58,16 @@ export type TargetWorkflowOutcome =
|
|
|
58
58
|
notes: readonly string[];
|
|
59
59
|
}
|
|
60
60
|
| {
|
|
61
|
-
kind: "
|
|
61
|
+
kind: "file-outline";
|
|
62
62
|
file: string;
|
|
63
63
|
confidence: ResolvedTargetData["confidence"];
|
|
64
|
-
discoveryProvenance:
|
|
64
|
+
discoveryProvenance: FileOutlineData["discoveryProvenance"];
|
|
65
65
|
targets: ReadonlyArray<Readonly<TargetStoreEntry>>;
|
|
66
66
|
totalCount: number;
|
|
67
67
|
omittedCount: number;
|
|
68
|
-
|
|
69
|
-
partial?:
|
|
68
|
+
unknownLevelCount: number;
|
|
69
|
+
partial?: FileOutlineData["partial"];
|
|
70
|
+
notListed: FileOutlineData["notListed"];
|
|
70
71
|
}
|
|
71
72
|
| ({
|
|
72
73
|
kind: "disambiguation";
|
|
@@ -266,7 +267,7 @@ async function resolveFileOnlyWorkflow(
|
|
|
266
267
|
return { kind: "unavailable", reason: readiness.reason };
|
|
267
268
|
}
|
|
268
269
|
|
|
269
|
-
const result = await
|
|
270
|
+
const result = await resolveFileOutline(
|
|
270
271
|
file,
|
|
271
272
|
deps.cwd,
|
|
272
273
|
{
|
|
@@ -284,7 +285,7 @@ async function resolveFileOnlyWorkflow(
|
|
|
284
285
|
return { kind: "unavailable", reason: result.message };
|
|
285
286
|
}
|
|
286
287
|
|
|
287
|
-
return
|
|
288
|
+
return registerFileOutline(result.outline, deps, maxResults);
|
|
288
289
|
}
|
|
289
290
|
|
|
290
291
|
function toWorkflowOutcome(
|
|
@@ -317,8 +318,8 @@ function toWorkflowOutcome(
|
|
|
317
318
|
};
|
|
318
319
|
}
|
|
319
320
|
|
|
320
|
-
if (outcome.kind === "
|
|
321
|
-
return
|
|
321
|
+
if (outcome.kind === "file-outline") {
|
|
322
|
+
return registerFileOutline(outcome.outline, deps, policy.maxResults ?? 10);
|
|
322
323
|
}
|
|
323
324
|
|
|
324
325
|
const candidates = registerTargetCandidates(outcome.candidates, deps.registerTarget);
|
|
@@ -342,28 +343,29 @@ function toWorkflowOutcome(
|
|
|
342
343
|
};
|
|
343
344
|
}
|
|
344
345
|
|
|
345
|
-
function
|
|
346
|
-
|
|
346
|
+
function registerFileOutline(
|
|
347
|
+
outline: FileOutlineData,
|
|
347
348
|
deps: TargetWorkflowDeps,
|
|
348
349
|
maxResults: number,
|
|
349
350
|
): TargetWorkflowOutcome {
|
|
350
|
-
const totalCount =
|
|
351
|
-
const visibleTargets =
|
|
352
|
-
const fingerprint = computeFileFingerprint(
|
|
351
|
+
const totalCount = outline.targets.length;
|
|
352
|
+
const visibleTargets = outline.targets.slice(0, Math.max(0, maxResults));
|
|
353
|
+
const fingerprint = computeFileFingerprint(outline.file);
|
|
353
354
|
const fileFingerprint = fingerprint.kind === "ok" ? fingerprint.fingerprint : "unfingerprinted";
|
|
354
355
|
const targets = visibleTargets.map((target) =>
|
|
355
356
|
immutableEntry(registerFromTargetData(target, deps, fileFingerprint).entry),
|
|
356
357
|
);
|
|
357
358
|
return Object.freeze({
|
|
358
|
-
kind: "
|
|
359
|
-
file:
|
|
360
|
-
confidence:
|
|
361
|
-
discoveryProvenance: Object.freeze([...
|
|
359
|
+
kind: "file-outline",
|
|
360
|
+
file: outline.file,
|
|
361
|
+
confidence: outline.confidence,
|
|
362
|
+
discoveryProvenance: Object.freeze([...outline.discoveryProvenance]),
|
|
362
363
|
targets: Object.freeze(targets),
|
|
363
364
|
totalCount,
|
|
364
365
|
omittedCount: totalCount - targets.length,
|
|
365
|
-
|
|
366
|
-
...(
|
|
366
|
+
unknownLevelCount: outline.unknownLevelCount,
|
|
367
|
+
...(outline.partial ? { partial: outline.partial } : {}),
|
|
368
|
+
notListed: outline.notListed,
|
|
367
369
|
});
|
|
368
370
|
}
|
|
369
371
|
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
/** Thin Pi adapter for the session-owned code_find workflow. */
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { FindSearchInput, FindWorkflowInput } from "../../session/find-types.ts";
|
|
4
4
|
import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
5
5
|
import { toWorkflowControl } from "../infra/workflow-control.ts";
|
|
6
|
-
import type { CodeFindAstKind } from "./ast-kinds.ts";
|
|
7
6
|
import { finishFindResult } from "./result.ts";
|
|
8
7
|
|
|
9
8
|
export interface CodeFindToolParams {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
mode: FindMode;
|
|
13
|
-
kind?: CodeFindAstKind;
|
|
9
|
+
search: FindSearchInput;
|
|
10
|
+
scopes?: string[];
|
|
14
11
|
maxResults?: number;
|
|
15
12
|
}
|
|
16
13
|
|
|
@@ -19,5 +16,7 @@ export async function executeFindTool(
|
|
|
19
16
|
ctx: CodeIntelToolExecCtx,
|
|
20
17
|
): Promise<CodeIntelResult> {
|
|
21
18
|
const outcome = await ctx.session.find(params as FindWorkflowInput, toWorkflowControl(ctx));
|
|
22
|
-
|
|
19
|
+
const semantic =
|
|
20
|
+
typeof params.search === "object" && params.search !== null && "semantic" in params.search;
|
|
21
|
+
return finishFindResult(outcome, ctx.cwd, params.scopes, semantic ? "semantic" : "ast");
|
|
23
22
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import type { CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
3
|
-
import {
|
|
4
|
-
import { CODE_FIND_AST_KINDS } from "./ast-kinds.ts";
|
|
3
|
+
import { FindScopesParam, FindSearchParam, MaxResultsParam } from "../schemas.ts";
|
|
5
4
|
import { executeFindTool } from "./execute.ts";
|
|
6
|
-
import { CODE_FIND_MODES } from "./modes.ts";
|
|
7
5
|
import { FindOutputSchema } from "./structured.ts";
|
|
8
6
|
import { renderFindCall, renderFindResult } from "./tui.ts";
|
|
9
7
|
|
|
@@ -14,22 +12,17 @@ export const CODE_FIND_TOOL_LABEL = "Code Find";
|
|
|
14
12
|
export const codeFindSpec = {
|
|
15
13
|
name: CODE_FIND_TOOL_NAME,
|
|
16
14
|
label: CODE_FIND_TOOL_LABEL,
|
|
15
|
+
annotations: {
|
|
16
|
+
readOnlyHint: true,
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
},
|
|
17
21
|
outputSchema: FindOutputSchema,
|
|
18
22
|
parameters: Type.Object(
|
|
19
23
|
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
mode: Type.Enum(CODE_FIND_MODES, {
|
|
23
|
-
type: "string",
|
|
24
|
-
description:
|
|
25
|
-
"Required code-aware search mode. AST mode requires `kind`; semantic mode rejects `kind`.",
|
|
26
|
-
}),
|
|
27
|
-
kind: Type.Optional(
|
|
28
|
-
Type.Enum(CODE_FIND_AST_KINDS, {
|
|
29
|
-
type: "string",
|
|
30
|
-
description: 'AST structure kind; required only for mode:"ast".',
|
|
31
|
-
}),
|
|
32
|
-
),
|
|
24
|
+
search: FindSearchParam,
|
|
25
|
+
scopes: Type.Optional(FindScopesParam),
|
|
33
26
|
maxResults: Type.Optional(MaxResultsParam),
|
|
34
27
|
},
|
|
35
28
|
{ additionalProperties: false },
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type ToolRendererContext,
|
|
9
9
|
type ToolResult,
|
|
10
10
|
} from "../../ui/tui/common.ts";
|
|
11
|
-
import
|
|
11
|
+
import { CODE_FIND_MODES } from "./modes.ts";
|
|
12
12
|
|
|
13
13
|
/** Render the compact code_find call header. */
|
|
14
14
|
export function renderFindCall(
|
|
@@ -16,15 +16,21 @@ export function renderFindCall(
|
|
|
16
16
|
theme: Theme,
|
|
17
17
|
_context: ToolRendererContext | undefined,
|
|
18
18
|
): Text {
|
|
19
|
-
|
|
20
|
-
const
|
|
19
|
+
// Streaming calls arrive partial, so every level is read defensively.
|
|
20
|
+
const search = ((args ?? {}) as { search?: unknown }).search;
|
|
21
|
+
const branches = (search && typeof search === "object" ? search : {}) as Record<
|
|
22
|
+
string,
|
|
23
|
+
{ query?: unknown; kind?: unknown } | undefined
|
|
24
|
+
>;
|
|
25
|
+
const mode = CODE_FIND_MODES.find((candidate) => branches[candidate] !== undefined);
|
|
26
|
+
const branch = (mode ? branches[mode] : undefined) ?? {};
|
|
21
27
|
|
|
22
28
|
let content = theme.fg("toolTitle", "code_find");
|
|
23
|
-
const query = formatCallValue(
|
|
29
|
+
const query = formatCallValue(branch.query);
|
|
24
30
|
if (query) content += ` ${theme.fg("accent", JSON.stringify(query))}`;
|
|
25
|
-
content += ` ${theme.fg("muted", mode)}`;
|
|
31
|
+
content += ` ${theme.fg("muted", mode ?? "mode?")}`;
|
|
26
32
|
|
|
27
|
-
const kind = formatCallValue(
|
|
33
|
+
const kind = formatCallValue(branch.kind, 30);
|
|
28
34
|
if (kind) content += theme.fg("dim", ` [${kind}]`);
|
|
29
35
|
|
|
30
36
|
return new Text(content, 0, 0);
|
|
@@ -45,6 +45,7 @@ export function assembleGraphSection(
|
|
|
45
45
|
maxResults,
|
|
46
46
|
invalidLocationCount: section.data.invalidLocationCount,
|
|
47
47
|
partialReason: section.data.partialReason,
|
|
48
|
+
partialMessage: section.data.partialMessage,
|
|
48
49
|
});
|
|
49
50
|
return {
|
|
50
51
|
...section,
|
|
@@ -94,6 +95,7 @@ export function assembleGraphSection(
|
|
|
94
95
|
maxResults,
|
|
95
96
|
invalidLocationCount: section.data.invalidLocationCount,
|
|
96
97
|
partialReason: section.data.partialReason,
|
|
98
|
+
partialMessage: section.data.partialMessage,
|
|
97
99
|
}),
|
|
98
100
|
};
|
|
99
101
|
}
|
|
@@ -105,6 +107,7 @@ function createRelationEvidenceList<T>(params: {
|
|
|
105
107
|
maxResults: number;
|
|
106
108
|
invalidLocationCount: number;
|
|
107
109
|
partialReason: RelationLocationPartialReason | null;
|
|
110
|
+
partialMessage: string | null;
|
|
108
111
|
}): EvidenceList<T> {
|
|
109
112
|
const evidence =
|
|
110
113
|
params.partialReason === "provider-limited"
|
|
@@ -117,6 +120,7 @@ function createRelationEvidenceList<T>(params: {
|
|
|
117
120
|
...evidence.metadata,
|
|
118
121
|
partialReason: params.partialReason,
|
|
119
122
|
invalidLocationCount: params.invalidLocationCount,
|
|
123
|
+
...(params.partialMessage ? { partialMessage: params.partialMessage } : {}),
|
|
120
124
|
},
|
|
121
125
|
};
|
|
122
126
|
}
|
|
@@ -12,6 +12,12 @@ export const CODE_GRAPH_TOOL_LABEL = "Code Graph";
|
|
|
12
12
|
export const codeGraphSpec = {
|
|
13
13
|
name: CODE_GRAPH_TOOL_NAME,
|
|
14
14
|
label: CODE_GRAPH_TOOL_LABEL,
|
|
15
|
+
annotations: {
|
|
16
|
+
readOnlyHint: true,
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
},
|
|
15
21
|
outputSchema: GraphOutputSchema,
|
|
16
22
|
parameters: Type.Object(
|
|
17
23
|
{
|
|
@@ -12,6 +12,12 @@ export const CODE_HEALTH_TOOL_LABEL = "Code Health";
|
|
|
12
12
|
export const codeHealthSpec = {
|
|
13
13
|
name: CODE_HEALTH_TOOL_NAME,
|
|
14
14
|
label: CODE_HEALTH_TOOL_LABEL,
|
|
15
|
+
annotations: {
|
|
16
|
+
readOnlyHint: true,
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
},
|
|
15
21
|
parameters: Type.Object(
|
|
16
22
|
{
|
|
17
23
|
scope: Type.Optional(ScopeParam),
|
|
@@ -77,14 +77,14 @@ const operation = object({
|
|
|
77
77
|
server: Type.Enum(["advertised", "not-advertised", "unknown"], { type: "string" }),
|
|
78
78
|
supi: Type.Enum(["supported", "limited", "unsupported"], { type: "string" }),
|
|
79
79
|
reason: Type.Optional(Type.String()),
|
|
80
|
+
kinds: Type.Optional(Type.Array(Type.String())),
|
|
81
|
+
anyKind: Type.Optional(Type.Boolean()),
|
|
80
82
|
});
|
|
81
83
|
const support = object({
|
|
82
84
|
rename_symbol: Type.Optional(operation),
|
|
83
85
|
prepare_rename: Type.Optional(operation),
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
update_imports: Type.Optional(operation),
|
|
87
|
-
delete_dead_code: Type.Optional(operation),
|
|
86
|
+
code_action: Type.Optional(operation),
|
|
87
|
+
source_action: Type.Optional(operation),
|
|
88
88
|
code_action_resolve: Type.Optional(operation),
|
|
89
89
|
});
|
|
90
90
|
const server = object({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DiagnosticEvidenceSummary } from "@mrclrchtr/supi-lsp/api";
|
|
1
|
+
import type { DiagnosticEvidenceSummary, ServerOperationSupport } from "@mrclrchtr/supi-lsp/api";
|
|
2
2
|
import type { Static } from "typebox";
|
|
3
3
|
import type {
|
|
4
4
|
HealthData,
|
|
@@ -166,10 +166,8 @@ export function structuredHealthResult(data: HealthData): Output {
|
|
|
166
166
|
const operations = [
|
|
167
167
|
"rename_symbol",
|
|
168
168
|
"prepare_rename",
|
|
169
|
-
"
|
|
170
|
-
"
|
|
171
|
-
"update_imports",
|
|
172
|
-
"delete_dead_code",
|
|
169
|
+
"code_action",
|
|
170
|
+
"source_action",
|
|
173
171
|
"code_action_resolve",
|
|
174
172
|
] as const;
|
|
175
173
|
const servers = data.servers.map(
|
|
@@ -197,18 +195,7 @@ export function structuredHealthResult(data: HealthData): Output {
|
|
|
197
195
|
operationSupport: Object.fromEntries(
|
|
198
196
|
operations.flatMap((key) => {
|
|
199
197
|
const item = operationSupport[key];
|
|
200
|
-
return item
|
|
201
|
-
? [
|
|
202
|
-
[
|
|
203
|
-
key,
|
|
204
|
-
{
|
|
205
|
-
server: item.server,
|
|
206
|
-
supi: item.supi,
|
|
207
|
-
...(item.reason === undefined ? {} : { reason: item.reason }),
|
|
208
|
-
},
|
|
209
|
-
],
|
|
210
|
-
]
|
|
211
|
-
: [];
|
|
198
|
+
return item ? [[key, structuredOperationSupport(item)]] : [];
|
|
212
199
|
}),
|
|
213
200
|
),
|
|
214
201
|
}
|
|
@@ -254,3 +241,14 @@ export function structuredHealthResult(data: HealthData): Output {
|
|
|
254
241
|
: {}),
|
|
255
242
|
} as Output;
|
|
256
243
|
}
|
|
244
|
+
|
|
245
|
+
/** Copy one operation-support entry, omitting absent optional fields. */
|
|
246
|
+
function structuredOperationSupport(item: ServerOperationSupport) {
|
|
247
|
+
return {
|
|
248
|
+
server: item.server,
|
|
249
|
+
supi: item.supi,
|
|
250
|
+
...(item.reason === undefined ? {} : { reason: item.reason }),
|
|
251
|
+
...(item.kinds === undefined ? {} : { kinds: [...item.kinds] }),
|
|
252
|
+
...(item.anyKind ? { anyKind: true } : {}),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
@@ -32,13 +32,13 @@ function renderNode(
|
|
|
32
32
|
appendSyntaxRecovery(lines, observation.recovery);
|
|
33
33
|
const node = observation.data;
|
|
34
34
|
if (!node) {
|
|
35
|
-
lines.push("_No syntax node at this
|
|
35
|
+
lines.push("_No syntax node at this anchor._", "");
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
lines.push(
|
|
39
39
|
`- \`${node.type}\` L${node.startLine}:${node.startCharacter}–L${node.endLine}:${node.endCharacter}`,
|
|
40
40
|
);
|
|
41
|
-
if (node.text) lines
|
|
41
|
+
if (node.text) appendNodeText(lines, node);
|
|
42
42
|
if (node.ancestry.length > 0) {
|
|
43
43
|
lines.push(
|
|
44
44
|
`Ancestry: ${node.ancestry.map((ancestor) => `\`${ancestor.type} L${ancestor.startLine}:${ancestor.startCharacter}–L${ancestor.endLine}:${ancestor.endCharacter}\``).join(" > ")}`,
|
|
@@ -47,6 +47,33 @@ function renderNode(
|
|
|
47
47
|
lines.push("");
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/** Preview bounds for syntax-node text; a whitespace anchor selects the whole file's root node. */
|
|
51
|
+
const NODE_TEXT_MAX_LINES = 12;
|
|
52
|
+
const NODE_TEXT_MAX_CHARACTERS = 1200;
|
|
53
|
+
|
|
54
|
+
/** Print a bounded preview of the node text; the range above locates the rest. */
|
|
55
|
+
function appendNodeText(
|
|
56
|
+
lines: string[],
|
|
57
|
+
node: { text: string; startLine: number; endLine: number },
|
|
58
|
+
): void {
|
|
59
|
+
const textLines = node.text.split("\n");
|
|
60
|
+
let shown = textLines.slice(0, NODE_TEXT_MAX_LINES).join("\n");
|
|
61
|
+
// Array.from keeps surrogate pairs whole when a single long line is cut.
|
|
62
|
+
const characters = Array.from(shown);
|
|
63
|
+
if (characters.length > NODE_TEXT_MAX_CHARACTERS) {
|
|
64
|
+
shown = characters.slice(0, NODE_TEXT_MAX_CHARACTERS).join("");
|
|
65
|
+
}
|
|
66
|
+
lines.push("```text", shown, "```");
|
|
67
|
+
if (shown.length === node.text.length) return;
|
|
68
|
+
const preview =
|
|
69
|
+
textLines.length > NODE_TEXT_MAX_LINES
|
|
70
|
+
? `first ${NODE_TEXT_MAX_LINES} of ${textLines.length} lines`
|
|
71
|
+
: `first ${NODE_TEXT_MAX_CHARACTERS} characters`;
|
|
72
|
+
lines.push(
|
|
73
|
+
`_Node text shortened to the ${preview}; read L${node.startLine}–L${node.endLine} for the rest._`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
50
77
|
function renderEnclosingSymbol(
|
|
51
78
|
lines: string[],
|
|
52
79
|
observation: InspectResultAssembly["data"]["sections"]["enclosingSymbol"],
|
|
@@ -60,7 +87,7 @@ function renderEnclosingSymbol(
|
|
|
60
87
|
appendSyntaxRecovery(lines, observation.recovery);
|
|
61
88
|
const symbol = observation.data;
|
|
62
89
|
if (!symbol) {
|
|
63
|
-
lines.push("_No provider-reported declaration encloses this
|
|
90
|
+
lines.push("_No provider-reported declaration encloses this anchor._", "");
|
|
64
91
|
return;
|
|
65
92
|
}
|
|
66
93
|
lines.push(
|
|
@@ -79,7 +106,7 @@ function renderHover(
|
|
|
79
106
|
return;
|
|
80
107
|
}
|
|
81
108
|
appendPartial(lines, observation);
|
|
82
|
-
lines.push(observation.data ?? "_No hover result at this
|
|
109
|
+
lines.push(observation.data ?? "_No hover result at this anchor._", "");
|
|
83
110
|
}
|
|
84
111
|
|
|
85
112
|
function renderDefinitions(lines: string[], assembly: InspectResultAssembly): void {
|
|
@@ -88,7 +115,7 @@ function renderDefinitions(lines: string[], assembly: InspectResultAssembly): vo
|
|
|
88
115
|
if (appendUnavailable(lines, observation)) return;
|
|
89
116
|
appendPartial(lines, observation);
|
|
90
117
|
if (assembly.displayedDefinitions.length === 0) {
|
|
91
|
-
lines.push("_No definition result at this
|
|
118
|
+
lines.push("_No definition result at this anchor._");
|
|
92
119
|
} else {
|
|
93
120
|
for (const definition of assembly.displayedDefinitions) {
|
|
94
121
|
lines.push(`- ${formatDefinition(definition, assembly.data)}`);
|
|
@@ -109,7 +136,7 @@ function formatDefinition(
|
|
|
109
136
|
return `\`${definition.file}:${definition.line}:${definition.character}\``;
|
|
110
137
|
}
|
|
111
138
|
if (definition.line === focus.line && definition.character === focus.character)
|
|
112
|
-
return "Same
|
|
139
|
+
return "Same anchor";
|
|
113
140
|
return `L${definition.line}:${definition.character}`;
|
|
114
141
|
}
|
|
115
142
|
|
|
@@ -336,7 +336,7 @@ type InspectOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["inspec
|
|
|
336
336
|
export function finishInspectResult(outcome: InspectOutcome): CodeIntelResult {
|
|
337
337
|
if (outcome.kind === "unavailable") throw new Error(outcome.reason);
|
|
338
338
|
if (outcome.kind === "invalid-input") {
|
|
339
|
-
const nextQueries = ["Provide an existing file and exact 1-based
|
|
339
|
+
const nextQueries = ["Provide an existing file and exact 1-based anchor"];
|
|
340
340
|
return {
|
|
341
341
|
...inspectErrorResult(`**Error:** ${outcome.message}`, {
|
|
342
342
|
focusTarget: "invalid input",
|
|
@@ -12,15 +12,23 @@ export const CODE_INSPECT_TOOL_LABEL = "Code Inspect";
|
|
|
12
12
|
export const codeInspectSpec = {
|
|
13
13
|
name: CODE_INSPECT_TOOL_NAME,
|
|
14
14
|
label: CODE_INSPECT_TOOL_LABEL,
|
|
15
|
+
annotations: {
|
|
16
|
+
readOnlyHint: true,
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
},
|
|
15
21
|
outputSchema: InspectOutputSchema,
|
|
16
22
|
parameters: Type.Object(
|
|
17
23
|
{
|
|
18
|
-
|
|
19
|
-
maxResults: Type.Optional(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
anchor: SourcePointParam,
|
|
25
|
+
maxResults: Type.Optional(
|
|
26
|
+
Type.Integer({
|
|
27
|
+
...MaxResultsParam,
|
|
28
|
+
description:
|
|
29
|
+
"Maximum entries per definition or diagnostic list; does not limit syntax or hover text.",
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
24
32
|
},
|
|
25
33
|
{ additionalProperties: false },
|
|
26
34
|
),
|
|
@@ -78,7 +78,7 @@ export const InspectOutputSchema = Type.Union([
|
|
|
78
78
|
Type.Object(
|
|
79
79
|
{
|
|
80
80
|
kind: Type.Literal("completed"),
|
|
81
|
-
|
|
81
|
+
anchor: Type.Object(
|
|
82
82
|
{ file: Type.String(), line: Type.Integer(), character: Type.Integer() },
|
|
83
83
|
{ additionalProperties: false },
|
|
84
84
|
),
|
|
@@ -141,7 +141,7 @@ export function structuredInspectResult(
|
|
|
141
141
|
const { data, assembled } = assembly;
|
|
142
142
|
return {
|
|
143
143
|
kind: "completed",
|
|
144
|
-
|
|
144
|
+
anchor: { file: data.relPath, line: data.line, character: data.character },
|
|
145
145
|
confidence: data.confidence,
|
|
146
146
|
diagnosticWindow: {
|
|
147
147
|
startLine: data.diagnosticWindow.startLine,
|