@npeercy/skills 0.1.10 → 0.1.11
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 +10 -5
- package/lib/api.js +2 -2
- package/lib/config.js +1 -0
- package/lib/skills.js +24 -5
- package/package.json +1 -1
package/bin/skills.js
CHANGED
|
@@ -17,8 +17,8 @@ Usage: skills <command> [options]
|
|
|
17
17
|
|
|
18
18
|
Setup:
|
|
19
19
|
init [--server <url>] [--token <token>] Setup skill-sharer (local-only; never publishes)
|
|
20
|
-
login [--server <url>] [--token <token>]
|
|
21
|
-
logout
|
|
20
|
+
login [--server <url>] [--token <token>] [--name <n>] Login (name defaults to hostname)
|
|
21
|
+
logout [--revoke] Local logout (--revoke also invalidates server token)
|
|
22
22
|
|
|
23
23
|
Discovery:
|
|
24
24
|
search [query] Search skills (no query = browse all)
|
|
@@ -94,13 +94,18 @@ async function main() {
|
|
|
94
94
|
const { values } = parseArgs({ args: rest, options: {
|
|
95
95
|
server: { type: 'string' },
|
|
96
96
|
token: { type: 'string' },
|
|
97
|
+
name: { type: 'string' },
|
|
97
98
|
}, allowPositionals: false });
|
|
98
|
-
await cmdLogin({ server: values.server, token: values.token });
|
|
99
|
+
await cmdLogin({ server: values.server, token: values.token, name: values.name });
|
|
99
100
|
break;
|
|
100
101
|
}
|
|
101
|
-
case 'logout':
|
|
102
|
-
|
|
102
|
+
case 'logout': {
|
|
103
|
+
const { values } = parseArgs({ args: rest, options: {
|
|
104
|
+
revoke: { type: 'boolean', default: false },
|
|
105
|
+
}, allowPositionals: false });
|
|
106
|
+
await cmdLogout({ revoke: values.revoke });
|
|
103
107
|
break;
|
|
108
|
+
}
|
|
104
109
|
case 'search': {
|
|
105
110
|
const { positionals } = parseArgs({ args: rest, allowPositionals: true, options: {} });
|
|
106
111
|
await cmdSearch({ query: positionals[0] || '' });
|
package/lib/api.js
CHANGED
|
@@ -27,8 +27,8 @@ async function request(method, path, body = null) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// --- Auth ---
|
|
30
|
-
export async function createToken(user) {
|
|
31
|
-
return request('POST', '/auth/token', { user });
|
|
30
|
+
export async function createToken(user, name) {
|
|
31
|
+
return request('POST', '/auth/token', { user, name });
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export async function whoami() {
|
package/lib/config.js
CHANGED
package/lib/skills.js
CHANGED
|
@@ -455,12 +455,21 @@ export async function cmdLogin(args) {
|
|
|
455
455
|
cfg.token = await promptForToken(cfg.server);
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
+
// Store token name (device name)
|
|
459
|
+
if (args.name) {
|
|
460
|
+
cfg.tokenName = args.name;
|
|
461
|
+
} else if (!cfg.tokenName) {
|
|
462
|
+
const { hostname } = await import('os');
|
|
463
|
+
cfg.tokenName = hostname();
|
|
464
|
+
}
|
|
465
|
+
|
|
458
466
|
saveConfig(cfg);
|
|
459
467
|
const me = await api.whoami();
|
|
460
468
|
cfg.org = me.org;
|
|
461
469
|
saveConfig(cfg);
|
|
462
470
|
console.log(`✓ Logged in as ${me.user} (org: ${me.org}, role: ${me.role})`);
|
|
463
|
-
console.log(`
|
|
471
|
+
console.log(` Token: ${me.tokenName || cfg.tokenName || 'default'}`);
|
|
472
|
+
console.log(` Publish namespace: ${me.org}/${me.user}/<skillname>`);
|
|
464
473
|
|
|
465
474
|
// First-time setup guidance
|
|
466
475
|
const diag = getLocalDiagnostics();
|
|
@@ -490,14 +499,24 @@ export async function cmdLogin(args) {
|
|
|
490
499
|
}
|
|
491
500
|
}
|
|
492
501
|
|
|
493
|
-
export async function cmdLogout() {
|
|
502
|
+
export async function cmdLogout(args = {}) {
|
|
494
503
|
const cfg = loadConfig();
|
|
495
|
-
if (cfg.token) {
|
|
496
|
-
try {
|
|
504
|
+
if (args.revoke && cfg.token) {
|
|
505
|
+
try {
|
|
506
|
+
await api.logout();
|
|
507
|
+
console.log('Token revoked on server.');
|
|
508
|
+
} catch { /* ignore */ }
|
|
497
509
|
}
|
|
510
|
+
const name = cfg.tokenName || 'default';
|
|
498
511
|
cfg.token = '';
|
|
512
|
+
cfg.tokenName = '';
|
|
499
513
|
saveConfig(cfg);
|
|
500
|
-
|
|
514
|
+
if (args.revoke) {
|
|
515
|
+
console.log(`Logged out and revoked token "${name}" on server.`);
|
|
516
|
+
} else {
|
|
517
|
+
console.log(`Logged out locally. Token "${name}" is still valid on other devices.`);
|
|
518
|
+
console.log('Use --revoke to also invalidate the token on the server.');
|
|
519
|
+
}
|
|
501
520
|
}
|
|
502
521
|
|
|
503
522
|
export async function cmdSearch(args) {
|