@mrclrchtr/supi-code-intelligence 6.1.0 → 6.2.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.
- package/README.md +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/debug-identity.ts +11 -0
- package/node_modules/@mrclrchtr/supi-core/src/debug.ts +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +21 -3
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-identity.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug.ts +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +4 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +12 -7
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +0 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-publication.ts +6 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +2 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +5 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +2 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +17 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +40 -18
- package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +164 -30
- package/node_modules/@mrclrchtr/supi-lsp/src/config/lsp-settings.ts +9 -87
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +0 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +4 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/types.ts +0 -29
- package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +7 -21
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-severity.ts +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-summary.ts +11 -14
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +0 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/stale-diagnostics.ts +0 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/workspace-sentinels.ts +29 -49
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +4 -8
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-helpers.ts +1 -9
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +6 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +9 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +26 -41
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +275 -99
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +4 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +59 -28
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +27 -19
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +26 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registration.ts +0 -17
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +83 -19
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +5 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +24 -21
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +29 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/summary.ts +19 -40
- package/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +13 -19
- package/node_modules/@mrclrchtr/supi-lsp/src/workspace-path-policy.ts +287 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +6 -18
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-identity.ts +11 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug.ts +5 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +1 -11
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/coordinates.ts +19 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +5 -23
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/operation-support.ts +3 -21
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +5 -9
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +10 -20
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +7 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +9 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +134 -9
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-name.ts +96 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +11 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +39 -56
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +9 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/js-binding-pattern.ts +26 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +2 -21
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-html-sql.ts +144 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline.ts +50 -37
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/scope.ts +138 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +0 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store.ts +1 -14
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +0 -10
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +6 -8
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +34 -10
- package/package.json +5 -5
- package/src/analysis/capability/capability-warnings.ts +4 -22
- package/src/analysis/search/ast-scan-timing.ts +4 -2
- package/src/analysis/search/ast-scan.ts +1 -1
- package/src/api.ts +1 -0
- package/src/extension.ts +4 -2
- package/src/session/health-refresh.ts +24 -2
- package/src/session/health-types.ts +19 -0
- package/src/session/input/health-refactor.ts +16 -14
- package/src/session/refactor-types.ts +14 -1
- package/src/session/refactor-workflow.ts +21 -16
- package/src/substrate/lsp/lifecycle.ts +0 -3
- package/src/substrate/lsp/maintenance.ts +4 -5
- package/src/substrate/lsp/settings.ts +6 -9
- package/src/substrate/lsp/state.ts +0 -2
- package/src/substrate/workspace-provider-host.ts +2 -2
- package/src/tool/code_health/file-scope-markdown.ts +43 -0
- package/src/tool/code_health/markdown.ts +66 -66
- package/src/tool/code_health/refresh-outcome.ts +46 -0
- package/src/tool/code_health/refresh-status.ts +166 -23
- package/src/tool/code_health/result.ts +1 -0
- package/src/tool/code_health/tui.ts +18 -5
- package/src/tool/code_refactor_apply/guidance.ts +3 -2
- package/src/tool/code_refactor_plan/guidance.ts +1 -1
- package/src/tool/register.ts +5 -2
- package/src/tool/schemas.ts +21 -11
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-actions.ts +0 -59
- package/node_modules/@mrclrchtr/supi-lsp/src/pattern-matcher.ts +0 -24
- package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/generate-kotlin-wasm.mjs +0 -132
- package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/generate-sql-wasm.mjs +0 -158
- package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/vendor-wasm.mjs +0 -167
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +0 -42
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-registration.ts +0 -37
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/service-registry.ts +0 -30
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/structure.ts +0 -8
|
@@ -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
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Shared session-scoped Tree-sitter service registry.
|
|
2
|
-
// Peer extensions can import `getSessionTreeSitterService` from the package API
|
|
3
|
-
// to reuse the active structural runtime without creating duplicate sessions.
|
|
4
|
-
|
|
5
|
-
import { createSessionStateRegistry } from "@mrclrchtr/supi-core/session";
|
|
6
|
-
import type { SessionTreeSitterService, SessionTreeSitterServiceState } from "../types.ts";
|
|
7
|
-
|
|
8
|
-
const registry = createSessionStateRegistry<SessionTreeSitterServiceState>(
|
|
9
|
-
"supi-tree-sitter/session-registry",
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
/** Publish the shared Tree-sitter service for one session cwd. */
|
|
13
|
-
export function setSessionTreeSitterService(cwd: string, service: SessionTreeSitterService): void {
|
|
14
|
-
registry.set(cwd, { kind: "ready", service });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Acquire the shared Tree-sitter service state for one session cwd. */
|
|
18
|
-
export function getSessionTreeSitterService(cwd: string): SessionTreeSitterServiceState {
|
|
19
|
-
return (
|
|
20
|
-
registry.get(cwd) ?? {
|
|
21
|
-
kind: "unavailable",
|
|
22
|
-
reason: "No Tree-sitter session initialized for this workspace",
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Remove the shared Tree-sitter service for one session cwd. */
|
|
28
|
-
export function clearSessionTreeSitterService(cwd: string): void {
|
|
29
|
-
registry.clear(cwd);
|
|
30
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Structural extraction services — re-exports from sub-modules.
|
|
2
|
-
|
|
3
|
-
export { extractCallSites } from "./call-sites.ts";
|
|
4
|
-
export { lookupCalleesAt } from "./callees.ts";
|
|
5
|
-
export { extractExports } from "./exports.ts";
|
|
6
|
-
export { extractImports } from "./imports.ts";
|
|
7
|
-
export { lookupNodeAt } from "./node-at.ts";
|
|
8
|
-
export { collectOutline as extractOutline } from "./outline.ts";
|