@mrclrchtr/supi-code-intelligence 4.10.0 → 5.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 (203) hide show
  1. package/README.md +2 -1
  2. package/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
  6. package/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
  7. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
  8. package/node_modules/@mrclrchtr/supi-core/README.md +2 -0
  9. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  10. package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
  12. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -3
  13. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
  14. package/node_modules/@mrclrchtr/supi-lsp/README.md +80 -5
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +2 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -3
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/package.json +7 -6
  28. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +10 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +206 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +78 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +114 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-evidence.ts +372 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +14 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-pull.ts +62 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +491 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +9 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +71 -11
  38. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-waiters.ts +206 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +365 -297
  40. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +52 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +185 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +25 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +467 -115
  44. package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +161 -33
  45. package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +10 -1
  46. package/node_modules/@mrclrchtr/supi-lsp/src/config/defaults.json +1 -1
  47. package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +45 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +38 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +79 -9
  50. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +13 -4
  51. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +300 -24
  52. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +5 -2
  53. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +464 -96
  54. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +130 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +45 -329
  56. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +57 -120
  57. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +320 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +207 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/src/session/readiness.ts +72 -2
  60. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +151 -26
  61. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +40 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +50 -0
  63. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +136 -120
  64. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +49 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +102 -0
  66. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +17 -7
  67. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
  68. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +2 -0
  74. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  75. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -3
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/LICENSE +21 -0
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/README.md +258 -0
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/babel.cjs +257 -0
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/jiti.cjs +1 -0
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-cli.mjs +34 -0
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-native.mjs +121 -0
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.d.mts +1 -0
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.mjs +4 -0
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-static.mjs +23 -0
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.cjs +30 -0
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.cts +8 -0
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.mts +8 -0
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.mjs +29 -0
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/types.d.ts +420 -0
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/package.json +146 -0
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -3
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +0 -9
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +0 -8
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +16 -12
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +65 -87
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +47 -95
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-timing.ts +147 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client-lifecycle.ts +39 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +561 -0
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-message-size.ts +24 -0
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +452 -0
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +4 -2
  107. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +12 -4
  108. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +4 -2
  109. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +4 -2
  110. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +5 -3
  111. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +33 -12
  112. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/blocking-test-bootstrap.mjs +34 -0
  113. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/bootstrap.mjs +8 -0
  114. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store-helpers.ts +23 -0
  115. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store.ts +400 -0
  116. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/request-control.ts +48 -0
  117. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-parser-helpers.ts +24 -0
  118. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-query-helpers.ts +43 -0
  119. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +421 -0
  120. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +116 -0
  121. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +201 -0
  122. package/package.json +5 -5
  123. package/src/analysis/health/diagnostics.ts +236 -24
  124. package/src/analysis/health/recovery.ts +6 -2
  125. package/src/analysis/provider.ts +58 -0
  126. package/src/analysis/readiness.ts +30 -9
  127. package/src/analysis/refactor/apply.ts +45 -1
  128. package/src/analysis/refactor/mutation-authority.ts +143 -0
  129. package/src/analysis/relations/callees.ts +9 -1
  130. package/src/analysis/relations/types.ts +5 -2
  131. package/src/analysis/search/ast-scan-timing.ts +9 -2
  132. package/src/analysis/search/ast-scan.ts +1 -1
  133. package/src/analysis/search/deadline.ts +2 -2
  134. package/src/analysis/search/pattern-analysis.ts +46 -32
  135. package/src/analysis/search/pattern.ts +12 -2
  136. package/src/analysis/target/anchored.ts +20 -11
  137. package/src/analysis/target/file.ts +18 -11
  138. package/src/analysis/target/identity.ts +19 -3
  139. package/src/analysis/target/symbol.ts +36 -15
  140. package/src/api.ts +4 -0
  141. package/src/diagnostics/evidence.ts +51 -0
  142. package/src/session/capability-adapter.ts +12 -3
  143. package/src/session/find-workflow.ts +17 -7
  144. package/src/session/graph/collect.ts +18 -2
  145. package/src/session/graph-workflow.ts +19 -12
  146. package/src/session/health-refresh.ts +148 -0
  147. package/src/session/health-types.ts +37 -15
  148. package/src/session/health-workflow.ts +37 -39
  149. package/src/session/inspect/collect.ts +20 -3
  150. package/src/session/inspect-workflow.ts +10 -5
  151. package/src/session/orientation/collect.ts +10 -1
  152. package/src/session/orientation/context-facts.ts +3 -1
  153. package/src/session/orientation/context-sections.ts +20 -7
  154. package/src/session/orientation/gather.ts +17 -11
  155. package/src/session/orientation-types.ts +2 -1
  156. package/src/session/orientation-workflow.ts +15 -8
  157. package/src/session/refactor-plans.ts +2 -0
  158. package/src/session/refactor-workflow.ts +59 -14
  159. package/src/session/session.ts +4 -1
  160. package/src/session/target-workflow.ts +54 -23
  161. package/src/session/workflow-control.ts +7 -3
  162. package/src/substrate/lsp/lifecycle.ts +26 -46
  163. package/src/substrate/lsp/maintenance.ts +199 -25
  164. package/src/substrate/lsp/state.ts +2 -2
  165. package/src/substrate/workspace-provider-host.ts +25 -3
  166. package/src/tool/find/execute.ts +7 -1
  167. package/src/tool/find/render.ts +20 -3
  168. package/src/tool/find/tui.ts +23 -21
  169. package/src/tool/graph/execute.ts +23 -3
  170. package/src/tool/graph/tui.ts +59 -46
  171. package/src/tool/health/execute.ts +7 -2
  172. package/src/tool/health/markdown.ts +56 -14
  173. package/src/tool/health/refresh-status.ts +105 -0
  174. package/src/tool/health/tui.ts +95 -98
  175. package/src/tool/infra/workflow-control.ts +8 -0
  176. package/src/tool/inspect/execute.ts +7 -1
  177. package/src/tool/inspect/tui.ts +26 -18
  178. package/src/tool/orientation/execute.ts +21 -3
  179. package/src/tool/orientation/tui.ts +51 -35
  180. package/src/tool/refactor-apply/execute.ts +3 -0
  181. package/src/tool/refactor-apply/tui.ts +43 -25
  182. package/src/tool/refactor-plan/execute.ts +4 -0
  183. package/src/tool/refactor-plan/tui.ts +33 -20
  184. package/src/tool/register.ts +127 -22
  185. package/src/tool/resolve/execute.ts +18 -1
  186. package/src/tool/resolve/tui.ts +42 -24
  187. package/src/tool/result/display.ts +107 -0
  188. package/src/tool/result/errors.ts +20 -17
  189. package/src/tool/result/find.ts +52 -8
  190. package/src/tool/result/graph.ts +44 -1
  191. package/src/tool/result/health.ts +53 -1
  192. package/src/tool/result/inspect.ts +113 -1
  193. package/src/tool/result/orientation.ts +66 -14
  194. package/src/tool/result/refactor.ts +36 -4
  195. package/src/tool/result/resolve.ts +44 -7
  196. package/src/tool/result/types.ts +20 -0
  197. package/src/types/execution.ts +18 -5
  198. package/src/types/index.ts +8 -1
  199. package/src/ui/status-command.ts +5 -3
  200. package/src/ui/status-overlay.ts +4 -0
  201. package/src/ui/tui/common.ts +108 -10
  202. package/src/ui/tui/display.ts +48 -0
  203. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime.ts +0 -351
@@ -26,7 +26,9 @@ This package provides the parser-backed structural substrate consumed by `@mrclr
26
26
  - a shared session-scoped Tree-sitter service for structural analysis
27
27
  - an owned parsing session API for direct library consumers
28
28
  - a `StructuralProvider` adapter published through `./provider/tree-sitter-provider`
29
- - structural extraction helpers for outline/import/export/node/callee/call-site analysis inside the library surface
29
+ - a long-lived owned Structural Worker that keeps Pi responsive during parser-backed work
30
+ - `CodeRequestControl` cancellation, absolute deadlines, shared atomic interruption, and hard-stop termination
31
+ - structural outline/import/export/node/callee/call-site operations through the asynchronous service surface
30
32
  - operation-specific extension discovery through `getStructuralSearchSupportedExtensions()`
31
33
 
32
34
  It does **not** register pi tools or commands on its own.
@@ -61,7 +63,7 @@ capabilities into the shared workspace runtime.
61
63
  ```text
62
64
  supi-code-runtime ← shared contracts + workspace runtime
63
65
 
64
- supi-tree-sitter ← Tree-sitter WASM + session-scoped service + runtime capabilities
66
+ supi-tree-sitter ← one owned Structural Worker + session-scoped service + runtime capabilities
65
67
  ```
66
68
 
67
69
  ## Package surfaces
@@ -82,7 +84,7 @@ const parseable = await session.canParse("src/index.ts");
82
84
  const outline = await session.outline("src/index.ts");
83
85
  const callees = await session.calleesAt("src/index.ts", 42, 10);
84
86
 
85
- session.dispose();
87
+ await session.dispose();
86
88
  ```
87
89
 
88
90
  Shared session-scoped service example:
@@ -104,15 +106,23 @@ Run the stable outline fixture on the same machine and dependency versions:
104
106
  pnpm --filter @mrclrchtr/supi-tree-sitter bench:structural
105
107
  ```
106
108
 
107
- The benchmark reports a cold session parser baseline and a repeated parser baseline. Debug capture is active, so the baseline includes the internal timing observation cost. The benchmark records measurements but does not set a pass or fail threshold.
109
+ The benchmark reports cold and repeated outline results. It also reports cold and repeated call-site query results. Repeated operations reuse unchanged parsed trees and compiled queries. Debug capture is active, so the baseline includes the internal timing observation cost. The benchmark records measurements but does not set a pass or fail threshold.
110
+
111
+ The Structural Worker reads files asynchronously. It identifies fresh parsed files by canonical path, grammar, and SHA-256 content hash. Cached trees use true least-recently-used eviction with limits of 128 files and 32 MiB of retained UTF-8 source bytes. Compiled queries use the same policy with limits of 128 queries and 512 KiB of retained UTF-8 query text. Source and query byte counts are memory-related proxies because `web-tree-sitter` does not report WASM resource sizes. Cached canonical trees stay private in the Worker.
112
+
113
+ All structural service operations accept optional `CodeRequestControl`. The parent converts cancellation to one shared atomic flag and forwards absolute deadlines. When present, it forwards only the opaque Debug Operation ID through the Worker protocol so parse and query timing events keep direct request ownership. Direct library calls have no ID. Worker read phases observe a local abort signal. Parser and query progress callbacks observe the flag and deadline. If cooperative interruption does not settle in the fixed 250 ms grace period, the parent terminates the Worker. Valid queued work keeps FIFO order on one fresh Worker with cold caches. There is no main-thread parser fallback.
108
114
 
109
115
  ## Source
110
116
 
111
117
  - `src/api.ts` — public library entrypoint
112
118
  - `src/index.ts` — re-export surface
113
- - `src/session/runtime.ts` — parser and query runtime
114
- - `src/session/session.ts` — runtime-backed service helpers and owned session API
119
+ - `src/worker/bootstrap.mjs` — package-owned Worker bootstrap and direct `jiti` loader
120
+ - `src/worker/runtime.ts` — Worker-only parser and query runtime
121
+ - `src/worker/parsed-file-store.ts` — Worker-only parsed-file and compiled-query reuse
122
+ - `src/session/structural-worker-client.ts` — bounded FIFO mailbox, protocol, cancellation, and restart ownership
123
+ - `src/session/runtime-controller.ts` — generation-fenced shared Worker lifecycle
124
+ - `src/session/session.ts` — asynchronous Worker-proxy service and owned session API
115
125
  - `src/operation-support.ts` — authoritative operation-specific extension support
116
126
  - `src/session/service-registry.ts` — shared session-scoped structural service registry
117
127
  - `src/provider/tree-sitter-provider.ts` — `StructuralProvider` adapter consumed by `@mrclrchtr/supi-code-intelligence`
118
- - `src/tool/outline.ts`, `src/tool/outline-*.ts`, `src/tool/imports.ts`, `src/tool/exports.ts`, `src/tool/node-at.ts`, `src/tool/callees.ts`, `src/tool/call-sites.ts` — structural analyses exposed through the library surface
128
+ - `src/tool/outline.ts`, `src/tool/outline-*.ts`, `src/tool/imports.ts`, `src/tool/exports.ts`, `src/tool/node-at.ts`, `src/tool/callees.ts`, `src/tool/call-sites.ts` — Worker-internal structural analyses
@@ -22,6 +22,8 @@ Read-only provider methods return `CodeQueryResult<T>`:
22
22
 
23
23
  This keeps successful zero-result facts distinct from routing, transport, and provider failures.
24
24
 
25
+ Semantic and structural provider methods also accept optional `CodeRequestControl` metadata. It contains a caller `AbortSignal`, an absolute Unix-epoch deadline, and an optional opaque Debug Operation ID. Adapters preserve the same object. The ID does not change cancellation semantics. Canonical helpers identify cancellation and deadline expiry across bundled package copies. Cooperative structural substrates apply the control; unsupported substrates can preserve it without applying behavior.
26
+
25
27
  ## License
26
28
 
27
29
  MIT
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-runtime",
3
- "version": "4.10.0",
3
+ "version": "5.0.0",
4
4
  "description": "Shared workspace context and capability contracts for code intelligence",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -9,6 +9,7 @@
9
9
  // Capability interfaces and availability states
10
10
  export type {
11
11
  CapabilityState,
12
+ CodeRequestControl,
12
13
  SemanticProvider,
13
14
  StructuralProvider,
14
15
  StructuralResult,
@@ -21,6 +22,13 @@ export {
21
22
  partialCodeQuery,
22
23
  unavailableCodeQuery,
23
24
  } from "./query-result.ts";
25
+ export {
26
+ CodeRequestDeadlineError,
27
+ isCodeRequestDeadlineError,
28
+ isCodeRequestInterrupted,
29
+ isCodeRequestInterruption,
30
+ throwIfCodeRequestInterrupted,
31
+ } from "./request-control.ts";
24
32
  // Shared canonical types
25
33
  export type {
26
34
  CalleeDepth,
@@ -34,6 +42,7 @@ export type {
34
42
  DeclarationNesting,
35
43
  DisambiguationCandidate,
36
44
  DocumentCodeSymbol,
45
+ DocumentEditPrecondition,
37
46
  ExportData,
38
47
  FileEdit,
39
48
  ImportData,
@@ -43,6 +43,16 @@ export type CapabilityState =
43
43
 
44
44
  // ── Provider interfaces ────────────────────────────────────────────────
45
45
 
46
+ /** Request control that adapters preserve and cooperative providers apply. */
47
+ export interface CodeRequestControl {
48
+ /** Opaque Debug Operation ID for work directly owned by one public Tool call. */
49
+ readonly operationId?: string;
50
+ /** Caller cancellation signal, when one exists. */
51
+ readonly signal?: AbortSignal;
52
+ /** Absolute wall-clock deadline in Unix epoch milliseconds. */
53
+ readonly deadline?: number;
54
+ }
55
+
46
56
  /**
47
57
  * Semantic analysis capability backed by a language server (LSP).
48
58
  *
@@ -51,16 +61,31 @@ export type CapabilityState =
51
61
  * null values are completed observations rather than capability failures.
52
62
  */
53
63
  export interface SemanticProvider {
54
- references(filePath: string, position: CodePosition): Promise<CodeQueryResult<CodeLocation[]>>;
64
+ references(
65
+ filePath: string,
66
+ position: CodePosition,
67
+ control?: CodeRequestControl,
68
+ ): Promise<CodeQueryResult<CodeLocation[]>>;
55
69
  implementation(
56
70
  filePath: string,
57
71
  position: CodePosition,
72
+ control?: CodeRequestControl,
58
73
  ): Promise<CodeQueryResult<CodeLocation[]>>;
59
- documentSymbols(filePath: string): Promise<CodeQueryResult<DocumentCodeSymbol[]>>;
60
- workspaceSymbols(query: string): Promise<CodeQueryResult<CodeSymbol[]>>;
74
+ documentSymbols(
75
+ filePath: string,
76
+ control?: CodeRequestControl,
77
+ ): Promise<CodeQueryResult<DocumentCodeSymbol[]>>;
78
+ workspaceSymbols(
79
+ query: string,
80
+ control?: CodeRequestControl,
81
+ ): Promise<CodeQueryResult<CodeSymbol[]>>;
61
82
 
62
83
  /** Optional definition capability with explicit completed-empty semantics. */
63
- definition?(filePath: string, position: CodePosition): Promise<CodeQueryResult<CodeLocation[]>>;
84
+ definition?(
85
+ filePath: string,
86
+ position: CodePosition,
87
+ control?: CodeRequestControl,
88
+ ): Promise<CodeQueryResult<CodeLocation[]>>;
64
89
 
65
90
  /**
66
91
  * Optional hover capability. A completed `null` data value means the
@@ -69,6 +94,7 @@ export interface SemanticProvider {
69
94
  hover?(
70
95
  filePath: string,
71
96
  position: CodePosition,
97
+ control?: CodeRequestControl,
72
98
  ): Promise<CodeQueryResult<{ contents: string; range?: SourceRange } | null>>;
73
99
 
74
100
  /**
@@ -79,7 +105,7 @@ export interface SemanticProvider {
79
105
  * organize imports, dead-code cleanup, etc.) without exposing that branching
80
106
  * to callers.
81
107
  */
82
- refactor?(request: RefactorRequest): Promise<RefactorResult>;
108
+ refactor?(request: RefactorRequest, control?: CodeRequestControl): Promise<RefactorResult>;
83
109
 
84
110
  /**
85
111
  * Optional rename capability. When present, the provider supports
@@ -88,7 +114,12 @@ export interface SemanticProvider {
88
114
  * This remains a lower-level substrate helper for providers that expose
89
115
  * symbol rename independently of their general refactor planner.
90
116
  */
91
- rename?(file: string, position: CodePosition, newName: string): Promise<RefactorResult>;
117
+ rename?(
118
+ file: string,
119
+ position: CodePosition,
120
+ newName: string,
121
+ control?: CodeRequestControl,
122
+ ): Promise<RefactorResult>;
92
123
 
93
124
  /**
94
125
  * Optional code actions capability. When present, the provider
@@ -96,7 +127,11 @@ export interface SemanticProvider {
96
127
  *
97
128
  * Kept as a low-level substrate helper and for lightweight introspection.
98
129
  */
99
- codeActions?(file: string, position: CodePosition): Promise<RefactorResult[]>;
130
+ codeActions?(
131
+ file: string,
132
+ position: CodePosition,
133
+ control?: CodeRequestControl,
134
+ ): Promise<RefactorResult[]>;
100
135
  }
101
136
 
102
137
  /**
@@ -111,14 +146,19 @@ export interface StructuralProvider {
111
146
  file: string,
112
147
  line: number,
113
148
  character: number,
114
- depth?: CalleeDepth,
149
+ depthOrOptions?: CalleeDepth | { depth?: CalleeDepth; control?: CodeRequestControl },
115
150
  ): Promise<CodeResult<CalleesData>>;
116
- exports(file: string): Promise<CodeResult<ExportData[]>>;
117
- outline(file: string): Promise<CodeResult<OutlineData[]>>;
118
- imports(file: string): Promise<CodeResult<ImportData[]>>;
119
- nodeAt(file: string, line: number, character: number): Promise<CodeResult<NodeAtData>>;
151
+ exports(file: string, control?: CodeRequestControl): Promise<CodeResult<ExportData[]>>;
152
+ outline(file: string, control?: CodeRequestControl): Promise<CodeResult<OutlineData[]>>;
153
+ imports(file: string, control?: CodeRequestControl): Promise<CodeResult<ImportData[]>>;
154
+ nodeAt(
155
+ file: string,
156
+ line: number,
157
+ character: number,
158
+ control?: CodeRequestControl,
159
+ ): Promise<CodeResult<NodeAtData>>;
120
160
  /** Find all call-site identifiers in a file. Returns name + start line for each match. */
121
- callSites(file: string): Promise<CodeResult<CallSite[]>>;
161
+ callSites(file: string, control?: CodeRequestControl): Promise<CodeResult<CallSite[]>>;
122
162
  }
123
163
 
124
164
  /** Convenience alias for `CodeResult` used in structural contexts. */
@@ -0,0 +1,47 @@
1
+ import type { CodeRequestControl } from "./capability/types.ts";
2
+
3
+ /** Error raised when an absolute code-request deadline has elapsed. */
4
+ export class CodeRequestDeadlineError extends Error {
5
+ constructor() {
6
+ super("Code request deadline exceeded");
7
+ this.name = "CodeRequestDeadlineError";
8
+ }
9
+ }
10
+
11
+ /** Test whether request cancellation or its absolute deadline has elapsed. */
12
+ export function isCodeRequestInterrupted(
13
+ control: CodeRequestControl | undefined,
14
+ now: () => number = Date.now,
15
+ ): boolean {
16
+ return (
17
+ control?.signal?.aborted === true ||
18
+ (control?.deadline !== undefined && now() >= control.deadline)
19
+ );
20
+ }
21
+
22
+ /** Throw the caller abort reason or a canonical absolute-deadline error. */
23
+ export function throwIfCodeRequestInterrupted(
24
+ control: CodeRequestControl | undefined,
25
+ now: () => number = Date.now,
26
+ ): void {
27
+ control?.signal?.throwIfAborted();
28
+ if (control?.deadline !== undefined && now() >= control.deadline) {
29
+ throw new CodeRequestDeadlineError();
30
+ }
31
+ }
32
+
33
+ /** Identify an absolute-deadline error across bundled package copies. */
34
+ export function isCodeRequestDeadlineError(error: unknown): error is Error {
35
+ return (
36
+ error instanceof CodeRequestDeadlineError ||
37
+ (error instanceof Error && error.name === "CodeRequestDeadlineError")
38
+ );
39
+ }
40
+
41
+ /** Identify an error caused by the supplied request control. */
42
+ export function isCodeRequestInterruption(
43
+ error: unknown,
44
+ control: CodeRequestControl | undefined,
45
+ ): boolean {
46
+ return isCodeRequestDeadlineError(error) || control?.signal?.aborted === true;
47
+ }
@@ -149,11 +149,18 @@ export interface FileEdit {
149
149
  newText: string;
150
150
  }
151
151
 
152
+ /** A document-state precondition established when semantic edits are normalized. */
153
+ export type DocumentEditPrecondition =
154
+ | { file: string; kind: "open-document-version"; version: number }
155
+ | { file: string; kind: "disk-content" };
156
+
152
157
  /**
153
158
  * A precise workspace edit — one or more file edits to apply atomically.
154
159
  */
155
160
  export interface WorkspaceEdit {
156
161
  edits: FileEdit[];
162
+ /** Document state that the semantic provider validated before it made this plan. */
163
+ documentPreconditions?: DocumentEditPrecondition[];
157
164
  }
158
165
 
159
166
  /**
@@ -202,7 +209,12 @@ export interface DisambiguationCandidate {
202
209
  * - `unavailable`: refactoring not possible
203
210
  */
204
211
  export type RefactorResult =
205
- | { kind: "precise"; edits: WorkspaceEdit }
212
+ | {
213
+ kind: "precise";
214
+ edits: WorkspaceEdit;
215
+ /** Provider roots authorized by the semantic route. Consumers canonicalize before storage. */
216
+ authorizedMutationRoots: string[];
217
+ }
206
218
  | { kind: "ambiguous"; candidates: DisambiguationCandidate[] }
207
219
  | { kind: "unavailable"; reason: string };
208
220
 
@@ -28,6 +28,7 @@ pnpm add @mrclrchtr/supi-core
28
28
  - `loadSupiConfig()` — merged config with resolution order `defaults <- global <- project`
29
29
  - `loadSupiConfigForScope()` — load one scope at a time for settings UIs
30
30
  - `writeSupiConfig()` — persist values
31
+ - `replaceSupiConfigSection()` — replace one nested section while preserving other sections
31
32
  - `removeSupiConfigKey()` — remove a key or override
32
33
 
33
34
  Config file locations:
@@ -49,6 +50,7 @@ Config file locations:
49
50
 
50
51
  - context-provider registry for `/supi-context`
51
52
  - debug-event registry and monotonic phase timers for producers that want shared debug capture
53
+ - optional Debug Operation IDs for exact, directly owned public Tool-call correlation; ambient events stay uncorrelated
52
54
  - settings registry used by `/supi-settings`
53
55
 
54
56
  ### Project and session helpers
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "4.10.0",
3
+ "version": "5.0.0",
4
4
  "description": "Shared settings, configuration, reporting, and session infrastructure",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -148,6 +148,37 @@ export function writeSupiConfig(
148
148
  fs.writeFileSync(configPath, `${JSON.stringify(existing, null, 2)}\n`, "utf-8");
149
149
  }
150
150
 
151
+ /**
152
+ * Replace one complete config section while preserving other sections.
153
+ *
154
+ * This is useful for nested settings that must remove stale keys as part of
155
+ * one update. An empty section is removed from the config file.
156
+ */
157
+ export function replaceSupiConfigSection(
158
+ loc: SupiConfigLocation,
159
+ value: Record<string, unknown>,
160
+ options?: SupiConfigOptions,
161
+ ): void {
162
+ const configPath = getSupiConfigPath(loc.scope, loc.cwd, options);
163
+ const existing = readJsonFile(configPath) ?? {};
164
+
165
+ if (Object.keys(value).length > 0) existing[loc.section] = value;
166
+ else delete existing[loc.section];
167
+
168
+ const content = Object.keys(existing).length > 0 ? `${JSON.stringify(existing, null, 2)}\n` : "";
169
+ if (content) {
170
+ fs.mkdirSync(path.dirname(configPath), { recursive: true });
171
+ fs.writeFileSync(configPath, content, "utf-8");
172
+ return;
173
+ }
174
+
175
+ try {
176
+ fs.unlinkSync(configPath);
177
+ } catch {
178
+ // File may not exist.
179
+ }
180
+ }
181
+
151
182
  /**
152
183
  * Remove a key from a config section.
153
184
  * Used by `interval default` to remove the project override.
@@ -1,10 +1,12 @@
1
1
  // supi-core config domain — config loading.
2
2
  export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
3
3
  export {
4
+ getSupiConfigPath,
4
5
  loadSupiConfig,
5
6
  loadSupiConfigForScope,
6
7
  loadSupiConfigSectionForScope,
7
8
  readJsonFile,
8
9
  removeSupiConfigKey,
10
+ replaceSupiConfigSection,
9
11
  writeSupiConfig,
10
12
  } from "./config/config.ts";
@@ -25,6 +25,8 @@ export const DEBUG_REGISTRY_DEFAULTS: DebugRegistryConfig = {
25
25
  };
26
26
 
27
27
  export interface DebugEventInput {
28
+ /** Opaque identity for events directly owned by one public Tool call. */
29
+ operationId?: string;
28
30
  source: string;
29
31
  level: DebugLevel;
30
32
  category: string;
@@ -42,6 +44,8 @@ export interface DebugEvent extends DebugEventInput {
42
44
  }
43
45
 
44
46
  export interface DebugEventQuery {
47
+ /** Match one exact Debug Operation ID. */
48
+ operationId?: string;
45
49
  source?: string;
46
50
  level?: DebugLevel;
47
51
  category?: string;
@@ -53,6 +57,7 @@ export interface DebugEventQuery {
53
57
  export interface DebugEventView {
54
58
  id: number;
55
59
  timestamp: number;
60
+ operationId?: string;
56
61
  source: string;
57
62
  level: DebugLevel;
58
63
  category: string;
@@ -84,6 +89,7 @@ interface DebugRegistryState {
84
89
  }
85
90
 
86
91
  const REGISTRY_KEY = Symbol.for("@mrclrchtr/supi-core/debug-registry");
92
+ const DEBUG_OPERATION_ID_RE = /^op-[A-Za-z0-9_-]{21}[AQgw]$/;
87
93
  const SECRET_KEY_RE = /(?:token|password|passwd|secret|api[_-]?key|authorization|credential)/i;
88
94
  const ENV_SECRET_RE =
89
95
  /\b([A-Za-z0-9_]*(?:token|password|passwd|secret|api[_-]?key|authorization|credential)[A-Za-z0-9_]*)=(?:'[^']*'|"[^"]*"|\S+)/gi;
@@ -135,11 +141,17 @@ export function isDebugLevel(value: unknown): value is DebugLevel {
135
141
  return value === "debug" || value === "info" || value === "warning" || value === "error";
136
142
  }
137
143
 
138
- /** Match a debug event against the supported source, level, and category filters. */
144
+ /** Return whether a value has the exact 16-byte base64url Debug Operation ID form. */
145
+ export function isDebugOperationId(value: unknown): value is string {
146
+ return typeof value === "string" && DEBUG_OPERATION_ID_RE.test(value);
147
+ }
148
+
149
+ /** Match a debug event against the supported exact filters. */
139
150
  export function matchesDebugEventQuery(
140
- event: Pick<DebugEventView, "source" | "level" | "category">,
141
- query: Pick<DebugEventQuery, "source" | "level" | "category">,
151
+ event: Pick<DebugEventView, "operationId" | "source" | "level" | "category">,
152
+ query: Pick<DebugEventQuery, "operationId" | "source" | "level" | "category">,
142
153
  ): boolean {
154
+ if (query.operationId && event.operationId !== query.operationId) return false;
143
155
  if (query.source && event.source !== query.source) return false;
144
156
  if (query.level && event.level !== query.level) return false;
145
157
  if (query.category && event.category !== query.category) return false;
@@ -197,6 +209,7 @@ function toSanitizedView(event: DebugEvent): DebugEventView {
197
209
  return {
198
210
  id: event.id,
199
211
  timestamp: event.timestamp,
212
+ operationId: event.operationId,
200
213
  source: event.source,
201
214
  level: event.level,
202
215
  category: event.category,
@@ -216,6 +229,9 @@ export function subscribeDebugEvents(listener: DebugEventListener): () => void {
216
229
  /** Record a session-local debug event if debugging is enabled. */
217
230
  export function recordDebugEvent(input: DebugEventInput): DebugEvent | null {
218
231
  const state = getState();
232
+ if (input.operationId !== undefined && !isDebugOperationId(input.operationId)) {
233
+ return null;
234
+ }
219
235
  if (!state.config.enabled) {
220
236
  return null;
221
237
  }
@@ -41,7 +41,10 @@ export interface SettingsApplyResult {
41
41
  */
42
42
  export interface SettingsModule {
43
43
  id: string;
44
+ /** Human-readable section label shown in the UI. */
44
45
  label: string;
46
+ /** Optional label that groups this module within its section. */
47
+ subsection?: string;
45
48
  read(context: SettingsContext): Promise<SettingsSnapshot>;
46
49
  apply(request: SettingsActionRequest): Promise<SettingsApplyResult>;
47
50
  }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Pooya Parsa <pooya@pi0.io>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.