@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,250 @@
1
+ import { StringEnum } from "@earendil-works/pi-ai";
2
+ import { Type } from "typebox";
3
+ import { HEALTH_DIAGNOSTIC_MESSAGE_LIMIT } from "../../session/health-types.ts";
4
+
5
+ const object = <T extends import("typebox").TProperties>(properties: T) =>
6
+ Type.Object(properties, { additionalProperties: false });
7
+ const nullableString = Type.Union([Type.String(), Type.Null()]);
8
+ const scope = Type.Union([
9
+ object({ kind: Type.Literal("file"), path: Type.String() }),
10
+ object({ kind: Type.Literal("tracked-files"), filter: nullableString }),
11
+ ]);
12
+ const evidence = object({
13
+ requested: Type.Integer(),
14
+ confirmed: Type.Integer(),
15
+ unconfirmed: Type.Integer(),
16
+ failed: Type.Integer(),
17
+ removed: Type.Integer(),
18
+ documents: Type.Array(
19
+ object({
20
+ file: Type.String(),
21
+ status: StringEnum(["confirmed", "unconfirmed", "failed", "removed"]),
22
+ }),
23
+ ),
24
+ });
25
+ const scopeStatus = object({
26
+ status: StringEnum(["included", "excluded", "no-config", "out-of-tree"]),
27
+ basis: Type.Union([
28
+ StringEnum([
29
+ "fileNames",
30
+ "explicit",
31
+ "include-pattern",
32
+ "default-include",
33
+ "exclude-pattern",
34
+ "extension",
35
+ ]),
36
+ Type.Null(),
37
+ ]),
38
+ configPath: nullableString,
39
+ caseSensitiveFileNames: Type.Boolean(),
40
+ });
41
+ const diagnosticEntry = object({
42
+ file: Type.String(),
43
+ errors: Type.Integer(),
44
+ warnings: Type.Integer(),
45
+ messages: Type.Optional(
46
+ Type.Array(
47
+ object({
48
+ line: Type.Integer({ description: "1-based line." }),
49
+ severity: StringEnum(["error", "warning"]),
50
+ message: Type.String(),
51
+ source: Type.Optional(Type.String()),
52
+ }),
53
+ ),
54
+ ),
55
+ });
56
+ const diagnostics = Type.Union([
57
+ object({ kind: Type.Literal("not-requested"), entries: Type.Array(diagnosticEntry) }),
58
+ object({
59
+ kind: Type.Literal("completed"),
60
+ scope,
61
+ entries: Type.Array(diagnosticEntry),
62
+ evidence,
63
+ scopeStatus: Type.Optional(scopeStatus),
64
+ }),
65
+ object({
66
+ kind: StringEnum(["partial", "unavailable"]),
67
+ scope,
68
+ entries: Type.Array(diagnosticEntry),
69
+ evidence,
70
+ reason: Type.String(),
71
+ scopeStatus: Type.Optional(scopeStatus),
72
+ }),
73
+ ]);
74
+ const operation = object({
75
+ server: StringEnum(["advertised", "not-advertised", "unknown"]),
76
+ supi: StringEnum(["supported", "limited", "unsupported"]),
77
+ reason: Type.Optional(Type.String()),
78
+ });
79
+ const support = object({
80
+ rename_symbol: Type.Optional(operation),
81
+ prepare_rename: Type.Optional(operation),
82
+ extract_function: Type.Optional(operation),
83
+ extract_variable: Type.Optional(operation),
84
+ update_imports: Type.Optional(operation),
85
+ delete_dead_code: Type.Optional(operation),
86
+ code_action_resolve: Type.Optional(operation),
87
+ });
88
+ const server = object({
89
+ name: Type.String(),
90
+ root: Type.String(),
91
+ fileTypes: Type.Array(Type.String()),
92
+ status: StringEnum(["running", "error", "unavailable"]),
93
+ statusReason: Type.Optional(
94
+ StringEnum([
95
+ "process-crashed",
96
+ "process-crash-recovery-pending",
97
+ "process-crash-recovery-exhausted",
98
+ ]),
99
+ ),
100
+ ready: Type.Boolean(),
101
+ operationSupport: Type.Optional(support),
102
+ typescript: Type.Optional(
103
+ object({
104
+ backend: Type.Union([Type.Literal("tsserver"), Type.Literal("native")]),
105
+ packageName: Type.String(),
106
+ compilerVersion: Type.Optional(Type.String()),
107
+ wrapperVersion: Type.Optional(Type.String()),
108
+ }),
109
+ ),
110
+ failureMessage: Type.Optional(Type.String()),
111
+ });
112
+ const stale = object({
113
+ scope: StringEnum(["file", "workspace"]),
114
+ suspected: Type.Union([Type.Boolean(), Type.Null()]),
115
+ matchedFileCount: Type.Integer(),
116
+ warning: nullableString,
117
+ });
118
+ const recoveryEntry = object({
119
+ name: Type.String(),
120
+ root: Type.String(),
121
+ outcome: StringEnum([
122
+ "recovered",
123
+ "skipped-no-retained-file",
124
+ "recovery-failed",
125
+ "recovery-exhausted",
126
+ ]),
127
+ nextAction: Type.Optional(StringEnum(["use-exact-file", "refresh"])),
128
+ failureMessage: Type.Optional(Type.String()),
129
+ });
130
+ const crashRecovery = object({
131
+ recoveredRoutes: Type.Integer(),
132
+ skippedRoutes: Type.Integer(),
133
+ failedRoutes: Type.Integer(),
134
+ exhaustedRoutes: Type.Integer(),
135
+ entries: Type.Array(recoveryEntry),
136
+ omittedEntries: Type.Integer(),
137
+ });
138
+ const startupRetry = object({
139
+ recoveredRoutes: Type.Integer(),
140
+ failedRoutes: Type.Integer(),
141
+ entries: Type.Array(
142
+ object({
143
+ name: Type.String(),
144
+ root: Type.String(),
145
+ outcome: StringEnum(["recovered", "retry-failed"]),
146
+ nextAction: Type.Optional(Type.Literal("refresh")),
147
+ failureMessage: Type.Optional(Type.String()),
148
+ }),
149
+ ),
150
+ omittedEntries: Type.Integer(),
151
+ });
152
+ const tracking = object({
153
+ status: StringEnum(["complete", "limited"]),
154
+ reason: Type.Union([StringEnum(["file-limit", "filesystem-error"]), Type.Null()]),
155
+ observedFileCount: Type.Integer(),
156
+ discovered: Type.Array(Type.String()),
157
+ tracked: Type.Array(Type.String()),
158
+ skipped: Type.Array(Type.String()),
159
+ unavailable: Type.Array(Type.String()),
160
+ deferred: Type.Integer(),
161
+ });
162
+ const attemptFields = {
163
+ attemptedAt: Type.Number(),
164
+ elapsedMs: Type.Number(),
165
+ requestedDiagnosticScope: scope,
166
+ operationScope: StringEnum(["file-runtime", "workspace-runtime"]),
167
+ attemptedActiveClients: Type.Optional(Type.Integer()),
168
+ restartedClients: Type.Optional(Type.Integer()),
169
+ fileReadiness: Type.Optional(StringEnum(["ready", "pending", "unavailable"])),
170
+ staleAssessment: Type.Optional(stale),
171
+ diagnosticEvidence: Type.Optional(evidence),
172
+ processCrashRecovery: Type.Optional(crashRecovery),
173
+ startupRetry: Type.Optional(startupRetry),
174
+ sourceTracking: Type.Optional(tracking),
175
+ };
176
+ const completedAttemptFields = {
177
+ ...attemptFields,
178
+ attemptedActiveClients: Type.Integer(),
179
+ restartedClients: Type.Integer(),
180
+ staleAssessment: stale,
181
+ processCrashRecovery: crashRecovery,
182
+ };
183
+ const attempt = Type.Union([
184
+ object({
185
+ kind: Type.Literal("completed"),
186
+ ...completedAttemptFields,
187
+ operationScope: Type.Literal("workspace-runtime"),
188
+ diagnosticEvidence: evidence,
189
+ }),
190
+ object({
191
+ kind: Type.Literal("completed"),
192
+ ...completedAttemptFields,
193
+ operationScope: Type.Literal("file-runtime"),
194
+ }),
195
+ object({ kind: Type.Literal("failed"), ...attemptFields, reason: Type.String() }),
196
+ ]);
197
+ const refresh = Type.Union([
198
+ attempt,
199
+ object({
200
+ kind: StringEnum(["not-requested", "not-attempted"]),
201
+ reason: Type.String(),
202
+ lastAttempt: Type.Union([attempt, Type.Null()]),
203
+ }),
204
+ ]);
205
+ const warningReport = object({
206
+ hasWarnings: Type.Boolean(),
207
+ warnings: Type.Array(
208
+ object({
209
+ type: StringEnum([
210
+ "language-disabled",
211
+ "missing-server",
212
+ "structural-unavailable",
213
+ "configuration-error",
214
+ ]),
215
+ message: Type.String(),
216
+ language: Type.Optional(Type.String()),
217
+ detail: Type.Optional(Type.String()),
218
+ }),
219
+ ),
220
+ });
221
+
222
+ /** Complete collected health facts; diagnostic observations never imply workspace-wide coverage. */
223
+ export const HealthOutputSchema = Type.Union([
224
+ object({ kind: Type.Literal("invalid-input"), message: Type.String() }),
225
+ object({
226
+ kind: Type.Literal("completed"),
227
+ level: StringEnum(["summary", "detailed"]),
228
+ includedSections: Type.Array(StringEnum(["diagnostics", "servers"])),
229
+ semanticState: Type.Union([
230
+ object({ kind: Type.Literal("ready") }),
231
+ object({
232
+ kind: StringEnum(["pending", "inactive", "disabled", "unavailable"]),
233
+ reason: Type.String(),
234
+ }),
235
+ Type.Null(),
236
+ ]),
237
+ structuralAvailable: Type.Optional(Type.Boolean()),
238
+ structuralStatus: Type.Optional(Type.String()),
239
+ diagnostics,
240
+ diagnosticMessageLimitPerFile: Type.Literal(HEALTH_DIAGNOSTIC_MESSAGE_LIMIT, {
241
+ description:
242
+ "Detailed diagnostics include at most three error/warning messages per file; line numbers are 1-based.",
243
+ }),
244
+ serverInventoryScope: Type.Literal("workspace"),
245
+ serverInventoryAvailable: Type.Boolean(),
246
+ servers: Type.Array(server),
247
+ refresh,
248
+ capabilityWarnings: Type.Optional(warningReport),
249
+ }),
250
+ ]);
@@ -0,0 +1,256 @@
1
+ import type { DiagnosticEvidenceSummary } from "@mrclrchtr/supi-lsp/api";
2
+ import type { Static } from "typebox";
3
+ import type {
4
+ HealthData,
5
+ HealthDiagnosticScope,
6
+ HealthRefreshAttempt,
7
+ HealthRefreshState,
8
+ } from "../../session/health-types.ts";
9
+ import { HEALTH_DIAGNOSTIC_MESSAGE_LIMIT } from "../../session/health-types.ts";
10
+ import type { HealthOutputSchema } from "./structured-schema.ts";
11
+
12
+ type Output = Static<typeof HealthOutputSchema>;
13
+
14
+ // Explicitly copy public fields; provider and session-owned objects must not cross this seam.
15
+ function copyEvidence(value: DiagnosticEvidenceSummary) {
16
+ return {
17
+ requested: value.requested,
18
+ confirmed: value.confirmed,
19
+ unconfirmed: value.unconfirmed,
20
+ failed: value.failed,
21
+ removed: value.removed,
22
+ documents: value.documents.map(({ file, status }) => ({ file, status })),
23
+ };
24
+ }
25
+ function copyScope(value: HealthDiagnosticScope) {
26
+ return value.kind === "file"
27
+ ? { kind: value.kind, path: value.path }
28
+ : { kind: value.kind, filter: value.filter };
29
+ }
30
+ function copyAttempt(value: HealthRefreshAttempt) {
31
+ const {
32
+ kind,
33
+ attemptedAt,
34
+ elapsedMs,
35
+ requestedDiagnosticScope,
36
+ operationScope,
37
+ attemptedActiveClients,
38
+ restartedClients,
39
+ fileReadiness,
40
+ staleAssessment,
41
+ processCrashRecovery,
42
+ startupRetry: retry,
43
+ sourceTracking,
44
+ } = value;
45
+ const diagnosticEvidence = "diagnosticEvidence" in value ? value.diagnosticEvidence : undefined;
46
+ return {
47
+ kind,
48
+ attemptedAt,
49
+ elapsedMs,
50
+ requestedDiagnosticScope: copyScope(requestedDiagnosticScope),
51
+ operationScope,
52
+ ...(attemptedActiveClients === undefined ? {} : { attemptedActiveClients }),
53
+ ...(restartedClients === undefined ? {} : { restartedClients }),
54
+ ...(fileReadiness === undefined ? {} : { fileReadiness }),
55
+ ...(staleAssessment
56
+ ? {
57
+ staleAssessment: {
58
+ scope: staleAssessment.scope,
59
+ suspected: staleAssessment.suspected,
60
+ matchedFileCount: staleAssessment.matchedFileCount,
61
+ warning: staleAssessment.warning,
62
+ },
63
+ }
64
+ : {}),
65
+ ...(diagnosticEvidence ? { diagnosticEvidence: copyEvidence(diagnosticEvidence) } : {}),
66
+ ...(processCrashRecovery
67
+ ? {
68
+ processCrashRecovery: {
69
+ recoveredRoutes: processCrashRecovery.recoveredRoutes,
70
+ skippedRoutes: processCrashRecovery.skippedRoutes,
71
+ failedRoutes: processCrashRecovery.failedRoutes,
72
+ exhaustedRoutes: processCrashRecovery.exhaustedRoutes,
73
+ omittedEntries: processCrashRecovery.omittedEntries,
74
+ entries: processCrashRecovery.entries.map(
75
+ ({ name, root, outcome, nextAction, failureMessage }) => ({
76
+ name,
77
+ root,
78
+ outcome,
79
+ ...(nextAction === undefined ? {} : { nextAction }),
80
+ ...(failureMessage === undefined ? {} : { failureMessage }),
81
+ }),
82
+ ),
83
+ },
84
+ }
85
+ : {}),
86
+ ...(retry
87
+ ? {
88
+ startupRetry: {
89
+ recoveredRoutes: retry.recoveredRoutes,
90
+ failedRoutes: retry.failedRoutes,
91
+ omittedEntries: retry.omittedEntries,
92
+ entries: retry.entries.map(({ name, root, outcome, nextAction, failureMessage }) => ({
93
+ name,
94
+ root,
95
+ outcome,
96
+ ...(nextAction === undefined ? {} : { nextAction }),
97
+ ...(failureMessage === undefined ? {} : { failureMessage }),
98
+ })),
99
+ },
100
+ }
101
+ : {}),
102
+ ...(sourceTracking
103
+ ? {
104
+ sourceTracking: {
105
+ status: sourceTracking.status,
106
+ reason: sourceTracking.reason,
107
+ observedFileCount: sourceTracking.observedFileCount,
108
+ discovered: [...sourceTracking.discovered],
109
+ tracked: [...sourceTracking.tracked],
110
+ skipped: [...sourceTracking.skipped],
111
+ unavailable: [...sourceTracking.unavailable],
112
+ deferred: sourceTracking.deferred,
113
+ },
114
+ }
115
+ : {}),
116
+ ...(kind === "failed" ? { reason: value.reason } : {}),
117
+ };
118
+ }
119
+ function copyRefresh(value: HealthRefreshState) {
120
+ return value.kind === "not-requested" || value.kind === "not-attempted"
121
+ ? {
122
+ kind: value.kind,
123
+ reason: value.reason,
124
+ lastAttempt: value.lastAttempt ? copyAttempt(value.lastAttempt) : null,
125
+ }
126
+ : copyAttempt(value);
127
+ }
128
+ /** Project health workflow facts without including session state or text-preview limits. */
129
+ export function structuredHealthResult(data: HealthData): Output {
130
+ const observation = data.diagnostics;
131
+ const entries = observation.entries.map(({ file, errors, warnings, messages }) => ({
132
+ file,
133
+ errors,
134
+ warnings,
135
+ ...(messages
136
+ ? {
137
+ messages: messages.map(({ line, severity, message, source }) => ({
138
+ line,
139
+ severity,
140
+ message,
141
+ ...(source === undefined ? {} : { source }),
142
+ })),
143
+ }
144
+ : {}),
145
+ }));
146
+ const diagnosticResult =
147
+ observation.kind === "not-requested"
148
+ ? { kind: observation.kind, entries }
149
+ : {
150
+ kind: observation.kind,
151
+ entries,
152
+ scope: copyScope(observation.scope),
153
+ evidence: copyEvidence(observation.evidence),
154
+ ...(observation.kind === "completed" ? {} : { reason: observation.reason }),
155
+ ...(observation.scopeStatus
156
+ ? {
157
+ scopeStatus: {
158
+ status: observation.scopeStatus.status,
159
+ basis: observation.scopeStatus.basis,
160
+ configPath: observation.scopeStatus.configPath,
161
+ caseSensitiveFileNames: observation.scopeStatus.caseSensitiveFileNames,
162
+ },
163
+ }
164
+ : {}),
165
+ };
166
+ const operations = [
167
+ "rename_symbol",
168
+ "prepare_rename",
169
+ "extract_function",
170
+ "extract_variable",
171
+ "update_imports",
172
+ "delete_dead_code",
173
+ "code_action_resolve",
174
+ ] as const;
175
+ const servers = data.servers.map(
176
+ ({
177
+ name,
178
+ root,
179
+ fileTypes,
180
+ status,
181
+ statusReason,
182
+ ready,
183
+ operationSupport,
184
+ typescript,
185
+ failureMessage,
186
+ }) => ({
187
+ name,
188
+ root,
189
+ fileTypes: [...fileTypes],
190
+ status,
191
+ ready,
192
+ ...(statusReason === undefined ? {} : { statusReason }),
193
+ ...(typescript ? { typescript } : {}),
194
+ ...(failureMessage ? { failureMessage } : {}),
195
+ ...(operationSupport
196
+ ? {
197
+ operationSupport: Object.fromEntries(
198
+ operations.flatMap((key) => {
199
+ const item = operationSupport[key];
200
+ return item
201
+ ? [
202
+ [
203
+ key,
204
+ {
205
+ server: item.server,
206
+ supi: item.supi,
207
+ ...(item.reason === undefined ? {} : { reason: item.reason }),
208
+ },
209
+ ],
210
+ ]
211
+ : [];
212
+ }),
213
+ ),
214
+ }
215
+ : {}),
216
+ }),
217
+ );
218
+ const semanticState =
219
+ data.semanticState === null
220
+ ? null
221
+ : data.semanticState.kind === "ready"
222
+ ? { kind: "ready" as const }
223
+ : { kind: data.semanticState.kind, reason: data.semanticState.reason };
224
+ // The input types are discriminated more narrowly than the independently projected fields.
225
+ return {
226
+ kind: "completed",
227
+ level: data.level,
228
+ includedSections: [...data.includedSections],
229
+ semanticState,
230
+ ...(data.structuralAvailable === undefined
231
+ ? {}
232
+ : { structuralAvailable: data.structuralAvailable }),
233
+ ...(data.structuralStatus === undefined ? {} : { structuralStatus: data.structuralStatus }),
234
+ diagnostics: diagnosticResult,
235
+ diagnosticMessageLimitPerFile: HEALTH_DIAGNOSTIC_MESSAGE_LIMIT,
236
+ serverInventoryScope: "workspace",
237
+ serverInventoryAvailable: data.serverInventoryAvailable,
238
+ servers,
239
+ refresh: copyRefresh(data.refresh),
240
+ ...(data.capabilityWarnings
241
+ ? {
242
+ capabilityWarnings: {
243
+ hasWarnings: data.capabilityWarnings.hasWarnings,
244
+ warnings: data.capabilityWarnings.warnings.map(
245
+ ({ type, message, language, detail }) => ({
246
+ type,
247
+ message,
248
+ ...(language === undefined ? {} : { language }),
249
+ ...(detail === undefined ? {} : { detail }),
250
+ }),
251
+ ),
252
+ },
253
+ }
254
+ : {}),
255
+ } as Output;
256
+ }
@@ -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),
@@ -327,6 +328,7 @@ function overallProvenance(data: InspectResultData): ResultProvenance[] {
327
328
  import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
328
329
  import { inspectErrorResult } from "../result/errors.ts";
329
330
  import { renderInspectResult } from "./markdown.ts";
331
+ import { structuredInspectResult } from "./structured.ts";
330
332
 
331
333
  type InspectOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["inspect"]>>;
332
334
 
@@ -334,16 +336,21 @@ type InspectOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["inspec
334
336
  export function finishInspectResult(outcome: InspectOutcome): CodeIntelResult {
335
337
  if (outcome.kind === "unavailable") throw new Error(outcome.reason);
336
338
  if (outcome.kind === "invalid-input") {
337
- return inspectErrorResult(`**Error:** ${outcome.message}`, {
338
- focusTarget: "invalid input",
339
- nextQueries: ["Provide an existing file and exact 1-based point"],
340
- message: outcome.message,
341
- });
339
+ const nextQueries = ["Provide an existing file and exact 1-based point"];
340
+ return {
341
+ ...inspectErrorResult(`**Error:** ${outcome.message}`, {
342
+ focusTarget: "invalid input",
343
+ nextQueries,
344
+ message: outcome.message,
345
+ }),
346
+ structuredContent: { kind: "invalid-input", message: outcome.message, nextQueries },
347
+ };
342
348
  }
343
349
 
344
350
  const assembly = assembleInspectResult(outcome.data, outcome.nextQueries);
345
351
  return {
346
352
  content: renderInspectResult(assembly),
353
+ structuredContent: structuredInspectResult(assembly),
347
354
  details: {
348
355
  type: "inspect",
349
356
  data: assembly.details,
@@ -2,6 +2,7 @@ import { Type } from "typebox";
2
2
  import type { CodeIntelToolExecCtx } from "../../types/index.ts";
3
3
  import { MaxResultsParam, SourcePointParam } from "../schemas.ts";
4
4
  import { executeInspectTool } from "./execute.ts";
5
+ import { InspectOutputSchema } from "./structured.ts";
5
6
  import { renderInspectCall, renderInspectResult } from "./tui.ts";
6
7
 
7
8
  export const CODE_INSPECT_TOOL_NAME = "code_inspect";
@@ -11,6 +12,7 @@ export const CODE_INSPECT_TOOL_LABEL = "Code Inspect";
11
12
  export const codeInspectSpec = {
12
13
  name: CODE_INSPECT_TOOL_NAME,
13
14
  label: CODE_INSPECT_TOOL_LABEL,
15
+ outputSchema: InspectOutputSchema,
14
16
  parameters: Type.Object(
15
17
  {
16
18
  point: SourcePointParam,