@noego/trust 0.5.0-dev.0 → 0.5.0-dev.1

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 (142) hide show
  1. package/README.md +44 -9
  2. package/dist/{baseline-B0AplCuF.d.ts → baseline-Bkav9mS0.d.ts} +22 -4
  3. package/dist/{chunk-V72KWVWP.js → chunk-7PY2Q6OX.js} +212 -16
  4. package/dist/chunk-7PY2Q6OX.js.map +1 -0
  5. package/dist/{chunk-NG4KYWVW.js → chunk-UG6D3V4M.js} +877 -41
  6. package/dist/chunk-UG6D3V4M.js.map +1 -0
  7. package/dist/{chunk-OSSITT3R.js → chunk-XXLWC5DB.js} +17 -61
  8. package/dist/chunk-XXLWC5DB.js.map +1 -0
  9. package/dist/cli/index.js +341 -92
  10. package/dist/cli/index.js.map +1 -1
  11. package/dist/cli/wasm-worker.js +257 -0
  12. package/dist/cli/wasm-worker.js.map +1 -0
  13. package/dist/core/index.d.ts +5 -3
  14. package/dist/core/index.js +7 -7
  15. package/dist/eslint/index.d.ts +6 -2
  16. package/dist/eslint/index.js +2 -2
  17. package/dist/licenses/@jridgewell__resolve-uri/LICENSE +19 -0
  18. package/dist/licenses/@jridgewell__sourcemap-codec/LICENSE +19 -0
  19. package/dist/licenses/@jridgewell__trace-mapping/LICENSE +19 -0
  20. package/dist/licenses/JS-DEPENDENCIES.json +83 -0
  21. package/dist/licenses/balanced-match/LICENSE.md +23 -0
  22. package/dist/licenses/brace-expansion/LICENSE +23 -0
  23. package/dist/licenses/dedent-js/LICENSE +19 -0
  24. package/dist/licenses/minimatch/LICENSE.md +55 -0
  25. package/dist/licenses/scule/LICENSE +21 -0
  26. package/dist/licenses/svelte2tsx/LICENSE +21 -0
  27. package/dist/native/licenses/CARGO-DEPENDENCIES.json +479 -0
  28. package/dist/native/licenses/LICENSE-trust.txt +15 -0
  29. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-0BSD +12 -0
  30. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-APACHE +201 -0
  31. package/dist/native/licenses/cargo/adler2-2.0.1/LICENSE-MIT +23 -0
  32. package/dist/native/licenses/cargo/aho-corasick-1.1.5/COPYING +3 -0
  33. package/dist/native/licenses/cargo/aho-corasick-1.1.5/LICENSE-MIT +21 -0
  34. package/dist/native/licenses/cargo/autocfg-1.5.1/LICENSE-APACHE +201 -0
  35. package/dist/native/licenses/cargo/autocfg-1.5.1/LICENSE-MIT +25 -0
  36. package/dist/native/licenses/cargo/bitflags-1.3.2/LICENSE-APACHE +201 -0
  37. package/dist/native/licenses/cargo/bitflags-1.3.2/LICENSE-MIT +25 -0
  38. package/dist/native/licenses/cargo/bstr-1.13.1/COPYING +8 -0
  39. package/dist/native/licenses/cargo/bstr-1.13.1/LICENSE-APACHE +201 -0
  40. package/dist/native/licenses/cargo/bstr-1.13.1/LICENSE-MIT +21 -0
  41. package/dist/native/licenses/cargo/bumpalo-3.20.3/LICENSE-APACHE +201 -0
  42. package/dist/native/licenses/cargo/bumpalo-3.20.3/LICENSE-MIT +25 -0
  43. package/dist/native/licenses/cargo/cfg-if-1.0.5/LICENSE-APACHE +201 -0
  44. package/dist/native/licenses/cargo/cfg-if-1.0.5/LICENSE-MIT +25 -0
  45. package/dist/native/licenses/cargo/crc32fast-1.5.2/LICENSE-APACHE +202 -0
  46. package/dist/native/licenses/cargo/crc32fast-1.5.2/LICENSE-MIT +21 -0
  47. package/dist/native/licenses/cargo/defmt-1.1.1/LICENSE-APACHE +201 -0
  48. package/dist/native/licenses/cargo/defmt-1.1.1/LICENSE-MIT +25 -0
  49. package/dist/native/licenses/cargo/defmt-macros-1.1.1/LICENSE-APACHE +201 -0
  50. package/dist/native/licenses/cargo/defmt-macros-1.1.1/LICENSE-MIT +25 -0
  51. package/dist/native/licenses/cargo/equivalent-1.0.2/LICENSE-APACHE +201 -0
  52. package/dist/native/licenses/cargo/equivalent-1.0.2/LICENSE-MIT +25 -0
  53. package/dist/native/licenses/cargo/flate2-1.1.10/LICENSE-APACHE +201 -0
  54. package/dist/native/licenses/cargo/flate2-1.1.10/LICENSE-MIT +25 -0
  55. package/dist/native/licenses/cargo/globset-0.4.20/COPYING +3 -0
  56. package/dist/native/licenses/cargo/globset-0.4.20/LICENSE-MIT +21 -0
  57. package/dist/native/licenses/cargo/hashbrown-0.17.1/LICENSE-APACHE +201 -0
  58. package/dist/native/licenses/cargo/hashbrown-0.17.1/LICENSE-MIT +25 -0
  59. package/dist/native/licenses/cargo/indexmap-2.14.0/LICENSE-APACHE +201 -0
  60. package/dist/native/licenses/cargo/indexmap-2.14.0/LICENSE-MIT +25 -0
  61. package/dist/native/licenses/cargo/itoa-1.0.18/LICENSE-APACHE +176 -0
  62. package/dist/native/licenses/cargo/itoa-1.0.18/LICENSE-MIT +23 -0
  63. package/dist/native/licenses/cargo/jiff-0.2.37/COPYING +3 -0
  64. package/dist/native/licenses/cargo/jiff-0.2.37/LICENSE-MIT +21 -0
  65. package/dist/native/licenses/cargo/jiff-core-0.1.1/COPYING +3 -0
  66. package/dist/native/licenses/cargo/jiff-core-0.1.1/LICENSE-MIT +21 -0
  67. package/dist/native/licenses/cargo/jiff-tzdb-0.1.9/COPYING +3 -0
  68. package/dist/native/licenses/cargo/jiff-tzdb-0.1.9/LICENSE-MIT +21 -0
  69. package/dist/native/licenses/cargo/jiff-tzdb-platform-0.1.3/COPYING +3 -0
  70. package/dist/native/licenses/cargo/jiff-tzdb-platform-0.1.3/LICENSE-MIT +21 -0
  71. package/dist/native/licenses/cargo/log-0.4.34/LICENSE-APACHE +201 -0
  72. package/dist/native/licenses/cargo/log-0.4.34/LICENSE-MIT +25 -0
  73. package/dist/native/licenses/cargo/lzma-rust2-0.21.0/LICENSE +201 -0
  74. package/dist/native/licenses/cargo/memchr-2.8.2/COPYING +3 -0
  75. package/dist/native/licenses/cargo/memchr-2.8.2/LICENSE-MIT +21 -0
  76. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE +25 -0
  77. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-APACHE.md +177 -0
  78. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-MIT.md +24 -0
  79. package/dist/native/licenses/cargo/miniz_oxide-0.9.1/LICENSE-ZLIB.md +14 -0
  80. package/dist/native/licenses/cargo/num-bigint-0.4.6/LICENSE-APACHE +201 -0
  81. package/dist/native/licenses/cargo/num-bigint-0.4.6/LICENSE-MIT +25 -0
  82. package/dist/native/licenses/cargo/num-integer-0.1.47/LICENSE-APACHE +201 -0
  83. package/dist/native/licenses/cargo/num-integer-0.1.47/LICENSE-MIT +25 -0
  84. package/dist/native/licenses/cargo/num-traits-0.2.19/LICENSE-APACHE +201 -0
  85. package/dist/native/licenses/cargo/num-traits-0.2.19/LICENSE-MIT +25 -0
  86. package/dist/native/licenses/cargo/proc-macro2-1.0.107/LICENSE-APACHE +176 -0
  87. package/dist/native/licenses/cargo/proc-macro2-1.0.107/LICENSE-MIT +23 -0
  88. package/dist/native/licenses/cargo/quote-1.0.47/LICENSE-APACHE +176 -0
  89. package/dist/native/licenses/cargo/quote-1.0.47/LICENSE-MIT +23 -0
  90. package/dist/native/licenses/cargo/regex-automata-0.4.18/LICENSE-APACHE +201 -0
  91. package/dist/native/licenses/cargo/regex-automata-0.4.18/LICENSE-MIT +25 -0
  92. package/dist/native/licenses/cargo/regex-syntax-0.8.11/LICENSE-APACHE +201 -0
  93. package/dist/native/licenses/cargo/regex-syntax-0.8.11/LICENSE-MIT +25 -0
  94. package/dist/native/licenses/cargo/rustc-hash-2.1.2/LICENSE-APACHE +176 -0
  95. package/dist/native/licenses/cargo/rustc-hash-2.1.2/LICENSE-MIT +23 -0
  96. package/dist/native/licenses/cargo/ryu-js-1.0.2/LICENSE-APACHE +176 -0
  97. package/dist/native/licenses/cargo/ryu-js-1.0.2/LICENSE-BOOST +23 -0
  98. package/dist/native/licenses/cargo/serde-1.0.229/LICENSE-APACHE +176 -0
  99. package/dist/native/licenses/cargo/serde-1.0.229/LICENSE-MIT +23 -0
  100. package/dist/native/licenses/cargo/serde_core-1.0.229/LICENSE-APACHE +176 -0
  101. package/dist/native/licenses/cargo/serde_core-1.0.229/LICENSE-MIT +23 -0
  102. package/dist/native/licenses/cargo/serde_derive-1.0.229/LICENSE-APACHE +176 -0
  103. package/dist/native/licenses/cargo/serde_derive-1.0.229/LICENSE-MIT +23 -0
  104. package/dist/native/licenses/cargo/serde_json-1.0.152/LICENSE-APACHE +176 -0
  105. package/dist/native/licenses/cargo/serde_json-1.0.152/LICENSE-MIT +23 -0
  106. package/dist/native/licenses/cargo/simd-adler32-0.3.10/LICENSE.md +21 -0
  107. package/dist/native/licenses/cargo/smallvec-1.15.1/LICENSE-APACHE +201 -0
  108. package/dist/native/licenses/cargo/smallvec-1.15.1/LICENSE-MIT +25 -0
  109. package/dist/native/licenses/cargo/syn-2.0.119/LICENSE-APACHE +176 -0
  110. package/dist/native/licenses/cargo/syn-2.0.119/LICENSE-MIT +23 -0
  111. package/dist/native/licenses/cargo/syn-3.0.7/LICENSE-APACHE +176 -0
  112. package/dist/native/licenses/cargo/syn-3.0.7/LICENSE-MIT +23 -0
  113. package/dist/native/licenses/cargo/thiserror-2.0.21/LICENSE-APACHE +176 -0
  114. package/dist/native/licenses/cargo/thiserror-2.0.21/LICENSE-MIT +23 -0
  115. package/dist/native/licenses/cargo/thiserror-impl-2.0.21/LICENSE-APACHE +176 -0
  116. package/dist/native/licenses/cargo/thiserror-impl-2.0.21/LICENSE-MIT +23 -0
  117. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-APACHE +176 -0
  118. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-MIT +23 -0
  119. package/dist/native/licenses/cargo/unicode-ident-1.0.26/LICENSE-UNICODE +39 -0
  120. package/dist/native/licenses/cargo/xxhash-rust-0.8.15/LICENSE +23 -0
  121. package/dist/native/licenses/cargo/zlib-rs-0.6.8/LICENSE +19 -0
  122. package/dist/native/licenses/cargo/zmij-1.0.23/LICENSE-MIT +23 -0
  123. package/dist/native/licenses/ts-rust/LICENSE +21 -0
  124. package/dist/native/licenses/ts-rust/NOTICE.md +53 -0
  125. package/dist/native/licenses/ts-rust/licenses/Go-LICENSE.txt +27 -0
  126. package/dist/native/licenses/ts-rust/licenses/TypeScript-LICENSE.txt +55 -0
  127. package/dist/native/licenses/ts-rust/licenses/TypeScript-NOTICE.txt +405 -0
  128. package/dist/native/licenses/ts-rust/licenses/Unicode-LICENSE.txt +39 -0
  129. package/dist/native/licenses/ts-rust/licenses/vscode-languageserver-node-LICENSE.txt +18 -0
  130. package/dist/native/licenses/typescript/LICENSE.txt +55 -0
  131. package/dist/native/licenses/typescript/ThirdPartyNoticeText.txt +193 -0
  132. package/dist/native/licenses/typescript/manifest.json +105 -0
  133. package/dist/native/trust_native_wasm.wasm +0 -0
  134. package/dist/svelte2tsx/index.cjs +7064 -0
  135. package/dist/svelte2tsx/svelte-jsx-v4.d.ts +230 -0
  136. package/dist/svelte2tsx/svelte-jsx.d.ts +1492 -0
  137. package/dist/svelte2tsx/svelte-shims-v4.d.ts +290 -0
  138. package/dist/svelte2tsx/svelte-shims.d.ts +305 -0
  139. package/package.json +25 -5
  140. package/dist/chunk-NG4KYWVW.js.map +0 -1
  141. package/dist/chunk-OSSITT3R.js.map +0 -1
  142. package/dist/chunk-V72KWVWP.js.map +0 -1
package/dist/cli/index.js CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  checkSourceFile,
6
6
  checkSourceFileWithAccepted,
7
7
  claimSpan,
8
+ decide,
8
9
  emptyTrustConfig,
9
10
  guardCallOf,
10
11
  policyFor,
@@ -16,35 +17,43 @@ import {
16
17
  untrustedValueContext,
17
18
  untrustedValueMessage,
18
19
  untrustedValuesIn
19
- } from "../chunk-V72KWVWP.js";
20
+ } from "../chunk-7PY2Q6OX.js";
20
21
  import {
21
22
  compareFindings,
22
- createPrograms,
23
23
  forEachSourceFile,
24
24
  formatFinding,
25
+ formatWalkFailure,
26
+ logUnmatchedGlobs,
25
27
  logWalkFailure,
26
28
  relativeTo,
27
- resolveFiles,
28
- sourceFileOf
29
- } from "../chunk-OSSITT3R.js";
29
+ resolveFiles
30
+ } from "../chunk-XXLWC5DB.js";
30
31
  import {
31
32
  DROPPED_RESULT_RULE,
33
+ SvelteFileError,
34
+ SvelteInputs,
32
35
  TYPE_CLAIM_RULE,
33
36
  UNTRUSTED_ENTRY_LABELS,
34
37
  UNTRUSTED_VALUE_RULE,
35
38
  WHOLE_BASELINE,
36
39
  Zones,
37
40
  compareToBaseline,
41
+ createPrograms,
38
42
  describeBaselineDelta,
43
+ groupByTsconfig,
39
44
  groupMatches,
40
45
  isRuleEnabled,
41
46
  loadTrustConfig,
42
47
  loadTypeScript,
48
+ prepareSvelte,
43
49
  readBaseline,
44
50
  realpathOrSelf,
45
51
  serializeBaseline,
52
+ sourceFileOf,
53
+ svelteFor,
54
+ svelteForSource,
46
55
  updateBaseline
47
- } from "../chunk-NG4KYWVW.js";
56
+ } from "../chunk-UG6D3V4M.js";
48
57
 
49
58
  // src/cli/baseline-command.ts
50
59
  import { existsSync, writeFileSync } from "fs";
@@ -57,7 +66,8 @@ async function runBaselineCommand(options) {
57
66
  }
58
67
  const configPath = resolve(options.cwd, options.configFile);
59
68
  const rootDir = options.root === void 0 ? void 0 : resolve(options.cwd, options.root);
60
- const config = existsSync(configPath) ? loadTrustConfig(configPath, { validateGlobs: false, rootDir }) : emptyTrustConfig(rootDir ?? options.cwd);
69
+ const config = existsSync(configPath) ? loadTrustConfig(configPath, { rootDir }) : emptyTrustConfig(rootDir ?? options.cwd);
70
+ logUnmatchedGlobs(options.log, "baseline", config);
61
71
  const baselineFile = resolve(options.cwd, options.baselineFile ?? join(config.rootDir, "trust-baseline.json"));
62
72
  const zones = new Zones(config.rootDir, config.passthrough, config.ignore);
63
73
  const files = resolved.files.filter((file) => zones.zoneOf(file) !== "ignore");
@@ -111,86 +121,296 @@ async function runBaselineCommand(options) {
111
121
 
112
122
  // src/cli/check-command.ts
113
123
  import { existsSync as existsSync2 } from "fs";
114
- import { resolve as resolve2 } from "path";
124
+ import { resolve as resolve4 } from "path";
125
+
126
+ // src/cli/native-check.ts
127
+ import { readFileSync as readFileSync2 } from "fs";
128
+ import { resolve as resolve3 } from "path";
129
+ import { spawnSync } from "child_process";
130
+ import { Worker } from "worker_threads";
115
131
 
116
- // src/cli/no-written-return-type.ts
117
- var NO_WRITTEN_RETURN_TYPE_RULE = "no-written-return-type";
118
- function isReportedKind(ts, node) {
119
- return ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodDeclaration(node) || ts.isGetAccessorDeclaration(node);
132
+ // src/cli/native-engine.ts
133
+ import { accessSync, constants, readFileSync, statSync } from "fs";
134
+ import { createRequire } from "module";
135
+ import { dirname, join as join2, resolve as resolve2 } from "path";
136
+ import { fileURLToPath } from "url";
137
+ function nativePlatformPackage(platform, arch, libc = null) {
138
+ if (platform === "darwin" && (arch === "arm64" || arch === "x64")) return `@noego/trust-darwin-${arch}`;
139
+ if (platform === "linux" && libc === "glibc" && (arch === "arm64" || arch === "x64")) return `@noego/trust-linux-${arch}-gnu`;
140
+ if (platform === "win32" && arch === "x64") return "@noego/trust-win32-x64-msvc";
141
+ return null;
120
142
  }
121
- function functionName(ts, node, sourceFile) {
122
- if (ts.isArrowFunction(node)) return "(arrow function)";
123
- const name = node.name;
124
- if (!name) return "(anonymous function)";
125
- if (ts.isIdentifier(name) || ts.isPrivateIdentifier(name) || ts.isStringLiteral(name) || ts.isNumericLiteral(name)) {
126
- return name.text;
127
- }
128
- return name.getText(sourceFile);
143
+ var NATIVE_MINIMUM_GLIBC = "2.35";
144
+ function supportsNativeGlibc(version) {
145
+ if (!version || !/^\d+\.\d+(?:\.\d+)?$/.test(version)) return false;
146
+ const [major, minor] = version.split(".").map(Number);
147
+ const [minimumMajor, minimumMinor] = NATIVE_MINIMUM_GLIBC.split(".").map(Number);
148
+ return major > minimumMajor || major === minimumMajor && minor >= minimumMinor;
129
149
  }
130
- function findWrittenReturnTypes(ts, sourceFile) {
131
- if (sourceFile.isDeclarationFile) return [];
132
- const findings = [];
133
- const visit = (node) => {
134
- if (isReportedKind(ts, node) && node.body && node.type && node.type.kind !== ts.SyntaxKind.TypePredicate) {
135
- const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.type.getStart(sourceFile));
136
- findings.push({
137
- rule: NO_WRITTEN_RETURN_TYPE_RULE,
138
- line: line + 1,
139
- column: character + 1,
140
- message: `${functionName(ts, node, sourceFile)}: delete the return type annotation; the return type is inferred`
141
- });
150
+ function runtimeLinux(platform) {
151
+ if (platform !== "linux") return { libc: null, version: null };
152
+ try {
153
+ const report = process.report?.getReport();
154
+ if (typeof report !== "object" || report === null) return { libc: null, version: null };
155
+ const header = report.header;
156
+ const version = header?.glibcVersionRuntime ?? null;
157
+ return { libc: version ? "glibc" : "musl", version };
158
+ } catch {
159
+ return { libc: null, version: null };
160
+ }
161
+ }
162
+ var requireFromHere = createRequire(import.meta.url);
163
+ function packageRoots() {
164
+ const here = dirname(fileURLToPath(import.meta.url));
165
+ const roots = [resolve2(here, "..", "..")];
166
+ try {
167
+ roots.unshift(dirname(requireFromHere.resolve("@noego/trust/package.json")));
168
+ } catch {
169
+ }
170
+ return [...new Set(roots)];
171
+ }
172
+ function isFile(path, executable = false, platform = process.platform) {
173
+ try {
174
+ if (!statSync(path).isFile()) return false;
175
+ accessSync(path, executable && platform !== "win32" ? constants.X_OK : constants.R_OK);
176
+ return true;
177
+ } catch {
178
+ return false;
179
+ }
180
+ }
181
+ function packageVersion(roots, name) {
182
+ for (const root of roots) {
183
+ try {
184
+ const manifest = JSON.parse(readFileSync(join2(root, "package.json"), "utf8"));
185
+ const version = manifest.optionalDependencies?.[name];
186
+ if (manifest.name === "@noego/trust" && typeof version === "string" && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) return version;
187
+ } catch {
142
188
  }
143
- ts.forEachChild(node, visit);
144
- };
145
- visit(sourceFile);
146
- return findings;
189
+ }
190
+ return null;
191
+ }
192
+ function nativeBinary(options = {}) {
193
+ const env = options.env ?? process.env;
194
+ if (env.TRUST_NATIVE_BIN) return env.TRUST_NATIVE_BIN;
195
+ const roots = options.roots ?? packageRoots();
196
+ const platform = options.platform ?? process.platform;
197
+ const linux = runtimeLinux(platform);
198
+ const libc = options.libc === void 0 ? linux.libc : options.libc;
199
+ const glibcVersion = options.glibcVersion === void 0 ? linux.version : options.glibcVersion;
200
+ const supported = platform !== "linux" || libc === "glibc" && supportsNativeGlibc(glibcVersion);
201
+ const name = supported ? nativePlatformPackage(platform, options.arch ?? process.arch, libc) : null;
202
+ const version = name ? packageVersion(roots, name) : null;
203
+ const executable = platform === "win32" ? "trust-native.exe" : "trust-native";
204
+ if (name && version) {
205
+ try {
206
+ const manifestPath = (options.resolvePackage ?? requireFromHere.resolve)(`${name}/package.json`);
207
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
208
+ const candidate = join2(dirname(manifestPath), "bin", executable);
209
+ if (manifest.name === name && manifest.version === version && isFile(candidate, true, platform)) return candidate;
210
+ } catch {
211
+ }
212
+ }
213
+ return roots.map((root) => join2(root, "native", "target", "release", executable)).find((candidate) => isFile(candidate, true, platform)) ?? null;
214
+ }
215
+ function nativeWasm(options = {}) {
216
+ const env = options.env ?? process.env;
217
+ if (env.TRUST_NATIVE_WASM) return env.TRUST_NATIVE_WASM;
218
+ const candidates = (options.roots ?? packageRoots()).flatMap((root) => [
219
+ join2(root, "dist", "native", "trust_native_wasm.wasm"),
220
+ join2(root, "native", "target", "wasm32-wasip1", "wasm", "trust_native_wasm.wasm"),
221
+ join2(root, "native", "target", "wasm32-wasip1", "release", "trust_native_wasm.wasm")
222
+ ]);
223
+ return candidates.find((candidate) => isFile(candidate)) ?? null;
224
+ }
225
+ function nativeEngine(options = {}) {
226
+ const forced = (options.env ?? process.env).TRUST_NATIVE_ENGINE;
227
+ if (forced !== "wasm") {
228
+ const path2 = nativeBinary(options);
229
+ if (path2) return { kind: "binary", path: path2 };
230
+ if (forced === "binary") return null;
231
+ }
232
+ const path = nativeWasm(options);
233
+ return path ? { kind: "wasm", path } : null;
147
234
  }
148
235
 
149
- // src/cli/check-command.ts
150
- async function runCheckCommand(options) {
151
- if (options.paths.length === 0) {
152
- options.log("trust check needs at least one path: trust check <paths...> [--strict] [--config trust.config.json] [--tsconfig <path>]");
153
- return 2;
236
+ // src/cli/native-check.ts
237
+ var NATIVE_PROTOCOL_VERSION = 3;
238
+ var WASM_STACK_SIZE_MB = 256;
239
+ var OPT_IN_RULES = [];
240
+ function runBinary(binary, request, cwd) {
241
+ const result = spawnSync(binary, [], { cwd, input: request, encoding: "utf8", maxBuffer: 1024 * 1024 * 1024 });
242
+ if (result.error) return { status: -1, output: `trust-native could not run: ${result.error.message}`, stderr: "" };
243
+ if (result.status !== 0) {
244
+ return { status: result.status ?? -1, output: `trust-native exited with ${result.status ?? result.signal}: ${result.stderr.trim().split("\n").slice(0, 5).join("\n")}`, stderr: result.stderr };
245
+ }
246
+ return { status: 0, output: result.stdout, stderr: result.stderr };
247
+ }
248
+ function runWasm(wasmPath, request) {
249
+ return new Promise((resolvePromise) => {
250
+ const worker = new Worker(new URL("./wasm-worker.js", import.meta.url), {
251
+ workerData: { wasmPath, request },
252
+ resourceLimits: { stackSizeMb: WASM_STACK_SIZE_MB }
253
+ });
254
+ let result;
255
+ worker.on("message", (message) => {
256
+ result = message.status === 0 ? message : { status: message.status, output: `trust-native (wasm) failed with ${message.status}: ${message.output.trim().split("\n").slice(0, 5).join("\n")}`, stderr: message.stderr };
257
+ });
258
+ worker.on("error", (error) => {
259
+ result ??= { status: -1, output: `trust-native (wasm) crashed: ${error.message}`, stderr: "" };
260
+ });
261
+ worker.on("exit", (code) => {
262
+ resolvePromise(result ?? { status: -1, output: `trust-native (wasm) worker ended without a result (exit ${code})`, stderr: "" });
263
+ });
264
+ });
265
+ }
266
+ function validResponse(value) {
267
+ if (!value || typeof value !== "object") return false;
268
+ const response = value;
269
+ if (response.version !== NATIVE_PROTOCOL_VERSION || !Array.isArray(response.findings) || !Array.isArray(response.errors)) return false;
270
+ if (response.setupError !== null && typeof response.setupError !== "string") return false;
271
+ if (!response.errors.every((error) => typeof error === "string")) return false;
272
+ if (!response.findings.every((finding) => finding && typeof finding === "object" && ["file", "rule", "message"].every((key) => typeof finding[key] === "string") && Number.isInteger(finding.line) && finding.line > 0 && Number.isInteger(finding.column) && finding.column > 0 && (finding.severity === "error" || finding.severity === "warning"))) return false;
273
+ const stats = response.stats;
274
+ return !!stats && ["loadSeconds", "checkSeconds", "checkedFiles"].every((key) => typeof stats[key] === "number" && Number.isFinite(stats[key]) && stats[key] >= 0);
275
+ }
276
+ async function checkNative(options) {
277
+ const { config } = options;
278
+ if (options.files.length === 0) return { findings: [], walk: { status: "ok" } };
279
+ for (const rule of OPT_IN_RULES) {
280
+ if (isRuleEnabled(config, rule)) {
281
+ return { findings: [], walk: { status: "setup-failed", message: `the native engine does not support the "${rule}" rule yet; this release cannot check this configuration safely` } };
282
+ }
154
283
  }
155
- const resolved = resolveFiles(options.cwd, options.paths);
156
- if ("missing" in resolved) {
157
- options.log(`trust check: no such file or directory: ${resolved.missing}`);
158
- return 2;
284
+ const engine = nativeEngine();
285
+ if (!engine) {
286
+ return {
287
+ findings: [],
288
+ walk: {
289
+ status: "setup-failed",
290
+ message: "the trust-native engine is missing: reinstall @noego/trust (it includes a Wasm fallback), unset TRUST_NATIVE_ENGINE if it forces an unavailable binary, or set TRUST_NATIVE_BIN / TRUST_NATIVE_WASM; for a checkout, build the engine in native/"
291
+ }
292
+ };
159
293
  }
160
- const configPath = resolve2(options.cwd, options.configFile);
161
- const rootDir = options.root === void 0 ? void 0 : resolve2(options.cwd, options.root);
162
- const config = existsSync2(configPath) ? loadTrustConfig(configPath, { validateGlobs: false, rootDir }) : emptyTrustConfig(rootDir ?? options.cwd);
163
- const zones = new Zones(config.rootDir, config.passthrough, config.ignore);
164
- const files = resolved.files.filter((file) => zones.zoneOf(file) !== "ignore");
165
- const skipped = resolved.files.length - files.length;
166
- const strictByConfig = new Set(
167
- files.filter((file) => {
168
- const real = realpathOrSelf(file);
169
- return config.strict.some((group) => groupMatches(group, real));
170
- })
171
- );
172
- const findings = [];
173
- const programs = { tsconfig: options.tsconfig, mappings: config.tsconfig };
174
- const walk = forEachSourceFile(options.cwd, files, programs, ({ ts, program, sourceFile, file }) => {
175
- findings.push(...checkSourceFile({ ts, program, config, sourceFile }));
176
- if (options.strict || strictByConfig.has(file)) {
177
- const relative = relativeTo(config.rootDir, file);
178
- findings.push(...findWrittenReturnTypes(ts, sourceFile).map((finding) => ({ file: relative, ...finding })));
294
+ let svelte;
295
+ let extraRoots;
296
+ try {
297
+ const needed = options.files.some((file) => file.endsWith(".svelte") || readFileSync2(file, "utf8").includes(".svelte"));
298
+ if (!needed) {
299
+ svelte = new SvelteInputs();
300
+ extraRoots = {};
301
+ } else {
302
+ const ts = loadTypeScript(options.cwd);
303
+ svelte = prepareSvelte(ts, options.cwd, options.files, options.programs.tsconfig, options.programs.mappings);
304
+ const grouping = groupByTsconfig(ts, options.cwd, options.files, options.programs.tsconfig, options.programs.mappings);
305
+ if (grouping.kind !== "grouped") return { findings: [], walk: { status: "setup-failed", message: grouping.message } };
306
+ extraRoots = Object.fromEntries([...grouping.groups].map(([owner, files]) => [owner ?? "", svelte.extraRoots(files)]));
179
307
  }
308
+ } catch (error) {
309
+ return { findings: [], walk: error instanceof SvelteFileError ? { status: "file-errors", errors: [error.message] } : { status: "setup-failed", message: error instanceof Error ? error.message : String(error) } };
310
+ }
311
+ const request = JSON.stringify({
312
+ version: NATIVE_PROTOCOL_VERSION,
313
+ cwd: options.cwd,
314
+ rootDir: config.rootDir,
315
+ files: options.files.map((file) => svelte.generated(file)),
316
+ virtualFiles: Object.fromEntries(svelte.virtual),
317
+ virtualPaths: Object.fromEntries(svelte.paths),
318
+ extraRoots,
319
+ programs: options.programs,
320
+ perf: options.perf ?? false,
321
+ rules: { typeClaim: isRuleEnabled(config, "type-claim"), untrustedValue: isRuleEnabled(config, "untrusted-value"), untrustedCallbacks: config.rules.untrustedCallbacks, droppedResult: isRuleEnabled(config, "dropped-result"), redundantGuard: isRuleEnabled(config, "redundant-guard") },
322
+ config: {
323
+ levels: config.levels.map((level) => ({ source: level.source, trust: level.trust, distrust: level.distrust, typeTrust: level.typeTrust, typeDistrust: level.typeDistrust })),
324
+ passthrough: config.passthrough.map((group) => ({ source: group.source, baseDir: group.baseDir, patterns: group.patterns })),
325
+ ignore: config.ignore.map((group) => ({ source: group.source, baseDir: group.baseDir, patterns: group.patterns }))
326
+ },
327
+ strictFiles: options.strictFiles.map((file) => svelte.generated(file))
180
328
  });
181
- if (walk.status !== "ok") {
182
- logWalkFailure(options.log, "check", walk);
329
+ const started = Date.now();
330
+ const result = engine.kind === "binary" ? runBinary(engine.path, request, options.cwd) : await runWasm(engine.path, request);
331
+ if (result.status !== 0) {
332
+ return { findings: [], walk: { status: "setup-failed", message: result.output } };
333
+ }
334
+ let response;
335
+ try {
336
+ const value = JSON.parse(result.output);
337
+ if (!validResponse(value)) throw new Error("Invalid engine response");
338
+ response = value;
339
+ } catch {
340
+ return { findings: [], walk: { status: "setup-failed", message: `trust-native (${engine.kind}) returned malformed output` } };
341
+ }
342
+ if (process.env.TRUST_NATIVE_DEBUG) {
343
+ options.log(
344
+ `trust native: ${engine.kind} engine checked ${response.stats.checkedFiles} file(s): load ${response.stats.loadSeconds.toFixed(1)}s, rules ${response.stats.checkSeconds.toFixed(1)}s, round trip ${((Date.now() - started) / 1e3).toFixed(1)}s`
345
+ );
346
+ if (result.stderr.trim()) options.log(result.stderr.trim());
347
+ }
348
+ if (response.setupError !== null) return { findings: [], walk: { status: "setup-failed", message: response.setupError } };
349
+ if (response.errors.length > 0) return { findings: [], walk: { status: "file-errors", errors: response.errors.map((error) => svelte.error(error)) } };
350
+ const snippetTrusted = decide(config.levels, (level) => level, "svelte.__renderSnippet", "svelte").trusted && !("distrustedBy" in decide(config.levels, (level) => level, "svelte.Snippet", "svelte"));
351
+ const findings = response.findings.flatMap((finding) => {
352
+ const file = resolve3(config.rootDir, finding.file);
353
+ const mapped = svelte.finding(file, finding, snippetTrusted);
354
+ return mapped ? [{ ...mapped, file: svelte.paths.has(file) ? relativeTo(config.rootDir, svelte.original(file)) : finding.file }] : [];
355
+ });
356
+ return { findings, walk: { status: "ok" } };
357
+ }
358
+
359
+ // src/cli/check-command.ts
360
+ async function runCheckCommand(options) {
361
+ const fail = (errors) => {
362
+ if (options.json) options.log(JSON.stringify({ findings: [], errors, warnings: [] }));
363
+ else for (const error of errors) options.log(error);
183
364
  return 2;
365
+ };
366
+ if (options.paths.length === 0) return fail(["trust check needs at least one path: trust check <paths...> [--strict] [--perf] [--json]"]);
367
+ try {
368
+ const resolved = resolveFiles(options.cwd, options.paths);
369
+ if ("missing" in resolved) return fail([`trust check: no such file or directory: ${resolved.missing}`]);
370
+ const configPath = resolve4(options.cwd, options.configFile);
371
+ const rootDir = options.root === void 0 ? void 0 : resolve4(options.cwd, options.root);
372
+ const config = existsSync2(configPath) ? loadTrustConfig(configPath, { rootDir }) : emptyTrustConfig(rootDir ?? options.cwd);
373
+ const warnings = config.unmatchedGlobs.map((line) => `trust check: warning: ${line}`);
374
+ const zones = new Zones(config.rootDir, config.passthrough, config.ignore);
375
+ const files = resolved.files.filter((file) => zones.zoneOf(file) !== "ignore");
376
+ const skipped = resolved.files.length - files.length;
377
+ const strictByConfig = files.filter((file) => config.strict.some((group) => groupMatches(group, realpathOrSelf(file))));
378
+ const result = await checkNative({
379
+ cwd: options.cwd,
380
+ files,
381
+ config,
382
+ programs: { tsconfig: options.tsconfig, mappings: config.tsconfig },
383
+ strictFiles: options.strict ? files : strictByConfig,
384
+ perf: options.perf,
385
+ // Keep --json a single parseable document, even with debugging enabled.
386
+ log: (line) => {
387
+ if (!options.json) options.log(line);
388
+ }
389
+ });
390
+ if (result.walk.status !== "ok") return fail(formatWalkFailure("trust check", result.walk));
391
+ const findings = result.findings.sort(compareFindings).map((finding) => ({ ...finding, severity: finding.severity ?? "error" }));
392
+ const errors = findings.filter((finding) => finding.severity === "error").length;
393
+ const advice = findings.length - errors;
394
+ if (options.json) {
395
+ options.log(JSON.stringify({ findings, errors: [], warnings, summary: { errors, warnings: advice, checkedFiles: files.length, skippedFiles: skipped } }));
396
+ } else {
397
+ for (const warning of warnings) options.log(warning);
398
+ for (const finding of findings) options.log(formatFinding(finding));
399
+ const notes = [];
400
+ if (options.strict) notes.push("strict");
401
+ else if (strictByConfig.length) notes.push(`${strictByConfig.length} strict by config`);
402
+ if (options.perf) notes.push("perf");
403
+ const counts = options.perf ? `${errors} error(s), ${advice} warning(s)` : `${findings.length} finding(s)`;
404
+ options.log(`${counts} in ${files.length} checked file(s), ${skipped} ignored file(s) skipped${notes.length ? ` (${notes.join(", ")})` : ""}.`);
405
+ }
406
+ return errors > 0 ? 1 : 0;
407
+ } catch (error) {
408
+ return fail([`trust check: ${error instanceof Error ? error.message : String(error)}`]);
184
409
  }
185
- findings.sort(compareFindings);
186
- for (const finding of findings) options.log(formatFinding(finding));
187
- const strictNote = options.strict ? " (strict)" : strictByConfig.size > 0 ? ` (${strictByConfig.size} strict by config)` : "";
188
- options.log(`${findings.length} finding(s) in ${files.length} checked file(s), ${skipped} ignored file(s) skipped${strictNote}.`);
189
- return findings.length > 0 ? 1 : 0;
190
410
  }
191
411
 
192
412
  // src/cli/explain.ts
193
- import { resolve as resolve3 } from "path";
413
+ import { resolve as resolve5 } from "path";
194
414
  function clipText(raw) {
195
415
  const text = raw.replace(/\s+/g, " ");
196
416
  return text.length > 80 ? `${text.slice(0, 77)}...` : text;
@@ -200,7 +420,9 @@ function declaredAt(ts, policy, node) {
200
420
  if (!resolved) return null;
201
421
  const source = resolved.declaration.getSourceFile();
202
422
  const { line } = ts.getLineAndCharacterOfPosition(source, resolved.declaration.getStart(source));
203
- return `${source.fileName}:${line + 1}`;
423
+ const inputs = svelteForSource(source);
424
+ const original = inputs?.position(source.fileName, startOf(ts, source, resolved.declaration));
425
+ return `${inputs?.original(source.fileName) ?? source.fileName}:${original?.line ?? line + 1}`;
204
426
  }
205
427
  function explainGuard(call, source, context) {
206
428
  const guard = guardCallOf(call, context);
@@ -213,9 +435,9 @@ var NOT_REPORTED = {
213
435
  };
214
436
  function explain(options) {
215
437
  const ts = loadTypeScript(options.cwd);
216
- const file = resolve3(options.cwd, options.file);
217
- const rootDir = options.root === void 0 ? void 0 : resolve3(options.cwd, options.root);
218
- const config = loadTrustConfig(resolve3(options.cwd, options.configFile), { rootDir });
438
+ const file = resolve5(options.cwd, options.file);
439
+ const rootDir = options.root === void 0 ? void 0 : resolve5(options.cwd, options.root);
440
+ const config = loadTrustConfig(resolve5(options.cwd, options.configFile), { rootDir });
219
441
  const creation = createPrograms(ts, options.cwd, [file], options.tsconfig, config.tsconfig);
220
442
  if (creation.kind !== "created") return creation;
221
443
  const [{ program }] = creation.groups;
@@ -224,7 +446,12 @@ function explain(options) {
224
446
  const checker = program.getTypeChecker();
225
447
  const policy = new TrustPolicy(ts, checker, config);
226
448
  const valueContext = untrustedValueContext(ts, checker, policy);
449
+ const generatedLines = svelteFor(checker)?.generatedLines(source.fileName, options.line);
227
450
  const here = (position) => {
451
+ if (generatedLines && !generatedLines.has(position.line)) return null;
452
+ const mapped = svelteFor(checker)?.position(source.fileName, position);
453
+ if (mapped === null) return null;
454
+ position = mapped ?? position;
228
455
  const onLine = position.line === options.line;
229
456
  return onLine && (options.column === void 0 || position.column === options.column) ? position : null;
230
457
  };
@@ -236,7 +463,11 @@ function explain(options) {
236
463
  calls.push({
237
464
  ...position,
238
465
  text: clipText(node.getText(source)),
239
- verdict: policy.classify(node),
466
+ verdict: (() => {
467
+ const verdict = policy.classify(node);
468
+ const wrapper = policy.lookup("svelte.__renderSnippet", "svelte");
469
+ return verdict.kind === "untrusted" && !verdict.distrustedBy && verdict.origin.origin === "svelte.Snippet" && svelteFor(checker)?.snippetCall(source.fileName, node.getStart(source)) && wrapper.trusted ? { kind: "trusted", origin: verdict.origin, by: wrapper.by } : verdict;
470
+ })(),
240
471
  typeTrust: callTypeVerdict(node, valueContext),
241
472
  guard: ts.isCallExpression(node) ? explainGuard(node, source, valueContext) : null,
242
473
  declaredAt: declaredAt(ts, policy, node)
@@ -269,10 +500,12 @@ function explain(options) {
269
500
  const { finding, acceptance } = entry;
270
501
  const position = here({ line: finding.line, column: finding.column });
271
502
  if (!position) return [];
272
- const directiveLine = positionAt(ts, source, acceptance.directive.pos).line;
503
+ const directivePosition = positionAt(ts, source, acceptance.directive.pos);
504
+ const directiveLine = svelteFor(checker)?.position(source.fileName, directivePosition)?.line ?? directivePosition.line;
273
505
  return [{ ...position, text: clipText(entry.text), rule: finding.rule, origin: finding.origin, why: finding.message, reason: acceptance.reason, directiveLine }];
274
506
  });
275
- return { kind: "explained", explanation: { file, zone: policy.zones.zoneOf(file), calls, claims, values, accepted, off } };
507
+ const unique = (items) => [...new Map(items.map((item) => [JSON.stringify(item), item])).values()];
508
+ return { kind: "explained", explanation: { file, zone: policy.zones.zoneOf(file), calls: unique(calls), claims: unique(claims), values: unique(values), accepted: unique(accepted), off } };
276
509
  }
277
510
  function describe(verdict) {
278
511
  switch (verdict.kind) {
@@ -381,7 +614,7 @@ function formatExplanation(explanation) {
381
614
 
382
615
  // src/cli/refactor-command.ts
383
616
  import { existsSync as existsSync3 } from "fs";
384
- import { join as join2, resolve as resolve4 } from "path";
617
+ import { join as join3, resolve as resolve6 } from "path";
385
618
 
386
619
  // src/core/call-graph.ts
387
620
  var TOP_LEVEL = "(top level)";
@@ -419,10 +652,15 @@ function declarationOf(ts, node) {
419
652
  const chain = [];
420
653
  for (let current = node; !ts.isSourceFile(current); current = current.parent) chain.push(current);
421
654
  if (chain.length === 0) return null;
422
- return nameIn(ts, chain.reverse(), 0, "");
655
+ chain.reverse();
656
+ const virtual = svelteForSource(node.getSourceFile());
657
+ const render = virtual && chain.findIndex((part) => ts.isFunctionDeclaration(part) && part.name?.text === "$$render");
658
+ const index = typeof render === "number" && render >= 0 ? render + 2 : 0;
659
+ return index < chain.length ? nameIn(ts, chain, index, "") : TOP_LEVEL;
423
660
  }
424
661
  function declarationAt(ts, sourceFile, line, column) {
425
- const position = ts.getPositionOfLineAndCharacter(sourceFile, line - 1, column - 1);
662
+ const generated = svelteForSource(sourceFile)?.generatedPositions(sourceFile.fileName, { line, column })[0];
663
+ const position = ts.getPositionOfLineAndCharacter(sourceFile, (generated?.line ?? line) - 1, (generated?.column ?? column) - 1);
426
664
  let node = sourceFile;
427
665
  for (; ; ) {
428
666
  const child = ts.forEachChild(node, (candidate) => candidate.getStart(sourceFile) <= position && position < candidate.end ? candidate : void 0);
@@ -909,7 +1147,7 @@ function internalOrder(group, loaded, config, keyOfTarget, maxGroupSize) {
909
1147
  const checker = program.getTypeChecker();
910
1148
  const policy = policyFor(ts, checker, config);
911
1149
  for (const call of collectCalls(ts, policy, changeOracleFor(ts, checker, policy), sourceFile)) {
912
- const targetFile = keyOfTarget(call.targetFile);
1150
+ const targetFile = keyOfTarget(policy.zones.virtualPaths.get(call.targetFile) ?? call.targetFile);
913
1151
  if (targetFile === void 0 || !inGroup.has(targetFile)) continue;
914
1152
  const from = `${file}#${call.from}`;
915
1153
  const to = `${targetFile}#${call.to}`;
@@ -1040,12 +1278,13 @@ async function runRefactorCommand(options) {
1040
1278
  options.log(`trust refactor: no such file or directory: ${resolved.missing}`);
1041
1279
  return 2;
1042
1280
  }
1043
- const configPath = resolve4(options.cwd, options.configFile);
1044
- const rootDir = options.root === void 0 ? void 0 : resolve4(options.cwd, options.root);
1045
- const config = existsSync3(configPath) ? loadTrustConfig(configPath, { validateGlobs: false, rootDir }) : emptyTrustConfig(rootDir ?? options.cwd);
1281
+ const configPath = resolve6(options.cwd, options.configFile);
1282
+ const rootDir = options.root === void 0 ? void 0 : resolve6(options.cwd, options.root);
1283
+ const config = existsSync3(configPath) ? loadTrustConfig(configPath, { rootDir }) : emptyTrustConfig(rootDir ?? options.cwd);
1284
+ logUnmatchedGlobs(options.log, "refactor", config);
1046
1285
  const zones = new Zones(config.rootDir, config.passthrough, config.ignore);
1047
1286
  const files = resolved.files.filter((file) => zones.zoneOf(file) !== "ignore");
1048
- const baselineFile = resolve4(options.cwd, options.baselineFile ?? join2(config.rootDir, "trust-baseline.json"));
1287
+ const baselineFile = resolve6(options.cwd, options.baselineFile ?? join3(config.rootDir, "trust-baseline.json"));
1049
1288
  const fromBaseline = existsSync3(baselineFile);
1050
1289
  if (!fromBaseline && options.baselineFile !== void 0) {
1051
1290
  options.log(`trust refactor: no such baseline: ${options.baselineFile}`);
@@ -1084,7 +1323,7 @@ async function runRefactorCommand(options) {
1084
1323
  const targets = /* @__PURE__ */ new Map();
1085
1324
  for (const edge of imports.edges) {
1086
1325
  if (options.valueOnly && edge.typeOnly || outside.has(edge.target)) continue;
1087
- const to = keyOfTarget(edge.target);
1326
+ const to = keyOfTarget(policyFor(ts, checker, config).zones.virtualPaths.get(edge.target) ?? edge.target);
1088
1327
  if (to === void 0) outside.add(edge.target);
1089
1328
  if (to === void 0 || to === from) continue;
1090
1329
  let names = targets.get(to);
@@ -1098,7 +1337,10 @@ async function runRefactorCommand(options) {
1098
1337
  dependencies.set(from, new Set(targets.keys()));
1099
1338
  imported.set(from, targets);
1100
1339
  loaded.set(from, { ts, program, sourceFile });
1101
- for (const computed of imports.computed) warnings.push({ kind: "computed-import", file: from, ...computed });
1340
+ for (const computed of imports.computed) {
1341
+ const position = svelteFor(checker)?.position(sourceFile.fileName, computed);
1342
+ if (position !== null) warnings.push({ kind: "computed-import", file: from, ...computed, ...position });
1343
+ }
1102
1344
  if (!fromBaseline && checkSourceFile({ ts, program, config, sourceFile }).length > 0) checked.add(from);
1103
1345
  });
1104
1346
  if (walk.status !== "ok") {
@@ -1175,12 +1417,14 @@ var USAGE = `Usage:
1175
1417
  Check the files with TypeScript alone (no ESLint) and fail on trust violations not in the baseline.
1176
1418
  Files are found and skipped as in trust check; --update rewrites the baseline from the current findings.
1177
1419
  With paths, only the checked files' entries are reported as shrunk or rewritten by --update.
1178
- trust check <paths...> [--strict] [--config trust.config.json] [--tsconfig <path>] [--root <dir>]
1179
- Check the files with TypeScript alone (no ESLint) and fail on any trust violation (no baseline).
1420
+ trust check <paths...> [--strict] [--perf] [--json] [--config trust.config.json] [--tsconfig <path>] [--root <dir>]
1421
+ Check with the native Rust engine (bundled Wasm fallback); .svelte conversion uses TypeScript in Node.
1180
1422
  Each file uses --tsconfig if given, else the first matching "tsconfig" entry of the trust config,
1181
1423
  else the nearest tsconfig.json above it.
1182
1424
  Files in the config's ignore zone are skipped. --strict also fails on written return types
1183
1425
  in every checked file; the config's "strict" globs do the same for the files they match.
1426
+ --perf adds performance warnings, which never fail the check. --json emits findings with severity.
1427
+ Exit codes: 0 clean or warnings only, 1 trust errors, 2 the check could not run.
1184
1428
  trust refactor [paths...] [--json] [--value-only] [--max-group <n>] [--config trust.config.json] [--baseline trust-baseline.json] [--tsconfig <path>] [--root <dir>]
1185
1429
  Print the order to refactor the files with findings in: waves of work items, leaves of the import
1186
1430
  graph first. The items of a wave can be done in parallel; a circular-import group is one item.
@@ -1193,7 +1437,7 @@ var USAGE = `Usage:
1193
1437
  first, and declarations that call each other in a circle are reported with the calls closing it.
1194
1438
  --root <dir> resolves the config's globs, tsconfig paths and baseline keys against <dir> instead of
1195
1439
  the config file's directory (for a config kept outside the project).`;
1196
- var BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["update", "help", "strict", "json", "value-only"]);
1440
+ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["update", "help", "strict", "json", "value-only", "perf"]);
1197
1441
  function parseArgs(argv) {
1198
1442
  const positional = [];
1199
1443
  const flags = /* @__PURE__ */ new Map();
@@ -1204,6 +1448,9 @@ function parseArgs(argv) {
1204
1448
  continue;
1205
1449
  }
1206
1450
  const [name, inline] = arg.slice(2).split("=", 2);
1451
+ if (name === "rs" || name === "go") throw new Error("--rs and --go were removed; trust check uses the native engine automatically");
1452
+ if (!BOOLEAN_FLAGS.has(name) && !["config", "tsconfig", "root", "baseline", "max-group"].includes(name)) throw new Error(`unknown flag --${name}`);
1453
+ if (BOOLEAN_FLAGS.has(name) && inline !== void 0) throw new Error(`--${name} does not take a value`);
1207
1454
  if (inline !== void 0) flags.set(name, inline);
1208
1455
  else if (BOOLEAN_FLAGS.has(name)) flags.set(name, true);
1209
1456
  else {
@@ -1264,6 +1511,8 @@ async function main(argv) {
1264
1511
  strict: flags.get("strict") === true,
1265
1512
  tsconfig: stringFlag(flags, "tsconfig"),
1266
1513
  root: stringFlag(flags, "root"),
1514
+ perf: flags.get("perf") === true,
1515
+ json: flags.get("json") === true,
1267
1516
  log: (line) => console.log(line)
1268
1517
  });
1269
1518
  }