@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.
Files changed (112) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +16 -6
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  6. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  7. package/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  8. package/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  9. package/node_modules/@mrclrchtr/supi-lsp/README.md +39 -2
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  16. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  17. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +11 -4
  18. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +77 -6
  19. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +149 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-typescript-project.ts +40 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +151 -44
  22. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +2 -2
  23. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +157 -23
  24. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +254 -56
  25. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +19 -2
  26. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +1 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +5 -1
  28. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +2 -2
  29. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  30. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  31. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  32. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  33. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  34. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  35. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  36. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  37. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +5 -1
  38. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  39. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +5 -1
  40. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +40 -25
  41. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +2 -0
  42. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/call-context.ts +44 -0
  43. package/package.json +6 -5
  44. package/src/analysis/health/server-status.ts +6 -2
  45. package/src/analysis/search/exclusions.ts +47 -0
  46. package/src/analysis/search/paths.ts +32 -9
  47. package/src/analysis/target/anchored-structural.ts +3 -8
  48. package/src/analysis/target/anchored.ts +4 -20
  49. package/src/analysis/target/identity.ts +1 -1
  50. package/src/analysis/target/latex-label-container.ts +6 -6
  51. package/src/analysis/target/latex-section-anchor.ts +6 -6
  52. package/src/analysis/target/resolution.ts +18 -0
  53. package/src/analysis/target/symbol.ts +39 -11
  54. package/src/analysis/target/types.ts +6 -1
  55. package/src/extension.ts +17 -11
  56. package/src/session/graph/collect.ts +1 -10
  57. package/src/session/graph-types.ts +2 -0
  58. package/src/session/graph-workflow.ts +1 -0
  59. package/src/session/inspect/collect.ts +8 -2
  60. package/src/session/inspect/file-point.ts +2 -3
  61. package/src/session/inspect-workflow.ts +1 -1
  62. package/src/session/orientation/collect.ts +54 -16
  63. package/src/session/orientation/context-sections.ts +2 -3
  64. package/src/session/orientation/facts.ts +9 -1
  65. package/src/session/orientation-types.ts +3 -0
  66. package/src/session/orientation-workflow.ts +18 -5
  67. package/src/session/refactor-identity.ts +76 -0
  68. package/src/session/refactor-workflow.ts +11 -14
  69. package/src/session/target-store.ts +3 -18
  70. package/src/session/target-workflow.ts +33 -16
  71. package/src/substrate/lsp/recovery.ts +5 -5
  72. package/src/tool/code_find/render.ts +8 -4
  73. package/src/tool/code_find/result.ts +78 -6
  74. package/src/tool/code_find/spec.ts +4 -3
  75. package/src/tool/code_find/structured.ts +25 -9
  76. package/src/tool/code_graph/details.ts +1 -0
  77. package/src/tool/code_graph/display.ts +1 -1
  78. package/src/tool/code_graph/guidance.ts +1 -1
  79. package/src/tool/code_graph/markdown.ts +11 -6
  80. package/src/tool/code_graph/read-next.ts +38 -9
  81. package/src/tool/code_graph/reference-selection.ts +30 -0
  82. package/src/tool/code_graph/result.ts +25 -118
  83. package/src/tool/code_graph/section.ts +133 -0
  84. package/src/tool/code_graph/spec.ts +3 -3
  85. package/src/tool/code_graph/structured.ts +17 -6
  86. package/src/tool/code_health/display-paths.ts +92 -0
  87. package/src/tool/code_health/file-scope-markdown.ts +3 -2
  88. package/src/tool/code_health/result.ts +4 -2
  89. package/src/tool/code_health/spec.ts +3 -3
  90. package/src/tool/code_health/structured-schema.ts +44 -44
  91. package/src/tool/code_inspect/spec.ts +5 -1
  92. package/src/tool/code_inspect/structured.ts +1 -2
  93. package/src/tool/code_orientation/execute.ts +1 -1
  94. package/src/tool/code_orientation/result.ts +22 -5
  95. package/src/tool/code_orientation/structured-schema.ts +46 -36
  96. package/src/tool/code_orientation/structured-workspace.ts +2 -1
  97. package/src/tool/code_orientation/structured.ts +6 -12
  98. package/src/tool/code_orientation/workspace-format.ts +2 -5
  99. package/src/tool/code_orientation/workspace-sections.ts +3 -2
  100. package/src/tool/code_refactor_apply/result.ts +1 -1
  101. package/src/tool/code_refactor_plan/result.ts +2 -1
  102. package/src/tool/code_refactor_plan/structured.ts +2 -3
  103. package/src/tool/code_resolve/markdown.ts +6 -30
  104. package/src/tool/code_resolve/result.ts +24 -11
  105. package/src/tool/code_resolve/structured.ts +7 -9
  106. package/src/tool/result/refactor.ts +8 -5
  107. package/src/tool/result/structured.ts +8 -5
  108. package/src/tool/result/types.ts +18 -14
  109. package/src/tool/schemas.ts +5 -5
  110. package/src/ui/status-command.ts +37 -1
  111. package/src/ui/status-overlay.ts +70 -51
  112. package/src/ui/status-presentation.ts +108 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "description": "Shared settings, configuration, reporting, and session infrastructure",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -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
+ }
@@ -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.2.0",
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.2.0",
40
- "@mrclrchtr/supi-core": "11.2.0"
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",
@@ -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": "c5101ee00725c52a8aa083afa4749b598a5ff884482f80ed114fca18e88629a6"
27
+ "sha256": "aaa2904a00000d8e058708845172bd3ce7836566c7e16e9ee594c43f4ba4f451"
24
28
  }
@@ -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": "db071e260bcfec92f4b11997516dec49393c5086775eb8f090217d38de300c0d"
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 type { TreeSitterRuntime } from "../worker/runtime.ts";
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 queryResult = await runtime.queryFile(filePath, queryStr, control);
70
- if (queryResult.kind !== "success" && queryResult.kind !== "partial") return queryResult;
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
- const captures = queryResult.data;
73
- const seen = new Set<string>();
74
- const matches: CallSiteMatch[] = [];
84
+ const seen = new Set<string>();
85
+ const matches: CallSiteMatch[] = [];
75
86
 
76
- for (const capture of captures) {
77
- // Normalize: trim whitespace and collapse internal whitespace to single space
78
- const name = normalizeCallName(capture.text, grammarId, capture.nodeType);
79
- if (name.length === 0) continue;
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
- // Collapse duplicate captures only when they identify the same source range.
82
- const key = `${capture.range.startLine}:${capture.range.startCharacter}:${capture.range.endLine}:${capture.range.endCharacter}`;
83
- if (seen.has(key)) continue;
84
- seen.add(key);
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
- matches.push({
87
- name,
88
- startLine: capture.range.startLine,
89
- startCharacter: capture.range.startCharacter,
90
- endLine: capture.range.endLine,
91
- endCharacter: capture.range.endCharacter,
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
- return queryResult.kind === "partial"
96
- ? { ...queryResult, data: matches }
97
- : { kind: "success", data: matches };
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.2.0",
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.2.0",
46
- "@mrclrchtr/supi-core": "11.2.0",
47
- "@mrclrchtr/supi-lsp": "11.2.0",
48
- "@mrclrchtr/supi-tree-sitter": "11.2.0"
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 an LSP route root relative to its workspace. */
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 relative = path.relative(cwd, root);
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) => byPath.get(resolved) ?? resolved).join(", "),
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 a path relative to a base, retaining absolute paths outside it. */
76
+ /** Render filesystem locations canonically; preserve virtual provider URIs without inventing files. */
77
77
  export function relativeDisplayPath(basePath: string, filePath: string, samePath = "."): string {
78
- const relativePath = path.relative(basePath, filePath);
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 filePath;
83
+ if (relativePath.startsWith(`..${path.sep}`) || relativePath === "..") return file;
81
84
  return relativePath.replaceAll("\\", "/");
82
85
  }
83
86
 
84
- /** Render an absolute path relative to cwd when it is inside the workspace. */
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
- if (!path.isAbsolute(filePath)) return filePath.replaceAll("\\", "/");
87
- return relativeDisplayPath(cwd, filePath, filePath);
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
- "`code_resolve` resolves real symbol targets from provider-backed evidence; " +
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 { AnchoredResolutionMetadata, AnchoredResolutionSource } from "../../types/index.ts";
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: buildResolution(opts.requested, a, opts.snapped, opts.source),
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
- "`code_resolve` resolves real symbol targets from provider-backed evidence; " +
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
- kind: "resolved",
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
- requested: { line: input.line, character: input.character },
115
- resolved: { line: anchor.line, character: anchor.character },
116
- snapped: anchor.line !== input.line || anchor.character !== input.character,
117
- source: "structural-identifier",
118
- },
114
+ resolution: createAnchoredResolution(
115
+ { line: input.line, character: input.character },
116
+ anchor,
117
+ "structural-identifier",
118
+ ),
119
119
  };
120
120
  }
121
121