@rocksky/cli 0.3.1 → 0.3.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/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  🎧 The official command-line interface for [Rocksky](https://rocksky.app) — a modern, decentralized music tracking and discovery platform built on [AT Protocol](https://atproto.com).
4
4
 
5
+ 📚 **[View Full Documentation](https://docs.rocksky.app)**
6
+
7
+ ![Rocksky CLI Preview](./preview.png)
8
+
5
9
  ## Features
6
10
  - 🔐 Authenticate with your Rocksky account using OAuth
7
11
  - 🎵 View your currently playing track
@@ -11,6 +15,7 @@
11
15
  - 🤖 MCP Server
12
16
 
13
17
  ## Table of Contents
18
+ - [Documentation](#documentation)
14
19
  - [Installation](#installation)
15
20
  - [Run in development](#run-in-development)
16
21
  - [Usage](#usage)
@@ -25,6 +30,10 @@
25
30
  - [albums](#albums)
26
31
  - [tracks](#tracks)
27
32
 
33
+ ## Documentation
34
+
35
+ For comprehensive guides, API references, and tutorials, visit the official documentation at **[docs.rocksky.app](https://docs.rocksky.app)**.
36
+
28
37
  ## Installation
29
38
 
30
39
  ```sh
package/dist/index.js CHANGED
@@ -7583,11 +7583,12 @@ async function sync() {
7583
7583
  await subscribeToJetstream(user);
7584
7584
  logger.info` DID: ${did}`;
7585
7585
  logger.info` Handle: ${handle}`;
7586
+ const carReader = await downloadCarFile(agent);
7586
7587
  const [artists, albums, songs, scrobbles] = await Promise.all([
7587
- getRockskyUserArtists(agent),
7588
- getRockskyUserAlbums(agent),
7589
- getRockskyUserSongs(agent),
7590
- getRockskyUserScrobbles(agent)
7588
+ getRockskyUserArtists(agent, carReader),
7589
+ getRockskyUserAlbums(agent, carReader),
7590
+ getRockskyUserSongs(agent, carReader),
7591
+ getRockskyUserScrobbles(agent, carReader)
7591
7592
  ]);
7592
7593
  logger.info` Artists: ${artists.length}`;
7593
7594
  logger.info` Albums: ${albums.length}`;
@@ -8163,14 +8164,16 @@ const onNewScrobble = async (record, cid, uri, user) => {
8163
8164
  user
8164
8165
  );
8165
8166
  };
8166
- const getRockskyUserSongs = async (agent) => {
8167
+ const downloadCarFile = async (agent) => {
8168
+ logger.info(`Fetching repository CAR file ...`);
8169
+ const repoRes = await agent.com.atproto.sync.getRepo({
8170
+ did: agent.assertDid
8171
+ });
8172
+ return CarReader.fromBytes(new Uint8Array(repoRes.data));
8173
+ };
8174
+ const getRockskyUserSongs = async (agent, carReader) => {
8167
8175
  const results = [];
8168
8176
  try {
8169
- logger.info(`Fetching repository CAR file for songs...`);
8170
- const repoRes = await agent.com.atproto.sync.getRepo({
8171
- did: agent.assertDid
8172
- });
8173
- const carReader = await CarReader.fromBytes(new Uint8Array(repoRes.data));
8174
8177
  const collection = "app.rocksky.song";
8175
8178
  for await (const { cid, bytes } of carReader.blocks()) {
8176
8179
  try {
@@ -8200,15 +8203,11 @@ const getRockskyUserSongs = async (agent) => {
8200
8203
  }
8201
8204
  return results;
8202
8205
  };
8203
- const getRockskyUserAlbums = async (agent) => {
8206
+ const getRockskyUserAlbums = async (agent, carReader) => {
8204
8207
  const results = [];
8205
8208
  try {
8206
- logger.info(`Fetching repository CAR file for albums...`);
8207
- const repoRes = await agent.com.atproto.sync.getRepo({
8208
- did: agent.assertDid
8209
- });
8210
- const carReader = await CarReader.fromBytes(new Uint8Array(repoRes.data));
8211
8209
  const collection = "app.rocksky.album";
8210
+ logger.info`Extracting ${collection} records from CAR file ...`;
8212
8211
  for await (const { cid, bytes } of carReader.blocks()) {
8213
8212
  try {
8214
8213
  const decoded = cbor.decode(bytes);
@@ -8237,15 +8236,11 @@ const getRockskyUserAlbums = async (agent) => {
8237
8236
  }
8238
8237
  return results;
8239
8238
  };
8240
- const getRockskyUserArtists = async (agent) => {
8239
+ const getRockskyUserArtists = async (agent, carReader) => {
8241
8240
  const results = [];
8242
8241
  try {
8243
- logger.info(`Fetching repository CAR file for artists...`);
8244
- const repoRes = await agent.com.atproto.sync.getRepo({
8245
- did: agent.assertDid
8246
- });
8247
- const carReader = await CarReader.fromBytes(new Uint8Array(repoRes.data));
8248
8242
  const collection = "app.rocksky.artist";
8243
+ logger.info`Extracting ${collection} records from CAR file ...`;
8249
8244
  for await (const { cid, bytes } of carReader.blocks()) {
8250
8245
  try {
8251
8246
  const decoded = cbor.decode(bytes);
@@ -8273,15 +8268,11 @@ const getRockskyUserArtists = async (agent) => {
8273
8268
  }
8274
8269
  return results;
8275
8270
  };
8276
- const getRockskyUserScrobbles = async (agent) => {
8271
+ const getRockskyUserScrobbles = async (agent, carReader) => {
8277
8272
  const results = [];
8278
8273
  try {
8279
- logger.info(`Fetching repository CAR file for scrobbles...`);
8280
- const repoRes = await agent.com.atproto.sync.getRepo({
8281
- did: agent.assertDid
8282
- });
8283
- const carReader = await CarReader.fromBytes(new Uint8Array(repoRes.data));
8284
8274
  const collection = "app.rocksky.scrobble";
8275
+ logger.info`Extracting ${collection} records from CAR file ...`;
8285
8276
  for await (const { cid, bytes } of carReader.blocks()) {
8286
8277
  try {
8287
8278
  const decoded = cbor.decode(bytes);
@@ -8793,7 +8784,7 @@ async function whoami() {
8793
8784
  }
8794
8785
  }
8795
8786
 
8796
- var version = "0.3.1";
8787
+ var version = "0.3.2";
8797
8788
 
8798
8789
  async function login(handle) {
8799
8790
  const app = express();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocksky/cli",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Command-line interface for Rocksky – scrobble tracks, view stats, and manage your listening history",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/preview.png ADDED
Binary file
package/src/cmd/sync.ts CHANGED
@@ -39,11 +39,13 @@ export async function sync() {
39
39
  logger.info` DID: ${did}`;
40
40
  logger.info` Handle: ${handle}`;
41
41
 
42
+ const carReader = await downloadCarFile(agent);
43
+
42
44
  const [artists, albums, songs, scrobbles] = await Promise.all([
43
- getRockskyUserArtists(agent),
44
- getRockskyUserAlbums(agent),
45
- getRockskyUserSongs(agent),
46
- getRockskyUserScrobbles(agent),
45
+ getRockskyUserArtists(agent, carReader),
46
+ getRockskyUserAlbums(agent, carReader),
47
+ getRockskyUserSongs(agent, carReader),
48
+ getRockskyUserScrobbles(agent, carReader),
47
49
  ]);
48
50
 
49
51
  logger.info` Artists: ${artists.length}`;
@@ -880,7 +882,20 @@ const onNewScrobble = async (
880
882
  );
881
883
  };
882
884
 
883
- const getRockskyUserSongs = async (agent: Agent): Promise<Songs> => {
885
+ const downloadCarFile = async (agent: Agent) => {
886
+ logger.info(`Fetching repository CAR file ...`);
887
+
888
+ const repoRes = await agent.com.atproto.sync.getRepo({
889
+ did: agent.assertDid,
890
+ });
891
+
892
+ return CarReader.fromBytes(new Uint8Array(repoRes.data));
893
+ };
894
+
895
+ const getRockskyUserSongs = async (
896
+ agent: Agent,
897
+ carReader: CarReader,
898
+ ): Promise<Songs> => {
884
899
  const results: {
885
900
  value: Song.Record;
886
901
  uri: string;
@@ -888,13 +903,6 @@ const getRockskyUserSongs = async (agent: Agent): Promise<Songs> => {
888
903
  }[] = [];
889
904
 
890
905
  try {
891
- logger.info(`Fetching repository CAR file for songs...`);
892
-
893
- const repoRes = await agent.com.atproto.sync.getRepo({
894
- did: agent.assertDid,
895
- });
896
-
897
- const carReader = await CarReader.fromBytes(new Uint8Array(repoRes.data));
898
906
  const collection = "app.rocksky.song";
899
907
 
900
908
  for await (const { cid, bytes } of carReader.blocks()) {
@@ -932,7 +940,10 @@ const getRockskyUserSongs = async (agent: Agent): Promise<Songs> => {
932
940
  return results;
933
941
  };
934
942
 
935
- const getRockskyUserAlbums = async (agent: Agent): Promise<Albums> => {
943
+ const getRockskyUserAlbums = async (
944
+ agent: Agent,
945
+ carReader: CarReader,
946
+ ): Promise<Albums> => {
936
947
  const results: {
937
948
  value: Album.Record;
938
949
  uri: string;
@@ -940,16 +951,8 @@ const getRockskyUserAlbums = async (agent: Agent): Promise<Albums> => {
940
951
  }[] = [];
941
952
 
942
953
  try {
943
- logger.info(`Fetching repository CAR file for albums...`);
944
-
945
- // Use getRepo to fetch the entire repository as a CAR file
946
- const repoRes = await agent.com.atproto.sync.getRepo({
947
- did: agent.assertDid,
948
- });
949
-
950
- // Parse the CAR file
951
- const carReader = await CarReader.fromBytes(new Uint8Array(repoRes.data));
952
954
  const collection = "app.rocksky.album";
955
+ logger.info`Extracting ${collection} records from CAR file ...`;
953
956
 
954
957
  for await (const { cid, bytes } of carReader.blocks()) {
955
958
  try {
@@ -984,7 +987,10 @@ const getRockskyUserAlbums = async (agent: Agent): Promise<Albums> => {
984
987
  return results;
985
988
  };
986
989
 
987
- const getRockskyUserArtists = async (agent: Agent): Promise<Artists> => {
990
+ const getRockskyUserArtists = async (
991
+ agent: Agent,
992
+ carReader: CarReader,
993
+ ): Promise<Artists> => {
988
994
  const results: {
989
995
  value: Artist.Record;
990
996
  uri: string;
@@ -992,14 +998,8 @@ const getRockskyUserArtists = async (agent: Agent): Promise<Artists> => {
992
998
  }[] = [];
993
999
 
994
1000
  try {
995
- logger.info(`Fetching repository CAR file for artists...`);
996
-
997
- const repoRes = await agent.com.atproto.sync.getRepo({
998
- did: agent.assertDid,
999
- });
1000
-
1001
- const carReader = await CarReader.fromBytes(new Uint8Array(repoRes.data));
1002
1001
  const collection = "app.rocksky.artist";
1002
+ logger.info`Extracting ${collection} records from CAR file ...`;
1003
1003
 
1004
1004
  for await (const { cid, bytes } of carReader.blocks()) {
1005
1005
  try {
@@ -1034,7 +1034,10 @@ const getRockskyUserArtists = async (agent: Agent): Promise<Artists> => {
1034
1034
  return results;
1035
1035
  };
1036
1036
 
1037
- const getRockskyUserScrobbles = async (agent: Agent): Promise<Scrobbles> => {
1037
+ const getRockskyUserScrobbles = async (
1038
+ agent: Agent,
1039
+ carReader: CarReader,
1040
+ ): Promise<Scrobbles> => {
1038
1041
  const results: {
1039
1042
  value: Scrobble.Record;
1040
1043
  uri: string;
@@ -1042,14 +1045,8 @@ const getRockskyUserScrobbles = async (agent: Agent): Promise<Scrobbles> => {
1042
1045
  }[] = [];
1043
1046
 
1044
1047
  try {
1045
- logger.info(`Fetching repository CAR file for scrobbles...`);
1046
-
1047
- const repoRes = await agent.com.atproto.sync.getRepo({
1048
- did: agent.assertDid,
1049
- });
1050
-
1051
- const carReader = await CarReader.fromBytes(new Uint8Array(repoRes.data));
1052
1048
  const collection = "app.rocksky.scrobble";
1049
+ logger.info`Extracting ${collection} records from CAR file ...`;
1053
1050
 
1054
1051
  for await (const { cid, bytes } of carReader.blocks()) {
1055
1052
  try {