@typeonce/ritmo-devtools 0.14.0 → 0.16.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/CHANGELOG.md +283 -0
- package/README.md +303 -55
- package/dist/Desync.d.ts +23 -3
- package/dist/Desync.d.ts.map +1 -1
- package/dist/Desync.js +17 -15
- package/dist/Desync.js.map +1 -1
- package/dist/Determinism.d.ts +20 -6
- package/dist/Determinism.d.ts.map +1 -1
- package/dist/Determinism.js +11 -3
- package/dist/Determinism.js.map +1 -1
- package/dist/Format.d.ts +43 -8
- package/dist/Format.d.ts.map +1 -1
- package/dist/Format.js +66 -31
- package/dist/Format.js.map +1 -1
- package/dist/Fuzz.d.ts +275 -0
- package/dist/Fuzz.d.ts.map +1 -0
- package/dist/Fuzz.js +362 -0
- package/dist/Fuzz.js.map +1 -0
- package/dist/Invariant.d.ts +9 -2
- package/dist/Invariant.d.ts.map +1 -1
- package/dist/Invariant.js.map +1 -1
- package/dist/Lint.d.ts +11 -5
- package/dist/Lint.d.ts.map +1 -1
- package/dist/Lint.js.map +1 -1
- package/dist/PlaywrightEngine.d.ts +29 -0
- package/dist/PlaywrightEngine.d.ts.map +1 -0
- package/dist/PlaywrightEngine.js +196 -0
- package/dist/PlaywrightEngine.js.map +1 -0
- package/dist/Replay.d.ts +47 -23
- package/dist/Replay.d.ts.map +1 -1
- package/dist/Replay.js +26 -30
- package/dist/Replay.js.map +1 -1
- package/dist/ReplayNodeSink.d.ts.map +1 -1
- package/dist/ReplayNodeSink.js +4 -1
- package/dist/ReplayNodeSink.js.map +1 -1
- package/dist/ReplayVitePlugin.d.ts +1 -0
- package/dist/ReplayVitePlugin.d.ts.map +1 -1
- package/dist/ReplayVitePlugin.js.map +1 -1
- package/dist/Session.d.ts +224 -18
- package/dist/Session.d.ts.map +1 -1
- package/dist/Session.js +571 -58
- package/dist/Session.js.map +1 -1
- package/dist/Verify.d.ts +150 -0
- package/dist/Verify.d.ts.map +1 -0
- package/dist/Verify.js +154 -0
- package/dist/Verify.js.map +1 -0
- package/dist/cli.js +157 -16
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/dependencyScan.d.ts +44 -0
- package/dist/internal/dependencyScan.d.ts.map +1 -0
- package/dist/internal/dependencyScan.js +313 -0
- package/dist/internal/dependencyScan.js.map +1 -0
- package/dist/internal/fuzzNetwork.d.ts +56 -0
- package/dist/internal/fuzzNetwork.d.ts.map +1 -0
- package/dist/internal/fuzzNetwork.js +96 -0
- package/dist/internal/fuzzNetwork.js.map +1 -0
- package/dist/internal/simulationCoverage.d.ts.map +1 -1
- package/dist/internal/simulationCoverage.js +2 -1
- package/dist/internal/simulationCoverage.js.map +1 -1
- package/dist/internal/skillLink.d.ts +14 -0
- package/dist/internal/skillLink.d.ts.map +1 -0
- package/dist/internal/skillLink.js +46 -0
- package/dist/internal/skillLink.js.map +1 -0
- package/dist/internal/values.d.ts +9 -1
- package/dist/internal/values.d.ts.map +1 -1
- package/dist/internal/values.js +11 -1
- package/dist/internal/values.js.map +1 -1
- package/dist/internal/verifyRunner.d.ts +19 -0
- package/dist/internal/verifyRunner.d.ts.map +1 -0
- package/dist/internal/verifyRunner.js +47 -0
- package/dist/internal/verifyRunner.js.map +1 -0
- package/dist/internal/version.d.ts +1 -1
- package/dist/internal/version.js +1 -1
- package/package.json +28 -3
- package/src/Desync.ts +40 -17
- package/src/Determinism.ts +49 -11
- package/src/Format.ts +101 -34
- package/src/Fuzz.ts +551 -0
- package/src/Invariant.ts +9 -2
- package/src/Lint.ts +11 -5
- package/src/PlaywrightEngine.ts +232 -0
- package/src/Replay.ts +100 -47
- package/src/ReplayNodeSink.ts +4 -1
- package/src/ReplayVitePlugin.ts +1 -0
- package/src/Session.ts +816 -73
- package/src/Verify.ts +276 -0
- package/src/cli.ts +150 -15
- package/src/index.ts +3 -2
- package/src/internal/dependencyScan.ts +356 -0
- package/src/internal/fuzzNetwork.ts +130 -0
- package/src/internal/simulationCoverage.ts +2 -1
- package/src/internal/skillLink.ts +53 -0
- package/src/internal/values.ts +20 -1
- package/src/internal/verifyRunner.ts +46 -0
- package/src/internal/version.ts +1 -1
- package/dist/Monitor.d.ts +0 -101
- package/dist/Monitor.d.ts.map +0 -1
- package/dist/Monitor.js +0 -602
- package/dist/Monitor.js.map +0 -1
- package/dist/internal/monitor.d.ts +0 -126
- package/dist/internal/monitor.d.ts.map +0 -1
- package/dist/internal/monitor.js +0 -279
- package/dist/internal/monitor.js.map +0 -1
- package/src/Monitor.ts +0 -713
- package/src/internal/monitor.ts +0 -370
package/dist/cli.js
CHANGED
|
@@ -11,8 +11,10 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
11
11
|
* `ritmo-devtools`: devtools from the command line.
|
|
12
12
|
*
|
|
13
13
|
* ritmo-devtools lint <entry>
|
|
14
|
+
* ritmo-devtools verify <entry> <replay> [--engines node,chromium,webkit,firefox] [--json]
|
|
15
|
+
* ritmo-devtools scan <entry> [--json]
|
|
14
16
|
*
|
|
15
|
-
*
|
|
17
|
+
* `lint` imports `<entry>` (a module exporting `lintTarget`, see the `Lint` module),
|
|
16
18
|
* prints every lint of its schedules with its fix, and exits with 1 when one
|
|
17
19
|
* is a warning. Info-level lints are printed and do not fail.
|
|
18
20
|
*
|
|
@@ -27,18 +29,57 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
27
29
|
* A missing or unreadable config, one with `extends`, or one that never turns
|
|
28
30
|
* the rule on prints why the check was skipped and does not fail.
|
|
29
31
|
*
|
|
30
|
-
*
|
|
32
|
+
* Last, it notes when the project does not link the Ritmo skill from the
|
|
33
|
+
* installed package (`.agents/skills/ritmo` or `.claude/skills/ritmo`, see
|
|
34
|
+
* `SETUP.md`), or holds a copy that goes stale on upgrade. The note never
|
|
35
|
+
* fails the lint.
|
|
36
|
+
*
|
|
37
|
+
* `verify` imports `<entry>` (a module exporting `replayTarget`, the
|
|
38
|
+
* `make(playback)` factory `Replay.session` takes), plays the replay file in
|
|
39
|
+
* Node and in each listed browser engine, and prints the first tick whose
|
|
40
|
+
* checksum differs from Node's, with every value that differs there (see the
|
|
41
|
+
* `Verify` module). Node always runs, as the reference; `--engines node` (the
|
|
42
|
+
* default) needs no other dependency. Browser engines need `playwright` and
|
|
43
|
+
* `vite` (see the `PlaywrightEngine` module); one that is not installed is
|
|
44
|
+
* printed with its install command and fails the check. `--json` prints the
|
|
45
|
+
* result as JSON instead of text.
|
|
46
|
+
*
|
|
47
|
+
* `scan` resolves every file `<entry>` (the simulation entry) imports,
|
|
48
|
+
* `node_modules` included, and runs the oxlint rules `ritmo/use-ops-for-math`,
|
|
49
|
+
* `ritmo/use-clock-for-time`, and `ritmo/use-random-for-randomness` over them,
|
|
50
|
+
* so a dependency that calls `Math.sin`, `Date.now`, or `Math.random` shows
|
|
51
|
+
* before a desync does. Findings are printed per package with what to do next;
|
|
52
|
+
* `--json` prints them as JSON instead. It is a hint, not a verdict: it exits
|
|
53
|
+
* with 0 with or without findings. It needs `rolldown` (Vite 8 includes it)
|
|
54
|
+
* and the game's `oxlint` with `@typeonce/oxlint-plugin-ritmo`; a missing one
|
|
55
|
+
* is printed with its install command and exits with 2.
|
|
56
|
+
*
|
|
57
|
+
* Exit codes: 0 ok (and every `scan` that ran), 1 lint warning, uncovered
|
|
58
|
+
* module, or an engine that differs or did not run, 2 usage error (for `scan`
|
|
59
|
+
* also an unreadable entry, an import that does not resolve, or a missing tool).
|
|
31
60
|
* Requires Node 22.15 or later for `module.registerHooks`; on older Node it
|
|
32
61
|
* prints that coverage was not checked.
|
|
33
62
|
*
|
|
34
63
|
* @module cli
|
|
35
64
|
* @docGroup devtools
|
|
36
65
|
*/
|
|
66
|
+
import { readFileSync } from "node:fs";
|
|
37
67
|
import { resolve } from "node:path";
|
|
38
68
|
import { pathToFileURL } from "node:url";
|
|
69
|
+
import * as DependencyScan from "./internal/dependencyScan.js";
|
|
39
70
|
import * as SimulationCoverage from "./internal/simulationCoverage.js";
|
|
71
|
+
import * as SkillLink from "./internal/skillLink.js";
|
|
40
72
|
import * as Lint from "./Lint.js";
|
|
41
|
-
|
|
73
|
+
import * as Replay from "./Replay.js";
|
|
74
|
+
import * as Verify from "./Verify.js";
|
|
75
|
+
const usage = [
|
|
76
|
+
"usage: ritmo-devtools lint <entry>",
|
|
77
|
+
" ritmo-devtools verify <entry> <replay> [--engines node,chromium,webkit,firefox] [--json]",
|
|
78
|
+
" ritmo-devtools scan <entry> [--json]",
|
|
79
|
+
" lint: <entry> exports lintTarget: () => { runtime, schedules, describe?, hostEvents? } (see the Lint module)",
|
|
80
|
+
" verify: <entry> exports replayTarget: (playback) => { runtime, schedules, hostClock } (see the Verify module)",
|
|
81
|
+
" scan: <entry> is the simulation's entry module; every file it imports, node_modules included, is checked for Math, clock, and randomness calls"
|
|
82
|
+
].join("\n");
|
|
42
83
|
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
43
84
|
/** Checks at runtime what the type of `lintTarget`'s result promises, so a wrong entry fails with a message. */
|
|
44
85
|
const isTarget = (value) => isRecord(value)
|
|
@@ -49,11 +90,17 @@ const isTarget = (value) => isRecord(value)
|
|
|
49
90
|
&& (value["describe"] === undefined || isRecord(value["describe"]))
|
|
50
91
|
&& (value["hostEvents"] === undefined || Array.isArray(value["hostEvents"]));
|
|
51
92
|
const main = async (args) => {
|
|
52
|
-
const [command,
|
|
53
|
-
if (command
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
93
|
+
const [command, ...rest] = args;
|
|
94
|
+
if (command === "lint" && rest.length === 1)
|
|
95
|
+
return lint(rest[0]);
|
|
96
|
+
if (command === "verify")
|
|
97
|
+
return verify(rest);
|
|
98
|
+
if (command === "scan")
|
|
99
|
+
return scan(rest);
|
|
100
|
+
console.error(usage);
|
|
101
|
+
return 2;
|
|
102
|
+
};
|
|
103
|
+
const lint = async (entry) => {
|
|
57
104
|
const loads = SimulationCoverage.recordLoads();
|
|
58
105
|
const loaded = await import(__rewriteRelativeImportExtension(pathToFileURL(resolve(entry)).href));
|
|
59
106
|
// Snapshot before lintTarget runs: modules it imports (render schedules to describe) are host code.
|
|
@@ -70,15 +117,109 @@ const main = async (args) => {
|
|
|
70
117
|
}
|
|
71
118
|
const report = Lint.run(target);
|
|
72
119
|
console.log(report.text);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
120
|
+
const status = (() => {
|
|
121
|
+
if (simulationModules === undefined) {
|
|
122
|
+
console.log("simulation coverage not checked: needs Node 22.15 or later (module.registerHooks)");
|
|
123
|
+
return report.data.ok ? 0 : 1;
|
|
124
|
+
}
|
|
125
|
+
const coverage = SimulationCoverage.check(process.cwd(), resolve(entry), simulationModules);
|
|
126
|
+
const text = SimulationCoverage.format(coverage);
|
|
127
|
+
if (text !== "")
|
|
128
|
+
console.log(text);
|
|
129
|
+
return report.data.ok && (!coverage.checked || coverage.uncovered.length === 0) ? 0 : 1;
|
|
130
|
+
})();
|
|
131
|
+
// A note only: it never changes the exit code.
|
|
132
|
+
const skill = SkillLink.format(SkillLink.check(process.cwd()));
|
|
133
|
+
if (skill !== "")
|
|
134
|
+
console.log(skill);
|
|
135
|
+
return status;
|
|
136
|
+
};
|
|
137
|
+
const engineNames = ["node", "chromium", "webkit", "firefox"];
|
|
138
|
+
const verify = async (args) => {
|
|
139
|
+
const positional = [];
|
|
140
|
+
let engines = ["node"];
|
|
141
|
+
let json = false;
|
|
142
|
+
for (let index = 0; index < args.length; index++) {
|
|
143
|
+
const arg = args[index];
|
|
144
|
+
if (arg === "--json")
|
|
145
|
+
json = true;
|
|
146
|
+
else if (arg === "--engines")
|
|
147
|
+
engines = (args[++index] ?? "").split(",").filter((name) => name !== "");
|
|
148
|
+
else if (arg.startsWith("--engines="))
|
|
149
|
+
engines = arg.slice("--engines=".length).split(",").filter((name) => name !== "");
|
|
150
|
+
else
|
|
151
|
+
positional.push(arg);
|
|
152
|
+
}
|
|
153
|
+
const [entry, replay] = positional;
|
|
154
|
+
if (entry === undefined || replay === undefined || positional.length !== 2) {
|
|
155
|
+
console.error(usage);
|
|
156
|
+
return 2;
|
|
157
|
+
}
|
|
158
|
+
const unknown = engines.filter((name) => !engineNames.includes(name));
|
|
159
|
+
if (engines.length === 0 || unknown.length > 0) {
|
|
160
|
+
console.error(`--engines takes a comma-separated list of ${engineNames.join(", ")}${unknown.length > 0 ? `; unknown: ${unknown.join(", ")}` : ""}`);
|
|
161
|
+
return 2;
|
|
162
|
+
}
|
|
163
|
+
let data;
|
|
164
|
+
try {
|
|
165
|
+
data = JSON.parse(readFileSync(resolve(replay), "utf8"));
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
console.error(`${replay} could not be read as JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
169
|
+
return 2;
|
|
170
|
+
}
|
|
171
|
+
const file = Replay.parse(data);
|
|
172
|
+
if (!file.ok) {
|
|
173
|
+
console.error(`${replay} is not a replay file: ${file.error._tag === "InvalidReplay" ? file.error.message : file.error._tag}`);
|
|
174
|
+
return 2;
|
|
175
|
+
}
|
|
176
|
+
const loaded = await import(__rewriteRelativeImportExtension(pathToFileURL(resolve(entry)).href));
|
|
177
|
+
const make = isRecord(loaded) ? loaded["replayTarget"] : undefined;
|
|
178
|
+
if (typeof make !== "function") {
|
|
179
|
+
console.error(`${entry} must export replayTarget: (playback) => { runtime, schedules, hostClock } (see the Verify module)`);
|
|
180
|
+
return 2;
|
|
181
|
+
}
|
|
182
|
+
// The browser adapter, and with it playwright and vite, loads only when a browser is listed.
|
|
183
|
+
const browsers = engines.filter((name) => name !== "node");
|
|
184
|
+
const PlaywrightEngine = browsers.length > 0 ? await import("./PlaywrightEngine.js") : undefined;
|
|
185
|
+
const playwright = PlaywrightEngine?.make({ entry, browsers: browsers.filter(PlaywrightEngine.isBrowser) });
|
|
186
|
+
let result;
|
|
187
|
+
try {
|
|
188
|
+
// The entry's type is checked where it is written; here only its shape is known.
|
|
189
|
+
result = await Verify.acrossEngines(make, file.value, { engines: playwright?.engines ?? [] });
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
console.error(`replayTarget in ${entry} threw: ${error instanceof Error ? error.stack ?? error.message : String(error)}`);
|
|
193
|
+
return 2;
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
await playwright?.close();
|
|
197
|
+
}
|
|
198
|
+
console.log(json ? JSON.stringify(result.ok ? { ok: true, ...result.value.data } : { ok: false, ...withoutText(result.error) }, null, 2) : result.ok ? result.value.text : result.error.text);
|
|
199
|
+
return result.ok ? 0 : 1;
|
|
200
|
+
};
|
|
201
|
+
const scan = async (args) => {
|
|
202
|
+
const json = args.includes("--json");
|
|
203
|
+
const positional = args.filter((arg) => arg !== "--json");
|
|
204
|
+
if (positional.length !== 1 || positional[0].startsWith("-")) {
|
|
205
|
+
console.error(usage);
|
|
206
|
+
return 2;
|
|
207
|
+
}
|
|
208
|
+
const result = await DependencyScan.run(positional[0], process.cwd());
|
|
209
|
+
if (!result.ok) {
|
|
210
|
+
const error = result.error;
|
|
211
|
+
console.error(error._tag === "ToolMissing"
|
|
212
|
+
? `scan needs ${error.tool}, which is not installed: ${error.install}`
|
|
213
|
+
: error._tag === "ResolveFailed"
|
|
214
|
+
? `the imports of ${positional[0]} could not be resolved: ${error.message}`
|
|
215
|
+
: error._tag === "LintFailed"
|
|
216
|
+
? `oxlint did not run: ${error.message}`
|
|
217
|
+
: error.message);
|
|
218
|
+
return 2;
|
|
76
219
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (text !== "")
|
|
80
|
-
console.log(text);
|
|
81
|
-
return report.data.ok && (!coverage.checked || coverage.uncovered.length === 0) ? 0 : 1;
|
|
220
|
+
console.log(json ? JSON.stringify(result.value, null, 2) : DependencyScan.format(result.value));
|
|
221
|
+
return 0;
|
|
82
222
|
};
|
|
223
|
+
const withoutText = ({ text: _text, ...error }) => error;
|
|
83
224
|
process.exitCode = await main(process.argv.slice(2));
|
|
84
225
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;AACA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,KAAK,cAAc,MAAM,8BAA8B,CAAA;AAC9D,OAAO,KAAK,kBAAkB,MAAM,kCAAkC,CAAA;AACtE,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAA;AACpD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,MAAM,KAAK,GAAG;IACZ,oCAAoC;IACpC,iGAAiG;IACjG,6CAA6C;IAC7C,kHAAkH;IAClH,iHAAiH;IACjH,oJAAoJ;CACrJ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEZ,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAA;AAElH,gHAAgH;AAChH,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAkC,EAAE,CAClE,QAAQ,CAAC,KAAK,CAAC;OACZ,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;OAC1B,QAAQ,CAAC,KAAK,CAAC,SAAS,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,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Headless debug sessions, trace history, text reports, replays, and fuzzing for ritmo runtimes. */
|
|
2
2
|
export * as Format from "./Format.ts";
|
|
3
|
+
export * as Fuzz from "./Fuzz.ts";
|
|
3
4
|
export * as Desync from "./Desync.ts";
|
|
4
5
|
export * as Determinism from "./Determinism.ts";
|
|
5
6
|
export * as Invariant from "./Invariant.ts";
|
|
6
7
|
export * as Lint from "./Lint.ts";
|
|
7
|
-
export * as Monitor from "./Monitor.ts";
|
|
8
8
|
export * as Replay from "./Replay.ts";
|
|
9
9
|
export * as Rendered from "./Rendered.ts";
|
|
10
10
|
export * as Session from "./Session.ts";
|
|
11
|
+
export * as Verify from "./Verify.ts";
|
|
11
12
|
/** The package's identifier. */
|
|
12
13
|
export declare const packageTag: "devtools";
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAG,UAAmB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Headless debug sessions, trace history, text reports, replays, and fuzzing for ritmo runtimes. */
|
|
2
2
|
export * as Format from "./Format.js";
|
|
3
|
+
export * as Fuzz from "./Fuzz.js";
|
|
3
4
|
export * as Desync from "./Desync.js";
|
|
4
5
|
export * as Determinism from "./Determinism.js";
|
|
5
6
|
export * as Invariant from "./Invariant.js";
|
|
6
7
|
export * as Lint from "./Lint.js";
|
|
7
|
-
export * as Monitor from "./Monitor.js";
|
|
8
8
|
export * as Replay from "./Replay.js";
|
|
9
9
|
export * as Rendered from "./Rendered.js";
|
|
10
10
|
export * as Session from "./Session.js";
|
|
11
|
+
export * as Verify from "./Verify.js";
|
|
11
12
|
/** The package's identifier. */
|
|
12
13
|
export const packageTag = "devtools";
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,gCAAgC;AAChC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAmB,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as Result from "@typeonce/ritmo/Result";
|
|
2
|
+
/** The rules the scan runs: the determinism rules a dependency can break. */
|
|
3
|
+
export declare const rules: readonly ["ritmo/use-ops-for-math", "ritmo/use-clock-for-time", "ritmo/use-random-for-randomness"];
|
|
4
|
+
export type Rule = (typeof rules)[number];
|
|
5
|
+
/** One report of a rule, at a 1-based line and column (UTF-16) in a file relative to the working directory. */
|
|
6
|
+
export interface Finding {
|
|
7
|
+
readonly file: string;
|
|
8
|
+
readonly line: number;
|
|
9
|
+
readonly column: number;
|
|
10
|
+
readonly rule: Rule;
|
|
11
|
+
/** The flagged source (`Math.sin`, `x ** 3`, `Date.now`), shortened to one line. */
|
|
12
|
+
readonly snippet: string;
|
|
13
|
+
}
|
|
14
|
+
/** Findings of the files that belong to one package (nearest `package.json` with a `name`). */
|
|
15
|
+
export interface PackageReport {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly files: number;
|
|
18
|
+
readonly findings: ReadonlyArray<Finding>;
|
|
19
|
+
}
|
|
20
|
+
/** The scan result; `packages` starts with the entry's own package, then the rest by name. */
|
|
21
|
+
export interface Report {
|
|
22
|
+
readonly entry: string;
|
|
23
|
+
readonly files: number;
|
|
24
|
+
readonly packages: ReadonlyArray<PackageReport>;
|
|
25
|
+
}
|
|
26
|
+
export type ScanError = {
|
|
27
|
+
readonly _tag: "EntryUnreadable";
|
|
28
|
+
readonly message: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly _tag: "ToolMissing";
|
|
31
|
+
readonly tool: string;
|
|
32
|
+
readonly install: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly _tag: "ResolveFailed";
|
|
35
|
+
readonly message: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly _tag: "LintFailed";
|
|
38
|
+
readonly message: string;
|
|
39
|
+
};
|
|
40
|
+
/** Scans the import closure of `entry`; paths in the report are relative to `cwd`. */
|
|
41
|
+
export declare const run: (entry: string, cwd: string) => Promise<Result.Result<Report, ScanError>>;
|
|
42
|
+
/** The text report: findings grouped by package, a summary line, and what to do next. */
|
|
43
|
+
export declare const format: (report: Report) => string;
|
|
44
|
+
//# sourceMappingURL=dependencyScan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencyScan.d.ts","sourceRoot":"","sources":["../../src/internal/dependencyScan.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAA;AAEhD,6EAA6E;AAC7E,eAAO,MAAM,KAAK,YAAI,wBAAwB,EAAE,0BAA0B,EAAE,iCAAiC,CAAU,CAAA;AAEvH,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAA;AAEzC,+GAA+G;AAC/G,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED,+FAA+F;AAC/F,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CAC1C;AAED,8FAA8F;AAC9F,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,CAAA;CAChD;AAED,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC9D;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACjF;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAqN7D,sFAAsF;AACtF,eAAO,MAAM,GAAG,UAAiB,MAAM,OAAO,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAmD9F,CAAA;AAID,yFAAyF;AACzF,eAAO,MAAM,MAAM,WAAY,MAAM,KAAG,MAgBvC,CAAA"}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The dependency determinism scan behind `ritmo-devtools scan <entry>` (Node
|
|
11
|
+
* only): every file the simulation entry imports, `node_modules` included,
|
|
12
|
+
* checked with the oxlint rules `ritmo/use-ops-for-math`,
|
|
13
|
+
* `ritmo/use-clock-for-time`, and `ritmo/use-random-for-randomness`.
|
|
14
|
+
*
|
|
15
|
+
* The import closure comes from rolldown: a real bundler resolves exactly
|
|
16
|
+
* what a game's build resolves (package `exports`, `browser` fields, CJS and
|
|
17
|
+
* ESM, TypeScript with type-only imports erased), and its module graph
|
|
18
|
+
* (`this.getModuleIds()`) lists every loaded file, including ones tree-shaking
|
|
19
|
+
* would drop. Rolldown is what Vite 8 builds with, so a game with Vite 8 needs
|
|
20
|
+
* nothing new: it is found as Vite's own dependency when the game does not
|
|
21
|
+
* install it directly. esbuild (through tsx) was the alternative, but Vite 8
|
|
22
|
+
* no longer depends on it, so fewer games would have it.
|
|
23
|
+
*
|
|
24
|
+
* The files are checked by spawning the game's own `oxlint` with
|
|
25
|
+
* `@typeonce/oxlint-plugin-ritmo` (both are in every game's setup) and a
|
|
26
|
+
* generated config that turns on only those three rules. Running the rules
|
|
27
|
+
* themselves, not a scanner that mirrors them, keeps one definition of what is
|
|
28
|
+
* flagged: the scan reports exactly what the lint would report if the
|
|
29
|
+
* dependency were the game's code, and what `oxlint --fix` fixes after the
|
|
30
|
+
* dependency is vendored.
|
|
31
|
+
*
|
|
32
|
+
* Each tool is looked up from the entry's directory first, then from devtools
|
|
33
|
+
* (`oxlint` and `rolldown` are optional peer dependencies).
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
import { spawnSync } from "node:child_process";
|
|
38
|
+
import { existsSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
39
|
+
import { tmpdir } from "node:os";
|
|
40
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
41
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
42
|
+
import * as Result from "@typeonce/ritmo/Result";
|
|
43
|
+
/** The rules the scan runs: the determinism rules a dependency can break. */
|
|
44
|
+
export const rules = ["ritmo/use-ops-for-math", "ritmo/use-clock-for-time", "ritmo/use-random-for-randomness"];
|
|
45
|
+
const sourceFile = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
46
|
+
const chunkSize = 400;
|
|
47
|
+
const unnamed = "(no package)";
|
|
48
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
49
|
+
const readJson = (path) => {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/** The real directory of the installed package `name`, looked up through `node_modules` from `from` upward. */
|
|
58
|
+
const findPackage = (name, from) => {
|
|
59
|
+
for (let directory = from;; directory = dirname(directory)) {
|
|
60
|
+
const candidate = join(directory, "node_modules", name);
|
|
61
|
+
if (existsSync(join(candidate, "package.json")))
|
|
62
|
+
return realpathSync(candidate);
|
|
63
|
+
if (dirname(directory) === directory)
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const exportTarget = (value) => {
|
|
68
|
+
if (typeof value === "string")
|
|
69
|
+
return value;
|
|
70
|
+
if (Array.isArray(value))
|
|
71
|
+
return exportTarget(value[0]);
|
|
72
|
+
if (!isRecord(value))
|
|
73
|
+
return undefined;
|
|
74
|
+
for (const [condition, target] of Object.entries(value)) {
|
|
75
|
+
if (condition === "import" || condition === "node" || condition === "default") {
|
|
76
|
+
const found = exportTarget(target);
|
|
77
|
+
if (found !== undefined)
|
|
78
|
+
return found;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
};
|
|
83
|
+
/** The file the package's main entry imports (`exports["."]` with `import`/`node`/`default`, then `module`, `main`). */
|
|
84
|
+
const packageEntry = (directory) => {
|
|
85
|
+
const manifest = readJson(join(directory, "package.json"));
|
|
86
|
+
const record = isRecord(manifest) ? manifest : {};
|
|
87
|
+
const exports = record["exports"];
|
|
88
|
+
const main = isRecord(exports) && "." in exports ? exports["."] : exports;
|
|
89
|
+
const target = exportTarget(main)
|
|
90
|
+
?? (typeof record["module"] === "string" ? record["module"] : undefined)
|
|
91
|
+
?? (typeof record["main"] === "string" ? record["main"] : "index.js");
|
|
92
|
+
return join(directory, target);
|
|
93
|
+
};
|
|
94
|
+
const devtoolsDirectory = dirname(fileURLToPath(import.meta.url));
|
|
95
|
+
const locate = (name, from) => findPackage(name, from) ?? findPackage(name, devtoolsDirectory);
|
|
96
|
+
/** Rolldown, installed directly or as Vite 8's dependency. */
|
|
97
|
+
const loadRolldown = async (from) => {
|
|
98
|
+
const vite = locate("vite", from);
|
|
99
|
+
const directory = locate("rolldown", from) ?? (vite === undefined ? undefined : findPackage("rolldown", vite));
|
|
100
|
+
if (directory === undefined)
|
|
101
|
+
return undefined;
|
|
102
|
+
const loaded = await import(__rewriteRelativeImportExtension(pathToFileURL(packageEntry(directory)).href));
|
|
103
|
+
const rolldown = isRecord(loaded) ? loaded["rolldown"] : undefined;
|
|
104
|
+
// The module is untyped here (an optional peer); only its shape was checked.
|
|
105
|
+
return typeof rolldown === "function" ? rolldown : undefined;
|
|
106
|
+
};
|
|
107
|
+
/** Every source file the entry imports, itself included, as real absolute paths. */
|
|
108
|
+
const closure = async (rolldown, entry) => {
|
|
109
|
+
let ids = [];
|
|
110
|
+
const bundle = await rolldown({
|
|
111
|
+
input: entry,
|
|
112
|
+
cwd: dirname(entry),
|
|
113
|
+
// The build that ships to players; Node builtins stay external.
|
|
114
|
+
platform: "browser",
|
|
115
|
+
treeshake: false,
|
|
116
|
+
logLevel: "silent",
|
|
117
|
+
plugins: [{
|
|
118
|
+
name: "ritmo-devtools-scan",
|
|
119
|
+
buildEnd() {
|
|
120
|
+
ids = [...this.getModuleIds()];
|
|
121
|
+
}
|
|
122
|
+
}]
|
|
123
|
+
});
|
|
124
|
+
try {
|
|
125
|
+
await bundle.generate({});
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
await bundle.close();
|
|
129
|
+
}
|
|
130
|
+
return [...new Set(ids.filter((id) => isAbsolute(id) && sourceFile.test(id) && existsSync(id)).map((id) => realpathSync(id)))].sort();
|
|
131
|
+
};
|
|
132
|
+
const parseDiagnostics = (stdout) => {
|
|
133
|
+
let parsed;
|
|
134
|
+
try {
|
|
135
|
+
parsed = JSON.parse(stdout);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
if (!isRecord(parsed) || !Array.isArray(parsed["diagnostics"]))
|
|
141
|
+
return undefined;
|
|
142
|
+
const out = [];
|
|
143
|
+
for (const diagnostic of parsed["diagnostics"]) {
|
|
144
|
+
if (!isRecord(diagnostic) || typeof diagnostic["code"] !== "string" || typeof diagnostic["filename"] !== "string")
|
|
145
|
+
continue;
|
|
146
|
+
const rule = diagnostic["code"].replace(/^ritmo\((.*)\)$/, "ritmo/$1");
|
|
147
|
+
const label = Array.isArray(diagnostic["labels"]) ? diagnostic["labels"][0] : undefined;
|
|
148
|
+
const span = isRecord(label) && isRecord(label["span"]) ? label["span"] : undefined;
|
|
149
|
+
if (!rules.includes(rule) || span === undefined)
|
|
150
|
+
continue;
|
|
151
|
+
if (typeof span["offset"] !== "number" || typeof span["length"] !== "number")
|
|
152
|
+
continue;
|
|
153
|
+
out.push({ file: diagnostic["filename"], rule: rule, offset: span["offset"], length: span["length"] });
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
};
|
|
157
|
+
const lint = (oxlint, plugin, files) => {
|
|
158
|
+
const directory = mkdtempSync(join(tmpdir(), "ritmo-scan-"));
|
|
159
|
+
try {
|
|
160
|
+
const config = join(directory, "oxlintrc.json");
|
|
161
|
+
writeFileSync(config, JSON.stringify({
|
|
162
|
+
jsPlugins: [plugin],
|
|
163
|
+
categories: { correctness: "off" },
|
|
164
|
+
rules: Object.fromEntries(rules.map((rule) => [rule, "error"])),
|
|
165
|
+
ignorePatterns: []
|
|
166
|
+
}));
|
|
167
|
+
const diagnostics = [];
|
|
168
|
+
for (let start = 0; start < files.length; start += chunkSize) {
|
|
169
|
+
const run = spawnSync(process.execPath, [oxlint, "-c", config, "--format", "json", "--no-ignore", "--disable-nested-config", ...files.slice(start, start + chunkSize)], { encoding: "utf8", maxBuffer: 1024 * 1024 * 1024 });
|
|
170
|
+
const parsed = parseDiagnostics(run.stdout ?? "");
|
|
171
|
+
if (parsed === undefined) {
|
|
172
|
+
return Result.failure({ _tag: "LintFailed", message: (run.stderr || run.stdout || run.error?.message || "no output").trim() });
|
|
173
|
+
}
|
|
174
|
+
diagnostics.push(...parsed);
|
|
175
|
+
}
|
|
176
|
+
return Result.success(diagnostics);
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
rmSync(directory, { recursive: true, force: true });
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const shorten = (text) => {
|
|
183
|
+
const line = text.replace(/\s+/g, " ").trim();
|
|
184
|
+
return line.length > 60 ? `${line.slice(0, 59)}…` : line;
|
|
185
|
+
};
|
|
186
|
+
/** Line, column (UTF-16), and snippet of each byte span (oxlint reports UTF-8 offsets), walking the file once. */
|
|
187
|
+
const locateSpans = (path, cwd, found) => {
|
|
188
|
+
const bytes = readFileSync(path);
|
|
189
|
+
const file = relative(cwd, path);
|
|
190
|
+
const sorted = [...found].sort((a, b) => a.offset - b.offset);
|
|
191
|
+
const out = [];
|
|
192
|
+
let cursor = 0;
|
|
193
|
+
let line = 1;
|
|
194
|
+
let column = 1;
|
|
195
|
+
for (const diagnostic of sorted) {
|
|
196
|
+
const end = Math.min(diagnostic.offset, bytes.length);
|
|
197
|
+
let lineStart = cursor;
|
|
198
|
+
for (let index = cursor; index < end; index++) {
|
|
199
|
+
if (bytes[index] === 0x0a) {
|
|
200
|
+
line++;
|
|
201
|
+
column = 1;
|
|
202
|
+
lineStart = index + 1;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
column += bytes.subarray(lineStart, end).toString("utf8").length;
|
|
206
|
+
cursor = end;
|
|
207
|
+
out.push({
|
|
208
|
+
file,
|
|
209
|
+
line,
|
|
210
|
+
column,
|
|
211
|
+
rule: diagnostic.rule,
|
|
212
|
+
snippet: shorten(bytes.subarray(diagnostic.offset, diagnostic.offset + diagnostic.length).toString("utf8"))
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return out;
|
|
216
|
+
};
|
|
217
|
+
/** The `name` of the nearest `package.json` above `file` that has one. */
|
|
218
|
+
const packageOf = (cache, file) => {
|
|
219
|
+
const visited = [];
|
|
220
|
+
let name;
|
|
221
|
+
for (let directory = dirname(file);; directory = dirname(directory)) {
|
|
222
|
+
if (cache.has(directory)) {
|
|
223
|
+
name = cache.get(directory);
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
visited.push(directory);
|
|
227
|
+
const manifest = readJson(join(directory, "package.json"));
|
|
228
|
+
if (isRecord(manifest) && typeof manifest["name"] === "string" && manifest["name"] !== "") {
|
|
229
|
+
name = manifest["name"];
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
if (dirname(directory) === directory)
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
for (const directory of visited)
|
|
236
|
+
cache.set(directory, name);
|
|
237
|
+
return name;
|
|
238
|
+
};
|
|
239
|
+
/** Scans the import closure of `entry`; paths in the report are relative to `cwd`. */
|
|
240
|
+
export const run = async (entry, cwd) => {
|
|
241
|
+
const absolute = resolve(cwd, entry);
|
|
242
|
+
try {
|
|
243
|
+
if (!statSync(absolute).isFile())
|
|
244
|
+
return Result.failure({ _tag: "EntryUnreadable", message: `${entry} is not a file` });
|
|
245
|
+
readFileSync(absolute);
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
return Result.failure({ _tag: "EntryUnreadable", message: `${entry} could not be read: ${error instanceof Error ? error.message : String(error)}` });
|
|
249
|
+
}
|
|
250
|
+
const from = dirname(realpathSync(absolute));
|
|
251
|
+
const rolldown = await loadRolldown(from);
|
|
252
|
+
if (rolldown === undefined) {
|
|
253
|
+
return Result.failure({ _tag: "ToolMissing", tool: "rolldown (or vite 8, which includes it)", install: "npm install --save-dev rolldown" });
|
|
254
|
+
}
|
|
255
|
+
const oxlint = locate("oxlint", from);
|
|
256
|
+
const plugin = locate("@typeonce/oxlint-plugin-ritmo", from);
|
|
257
|
+
if (oxlint === undefined || plugin === undefined) {
|
|
258
|
+
return Result.failure({ _tag: "ToolMissing", tool: "oxlint with @typeonce/oxlint-plugin-ritmo", install: "npm install --save-dev oxlint @typeonce/oxlint-plugin-ritmo" });
|
|
259
|
+
}
|
|
260
|
+
const manifest = readJson(join(oxlint, "package.json"));
|
|
261
|
+
const bin = isRecord(manifest) ? manifest["bin"] : undefined;
|
|
262
|
+
const oxlintBin = join(oxlint, typeof bin === "string" ? bin : isRecord(bin) && typeof bin["oxlint"] === "string" ? bin["oxlint"] : "bin/oxlint");
|
|
263
|
+
let files;
|
|
264
|
+
try {
|
|
265
|
+
files = await closure(rolldown, realpathSync(absolute));
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
return Result.failure({ _tag: "ResolveFailed", message: error instanceof Error ? error.message : String(error) });
|
|
269
|
+
}
|
|
270
|
+
const diagnostics = lint(oxlintBin, packageEntry(plugin), files);
|
|
271
|
+
if (!diagnostics.ok)
|
|
272
|
+
return diagnostics;
|
|
273
|
+
const base = realpathSync(cwd);
|
|
274
|
+
const byFile = new Map();
|
|
275
|
+
for (const diagnostic of diagnostics.value) {
|
|
276
|
+
const path = realpathSync(diagnostic.file);
|
|
277
|
+
byFile.set(path, [...(byFile.get(path) ?? []), diagnostic]);
|
|
278
|
+
}
|
|
279
|
+
const cache = new Map();
|
|
280
|
+
const own = packageOf(cache, realpathSync(absolute)) ?? unnamed;
|
|
281
|
+
const groups = new Map([[own, { files: 0, findings: [] }]]);
|
|
282
|
+
for (const file of files) {
|
|
283
|
+
const name = packageOf(cache, file) ?? unnamed;
|
|
284
|
+
const group = groups.get(name) ?? { files: 0, findings: [] };
|
|
285
|
+
group.files++;
|
|
286
|
+
group.findings.push(...locateSpans(file, base, byFile.get(file) ?? []));
|
|
287
|
+
groups.set(name, group);
|
|
288
|
+
}
|
|
289
|
+
const packages = [...groups]
|
|
290
|
+
.sort(([a], [b]) => a === own ? -1 : b === own ? 1 : a.localeCompare(b))
|
|
291
|
+
.map(([name, group]) => ({ name, files: group.files, findings: group.findings }));
|
|
292
|
+
return Result.success({ entry: relative(base, realpathSync(absolute)), files: files.length, packages });
|
|
293
|
+
};
|
|
294
|
+
const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
295
|
+
/** The text report: findings grouped by package, a summary line, and what to do next. */
|
|
296
|
+
export const format = (report) => {
|
|
297
|
+
const flagged = report.packages.filter((entry) => entry.findings.length > 0);
|
|
298
|
+
const total = flagged.reduce((sum, entry) => sum + entry.findings.length, 0);
|
|
299
|
+
const lines = [];
|
|
300
|
+
for (const entry of flagged) {
|
|
301
|
+
lines.push(`${entry.name} (${plural(entry.findings.length, "finding")})`);
|
|
302
|
+
for (const finding of entry.findings) {
|
|
303
|
+
lines.push(` ${finding.file}:${finding.line}:${finding.column} ${finding.rule} ${finding.snippet}`);
|
|
304
|
+
}
|
|
305
|
+
lines.push("");
|
|
306
|
+
}
|
|
307
|
+
lines.push(`scanned ${plural(report.files, "file")} in ${plural(report.packages.length, "package")} imported by ${report.entry}: ${plural(total, "finding")} in ${plural(flagged.length, "package")}`);
|
|
308
|
+
lines.push(total > 0
|
|
309
|
+
? "These are hints: code the simulation never calls is fine. For a dependency the simulation calls, vendor it into your source and run `oxlint --fix` with these rules on, or replace it; then confirm with Verify.acrossEngines (`ritmo-devtools verify`) or Netcode.syncTest."
|
|
310
|
+
: "No dependency uses the Math functions, clock, or randomness these rules flag; confirm the whole run with Verify.acrossEngines (`ritmo-devtools verify`) or Netcode.syncTest.");
|
|
311
|
+
return lines.join("\n");
|
|
312
|
+
};
|
|
313
|
+
//# sourceMappingURL=dependencyScan.js.map
|