@mrclrchtr/supi-code-intelligence 6.1.0 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/README.md +3 -1
  2. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  3. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-core/src/debug-identity.ts +11 -0
  5. package/node_modules/@mrclrchtr/supi-core/src/debug.ts +5 -0
  6. package/node_modules/@mrclrchtr/supi-lsp/README.md +23 -3
  7. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  8. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  9. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-identity.ts +11 -0
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug.ts +5 -0
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/README.md +52 -0
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.js +785 -129
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/legacy.js +660 -98
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/package.json +10 -4
  15. package/node_modules/@mrclrchtr/supi-lsp/package.json +4 -5
  16. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +16 -7
  17. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +1 -1
  18. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +0 -5
  19. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-publication.ts +6 -3
  20. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +2 -1
  21. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +5 -2
  22. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +2 -1
  23. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +17 -5
  24. package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +40 -18
  25. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +164 -30
  26. package/node_modules/@mrclrchtr/supi-lsp/src/config/lsp-settings.ts +9 -87
  27. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +0 -1
  28. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +4 -5
  29. package/node_modules/@mrclrchtr/supi-lsp/src/config/types.ts +0 -29
  30. package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +7 -21
  31. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-severity.ts +6 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-summary.ts +11 -14
  33. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +0 -5
  34. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/stale-diagnostics.ts +0 -1
  35. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/workspace-sentinels.ts +29 -49
  36. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +1 -1
  37. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +4 -8
  38. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-helpers.ts +1 -9
  39. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-process-crash-report.ts +106 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +6 -3
  41. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +9 -1
  42. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +26 -41
  43. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +577 -152
  44. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +4 -1
  45. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +59 -28
  46. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +27 -19
  47. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +54 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registration.ts +0 -17
  49. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +74 -19
  50. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +5 -2
  51. package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +24 -21
  52. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +29 -3
  53. package/node_modules/@mrclrchtr/supi-lsp/src/summary.ts +19 -40
  54. package/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +13 -19
  55. package/node_modules/@mrclrchtr/supi-lsp/src/workspace-path-policy.ts +296 -0
  56. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +6 -18
  57. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  58. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  59. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-identity.ts +11 -0
  60. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug.ts +5 -0
  61. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/README.md +29 -1
  62. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +99 -19
  63. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +4 -4
  64. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +94 -18
  65. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +4 -4
  66. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  67. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +14 -14
  68. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +13 -8
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +97 -19
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +4 -4
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +28 -8
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +1 -1
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +28 -8
  74. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +1 -1
  75. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +92 -18
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +4 -4
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +17 -17
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +7 -6
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm +0 -0
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +2 -2
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm +0 -0
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +2 -2
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +1 -11
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/src/coordinates.ts +19 -0
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +5 -23
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/src/operation-support.ts +3 -21
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +5 -9
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +10 -20
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +7 -1
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +9 -5
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +134 -9
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-name.ts +96 -0
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +11 -12
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +39 -56
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +9 -7
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/js-binding-pattern.ts +26 -0
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +2 -21
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-html-sql.ts +144 -12
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline.ts +50 -37
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/scope.ts +138 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +0 -7
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store.ts +1 -14
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +0 -10
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +6 -8
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +34 -10
  107. package/package.json +5 -5
  108. package/src/analysis/capability/capability-warnings.ts +4 -22
  109. package/src/analysis/search/ast-scan-timing.ts +4 -2
  110. package/src/analysis/search/ast-scan.ts +1 -1
  111. package/src/api.ts +1 -0
  112. package/src/extension.ts +4 -2
  113. package/src/session/health-refresh.ts +26 -2
  114. package/src/session/health-types.ts +19 -0
  115. package/src/session/input/health-refactor.ts +16 -14
  116. package/src/session/refactor-types.ts +14 -1
  117. package/src/session/refactor-workflow.ts +21 -16
  118. package/src/substrate/lsp/lifecycle.ts +0 -3
  119. package/src/substrate/lsp/maintenance.ts +4 -5
  120. package/src/substrate/lsp/settings.ts +7 -9
  121. package/src/substrate/lsp/state.ts +0 -2
  122. package/src/substrate/workspace-provider-host.ts +2 -2
  123. package/src/tool/code_health/file-scope-markdown.ts +43 -0
  124. package/src/tool/code_health/markdown.ts +66 -66
  125. package/src/tool/code_health/refresh-outcome.ts +76 -0
  126. package/src/tool/code_health/refresh-status.ts +212 -23
  127. package/src/tool/code_health/result.ts +1 -0
  128. package/src/tool/code_health/tui.ts +18 -5
  129. package/src/tool/code_refactor_apply/guidance.ts +3 -2
  130. package/src/tool/code_refactor_plan/guidance.ts +1 -1
  131. package/src/tool/register.ts +5 -2
  132. package/src/tool/schemas.ts +21 -11
  133. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-actions.ts +0 -59
  134. package/node_modules/@mrclrchtr/supi-lsp/src/pattern-matcher.ts +0 -24
  135. package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/generate-kotlin-wasm.mjs +0 -132
  136. package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/generate-sql-wasm.mjs +0 -158
  137. package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/vendor-wasm.mjs +0 -167
  138. package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +0 -42
  139. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-registration.ts +0 -37
  140. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/service-registry.ts +0 -30
  141. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/structure.ts +0 -8
@@ -1,7 +1,10 @@
1
1
  import { createHmac, randomBytes } from "node:crypto";
2
2
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
3
- import { recordDebugEvent, startDebugTimer } from "@mrclrchtr/supi-core/debug";
4
- import { truncateIdentity } from "@mrclrchtr/supi-lsp/debug-telemetry";
3
+ import {
4
+ recordDebugEvent,
5
+ startDebugTimer,
6
+ truncateDebugIdentity as truncateIdentity,
7
+ } from "@mrclrchtr/supi-core/debug";
5
8
  import type { WorkspaceCodeIntelligenceSession } from "../session/session.ts";
6
9
  import {
7
10
  CODE_INTELLIGENCE_TOOL_PROMPT_SURFACES,
@@ -1,5 +1,9 @@
1
1
  import { StringEnum } from "@earendil-works/pi-ai";
2
2
  import { type TSchema, Type } from "typebox";
3
+ import {
4
+ PUBLIC_REFACTOR_OPERATION_NAMES,
5
+ type PublicRefactorOperationName,
6
+ } from "../session/refactor-types.ts";
3
7
  import { TARGET_SYMBOL_KINDS } from "../session/target-input.ts";
4
8
 
5
9
  export const ScopeParam = Type.String({
@@ -127,18 +131,24 @@ const RangeParam = Type.Object(
127
131
 
128
132
  const NewNameParam = Type.String({ description: "New symbol name.", minLength: 1 });
129
133
 
134
+ const RefactorOperationProperties = {
135
+ rename_symbol: Type.Object({ newName: NewNameParam }, { additionalProperties: false }),
136
+ extract_function: Type.Object(
137
+ { newName: NewNameParam, range: RangeParam },
138
+ { additionalProperties: false },
139
+ ),
140
+ extract_variable: Type.Object(
141
+ { newName: NewNameParam, range: RangeParam },
142
+ { additionalProperties: false },
143
+ ),
144
+ update_imports: Type.Object({}, { additionalProperties: false }),
145
+ delete_dead_code: Type.Object({}, { additionalProperties: false }),
146
+ } satisfies Record<PublicRefactorOperationName, TSchema>;
147
+
130
148
  export const RefactorOperationParam = exactOneSelector(
131
- {
132
- rename_symbol: Type.Object({ newName: NewNameParam }, { additionalProperties: false }),
133
- extract_function: Type.Object(
134
- { newName: NewNameParam, range: RangeParam },
135
- { additionalProperties: false },
136
- ),
137
- extract_variable: Type.Object(
138
- { newName: NewNameParam, range: RangeParam },
139
- { additionalProperties: false },
140
- ),
141
- },
149
+ Object.fromEntries(
150
+ PUBLIC_REFACTOR_OPERATION_NAMES.map((name) => [name, RefactorOperationProperties[name]]),
151
+ ),
142
152
  "Exactly one refactor operation.",
143
153
  );
144
154
 
@@ -1,59 +0,0 @@
1
- // Server capability action label helpers — maps LSP capabilities to readable action labels.
2
-
3
- import type { ServerCapabilities } from "../config/types.ts";
4
-
5
- interface LspServerSupportedActionSpec {
6
- label: string;
7
- isSupported: (capabilities: ServerCapabilities | null | undefined) => boolean;
8
- }
9
-
10
- const LSP_SERVER_SUPPORTED_ACTION_SPECS: readonly LspServerSupportedActionSpec[] = [
11
- {
12
- label: "diagnostics [optional file]",
13
- isSupported: () => true,
14
- },
15
- {
16
- label: "hover(file,line,char)",
17
- isSupported: (capabilities) => Boolean(capabilities?.hoverProvider),
18
- },
19
- {
20
- label: "definition(file,line,char)",
21
- isSupported: (capabilities) => Boolean(capabilities?.definitionProvider),
22
- },
23
- {
24
- label: "references(file,line,char)",
25
- isSupported: (capabilities) => Boolean(capabilities?.referencesProvider),
26
- },
27
- {
28
- label: "implementation(file,line,char)",
29
- isSupported: (capabilities) => Boolean(capabilities?.implementationProvider),
30
- },
31
- {
32
- label: "symbols(file)",
33
- isSupported: (capabilities) => Boolean(capabilities?.documentSymbolProvider),
34
- },
35
- {
36
- label: "workspace_symbols(query)",
37
- isSupported: (capabilities) => Boolean(capabilities?.workspaceSymbolProvider),
38
- },
39
- {
40
- label: "rename(file,line,char,newName)",
41
- isSupported: (capabilities) => Boolean(capabilities?.renameProvider),
42
- },
43
- {
44
- label: "code_actions(file,line,char)",
45
- isSupported: (capabilities) => Boolean(capabilities?.codeActionProvider),
46
- },
47
- ] as const;
48
-
49
- /**
50
- * Get the list of supported LSP server actions based on capabilities.
51
- */
52
- export function getSupportedLspServerActions(
53
- capabilities: ServerCapabilities | null | undefined,
54
- ): string[] {
55
- if (!capabilities) return [];
56
- return LSP_SERVER_SUPPORTED_ACTION_SPECS.filter((spec) => spec.isSupported(capabilities)).map(
57
- (spec) => spec.label,
58
- );
59
- }
@@ -1,24 +0,0 @@
1
- import ignore from "ignore";
2
-
3
- /** Gitignore-style glob pattern matching for path exclusion.
4
- *
5
- * Delegates to the {@link https://github.com/kaelzhang/node-ignore | ignore} package,
6
- * which provides battle-tested .gitignore semantics used by ESLint, Prettier, and others.
7
- *
8
- * Supports full gitignore syntax: literal names, `*` / `?` wildcards, `**` recursive globs,
9
- * leading `/` anchored patterns, trailing `/` directory-only patterns, and `!` negation.
10
- *
11
- * **Note:** Patterns that start with `#` are treated as comments unless escaped with `\#`.
12
- */
13
-
14
- /**
15
- * Check whether a project-relative file path matches a gitignore-style glob pattern.
16
- *
17
- * @param filePath - Relative file path with forward slashes (e.g. `"src/__tests__/bar.test.ts"`)
18
- * @param pattern - Gitignore-style glob pattern (e.g. `"__tests__/"`, `"*.test.ts"`, `"/build"`)
19
- * @returns `true` if the file path matches the pattern
20
- */
21
- export function isGlobMatch(filePath: string, pattern: string): boolean {
22
- if (!filePath || !pattern) return false;
23
- return ignore().add(pattern).ignores(filePath);
24
- }
@@ -1,132 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawnSync } from "node:child_process";
4
- import { createHash } from "node:crypto";
5
- import * as fs from "node:fs";
6
- import { createRequire } from "node:module";
7
- import * as os from "node:os";
8
- import * as path from "node:path";
9
- import { fileURLToPath } from "node:url";
10
-
11
- const require = createRequire(import.meta.url);
12
- const scriptDir = path.dirname(fileURLToPath(import.meta.url));
13
- const packageRoot = path.resolve(scriptDir, "..");
14
- const wasmDir = path.join(packageRoot, "resources", "grammars", "kotlin");
15
- const wasmPath = path.join(wasmDir, "tree-sitter-kotlin.wasm");
16
- const metadataPath = path.join(wasmDir, "tree-sitter-kotlin.wasm.json");
17
- const checkMode = process.argv.includes("--check");
18
-
19
- function readPackage(packageName) {
20
- const packageJsonPath = require.resolve(`${packageName}/package.json`);
21
- return {
22
- dir: path.dirname(packageJsonPath),
23
- json: JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")),
24
- };
25
- }
26
-
27
- function sha256(filePath) {
28
- return createHash("sha256").update(fs.readFileSync(filePath)).digest("hex");
29
- }
30
-
31
- function readMetadata() {
32
- return JSON.parse(fs.readFileSync(metadataPath, "utf-8"));
33
- }
34
-
35
- function expectedReleaseAsset(version) {
36
- return `https://github.com/fwcd/tree-sitter-kotlin/releases/download/${version}/tree-sitter-kotlin.wasm`;
37
- }
38
-
39
- function assertKotlinWasmCurrent() {
40
- const kotlinPackage = readPackage("tree-sitter-kotlin");
41
- const cliPackage = readPackage("tree-sitter-cli");
42
- const metadata = readMetadata();
43
- const actualSha = sha256(wasmPath);
44
- const errors = [];
45
-
46
- if (metadata.source?.npmPackage !== "tree-sitter-kotlin") {
47
- errors.push("metadata source package must be tree-sitter-kotlin");
48
- }
49
- if (metadata.source?.version !== kotlinPackage.json.version) {
50
- errors.push(
51
- `metadata pins tree-sitter-kotlin ${metadata.source?.version}, but installed package is ${kotlinPackage.json.version}`,
52
- );
53
- }
54
- if (metadata.source?.releaseAsset !== expectedReleaseAsset(kotlinPackage.json.version)) {
55
- errors.push(
56
- "metadata release asset URL does not match the installed tree-sitter-kotlin version",
57
- );
58
- }
59
- if (metadata.generatedWith?.treeSitterCli !== cliPackage.json.version) {
60
- errors.push(
61
- `metadata pins tree-sitter-cli ${metadata.generatedWith?.treeSitterCli}, but installed CLI is ${cliPackage.json.version}`,
62
- );
63
- }
64
- if (metadata.sha256 !== actualSha) {
65
- errors.push(`metadata sha256 ${metadata.sha256} does not match vendored file ${actualSha}`);
66
- }
67
-
68
- if (errors.length > 0) {
69
- throw new Error(
70
- `Vendored Kotlin Tree-sitter WASM is stale:\n- ${errors.join("\n- ")}\nRun: pnpm --filter @mrclrchtr/supi-tree-sitter generate:kotlin-wasm`,
71
- );
72
- }
73
-
74
- process.stdout.write(
75
- `Kotlin Tree-sitter WASM is current (${kotlinPackage.json.version}, ${actualSha}).\n`,
76
- );
77
- }
78
-
79
- function generateKotlinWasm() {
80
- const kotlinPackage = readPackage("tree-sitter-kotlin");
81
- const cliPackage = readPackage("tree-sitter-cli");
82
- const cliPath = path.join(cliPackage.dir, "cli.js");
83
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "supi-kotlin-wasm-"));
84
- const grammarDir = path.join(tempRoot, "tree-sitter-kotlin");
85
-
86
- try {
87
- fs.cpSync(kotlinPackage.dir, grammarDir, { recursive: true });
88
- const result = spawnSync(process.execPath, [cliPath, "build", "--wasm"], {
89
- cwd: grammarDir,
90
- stdio: "inherit",
91
- });
92
-
93
- if (result.status !== 0) {
94
- throw new Error(
95
- "tree-sitter build --wasm failed. Install Docker or Emscripten, then rerun generate:kotlin-wasm.",
96
- );
97
- }
98
-
99
- const generatedWasmPath = path.join(grammarDir, "tree-sitter-kotlin.wasm");
100
- if (!fs.existsSync(generatedWasmPath)) {
101
- throw new Error(`Expected generated WASM at ${generatedWasmPath}`);
102
- }
103
-
104
- fs.mkdirSync(wasmDir, { recursive: true });
105
- fs.copyFileSync(generatedWasmPath, wasmPath);
106
-
107
- const checksum = sha256(wasmPath);
108
- const metadata = {
109
- source: {
110
- npmPackage: "tree-sitter-kotlin",
111
- version: kotlinPackage.json.version,
112
- repository: "https://github.com/fwcd/tree-sitter-kotlin",
113
- releaseAsset: expectedReleaseAsset(kotlinPackage.json.version),
114
- },
115
- generatedWith: {
116
- treeSitterCli: cliPackage.json.version,
117
- },
118
- sha256: checksum,
119
- };
120
- fs.writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}\n`);
121
- process.stdout.write(`Generated ${wasmPath}\n`);
122
- process.stdout.write(`SHA256 ${checksum}\n`);
123
- } finally {
124
- fs.rmSync(tempRoot, { recursive: true, force: true });
125
- }
126
- }
127
-
128
- if (checkMode) {
129
- assertKotlinWasmCurrent();
130
- } else {
131
- generateKotlinWasm();
132
- }
@@ -1,158 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * SQL Tree-sitter WASM generator
4
- *
5
- * Rebuilds the vendored SQL grammar WASM from the @derekstride/tree-sitter-sql
6
- * npm package. This package is a devDependency ONLY — the vendored WASM is the
7
- * sole runtime artifact. The npm package is never resolved at runtime.
8
- *
9
- * Trust considerations:
10
- * - The @derekstride/tree-sitter-sql install script uses "npx --yes", which
11
- * some package managers flag as a supply-chain risk. This workspace disables
12
- * that package's build script explicitly via pnpm `allowBuilds`.
13
- * - The WASM is built locally from the installed package source (not downloaded
14
- * from npm). The build uses tree-sitter-cli with Emscripten/Docker.
15
- * - Alternatives considered: tree-sitter-sql (m-novikov, stale since 2021),
16
- * tree-sitter-sql-bigquery (dialect-specific), and dialect-specific grammars.
17
- * derekstride/tree-sitter-sql is the most mature general-purpose SQL grammar.
18
- *
19
- * Usage:
20
- * pnpm --filter @mrclrchtr/supi-tree-sitter generate:sql-wasm
21
- * pnpm --filter @mrclrchtr/supi-tree-sitter check:sql-wasm
22
- */
23
-
24
- import { spawnSync } from "node:child_process";
25
- import { createHash } from "node:crypto";
26
- import * as fs from "node:fs";
27
- import { createRequire } from "node:module";
28
- import * as os from "node:os";
29
- import * as path from "node:path";
30
- import { fileURLToPath } from "node:url";
31
-
32
- const require = createRequire(import.meta.url);
33
- const scriptDir = path.dirname(fileURLToPath(import.meta.url));
34
- const packageRoot = path.resolve(scriptDir, "..");
35
- const wasmDir = path.join(packageRoot, "resources", "grammars", "sql");
36
- const wasmPath = path.join(wasmDir, "tree-sitter-sql.wasm");
37
- const metadataPath = path.join(wasmDir, "tree-sitter-sql.wasm.json");
38
- const checkMode = process.argv.includes("--check");
39
-
40
- function readPackage(packageName) {
41
- const packageJsonPath = require.resolve(`${packageName}/package.json`);
42
- return {
43
- dir: path.dirname(packageJsonPath),
44
- json: JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")),
45
- };
46
- }
47
-
48
- function sha256(filePath) {
49
- return createHash("sha256").update(fs.readFileSync(filePath)).digest("hex");
50
- }
51
-
52
- function readMetadata() {
53
- return JSON.parse(fs.readFileSync(metadataPath, "utf-8"));
54
- }
55
-
56
- function assertSqlWasmCurrent() {
57
- const sqlPackage = readPackage("@derekstride/tree-sitter-sql");
58
- const cliPackage = readPackage("tree-sitter-cli");
59
- const metadata = readMetadata();
60
- const actualSha = sha256(wasmPath);
61
- const errors = [];
62
-
63
- if (metadata.source?.npmPackage !== "@derekstride/tree-sitter-sql") {
64
- errors.push("metadata source package must be @derekstride/tree-sitter-sql");
65
- }
66
- if (metadata.source?.version !== sqlPackage.json.version) {
67
- errors.push(
68
- `metadata pins @derekstride/tree-sitter-sql ${metadata.source?.version}, but installed package is ${sqlPackage.json.version}`,
69
- );
70
- }
71
- if (metadata.generatedWith?.treeSitterCli !== cliPackage.json.version) {
72
- errors.push(
73
- `metadata pins tree-sitter-cli ${metadata.generatedWith?.treeSitterCli}, but installed CLI is ${cliPackage.json.version}`,
74
- );
75
- }
76
- if (metadata.sha256 !== actualSha) {
77
- errors.push(`metadata sha256 ${metadata.sha256} does not match vendored file ${actualSha}`);
78
- }
79
-
80
- if (errors.length > 0) {
81
- throw new Error(
82
- `Vendored SQL Tree-sitter WASM is stale:\n- ${errors.join("\n- ")}\nRun: pnpm --filter @mrclrchtr/supi-tree-sitter generate:sql-wasm`,
83
- );
84
- }
85
-
86
- process.stdout.write(
87
- `SQL Tree-sitter WASM is current (${sqlPackage.json.version}, ${actualSha}).\n`,
88
- );
89
- }
90
-
91
- function generateSqlWasm() {
92
- const sqlPackage = readPackage("@derekstride/tree-sitter-sql");
93
- const cliPackage = readPackage("tree-sitter-cli");
94
- const cliPath = path.join(cliPackage.dir, "cli.js");
95
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "supi-sql-wasm-"));
96
- const grammarDir = path.join(tempRoot, "tree-sitter-sql");
97
-
98
- try {
99
- fs.cpSync(sqlPackage.dir, grammarDir, { recursive: true });
100
-
101
- // tree-sitter-cli requires a "tree-sitter" section in package.json
102
- const grammarPackageJsonPath = path.join(grammarDir, "package.json");
103
- const grammarPackageJson = JSON.parse(fs.readFileSync(grammarPackageJsonPath, "utf-8"));
104
- grammarPackageJson["tree-sitter"] = [{ scope: "source.sql" }];
105
- fs.writeFileSync(grammarPackageJsonPath, JSON.stringify(grammarPackageJson, null, 2));
106
-
107
- const result = spawnSync(process.execPath, [cliPath, "build", "--wasm"], {
108
- cwd: grammarDir,
109
- stdio: "inherit",
110
- });
111
-
112
- if (result.status !== 0) {
113
- throw new Error(
114
- "tree-sitter build --wasm failed. Install Docker or Emscripten, then rerun generate:sql-wasm.",
115
- );
116
- }
117
-
118
- const generatedWasmPath = path.join(grammarDir, "tree-sitter-sql.wasm");
119
- if (!fs.existsSync(generatedWasmPath)) {
120
- throw new Error(`Expected generated WASM at ${generatedWasmPath}`);
121
- }
122
-
123
- fs.mkdirSync(wasmDir, { recursive: true });
124
- fs.copyFileSync(generatedWasmPath, wasmPath);
125
-
126
- const checksum = sha256(wasmPath);
127
- const metadata = {
128
- source: {
129
- npmPackage: "@derekstride/tree-sitter-sql",
130
- version: sqlPackage.json.version,
131
- repository: "https://github.com/derekstride/tree-sitter-sql",
132
- },
133
- generatedWith: {
134
- treeSitterCli: cliPackage.json.version,
135
- },
136
- sha256: checksum,
137
- trust: {
138
- note: "The @derekstride/tree-sitter-sql npm package is a devDependency only. It is never resolved at runtime; the vendored WASM above is the sole runtime artifact. This workspace explicitly disables the package's npx-based install script via pnpm allowBuilds. The WASM was built locally from the installed package source. See scripts/generate-sql-wasm.mjs for the rebuild procedure.",
139
- alternativesConsidered: [
140
- "tree-sitter-sql (m-novikov, 2021, stale)",
141
- "tree-sitter-sql-bigquery (BigQuery-specific)",
142
- "dialect-specific grammars (too narrow)",
143
- ],
144
- },
145
- };
146
- fs.writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}\n`);
147
- process.stdout.write(`Generated ${wasmPath}\n`);
148
- process.stdout.write(`SHA256 ${checksum}\n`);
149
- } finally {
150
- fs.rmSync(tempRoot, { recursive: true, force: true });
151
- }
152
- }
153
-
154
- if (checkMode) {
155
- assertSqlWasmCurrent();
156
- } else {
157
- generateSqlWasm();
158
- }
@@ -1,167 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Vendors Tree-sitter grammar WASM files from their installed npm packages
4
- * into the package's resources/ directory.
5
- *
6
- * Grammars whose npm packages ship pre-built WASM files are copied directly.
7
- * Kotlin and SQL are handled by dedicated generator scripts because their
8
- * npm packages do not include WASM files.
9
- *
10
- * Usage:
11
- * node scripts/vendor-wasm.mjs # Copy WASM files
12
- * node scripts/vendor-wasm.mjs --check # Verify checksums
13
- */
14
-
15
- import { createHash } from "node:crypto";
16
- import * as fs from "node:fs";
17
- import { createRequire } from "node:module";
18
- import * as path from "node:path";
19
- import { fileURLToPath } from "node:url";
20
-
21
- const require = createRequire(import.meta.url);
22
- const scriptDir = path.dirname(fileURLToPath(import.meta.url));
23
- const packageRoot = path.resolve(scriptDir, "..");
24
- const resourcesDir = path.join(packageRoot, "resources", "grammars");
25
- const checkMode = process.argv.includes("--check");
26
-
27
- /**
28
- * Map: grammarId → { npmPackage, wasmFile }
29
- * Only grammars whose npm packages ship .wasm files belong here.
30
- * Kotlin and SQL use dedicated generator scripts (generate-kotlin-wasm.mjs,
31
- * generate-sql-wasm.mjs) because their packages do not include WASM.
32
- */
33
- const GRAMMAR_SOURCES = {
34
- javascript: { npmPackage: "tree-sitter-javascript", wasmFile: "tree-sitter-javascript.wasm" },
35
- typescript: { npmPackage: "tree-sitter-typescript", wasmFile: "tree-sitter-typescript.wasm" },
36
- tsx: { npmPackage: "tree-sitter-typescript", wasmFile: "tree-sitter-tsx.wasm" },
37
- python: { npmPackage: "tree-sitter-python", wasmFile: "tree-sitter-python.wasm" },
38
- rust: { npmPackage: "tree-sitter-rust", wasmFile: "tree-sitter-rust.wasm" },
39
- go: { npmPackage: "tree-sitter-go", wasmFile: "tree-sitter-go.wasm" },
40
- c: { npmPackage: "tree-sitter-c", wasmFile: "tree-sitter-c.wasm" },
41
- cpp: { npmPackage: "tree-sitter-cpp", wasmFile: "tree-sitter-cpp.wasm" },
42
- java: { npmPackage: "tree-sitter-java", wasmFile: "tree-sitter-java.wasm" },
43
- ruby: { npmPackage: "tree-sitter-ruby", wasmFile: "tree-sitter-ruby.wasm" },
44
- bash: { npmPackage: "tree-sitter-bash", wasmFile: "tree-sitter-bash.wasm" },
45
- html: { npmPackage: "tree-sitter-html", wasmFile: "tree-sitter-html.wasm" },
46
- r: { npmPackage: "@davisvaughan/tree-sitter-r", wasmFile: "tree-sitter-r.wasm" },
47
- };
48
-
49
- function sha256(filePath) {
50
- return createHash("sha256").update(fs.readFileSync(filePath)).digest("hex");
51
- }
52
-
53
- function readPackage(packageName) {
54
- const packageJsonPath = require.resolve(`${packageName}/package.json`);
55
- return {
56
- dir: path.dirname(packageJsonPath),
57
- json: JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")),
58
- };
59
- }
60
-
61
- function vendorGrammar(grammarId, source) {
62
- const pkg = readPackage(source.npmPackage);
63
- const srcWasmPath = path.join(pkg.dir, source.wasmFile);
64
-
65
- if (!fs.existsSync(srcWasmPath)) {
66
- throw new Error(
67
- `WASM file not found in ${source.npmPackage} at ${srcWasmPath}. ` +
68
- `Ensure the package is installed (pnpm install) and ships a .wasm file.`,
69
- );
70
- }
71
-
72
- const grammarDir = path.join(resourcesDir, grammarId);
73
- const destWasmPath = path.join(grammarDir, source.wasmFile);
74
- const metadataPath = path.join(grammarDir, `${source.wasmFile}.json`);
75
-
76
- fs.mkdirSync(grammarDir, { recursive: true });
77
- fs.copyFileSync(srcWasmPath, destWasmPath);
78
-
79
- const checksum = sha256(destWasmPath);
80
- const metadata = {
81
- source: {
82
- npmPackage: source.npmPackage,
83
- version: pkg.json.version,
84
- },
85
- sha256: checksum,
86
- };
87
- fs.writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}\n`);
88
-
89
- process.stdout.write(
90
- `${grammarId}: ${source.wasmFile} (${source.npmPackage} ${pkg.json.version}, ${checksum})\n`,
91
- );
92
- }
93
-
94
- function checkGrammar(grammarId, source) {
95
- const grammarDir = path.join(resourcesDir, grammarId);
96
- const wasmPath = path.join(grammarDir, source.wasmFile);
97
- const metadataPath = path.join(grammarDir, `${source.wasmFile}.json`);
98
- const errors = [];
99
-
100
- if (!fs.existsSync(wasmPath)) {
101
- errors.push(`${grammarId}: missing vendored WASM at ${wasmPath}`);
102
- return errors;
103
- }
104
- if (!fs.existsSync(metadataPath)) {
105
- errors.push(`${grammarId}: missing metadata at ${metadataPath}`);
106
- return errors;
107
- }
108
-
109
- try {
110
- const pkg = readPackage(source.npmPackage);
111
- const sourceWasmPath = path.join(pkg.dir, source.wasmFile);
112
- if (!fs.existsSync(sourceWasmPath)) {
113
- errors.push(`${grammarId}: installed package is missing ${source.wasmFile}`);
114
- return errors;
115
- }
116
- const metadata = JSON.parse(fs.readFileSync(metadataPath, "utf-8"));
117
- const actualSha = sha256(wasmPath);
118
- const sourceSha = sha256(sourceWasmPath);
119
-
120
- if (metadata.source?.npmPackage !== source.npmPackage) {
121
- errors.push(`${grammarId}: metadata source npmPackage mismatch`);
122
- }
123
- if (metadata.source?.version !== pkg.json.version) {
124
- errors.push(
125
- `${grammarId}: metadata version ${metadata.source?.version} !== installed ${pkg.json.version}`,
126
- );
127
- }
128
- if (actualSha !== sourceSha) {
129
- errors.push(
130
- `${grammarId}: vendored sha256 ${actualSha} !== installed package source ${sourceSha}`,
131
- );
132
- }
133
- if (metadata.sha256 !== actualSha) {
134
- errors.push(`${grammarId}: metadata sha256 ${metadata.sha256} !== vendored ${actualSha}`);
135
- }
136
- if (metadata.sha256 !== sourceSha) {
137
- errors.push(
138
- `${grammarId}: metadata sha256 ${metadata.sha256} !== installed package source ${sourceSha}`,
139
- );
140
- }
141
- } catch (err) {
142
- errors.push(`${grammarId}: ${err.message}`);
143
- }
144
-
145
- return errors;
146
- }
147
-
148
- // Main
149
- if (checkMode) {
150
- let allErrors = [];
151
- for (const [grammarId, source] of Object.entries(GRAMMAR_SOURCES)) {
152
- const errors = checkGrammar(grammarId, source);
153
- allErrors = allErrors.concat(errors);
154
- }
155
-
156
- if (allErrors.length > 0) {
157
- throw new Error(
158
- `Vendored WASM checks failed:\n- ${allErrors.join("\n- ")}\nRun: node scripts/vendor-wasm.mjs`,
159
- );
160
- }
161
- process.stdout.write("All vendored WASM files are current.\n");
162
- } else {
163
- for (const [grammarId, source] of Object.entries(GRAMMAR_SOURCES)) {
164
- vendorGrammar(grammarId, source);
165
- }
166
- process.stdout.write("All vendored WASM files generated.\n");
167
- }
@@ -1,42 +0,0 @@
1
- // Public session factory, shared session service access, and re-exports for @mrclrchtr/supi-tree-sitter.
2
- //
3
- // This package is library-only — no pi extension surface.
4
- // Tool handler string-formatting lives in @mrclrchtr/supi-code-intelligence.
5
-
6
- // Language detection helpers
7
- export {
8
- detectGrammar,
9
- getSupportedExtension,
10
- getSupportedExtensions,
11
- isJsTsGrammar,
12
- isSupportedFile,
13
- } from "./language.ts";
14
- export type { StructuralSearchOperation } from "./operation-support.ts";
15
- export { getStructuralSearchSupportedExtensions } from "./operation-support.ts";
16
- // Provider implementation
17
- export { createTreeSitterProvider } from "./provider/tree-sitter-provider.ts";
18
- export type {
19
- TsControllerState,
20
- TsStartResult,
21
- } from "./session/runtime-controller.ts";
22
- export { TreeSitterRuntimeController } from "./session/runtime-controller.ts";
23
- export { getSessionTreeSitterService } from "./session/service-registry.ts";
24
- export { createTreeSitterSession } from "./session/session.ts";
25
- // Shared types
26
- export type {
27
- CalleesAtResult,
28
- CallSiteMatch,
29
- ExportRecord,
30
- GrammarId,
31
- ImportRecord,
32
- NodeAtResult,
33
- OutlineItem,
34
- QueryCapture,
35
- SessionTreeSitterService,
36
- SessionTreeSitterServiceState,
37
- SourceRange,
38
- SupportedExtension,
39
- TreeSitterResult,
40
- TreeSitterService,
41
- TreeSitterSession,
42
- } from "./types.ts";
@@ -1,37 +0,0 @@
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
- }