@skydiveai/git-cache 0.1.252-beta.4 → 0.1.252-beta.41
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/dist/cli.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as isProtocolV2Request, c as parseAdvertisement, d as shouldBackfillAfterPassthrough, f as startServer, i as explainRejection, l as parseUpstream, n as classifyUploadRequest, o as metricsSnapshot, r as copyRequestHeaders, s as mirrorHasObjects, t as SidebandPackExtractor, u as recordColdBuildOutcome } from "./server-
|
|
1
|
+
import { a as isProtocolV2Request, c as parseAdvertisement, d as shouldBackfillAfterPassthrough, f as startServer, i as explainRejection, l as parseUpstream, n as classifyUploadRequest, o as metricsSnapshot, r as copyRequestHeaders, s as mirrorHasObjects, t as SidebandPackExtractor, u as recordColdBuildOutcome } from "./server-BEKSCDm3.mjs";
|
|
2
2
|
export { SidebandPackExtractor, classifyUploadRequest, copyRequestHeaders, explainRejection, isProtocolV2Request, metricsSnapshot, mirrorHasObjects, parseAdvertisement, parseUpstream, recordColdBuildOutcome, shouldBackfillAfterPassthrough, startServer };
|
|
@@ -466,7 +466,8 @@ function parseUpstream(rawPathname, rawSearch = "") {
|
|
|
466
466
|
if (config.hostAllowlist.length && !config.hostAllowlist.includes(host)) return null;
|
|
467
467
|
if (repoPath.includes("..") || repoPath.startsWith("/") || repoPath.endsWith("/") || repoPath.split("/").some((seg) => seg === "" || seg === "." || seg === "..")) return null;
|
|
468
468
|
if (!/^[A-Za-z0-9._~+@/-]+$/.test(repoPath)) return null;
|
|
469
|
-
const
|
|
469
|
+
const keyPath = host === "github.com" ? repoPath.toLowerCase() : repoPath;
|
|
470
|
+
const repo = `${host}/${keyPath}`;
|
|
470
471
|
const suffix = hadDotGit ? ".git" : "";
|
|
471
472
|
return {
|
|
472
473
|
repo,
|
|
@@ -1526,7 +1527,7 @@ function proxyUploadPackWithBody(res, upstreamUrl, reqHeaders, body, credHeader)
|
|
|
1526
1527
|
});
|
|
1527
1528
|
up.end(body);
|
|
1528
1529
|
}
|
|
1529
|
-
function serveUploadPack(req, res, local, advertise, cacheState, body = null) {
|
|
1530
|
+
function serveUploadPack(req, res, local, advertise, cacheState, body = null, detail = null) {
|
|
1530
1531
|
const args = ["--stateless-rpc"];
|
|
1531
1532
|
if (advertise) args.push("--advertise-refs");
|
|
1532
1533
|
args.push(local);
|
|
@@ -1554,6 +1555,10 @@ function serveUploadPack(req, res, local, advertise, cacheState, body = null) {
|
|
|
1554
1555
|
req.pipe(gunzip).pipe(child.stdin);
|
|
1555
1556
|
} else req.pipe(child.stdin);
|
|
1556
1557
|
child.stdout.pipe(res);
|
|
1558
|
+
let bytes = 0;
|
|
1559
|
+
child.stdout.on("data", (d) => {
|
|
1560
|
+
bytes += d.length;
|
|
1561
|
+
});
|
|
1557
1562
|
let stderr = "";
|
|
1558
1563
|
let finished = false;
|
|
1559
1564
|
child.stderr.on("data", (d) => {
|
|
@@ -1566,6 +1571,10 @@ function serveUploadPack(req, res, local, advertise, cacheState, body = null) {
|
|
|
1566
1571
|
code,
|
|
1567
1572
|
stderr: stderr.trim()
|
|
1568
1573
|
});
|
|
1574
|
+
if (detail) log("info", "serve_detail", {
|
|
1575
|
+
...detail,
|
|
1576
|
+
bytes
|
|
1577
|
+
});
|
|
1569
1578
|
if (!res.writableEnded) res.end();
|
|
1570
1579
|
});
|
|
1571
1580
|
res.on("close", () => {
|
|
@@ -1826,6 +1835,7 @@ async function handle(req, res) {
|
|
|
1826
1835
|
const host = up.repo.split("/")[0] ?? "";
|
|
1827
1836
|
let uploadBody = null;
|
|
1828
1837
|
let uploadWants = [];
|
|
1838
|
+
let uploadVerdict = null;
|
|
1829
1839
|
if (up.operation === "git-upload-pack") {
|
|
1830
1840
|
try {
|
|
1831
1841
|
uploadBody = await readBody(req, 16 * 1024 * 1024);
|
|
@@ -1841,7 +1851,8 @@ async function handle(req, res) {
|
|
|
1841
1851
|
if (!res.headersSent) res.writeHead(400);
|
|
1842
1852
|
return res.end("bad gzip body\n");
|
|
1843
1853
|
}
|
|
1844
|
-
|
|
1854
|
+
uploadVerdict = classifyUploadRequest(uploadBody);
|
|
1855
|
+
uploadWants = uploadVerdict.wants;
|
|
1845
1856
|
}
|
|
1846
1857
|
if (await pathExists(localPath(up.repo))) {
|
|
1847
1858
|
const warm = await ensureWarm(up.repo, clientCred, up.operation === "info/refs");
|
|
@@ -1864,7 +1875,11 @@ async function handle(req, res) {
|
|
|
1864
1875
|
});
|
|
1865
1876
|
if (!await mirrorHasObjects(warm.local, uploadWants)) {
|
|
1866
1877
|
metrics.passthrough_missing_want++;
|
|
1867
|
-
log("info", "passthrough_missing_want", {
|
|
1878
|
+
log("info", "passthrough_missing_want", {
|
|
1879
|
+
repo: up.repo,
|
|
1880
|
+
eligibility: uploadVerdict ? uploadVerdict.reason : null,
|
|
1881
|
+
wants: uploadVerdict ? uploadVerdict.wants.length : null
|
|
1882
|
+
});
|
|
1868
1883
|
const credHeader = clientCred ?? await fetchCredentialHeader(host);
|
|
1869
1884
|
return proxyUploadPackWithBody(res, up.upstreamUrl, req.headers, uploadBody, credHeader);
|
|
1870
1885
|
}
|
|
@@ -1872,9 +1887,17 @@ async function handle(req, res) {
|
|
|
1872
1887
|
log("info", "serve", {
|
|
1873
1888
|
repo: up.repo,
|
|
1874
1889
|
op: up.operation,
|
|
1875
|
-
state: warm.cacheState
|
|
1890
|
+
state: warm.cacheState,
|
|
1891
|
+
eligibility: uploadVerdict ? uploadVerdict.reason : null,
|
|
1892
|
+
wants: uploadVerdict ? uploadVerdict.wants.length : null
|
|
1893
|
+
});
|
|
1894
|
+
return serveUploadPack(req, res, warm.local, up.operation === "info/refs", warm.cacheState, uploadBody, {
|
|
1895
|
+
repo: up.repo,
|
|
1896
|
+
op: up.operation,
|
|
1897
|
+
state: warm.cacheState,
|
|
1898
|
+
eligibility: uploadVerdict ? uploadVerdict.reason : null,
|
|
1899
|
+
wants: uploadVerdict ? uploadVerdict.wants.length : null
|
|
1876
1900
|
});
|
|
1877
|
-
return serveUploadPack(req, res, warm.local, up.operation === "info/refs", warm.cacheState, uploadBody);
|
|
1878
1901
|
}
|
|
1879
1902
|
if (up.operation === "info/refs") return await proxyInfoRefs(req, res, up.repo, up.upstreamUrl, host, clientCred);
|
|
1880
1903
|
const body = uploadBody ?? Buffer.alloc(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skydiveai/git-cache",
|
|
3
|
-
"version": "0.1.252-beta.
|
|
3
|
+
"version": "0.1.252-beta.41",
|
|
4
4
|
"description": "Sandbox-local Git smart-HTTP clone/fetch cache: a loopback daemon that transparently mirrors HTTPS git reads so repeated clone/fetch/ls-remote skip the origin round-trip. Runs inside an agent sandbox; pushes stay direct.",
|
|
5
5
|
"homepage": "https://skydive.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^24.0.0",
|
|
37
37
|
"@typescript/native-preview": "^7.0.0-dev.20260113.1",
|
|
38
|
-
"@vitest/coverage-v8": "^2.
|
|
38
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
39
39
|
"shellcheck": "^4.1.0",
|
|
40
40
|
"tsdown": "^0.21.10",
|
|
41
|
-
"typescript": "^
|
|
42
|
-
"vitest": "^2.
|
|
41
|
+
"typescript": "^6.0.3",
|
|
42
|
+
"vitest": "^3.2.7"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": "24.x"
|