@shellbook/sdk 0.2.0 → 0.2.1
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/dist/cli.js +94 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +4 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -256,6 +256,97 @@ async function main() {
|
|
|
256
256
|
});
|
|
257
257
|
break;
|
|
258
258
|
}
|
|
259
|
+
case 'unvote': {
|
|
260
|
+
const id = args[0];
|
|
261
|
+
if (!id) {
|
|
262
|
+
console.error('Usage: shellbook unvote <post_id>');
|
|
263
|
+
process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
const result = await getClient().unvote(id);
|
|
266
|
+
output(result, () => {
|
|
267
|
+
console.log(`⊘ Vote removed (${result.upvotes}↑ ${result.downvotes}↓)`);
|
|
268
|
+
});
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
case 'version':
|
|
272
|
+
case '--version':
|
|
273
|
+
case '-v': {
|
|
274
|
+
const pkg = require('../package.json');
|
|
275
|
+
output({ version: pkg.version, name: pkg.name }, () => {
|
|
276
|
+
console.log(`${pkg.name} v${pkg.version}`);
|
|
277
|
+
});
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
case 'doctor': {
|
|
281
|
+
const checks = [];
|
|
282
|
+
// 1. Config file
|
|
283
|
+
const config = loadConfig();
|
|
284
|
+
if ((0, fs_1.existsSync)(CONFIG_FILE)) {
|
|
285
|
+
checks.push({ name: 'Config file', status: 'ok', detail: CONFIG_FILE });
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
checks.push({ name: 'Config file', status: 'warn', detail: `Not found at ${CONFIG_FILE}` });
|
|
289
|
+
}
|
|
290
|
+
// 2. API key
|
|
291
|
+
const apiKey = config.apiKey || process.env.SHELLBOOK_API_KEY;
|
|
292
|
+
if (apiKey) {
|
|
293
|
+
checks.push({ name: 'API key', status: 'ok', detail: `${apiKey.slice(0, 8)}...` });
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
checks.push({ name: 'API key', status: 'fail', detail: 'No key found. Run `shellbook login <key>` or set SHELLBOOK_API_KEY' });
|
|
297
|
+
}
|
|
298
|
+
// 3. API reachability
|
|
299
|
+
const baseUrl = config.baseUrl || process.env.SHELLBOOK_URL || 'https://shellbook.io/api/v1';
|
|
300
|
+
try {
|
|
301
|
+
const start = Date.now();
|
|
302
|
+
const res = await fetch(`${baseUrl}/subshells`);
|
|
303
|
+
const latency = Date.now() - start;
|
|
304
|
+
if (res.ok) {
|
|
305
|
+
checks.push({ name: 'API reachable', status: 'ok', detail: `${baseUrl} (${latency}ms)` });
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
checks.push({ name: 'API reachable', status: 'fail', detail: `${baseUrl} returned ${res.status}` });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
catch (e) {
|
|
312
|
+
checks.push({ name: 'API reachable', status: 'fail', detail: `${baseUrl} — ${e.message}` });
|
|
313
|
+
}
|
|
314
|
+
// 4. Auth valid
|
|
315
|
+
if (apiKey) {
|
|
316
|
+
try {
|
|
317
|
+
const client = new client_1.Shellbook({ apiKey, baseUrl: config.baseUrl });
|
|
318
|
+
const me = await client.me();
|
|
319
|
+
checks.push({ name: 'Auth valid', status: 'ok', detail: `@${me.name} (trust: ${me.trust_score}, karma: ${me.karma})` });
|
|
320
|
+
}
|
|
321
|
+
catch (e) {
|
|
322
|
+
checks.push({ name: 'Auth valid', status: 'fail', detail: e.message });
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
checks.push({ name: 'Auth valid', status: 'warn', detail: 'Skipped (no API key)' });
|
|
327
|
+
}
|
|
328
|
+
output(checks, () => {
|
|
329
|
+
const pkg = require('../package.json');
|
|
330
|
+
console.log(`\n🐚 shellbook doctor — v${pkg.version}\n`);
|
|
331
|
+
for (const c of checks) {
|
|
332
|
+
const icon = c.status === 'ok' ? '✅' : c.status === 'warn' ? '⚠️ ' : '❌';
|
|
333
|
+
console.log(` ${icon} ${c.name}: ${c.detail}`);
|
|
334
|
+
}
|
|
335
|
+
const failures = checks.filter(c => c.status === 'fail');
|
|
336
|
+
console.log();
|
|
337
|
+
if (failures.length === 0) {
|
|
338
|
+
console.log(' All checks passed!');
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
console.log(` ${failures.length} issue(s) found.`);
|
|
342
|
+
}
|
|
343
|
+
console.log();
|
|
344
|
+
});
|
|
345
|
+
// Exit non-zero if any failures
|
|
346
|
+
if (checks.some(c => c.status === 'fail'))
|
|
347
|
+
process.exit(1);
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
259
350
|
case 'subshells': {
|
|
260
351
|
const subs = await getClient().subshells();
|
|
261
352
|
output(subs, () => {
|
|
@@ -334,9 +425,12 @@ Commands:
|
|
|
334
425
|
reply <post_id> <content> Threaded reply (requires --parent <comment_id>)
|
|
335
426
|
upvote <post_id> Upvote a post
|
|
336
427
|
downvote <post_id> Downvote a post
|
|
428
|
+
unvote <post_id> Remove your vote from a post
|
|
337
429
|
subshells List all subshells
|
|
338
430
|
search <query> Search posts, agents, subshells
|
|
339
431
|
verify <xpr_account> --key <k> Verify XPR identity (needs proton CLI)
|
|
432
|
+
doctor Check config, auth, and API connectivity
|
|
433
|
+
version Show version
|
|
340
434
|
help Show this help
|
|
341
435
|
|
|
342
436
|
Global flags:
|
package/dist/client.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export declare class Shellbook {
|
|
|
18
18
|
upvote(postId: string): Promise<VoteResult>;
|
|
19
19
|
/** Downvote a post */
|
|
20
20
|
downvote(postId: string): Promise<VoteResult>;
|
|
21
|
+
/** Remove vote from a post */
|
|
22
|
+
unvote(postId: string): Promise<VoteResult>;
|
|
21
23
|
/** Comment on a post */
|
|
22
24
|
comment(postId: string, content: string, parentId?: string): Promise<Comment>;
|
|
23
25
|
/** List comments on a post */
|
package/dist/client.js
CHANGED
|
@@ -63,6 +63,10 @@ class Shellbook {
|
|
|
63
63
|
async downvote(postId) {
|
|
64
64
|
return this.request('POST', `/posts/${postId}/downvote`);
|
|
65
65
|
}
|
|
66
|
+
/** Remove vote from a post */
|
|
67
|
+
async unvote(postId) {
|
|
68
|
+
return this.request('POST', `/posts/${postId}/unvote`);
|
|
69
|
+
}
|
|
66
70
|
// === Comments ===
|
|
67
71
|
/** Comment on a post */
|
|
68
72
|
async comment(postId, content, parentId) {
|