@lpm-registry/cli 0.2.6 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.3.0] - 2026-03-22
6
+
7
+ ### Added
8
+
9
+ - **Upstream npm proxy mode (default)** — `lpm npmrc` and `lpm setup` now configure LPM as the default registry. All packages (LPM + npm) are fetched through LPM for faster, edge-cached installs via Cloudflare R2.
10
+ - **`--scoped` flag** — Use `lpm npmrc --scoped` or `lpm setup --scoped` to only route `@lpm.dev` packages through LPM (old behavior).
11
+ - **Custom registry detection** — If `.npmrc` already has a custom default registry (e.g., Artifactory), the CLI warns and automatically falls back to `--scoped` mode to avoid overriding it.
12
+ - **Pre-publish skills staleness warning** — When Agent Skills haven't changed since the previous version, the warning now appears before the publish confirmation prompt (instead of after), so you can cancel and update skills before publishing.
13
+
14
+ ### Changed
15
+
16
+ - `lpm npmrc` default output changed from `@lpm.dev:registry=...` (scoped) to `registry=...` (proxy mode)
17
+ - `lpm setup` and `lpm setup --oidc` default output changed to proxy mode
18
+ - Updated CLI output messaging to indicate proxy vs scoped mode
19
+ - Updated README with new default behavior and `--scoped` flag
20
+
5
21
  ## [0.2.6] - 2026-03-21
6
22
 
7
23
  ### Added
package/README.md CHANGED
@@ -69,10 +69,13 @@ lpm whoami
69
69
 
70
70
  Generate a 30-day read-only token for your project. Makes `npm install` work with LPM packages.
71
71
 
72
+ By default, LPM is configured as your default registry — all packages (LPM + npm) are fetched through LPM for faster, edge-cached installs.
73
+
72
74
  ```bash
73
- lpm npmrc # 30-day token (default)
75
+ lpm npmrc # 30-day token, proxy mode (default)
74
76
  lpm npmrc --days 7 # 7-day token
75
77
  lpm npmrc --days 90 # 90-day token
78
+ lpm npmrc --scoped # Only route @lpm.dev packages through LPM
76
79
  ```
77
80
 
78
81
  Automatically adds `.npmrc` to `.gitignore` to prevent token leaks.
@@ -82,8 +85,9 @@ Automatically adds `.npmrc` to `.gitignore` to prevent token leaks.
82
85
  Configure `.npmrc` for CI/CD environments.
83
86
 
84
87
  ```bash
85
- lpm setup # Writes ${LPM_TOKEN} placeholder
88
+ lpm setup # Writes ${LPM_TOKEN} placeholder (proxy mode)
86
89
  lpm setup --oidc # OIDC — no secrets needed (GitHub Actions, GitLab CI)
90
+ lpm setup --scoped # Only route @lpm.dev packages through LPM
87
91
  ```
88
92
 
89
93
  For deployment platforms (Vercel, Netlify), set the `LPM_TOKEN` environment variable.
package/bin/lpm.js CHANGED
@@ -210,18 +210,26 @@ program
210
210
 
211
211
  program
212
212
  .command("setup")
213
- .description("Configure .npmrc for LPM packages (@lpm.dev scope)")
213
+ .description("Configure .npmrc for LPM registry")
214
214
  .option("-r, --registry <url>", "Custom registry URL")
215
215
  .option(
216
216
  "--oidc",
217
217
  "Exchange CI OIDC token for install access (no secrets needed)",
218
218
  )
219
+ .option(
220
+ "--scoped",
221
+ "Only route @lpm.dev packages through LPM (don't proxy npm)",
222
+ )
219
223
  .action(setup)
220
224
 
221
225
  program
222
226
  .command("npmrc")
223
227
  .description("Generate a read-only .npmrc token for local development")
224
228
  .option("-d, --days <number>", "Token expiry in days (default: 30)")
229
+ .option(
230
+ "--scoped",
231
+ "Only route @lpm.dev packages through LPM (don't proxy npm)",
232
+ )
225
233
  .action(npmrc)
226
234
 
227
235
  program
@@ -82,15 +82,41 @@ export async function npmrc(options) {
82
82
  : `${registryUrl}/api/registry`
83
83
  const registryHost = fullRegistryUrl.replace(/^https?:/, "")
84
84
 
85
- // Read existing .npmrc and remove old LPM config lines
85
+ // Determine proxy vs scoped mode
86
+ let useScoped = !!options?.scoped
87
+
88
+ // Read existing .npmrc and check for custom default registry
86
89
  let npmrcContent = ""
87
90
  if (fs.existsSync(npmrcPath)) {
88
- npmrcContent = fs
89
- .readFileSync(npmrcPath, "utf8")
91
+ const existingContent = fs.readFileSync(npmrcPath, "utf8")
92
+
93
+ // Detect custom default registry (not npmjs.org and not lpm.dev)
94
+ if (!useScoped) {
95
+ const registryLine = existingContent
96
+ .split("\n")
97
+ .find(
98
+ line =>
99
+ line.match(/^registry=/) &&
100
+ !line.includes("registry.npmjs.org") &&
101
+ !line.includes("lpm.dev"),
102
+ )
103
+ if (registryLine) {
104
+ log.warn(`Found existing default registry: ${registryLine.trim()}`)
105
+ log.warn("Using --scoped mode to avoid overriding it.")
106
+ log.warn(
107
+ "To use LPM as your default registry, remove the existing registry= line first.",
108
+ )
109
+ useScoped = true
110
+ }
111
+ }
112
+
113
+ // Remove old LPM config lines (both scoped and unscoped formats)
114
+ npmrcContent = existingContent
90
115
  .split("\n")
91
116
  .filter(line => {
92
117
  return (
93
118
  !line.includes("@lpm.dev:registry") &&
119
+ !line.match(/^registry=.*lpm\.dev/) &&
94
120
  !line.includes("lpm.dev/api/registry/:_authToken") &&
95
121
  !line.includes("_authToken=lpm_") &&
96
122
  // biome-ignore lint/suspicious/noTemplateCurlyInString: matching literal npm token placeholder
@@ -102,8 +128,12 @@ export async function npmrc(options) {
102
128
  .trim()
103
129
  }
104
130
 
131
+ const registryLine = useScoped
132
+ ? `@lpm.dev:registry=${fullRegistryUrl}`
133
+ : `registry=${fullRegistryUrl}`
134
+
105
135
  const lpmConfig = `# LPM Registry (generated by lpm npmrc — do not commit)
106
- @lpm.dev:registry=${fullRegistryUrl}
136
+ ${registryLine}
107
137
  ${registryHost}/:_authToken=${readToken}`
108
138
 
109
139
  npmrcContent = npmrcContent ? `${npmrcContent}\n\n${lpmConfig}` : lpmConfig
@@ -129,6 +159,13 @@ ${registryHost}/:_authToken=${readToken}`
129
159
  log.info(".npmrc added to .gitignore to prevent token leaks.")
130
160
  }
131
161
 
162
+ if (useScoped) {
163
+ log.info("Only @lpm.dev packages will route through lpm.dev.")
164
+ } else {
165
+ log.info("All packages (LPM + npm) will route through lpm.dev.")
166
+ log.info("Note: First install may update resolved URLs in your lockfile.")
167
+ }
168
+
132
169
  const expiryDate = new Date(expiresAt).toLocaleDateString("en-US", {
133
170
  year: "numeric",
134
171
  month: "long",
@@ -522,8 +522,63 @@ export async function publish(options = {}) {
522
522
  swiftManifest,
523
523
  })
524
524
 
525
+ // 7b. Check for stale skills (compare local with published)
526
+ spinner.text = "Checking skills..."
527
+ const prePublishWarnings = []
528
+ try {
529
+ const localSkillsDir = path.join(process.cwd(), ".lpm", "skills")
530
+ if (fs.existsSync(localSkillsDir)) {
531
+ const skillFiles = fs
532
+ .readdirSync(localSkillsDir)
533
+ .filter(f => f.endsWith(".md"))
534
+ .sort()
535
+
536
+ if (skillFiles.length > 0) {
537
+ // Read local skills content
538
+ const localSkills = skillFiles.map(f => ({
539
+ name: f.replace(/\.md$/, ""),
540
+ rawContent: fs.readFileSync(path.join(localSkillsDir, f), "utf8"),
541
+ }))
542
+
543
+ // Fetch published skills for comparison
544
+ const cleanedName = name.startsWith("@lpm.dev/")
545
+ ? name.replace("@lpm.dev/", "")
546
+ : `${owner}.${packageName}`
547
+ const skillsResponse = await request(
548
+ `/skills?name=${encodeURIComponent(cleanedName)}`,
549
+ { method: "GET" },
550
+ ).catch(() => null)
551
+
552
+ if (skillsResponse?.ok) {
553
+ const published = await skillsResponse.json()
554
+ if (published.available && published.skills?.length > 0) {
555
+ const pubSorted = [...published.skills]
556
+ .map(s => ({ name: s.name, rawContent: s.rawContent }))
557
+ .sort((a, b) => a.name.localeCompare(b.name))
558
+
559
+ const isIdentical =
560
+ localSkills.length === pubSorted.length &&
561
+ localSkills.every(
562
+ (local, i) =>
563
+ local.name === pubSorted[i].name &&
564
+ local.rawContent === pubSorted[i].rawContent,
565
+ )
566
+
567
+ if (isIdentical) {
568
+ prePublishWarnings.push(
569
+ `Agent Skills haven't changed since v${published.version} - consider reviewing them for accuracy`,
570
+ )
571
+ }
572
+ }
573
+ }
574
+ }
575
+ }
576
+ } catch {
577
+ // Non-critical — skip skills staleness check
578
+ }
579
+
525
580
  spinner.stop()
526
- displayQualityReport(qualityResult)
581
+ displayQualityReport({ ...qualityResult, warnings: prePublishWarnings })
527
582
 
528
583
  // --dry-run: print summary and exit without uploading
529
584
  if (dryRun) {
@@ -848,11 +903,16 @@ export async function publish(options = {}) {
848
903
  )
849
904
  }
850
905
 
851
- // Show any server warnings (e.g., stale skills)
906
+ // Server may still return warnings for edge cases not caught client-side
852
907
  if (publishResult.warnings?.length > 0) {
853
- console.log("")
854
- for (const warning of publishResult.warnings) {
855
- log.warn(warning)
908
+ const newWarnings = publishResult.warnings.filter(
909
+ w => !prePublishWarnings.includes(w),
910
+ )
911
+ if (newWarnings.length > 0) {
912
+ console.log("")
913
+ for (const warning of newWarnings) {
914
+ log.warn(warning)
915
+ }
856
916
  }
857
917
  }
858
918
  } catch (error) {
@@ -8,6 +8,7 @@ import { log, printHeader } from "../ui.js"
8
8
 
9
9
  /**
10
10
  * Remove existing LPM config lines from .npmrc content.
11
+ * Handles both scoped (@lpm.dev:registry=) and unscoped (registry=...lpm.dev) formats.
11
12
  * @param {string} content
12
13
  * @returns {string}
13
14
  */
@@ -17,6 +18,7 @@ function removeLpmLines(content) {
17
18
  .filter(line => {
18
19
  return (
19
20
  !line.includes("@lpm.dev:registry") &&
21
+ !line.match(/^registry=.*lpm\.dev/) &&
20
22
  !line.includes("lpm.dev/api/registry/:_authToken") &&
21
23
  !line.includes("_authToken=lpm_") &&
22
24
  // biome-ignore lint/suspicious/noTemplateCurlyInString: matching literal npm token placeholder
@@ -28,6 +30,24 @@ function removeLpmLines(content) {
28
30
  .trim()
29
31
  }
30
32
 
33
+ /**
34
+ * Check if .npmrc has a custom default registry that is NOT npmjs.org or lpm.dev.
35
+ * @param {string} content - Existing .npmrc content
36
+ * @returns {string|null} The custom registry line, or null if none found
37
+ */
38
+ function detectCustomRegistry(content) {
39
+ return (
40
+ content
41
+ .split("\n")
42
+ .find(
43
+ line =>
44
+ line.match(/^registry=/) &&
45
+ !line.includes("registry.npmjs.org") &&
46
+ !line.includes("lpm.dev"),
47
+ ) || null
48
+ )
49
+ }
50
+
31
51
  /**
32
52
  * Configure .npmrc for LPM packages.
33
53
  *
@@ -55,6 +75,9 @@ export async function setup(options) {
55
75
  : `${registryUrl}/api/registry`
56
76
  const registryHost = fullRegistryUrl.replace(/^https?:/, "")
57
77
 
78
+ // Determine proxy vs scoped mode
79
+ let useScoped = !!options?.scoped
80
+
58
81
  // ── OIDC mode: exchange CI token for a real short-lived install token ──
59
82
  if (options?.oidc) {
60
83
  let oidcToken
@@ -70,11 +93,29 @@ export async function setup(options) {
70
93
  if (oidcToken) {
71
94
  let npmrcContent = ""
72
95
  if (fs.existsSync(npmrcPath)) {
73
- npmrcContent = removeLpmLines(fs.readFileSync(npmrcPath, "utf8"))
96
+ const existingContent = fs.readFileSync(npmrcPath, "utf8")
97
+
98
+ // Detect custom default registry
99
+ if (!useScoped) {
100
+ const customRegistry = detectCustomRegistry(existingContent)
101
+ if (customRegistry) {
102
+ log.warn(
103
+ `Found existing default registry: ${customRegistry.trim()}`,
104
+ )
105
+ log.warn("Using --scoped mode to avoid overriding it.")
106
+ useScoped = true
107
+ }
108
+ }
109
+
110
+ npmrcContent = removeLpmLines(existingContent)
74
111
  }
75
112
 
113
+ const registryLine = useScoped
114
+ ? `@lpm.dev:registry=${fullRegistryUrl}`
115
+ : `registry=${fullRegistryUrl}`
116
+
76
117
  const lpmConfig = `# LPM Registry (OIDC — expires in 30 minutes)
77
- @lpm.dev:registry=${fullRegistryUrl}
118
+ ${registryLine}
78
119
  ${registryHost}/:_authToken=${oidcToken}`
79
120
 
80
121
  npmrcContent = npmrcContent
@@ -83,13 +124,16 @@ ${registryHost}/:_authToken=${oidcToken}`
83
124
  fs.writeFileSync(npmrcPath, `${npmrcContent}\n`)
84
125
 
85
126
  p.note(
86
- `@lpm.dev:registry=${fullRegistryUrl}\nToken: OIDC read-only (30 min)`,
127
+ `${registryLine}\nToken: OIDC read-only (30 min)`,
87
128
  ".npmrc configuration",
88
129
  )
89
130
 
90
131
  console.log("")
91
132
  log.success(".npmrc configured with OIDC read-only token.")
92
133
  log.info("Token expires in 30 minutes. No LPM_TOKEN secret needed.")
134
+ if (!useScoped) {
135
+ log.info("All packages (LPM + npm) will route through lpm.dev.")
136
+ }
93
137
  console.log("")
94
138
 
95
139
  p.outro("Setup complete!")
@@ -104,8 +148,24 @@ ${registryHost}/:_authToken=${oidcToken}`
104
148
  if (fs.existsSync(npmrcPath)) {
105
149
  npmrcContent = fs.readFileSync(npmrcPath, "utf8")
106
150
 
107
- // Check if already configured
108
- if (npmrcContent.includes("@lpm.dev:registry")) {
151
+ // Detect custom default registry
152
+ if (!useScoped) {
153
+ const customRegistry = detectCustomRegistry(npmrcContent)
154
+ if (customRegistry) {
155
+ log.warn(`Found existing default registry: ${customRegistry.trim()}`)
156
+ log.warn("Using --scoped mode to avoid overriding it.")
157
+ log.warn(
158
+ "To use LPM as your default registry, remove the existing registry= line first.",
159
+ )
160
+ useScoped = true
161
+ }
162
+ }
163
+
164
+ // Check if already configured (both scoped and unscoped formats)
165
+ if (
166
+ npmrcContent.includes("@lpm.dev:registry") ||
167
+ npmrcContent.match(/^registry=.*lpm\.dev/m)
168
+ ) {
109
169
  const overwrite = await p.confirm({
110
170
  message: ".npmrc already has LPM configuration. Overwrite?",
111
171
  initialValue: false,
@@ -120,10 +180,14 @@ ${registryHost}/:_authToken=${oidcToken}`
120
180
  }
121
181
  }
122
182
 
183
+ const registryLine = useScoped
184
+ ? `@lpm.dev:registry=${fullRegistryUrl}`
185
+ : `registry=${fullRegistryUrl}`
186
+
123
187
  // Add LPM registry config with placeholder
124
188
  const lpmConfig = `
125
189
  # LPM Registry
126
- @lpm.dev:registry=${fullRegistryUrl}
190
+ ${registryLine}
127
191
  ${registryHost}/:_authToken=\${LPM_TOKEN}
128
192
  `.trim()
129
193
 
@@ -131,12 +195,18 @@ ${registryHost}/:_authToken=\${LPM_TOKEN}
131
195
  fs.writeFileSync(npmrcPath, `${npmrcContent}\n`)
132
196
 
133
197
  p.note(
134
- `@lpm.dev:registry=${fullRegistryUrl}\n${registryHost}/:_authToken=\${LPM_TOKEN}`,
198
+ `${registryLine}\n${registryHost}/:_authToken=\${LPM_TOKEN}`,
135
199
  ".npmrc configuration",
136
200
  )
137
201
 
138
202
  console.log("")
139
- log.success(".npmrc configured for LPM packages.")
203
+ log.success(".npmrc configured for LPM registry.")
204
+ if (useScoped) {
205
+ log.info("Only @lpm.dev packages will route through lpm.dev.")
206
+ } else {
207
+ log.info("All packages (LPM + npm) will route through lpm.dev.")
208
+ log.info("Note: First install may update resolved URLs in your lockfile.")
209
+ }
140
210
  log.info("For local development: Run `lpm npmrc` to generate a token.")
141
211
  log.info("For CI/CD: Set the LPM_TOKEN environment variable.")
142
212
  log.info("For CI/CD with OIDC: Run `lpm setup --oidc` (no secrets needed).")
@@ -38,9 +38,9 @@ function progressBar(value, max, width = 18) {
38
38
  /**
39
39
  * Display quality report in the terminal.
40
40
  *
41
- * @param {{ score: number, checks: Array, meta: object }} result
41
+ * @param {{ score: number, checks: Array, meta: object, warnings?: string[] }} result
42
42
  */
43
- export function displayQualityReport({ score, checks, meta }) {
43
+ export function displayQualityReport({ score, checks, meta, warnings }) {
44
44
  const tierColor = TIER_COLORS[meta.tier] || chalk.white
45
45
  const tierLabel = TIER_LABELS[meta.tier] || meta.tier
46
46
 
@@ -76,6 +76,14 @@ export function displayQualityReport({ score, checks, meta }) {
76
76
  }
77
77
  }
78
78
 
79
+ // Show warnings (e.g., stale skills)
80
+ if (warnings?.length > 0) {
81
+ if (failed.length === 0) console.log("")
82
+ for (const warning of warnings) {
83
+ console.log(` ${chalk.yellow("⚠")} ${chalk.yellow(warning)}`)
84
+ }
85
+ }
86
+
79
87
  if (failed.length > 0 && score < 90) {
80
88
  console.log(
81
89
  chalk.dim(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lpm-registry/cli",
3
- "version": "0.2.6",
3
+ "version": "0.3.0",
4
4
  "description": "CLI for Licensed Package Manager",
5
5
  "author": "LPM <hello@lpm.dev> (https://lpm.dev)",
6
6
  "repository": {