@danypops/pi-packed 0.21.7 → 0.21.8
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/package.json
CHANGED
|
@@ -16,6 +16,7 @@ import { createLogger } from "../shared/log.ts";
|
|
|
16
16
|
|
|
17
17
|
const log = createLogger("registry");
|
|
18
18
|
const README_MAX_CHARS = 50_000;
|
|
19
|
+
const README_DOCUMENT_MAX_BYTES = 1024 * 1024;
|
|
19
20
|
|
|
20
21
|
/** Upstream etiquette: honor Retry-After on 429, exponential backoff
|
|
21
22
|
* otherwise, give up after RETRY_MAX_ATTEMPTS. */
|
|
@@ -126,11 +127,10 @@ export class HttpRegistry implements Registry {
|
|
|
126
127
|
pi?: Record<string, unknown>;
|
|
127
128
|
peerDependencies?: Record<string, string>;
|
|
128
129
|
scripts?: Record<string, string>;
|
|
129
|
-
readme?: unknown;
|
|
130
130
|
dist?: { unpackedSize?: number; integrity?: string; attestations?: { url?: string; provenance?: unknown } };
|
|
131
131
|
};
|
|
132
132
|
const manifestFields = v.pi ? Object.keys(v.pi).filter((key) => ["extensions", "skills", "prompts", "themes"].includes(key)) : [];
|
|
133
|
-
const readme =
|
|
133
|
+
const readme = await this.publishedReadme(encoded);
|
|
134
134
|
return {
|
|
135
135
|
name: boundedString(v.name, 214) ?? boundedString(name, 214)!,
|
|
136
136
|
version: boundedString(v.version, 128) ?? "",
|
|
@@ -166,6 +166,22 @@ export class HttpRegistry implements Registry {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
private async publishedReadme(encodedName: string): Promise<string | undefined> {
|
|
170
|
+
try {
|
|
171
|
+
const response = await fetchWithRetry(
|
|
172
|
+
`${this.base}/${encodedName}`,
|
|
173
|
+
{ headers: { accept: "application/json" } },
|
|
174
|
+
this.retryBaseDelayMs,
|
|
175
|
+
);
|
|
176
|
+
if (!response.ok) return undefined;
|
|
177
|
+
const document = (await boundedJson(response, README_DOCUMENT_MAX_BYTES)) as { readme?: unknown };
|
|
178
|
+
return boundedString(document.readme, README_MAX_CHARS);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
log.debug("published README unavailable", { error: error instanceof Error ? error.message : String(error) });
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
169
185
|
/** Uses npm's abbreviated multi-version doc, not `/latest` (which carries
|
|
170
186
|
* no `time`/`modified` field at all -- confirmed against the live
|
|
171
187
|
* registry). Still bounded well under the full unabbreviated document's
|
|
@@ -69,7 +69,6 @@ describe("HttpRegistry", () => {
|
|
|
69
69
|
license: "MIT",
|
|
70
70
|
keywords: ["pi-package", "lsp"],
|
|
71
71
|
pi: { extensions: ["./src/index.ts"] },
|
|
72
|
-
readme: `# pi-lsp\n\n${"r".repeat(60_000)}`,
|
|
73
72
|
dist: {
|
|
74
73
|
unpackedSize: 12345,
|
|
75
74
|
integrity: "sha512-test",
|
|
@@ -77,6 +76,7 @@ describe("HttpRegistry", () => {
|
|
|
77
76
|
},
|
|
78
77
|
});
|
|
79
78
|
}
|
|
79
|
+
if (url.pathname === "/pi-lsp") return Response.json({ readme: `# pi-lsp\n\n${"r".repeat(60_000)}` });
|
|
80
80
|
return new Response("nf", { status: 404 });
|
|
81
81
|
},
|
|
82
82
|
});
|
|
@@ -52,10 +52,16 @@ describe("published npm metadata E2E", () => {
|
|
|
52
52
|
description: "Encrypted credential vault daemon",
|
|
53
53
|
license: "MIT",
|
|
54
54
|
repository: { type: "git", url: "git+https://github.com/DanyPops/enigma.git" },
|
|
55
|
-
readme: PUBLISHED_README,
|
|
56
55
|
dist: { integrity: "sha512-published-fixture" },
|
|
57
56
|
});
|
|
58
57
|
}
|
|
58
|
+
if (url.pathname === "/%40danypops/enigma") {
|
|
59
|
+
return Response.json({
|
|
60
|
+
name: "@danypops/enigma",
|
|
61
|
+
"dist-tags": { latest: "0.22.1" },
|
|
62
|
+
readme: PUBLISHED_README,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
59
65
|
return new Response("not found", { status: 404 });
|
|
60
66
|
},
|
|
61
67
|
});
|
|
@@ -78,7 +84,13 @@ describe("published npm metadata E2E", () => {
|
|
|
78
84
|
const client = new PackedClient(`http://127.0.0.1:${daemonServer.port}`, TOKEN);
|
|
79
85
|
const info = await client.info("@danypops/enigma");
|
|
80
86
|
|
|
81
|
-
expect(npmRequests).
|
|
87
|
+
expect(npmRequests).toHaveLength(2);
|
|
88
|
+
expect(npmRequests).toEqual(
|
|
89
|
+
expect.arrayContaining([
|
|
90
|
+
{ path: "/%40danypops/enigma/latest", accept: "application/json" },
|
|
91
|
+
{ path: "/%40danypops/enigma", accept: "application/json" },
|
|
92
|
+
]),
|
|
93
|
+
);
|
|
82
94
|
expect(info).toMatchObject({
|
|
83
95
|
name: "@danypops/enigma",
|
|
84
96
|
version: "0.22.1",
|