@mrclrchtr/supi-tree-sitter 1.7.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 (62) hide show
  1. package/README.md +44 -16
  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 +13 -8
  40. package/node_modules/@mrclrchtr/supi-core/src/api.ts +26 -92
  41. package/node_modules/@mrclrchtr/supi-core/src/config.ts +11 -0
  42. package/node_modules/@mrclrchtr/supi-core/src/context.ts +16 -0
  43. package/node_modules/@mrclrchtr/supi-core/src/index.ts +26 -92
  44. package/node_modules/@mrclrchtr/supi-core/src/path.ts +2 -0
  45. package/node_modules/@mrclrchtr/supi-core/src/project.ts +15 -0
  46. package/node_modules/@mrclrchtr/supi-core/src/session.ts +4 -0
  47. package/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +2 -0
  48. package/node_modules/@mrclrchtr/supi-core/src/settings.ts +9 -0
  49. package/node_modules/@mrclrchtr/supi-core/src/substrate-types.ts +11 -0
  50. package/node_modules/@mrclrchtr/supi-core/src/types.ts +2 -0
  51. package/package.json +9 -6
  52. package/src/provider/tree-sitter-provider.ts +144 -0
  53. package/src/session/runtime-registration.ts +37 -0
  54. package/src/session/runtime.ts +1 -1
  55. package/src/session/service-registry.ts +1 -1
  56. package/src/tool/guidance.ts +29 -25
  57. package/src/tool/handlers.ts +196 -0
  58. package/src/tool/register-tools.ts +107 -0
  59. package/src/tool/tool-specs.ts +117 -0
  60. package/src/tree-sitter.ts +21 -307
  61. package/node_modules/@mrclrchtr/supi-core/src/extension.ts +0 -1
  62. package/src/tool/action-specs.ts +0 -92
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "SuPi core — shared infrastructure for SuPi extensions (XML context tags, config system)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -37,12 +37,17 @@
37
37
  "main": "src/api.ts",
38
38
  "exports": {
39
39
  "./api": "./src/api.ts",
40
- "./extension": "./src/extension.ts",
41
- "./package.json": "./package.json"
42
- },
43
- "pi": {
44
- "extensions": [
45
- "./src/extension.ts"
46
- ]
40
+ "./config": "./src/config.ts",
41
+ "./context": "./src/context.ts",
42
+ "./debug": "./src/debug-registry.ts",
43
+ "./package.json": "./package.json",
44
+ "./path": "./src/path.ts",
45
+ "./project": "./src/project.ts",
46
+ "./session": "./src/session.ts",
47
+ "./settings": "./src/settings.ts",
48
+ "./settings-ui": "./src/settings-ui.ts",
49
+ "./terminal": "./src/terminal.ts",
50
+ "./tool-framework": "./src/tool-framework.ts",
51
+ "./types": "./src/types.ts"
47
52
  }
48
53
  }
@@ -1,96 +1,30 @@
1
1
  // supi-core — shared infrastructure for SuPi extensions.
2
2
  // Provides XML context tag wrapping, unified config system, context-message utilities,
3
3
  // settings registry for supi-wide TUI settings, and a shared tool-spec/registration framework.
4
+ //
5
+ // Convenience barrel — re-exports all domain entry points.
6
+ // For lighter imports, use one of the domain subpaths directly
7
+ // (e.g. @mrclrchtr/supi-core/config, @mrclrchtr/supi-core/context).
4
8
 
5
- export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
6
- export {
7
- loadSupiConfig,
8
- loadSupiConfigForScope,
9
- readJsonFile,
10
- removeSupiConfigKey,
11
- writeSupiConfig,
12
- } from "./config/config.ts";
13
- export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
14
- export { registerConfigSettings } from "./config/config-settings.ts";
15
- export type { ContextMessageLike } from "./context/context-messages.ts";
16
- export {
17
- findLastUserMessageIndex,
18
- getContextToken,
19
- getPromptContent,
20
- pruneAndReorderContextMessages,
21
- restorePromptContent,
22
- } from "./context/context-messages.ts";
23
- export type { ContextProvider } from "./context/context-provider-registry.ts";
24
- export {
25
- clearRegisteredContextProviders,
26
- getRegisteredContextProviders,
27
- registerContextProvider,
28
- } from "./context/context-provider-registry.ts";
29
- export { wrapExtensionContext } from "./context/context-tag.ts";
30
- export type {
31
- DebugAgentAccess,
32
- DebugEvent,
33
- DebugEventInput,
34
- DebugEventQuery,
35
- DebugEventQueryResult,
36
- DebugEventView,
37
- DebugLevel,
38
- DebugNotifyLevel,
39
- DebugRegistryConfig,
40
- DebugSummary,
41
- } from "./debug-registry.ts";
42
- export {
43
- clearDebugEvents,
44
- configureDebugRegistry,
45
- DEBUG_REGISTRY_DEFAULTS,
46
- getDebugEvents,
47
- getDebugRegistryConfig,
48
- getDebugSummary,
49
- recordDebugEvent,
50
- redactDebugData,
51
- resetDebugRegistry,
52
- } from "./debug-registry.ts";
53
- export { fileToUri, resolveToolPath, stripToolPathPrefix, uriToFile } from "./path-utils.ts";
54
- export type { KnownRootEntry } from "./project-roots.ts";
55
- export {
56
- buildKnownRootsMap,
57
- byPathDepth,
58
- dedupeTopmostRoots,
59
- findProjectRoot,
60
- isWithin,
61
- isWithinOrEqual,
62
- mergeKnownRoots,
63
- resolveKnownRoot,
64
- segmentCount,
65
- sortRootsBySpecificity,
66
- walkProject,
67
- } from "./project-roots.ts";
68
- export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
69
- export { getActiveBranchEntries } from "./session-utils.ts";
70
- export { registerSettingsCommand } from "./settings/settings-command.ts";
71
- export type { SettingsScope, SettingsSection } from "./settings/settings-registry.ts";
72
- export {
73
- clearRegisteredSettings,
74
- getRegisteredSettings,
75
- registerSettings,
76
- } from "./settings/settings-registry.ts";
77
- export { createInputSubmenu, openSettingsOverlay } from "./settings/settings-ui.ts";
78
- export type { TitleTarget } from "./terminal.ts";
79
- export {
80
- DONE_SYMBOL,
81
- formatTitle,
82
- signalBell,
83
- signalDone,
84
- signalWaiting,
85
- WAITING_SYMBOL,
86
- } from "./terminal.ts";
87
- export type { SuiPiToolPromptSurface, SuiPiToolSpec, ToolExecuteFn } from "./tool-framework.ts";
88
- export {
89
- CharacterParam,
90
- derivePromptSurface,
91
- FileParam,
92
- LineParam,
93
- MaxResultsParam,
94
- registerSuiPiTools,
95
- SymbolParam,
96
- } from "./tool-framework.ts";
9
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
10
+ export * from "./config.ts";
11
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
12
+ export * from "./context.ts";
13
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
14
+ export * from "./debug-registry.ts";
15
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
16
+ export * from "./path.ts";
17
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
18
+ export * from "./project.ts";
19
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
20
+ export * from "./session.ts";
21
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
22
+ export * from "./settings.ts";
23
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
24
+ export * from "./settings-ui.ts";
25
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
26
+ export * from "./terminal.ts";
27
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
28
+ export * from "./tool-framework.ts";
29
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
30
+ export * from "./types.ts";
@@ -0,0 +1,11 @@
1
+ // supi-core config domain — config loading and config-settings helpers.
2
+ export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
3
+ export {
4
+ loadSupiConfig,
5
+ loadSupiConfigForScope,
6
+ readJsonFile,
7
+ removeSupiConfigKey,
8
+ writeSupiConfig,
9
+ } from "./config/config.ts";
10
+ export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
11
+ export { registerConfigSettings } from "./config/config-settings.ts";
@@ -0,0 +1,16 @@
1
+ // supi-core context domain — context messages, providers, and XML tags.
2
+ export type { ContextMessageLike } from "./context/context-messages.ts";
3
+ export {
4
+ findLastUserMessageIndex,
5
+ getContextToken,
6
+ getPromptContent,
7
+ pruneAndReorderContextMessages,
8
+ restorePromptContent,
9
+ } from "./context/context-messages.ts";
10
+ export type { ContextProvider } from "./context/context-provider-registry.ts";
11
+ export {
12
+ clearRegisteredContextProviders,
13
+ getRegisteredContextProviders,
14
+ registerContextProvider,
15
+ } from "./context/context-provider-registry.ts";
16
+ export { wrapExtensionContext } from "./context/context-tag.ts";
@@ -1,96 +1,30 @@
1
1
  // supi-core — shared infrastructure for SuPi extensions.
2
2
  // Provides XML context tag wrapping, unified config system, context-message utilities,
3
3
  // settings registry for supi-wide TUI settings, and a shared tool-spec/registration framework.
4
+ //
5
+ // Convenience barrel — re-exports all domain entry points.
6
+ // For lighter imports, use one of the domain subpaths directly
7
+ // (e.g. @mrclrchtr/supi-core/config, @mrclrchtr/supi-core/context).
4
8
 
5
- export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
6
- export {
7
- loadSupiConfig,
8
- loadSupiConfigForScope,
9
- readJsonFile,
10
- removeSupiConfigKey,
11
- writeSupiConfig,
12
- } from "./config/config.ts";
13
- export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
14
- export { registerConfigSettings } from "./config/config-settings.ts";
15
- export type { ContextMessageLike } from "./context/context-messages.ts";
16
- export {
17
- findLastUserMessageIndex,
18
- getContextToken,
19
- getPromptContent,
20
- pruneAndReorderContextMessages,
21
- restorePromptContent,
22
- } from "./context/context-messages.ts";
23
- export type { ContextProvider } from "./context/context-provider-registry.ts";
24
- export {
25
- clearRegisteredContextProviders,
26
- getRegisteredContextProviders,
27
- registerContextProvider,
28
- } from "./context/context-provider-registry.ts";
29
- export { wrapExtensionContext } from "./context/context-tag.ts";
30
- export type {
31
- DebugAgentAccess,
32
- DebugEvent,
33
- DebugEventInput,
34
- DebugEventQuery,
35
- DebugEventQueryResult,
36
- DebugEventView,
37
- DebugLevel,
38
- DebugNotifyLevel,
39
- DebugRegistryConfig,
40
- DebugSummary,
41
- } from "./debug-registry.ts";
42
- export {
43
- clearDebugEvents,
44
- configureDebugRegistry,
45
- DEBUG_REGISTRY_DEFAULTS,
46
- getDebugEvents,
47
- getDebugRegistryConfig,
48
- getDebugSummary,
49
- recordDebugEvent,
50
- redactDebugData,
51
- resetDebugRegistry,
52
- } from "./debug-registry.ts";
53
- export { fileToUri, resolveToolPath, stripToolPathPrefix, uriToFile } from "./path-utils.ts";
54
- export type { KnownRootEntry } from "./project-roots.ts";
55
- export {
56
- buildKnownRootsMap,
57
- byPathDepth,
58
- dedupeTopmostRoots,
59
- findProjectRoot,
60
- isWithin,
61
- isWithinOrEqual,
62
- mergeKnownRoots,
63
- resolveKnownRoot,
64
- segmentCount,
65
- sortRootsBySpecificity,
66
- walkProject,
67
- } from "./project-roots.ts";
68
- export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
69
- export { getActiveBranchEntries } from "./session-utils.ts";
70
- export { registerSettingsCommand } from "./settings/settings-command.ts";
71
- export type { SettingsScope, SettingsSection } from "./settings/settings-registry.ts";
72
- export {
73
- clearRegisteredSettings,
74
- getRegisteredSettings,
75
- registerSettings,
76
- } from "./settings/settings-registry.ts";
77
- export { createInputSubmenu, openSettingsOverlay } from "./settings/settings-ui.ts";
78
- export type { TitleTarget } from "./terminal.ts";
79
- export {
80
- DONE_SYMBOL,
81
- formatTitle,
82
- signalBell,
83
- signalDone,
84
- signalWaiting,
85
- WAITING_SYMBOL,
86
- } from "./terminal.ts";
87
- export type { SuiPiToolPromptSurface, SuiPiToolSpec, ToolExecuteFn } from "./tool-framework.ts";
88
- export {
89
- CharacterParam,
90
- derivePromptSurface,
91
- FileParam,
92
- LineParam,
93
- MaxResultsParam,
94
- registerSuiPiTools,
95
- SymbolParam,
96
- } from "./tool-framework.ts";
9
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
10
+ export * from "./config.ts";
11
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
12
+ export * from "./context.ts";
13
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
14
+ export * from "./debug-registry.ts";
15
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
16
+ export * from "./path.ts";
17
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
18
+ export * from "./project.ts";
19
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
20
+ export * from "./session.ts";
21
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
22
+ export * from "./settings.ts";
23
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
24
+ export * from "./settings-ui.ts";
25
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
26
+ export * from "./terminal.ts";
27
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
28
+ export * from "./tool-framework.ts";
29
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
30
+ export * from "./types.ts";
@@ -0,0 +1,2 @@
1
+ // supi-core path domain — file and URI path utilities.
2
+ export { fileToUri, resolveToolPath, stripToolPathPrefix, uriToFile } from "./path-utils.ts";
@@ -0,0 +1,15 @@
1
+ // supi-core project domain — project root discovery and traversal.
2
+ export type { KnownRootEntry } from "./project-roots.ts";
3
+ export {
4
+ buildKnownRootsMap,
5
+ byPathDepth,
6
+ dedupeTopmostRoots,
7
+ findProjectRoot,
8
+ isWithin,
9
+ isWithinOrEqual,
10
+ mergeKnownRoots,
11
+ resolveKnownRoot,
12
+ segmentCount,
13
+ sortRootsBySpecificity,
14
+ walkProject,
15
+ } from "./project-roots.ts";
@@ -0,0 +1,4 @@
1
+ // supi-core session domain — session utilities and registries.
2
+
3
+ export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
4
+ export { getActiveBranchEntries } from "./session-utils.ts";
@@ -0,0 +1,2 @@
1
+ // supi-core settings-ui domain — settings TUI components (imports pi-tui at runtime, heavy).
2
+ export { createInputSubmenu, openSettingsOverlay } from "./settings/settings-ui.ts";
@@ -0,0 +1,9 @@
1
+ // supi-core settings domain — settings registry (lightweight, type-only pi-tui import).
2
+
3
+ export { registerSettingsCommand } from "./settings/settings-command.ts";
4
+ export type { SettingsScope, SettingsSection } from "./settings/settings-registry.ts";
5
+ export {
6
+ clearRegisteredSettings,
7
+ getRegisteredSettings,
8
+ registerSettings,
9
+ } from "./settings/settings-registry.ts";
@@ -0,0 +1,11 @@
1
+ /** 0-based position used by LSP and code-intelligence internally. */
2
+ export interface CodePosition {
3
+ line: number;
4
+ character: number;
5
+ }
6
+
7
+ /** Normalized location — flat replacement for LSP's nested Location/range shape. */
8
+ export interface CodeLocation {
9
+ uri: string;
10
+ range: { start: CodePosition; end: CodePosition };
11
+ }
@@ -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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-tree-sitter",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "SuPi Tree-sitter extension — structural AST analysis for pi",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,7 +24,8 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "web-tree-sitter": "^0.26.8",
27
- "@mrclrchtr/supi-core": "1.7.0"
27
+ "@mrclrchtr/supi-code-runtime": "1.9.0",
28
+ "@mrclrchtr/supi-core": "1.9.0"
28
29
  },
29
30
  "peerDependencies": {
30
31
  "@earendil-works/pi-ai": "*",
@@ -44,18 +45,20 @@
44
45
  },
45
46
  "pi": {
46
47
  "extensions": [
47
- "./src/extension.ts",
48
- "node_modules/@mrclrchtr/supi-core/src/extension.ts"
49
- ]
48
+ "./src/extension.ts"
49
+ ],
50
+ "image": "https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-tree-sitter/assets/logo.png"
50
51
  },
51
52
  "bundledDependencies": [
53
+ "@mrclrchtr/supi-code-runtime",
52
54
  "@mrclrchtr/supi-core"
53
55
  ],
54
56
  "main": "src/api.ts",
55
57
  "exports": {
56
58
  "./api": "./src/api.ts",
57
59
  "./extension": "./src/extension.ts",
58
- "./package.json": "./package.json"
60
+ "./package.json": "./package.json",
61
+ "./provider/tree-sitter-provider": "./src/provider/tree-sitter-provider.ts"
59
62
  },
60
63
  "scripts": {
61
64
  "vendor:wasm": "node scripts/vendor-wasm.mjs",
@@ -0,0 +1,144 @@
1
+ // Structural provider adapter — wraps TreeSitterService into the shared
2
+ // StructuralProvider contract from supi-code-runtime.
3
+
4
+ import type {
5
+ CalleesData,
6
+ CodeResult,
7
+ ExportData,
8
+ ImportData,
9
+ NodeAtData,
10
+ OutlineData,
11
+ StructuralProvider,
12
+ } from "@mrclrchtr/supi-code-runtime/api";
13
+ import type {
14
+ CalleesAtResult,
15
+ ExportRecord,
16
+ ImportRecord,
17
+ NodeAtResult,
18
+ OutlineItem,
19
+ TreeSitterResult,
20
+ TreeSitterService,
21
+ } from "../types.ts";
22
+
23
+ /**
24
+ * Create a StructuralProvider backed by a TreeSitterService.
25
+ * Maps tree-sitter's nested `range` shapes into the flat range
26
+ * fields used by the shared code-runtime types.
27
+ */
28
+ export function createTreeSitterProvider(service: TreeSitterService): StructuralProvider {
29
+ return {
30
+ async calleesAt(file, line, character) {
31
+ const result = await service.calleesAt(file, line, character);
32
+ return mapTreeSitterResult(result, mapCalleesAtResult);
33
+ },
34
+
35
+ async exports(file) {
36
+ const result = await service.exports(file);
37
+ return mapTreeSitterResult(result, mapExportRecords);
38
+ },
39
+
40
+ async outline(file) {
41
+ const result = await service.outline(file);
42
+ return mapTreeSitterResult(result, mapOutlineItems);
43
+ },
44
+
45
+ async imports(file) {
46
+ const result = await service.imports(file);
47
+ return mapTreeSitterResult(result, mapImportRecords);
48
+ },
49
+
50
+ async nodeAt(file, line, character) {
51
+ const result = await service.nodeAt(file, line, character);
52
+ return mapTreeSitterResult(result, mapNodeAtResult);
53
+ },
54
+ };
55
+ }
56
+
57
+ // ── Generic result mapper ─────────────────────────────────────────────
58
+
59
+ function mapTreeSitterResult<T, U>(
60
+ result: TreeSitterResult<T>,
61
+ mapData: (data: T) => U,
62
+ ): CodeResult<U> {
63
+ switch (result.kind) {
64
+ case "success":
65
+ return { kind: "success", data: mapData(result.data) };
66
+ case "unsupported-language":
67
+ return { kind: "unsupported-language", file: result.file, message: result.message };
68
+ case "file-access-error":
69
+ return { kind: "file-access-error", file: result.file, message: result.message };
70
+ case "validation-error":
71
+ return { kind: "validation-error", message: result.message };
72
+ case "runtime-error":
73
+ return { kind: "runtime-error", message: result.message };
74
+ }
75
+ }
76
+
77
+ // ── Data mappers (nested range → flat fields) ─────────────────────────
78
+
79
+ type RangeLike = {
80
+ startLine: number;
81
+ startCharacter: number;
82
+ endLine: number;
83
+ endCharacter: number;
84
+ };
85
+
86
+ function takeRange(r: RangeLike) {
87
+ return {
88
+ startLine: r.startLine,
89
+ startCharacter: r.startCharacter,
90
+ endLine: r.endLine,
91
+ endCharacter: r.endCharacter,
92
+ };
93
+ }
94
+
95
+ function mapOutlineItems(items: OutlineItem[]): OutlineData[] {
96
+ return items.map((item) => ({
97
+ name: item.name,
98
+ kind: item.kind,
99
+ ...takeRange(item.range),
100
+ children: item.children ? mapOutlineItems(item.children) : undefined,
101
+ }));
102
+ }
103
+
104
+ function mapExportRecords(records: ExportRecord[]): ExportData[] {
105
+ return records.map((record) => ({
106
+ name: record.name,
107
+ kind: record.kind,
108
+ ...takeRange(record.range),
109
+ moduleSpecifier: record.moduleSpecifier,
110
+ }));
111
+ }
112
+
113
+ function mapImportRecords(records: ImportRecord[]): ImportData[] {
114
+ return records.map((record) => ({
115
+ moduleSpecifier: record.moduleSpecifier,
116
+ ...takeRange(record.range),
117
+ }));
118
+ }
119
+
120
+ function mapNodeAtResult(result: NodeAtResult): NodeAtData {
121
+ return {
122
+ type: result.type,
123
+ ...takeRange(result.range),
124
+ text: result.text,
125
+ ancestry: result.ancestry.map((a) => ({
126
+ type: a.type,
127
+ ...takeRange(a.range),
128
+ })),
129
+ };
130
+ }
131
+
132
+ function mapCalleesAtResult(result: CalleesAtResult): CalleesData {
133
+ return {
134
+ enclosingScope: {
135
+ name: result.enclosingScope.name,
136
+ startLine: result.enclosingScope.range.startLine,
137
+ endLine: result.enclosingScope.range.endLine,
138
+ },
139
+ callees: result.callees.map((c) => ({
140
+ name: c.name,
141
+ startLine: c.range.startLine,
142
+ })),
143
+ };
144
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Tree-sitter-to-runtime capability registration.
3
+ *
4
+ * Adapts a TreeSitterService into the runtime's StructuralProvider interface
5
+ * via the existing tree-sitter-provider adapter, and registers/unregisters it
6
+ * with the shared WorkspaceRuntime at session lifecycle boundaries.
7
+ */
8
+
9
+ import type { WorkspaceRuntime } from "@mrclrchtr/supi-code-runtime/api";
10
+ import { createTreeSitterProvider } from "../provider/tree-sitter-provider.ts";
11
+ import type { TreeSitterService } from "../types.ts";
12
+
13
+ /**
14
+ * Register tree-sitter structural capabilities for a workspace cwd.
15
+ *
16
+ * Wraps TreeSitterService into a StructuralProvider via the existing
17
+ * structural adapter and publishes it into the shared workspace runtime.
18
+ */
19
+ export function registerTreeSitterCapabilities(
20
+ runtime: WorkspaceRuntime,
21
+ cwd: string,
22
+ service: TreeSitterService,
23
+ ): void {
24
+ const provider = createTreeSitterProvider(service);
25
+ runtime.registerStructural(cwd, provider);
26
+ }
27
+
28
+ /**
29
+ * Unregister tree-sitter structural capabilities for a workspace cwd.
30
+ *
31
+ * Clears only the structural capability slot — semantic (LSP) state
32
+ * is left intact so that a tree-sitter session restart does not wipe
33
+ * LSP capabilities that were registered earlier in the same lifecycle.
34
+ */
35
+ export function unregisterTreeSitterCapabilities(runtime: WorkspaceRuntime, cwd: string): void {
36
+ runtime.clearStructural(cwd);
37
+ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
- import { resolveToolPath } from "@mrclrchtr/supi-core/api";
5
+ import { resolveToolPath } from "@mrclrchtr/supi-core/path";
6
6
  import type { Language, Parser, Tree } from "web-tree-sitter";
7
7
  import { nodeToRange } from "../coordinates.ts";
8
8
  import { detectGrammar, resolveGrammarWasmPath } from "../language.ts";
@@ -2,7 +2,7 @@
2
2
  // Peer extensions can import `getSessionTreeSitterService` from the package API
3
3
  // to reuse the active structural runtime without creating duplicate sessions.
4
4
 
5
- import { createSessionStateRegistry } from "@mrclrchtr/supi-core/api";
5
+ import { createSessionStateRegistry } from "@mrclrchtr/supi-core/session";
6
6
  import type { SessionTreeSitterService, SessionTreeSitterServiceState } from "../types.ts";
7
7
 
8
8
  const registry = createSessionStateRegistry<SessionTreeSitterServiceState>(