@audiofool/moondog 0.3.0-beta.15 → 0.3.0-beta.17
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 +6 -3
- package/package.json +3 -2
- package/scripts/moondog.mjs +4 -5
- package/src/core/capability-catalog.mjs +24 -14
- package/src/core/host.mjs +30 -0
- package/src/core/library-store.mjs +33 -1
- package/src/core/listening-now.mjs +7 -2
- package/src/core/moondog-application.mjs +219 -143
- package/src/i18n/messages/de.mjs +4 -3
- package/src/i18n/messages/en.mjs +4 -3
- package/src/i18n/messages/es.mjs +4 -3
- package/src/i18n/messages/fr.mjs +4 -3
- package/src/i18n/messages/it.mjs +4 -3
- package/src/i18n/messages/ja.mjs +4 -3
- package/src/i18n/messages/ko.mjs +4 -3
- package/src/i18n/messages/pt.mjs +4 -3
- package/src/i18n/messages/zh-Hant.mjs +4 -3
- package/src/i18n/messages/zh.mjs +4 -3
- package/src/i18n/screen/es.mjs +16 -3
- package/src/i18n/screen/ja.mjs +16 -3
- package/src/i18n/screen/pt.mjs +16 -3
- package/src/i18n/screen/zh.mjs +16 -3
- package/src/importers/zip-reader.mjs +61 -0
- package/src/integrations/apple-music/music-app.mjs +3 -2
- package/src/integrations/lastfm/history.mjs +2 -1
- package/src/integrations/lyrics/lrclib.mjs +1 -1
- package/src/integrations/netease/ncm-cli-player.mjs +62 -20
- package/src/integrations/open-music-similarity/artist-radio.mjs +3 -3
- package/src/integrations/spotify/account-data-history.mjs +63 -57
- package/src/integrations/spotify/authentication.mjs +2 -22
- package/src/integrations/spotify/extended-streaming-history.mjs +48 -40
- package/src/integrations/spotify/history-archive.mjs +2 -13
- package/src/integrations/spotify/service.mjs +62 -57
- package/src/integrations/spotify/web-api-client.mjs +4 -2
- package/src/integrations/user-agent.mjs +6 -0
- package/src/integrations/web/codex-web.mjs +3 -1
- package/src/integrations/youtube-music/takeout.mjs +11 -16
- package/src/profile/history-import.mjs +3 -1
- package/src/runtime/pi/agent-runtime.mjs +138 -136
- package/src/runtime/pi/next-songs.mjs +71 -0
- package/src/runtime/pi/persistent-credential-store.mjs +2 -0
- package/src/surfaces/cli/command-completions.mjs +1 -0
- package/src/surfaces/cli/format-output.mjs +19 -7
- package/src/surfaces/cli/tui.mjs +24 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">Moondog</h1>
|
|
6
6
|
|
|
7
|
-
<p align="center">Source candidate 0.3.0-beta.
|
|
7
|
+
<p align="center">Source candidate 0.3.0-beta.17</p>
|
|
8
8
|
|
|
9
9
|
<p align="center"><strong>On the air, just for you.</strong></p>
|
|
10
10
|
|
|
@@ -42,10 +42,12 @@ See [updating and release channels](docs/UPDATES.md), including the one-time upg
|
|
|
42
42
|
|
|
43
43
|
## On your Mac
|
|
44
44
|
|
|
45
|
-
[Moondog
|
|
45
|
+
[Moondog desktop](app/README.md) is a native window on the same core as the terminal room, with build targets for macOS (Apple silicon), Windows (x64), and Linux (x64).
|
|
46
46
|
It shares your profile, settings, sign-ins, and conversations with `moondog`, and draws its own conversation, now playing, and up next.
|
|
47
47
|
Download the notarized build for Apple silicon from the [project page](https://moondog.audiofool.ai), or run it from this checkout with `cd app && npm ci && npm start`.
|
|
48
48
|
It updates itself, on a Stable or Beta channel you choose in Settings.
|
|
49
|
+
The Windows and Linux desktop builds use Spotify playback and Apple Music previews; full Apple Music songs and reading the Music app require macOS.
|
|
50
|
+
Windows support applies to the desktop app; the terminal launcher and its updater remain supported on macOS and Linux.
|
|
49
51
|
|
|
50
52
|
The [project page](https://moondog.audiofool.ai) plays a short scene in this window, in a browser, with a made-up listener ([how](site/README.md)).
|
|
51
53
|
|
|
@@ -170,7 +172,7 @@ Songs Moondog chose for you do not count as your own taste.
|
|
|
170
172
|
| --- | --- |
|
|
171
173
|
| A model through Pi | Conversation, discovery, and playlists built together. |
|
|
172
174
|
| A web search service | `/web` lookups with links to their sources, through DeepSeek (`/auth deepseek`, which also reads pages), Brave Search (`/auth brave`), or your own signed-in Codex CLI. |
|
|
173
|
-
| Spotify sign-in | Playback, and
|
|
175
|
+
| Spotify sign-in | Playback, and playlists made only when you ask. |
|
|
174
176
|
| NetEase Music | Whole songs through its own `ncm-cli`, for listeners in mainland China. |
|
|
175
177
|
|
|
176
178
|
Your profile never touches the network.
|
|
@@ -186,6 +188,7 @@ Read the [connection and data details](docs/TERMINAL_GUIDE.md) before you connec
|
|
|
186
188
|
`/library save` keeps what is playing, and `/library play Night drive` plays a playlist on the service you chose.
|
|
187
189
|
`/library import <link>` copies a Spotify, Apple Music, NetEase Music or QQ Music playlist into it.
|
|
188
190
|
A playlist you made on Spotify also shapes your taste; for any other one, you decide.
|
|
191
|
+
`/library export Night drive` puts a copy of a playlist on Spotify, and exporting it again updates that copy.
|
|
189
192
|
|
|
190
193
|
## Music it makes
|
|
191
194
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audiofool/moondog",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A local-first AI radio host, just for you.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
"@earendil-works/pi-tui": "1.0.1",
|
|
72
72
|
"ajv": "8.20.0",
|
|
73
73
|
"ajv-formats": "3.0.1",
|
|
74
|
-
"plist": "5.0.0"
|
|
74
|
+
"plist": "5.0.0",
|
|
75
|
+
"yauzl": "3.4.0"
|
|
75
76
|
},
|
|
76
77
|
"devDependencies": {
|
|
77
78
|
"yaml": "2.9.0"
|
package/scripts/moondog.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { execFile } from "node:child_process";
|
|
4
|
-
import { promisify } from "node:util";
|
|
5
3
|
import { createApplicationUpdater } from "../src/core/application-update.mjs";
|
|
4
|
+
import { openInDefaultBrowser } from "../src/core/host.mjs";
|
|
6
5
|
import { runUpdateCommand } from "../src/surfaces/cli/update-command.mjs";
|
|
7
6
|
|
|
8
7
|
import { MoondogApplication } from "../src/core/moondog-application.mjs";
|
|
@@ -407,9 +406,7 @@ async function prepareTuiHistoryImport(filePath, { recentPage, librarySnapshot,
|
|
|
407
406
|
async function openImportHelp(destination) {
|
|
408
407
|
const url = IMPORT_GUIDE_URLS[destination];
|
|
409
408
|
if (!url) throw new Error("Unknown import guide.");
|
|
410
|
-
await
|
|
411
|
-
timeout: 10_000,
|
|
412
|
-
});
|
|
409
|
+
await openInDefaultBrowser(url);
|
|
413
410
|
}
|
|
414
411
|
|
|
415
412
|
function tasteCoverage(profile) {
|
|
@@ -1049,6 +1046,8 @@ async function main() {
|
|
|
1049
1046
|
process.stdout.write(
|
|
1050
1047
|
`${options.json ? JSON.stringify(value, null, 2) : formatLocalResult(options.command, value)}\n`,
|
|
1051
1048
|
);
|
|
1049
|
+
// A failed required check makes the checkup fail, so scripts can rely on it.
|
|
1050
|
+
if (options.command === "doctor" && !value.ok) process.exitCode = 1;
|
|
1052
1051
|
return;
|
|
1053
1052
|
}
|
|
1054
1053
|
|
|
@@ -592,20 +592,6 @@ const catalog = [
|
|
|
592
592
|
label: N_("Change a Spotify playlist"),
|
|
593
593
|
},
|
|
594
594
|
},
|
|
595
|
-
{
|
|
596
|
-
id: "spotify.playlist.write",
|
|
597
|
-
version: "1",
|
|
598
|
-
state: "enabled",
|
|
599
|
-
effect: "write_external",
|
|
600
|
-
description:
|
|
601
|
-
"Create one private Spotify playlist from the exact validated playlist plan explicitly requested by the user.",
|
|
602
|
-
requires_spotify: true,
|
|
603
|
-
requires_playlist_services: true,
|
|
604
|
-
agent_tool: {
|
|
605
|
-
name: "moondog_spotify_playlist_write",
|
|
606
|
-
label: N_("Save the playlist to Spotify"),
|
|
607
|
-
},
|
|
608
|
-
},
|
|
609
595
|
{
|
|
610
596
|
id: "collection.list",
|
|
611
597
|
version: "1",
|
|
@@ -661,6 +647,30 @@ const catalog = [
|
|
|
661
647
|
label: N_("Play from the library"),
|
|
662
648
|
},
|
|
663
649
|
},
|
|
650
|
+
{
|
|
651
|
+
id: "collection.plan_save",
|
|
652
|
+
version: "1",
|
|
653
|
+
state: "enabled",
|
|
654
|
+
effect: "write_external",
|
|
655
|
+
description: "Keep the exact validated playlist plan as a playlist in the listener's library, and send it to Spotify as that playlist's copy when the listener names Spotify.",
|
|
656
|
+
requires_playlist_services: true,
|
|
657
|
+
agent_tool: {
|
|
658
|
+
name: "moondog_playlist_save",
|
|
659
|
+
label: N_("Save the playlist"),
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
id: "collection.export",
|
|
664
|
+
version: "1",
|
|
665
|
+
state: "enabled",
|
|
666
|
+
effect: "write_external",
|
|
667
|
+
description: "Export a playlist from the listener's library to Spotify as a playlist there, or bring the copy an earlier export made up to date.",
|
|
668
|
+
requires_spotify: true,
|
|
669
|
+
agent_tool: {
|
|
670
|
+
name: "moondog_collection_export",
|
|
671
|
+
label: N_("Export a playlist"),
|
|
672
|
+
},
|
|
673
|
+
},
|
|
664
674
|
{
|
|
665
675
|
id: "music.generate.local",
|
|
666
676
|
version: "1",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// What differs between the operating systems the core runs on: the environment's PATH key and
|
|
2
|
+
// how a link opens in the listener's browser.
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
|
|
5
|
+
/** Windows spells the PATH variable as it likes (often "Path"); the others use PATH. */
|
|
6
|
+
export function environmentPathKey(environment) {
|
|
7
|
+
return Object.keys(environment).find((key) => key.toUpperCase() === "PATH") ?? "PATH";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Opens a link in the default browser, and resolves once the opener has started. */
|
|
11
|
+
export function openInDefaultBrowser(url, platform = process.platform) {
|
|
12
|
+
const [command, args] =
|
|
13
|
+
platform === "darwin"
|
|
14
|
+
? ["open", [url]]
|
|
15
|
+
: platform === "win32"
|
|
16
|
+
? ["rundll32", ["url.dll,FileProtocolHandler", url]]
|
|
17
|
+
: ["xdg-open", [url]];
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const child = spawn(command, args, {
|
|
20
|
+
detached: true,
|
|
21
|
+
stdio: "ignore",
|
|
22
|
+
windowsHide: true,
|
|
23
|
+
});
|
|
24
|
+
child.once("error", reject);
|
|
25
|
+
child.once("spawn", () => {
|
|
26
|
+
child.unref();
|
|
27
|
+
resolve();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
// tracks the listener kept, first in the list, never renamed or deleted. An entry keeps what names the song
|
|
8
8
|
// (title, artist, album, ISRC) and the ids each service found for it, so the same playlist plays on whichever
|
|
9
9
|
// service the listener chose, and any one service can be dropped without losing it.
|
|
10
|
+
//
|
|
11
|
+
// A playlist is made and arranged here. A service gets a copy when the listener exports it: library_exports keeps
|
|
12
|
+
// where that copy is and what it held, so the next export brings the same copy up to date instead of making another.
|
|
10
13
|
import { randomUUID } from "node:crypto";
|
|
11
14
|
import { chmod, mkdir } from "node:fs/promises";
|
|
12
15
|
import path from "node:path";
|
|
@@ -53,6 +56,16 @@ const schema = `
|
|
|
53
56
|
added_by TEXT NOT NULL,
|
|
54
57
|
added_at TEXT NOT NULL
|
|
55
58
|
) STRICT;
|
|
59
|
+
CREATE TABLE IF NOT EXISTS library_exports (
|
|
60
|
+
playlist_id TEXT NOT NULL REFERENCES library_playlists(playlist_id) ON DELETE CASCADE,
|
|
61
|
+
provider TEXT NOT NULL,
|
|
62
|
+
remote_id TEXT NOT NULL,
|
|
63
|
+
url TEXT,
|
|
64
|
+
count INTEGER NOT NULL,
|
|
65
|
+
signature TEXT,
|
|
66
|
+
exported_at TEXT NOT NULL,
|
|
67
|
+
PRIMARY KEY (playlist_id, provider)
|
|
68
|
+
) STRICT;
|
|
56
69
|
CREATE INDEX IF NOT EXISTS library_entries_by_playlist ON library_entries(playlist_id, position);
|
|
57
70
|
CREATE INDEX IF NOT EXISTS library_entries_by_made ON library_entries(made_id) WHERE made_id IS NOT NULL;
|
|
58
71
|
`;
|
|
@@ -270,9 +283,12 @@ export class LibraryStore {
|
|
|
270
283
|
const row = this.#database.prepare("SELECT * FROM library_playlists WHERE playlist_id = ?").get(String(id ?? ""));
|
|
271
284
|
if (!row) return null;
|
|
272
285
|
const entries = this.#database.prepare("SELECT * FROM library_entries WHERE playlist_id = ? ORDER BY position, added_at").all(row.playlist_id).map(entryOf);
|
|
286
|
+
const exports = this.#database.prepare("SELECT provider, remote_id, url, count, signature, exported_at FROM library_exports WHERE playlist_id = ? ORDER BY provider")
|
|
287
|
+
.all(row.playlist_id).map((copy) => ({ provider: copy.provider, id: copy.remote_id, url: copy.url ?? null, count: copy.count,
|
|
288
|
+
signature: copy.signature ?? null, exportedAt: copy.exported_at }));
|
|
273
289
|
return { id: row.playlist_id, folderId: row.folder_id ?? null, name: row.name, origin: row.origin,
|
|
274
290
|
...(row.source_json ? { source: JSON.parse(row.source_json) } : {}), createdAt: row.created_at, updatedAt: row.updated_at,
|
|
275
|
-
...(row.playlist_id === SAVED_PLAYLIST_ID ? { saved: true } : {}), entries };
|
|
291
|
+
...(row.playlist_id === SAVED_PLAYLIST_ID ? { saved: true } : {}), ...(exports.length ? { exports } : {}), entries };
|
|
276
292
|
}
|
|
277
293
|
|
|
278
294
|
/** Playlists whose names hold the words, best first, for the agent and the terminal. */
|
|
@@ -455,6 +471,22 @@ export class LibraryStore {
|
|
|
455
471
|
});
|
|
456
472
|
}
|
|
457
473
|
|
|
474
|
+
/**
|
|
475
|
+
* Keeps where a playlist's copy on a service is, after an export: the copy's id and link there, how many songs
|
|
476
|
+
* it took, and a signature of what it held, which tells a later export whether the copy was changed there.
|
|
477
|
+
*/
|
|
478
|
+
rememberExport(playlistId, { provider, id, url, count, signature } = {}) {
|
|
479
|
+
return this.#transaction(() => {
|
|
480
|
+
const playlist = cleanId(playlistId, "Playlist");
|
|
481
|
+
this.#requirePlaylist(playlist);
|
|
482
|
+
this.#database.prepare(`INSERT INTO library_exports(playlist_id, provider, remote_id, url, count, signature, exported_at) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
483
|
+
ON CONFLICT(playlist_id, provider) DO UPDATE SET remote_id = excluded.remote_id, url = excluded.url, count = excluded.count,
|
|
484
|
+
signature = excluded.signature, exported_at = excluded.exported_at`)
|
|
485
|
+
.run(playlist, cleanId(provider, "Service"), cleanId(id, "Copy"), cleanText(url, 400, "Link", { optional: true }),
|
|
486
|
+
Number.isInteger(count) && count >= 0 ? count : 0, cleanText(signature, 128, "Signature", { optional: true }), this.#now());
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
|
|
458
490
|
/** Moves entries, in their order, before another entry or to the end. */
|
|
459
491
|
moveEntries(playlistId, entryIds, beforeId = null) {
|
|
460
492
|
return this.#transaction(() => {
|
|
@@ -156,6 +156,11 @@ export function createPlayerNow() {
|
|
|
156
156
|
if (event?.type === "queue" && Array.isArray(event.tracks)) { this.queued(event.tracks); return; }
|
|
157
157
|
if (!queue) return;
|
|
158
158
|
if (event?.type === "stopped") { queue = null; return; }
|
|
159
|
+
// A song the listener took out of Up next keeps its place, so the positions the player reports still match.
|
|
160
|
+
if (event?.type === "removed") {
|
|
161
|
+
if (Number.isInteger(event.position) && event.position > queue.index + 1 && event.position <= queue.tracks.length) queue.tracks[event.position - 1].removed = true;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
159
164
|
if (Number.isInteger(event?.position) && event.position >= 1 && event.position <= queue.tracks.length) queue.index = event.position - 1;
|
|
160
165
|
if (event?.type === "playing" || event?.type === "paused" || event?.type === "loading") queue.state = event.type;
|
|
161
166
|
},
|
|
@@ -164,7 +169,7 @@ export function createPlayerNow() {
|
|
|
164
169
|
},
|
|
165
170
|
/** The song playing and every one after it, for keeping the whole queue: read() shows only ten. */
|
|
166
171
|
remaining() {
|
|
167
|
-
return queue ? queue.tracks.slice(queue.index).map((track) => ({ ...track })) : [];
|
|
172
|
+
return queue ? queue.tracks.slice(queue.index).filter((track) => !track.removed).map((track) => ({ ...track })) : [];
|
|
168
173
|
},
|
|
169
174
|
/** null when nothing is queued, or { state, song, position, count, next } with up to ten songs after it. */
|
|
170
175
|
read() {
|
|
@@ -175,7 +180,7 @@ export function createPlayerNow() {
|
|
|
175
180
|
song: { ...queue.tracks[queue.index] },
|
|
176
181
|
position: queue.index + 1,
|
|
177
182
|
count: queue.tracks.length,
|
|
178
|
-
next: queue.tracks.slice(queue.index + 1
|
|
183
|
+
next: queue.tracks.slice(queue.index + 1).filter((track) => !track.removed).slice(0, 10).map((track) => ({ ...track })),
|
|
179
184
|
};
|
|
180
185
|
},
|
|
181
186
|
};
|