jorgex-stack 1.9.62 → 1.9.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -30
- package/dist/browser-playwright.d.ts +2 -0
- package/dist/browser-playwright.js +955 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +9616 -1827
- package/dist/pi-ci-artifact.js +341 -35
- package/dist/quality-verifier.js +399 -29
- package/package.json +3 -2
- package/stack/mcp/servers.json +1 -1
- package/stack/system-prompt/browser-playwright.md +1 -1
- package/upstreams.json +8 -8
- package/dist/chunk-2CBCBOP7.js +0 -245
- package/dist/chunk-4USZMJ3I.js +0 -554
- package/dist/chunk-66WVKOU4.js +0 -693
- package/dist/chunk-B76ZJXXD.js +0 -989
- package/dist/chunk-BSHTDTJL.js +0 -781
- package/dist/chunk-KGL5VNVZ.js +0 -305
- package/dist/chunk-KKN4OYHD.js +0 -704
- package/dist/chunk-N5IC2JBJ.js +0 -467
- package/dist/chunk-NQZVJFV2.js +0 -33
- package/dist/claude-code-BBHLN5TD.js +0 -12
- package/dist/codex-ALGP2YBC.js +0 -12
- package/dist/official-engram-setup-4WIXM4EF.js +0 -34
- package/dist/opencode-VG2IZRRF.js +0 -32
- package/dist/pi-CKFSPGJU.js +0 -13
package/dist/chunk-KGL5VNVZ.js
DELETED
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/lib/pi-release-resolver.ts
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import { createHash, randomBytes, timingSafeEqual } from "crypto";
|
|
7
|
-
var REGISTRY_URL = "https://registry.npmjs.org/jorgex-pi";
|
|
8
|
-
var REGISTRY_HOST = "registry.npmjs.org";
|
|
9
|
-
var ACCEPT = "application/vnd.npm.install-v1+json";
|
|
10
|
-
var MAX_METADATA_BYTES = 4 * 1024 * 1024;
|
|
11
|
-
var FETCH_TIMEOUT_MS = 1e4;
|
|
12
|
-
var STABLE_SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
13
|
-
function fail(message) {
|
|
14
|
-
throw new Error(`pi-release-resolver: ${message}`);
|
|
15
|
-
}
|
|
16
|
-
function isRecord(value) {
|
|
17
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
18
|
-
}
|
|
19
|
-
function canonicalTarballUrl(version) {
|
|
20
|
-
return `https://registry.npmjs.org/jorgex-pi/-/jorgex-pi-${version}.tgz`;
|
|
21
|
-
}
|
|
22
|
-
async function readBoundedText(response) {
|
|
23
|
-
if (response.body === null) fail("missing response body");
|
|
24
|
-
const reader = response.body.getReader();
|
|
25
|
-
const chunks = [];
|
|
26
|
-
let total = 0;
|
|
27
|
-
try {
|
|
28
|
-
for (; ; ) {
|
|
29
|
-
const { done, value } = await reader.read();
|
|
30
|
-
if (done) break;
|
|
31
|
-
total += value.byteLength;
|
|
32
|
-
if (total >= MAX_METADATA_BYTES) {
|
|
33
|
-
await reader.cancel().catch(() => {
|
|
34
|
-
});
|
|
35
|
-
fail("metadata exceeds 4 MiB");
|
|
36
|
-
}
|
|
37
|
-
chunks.push(value);
|
|
38
|
-
}
|
|
39
|
-
} finally {
|
|
40
|
-
reader.releaseLock();
|
|
41
|
-
}
|
|
42
|
-
return Buffer.concat(chunks.map((chunk) => Buffer.from(chunk))).toString("utf8");
|
|
43
|
-
}
|
|
44
|
-
function assertCanonicalIntegrity(integrity) {
|
|
45
|
-
if (typeof integrity !== "string" || !integrity.startsWith("sha512-")) {
|
|
46
|
-
fail("invalid integrity (expected canonical sha512 SRI)");
|
|
47
|
-
}
|
|
48
|
-
const b64 = integrity.slice("sha512-".length);
|
|
49
|
-
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(b64)) fail("invalid integrity (expected canonical sha512 SRI)");
|
|
50
|
-
let bytes;
|
|
51
|
-
try {
|
|
52
|
-
bytes = Buffer.from(b64, "base64");
|
|
53
|
-
} catch {
|
|
54
|
-
fail("invalid integrity (expected canonical sha512 SRI)");
|
|
55
|
-
}
|
|
56
|
-
if (bytes.length !== 64 || bytes.toString("base64") !== b64) {
|
|
57
|
-
fail("invalid integrity (expected canonical sha512 SRI)");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async function resolveLatestPiRelease(fetchImpl) {
|
|
61
|
-
const response = await fetchImpl(REGISTRY_URL, {
|
|
62
|
-
headers: { Accept: ACCEPT },
|
|
63
|
-
redirect: "error",
|
|
64
|
-
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
|
|
65
|
-
});
|
|
66
|
-
if (!response.ok) fail(`registry responded ${response.status}`);
|
|
67
|
-
if (response.url !== REGISTRY_URL) fail(`unexpected response URL ${response.url}`);
|
|
68
|
-
const lengthHeader = response.headers.get("content-length");
|
|
69
|
-
if (lengthHeader !== null) {
|
|
70
|
-
const trimmed = lengthHeader.trim();
|
|
71
|
-
if (!/^\d+$/.test(trimmed)) fail("invalid content-length");
|
|
72
|
-
if (Number(trimmed) > MAX_METADATA_BYTES) fail("metadata exceeds 4 MiB");
|
|
73
|
-
}
|
|
74
|
-
const text = await readBoundedText(response);
|
|
75
|
-
let data;
|
|
76
|
-
try {
|
|
77
|
-
data = JSON.parse(text);
|
|
78
|
-
} catch {
|
|
79
|
-
fail("malformed packument JSON");
|
|
80
|
-
}
|
|
81
|
-
if (!isRecord(data) || data["name"] !== "jorgex-pi") fail("malformed packument name");
|
|
82
|
-
const tags = data["dist-tags"];
|
|
83
|
-
if (!isRecord(tags) || typeof tags["latest"] !== "string") fail("missing dist-tags.latest");
|
|
84
|
-
const latest = tags["latest"];
|
|
85
|
-
if (!STABLE_SEMVER.test(latest)) fail(`unstable or malformed version ${latest}`);
|
|
86
|
-
const versions = data["versions"];
|
|
87
|
-
if (!isRecord(versions)) fail("missing versions map");
|
|
88
|
-
const entry = versions[latest];
|
|
89
|
-
if (!isRecord(entry)) fail(`missing versions[${latest}]`);
|
|
90
|
-
if (entry["name"] !== "jorgex-pi" || entry["version"] !== latest) {
|
|
91
|
-
fail("version mismatch in versions entry");
|
|
92
|
-
}
|
|
93
|
-
if (entry["deprecated"] !== void 0) fail(`version ${latest} is deprecated`);
|
|
94
|
-
const dist = entry["dist"];
|
|
95
|
-
if (!isRecord(dist)) fail("missing dist");
|
|
96
|
-
const { tarball, integrity } = dist;
|
|
97
|
-
if (typeof tarball !== "string" || typeof integrity !== "string") {
|
|
98
|
-
fail("missing dist.tarball/integrity");
|
|
99
|
-
}
|
|
100
|
-
let parsed;
|
|
101
|
-
try {
|
|
102
|
-
parsed = new URL(tarball);
|
|
103
|
-
} catch {
|
|
104
|
-
fail("foreign tarball URL");
|
|
105
|
-
}
|
|
106
|
-
if (parsed.protocol !== "https:" || parsed.host !== REGISTRY_HOST || tarball !== canonicalTarballUrl(latest)) {
|
|
107
|
-
fail("foreign tarball URL");
|
|
108
|
-
}
|
|
109
|
-
assertCanonicalIntegrity(integrity);
|
|
110
|
-
return { version: latest, tarballUrl: tarball, integrity };
|
|
111
|
-
}
|
|
112
|
-
var MAX_TARBALL_BYTES = 128 * 1024 * 1024;
|
|
113
|
-
var TARBALL_FETCH_TIMEOUT_MS = 12e4;
|
|
114
|
-
function expectedSha512Digest(integrity) {
|
|
115
|
-
assertCanonicalIntegrity(integrity);
|
|
116
|
-
return Buffer.from(integrity.slice("sha512-".length), "base64");
|
|
117
|
-
}
|
|
118
|
-
function assertCanonicalReleaseInput(release) {
|
|
119
|
-
if (!isRecord(release)) fail("invalid release");
|
|
120
|
-
const { version, tarballUrl, integrity } = release;
|
|
121
|
-
if (typeof version !== "string" || !STABLE_SEMVER.test(version)) fail("invalid release version");
|
|
122
|
-
if (typeof tarballUrl !== "string") fail("foreign tarball URL");
|
|
123
|
-
let parsed;
|
|
124
|
-
try {
|
|
125
|
-
parsed = new URL(tarballUrl);
|
|
126
|
-
} catch {
|
|
127
|
-
fail("foreign tarball URL");
|
|
128
|
-
}
|
|
129
|
-
if (parsed.protocol !== "https:" || parsed.host !== REGISTRY_HOST || tarballUrl !== canonicalTarballUrl(version)) {
|
|
130
|
-
fail("foreign tarball URL");
|
|
131
|
-
}
|
|
132
|
-
return { tarballUrl, expectedSha512: expectedSha512Digest(integrity) };
|
|
133
|
-
}
|
|
134
|
-
function readExistingArtifact(file) {
|
|
135
|
-
const stat = fs.statSync(file, { throwIfNoEntry: false });
|
|
136
|
-
if (stat === void 0) return null;
|
|
137
|
-
if (!stat.isFile()) fail("destination is not a regular file");
|
|
138
|
-
let fd;
|
|
139
|
-
try {
|
|
140
|
-
fd = fs.openSync(file, "r");
|
|
141
|
-
} catch {
|
|
142
|
-
fail("cannot read existing destination");
|
|
143
|
-
}
|
|
144
|
-
const sha256 = createHash("sha256");
|
|
145
|
-
const sha512 = createHash("sha512");
|
|
146
|
-
const buffer = Buffer.allocUnsafe(1024 * 1024);
|
|
147
|
-
let bytes = 0;
|
|
148
|
-
try {
|
|
149
|
-
for (; ; ) {
|
|
150
|
-
const read = fs.readSync(fd, buffer, 0, buffer.length, null);
|
|
151
|
-
if (read === 0) break;
|
|
152
|
-
bytes += read;
|
|
153
|
-
if (bytes >= MAX_TARBALL_BYTES) fail("existing destination exceeds tarball bound");
|
|
154
|
-
sha256.update(buffer.subarray(0, read));
|
|
155
|
-
sha512.update(buffer.subarray(0, read));
|
|
156
|
-
}
|
|
157
|
-
} finally {
|
|
158
|
-
try {
|
|
159
|
-
fs.closeSync(fd);
|
|
160
|
-
} catch {
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return { bytes, sha256: sha256.digest("hex"), sha512: sha512.digest("hex") };
|
|
164
|
-
}
|
|
165
|
-
async function downloadVerifiedPiTarball(release, destination, fetchImpl) {
|
|
166
|
-
const { tarballUrl, expectedSha512 } = assertCanonicalReleaseInput(release);
|
|
167
|
-
if (typeof destination !== "string" || destination === "") fail("invalid destination");
|
|
168
|
-
const existing = readExistingArtifact(destination);
|
|
169
|
-
if (existing !== null) {
|
|
170
|
-
const existing512 = Buffer.from(existing.sha512, "hex");
|
|
171
|
-
if (existing512.length === expectedSha512.length && timingSafeEqual(existing512, expectedSha512)) {
|
|
172
|
-
return { path: destination, bytes: existing.bytes, sha256: existing.sha256, sha512: existing.sha512 };
|
|
173
|
-
}
|
|
174
|
-
fail("destination bytes do not match requested integrity");
|
|
175
|
-
}
|
|
176
|
-
let response;
|
|
177
|
-
try {
|
|
178
|
-
response = await fetchImpl(tarballUrl, {
|
|
179
|
-
headers: { accept: "application/octet-stream" },
|
|
180
|
-
redirect: "error",
|
|
181
|
-
signal: AbortSignal.timeout(TARBALL_FETCH_TIMEOUT_MS)
|
|
182
|
-
});
|
|
183
|
-
} catch (error) {
|
|
184
|
-
fail(`tarball fetch failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
185
|
-
}
|
|
186
|
-
if (!response.ok) fail(`tarball responded ${response.status}`);
|
|
187
|
-
if (response.url !== tarballUrl) fail(`unexpected tarball response URL ${response.url}`);
|
|
188
|
-
const declared = response.headers.get("content-length");
|
|
189
|
-
if (declared !== null) {
|
|
190
|
-
const trimmed = declared.trim();
|
|
191
|
-
if (!/^\d+$/.test(trimmed)) fail("invalid tarball content-length");
|
|
192
|
-
if (Number(trimmed) > MAX_TARBALL_BYTES) fail("tarball exceeds 128 MiB");
|
|
193
|
-
}
|
|
194
|
-
if (response.body === null) fail("missing tarball body");
|
|
195
|
-
const tempPath = path.join(
|
|
196
|
-
path.dirname(destination),
|
|
197
|
-
`jorgex-pi-partial-${process.pid}-${randomBytes(8).toString("hex")}`
|
|
198
|
-
);
|
|
199
|
-
let fd;
|
|
200
|
-
try {
|
|
201
|
-
fd = fs.openSync(tempPath, "wx", 384);
|
|
202
|
-
} catch {
|
|
203
|
-
fail("cannot stage tarball temp");
|
|
204
|
-
}
|
|
205
|
-
let fdClosed = false;
|
|
206
|
-
const closeFd = () => {
|
|
207
|
-
if (fdClosed) return;
|
|
208
|
-
fdClosed = true;
|
|
209
|
-
try {
|
|
210
|
-
fs.closeSync(fd);
|
|
211
|
-
} catch {
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
const discardStaged = () => {
|
|
215
|
-
closeFd();
|
|
216
|
-
try {
|
|
217
|
-
fs.rmSync(tempPath, { force: true });
|
|
218
|
-
} catch {
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
try {
|
|
222
|
-
const reader = response.body.getReader();
|
|
223
|
-
const sha256 = createHash("sha256");
|
|
224
|
-
const sha512 = createHash("sha512");
|
|
225
|
-
let bytes = 0;
|
|
226
|
-
try {
|
|
227
|
-
for (; ; ) {
|
|
228
|
-
const { done, value } = await reader.read();
|
|
229
|
-
if (done) break;
|
|
230
|
-
bytes += value.byteLength;
|
|
231
|
-
if (bytes + value.byteLength >= MAX_TARBALL_BYTES) {
|
|
232
|
-
await reader.cancel().catch(() => {
|
|
233
|
-
});
|
|
234
|
-
fail("tarball exceeds 128 MiB");
|
|
235
|
-
}
|
|
236
|
-
sha256.update(value);
|
|
237
|
-
sha512.update(value);
|
|
238
|
-
let offset = 0;
|
|
239
|
-
while (offset < value.byteLength) {
|
|
240
|
-
offset += fs.writeSync(fd, value, offset, value.byteLength - offset);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
} finally {
|
|
244
|
-
reader.releaseLock();
|
|
245
|
-
}
|
|
246
|
-
closeFd();
|
|
247
|
-
const actual512 = sha512.digest();
|
|
248
|
-
if (!timingSafeEqual(actual512, expectedSha512)) fail("tarball integrity mismatch");
|
|
249
|
-
try {
|
|
250
|
-
fs.linkSync(tempPath, destination);
|
|
251
|
-
} catch {
|
|
252
|
-
fail("tarball publish raced with existing destination");
|
|
253
|
-
}
|
|
254
|
-
try {
|
|
255
|
-
fs.rmSync(tempPath, { force: true });
|
|
256
|
-
} catch {
|
|
257
|
-
}
|
|
258
|
-
return { path: destination, bytes, sha256: sha256.digest("hex"), sha512: actual512.toString("hex") };
|
|
259
|
-
} catch (error) {
|
|
260
|
-
discardStaged();
|
|
261
|
-
if (error instanceof Error && error.message.startsWith("pi-release-resolver: ")) throw error;
|
|
262
|
-
fail(`tarball download failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
var PRODUCER_REF_API = "https://api.github.com/repos/jorgehn98/jorgex-pi/git/ref/tags";
|
|
266
|
-
var PRODUCER_ACCEPT = "application/vnd.github+json";
|
|
267
|
-
var SHA40_HEX = /^[0-9a-f]{40}$/;
|
|
268
|
-
function producerTagUrl(version) {
|
|
269
|
-
return `${PRODUCER_REF_API}/v${version}`;
|
|
270
|
-
}
|
|
271
|
-
async function resolvePiProducerCommit(version, fetchImpl) {
|
|
272
|
-
if (typeof version !== "string" || !STABLE_SEMVER.test(version)) fail("invalid producer version");
|
|
273
|
-
const url = producerTagUrl(version);
|
|
274
|
-
let response;
|
|
275
|
-
try {
|
|
276
|
-
response = await fetchImpl(url, {
|
|
277
|
-
headers: { accept: PRODUCER_ACCEPT },
|
|
278
|
-
redirect: "error",
|
|
279
|
-
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
|
|
280
|
-
});
|
|
281
|
-
} catch (error) {
|
|
282
|
-
fail(`producer ref fetch failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
283
|
-
}
|
|
284
|
-
if (!response.ok) fail(`producer ref responded ${response.status}`);
|
|
285
|
-
if (response.url !== url) fail(`unexpected producer ref response URL ${response.url}`);
|
|
286
|
-
const text = await readBoundedText(response);
|
|
287
|
-
let data;
|
|
288
|
-
try {
|
|
289
|
-
data = JSON.parse(text);
|
|
290
|
-
} catch {
|
|
291
|
-
fail("malformed producer ref JSON");
|
|
292
|
-
}
|
|
293
|
-
if (!isRecord(data) || data["ref"] !== `refs/tags/v${version}`) fail("producer ref mismatch");
|
|
294
|
-
const object = data["object"];
|
|
295
|
-
if (!isRecord(object) || object["type"] !== "commit") fail("producer ref is not a lightweight tag commit");
|
|
296
|
-
const sha = object["sha"];
|
|
297
|
-
if (typeof sha !== "string" || !SHA40_HEX.test(sha)) fail("invalid producer commit sha");
|
|
298
|
-
return sha;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export {
|
|
302
|
-
resolveLatestPiRelease,
|
|
303
|
-
downloadVerifiedPiTarball,
|
|
304
|
-
resolvePiProducerCommit
|
|
305
|
-
};
|