/ clis / bluesky / thread.js
thread.js
 1  import { cli, Strategy } from '@jackwener/opencli/registry';
 2  cli({
 3      site: 'bluesky',
 4      name: 'thread',
 5      description: 'Get a Bluesky post thread with replies',
 6      domain: 'public.api.bsky.app',
 7      strategy: Strategy.PUBLIC,
 8      browser: false,
 9      args: [
10          {
11              name: 'uri',
12              required: true,
13              positional: true,
14              help: 'Post AT URI (at://did:.../app.bsky.feed.post/...) or bsky.app URL',
15          },
16          { name: 'limit', type: 'int', default: 20, help: 'Number of replies' },
17      ],
18      columns: ['author', 'text', 'likes', 'reposts', 'replies_count'],
19      pipeline: [
20          { fetch: { url: 'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread?uri=${{ args.uri }}&depth=2' } },
21          { select: 'thread' },
22          { map: {
23                  author: '${{ item.post.author.handle }}',
24                  text: '${{ item.post.record.text }}',
25                  likes: '${{ item.post.likeCount }}',
26                  reposts: '${{ item.post.repostCount }}',
27                  replies_count: '${{ item.post.replyCount }}',
28              } },
29      ],
30  });