@audiofool/moondog 0.4.0-beta.2 → 0.4.0-beta.4
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 +19 -8
- package/package.json +1 -1
- package/scripts/moondog.mjs +130 -106
- package/src/core/apple-library-source-status.mjs +64 -18
- package/src/core/apple-projection-domain-services.mjs +67 -52
- package/src/core/capability-catalog.mjs +18 -2
- package/src/core/import-source-history.mjs +28 -0
- package/src/core/library-draft.mjs +16 -0
- package/src/core/library-names.mjs +12 -0
- package/src/core/library-store.mjs +361 -23
- package/src/core/listener-avoids.mjs +31 -0
- package/src/core/listening-action.mjs +41 -0
- package/src/core/listening-moment.mjs +67 -0
- package/src/core/listening-now.mjs +69 -28
- package/src/core/listening-profile-domain-services.mjs +32 -18
- package/src/core/listening-scope.mjs +119 -0
- package/src/core/moondog-application.mjs +1045 -270
- package/src/core/play-follower.mjs +104 -0
- package/src/core/portable-playlist.mjs +125 -0
- package/src/core/profile-discovery-draft.mjs +35 -0
- package/src/core/track-title.mjs +70 -4
- package/src/i18n/import-history.mjs +647 -0
- package/src/i18n/messages/de.mjs +3 -3
- package/src/i18n/messages/en.mjs +3 -3
- package/src/i18n/messages/es.mjs +3 -3
- package/src/i18n/messages/fr.mjs +3 -3
- package/src/i18n/messages/it.mjs +3 -3
- package/src/i18n/messages/ja.mjs +3 -3
- package/src/i18n/messages/ko.mjs +3 -3
- package/src/i18n/messages/pt.mjs +3 -3
- package/src/i18n/messages/zh-Hant.mjs +3 -3
- package/src/i18n/messages/zh.mjs +3 -3
- package/src/i18n/screen/es.mjs +90 -26
- package/src/i18n/screen/ja.mjs +89 -25
- package/src/i18n/screen/pt.mjs +90 -26
- package/src/i18n/screen/zh.mjs +89 -25
- package/src/importers/apple-music-library/import-batch.mjs +64 -32
- package/src/importers/apple-music-library/normalize.mjs +36 -6
- package/src/importers/apple-music-library/save-time.mjs +17 -0
- package/src/importers/zip-reader.mjs +24 -2
- package/src/integrations/apple-music/catalog-playlist-reader.mjs +111 -0
- package/src/integrations/apple-music/catalog.mjs +84 -25
- package/src/integrations/apple-music/music-app-listening.mjs +107 -0
- package/src/integrations/apple-music/music-app.mjs +6 -2
- package/src/integrations/apple-music/song-id.mjs +13 -0
- package/src/integrations/apple-music/terminal-preview-player.mjs +154 -44
- package/src/integrations/listenbrainz/history-file.mjs +63 -35
- package/src/integrations/netease/ncm-cli-player.mjs +355 -68
- package/src/integrations/netease/queue-occurrence.mjs +138 -0
- package/src/integrations/playlist-links.mjs +93 -30
- package/src/integrations/public-playlists.mjs +21 -15
- package/src/integrations/spotify/account-data-history.mjs +9 -10
- package/src/integrations/spotify/account-data-profile.mjs +1 -0
- package/src/integrations/spotify/extended-streaming-history.mjs +57 -52
- package/src/integrations/spotify/history-archive.mjs +8 -18
- package/src/integrations/spotify/library-snapshot.mjs +2 -1
- package/src/integrations/spotify/service.mjs +29 -11
- package/src/integrations/spotify/web-api-client.mjs +2 -2
- package/src/integrations/stable-audio/local-generator.mjs +13 -5
- package/src/integrations/youtube-music/takeout.mjs +12 -8
- package/src/memory/local-memory-store.mjs +479 -27
- package/src/memory/reflection-worker.mjs +19 -0
- package/src/profile/apple-library-import.mjs +56 -2
- package/src/profile/history-import.mjs +58 -27
- package/src/profile/listener-corrections.mjs +2 -4
- package/src/profile/listener-profile-build.mjs +133 -46
- package/src/profile/listener-profile-store.mjs +57 -4
- package/src/profile/listener-profile-verification.mjs +11 -5
- package/src/profile/listener-profile-worker.mjs +36 -10
- package/src/profile/listening-history-store.mjs +975 -354
- package/src/profile/listening-profile-projection.mjs +130 -160
- package/src/profile/local-file-import.mjs +172 -0
- package/src/profile/moondog-suggestions.mjs +40 -11
- package/src/profile/profile-exploration.mjs +36 -6
- package/src/profile/recorded-measures.mjs +5 -0
- package/src/profile/spotify-archive-taste.mjs +41 -65
- package/src/runtime/pi/agent-runtime.mjs +368 -221
- package/src/runtime/pi/custom-endpoints.mjs +30 -8
- package/src/runtime/pi/memory-agent-runtime.mjs +45 -3
- package/src/runtime/pi/moondog-model.mjs +6 -0
- package/src/runtime/pi/playback-rules.mjs +100 -0
- package/src/runtime/pi/profile-build-runtime.mjs +85 -24
- package/src/surfaces/cli/brand-components.mjs +9 -6
- package/src/surfaces/cli/command-completions.mjs +8 -1
- package/src/surfaces/cli/format-output.mjs +207 -34
- package/src/surfaces/cli/history-import-view.mjs +130 -21
- package/src/surfaces/cli/listenbrainz-command.mjs +7 -2
- package/src/surfaces/cli/listener-profile-command.mjs +67 -8
- package/src/surfaces/cli/listening-menu.mjs +3 -0
- package/src/surfaces/cli/profile-command.mjs +1 -0
- package/src/surfaces/cli/spotify-command.mjs +17 -25
- package/src/surfaces/cli/taste-period.mjs +22 -0
- package/src/surfaces/cli/taste-profile-model.mjs +52 -32
- package/src/surfaces/cli/tui.mjs +557 -170
- package/src/surfaces/html/tasteprint.mjs +181 -93
- package/src/surfaces/import-source-history.mjs +80 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { importHistoryStrings } from "../i18n/import-history.mjs";
|
|
2
|
+
import { MUSIC_PROVIDER_LABELS } from "../profile/music-providers.mjs";
|
|
3
|
+
|
|
4
|
+
export function utcDay(value) {
|
|
5
|
+
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}(?:T[\d:.]+(?:Z|[+-]\d{2}:\d{2}))?$/u.test(value)) return null;
|
|
6
|
+
const time = Date.parse(value);
|
|
7
|
+
return Number.isFinite(time) ? new Date(time).toISOString().slice(0, 10) : null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function sourceTitle(record, labels) {
|
|
11
|
+
switch (record.sourceFormat) {
|
|
12
|
+
case "apple-music-library": return labels.apple;
|
|
13
|
+
case "spotify_account_data_streaming_history_v1": return "Spotify Account Data";
|
|
14
|
+
case "spotify_account_data_music_profile_v1": return `Spotify Account Data · ${labels.collection}`;
|
|
15
|
+
case "spotify_extended_streaming_history_music_v1": return "Spotify Extended Streaming History";
|
|
16
|
+
case "spotify_quick_import_v1": return record.dataScope === "recent_listening_and_library" ? labels.quickLibrary : labels.quickRecent;
|
|
17
|
+
case "spotify_playlist_music_v1": return `Spotify · ${labels.playlist}`;
|
|
18
|
+
case "apple_music_playlist_music_v1": return `Apple Music · ${labels.playlist}`;
|
|
19
|
+
case "spotify_web_api_library_v1": return `Spotify · ${labels.collection}`;
|
|
20
|
+
case "listenbrainz_listen_json_v1": return "ListenBrainz JSON";
|
|
21
|
+
case "youtube_music_music_v1": return "YouTube Music · Google Takeout";
|
|
22
|
+
default: return MUSIC_PROVIDER_LABELS[String(record.sourceKey ?? "").split(".")[0]] ?? labels.history;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function importEntry(record, labels, number) {
|
|
27
|
+
const dates = [], effects = [];
|
|
28
|
+
const dated = (key, value) => { if (value) dates.push(`${labels[key]} ${value} (UTC)`); };
|
|
29
|
+
const count = (key, value) => { if (Number.isSafeInteger(value)) effects.push(`${labels[key]} ${number(value)}`); };
|
|
30
|
+
const saved = utcDay(record.importedAt);
|
|
31
|
+
if (record.sourceFormat === "apple-music-library") {
|
|
32
|
+
dated("observed", utcDay(record.observedAt));
|
|
33
|
+
dated("saved", saved);
|
|
34
|
+
count("songs", record.trackCount);
|
|
35
|
+
} else {
|
|
36
|
+
const first = utcDay(record.earliestOccurredAt), last = utcDay(record.latestOccurredAt);
|
|
37
|
+
dated("readAt", utcDay(record.observedAt));
|
|
38
|
+
if (record.kind === "listening" && first && last && first <= last) dated("listening", first === last ? first : `${first} – ${last}`);
|
|
39
|
+
if (record.alreadyImported || record.legacy) dated("first", utcDay(record.firstImportedAt) ?? (record.legacy ? saved : null));
|
|
40
|
+
if (!record.legacy) dated(record.alreadyImported ? "checked" : "saved", saved);
|
|
41
|
+
if (record.kind === "listening" && Number.isSafeInteger(record.inputRecords)) {
|
|
42
|
+
count("input", record.inputRecords);
|
|
43
|
+
count("inserted", record.insertedEvents);
|
|
44
|
+
count("duplicates", record.duplicateEvents);
|
|
45
|
+
if (record.inputRecords > 0 && Number.isSafeInteger(record.eventsWithPlayedMs)) {
|
|
46
|
+
effects.push(`${labels.duration} ${number(record.eventsWithPlayedMs)}/${number(record.inputRecords)}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (record.supersededEvents > 0) count("reconciled", record.supersededEvents);
|
|
50
|
+
if (record.mirroredEvents > 0) count("mirrored", record.mirroredEvents);
|
|
51
|
+
if (record.kind === "listening" && Number.isSafeInteger(record.effectiveEventDelta)) {
|
|
52
|
+
const delta = record.effectiveEventDelta;
|
|
53
|
+
effects.push(`${labels.playChange} ${delta > 0 ? "+" : ""}${number(delta)}`);
|
|
54
|
+
}
|
|
55
|
+
if (record.inputProfileEvidence > 0 || record.kind === "collection") {
|
|
56
|
+
count("collectionRead", record.inputProfileEvidence);
|
|
57
|
+
count("collectionAdded", record.insertedProfileEvidence);
|
|
58
|
+
} else if (record.insertedProfileEvidence > 0) count("collectionAdded", record.insertedProfileEvidence);
|
|
59
|
+
}
|
|
60
|
+
return { title: sourceTitle(record, labels), dates: dates.join(" · "), effects: effects.join(" · "),
|
|
61
|
+
note: record.legacy ? labels.legacy : "" };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Both listening rooms describe the same stored receipts; the native controls and terminal commands stay separate. */
|
|
65
|
+
export function importSourcePage(history, locale) {
|
|
66
|
+
const labels = importHistoryStrings(locale);
|
|
67
|
+
const number = new Intl.NumberFormat(locale ?? "en").format;
|
|
68
|
+
const { items, offset, nextOffset, total, collectionState } = history;
|
|
69
|
+
const entries = items.map(record => importEntry(record, labels, number));
|
|
70
|
+
let note = "";
|
|
71
|
+
if (collectionState === "multiple_subjects") note = labels.multiple;
|
|
72
|
+
else if (collectionState === "unavailable") note = labels.unavailable;
|
|
73
|
+
if (!entries.length && total > 0) note = [labels.beyond, note].filter(Boolean).join(" ");
|
|
74
|
+
if (!entries.length && !note) note = labels.none;
|
|
75
|
+
return { title: labels.heading, entries, note,
|
|
76
|
+
position: entries.length ? `${number(offset + 1)}–${number(offset + entries.length)} / ${number(total)}` : "",
|
|
77
|
+
previous: labels.previous, next: labels.next,
|
|
78
|
+
previousOffset: offset > 0 && total > 0 ? Math.min(Math.max(0, offset - 12), Math.floor((total - 1) / 12) * 12) : null,
|
|
79
|
+
nextOffset: nextOffset ?? null };
|
|
80
|
+
}
|