@npeercy/skills 0.1.1 → 0.1.2

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/bin/skills.js CHANGED
@@ -1,11 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import { parseArgs } from 'node:util';
3
+ import { readFileSync } from 'node:fs';
4
+ import { dirname, join } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
3
6
  import {
4
7
  cmdInit, cmdLogin, cmdLogout, cmdSearch, cmdInfo,
5
8
  cmdInstall, cmdList, cmdUpdate, cmdUninstall,
6
9
  cmdEdit, cmdValidate, cmdPublish, cmdImport, cmdDoctor,
7
10
  cmdShare, cmdUnshare, cmdVisibility,
8
11
  } from '../lib/skills.js';
12
+ import { loadConfig, saveConfig } from '../lib/config.js';
9
13
 
10
14
  const USAGE = `skill-sharer — CLI skill manager for coding agents
11
15
 
@@ -43,6 +47,55 @@ Maintenance:
43
47
  doctor [--dry] Diagnose + fix issues
44
48
  `;
45
49
 
50
+ const PKG = JSON.parse(
51
+ readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf8')
52
+ );
53
+
54
+ function cmpSemver(a, b) {
55
+ const pa = String(a || '').split('.').map(n => parseInt(n, 10) || 0);
56
+ const pb = String(b || '').split('.').map(n => parseInt(n, 10) || 0);
57
+ const len = Math.max(pa.length, pb.length);
58
+ for (let i = 0; i < len; i++) {
59
+ const da = pa[i] || 0;
60
+ const db = pb[i] || 0;
61
+ if (da > db) return 1;
62
+ if (da < db) return -1;
63
+ }
64
+ return 0;
65
+ }
66
+
67
+ async function maybeWarnOutdated() {
68
+ if (process.env.SKILLS_NO_UPDATE_CHECK === '1') return;
69
+
70
+ const cfg = loadConfig();
71
+ const now = Date.now();
72
+ const oneDayMs = 24 * 60 * 60 * 1000;
73
+ const lastChecked = cfg.updateCheck?.lastChecked ? Date.parse(cfg.updateCheck.lastChecked) : 0;
74
+ let latest = cfg.updateCheck?.latestVersion || '';
75
+
76
+ if (!lastChecked || now - lastChecked > oneDayMs || !latest) {
77
+ try {
78
+ const res = await fetch('https://registry.npmjs.org/@npeercy%2fskills/latest');
79
+ if (res.ok) {
80
+ const data = await res.json();
81
+ latest = data.version || latest;
82
+ cfg.updateCheck = {
83
+ lastChecked: new Date(now).toISOString(),
84
+ latestVersion: latest,
85
+ };
86
+ saveConfig(cfg);
87
+ }
88
+ } catch {
89
+ // Silent fail; command should continue even offline.
90
+ }
91
+ }
92
+
93
+ if (latest && cmpSemver(latest, PKG.version) > 0) {
94
+ console.log(`⚠ Update available: @npeercy/skills ${PKG.version} → ${latest}`);
95
+ console.log(' Run: npm install -g @npeercy/skills\n');
96
+ }
97
+ }
98
+
46
99
  async function main() {
47
100
  const args = process.argv.slice(2);
48
101
  if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
@@ -53,6 +106,8 @@ async function main() {
53
106
  const cmd = args[0];
54
107
  const rest = args.slice(1);
55
108
 
109
+ await maybeWarnOutdated();
110
+
56
111
  try {
57
112
  switch (cmd) {
58
113
  case 'init': {
package/lib/config.js CHANGED
@@ -23,7 +23,15 @@ function saveJson(path, data) {
23
23
  }
24
24
 
25
25
  // --- Config ---
26
- const DEFAULT_CONFIG = { server: 'https://skills.npeercy.com', org: '', token: '' };
26
+ const DEFAULT_CONFIG = {
27
+ server: 'https://skills.npeercy.com',
28
+ org: '',
29
+ token: '',
30
+ updateCheck: {
31
+ lastChecked: '',
32
+ latestVersion: ''
33
+ }
34
+ };
27
35
 
28
36
  export function loadConfig() {
29
37
  mkdirSync(CONFIG_HOME, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npeercy/skills",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CLI-first skill marketplace for coding agents",
5
5
  "type": "module",
6
6
  "bin": {
Binary file