prpm 2.1.20 → 2.1.22
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.js +628 -297
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -73,21 +73,36 @@ function createLockfile() {
|
|
|
73
73
|
generated: (/* @__PURE__ */ new Date()).toISOString()
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
function getLockfileKey(packageId, format) {
|
|
76
|
+
function getLockfileKey(packageId, format, location) {
|
|
77
77
|
if (!format) {
|
|
78
78
|
return packageId;
|
|
79
79
|
}
|
|
80
|
+
if (location) {
|
|
81
|
+
return `${packageId}#${format}:${location}`;
|
|
82
|
+
}
|
|
80
83
|
return `${packageId}#${format}`;
|
|
81
84
|
}
|
|
82
85
|
function parseLockfileKey(key) {
|
|
83
|
-
const
|
|
86
|
+
const hashIndex = key.indexOf("#");
|
|
87
|
+
if (hashIndex === -1) {
|
|
88
|
+
return { packageId: key };
|
|
89
|
+
}
|
|
90
|
+
const packageId = key.substring(0, hashIndex);
|
|
91
|
+
const rest = key.substring(hashIndex + 1);
|
|
92
|
+
const colonIndex = rest.indexOf(":");
|
|
93
|
+
if (colonIndex === -1) {
|
|
94
|
+
return { packageId, format: rest };
|
|
95
|
+
}
|
|
84
96
|
return {
|
|
85
|
-
packageId
|
|
86
|
-
format:
|
|
97
|
+
packageId,
|
|
98
|
+
format: rest.substring(0, colonIndex),
|
|
99
|
+
location: rest.substring(colonIndex + 1)
|
|
87
100
|
};
|
|
88
101
|
}
|
|
89
102
|
function addToLockfile(lockfile, packageId, packageInfo) {
|
|
90
|
-
|
|
103
|
+
var _a;
|
|
104
|
+
const snippetLocation = packageInfo.subtype === "snippet" ? (_a = packageInfo.snippetMetadata) == null ? void 0 : _a.targetPath : void 0;
|
|
105
|
+
const lockfileKey = getLockfileKey(packageId, packageInfo.format, snippetLocation);
|
|
91
106
|
lockfile.packages[lockfileKey] = {
|
|
92
107
|
version: packageInfo.version,
|
|
93
108
|
resolved: packageInfo.tarballUrl,
|
|
@@ -107,16 +122,16 @@ function addToLockfile(lockfile, packageId, packageInfo) {
|
|
|
107
122
|
};
|
|
108
123
|
lockfile.generated = (/* @__PURE__ */ new Date()).toISOString();
|
|
109
124
|
}
|
|
110
|
-
function setPackageIntegrity(lockfile, packageId, tarballBuffer, format) {
|
|
111
|
-
const lockfileKey = getLockfileKey(packageId, format);
|
|
125
|
+
function setPackageIntegrity(lockfile, packageId, tarballBuffer, format, location) {
|
|
126
|
+
const lockfileKey = getLockfileKey(packageId, format, location);
|
|
112
127
|
if (!lockfile.packages[lockfileKey]) {
|
|
113
128
|
throw new Error(`Package ${lockfileKey} not found in lock file`);
|
|
114
129
|
}
|
|
115
130
|
const hash = (0, import_crypto.createHash)("sha256").update(tarballBuffer).digest("hex");
|
|
116
131
|
lockfile.packages[lockfileKey].integrity = `sha256-${hash}`;
|
|
117
132
|
}
|
|
118
|
-
function verifyPackageIntegrity(lockfile, packageId, tarballBuffer, format) {
|
|
119
|
-
const lockfileKey = getLockfileKey(packageId, format);
|
|
133
|
+
function verifyPackageIntegrity(lockfile, packageId, tarballBuffer, format, location) {
|
|
134
|
+
const lockfileKey = getLockfileKey(packageId, format, location);
|
|
120
135
|
const pkg = lockfile.packages[lockfileKey];
|
|
121
136
|
if (!pkg || !pkg.integrity) {
|
|
122
137
|
return false;
|
|
@@ -1164,8 +1179,8 @@ function extractAtReferences(content) {
|
|
|
1164
1179
|
const refs = Array.from(matches, (m) => m[1]);
|
|
1165
1180
|
return [...new Set(refs)];
|
|
1166
1181
|
}
|
|
1167
|
-
function categorizeFile(
|
|
1168
|
-
const pathLower =
|
|
1182
|
+
function categorizeFile(path12) {
|
|
1183
|
+
const pathLower = path12.toLowerCase();
|
|
1169
1184
|
if (pathLower.includes("/patterns/") || pathLower.includes("/pattern/") || pathLower.startsWith("patterns/") || pathLower.startsWith("pattern/")) {
|
|
1170
1185
|
return "pattern";
|
|
1171
1186
|
}
|
|
@@ -1189,8 +1204,8 @@ function categorizeFile(path11) {
|
|
|
1189
1204
|
}
|
|
1190
1205
|
return "other";
|
|
1191
1206
|
}
|
|
1192
|
-
function detectContentType(
|
|
1193
|
-
const ext = (0, import_path5.extname)(
|
|
1207
|
+
function detectContentType(path12) {
|
|
1208
|
+
const ext = (0, import_path5.extname)(path12).toLowerCase();
|
|
1194
1209
|
const typeMap = {
|
|
1195
1210
|
".md": "text/markdown",
|
|
1196
1211
|
".txt": "text/plain",
|
|
@@ -1252,8 +1267,8 @@ function loadReferencedFiles(references, basePath) {
|
|
|
1252
1267
|
}
|
|
1253
1268
|
function extractDirectories(filePaths) {
|
|
1254
1269
|
const dirs = /* @__PURE__ */ new Set();
|
|
1255
|
-
for (const
|
|
1256
|
-
const dir = (0, import_path5.dirname)(
|
|
1270
|
+
for (const path12 of filePaths) {
|
|
1271
|
+
const dir = (0, import_path5.dirname)(path12);
|
|
1257
1272
|
if (dir && dir !== ".") {
|
|
1258
1273
|
dirs.add(dir);
|
|
1259
1274
|
const parts = dir.split("/");
|
|
@@ -8938,11 +8953,11 @@ function validateFormat(format, data, subtype) {
|
|
|
8938
8953
|
const warnings = [];
|
|
8939
8954
|
if (!valid && validate.errors) {
|
|
8940
8955
|
for (const error of validate.errors) {
|
|
8941
|
-
const
|
|
8956
|
+
const path12 = error.instancePath || "/" + error.params.missingProperty || "/";
|
|
8942
8957
|
const message = error.message || "Validation error";
|
|
8943
8958
|
const validationError = {
|
|
8944
|
-
path:
|
|
8945
|
-
message: `${
|
|
8959
|
+
path: path12,
|
|
8960
|
+
message: `${path12}: ${message}`,
|
|
8946
8961
|
value: error.data
|
|
8947
8962
|
};
|
|
8948
8963
|
if (error.keyword === "deprecated") {
|
|
@@ -15199,7 +15214,7 @@ async function handleCollectionsSearch(query, options) {
|
|
|
15199
15214
|
const startTime = Date.now();
|
|
15200
15215
|
try {
|
|
15201
15216
|
const config = await getConfig();
|
|
15202
|
-
const client = (0,
|
|
15217
|
+
const client = (0, import_registry_client5.getRegistryClient)(config);
|
|
15203
15218
|
console.log(`\u{1F50D} Searching collections for "${query}"...
|
|
15204
15219
|
`);
|
|
15205
15220
|
const result = await client.getCollections({
|
|
@@ -15292,7 +15307,7 @@ async function handleCollectionsList(options) {
|
|
|
15292
15307
|
const startTime = Date.now();
|
|
15293
15308
|
try {
|
|
15294
15309
|
const config = await getConfig();
|
|
15295
|
-
const client = (0,
|
|
15310
|
+
const client = (0, import_registry_client5.getRegistryClient)(config);
|
|
15296
15311
|
console.log("\u{1F4E6} Searching collections...\n");
|
|
15297
15312
|
const result = await client.getCollections({
|
|
15298
15313
|
category: options.category,
|
|
@@ -15393,7 +15408,7 @@ async function handleCollectionInfo(collectionSpec) {
|
|
|
15393
15408
|
}
|
|
15394
15409
|
[, name_slug, version] = match;
|
|
15395
15410
|
const config = await getConfig();
|
|
15396
|
-
const client = (0,
|
|
15411
|
+
const client = (0, import_registry_client5.getRegistryClient)(config);
|
|
15397
15412
|
console.log(`\u{1F4E6} Loading collection: ${name_slug}...
|
|
15398
15413
|
`);
|
|
15399
15414
|
const collection = await client.getCollection(name_slug, version);
|
|
@@ -15484,14 +15499,14 @@ async function handleCollectionPublish(manifestPath = "./collection.json") {
|
|
|
15484
15499
|
const startTime = Date.now();
|
|
15485
15500
|
try {
|
|
15486
15501
|
const config = await getConfig();
|
|
15487
|
-
const client = (0,
|
|
15502
|
+
const client = (0, import_registry_client5.getRegistryClient)(config);
|
|
15488
15503
|
if (!config.token) {
|
|
15489
15504
|
console.error("\n\u274C Authentication required. Run `prpm login` first.\n");
|
|
15490
15505
|
throw new CLIError("\n\u274C Authentication required. Run `prpm login` first.", 1);
|
|
15491
15506
|
}
|
|
15492
15507
|
console.log("\u{1F4E6} Publishing collection...\n");
|
|
15493
|
-
const
|
|
15494
|
-
const manifestContent = await
|
|
15508
|
+
const fs16 = await import("fs/promises");
|
|
15509
|
+
const manifestContent = await fs16.readFile(manifestPath, "utf-8");
|
|
15495
15510
|
const manifest = JSON.parse(manifestContent);
|
|
15496
15511
|
const required = ["id", "name", "description", "packages"];
|
|
15497
15512
|
const missing = required.filter((field) => !manifest[field]);
|
|
@@ -15587,7 +15602,7 @@ async function handleCollectionDeprecate(collectionSpec, options) {
|
|
|
15587
15602
|
console.error("\n\u274C Authentication required. Run `prpm login` first.\n");
|
|
15588
15603
|
throw new CLIError("Authentication required. Run `prpm login` first.", 1);
|
|
15589
15604
|
}
|
|
15590
|
-
const client = (0,
|
|
15605
|
+
const client = (0, import_registry_client5.getRegistryClient)(config);
|
|
15591
15606
|
const action = options.undo ? "Undeprecating" : "Deprecating";
|
|
15592
15607
|
console.log(`\u26A0\uFE0F ${action} collection: ${name_slug}...
|
|
15593
15608
|
`);
|
|
@@ -15648,7 +15663,7 @@ async function handleCollectionInstall(collectionSpec, options) {
|
|
|
15648
15663
|
}
|
|
15649
15664
|
[, name_slug, version] = match;
|
|
15650
15665
|
const config = await getConfig();
|
|
15651
|
-
const client = (0,
|
|
15666
|
+
const client = (0, import_registry_client5.getRegistryClient)(config);
|
|
15652
15667
|
console.log(`\u{1F4E6} Installing collection: ${name_slug}...
|
|
15653
15668
|
`);
|
|
15654
15669
|
const installResult = await client.installCollection({
|
|
@@ -15761,7 +15776,7 @@ async function handleCollectionInstall(collectionSpec, options) {
|
|
|
15761
15776
|
}
|
|
15762
15777
|
}
|
|
15763
15778
|
function createCollectionsCommand() {
|
|
15764
|
-
const command = new
|
|
15779
|
+
const command = new import_commander11.Command("collections");
|
|
15765
15780
|
command.description("Manage package collections").alias("collection").action(async (options) => {
|
|
15766
15781
|
await handleCollectionsList(options);
|
|
15767
15782
|
});
|
|
@@ -15783,13 +15798,13 @@ function createCollectionsCommand() {
|
|
|
15783
15798
|
});
|
|
15784
15799
|
return command;
|
|
15785
15800
|
}
|
|
15786
|
-
var
|
|
15801
|
+
var import_commander11, import_registry_client5;
|
|
15787
15802
|
var init_collections = __esm({
|
|
15788
15803
|
"src/commands/collections.ts"() {
|
|
15789
15804
|
"use strict";
|
|
15790
15805
|
init_cjs_shims();
|
|
15791
|
-
|
|
15792
|
-
|
|
15806
|
+
import_commander11 = require("commander");
|
|
15807
|
+
import_registry_client5 = require("@pr-pm/registry-client");
|
|
15793
15808
|
init_user_config();
|
|
15794
15809
|
init_install();
|
|
15795
15810
|
init_telemetry();
|
|
@@ -16046,7 +16061,7 @@ function findMainFile(files, format, subtype) {
|
|
|
16046
16061
|
const nestedIndicator = getNestedIndicator(format, subtype);
|
|
16047
16062
|
if (nestedIndicator) {
|
|
16048
16063
|
const match = files.find((f) => {
|
|
16049
|
-
const filename =
|
|
16064
|
+
const filename = import_path15.default.basename(f.name);
|
|
16050
16065
|
return filename.toLowerCase() === nestedIndicator.toLowerCase();
|
|
16051
16066
|
});
|
|
16052
16067
|
if (match) return match;
|
|
@@ -16055,7 +16070,7 @@ function findMainFile(files, format, subtype) {
|
|
|
16055
16070
|
if (filePatterns) {
|
|
16056
16071
|
for (const pattern of filePatterns) {
|
|
16057
16072
|
for (const file of files) {
|
|
16058
|
-
const filename =
|
|
16073
|
+
const filename = import_path15.default.basename(file.name);
|
|
16059
16074
|
if (pattern.startsWith("*")) {
|
|
16060
16075
|
const extension = pattern.slice(1);
|
|
16061
16076
|
if (filename.endsWith(extension)) {
|
|
@@ -16086,7 +16101,7 @@ function findMainFile(files, format, subtype) {
|
|
|
16086
16101
|
];
|
|
16087
16102
|
for (const pattern of fallbackPatterns) {
|
|
16088
16103
|
for (const file of files) {
|
|
16089
|
-
const filename =
|
|
16104
|
+
const filename = import_path15.default.basename(file.name);
|
|
16090
16105
|
if (filename.toLowerCase() === pattern.toLowerCase()) {
|
|
16091
16106
|
return file;
|
|
16092
16107
|
}
|
|
@@ -16145,19 +16160,32 @@ async function handleInstall(packageSpec, options) {
|
|
|
16145
16160
|
version = options.version || specVersion || lockedVersion || "latest";
|
|
16146
16161
|
}
|
|
16147
16162
|
if (!options.force && lockfile && targetFormat) {
|
|
16148
|
-
const
|
|
16149
|
-
|
|
16163
|
+
const requestedLocation = (_a = options.location) == null ? void 0 : _a.trim();
|
|
16164
|
+
let installedPkg;
|
|
16165
|
+
let matchedKey;
|
|
16166
|
+
const snippetLocation = requestedLocation || "AGENTS.md";
|
|
16167
|
+
const snippetKey = getLockfileKey(packageId, targetFormat, snippetLocation);
|
|
16168
|
+
if (lockfile.packages[snippetKey]) {
|
|
16169
|
+
installedPkg = lockfile.packages[snippetKey];
|
|
16170
|
+
matchedKey = snippetKey;
|
|
16171
|
+
}
|
|
16172
|
+
if (!installedPkg) {
|
|
16173
|
+
const standardKey = getLockfileKey(packageId, targetFormat);
|
|
16174
|
+
if (lockfile.packages[standardKey]) {
|
|
16175
|
+
installedPkg = lockfile.packages[standardKey];
|
|
16176
|
+
matchedKey = standardKey;
|
|
16177
|
+
}
|
|
16178
|
+
}
|
|
16150
16179
|
if (installedPkg) {
|
|
16151
16180
|
const requestedVersion = options.version || specVersion;
|
|
16152
|
-
const existingLocation = ((
|
|
16153
|
-
const requestedLocation = (_b = options.location) == null ? void 0 : _b.trim();
|
|
16181
|
+
const existingLocation = ((_b = installedPkg.snippetMetadata) == null ? void 0 : _b.targetPath) || installedPkg.installedPath;
|
|
16154
16182
|
let isDifferentLocation = false;
|
|
16155
16183
|
if (requestedLocation && existingLocation) {
|
|
16156
16184
|
if (installedPkg.subtype === "snippet") {
|
|
16157
|
-
isDifferentLocation =
|
|
16185
|
+
isDifferentLocation = import_path15.default.resolve(requestedLocation) !== import_path15.default.resolve(existingLocation);
|
|
16158
16186
|
} else {
|
|
16159
|
-
const existingDir =
|
|
16160
|
-
isDifferentLocation =
|
|
16187
|
+
const existingDir = import_path15.default.dirname(existingLocation);
|
|
16188
|
+
isDifferentLocation = import_path15.default.resolve(requestedLocation) !== import_path15.default.resolve(existingDir);
|
|
16161
16189
|
}
|
|
16162
16190
|
}
|
|
16163
16191
|
if (!requestedVersion || requestedVersion === "latest" || requestedVersion === installedPkg.version) {
|
|
@@ -16194,7 +16222,7 @@ async function handleInstall(packageSpec, options) {
|
|
|
16194
16222
|
}
|
|
16195
16223
|
}
|
|
16196
16224
|
console.log(`\u{1F4E5} Installing ${packageId}@${version}...`);
|
|
16197
|
-
const client = (0,
|
|
16225
|
+
const client = (0, import_registry_client6.getRegistryClient)(config);
|
|
16198
16226
|
let isCollection = false;
|
|
16199
16227
|
try {
|
|
16200
16228
|
await client.getCollection(packageId, version === "latest" ? void 0 : version);
|
|
@@ -16506,9 +16534,9 @@ This could indicate:
|
|
|
16506
16534
|
(f) => f.name.startsWith("agents/") && f.name.endsWith(".md")
|
|
16507
16535
|
);
|
|
16508
16536
|
if (agentFiles.length > 0) {
|
|
16509
|
-
await
|
|
16537
|
+
await import_promises4.default.mkdir(".claude/agents", { recursive: true });
|
|
16510
16538
|
for (const file of agentFiles) {
|
|
16511
|
-
const filename =
|
|
16539
|
+
const filename = import_path15.default.basename(file.name);
|
|
16512
16540
|
const destFile = `.claude/agents/${filename}`;
|
|
16513
16541
|
await saveFile(destFile, file.content);
|
|
16514
16542
|
installedFiles.push(destFile);
|
|
@@ -16522,8 +16550,8 @@ This could indicate:
|
|
|
16522
16550
|
for (const file of skillFiles) {
|
|
16523
16551
|
const relativePath = file.name.replace(/^skills\//, "");
|
|
16524
16552
|
const destFile = `.claude/skills/${relativePath}`;
|
|
16525
|
-
const destFileDir =
|
|
16526
|
-
await
|
|
16553
|
+
const destFileDir = import_path15.default.dirname(destFile);
|
|
16554
|
+
await import_promises4.default.mkdir(destFileDir, { recursive: true });
|
|
16527
16555
|
await saveFile(destFile, file.content);
|
|
16528
16556
|
installedFiles.push(destFile);
|
|
16529
16557
|
}
|
|
@@ -16533,9 +16561,9 @@ This could indicate:
|
|
|
16533
16561
|
(f) => f.name.startsWith("commands/") && f.name.endsWith(".md")
|
|
16534
16562
|
);
|
|
16535
16563
|
if (commandFiles.length > 0) {
|
|
16536
|
-
await
|
|
16564
|
+
await import_promises4.default.mkdir(".claude/commands", { recursive: true });
|
|
16537
16565
|
for (const file of commandFiles) {
|
|
16538
|
-
const filename =
|
|
16566
|
+
const filename = import_path15.default.basename(file.name);
|
|
16539
16567
|
const destFile = `.claude/commands/${filename}`;
|
|
16540
16568
|
await saveFile(destFile, file.content);
|
|
16541
16569
|
installedFiles.push(destFile);
|
|
@@ -16646,7 +16674,7 @@ This could indicate:
|
|
|
16646
16674
|
destDir = getDestinationDir2(effectiveFormat, effectiveSubtype, pkg.name);
|
|
16647
16675
|
if (locationOverride && effectiveFormat === "cursor") {
|
|
16648
16676
|
const relativeDestDir = destDir.startsWith("./") ? destDir.slice(2) : destDir;
|
|
16649
|
-
destDir =
|
|
16677
|
+
destDir = import_path15.default.join(locationOverride, relativeDestDir);
|
|
16650
16678
|
console.log(` \u{1F4C1} Installing Cursor package to custom location: ${destDir}`);
|
|
16651
16679
|
}
|
|
16652
16680
|
let mainFile = extractedFiles[0].content;
|
|
@@ -16677,7 +16705,7 @@ This could indicate:
|
|
|
16677
16705
|
const manifestFilename = getManifestFilename(effectiveFormat);
|
|
16678
16706
|
let targetPath = manifestFilename;
|
|
16679
16707
|
if (locationOverride) {
|
|
16680
|
-
targetPath =
|
|
16708
|
+
targetPath = import_path15.default.join(locationOverride, `${manifestFilename.replace(".md", ".override.md")}`);
|
|
16681
16709
|
console.log(` \u{1F4C1} Installing to custom location: ${targetPath}`);
|
|
16682
16710
|
}
|
|
16683
16711
|
destPath = targetPath;
|
|
@@ -16771,7 +16799,7 @@ This could indicate:
|
|
|
16771
16799
|
let existingSettings = { hooks: {} };
|
|
16772
16800
|
if (await fileExists(destPath)) {
|
|
16773
16801
|
try {
|
|
16774
|
-
const existingContent = await
|
|
16802
|
+
const existingContent = await import_promises4.default.readFile(destPath, "utf-8");
|
|
16775
16803
|
existingSettings = JSON.parse(existingContent);
|
|
16776
16804
|
if (!existingSettings.hooks) {
|
|
16777
16805
|
existingSettings.hooks = {};
|
|
@@ -16825,7 +16853,7 @@ This could indicate:
|
|
|
16825
16853
|
}
|
|
16826
16854
|
if (locationOverride && effectiveFormat === "cursor") {
|
|
16827
16855
|
const relativeDestDir = destDir.startsWith("./") ? destDir.slice(2) : destDir;
|
|
16828
|
-
destDir =
|
|
16856
|
+
destDir = import_path15.default.join(locationOverride, relativeDestDir);
|
|
16829
16857
|
console.log(` \u{1F4C1} Installing Cursor package to custom location: ${destDir}`);
|
|
16830
16858
|
}
|
|
16831
16859
|
const isCursorConversion = effectiveFormat === "cursor" && pkg.format === "claude" && pkg.subtype === "skill";
|
|
@@ -16892,7 +16920,7 @@ This could indicate:
|
|
|
16892
16920
|
}
|
|
16893
16921
|
if (isCursorConversion && jsonFiles.length > 0) {
|
|
16894
16922
|
const mdcFile = `${packageDir}/${packageName}.mdc`;
|
|
16895
|
-
let mdcContent = await
|
|
16923
|
+
let mdcContent = await import_promises4.default.readFile(mdcFile, "utf-8");
|
|
16896
16924
|
const frontmatterMatch = mdcContent.match(/^---\n[\s\S]*?\n---\n/);
|
|
16897
16925
|
if (frontmatterMatch) {
|
|
16898
16926
|
const frontmatterEnd = frontmatterMatch[0].length;
|
|
@@ -16983,7 +17011,8 @@ ${afterFrontmatter}`;
|
|
|
16983
17011
|
snippetMetadata
|
|
16984
17012
|
// Track snippet installation metadata for uninstall
|
|
16985
17013
|
});
|
|
16986
|
-
|
|
17014
|
+
const snippetTargetPath = effectiveSubtype === "snippet" ? snippetMetadata == null ? void 0 : snippetMetadata.targetPath : void 0;
|
|
17015
|
+
setPackageIntegrity(updatedLockfile, packageId, tarball, effectiveFormat, snippetTargetPath);
|
|
16987
17016
|
await writeLockfile(updatedLockfile);
|
|
16988
17017
|
await client.trackDownload(packageId, {
|
|
16989
17018
|
version: actualVersion || version,
|
|
@@ -17045,12 +17074,12 @@ ${afterFrontmatter}`;
|
|
|
17045
17074
|
await telemetry.shutdown();
|
|
17046
17075
|
}
|
|
17047
17076
|
}
|
|
17048
|
-
function
|
|
17049
|
-
const resolvedPath =
|
|
17050
|
-
const resolvedTarget =
|
|
17051
|
-
return resolvedPath.startsWith(resolvedTarget +
|
|
17077
|
+
function isPathSafe2(targetDir, filePath) {
|
|
17078
|
+
const resolvedPath = import_path15.default.resolve(targetDir, filePath);
|
|
17079
|
+
const resolvedTarget = import_path15.default.resolve(targetDir);
|
|
17080
|
+
return resolvedPath.startsWith(resolvedTarget + import_path15.default.sep) || resolvedPath === resolvedTarget;
|
|
17052
17081
|
}
|
|
17053
|
-
function
|
|
17082
|
+
function hasUnsafePathPatterns2(filePath) {
|
|
17054
17083
|
if (filePath.includes("..")) return true;
|
|
17055
17084
|
if (filePath.startsWith("/")) return true;
|
|
17056
17085
|
if (/^[a-zA-Z]:/.test(filePath)) return true;
|
|
@@ -17061,7 +17090,7 @@ async function extractTarball(tarball, packageId) {
|
|
|
17061
17090
|
let decompressed;
|
|
17062
17091
|
try {
|
|
17063
17092
|
decompressed = await new Promise((resolve3, reject) => {
|
|
17064
|
-
|
|
17093
|
+
import_zlib2.default.gunzip(tarball, (err, result) => {
|
|
17065
17094
|
if (err) {
|
|
17066
17095
|
reject(new Error(`Failed to decompress tarball: ${err.message}`));
|
|
17067
17096
|
return;
|
|
@@ -17072,10 +17101,10 @@ async function extractTarball(tarball, packageId) {
|
|
|
17072
17101
|
} catch (error) {
|
|
17073
17102
|
throw new CLIError(`Package decompression failed: ${error.message}`);
|
|
17074
17103
|
}
|
|
17075
|
-
const tmpDir = await
|
|
17104
|
+
const tmpDir = await import_promises4.default.mkdtemp(import_path15.default.join(import_os5.default.tmpdir(), "prpm-"));
|
|
17076
17105
|
const cleanup = async () => {
|
|
17077
17106
|
try {
|
|
17078
|
-
await
|
|
17107
|
+
await import_promises4.default.rm(tmpDir, { recursive: true, force: true });
|
|
17079
17108
|
} catch {
|
|
17080
17109
|
}
|
|
17081
17110
|
};
|
|
@@ -17089,7 +17118,7 @@ async function extractTarball(tarball, packageId) {
|
|
|
17089
17118
|
"LICENSE.md"
|
|
17090
17119
|
]);
|
|
17091
17120
|
try {
|
|
17092
|
-
const
|
|
17121
|
+
const extract3 = tar2.extract({
|
|
17093
17122
|
cwd: tmpDir,
|
|
17094
17123
|
strict: true,
|
|
17095
17124
|
// Enable strict mode to reject malformed archives
|
|
@@ -17104,19 +17133,19 @@ async function extractTarball(tarball, packageId) {
|
|
|
17104
17133
|
console.warn(` \u26A0\uFE0F Blocked symlink in package: ${entryPath}`);
|
|
17105
17134
|
return false;
|
|
17106
17135
|
}
|
|
17107
|
-
if (
|
|
17136
|
+
if (hasUnsafePathPatterns2(entryPath)) {
|
|
17108
17137
|
console.warn(` \u26A0\uFE0F Blocked unsafe path in package: ${entryPath}`);
|
|
17109
17138
|
return false;
|
|
17110
17139
|
}
|
|
17111
|
-
if (!
|
|
17140
|
+
if (!isPathSafe2(tmpDir, entryPath)) {
|
|
17112
17141
|
console.warn(` \u26A0\uFE0F Blocked path traversal attempt: ${entryPath}`);
|
|
17113
17142
|
return false;
|
|
17114
17143
|
}
|
|
17115
17144
|
return true;
|
|
17116
17145
|
}
|
|
17117
17146
|
});
|
|
17118
|
-
await (0,
|
|
17119
|
-
const extractedFiles = await collectExtractedFiles(tmpDir, excludedNames,
|
|
17147
|
+
await (0, import_promises3.pipeline)(import_stream2.Readable.from(decompressed), extract3);
|
|
17148
|
+
const extractedFiles = await collectExtractedFiles(tmpDir, excludedNames, import_promises4.default);
|
|
17120
17149
|
if (extractedFiles.length === 0) {
|
|
17121
17150
|
throw new CLIError("Package archive contains no valid files");
|
|
17122
17151
|
}
|
|
@@ -17134,15 +17163,15 @@ async function extractTarball(tarball, packageId) {
|
|
|
17134
17163
|
await cleanup();
|
|
17135
17164
|
}
|
|
17136
17165
|
}
|
|
17137
|
-
async function collectExtractedFiles(rootDir, excludedNames,
|
|
17166
|
+
async function collectExtractedFiles(rootDir, excludedNames, fs16) {
|
|
17138
17167
|
const files = [];
|
|
17139
17168
|
const dirs = [rootDir];
|
|
17140
17169
|
while (dirs.length > 0) {
|
|
17141
17170
|
const currentDir = dirs.pop();
|
|
17142
17171
|
if (!currentDir) continue;
|
|
17143
|
-
const entries = await
|
|
17172
|
+
const entries = await fs16.readdir(currentDir, { withFileTypes: true });
|
|
17144
17173
|
for (const entry of entries) {
|
|
17145
|
-
const fullPath =
|
|
17174
|
+
const fullPath = import_path15.default.join(currentDir, entry.name);
|
|
17146
17175
|
if (entry.isDirectory()) {
|
|
17147
17176
|
dirs.push(fullPath);
|
|
17148
17177
|
continue;
|
|
@@ -17153,8 +17182,8 @@ async function collectExtractedFiles(rootDir, excludedNames, fs15) {
|
|
|
17153
17182
|
if (excludedNames.has(entry.name)) {
|
|
17154
17183
|
continue;
|
|
17155
17184
|
}
|
|
17156
|
-
const content = await
|
|
17157
|
-
const relativePath =
|
|
17185
|
+
const content = await fs16.readFile(fullPath, "utf-8");
|
|
17186
|
+
const relativePath = import_path15.default.relative(rootDir, fullPath).split(import_path15.default.sep).join("/");
|
|
17158
17187
|
files.push({
|
|
17159
17188
|
name: relativePath,
|
|
17160
17189
|
content
|
|
@@ -17188,11 +17217,11 @@ async function installFromLockfile(options) {
|
|
|
17188
17217
|
console.log(` Installing ${displayName}...`);
|
|
17189
17218
|
let locationOverride = options.location;
|
|
17190
17219
|
if (!locationOverride && lockEntry.format === "agents.md" && lockEntry.installedPath) {
|
|
17191
|
-
const baseName =
|
|
17220
|
+
const baseName = import_path15.default.basename(lockEntry.installedPath);
|
|
17192
17221
|
if (baseName === "AGENTS.override.md") {
|
|
17193
|
-
locationOverride =
|
|
17222
|
+
locationOverride = import_path15.default.dirname(lockEntry.installedPath);
|
|
17194
17223
|
} else if (baseName !== "AGENTS.md") {
|
|
17195
|
-
locationOverride =
|
|
17224
|
+
locationOverride = import_path15.default.dirname(lockEntry.installedPath);
|
|
17196
17225
|
}
|
|
17197
17226
|
}
|
|
17198
17227
|
const manifestFile = (_a = lockEntry.progressiveDisclosure) == null ? void 0 : _a.manifestPath;
|
|
@@ -17237,7 +17266,7 @@ async function installFromLockfile(options) {
|
|
|
17237
17266
|
}
|
|
17238
17267
|
}
|
|
17239
17268
|
function createInstallCommand() {
|
|
17240
|
-
const command = new
|
|
17269
|
+
const command = new import_commander12.Command("install");
|
|
17241
17270
|
command.description("Install a package from the registry, or install all packages from prpm.lock if no package specified").argument("[package]", "Package to install (e.g., react-rules or react-rules@1.2.0). If omitted, installs all packages from prpm.lock").option("--version <version>", "Specific version to install").option("--as <format>", `Convert and install in specific format (${import_types.FORMATS.join(", ")})`).option("--format <format>", "Alias for --as").option("--location <path>", "Custom location for installed files (Agents.md or nested Cursor rules)").option("--subtype <subtype>", "Specify subtype when converting (skill, agent, rule, etc.)").option("--hook-mapping <strategy>", "Hook mapping strategy: auto (default), strict, skip", "auto").option("--frozen-lockfile", "Fail if lock file needs to be updated (for CI)").option("-y, --yes", "Auto-confirm prompts (overwrite files without asking)").option("--no-append", "Skip adding skill to manifest file (skill files only)").option("--manifest-file <filename>", "Custom manifest filename for progressive disclosure").option("--eager", "Force skill/agent to always activate (not on-demand)").option("--lazy", "Use default on-demand activation (overrides package eager setting)").action(async (packageSpec, options) => {
|
|
17242
17271
|
const convertTo = options.format || options.as;
|
|
17243
17272
|
const validFormats = import_types.FORMATS;
|
|
@@ -17286,27 +17315,27 @@ Valid strategies: ${VALID_HOOK_MAPPING_STRATEGIES.join(", ")}`
|
|
|
17286
17315
|
});
|
|
17287
17316
|
return command;
|
|
17288
17317
|
}
|
|
17289
|
-
var
|
|
17318
|
+
var import_commander12, import_registry_client6, import_stream2, import_promises3, tar2, import_path15, import_zlib2, import_promises4, import_os5, import_semver;
|
|
17290
17319
|
var init_install = __esm({
|
|
17291
17320
|
"src/commands/install.ts"() {
|
|
17292
17321
|
"use strict";
|
|
17293
17322
|
init_cjs_shims();
|
|
17294
|
-
|
|
17323
|
+
import_commander12 = require("commander");
|
|
17295
17324
|
init_source();
|
|
17296
|
-
|
|
17325
|
+
import_registry_client6 = require("@pr-pm/registry-client");
|
|
17297
17326
|
init_user_config();
|
|
17298
17327
|
init_filesystem();
|
|
17299
17328
|
init_telemetry();
|
|
17300
17329
|
init_types();
|
|
17301
|
-
|
|
17302
|
-
|
|
17303
|
-
|
|
17330
|
+
import_stream2 = require("stream");
|
|
17331
|
+
import_promises3 = require("stream/promises");
|
|
17332
|
+
tar2 = __toESM(require("tar"));
|
|
17304
17333
|
init_errors();
|
|
17305
17334
|
init_prompts();
|
|
17306
|
-
|
|
17307
|
-
|
|
17308
|
-
|
|
17309
|
-
|
|
17335
|
+
import_path15 = __toESM(require("path"));
|
|
17336
|
+
import_zlib2 = __toESM(require("zlib"));
|
|
17337
|
+
import_promises4 = __toESM(require("fs/promises"));
|
|
17338
|
+
import_os5 = __toESM(require("os"));
|
|
17310
17339
|
import_semver = __toESM(require("semver"));
|
|
17311
17340
|
init_collections();
|
|
17312
17341
|
init_lockfile();
|
|
@@ -17412,7 +17441,7 @@ async function fileExists2(filePath) {
|
|
|
17412
17441
|
}
|
|
17413
17442
|
async function scanDirectory2(config, cwd) {
|
|
17414
17443
|
const packages = [];
|
|
17415
|
-
const fullDir =
|
|
17444
|
+
const fullDir = import_path21.default.join(cwd, config.directory);
|
|
17416
17445
|
if (!await directoryExists2(fullDir)) {
|
|
17417
17446
|
return packages;
|
|
17418
17447
|
}
|
|
@@ -17420,13 +17449,13 @@ async function scanDirectory2(config, cwd) {
|
|
|
17420
17449
|
if (config.nested) {
|
|
17421
17450
|
for (const entry of entries) {
|
|
17422
17451
|
if (!entry.isDirectory()) continue;
|
|
17423
|
-
const packageDir =
|
|
17452
|
+
const packageDir = import_path21.default.join(fullDir, entry.name);
|
|
17424
17453
|
if (config.nestedIndicator) {
|
|
17425
|
-
const indicatorPath =
|
|
17454
|
+
const indicatorPath = import_path21.default.join(packageDir, config.nestedIndicator);
|
|
17426
17455
|
if (!await fileExists2(indicatorPath)) continue;
|
|
17427
17456
|
const packageFiles = await collectPackageFiles(packageDir, config.directory, entry.name);
|
|
17428
17457
|
const metadata = await extractMetadata2(indicatorPath);
|
|
17429
|
-
const relativePath =
|
|
17458
|
+
const relativePath = import_path21.default.join(config.directory, entry.name, config.nestedIndicator);
|
|
17430
17459
|
packages.push({
|
|
17431
17460
|
name: metadata.name || filenameToPackageName(entry.name),
|
|
17432
17461
|
format: config.format,
|
|
@@ -17441,8 +17470,8 @@ async function scanDirectory2(config, cwd) {
|
|
|
17441
17470
|
for (const subEntry of subEntries) {
|
|
17442
17471
|
if (!subEntry.isFile()) continue;
|
|
17443
17472
|
if (!matchesPattern(subEntry.name, config.patterns)) continue;
|
|
17444
|
-
const filePath =
|
|
17445
|
-
const relativePath =
|
|
17473
|
+
const filePath = import_path21.default.join(packageDir, subEntry.name);
|
|
17474
|
+
const relativePath = import_path21.default.join(config.directory, entry.name, subEntry.name);
|
|
17446
17475
|
const metadata = await extractMetadata2(filePath);
|
|
17447
17476
|
packages.push({
|
|
17448
17477
|
name: metadata.name || filenameToPackageName(entry.name),
|
|
@@ -17460,8 +17489,8 @@ async function scanDirectory2(config, cwd) {
|
|
|
17460
17489
|
for (const entry of entries) {
|
|
17461
17490
|
if (!entry.isFile()) continue;
|
|
17462
17491
|
if (!matchesPattern(entry.name, config.patterns)) continue;
|
|
17463
|
-
const filePath =
|
|
17464
|
-
const relativePath =
|
|
17492
|
+
const filePath = import_path21.default.join(fullDir, entry.name);
|
|
17493
|
+
const relativePath = import_path21.default.join(config.directory, entry.name);
|
|
17465
17494
|
const metadata = await extractMetadata2(filePath);
|
|
17466
17495
|
packages.push({
|
|
17467
17496
|
name: metadata.name || filenameToPackageName(entry.name),
|
|
@@ -17481,22 +17510,22 @@ async function collectPackageFiles(packageDir, baseDir, packageName) {
|
|
|
17481
17510
|
async function walkDir(dir, relativeBase) {
|
|
17482
17511
|
const entries = await import_fs16.promises.readdir(dir, { withFileTypes: true });
|
|
17483
17512
|
for (const entry of entries) {
|
|
17484
|
-
const fullPath =
|
|
17485
|
-
const relativePath =
|
|
17513
|
+
const fullPath = import_path21.default.join(dir, entry.name);
|
|
17514
|
+
const relativePath = import_path21.default.join(relativeBase, entry.name);
|
|
17486
17515
|
if (entry.isDirectory()) {
|
|
17487
17516
|
if (["node_modules", "dist", ".git", "coverage"].includes(entry.name)) {
|
|
17488
17517
|
continue;
|
|
17489
17518
|
}
|
|
17490
17519
|
await walkDir(fullPath, relativePath);
|
|
17491
17520
|
} else if (entry.isFile()) {
|
|
17492
|
-
const ext =
|
|
17521
|
+
const ext = import_path21.default.extname(entry.name).toLowerCase();
|
|
17493
17522
|
if ([".md", ".json", ".js", ".ts", ".toml"].includes(ext)) {
|
|
17494
17523
|
files.push(relativePath);
|
|
17495
17524
|
}
|
|
17496
17525
|
}
|
|
17497
17526
|
}
|
|
17498
17527
|
}
|
|
17499
|
-
await walkDir(packageDir,
|
|
17528
|
+
await walkDir(packageDir, import_path21.default.join(baseDir, packageName));
|
|
17500
17529
|
return files;
|
|
17501
17530
|
}
|
|
17502
17531
|
function buildRootManifestFiles() {
|
|
@@ -17518,7 +17547,7 @@ async function scanForPackages(cwd = process.cwd()) {
|
|
|
17518
17547
|
allPackages.push(...packages);
|
|
17519
17548
|
}
|
|
17520
17549
|
for (const { file, format } of ROOT_MANIFEST_FILES) {
|
|
17521
|
-
const filePath =
|
|
17550
|
+
const filePath = import_path21.default.join(cwd, file);
|
|
17522
17551
|
if (await fileExists2(filePath)) {
|
|
17523
17552
|
const metadata = await extractMetadata2(filePath);
|
|
17524
17553
|
allPackages.push({
|
|
@@ -17532,7 +17561,7 @@ async function scanForPackages(cwd = process.cwd()) {
|
|
|
17532
17561
|
});
|
|
17533
17562
|
}
|
|
17534
17563
|
}
|
|
17535
|
-
const copilotInstructionsPath =
|
|
17564
|
+
const copilotInstructionsPath = import_path21.default.join(cwd, ".github/copilot-instructions.md");
|
|
17536
17565
|
if (await fileExists2(copilotInstructionsPath)) {
|
|
17537
17566
|
const metadata = await extractMetadata2(copilotInstructionsPath);
|
|
17538
17567
|
allPackages.push({
|
|
@@ -17547,13 +17576,13 @@ async function scanForPackages(cwd = process.cwd()) {
|
|
|
17547
17576
|
}
|
|
17548
17577
|
return allPackages;
|
|
17549
17578
|
}
|
|
17550
|
-
var import_fs16,
|
|
17579
|
+
var import_fs16, import_path21, SCAN_CONFIGS, ROOT_MANIFEST_FILES;
|
|
17551
17580
|
var init_package_scanner = __esm({
|
|
17552
17581
|
"src/core/package-scanner.ts"() {
|
|
17553
17582
|
"use strict";
|
|
17554
17583
|
init_cjs_shims();
|
|
17555
17584
|
import_fs16 = require("fs");
|
|
17556
|
-
|
|
17585
|
+
import_path21 = __toESM(require("path"));
|
|
17557
17586
|
init_dist();
|
|
17558
17587
|
SCAN_CONFIGS = buildScanConfigs();
|
|
17559
17588
|
ROOT_MANIFEST_FILES = buildRootManifestFiles();
|
|
@@ -17563,7 +17592,7 @@ var init_package_scanner = __esm({
|
|
|
17563
17592
|
// src/core/package-reconciler.ts
|
|
17564
17593
|
async function readManifest(cwd = process.cwd()) {
|
|
17565
17594
|
try {
|
|
17566
|
-
const manifestPath =
|
|
17595
|
+
const manifestPath = import_path22.default.join(cwd, "prpm.json");
|
|
17567
17596
|
const content = await import_fs17.promises.readFile(manifestPath, "utf-8");
|
|
17568
17597
|
const raw = JSON.parse(content);
|
|
17569
17598
|
if ("packages" in raw && Array.isArray(raw.packages)) {
|
|
@@ -17646,7 +17675,7 @@ async function reconcilePackages(detected, manifest, cwd = process.cwd()) {
|
|
|
17646
17675
|
const manifestPkg = manifest[mi];
|
|
17647
17676
|
let anyFileExists = false;
|
|
17648
17677
|
for (const file of manifestPkg.files) {
|
|
17649
|
-
const fullPath =
|
|
17678
|
+
const fullPath = import_path22.default.join(cwd, file);
|
|
17650
17679
|
if (await fileExists3(fullPath)) {
|
|
17651
17680
|
anyFileExists = true;
|
|
17652
17681
|
break;
|
|
@@ -17715,7 +17744,7 @@ function createManifestFromDetected(packages, defaults) {
|
|
|
17715
17744
|
files: pkg.files
|
|
17716
17745
|
};
|
|
17717
17746
|
}
|
|
17718
|
-
const projectName =
|
|
17747
|
+
const projectName = import_path22.default.basename(process.cwd()).toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
17719
17748
|
return {
|
|
17720
17749
|
name: `${projectName}-packages`,
|
|
17721
17750
|
version: "1.0.0",
|
|
@@ -17726,13 +17755,13 @@ function createManifestFromDetected(packages, defaults) {
|
|
|
17726
17755
|
packages: packages.map(detectedToManifest)
|
|
17727
17756
|
};
|
|
17728
17757
|
}
|
|
17729
|
-
var import_fs17,
|
|
17758
|
+
var import_fs17, import_path22;
|
|
17730
17759
|
var init_package_reconciler = __esm({
|
|
17731
17760
|
"src/core/package-reconciler.ts"() {
|
|
17732
17761
|
"use strict";
|
|
17733
17762
|
init_cjs_shims();
|
|
17734
17763
|
import_fs17 = require("fs");
|
|
17735
|
-
|
|
17764
|
+
import_path22 = __toESM(require("path"));
|
|
17736
17765
|
}
|
|
17737
17766
|
});
|
|
17738
17767
|
|
|
@@ -17783,7 +17812,7 @@ ${question}`);
|
|
|
17783
17812
|
}
|
|
17784
17813
|
async function extractMetadataFromFile(filePath) {
|
|
17785
17814
|
try {
|
|
17786
|
-
const content = await (0,
|
|
17815
|
+
const content = await (0, import_promises10.readFile)(filePath, "utf-8");
|
|
17787
17816
|
const metadata = {};
|
|
17788
17817
|
const frontmatterMatch = content.match(/^---\s*\n([\s\S]*?)\n---/);
|
|
17789
17818
|
if (frontmatterMatch) {
|
|
@@ -17847,10 +17876,10 @@ function getDefaultAuthor() {
|
|
|
17847
17876
|
async function createExampleFiles(format, files, packageName) {
|
|
17848
17877
|
const templates = EXAMPLE_TEMPLATES[format] || {};
|
|
17849
17878
|
for (const file of files) {
|
|
17850
|
-
const filePath = (0,
|
|
17851
|
-
const dirPath = (0,
|
|
17879
|
+
const filePath = (0, import_path23.join)(process.cwd(), file);
|
|
17880
|
+
const dirPath = (0, import_path23.join)(filePath, "..");
|
|
17852
17881
|
if (!(0, import_fs18.existsSync)(dirPath)) {
|
|
17853
|
-
await (0,
|
|
17882
|
+
await (0, import_promises10.mkdir)(dirPath, { recursive: true });
|
|
17854
17883
|
}
|
|
17855
17884
|
if ((0, import_fs18.existsSync)(filePath)) {
|
|
17856
17885
|
console.log(` Skipping ${file} (already exists)`);
|
|
@@ -17861,12 +17890,12 @@ async function createExampleFiles(format, files, packageName) {
|
|
|
17861
17890
|
Add your content here.
|
|
17862
17891
|
`;
|
|
17863
17892
|
content = content.replace(/example-skill/g, packageName);
|
|
17864
|
-
await (0,
|
|
17893
|
+
await (0, import_promises10.writeFile)(filePath, content, "utf-8");
|
|
17865
17894
|
console.log(` Created ${file}`);
|
|
17866
17895
|
}
|
|
17867
17896
|
}
|
|
17868
17897
|
async function createReadme(config) {
|
|
17869
|
-
const readmePath = (0,
|
|
17898
|
+
const readmePath = (0, import_path23.join)(process.cwd(), "README.md");
|
|
17870
17899
|
if ((0, import_fs18.existsSync)(readmePath)) {
|
|
17871
17900
|
console.log(" Skipping README.md (already exists)");
|
|
17872
17901
|
return;
|
|
@@ -17897,7 +17926,7 @@ ${config.author}
|
|
|
17897
17926
|
|
|
17898
17927
|
${config.license}
|
|
17899
17928
|
`;
|
|
17900
|
-
await (0,
|
|
17929
|
+
await (0, import_promises10.writeFile)(readmePath, content, "utf-8");
|
|
17901
17930
|
console.log(" Created README.md");
|
|
17902
17931
|
}
|
|
17903
17932
|
function displayPackagesTable(packages) {
|
|
@@ -17976,7 +18005,7 @@ async function reviewMissingPackage(rl, pkg, index, total) {
|
|
|
17976
18005
|
return await confirm(rl, "\n Remove from prpm.json?", true);
|
|
17977
18006
|
}
|
|
17978
18007
|
async function smartInit(options) {
|
|
17979
|
-
const manifestPath = (0,
|
|
18008
|
+
const manifestPath = (0, import_path23.join)(process.cwd(), "prpm.json");
|
|
17980
18009
|
const hasManifest = (0, import_fs18.existsSync)(manifestPath);
|
|
17981
18010
|
console.log("\nScanning for packages...\n");
|
|
17982
18011
|
const detected = await scanForPackages();
|
|
@@ -18050,7 +18079,7 @@ ${summaryParts.join(" and ")} package${changes === 1 ? "" : "s"}?`,
|
|
|
18050
18079
|
packagesToRemove,
|
|
18051
18080
|
existingManifest.isMultiPackage
|
|
18052
18081
|
);
|
|
18053
|
-
await (0,
|
|
18082
|
+
await (0, import_promises10.writeFile)(
|
|
18054
18083
|
manifestPath,
|
|
18055
18084
|
JSON.stringify(updatedManifest, null, 2) + "\n",
|
|
18056
18085
|
"utf-8"
|
|
@@ -18109,7 +18138,7 @@ Create multi-package prpm.json with these ${detected.length} packages?` : "\nCre
|
|
|
18109
18138
|
author: defaultAuthor || void 0,
|
|
18110
18139
|
license: "MIT"
|
|
18111
18140
|
});
|
|
18112
|
-
await (0,
|
|
18141
|
+
await (0, import_promises10.writeFile)(
|
|
18113
18142
|
manifestPath,
|
|
18114
18143
|
JSON.stringify(manifest, null, 2) + "\n",
|
|
18115
18144
|
"utf-8"
|
|
@@ -18127,7 +18156,7 @@ Create multi-package prpm.json with these ${detected.length} packages?` : "\nCre
|
|
|
18127
18156
|
}
|
|
18128
18157
|
}
|
|
18129
18158
|
async function classicInit(options) {
|
|
18130
|
-
const manifestPath = (0,
|
|
18159
|
+
const manifestPath = (0, import_path23.join)(process.cwd(), "prpm.json");
|
|
18131
18160
|
if ((0, import_fs18.existsSync)(manifestPath) && !options.force) {
|
|
18132
18161
|
throw new Error(
|
|
18133
18162
|
"prpm.json already exists. Use --force to overwrite, or run this command in a different directory."
|
|
@@ -18299,7 +18328,7 @@ Current files (${config.files.length}):`);
|
|
|
18299
18328
|
manifest.tags = config.tags;
|
|
18300
18329
|
}
|
|
18301
18330
|
manifest.files = config.files;
|
|
18302
|
-
await (0,
|
|
18331
|
+
await (0, import_promises10.writeFile)(
|
|
18303
18332
|
manifestPath,
|
|
18304
18333
|
JSON.stringify(manifest, null, 2) + "\n",
|
|
18305
18334
|
"utf-8"
|
|
@@ -18386,11 +18415,11 @@ async function scanMode(directories, options) {
|
|
|
18386
18415
|
console.log("\u{1F50D} Dry run - no changes made\n");
|
|
18387
18416
|
return;
|
|
18388
18417
|
}
|
|
18389
|
-
const prpmJsonPath = options.output || (0,
|
|
18418
|
+
const prpmJsonPath = options.output || (0, import_path23.join)(process.cwd(), "prpm.json");
|
|
18390
18419
|
let manifest;
|
|
18391
18420
|
if (options.append) {
|
|
18392
18421
|
try {
|
|
18393
|
-
const existingContent = await (0,
|
|
18422
|
+
const existingContent = await (0, import_promises10.readFile)(prpmJsonPath, "utf-8");
|
|
18394
18423
|
const existing = JSON.parse(existingContent);
|
|
18395
18424
|
if ("packages" in existing && Array.isArray(existing.packages)) {
|
|
18396
18425
|
manifest = existing;
|
|
@@ -18436,7 +18465,7 @@ async function scanMode(directories, options) {
|
|
|
18436
18465
|
manifest.packages.push(packageManifest);
|
|
18437
18466
|
addedCount++;
|
|
18438
18467
|
}
|
|
18439
|
-
await (0,
|
|
18468
|
+
await (0, import_promises10.writeFile)(
|
|
18440
18469
|
prpmJsonPath,
|
|
18441
18470
|
JSON.stringify(manifest, null, 2) + "\n",
|
|
18442
18471
|
"utf-8"
|
|
@@ -18462,7 +18491,7 @@ async function initPackage(options, scanDirectories) {
|
|
|
18462
18491
|
return smartInit(options);
|
|
18463
18492
|
}
|
|
18464
18493
|
function createInitCommand() {
|
|
18465
|
-
const command = new
|
|
18494
|
+
const command = new import_commander13.Command("init");
|
|
18466
18495
|
command.description("Initialize a new PRPM package with interactive prompts").argument("[directories...]", "Directories to scan (only used with --scan)").option("-y, --yes", "Skip prompts and use defaults").option("--private", "Create a private package").option("-f, --force", "Overwrite existing prpm.json").option(
|
|
18467
18496
|
"-s, --scan",
|
|
18468
18497
|
"Scan mode: discover packages in directories without prompts"
|
|
@@ -18488,14 +18517,14 @@ function createInitCommand() {
|
|
|
18488
18517
|
});
|
|
18489
18518
|
return command;
|
|
18490
18519
|
}
|
|
18491
|
-
var
|
|
18520
|
+
var import_commander13, import_promises10, import_path23, import_fs18, readline4, import_process, FORMAT_EXAMPLES, EXAMPLE_TEMPLATES;
|
|
18492
18521
|
var init_init = __esm({
|
|
18493
18522
|
"src/commands/init.ts"() {
|
|
18494
18523
|
"use strict";
|
|
18495
18524
|
init_cjs_shims();
|
|
18496
|
-
|
|
18497
|
-
|
|
18498
|
-
|
|
18525
|
+
import_commander13 = require("commander");
|
|
18526
|
+
import_promises10 = require("fs/promises");
|
|
18527
|
+
import_path23 = require("path");
|
|
18499
18528
|
import_fs18 = require("fs");
|
|
18500
18529
|
readline4 = __toESM(require("readline/promises"));
|
|
18501
18530
|
import_process = require("process");
|
|
@@ -18878,9 +18907,9 @@ Include examples if helpful.
|
|
|
18878
18907
|
|
|
18879
18908
|
// src/index.ts
|
|
18880
18909
|
init_cjs_shims();
|
|
18881
|
-
var
|
|
18910
|
+
var import_commander32 = require("commander");
|
|
18882
18911
|
var import_fs22 = require("fs");
|
|
18883
|
-
var
|
|
18912
|
+
var import_path27 = require("path");
|
|
18884
18913
|
|
|
18885
18914
|
// src/commands/list.ts
|
|
18886
18915
|
init_cjs_shims();
|
|
@@ -20335,24 +20364,325 @@ function createInfoCommand() {
|
|
|
20335
20364
|
return command;
|
|
20336
20365
|
}
|
|
20337
20366
|
|
|
20367
|
+
// src/commands/show.ts
|
|
20368
|
+
init_cjs_shims();
|
|
20369
|
+
var import_commander10 = require("commander");
|
|
20370
|
+
var import_registry_client4 = require("@pr-pm/registry-client");
|
|
20371
|
+
init_user_config();
|
|
20372
|
+
init_telemetry();
|
|
20373
|
+
init_errors();
|
|
20374
|
+
var import_stream = require("stream");
|
|
20375
|
+
var import_promises = require("stream/promises");
|
|
20376
|
+
var tar = __toESM(require("tar"));
|
|
20377
|
+
var import_zlib = __toESM(require("zlib"));
|
|
20378
|
+
var import_path14 = __toESM(require("path"));
|
|
20379
|
+
var import_os4 = __toESM(require("os"));
|
|
20380
|
+
var import_promises2 = __toESM(require("fs/promises"));
|
|
20381
|
+
function isPathSafe(targetDir, filePath) {
|
|
20382
|
+
const resolvedPath = import_path14.default.resolve(targetDir, filePath);
|
|
20383
|
+
const resolvedTarget = import_path14.default.resolve(targetDir);
|
|
20384
|
+
return resolvedPath.startsWith(resolvedTarget + import_path14.default.sep) || resolvedPath === resolvedTarget;
|
|
20385
|
+
}
|
|
20386
|
+
function hasUnsafePathPatterns(filePath) {
|
|
20387
|
+
if (filePath.includes("..")) return true;
|
|
20388
|
+
if (filePath.startsWith("/")) return true;
|
|
20389
|
+
if (/^[a-zA-Z]:/.test(filePath)) return true;
|
|
20390
|
+
if (filePath.includes("\0")) return true;
|
|
20391
|
+
return false;
|
|
20392
|
+
}
|
|
20393
|
+
function isBinaryContent(buffer) {
|
|
20394
|
+
if (buffer.includes(0)) return true;
|
|
20395
|
+
const sampleSize = Math.min(buffer.length, 512);
|
|
20396
|
+
let nonPrintable = 0;
|
|
20397
|
+
for (let i = 0; i < sampleSize; i++) {
|
|
20398
|
+
const byte = buffer[i];
|
|
20399
|
+
if (byte !== 9 && byte !== 10 && byte !== 13 && (byte < 32 || byte > 126)) {
|
|
20400
|
+
nonPrintable++;
|
|
20401
|
+
}
|
|
20402
|
+
}
|
|
20403
|
+
return nonPrintable / sampleSize > 0.3;
|
|
20404
|
+
}
|
|
20405
|
+
async function extractTarballContents(tarball) {
|
|
20406
|
+
let decompressed;
|
|
20407
|
+
try {
|
|
20408
|
+
decompressed = await new Promise((resolve3, reject) => {
|
|
20409
|
+
import_zlib.default.gunzip(tarball, (err, result) => {
|
|
20410
|
+
if (err) {
|
|
20411
|
+
reject(new Error(`Failed to decompress tarball: ${err.message}`));
|
|
20412
|
+
return;
|
|
20413
|
+
}
|
|
20414
|
+
resolve3(result);
|
|
20415
|
+
});
|
|
20416
|
+
});
|
|
20417
|
+
} catch (error) {
|
|
20418
|
+
throw new CLIError(`Package decompression failed: ${error.message}`);
|
|
20419
|
+
}
|
|
20420
|
+
const tmpDir = await import_promises2.default.mkdtemp(import_path14.default.join(import_os4.default.tmpdir(), "prpm-show-"));
|
|
20421
|
+
const cleanup = async () => {
|
|
20422
|
+
try {
|
|
20423
|
+
await import_promises2.default.rm(tmpDir, { recursive: true, force: true });
|
|
20424
|
+
} catch {
|
|
20425
|
+
}
|
|
20426
|
+
};
|
|
20427
|
+
try {
|
|
20428
|
+
const extract3 = tar.extract({
|
|
20429
|
+
cwd: tmpDir,
|
|
20430
|
+
strict: true,
|
|
20431
|
+
// Security: filter out dangerous entries before extraction
|
|
20432
|
+
filter: (entryPath, entry) => {
|
|
20433
|
+
const entryType = "type" in entry ? entry.type : null;
|
|
20434
|
+
if (entryType === "SymbolicLink" || entryType === "Link") {
|
|
20435
|
+
console.warn(` \u26A0\uFE0F Blocked symlink in package: ${entryPath}`);
|
|
20436
|
+
return false;
|
|
20437
|
+
}
|
|
20438
|
+
if ("isSymbolicLink" in entry && entry.isSymbolicLink()) {
|
|
20439
|
+
console.warn(` \u26A0\uFE0F Blocked symlink in package: ${entryPath}`);
|
|
20440
|
+
return false;
|
|
20441
|
+
}
|
|
20442
|
+
if (hasUnsafePathPatterns(entryPath)) {
|
|
20443
|
+
console.warn(` \u26A0\uFE0F Blocked unsafe path in package: ${entryPath}`);
|
|
20444
|
+
return false;
|
|
20445
|
+
}
|
|
20446
|
+
if (!isPathSafe(tmpDir, entryPath)) {
|
|
20447
|
+
console.warn(` \u26A0\uFE0F Blocked path traversal attempt: ${entryPath}`);
|
|
20448
|
+
return false;
|
|
20449
|
+
}
|
|
20450
|
+
return true;
|
|
20451
|
+
}
|
|
20452
|
+
});
|
|
20453
|
+
await (0, import_promises.pipeline)(import_stream.Readable.from(decompressed), extract3);
|
|
20454
|
+
const files = [];
|
|
20455
|
+
const dirs = [tmpDir];
|
|
20456
|
+
while (dirs.length > 0) {
|
|
20457
|
+
const currentDir = dirs.pop();
|
|
20458
|
+
if (!currentDir) continue;
|
|
20459
|
+
const entries = await import_promises2.default.readdir(currentDir, { withFileTypes: true });
|
|
20460
|
+
for (const entry of entries) {
|
|
20461
|
+
const fullPath = import_path14.default.join(currentDir, entry.name);
|
|
20462
|
+
if (entry.isDirectory()) {
|
|
20463
|
+
dirs.push(fullPath);
|
|
20464
|
+
continue;
|
|
20465
|
+
}
|
|
20466
|
+
if (!entry.isFile()) {
|
|
20467
|
+
continue;
|
|
20468
|
+
}
|
|
20469
|
+
const buffer = await import_promises2.default.readFile(fullPath);
|
|
20470
|
+
const stats = await import_promises2.default.stat(fullPath);
|
|
20471
|
+
const relativePath = import_path14.default.relative(tmpDir, fullPath).split(import_path14.default.sep).join("/");
|
|
20472
|
+
const binary2 = isBinaryContent(buffer);
|
|
20473
|
+
files.push({
|
|
20474
|
+
name: relativePath,
|
|
20475
|
+
content: binary2 ? `[Binary file - ${stats.size} bytes]` : buffer.toString("utf-8"),
|
|
20476
|
+
size: stats.size,
|
|
20477
|
+
isBinary: binary2
|
|
20478
|
+
});
|
|
20479
|
+
}
|
|
20480
|
+
}
|
|
20481
|
+
return files;
|
|
20482
|
+
} finally {
|
|
20483
|
+
await cleanup();
|
|
20484
|
+
}
|
|
20485
|
+
}
|
|
20486
|
+
function formatSize(bytes) {
|
|
20487
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
20488
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
20489
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
20490
|
+
}
|
|
20491
|
+
function getFileIcon(filename, isBinary2 = false) {
|
|
20492
|
+
if (isBinary2) return "\u{1F512}";
|
|
20493
|
+
const ext = import_path14.default.extname(filename).toLowerCase();
|
|
20494
|
+
const iconMap = {
|
|
20495
|
+
".md": "\u{1F4C4}",
|
|
20496
|
+
".mdc": "\u{1F4CB}",
|
|
20497
|
+
".json": "\u{1F4E6}",
|
|
20498
|
+
".toml": "\u2699\uFE0F",
|
|
20499
|
+
".yaml": "\u2699\uFE0F",
|
|
20500
|
+
".yml": "\u2699\uFE0F",
|
|
20501
|
+
".ts": "\u{1F4DC}",
|
|
20502
|
+
".js": "\u{1F4DC}",
|
|
20503
|
+
".sh": "\u{1F527}",
|
|
20504
|
+
".txt": "\u{1F4DD}"
|
|
20505
|
+
};
|
|
20506
|
+
return iconMap[ext] || "\u{1F4C4}";
|
|
20507
|
+
}
|
|
20508
|
+
async function handleShow(packageSpec, options) {
|
|
20509
|
+
const startTime = Date.now();
|
|
20510
|
+
let success = false;
|
|
20511
|
+
let error;
|
|
20512
|
+
try {
|
|
20513
|
+
let packageId;
|
|
20514
|
+
let specVersion;
|
|
20515
|
+
if (packageSpec.startsWith("@")) {
|
|
20516
|
+
const match = packageSpec.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
|
|
20517
|
+
if (!match) {
|
|
20518
|
+
throw new Error("Invalid package spec format. Use: @scope/package or @scope/package@version");
|
|
20519
|
+
}
|
|
20520
|
+
packageId = match[1];
|
|
20521
|
+
specVersion = match[2];
|
|
20522
|
+
} else {
|
|
20523
|
+
const parts = packageSpec.split("@");
|
|
20524
|
+
packageId = parts[0];
|
|
20525
|
+
specVersion = parts[1];
|
|
20526
|
+
}
|
|
20527
|
+
console.log(`\u{1F4E6} Fetching package contents for "${packageId}"...`);
|
|
20528
|
+
const config = await getConfig();
|
|
20529
|
+
const client = (0, import_registry_client4.getRegistryClient)(config);
|
|
20530
|
+
const pkg = await client.getPackage(packageId);
|
|
20531
|
+
let tarballUrl;
|
|
20532
|
+
let actualVersion;
|
|
20533
|
+
if (specVersion && specVersion !== "latest") {
|
|
20534
|
+
const versionInfo = await client.getPackageVersion(packageId, specVersion);
|
|
20535
|
+
tarballUrl = versionInfo.tarball_url;
|
|
20536
|
+
actualVersion = specVersion;
|
|
20537
|
+
} else {
|
|
20538
|
+
if (!pkg.latest_version) {
|
|
20539
|
+
throw new Error("No versions available for this package");
|
|
20540
|
+
}
|
|
20541
|
+
tarballUrl = pkg.latest_version.tarball_url;
|
|
20542
|
+
actualVersion = pkg.latest_version.version;
|
|
20543
|
+
}
|
|
20544
|
+
console.log(` Version: ${actualVersion}`);
|
|
20545
|
+
console.log(` \u2B07\uFE0F Downloading package...`);
|
|
20546
|
+
const tarball = await client.downloadPackage(tarballUrl);
|
|
20547
|
+
console.log(` \u{1F4C2} Extracting contents...
|
|
20548
|
+
`);
|
|
20549
|
+
const files = await extractTarballContents(tarball);
|
|
20550
|
+
if (files.length === 0) {
|
|
20551
|
+
console.log("\u26A0\uFE0F Package contains no files");
|
|
20552
|
+
success = true;
|
|
20553
|
+
return;
|
|
20554
|
+
}
|
|
20555
|
+
if (options.json) {
|
|
20556
|
+
const output2 = {
|
|
20557
|
+
package: packageId,
|
|
20558
|
+
version: actualVersion,
|
|
20559
|
+
format: pkg.format,
|
|
20560
|
+
subtype: pkg.subtype,
|
|
20561
|
+
description: pkg.description,
|
|
20562
|
+
files: files.map((f) => ({
|
|
20563
|
+
path: f.name,
|
|
20564
|
+
size: f.size,
|
|
20565
|
+
isBinary: f.isBinary,
|
|
20566
|
+
content: options.full ? f.content : void 0
|
|
20567
|
+
}))
|
|
20568
|
+
};
|
|
20569
|
+
console.log(JSON.stringify(output2, null, 2));
|
|
20570
|
+
success = true;
|
|
20571
|
+
return;
|
|
20572
|
+
}
|
|
20573
|
+
console.log("=".repeat(60));
|
|
20574
|
+
console.log(` ${pkg.name} v${actualVersion}`);
|
|
20575
|
+
console.log("=".repeat(60));
|
|
20576
|
+
if (pkg.description) {
|
|
20577
|
+
console.log(`
|
|
20578
|
+
\u{1F4DD} ${pkg.description}`);
|
|
20579
|
+
}
|
|
20580
|
+
console.log(`
|
|
20581
|
+
\u{1F4C2} Type: ${pkg.format} ${pkg.subtype}`);
|
|
20582
|
+
console.log(`\u{1F4E6} Files: ${files.length}`);
|
|
20583
|
+
console.log(`\u{1F4CA} Total size: ${formatSize(files.reduce((sum, f) => sum + f.size, 0))}`);
|
|
20584
|
+
if (options.file) {
|
|
20585
|
+
const targetFile = files.find(
|
|
20586
|
+
(f) => f.name === options.file || f.name.endsWith("/" + options.file) || import_path14.default.basename(f.name) === options.file
|
|
20587
|
+
);
|
|
20588
|
+
if (!targetFile) {
|
|
20589
|
+
console.log(`
|
|
20590
|
+
\u274C File not found: ${options.file}`);
|
|
20591
|
+
console.log("\n\u{1F4CB} Available files:");
|
|
20592
|
+
for (const file of files) {
|
|
20593
|
+
console.log(` ${getFileIcon(file.name, file.isBinary)} ${file.name}`);
|
|
20594
|
+
}
|
|
20595
|
+
throw new CLIError(`File "${options.file}" not found in package`, 1);
|
|
20596
|
+
}
|
|
20597
|
+
console.log("\n" + "\u2500".repeat(60));
|
|
20598
|
+
console.log(`\u{1F4C4} ${targetFile.name} (${formatSize(targetFile.size)})`);
|
|
20599
|
+
console.log("\u2500".repeat(60));
|
|
20600
|
+
console.log(targetFile.content);
|
|
20601
|
+
success = true;
|
|
20602
|
+
return;
|
|
20603
|
+
}
|
|
20604
|
+
console.log("\n" + "\u2500".repeat(60));
|
|
20605
|
+
console.log(" \u{1F4CB} Package Contents");
|
|
20606
|
+
console.log("\u2500".repeat(60));
|
|
20607
|
+
for (const file of files) {
|
|
20608
|
+
const binaryLabel = file.isBinary ? " [binary]" : "";
|
|
20609
|
+
console.log(` ${getFileIcon(file.name, file.isBinary)} ${file.name} (${formatSize(file.size)})${binaryLabel}`);
|
|
20610
|
+
}
|
|
20611
|
+
if (options.full) {
|
|
20612
|
+
console.log("\n" + "\u2550".repeat(60));
|
|
20613
|
+
console.log(" \u{1F4D6} Full File Contents");
|
|
20614
|
+
console.log("\u2550".repeat(60));
|
|
20615
|
+
for (const file of files) {
|
|
20616
|
+
console.log("\n" + "\u2500".repeat(60));
|
|
20617
|
+
console.log(`\u{1F4C4} ${file.name}`);
|
|
20618
|
+
console.log("\u2500".repeat(60));
|
|
20619
|
+
console.log(file.content);
|
|
20620
|
+
}
|
|
20621
|
+
} else {
|
|
20622
|
+
console.log("\n\u{1F4A1} Tip: Use --full to see complete file contents");
|
|
20623
|
+
console.log(` prpm show ${packageSpec} --full`);
|
|
20624
|
+
console.log(` prpm show ${packageSpec} --file <filename> # View specific file`);
|
|
20625
|
+
}
|
|
20626
|
+
console.log("\n" + "=".repeat(60));
|
|
20627
|
+
console.log(`
|
|
20628
|
+
\u{1F4BB} To install: prpm install ${packageId}`);
|
|
20629
|
+
success = true;
|
|
20630
|
+
} catch (err) {
|
|
20631
|
+
error = err instanceof Error ? err.message : String(err);
|
|
20632
|
+
if (err instanceof CLIError) {
|
|
20633
|
+
throw err;
|
|
20634
|
+
}
|
|
20635
|
+
throw new CLIError(
|
|
20636
|
+
`
|
|
20637
|
+
\u274C Failed to show package contents: ${error}
|
|
20638
|
+
|
|
20639
|
+
\u{1F4A1} Tips:
|
|
20640
|
+
- Check the package ID spelling
|
|
20641
|
+
- Search for packages: prpm search <query>
|
|
20642
|
+
- Get package info: prpm info <package>`,
|
|
20643
|
+
1
|
|
20644
|
+
);
|
|
20645
|
+
} finally {
|
|
20646
|
+
await telemetry.track({
|
|
20647
|
+
command: "show",
|
|
20648
|
+
success,
|
|
20649
|
+
error,
|
|
20650
|
+
duration: Date.now() - startTime,
|
|
20651
|
+
data: {
|
|
20652
|
+
packageName: packageSpec,
|
|
20653
|
+
full: options.full,
|
|
20654
|
+
json: options.json
|
|
20655
|
+
}
|
|
20656
|
+
});
|
|
20657
|
+
await telemetry.shutdown();
|
|
20658
|
+
}
|
|
20659
|
+
}
|
|
20660
|
+
function createShowCommand() {
|
|
20661
|
+
const command = new import_commander10.Command("show");
|
|
20662
|
+
command.description("Display package contents before installing").argument("<package>", "Package ID to show (e.g., @user/package or @user/package@1.0.0)").option("--full", "Show complete file contents").option("--file <name>", "Show contents of a specific file").option("--json", "Output in JSON format (for programmatic use)").action(async (packageSpec, options) => {
|
|
20663
|
+
await handleShow(packageSpec, options);
|
|
20664
|
+
});
|
|
20665
|
+
return command;
|
|
20666
|
+
}
|
|
20667
|
+
|
|
20338
20668
|
// src/index.ts
|
|
20339
20669
|
init_install();
|
|
20340
20670
|
|
|
20341
20671
|
// src/commands/publish.ts
|
|
20342
20672
|
init_cjs_shims();
|
|
20343
|
-
var
|
|
20344
|
-
var
|
|
20345
|
-
var
|
|
20673
|
+
var import_commander14 = require("commander");
|
|
20674
|
+
var import_promises11 = require("fs/promises");
|
|
20675
|
+
var import_path24 = require("path");
|
|
20346
20676
|
var import_fs19 = require("fs");
|
|
20347
|
-
var
|
|
20677
|
+
var import_registry_client7 = require("@pr-pm/registry-client");
|
|
20348
20678
|
init_user_config();
|
|
20349
20679
|
init_telemetry();
|
|
20350
20680
|
init_errors();
|
|
20351
20681
|
|
|
20352
20682
|
// src/utils/license-extractor.ts
|
|
20353
20683
|
init_cjs_shims();
|
|
20354
|
-
var
|
|
20355
|
-
var
|
|
20684
|
+
var import_promises5 = require("fs/promises");
|
|
20685
|
+
var import_path16 = require("path");
|
|
20356
20686
|
var import_fs14 = require("fs");
|
|
20357
20687
|
var LICENSE_FILE_PATTERNS = [
|
|
20358
20688
|
"LICENSE",
|
|
@@ -20402,10 +20732,10 @@ function generateLicenseUrl(repositoryUrl, fileName) {
|
|
|
20402
20732
|
async function extractLicenseInfo(repositoryUrl) {
|
|
20403
20733
|
const cwd = process.cwd();
|
|
20404
20734
|
for (const fileName of LICENSE_FILE_PATTERNS) {
|
|
20405
|
-
const filePath = (0,
|
|
20735
|
+
const filePath = (0, import_path16.join)(cwd, fileName);
|
|
20406
20736
|
try {
|
|
20407
|
-
await (0,
|
|
20408
|
-
const text = await (0,
|
|
20737
|
+
await (0, import_promises5.access)(filePath, import_fs14.constants.R_OK);
|
|
20738
|
+
const text = await (0, import_promises5.readFile)(filePath, "utf-8");
|
|
20409
20739
|
const type2 = detectLicenseType(text);
|
|
20410
20740
|
const url = generateLicenseUrl(repositoryUrl, fileName);
|
|
20411
20741
|
return {
|
|
@@ -20437,8 +20767,8 @@ function validateLicenseInfo(licenseInfo, packageName) {
|
|
|
20437
20767
|
|
|
20438
20768
|
// src/utils/snippet-extractor.ts
|
|
20439
20769
|
init_cjs_shims();
|
|
20440
|
-
var
|
|
20441
|
-
var
|
|
20770
|
+
var import_promises6 = require("fs/promises");
|
|
20771
|
+
var import_path17 = require("path");
|
|
20442
20772
|
var MAX_SNIPPET_LENGTH = 2e3;
|
|
20443
20773
|
async function extractSnippet(manifest) {
|
|
20444
20774
|
const cwd = process.cwd();
|
|
@@ -20454,13 +20784,13 @@ async function extractSnippet(manifest) {
|
|
|
20454
20784
|
const firstFile = manifest.files[0];
|
|
20455
20785
|
fileName = typeof firstFile === "string" ? firstFile : firstFile.path;
|
|
20456
20786
|
}
|
|
20457
|
-
const fullPath = (0,
|
|
20458
|
-
const stats = await (0,
|
|
20787
|
+
const fullPath = (0, import_path17.join)(cwd, fileName);
|
|
20788
|
+
const stats = await (0, import_promises6.stat)(fullPath);
|
|
20459
20789
|
if (stats.isDirectory()) {
|
|
20460
20790
|
console.warn(`\u26A0\uFE0F Skipping snippet extraction: "${fullPath}" is a directory`);
|
|
20461
20791
|
return null;
|
|
20462
20792
|
}
|
|
20463
|
-
const content = await (0,
|
|
20793
|
+
const content = await (0, import_promises6.readFile)(fullPath, "utf-8");
|
|
20464
20794
|
if (content.length <= MAX_SNIPPET_LENGTH) {
|
|
20465
20795
|
return content.trim();
|
|
20466
20796
|
}
|
|
@@ -20543,7 +20873,7 @@ async function executePrepublishOnly(scripts, options = {}) {
|
|
|
20543
20873
|
|
|
20544
20874
|
// src/utils/format-file-validator.ts
|
|
20545
20875
|
init_cjs_shims();
|
|
20546
|
-
var
|
|
20876
|
+
var import_promises7 = require("fs/promises");
|
|
20547
20877
|
init_dist();
|
|
20548
20878
|
function normalizeFilePaths(files) {
|
|
20549
20879
|
return files.map((file) => {
|
|
@@ -20569,7 +20899,7 @@ function getFormatType(format) {
|
|
|
20569
20899
|
}
|
|
20570
20900
|
async function validateMarkdownFile(filePath, formatType, subtype) {
|
|
20571
20901
|
try {
|
|
20572
|
-
const content = await (0,
|
|
20902
|
+
const content = await (0, import_promises7.readFile)(filePath, "utf-8");
|
|
20573
20903
|
const result = validateMarkdown(formatType, content, subtype);
|
|
20574
20904
|
return {
|
|
20575
20905
|
valid: result.valid,
|
|
@@ -20588,7 +20918,7 @@ Stack: ${error.stack}` : String(error);
|
|
|
20588
20918
|
}
|
|
20589
20919
|
async function validateStructuredFile(filePath, formatType, subtype) {
|
|
20590
20920
|
try {
|
|
20591
|
-
const content = await (0,
|
|
20921
|
+
const content = await (0, import_promises7.readFile)(filePath, "utf-8");
|
|
20592
20922
|
let data;
|
|
20593
20923
|
try {
|
|
20594
20924
|
data = JSON.parse(content);
|
|
@@ -20695,13 +21025,13 @@ async function validatePackageFiles(manifest) {
|
|
|
20695
21025
|
}
|
|
20696
21026
|
}
|
|
20697
21027
|
if (manifest.format === "claude" && manifest.subtype === "skill") {
|
|
20698
|
-
const hasSkillMd = filePaths.some((
|
|
20699
|
-
const mdFiles = filePaths.filter((
|
|
21028
|
+
const hasSkillMd = filePaths.some((path12) => path12.endsWith("/SKILL.md") || path12 === "SKILL.md");
|
|
21029
|
+
const mdFiles = filePaths.filter((path12) => {
|
|
20700
21030
|
var _a;
|
|
20701
|
-
if (!
|
|
20702
|
-
const filename = ((_a =
|
|
21031
|
+
if (!path12.endsWith(".md")) return false;
|
|
21032
|
+
const filename = ((_a = path12.split(/[\\/]/).pop()) == null ? void 0 : _a.toLowerCase()) || "";
|
|
20703
21033
|
if (filename === "readme.md") return false;
|
|
20704
|
-
if (
|
|
21034
|
+
if (path12.includes("examples/") || path12.includes("example/") || path12.includes("tests/") || path12.includes("__tests__/") || path12.includes("docs/") || path12.includes("doc/")) return false;
|
|
20705
21035
|
return true;
|
|
20706
21036
|
});
|
|
20707
21037
|
if (!hasSkillMd && mdFiles.length === 0) {
|
|
@@ -20713,7 +21043,7 @@ async function validatePackageFiles(manifest) {
|
|
|
20713
21043
|
}
|
|
20714
21044
|
}
|
|
20715
21045
|
if (manifest.format === "windsurf") {
|
|
20716
|
-
const hasWindsurfRules = filePaths.some((
|
|
21046
|
+
const hasWindsurfRules = filePaths.some((path12) => path12.includes(".windsurf/rules"));
|
|
20717
21047
|
if (!hasWindsurfRules) {
|
|
20718
21048
|
warnings.push("Windsurf packages typically use .windsurf/rules filename");
|
|
20719
21049
|
}
|
|
@@ -20723,8 +21053,8 @@ async function validatePackageFiles(manifest) {
|
|
|
20723
21053
|
|
|
20724
21054
|
// src/utils/manifest-loader.ts
|
|
20725
21055
|
init_cjs_shims();
|
|
20726
|
-
var
|
|
20727
|
-
var
|
|
21056
|
+
var import_promises8 = require("fs/promises");
|
|
21057
|
+
var import_path19 = require("path");
|
|
20728
21058
|
|
|
20729
21059
|
// src/core/marketplace-converter.ts
|
|
20730
21060
|
init_cjs_shims();
|
|
@@ -20891,13 +21221,13 @@ init_cjs_shims();
|
|
|
20891
21221
|
var import_ajv2 = __toESM(require("ajv"));
|
|
20892
21222
|
var import_ajv_formats2 = __toESM(require("ajv-formats"));
|
|
20893
21223
|
var import_fs15 = require("fs");
|
|
20894
|
-
var
|
|
21224
|
+
var import_path18 = require("path");
|
|
20895
21225
|
var schema2;
|
|
20896
21226
|
var schemaCandidates = [
|
|
20897
21227
|
// Source file layout (src/core → ../../schemas)
|
|
20898
|
-
(0,
|
|
21228
|
+
(0, import_path18.join)(__dirname, "../../schemas/prpm-manifest.schema.json"),
|
|
20899
21229
|
// Bundled layout (dist/index.js → ../schemas)
|
|
20900
|
-
(0,
|
|
21230
|
+
(0, import_path18.join)(__dirname, "../schemas/prpm-manifest.schema.json")
|
|
20901
21231
|
];
|
|
20902
21232
|
for (const candidate of schemaCandidates) {
|
|
20903
21233
|
try {
|
|
@@ -20924,27 +21254,27 @@ function validateManifestSchema(manifest) {
|
|
|
20924
21254
|
const valid = validate(manifest);
|
|
20925
21255
|
if (!valid && validate.errors) {
|
|
20926
21256
|
const errors = validate.errors.map((err) => {
|
|
20927
|
-
const
|
|
21257
|
+
const path12 = err.instancePath || "manifest";
|
|
20928
21258
|
const message = err.message || "validation failed";
|
|
20929
21259
|
if (err.keyword === "required") {
|
|
20930
21260
|
const missingProp = err.params.missingProperty;
|
|
20931
21261
|
return `Missing required field: ${missingProp}`;
|
|
20932
21262
|
}
|
|
20933
21263
|
if (err.keyword === "pattern") {
|
|
20934
|
-
return `${
|
|
21264
|
+
return `${path12}: ${message}. Value does not match required pattern.`;
|
|
20935
21265
|
}
|
|
20936
21266
|
if (err.keyword === "enum") {
|
|
20937
21267
|
const allowedValues = err.params.allowedValues;
|
|
20938
|
-
return `${
|
|
21268
|
+
return `${path12}: ${message}. Allowed values: ${allowedValues.join(", ")}`;
|
|
20939
21269
|
}
|
|
20940
21270
|
if (err.keyword === "minLength" || err.keyword === "maxLength") {
|
|
20941
21271
|
const limit = err.params.limit;
|
|
20942
|
-
return `${
|
|
21272
|
+
return `${path12}: ${message} (${err.keyword}: ${limit})`;
|
|
20943
21273
|
}
|
|
20944
21274
|
if (err.keyword === "oneOf") {
|
|
20945
|
-
return `${
|
|
21275
|
+
return `${path12}: must match exactly one schema (check if files array uses either all strings or all objects, not mixed)`;
|
|
20946
21276
|
}
|
|
20947
|
-
return `${
|
|
21277
|
+
return `${path12}: ${message}`;
|
|
20948
21278
|
});
|
|
20949
21279
|
return { valid: false, errors };
|
|
20950
21280
|
}
|
|
@@ -20959,10 +21289,10 @@ function toOrganizationSlug(value) {
|
|
|
20959
21289
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-+/g, "-");
|
|
20960
21290
|
}
|
|
20961
21291
|
async function findAndLoadManifests() {
|
|
20962
|
-
const prpmJsonPath = (0,
|
|
21292
|
+
const prpmJsonPath = (0, import_path19.join)(process.cwd(), "prpm.json");
|
|
20963
21293
|
let prpmJsonExists = false;
|
|
20964
21294
|
try {
|
|
20965
|
-
const content = await (0,
|
|
21295
|
+
const content = await (0, import_promises8.readFile)(prpmJsonPath, "utf-8");
|
|
20966
21296
|
prpmJsonExists = true;
|
|
20967
21297
|
const manifest = JSON.parse(content);
|
|
20968
21298
|
const collections = [];
|
|
@@ -21020,13 +21350,13 @@ async function findAndLoadManifests() {
|
|
|
21020
21350
|
throw error;
|
|
21021
21351
|
}
|
|
21022
21352
|
}
|
|
21023
|
-
const marketplaceJsonPath = (0,
|
|
21353
|
+
const marketplaceJsonPath = (0, import_path19.join)(
|
|
21024
21354
|
process.cwd(),
|
|
21025
21355
|
".claude",
|
|
21026
21356
|
"marketplace.json"
|
|
21027
21357
|
);
|
|
21028
21358
|
try {
|
|
21029
|
-
const content = await (0,
|
|
21359
|
+
const content = await (0, import_promises8.readFile)(marketplaceJsonPath, "utf-8");
|
|
21030
21360
|
const marketplaceData = JSON.parse(content);
|
|
21031
21361
|
if (!validateMarketplaceJson(marketplaceData)) {
|
|
21032
21362
|
throw new Error("Invalid marketplace.json format");
|
|
@@ -21040,13 +21370,13 @@ async function findAndLoadManifests() {
|
|
|
21040
21370
|
return { manifests, collections: [], source: ".claude/marketplace.json" };
|
|
21041
21371
|
} catch (error) {
|
|
21042
21372
|
}
|
|
21043
|
-
const marketplaceJsonPluginPath = (0,
|
|
21373
|
+
const marketplaceJsonPluginPath = (0, import_path19.join)(
|
|
21044
21374
|
process.cwd(),
|
|
21045
21375
|
".claude-plugin",
|
|
21046
21376
|
"marketplace.json"
|
|
21047
21377
|
);
|
|
21048
21378
|
try {
|
|
21049
|
-
const content = await (0,
|
|
21379
|
+
const content = await (0, import_promises8.readFile)(marketplaceJsonPluginPath, "utf-8");
|
|
21050
21380
|
const marketplaceData = JSON.parse(content);
|
|
21051
21381
|
if (!validateMarketplaceJson(marketplaceData)) {
|
|
21052
21382
|
throw new Error("Invalid marketplace.json format");
|
|
@@ -21097,7 +21427,7 @@ function validateManifest(manifest, contextLabel) {
|
|
|
21097
21427
|
if (manifest.format === "claude" && manifest.subtype === "skill") {
|
|
21098
21428
|
const filePaths = normalizeFilePaths2(manifest.files);
|
|
21099
21429
|
const hasSkillMd = filePaths.some(
|
|
21100
|
-
(
|
|
21430
|
+
(path12) => path12.endsWith("/SKILL.md") || path12 === "SKILL.md"
|
|
21101
21431
|
);
|
|
21102
21432
|
const mdFiles = filePaths.filter((filePath) => {
|
|
21103
21433
|
var _a2;
|
|
@@ -21206,10 +21536,10 @@ function getSafePackageName(manifest, userInfo, fallbackName) {
|
|
|
21206
21536
|
|
|
21207
21537
|
// src/utils/tarball-creator.ts
|
|
21208
21538
|
init_cjs_shims();
|
|
21209
|
-
var
|
|
21210
|
-
var
|
|
21211
|
-
var
|
|
21212
|
-
var
|
|
21539
|
+
var import_promises9 = require("fs/promises");
|
|
21540
|
+
var import_path20 = require("path");
|
|
21541
|
+
var tar3 = __toESM(require("tar"));
|
|
21542
|
+
var import_os6 = require("os");
|
|
21213
21543
|
var import_crypto2 = require("crypto");
|
|
21214
21544
|
var RELOCATION_CONFIG = {
|
|
21215
21545
|
claude: {
|
|
@@ -21297,12 +21627,12 @@ var RELOCATION_CONFIG = {
|
|
|
21297
21627
|
}
|
|
21298
21628
|
};
|
|
21299
21629
|
async function createTarball(manifest) {
|
|
21300
|
-
const tmpDir = (0,
|
|
21301
|
-
const tarballPath = (0,
|
|
21302
|
-
const stagingDir = (0,
|
|
21630
|
+
const tmpDir = (0, import_path20.join)((0, import_os6.tmpdir)(), `prpm-${(0, import_crypto2.randomBytes)(8).toString("hex")}`);
|
|
21631
|
+
const tarballPath = (0, import_path20.join)(tmpDir, "package.tar.gz");
|
|
21632
|
+
const stagingDir = (0, import_path20.join)(tmpDir, "staging");
|
|
21303
21633
|
try {
|
|
21304
|
-
await (0,
|
|
21305
|
-
await (0,
|
|
21634
|
+
await (0, import_promises9.mkdir)(tmpDir, { recursive: true });
|
|
21635
|
+
await (0, import_promises9.mkdir)(stagingDir, { recursive: true });
|
|
21306
21636
|
const filePaths = normalizeFilePaths2(manifest.files);
|
|
21307
21637
|
const standardFiles = ["prpm.json", "README.md", "LICENSE"];
|
|
21308
21638
|
for (const file of standardFiles) {
|
|
@@ -21314,18 +21644,18 @@ async function createTarball(manifest) {
|
|
|
21314
21644
|
const fileRenames = /* @__PURE__ */ new Map();
|
|
21315
21645
|
if (manifest.format === "claude" && manifest.subtype === "skill") {
|
|
21316
21646
|
const hasSkillMd = filePaths.some(
|
|
21317
|
-
(
|
|
21647
|
+
(path12) => path12.endsWith("/SKILL.md") || path12 === "SKILL.md"
|
|
21318
21648
|
);
|
|
21319
21649
|
if (!hasSkillMd) {
|
|
21320
21650
|
const mdFiles = filePaths.filter(
|
|
21321
|
-
(
|
|
21651
|
+
(path12) => path12.endsWith(".md") && !path12.toLowerCase().includes("readme")
|
|
21322
21652
|
);
|
|
21323
21653
|
if (mdFiles.length === 1) {
|
|
21324
21654
|
const file = mdFiles[0];
|
|
21325
21655
|
try {
|
|
21326
|
-
await (0,
|
|
21327
|
-
const dir = (0,
|
|
21328
|
-
const newPath = dir === "." ? "SKILL.md" : (0,
|
|
21656
|
+
await (0, import_promises9.stat)(file);
|
|
21657
|
+
const dir = (0, import_path20.dirname)(file);
|
|
21658
|
+
const newPath = dir === "." ? "SKILL.md" : (0, import_path20.join)(dir, "SKILL.md");
|
|
21329
21659
|
fileRenames.set(file, newPath);
|
|
21330
21660
|
console.log(` \u{1F4DD} Renaming ${file} \u2192 ${newPath}`);
|
|
21331
21661
|
} catch {
|
|
@@ -21337,20 +21667,20 @@ async function createTarball(manifest) {
|
|
|
21337
21667
|
const subtypeConfig = formatConfig == null ? void 0 : formatConfig[manifest.subtype || "rule"];
|
|
21338
21668
|
if (subtypeConfig) {
|
|
21339
21669
|
const contentFiles = filePaths.filter(
|
|
21340
|
-
(
|
|
21670
|
+
(path12) => !path12.toLowerCase().includes("readme") && !path12.toLowerCase().includes("license") && path12 !== "prpm.json" && (path12.endsWith(".md") || path12.endsWith(".mdc") || path12.endsWith(".json"))
|
|
21341
21671
|
);
|
|
21342
21672
|
for (const file of contentFiles) {
|
|
21343
21673
|
if (file.includes(subtypeConfig.checkPath)) {
|
|
21344
21674
|
continue;
|
|
21345
21675
|
}
|
|
21346
21676
|
try {
|
|
21347
|
-
await (0,
|
|
21348
|
-
let fileName = (0,
|
|
21677
|
+
await (0, import_promises9.stat)(file);
|
|
21678
|
+
let fileName = (0, import_path20.basename)(file);
|
|
21349
21679
|
if (subtypeConfig.extension) {
|
|
21350
21680
|
const nameWithoutExt = fileName.replace(/\.[^.]+$/, "");
|
|
21351
21681
|
fileName = nameWithoutExt + subtypeConfig.extension;
|
|
21352
21682
|
}
|
|
21353
|
-
const newPath = (0,
|
|
21683
|
+
const newPath = (0, import_path20.join)(subtypeConfig.directory, fileName);
|
|
21354
21684
|
fileRenames.set(file, newPath);
|
|
21355
21685
|
console.log(` \u{1F4DD} Relocating ${file} \u2192 ${newPath}`);
|
|
21356
21686
|
} catch {
|
|
@@ -21359,11 +21689,11 @@ async function createTarball(manifest) {
|
|
|
21359
21689
|
}
|
|
21360
21690
|
for (const file of filePaths) {
|
|
21361
21691
|
try {
|
|
21362
|
-
await (0,
|
|
21692
|
+
await (0, import_promises9.stat)(file);
|
|
21363
21693
|
const targetPath = fileRenames.get(file) || file;
|
|
21364
|
-
const stagingPath = (0,
|
|
21365
|
-
await (0,
|
|
21366
|
-
await (0,
|
|
21694
|
+
const stagingPath = (0, import_path20.join)(stagingDir, targetPath);
|
|
21695
|
+
await (0, import_promises9.mkdir)((0, import_path20.dirname)(stagingPath), { recursive: true });
|
|
21696
|
+
await (0, import_promises9.copyFile)(file, stagingPath);
|
|
21367
21697
|
existingFiles.push(targetPath);
|
|
21368
21698
|
} catch {
|
|
21369
21699
|
}
|
|
@@ -21371,7 +21701,7 @@ async function createTarball(manifest) {
|
|
|
21371
21701
|
if (existingFiles.length === 0) {
|
|
21372
21702
|
throw new Error("No package files found to include in tarball");
|
|
21373
21703
|
}
|
|
21374
|
-
await
|
|
21704
|
+
await tar3.create(
|
|
21375
21705
|
{
|
|
21376
21706
|
gzip: true,
|
|
21377
21707
|
file: tarballPath,
|
|
@@ -21379,7 +21709,7 @@ async function createTarball(manifest) {
|
|
|
21379
21709
|
},
|
|
21380
21710
|
existingFiles
|
|
21381
21711
|
);
|
|
21382
|
-
const tarballBuffer = await (0,
|
|
21712
|
+
const tarballBuffer = await (0, import_promises9.readFile)(tarballPath);
|
|
21383
21713
|
const sizeMB = tarballBuffer.length / (1024 * 1024);
|
|
21384
21714
|
if (sizeMB > 10) {
|
|
21385
21715
|
throw new Error(
|
|
@@ -21391,7 +21721,7 @@ async function createTarball(manifest) {
|
|
|
21391
21721
|
throw error;
|
|
21392
21722
|
} finally {
|
|
21393
21723
|
try {
|
|
21394
|
-
await (0,
|
|
21724
|
+
await (0, import_promises9.rm)(tmpDir, { recursive: true, force: true });
|
|
21395
21725
|
} catch {
|
|
21396
21726
|
}
|
|
21397
21727
|
}
|
|
@@ -21484,13 +21814,13 @@ async function handlePublish(options) {
|
|
|
21484
21814
|
console.log("\u{1F916} CI Mode: Publishing without authentication\n");
|
|
21485
21815
|
}
|
|
21486
21816
|
console.log("\u{1F4E6} Publishing package...\n");
|
|
21487
|
-
const prpmJsonPath = (0,
|
|
21488
|
-
const marketplaceJsonPath = (0,
|
|
21817
|
+
const prpmJsonPath = (0, import_path24.join)(process.cwd(), "prpm.json");
|
|
21818
|
+
const marketplaceJsonPath = (0, import_path24.join)(
|
|
21489
21819
|
process.cwd(),
|
|
21490
21820
|
".claude",
|
|
21491
21821
|
"marketplace.json"
|
|
21492
21822
|
);
|
|
21493
|
-
const marketplaceJsonPluginPath = (0,
|
|
21823
|
+
const marketplaceJsonPluginPath = (0, import_path24.join)(
|
|
21494
21824
|
process.cwd(),
|
|
21495
21825
|
".claude-plugin",
|
|
21496
21826
|
"marketplace.json"
|
|
@@ -21511,8 +21841,8 @@ async function handlePublish(options) {
|
|
|
21511
21841
|
const { manifests, collections, source } = await findAndLoadManifests();
|
|
21512
21842
|
if (source === "prpm.json (multi-package)" || source === "prpm.json") {
|
|
21513
21843
|
try {
|
|
21514
|
-
const prpmJsonPath2 = (0,
|
|
21515
|
-
const prpmContent = await (0,
|
|
21844
|
+
const prpmJsonPath2 = (0, import_path24.join)(process.cwd(), "prpm.json");
|
|
21845
|
+
const prpmContent = await (0, import_promises11.readFile)(prpmJsonPath2, "utf-8");
|
|
21516
21846
|
const prpmManifest = JSON.parse(prpmContent);
|
|
21517
21847
|
if (prpmManifest.scripts) {
|
|
21518
21848
|
await executePrepublishOnly(prpmManifest.scripts);
|
|
@@ -21556,7 +21886,7 @@ async function handlePublish(options) {
|
|
|
21556
21886
|
`);
|
|
21557
21887
|
}
|
|
21558
21888
|
console.log("\u{1F50D} Checking authentication...");
|
|
21559
|
-
const client = (0,
|
|
21889
|
+
const client = (0, import_registry_client7.getRegistryClient)(config);
|
|
21560
21890
|
let userInfo;
|
|
21561
21891
|
try {
|
|
21562
21892
|
userInfo = await client.whoami();
|
|
@@ -22101,7 +22431,7 @@ ${"=".repeat(60)}`);
|
|
|
22101
22431
|
}
|
|
22102
22432
|
}
|
|
22103
22433
|
function createPublishCommand() {
|
|
22104
|
-
return new
|
|
22434
|
+
return new import_commander14.Command("publish").description("Publish packages and collections to the registry").option(
|
|
22105
22435
|
"--access <type>",
|
|
22106
22436
|
"Package access (public or private) - overrides manifest setting"
|
|
22107
22437
|
).option("--tag <tag>", "NPM-style tag (e.g., latest, beta)", "latest").option("--dry-run", "Validate package without publishing").option(
|
|
@@ -22117,8 +22447,8 @@ function createPublishCommand() {
|
|
|
22117
22447
|
|
|
22118
22448
|
// src/commands/deprecate.ts
|
|
22119
22449
|
init_cjs_shims();
|
|
22120
|
-
var
|
|
22121
|
-
var
|
|
22450
|
+
var import_commander15 = require("commander");
|
|
22451
|
+
var import_registry_client8 = require("@pr-pm/registry-client");
|
|
22122
22452
|
init_user_config();
|
|
22123
22453
|
init_telemetry();
|
|
22124
22454
|
init_errors();
|
|
@@ -22133,7 +22463,7 @@ async function handleDeprecate(packageName, options) {
|
|
|
22133
22463
|
if (!config.token) {
|
|
22134
22464
|
throw new CLIError("\u274C Authentication required. Run `prpm login` first.", 1);
|
|
22135
22465
|
}
|
|
22136
|
-
const client = (0,
|
|
22466
|
+
const client = (0, import_registry_client8.getRegistryClient)(config);
|
|
22137
22467
|
const action = options.undo ? "Undeprecating" : "Deprecating";
|
|
22138
22468
|
console.log(`\u26A0\uFE0F ${action} package: ${packageName}...
|
|
22139
22469
|
`);
|
|
@@ -22181,7 +22511,7 @@ async function handleDeprecate(packageName, options) {
|
|
|
22181
22511
|
}
|
|
22182
22512
|
}
|
|
22183
22513
|
function createDeprecateCommand() {
|
|
22184
|
-
const command = new
|
|
22514
|
+
const command = new import_commander15.Command("deprecate");
|
|
22185
22515
|
command.description("Deprecate a package (owner only)").argument("<package>", "Package name to deprecate").option("--reason <reason>", "Reason for deprecation").option("--undo", "Remove deprecation status").action(async (packageName, options) => {
|
|
22186
22516
|
await handleDeprecate(packageName, options);
|
|
22187
22517
|
});
|
|
@@ -22190,8 +22520,8 @@ function createDeprecateCommand() {
|
|
|
22190
22520
|
|
|
22191
22521
|
// src/commands/visibility.ts
|
|
22192
22522
|
init_cjs_shims();
|
|
22193
|
-
var
|
|
22194
|
-
var
|
|
22523
|
+
var import_commander16 = require("commander");
|
|
22524
|
+
var import_registry_client9 = require("@pr-pm/registry-client");
|
|
22195
22525
|
init_user_config();
|
|
22196
22526
|
init_telemetry();
|
|
22197
22527
|
init_errors();
|
|
@@ -22212,7 +22542,7 @@ async function handleVisibility(packageName, options) {
|
|
|
22212
22542
|
throw new CLIError("\u274C Must specify either --public or --private", 1);
|
|
22213
22543
|
}
|
|
22214
22544
|
visibility = options.public ? "public" : "private";
|
|
22215
|
-
const client = (0,
|
|
22545
|
+
const client = (0, import_registry_client9.getRegistryClient)(config);
|
|
22216
22546
|
console.log(`\u{1F504} Setting package visibility: ${packageName} -> ${visibility}...
|
|
22217
22547
|
`);
|
|
22218
22548
|
const result = await client.setPackageVisibility(packageName, visibility);
|
|
@@ -22255,7 +22585,7 @@ async function handleVisibility(packageName, options) {
|
|
|
22255
22585
|
}
|
|
22256
22586
|
}
|
|
22257
22587
|
function createVisibilityCommand() {
|
|
22258
|
-
const command = new
|
|
22588
|
+
const command = new import_commander16.Command("visibility");
|
|
22259
22589
|
command.description("Change package visibility (owner only)").argument("<package>", "Package name to update").option("--public", "Make the package public (visible in search)").option("--private", "Make the package private (org members only)").action(async (packageName, options) => {
|
|
22260
22590
|
await handleVisibility(packageName, options);
|
|
22261
22591
|
});
|
|
@@ -22264,7 +22594,7 @@ function createVisibilityCommand() {
|
|
|
22264
22594
|
|
|
22265
22595
|
// src/commands/login.ts
|
|
22266
22596
|
init_cjs_shims();
|
|
22267
|
-
var
|
|
22597
|
+
var import_commander17 = require("commander");
|
|
22268
22598
|
var jwt = __toESM(require("jsonwebtoken"));
|
|
22269
22599
|
init_telemetry();
|
|
22270
22600
|
init_user_config();
|
|
@@ -22431,16 +22761,16 @@ async function handleLogin(options) {
|
|
|
22431
22761
|
}
|
|
22432
22762
|
}
|
|
22433
22763
|
function createLoginCommand() {
|
|
22434
|
-
return new
|
|
22764
|
+
return new import_commander17.Command("login").description("Login to the PRMP registry").option("--token <token>", "Login with a personal access token").action(async (options) => {
|
|
22435
22765
|
await handleLogin(options);
|
|
22436
22766
|
});
|
|
22437
22767
|
}
|
|
22438
22768
|
|
|
22439
22769
|
// src/commands/whoami.ts
|
|
22440
22770
|
init_cjs_shims();
|
|
22441
|
-
var
|
|
22771
|
+
var import_commander18 = require("commander");
|
|
22442
22772
|
init_user_config();
|
|
22443
|
-
var
|
|
22773
|
+
var import_registry_client10 = require("@pr-pm/registry-client");
|
|
22444
22774
|
init_telemetry();
|
|
22445
22775
|
init_errors();
|
|
22446
22776
|
async function handleWhoami() {
|
|
@@ -22456,7 +22786,7 @@ async function handleWhoami() {
|
|
|
22456
22786
|
return;
|
|
22457
22787
|
}
|
|
22458
22788
|
try {
|
|
22459
|
-
const client = (0,
|
|
22789
|
+
const client = (0, import_registry_client10.getRegistryClient)(config);
|
|
22460
22790
|
const userProfile = await client.getUserProfile(config.username);
|
|
22461
22791
|
console.log(`
|
|
22462
22792
|
\u{1F464} ${userProfile.username}${userProfile.verified_author ? " \u2713" : ""}`);
|
|
@@ -22496,7 +22826,7 @@ async function handleWhoami() {
|
|
|
22496
22826
|
}
|
|
22497
22827
|
}
|
|
22498
22828
|
function createWhoamiCommand() {
|
|
22499
|
-
return new
|
|
22829
|
+
return new import_commander18.Command("whoami").description("Show current logged-in user").action(async () => {
|
|
22500
22830
|
await handleWhoami();
|
|
22501
22831
|
});
|
|
22502
22832
|
}
|
|
@@ -22506,8 +22836,8 @@ init_collections();
|
|
|
22506
22836
|
|
|
22507
22837
|
// src/commands/outdated.ts
|
|
22508
22838
|
init_cjs_shims();
|
|
22509
|
-
var
|
|
22510
|
-
var
|
|
22839
|
+
var import_commander19 = require("commander");
|
|
22840
|
+
var import_registry_client11 = require("@pr-pm/registry-client");
|
|
22511
22841
|
init_user_config();
|
|
22512
22842
|
init_lockfile();
|
|
22513
22843
|
init_telemetry();
|
|
@@ -22519,7 +22849,7 @@ async function handleOutdated() {
|
|
|
22519
22849
|
try {
|
|
22520
22850
|
console.log("\u{1F50D} Checking for package updates...\n");
|
|
22521
22851
|
const config = await getConfig();
|
|
22522
|
-
const client = (0,
|
|
22852
|
+
const client = (0, import_registry_client11.getRegistryClient)(config);
|
|
22523
22853
|
const installedPackages = await listPackages();
|
|
22524
22854
|
if (installedPackages.length === 0) {
|
|
22525
22855
|
console.log("No packages installed.");
|
|
@@ -22609,15 +22939,15 @@ function getUpdateType(current, latest) {
|
|
|
22609
22939
|
return "patch";
|
|
22610
22940
|
}
|
|
22611
22941
|
function createOutdatedCommand() {
|
|
22612
|
-
return new
|
|
22942
|
+
return new import_commander19.Command("outdated").description("Check for package updates").action(async () => {
|
|
22613
22943
|
await handleOutdated();
|
|
22614
22944
|
});
|
|
22615
22945
|
}
|
|
22616
22946
|
|
|
22617
22947
|
// src/commands/update.ts
|
|
22618
22948
|
init_cjs_shims();
|
|
22619
|
-
var
|
|
22620
|
-
var
|
|
22949
|
+
var import_commander20 = require("commander");
|
|
22950
|
+
var import_registry_client12 = require("@pr-pm/registry-client");
|
|
22621
22951
|
init_user_config();
|
|
22622
22952
|
init_lockfile();
|
|
22623
22953
|
init_install();
|
|
@@ -22630,7 +22960,7 @@ async function handleUpdate(packageName, options = {}) {
|
|
|
22630
22960
|
let updatedCount = 0;
|
|
22631
22961
|
try {
|
|
22632
22962
|
const config = await getConfig();
|
|
22633
|
-
const client = (0,
|
|
22963
|
+
const client = (0, import_registry_client12.getRegistryClient)(config);
|
|
22634
22964
|
const installedPackages = await listPackages();
|
|
22635
22965
|
if (installedPackages.length === 0) {
|
|
22636
22966
|
console.log("No packages installed.");
|
|
@@ -22722,7 +23052,7 @@ function getUpdateType2(current, latest) {
|
|
|
22722
23052
|
return "patch";
|
|
22723
23053
|
}
|
|
22724
23054
|
function createUpdateCommand() {
|
|
22725
|
-
return new
|
|
23055
|
+
return new import_commander20.Command("update").description(
|
|
22726
23056
|
"Update packages to latest compatible versions (minor/patch only)"
|
|
22727
23057
|
).argument("[package]", "Specific package to update (optional)").option("--all", "Update all packages").action(async (packageName, options) => {
|
|
22728
23058
|
await handleUpdate(packageName, options);
|
|
@@ -22731,8 +23061,8 @@ function createUpdateCommand() {
|
|
|
22731
23061
|
|
|
22732
23062
|
// src/commands/upgrade.ts
|
|
22733
23063
|
init_cjs_shims();
|
|
22734
|
-
var
|
|
22735
|
-
var
|
|
23064
|
+
var import_commander21 = require("commander");
|
|
23065
|
+
var import_registry_client13 = require("@pr-pm/registry-client");
|
|
22736
23066
|
init_user_config();
|
|
22737
23067
|
init_lockfile();
|
|
22738
23068
|
init_install();
|
|
@@ -22746,7 +23076,7 @@ async function handleUpgrade(packageName, options = {}) {
|
|
|
22746
23076
|
let upgradedCount = 0;
|
|
22747
23077
|
try {
|
|
22748
23078
|
const config = await getConfig();
|
|
22749
|
-
const client = (0,
|
|
23079
|
+
const client = (0, import_registry_client13.getRegistryClient)(config);
|
|
22750
23080
|
const installedPackages = await listPackages();
|
|
22751
23081
|
if (installedPackages.length === 0) {
|
|
22752
23082
|
console.log("No packages installed.");
|
|
@@ -22913,7 +23243,7 @@ function getUpdateType3(current, latest) {
|
|
|
22913
23243
|
return "patch";
|
|
22914
23244
|
}
|
|
22915
23245
|
function createUpgradeCommand() {
|
|
22916
|
-
return new
|
|
23246
|
+
return new import_commander21.Command("upgrade").description(
|
|
22917
23247
|
"Upgrade packages to latest versions (including major updates)"
|
|
22918
23248
|
).argument("[package]", "Specific package to upgrade (optional)").option("--all", "Upgrade all packages").option("--force", "Skip warning for major version upgrades").action(
|
|
22919
23249
|
async (packageName, options) => {
|
|
@@ -22924,7 +23254,7 @@ function createUpgradeCommand() {
|
|
|
22924
23254
|
|
|
22925
23255
|
// src/commands/schema.ts
|
|
22926
23256
|
init_cjs_shims();
|
|
22927
|
-
var
|
|
23257
|
+
var import_commander22 = require("commander");
|
|
22928
23258
|
init_errors();
|
|
22929
23259
|
async function handleSchema() {
|
|
22930
23260
|
try {
|
|
@@ -22941,7 +23271,7 @@ async function handleSchema() {
|
|
|
22941
23271
|
}
|
|
22942
23272
|
}
|
|
22943
23273
|
function createSchemaCommand() {
|
|
22944
|
-
const command = new
|
|
23274
|
+
const command = new import_commander22.Command("schema");
|
|
22945
23275
|
command.description("Display the PRPM manifest JSON schema").action(async () => {
|
|
22946
23276
|
await handleSchema();
|
|
22947
23277
|
});
|
|
@@ -22953,7 +23283,7 @@ init_init();
|
|
|
22953
23283
|
|
|
22954
23284
|
// src/commands/config.ts
|
|
22955
23285
|
init_cjs_shims();
|
|
22956
|
-
var
|
|
23286
|
+
var import_commander23 = require("commander");
|
|
22957
23287
|
init_user_config();
|
|
22958
23288
|
init_errors();
|
|
22959
23289
|
async function handleConfigGet(key) {
|
|
@@ -23044,7 +23374,7 @@ async function handleConfigDelete(key) {
|
|
|
23044
23374
|
}
|
|
23045
23375
|
}
|
|
23046
23376
|
function createConfigCommand() {
|
|
23047
|
-
const command = new
|
|
23377
|
+
const command = new import_commander23.Command("config").description("Manage CLI configuration");
|
|
23048
23378
|
command.command("list").alias("ls").description("List all configuration values").action(async () => {
|
|
23049
23379
|
await handleConfigList();
|
|
23050
23380
|
});
|
|
@@ -23065,9 +23395,9 @@ function createConfigCommand() {
|
|
|
23065
23395
|
|
|
23066
23396
|
// src/commands/catalog.ts
|
|
23067
23397
|
init_cjs_shims();
|
|
23068
|
-
var
|
|
23398
|
+
var import_commander24 = require("commander");
|
|
23069
23399
|
function createCatalogCommand() {
|
|
23070
|
-
return new
|
|
23400
|
+
return new import_commander24.Command("catalog").description(
|
|
23071
23401
|
"[DEPRECATED] Use 'prpm init --scan' instead. Discover and catalog packages."
|
|
23072
23402
|
).argument("[directories...]", "Directories to scan for packages").option("-o, --output <path>", "Output path for prpm.json").option("-a, --append", "Append to existing prpm.json").option("--dry-run", "Show what would be cataloged without making changes").action(
|
|
23073
23403
|
async (directories, options) => {
|
|
@@ -23106,12 +23436,12 @@ function createCatalogCommand() {
|
|
|
23106
23436
|
|
|
23107
23437
|
// src/commands/playground.ts
|
|
23108
23438
|
init_cjs_shims();
|
|
23109
|
-
var
|
|
23439
|
+
var import_commander25 = require("commander");
|
|
23110
23440
|
init_user_config();
|
|
23111
23441
|
init_telemetry();
|
|
23112
23442
|
var readline5 = __toESM(require("readline"));
|
|
23113
|
-
var
|
|
23114
|
-
var
|
|
23443
|
+
var fs14 = __toESM(require("fs"));
|
|
23444
|
+
var path11 = __toESM(require("path"));
|
|
23115
23445
|
init_errors();
|
|
23116
23446
|
function createReadline() {
|
|
23117
23447
|
return readline5.createInterface({
|
|
@@ -23229,11 +23559,11 @@ async function runCustomPrompt(customPrompt, input2, options, sessionId) {
|
|
|
23229
23559
|
return response.json();
|
|
23230
23560
|
}
|
|
23231
23561
|
function readPromptFile(filePath) {
|
|
23232
|
-
const absolutePath =
|
|
23233
|
-
if (!
|
|
23562
|
+
const absolutePath = path11.resolve(filePath);
|
|
23563
|
+
if (!fs14.existsSync(absolutePath)) {
|
|
23234
23564
|
throw new Error(`Prompt file not found: ${filePath}`);
|
|
23235
23565
|
}
|
|
23236
|
-
return
|
|
23566
|
+
return fs14.readFileSync(absolutePath, "utf-8");
|
|
23237
23567
|
}
|
|
23238
23568
|
function displayResponse(result, showStats = true) {
|
|
23239
23569
|
const lastMessage = result.conversation[result.conversation.length - 1];
|
|
@@ -23546,7 +23876,7 @@ async function handlePlayground(options) {
|
|
|
23546
23876
|
}
|
|
23547
23877
|
}
|
|
23548
23878
|
function createPlaygroundCommand() {
|
|
23549
|
-
const command = new
|
|
23879
|
+
const command = new import_commander25.Command("playground");
|
|
23550
23880
|
command.description("Test a package or custom prompt with AI models in the playground").option("-p, --package <name>", "Package name to test").option("--input <text>", "Input text to send to the model (omit for interactive mode)").option(
|
|
23551
23881
|
"-m, --model <model>",
|
|
23552
23882
|
"AI model to use (sonnet, opus, gpt-4o, gpt-4o-mini, gpt-4-turbo)",
|
|
@@ -23615,7 +23945,7 @@ Note: Playground usage requires credits. Run 'prpm credits' to check balance.
|
|
|
23615
23945
|
|
|
23616
23946
|
// src/commands/credits.ts
|
|
23617
23947
|
init_cjs_shims();
|
|
23618
|
-
var
|
|
23948
|
+
var import_commander26 = require("commander");
|
|
23619
23949
|
init_user_config();
|
|
23620
23950
|
init_telemetry();
|
|
23621
23951
|
init_errors();
|
|
@@ -23742,7 +24072,7 @@ async function handleCredits(options) {
|
|
|
23742
24072
|
}
|
|
23743
24073
|
}
|
|
23744
24074
|
function createCreditsCommand() {
|
|
23745
|
-
const command = new
|
|
24075
|
+
const command = new import_commander26.Command("credits");
|
|
23746
24076
|
command.description("Check playground credits balance and transaction history").option("-h, --history", "Show transaction history instead of balance", false).option("-l, --limit <number>", "Number of transactions to show in history", "10").addHelpText(
|
|
23747
24077
|
"after",
|
|
23748
24078
|
`
|
|
@@ -23777,7 +24107,7 @@ Get more credits:
|
|
|
23777
24107
|
|
|
23778
24108
|
// src/commands/subscribe.ts
|
|
23779
24109
|
init_cjs_shims();
|
|
23780
|
-
var
|
|
24110
|
+
var import_commander27 = require("commander");
|
|
23781
24111
|
init_user_config();
|
|
23782
24112
|
init_telemetry();
|
|
23783
24113
|
var import_child_process2 = require("child_process");
|
|
@@ -23936,7 +24266,7 @@ async function handleSubscribe() {
|
|
|
23936
24266
|
}
|
|
23937
24267
|
}
|
|
23938
24268
|
function createSubscribeCommand() {
|
|
23939
|
-
const command = new
|
|
24269
|
+
const command = new import_commander27.Command("subscribe");
|
|
23940
24270
|
command.description("Subscribe to PRPM+ for monthly playground credits and benefits").addHelpText(
|
|
23941
24271
|
"after",
|
|
23942
24272
|
`
|
|
@@ -23977,7 +24307,7 @@ Note: You can cancel anytime from https://prpm.dev/settings/billing
|
|
|
23977
24307
|
|
|
23978
24308
|
// src/commands/buy-credits.ts
|
|
23979
24309
|
init_cjs_shims();
|
|
23980
|
-
var
|
|
24310
|
+
var import_commander28 = require("commander");
|
|
23981
24311
|
init_user_config();
|
|
23982
24312
|
init_telemetry();
|
|
23983
24313
|
var import_child_process3 = require("child_process");
|
|
@@ -24118,7 +24448,7 @@ async function handleBuyCredits(options) {
|
|
|
24118
24448
|
}
|
|
24119
24449
|
}
|
|
24120
24450
|
function createBuyCreditsCommand() {
|
|
24121
|
-
const command = new
|
|
24451
|
+
const command = new import_commander28.Command("buy-credits");
|
|
24122
24452
|
command.description("Purchase one-time playground credits (never expire)").option(
|
|
24123
24453
|
"-p, --package <package>",
|
|
24124
24454
|
"Credit package to purchase (small, medium, large)"
|
|
@@ -24171,8 +24501,8 @@ Note: Purchased credits are one-time and never expire, unlike monthly credits.
|
|
|
24171
24501
|
|
|
24172
24502
|
// src/commands/starred.ts
|
|
24173
24503
|
init_cjs_shims();
|
|
24174
|
-
var
|
|
24175
|
-
var
|
|
24504
|
+
var import_commander29 = require("commander");
|
|
24505
|
+
var import_registry_client14 = require("@pr-pm/registry-client");
|
|
24176
24506
|
init_user_config();
|
|
24177
24507
|
init_telemetry();
|
|
24178
24508
|
init_errors();
|
|
@@ -24185,7 +24515,7 @@ async function handleStarred(options) {
|
|
|
24185
24515
|
throw new CLIError("You must be logged in to view starred items. Run `prpm login` first.");
|
|
24186
24516
|
}
|
|
24187
24517
|
const registryUrl = config.registryUrl || process.env.PRPM_REGISTRY_URL || "https://registry.prpm.dev";
|
|
24188
|
-
const client = (0,
|
|
24518
|
+
const client = (0, import_registry_client14.getRegistryClient)({ registryUrl, token });
|
|
24189
24519
|
const showPackages = options.packages || !options.packages && !options.collections;
|
|
24190
24520
|
const showCollections = options.collections || !options.packages && !options.collections;
|
|
24191
24521
|
const limit = options.limit || 100;
|
|
@@ -24287,91 +24617,91 @@ Total: ${packages.length + collections.length} starred items`);
|
|
|
24287
24617
|
}
|
|
24288
24618
|
}
|
|
24289
24619
|
function createStarredCommand() {
|
|
24290
|
-
const command = new
|
|
24620
|
+
const command = new import_commander29.Command("starred");
|
|
24291
24621
|
command.description("List your starred packages and collections").option("--packages", "Show only starred packages").option("--collections", "Show only starred collections").option("--format <format>", "Filter packages by format (cursor, claude, continue, windsurf, etc.)").option("--limit <number>", "Maximum number of items to fetch (default: 100)", (val) => parseInt(val, 10)).action(handleStarred);
|
|
24292
24622
|
return command;
|
|
24293
24623
|
}
|
|
24294
24624
|
|
|
24295
24625
|
// src/commands/convert.ts
|
|
24296
24626
|
init_cjs_shims();
|
|
24297
|
-
var
|
|
24298
|
-
var
|
|
24299
|
-
var
|
|
24627
|
+
var import_commander30 = require("commander");
|
|
24628
|
+
var import_promises12 = require("fs/promises");
|
|
24629
|
+
var import_path25 = require("path");
|
|
24300
24630
|
var import_fs20 = require("fs");
|
|
24301
24631
|
var import_readline = require("readline");
|
|
24302
24632
|
init_source();
|
|
24303
24633
|
init_errors();
|
|
24304
24634
|
init_dist();
|
|
24305
24635
|
function getDefaultPath(format, filename, subtype, customName) {
|
|
24306
|
-
const baseName = customName || (0,
|
|
24636
|
+
const baseName = customName || (0, import_path25.basename)(filename, (0, import_path25.extname)(filename));
|
|
24307
24637
|
switch (format) {
|
|
24308
24638
|
case "cursor":
|
|
24309
24639
|
if (subtype === "slash-command") {
|
|
24310
|
-
return (0,
|
|
24640
|
+
return (0, import_path25.join)(process.cwd(), ".cursor", "commands", `${baseName}.md`);
|
|
24311
24641
|
}
|
|
24312
24642
|
if (subtype === "hook") {
|
|
24313
|
-
return (0,
|
|
24643
|
+
return (0, import_path25.join)(process.cwd(), ".cursor", "hooks", "hooks.json");
|
|
24314
24644
|
}
|
|
24315
|
-
return (0,
|
|
24645
|
+
return (0, import_path25.join)(process.cwd(), ".cursor", "rules", `${baseName}.mdc`);
|
|
24316
24646
|
case "claude":
|
|
24317
24647
|
if (subtype === "skill") {
|
|
24318
|
-
return (0,
|
|
24648
|
+
return (0, import_path25.join)(process.cwd(), ".claude", "skills", baseName, "SKILL.md");
|
|
24319
24649
|
} else if (subtype === "slash-command") {
|
|
24320
|
-
return (0,
|
|
24650
|
+
return (0, import_path25.join)(process.cwd(), ".claude", "commands", `${baseName}.md`);
|
|
24321
24651
|
} else {
|
|
24322
|
-
return (0,
|
|
24652
|
+
return (0, import_path25.join)(process.cwd(), ".claude", "agents", `${baseName}.md`);
|
|
24323
24653
|
}
|
|
24324
24654
|
case "windsurf":
|
|
24325
|
-
return (0,
|
|
24655
|
+
return (0, import_path25.join)(process.cwd(), ".windsurf", "rules", `${baseName}.md`);
|
|
24326
24656
|
case "kiro":
|
|
24327
24657
|
if (subtype === "hook") {
|
|
24328
|
-
return (0,
|
|
24658
|
+
return (0, import_path25.join)(process.cwd(), ".kiro", "hooks", `${baseName}.kiro.hook`);
|
|
24329
24659
|
}
|
|
24330
24660
|
if (subtype === "agent") {
|
|
24331
|
-
return (0,
|
|
24661
|
+
return (0, import_path25.join)(process.cwd(), ".kiro", "agents", `${baseName}.json`);
|
|
24332
24662
|
}
|
|
24333
|
-
return (0,
|
|
24663
|
+
return (0, import_path25.join)(process.cwd(), ".kiro", "steering", `${baseName}.md`);
|
|
24334
24664
|
case "copilot":
|
|
24335
|
-
return (0,
|
|
24665
|
+
return (0, import_path25.join)(process.cwd(), ".github", "instructions", `${baseName}.instructions.md`);
|
|
24336
24666
|
case "continue":
|
|
24337
24667
|
if (subtype === "slash-command" || subtype === "prompt") {
|
|
24338
|
-
return (0,
|
|
24668
|
+
return (0, import_path25.join)(process.cwd(), ".continue", "prompts", `${baseName}.md`);
|
|
24339
24669
|
}
|
|
24340
|
-
return (0,
|
|
24670
|
+
return (0, import_path25.join)(process.cwd(), ".continue", "rules", `${baseName}.md`);
|
|
24341
24671
|
case "agents.md":
|
|
24342
|
-
return (0,
|
|
24672
|
+
return (0, import_path25.join)(process.cwd(), "agents.md");
|
|
24343
24673
|
case "gemini":
|
|
24344
|
-
return (0,
|
|
24674
|
+
return (0, import_path25.join)(process.cwd(), ".gemini", "commands", `${baseName}.toml`);
|
|
24345
24675
|
case "ruler":
|
|
24346
|
-
return (0,
|
|
24676
|
+
return (0, import_path25.join)(process.cwd(), ".ruler", `${baseName}.md`);
|
|
24347
24677
|
case "zed":
|
|
24348
24678
|
if (subtype === "slash-command") {
|
|
24349
|
-
return (0,
|
|
24679
|
+
return (0, import_path25.join)(process.cwd(), ".zed", "slash_commands", `${baseName}.md`);
|
|
24350
24680
|
}
|
|
24351
|
-
return (0,
|
|
24681
|
+
return (0, import_path25.join)(process.cwd(), ".zed", "extensions", `${baseName}.json`);
|
|
24352
24682
|
case "opencode":
|
|
24353
|
-
return (0,
|
|
24683
|
+
return (0, import_path25.join)(process.cwd(), ".opencode", `${baseName}.md`);
|
|
24354
24684
|
case "aider":
|
|
24355
|
-
return (0,
|
|
24685
|
+
return (0, import_path25.join)(process.cwd(), ".aider", `${baseName}.md`);
|
|
24356
24686
|
case "trae":
|
|
24357
|
-
return (0,
|
|
24687
|
+
return (0, import_path25.join)(process.cwd(), ".trae", "rules", `${baseName}.md`);
|
|
24358
24688
|
case "replit":
|
|
24359
|
-
return (0,
|
|
24689
|
+
return (0, import_path25.join)(process.cwd(), ".replit", `${baseName}.md`);
|
|
24360
24690
|
case "zencoder":
|
|
24361
|
-
return (0,
|
|
24691
|
+
return (0, import_path25.join)(process.cwd(), ".zencoder", `${baseName}.md`);
|
|
24362
24692
|
case "droid":
|
|
24363
|
-
return (0,
|
|
24693
|
+
return (0, import_path25.join)(process.cwd(), ".factory", `${baseName}.md`);
|
|
24364
24694
|
case "codex":
|
|
24365
24695
|
if (subtype === "skill") {
|
|
24366
|
-
return (0,
|
|
24696
|
+
return (0, import_path25.join)(process.cwd(), ".codex", "skills", baseName, "SKILL.md");
|
|
24367
24697
|
}
|
|
24368
|
-
return (0,
|
|
24698
|
+
return (0, import_path25.join)(process.cwd(), "AGENTS.md");
|
|
24369
24699
|
default:
|
|
24370
24700
|
throw new CLIError(`Unknown format: ${format}`);
|
|
24371
24701
|
}
|
|
24372
24702
|
}
|
|
24373
24703
|
function detectFormat(content, filepath) {
|
|
24374
|
-
const ext = (0,
|
|
24704
|
+
const ext = (0, import_path25.extname)(filepath).toLowerCase();
|
|
24375
24705
|
if (ext === ".mdc" || filepath.includes(".cursor/rules") || filepath.includes(".cursor/commands")) {
|
|
24376
24706
|
return "cursor";
|
|
24377
24707
|
}
|
|
@@ -24393,10 +24723,10 @@ function detectFormat(content, filepath) {
|
|
|
24393
24723
|
if (filepath.includes(".continue/rules") || filepath.includes(".continue/prompts") || filepath.includes(".continuerules")) {
|
|
24394
24724
|
return "continue";
|
|
24395
24725
|
}
|
|
24396
|
-
if ((0,
|
|
24726
|
+
if ((0, import_path25.basename)(filepath) === "agents.md") {
|
|
24397
24727
|
return "agents.md";
|
|
24398
24728
|
}
|
|
24399
|
-
if ((0,
|
|
24729
|
+
if ((0, import_path25.basename)(filepath) === "gemini-extension.json" || filepath.includes(".gemini/extensions")) {
|
|
24400
24730
|
return "gemini-extension";
|
|
24401
24731
|
}
|
|
24402
24732
|
if (ext === ".toml" || filepath.includes(".gemini/commands")) {
|
|
@@ -24449,7 +24779,7 @@ async function handleConvert(sourcePath, options) {
|
|
|
24449
24779
|
console.log(source_default.dim("Reading source file..."));
|
|
24450
24780
|
let content;
|
|
24451
24781
|
try {
|
|
24452
|
-
content = await (0,
|
|
24782
|
+
content = await (0, import_promises12.readFile)(sourcePath, "utf-8");
|
|
24453
24783
|
} catch (error) {
|
|
24454
24784
|
throw new CLIError(`Failed to read source file: ${error.message}`);
|
|
24455
24785
|
}
|
|
@@ -24485,7 +24815,7 @@ async function handleConvert(sourcePath, options) {
|
|
|
24485
24815
|
}
|
|
24486
24816
|
canonicalPkg = fromCursor(content, metadata, {
|
|
24487
24817
|
resolveFiles: hasFileReferences,
|
|
24488
|
-
basePath: hasFileReferences ? (0,
|
|
24818
|
+
basePath: hasFileReferences ? (0, import_path25.dirname)(sourcePath) : void 0
|
|
24489
24819
|
});
|
|
24490
24820
|
break;
|
|
24491
24821
|
case "cursor-hooks":
|
|
@@ -24642,10 +24972,10 @@ async function handleConvert(sourcePath, options) {
|
|
|
24642
24972
|
return;
|
|
24643
24973
|
}
|
|
24644
24974
|
}
|
|
24645
|
-
const outputDir = (0,
|
|
24646
|
-
await (0,
|
|
24975
|
+
const outputDir = (0, import_path25.dirname)(outputPath);
|
|
24976
|
+
await (0, import_promises12.mkdir)(outputDir, { recursive: true });
|
|
24647
24977
|
console.log(source_default.dim("Writing converted file..."));
|
|
24648
|
-
await (0,
|
|
24978
|
+
await (0, import_promises12.writeFile)(outputPath, result.content, "utf-8");
|
|
24649
24979
|
console.log(source_default.green(`\u2713 Converted file written to ${outputPath}`));
|
|
24650
24980
|
console.log();
|
|
24651
24981
|
if (options.to === "cursor") {
|
|
@@ -24669,7 +24999,7 @@ async function handleConvert(sourcePath, options) {
|
|
|
24669
24999
|
}
|
|
24670
25000
|
}
|
|
24671
25001
|
function createConvertCommand() {
|
|
24672
|
-
const command = new
|
|
25002
|
+
const command = new import_commander30.Command("convert").description("Convert AI prompt files between formats").argument("<source>", "Source file path to convert").option("-t, --to <format>", `Target format (${CLI_SUPPORTED_FORMATS.join(", ")})`).option("-s, --subtype <subtype>", "Target subtype (agent, skill, slash-command, rule, hook, prompt, etc.)").option("-o, --output <path>", "Output path (defaults to format-specific location)").option("-n, --name <name>", 'Custom output filename (without extension, e.g., "my-rule")').option("--hook-mapping <strategy>", "Hook mapping strategy: auto (default), strict, skip", "auto").option("-y, --yes", "Skip confirmation prompts").action(async (source, options) => {
|
|
24673
25003
|
try {
|
|
24674
25004
|
if (!options.to) {
|
|
24675
25005
|
throw new CLIError("Target format is required. Use --to <format>");
|
|
@@ -24718,9 +25048,9 @@ Valid subtypes: ${validSubtypes.join(", ")}`
|
|
|
24718
25048
|
|
|
24719
25049
|
// src/commands/export.ts
|
|
24720
25050
|
init_cjs_shims();
|
|
24721
|
-
var
|
|
25051
|
+
var import_commander31 = require("commander");
|
|
24722
25052
|
var import_fs21 = require("fs");
|
|
24723
|
-
var
|
|
25053
|
+
var import_path26 = require("path");
|
|
24724
25054
|
init_source();
|
|
24725
25055
|
init_errors();
|
|
24726
25056
|
init_lockfile();
|
|
@@ -24736,7 +25066,7 @@ async function exportToRuler(options) {
|
|
|
24736
25066
|
}
|
|
24737
25067
|
console.log(source_default.green(`\u2713 Found ${packages.length} installed package${packages.length === 1 ? "" : "s"}`));
|
|
24738
25068
|
console.log();
|
|
24739
|
-
const outputDir = options.output || (0,
|
|
25069
|
+
const outputDir = options.output || (0, import_path26.join)(process.cwd(), ".ruler");
|
|
24740
25070
|
let rulerExists = false;
|
|
24741
25071
|
try {
|
|
24742
25072
|
await import_fs21.promises.access(outputDir);
|
|
@@ -24763,7 +25093,7 @@ async function exportToRuler(options) {
|
|
|
24763
25093
|
const content = await import_fs21.promises.readFile(pkg.installedPath, "utf-8");
|
|
24764
25094
|
const rulerContent = createRulerFormat(pkg.id, pkg.version, content, pkg.format, pkg.subtype);
|
|
24765
25095
|
const rulerFilename = `${packageName}.md`;
|
|
24766
|
-
const rulerPath = (0,
|
|
25096
|
+
const rulerPath = (0, import_path26.join)(outputDir, rulerFilename);
|
|
24767
25097
|
await import_fs21.promises.writeFile(rulerPath, rulerContent, "utf-8");
|
|
24768
25098
|
console.log(source_default.green(`\u2713 Exported ${pkg.id} \u2192 ${rulerFilename}`));
|
|
24769
25099
|
exportedCount++;
|
|
@@ -24803,7 +25133,7 @@ function createRulerFormat(packageId, version, content, format, subtype) {
|
|
|
24803
25133
|
return frontmatter + contentWithoutFrontmatter;
|
|
24804
25134
|
}
|
|
24805
25135
|
async function ensureRulerConfig(rulerDir) {
|
|
24806
|
-
const configPath = (0,
|
|
25136
|
+
const configPath = (0, import_path26.join)((0, import_path26.dirname)(rulerDir), "ruler.toml");
|
|
24807
25137
|
try {
|
|
24808
25138
|
await import_fs21.promises.access(configPath);
|
|
24809
25139
|
console.log(source_default.dim("\u2139 ruler.toml already exists (not modified)"));
|
|
@@ -24867,7 +25197,7 @@ async function handleExport(options) {
|
|
|
24867
25197
|
}
|
|
24868
25198
|
}
|
|
24869
25199
|
function createExportCommand() {
|
|
24870
|
-
const command = new
|
|
25200
|
+
const command = new import_commander31.Command("export");
|
|
24871
25201
|
command.description("Export installed packages to external tools").option("--to <tool>", "Export target (currently supports: ruler)", "ruler").option("-o, --output <dir>", "Custom output directory").option("-y, --yes", "Skip confirmation prompts").action(async (options) => {
|
|
24872
25202
|
try {
|
|
24873
25203
|
if (!options.to) {
|
|
@@ -24901,14 +25231,14 @@ init_telemetry();
|
|
|
24901
25231
|
init_errors();
|
|
24902
25232
|
function getVersion() {
|
|
24903
25233
|
try {
|
|
24904
|
-
const packageJsonPath = (0,
|
|
25234
|
+
const packageJsonPath = (0, import_path27.join)(__dirname, "../package.json");
|
|
24905
25235
|
const packageJson = JSON.parse((0, import_fs22.readFileSync)(packageJsonPath, "utf-8"));
|
|
24906
25236
|
return packageJson.version || "0.0.0";
|
|
24907
25237
|
} catch {
|
|
24908
25238
|
return "0.0.0";
|
|
24909
25239
|
}
|
|
24910
25240
|
}
|
|
24911
|
-
var program = new
|
|
25241
|
+
var program = new import_commander32.Command();
|
|
24912
25242
|
program.name("prpm").description("Prompt Package Manager - Install and manage prompt-based files").version(getVersion());
|
|
24913
25243
|
program.addCommand(createInitCommand());
|
|
24914
25244
|
program.addCommand(createCatalogCommand());
|
|
@@ -24916,6 +25246,7 @@ program.addCommand(createSearchCommand());
|
|
|
24916
25246
|
program.addCommand(createAISearchCommand());
|
|
24917
25247
|
program.addCommand(createInstallCommand());
|
|
24918
25248
|
program.addCommand(createInfoCommand());
|
|
25249
|
+
program.addCommand(createShowCommand());
|
|
24919
25250
|
program.addCommand(createTrendingCommand());
|
|
24920
25251
|
program.addCommand(createPopularCommand());
|
|
24921
25252
|
program.addCommand(createPublishCommand());
|