prpm 2.1.20 → 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 +43 -14
  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;
@@ -16145,12 +16160,25 @@ 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;
16152
- const existingLocation = ((_a = installedPkg.snippetMetadata) == null ? void 0 : _a.targetPath) || installedPkg.installedPath;
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") {
@@ -16983,7 +17011,8 @@ ${afterFrontmatter}`;
16983
17011
  snippetMetadata
16984
17012
  // Track snippet installation metadata for uninstall
16985
17013
  });
16986
- 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);
16987
17016
  await writeLockfile(updatedLockfile);
16988
17017
  await client.trackDownload(packageId, {
16989
17018
  version: actualVersion || version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prpm",
3
- "version": "2.1.20",
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.21",
49
- "@pr-pm/registry-client": "^2.3.20",
50
- "@pr-pm/types": "^2.1.21",
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",