@mrclrchtr/supi-code-intelligence 1.8.0 → 1.9.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 (159) hide show
  1. package/README.md +17 -1
  2. package/node_modules/@mrclrchtr/supi-code-runtime/README.md +13 -0
  3. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +97 -0
  4. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +53 -0
  5. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +30 -0
  6. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +76 -0
  7. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config.ts +186 -0
  8. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +11 -0
  9. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-messages.ts +119 -0
  10. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-provider-registry.ts +36 -0
  11. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +31 -0
  12. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context.ts +16 -0
  13. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +255 -0
  14. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +30 -0
  15. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/path-utils.ts +40 -0
  16. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/path.ts +2 -0
  17. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/project-roots.ts +170 -0
  18. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/project.ts +15 -0
  19. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +86 -0
  20. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/session-utils.ts +29 -0
  21. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/session.ts +4 -0
  22. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +15 -0
  23. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +41 -0
  24. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +226 -0
  25. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +2 -0
  26. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings.ts +9 -0
  27. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/substrate-types.ts +11 -0
  28. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/terminal.ts +60 -0
  29. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +116 -0
  30. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/types.ts +2 -0
  31. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +40 -0
  32. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +35 -0
  33. package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +68 -0
  34. package/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +31 -0
  35. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +110 -0
  36. package/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/context.ts +41 -0
  37. package/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +170 -0
  38. package/node_modules/@mrclrchtr/supi-core/README.md +3 -13
  39. package/node_modules/@mrclrchtr/supi-core/package.json +1 -7
  40. package/node_modules/@mrclrchtr/supi-lsp/README.md +20 -2
  41. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/README.md +13 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +97 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +57 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +30 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +76 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config.ts +186 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +11 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-messages.ts +119 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-provider-registry.ts +36 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +31 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context.ts +16 -0
  52. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +255 -0
  53. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +30 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/path-utils.ts +40 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/path.ts +2 -0
  56. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/project-roots.ts +170 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/project.ts +15 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +86 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/session-utils.ts +29 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/session.ts +4 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +15 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +41 -0
  63. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +226 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +2 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings.ts +9 -0
  66. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/substrate-types.ts +11 -0
  67. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/terminal.ts +60 -0
  68. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +116 -0
  69. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/types.ts +2 -0
  70. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +40 -0
  71. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +35 -0
  72. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +68 -0
  73. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +31 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +110 -0
  75. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/context.ts +41 -0
  76. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +170 -0
  77. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +3 -13
  78. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -7
  79. package/node_modules/@mrclrchtr/supi-lsp/package.json +9 -6
  80. package/node_modules/@mrclrchtr/supi-lsp/src/handlers/session-lifecycle.ts +17 -7
  81. package/node_modules/@mrclrchtr/supi-lsp/src/lsp.ts +3 -1
  82. package/node_modules/@mrclrchtr/supi-lsp/src/manager/capability-index.ts +24 -0
  83. package/node_modules/@mrclrchtr/supi-lsp/src/manager/client-pool.ts +33 -0
  84. package/node_modules/@mrclrchtr/supi-lsp/src/manager/diagnostic-store.ts +51 -0
  85. package/node_modules/@mrclrchtr/supi-lsp/src/manager/recovery-coordinator.ts +37 -0
  86. package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-router.ts +44 -0
  87. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +156 -0
  88. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registration.ts +39 -0
  89. package/node_modules/@mrclrchtr/supi-lsp/src/tool/register-tools.ts +0 -1
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +18 -1
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/README.md +13 -0
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +97 -0
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +57 -0
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +30 -0
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +76 -0
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config.ts +186 -0
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +11 -0
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-messages.ts +119 -0
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-provider-registry.ts +36 -0
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +31 -0
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/context.ts +16 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +255 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +30 -0
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/path-utils.ts +40 -0
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/path.ts +2 -0
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/project-roots.ts +170 -0
  107. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/project.ts +15 -0
  108. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +86 -0
  109. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/session-utils.ts +29 -0
  110. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/session.ts +4 -0
  111. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +15 -0
  112. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +41 -0
  113. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +226 -0
  114. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +2 -0
  115. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings.ts +9 -0
  116. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/substrate-types.ts +11 -0
  117. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/terminal.ts +60 -0
  118. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +116 -0
  119. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/types.ts +2 -0
  120. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +40 -0
  121. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +35 -0
  122. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +68 -0
  123. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/index.ts +31 -0
  124. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +110 -0
  125. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/context.ts +41 -0
  126. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/workspace/runtime.ts +170 -0
  127. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +3 -13
  128. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -7
  129. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +9 -6
  130. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +144 -0
  131. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-registration.ts +37 -0
  132. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tree-sitter.ts +18 -8
  133. package/package.json +8 -6
  134. package/src/api.ts +31 -16
  135. package/src/brief-focused.ts +2 -2
  136. package/src/brief.ts +2 -2
  137. package/src/code-intelligence.ts +13 -1
  138. package/src/index.ts +29 -16
  139. package/src/{architecture.ts → model.ts} +20 -61
  140. package/src/presentation/markdown/brief.ts +2 -2
  141. package/src/substrates/types.ts +22 -105
  142. package/src/targeting/resolve-file.ts +4 -7
  143. package/src/tool/execute-affected.ts +25 -1
  144. package/src/tool/execute-brief.ts +5 -4
  145. package/src/tool/execute-pattern.ts +4 -3
  146. package/src/tool/execute-relations.ts +22 -1
  147. package/src/types.ts +101 -3
  148. package/src/use-case/build-overview.ts +1 -1
  149. package/src/use-case/generate-affected.ts +25 -7
  150. package/src/use-case/generate-brief.ts +31 -14
  151. package/src/use-case/generate-pattern.ts +9 -9
  152. package/src/use-case/generate-relations.ts +66 -20
  153. package/src/use-case/types.ts +3 -3
  154. package/src/workspace/request-context.ts +139 -0
  155. package/node_modules/@mrclrchtr/supi-core/src/extension.ts +0 -1
  156. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/extension.ts +0 -1
  157. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/extension.ts +0 -1
  158. package/src/substrates/lsp-adapter.ts +0 -197
  159. package/src/substrates/tree-sitter-adapter.ts +0 -173
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Shared terminal title formatting and signaling utilities.
3
+ *
4
+ * Centralized place for pi title convention (π prefix), completion (✓)
5
+ * and waiting (●) indicators, and the audible terminal bell.
6
+ */
7
+ import path from "node:path";
8
+
9
+ /** Unicode checkmark shown when the agent finishes a turn. */
10
+ export const DONE_SYMBOL = "\u2713";
11
+ /** Unicode dot shown when waiting for user input. */
12
+ export const WAITING_SYMBOL = "\u25CF";
13
+
14
+ /** Minimal UI surface needed for title operations. */
15
+ export interface TitleTarget {
16
+ ui: {
17
+ setTitle?(title: string): void;
18
+ };
19
+ }
20
+
21
+ /**
22
+ * Format pi's canonical terminal title from session name and cwd.
23
+ * Falls back gracefully when either is missing.
24
+ *
25
+ * @example
26
+ * formatTitle("my-session", "/home/projects/foo") // "π - my-session - foo"
27
+ * formatTitle(undefined, "/home/projects/foo") // "π - foo"
28
+ * formatTitle("my-session") // "π - my-session"
29
+ * formatTitle() // "π"
30
+ */
31
+ export function formatTitle(sessionName?: string, cwd?: string): string {
32
+ const base = cwd ? path.basename(cwd) : undefined;
33
+ if (sessionName && base) return `π - ${sessionName} - ${base}`;
34
+ if (sessionName) return `π - ${sessionName}`;
35
+ if (base) return `π - ${base}`;
36
+ return "π";
37
+ }
38
+
39
+ /** Sound the audible terminal bell (ASCII BEL). */
40
+ export function signalBell(): void {
41
+ process.stdout.write("\x07");
42
+ }
43
+
44
+ /**
45
+ * Set the terminal title to indicate the agent is waiting for user input.
46
+ * Prefixes with ● and sounds the terminal bell.
47
+ */
48
+ export function signalWaiting(ctx: TitleTarget, title: string): void {
49
+ ctx.ui.setTitle?.(`${WAITING_SYMBOL} ${title}`);
50
+ signalBell();
51
+ }
52
+
53
+ /**
54
+ * Set the terminal title to indicate the agent turn has completed.
55
+ * Prefixes with ✓ and sounds the terminal bell.
56
+ */
57
+ export function signalDone(ctx: TitleTarget, title: string): void {
58
+ ctx.ui.setTitle?.(`${DONE_SYMBOL} ${title}`);
59
+ signalBell();
60
+ }
@@ -0,0 +1,116 @@
1
+ // Shared tool framework for SuPi extensions.
2
+ //
3
+ // Provides a standard ToolSpec→PromptSurface→registerTool pipeline so
4
+ // individual packages do not duplicate spec interfaces, guidance derivation,
5
+ // registration loops, or common TypeBox parameter schemas.
6
+
7
+ import type {
8
+ AgentToolResult,
9
+ AgentToolUpdateCallback,
10
+ ExtensionAPI,
11
+ ExtensionContext,
12
+ } from "@earendil-works/pi-coding-agent";
13
+ import { type TSchema, Type } from "typebox";
14
+
15
+ // ---------------------------------------------------------------------------
16
+ // Types
17
+ // ---------------------------------------------------------------------------
18
+
19
+ /** Minimum contract for a SuPi tool definition. */
20
+ export interface SuiPiToolSpec {
21
+ name: string;
22
+ label: string;
23
+ description: string;
24
+ promptSnippet: string;
25
+ promptGuidelines: string[];
26
+ parameters: TSchema;
27
+ }
28
+
29
+ /** Derived prompt surface — what pi flattens into the system prompt. */
30
+ export interface SuiPiToolPromptSurface {
31
+ description: string;
32
+ promptSnippet: string;
33
+ promptGuidelines: string[];
34
+ }
35
+
36
+ // ---------------------------------------------------------------------------
37
+ // Guidance derivation
38
+ // ---------------------------------------------------------------------------
39
+
40
+ /**
41
+ * Static derivation: copies spec fields into a prompt surface.
42
+ *
43
+ * Packages that need dynamic guidance (e.g. server-coverage injection) should
44
+ * build their own surfaces, optionally starting from the output of this helper.
45
+ */
46
+ export function derivePromptSurface(spec: SuiPiToolSpec): SuiPiToolPromptSurface {
47
+ return {
48
+ description: spec.description,
49
+ promptSnippet: spec.promptSnippet,
50
+ promptGuidelines: [...spec.promptGuidelines],
51
+ };
52
+ }
53
+
54
+ // ---------------------------------------------------------------------------
55
+ // Registration
56
+ // ---------------------------------------------------------------------------
57
+
58
+ // biome-ignore lint/complexity/useMaxParams: matches pi ToolDefinition.execute signature
59
+ export type ToolExecuteFn = (
60
+ toolCallId: string,
61
+ params: unknown,
62
+ signal: AbortSignal | undefined,
63
+ onUpdate: AgentToolUpdateCallback<Record<string, unknown>> | undefined,
64
+ ctx: ExtensionContext,
65
+ ) => Promise<AgentToolResult<Record<string, unknown>>>;
66
+
67
+ /**
68
+ * Register a set of tools from specs + pre-derived surfaces.
69
+ *
70
+ * `createExecute` receives the spec and returns a pi-compatible execute
71
+ * function. This keeps execute-logic package-local while the framework owns
72
+ * the declarative surface and registration boilerplate.
73
+ */
74
+ export function registerSuiPiTools(
75
+ pi: ExtensionAPI,
76
+ specs: readonly SuiPiToolSpec[],
77
+ surfaces: Record<string, SuiPiToolPromptSurface>,
78
+ createExecute: (spec: SuiPiToolSpec) => ToolExecuteFn,
79
+ ): void {
80
+ for (const spec of specs) {
81
+ const surface = surfaces[spec.name];
82
+ pi.registerTool({
83
+ name: spec.name,
84
+ label: spec.label,
85
+ description: surface?.description ?? spec.description,
86
+ promptSnippet: surface?.promptSnippet ?? spec.promptSnippet,
87
+ promptGuidelines: surface?.promptGuidelines ?? [...spec.promptGuidelines],
88
+ parameters: spec.parameters,
89
+ execute: createExecute(spec),
90
+ });
91
+ }
92
+ }
93
+
94
+ // ---------------------------------------------------------------------------
95
+ // Shared parameter builders
96
+ // ---------------------------------------------------------------------------
97
+
98
+ /** File path (relative or absolute). */
99
+ export const FileParam = Type.String({ description: "File path (relative or absolute)" });
100
+
101
+ /** 1-based line number. */
102
+ export const LineParam = Type.Number({ description: "1-based line number", minimum: 1 });
103
+
104
+ /** 1-based character column (UTF-16). */
105
+ export const CharacterParam = Type.Number({
106
+ description: "1-based column number (UTF-16)",
107
+ minimum: 1,
108
+ });
109
+
110
+ /** Symbol name for discovery-based resolution. */
111
+ export const SymbolParam = Type.String({
112
+ description: "Symbol name for discovery-based resolution",
113
+ });
114
+
115
+ /** Maximum results to return. */
116
+ export const MaxResultsParam = Type.Number({ description: "Maximum results to return" });
@@ -0,0 +1,2 @@
1
+ // supi-core types domain — shared substrate types (zero dependencies, pure types).
2
+ export type { CodeLocation, CodePosition } from "./substrate-types.ts";
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@mrclrchtr/supi-code-runtime",
3
+ "version": "1.9.0",
4
+ "description": "SuPi code-runtime — shared workspace context, capability contracts, and canonical types for the code-understanding stack",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/mrclrchtr/supi.git"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "keywords": [
14
+ "pi",
15
+ "pi-coding-agent"
16
+ ],
17
+ "files": [
18
+ "src/**/*.ts",
19
+ "!__tests__"
20
+ ],
21
+ "dependencies": {
22
+ "@mrclrchtr/supi-core": "1.9.0"
23
+ },
24
+ "peerDependencies": {
25
+ "@earendil-works/pi-coding-agent": "*"
26
+ },
27
+ "peerDependenciesMeta": {
28
+ "@earendil-works/pi-coding-agent": {
29
+ "optional": true
30
+ }
31
+ },
32
+ "bundledDependencies": [
33
+ "@mrclrchtr/supi-core"
34
+ ],
35
+ "main": "src/api.ts",
36
+ "exports": {
37
+ "./api": "./src/api.ts",
38
+ "./package.json": "./package.json"
39
+ }
40
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Public API surface for @mrclrchtr/supi-code-runtime.
3
+ *
4
+ * This package exports shared canonical types, capability interfaces,
5
+ * workspace runtime primitives, and typed request context helpers.
6
+ * It is a library-only package with no pi extension entrypoint.
7
+ */
8
+
9
+ // Capability interfaces and availability states
10
+ export type {
11
+ CapabilityState,
12
+ SemanticProvider,
13
+ StructuralProvider,
14
+ StructuralResult,
15
+ } from "./capability/types.ts";
16
+ // Shared canonical types
17
+ export type {
18
+ CalleesData,
19
+ CodeLocation,
20
+ CodePosition,
21
+ CodeResult,
22
+ CodeSymbol,
23
+ ConfidenceMode,
24
+ ExportData,
25
+ ImportData,
26
+ NodeAtData,
27
+ OutlineData,
28
+ SourceRange,
29
+ } from "./types.ts";
30
+ export type { WorkspaceContext } from "./workspace/context.ts";
31
+ // Workspace context
32
+ export { createWorkspaceContext } from "./workspace/context.ts";
33
+ export type { WorkspaceCapabilities } from "./workspace/runtime.ts";
34
+ // Workspace runtime
35
+ export { getDefaultWorkspaceRuntime, WorkspaceRuntime } from "./workspace/runtime.ts";
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Capability interfaces and availability states for the code-understanding
3
+ * stack. These define the contracts through which substrates (LSP,
4
+ * tree-sitter) advertise what they can do.
5
+ */
6
+
7
+ import type {
8
+ CalleesData,
9
+ CodeLocation,
10
+ CodePosition,
11
+ CodeResult,
12
+ CodeSymbol,
13
+ ExportData,
14
+ ImportData,
15
+ NodeAtData,
16
+ OutlineData,
17
+ } from "../types.ts";
18
+
19
+ // ── Availability state ─────────────────────────────────────────────────
20
+
21
+ /**
22
+ * Availability state for a capability within a workspace.
23
+ *
24
+ * - `pending`: the capability may become ready soon (e.g., server starting)
25
+ * - `ready`: the capability is active and can be used
26
+ * - `inactive`: the capability exists but is intentionally turned off
27
+ * - `disabled`: the capability is unavailable for workspace-specific reasons
28
+ * - `unavailable`: the capability cannot be provided at all
29
+ */
30
+ export type CapabilityState =
31
+ | { kind: "pending" }
32
+ | { kind: "ready" }
33
+ | { kind: "inactive" }
34
+ | { kind: "disabled" }
35
+ | { kind: "unavailable"; reason: string };
36
+
37
+ // ── Provider interfaces ────────────────────────────────────────────────
38
+
39
+ /**
40
+ * Semantic analysis capability backed by a language server (LSP).
41
+ *
42
+ * Methods return `null` to signal absence (unavailable / inactive) and
43
+ * an array to signal a successful query (possibly empty).
44
+ */
45
+ export interface SemanticProvider {
46
+ references(filePath: string, position: CodePosition): Promise<CodeLocation[] | null>;
47
+ implementation(filePath: string, position: CodePosition): Promise<CodeLocation[] | null>;
48
+ documentSymbols(filePath: string): Promise<CodeSymbol[] | null>;
49
+ workspaceSymbols(query: string): Promise<CodeSymbol[] | null>;
50
+ }
51
+
52
+ /**
53
+ * Structural analysis capability backed by a parser (tree-sitter).
54
+ *
55
+ * Methods return a discriminated `CodeResult` union that explicitly encodes
56
+ * success, unsupported-language, file-access error, validation error,
57
+ * and runtime error states.
58
+ */
59
+ export interface StructuralProvider {
60
+ calleesAt(file: string, line: number, character: number): Promise<CodeResult<CalleesData>>;
61
+ exports(file: string): Promise<CodeResult<ExportData[]>>;
62
+ outline(file: string): Promise<CodeResult<OutlineData[]>>;
63
+ imports(file: string): Promise<CodeResult<ImportData[]>>;
64
+ nodeAt(file: string, line: number, character: number): Promise<CodeResult<NodeAtData>>;
65
+ }
66
+
67
+ /** Convenience alias for `CodeResult` used in structural contexts. */
68
+ export type StructuralResult<T> = CodeResult<T>;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Package-root re-export surface for @mrclrchtr/supi-code-runtime.
3
+ *
4
+ * Prefer importing from `@mrclrchtr/supi-code-runtime/api` for explicit
5
+ * access to the shared contracts and workspace primitives.
6
+ */
7
+
8
+ export type {
9
+ CalleesData,
10
+ CapabilityState,
11
+ CodeLocation,
12
+ CodePosition,
13
+ CodeResult,
14
+ CodeSymbol,
15
+ ConfidenceMode,
16
+ ExportData,
17
+ ImportData,
18
+ NodeAtData,
19
+ OutlineData,
20
+ SemanticProvider,
21
+ SourceRange,
22
+ StructuralProvider,
23
+ StructuralResult,
24
+ WorkspaceCapabilities,
25
+ WorkspaceContext,
26
+ } from "./api.ts";
27
+ export {
28
+ createWorkspaceContext,
29
+ getDefaultWorkspaceRuntime,
30
+ WorkspaceRuntime,
31
+ } from "./api.ts";
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Canonical shared types for the SuPi code-understanding stack.
3
+ *
4
+ * These types are package-agnostic and used across supi-lsp, supi-tree-sitter,
5
+ * and supi-code-intelligence for communicating code analysis results,
6
+ * capability availability, and structural data shapes.
7
+ */
8
+
9
+ // ── Position and location types ────────────────────────────────────────
10
+
11
+ /** 0-based LSP position. */
12
+ export interface CodePosition {
13
+ line: number;
14
+ character: number;
15
+ }
16
+
17
+ /** A source range spanning two CodePositions. */
18
+ export interface SourceRange {
19
+ start: CodePosition;
20
+ end: CodePosition;
21
+ }
22
+
23
+ /** A code location (file URI + range). */
24
+ export interface CodeLocation {
25
+ uri: string;
26
+ range: SourceRange;
27
+ }
28
+
29
+ // ── Symbol types ───────────────────────────────────────────────────────
30
+
31
+ /** A discovered symbol / declaration. */
32
+ export interface CodeSymbol {
33
+ name: string;
34
+ kind: string;
35
+ file: string;
36
+ line: number;
37
+ character: number;
38
+ container?: string | null;
39
+ }
40
+
41
+ // ── Result types ───────────────────────────────────────────────────────
42
+
43
+ /**
44
+ * Discriminated result union for provider operations.
45
+ *
46
+ * Used primarily by structural (tree-sitter-backed) operations that
47
+ * have explicit error and unsupported-language states. Semantic operations
48
+ * use `null` to signal absence.
49
+ */
50
+ export type CodeResult<T> =
51
+ | { kind: "success"; data: T }
52
+ | { kind: "unsupported-language"; file: string; message: string }
53
+ | { kind: "file-access-error"; file: string; message: string }
54
+ | { kind: "validation-error"; message: string }
55
+ | { kind: "runtime-error"; message: string }
56
+ | { kind: "unavailable"; message: string };
57
+
58
+ /** Result confidence classification. */
59
+ export type ConfidenceMode = "semantic" | "structural" | "heuristic" | "unavailable";
60
+
61
+ // ── Structural data shapes (value types, range-flattened) ──────────────
62
+
63
+ export interface OutlineData {
64
+ name: string;
65
+ kind: string;
66
+ startLine: number;
67
+ startCharacter: number;
68
+ endLine: number;
69
+ endCharacter: number;
70
+ children?: OutlineData[];
71
+ }
72
+
73
+ export interface ExportData {
74
+ name: string;
75
+ kind: string;
76
+ startLine: number;
77
+ startCharacter: number;
78
+ endLine: number;
79
+ endCharacter: number;
80
+ moduleSpecifier?: string;
81
+ }
82
+
83
+ export interface ImportData {
84
+ moduleSpecifier: string;
85
+ startLine: number;
86
+ startCharacter: number;
87
+ endLine: number;
88
+ endCharacter: number;
89
+ }
90
+
91
+ export interface NodeAtData {
92
+ type: string;
93
+ startLine: number;
94
+ startCharacter: number;
95
+ endLine: number;
96
+ endCharacter: number;
97
+ text: string;
98
+ ancestry: Array<{
99
+ type: string;
100
+ startLine: number;
101
+ startCharacter: number;
102
+ endLine: number;
103
+ endCharacter: number;
104
+ }>;
105
+ }
106
+
107
+ export interface CalleesData {
108
+ enclosingScope: { name: string; startLine: number; endLine: number };
109
+ callees: Array<{ name: string; startLine: number }>;
110
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Typed request context helper for consumers that need a convenient view
3
+ * of the capability state for a workspace cwd.
4
+ *
5
+ * This is the primary way that `supi-code-intelligence` reads capability
6
+ * state from the shared runtime. Substrates register providers through
7
+ * {@link WorkspaceRuntime} directly.
8
+ */
9
+
10
+ import type { CapabilityState, SemanticProvider, StructuralProvider } from "../capability/types.ts";
11
+ import type { WorkspaceRuntime } from "./runtime.ts";
12
+
13
+ /**
14
+ * A workspace-scoped request context that provides access to active
15
+ * semantic and structural capabilities along with their availability
16
+ * state and the cached project model.
17
+ */
18
+ export interface WorkspaceContext {
19
+ /** The working directory this context is scoped to. */
20
+ cwd: string;
21
+ /** Semantic analysis capability state and provider. */
22
+ semantic: { state: CapabilityState; provider: SemanticProvider | null };
23
+ /** Structural analysis capability state and provider. */
24
+ structural: { state: CapabilityState; provider: StructuralProvider | null };
25
+ }
26
+
27
+ /**
28
+ * Create a typed workspace context from the shared runtime.
29
+ *
30
+ * @param cwd - The working directory for this context.
31
+ * @param runtime - The shared workspace runtime instance.
32
+ * @returns A snapshot of the capability state for this workspace.
33
+ */
34
+ export function createWorkspaceContext(cwd: string, runtime: WorkspaceRuntime): WorkspaceContext {
35
+ const ws = runtime.getWorkspace(cwd);
36
+ return {
37
+ cwd,
38
+ semantic: ws.semantic,
39
+ structural: ws.structural,
40
+ };
41
+ }
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Workspace-scoped capability registry.
3
+ *
4
+ * Substrates (LSP, tree-sitter) register their capabilities per cwd
5
+ * at session startup. Code-intelligence reads capability state from
6
+ * this registry instead of maintaining a local provider composition
7
+ * layer.
8
+ *
9
+ * Capabilities are independent: registering a semantic provider does not
10
+ * affect an already-registered structural provider for the same cwd.
11
+ */
12
+
13
+ import type { CapabilityState, SemanticProvider, StructuralProvider } from "../capability/types.ts";
14
+
15
+ // ── Public types ───────────────────────────────────────────────────────
16
+
17
+ /**
18
+ * The combined capability state for a workspace.
19
+ * Each capability slot includes both the availability state and the
20
+ * provider instance (null when not ready).
21
+ */
22
+ export interface WorkspaceCapabilities {
23
+ semantic: { state: CapabilityState; provider: SemanticProvider | null };
24
+ structural: { state: CapabilityState; provider: StructuralProvider | null };
25
+ }
26
+
27
+ // ── Defaults ───────────────────────────────────────────────────────────
28
+
29
+ const DEFAULT_UNAVAILABLE_REASON = "No provider registered for this workspace";
30
+
31
+ function createDefaultCapabilities(): WorkspaceCapabilities {
32
+ return {
33
+ semantic: {
34
+ state: { kind: "unavailable", reason: DEFAULT_UNAVAILABLE_REASON },
35
+ provider: null,
36
+ },
37
+ structural: {
38
+ state: { kind: "unavailable", reason: DEFAULT_UNAVAILABLE_REASON },
39
+ provider: null,
40
+ },
41
+ };
42
+ }
43
+
44
+ // ── Runtime ────────────────────────────────────────────────────────────
45
+
46
+ /**
47
+ * Workspace-scoped capability registry keyed by cwd/project root.
48
+ *
49
+ * Each workspace stores independent capability state for semantic
50
+ * (LSP-backed) and structural (tree-sitter-backed) analysis. Substrates
51
+ * register their capabilities at session start; consumers read them
52
+ * as needed.
53
+ *
54
+ * The registry is intentionally unopinionated about which capabilities
55
+ * are required — a workspace may have only semantic, only structural,
56
+ * both, or neither.
57
+ */
58
+ export class WorkspaceRuntime {
59
+ readonly #workspaces = new Map<string, WorkspaceCapabilities>();
60
+
61
+ /**
62
+ * Get the capability state for a workspace cwd.
63
+ * Returns a default "unavailable" state if the workspace
64
+ * has never been registered.
65
+ */
66
+ getWorkspace(cwd: string): WorkspaceCapabilities {
67
+ return this.#workspaces.get(cwd) ?? createDefaultCapabilities();
68
+ }
69
+
70
+ /**
71
+ * Register a semantic provider for a workspace.
72
+ * Replaces any existing semantic provider for the same cwd
73
+ * without affecting the structural provider.
74
+ */
75
+ registerSemantic(cwd: string, provider: SemanticProvider): void {
76
+ const existing = this.#workspaces.get(cwd);
77
+ if (existing) {
78
+ existing.semantic = { state: { kind: "ready" }, provider };
79
+ } else {
80
+ this.#workspaces.set(cwd, {
81
+ semantic: { state: { kind: "ready" }, provider },
82
+ structural: createDefaultCapabilities().structural,
83
+ });
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Register a structural provider for a workspace.
89
+ * Replaces any existing structural provider for the same cwd
90
+ * without affecting the semantic provider.
91
+ */
92
+ registerStructural(cwd: string, provider: StructuralProvider): void {
93
+ const existing = this.#workspaces.get(cwd);
94
+ if (existing) {
95
+ existing.structural = { state: { kind: "ready" }, provider };
96
+ } else {
97
+ this.#workspaces.set(cwd, {
98
+ semantic: createDefaultCapabilities().semantic,
99
+ structural: { state: { kind: "ready" }, provider },
100
+ });
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Remove all capability state for a single workspace cwd.
106
+ */
107
+ clearWorkspace(cwd: string): void {
108
+ this.#workspaces.delete(cwd);
109
+ }
110
+
111
+ /**
112
+ * Clear only the semantic capability slot for a workspace.
113
+ * Leaves the structural slot untouched.
114
+ */
115
+ clearSemantic(cwd: string): void {
116
+ const ws = this.#workspaces.get(cwd);
117
+ if (!ws) return;
118
+ ws.semantic = createDefaultCapabilities().semantic;
119
+ // If both slots are now unavailable, remove the entire entry
120
+ if (ws.semantic.state.kind === "unavailable" && ws.structural.state.kind === "unavailable") {
121
+ this.#workspaces.delete(cwd);
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Clear only the structural capability slot for a workspace.
127
+ * Leaves the semantic slot untouched.
128
+ */
129
+ clearStructural(cwd: string): void {
130
+ const ws = this.#workspaces.get(cwd);
131
+ if (!ws) return;
132
+ ws.structural = createDefaultCapabilities().structural;
133
+ // If both slots are now unavailable, remove the entire entry
134
+ if (ws.semantic.state.kind === "unavailable" && ws.structural.state.kind === "unavailable") {
135
+ this.#workspaces.delete(cwd);
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Remove all capability state for every workspace.
141
+ */
142
+ clearAll(): void {
143
+ this.#workspaces.clear();
144
+ }
145
+ }
146
+
147
+ // ── Default singleton ───────────────────────────────────────────────────
148
+
149
+ const RUNTIME_SYMBOL = Symbol.for("@mrclrchtr/supi-code-runtime/default-runtime");
150
+
151
+ /**
152
+ * Get the shared default workspace runtime instance.
153
+ *
154
+ * Backed by `globalThis` + `Symbol.for` so that all jiti module instances
155
+ * (even duplicate loads through separate `node_modules` paths) share the
156
+ * same WorkspaceRuntime. Without this, standalone installs where
157
+ * `supi-lsp`, `supi-tree-sitter`, and `supi-code-intelligence` each bundle
158
+ * their own copy of `@mrclrchtr/supi-code-runtime` would get separate
159
+ * runtimes — LSP/tree-sitter would register capabilities into one while
160
+ * code-intelligence reads from another.
161
+ */
162
+ export function getDefaultWorkspaceRuntime(): WorkspaceRuntime {
163
+ const g = globalThis as Record<symbol, unknown>;
164
+ let runtime = g[RUNTIME_SYMBOL] as WorkspaceRuntime | undefined;
165
+ if (!runtime) {
166
+ runtime = new WorkspaceRuntime();
167
+ g[RUNTIME_SYMBOL] = runtime;
168
+ }
169
+ return runtime;
170
+ }