···11+ Apache License
22+ Version 2.0, January 2004
33+ http://www.apache.org/licenses/
44+55+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
66+77+ 1. Definitions.
88+99+ "License" shall mean the terms and conditions for use, reproduction,
1010+ and distribution as defined by Sections 1 through 9 of this document.
1111+1212+ "Licensor" shall mean the copyright owner or entity authorized by
1313+ the copyright owner that is granting the License.
1414+1515+ "Legal Entity" shall mean the union of the acting entity and all
1616+ other entities that control, are controlled by, or are under common
1717+ control with that entity. For the purposes of this definition,
1818+ "control" means (i) the power, direct or indirect, to cause the
1919+ direction or management of such entity, whether by contract or
2020+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
2121+ outstanding shares, or (iii) beneficial ownership of such entity.
2222+2323+ "You" (or "Your") shall mean an individual or Legal Entity
2424+ exercising permissions granted by this License.
2525+2626+ "Source" form shall mean the preferred form for making modifications,
2727+ including but not limited to software source code, documentation
2828+ source, and configuration files.
2929+3030+ "Object" form shall mean any form resulting from mechanical
3131+ transformation or translation of a Source form, including but
3232+ not limited to compiled object code, generated documentation,
3333+ and conversions to other media types.
3434+3535+ "Work" shall mean the work of authorship, whether in Source or
3636+ Object form, made available under the License, as indicated by a
3737+ copyright notice that is included in or attached to the work
3838+ (an example is provided in the Appendix below).
3939+4040+ "Derivative Works" shall mean any work, whether in Source or Object
4141+ form, that is based on (or derived from) the Work and for which the
4242+ editorial revisions, annotations, elaborations, or other modifications
4343+ represent, as a whole, an original work of authorship. For the purposes
4444+ of this License, Derivative Works shall not include works that remain
4545+ separable from, or merely link (or bind by name) to the interfaces of,
4646+ the Work and Derivative Works thereof.
4747+4848+ "Contribution" shall mean any work of authorship, including
4949+ the original version of the Work and any modifications or additions
5050+ to that Work or Derivative Works thereof, that is intentionally
5151+ submitted to Licensor for inclusion in the Work by the copyright owner
5252+ or by an individual or Legal Entity authorized to submit on behalf of
5353+ the copyright owner. For the purposes of this definition, "submitted"
5454+ means any form of electronic, verbal, or written communication sent
5555+ to the Licensor or its representatives, including but not limited to
5656+ communication on electronic mailing lists, source code control systems,
5757+ and issue tracking systems that are managed by, or on behalf of, the
5858+ Licensor for the purpose of discussing and improving the Work, but
5959+ excluding communication that is conspicuously marked or otherwise
6060+ designated in writing by the copyright owner as "Not a Contribution."
6161+6262+ "Contributor" shall mean Licensor and any individual or Legal Entity
6363+ on behalf of whom a Contribution has been received by Licensor and
6464+ subsequently incorporated within the Work.
6565+6666+ 2. Grant of Copyright License. Subject to the terms and conditions of
6767+ this License, each Contributor hereby grants to You a perpetual,
6868+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
6969+ copyright license to reproduce, prepare Derivative Works of,
7070+ publicly display, publicly perform, sublicense, and distribute the
7171+ Work and such Derivative Works in Source or Object form.
7272+7373+ 3. Grant of Patent License. Subject to the terms and conditions of
7474+ this License, each Contributor hereby grants to You a perpetual,
7575+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
7676+ (except as stated in this section) patent license to make, have made,
7777+ use, offer to sell, sell, import, and otherwise transfer the Work,
7878+ where such license applies only to those patent claims licensable
7979+ by such Contributor that are necessarily infringed by their
8080+ Contribution(s) alone or by combination of their Contribution(s)
8181+ with the Work to which such Contribution(s) was submitted. If You
8282+ institute patent litigation against any entity (including a
8383+ cross-claim or counterclaim in a lawsuit) alleging that the Work
8484+ or a Contribution incorporated within the Work constitutes direct
8585+ or contributory patent infringement, then any patent licenses
8686+ granted to You under this License for that Work shall terminate
8787+ as of the date such litigation is filed.
8888+8989+ 4. Redistribution. You may reproduce and distribute copies of the
9090+ Work or Derivative Works thereof in any medium, with or without
9191+ modifications, and in Source or Object form, provided that You
9292+ meet the following conditions:
9393+9494+ (a) You must give any other recipients of the Work or
9595+ Derivative Works a copy of this License; and
9696+9797+ (b) You must cause any modified files to carry prominent notices
9898+ stating that You changed the files; and
9999+100100+ (c) You must retain, in the Source form of any Derivative Works
101101+ that You distribute, all copyright, patent, trademark, and
102102+ attribution notices from the Source form of the Work,
103103+ excluding those notices that do not pertain to any part of
104104+ the Derivative Works; and
105105+106106+ (d) If the Work includes a "NOTICE" text file as part of its
107107+ distribution, then any Derivative Works that You distribute must
108108+ include a readable copy of the attribution notices contained
109109+ within such NOTICE file, excluding those notices that do not
110110+ pertain to any part of the Derivative Works, in at least one
111111+ of the following places: within a NOTICE text file distributed
112112+ as part of the Derivative Works; within the Source form or
113113+ documentation, if provided along with the Derivative Works; or,
114114+ within a display generated by the Derivative Works, if and
115115+ wherever such third-party notices normally appear. The contents
116116+ of the NOTICE file are for informational purposes only and
117117+ do not modify the License. You may add Your own attribution
118118+ notices within Derivative Works that You distribute, alongside
119119+ or as an addendum to the NOTICE text from the Work, provided
120120+ that such additional attribution notices cannot be construed
121121+ as modifying the License.
122122+123123+ You may add Your own copyright statement to Your modifications and
124124+ may provide additional or different license terms and conditions
125125+ for use, reproduction, or distribution of Your modifications, or
126126+ for any such Derivative Works as a whole, provided Your use,
127127+ reproduction, and distribution of the Work otherwise complies with
128128+ the conditions stated in this License.
129129+130130+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131131+ any Contribution intentionally submitted for inclusion in the Work
132132+ by You to the Licensor shall be under the terms and conditions of
133133+ this License, without any additional terms or conditions.
134134+ Notwithstanding the above, nothing herein shall supersede or modify
135135+ the terms of any separate license agreement you may have executed
136136+ with Licensor regarding such Contributions.
137137+138138+ 6. Trademarks. This License does not grant permission to use the trade
139139+ names, trademarks, service marks, or product names of the Licensor,
140140+ except as required for reasonable and customary use in describing the
141141+ origin of the Work and reproducing the content of the NOTICE file.
142142+143143+ 7. Disclaimer of Warranty. Unless required by applicable law or
144144+ agreed to in writing, Licensor provides the Work (and each
145145+ Contributor provides its Contributions) on an "AS IS" BASIS,
146146+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147147+ implied, including, without limitation, any warranties or conditions
148148+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149149+ PARTICULAR PURPOSE. You are solely responsible for determining the
150150+ appropriateness of using or redistributing the Work and assume any
151151+ risks associated with Your exercise of permissions under this License.
152152+153153+ 8. Limitation of Liability. In no event and under no legal theory,
154154+ whether in tort (including negligence), contract, or otherwise,
155155+ unless required by applicable law (such as deliberate and grossly
156156+ negligent acts) or agreed to in writing, shall any Contributor be
157157+ liable to You for damages, including any direct, indirect, special,
158158+ incidental, or consequential damages of any character arising as a
159159+ result of this License or out of the use or inability to use the
160160+ Work (including but not limited to damages for loss of goodwill,
161161+ work stoppage, computer failure or malfunction, or any and all
162162+ other commercial damages or losses), even if such Contributor
163163+ has been advised of the possibility of such damages.
164164+165165+ 9. Accepting Warranty or Additional Liability. While redistributing
166166+ the Work or Derivative Works thereof, You may choose to offer,
167167+ and charge a fee for, acceptance of support, warranty, indemnity,
168168+ or other liability obligations and/or rights consistent with this
169169+ License. However, in accepting such obligations, You may act only
170170+ on Your own behalf and on Your sole responsibility, not on behalf
171171+ of any other Contributor, and only if You agree to indemnify,
172172+ defend, and hold each Contributor harmless for any liability
173173+ incurred by, or claims asserted against, such Contributor by reason
174174+ of your accepting any such warranty or additional liability.
175175+176176+ END OF TERMS AND CONDITIONS
177177+178178+ APPENDIX: How to apply the Apache License to your work.
179179+180180+ To apply the Apache License to your work, attach the following
181181+ boilerplate notice, with the fields enclosed by brackets "[]"
182182+ replaced with your own identifying information. (Don't include
183183+ the brackets!) The text should be enclosed in the appropriate
184184+ comment syntax for the file format. We also recommend that a
185185+ file or class name and description of purpose be included on the
186186+ same "printed page" as the copyright notice for easier
187187+ identification within third-party archives.
188188+189189+ Copyright 2025 Tsiry Sandratraina
190190+191191+ Licensed under the Apache License, Version 2.0 (the "License");
192192+ you may not use this file except in compliance with the License.
193193+ You may obtain a copy of the License at
194194+195195+ http://www.apache.org/licenses/LICENSE-2.0
196196+197197+ Unless required by applicable law or agreed to in writing, software
198198+ distributed under the License is distributed on an "AS IS" BASIS,
199199+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200+ See the License for the specific language governing permissions and
201201+ limitations under the License.
+31
README.md
···11+## Rocksky CLI
22+33+🎧 The official command-line interface for [Rocksky](https://rocksky.app) — a modern, decentralized music tracking and discovery platform built on the AT Protocol.
44+55+## Features
66+- 🔐 Authenticate with your Rocksky account using OAuth
77+- 🎵 View your currently playing track
88+- 📈 See your recent scrobbles
99+- 📤 Manually scrobble tracks
1010+- 🛠️ Useful developer tools for integrating Rocksky into your workflows
1111+1212+## Usage
1313+1414+```bash
1515+rocksky <command> [options]
1616+```
1717+1818+## Available Commands
1919+2020+`login` - Initiates a browser-based OAuth login flow and saves your access token securely on your machine.
2121+2222+```bash
2323+rocksky login
2424+```
2525+2626+`nowplaying` - Displays the currently playing track on your/other Rocksky account.
2727+2828+```bash
2929+rocksky nowplaying
3030+```
3131+
···11+import axios from "axios";
22+import chalk from "chalk";
33+import cors from "cors";
44+import express, { Request, Response } from "express";
55+import fs from "fs/promises";
66+import open from "open";
77+import os from "os";
88+import path from "path";
99+1010+export async function login(handle: string): Promise<void> {
1111+ const app = express();
1212+ app.use(cors());
1313+ app.use(express.json());
1414+1515+ const server = app.listen(6996);
1616+1717+ app.post("/token", async (req: Request, res: Response) => {
1818+ console.log(chalk.bold(chalk.greenBright("Login successful!\n")));
1919+ console.log(
2020+ "You can use this session key (Token) to authenticate with the API."
2121+ );
2222+ console.log("Received token (session key):", chalk.green(req.body.token));
2323+2424+ const tokenPath = path.join(os.homedir(), ".rocksky", "token.json");
2525+ await fs.mkdir(path.dirname(tokenPath), { recursive: true });
2626+ await fs.writeFile(
2727+ tokenPath,
2828+ JSON.stringify({ token: req.body.token }, null, 2)
2929+ );
3030+3131+ res.json({
3232+ ok: 1,
3333+ });
3434+3535+ server.close();
3636+ });
3737+3838+ const response = await axios.post("https://api.rocksky.app/login", {
3939+ handle,
4040+ cli: true,
4141+ });
4242+4343+ const redirectUrl = response.data;
4444+4545+ if (!redirectUrl.includes("authorize")) {
4646+ console.error("Failed to login, please check your handle and try again.");
4747+ server.close();
4848+ return;
4949+ }
5050+5151+ console.log("Please visit this URL to authorize the app:");
5252+ console.log(chalk.cyan(redirectUrl));
5353+5454+ open(redirectUrl);
5555+}
+57
src/cmd/nowplaying.ts
···11+import chalk from "chalk";
22+import { RockskyClient } from "client";
33+import fs from "fs/promises";
44+import os from "os";
55+import path from "path";
66+77+export async function nowplaying(did?: string) {
88+ const tokenPath = path.join(os.homedir(), ".rocksky", "token.json");
99+ try {
1010+ await fs.access(tokenPath);
1111+ } catch (err) {
1212+ console.error(
1313+ `You are not logged in. Please run ${chalk.greenBright(
1414+ "`rocksky login <username>.bsky.social`"
1515+ )} first.`
1616+ );
1717+ return;
1818+ }
1919+2020+ const tokenData = await fs.readFile(tokenPath, "utf-8");
2121+ const { token } = JSON.parse(tokenData);
2222+ if (!token) {
2323+ console.error(
2424+ `You are not logged in. Please run ${chalk.greenBright(
2525+ "`rocksky login <username>.bsky.social`"
2626+ )} first.`
2727+ );
2828+ return;
2929+ }
3030+3131+ const client = new RockskyClient(token);
3232+ try {
3333+ const nowPlaying = await client.getSpotifyNowPlaying(did);
3434+ if (!nowPlaying || Object.keys(nowPlaying).length === 0) {
3535+ const nowPlaying = await client.getNowPlaying(did);
3636+ if (!nowPlaying || Object.keys(nowPlaying).length === 0) {
3737+ console.log("No track is currently playing.");
3838+ return;
3939+ }
4040+ console.log(`${nowPlaying.title} - ${nowPlaying.artist}`);
4141+ console.log(`${nowPlaying.album}`);
4242+ return;
4343+ }
4444+4545+ console.log(
4646+ `${nowPlaying.item.name} - ${nowPlaying.item.artists
4747+ .map((a) => a.name)
4848+ .join(", ")}`
4949+ );
5050+ console.log(`${nowPlaying.item.album.name}`);
5151+ } catch (err) {
5252+ console.log(err);
5353+ console.error(
5454+ `Failed to fetch now playing data. Please check your token and try again.`
5555+ );
5656+ }
5757+}
+45
src/cmd/whoami.ts
···11+import chalk from "chalk";
22+import { RockskyClient } from "client";
33+import fs from "fs/promises";
44+import os from "os";
55+import path from "path";
66+77+export async function whoami() {
88+ const tokenPath = path.join(os.homedir(), ".rocksky", "token.json");
99+ try {
1010+ await fs.access(tokenPath);
1111+ } catch (err) {
1212+ console.error(
1313+ `You are not logged in. Please run ${chalk.greenBright(
1414+ "`rocksky login <username>.bsky.social`"
1515+ )} first.`
1616+ );
1717+ return;
1818+ }
1919+2020+ const tokenData = await fs.readFile(tokenPath, "utf-8");
2121+ const { token } = JSON.parse(tokenData);
2222+ if (!token) {
2323+ console.error(
2424+ `You are not logged in. Please run ${chalk.greenBright(
2525+ "`rocksky login <username>.bsky.social`"
2626+ )} first.`
2727+ );
2828+ return;
2929+ }
3030+3131+ const client = new RockskyClient(token);
3232+ try {
3333+ const user = await client.getCurrentUser();
3434+ console.log(`You are logged in as ${user.handle} (${user.displayName}).`);
3535+ console.log(
3636+ `View your profile at: ${chalk.magenta(
3737+ `https://rocksky.app/profile/${user.handle}`
3838+ )}`
3939+ );
4040+ } catch (err) {
4141+ console.error(
4242+ `Failed to fetch user data. Please check your token and try again.`
4343+ );
4444+ }
4545+}
+36
src/index.ts
···11+import { nowplaying } from "cmd/nowplaying";
22+import { whoami } from "cmd/whoami";
33+import { Command } from "commander";
44+import version from "../package.json" assert { type: "json" };
55+import { login } from "./cmd/login";
66+77+const program = new Command();
88+99+program
1010+ .name("rocksky")
1111+ .description(
1212+ "Command-line interface for Rocksky – scrobble tracks, view stats, and manage your listening history."
1313+ )
1414+ .version(version.version);
1515+1616+program
1717+ .command("login")
1818+ .argument("<handle>", "Your BlueSky handle (e.g., <username>.bsky.social)")
1919+ .description("Login with your BlueSky account and get a session token.")
2020+ .action(login);
2121+2222+program
2323+ .command("whoami")
2424+ .description("Get the current logged-in user.")
2525+ .action(whoami);
2626+2727+program
2828+ .command("nowplaying")
2929+ .argument(
3030+ "[did]",
3131+ "The DID or handle of the user to get the now playing track for."
3232+ )
3333+ .description("Get the currently playing track.")
3434+ .action(nowplaying);
3535+3636+program.parse(process.argv);