@mrclrchtr/supi-code-intelligence 11.2.0 → 11.3.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 +19 -0
- package/README.md +16 -6
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
- package/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +39 -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/capability/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -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/child-web-tools.ts +110 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +11 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +77 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +149 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-typescript-project.ts +40 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +151 -44
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +157 -23
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +254 -56
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +19 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +2 -2
- 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/capability/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -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/child-web-tools.ts +110 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
- 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/tool/call-sites.ts +40 -25
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/call-context.ts +44 -0
- package/package.json +6 -5
- package/src/analysis/health/server-status.ts +6 -2
- package/src/analysis/search/exclusions.ts +47 -0
- package/src/analysis/search/paths.ts +32 -9
- package/src/analysis/target/anchored-structural.ts +3 -8
- package/src/analysis/target/anchored.ts +4 -20
- package/src/analysis/target/identity.ts +1 -1
- package/src/analysis/target/latex-label-container.ts +6 -6
- package/src/analysis/target/latex-section-anchor.ts +6 -6
- package/src/analysis/target/resolution.ts +18 -0
- package/src/analysis/target/symbol.ts +39 -11
- package/src/analysis/target/types.ts +6 -1
- package/src/extension.ts +17 -11
- package/src/session/graph/collect.ts +1 -10
- package/src/session/graph-types.ts +2 -0
- package/src/session/graph-workflow.ts +1 -0
- package/src/session/inspect/collect.ts +8 -2
- package/src/session/inspect/file-point.ts +2 -3
- package/src/session/inspect-workflow.ts +1 -1
- package/src/session/orientation/collect.ts +54 -16
- package/src/session/orientation/context-sections.ts +2 -3
- package/src/session/orientation/facts.ts +9 -1
- package/src/session/orientation-types.ts +3 -0
- package/src/session/orientation-workflow.ts +18 -5
- package/src/session/refactor-identity.ts +76 -0
- package/src/session/refactor-workflow.ts +11 -14
- package/src/session/target-store.ts +3 -18
- package/src/session/target-workflow.ts +33 -16
- package/src/substrate/lsp/recovery.ts +5 -5
- package/src/tool/code_find/render.ts +8 -4
- package/src/tool/code_find/result.ts +78 -6
- package/src/tool/code_find/spec.ts +4 -3
- package/src/tool/code_find/structured.ts +25 -9
- package/src/tool/code_graph/details.ts +1 -0
- package/src/tool/code_graph/display.ts +1 -1
- package/src/tool/code_graph/guidance.ts +1 -1
- package/src/tool/code_graph/markdown.ts +11 -6
- package/src/tool/code_graph/read-next.ts +38 -9
- package/src/tool/code_graph/reference-selection.ts +30 -0
- package/src/tool/code_graph/result.ts +25 -118
- package/src/tool/code_graph/section.ts +133 -0
- package/src/tool/code_graph/spec.ts +3 -3
- package/src/tool/code_graph/structured.ts +17 -6
- package/src/tool/code_health/display-paths.ts +92 -0
- package/src/tool/code_health/file-scope-markdown.ts +3 -2
- package/src/tool/code_health/result.ts +4 -2
- package/src/tool/code_health/spec.ts +3 -3
- package/src/tool/code_health/structured-schema.ts +44 -44
- package/src/tool/code_inspect/spec.ts +5 -1
- package/src/tool/code_inspect/structured.ts +1 -2
- package/src/tool/code_orientation/execute.ts +1 -1
- package/src/tool/code_orientation/result.ts +22 -5
- package/src/tool/code_orientation/structured-schema.ts +46 -36
- package/src/tool/code_orientation/structured-workspace.ts +2 -1
- package/src/tool/code_orientation/structured.ts +6 -12
- package/src/tool/code_orientation/workspace-format.ts +2 -5
- package/src/tool/code_orientation/workspace-sections.ts +3 -2
- package/src/tool/code_refactor_apply/result.ts +1 -1
- package/src/tool/code_refactor_plan/result.ts +2 -1
- package/src/tool/code_refactor_plan/structured.ts +2 -3
- package/src/tool/code_resolve/markdown.ts +6 -30
- package/src/tool/code_resolve/result.ts +24 -11
- package/src/tool/code_resolve/structured.ts +7 -9
- package/src/tool/result/refactor.ts +8 -5
- package/src/tool/result/structured.ts +8 -5
- package/src/tool/result/types.ts +18 -14
- package/src/tool/schemas.ts +5 -5
- package/src/ui/status-command.ts +37 -1
- package/src/ui/status-overlay.ts +70 -51
- package/src/ui/status-presentation.ts +108 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Session-provided Web tools for SuPi child sessions (Agent Runs and Reviewer Sessions).
|
|
2
|
+
//
|
|
3
|
+
// The loaded supi-web extension answers a synchronous request on the parent event bus.
|
|
4
|
+
// Consumers never depend on supi-web; when it is absent or provides no tools, the
|
|
5
|
+
// request returns undefined and the child simply lacks Web tools.
|
|
6
|
+
|
|
7
|
+
import type { ExtensionAPI, ExtensionFactory } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
|
|
9
|
+
/** Web tools that child sessions may receive when the containing session provides them. */
|
|
10
|
+
export const CHILD_WEB_TOOL_NAMES = [
|
|
11
|
+
"web_fetch_md",
|
|
12
|
+
"web_search",
|
|
13
|
+
"web_docs_search",
|
|
14
|
+
"web_docs_fetch",
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
17
|
+
/** One session-provided Web tool name. */
|
|
18
|
+
export type ChildWebToolName = (typeof CHILD_WEB_TOOL_NAMES)[number];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Web tools currently callable in the containing session plus a child-only extension
|
|
22
|
+
* factory that registers them. The factory must not capture the parent session; it may
|
|
23
|
+
* capture plain data such as the containing session's configuration directory.
|
|
24
|
+
*/
|
|
25
|
+
export interface ChildWebToolProvision {
|
|
26
|
+
readonly toolNames: readonly ChildWebToolName[];
|
|
27
|
+
/** Register the requested subset of `toolNames` in a child session. */
|
|
28
|
+
readonly createFactory: (toolNames: readonly ChildWebToolName[]) => ExtensionFactory;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Plain containing-session data supplied with a child Web tool request. */
|
|
32
|
+
export interface ChildWebToolsRequestContext {
|
|
33
|
+
/**
|
|
34
|
+
* Working directory whose SuPi configuration governs Web settings such as Firecrawl.
|
|
35
|
+
* Children with a different cwd (for example a frozen Review Workspace) keep this policy.
|
|
36
|
+
*/
|
|
37
|
+
readonly configCwd: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type EventBusLike = Pick<ExtensionAPI["events"], "on" | "emit">;
|
|
41
|
+
|
|
42
|
+
const REQUEST_CHANNEL = "supi:child-web-tools:request";
|
|
43
|
+
const RESPONSE_CHANNEL = "supi:child-web-tools:response";
|
|
44
|
+
|
|
45
|
+
interface ChildWebToolsRequest extends ChildWebToolsRequestContext {
|
|
46
|
+
readonly requestId: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface ChildWebToolsResponse {
|
|
50
|
+
readonly requestId: string;
|
|
51
|
+
readonly provision: ChildWebToolProvision;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let nextRequestId = 0;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Answer child Web tool requests on the parent event bus. The callback must be synchronous
|
|
58
|
+
* because Pi's event bus does not await listeners. Returns an unsubscribe function.
|
|
59
|
+
*/
|
|
60
|
+
export function provideChildWebTools(
|
|
61
|
+
events: EventBusLike,
|
|
62
|
+
resolve: (context: ChildWebToolsRequestContext) => ChildWebToolProvision | undefined,
|
|
63
|
+
): () => void {
|
|
64
|
+
return events.on(REQUEST_CHANNEL, (data) => {
|
|
65
|
+
const request = data as Partial<ChildWebToolsRequest> | undefined;
|
|
66
|
+
if (typeof request?.requestId !== "string" || typeof request.configCwd !== "string") return;
|
|
67
|
+
const { requestId, configCwd } = request;
|
|
68
|
+
const provision = resolve({ configCwd });
|
|
69
|
+
if (!provision || provision.toolNames.length === 0) return;
|
|
70
|
+
events.emit(RESPONSE_CHANNEL, { requestId, provision } satisfies ChildWebToolsResponse);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Capture the Web tools the containing session currently provides, if any. */
|
|
75
|
+
export function requestChildWebTools(
|
|
76
|
+
events: EventBusLike,
|
|
77
|
+
context: ChildWebToolsRequestContext,
|
|
78
|
+
): ChildWebToolProvision | undefined {
|
|
79
|
+
const requestId = `child-web-${process.pid}-${++nextRequestId}`;
|
|
80
|
+
let provision: ChildWebToolProvision | undefined;
|
|
81
|
+
const unsubscribe = events.on(RESPONSE_CHANNEL, (data) => {
|
|
82
|
+
const response = data as Partial<ChildWebToolsResponse> | undefined;
|
|
83
|
+
if (response?.requestId === requestId && response.provision) provision = response.provision;
|
|
84
|
+
});
|
|
85
|
+
try {
|
|
86
|
+
events.emit(REQUEST_CHANNEL, { requestId, ...context } satisfies ChildWebToolsRequest);
|
|
87
|
+
} finally {
|
|
88
|
+
unsubscribe();
|
|
89
|
+
}
|
|
90
|
+
return provision;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Return the Web tools callable in a session under Pi's exposure rules: active `direct`
|
|
95
|
+
* tools, plus registered `codemode` and `deferred` tools. `model-only` and `hidden`
|
|
96
|
+
* tools are not callable.
|
|
97
|
+
*/
|
|
98
|
+
export function callableChildWebToolNames(
|
|
99
|
+
pi: Pick<ExtensionAPI, "getAllTools" | "getActiveTools">,
|
|
100
|
+
): ChildWebToolName[] {
|
|
101
|
+
const active = new Set(pi.getActiveTools());
|
|
102
|
+
const exposures = new Map(
|
|
103
|
+
pi.getAllTools().map((tool) => [tool.name, tool.exposure ?? "direct"] as const),
|
|
104
|
+
);
|
|
105
|
+
return CHILD_WEB_TOOL_NAMES.filter((name) => {
|
|
106
|
+
const exposure = exposures.get(name);
|
|
107
|
+
if (exposure === "direct") return active.has(name);
|
|
108
|
+
return exposure === "codemode" || exposure === "deferred";
|
|
109
|
+
});
|
|
110
|
+
}
|
package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
// supi-core session domain — session utilities and registries.
|
|
2
2
|
|
|
3
|
+
export type {
|
|
4
|
+
ChildWebToolName,
|
|
5
|
+
ChildWebToolProvision,
|
|
6
|
+
ChildWebToolsRequestContext,
|
|
7
|
+
} from "./child-web-tools.ts";
|
|
8
|
+
export {
|
|
9
|
+
CHILD_WEB_TOOL_NAMES,
|
|
10
|
+
callableChildWebToolNames,
|
|
11
|
+
provideChildWebTools,
|
|
12
|
+
requestChildWebTools,
|
|
13
|
+
} from "./child-web-tools.ts";
|
|
3
14
|
export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
|
|
4
15
|
export type {
|
|
5
16
|
SessionCapabilitySkill,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-tree-sitter",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.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.0",
|
|
39
|
-
"@mrclrchtr/supi-code-runtime": "11.
|
|
40
|
-
"@mrclrchtr/supi-core": "11.
|
|
39
|
+
"@mrclrchtr/supi-code-runtime": "11.3.0",
|
|
40
|
+
"@mrclrchtr/supi-core": "11.3.0"
|
|
41
41
|
},
|
|
42
42
|
"bundledDependencies": [
|
|
43
43
|
"@mrclrchtr/supi-code-runtime",
|
package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm
CHANGED
|
Binary file
|
package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json
CHANGED
|
@@ -18,7 +18,11 @@
|
|
|
18
18
|
{
|
|
19
19
|
"id": "import-types-as-primary-types-v1",
|
|
20
20
|
"file": "common/define-grammar.js"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "import-type-generic-calls-v1",
|
|
24
|
+
"file": "common/define-grammar.js"
|
|
21
25
|
}
|
|
22
26
|
],
|
|
23
|
-
"sha256": "
|
|
27
|
+
"sha256": "aaa2904a00000d8e058708845172bd3ce7836566c7e16e9ee594c43f4ba4f451"
|
|
24
28
|
}
|
|
Binary file
|
|
@@ -18,7 +18,11 @@
|
|
|
18
18
|
{
|
|
19
19
|
"id": "import-types-as-primary-types-v1",
|
|
20
20
|
"file": "common/define-grammar.js"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "import-type-generic-calls-v1",
|
|
24
|
+
"file": "common/define-grammar.js"
|
|
21
25
|
}
|
|
22
26
|
],
|
|
23
|
-
"sha256": "
|
|
27
|
+
"sha256": "86ba3af6f8214c90f32af1ea82214a0c1da87c9e2f5ea47c19577ba5b6c78bfb"
|
|
24
28
|
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
|
|
4
4
|
import type { CallSiteMatch, GrammarId, TreeSitterResult } from "../types.ts";
|
|
5
|
-
import
|
|
5
|
+
import { isTypeOnlyImportCapture } from "../worker/call-context.ts";
|
|
6
|
+
import { queryParsedFile, type TreeSitterRuntime } from "../worker/runtime.ts";
|
|
6
7
|
import { normalizeCallName } from "./call-name.ts";
|
|
7
8
|
|
|
8
9
|
// ── Per-grammar call-site queries ─────────────────────────────────────
|
|
@@ -66,33 +67,47 @@ export async function extractCallSites(
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
70
|
+
const parsed = await runtime.parseFile(filePath, control);
|
|
71
|
+
if (parsed.kind !== "success") return parsed;
|
|
72
|
+
const { tree, source } = parsed.data;
|
|
73
|
+
try {
|
|
74
|
+
const queryResult = await queryParsedFile(runtime, {
|
|
75
|
+
file: filePath,
|
|
76
|
+
grammarId,
|
|
77
|
+
tree,
|
|
78
|
+
source,
|
|
79
|
+
queryString: queryStr,
|
|
80
|
+
control,
|
|
81
|
+
});
|
|
82
|
+
if (queryResult.kind !== "success" && queryResult.kind !== "partial") return queryResult;
|
|
71
83
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const matches: CallSiteMatch[] = [];
|
|
84
|
+
const seen = new Set<string>();
|
|
85
|
+
const matches: CallSiteMatch[] = [];
|
|
75
86
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
for (const capture of queryResult.data) {
|
|
88
|
+
if (isTypeOnlyImportCapture(tree.rootNode, capture, grammarId)) continue;
|
|
89
|
+
// Normalize: trim whitespace and collapse internal whitespace to single space
|
|
90
|
+
const name = normalizeCallName(capture.text, grammarId, capture.nodeType);
|
|
91
|
+
if (name.length === 0) continue;
|
|
80
92
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
// Collapse duplicate captures only when they identify the same source range.
|
|
94
|
+
const key = `${capture.range.startLine}:${capture.range.startCharacter}:${capture.range.endLine}:${capture.range.endCharacter}`;
|
|
95
|
+
if (seen.has(key)) continue;
|
|
96
|
+
seen.add(key);
|
|
85
97
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
matches.push({
|
|
99
|
+
name,
|
|
100
|
+
startLine: capture.range.startLine,
|
|
101
|
+
startCharacter: capture.range.startCharacter,
|
|
102
|
+
endLine: capture.range.endLine,
|
|
103
|
+
endCharacter: capture.range.endCharacter,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
94
106
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
return queryResult.kind === "partial"
|
|
108
|
+
? { ...queryResult, data: matches }
|
|
109
|
+
: { kind: "success", data: matches };
|
|
110
|
+
} finally {
|
|
111
|
+
tree.delete();
|
|
112
|
+
}
|
|
98
113
|
}
|
|
@@ -6,6 +6,7 @@ import { validatePublicPositionBounds } from "../coordinates.ts";
|
|
|
6
6
|
import { withSyntaxCompleteness } from "../syntax-errors.ts";
|
|
7
7
|
import type { SyntaxNodeLike } from "../syntax-node.ts";
|
|
8
8
|
import type { GrammarId, SourceRange, TreeSitterResult } from "../types.ts";
|
|
9
|
+
import { isTypeOnlyImportCapture } from "../worker/call-context.ts";
|
|
9
10
|
import { queryParsedFile, type TreeSitterRuntime } from "../worker/runtime.ts";
|
|
10
11
|
import { normalizeCallName } from "./call-name.ts";
|
|
11
12
|
import { createCalleeDisplayName, createSourceLineStarts } from "./callee-display-name.ts";
|
|
@@ -384,6 +385,7 @@ function filterCalleeCaptures(
|
|
|
384
385
|
if (isInInner) continue;
|
|
385
386
|
}
|
|
386
387
|
|
|
388
|
+
if (isTypeOnlyImportCapture(enclosingNode, capture, grammarId)) continue;
|
|
387
389
|
const name = normalizeCallName(capture.text, grammarId, capture.nodeType);
|
|
388
390
|
const rangeKey = sourceRangeKey(capture.range);
|
|
389
391
|
if (name.length === 0 || seenRanges.has(rangeKey)) continue;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Node } from "web-tree-sitter";
|
|
2
|
+
import type { GrammarId, QueryCapture } from "../types.ts";
|
|
3
|
+
|
|
4
|
+
const TYPE_ONLY_CONTEXTS = new Set([
|
|
5
|
+
"type_annotation",
|
|
6
|
+
"type_arguments",
|
|
7
|
+
"type_parameters",
|
|
8
|
+
"type_alias_declaration",
|
|
9
|
+
"type_query",
|
|
10
|
+
"type_predicate",
|
|
11
|
+
"interface_declaration",
|
|
12
|
+
"implements_clause",
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Tree-sitter aliases TypeScript import types to call-expression nodes.
|
|
17
|
+
* Exclude those erased references without dropping dynamic import expressions.
|
|
18
|
+
*/
|
|
19
|
+
export function isTypeOnlyImportCapture(
|
|
20
|
+
root: Node,
|
|
21
|
+
capture: Pick<QueryCapture, "nodeType" | "range">,
|
|
22
|
+
grammarId: GrammarId,
|
|
23
|
+
): boolean {
|
|
24
|
+
if (capture.nodeType !== "import" || (grammarId !== "typescript" && grammarId !== "tsx")) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let node = root.descendantForPosition(
|
|
29
|
+
{ row: capture.range.startLine - 1, column: capture.range.startCharacter - 1 },
|
|
30
|
+
{ row: capture.range.endLine - 1, column: capture.range.endCharacter - 1 },
|
|
31
|
+
);
|
|
32
|
+
while (node?.parent) {
|
|
33
|
+
const parent = node.parent;
|
|
34
|
+
if (TYPE_ONLY_CONTEXTS.has(parent.type)) return true;
|
|
35
|
+
if (parent.type === "as_expression" || parent.type === "satisfies_expression") {
|
|
36
|
+
const value = parent.firstNamedChild;
|
|
37
|
+
if (value && (node.startIndex !== value.startIndex || node.endIndex !== value.endIndex)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
node = parent;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-intelligence",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"description": "LSP and AST navigation, search, diagnostics, and refactoring",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"type": "module",
|
|
33
33
|
"files": [
|
|
34
|
+
"CHANGELOG.md",
|
|
34
35
|
"src/**/*.ts",
|
|
35
36
|
"gradle-helper/lib/*.jar",
|
|
36
37
|
"gradle-helper/licenses/**",
|
|
@@ -42,10 +43,10 @@
|
|
|
42
43
|
"ignore": "^7.0.12",
|
|
43
44
|
"smol-toml": "^1.9.1",
|
|
44
45
|
"yaml": "^2.9.0",
|
|
45
|
-
"@mrclrchtr/supi-code-runtime": "11.
|
|
46
|
-
"@mrclrchtr/supi-
|
|
47
|
-
"@mrclrchtr/supi-
|
|
48
|
-
"@mrclrchtr/supi-
|
|
46
|
+
"@mrclrchtr/supi-code-runtime": "11.3.0",
|
|
47
|
+
"@mrclrchtr/supi-lsp": "11.3.0",
|
|
48
|
+
"@mrclrchtr/supi-tree-sitter": "11.3.0",
|
|
49
|
+
"@mrclrchtr/supi-core": "11.3.0"
|
|
49
50
|
},
|
|
50
51
|
"bundledDependencies": [
|
|
51
52
|
"@mrclrchtr/supi-code-runtime",
|
|
@@ -45,9 +45,13 @@ export function formatProjectServerRouteStatusCounts(
|
|
|
45
45
|
return parts.length > 0 ? `workspace routes: ${parts.join(", ")}` : null;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
/** Render
|
|
48
|
+
/** Render observed route roots relatively inside the workspace and absolutely outside, without resolving aliases. */
|
|
49
49
|
export function formatProjectServerRoot(cwd: string, root: string): string {
|
|
50
|
-
const
|
|
50
|
+
const absolute = path.resolve(cwd, root);
|
|
51
|
+
const relative = path.relative(cwd, absolute);
|
|
52
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
53
|
+
return absolute;
|
|
54
|
+
}
|
|
51
55
|
return (relative || ".").replaceAll("\\", "/");
|
|
52
56
|
}
|
|
53
57
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CodeQueryPartialMetadata } from "@mrclrchtr/supi-code-runtime/api";
|
|
2
|
+
import { toDisplayPath } from "./paths.ts";
|
|
3
|
+
|
|
4
|
+
/** Excluded provider observations, distinct from navigable canonical source locations. */
|
|
5
|
+
export interface AutomaticPathExclusionDisplay {
|
|
6
|
+
readonly excludedCount: number;
|
|
7
|
+
readonly examples: readonly {
|
|
8
|
+
/** Original policy observation; intentionally not canonicalized. */
|
|
9
|
+
readonly observedPath: string;
|
|
10
|
+
/** Canonical workspace-relative or external absolute navigation path. */
|
|
11
|
+
readonly canonicalPath: string;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Project typed exclusion evidence without rewriting provider prose or source identities. */
|
|
16
|
+
export function displayAutomaticPathExclusion(
|
|
17
|
+
exclusion: CodeQueryPartialMetadata["automaticPathExclusion"],
|
|
18
|
+
cwd: string,
|
|
19
|
+
): AutomaticPathExclusionDisplay | undefined {
|
|
20
|
+
return exclusion
|
|
21
|
+
? {
|
|
22
|
+
excludedCount: exclusion.excludedCount,
|
|
23
|
+
examples: exclusion.examples.map((observedPath) => ({
|
|
24
|
+
observedPath,
|
|
25
|
+
canonicalPath: toDisplayPath(cwd, observedPath),
|
|
26
|
+
})),
|
|
27
|
+
}
|
|
28
|
+
: undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Explain which observed path was excluded even when a matching canonical source was retained. */
|
|
32
|
+
export function describeExcludedPath(
|
|
33
|
+
example: AutomaticPathExclusionDisplay["examples"][number],
|
|
34
|
+
): string {
|
|
35
|
+
return `observed \`${example.observedPath}\` → canonical \`${example.canonicalPath}\``;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Preserve provider failure reasons and append path explanations from typed metadata only. */
|
|
39
|
+
export function describePartialQuery(
|
|
40
|
+
reason: string,
|
|
41
|
+
metadata: CodeQueryPartialMetadata | undefined,
|
|
42
|
+
cwd: string,
|
|
43
|
+
): string {
|
|
44
|
+
const exclusion = displayAutomaticPathExclusion(metadata?.automaticPathExclusion, cwd);
|
|
45
|
+
if (!exclusion?.examples.length) return reason;
|
|
46
|
+
return `${reason} Excluded path examples: ${exclusion.examples.map(describeExcludedPath).join(", ")}.`;
|
|
47
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import { resolveToolPath } from "@mrclrchtr/supi-core/path";
|
|
3
|
+
import { resolveToolPath, uriToFile } from "@mrclrchtr/supi-core/path";
|
|
4
4
|
|
|
5
5
|
/** Check whether a path is within the project rather than a dependency store. */
|
|
6
6
|
export function isInProjectPath(filePath: string, cwd: string): boolean {
|
|
@@ -58,7 +58,7 @@ export function resolveScopeSet(
|
|
|
58
58
|
return {
|
|
59
59
|
kind: "ok",
|
|
60
60
|
paths,
|
|
61
|
-
display: paths.map((resolved) =>
|
|
61
|
+
display: paths.map((resolved) => toDisplayPath(cwd, resolved)).join(", "),
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -73,16 +73,39 @@ export function normalizePath(input: string, cwd: string): string {
|
|
|
73
73
|
return resolveToolPath(cwd, input);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/** Render
|
|
76
|
+
/** Render filesystem locations canonically; preserve virtual provider URIs without inventing files. */
|
|
77
77
|
export function relativeDisplayPath(basePath: string, filePath: string, samePath = "."): string {
|
|
78
|
-
|
|
78
|
+
if (isNonFileUri(filePath)) return filePath;
|
|
79
|
+
const base = canonicalDisplayPath(path.resolve(basePath));
|
|
80
|
+
const file = canonicalDisplayPath(path.resolve(basePath, uriToFile(filePath)));
|
|
81
|
+
const relativePath = path.relative(base, file);
|
|
79
82
|
if (!relativePath || relativePath === ".") return samePath;
|
|
80
|
-
if (relativePath.startsWith(`..${path.sep}`) || relativePath === "..") return
|
|
83
|
+
if (relativePath.startsWith(`..${path.sep}`) || relativePath === "..") return file;
|
|
81
84
|
return relativePath.replaceAll("\\", "/");
|
|
82
85
|
}
|
|
83
86
|
|
|
84
|
-
/**
|
|
87
|
+
/** Identify provider URIs that cannot be navigated as local filesystem paths. */
|
|
88
|
+
export function isNonFileUri(value: string): boolean {
|
|
89
|
+
return !path.isAbsolute(value) && /^[a-z][a-z\d+.-]*:/iu.test(value) && !/^file:/iu.test(value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Display filesystem sources relatively inside the workspace and absolutely outside; preserve other URIs. */
|
|
85
93
|
export function toDisplayPath(cwd: string, filePath: string): string {
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
return relativeDisplayPath(cwd, filePath);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Resolve existing ancestors too, so missing provider files retain the workspace's canonical spelling. */
|
|
98
|
+
function canonicalDisplayPath(absolutePath: string): string {
|
|
99
|
+
let current = absolutePath;
|
|
100
|
+
const suffix: string[] = [];
|
|
101
|
+
while (true) {
|
|
102
|
+
try {
|
|
103
|
+
return path.join(realpathSync(current), ...suffix.reverse());
|
|
104
|
+
} catch {
|
|
105
|
+
const parent = path.dirname(current);
|
|
106
|
+
if (parent === current) return absolutePath;
|
|
107
|
+
suffix.push(path.basename(current));
|
|
108
|
+
current = parent;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
88
111
|
}
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
type NodeAtData,
|
|
7
7
|
type StructuralProvider,
|
|
8
8
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
9
|
-
import type { AnchoredResolutionMetadata } from "../../types/index.ts";
|
|
10
9
|
import { resolveLatexTargetAtAnchor } from "./latex-target-anchor.ts";
|
|
10
|
+
import { createAnchoredResolution } from "./resolution.ts";
|
|
11
11
|
import type { TargetOutcome } from "./types.ts";
|
|
12
12
|
|
|
13
13
|
type Anchor = { line: number; character: number };
|
|
@@ -129,12 +129,7 @@ export async function resolveFromStructural(
|
|
|
129
129
|
provenance: ["structural"],
|
|
130
130
|
anchorKind: "name",
|
|
131
131
|
container: null,
|
|
132
|
-
resolution:
|
|
133
|
-
requested: { ...requested },
|
|
134
|
-
resolved: anchor,
|
|
135
|
-
snapped: anchor.line !== requested.line || anchor.character !== requested.character,
|
|
136
|
-
source: "structural-identifier",
|
|
137
|
-
} satisfies AnchoredResolutionMetadata,
|
|
132
|
+
resolution: createAnchoredResolution(requested, anchor, "structural-identifier"),
|
|
138
133
|
},
|
|
139
134
|
};
|
|
140
135
|
}
|
|
@@ -143,7 +138,7 @@ function coordinateNotOnSymbolMessage(file: string, requested: Anchor, detail: s
|
|
|
143
138
|
const at = `${basename(file)}:${requested.line}:${requested.character}`;
|
|
144
139
|
return (
|
|
145
140
|
`No symbol target resolved at \`${at}\` (on \`${detail}\`). ` +
|
|
146
|
-
"
|
|
141
|
+
"Target resolution requires a real symbol backed by provider evidence; " +
|
|
147
142
|
"use `code_inspect` for point-level facts at this coordinate, or pass the identifier coordinate of a declaration."
|
|
148
143
|
);
|
|
149
144
|
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
type StructuralProvider,
|
|
18
18
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
19
19
|
import type { AnchorKind } from "../../session/target-store.ts";
|
|
20
|
-
import type {
|
|
20
|
+
import type { AnchoredResolutionSource } from "../../types/index.ts";
|
|
21
21
|
import { resolveFromStructural } from "./anchored-structural.ts";
|
|
22
22
|
import {
|
|
23
23
|
canonicalFileDeclarationKind,
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type DeclarationOccurrenceIdentity,
|
|
26
26
|
} from "./identity.ts";
|
|
27
27
|
import { resolveTexlabSectionLabelCollision } from "./latex-label-container.ts";
|
|
28
|
+
import { createAnchoredResolution } from "./resolution.ts";
|
|
28
29
|
import type { DisambiguationCandidateData, ResolvedTargetData, TargetOutcome } from "./types.ts";
|
|
29
30
|
|
|
30
31
|
/** 1-based symbol anchor position (mirrors the runtime `SymbolAnchor`). */
|
|
@@ -93,25 +94,10 @@ function matchSymbolAt(s: CodeSymbol, line: number, character: number): "exact"
|
|
|
93
94
|
return null;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
function buildResolution(
|
|
97
|
-
requested: Anchor,
|
|
98
|
-
resolvedAnchor: Anchor,
|
|
99
|
-
snapped: boolean,
|
|
100
|
-
source: AnchoredResolutionSource,
|
|
101
|
-
): AnchoredResolutionMetadata {
|
|
102
|
-
return {
|
|
103
|
-
requested: { line: requested.line, character: requested.character },
|
|
104
|
-
resolved: { line: resolvedAnchor.line, character: resolvedAnchor.character },
|
|
105
|
-
snapped,
|
|
106
|
-
source,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
97
|
function resolvedFromSymbol(
|
|
111
98
|
file: string,
|
|
112
99
|
s: CodeSymbol,
|
|
113
100
|
opts: {
|
|
114
|
-
snapped: boolean;
|
|
115
101
|
requested: Anchor;
|
|
116
102
|
source: AnchoredResolutionSource;
|
|
117
103
|
identity: DeclarationOccurrenceIdentity;
|
|
@@ -135,7 +121,7 @@ function resolvedFromSymbol(
|
|
|
135
121
|
provenance: opts.identity.structuralEvidence ? ["semantic", "structural"] : ["semantic"],
|
|
136
122
|
anchorKind: (s.nameAnchor ? "name" : "declaration") as AnchorKind,
|
|
137
123
|
container: s.container ?? null,
|
|
138
|
-
resolution:
|
|
124
|
+
resolution: createAnchoredResolution(opts.requested, a, opts.source),
|
|
139
125
|
},
|
|
140
126
|
};
|
|
141
127
|
}
|
|
@@ -213,7 +199,6 @@ async function resolveFromSemantic(
|
|
|
213
199
|
const resolveIdentity = createCodeSymbolIdentityResolver(file, symbols, structural, control);
|
|
214
200
|
if (exact.length === 1) {
|
|
215
201
|
return resolvedFromSymbol(file, exact[0], {
|
|
216
|
-
snapped: false,
|
|
217
202
|
requested,
|
|
218
203
|
source: "semantic",
|
|
219
204
|
identity: await resolveIdentity(exact[0]),
|
|
@@ -222,7 +207,6 @@ async function resolveFromSemantic(
|
|
|
222
207
|
if (exact.length > 1) return candidatesFromSymbols(file, exact, resolveIdentity);
|
|
223
208
|
if (snap.length === 1) {
|
|
224
209
|
return resolvedFromSymbol(file, snap[0], {
|
|
225
|
-
snapped: true,
|
|
226
210
|
requested,
|
|
227
211
|
source: "semantic",
|
|
228
212
|
identity: await resolveIdentity(snap[0]),
|
|
@@ -296,7 +280,7 @@ function coordinateNotOnSymbolMessage(
|
|
|
296
280
|
const reason = detail ? ` (on \`${detail}\`)` : "";
|
|
297
281
|
return (
|
|
298
282
|
`No symbol target resolved at \`${at}\`${reason}. ` +
|
|
299
|
-
"
|
|
283
|
+
"Target resolution requires a real symbol backed by provider evidence; " +
|
|
300
284
|
"use `code_inspect` for point-level facts at this coordinate, or pass the identifier coordinate of a declaration."
|
|
301
285
|
);
|
|
302
286
|
}
|
|
@@ -306,7 +306,7 @@ export async function refineTargetOutcomeIdentity(
|
|
|
306
306
|
): Promise<TargetOutcome> {
|
|
307
307
|
if (outcome.kind === "resolved") {
|
|
308
308
|
return {
|
|
309
|
-
|
|
309
|
+
...outcome,
|
|
310
310
|
target: await refineTypeAliasIdentity(outcome.target, structural, control),
|
|
311
311
|
};
|
|
312
312
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
type DeclarationOccurrenceCandidate,
|
|
12
12
|
declarationOccurrenceFor,
|
|
13
13
|
} from "./identity.ts";
|
|
14
|
+
import { createAnchoredResolution } from "./resolution.ts";
|
|
14
15
|
import type { ResolvedTargetData, TargetOutcome } from "./types.ts";
|
|
15
16
|
|
|
16
17
|
type LabelOutlineCandidate = DeclarationOccurrenceCandidate & {
|
|
@@ -110,12 +111,11 @@ export async function resolveLatexLabelTargetAtAnchor(input: {
|
|
|
110
111
|
provenance: ["structural"],
|
|
111
112
|
anchorKind: "name",
|
|
112
113
|
container: label.container,
|
|
113
|
-
resolution:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
},
|
|
114
|
+
resolution: createAnchoredResolution(
|
|
115
|
+
{ line: input.line, character: input.character },
|
|
116
|
+
anchor,
|
|
117
|
+
"structural-identifier",
|
|
118
|
+
),
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
|