@hraness/direct 0.7.5
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/LICENSE +21 -0
- package/README.md +436 -0
- package/dist/core/index.js +162 -0
- package/dist/index-1csg00w4.js +1167 -0
- package/dist/index-6mdfd2ey.js +464 -0
- package/dist/index-7n1h75n6.js +616 -0
- package/dist/index.js +232 -0
- package/dist/react.js +32 -0
- package/dist/testing/index.js +1069 -0
- package/dist/tooling/bombadil.js +2117 -0
- package/dist/tooling/browser-verification-entry.js +1499 -0
- package/dist/tooling/bundle-boundary.js +119 -0
- package/dist/web.js +605 -0
- package/package.json +179 -0
- package/skills/direct/AGENTS.md +13 -0
- package/skills/direct/SKILL.md +49 -0
- package/skills/direct/agents/openai.yaml +4 -0
- package/skills/direct/references/adoption.md +131 -0
- package/skills/direct/references/install.md +91 -0
- package/skills/direct/references/verification.md +247 -0
- package/src/core/coverage.ts +336 -0
- package/src/core/definition.ts +378 -0
- package/src/core/effects.ts +88 -0
- package/src/core/fixture.ts +185 -0
- package/src/core/ids.ts +77 -0
- package/src/core/index.ts +13 -0
- package/src/core/json-value.ts +7 -0
- package/src/core/json.ts +593 -0
- package/src/core/query.ts +230 -0
- package/src/core/reason.ts +16 -0
- package/src/core/resource.ts +10 -0
- package/src/core/result.ts +19 -0
- package/src/core/runtime.ts +229 -0
- package/src/core/scenario.ts +149 -0
- package/src/core/store.ts +784 -0
- package/src/index.ts +51 -0
- package/src/react.ts +54 -0
- package/src/testing/activity.ts +228 -0
- package/src/testing/coverage-binding.ts +99 -0
- package/src/testing/evidence.ts +59 -0
- package/src/testing/index.ts +22 -0
- package/src/testing/manifest.ts +559 -0
- package/src/testing/probe.ts +446 -0
- package/src/testing/scripted-transport.ts +775 -0
- package/src/testing/session.ts +525 -0
- package/src/tooling/bombadil-campaign.ts +288 -0
- package/src/tooling/bombadil-internal.d.ts +46 -0
- package/src/tooling/bombadil-runner.ts +1424 -0
- package/src/tooling/bombadil.ts +27 -0
- package/src/tooling/browser-verification-entry.ts +32 -0
- package/src/tooling/browser-verification.ts +916 -0
- package/src/tooling/bundle-boundary.ts +159 -0
- package/src/web/browser-bridge.ts +296 -0
- package/src/web/browser.ts +277 -0
- package/src/web/fetch-firewall.ts +251 -0
- package/src/web.ts +27 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/tooling/bundle-boundary.ts
|
|
3
|
+
import path from "path";
|
|
4
|
+
var DIRECT_WIRE_MARKERS = Object.freeze([
|
|
5
|
+
"direct.browser-bridge/",
|
|
6
|
+
"direct.coverage/",
|
|
7
|
+
"direct.fixture/",
|
|
8
|
+
"direct.probe/",
|
|
9
|
+
"direct.runtime/",
|
|
10
|
+
"direct.session-manifest/"
|
|
11
|
+
]);
|
|
12
|
+
function validatedMarkers(markers) {
|
|
13
|
+
const seen = new Set;
|
|
14
|
+
const output = [];
|
|
15
|
+
for (const marker of markers) {
|
|
16
|
+
if (marker.length === 0)
|
|
17
|
+
throw new Error("Bundle-boundary markers cannot be empty.");
|
|
18
|
+
if (seen.has(marker))
|
|
19
|
+
throw new Error(`Bundle-boundary marker is duplicated: ${marker}`);
|
|
20
|
+
seen.add(marker);
|
|
21
|
+
output.push(marker);
|
|
22
|
+
}
|
|
23
|
+
if (output.length === 0)
|
|
24
|
+
throw new Error("A bundle boundary needs at least one forbidden marker.");
|
|
25
|
+
return Object.freeze(output);
|
|
26
|
+
}
|
|
27
|
+
function validatedPatterns(patterns) {
|
|
28
|
+
if (patterns.length === 0)
|
|
29
|
+
throw new Error("A bundle boundary needs at least one file pattern.");
|
|
30
|
+
return Object.freeze(patterns.map((pattern) => {
|
|
31
|
+
if (pattern.length === 0)
|
|
32
|
+
throw new Error("Bundle-boundary file patterns cannot be empty.");
|
|
33
|
+
return pattern;
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
function validatedExcludePatterns(patterns) {
|
|
37
|
+
return Object.freeze((patterns ?? []).map((pattern) => {
|
|
38
|
+
if (pattern.length === 0)
|
|
39
|
+
throw new Error("Bundle-boundary exclusion patterns cannot be empty.");
|
|
40
|
+
return pattern;
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
function versionedMarkerFamilies(expectedMarkers) {
|
|
44
|
+
if (expectedMarkers.length === 0) {
|
|
45
|
+
throw new Error("An exact versioned-marker policy needs at least one expected marker.");
|
|
46
|
+
}
|
|
47
|
+
const seen = new Set;
|
|
48
|
+
return Object.freeze(expectedMarkers.map((expected) => {
|
|
49
|
+
const match = /^(?<family>[A-Za-z0-9][A-Za-z0-9._/-]*\/v)(?<version>0|[1-9][0-9]*)$/u.exec(expected);
|
|
50
|
+
const family = match?.groups?.["family"];
|
|
51
|
+
if (family === undefined) {
|
|
52
|
+
throw new Error(`Exact versioned marker must end in a canonical numeric version: ${expected}`);
|
|
53
|
+
}
|
|
54
|
+
if (seen.has(family)) {
|
|
55
|
+
throw new Error(`Exact versioned-marker family is duplicated: ${family}`);
|
|
56
|
+
}
|
|
57
|
+
seen.add(family);
|
|
58
|
+
return Object.freeze({ expected, family });
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
function escapedRegExp(value) {
|
|
62
|
+
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
63
|
+
}
|
|
64
|
+
function inspectExactVersionedMarkers(byteSequences, expectedMarkers) {
|
|
65
|
+
const families = versionedMarkerFamilies(expectedMarkers);
|
|
66
|
+
const observed = new Set;
|
|
67
|
+
const contents = [...byteSequences].map((bytes) => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("latin1"));
|
|
68
|
+
for (const { family } of families) {
|
|
69
|
+
const pattern = new RegExp(`(?<![A-Za-z0-9._/-])${escapedRegExp(family)}[0-9]+(?![A-Za-z0-9._/-])`, "gu");
|
|
70
|
+
for (const content of contents) {
|
|
71
|
+
for (const match of content.matchAll(pattern))
|
|
72
|
+
observed.add(match[0]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const expected = new Set(expectedMarkers);
|
|
76
|
+
const matching = expectedMarkers.filter((marker) => observed.has(marker));
|
|
77
|
+
const unexpected = [...observed].filter((marker) => !expected.has(marker)).sort((left, right) => left.localeCompare(right));
|
|
78
|
+
return Object.freeze({
|
|
79
|
+
missing: Object.freeze(expectedMarkers.filter((marker) => !observed.has(marker))),
|
|
80
|
+
observed: Object.freeze([...matching, ...unexpected]),
|
|
81
|
+
unexpected: Object.freeze(unexpected)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function findForbiddenMarkers(bytes, markers) {
|
|
85
|
+
const contents = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
86
|
+
return validatedMarkers(markers).filter((marker) => contents.includes(Buffer.from(marker)));
|
|
87
|
+
}
|
|
88
|
+
async function checkBundleBoundary(options) {
|
|
89
|
+
const root = path.resolve(options.directory);
|
|
90
|
+
const markers = validatedMarkers(options.markers);
|
|
91
|
+
const patterns = validatedPatterns(options.patterns);
|
|
92
|
+
const excludePatterns = validatedExcludePatterns(options.excludePatterns).map((pattern) => new Bun.Glob(pattern));
|
|
93
|
+
const scanned = new Set;
|
|
94
|
+
const violations = [];
|
|
95
|
+
for (const pattern of patterns) {
|
|
96
|
+
const glob = new Bun.Glob(pattern);
|
|
97
|
+
for await (const relative of glob.scan({ cwd: root, dot: true, onlyFiles: true })) {
|
|
98
|
+
if (excludePatterns.some((excludePattern) => excludePattern.match(relative)))
|
|
99
|
+
continue;
|
|
100
|
+
const file = path.join(root, relative);
|
|
101
|
+
if (scanned.has(file))
|
|
102
|
+
continue;
|
|
103
|
+
scanned.add(file);
|
|
104
|
+
const found = findForbiddenMarkers(new Uint8Array(await Bun.file(file).arrayBuffer()), markers);
|
|
105
|
+
if (found.length > 0)
|
|
106
|
+
violations.push({ file, markers: found });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
scanned: Object.freeze([...scanned].sort()),
|
|
111
|
+
violations: Object.freeze([...violations].sort((left, right) => left.file.localeCompare(right.file)))
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
inspectExactVersionedMarkers,
|
|
116
|
+
findForbiddenMarkers,
|
|
117
|
+
checkBundleBoundary,
|
|
118
|
+
DIRECT_WIRE_MARKERS
|
|
119
|
+
};
|