sensorium-trace 0.18.2__py3-none-any.whl
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.
- sensorium/__init__.py +0 -0
- sensorium/__main__.py +4 -0
- sensorium/_c/rt/sensorium_c_rt.c +1446 -0
- sensorium/_typescript/package-lock.json +68 -0
- sensorium/_typescript/package.json +39 -0
- sensorium/_typescript/src/bindings.mjs +792 -0
- sensorium/_typescript/src/cap.mjs +227 -0
- sensorium/_typescript/src/capabilities.mjs +40 -0
- sensorium/_typescript/src/dbg.mjs +348 -0
- sensorium/_typescript/src/escape.mjs +351 -0
- sensorium/_typescript/src/focus.mjs +135 -0
- sensorium/_typescript/src/hook.mjs +127 -0
- sensorium/_typescript/src/index.mjs +1 -0
- sensorium/_typescript/src/naming.mjs +63 -0
- sensorium/_typescript/src/positions.mjs +37 -0
- sensorium/_typescript/src/probe.mjs +246 -0
- sensorium/_typescript/src/qualname.mjs +236 -0
- sensorium/_typescript/src/redact.mjs +711 -0
- sensorium/_typescript/src/register.mjs +15 -0
- sensorium/_typescript/src/resolve.mjs +260 -0
- sensorium/_typescript/src/rt.mjs +798 -0
- sensorium/_typescript/src/setup.mjs +11 -0
- sensorium/_typescript/src/tally.mjs +164 -0
- sensorium/_typescript/src/tasks.mjs +175 -0
- sensorium/_typescript/src/transform.mjs +800 -0
- sensorium/_typescript/src/vite.mjs +99 -0
- sensorium/c/__init__.py +8 -0
- sensorium/c/cc.py +612 -0
- sensorium/c/cli.py +60 -0
- sensorium/c/convert.py +669 -0
- sensorium/c/decode.py +300 -0
- sensorium/c/driver.py +365 -0
- sensorium/c/dwarf.py +706 -0
- sensorium/c/format.py +271 -0
- sensorium/c/pkg.py +187 -0
- sensorium/c/plan.py +277 -0
- sensorium/cli.py +140 -0
- sensorium/driver.py +47 -0
- sensorium/exit.py +33 -0
- sensorium/invocations.py +83 -0
- sensorium/limits.py +253 -0
- sensorium/mcp/__init__.py +0 -0
- sensorium/mcp/audit.py +162 -0
- sensorium/mcp/child.py +240 -0
- sensorium/mcp/cmd.py +101 -0
- sensorium/mcp/jsonrpc.py +172 -0
- sensorium/mcp/result.py +187 -0
- sensorium/mcp/schema.py +390 -0
- sensorium/mcp/server.py +493 -0
- sensorium/mcp/tools.py +299 -0
- sensorium/paths.py +80 -0
- sensorium/query/__init__.py +0 -0
- sensorium/query/caps.py +150 -0
- sensorium/query/dbg_dialects.py +64 -0
- sensorium/query/diff_cmd.py +748 -0
- sensorium/query/diff_notes.py +117 -0
- sensorium/query/exceptions_c.py +263 -0
- sensorium/query/exceptions_cmd.py +788 -0
- sensorium/query/exceptions_group.py +571 -0
- sensorium/query/exceptions_invocation.py +487 -0
- sensorium/query/exceptions_rust.py +683 -0
- sensorium/query/exceptions_typescript.py +688 -0
- sensorium/query/expr.py +606 -0
- sensorium/query/failures_cmd.py +306 -0
- sensorium/query/flow_cmd.py +778 -0
- sensorium/query/flow_report.py +128 -0
- sensorium/query/flow_values.py +195 -0
- sensorium/query/fmt.py +280 -0
- sensorium/query/frame_cmd.py +237 -0
- sensorium/query/grep_cmd.py +156 -0
- sensorium/query/help.py +18 -0
- sensorium/query/info_cmd.py +527 -0
- sensorium/query/info_rust.py +214 -0
- sensorium/query/info_typescript.py +261 -0
- sensorium/query/js_inspect.py +394 -0
- sensorium/query/moves.py +254 -0
- sensorium/query/redact_cmd.py +304 -0
- sensorium/query/refocus_cmd.py +661 -0
- sensorium/query/refocus_env.py +493 -0
- sensorium/query/refocus_facts.py +269 -0
- sensorium/query/refocus_licence.py +187 -0
- sensorium/query/refocus_report.py +327 -0
- sensorium/query/refocus_rust.py +537 -0
- sensorium/query/refocus_threads.py +197 -0
- sensorium/query/refocus_typescript.py +756 -0
- sensorium/query/refocus_world.py +666 -0
- sensorium/query/runs_cmd.py +213 -0
- sensorium/query/rust_debug.py +176 -0
- sensorium/query/sites.py +171 -0
- sensorium/query/tree_cmd.py +511 -0
- sensorium/query/tree_threads.py +168 -0
- sensorium/query/vocab.py +723 -0
- sensorium/query/watch_cmd.py +657 -0
- sensorium/record/__init__.py +0 -0
- sensorium/record/boot.py +797 -0
- sensorium/record/boot_io.py +141 -0
- sensorium/record/budget.py +135 -0
- sensorium/record/capture.py +433 -0
- sensorium/record/children.py +755 -0
- sensorium/record/children_merge.py +179 -0
- sensorium/record/elide.py +55 -0
- sensorium/record/fingerprint.py +26 -0
- sensorium/record/thread_starts.py +261 -0
- sensorium/record/tracer.py +798 -0
- sensorium/record/tracer_exc.py +199 -0
- sensorium/record/tracer_frames.py +618 -0
- sensorium/redact.py +304 -0
- sensorium/redact_content.py +156 -0
- sensorium/redact_key.py +317 -0
- sensorium/redact_store.py +502 -0
- sensorium/redact_values.py +433 -0
- sensorium/store/__init__.py +0 -0
- sensorium/store/db.py +284 -0
- sensorium/store/gc.py +360 -0
- sensorium/store/payloads.py +69 -0
- sensorium/store/reader.py +438 -0
- sensorium/store/writer.py +283 -0
- sensorium/ts/__init__.py +10 -0
- sensorium/ts/build.py +783 -0
- sensorium/ts/cli.py +130 -0
- sensorium/ts/driver.py +472 -0
- sensorium/ts/focus.py +146 -0
- sensorium/ts/harness.py +314 -0
- sensorium/ts/ingest.py +380 -0
- sensorium/ts/invocation.py +252 -0
- sensorium/ts/pkg.py +167 -0
- sensorium/ts/redaction.py +64 -0
- sensorium/ts/spool.py +168 -0
- sensorium/ts/truncation.py +81 -0
- sensorium/ts/wrapper.py +255 -0
- sensorium_trace-0.18.2.dist-info/METADATA +245 -0
- sensorium_trace-0.18.2.dist-info/RECORD +135 -0
- sensorium_trace-0.18.2.dist-info/WHEEL +4 -0
- sensorium_trace-0.18.2.dist-info/entry_points.txt +3 -0
- sensorium_trace-0.18.2.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// The Vite plugin: the harness wiring for vitest. It runs `enforce: 'pre'`, so
|
|
2
|
+
// it sees the consumer's own TypeScript before esbuild has erased the types the
|
|
3
|
+
// transform positions itself against, and it hands Vite back the magic-string
|
|
4
|
+
// `hires` map so vitest reports the ORIGINAL line and column of a failure.
|
|
5
|
+
//
|
|
6
|
+
// Two resolutions, and neither of them uses this file's own location:
|
|
7
|
+
// * `typescript` comes from the ROOT — the consumer's compiler, the one whose
|
|
8
|
+
// AST the consumer's build already trusts. A recorder that parsed with its
|
|
9
|
+
// own copy would be reading a different language from the one being run.
|
|
10
|
+
// * `magic-string` comes from the PACKAGE — the recorder's own dependency.
|
|
11
|
+
// `transform.mjs` bare-imports it, so the resolution here is a check, not a
|
|
12
|
+
// handoff: it turns a cryptic ERR_MODULE_NOT_FOUND raised deep inside a
|
|
13
|
+
// transform into a named refusal at config time.
|
|
14
|
+
//
|
|
15
|
+
// The tally is per PROCESS, not per file: vitest transforms in its main process
|
|
16
|
+
// and ships the result to the workers, so one tally covers the invocation. It
|
|
17
|
+
// lives in `tally.mjs`, shared with the `node --test` loader hook, and is
|
|
18
|
+
// written on exit, never during, because a count that is still moving is not a
|
|
19
|
+
// count.
|
|
20
|
+
//
|
|
21
|
+
// `SENSORIUM_FOCUS` is read where the PLUGIN is built, not where this module is
|
|
22
|
+
// loaded. A config's `import` of this file is hoisted above the config's own
|
|
23
|
+
// body, so a project that sets the variable in its config -- which the probe
|
|
24
|
+
// project does, having no driver -- would set it after a module-load read and
|
|
25
|
+
// record no statement at all. One read per plugin is still one read per
|
|
26
|
+
// invocation, and it happens before the first transform.
|
|
27
|
+
import { createRequire } from 'node:module';
|
|
28
|
+
import path from 'node:path';
|
|
29
|
+
|
|
30
|
+
import { specsFromEnv } from './focus.mjs';
|
|
31
|
+
import * as tally from './tally.mjs';
|
|
32
|
+
import { classify, transformSource } from './transform.mjs';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} root the invocation root: the consumer's project directory
|
|
36
|
+
* @param {string} pkgDir this package's directory
|
|
37
|
+
* @returns {typeof import('typescript')} the consumer's own TypeScript
|
|
38
|
+
*/
|
|
39
|
+
function resolveTools(root, pkgDir) {
|
|
40
|
+
const fromRoot = createRequire(path.join(root, 'package.json'));
|
|
41
|
+
const fromPkg = createRequire(path.join(pkgDir, 'package.json'));
|
|
42
|
+
fromPkg.resolve('magic-string');
|
|
43
|
+
return fromRoot('typescript');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param {{root: string, pkgDir: string, rtPath: string}} opts
|
|
48
|
+
* `root` the consumer's project directory, `pkgDir` this package's directory,
|
|
49
|
+
* `rtPath` the specifier every instrumented module imports the runtime by —
|
|
50
|
+
* ONE specifier per invocation, or the runtime is two runtimes (R16).
|
|
51
|
+
* @returns {{name: string, enforce: 'pre', transform: (code: string, id: string) =>
|
|
52
|
+
* {code: string, map: unknown}|null}} a Vite plugin
|
|
53
|
+
*/
|
|
54
|
+
export function sensorium(opts) {
|
|
55
|
+
const root = path.resolve(opts.root);
|
|
56
|
+
const pkgDir = path.resolve(opts.pkgDir);
|
|
57
|
+
const rtPath = opts.rtPath;
|
|
58
|
+
const ts = resolveTools(root, pkgDir);
|
|
59
|
+
const focus = specsFromEnv(process.env.SENSORIUM_FOCUS ?? '');
|
|
60
|
+
const manifestDir = tally.dir();
|
|
61
|
+
if (manifestDir) tally.installExitWriter(manifestDir);
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
name: 'sensorium',
|
|
65
|
+
enforce: /** @type {'pre'} */ ('pre'),
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @param {string} code
|
|
69
|
+
* @param {string} id
|
|
70
|
+
* @returns {{code: string, map: unknown}|null}
|
|
71
|
+
*/
|
|
72
|
+
transform(code, id) {
|
|
73
|
+
// A virtual module has no file behind it and no line numbers we could
|
|
74
|
+
// vouch for, whatever its id looks like after the query is stripped.
|
|
75
|
+
if (id.startsWith('\0')) return null;
|
|
76
|
+
const file = id.split('?')[0];
|
|
77
|
+
const kind = classify(file, root);
|
|
78
|
+
if (kind === 'skip') return null;
|
|
79
|
+
// CommonJS is ours and countable, but this transform emits ESM and would
|
|
80
|
+
// change what the module IS; it is excluded by name, never by silence.
|
|
81
|
+
if (kind === 'commonjs') {
|
|
82
|
+
tally.exclude(file, 'commonjs');
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
// A throw here is `transform.mjs` refusing to splice blind (R10a). It
|
|
86
|
+
// propagates: a recorder that cannot vouch for its own edits must fail
|
|
87
|
+
// the run by name rather than record a file it did not understand.
|
|
88
|
+
const out = transformSource(code, file, { root, ts, rtPath, focus });
|
|
89
|
+
if (!out) return null;
|
|
90
|
+
tally.record(file, out, manifestDir);
|
|
91
|
+
// Ours, untouched, counted (R10): the file did not parse, its manifest
|
|
92
|
+
// says so, and Vite gets the source back exactly as it arrived.
|
|
93
|
+
if (out.code === null) return null;
|
|
94
|
+
return { code: out.code, map: out.map };
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default sensorium;
|