@mrclrchtr/supi-code-intelligence 0.1.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 (146) hide show
  1. package/README.md +212 -0
  2. package/node_modules/@mrclrchtr/supi-core/README.md +90 -0
  3. package/node_modules/@mrclrchtr/supi-core/package.json +30 -0
  4. package/node_modules/@mrclrchtr/supi-core/src/config-settings.ts +76 -0
  5. package/node_modules/@mrclrchtr/supi-core/src/config.ts +186 -0
  6. package/node_modules/@mrclrchtr/supi-core/src/context-messages.ts +119 -0
  7. package/node_modules/@mrclrchtr/supi-core/src/context-provider-registry.ts +36 -0
  8. package/node_modules/@mrclrchtr/supi-core/src/context-tag.ts +31 -0
  9. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +255 -0
  10. package/node_modules/@mrclrchtr/supi-core/src/index.ts +83 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/project-roots.ts +170 -0
  12. package/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +54 -0
  13. package/node_modules/@mrclrchtr/supi-core/src/session-utils.ts +29 -0
  14. package/node_modules/@mrclrchtr/supi-core/src/settings-command.ts +15 -0
  15. package/node_modules/@mrclrchtr/supi-core/src/settings-registry.ts +41 -0
  16. package/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +226 -0
  17. package/node_modules/@mrclrchtr/supi-core/src/terminal.ts +60 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/README.md +112 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +90 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +30 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config-settings.ts +76 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +186 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/context-messages.ts +119 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/context-provider-registry.ts +36 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/context-tag.ts +31 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +255 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +83 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/project-roots.ts +170 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +54 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session-utils.ts +29 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings-command.ts +15 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings-registry.ts +41 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +226 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/terminal.ts +60 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/package.json +45 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/src/capabilities.ts +62 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-refresh.ts +229 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +545 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +192 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/src/config.ts +143 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/src/defaults.json +82 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-augmentation.ts +82 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-display.ts +68 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-summary.ts +73 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostics.ts +98 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/stale-diagnostics.ts +47 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/suppression-diagnostics.ts +58 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/src/format.ts +359 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/src/guidance.ts +163 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/src/index.ts +17 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/src/lsp-state.ts +82 -0
  52. package/node_modules/@mrclrchtr/supi-lsp/src/lsp.ts +470 -0
  53. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +34 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +139 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-helpers.ts +39 -0
  56. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +46 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-types.ts +39 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +83 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +18 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +550 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/src/overrides.ts +173 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/src/pattern-matcher.ts +197 -0
  63. package/node_modules/@mrclrchtr/supi-lsp/src/renderer.ts +120 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/src/scanner.ts +153 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/src/search-fallback.ts +98 -0
  66. package/node_modules/@mrclrchtr/supi-lsp/src/service-registry.ts +153 -0
  67. package/node_modules/@mrclrchtr/supi-lsp/src/settings-registration.ts +292 -0
  68. package/node_modules/@mrclrchtr/supi-lsp/src/summary.ts +153 -0
  69. package/node_modules/@mrclrchtr/supi-lsp/src/tool-actions.ts +430 -0
  70. package/node_modules/@mrclrchtr/supi-lsp/src/tree-persist.ts +48 -0
  71. package/node_modules/@mrclrchtr/supi-lsp/src/tsconfig-scope.ts +156 -0
  72. package/node_modules/@mrclrchtr/supi-lsp/src/types.ts +409 -0
  73. package/node_modules/@mrclrchtr/supi-lsp/src/ui.ts +358 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +122 -0
  75. package/node_modules/@mrclrchtr/supi-lsp/src/workspace-sentinels.ts +114 -0
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +97 -0
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +67 -0
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/.gitkeep +0 -0
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/bash/tree-sitter-bash.wasm +0 -0
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/bash/tree-sitter-bash.wasm.json +7 -0
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/c/tree-sitter-c.wasm +0 -0
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/c/tree-sitter-c.wasm.json +7 -0
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/cpp/tree-sitter-cpp.wasm +0 -0
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/cpp/tree-sitter-cpp.wasm.json +7 -0
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/go/tree-sitter-go.wasm +0 -0
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/go/tree-sitter-go.wasm.json +7 -0
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/html/tree-sitter-html.wasm +0 -0
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/html/tree-sitter-html.wasm.json +7 -0
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/java/tree-sitter-java.wasm +0 -0
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/java/tree-sitter-java.wasm.json +7 -0
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/javascript/tree-sitter-javascript.wasm +0 -0
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/javascript/tree-sitter-javascript.wasm.json +7 -0
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm +0 -0
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +12 -0
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/python/tree-sitter-python.wasm +0 -0
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/python/tree-sitter-python.wasm.json +7 -0
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/r/tree-sitter-r.wasm +0 -0
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/r/tree-sitter-r.wasm.json +7 -0
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/ruby/tree-sitter-ruby.wasm +0 -0
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/ruby/tree-sitter-ruby.wasm.json +7 -0
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/rust/tree-sitter-rust.wasm +0 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/rust/tree-sitter-rust.wasm.json +7 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm +0 -0
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +19 -0
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +7 -0
  107. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  108. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +7 -0
  109. package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/generate-kotlin-wasm.mjs +126 -0
  110. package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/generate-sql-wasm.mjs +144 -0
  111. package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/vendor-wasm.mjs +151 -0
  112. package/node_modules/@mrclrchtr/supi-tree-sitter/src/callees.ts +343 -0
  113. package/node_modules/@mrclrchtr/supi-tree-sitter/src/coordinates.ts +108 -0
  114. package/node_modules/@mrclrchtr/supi-tree-sitter/src/exports.ts +315 -0
  115. package/node_modules/@mrclrchtr/supi-tree-sitter/src/formatting.ts +104 -0
  116. package/node_modules/@mrclrchtr/supi-tree-sitter/src/imports.ts +42 -0
  117. package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +16 -0
  118. package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +116 -0
  119. package/node_modules/@mrclrchtr/supi-tree-sitter/src/node-at.ts +96 -0
  120. package/node_modules/@mrclrchtr/supi-tree-sitter/src/outline.ts +287 -0
  121. package/node_modules/@mrclrchtr/supi-tree-sitter/src/runtime.ts +237 -0
  122. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session.ts +112 -0
  123. package/node_modules/@mrclrchtr/supi-tree-sitter/src/structure.ts +7 -0
  124. package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-node.ts +13 -0
  125. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tree-sitter.ts +306 -0
  126. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +146 -0
  127. package/package.json +47 -0
  128. package/src/actions/affected-action.ts +310 -0
  129. package/src/actions/brief-action.ts +242 -0
  130. package/src/actions/callees-action.ts +134 -0
  131. package/src/actions/callers-action.ts +215 -0
  132. package/src/actions/implementations-action.ts +190 -0
  133. package/src/actions/index-action.ts +187 -0
  134. package/src/actions/pattern-action.ts +232 -0
  135. package/src/architecture.ts +367 -0
  136. package/src/brief-focused.ts +383 -0
  137. package/src/brief.ts +228 -0
  138. package/src/code-intelligence.ts +122 -0
  139. package/src/git-context.ts +65 -0
  140. package/src/guidance.ts +39 -0
  141. package/src/index.ts +28 -0
  142. package/src/resolve-target.ts +104 -0
  143. package/src/search-helpers.ts +283 -0
  144. package/src/target-resolution.ts +368 -0
  145. package/src/tool-actions.ts +109 -0
  146. package/src/types.ts +57 -0
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@mrclrchtr/supi-tree-sitter",
3
+ "version": "0.1.0",
4
+ "description": "SuPi Tree-sitter extension — structural AST analysis for pi",
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-package",
15
+ "pi",
16
+ "pi-coding-agent"
17
+ ],
18
+ "files": [
19
+ "src/**/*.ts",
20
+ "src/**/*.json",
21
+ "resources",
22
+ "scripts/*.mjs",
23
+ "!__tests__"
24
+ ],
25
+ "scripts": {
26
+ "vendor:wasm": "node scripts/vendor-wasm.mjs",
27
+ "check:wasm": "node scripts/vendor-wasm.mjs --check",
28
+ "generate:kotlin-wasm": "node scripts/generate-kotlin-wasm.mjs",
29
+ "check:kotlin-wasm": "node scripts/generate-kotlin-wasm.mjs --check",
30
+ "generate:sql-wasm": "node scripts/generate-sql-wasm.mjs",
31
+ "check:sql-wasm": "node scripts/generate-sql-wasm.mjs --check"
32
+ },
33
+ "dependencies": {
34
+ "web-tree-sitter": "^0.26.8"
35
+ },
36
+ "peerDependencies": {
37
+ "@earendil-works/pi-ai": "*",
38
+ "@earendil-works/pi-coding-agent": "*",
39
+ "typebox": "*"
40
+ },
41
+ "devDependencies": {
42
+ "@davisvaughan/tree-sitter-r": "^1.2.0",
43
+ "@derekstride/tree-sitter-sql": "^0.3.11",
44
+ "@types/node": "^25.6.0",
45
+ "tree-sitter-bash": "^0.23.0",
46
+ "tree-sitter-c": "^0.23.0",
47
+ "tree-sitter-cli": "0.22.6",
48
+ "tree-sitter-cpp": "^0.23.0",
49
+ "tree-sitter-go": "^0.23.0",
50
+ "tree-sitter-html": "^0.23.0",
51
+ "tree-sitter-java": "^0.23.0",
52
+ "tree-sitter-javascript": "^0.23.0",
53
+ "tree-sitter-kotlin": "^0.3.8",
54
+ "tree-sitter-python": "^0.23.0",
55
+ "tree-sitter-ruby": "^0.23.0",
56
+ "tree-sitter-rust": "^0.23.0",
57
+ "tree-sitter-typescript": "^0.23.0",
58
+ "vitest": "^4.1.4",
59
+ "@mrclrchtr/supi-test-utils": "workspace:*"
60
+ },
61
+ "pi": {
62
+ "extensions": [
63
+ "./src/tree-sitter.ts"
64
+ ]
65
+ },
66
+ "main": "src/index.ts"
67
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-bash",
4
+ "version": "0.23.3"
5
+ },
6
+ "sha256": "d1844429a58620f306b6f42aebe92298243ca8120cd833a3ab5d87c7a2e7b9fd"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-c",
4
+ "version": "0.23.6"
5
+ },
6
+ "sha256": "146f85977800935f18b06940518b16ded13cf4007ef0e3190573b969a98b9adc"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-cpp",
4
+ "version": "0.23.4"
5
+ },
6
+ "sha256": "174eb0deb75b2ec7881bcacda9f995648d8e683956e5c2267e69ab6dc503fcbf"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-go",
4
+ "version": "0.23.4"
5
+ },
6
+ "sha256": "6dfc8eacdad0a54d0cad0d888851bd19cdd14d82582f110f888bbf6f9e5e2d64"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-html",
4
+ "version": "0.23.2"
5
+ },
6
+ "sha256": "c48fcd82c7ea8bf943180088ba7f28c48b2bb5287874179168bf9d31e394cf85"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-java",
4
+ "version": "0.23.5"
5
+ },
6
+ "sha256": "4fdeac4ca6ca089f06c6f7e562abcac1733cd465728cc7031ebb73c2019122c4"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-javascript",
4
+ "version": "0.23.1"
5
+ },
6
+ "sha256": "4a378293fe7853cbee2836023be072dafa0e53b3b5edb245920838ca834ed121"
7
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-kotlin",
4
+ "version": "0.3.8",
5
+ "repository": "https://github.com/fwcd/tree-sitter-kotlin",
6
+ "releaseAsset": "https://github.com/fwcd/tree-sitter-kotlin/releases/download/0.3.8/tree-sitter-kotlin.wasm"
7
+ },
8
+ "generatedWith": {
9
+ "treeSitterCli": "0.22.6"
10
+ },
11
+ "sha256": "c624e7443b371c28adc5d81674e73067564c12555ebe3ed96a6c8db814b7602d"
12
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-python",
4
+ "version": "0.23.6"
5
+ },
6
+ "sha256": "8c93692fb368e288a5824cee55773c9b3602804f513bda48c97661e52e9c2da2"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "@davisvaughan/tree-sitter-r",
4
+ "version": "1.2.0"
5
+ },
6
+ "sha256": "2a8f5acd1c53d91e0ec5c01a6830d8ac7f5a7f96f0ac4b3768c016c8e9d07711"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-ruby",
4
+ "version": "0.23.1"
5
+ },
6
+ "sha256": "09a96427d7c72f0613ed470cd9812223fc4a91d6a9c025c0235cc6bd59ff96f4"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-rust",
4
+ "version": "0.23.3"
5
+ },
6
+ "sha256": "f65f354215611fd94ad34134b3427eb3d58cbb745df7b6509ba722184db73d57"
7
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "@derekstride/tree-sitter-sql",
4
+ "version": "0.3.11",
5
+ "repository": "https://github.com/derekstride/tree-sitter-sql"
6
+ },
7
+ "generatedWith": {
8
+ "treeSitterCli": "0.22.6"
9
+ },
10
+ "sha256": "0871a3bd488ed39f5a521484337f07a43bd6aa95dbdf1cdd24744deecafa58fc",
11
+ "trust": {
12
+ "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. The npm package's install script uses 'npx --yes' which some package managers flag as a supply-chain risk; pnpm ignores build scripts by default, so this script never runs during install. The WASM was built locally from the package source (not downloaded from npm). See scripts/generate-sql-wasm.mjs for the rebuild procedure.",
13
+ "alternativesConsidered": [
14
+ "tree-sitter-sql (m-novikov, 2021, stale)",
15
+ "tree-sitter-sql-bigquery (BigQuery-specific)",
16
+ "dialect-specific grammars (too narrow)"
17
+ ]
18
+ }
19
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-typescript",
4
+ "version": "0.23.2"
5
+ },
6
+ "sha256": "79e5da75ea62855a0cd67177685f0164eac87d5f630b3cbe1e0a099751ad30f8"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": {
3
+ "npmPackage": "tree-sitter-typescript",
4
+ "version": "0.23.2"
5
+ },
6
+ "sha256": "778025db5a8be0e70f8ccc3671e486dfeddd048c25d9e8a70c26de2e1bf6f97d"
7
+ }
@@ -0,0 +1,126 @@
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 metadata = readMetadata();
42
+ const actualSha = sha256(wasmPath);
43
+ const errors = [];
44
+
45
+ if (metadata.source?.npmPackage !== "tree-sitter-kotlin") {
46
+ errors.push("metadata source package must be tree-sitter-kotlin");
47
+ }
48
+ if (metadata.source?.version !== kotlinPackage.json.version) {
49
+ errors.push(
50
+ `metadata pins tree-sitter-kotlin ${metadata.source?.version}, but installed package is ${kotlinPackage.json.version}`,
51
+ );
52
+ }
53
+ if (metadata.source?.releaseAsset !== expectedReleaseAsset(kotlinPackage.json.version)) {
54
+ errors.push(
55
+ "metadata release asset URL does not match the installed tree-sitter-kotlin version",
56
+ );
57
+ }
58
+ if (metadata.sha256 !== actualSha) {
59
+ errors.push(`metadata sha256 ${metadata.sha256} does not match vendored file ${actualSha}`);
60
+ }
61
+
62
+ if (errors.length > 0) {
63
+ throw new Error(
64
+ `Vendored Kotlin Tree-sitter WASM is stale:\n- ${errors.join("\n- ")}\nRun: pnpm --filter @mrclrchtr/supi-tree-sitter generate:kotlin-wasm`,
65
+ );
66
+ }
67
+
68
+ process.stdout.write(
69
+ `Kotlin Tree-sitter WASM is current (${kotlinPackage.json.version}, ${actualSha}).\n`,
70
+ );
71
+ }
72
+
73
+ function generateKotlinWasm() {
74
+ const kotlinPackage = readPackage("tree-sitter-kotlin");
75
+ const cliPackage = readPackage("tree-sitter-cli");
76
+ const cliPath = path.join(cliPackage.dir, "cli.js");
77
+ const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "supi-kotlin-wasm-"));
78
+ const grammarDir = path.join(tempRoot, "tree-sitter-kotlin");
79
+
80
+ try {
81
+ fs.cpSync(kotlinPackage.dir, grammarDir, { recursive: true });
82
+ const result = spawnSync(process.execPath, [cliPath, "build", "--wasm"], {
83
+ cwd: grammarDir,
84
+ stdio: "inherit",
85
+ });
86
+
87
+ if (result.status !== 0) {
88
+ throw new Error(
89
+ "tree-sitter build --wasm failed. Install Docker or Emscripten, then rerun generate:kotlin-wasm.",
90
+ );
91
+ }
92
+
93
+ const generatedWasmPath = path.join(grammarDir, "tree-sitter-kotlin.wasm");
94
+ if (!fs.existsSync(generatedWasmPath)) {
95
+ throw new Error(`Expected generated WASM at ${generatedWasmPath}`);
96
+ }
97
+
98
+ fs.mkdirSync(wasmDir, { recursive: true });
99
+ fs.copyFileSync(generatedWasmPath, wasmPath);
100
+
101
+ const checksum = sha256(wasmPath);
102
+ const metadata = {
103
+ source: {
104
+ npmPackage: "tree-sitter-kotlin",
105
+ version: kotlinPackage.json.version,
106
+ repository: "https://github.com/fwcd/tree-sitter-kotlin",
107
+ releaseAsset: expectedReleaseAsset(kotlinPackage.json.version),
108
+ },
109
+ generatedWith: {
110
+ treeSitterCli: cliPackage.json.version,
111
+ },
112
+ sha256: checksum,
113
+ };
114
+ fs.writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}\n`);
115
+ process.stdout.write(`Generated ${wasmPath}\n`);
116
+ process.stdout.write(`SHA256 ${checksum}\n`);
117
+ } finally {
118
+ fs.rmSync(tempRoot, { recursive: true, force: true });
119
+ }
120
+ }
121
+
122
+ if (checkMode) {
123
+ assertKotlinWasmCurrent();
124
+ } else {
125
+ generateKotlinWasm();
126
+ }
@@ -0,0 +1,144 @@
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. pnpm ignores build
12
+ * scripts by default, so this script never runs during install.
13
+ * - The WASM is built locally from the installed package source (not downloaded
14
+ * from npm). The build uses tree-sitter-cli 0.22.6 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 metadata = readMetadata();
59
+ const actualSha = sha256(wasmPath);
60
+ const errors = [];
61
+
62
+ if (metadata.source?.npmPackage !== "@derekstride/tree-sitter-sql") {
63
+ errors.push("metadata source package must be @derekstride/tree-sitter-sql");
64
+ }
65
+ if (metadata.source?.version !== sqlPackage.json.version) {
66
+ errors.push(
67
+ `metadata pins @derekstride/tree-sitter-sql ${metadata.source?.version}, but installed package is ${sqlPackage.json.version}`,
68
+ );
69
+ }
70
+ if (metadata.sha256 !== actualSha) {
71
+ errors.push(`metadata sha256 ${metadata.sha256} does not match vendored file ${actualSha}`);
72
+ }
73
+
74
+ if (errors.length > 0) {
75
+ throw new Error(
76
+ `Vendored SQL Tree-sitter WASM is stale:\n- ${errors.join("\n- ")}\nRun: pnpm --filter @mrclrchtr/supi-tree-sitter generate:sql-wasm`,
77
+ );
78
+ }
79
+
80
+ process.stdout.write(
81
+ `SQL Tree-sitter WASM is current (${sqlPackage.json.version}, ${actualSha}).\n`,
82
+ );
83
+ }
84
+
85
+ function generateSqlWasm() {
86
+ const sqlPackage = readPackage("@derekstride/tree-sitter-sql");
87
+ const cliPackage = readPackage("tree-sitter-cli");
88
+ const cliPath = path.join(cliPackage.dir, "cli.js");
89
+ const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "supi-sql-wasm-"));
90
+ const grammarDir = path.join(tempRoot, "tree-sitter-sql");
91
+
92
+ try {
93
+ fs.cpSync(sqlPackage.dir, grammarDir, { recursive: true });
94
+
95
+ // tree-sitter-cli 0.22.6 requires a "tree-sitter" section in package.json
96
+ const grammarPackageJsonPath = path.join(grammarDir, "package.json");
97
+ const grammarPackageJson = JSON.parse(fs.readFileSync(grammarPackageJsonPath, "utf-8"));
98
+ grammarPackageJson["tree-sitter"] = [{ scope: "source.sql" }];
99
+ fs.writeFileSync(grammarPackageJsonPath, JSON.stringify(grammarPackageJson, null, 2));
100
+
101
+ const result = spawnSync(process.execPath, [cliPath, "build", "--wasm"], {
102
+ cwd: grammarDir,
103
+ stdio: "inherit",
104
+ });
105
+
106
+ if (result.status !== 0) {
107
+ throw new Error(
108
+ "tree-sitter build --wasm failed. Install Docker or Emscripten, then rerun generate:sql-wasm.",
109
+ );
110
+ }
111
+
112
+ const generatedWasmPath = path.join(grammarDir, "tree-sitter-sql.wasm");
113
+ if (!fs.existsSync(generatedWasmPath)) {
114
+ throw new Error(`Expected generated WASM at ${generatedWasmPath}`);
115
+ }
116
+
117
+ fs.mkdirSync(wasmDir, { recursive: true });
118
+ fs.copyFileSync(generatedWasmPath, wasmPath);
119
+
120
+ const checksum = sha256(wasmPath);
121
+ const metadata = {
122
+ source: {
123
+ npmPackage: "@derekstride/tree-sitter-sql",
124
+ version: sqlPackage.json.version,
125
+ repository: "https://github.com/derekstride/tree-sitter-sql",
126
+ },
127
+ generatedWith: {
128
+ treeSitterCli: cliPackage.json.version,
129
+ },
130
+ sha256: checksum,
131
+ };
132
+ fs.writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}\n`);
133
+ process.stdout.write(`Generated ${wasmPath}\n`);
134
+ process.stdout.write(`SHA256 ${checksum}\n`);
135
+ } finally {
136
+ fs.rmSync(tempRoot, { recursive: true, force: true });
137
+ }
138
+ }
139
+
140
+ if (checkMode) {
141
+ assertSqlWasmCurrent();
142
+ } else {
143
+ generateSqlWasm();
144
+ }