@mrclrchtr/supi-code-intelligence 11.0.1 → 11.1.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 (100) hide show
  1. package/README.md +41 -4
  2. package/gradle-helper/README.md +48 -0
  3. package/gradle-helper/build.sh +73 -0
  4. package/gradle-helper/lib/gradle-tooling-api-9.4.0.jar +0 -0
  5. package/gradle-helper/lib/slf4j-api-2.0.17.jar +0 -0
  6. package/gradle-helper/lib/slf4j-simple-2.0.17.jar +0 -0
  7. package/gradle-helper/lib/supi-gradle-observation.jar +0 -0
  8. package/gradle-helper/licenses/DEPENDENCIES.md +11 -0
  9. package/gradle-helper/licenses/LICENSE-gradle-tooling-api.txt +422 -0
  10. package/gradle-helper/licenses/LICENSE-slf4j.txt +21 -0
  11. package/gradle-helper/licenses/NOTICE-gradle.txt +21 -0
  12. package/gradle-helper/src/GradleObservation.java +597 -0
  13. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  15. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
  16. package/node_modules/@mrclrchtr/supi-lsp/README.md +1 -1
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/README.md +5 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/browser/ril.js +8 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/connection.js +7 -2
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/ral.d.ts +8 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.d.ts +14 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.js +6 -4
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/ril.js +5 -1
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/package.json +4 -2
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/package.json +4 -3
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/esm/main.js +2 -2
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/umd/main.js +2 -2
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/package.json +2 -1
  32. package/node_modules/@mrclrchtr/supi-lsp/package.json +6 -6
  33. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +21 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +1 -1
  35. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -0
  36. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  37. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  38. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
  39. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -3
  40. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/LICENSE +21 -0
  41. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  42. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +19 -2
  43. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/LICENSE +21 -0
  44. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  45. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +19 -2
  46. package/node_modules/ignore/README.md +36 -10
  47. package/node_modules/ignore/index.d.ts +3 -2
  48. package/node_modules/ignore/index.js +57 -53
  49. package/node_modules/ignore/legacy.js +50 -46
  50. package/node_modules/ignore/package.json +1 -1
  51. package/package.json +11 -6
  52. package/src/analysis/gradle/query.ts +273 -0
  53. package/src/analysis/gradle/runtime.ts +173 -0
  54. package/src/analysis/gradle/types.ts +65 -0
  55. package/src/analysis/read-next.ts +1 -4
  56. package/src/analysis/refactor/apply.ts +2 -2
  57. package/src/analysis/refactor/mutation-authority.ts +4 -1
  58. package/src/analysis/search/ast-scan.ts +143 -18
  59. package/src/analysis/workspace/safe-path.ts +14 -2
  60. package/src/analysis/workspace/types.ts +2 -0
  61. package/src/extension.ts +10 -1
  62. package/src/gradle/consent.ts +279 -0
  63. package/src/headless.ts +3 -0
  64. package/src/overview/collect.ts +11 -3
  65. package/src/session/orientation/workspace-context.ts +49 -28
  66. package/src/session/orientation-types.ts +11 -1
  67. package/src/session/orientation-workflow.ts +2 -0
  68. package/src/session/session.ts +8 -0
  69. package/src/tool/code_find/execute.ts +1 -1
  70. package/src/tool/code_find/markdown.ts +24 -17
  71. package/src/tool/code_find/result.ts +18 -5
  72. package/src/tool/code_find/spec.ts +2 -0
  73. package/src/tool/code_find/structured.ts +161 -0
  74. package/src/tool/code_graph/result.ts +32 -15
  75. package/src/tool/code_graph/spec.ts +2 -0
  76. package/src/tool/code_graph/structured.ts +142 -0
  77. package/src/tool/code_health/markdown.ts +5 -15
  78. package/src/tool/code_inspect/markdown.ts +19 -11
  79. package/src/tool/code_inspect/result.ts +1 -0
  80. package/src/tool/code_orientation/directory-navigation.ts +66 -0
  81. package/src/tool/code_orientation/gradle-sections.ts +68 -0
  82. package/src/tool/code_orientation/markdown.ts +19 -8
  83. package/src/tool/code_orientation/result.ts +89 -11
  84. package/src/tool/code_orientation/workspace-format.ts +2 -1
  85. package/src/tool/code_orientation/workspace-output.ts +40 -13
  86. package/src/tool/code_orientation/workspace-projects.ts +170 -50
  87. package/src/tool/code_orientation/workspace-sections.ts +3 -1
  88. package/src/tool/code_resolve/markdown.ts +4 -10
  89. package/src/tool/code_resolve/result.ts +2 -0
  90. package/src/tool/code_resolve/spec.ts +2 -0
  91. package/src/tool/code_resolve/structured.ts +103 -0
  92. package/src/tool/infra/truncate.ts +12 -4
  93. package/src/tool/register.ts +10 -6
  94. package/src/tool/result/display.ts +17 -0
  95. package/src/tool/result/model-budget.ts +195 -0
  96. package/src/tool/result/structured.ts +62 -0
  97. package/src/tool/result/types.ts +10 -2
  98. package/src/tool/specs.ts +2 -0
  99. package/src/types/execution.ts +5 -1
  100. package/src/ui/tui/display.ts +10 -4
@@ -0,0 +1,161 @@
1
+ import { StringEnum } from "@earendil-works/pi-ai";
2
+ import { type Static, Type } from "typebox";
3
+ import { toDisplayPath } from "../../analysis/search/paths.ts";
4
+ import { ConfidenceSchema, EvidenceListSchema, RecoveryRangeSchema } from "../result/structured.ts";
5
+ import type { FindResultAssembly } from "./result.ts";
6
+
7
+ const ScanPathSummary = Type.Object({
8
+ reason: Type.String(),
9
+ pathCount: Type.Union([Type.Integer(), Type.Null()]),
10
+ examples: Type.Array(Type.String()),
11
+ });
12
+
13
+ /** Codemode search evidence, including scan-universe limits independently of match counts. */
14
+ export const FindOutputSchema = Type.Object(
15
+ {
16
+ kind: StringEnum(["completed", "invalid-input"]),
17
+ mode: Type.Optional(StringEnum(["semantic", "ast"])),
18
+ confidence: ConfidenceSchema,
19
+ matches: Type.Array(
20
+ Type.Object(
21
+ {
22
+ name: Type.String(),
23
+ kind: Type.String(),
24
+ file: Type.String(),
25
+ line: Type.Integer(),
26
+ character: Type.Integer(),
27
+ endLine: Type.Optional(Type.Integer()),
28
+ endCharacter: Type.Optional(Type.Integer()),
29
+ anchorKind: Type.Optional(StringEnum(["name", "declaration"])),
30
+ container: Type.Optional(Type.Union([Type.String(), Type.Null()])),
31
+ },
32
+ { additionalProperties: false },
33
+ ),
34
+ ),
35
+ evidenceLists: Type.Array(EvidenceListSchema),
36
+ nextQueries: Type.Array(Type.String()),
37
+ message: Type.Optional(Type.String()),
38
+ partialReason: Type.Optional(Type.Union([Type.String(), Type.Null()])),
39
+ automaticPathExclusion: Type.Optional(
40
+ Type.Object({ excludedCount: Type.Integer(), examples: Type.Array(Type.String()) }),
41
+ ),
42
+ scan: Type.Optional(
43
+ Type.Object({
44
+ universe: Type.String(),
45
+ roots: Type.Array(Type.String()),
46
+ eligibleFileCount: Type.Union([Type.Integer(), Type.Null()]),
47
+ analyzedFileCount: Type.Integer(),
48
+ complete: Type.Boolean(),
49
+ exclusions: Type.Array(
50
+ Type.Object({ ...ScanPathSummary.properties, scopeRoot: Type.String() }),
51
+ ),
52
+ limitations: Type.Array(ScanPathSummary),
53
+ policy: Type.Object({
54
+ operation: Type.String(),
55
+ supportedExtensions: Type.Array(Type.String()),
56
+ excludedDirectories: Type.Array(Type.String()),
57
+ configuredExclusions: Type.Array(Type.String()),
58
+ hiddenEntries: Type.String(),
59
+ ignoreFiles: Type.Boolean(),
60
+ symlinks: Type.String(),
61
+ maxFiles: Type.Integer(),
62
+ timeoutMs: Type.Number(),
63
+ }),
64
+ }),
65
+ ),
66
+ failures: Type.Optional(
67
+ Type.Array(
68
+ Type.Object({
69
+ file: Type.String(),
70
+ kind: Type.String(),
71
+ reason: Type.String(),
72
+ errorRanges: Type.Optional(Type.Array(RecoveryRangeSchema)),
73
+ }),
74
+ ),
75
+ ),
76
+ },
77
+ { additionalProperties: false },
78
+ );
79
+
80
+ /** Serialize only the visible matches while preserving complete collection metadata. */
81
+ export function structuredFindResult(
82
+ assembly: FindResultAssembly,
83
+ cwd: string,
84
+ ): Static<typeof FindOutputSchema> {
85
+ const { data } = assembly.outcome;
86
+ const evidence = assembly.assembled.evidenceLists;
87
+ const shown = evidence[0]?.shownCount ?? 0;
88
+ const base = {
89
+ kind: "completed" as const,
90
+ mode: data.kind,
91
+ confidence: assembly.assembled.confidence,
92
+ evidenceLists: evidence.map((entry) => ({ ...entry })),
93
+ nextQueries: assembly.details.nextQueries,
94
+ };
95
+ if (data.kind === "semantic") {
96
+ const exclusion = data.partialMetadata?.automaticPathExclusion;
97
+ return {
98
+ ...base,
99
+ matches: data.symbols.slice(0, shown).map((symbol) => {
100
+ const anchor = symbol.nameAnchor ?? symbol.declarationAnchor;
101
+ return {
102
+ name: symbol.name,
103
+ kind: symbol.kind,
104
+ file: toDisplayPath(cwd, symbol.file),
105
+ line: anchor.line,
106
+ character: anchor.character,
107
+ anchorKind: symbol.nameAnchor ? ("name" as const) : ("declaration" as const),
108
+ container: symbol.container ?? null,
109
+ };
110
+ }),
111
+ partialReason: data.partialReason,
112
+ ...(exclusion
113
+ ? {
114
+ automaticPathExclusion: {
115
+ excludedCount: exclusion.excludedCount,
116
+ examples: [...exclusion.examples],
117
+ },
118
+ }
119
+ : {}),
120
+ };
121
+ }
122
+ const { scan } = data.result;
123
+ return {
124
+ ...base,
125
+ matches: data.result.matches.slice(0, shown).map((match) => ({
126
+ name: match.name,
127
+ kind: match.kind,
128
+ file: match.file,
129
+ line: match.line,
130
+ character: match.startCharacter,
131
+ endLine: match.endLine,
132
+ endCharacter: match.endCharacter,
133
+ })),
134
+ partialReason: data.result.partialReason,
135
+ scan: {
136
+ ...scan,
137
+ roots: [...scan.roots],
138
+ policy: {
139
+ ...scan.policy,
140
+ supportedExtensions: [...scan.policy.supportedExtensions],
141
+ excludedDirectories: [...scan.policy.excludedDirectories],
142
+ configuredExclusions: [...scan.policy.configuredExclusions],
143
+ },
144
+ exclusions: scan.exclusions.map((entry) => ({ ...entry, examples: [...entry.examples] })),
145
+ limitations: scan.limitations.map((entry) => ({ ...entry, examples: [...entry.examples] })),
146
+ },
147
+ failures: data.result.failures.map((failure) => ({
148
+ file: failure.file,
149
+ kind: failure.kind,
150
+ reason: failure.reason,
151
+ ...(failure.errorRanges
152
+ ? {
153
+ errorRanges: failure.errorRanges.map((range) => ({
154
+ start: { ...range.start },
155
+ end: { ...range.end },
156
+ })),
157
+ }
158
+ : {}),
159
+ })),
160
+ };
161
+ }
@@ -26,6 +26,7 @@ import type { GraphDetails, GraphFileGroup, GraphSectionDetails } from "./detail
26
26
  import { graphDisplaySection } from "./display.ts";
27
27
  import { formatGraphEvidence } from "./format.ts";
28
28
  import { graphReadNext } from "./read-next.ts";
29
+ import { structuredGraphCandidates, structuredGraphResult } from "./structured.ts";
29
30
 
30
31
  export type { GraphRelationKind, GraphSection } from "../../session/graph-types.ts";
31
32
 
@@ -265,7 +266,17 @@ type GraphOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["graph"]>
265
266
  export function finishGraphResult(outcome: GraphOutcome, cwd: string): CodeIntelResult {
266
267
  if (outcome.kind === "unavailable") throw new Error(outcome.reason);
267
268
  if (outcome.kind === "invalid-input") {
268
- return searchErrorResult(`**Error:** ${outcome.message}`, { message: outcome.message });
269
+ return {
270
+ ...searchErrorResult(`**Error:** ${outcome.message}`, { message: outcome.message }),
271
+ structuredContent: {
272
+ kind: "invalid-input",
273
+ message: outcome.message,
274
+ sections: [],
275
+ evidenceLists: [],
276
+ readNext: [],
277
+ nextQueries: [],
278
+ },
279
+ };
269
280
  }
270
281
  if (outcome.kind === "disambiguation" || outcome.kind === "kind-mismatch") {
271
282
  return finishGraphCandidates(outcome);
@@ -281,6 +292,7 @@ export function finishGraphResult(outcome: GraphOutcome, cwd: string): CodeIntel
281
292
  const displayTruncated = hasHiddenDisplayEvidence(assembly);
282
293
  return {
283
294
  content: renderGraphResult(assembly),
295
+ structuredContent: structuredGraphResult(assembly),
284
296
  details: {
285
297
  type: "graph",
286
298
  data: assembly.details,
@@ -328,20 +340,25 @@ function finishGraphCandidates(
328
340
  format: (candidate) => formatCandidateRow(candidate, "handle-first"),
329
341
  }),
330
342
  ];
331
- return searchErrorResult(lines.join("\n"), {
332
- confidence: "semantic",
333
- evidenceLists: [evidence],
334
- nextQueries:
335
- outcome.kind === "kind-mismatch"
336
- ? ["Retry without symbolKind, use an observed provider kind, or choose a near-match handle"]
337
- : ["Choose one candidate handle, or narrow the symbol selector with scope or symbolKind"],
338
- status: outcome.kind === "disambiguation" ? "disambiguation" : "invalid-input",
339
- message:
340
- outcome.kind === "kind-mismatch"
341
- ? `No target matched provider kind ${outcome.requestedKind}.`
342
- : "The target is ambiguous.",
343
- displaySections,
344
- });
343
+ const nextQueries =
344
+ outcome.kind === "kind-mismatch"
345
+ ? ["Retry without symbolKind, use an observed provider kind, or choose a near-match handle"]
346
+ : ["Choose one candidate handle, or narrow the symbol selector with scope or symbolKind"];
347
+ const message =
348
+ outcome.kind === "kind-mismatch"
349
+ ? `No target matched provider kind ${outcome.requestedKind}.`
350
+ : "The target is ambiguous.";
351
+ return {
352
+ ...searchErrorResult(lines.join("\n"), {
353
+ confidence: "semantic",
354
+ evidenceLists: [evidence],
355
+ nextQueries,
356
+ status: outcome.kind === "disambiguation" ? "disambiguation" : "invalid-input",
357
+ message,
358
+ displaySections,
359
+ }),
360
+ structuredContent: structuredGraphCandidates(outcome, evidence, { message, nextQueries }),
361
+ };
345
362
  }
346
363
 
347
364
  function graphCandidateEvidence(
@@ -3,6 +3,7 @@ import { Type } from "typebox";
3
3
  import type { CodeIntelToolExecCtx } from "../../types/index.ts";
4
4
  import { GraphTargetParam, MaxResultsParam } from "../schemas.ts";
5
5
  import { executeGraphTool } from "./execute.ts";
6
+ import { GraphOutputSchema } from "./structured.ts";
6
7
  import { renderGraphCall, renderGraphResult } from "./tui.ts";
7
8
 
8
9
  export const CODE_GRAPH_TOOL_NAME = "code_graph";
@@ -12,6 +13,7 @@ export const CODE_GRAPH_TOOL_LABEL = "Code Graph";
12
13
  export const codeGraphSpec = {
13
14
  name: CODE_GRAPH_TOOL_NAME,
14
15
  label: CODE_GRAPH_TOOL_LABEL,
16
+ outputSchema: GraphOutputSchema,
15
17
  parameters: Type.Object(
16
18
  {
17
19
  target: GraphTargetParam,
@@ -0,0 +1,142 @@
1
+ import { StringEnum } from "@earendil-works/pi-ai";
2
+ import { type Static, Type } from "typebox";
3
+ import type { EvidenceListMetadata } from "../../analysis/evidence.ts";
4
+ import { toDisplayPath } from "../../analysis/search/paths.ts";
5
+ import type { GraphWorkflowOutcome } from "../../session/graph-types.ts";
6
+ import {
7
+ EvidenceListSchema,
8
+ NavigationTargetSchema,
9
+ ReadNextSchema,
10
+ RecoveryRangeSchema,
11
+ } from "../result/structured.ts";
12
+ import type { GraphResultAssembly } from "./result.ts";
13
+
14
+ /** Codemode relation evidence; callees describe written expressions, not resolved identities. */
15
+ export const GraphOutputSchema = Type.Object(
16
+ {
17
+ kind: StringEnum(["completed", "invalid-input", "disambiguation", "kind-mismatch"]),
18
+ target: Type.Optional(Type.Object({ name: Type.String(), file: Type.String() })),
19
+ sections: Type.Array(
20
+ Type.Object(
21
+ {
22
+ relation: StringEnum(["references", "callees", "implements"]),
23
+ source: StringEnum(["semantic", "structural"]),
24
+ status: StringEnum(["complete", "partial", "unavailable"]),
25
+ message: Type.Union([Type.String(), Type.Null()]),
26
+ items: Type.Array(
27
+ Type.Object(
28
+ {
29
+ name: Type.Union([Type.String(), Type.Null()]),
30
+ file: Type.String(),
31
+ line: Type.Integer(),
32
+ character: Type.Integer(),
33
+ },
34
+ { additionalProperties: false },
35
+ ),
36
+ ),
37
+ evidence: Type.Optional(EvidenceListSchema),
38
+ externalCount: Type.Integer(),
39
+ depth: Type.Union([StringEnum(["direct", "deep"]), Type.Null()]),
40
+ enclosingScope: Type.Union([
41
+ Type.Object({
42
+ name: Type.String(),
43
+ file: Type.String(),
44
+ startLine: Type.Integer(),
45
+ endLine: Type.Integer(),
46
+ }),
47
+ Type.Null(),
48
+ ]),
49
+ recovery: Type.Union([
50
+ Type.Object({
51
+ file: Type.String(),
52
+ reason: Type.String(),
53
+ errorRanges: Type.Array(RecoveryRangeSchema),
54
+ }),
55
+ Type.Null(),
56
+ ]),
57
+ },
58
+ { additionalProperties: false },
59
+ ),
60
+ ),
61
+ targets: Type.Optional(Type.Array(NavigationTargetSchema)),
62
+ evidenceLists: Type.Array(EvidenceListSchema),
63
+ readNext: Type.Array(ReadNextSchema),
64
+ message: Type.Optional(Type.String()),
65
+ requestedKind: Type.Optional(Type.String()),
66
+ nextQueries: Type.Array(Type.String()),
67
+ },
68
+ { additionalProperties: false },
69
+ );
70
+
71
+ /** Project the already-bounded assembly without exposing provider objects or UI previews. */
72
+ export function structuredGraphResult(
73
+ assembly: GraphResultAssembly,
74
+ ): Static<typeof GraphOutputSchema> {
75
+ return {
76
+ kind: "completed",
77
+ target: { name: assembly.displayName, file: assembly.resolvedDisplayFile },
78
+ sections: assembly.sections.map((section, index) => {
79
+ const info = assembly.details.sections[index];
80
+ return {
81
+ relation: section.rel,
82
+ source: info.source,
83
+ status: info.status,
84
+ message: info.message,
85
+ items:
86
+ section.kind === "unavailable"
87
+ ? []
88
+ : section.evidence.items.map((item) => ({
89
+ name: item.name,
90
+ file: toDisplayPath(assembly.cwd, item.file),
91
+ line: item.line,
92
+ character: item.character,
93
+ })),
94
+ ...(section.kind === "ok" ? { evidence: { ...section.evidence.metadata } } : {}),
95
+ externalCount: info.externalCount,
96
+ depth: info.depth,
97
+ enclosingScope: info.enclosingScope ? { ...info.enclosingScope } : null,
98
+ recovery: info.recovery
99
+ ? {
100
+ file: toDisplayPath(assembly.cwd, info.recovery.file),
101
+ reason: info.recovery.reason,
102
+ errorRanges: info.recovery.errorRanges.map((range) => ({
103
+ start: { ...range.start },
104
+ end: { ...range.end },
105
+ })),
106
+ }
107
+ : null,
108
+ };
109
+ }),
110
+ evidenceLists: assembly.assembled.evidenceLists.map((evidence) => ({ ...evidence })),
111
+ readNext: assembly.details.readNext.map((item) => ({ ...item })),
112
+ nextQueries: [],
113
+ };
114
+ }
115
+
116
+ /** Keep recoverable candidate selection machine-readable without parsing Markdown. */
117
+ export function structuredGraphCandidates(
118
+ outcome: Extract<GraphWorkflowOutcome, { kind: "disambiguation" | "kind-mismatch" }>,
119
+ evidence: EvidenceListMetadata,
120
+ actions: { message: string; nextQueries: string[] },
121
+ ): Static<typeof GraphOutputSchema> {
122
+ const { message, nextQueries } = actions;
123
+ return {
124
+ kind: outcome.kind,
125
+ message,
126
+ sections: [],
127
+ targets: outcome.candidates.map((candidate) => ({
128
+ handle: candidate.targetId,
129
+ name: candidate.name,
130
+ kind: candidate.kind,
131
+ file: candidate.file,
132
+ line: candidate.line,
133
+ character: candidate.character,
134
+ anchorKind: candidate.anchorKind,
135
+ container: candidate.container,
136
+ })),
137
+ evidenceLists: [{ ...evidence }],
138
+ readNext: [],
139
+ nextQueries,
140
+ ...(outcome.kind === "kind-mismatch" ? { requestedKind: outcome.requestedKind } : {}),
141
+ };
142
+ }
@@ -69,9 +69,7 @@ function renderRefreshStatus(
69
69
  if (data.refresh.lastAttempt) {
70
70
  renderRetainedAttempt(lines, data.refresh.lastAttempt, cwd);
71
71
  } else {
72
- lines.push(
73
- "**Diagnostic refresh attempt**: not requested this session. Use `refresh: true` to try one.",
74
- );
72
+ lines.push("Refresh: not requested (`refresh: true` to attempt).");
75
73
  }
76
74
  lines.push("");
77
75
  }
@@ -236,8 +234,9 @@ function renderStatusLine(lines: string[], data: HealthData, semanticRequested:
236
234
  if (!semanticRequested) return;
237
235
 
238
236
  const routeSummary = formatProjectServerRouteSummary(data.servers);
239
- lines.push(`**LSP**: ${displaySemanticStatus(data)}${routeSummary ? ` — ${routeSummary}` : ""}`);
240
- if (data.structuralStatus) lines.push(`**Structural**: ${data.structuralStatus}`);
237
+ lines.push(
238
+ `**LSP**: ${displaySemanticStatus(data)}${routeSummary ? ` — ${routeSummary}` : ""}${data.structuralStatus ? `; **Structural**: ${data.structuralStatus}` : ""}`,
239
+ );
241
240
  lines.push("");
242
241
  }
243
242
 
@@ -297,7 +296,7 @@ function renderDiagnosticObservation(lines: string[], data: HealthData, cwd: str
297
296
  return;
298
297
  }
299
298
  if (observation.entries.length === 0) {
300
- lines.push(emptyDiagnosticText(observation.scope, cwd));
299
+ lines.push("No errors or warnings reported in this scope.");
301
300
  return;
302
301
  }
303
302
  renderDiagnosticEntries(lines, data, cwd);
@@ -311,15 +310,6 @@ function asSentence(text: string): string {
311
310
  return /[.!?]$/.test(text) ? text : `${text}.`;
312
311
  }
313
312
 
314
- function emptyDiagnosticText(scope: HealthDiagnosticScope, cwd: string): string {
315
- if (scope.kind === "file") {
316
- return `No errors or warnings found for \`${makeRelative(cwd, scope.path)}\`.`;
317
- }
318
- return scope.filter
319
- ? `No errors or warnings are reported by the tracked-file diagnostic snapshot under \`${makeRelative(cwd, scope.filter)}\`.`
320
- : "No errors or warnings are reported by the tracked-file diagnostic snapshot.";
321
- }
322
-
323
313
  function renderDiagnosticEntries(lines: string[], data: HealthData, cwd: string): void {
324
314
  const entries = data.diagnostics.entries;
325
315
  if (data.level === "summary") {
@@ -1,5 +1,5 @@
1
1
  import { renderEvidenceListDisclosure } from "../../analysis/evidence.ts";
2
- import type { InspectObservation } from "../../session/inspect-types.ts";
2
+ import type { InspectDefinition, InspectObservation } from "../../session/inspect-types.ts";
3
3
  import type { InspectResultAssembly } from "./result.ts";
4
4
 
5
5
  export function renderInspectResult(assembly: InspectResultAssembly): string {
@@ -11,7 +11,7 @@ export function renderInspectResult(assembly: InspectResultAssembly): string {
11
11
  "",
12
12
  ];
13
13
 
14
- renderNode(lines, input, input.sections.node);
14
+ renderNode(lines, input.sections.node);
15
15
  renderEnclosingSymbol(lines, input.sections.enclosingSymbol);
16
16
  renderHover(lines, input.sections.hover);
17
17
  renderDefinitions(lines, assembly);
@@ -21,7 +21,6 @@ export function renderInspectResult(assembly: InspectResultAssembly): string {
21
21
 
22
22
  function renderNode(
23
23
  lines: string[],
24
- input: InspectResultAssembly["data"],
25
24
  observation: InspectResultAssembly["data"]["sections"]["node"],
26
25
  ): void {
27
26
  lines.push("## Syntax node");
@@ -37,16 +36,13 @@ function renderNode(
37
36
  return;
38
37
  }
39
38
  lines.push(
40
- `- Type: \`${node.type}\` at ${input.relPath}:${node.startLine}:${node.startCharacter}–${node.endLine}:${node.endCharacter}`,
39
+ `- \`${node.type}\` L${node.startLine}:${node.startCharacter}–L${node.endLine}:${node.endCharacter}`,
41
40
  );
42
41
  if (node.text) lines.push("```text", node.text, "```");
43
42
  if (node.ancestry.length > 0) {
44
- lines.push("", "### Ancestry");
45
- for (const ancestor of node.ancestry) {
46
- lines.push(
47
- `- \`${ancestor.type} L${ancestor.startLine}:${ancestor.startCharacter}–L${ancestor.endLine}:${ancestor.endCharacter}\``,
48
- );
49
- }
43
+ lines.push(
44
+ `Ancestry: ${node.ancestry.map((ancestor) => `\`${ancestor.type} L${ancestor.startLine}:${ancestor.startCharacter}–L${ancestor.endLine}:${ancestor.endCharacter}\``).join(" > ")}`,
45
+ );
50
46
  }
51
47
  lines.push("");
52
48
  }
@@ -95,7 +91,7 @@ function renderDefinitions(lines: string[], assembly: InspectResultAssembly): vo
95
91
  lines.push("_No definition result at this point._");
96
92
  } else {
97
93
  for (const definition of assembly.displayedDefinitions) {
98
- lines.push(`- \`${definition.file}:${definition.line}:${definition.character}\``);
94
+ lines.push(`- ${formatDefinition(definition, assembly.data)}`);
99
95
  }
100
96
  }
101
97
  const disclosure = assembly.definitionEvidence
@@ -105,6 +101,18 @@ function renderDefinitions(lines: string[], assembly: InspectResultAssembly): vo
105
101
  lines.push("");
106
102
  }
107
103
 
104
+ function formatDefinition(
105
+ definition: InspectDefinition,
106
+ focus: InspectResultAssembly["data"],
107
+ ): string {
108
+ if (definition.file !== focus.relPath) {
109
+ return `\`${definition.file}:${definition.line}:${definition.character}\``;
110
+ }
111
+ if (definition.line === focus.line && definition.character === focus.character)
112
+ return "Same point";
113
+ return `L${definition.line}:${definition.character}`;
114
+ }
115
+
108
116
  function renderDiagnostics(lines: string[], assembly: InspectResultAssembly): void {
109
117
  const observation = assembly.data.sections.diagnostics;
110
118
  const window = assembly.data.diagnosticWindow;
@@ -84,6 +84,7 @@ export function assembleInspectResult(
84
84
  confidence: data.confidence,
85
85
  focusTarget: `${data.relPath}:${data.line}:${data.character}`,
86
86
  diagnosticWindow: { ...data.diagnosticWindow },
87
+ diagnostics: (diagnosticEvidence?.items ?? []).map((diagnostic) => ({ ...diagnostic })),
87
88
  sections: inspectSectionDetails(data),
88
89
  evidenceLists: [...assembled.evidenceLists],
89
90
  nextQueries: assembledNextQueries(assembled),
@@ -0,0 +1,66 @@
1
+ import type {
2
+ OrientationResultData,
3
+ OrientationSectionData,
4
+ } from "../../session/orientation-types.ts";
5
+
6
+ const INLINE_SECTIONS = new Set([
7
+ "instructions",
8
+ "workspace.directories",
9
+ "workspace.files",
10
+ "workspace.issues",
11
+ ]);
12
+
13
+ /** Keep the immediate directory map and all collection problems inline; defer ancillary facts. */
14
+ export function selectDirectoryNavigation(data: OrientationResultData): OrientationResultData {
15
+ if (!data.workspace?.focus || data.workspace.overview) return data;
16
+ const workspaceRoot = data.workspace.focus === data.workspace.observation.root;
17
+ const inline = (section: OrientationSectionData): boolean =>
18
+ INLINE_SECTIONS.has(section.key) ||
19
+ section.key.startsWith("gradle.") ||
20
+ (workspaceRoot &&
21
+ (section.key === "workspace.projects" || section.key === "workspace.memberships")) ||
22
+ section.status !== "complete" ||
23
+ section.evidenceLists.some((list) => list.totalCount === null || list.partialReason !== null);
24
+ const sections = data.sections.filter(inline);
25
+ const deferred = data.sections.filter((section) => !inline(section));
26
+ const total = deferred.reduce(
27
+ (sum, section) =>
28
+ sum + section.evidenceLists.reduce((count, list) => count + (list.totalCount ?? 0), 0),
29
+ 0,
30
+ );
31
+ if (total > 0) {
32
+ sections.push({
33
+ key: "workspace.captured",
34
+ title: "Captured navigation",
35
+ status: "complete",
36
+ reason: null,
37
+ confidence: "unavailable",
38
+ provenance: [],
39
+ evidenceLists: [
40
+ {
41
+ key: "workspace.captured",
42
+ totalCount: total,
43
+ shownCount: 0,
44
+ omittedCount: total,
45
+ partialReason: null,
46
+ },
47
+ ],
48
+ items: [
49
+ {
50
+ kind: "paragraph",
51
+ text: `Ancillary sections are in the captured details: ${deferred.map((section) => section.title).join("; ")}.`,
52
+ },
53
+ ],
54
+ });
55
+ }
56
+ return {
57
+ ...data,
58
+ sections,
59
+ renderedSections: sections.map((section) => section.key),
60
+ omittedCount: sections.reduce(
61
+ (sum, section) =>
62
+ sum + section.evidenceLists.reduce((count, list) => count + (list.omittedCount ?? 0), 0),
63
+ 0,
64
+ ),
65
+ };
66
+ }
@@ -0,0 +1,68 @@
1
+ import type { GradleObservation } from "../../analysis/gradle/types.ts";
2
+ import type { OrientationSectionData } from "../../session/orientation-types.ts";
3
+ import { code, tableSection } from "./workspace-format.ts";
4
+
5
+ /** Project identities and runtime provenance stay separate from parsed Project declarations. */
6
+ export function gradleSections(
7
+ observation: GradleObservation | undefined,
8
+ limit: number,
9
+ ): OrientationSectionData[] {
10
+ if (!observation) return [];
11
+ const attempted = observation.status === "complete" || observation.stage === "query";
12
+ const uncertain = observation.status !== "complete" && observation.stage === "unknown";
13
+ let queryStatement = "Model query was not run";
14
+ if (attempted) queryStatement = "Model query was attempted";
15
+ if (uncertain) queryStatement = "Model query execution is unknown";
16
+ const detail = `Selected build ${observation.selectedRoot}; requested model ${observation.query}; ${queryStatement}${observation.gradleVersion ? `; Gradle ${observation.gradleVersion}` : ""}${observation.runtime ? `; ${observation.runtime.kind} from ${observation.runtime.source}` : ""}`;
17
+ const source = attempted || uncertain ? "runtime" : "configuration";
18
+ const capability = uncertain ? "Gradle collection" : observation.query;
19
+ const provenance = [{ source, capability, detail }] as const;
20
+ const common: OrientationSectionData = {
21
+ key: "gradle.observation",
22
+ title: "Gradle model observation",
23
+ status: observation.status === "complete" ? "complete" : "unavailable",
24
+ reason:
25
+ observation.status === "complete" ? null : `${observation.status}: ${observation.reason}`,
26
+ confidence: "unavailable",
27
+ provenance,
28
+ evidenceLists: [],
29
+ items: [
30
+ {
31
+ kind: "paragraph",
32
+ text: `Selected build: ${code(observation.selectedRoot)}. Requested model: ${code(observation.query)}. ${observation.gradleVersion ? `Gradle ${code(observation.gradleVersion)}. ` : ""}${observation.status === "complete" ? "Runtime-reported facts, not parsed Project declarations. Included-build trees are not expanded. Directories do not establish source ownership, dependency resolution, or runtime architecture." : `${queryStatement}. This does not establish that the build has no projects.`}`,
33
+ },
34
+ ],
35
+ };
36
+ if (observation.status !== "complete") return [common];
37
+ const projects = tableSection("gradle.projects", "Gradle-reported projects", {
38
+ headers: [
39
+ "Build identity (root directory)",
40
+ "Logical project path",
41
+ "Name",
42
+ "Parent path",
43
+ "Actual project directory",
44
+ ],
45
+ rows: observation.projects.map((project) => [
46
+ code(project.buildRoot),
47
+ code(project.path),
48
+ code(project.name),
49
+ project.parentPath === null ? "—" : code(project.parentPath),
50
+ code(project.directory),
51
+ ]),
52
+ limit,
53
+ source: "runtime",
54
+ detail,
55
+ });
56
+ const included = tableSection(
57
+ "gradle.included-builds",
58
+ "Gradle included-build references (not expanded)",
59
+ {
60
+ headers: ["Build identity (root directory)"],
61
+ rows: observation.includedBuilds.map((build) => [code(build.buildRoot)]),
62
+ limit,
63
+ source: "runtime",
64
+ detail,
65
+ },
66
+ );
67
+ return [common, { ...projects, provenance }, { ...included, provenance }];
68
+ }