@prompd/core 0.5.0-beta.17 → 0.5.0-beta.18
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/index.cjs +23 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +23 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3141,6 +3141,7 @@ var MAX_TOTAL_EXTRACTED_SIZE = 500 * 1024 * 1024;
|
|
|
3141
3141
|
function isSymlinkEntry(perms) {
|
|
3142
3142
|
return typeof perms === "number" && (perms & 61440) === 40960;
|
|
3143
3143
|
}
|
|
3144
|
+
var pdpkgDecoder = new TextDecoder();
|
|
3144
3145
|
async function extractPdpkg(buffer) {
|
|
3145
3146
|
const zip = await JSZip__default.default.loadAsync(buffer);
|
|
3146
3147
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -3164,7 +3165,7 @@ async function extractPdpkg(buffer) {
|
|
|
3164
3165
|
if (total > MAX_TOTAL_EXTRACTED_SIZE) {
|
|
3165
3166
|
throw new Error(`Package total decompressed size exceeds limit (${MAX_TOTAL_EXTRACTED_SIZE} bytes). Possible decompression bomb.`);
|
|
3166
3167
|
}
|
|
3167
|
-
out.set(entry.name,
|
|
3168
|
+
out.set(entry.name, pdpkgDecoder.decode(bytes));
|
|
3168
3169
|
}
|
|
3169
3170
|
return out;
|
|
3170
3171
|
}
|
|
@@ -3391,34 +3392,18 @@ var HybridFileSystem = class {
|
|
|
3391
3392
|
|
|
3392
3393
|
// src/lib/compiler/install.ts
|
|
3393
3394
|
var MAX_PACKAGE_SIZE = 50 * 1024 * 1024;
|
|
3394
|
-
function joinPosix3(...parts) {
|
|
3395
|
-
const joined = parts.filter((p) => p && p !== ".").join("/").replace(/\/{2,}/g, "/");
|
|
3396
|
-
return joined.replace(/\/+$/, "") || "/";
|
|
3397
|
-
}
|
|
3398
|
-
function normalizeSegments(p) {
|
|
3399
|
-
const out = [];
|
|
3400
|
-
for (const seg of p.split("/")) {
|
|
3401
|
-
if (!seg || seg === ".") continue;
|
|
3402
|
-
if (seg === "..") {
|
|
3403
|
-
out.pop();
|
|
3404
|
-
continue;
|
|
3405
|
-
}
|
|
3406
|
-
out.push(seg);
|
|
3407
|
-
}
|
|
3408
|
-
return out.join("/");
|
|
3409
|
-
}
|
|
3410
3395
|
function slugify(name) {
|
|
3411
3396
|
return name.toLowerCase().replace(/[@/]+/g, "-").replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3412
3397
|
}
|
|
3413
3398
|
function resolvePackageDir(root, type, name) {
|
|
3414
|
-
return
|
|
3399
|
+
return joinPosix(root, ".prompd", getInstallDirForType(type), name);
|
|
3415
3400
|
}
|
|
3416
3401
|
function resolveInstallDir(root, type, name, version) {
|
|
3417
|
-
return
|
|
3402
|
+
return joinPosix(resolvePackageDir(root, type, name), version);
|
|
3418
3403
|
}
|
|
3419
3404
|
async function addWorkspaceDependency(store, root, name, version) {
|
|
3420
3405
|
if (!store.readFile) return;
|
|
3421
|
-
const manifestPath =
|
|
3406
|
+
const manifestPath = joinPosix(root, "prompd.json");
|
|
3422
3407
|
try {
|
|
3423
3408
|
const existing = await store.readFile(manifestPath);
|
|
3424
3409
|
const manifest = existing && existing.trim() ? JSON.parse(existing) : {};
|
|
@@ -3430,7 +3415,7 @@ async function addWorkspaceDependency(store, root, name, version) {
|
|
|
3430
3415
|
}
|
|
3431
3416
|
async function removeWorkspaceDependency(store, root, name) {
|
|
3432
3417
|
if (!store.readFile) return;
|
|
3433
|
-
const manifestPath =
|
|
3418
|
+
const manifestPath = joinPosix(root, "prompd.json");
|
|
3434
3419
|
try {
|
|
3435
3420
|
const existing = await store.readFile(manifestPath);
|
|
3436
3421
|
if (!existing || !existing.trim()) return;
|
|
@@ -3482,22 +3467,22 @@ async function installInternal(opts, visited) {
|
|
|
3482
3467
|
if (!store.writeBytes) {
|
|
3483
3468
|
throw new Error("Installing a node-template requires a PackageStore with writeBytes (binary). This host does not support it.");
|
|
3484
3469
|
}
|
|
3485
|
-
const dir =
|
|
3486
|
-
installedPath =
|
|
3470
|
+
const dir = joinPosix(root, ".prompd", getInstallDirForType("node-template"));
|
|
3471
|
+
installedPath = joinPosix(dir, `${slugify(name)}-${version}.pdpkg`);
|
|
3487
3472
|
await store.writeBytes(installedPath, bytes);
|
|
3488
3473
|
} else {
|
|
3489
3474
|
installedPath = resolveInstallDir(root, type, name, version);
|
|
3490
|
-
const base =
|
|
3475
|
+
const base = normalizePosix(installedPath);
|
|
3491
3476
|
await store.removeDir?.(installedPath);
|
|
3492
3477
|
for (const [rel, content] of files) {
|
|
3493
|
-
const dest =
|
|
3494
|
-
if (
|
|
3478
|
+
const dest = joinPosix(installedPath, rel);
|
|
3479
|
+
if (dest !== base && !dest.startsWith(base + "/")) {
|
|
3495
3480
|
throw new Error(`Security violation: extracted path escapes install directory: ${rel}`);
|
|
3496
3481
|
}
|
|
3497
3482
|
await store.writeFile(dest, content);
|
|
3498
3483
|
written.push(rel);
|
|
3499
3484
|
}
|
|
3500
|
-
await store.writeFile(
|
|
3485
|
+
await store.writeFile(joinPosix(installedPath, ".prmdmeta"), JSON.stringify(m, null, 2) + "\n");
|
|
3501
3486
|
if (tools && tools.length > 0) {
|
|
3502
3487
|
if (type !== "skill") throw new Error(`Tool deploy is only valid for skills, but '${name}' is a ${type}.`);
|
|
3503
3488
|
if (!deployTool) throw new Error("tools were requested but no deployTool hook was provided.");
|
|
@@ -3515,15 +3500,19 @@ async function uninstallPackage(opts) {
|
|
|
3515
3500
|
const removed = [];
|
|
3516
3501
|
for (const type of ["package", "workflow", "skill", "node-template"]) {
|
|
3517
3502
|
if (type === "node-template") {
|
|
3518
|
-
const dir =
|
|
3519
|
-
if (!store.readdir || !store.removeFile) continue;
|
|
3503
|
+
const dir = joinPosix(root, ".prompd", getInstallDirForType("node-template"));
|
|
3504
|
+
if (!store.readdir || !store.removeFile || !store.readBytes) continue;
|
|
3520
3505
|
try {
|
|
3521
|
-
const prefix = `${slugify(name)}-`;
|
|
3522
3506
|
for (const entry of await store.readdir(dir)) {
|
|
3523
|
-
if (entry.
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3507
|
+
if (!entry.endsWith(".pdpkg")) continue;
|
|
3508
|
+
const p = joinPosix(dir, entry);
|
|
3509
|
+
try {
|
|
3510
|
+
const m = readManifest(await extractPdpkg(await store.readBytes(p)));
|
|
3511
|
+
if (m.name === name) {
|
|
3512
|
+
await store.removeFile(p);
|
|
3513
|
+
removed.push(p);
|
|
3514
|
+
}
|
|
3515
|
+
} catch {
|
|
3527
3516
|
}
|
|
3528
3517
|
}
|
|
3529
3518
|
} catch {
|