@mrclrchtr/supi-code-intelligence 11.1.0 → 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +41 -6
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  6. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  7. package/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  8. package/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  9. package/node_modules/@mrclrchtr/supi-lsp/README.md +81 -7
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/LICENSE +15 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
  52. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
  53. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
  56. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
  63. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
  66. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
  67. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
  68. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
  69. package/node_modules/@mrclrchtr/supi-lsp/package.json +5 -3
  70. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +11 -4
  71. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +77 -6
  72. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +149 -0
  73. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-typescript-project.ts +40 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +174 -49
  75. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
  76. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
  77. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
  78. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
  79. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +2 -2
  80. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
  81. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +157 -23
  82. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +306 -75
  83. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
  84. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
  85. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +19 -2
  86. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +1 -0
  87. package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +27 -15
  88. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +5 -1
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +2 -2
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +5 -1
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +5 -1
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +40 -25
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +2 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/call-context.ts +44 -0
  104. package/package.json +6 -5
  105. package/src/analysis/capability/capability-warnings.ts +18 -12
  106. package/src/analysis/health/check.ts +115 -0
  107. package/src/analysis/health/diagnostics.ts +3 -0
  108. package/src/analysis/health/file-scope.ts +2 -3
  109. package/src/analysis/health/semantic-state.ts +38 -0
  110. package/src/analysis/health/server-status.ts +14 -2
  111. package/src/analysis/health/signals.ts +2 -0
  112. package/src/analysis/health/status.ts +82 -0
  113. package/src/analysis/refactor/apply.ts +17 -8
  114. package/src/analysis/search/exclusions.ts +47 -0
  115. package/src/analysis/search/paths.ts +32 -9
  116. package/src/analysis/target/anchored-structural.ts +3 -8
  117. package/src/analysis/target/anchored.ts +4 -20
  118. package/src/analysis/target/identity.ts +1 -1
  119. package/src/analysis/target/latex-label-container.ts +6 -6
  120. package/src/analysis/target/latex-section-anchor.ts +6 -6
  121. package/src/analysis/target/resolution.ts +18 -0
  122. package/src/analysis/target/symbol.ts +39 -11
  123. package/src/analysis/target/types.ts +6 -1
  124. package/src/extension.ts +17 -11
  125. package/src/session/graph/collect.ts +1 -10
  126. package/src/session/graph-types.ts +2 -0
  127. package/src/session/graph-workflow.ts +1 -0
  128. package/src/session/health-types.ts +7 -0
  129. package/src/session/health-workflow.ts +8 -43
  130. package/src/session/inspect/collect.ts +8 -2
  131. package/src/session/inspect/file-point.ts +2 -3
  132. package/src/session/inspect-workflow.ts +1 -1
  133. package/src/session/orientation/collect.ts +184 -20
  134. package/src/session/orientation/context-facts.ts +27 -2
  135. package/src/session/orientation/context-sections.ts +49 -3
  136. package/src/session/orientation/facts.ts +132 -0
  137. package/src/session/orientation/gather.ts +98 -11
  138. package/src/session/orientation/workspace-context.ts +16 -6
  139. package/src/session/orientation-types.ts +8 -0
  140. package/src/session/orientation-workflow.ts +20 -6
  141. package/src/session/refactor-identity.ts +76 -0
  142. package/src/session/refactor-plans.ts +5 -2
  143. package/src/session/refactor-workflow.ts +15 -17
  144. package/src/session/target-store.ts +3 -18
  145. package/src/session/target-workflow.ts +33 -16
  146. package/src/substrate/lsp/recovery.ts +5 -5
  147. package/src/tool/code_find/guidance.ts +1 -1
  148. package/src/tool/code_find/render.ts +8 -4
  149. package/src/tool/code_find/result.ts +78 -6
  150. package/src/tool/code_find/spec.ts +4 -3
  151. package/src/tool/code_find/structured.ts +25 -9
  152. package/src/tool/code_graph/details.ts +1 -0
  153. package/src/tool/code_graph/display.ts +1 -1
  154. package/src/tool/code_graph/guidance.ts +1 -1
  155. package/src/tool/code_graph/markdown.ts +11 -6
  156. package/src/tool/code_graph/read-next.ts +38 -9
  157. package/src/tool/code_graph/reference-selection.ts +30 -0
  158. package/src/tool/code_graph/result.ts +25 -118
  159. package/src/tool/code_graph/section.ts +133 -0
  160. package/src/tool/code_graph/spec.ts +3 -3
  161. package/src/tool/code_graph/structured.ts +17 -6
  162. package/src/tool/code_health/display-paths.ts +92 -0
  163. package/src/tool/code_health/file-scope-markdown.ts +3 -2
  164. package/src/tool/code_health/markdown.ts +12 -2
  165. package/src/tool/code_health/result.ts +18 -3
  166. package/src/tool/code_health/spec.ts +5 -3
  167. package/src/tool/code_health/structured-schema.ts +250 -0
  168. package/src/tool/code_health/structured.ts +256 -0
  169. package/src/tool/code_inspect/result.ts +11 -5
  170. package/src/tool/code_inspect/spec.ts +7 -1
  171. package/src/tool/code_inspect/structured.ts +231 -0
  172. package/src/tool/code_orientation/execute.ts +1 -1
  173. package/src/tool/code_orientation/result.ts +31 -8
  174. package/src/tool/code_orientation/spec.ts +2 -0
  175. package/src/tool/code_orientation/structured-schema.ts +617 -0
  176. package/src/tool/code_orientation/structured-workspace.ts +194 -0
  177. package/src/tool/code_orientation/structured.ts +189 -0
  178. package/src/tool/code_orientation/workspace-format.ts +2 -5
  179. package/src/tool/code_orientation/workspace-observations.ts +81 -0
  180. package/src/tool/code_orientation/workspace-output.ts +5 -0
  181. package/src/tool/code_orientation/workspace-projects.ts +16 -31
  182. package/src/tool/code_orientation/workspace-sections.ts +46 -32
  183. package/src/tool/code_refactor_apply/execute.ts +1 -1
  184. package/src/tool/code_refactor_apply/result.ts +14 -6
  185. package/src/tool/code_refactor_apply/spec.ts +2 -0
  186. package/src/tool/code_refactor_apply/structured.ts +49 -0
  187. package/src/tool/code_refactor_plan/result.ts +18 -9
  188. package/src/tool/code_refactor_plan/spec.ts +2 -0
  189. package/src/tool/code_refactor_plan/structured.ts +127 -0
  190. package/src/tool/code_resolve/markdown.ts +6 -30
  191. package/src/tool/code_resolve/result.ts +24 -11
  192. package/src/tool/code_resolve/structured.ts +7 -9
  193. package/src/tool/result/refactor.ts +8 -5
  194. package/src/tool/result/structured.ts +8 -5
  195. package/src/tool/result/types.ts +18 -14
  196. package/src/tool/schemas.ts +12 -6
  197. package/src/ui/status-command.ts +147 -322
  198. package/src/ui/status-overlay.ts +584 -421
  199. package/src/ui/status-presentation.ts +108 -0
@@ -0,0 +1,250 @@
1
+ import { Type } from "typebox";
2
+ import { HEALTH_DIAGNOSTIC_MESSAGE_LIMIT } from "../../session/health-types.ts";
3
+
4
+ const object = <T extends import("typebox").TProperties>(properties: T) =>
5
+ Type.Object(properties, { additionalProperties: false });
6
+ const nullableString = Type.Union([Type.String(), Type.Null()]);
7
+ const scope = Type.Union([
8
+ object({ kind: Type.Literal("file"), path: Type.String() }),
9
+ object({ kind: Type.Literal("tracked-files"), filter: nullableString }),
10
+ ]);
11
+ const evidence = object({
12
+ requested: Type.Integer(),
13
+ confirmed: Type.Integer(),
14
+ unconfirmed: Type.Integer(),
15
+ failed: Type.Integer(),
16
+ removed: Type.Integer(),
17
+ documents: Type.Array(
18
+ object({
19
+ file: Type.String(),
20
+ status: Type.Enum(["confirmed", "unconfirmed", "failed", "removed"], { type: "string" }),
21
+ }),
22
+ ),
23
+ });
24
+ const scopeStatus = object({
25
+ status: Type.Enum(["included", "excluded", "no-config", "out-of-tree"], { type: "string" }),
26
+ basis: Type.Union([
27
+ Type.Enum(
28
+ [
29
+ "fileNames",
30
+ "explicit",
31
+ "include-pattern",
32
+ "default-include",
33
+ "exclude-pattern",
34
+ "extension",
35
+ ],
36
+ { type: "string" },
37
+ ),
38
+ Type.Null(),
39
+ ]),
40
+ configPath: nullableString,
41
+ caseSensitiveFileNames: Type.Boolean(),
42
+ });
43
+ const diagnosticEntry = object({
44
+ file: Type.String(),
45
+ errors: Type.Integer(),
46
+ warnings: Type.Integer(),
47
+ messages: Type.Optional(
48
+ Type.Array(
49
+ object({
50
+ line: Type.Integer({ description: "1-based line." }),
51
+ severity: Type.Enum(["error", "warning"], { type: "string" }),
52
+ message: Type.String(),
53
+ source: Type.Optional(Type.String()),
54
+ }),
55
+ ),
56
+ ),
57
+ });
58
+ const diagnostics = Type.Union([
59
+ object({ kind: Type.Literal("not-requested"), entries: Type.Array(diagnosticEntry) }),
60
+ object({
61
+ kind: Type.Literal("completed"),
62
+ scope,
63
+ entries: Type.Array(diagnosticEntry),
64
+ evidence,
65
+ scopeStatus: Type.Optional(scopeStatus),
66
+ }),
67
+ object({
68
+ kind: Type.Enum(["partial", "unavailable"], { type: "string" }),
69
+ scope,
70
+ entries: Type.Array(diagnosticEntry),
71
+ evidence,
72
+ reason: Type.String(),
73
+ scopeStatus: Type.Optional(scopeStatus),
74
+ }),
75
+ ]);
76
+ const operation = object({
77
+ server: Type.Enum(["advertised", "not-advertised", "unknown"], { type: "string" }),
78
+ supi: Type.Enum(["supported", "limited", "unsupported"], { type: "string" }),
79
+ reason: Type.Optional(Type.String()),
80
+ });
81
+ const support = object({
82
+ rename_symbol: Type.Optional(operation),
83
+ prepare_rename: Type.Optional(operation),
84
+ extract_function: Type.Optional(operation),
85
+ extract_variable: Type.Optional(operation),
86
+ update_imports: Type.Optional(operation),
87
+ delete_dead_code: Type.Optional(operation),
88
+ code_action_resolve: Type.Optional(operation),
89
+ });
90
+ const server = object({
91
+ name: Type.String(),
92
+ root: Type.String(),
93
+ fileTypes: Type.Array(Type.String()),
94
+ status: Type.Enum(["running", "error", "unavailable"], { type: "string" }),
95
+ statusReason: Type.Optional(
96
+ Type.Enum(
97
+ ["process-crashed", "process-crash-recovery-pending", "process-crash-recovery-exhausted"],
98
+ { type: "string" },
99
+ ),
100
+ ),
101
+ ready: Type.Boolean(),
102
+ operationSupport: Type.Optional(support),
103
+ typescript: Type.Optional(
104
+ object({
105
+ backend: Type.Union([Type.Literal("tsserver"), Type.Literal("native")]),
106
+ packageName: Type.String(),
107
+ compilerVersion: Type.Optional(Type.String()),
108
+ wrapperVersion: Type.Optional(Type.String()),
109
+ }),
110
+ ),
111
+ failureMessage: Type.Optional(Type.String()),
112
+ });
113
+ const stale = object({
114
+ scope: Type.Enum(["file", "workspace"], { type: "string" }),
115
+ suspected: Type.Union([Type.Boolean(), Type.Null()]),
116
+ matchedFileCount: Type.Integer(),
117
+ warning: nullableString,
118
+ });
119
+ const recoveryEntry = object({
120
+ name: Type.String(),
121
+ root: Type.String(),
122
+ outcome: Type.Enum(
123
+ ["recovered", "skipped-no-retained-file", "recovery-failed", "recovery-exhausted"],
124
+ { type: "string" },
125
+ ),
126
+ nextAction: Type.Optional(Type.Enum(["use-exact-file", "refresh"], { type: "string" })),
127
+ failureMessage: Type.Optional(Type.String()),
128
+ });
129
+ const crashRecovery = object({
130
+ recoveredRoutes: Type.Integer(),
131
+ skippedRoutes: Type.Integer(),
132
+ failedRoutes: Type.Integer(),
133
+ exhaustedRoutes: Type.Integer(),
134
+ entries: Type.Array(recoveryEntry),
135
+ omittedEntries: Type.Integer(),
136
+ });
137
+ const startupRetry = object({
138
+ recoveredRoutes: Type.Integer(),
139
+ failedRoutes: Type.Integer(),
140
+ entries: Type.Array(
141
+ object({
142
+ name: Type.String(),
143
+ root: Type.String(),
144
+ outcome: Type.Enum(["recovered", "retry-failed"], { type: "string" }),
145
+ nextAction: Type.Optional(Type.Literal("refresh")),
146
+ failureMessage: Type.Optional(Type.String()),
147
+ }),
148
+ ),
149
+ omittedEntries: Type.Integer(),
150
+ });
151
+ const tracking = object({
152
+ status: Type.Enum(["complete", "limited"], { type: "string" }),
153
+ reason: Type.Union([
154
+ Type.Enum(["file-limit", "filesystem-error"], { type: "string" }),
155
+ Type.Null(),
156
+ ]),
157
+ observedFileCount: Type.Integer(),
158
+ discovered: Type.Array(Type.String()),
159
+ tracked: Type.Array(Type.String()),
160
+ skipped: Type.Array(Type.String()),
161
+ unavailable: Type.Array(Type.String()),
162
+ deferred: Type.Integer(),
163
+ });
164
+ const attemptFields = {
165
+ attemptedAt: Type.Number(),
166
+ elapsedMs: Type.Number(),
167
+ requestedDiagnosticScope: scope,
168
+ operationScope: Type.Enum(["file-runtime", "workspace-runtime"], { type: "string" }),
169
+ attemptedActiveClients: Type.Optional(Type.Integer()),
170
+ restartedClients: Type.Optional(Type.Integer()),
171
+ fileReadiness: Type.Optional(Type.Enum(["ready", "pending", "unavailable"], { type: "string" })),
172
+ staleAssessment: Type.Optional(stale),
173
+ diagnosticEvidence: Type.Optional(evidence),
174
+ processCrashRecovery: Type.Optional(crashRecovery),
175
+ startupRetry: Type.Optional(startupRetry),
176
+ sourceTracking: Type.Optional(tracking),
177
+ };
178
+ const completedAttemptFields = {
179
+ ...attemptFields,
180
+ attemptedActiveClients: Type.Integer(),
181
+ restartedClients: Type.Integer(),
182
+ staleAssessment: stale,
183
+ processCrashRecovery: crashRecovery,
184
+ };
185
+ const attempt = Type.Union([
186
+ object({
187
+ kind: Type.Literal("completed"),
188
+ ...completedAttemptFields,
189
+ operationScope: Type.Literal("workspace-runtime"),
190
+ diagnosticEvidence: evidence,
191
+ }),
192
+ object({
193
+ kind: Type.Literal("completed"),
194
+ ...completedAttemptFields,
195
+ operationScope: Type.Literal("file-runtime"),
196
+ }),
197
+ object({ kind: Type.Literal("failed"), ...attemptFields, reason: Type.String() }),
198
+ ]);
199
+ const refresh = Type.Union([
200
+ attempt,
201
+ object({
202
+ kind: Type.Enum(["not-requested", "not-attempted"], { type: "string" }),
203
+ reason: Type.String(),
204
+ lastAttempt: Type.Union([attempt, Type.Null()]),
205
+ }),
206
+ ]);
207
+ const warningReport = object({
208
+ hasWarnings: Type.Boolean(),
209
+ warnings: Type.Array(
210
+ object({
211
+ type: Type.Enum(
212
+ ["language-disabled", "missing-server", "structural-unavailable", "configuration-error"],
213
+ { type: "string" },
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: Type.Enum(["summary", "detailed"], { type: "string" }),
228
+ includedSections: Type.Array(Type.Enum(["diagnostics", "servers"], { type: "string" })),
229
+ semanticState: Type.Union([
230
+ object({ kind: Type.Literal("ready") }),
231
+ object({
232
+ kind: Type.Enum(["pending", "inactive", "disabled", "unavailable"], { type: "string" }),
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
+ }
@@ -328,6 +328,7 @@ function overallProvenance(data: InspectResultData): ResultProvenance[] {
328
328
  import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
329
329
  import { inspectErrorResult } from "../result/errors.ts";
330
330
  import { renderInspectResult } from "./markdown.ts";
331
+ import { structuredInspectResult } from "./structured.ts";
331
332
 
332
333
  type InspectOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["inspect"]>>;
333
334
 
@@ -335,16 +336,21 @@ type InspectOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["inspec
335
336
  export function finishInspectResult(outcome: InspectOutcome): CodeIntelResult {
336
337
  if (outcome.kind === "unavailable") throw new Error(outcome.reason);
337
338
  if (outcome.kind === "invalid-input") {
338
- return inspectErrorResult(`**Error:** ${outcome.message}`, {
339
- focusTarget: "invalid input",
340
- nextQueries: ["Provide an existing file and exact 1-based point"],
341
- message: outcome.message,
342
- });
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
+ };
343
348
  }
344
349
 
345
350
  const assembly = assembleInspectResult(outcome.data, outcome.nextQueries);
346
351
  return {
347
352
  content: renderInspectResult(assembly),
353
+ structuredContent: structuredInspectResult(assembly),
348
354
  details: {
349
355
  type: "inspect",
350
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,10 +12,15 @@ 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,
17
- maxResults: Type.Optional(MaxResultsParam),
19
+ maxResults: Type.Optional({
20
+ ...MaxResultsParam,
21
+ description:
22
+ "Maximum entries per definition or diagnostic list; does not limit syntax or hover text.",
23
+ }),
18
24
  },
19
25
  { additionalProperties: false },
20
26
  ),