@mrclrchtr/supi-code-intelligence 11.0.1 → 11.2.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 (200) hide show
  1. package/README.md +68 -6
  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 +43 -6
  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/semver/LICENSE +15 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
  52. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
  53. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
  56. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
  63. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
  66. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
  67. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
  68. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
  69. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
  70. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
  71. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
  72. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
  73. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/README.md +5 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/browser/ril.js +8 -0
  75. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/connection.js +7 -2
  76. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/ral.d.ts +8 -0
  77. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.d.ts +14 -0
  78. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.js +6 -4
  79. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/ril.js +5 -1
  80. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/package.json +4 -2
  81. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/package.json +4 -3
  82. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/esm/main.js +2 -2
  83. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/umd/main.js +2 -2
  84. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/package.json +2 -1
  85. package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -6
  86. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +44 -5
  87. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
  88. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
  89. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
  90. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
  91. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
  92. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +53 -20
  93. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
  94. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
  95. package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +27 -15
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -0
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -3
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/LICENSE +21 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +19 -2
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/LICENSE +21 -0
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +19 -2
  107. package/node_modules/ignore/README.md +36 -10
  108. package/node_modules/ignore/index.d.ts +3 -2
  109. package/node_modules/ignore/index.js +57 -53
  110. package/node_modules/ignore/legacy.js +50 -46
  111. package/node_modules/ignore/package.json +1 -1
  112. package/package.json +11 -6
  113. package/src/analysis/capability/capability-warnings.ts +18 -12
  114. package/src/analysis/gradle/query.ts +273 -0
  115. package/src/analysis/gradle/runtime.ts +173 -0
  116. package/src/analysis/gradle/types.ts +65 -0
  117. package/src/analysis/health/check.ts +115 -0
  118. package/src/analysis/health/diagnostics.ts +3 -0
  119. package/src/analysis/health/file-scope.ts +2 -3
  120. package/src/analysis/health/semantic-state.ts +38 -0
  121. package/src/analysis/health/server-status.ts +8 -0
  122. package/src/analysis/health/signals.ts +2 -0
  123. package/src/analysis/health/status.ts +82 -0
  124. package/src/analysis/read-next.ts +1 -4
  125. package/src/analysis/refactor/apply.ts +19 -10
  126. package/src/analysis/refactor/mutation-authority.ts +4 -1
  127. package/src/analysis/search/ast-scan.ts +143 -18
  128. package/src/analysis/workspace/safe-path.ts +14 -2
  129. package/src/analysis/workspace/types.ts +2 -0
  130. package/src/extension.ts +10 -1
  131. package/src/gradle/consent.ts +279 -0
  132. package/src/headless.ts +3 -0
  133. package/src/overview/collect.ts +11 -3
  134. package/src/session/health-types.ts +7 -0
  135. package/src/session/health-workflow.ts +8 -43
  136. package/src/session/orientation/collect.ts +138 -12
  137. package/src/session/orientation/context-facts.ts +27 -2
  138. package/src/session/orientation/context-sections.ts +47 -0
  139. package/src/session/orientation/facts.ts +124 -0
  140. package/src/session/orientation/gather.ts +98 -11
  141. package/src/session/orientation/workspace-context.ts +59 -28
  142. package/src/session/orientation-types.ts +16 -1
  143. package/src/session/orientation-workflow.ts +5 -2
  144. package/src/session/refactor-plans.ts +5 -2
  145. package/src/session/refactor-workflow.ts +4 -3
  146. package/src/session/session.ts +8 -0
  147. package/src/tool/code_find/execute.ts +1 -1
  148. package/src/tool/code_find/guidance.ts +1 -1
  149. package/src/tool/code_find/markdown.ts +24 -17
  150. package/src/tool/code_find/result.ts +18 -5
  151. package/src/tool/code_find/spec.ts +2 -0
  152. package/src/tool/code_find/structured.ts +161 -0
  153. package/src/tool/code_graph/result.ts +32 -15
  154. package/src/tool/code_graph/spec.ts +2 -0
  155. package/src/tool/code_graph/structured.ts +142 -0
  156. package/src/tool/code_health/markdown.ts +17 -17
  157. package/src/tool/code_health/result.ts +15 -2
  158. package/src/tool/code_health/spec.ts +2 -0
  159. package/src/tool/code_health/structured-schema.ts +250 -0
  160. package/src/tool/code_health/structured.ts +256 -0
  161. package/src/tool/code_inspect/markdown.ts +19 -11
  162. package/src/tool/code_inspect/result.ts +12 -5
  163. package/src/tool/code_inspect/spec.ts +2 -0
  164. package/src/tool/code_inspect/structured.ts +232 -0
  165. package/src/tool/code_orientation/directory-navigation.ts +66 -0
  166. package/src/tool/code_orientation/gradle-sections.ts +68 -0
  167. package/src/tool/code_orientation/markdown.ts +19 -8
  168. package/src/tool/code_orientation/result.ts +95 -11
  169. package/src/tool/code_orientation/spec.ts +2 -0
  170. package/src/tool/code_orientation/structured-schema.ts +607 -0
  171. package/src/tool/code_orientation/structured-workspace.ts +193 -0
  172. package/src/tool/code_orientation/structured.ts +195 -0
  173. package/src/tool/code_orientation/workspace-format.ts +2 -1
  174. package/src/tool/code_orientation/workspace-observations.ts +81 -0
  175. package/src/tool/code_orientation/workspace-output.ts +45 -13
  176. package/src/tool/code_orientation/workspace-projects.ts +180 -75
  177. package/src/tool/code_orientation/workspace-sections.ts +46 -31
  178. package/src/tool/code_refactor_apply/execute.ts +1 -1
  179. package/src/tool/code_refactor_apply/result.ts +13 -5
  180. package/src/tool/code_refactor_apply/spec.ts +2 -0
  181. package/src/tool/code_refactor_apply/structured.ts +49 -0
  182. package/src/tool/code_refactor_plan/result.ts +16 -8
  183. package/src/tool/code_refactor_plan/spec.ts +2 -0
  184. package/src/tool/code_refactor_plan/structured.ts +128 -0
  185. package/src/tool/code_resolve/markdown.ts +4 -10
  186. package/src/tool/code_resolve/result.ts +2 -0
  187. package/src/tool/code_resolve/spec.ts +2 -0
  188. package/src/tool/code_resolve/structured.ts +103 -0
  189. package/src/tool/infra/truncate.ts +12 -4
  190. package/src/tool/register.ts +10 -6
  191. package/src/tool/result/display.ts +17 -0
  192. package/src/tool/result/model-budget.ts +195 -0
  193. package/src/tool/result/structured.ts +62 -0
  194. package/src/tool/result/types.ts +10 -2
  195. package/src/tool/schemas.ts +7 -1
  196. package/src/tool/specs.ts +2 -0
  197. package/src/types/execution.ts +5 -1
  198. package/src/ui/status-command.ts +110 -321
  199. package/src/ui/status-overlay.ts +564 -420
  200. 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
+ }
@@ -1,6 +1,7 @@
1
1
  /** Markdown renderer for code_health results. */
2
2
  import type { CapabilityWarningReport } from "../../analysis/capability/capability-warnings.ts";
3
3
  import {
4
+ formatProjectServerCompiler,
4
5
  formatProjectServerOperationSupport,
5
6
  formatProjectServerRoot,
6
7
  formatProjectServerRouteSummary,
@@ -69,9 +70,7 @@ function renderRefreshStatus(
69
70
  if (data.refresh.lastAttempt) {
70
71
  renderRetainedAttempt(lines, data.refresh.lastAttempt, cwd);
71
72
  } else {
72
- lines.push(
73
- "**Diagnostic refresh attempt**: not requested this session. Use `refresh: true` to try one.",
74
- );
73
+ lines.push("Refresh: not requested (`refresh: true` to attempt).");
75
74
  }
76
75
  lines.push("");
77
76
  }
@@ -236,8 +235,9 @@ function renderStatusLine(lines: string[], data: HealthData, semanticRequested:
236
235
  if (!semanticRequested) return;
237
236
 
238
237
  const routeSummary = formatProjectServerRouteSummary(data.servers);
239
- lines.push(`**LSP**: ${displaySemanticStatus(data)}${routeSummary ? ` — ${routeSummary}` : ""}`);
240
- if (data.structuralStatus) lines.push(`**Structural**: ${data.structuralStatus}`);
238
+ lines.push(
239
+ `**LSP**: ${displaySemanticStatus(data)}${routeSummary ? ` — ${routeSummary}` : ""}${data.structuralStatus ? `; **Structural**: ${data.structuralStatus}` : ""}`,
240
+ );
241
241
  lines.push("");
242
242
  }
243
243
 
@@ -297,7 +297,7 @@ function renderDiagnosticObservation(lines: string[], data: HealthData, cwd: str
297
297
  return;
298
298
  }
299
299
  if (observation.entries.length === 0) {
300
- lines.push(emptyDiagnosticText(observation.scope, cwd));
300
+ lines.push("No errors or warnings reported in this scope.");
301
301
  return;
302
302
  }
303
303
  renderDiagnosticEntries(lines, data, cwd);
@@ -311,15 +311,6 @@ function asSentence(text: string): string {
311
311
  return /[.!?]$/.test(text) ? text : `${text}.`;
312
312
  }
313
313
 
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
314
  function renderDiagnosticEntries(lines: string[], data: HealthData, cwd: string): void {
324
315
  const entries = data.diagnostics.entries;
325
316
  if (data.level === "summary") {
@@ -382,13 +373,22 @@ function renderServersSection(
382
373
  lines.push(
383
374
  `- ${statusIcon} **${server.name}** @ \`${formatProjectServerRoot(cwd, server.root)}\` (${server.fileTypes.join(", ")}) — ${server.status}${reason}`,
384
375
  );
385
- const operationSupport = formatProjectServerOperationSupport(server.operationSupport);
386
- if (operationSupport) lines.push(` - ${operationSupport}`);
376
+ renderServerDetails(lines, server);
387
377
  }
388
378
  }
389
379
  lines.push("");
390
380
  }
391
381
 
382
+ function renderServerDetails(lines: string[], server: HealthData["servers"][number]): void {
383
+ for (const detail of [
384
+ formatProjectServerCompiler(server.typescript),
385
+ server.failureMessage,
386
+ formatProjectServerOperationSupport(server.operationSupport),
387
+ ]) {
388
+ if (detail) lines.push(` - ${detail}`);
389
+ }
390
+ }
391
+
392
392
  function displaySemanticStatus(data: HealthData): string {
393
393
  return formatSemanticHealthState(data.semanticState);
394
394
  }
@@ -1,6 +1,7 @@
1
1
  import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
2
2
  import {
3
3
  countProjectServerRouteStatuses,
4
+ formatProjectServerCompiler,
4
5
  formatProjectServerOperationSupport,
5
6
  formatProjectServerRoot,
6
7
  formatProjectServerStatusReason,
@@ -117,7 +118,14 @@ function buildHealthDisplaySections(data: HealthData, cwd?: string): ToolDisplay
117
118
  totalCount: data.servers.length,
118
119
  format: (server) => {
119
120
  const root = cwd ? formatProjectServerRoot(cwd, server.root) : server.root;
120
- const support = formatProjectServerOperationSupport(server.operationSupport);
121
+ const compiler = formatProjectServerCompiler(server.typescript);
122
+ const support = [
123
+ compiler,
124
+ server.failureMessage,
125
+ formatProjectServerOperationSupport(server.operationSupport),
126
+ ]
127
+ .filter(Boolean)
128
+ .join(" — ");
121
129
  return `${server.name} @ ${root} (${server.fileTypes.join(", ")}) — ${server.status}${server.statusReason ? ` — ${formatProjectServerStatusReason(server.statusReason)}` : ""}${support ? ` — ${support}` : ""}`;
122
130
  },
123
131
  }),
@@ -257,6 +265,7 @@ function uniqueProvenance(provenance: readonly ResultProvenance[]): ResultProven
257
265
  import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
258
266
  import { healthErrorResult } from "../result/errors.ts";
259
267
  import { renderHealthResult } from "./markdown.ts";
268
+ import { structuredHealthResult } from "./structured.ts";
260
269
 
261
270
  type HealthOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["health"]>>;
262
271
 
@@ -264,12 +273,16 @@ type HealthOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["health"
264
273
  export function finishHealthResult(outcome: HealthOutcome, cwd: string): CodeIntelResult {
265
274
  if (outcome.kind === "unavailable") throw new Error(outcome.reason);
266
275
  if (outcome.kind === "invalid-input") {
267
- return healthErrorResult(`**Error:** ${outcome.message}`, outcome.message);
276
+ return {
277
+ ...healthErrorResult(`**Error:** ${outcome.message}`, outcome.message),
278
+ structuredContent: { kind: "invalid-input", message: outcome.message },
279
+ };
268
280
  }
269
281
 
270
282
  const assembly = assembleHealthResult(outcome.data, cwd);
271
283
  return {
272
284
  content: renderHealthResult(assembly, cwd),
285
+ structuredContent: structuredHealthResult(outcome.data),
273
286
  details: {
274
287
  type: "health",
275
288
  data: assembly.details,
@@ -3,6 +3,7 @@ import { Type } from "typebox";
3
3
  import type { CodeIntelToolExecCtx } from "../../types/index.ts";
4
4
  import { ScopeParam } from "../schemas.ts";
5
5
  import { executeHealthTool } from "./execute.ts";
6
+ import { HealthOutputSchema } from "./structured-schema.ts";
6
7
  import { renderHealthCall, renderHealthResult } from "./tui.ts";
7
8
 
8
9
  export const CODE_HEALTH_TOOL_NAME = "code_health";
@@ -35,6 +36,7 @@ export const codeHealthSpec = {
35
36
  },
36
37
  { additionalProperties: false },
37
38
  ),
39
+ outputSchema: HealthOutputSchema,
38
40
  run: (params: unknown, ctx: CodeIntelToolExecCtx) =>
39
41
  executeHealthTool(params as Parameters<typeof executeHealthTool>[0], ctx),
40
42
  renderCall: renderHealthCall,