prpm 2.1.19 → 2.1.21

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.
Files changed (2) hide show
  1. package/dist/index.js +70 -25
  2. 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 parts = key.split("#");
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: parts[0],
86
- format: parts[1]
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
- const lockfileKey = getLockfileKey(packageId, packageInfo.format);
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;
@@ -16099,7 +16114,7 @@ function findMainFile(files, format, subtype) {
16099
16114
  return null;
16100
16115
  }
16101
16116
  async function handleInstall(packageSpec, options) {
16102
- var _a;
16117
+ var _a, _b, _c;
16103
16118
  const startTime = Date.now();
16104
16119
  let success = false;
16105
16120
  let error;
@@ -16145,22 +16160,51 @@ async function handleInstall(packageSpec, options) {
16145
16160
  version = options.version || specVersion || lockedVersion || "latest";
16146
16161
  }
16147
16162
  if (!options.force && lockfile && targetFormat) {
16148
- const lockfileKey = getLockfileKey(packageId, targetFormat);
16149
- const installedPkg = lockfile.packages[lockfileKey];
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;
16181
+ const existingLocation = ((_b = installedPkg.snippetMetadata) == null ? void 0 : _b.targetPath) || installedPkg.installedPath;
16182
+ let isDifferentLocation = false;
16183
+ if (requestedLocation && existingLocation) {
16184
+ if (installedPkg.subtype === "snippet") {
16185
+ isDifferentLocation = import_path14.default.resolve(requestedLocation) !== import_path14.default.resolve(existingLocation);
16186
+ } else {
16187
+ const existingDir = import_path14.default.dirname(existingLocation);
16188
+ isDifferentLocation = import_path14.default.resolve(requestedLocation) !== import_path14.default.resolve(existingDir);
16189
+ }
16190
+ }
16152
16191
  if (!requestedVersion || requestedVersion === "latest" || requestedVersion === installedPkg.version) {
16153
- console.log(`
16192
+ if (isDifferentLocation) {
16193
+ console.log(`\u{1F4E6} Installing ${packageId} to different location: ${requestedLocation}`);
16194
+ console.log(` (already installed at: ${existingLocation})`);
16195
+ } else {
16196
+ console.log(`
16154
16197
  \u2728 Package already installed!`);
16155
- console.log(` \u{1F4E6} ${packageId}@${installedPkg.version}`);
16156
- console.log(` \u{1F504} Format: ${installedPkg.format || "unknown"} | Subtype: ${installedPkg.subtype || "unknown"}`);
16157
- console.log(`
16198
+ console.log(` \u{1F4E6} ${packageId}@${installedPkg.version}`);
16199
+ console.log(` \u{1F504} Format: ${installedPkg.format || "unknown"} | Subtype: ${installedPkg.subtype || "unknown"}`);
16200
+ console.log(`
16158
16201
  \u{1F4A1} To reinstall or upgrade:`);
16159
- console.log(` prpm upgrade ${packageId} # Upgrade to latest version`);
16160
- console.log(` prpm uninstall ${packageId} # Uninstall first, then install`);
16161
- console.log(` prpm install ${packageId} --as <format> # Install in different format`);
16162
- success = true;
16163
- return;
16202
+ console.log(` prpm upgrade ${packageId} # Upgrade to latest version`);
16203
+ console.log(` prpm uninstall ${packageId} # Uninstall first, then install`);
16204
+ console.log(` prpm install ${packageId} --as <format> # Install in different format`);
16205
+ success = true;
16206
+ return;
16207
+ }
16164
16208
  } else {
16165
16209
  console.log(`\u{1F4E6} Upgrading ${packageId}: ${installedPkg.version} \u2192 ${requestedVersion}`);
16166
16210
  }
@@ -16239,7 +16283,7 @@ async function handleInstall(packageSpec, options) {
16239
16283
  console.log(` \u26A0\uFE0F ${fallbackResult.reason}`);
16240
16284
  format = fallbackResult.format;
16241
16285
  }
16242
- if (format !== pkg.format) {
16286
+ if (format !== pkg.format && pkg.subtype !== "snippet") {
16243
16287
  console.log(` \u{1F504} Converting to ${format} format...`);
16244
16288
  }
16245
16289
  }
@@ -16296,7 +16340,7 @@ This could indicate:
16296
16340
  const effectiveFormat = format || pkg.format;
16297
16341
  const effectiveSubtype = options.subtype || pkg.subtype;
16298
16342
  let extractedFiles = await extractTarball(tarball, packageId);
16299
- if (options.as && format && format !== pkg.format) {
16343
+ if (options.as && format && format !== pkg.format && effectiveSubtype !== "snippet") {
16300
16344
  console.log(` \u{1F504} Converting from ${pkg.format} to ${format}...`);
16301
16345
  let sourceContent;
16302
16346
  if (extractedFiles.length === 1) {
@@ -16459,7 +16503,7 @@ This could indicate:
16459
16503
  console.log(` \u2713 Converted from ${pkg.format} to ${format}`);
16460
16504
  }
16461
16505
  const locationSupportedFormats = ["agents.md", "cursor"];
16462
- let locationOverride = (_a = options.location) == null ? void 0 : _a.trim();
16506
+ let locationOverride = (_c = options.location) == null ? void 0 : _c.trim();
16463
16507
  const isSnippet = effectiveSubtype === "snippet";
16464
16508
  if (locationOverride && !locationSupportedFormats.includes(effectiveFormat) && !isSnippet) {
16465
16509
  console.log(` \u26A0\uFE0F --location option currently applies to Cursor, Agents.md, or snippet installs. Ignoring provided value for ${effectiveFormat}.`);
@@ -16967,7 +17011,8 @@ ${afterFrontmatter}`;
16967
17011
  snippetMetadata
16968
17012
  // Track snippet installation metadata for uninstall
16969
17013
  });
16970
- setPackageIntegrity(updatedLockfile, packageId, tarball, effectiveFormat);
17014
+ const snippetTargetPath = effectiveSubtype === "snippet" ? snippetMetadata == null ? void 0 : snippetMetadata.targetPath : void 0;
17015
+ setPackageIntegrity(updatedLockfile, packageId, tarball, effectiveFormat, snippetTargetPath);
16971
17016
  await writeLockfile(updatedLockfile);
16972
17017
  await client.trackDownload(packageId, {
16973
17018
  version: actualVersion || version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prpm",
3
- "version": "2.1.19",
3
+ "version": "2.1.21",
4
4
  "description": "Prompt Package Manager CLI - Install and manage prompt-based files",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -45,9 +45,9 @@
45
45
  "license": "MIT",
46
46
  "dependencies": {
47
47
  "@octokit/rest": "^22.0.0",
48
- "@pr-pm/converters": "^2.1.20",
49
- "@pr-pm/registry-client": "^2.3.19",
50
- "@pr-pm/types": "^2.1.20",
48
+ "@pr-pm/converters": "^2.1.22",
49
+ "@pr-pm/registry-client": "^2.3.21",
50
+ "@pr-pm/types": "^2.1.22",
51
51
  "ajv": "^8.17.1",
52
52
  "ajv-formats": "^3.0.1",
53
53
  "chalk": "^5.6.2",