@mrclrchtr/supi-code-intelligence 12.0.0 → 13.0.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 (268) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +4 -2
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  5. package/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  6. package/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  7. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
  8. package/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  9. package/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
  10. package/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -8
  22. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +1 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +102 -47
  24. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +8 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +15 -1
  26. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +1 -1
  27. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +46 -4
  28. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-disk-stamp.ts +60 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +3 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +21 -1
  31. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +17 -3
  32. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +53 -4
  33. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +11 -3
  34. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +2 -1
  35. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +2 -2
  36. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +14 -5
  37. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-module.ts +17 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +2 -17
  40. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-removal-ledger.ts +52 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +40 -20
  42. package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +6 -1
  43. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +6 -1
  44. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +13 -3
  45. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +11 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +1 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +17 -2
  48. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +11 -1
  49. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +2 -0
  50. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  51. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  52. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  53. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
  54. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +22 -3
  55. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
  56. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +1 -0
  57. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
  58. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
  59. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +50 -75
  60. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +2 -2
  61. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +50 -75
  62. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +2 -2
  63. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  64. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +6 -6
  65. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
  66. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +50 -75
  67. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +2 -2
  68. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +7 -7
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +1 -1
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +7 -7
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +1 -1
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +50 -75
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +2 -2
  74. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  75. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +5 -5
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -5
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm.json +1 -1
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +1 -1
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +1 -1
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +1 -1
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +1 -1
  83. package/node_modules/fast-xml-parser/CHANGELOG.md +886 -0
  84. package/node_modules/fast-xml-parser/LICENSE +21 -0
  85. package/node_modules/fast-xml-parser/README.md +204 -0
  86. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
  87. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
  88. package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
  89. package/node_modules/fast-xml-parser/lib/fxp.d.cts +774 -0
  90. package/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
  91. package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
  92. package/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
  93. package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
  94. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +2 -0
  95. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
  96. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/README.md +92 -0
  97. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/package.json +57 -0
  98. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityDecoder.js +644 -0
  99. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityEncoder.js +239 -0
  100. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/all-entities.js +53 -0
  101. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entities.js +1139 -0
  102. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entityTries.js +60 -0
  103. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.d.ts +358 -0
  104. package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.js +29 -0
  105. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/CHANGELOG.md +52 -0
  106. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/LICENSE +21 -0
  107. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/README.md +77 -0
  108. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
  109. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.d.cts +270 -0
  110. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
  111. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
  112. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/package.json +77 -0
  113. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.d.ts +270 -0
  114. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.js +609 -0
  115. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/ignoreAttributes.js +18 -0
  116. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/orderedJs2Xml.js +360 -0
  117. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
  118. package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/util.js +23 -0
  119. package/node_modules/fast-xml-parser/node_modules/is-unsafe/LICENSE +21 -0
  120. package/node_modules/fast-xml-parser/node_modules/is-unsafe/README.md +632 -0
  121. package/node_modules/fast-xml-parser/node_modules/is-unsafe/package.json +56 -0
  122. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/html.js +102 -0
  123. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/log.js +98 -0
  124. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/nosql.js +114 -0
  125. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/redos.js +60 -0
  126. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/shell.js +105 -0
  127. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql-strict.js +47 -0
  128. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql.js +95 -0
  129. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/svg.js +81 -0
  130. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/xml.js +79 -0
  131. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.cjs +27 -0
  132. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.d.ts +103 -0
  133. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.js +292 -0
  134. package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/util/decode-entities.js +48 -0
  135. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/LICENSE +21 -0
  136. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/README.md +947 -0
  137. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
  138. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.d.cts +725 -0
  139. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
  140. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
  141. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/package.json +79 -0
  142. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Expression.js +232 -0
  143. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/ExpressionSet.js +225 -0
  144. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Matcher.js +663 -0
  145. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.d.ts +589 -0
  146. package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.js +30 -0
  147. package/node_modules/fast-xml-parser/node_modules/strnum/CHANGELOG.md +63 -0
  148. package/node_modules/fast-xml-parser/node_modules/strnum/LICENSE +21 -0
  149. package/node_modules/fast-xml-parser/node_modules/strnum/README.md +113 -0
  150. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/LICENSE +21 -0
  151. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/README.md +142 -0
  152. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/anynum.js +135 -0
  153. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/digitTable.js +116 -0
  154. package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/package.json +42 -0
  155. package/node_modules/fast-xml-parser/node_modules/strnum/package.json +36 -0
  156. package/node_modules/fast-xml-parser/node_modules/strnum/strnum.js +176 -0
  157. package/node_modules/fast-xml-parser/node_modules/xml-naming/LICENSE +21 -0
  158. package/node_modules/fast-xml-parser/node_modules/xml-naming/README.md +287 -0
  159. package/node_modules/fast-xml-parser/node_modules/xml-naming/package.json +56 -0
  160. package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.d.ts +108 -0
  161. package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.js +382 -0
  162. package/node_modules/fast-xml-parser/package.json +93 -0
  163. package/node_modules/fast-xml-parser/src/cli/cli.js +97 -0
  164. package/node_modules/fast-xml-parser/src/cli/man.js +17 -0
  165. package/node_modules/fast-xml-parser/src/cli/read.js +43 -0
  166. package/node_modules/fast-xml-parser/src/fxp.d.ts +754 -0
  167. package/node_modules/fast-xml-parser/src/fxp.js +14 -0
  168. package/node_modules/fast-xml-parser/src/ignoreAttributes.js +18 -0
  169. package/node_modules/fast-xml-parser/src/util.js +61 -0
  170. package/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +16 -0
  171. package/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +106 -0
  172. package/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +61 -0
  173. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +69 -0
  174. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +103 -0
  175. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +100 -0
  176. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +154 -0
  177. package/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +94 -0
  178. package/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
  179. package/node_modules/fast-xml-parser/src/v6/TagPath.js +81 -0
  180. package/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +13 -0
  181. package/node_modules/fast-xml-parser/src/v6/XMLParser.js +83 -0
  182. package/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +235 -0
  183. package/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +210 -0
  184. package/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +111 -0
  185. package/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +116 -0
  186. package/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +121 -0
  187. package/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +105 -0
  188. package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +22 -0
  189. package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +19 -0
  190. package/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +38 -0
  191. package/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +13 -0
  192. package/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +14 -0
  193. package/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +6 -0
  194. package/node_modules/fast-xml-parser/src/validator.js +518 -0
  195. package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +6 -0
  196. package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +426 -0
  197. package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +164 -0
  198. package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +907 -0
  199. package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +77 -0
  200. package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +177 -0
  201. package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +54 -0
  202. package/package.json +10 -8
  203. package/src/analysis/evidence.ts +331 -73
  204. package/src/analysis/health/diagnostics.ts +66 -18
  205. package/src/analysis/health/evidence-reason.ts +44 -0
  206. package/src/analysis/search/pattern.ts +3 -3
  207. package/src/analysis/target/anchored.ts +3 -6
  208. package/src/analysis/target/symbol.ts +41 -47
  209. package/src/analysis/target/types.ts +4 -9
  210. package/src/analysis/workspace/cmake-parser.ts +207 -0
  211. package/src/analysis/workspace/cmake.ts +141 -0
  212. package/src/analysis/workspace/maven.ts +310 -0
  213. package/src/analysis/workspace/membership.ts +100 -26
  214. package/src/analysis/workspace/metadata.ts +6 -1
  215. package/src/analysis/workspace/observe.ts +6 -0
  216. package/src/analysis/workspace/types.ts +11 -3
  217. package/src/diagnostics/coverage.ts +49 -0
  218. package/src/diagnostics/evidence.ts +10 -2
  219. package/src/session/health-workflow.ts +6 -0
  220. package/src/session/input/common.ts +1 -1
  221. package/src/session/orientation/collect.ts +42 -7
  222. package/src/session/orientation/context-facts.ts +3 -3
  223. package/src/session/orientation/context-sections.ts +13 -15
  224. package/src/session/orientation/facts.ts +5 -8
  225. package/src/session/orientation-workflow.ts +4 -19
  226. package/src/session/target-workflow.ts +25 -18
  227. package/src/tool/code_find/result.ts +5 -7
  228. package/src/tool/code_graph/display.ts +5 -6
  229. package/src/tool/code_graph/format.ts +8 -24
  230. package/src/tool/code_graph/result.ts +16 -75
  231. package/src/tool/code_graph/section.ts +21 -33
  232. package/src/tool/code_graph/tui.ts +10 -5
  233. package/src/tool/code_health/diagnostic-tui.ts +49 -0
  234. package/src/tool/code_health/guidance.ts +27 -0
  235. package/src/tool/code_health/markdown.ts +60 -8
  236. package/src/tool/code_health/result.ts +20 -9
  237. package/src/tool/code_health/structured-schema.ts +14 -0
  238. package/src/tool/code_health/structured.ts +7 -1
  239. package/src/tool/code_health/tui.ts +33 -40
  240. package/src/tool/code_inspect/result.ts +23 -18
  241. package/src/tool/code_inspect/structured.ts +2 -19
  242. package/src/tool/code_orientation/result.ts +53 -100
  243. package/src/tool/code_orientation/structured-schema.ts +16 -12
  244. package/src/tool/code_orientation/structured-workspace.ts +13 -7
  245. package/src/tool/code_orientation/structured.ts +31 -39
  246. package/src/tool/code_orientation/workspace-format.ts +4 -10
  247. package/src/tool/code_orientation/workspace-instructions.ts +4 -5
  248. package/src/tool/code_orientation/workspace-observations.ts +2 -2
  249. package/src/tool/code_orientation/workspace-output.ts +16 -7
  250. package/src/tool/code_orientation/workspace-projects.ts +7 -10
  251. package/src/tool/code_orientation/workspace-sections.ts +13 -19
  252. package/src/tool/code_resolve/markdown.ts +4 -46
  253. package/src/tool/code_resolve/result.ts +43 -72
  254. package/src/tool/infra/truncate.ts +2 -16
  255. package/src/tool/result/candidate-selection.ts +141 -0
  256. package/src/tool/result/display.ts +41 -45
  257. package/src/tool/result/errors.ts +1 -0
  258. package/src/tool/result/model-budget.ts +26 -1
  259. package/src/tool/result/refactor.ts +11 -8
  260. package/src/tool/result/structured.ts +2 -1
  261. package/src/tool/result/types.ts +9 -8
  262. package/src/tool/schemas.ts +15 -20
  263. package/src/ui/footer.ts +2 -4
  264. package/src/ui/status-presentation.ts +4 -7
  265. package/src/ui/tui/candidate-selection.ts +40 -95
  266. package/src/ui/tui/common.ts +16 -70
  267. package/src/ui/tui/display.ts +6 -24
  268. package/src/tool/result/candidate-row.ts +0 -49
@@ -196,7 +196,7 @@ export class DiagnosticRequestScheduler {
196
196
  return;
197
197
  }
198
198
  execution.result.then(job.resolve, job.reject).catch(() => {});
199
- execution.settled
199
+ void execution.settled
200
200
  .catch(() => {})
201
201
  .then(() => {
202
202
  if (this.#active !== job) return;
@@ -38,6 +38,7 @@ import {
38
38
  } from "./client-diagnostic-request.ts";
39
39
  import { DiagnosticObserver } from "./client-diagnostic-timing.ts";
40
40
  import { DiagnosticWaitRegistry } from "./client-diagnostic-waiters.ts";
41
+ import { type DiskStamp, statDiskStampSync } from "./client-disk-stamp.ts";
41
42
  import {
42
43
  type ClientDiagnosticSnapshot,
43
44
  type DiagnosticEntry,
@@ -136,18 +137,36 @@ export class ClientDiagnostics {
136
137
  return this.#inputAdmission.request(run, control, uri);
137
138
  }
138
139
 
139
- /** Read content only after admission; tracked-document changes never wait. */
140
- async openDocument(
140
+ /**
141
+ * Read content only after admission; tracked-document changes never wait.
142
+ *
143
+ * `readContent` reads the file from disk. The disk stamp taken directly
144
+ * before that read is recorded when the document then holds that content.
145
+ */
146
+ openDocument(
141
147
  filePath: string,
142
148
  readContent: () => string,
143
149
  control?: CodeRequestControl,
144
150
  protectInputs = false,
151
+ ): Promise<void> {
152
+ return this.#openDocument(filePath, readContent, control, { protectInputs, readsDisk: true });
153
+ }
154
+
155
+ async #openDocument(
156
+ filePath: string,
157
+ readContent: () => string,
158
+ control: CodeRequestControl | undefined,
159
+ { protectInputs, readsDisk }: { readonly protectInputs: boolean; readonly readsDisk: boolean },
145
160
  ): Promise<void> {
146
161
  throwIfCodeRequestInterrupted(control);
147
162
  const open = () => {
148
163
  throwIfCodeRequestInterrupted(control);
149
164
  if (!this.host.isOperational()) throw new Error("LSP client is not running.");
150
- this.didOpen(filePath, readContent());
165
+ // Stat inside the admitted closure, directly before the read.
166
+ const stamp = readsDisk ? statDiskStampSync(filePath) : undefined;
167
+ const content = readContent();
168
+ this.didOpen(filePath, content);
169
+ this.#recordDiskStampIfCurrent(fileToUri(filePath), content, stamp);
151
170
  };
152
171
  if (this.#openDocs.has(fileToUri(filePath))) {
153
172
  open();
@@ -274,6 +293,13 @@ export class ClientDiagnostics {
274
293
  this.#inputBarrier.forgetDocumentContent(uri);
275
294
  }
276
295
 
296
+ /** Record a pre-read stamp when the open document now holds exactly that read. */
297
+ #recordDiskStampIfCurrent(uri: string, content: string, stamp: DiskStamp | undefined): void {
298
+ if (!stamp) return;
299
+ if (this.#openDocs.get(uri)?.contentFingerprint !== fingerprintDocumentContent(content)) return;
300
+ this.#inputBarrier.recordDiskStamp(uri, stamp);
301
+ }
302
+
277
303
  async #ensureExplicitDocumentContent(
278
304
  filePath: string,
279
305
  content: string,
@@ -285,10 +311,12 @@ export class ClientDiagnostics {
285
311
  if (!document) {
286
312
  // A manager read can predate admission. Re-read disk after the wait;
287
313
  // explicit authoritative content retains its existing override semantics.
288
- await this.openDocument(
314
+ await this.#openDocument(
289
315
  filePath,
290
316
  () => (contentIsAuthoritative ? content : readFileSync(filePath, "utf-8")),
291
317
  control,
318
+ // Authoritative content is not a disk read and must not record a stamp.
319
+ { protectInputs: false, readsDisk: !contentIsAuthoritative },
292
320
  );
293
321
  return;
294
322
  }
@@ -434,6 +462,7 @@ export class ClientDiagnostics {
434
462
  if (!document) return;
435
463
 
436
464
  let content: string;
465
+ const stamp = statDiskStampSync(filePath);
437
466
  try {
438
467
  content = readFileSync(filePath, "utf-8");
439
468
  } catch {
@@ -443,6 +472,7 @@ export class ClientDiagnostics {
443
472
  if (document.contentFingerprint !== fingerprintDocumentContent(content)) {
444
473
  this.didChange(filePath, content);
445
474
  }
475
+ this.#recordDiskStampIfCurrent(uri, content, stamp);
446
476
  if (diskChanged) this.#noteExternalDiskChange(filePath, content);
447
477
  }
448
478
 
@@ -466,6 +496,10 @@ export class ClientDiagnostics {
466
496
  if (wasOpen && this.host.isOperational()) {
467
497
  sendDidCloseNotification(this.host, uri);
468
498
  }
499
+ // An intentional close of an existing file is not a removal.
500
+ if (hadState && getDiagnosticFileState(filePath) === "removed") {
501
+ this.host.onTrackedFileRemoved?.(filePath);
502
+ }
469
503
  }
470
504
 
471
505
  pruneMissingFiles(): string[] {
@@ -490,6 +524,7 @@ export class ClientDiagnostics {
490
524
  clearTrackedDocumentState(this.#openDocs, this.#diagnosticStore, this.#waiters, uri);
491
525
  removedFiles.push(filePath);
492
526
  if (wasOpen && this.host.isOperational()) sendDidCloseNotification(this.host, uri);
527
+ this.host.onTrackedFileRemoved?.(filePath);
493
528
  }
494
529
 
495
530
  return removedFiles;
@@ -506,6 +541,9 @@ export class ClientDiagnostics {
506
541
  getOpenDocumentVersion(filePath: string): number | null {
507
542
  return this.#openDocs.get(fileToUri(filePath))?.version ?? null;
508
543
  }
544
+ getOpenDocumentContent(filePath: string): string | null {
545
+ return this.#openDocs.get(fileToUri(filePath))?.content ?? null;
546
+ }
509
547
  getDiagnostics(filePath: string): Diagnostic[] {
510
548
  return this.#diagnosticStore.get(fileToUri(filePath))?.diagnostics ?? [];
511
549
  }
@@ -515,6 +553,7 @@ export class ClientDiagnostics {
515
553
  openDocuments: this.#openDocs,
516
554
  failedDocuments: this.#failedUris,
517
555
  evidenceRevision: this.#evidenceRevision,
556
+ observedDiskStamp: (uri) => this.#inputBarrier.getObservedDiskStamp(uri),
518
557
  });
519
558
  }
520
559
  getAllDiagnostics(): DiagnosticEntry[] {
@@ -642,6 +681,7 @@ export class ClientDiagnostics {
642
681
  nextSynchronizationId: () => ++this.#nextSynchronizationId,
643
682
  noteInputContentChange: () => this.#noteInputContentChange(),
644
683
  observeDiskContent: (uri, content) => this.#inputBarrier.observeDiskContent(uri, content),
684
+ recordDiskStamp: (uri, content, stamp) => this.#recordDiskStampIfCurrent(uri, content, stamp),
645
685
  noteExternalDiskChange: (uri, content) =>
646
686
  this.#noteExternalDiskChange(uriToFile(uri), content),
647
687
  invalidateEvidence: (uri) => {
@@ -663,6 +703,8 @@ export class ClientDiagnostics {
663
703
  this.#unversionedPushSyncMoments.delete(uri);
664
704
  this.#closedVersionedBarrier.add(uri);
665
705
  clearTrackedDocumentState(this.#openDocs, this.#diagnosticStore, this.#waiters, uri);
706
+ // Resynchronization clears only documents whose files were removed.
707
+ this.host.onTrackedFileRemoved?.(uriToFile(uri));
666
708
  },
667
709
  markUnversionedSyncMoment: (uri) => {
668
710
  this.#cancelDiagnosticRequest(uri);
@@ -0,0 +1,60 @@
1
+ import { statSync } from "node:fs";
2
+
3
+ /**
4
+ * File metadata that identifies one observed on-disk state of a document.
5
+ *
6
+ * A stamp can only withdraw diagnostic confirmation: a different stamp means
7
+ * the file may have changed since its content was last read. Only a content
8
+ * read restores confirmation. `ctimeNs` catches tools that restore mtime
9
+ * (`cp -p`, `rsync -t`, `touch -r`, tar); `ino` catches atomic replace.
10
+ * A same-size rewrite within one timestamp tick is not detected.
11
+ */
12
+ export interface DiskStamp {
13
+ readonly dev: bigint;
14
+ readonly ino: bigint;
15
+ readonly size: bigint;
16
+ readonly mtimeNs: bigint;
17
+ readonly ctimeNs: bigint;
18
+ }
19
+
20
+ interface BigIntStatLike {
21
+ readonly dev: bigint;
22
+ readonly ino: bigint;
23
+ readonly size: bigint;
24
+ readonly mtimeNs: bigint;
25
+ readonly ctimeNs: bigint;
26
+ }
27
+
28
+ /** Convert a bigint stat result into a stamp. */
29
+ export function toDiskStamp(stats: BigIntStatLike): DiskStamp {
30
+ return {
31
+ dev: stats.dev,
32
+ ino: stats.ino,
33
+ size: stats.size,
34
+ mtimeNs: stats.mtimeNs,
35
+ ctimeNs: stats.ctimeNs,
36
+ };
37
+ }
38
+
39
+ /**
40
+ * Stat one file before its content is read. Returns undefined on any failure;
41
+ * the following read decides whether the file is missing or unreadable.
42
+ */
43
+ export function statDiskStampSync(filePath: string): DiskStamp | undefined {
44
+ try {
45
+ return toDiskStamp(statSync(filePath, { bigint: true }));
46
+ } catch {
47
+ return undefined;
48
+ }
49
+ }
50
+
51
+ /** Compare two stamps field by field. */
52
+ export function sameDiskStamp(a: DiskStamp, b: DiskStamp): boolean {
53
+ return (
54
+ a.dev === b.dev &&
55
+ a.ino === b.ino &&
56
+ a.size === b.size &&
57
+ a.mtimeNs === b.mtimeNs &&
58
+ a.ctimeNs === b.ctimeNs
59
+ );
60
+ }
@@ -1,5 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import type { Diagnostic } from "../config/types.ts";
3
+ import type { DiagnosticEvidenceReason } from "../diagnostics/evidence.ts";
3
4
  import { type DiagnosticCacheEntry, isTentativePushEntry } from "./client-diagnostic-evidence.ts";
4
5
 
5
6
  /** One file's stored diagnostics as consumed by manager-level collection. */
@@ -14,6 +15,8 @@ export interface ClientDiagnosticDocument {
14
15
  uri: string;
15
16
  current: boolean;
16
17
  status: "confirmed" | "unconfirmed" | "failed" | "removed";
18
+ /** Why an otherwise current document is unconfirmed. */
19
+ reason?: DiagnosticEvidenceReason;
17
20
  }
18
21
 
19
22
  /** One client's diagnostic snapshot, including empty cache freshness. */
@@ -5,6 +5,7 @@ import {
5
5
  } from "vscode-languageserver-protocol";
6
6
  import type { DiagnosticSynchronization } from "./client-diagnostic-evidence.ts";
7
7
  import type { DiagnosticWaitRegistry } from "./client-diagnostic-waiters.ts";
8
+ import { type DiskStamp, statDiskStampSync } from "./client-disk-stamp.ts";
8
9
  import { fingerprintDocumentContent, type OpenDocumentState } from "./client-document-state.ts";
9
10
  import { getDiagnosticFileState } from "./client-file-state.ts";
10
11
 
@@ -194,12 +195,16 @@ interface ResynchronizeDocumentsOptions {
194
195
  noteInputContentChange(): number;
195
196
  /** Record the verified disk content and report whether its baseline changed. */
196
197
  observeDiskContent(uri: string, content: string): boolean;
198
+ /** Record a pre-read disk stamp when the document now equals that read. */
199
+ recordDiskStamp(uri: string, content: string, stamp: DiskStamp | undefined): void;
197
200
  /** Send one save for an externally observed disk change. */
198
201
  noteExternalDiskChange(uri: string, content: string): void;
199
202
  sendNotification: NotificationSender;
200
203
  uriToFile(uri: string): string;
201
204
  /** Disk content already read by classification; avoids a second read. */
202
205
  preloadedContent?: ReadonlyMap<string, string>;
206
+ /** Stamps taken before the preloaded reads. */
207
+ preloadedStamps?: ReadonlyMap<string, DiskStamp>;
203
208
  clearFile(uri: string): void;
204
209
  invalidateEvidence(uri: string): void;
205
210
  markUnversionedSyncMoment(uri: string): void;
@@ -229,6 +234,20 @@ function noteObservedDiskChange(
229
234
  }
230
235
  }
231
236
 
237
+ /** Read one document, or reuse its preloaded read; the stamp precedes the read. */
238
+ function readDocumentForResynchronization(
239
+ options: Pick<ResynchronizeDocumentsOptions, "preloadedContent" | "preloadedStamps">,
240
+ uri: string,
241
+ filePath: string,
242
+ ): { content: string; stamp: DiskStamp | undefined } {
243
+ const preloaded = options.preloadedContent?.get(uri);
244
+ if (preloaded !== undefined) {
245
+ return { content: preloaded, stamp: options.preloadedStamps?.get(uri) };
246
+ }
247
+ const stamp = statDiskStampSync(filePath);
248
+ return { content: readFileSync(filePath, "utf-8"), stamp };
249
+ }
250
+
232
251
  /** Re-read and synchronize every existing open document. */
233
252
  export function resynchronizeOpenDocuments(
234
253
  options: ResynchronizeDocumentsOptions,
@@ -243,7 +262,7 @@ export function resynchronizeOpenDocuments(
243
262
  const filePath = options.uriToFile(uri);
244
263
  try {
245
264
  options.markUnversionedSyncMoment(uri);
246
- const content = options.preloadedContent?.get(uri) ?? readFileSync(filePath, "utf-8");
265
+ const { content, stamp } = readDocumentForResynchronization(options, uri, filePath);
247
266
  const contentChanged = fingerprintDocumentContent(content) !== document.contentFingerprint;
248
267
  if (contentChanged) {
249
268
  if (!inputChangeNoted) {
@@ -273,6 +292,7 @@ export function resynchronizeOpenDocuments(
273
292
  });
274
293
  }
275
294
  noteObservedDiskChange(options, uri, content);
295
+ options.recordDiskStamp(uri, content, stamp);
276
296
  options.clearFailedFile(uri);
277
297
  synchronizedUris.add(uri);
278
298
  if (contentChanged) resynchronizedUris.add(uri);
@@ -1,16 +1,30 @@
1
1
  import { accessSync, constants, statSync } from "node:fs";
2
+ import { type DiskStamp, toDiskStamp } from "./client-disk-stamp.ts";
2
3
 
3
4
  /** State used to distinguish deleted files from files that cannot be read. */
4
5
  export type DiagnosticFileState = "present" | "removed" | "unreadable";
5
6
 
7
+ /** File-system state plus the disk stamp of a present file. */
8
+ export interface DiagnosticFileStatus {
9
+ readonly state: DiagnosticFileState;
10
+ /** Set only for a present file. */
11
+ readonly stamp?: DiskStamp;
12
+ }
13
+
6
14
  /** Read the file-system state without treating access errors as deletion. */
7
15
  export function getDiagnosticFileState(filePath: string): DiagnosticFileState {
16
+ return getDiagnosticFileStatus(filePath).state;
17
+ }
18
+
19
+ /** Read the file-system state and, for a present file, its disk stamp. */
20
+ export function getDiagnosticFileStatus(filePath: string): DiagnosticFileStatus {
8
21
  try {
9
- if (!statSync(filePath).isFile()) return "unreadable";
22
+ const stats = statSync(filePath, { bigint: true });
23
+ if (!stats.isFile()) return { state: "unreadable" };
10
24
  accessSync(filePath, constants.R_OK);
11
- return "present";
25
+ return { state: "present", stamp: toDiskStamp(stats) };
12
26
  } catch (error) {
13
- return isMissingFileError(error) ? "removed" : "unreadable";
27
+ return { state: isMissingFileError(error) ? "removed" : "unreadable" };
14
28
  }
15
29
  }
16
30
 
@@ -4,6 +4,7 @@ import {
4
4
  throwIfCodeRequestInterrupted,
5
5
  } from "@mrclrchtr/supi-code-runtime/api";
6
6
  import { raceRequestControl } from "../session/readiness.ts";
7
+ import { type DiskStamp, statDiskStampSync } from "./client-disk-stamp.ts";
7
8
  import { fingerprintDocumentContent } from "./client-document-state.ts";
8
9
  import {
9
10
  type SemanticInputChangeKind,
@@ -51,10 +52,16 @@ export interface SemanticInputBarrierHost {
51
52
  markUnreadableDocument(filePath: string): void;
52
53
  }
53
54
 
54
- /** Optional read bound and test seam for one input barrier. */
55
+ /** Optional read bound and test seams for one input barrier. */
55
56
  export interface SemanticInputBarrierOptions {
56
57
  readonly maxConcurrentReads?: number;
57
58
  readonly readFile?: SemanticInputFileReader;
59
+ /**
60
+ * Synchronous stat taken directly before each read. A failure returns
61
+ * undefined and keeps the previous stamp. Synchronous so the stat adds no
62
+ * I/O turn to the shared read pass.
63
+ */
64
+ readonly statFile?: (filePath: string) => DiskStamp | undefined;
58
65
  }
59
66
 
60
67
  /** Revision token used to check one semantic input generation. */
@@ -70,7 +77,7 @@ export interface SemanticInputSnapshot extends SemanticInputRevision {
70
77
  interface OpenDocumentRead {
71
78
  readonly document: SemanticInputDocument;
72
79
  readonly result:
73
- | { readonly kind: "content"; readonly content: string }
80
+ | { readonly kind: "content"; readonly content: string; readonly stamp?: DiskStamp }
74
81
  | { readonly kind: "error"; readonly error: unknown };
75
82
  }
76
83
 
@@ -78,6 +85,8 @@ interface SynchronizationPlan {
78
85
  readonly updates: SemanticInputUpdate[];
79
86
  readonly externalDiskChanges: Array<{ readonly filePath: string; readonly content: string }>;
80
87
  readonly observedDiskFingerprints: Map<string, string | undefined>;
88
+ /** Stamps whose read matched the resulting document content. */
89
+ readonly observedDiskStamps: Map<string, DiskStamp>;
81
90
  }
82
91
 
83
92
  interface PendingSynchronization {
@@ -102,8 +111,14 @@ export class SemanticInputBarrier {
102
111
  readonly #host: SemanticInputBarrierHost;
103
112
  readonly #maxConcurrentReads: number;
104
113
  readonly #readFile: SemanticInputFileReader;
114
+ readonly #statFile: (filePath: string) => DiskStamp | undefined;
105
115
  /** Last verified disk fingerprint for each URI; undefined means observed missing. */
106
116
  readonly #observedDiskFingerprints = new Map<string, string | undefined>();
117
+ /**
118
+ * Disk stamp of the last read whose content equaled the document content.
119
+ * Passive snapshots compare it with a fresh stat; only a content read writes it.
120
+ */
121
+ readonly #observedDiskStamps = new Map<string, DiskStamp>();
107
122
  #revision = 0;
108
123
  /** Latest non-enrollment change, used to classify stale snapshots. */
109
124
  #lastNonEnrollmentChange:
@@ -118,6 +133,7 @@ export class SemanticInputBarrier {
118
133
  Math.floor(options.maxConcurrentReads ?? DEFAULT_MAX_CONCURRENT_READS),
119
134
  );
120
135
  this.#readFile = options.readFile ?? defaultSemanticInputFileReader;
136
+ this.#statFile = options.statFile ?? statDiskStampSync;
121
137
  }
122
138
 
123
139
  /** Read and apply all open inputs, sharing work for one input generation. */
@@ -218,6 +234,21 @@ export class SemanticInputBarrier {
218
234
  /** Seed the initial disk baseline from the content used to open a document. */
219
235
  initializeDocumentContent(uri: string, content: string): void {
220
236
  this.#observedDiskFingerprints.set(uri, fingerprintDocumentContent(content));
237
+ // A new open starts without a stamp; the opener records one only for a disk read.
238
+ this.#observedDiskStamps.delete(uri);
239
+ }
240
+
241
+ /**
242
+ * Record the stamp of a disk read whose content now equals the document.
243
+ * The stat must precede that read. An undefined stamp keeps the previous one.
244
+ */
245
+ recordDiskStamp(uri: string, stamp: DiskStamp | undefined): void {
246
+ if (stamp) this.#observedDiskStamps.set(uri, stamp);
247
+ }
248
+
249
+ /** Return the stamp of the last verified disk read, when one exists. */
250
+ getObservedDiskStamp(uri: string): DiskStamp | undefined {
251
+ return this.#observedDiskStamps.get(uri);
221
252
  }
222
253
 
223
254
  /** Record content read from disk and report a changed known baseline. */
@@ -232,11 +263,13 @@ export class SemanticInputBarrier {
232
263
  /** Forget a document's last observed disk content. */
233
264
  forgetDocumentContent(uri: string): void {
234
265
  this.#observedDiskFingerprints.delete(uri);
266
+ this.#observedDiskStamps.delete(uri);
235
267
  }
236
268
 
237
269
  /** Stop pending work and discard observed input fingerprints. */
238
270
  clear(): void {
239
271
  this.#observedDiskFingerprints.clear();
272
+ this.#observedDiskStamps.clear();
240
273
  this.noteInputChange("lifecycle");
241
274
  }
242
275
 
@@ -363,13 +396,17 @@ export class SemanticInputBarrier {
363
396
  const updates: SemanticInputUpdate[] = [];
364
397
  const externalDiskChanges: Array<{ readonly filePath: string; readonly content: string }> = [];
365
398
  const observedDiskFingerprints = new Map<string, string | undefined>();
399
+ const observedDiskStamps = new Map<string, DiskStamp>();
366
400
  for (const read of reads) {
367
401
  const planned = this.#planDocumentRead(pending, read);
368
402
  observedDiskFingerprints.set(read.document.uri, planned.observedDiskFingerprint);
403
+ if (planned.observedDiskStamp) {
404
+ observedDiskStamps.set(read.document.uri, planned.observedDiskStamp);
405
+ }
369
406
  if (planned.update) updates.push(planned.update);
370
407
  if (planned.externalDiskChange) externalDiskChanges.push(planned.externalDiskChange);
371
408
  }
372
- return { updates, externalDiskChanges, observedDiskFingerprints };
409
+ return { updates, externalDiskChanges, observedDiskFingerprints, observedDiskStamps };
373
410
  }
374
411
 
375
412
  #planDocumentRead(
@@ -377,6 +414,7 @@ export class SemanticInputBarrier {
377
414
  read: OpenDocumentRead,
378
415
  ): {
379
416
  observedDiskFingerprint: string | undefined;
417
+ observedDiskStamp?: DiskStamp;
380
418
  update?: SemanticInputUpdate;
381
419
  externalDiskChange?: { readonly filePath: string; readonly content: string };
382
420
  } {
@@ -401,8 +439,12 @@ export class SemanticInputBarrier {
401
439
  ? read.document.content
402
440
  : read.result.content);
403
441
  const contentFingerprint = fingerprintDocumentContent(content);
442
+ // Record the stamp only when the resulting document equals the disk read.
443
+ // A kept document or an override that differs from disk stays unstamped.
444
+ const stamp = contentFingerprint === diskFingerprint ? read.result.stamp : undefined;
404
445
  return {
405
446
  observedDiskFingerprint: diskFingerprint,
447
+ ...(stamp ? { observedDiskStamp: stamp } : {}),
406
448
  ...(externalDiskChange ? { externalDiskChange } : {}),
407
449
  ...(read.document.contentFingerprint !== contentFingerprint
408
450
  ? { update: { document: read.document, content } }
@@ -437,6 +479,7 @@ export class SemanticInputBarrier {
437
479
  this.#advanceRevision("content");
438
480
  }
439
481
  this.#rememberObservedDiskFingerprints(plan.observedDiskFingerprints);
482
+ for (const [uri, stamp] of plan.observedDiskStamps) this.#observedDiskStamps.set(uri, stamp);
440
483
  for (const change of plan.externalDiskChanges) {
441
484
  this.#host.noteExternalDiskChange?.(change.filePath, change.content);
442
485
  }
@@ -475,8 +518,14 @@ export class SemanticInputBarrier {
475
518
  const document = documents[index];
476
519
  if (!document) return;
477
520
  try {
521
+ // Stat before the read: a change between both leaves an older stamp,
522
+ // so the next passive comparison fails closed.
523
+ const stamp = this.#statFile(document.filePath);
478
524
  const content = await this.#readFile(document.filePath, signal);
479
- reads[index] = { document, result: { kind: "content", content } };
525
+ reads[index] = {
526
+ document,
527
+ result: stamp ? { kind: "content", content, stamp } : { kind: "content", content },
528
+ };
480
529
  } catch (error) {
481
530
  reads[index] = { document, result: { kind: "error", error } };
482
531
  }
@@ -576,6 +576,8 @@ export class LspClient {
576
576
  readonly cwd?: string,
577
577
  /** Immutable workspace association snapshot for document language IDs. */
578
578
  fileAssociations?: CFamilyFileAssociationResolver,
579
+ /** Observer for tracked files cleared because they no longer exist. */
580
+ onTrackedFileRemoved?: (filePath: string) => void,
579
581
  ) {
580
582
  this.name = name;
581
583
  this.root = root;
@@ -618,6 +620,7 @@ export class LspClient {
618
620
  if (!this.shouldSendDocumentNotification(method)) return;
619
621
  if (this.rpc) void this.rpc.sendNotification(method, params);
620
622
  },
623
+ onTrackedFileRemoved,
621
624
  });
622
625
  }
623
626
 
@@ -1018,6 +1021,11 @@ export class LspClient {
1018
1021
  return this.diagnostics.getOpenDocumentVersion(filePath);
1019
1022
  }
1020
1023
 
1024
+ /** Return the text last synchronized to the server, or null when the document is not open. */
1025
+ getOpenDocumentContent(filePath: string): string | null {
1026
+ return this.diagnostics.getOpenDocumentContent(filePath);
1027
+ }
1028
+
1021
1029
  /** Return stored diagnostics for one file. */
1022
1030
  getDiagnostics(filePath: string): Diagnostic[] {
1023
1031
  return this.diagnostics.getDiagnostics(filePath);
@@ -1767,7 +1775,7 @@ export class LspClient {
1767
1775
  }): void {
1768
1776
  recordDebugEvent({
1769
1777
  source: "lsp",
1770
- level: "debug",
1778
+ level: options.outcome === "exhausted" || options.outcome === "failed" ? "warning" : "debug",
1771
1779
  category: "request.retry",
1772
1780
  message: "LSP request retry",
1773
1781
  cwd: boundCwd(this.cwd),
@@ -2123,7 +2131,7 @@ export class LspClient {
2123
2131
  if (becameReady) this.publishLifecycle("readiness");
2124
2132
  recordDebugEvent({
2125
2133
  source: "lsp",
2126
- level: "info",
2134
+ level: becameReady ? "info" : "debug",
2127
2135
  category: "readiness.resolved",
2128
2136
  message: `LSP client ${this.name} is ready`,
2129
2137
  cwd: boundCwd(this.cwd),
@@ -2187,7 +2195,7 @@ export class LspClient {
2187
2195
  this.tokenTimeouts.delete(token);
2188
2196
  recordDebugEvent({
2189
2197
  source: "lsp",
2190
- level: "debug",
2198
+ level: "info",
2191
2199
  category: "readiness.token-timeout",
2192
2200
  message: `Readiness per-token timeout fired for ${this.name} after ${timeoutMs}ms`,
2193
2201
  cwd: boundCwd(this.cwd),
@@ -1,6 +1,6 @@
1
1
  import * as path from "node:path";
2
- import ts from "typescript";
3
2
  import { normalizeTsconfigPath as normalizePath } from "./tsconfig-path.ts";
3
+ import { getTypeScript } from "./typescript-module.ts";
4
4
 
5
5
  /**
6
6
  * Collect recognized local project configs declared by `extends`, including
@@ -15,6 +15,7 @@ export function collectExtendedProjectConfigs(configPath: string): Set<string> {
15
15
  if (visited.has(normalizedConfigPath)) return;
16
16
  visited.add(normalizedConfigPath);
17
17
 
18
+ const ts = getTypeScript();
18
19
  const config = ts.readConfigFile(currentConfigPath, ts.sys.readFile).config;
19
20
  if (!config || typeof config !== "object") return;
20
21
 
@@ -1,8 +1,8 @@
1
1
  import * as path from "node:path";
2
- import ts from "typescript";
2
+ import { getTypeScript } from "./typescript-module.ts";
3
3
 
4
4
  /** Normalize a path for tsconfig cache keys and comparisons. */
5
5
  export function normalizeTsconfigPath(target: string): string {
6
6
  const resolved = path.resolve(target).replaceAll("\\", "/");
7
- return ts.sys.useCaseSensitiveFileNames ? resolved : resolved.toLowerCase();
7
+ return getTypeScript().sys.useCaseSensitiveFileNames ? resolved : resolved.toLowerCase();
8
8
  }
@@ -6,9 +6,10 @@
6
6
  // to suppress LSP errors on files that TypeScript itself would not include.
7
7
 
8
8
  import * as path from "node:path";
9
- import ts from "typescript";
9
+ import type ts from "typescript";
10
10
  import { collectExtendedProjectConfigs } from "./tsconfig-extends.ts";
11
11
  import { normalizeTsconfigPath as normalizePath } from "./tsconfig-path.ts";
12
+ import { getTypeScript } from "./typescript-module.ts";
12
13
 
13
14
  export { isProjectConfigFileName } from "./tsconfig-extends.ts";
14
15
 
@@ -74,7 +75,7 @@ export function isTsconfigApplicableFile(filePath: string): boolean {
74
75
  const nearestConfigCache = new Map<string, string | null>();
75
76
  const parsedConfigCache = new Map<string, ParsedProjectConfigCacheEntry>();
76
77
 
77
- const tsInternal = ts as typeof ts & {
78
+ type TypeScriptInternal = typeof ts & {
78
79
  getFileMatcherPatterns?: (
79
80
  configDir: string,
80
81
  excludes: readonly string[] | undefined,
@@ -91,6 +92,10 @@ const tsInternal = ts as typeof ts & {
91
92
  ) => ReadonlyArray<ReadonlyArray<string>>;
92
93
  };
93
94
 
95
+ function getTypeScriptInternal(): TypeScriptInternal {
96
+ return getTypeScript() as TypeScriptInternal;
97
+ }
98
+
94
99
  /**
95
100
  * Check whether a file is excluded by its nearest tsconfig.json or jsconfig.json.
96
101
  *
@@ -122,7 +127,7 @@ export function isFileExcludedByTsconfig(filePath: string, cwd: string): boolean
122
127
  * project config without re-deriving the scope logic.
123
128
  */
124
129
  export function getFileScopeDecision(filePath: string, cwd: string): FileScopeDecision {
125
- const caseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
130
+ const caseSensitiveFileNames = getTypeScript().sys.useCaseSensitiveFileNames;
126
131
  const absolutePath = path.resolve(cwd, filePath);
127
132
  if (isOutOfTree(cwd, absolutePath)) {
128
133
  return {
@@ -212,6 +217,7 @@ function findNearestProjectConfig(startDir: string, rootDir: string): string | n
212
217
  }
213
218
 
214
219
  function getLocalProjectConfig(directory: string): string | null {
220
+ const ts = getTypeScript();
215
221
  const tsconfigPath = path.join(directory, "tsconfig.json");
216
222
  if (ts.sys.fileExists(tsconfigPath)) return tsconfigPath;
217
223
 
@@ -230,6 +236,7 @@ function parseProjectConfig(configPath: string): ParsedProjectConfig | null {
230
236
  parsed: null,
231
237
  dependencies: collectExtendedProjectConfigs(configPath),
232
238
  };
239
+ const ts = getTypeScript();
233
240
  const parsed = ts.getParsedCommandLineOfConfigFile(configPath, {}, createParseConfigHost());
234
241
  if (!parsed) {
235
242
  parsedConfigCache.set(normalizedConfigPath, cacheEntry);
@@ -343,6 +350,7 @@ function decideFileScope(
343
350
  }
344
351
 
345
352
  function getSupportedExtensions(options: ts.CompilerOptions): string[] {
353
+ const tsInternal = getTypeScriptInternal();
346
354
  return tsInternal.getSupportedExtensions
347
355
  ? [...tsInternal.getSupportedExtensions(options, undefined).flat()]
348
356
  : [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
@@ -353,12 +361,13 @@ function getFileMatcherPatterns(
353
361
  excludeSpecs: readonly string[] | undefined,
354
362
  includeSpecs: readonly string[] | undefined,
355
363
  ): { includeFilePattern?: string; excludePattern?: string } {
364
+ const tsInternal = getTypeScriptInternal();
356
365
  return tsInternal.getFileMatcherPatterns
357
366
  ? tsInternal.getFileMatcherPatterns(
358
367
  configDir,
359
368
  excludeSpecs,
360
369
  includeSpecs,
361
- ts.sys.useCaseSensitiveFileNames,
370
+ tsInternal.sys.useCaseSensitiveFileNames,
362
371
  path.parse(configDir).root,
363
372
  )
364
373
  : {};
@@ -366,7 +375,7 @@ function getFileMatcherPatterns(
366
375
 
367
376
  function createParseConfigHost(): ts.ParseConfigFileHost {
368
377
  return {
369
- ...ts.sys,
378
+ ...getTypeScript().sys,
370
379
  onUnRecoverableConfigFileDiagnostic: () => {
371
380
  // Treat invalid configs as unsupported rather than surfacing a secondary
372
381
  // filter failure to the agent.