@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
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { N_, screenTranslator } from "../../i18n/index.mjs";
|
|
1
|
+
import { N_, intlLocale, screenTranslator } from "../../i18n/index.mjs";
|
|
2
|
+
import { importHistoryStrings } from "../../i18n/import-history.mjs";
|
|
3
|
+
import { recentListeningPeriod, recordedHistoryThrough } from "./taste-period.mjs";
|
|
4
|
+
import { importSourcePage, utcDay } from "../import-source-history.mjs";
|
|
2
5
|
|
|
3
6
|
export function sanitizeTerminalText(value) {
|
|
4
7
|
return String(value)
|
|
@@ -12,6 +15,71 @@ function words(value) {
|
|
|
12
15
|
return String(value ?? "unknown").replaceAll("_", " ");
|
|
13
16
|
}
|
|
14
17
|
|
|
18
|
+
function importChanges(preview, receipt, tr, locale) {
|
|
19
|
+
if (preview.kind === "library") {
|
|
20
|
+
const labels = importHistoryStrings(locale);
|
|
21
|
+
if (receipt.legacy_unclassified) return labels.appleLegacyMedia;
|
|
22
|
+
const summary = receipt.already_imported ? tr("You've imported this library before, so nothing changed.") : tr.n(receipt.library_tracks ?? preview.tracks,
|
|
23
|
+
"Saved {count} song from your library. A library shows what you keep, not when you played it, so no plays were added.",
|
|
24
|
+
"Saved {count} songs from your library. A library shows what you keep, not when you played it, so no plays were added.");
|
|
25
|
+
return receipt.excluded_non_music > 0 ? `${summary}\n${labels.appleNonMusic} ${tr.number(receipt.excluded_non_music)}` : summary;
|
|
26
|
+
}
|
|
27
|
+
const inserted = receipt.inserted_events ?? 0;
|
|
28
|
+
const duplicates = receipt.duplicate_events ?? 0;
|
|
29
|
+
const upgraded = receipt.upgraded_recording_events ?? 0;
|
|
30
|
+
const superseded = receipt.superseded_events ?? 0;
|
|
31
|
+
const mirrored = receipt.mirrored_events ?? 0;
|
|
32
|
+
const evidence = receipt.inserted_profile_evidence ?? 0;
|
|
33
|
+
const counts = [];
|
|
34
|
+
if (!inserted && !superseded && !mirrored && !evidence && !upgraded) counts.push(tr("Already up to date. There was nothing new in this one."));
|
|
35
|
+
if (superseded || mirrored) {
|
|
36
|
+
const delta = receipt.effective_event_delta ?? inserted - superseded - mirrored;
|
|
37
|
+
if (inserted) counts.push(tr.n(inserted, "Saved {count} new listening record.", "Saved {count} new listening records."));
|
|
38
|
+
counts.push(delta === 0 ? tr("The profile's play count is unchanged.")
|
|
39
|
+
: delta > 0 ? tr.n(delta, "The profile has {count} more play.", "The profile has {count} more plays.")
|
|
40
|
+
: tr.n(-delta, "The profile has {count} fewer play after reconciling overlaps.", "The profile has {count} fewer plays after reconciling overlaps."));
|
|
41
|
+
} else if (inserted) {
|
|
42
|
+
counts.push(tr.n(inserted, "{count} new play.", "{count} new plays."));
|
|
43
|
+
}
|
|
44
|
+
if (duplicates && !upgraded) counts.push(tr.n(duplicates, "Skipped {count} duplicate record.", "Skipped {count} duplicate records."));
|
|
45
|
+
if (evidence) {
|
|
46
|
+
const items = preview.library
|
|
47
|
+
? tr.n(evidence, "{count} saved song, album, follow, playlist entry, or Spotify top pick.", "{count} saved songs, albums, follows, playlist entries, and Spotify top picks.")
|
|
48
|
+
: tr.n(evidence, "{count} saved song, follow, or playlist entry.", "{count} saved songs, follows, or playlist entries.");
|
|
49
|
+
counts.push(counts.length ? tr("Also {items}", { items }) : items);
|
|
50
|
+
}
|
|
51
|
+
if (upgraded) {
|
|
52
|
+
const labels = importHistoryStrings(locale);
|
|
53
|
+
const numbers = new Intl.NumberFormat(intlLocale(locale));
|
|
54
|
+
counts.push([!inserted && !superseded && !mirrored && `${labels.playChange} ${numbers.format(0)}`,
|
|
55
|
+
duplicates && `${labels.duplicates} ${numbers.format(duplicates)}`,
|
|
56
|
+
`${labels.recordingMatches} ${numbers.format(upgraded)}`].filter(Boolean).join(" · "));
|
|
57
|
+
}
|
|
58
|
+
const paragraphs = [counts.join(" ")];
|
|
59
|
+
if (superseded) paragraphs.push(tr.n(superseded, "Reconciled {count} overlapping record, keeping the more detailed listening evidence.",
|
|
60
|
+
"Reconciled {count} overlapping records, keeping the more detailed listening evidence."));
|
|
61
|
+
if (mirrored) paragraphs.push(tr.n(mirrored, "{count} play was already here from another service, so it counts once.",
|
|
62
|
+
"{count} plays were already here from another service, so they count once."));
|
|
63
|
+
return paragraphs.join("\n\n");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The result of one confirmed import, in the listener's language. The caller supplies its own heading. */
|
|
67
|
+
export function formatImportReceipt(preview, receipt, tr = screenTranslator("en"), locale = tr.locale) {
|
|
68
|
+
const dates = [];
|
|
69
|
+
if (preview.kind !== "library" && preview.kind !== "collection") {
|
|
70
|
+
const { earliest_occurred_at = preview.earliestListeningAt, latest_occurred_at = preview.latestListeningAt } = receipt;
|
|
71
|
+
const first = utcDay(earliest_occurred_at), last = utcDay(latest_occurred_at);
|
|
72
|
+
if (first && last && first <= last) dates.push(first === last ? tr("Listening on {date} (UTC).", { date: first })
|
|
73
|
+
: tr("Listening from {first} to {last} (UTC).", { first, last }));
|
|
74
|
+
}
|
|
75
|
+
const imported = utcDay(receipt.imported_at);
|
|
76
|
+
const original = receipt.already_imported ? utcDay(receipt.first_imported_at) : null;
|
|
77
|
+
if (original) dates.push(tr("First import recorded on {date} (UTC).", { date: original }));
|
|
78
|
+
if (imported && imported !== original) dates.push(receipt.already_imported
|
|
79
|
+
? tr("Checked on {date} (UTC).", { date: imported }) : tr("Imported on {date} (UTC).", { date: imported }));
|
|
80
|
+
return [importChanges(preview, receipt, tr, locale), dates.join(" ")].filter(Boolean).join("\n\n");
|
|
81
|
+
}
|
|
82
|
+
|
|
15
83
|
function formatSource(source, tr) {
|
|
16
84
|
if (!source.latest) return `- ${tr("Apple Music library: not imported")}`;
|
|
17
85
|
return [
|
|
@@ -72,9 +140,66 @@ export function formatListeningTime(minutes, tr) {
|
|
|
72
140
|
return tr("{hours} h", { hours: tr.number(Math.round((minutes / 60) * 10) / 10) });
|
|
73
141
|
}
|
|
74
142
|
|
|
143
|
+
export function formatListeningHours(coverage, tr) {
|
|
144
|
+
const hours = coverage.listening_hours;
|
|
145
|
+
if (!Number.isFinite(hours) || hours < 0) return null;
|
|
146
|
+
// The profile rounds hours to tenths even when it has a recorded duration.
|
|
147
|
+
const amount = hours === 0 && coverage.events_with_played_duration > 0 ? `<${tr.number(0.1)}` : tr.number(hours);
|
|
148
|
+
return tr("{hours} h", { hours: amount });
|
|
149
|
+
}
|
|
150
|
+
|
|
75
151
|
function plays(value, tr) { return tr.n(value, "{count} play", "{count} plays"); }
|
|
76
152
|
function tracks(value, tr) { return tr.n(value, "{count} track", "{count} tracks"); }
|
|
77
153
|
|
|
154
|
+
export function profiledListeningMetrics(profile, tr) {
|
|
155
|
+
const coverage = profile?.coverage ?? {};
|
|
156
|
+
const total = coverage.effective_listening_events;
|
|
157
|
+
const playCount = coverage.profiled_listening_events ?? total;
|
|
158
|
+
const sourceTimed = coverage.events_with_played_duration;
|
|
159
|
+
let timedCount = profile?.listening_behavior?.context?.profiled_events_with_played_duration;
|
|
160
|
+
// Older summaries count durations across the whole source. With exclusions, a partial
|
|
161
|
+
// source count cannot tell how many of the listener's profiled plays have a duration.
|
|
162
|
+
if (timedCount == null) {
|
|
163
|
+
if (playCount === 0 || sourceTimed === 0) timedCount = 0;
|
|
164
|
+
else if (playCount === total) timedCount = sourceTimed;
|
|
165
|
+
else if (Number.isSafeInteger(total) && sourceTimed === total) timedCount = playCount;
|
|
166
|
+
}
|
|
167
|
+
const hours = timedCount === 0 ? null : formatListeningHours({
|
|
168
|
+
listening_hours: coverage.listening_hours, events_with_played_duration: timedCount,
|
|
169
|
+
}, tr);
|
|
170
|
+
return { playCount, timedCount, hours };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function collectionCoverageLines(coverage = {}, tr = screenTranslator("en")) {
|
|
174
|
+
const positive = value => Number.isSafeInteger(value) && value > 0;
|
|
175
|
+
const lines = [];
|
|
176
|
+
if (positive(coverage.tracks_observed)) {
|
|
177
|
+
const count = tracks(coverage.tracks_observed, tr);
|
|
178
|
+
const loved = coverage.loved_or_favorited;
|
|
179
|
+
lines.push(Number.isSafeInteger(loved) && loved >= 0
|
|
180
|
+
? tr("Apple Music library: {tracks} · {loved} loved", { tracks: count, loved: tr.number(loved) })
|
|
181
|
+
: tr("Apple Music library: {tracks}", { tracks: count }));
|
|
182
|
+
}
|
|
183
|
+
const sources = coverage.collection_sources ?? [];
|
|
184
|
+
const services = new Set(sources.filter(source => positive(source.tracks)).map(source => source.label));
|
|
185
|
+
if (services.size > 1 && positive(coverage.collection_tracks)) {
|
|
186
|
+
lines.push(tr("{songs} across {count} services", { songs: tr.n(coverage.collection_tracks, "{count} song", "{count} songs"), count: services.size }));
|
|
187
|
+
}
|
|
188
|
+
for (const source of sources) {
|
|
189
|
+
const details = [];
|
|
190
|
+
if (positive(source.tracks)) details.push(tracks(source.tracks, tr));
|
|
191
|
+
if (positive(source.saved_albums)) details.push(tr.n(source.saved_albums, "{count} saved album", "{count} saved albums"));
|
|
192
|
+
if (positive(source.followed_artists)) details.push(tr.n(source.followed_artists, "{count} followed artist", "{count} followed artists"));
|
|
193
|
+
if (details.length) lines.push(`${safeInlineText(source.label)}: ${details.join(" · ")}`);
|
|
194
|
+
}
|
|
195
|
+
const saved = coverage.saved_tracks ?? coverage.spotify_saved_tracks;
|
|
196
|
+
if (positive(saved)) lines.push(tr.n(saved, "{count} saved track", "{count} saved tracks"));
|
|
197
|
+
const memberships = coverage.playlist_memberships ?? coverage.spotify_playlist_memberships;
|
|
198
|
+
if (positive(memberships)) lines.push(tr.n(memberships, "{count} song on your playlists", "{count} songs on your playlists"));
|
|
199
|
+
if (!lines.length && positive(coverage.collection_tracks)) lines.push(tracks(coverage.collection_tracks, tr));
|
|
200
|
+
return lines;
|
|
201
|
+
}
|
|
202
|
+
|
|
78
203
|
function formatArtistSignal(item, tr) {
|
|
79
204
|
const details = [];
|
|
80
205
|
if (Number.isInteger(item.play_count)) details.push(plays(item.play_count, tr));
|
|
@@ -148,6 +273,13 @@ function formatTimeCapsuleTrack(item, tr) {
|
|
|
148
273
|
);
|
|
149
274
|
}
|
|
150
275
|
|
|
276
|
+
function formatLeadingArtist(name, playCount, tr) {
|
|
277
|
+
const artist = safeInlineText(name);
|
|
278
|
+
if (!artist) return null;
|
|
279
|
+
const label = tr("a leading artist was {artist}", { artist });
|
|
280
|
+
return Number.isInteger(playCount) ? `${label} (${plays(playCount, tr)})` : label;
|
|
281
|
+
}
|
|
282
|
+
|
|
151
283
|
function formatHistoryArc(item, tr) {
|
|
152
284
|
const details = [];
|
|
153
285
|
if (Number.isFinite(item.listening_minutes)) details.push(formatListeningTime(item.listening_minutes, tr));
|
|
@@ -156,8 +288,8 @@ function formatHistoryArc(item, tr) {
|
|
|
156
288
|
if (Number.isInteger(item.first_observed_tracks) && item.first_observed_tracks > 0) {
|
|
157
289
|
details.push(tr("{count} new", { count: tr.number(item.first_observed_tracks) }));
|
|
158
290
|
}
|
|
159
|
-
const
|
|
160
|
-
if (
|
|
291
|
+
const artist = formatLeadingArtist(item.top_artist?.name, item.top_artist?.play_count, tr);
|
|
292
|
+
if (artist) details.push(artist);
|
|
161
293
|
return `- ${Number.isInteger(item.year) ? item.year : tr("Unknown year")}${details.length > 0 ? ` · ${details.join(", ")}` : ""}`;
|
|
162
294
|
}
|
|
163
295
|
|
|
@@ -173,7 +305,7 @@ function formatListeningSeason(item, tr) {
|
|
|
173
305
|
plays(item.event_count, tr),
|
|
174
306
|
Number.isInteger(item.first_observed_tracks) && item.first_observed_tracks > 0
|
|
175
307
|
? tr("{count} new", { count: tr.number(item.first_observed_tracks) }) : null,
|
|
176
|
-
|
|
308
|
+
formatLeadingArtist(item.leading_artist?.name, item.leading_artist?.event_count, tr),
|
|
177
309
|
signature ? tr("top song {song}", { song: `${signature}${signatureArtist ? ` - ${signatureArtist}` : ""}` }) : null,
|
|
178
310
|
]);
|
|
179
311
|
}
|
|
@@ -205,7 +337,8 @@ function formatBehaviorContextLine(value, total, label, tr) {
|
|
|
205
337
|
// Section names are Pink Floyd titles and stay as they are; their subtitles are translated.
|
|
206
338
|
function formatTaste(profile, tr) {
|
|
207
339
|
const coverage = profile.coverage ?? {};
|
|
208
|
-
const
|
|
340
|
+
const { playCount, timedCount, hours } = profiledListeningMetrics(profile, tr);
|
|
341
|
+
const durationUnavailable = timedCount === 0;
|
|
209
342
|
const listeningSignal = (formatter) => (item) => formatter(durationUnavailable ? { ...item, listening_minutes: undefined } : item, tr);
|
|
210
343
|
const signal = (formatter) => (item) => formatter(item, tr);
|
|
211
344
|
const behavior = profile.listening_behavior ?? {};
|
|
@@ -217,9 +350,6 @@ function formatTaste(profile, tr) {
|
|
|
217
350
|
? tr("{first} to {last}", { first: listeningRange.earliest.slice(0, 10), last: listeningRange.latest.slice(0, 10) })
|
|
218
351
|
: null;
|
|
219
352
|
const oneOff = profile.preview_source?.persistent_import === false;
|
|
220
|
-
const hours = !durationUnavailable && Number.isFinite(coverage.listening_hours)
|
|
221
|
-
? tr("{hours} h", { hours: tr.number(coverage.listening_hours) })
|
|
222
|
-
: null;
|
|
223
353
|
const lines = [
|
|
224
354
|
`# ${tr("Your listening, so far")}`,
|
|
225
355
|
"",
|
|
@@ -231,23 +361,19 @@ function formatTaste(profile, tr) {
|
|
|
231
361
|
"",
|
|
232
362
|
];
|
|
233
363
|
const summary = [
|
|
234
|
-
Number.isInteger(
|
|
364
|
+
Number.isInteger(playCount) ? plays(playCount, tr) : null,
|
|
235
365
|
hours,
|
|
236
366
|
Number.isInteger(coverage.listening_tracks) ? tracks(coverage.listening_tracks, tr) : null,
|
|
237
367
|
].filter(Boolean);
|
|
238
|
-
|
|
368
|
+
const collection = collectionCoverageLines(coverage, tr);
|
|
369
|
+
const collectionOnly = playCount === 0 && collection.length > 0;
|
|
370
|
+
if (summary.length > 0 && !collectionOnly) lines.push(`- ${summary.join(" · ")}`);
|
|
239
371
|
if (range) lines.push(`- ${range}`);
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
if (source.tracks > 0) lines.push(`- ${safeInlineText(source.label)}: ${tracks(source.tracks, tr)}`);
|
|
246
|
-
}
|
|
247
|
-
if (!durationUnavailable && Number.isInteger(coverage.events_with_played_duration) &&
|
|
248
|
-
Number.isInteger(coverage.effective_listening_events) &&
|
|
249
|
-
coverage.events_with_played_duration < coverage.effective_listening_events) {
|
|
250
|
-
lines.push(`- ${tr("Listening time is known for {count} of those plays", { count: tr.number(coverage.events_with_played_duration) })}`);
|
|
372
|
+
lines.push(...collection.map(line => `- ${line}`));
|
|
373
|
+
const snapshotDate = coverage.tracks_observed > 0 && utcDay(profile.source?.captured_at);
|
|
374
|
+
if (snapshotDate) lines.push(`- ${tr("Library as of {date}", { date: snapshotDate })}`);
|
|
375
|
+
if (timedCount > 0 && timedCount < playCount) {
|
|
376
|
+
lines.push(`- ${tr("Listening time is known for {count} of those plays", { count: tr.number(timedCount) })}`);
|
|
251
377
|
}
|
|
252
378
|
if (Number.isInteger(coverage.cross_format_track_links) && coverage.cross_format_track_links > 0) {
|
|
253
379
|
lines.push(`- ${tr.n(coverage.cross_format_track_links, "{count} track matched across your two Spotify exports", "{count} tracks matched across your two Spotify exports")}`);
|
|
@@ -260,29 +386,28 @@ function formatTaste(profile, tr) {
|
|
|
260
386
|
}
|
|
261
387
|
|
|
262
388
|
appendTasteSection(lines, tr("What you told me"), profile.listener_assertions?.active, signal(formatListenerAssertion));
|
|
389
|
+
const recentPeriod = recentListeningPeriod(profile, tr);
|
|
263
390
|
appendTasteSection(lines, "Shine On", behavior.enduring_artists, listeningSignal(formatArtistSignal),
|
|
264
|
-
tr("
|
|
265
|
-
appendTasteSection(lines, tr("Lately"), behavior.recent_artists, listeningSignal(formatArtistSignal),
|
|
266
|
-
Number.isInteger(context.recent_window_days)
|
|
267
|
-
? tr("Who you've played most in the last {count} days", { count: context.recent_window_days })
|
|
268
|
-
: tr("Who you've played most recently"));
|
|
391
|
+
tr("Top artists across your recorded history"));
|
|
392
|
+
appendTasteSection(lines, tr("Lately"), behavior.recent_artists, listeningSignal(formatArtistSignal), recentPeriod);
|
|
269
393
|
appendTasteSection(lines, tr("Year by year"), behavior.history_arc, listeningSignal(formatHistoryArc));
|
|
270
394
|
const listeningSeasons = behavior.listening_seasons?.seasons;
|
|
271
395
|
appendTasteSection(lines, tr("Seasons"), Array.isArray(listeningSeasons) ? listeningSeasons.slice(-12) : [],
|
|
272
396
|
listeningSignal(formatListeningSeason),
|
|
273
397
|
tr("Your last twelve quarters. \"New\" means new to your history, not necessarily new to you."));
|
|
274
398
|
appendTasteSection(lines, "Time", behavior.time_capsule_tracks, signal(formatTimeCapsuleTrack), tr("The years, one track each"));
|
|
399
|
+
const quietSongs = Number.isInteger(context.rediscovery_quiet_days)
|
|
400
|
+
? tr("Frequent plays followed by {count}+ days without a recorded play", { count: context.rediscovery_quiet_days })
|
|
401
|
+
: tr("Gone quiet");
|
|
275
402
|
appendTasteSection(lines, "Wish You Were Here", behavior.rediscovery_tracks, signal(formatRediscoveryTrack),
|
|
276
|
-
|
|
277
|
-
? tr("Songs you used to play a lot that have gone quiet for {count}+ days", { count: context.rediscovery_quiet_days })
|
|
278
|
-
: tr("Songs you used to play a lot that have gone quiet"));
|
|
403
|
+
`${quietSongs} · ${recordedHistoryThrough(profile, tr)}`);
|
|
279
404
|
appendTasteSection(lines, "Coming Back to Life", behavior.historical_return_tracks, signal(formatHistoricalReturnTrack),
|
|
280
405
|
Number.isInteger(context.historical_return_minimum_gap_days)
|
|
281
406
|
? tr("Songs that found their way back after {count}+ days away", { count: context.historical_return_minimum_gap_days })
|
|
282
407
|
: tr("Songs that found their way back after long gaps"));
|
|
283
408
|
appendTasteSection(lines, "Echoes", behavior.back_to_back_tracks, signal(formatBackToBackTrack), tr("Songs you played again right away"));
|
|
284
409
|
appendTasteSection(lines, tr("Most played"), behavior.repeat_tracks, listeningSignal(formatTrackSignal));
|
|
285
|
-
appendTasteSection(lines, tr("Recently"), behavior.recent_tracks, listeningSignal(formatTrackSignal));
|
|
410
|
+
appendTasteSection(lines, tr("Recently"), behavior.recent_tracks, listeningSignal(formatTrackSignal), recentPeriod);
|
|
286
411
|
|
|
287
412
|
const behaviorContextLines = [
|
|
288
413
|
formatBehaviorContextLine(context.direct_selection_starts, context.start_reason_events, tr("Songs you picked yourself"), tr),
|
|
@@ -307,7 +432,8 @@ function formatTaste(profile, tr) {
|
|
|
307
432
|
"",
|
|
308
433
|
`*${tr("What this reading can't see")}*`,
|
|
309
434
|
"",
|
|
310
|
-
`- ${tr("
|
|
435
|
+
`- ${collectionOnly ? tr("A library shows what you keep, not every play")
|
|
436
|
+
: tr("Plays show attention, not love. A song can be on repeat because it was stuck in your head.")}`,
|
|
311
437
|
...(behaviorContextLines.length > 0 ? [`- ${tr("A skip is a moment, not a verdict.")}`] : []),
|
|
312
438
|
...((behavior.history_arc ?? []).length > 0 || (listeningSeasons ?? []).length > 0
|
|
313
439
|
? [`- ${tr("Years and seasons follow UTC, so a late night can land on the next day.")}`,
|
|
@@ -367,6 +493,9 @@ function formatReflectionProposal(proposal) {
|
|
|
367
493
|
if (proposal.action === "candidate_music_profile") {
|
|
368
494
|
return `- [music-profile/${proposal.direction}/${proposal.confidence}] ${proposal.dimension}: ${proposal.value}\n Evidence: ${evidence}\n Why: ${proposal.rationale}`;
|
|
369
495
|
}
|
|
496
|
+
if (proposal.action === "candidate_skill") {
|
|
497
|
+
return `- [learned-skill/${proposal.assertion_mode}/${proposal.confidence}] ${proposal.name}: ${proposal.description}\n Evidence: ${evidence}\n Why: ${proposal.rationale}`;
|
|
498
|
+
}
|
|
370
499
|
return `- [ignore] ${proposal.reason}\n Episodes: ${evidence}`;
|
|
371
500
|
}
|
|
372
501
|
|
|
@@ -386,6 +515,8 @@ export function formatMemoryReflection(value) {
|
|
|
386
515
|
`- Proposals: ${counts.proposals ?? value.proposals?.length ?? 0}`,
|
|
387
516
|
`- ${dryRun ? "Would promote durable memories" : "Durable memories promoted"}: ${counts.promoted_memories ?? 0}`,
|
|
388
517
|
`- ${dryRun ? "Would create durable memories" : "New durable memories"}: ${counts.created_memories ?? 0}`,
|
|
518
|
+
`- ${dryRun ? "Would promote learned practices" : "Learned practices promoted"}: ${counts.promoted_skills ?? 0}`,
|
|
519
|
+
`- ${dryRun ? "Would create learned practices" : "New learned practices"}: ${counts.created_skills ?? 0}`,
|
|
389
520
|
`- ${dryRun ? "Would become candidate episodes" : "Candidate episodes"}: ${counts.candidate_episodes ?? 0}`,
|
|
390
521
|
`- ${dryRun ? "Would ignore episodes" : "Ignored episodes"}: ${counts.ignored_episodes ?? 0}`,
|
|
391
522
|
];
|
|
@@ -400,6 +531,32 @@ export function formatMemoryReflection(value) {
|
|
|
400
531
|
return lines.join("\n");
|
|
401
532
|
}
|
|
402
533
|
|
|
534
|
+
export function formatLearnedSkills(skills) {
|
|
535
|
+
if (skills.length === 0) return "No learned practices yet.";
|
|
536
|
+
return [
|
|
537
|
+
"# Learned practices",
|
|
538
|
+
"",
|
|
539
|
+
...skills.map((skill) =>
|
|
540
|
+
`- ${skill.name} (revision ${skill.revision}): ${safeInlineText(skill.description)}`),
|
|
541
|
+
].join("\n");
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export function formatLearnedSkill(skill) {
|
|
545
|
+
const lines = [
|
|
546
|
+
`# ${skill.name}`,
|
|
547
|
+
"",
|
|
548
|
+
safeInlineText(skill.description),
|
|
549
|
+
"",
|
|
550
|
+
`- Revision: ${skill.revision}`,
|
|
551
|
+
`- Origin: ${skill.origin}`,
|
|
552
|
+
`- Updated: ${skill.updated_at}`,
|
|
553
|
+
`- Evidence episodes: ${skill.evidence_episode_ids.length}`,
|
|
554
|
+
];
|
|
555
|
+
if (skill.status === "archived") lines.push(`- Archived: ${skill.archived_at}`);
|
|
556
|
+
lines.push("", "## Instructions", "", sanitizeTerminalText(skill.instructions));
|
|
557
|
+
return lines.join("\n");
|
|
558
|
+
}
|
|
559
|
+
|
|
403
560
|
export function formatDemoResult(value) {
|
|
404
561
|
const lines = [
|
|
405
562
|
"# Moondog demo",
|
|
@@ -525,11 +682,27 @@ function formatSpotifyStatus(spotify, tr) {
|
|
|
525
682
|
: `- ${words(state)}`;
|
|
526
683
|
}
|
|
527
684
|
|
|
685
|
+
function formatSources(history, locale, command) {
|
|
686
|
+
const page = importSourcePage(history, locale);
|
|
687
|
+
const lines = [`# ${page.title}`];
|
|
688
|
+
const steps = [[page.previous, page.previousOffset], [page.next, page.nextOffset]];
|
|
689
|
+
const links = steps.filter(([, offset]) => offset !== null).map(([label, offset]) => `${label} \`${command} ${offset}\``);
|
|
690
|
+
const position = [page.position, ...links].filter(Boolean).join(" · ");
|
|
691
|
+
if (position) lines.push(position);
|
|
692
|
+
for (const entry of page.entries) {
|
|
693
|
+
lines.push("", `**${entry.title}**`, ...[entry.dates, entry.effects, entry.note].filter(Boolean));
|
|
694
|
+
}
|
|
695
|
+
if (page.note) lines.push("", page.note);
|
|
696
|
+
return lines.join("\n");
|
|
697
|
+
}
|
|
698
|
+
|
|
528
699
|
/** Local command output. The TUI passes its translator; the shell CLI uses English. */
|
|
529
|
-
export function formatLocalResult(command, value, tr = screenTranslator("en")) {
|
|
700
|
+
export function formatLocalResult(command, value, tr = screenTranslator("en"), { sourcesCommand = "moondog sources", locale = tr.locale } = {}) {
|
|
530
701
|
switch (command) {
|
|
531
|
-
case "status":
|
|
532
702
|
case "sources":
|
|
703
|
+
return value.importSourceHistory ? formatSources(value.importSourceHistory, locale, sourcesCommand)
|
|
704
|
+
: formatLocalResult("status", value, tr);
|
|
705
|
+
case "status":
|
|
533
706
|
return [
|
|
534
707
|
`# ${tr("Where things stand")}`,
|
|
535
708
|
"",
|
|
@@ -570,5 +743,5 @@ export function formatLocalResult(command, value, tr = screenTranslator("en")) {
|
|
|
570
743
|
}
|
|
571
744
|
|
|
572
745
|
export function helpText(tr = screenTranslator("en")) {
|
|
573
|
-
return tr("# Every command\n\nFrom your shell:\n\n- `moondog --version` - show the installed version\n- `moondog update [--check] [--channel latest|beta]` - check for or install a published release\n- `moondog web status|search|read [arguments] [--json]` - look things up on public music sites through DeepSeek, Brave Search or the Codex CLI\n- `moondog demo-history --output <absolute-file.zip> [--json]` - make a fictional Spotify history ZIP to try the importer with\n- `moondog auth login <provider>` - sign in to a model provider; the key is typed out of sight; `openai --chatgpt` signs in with your ChatGPT subscription\n- `moondog auth status [provider]` - see which sign-ins are saved\n- `moondog auth logout <provider>` - sign out of a provider\n- `moondog spotify help` - set up and control Spotify\n- `moondog spotify login [client-id]` - connect Spotify in your browser\n- `moondog spotify now|devices|queue` - see what Spotify is playing, where, and what's next\n- `moondog spotify recent` - see what you played lately\n- `moondog spotify sync-recent` - add your latest plays to your profile\n- `moondog spotify sync-library` - add your Spotify library to your profile\n- `moondog spotify play|pause|next|previous` - control Spotify playback\n- `moondog listenbrainz import-history <listen-history.json>` - add a ListenBrainz listens file to your profile\n- `moondog catalog latest-single --artist <name> [--known-release <title> | --from <spotify-history.zip>]` - find an artist's latest single on Apple Music (US), no model needed\n- `moondog status [--json]` - see where things stand\n- `moondog taste [--json]` - your listening report\n- `moondog taste --html [--output <file.html>]` - save your report as a web page that works offline\n- `moondog taste --card [--output <file.html>]` - save a short recap you can check before sharing\n- `moondog taste --from <spotify-history.zip> --html` - a one-off report from a Spotify ZIP, without saving it\n- `moondog taste --from <account-data.zip> --from <extended-history.zip> --html` - a one-off report from both Spotify exports together\n- `moondog taste --from <spotify-history.zip> --save --html` - save the Spotify history, then show your full report\n- `moondog data inspect --scope <listening|apple|profile>` - see what's stored, and get the code needed to reset it\n- `moondog data export --scope <listening|apple|profile> --output <directory>` - export a copy, leaving the original alone\n- `moondog data reset --scope <listening|apple|profile> --confirm <token>` - set stored data aside (it is archived, not deleted)\n- `moondog profile build [--force]` - build or resume a saved profile with your connected model\n- `moondog profile saved [offset]` - read your saved profile\n- `moondog profile explain <number>` - trace a saved finding to its evidence\n- `moondog profile corrections [--all]` - everything you've told me, including earlier choices\n- `moondog profile correct --artist <name> (--like|--avoid)` - like an artist, or keep them out\n- `moondog profile correct --track <title> --by <artist> (--like|--avoid)` - like a track, or keep it out\n- `moondog profile retract <correction-id>` - undo one of your choices\n- `moondog demo --offline [--json]` - a demo with made-up data, no sign-in needed\n- `moondog demo [prompt] [--json]` - the same demo, talking through your model\n- `moondog ask <prompt>` - ask one question and exit\n- `moondog remember <text>` - ask me to remember something\n- `moondog forget <memory-id>` - forget something\n- `moondog memory reflect [--dry-run] [--json]` - let me think over recent conversations now\n- `moondog` - open the listening room\n\nInside the listening room:\n\n- `/update [--check] [--channel latest|beta]` - check for updates, or save and close this session to install one\n- `/status`
|
|
746
|
+
return tr("# Every command\n\nFrom your shell:\n\n- `moondog --version` - show the installed version\n- `moondog update [--check] [--channel latest|beta]` - check for or install a published release\n- `moondog web status|search|read [arguments] [--json]` - look things up on public music sites through DeepSeek, Brave Search or the Codex CLI\n- `moondog demo-history --output <absolute-file.zip> [--json]` - make a fictional Spotify history ZIP to try the importer with\n- `moondog auth login <provider>` - sign in to a model provider; the key is typed out of sight; `openai --chatgpt` signs in with your ChatGPT subscription\n- `moondog auth status [provider]` - see which sign-ins are saved\n- `moondog auth logout <provider>` - sign out of a provider\n- `moondog spotify help` - set up and control Spotify\n- `moondog spotify login [client-id]` - connect Spotify in your browser\n- `moondog spotify now|devices|queue` - see what Spotify is playing, where, and what's next\n- `moondog spotify recent` - see what you played lately\n- `moondog spotify sync-recent` - add your latest plays to your profile\n- `moondog spotify sync-library` - add your Spotify library to your profile\n- `moondog spotify play|pause|next|previous` - control Spotify playback\n- `moondog listenbrainz import-history <listen-history.json>` - add a ListenBrainz listens file to your profile\n- `moondog catalog latest-single --artist <name> [--known-release <title> | --from <spotify-history.zip>]` - find an artist's latest single on Apple Music (US), no model needed\n- `moondog status [--json]` - see where things stand\n- `moondog sources [offset] [--json]` - see your import history\n- `moondog taste [--json]` - your listening report\n- `moondog taste --html [--output <file.html>]` - save your report as a web page that works offline\n- `moondog taste --card [--output <file.html>]` - save a short recap you can check before sharing\n- `moondog taste --from <spotify-history.zip> --html` - a one-off report from a Spotify ZIP, without saving it\n- `moondog taste --from <account-data.zip> --from <extended-history.zip> --html` - a one-off report from both Spotify exports together\n- `moondog taste --from <spotify-history.zip> --save --html` - save the Spotify history, then show your full report\n- `moondog data inspect --scope <listening|apple|profile>` - see what's stored, and get the code needed to reset it\n- `moondog data export --scope <listening|apple|profile> --output <directory>` - export a copy, leaving the original alone\n- `moondog data reset --scope <listening|apple|profile> --confirm <token>` - set stored data aside (it is archived, not deleted)\n- `moondog profile build [--force]` - build or resume a saved profile with your connected model\n- `moondog profile saved [offset]` - read your saved profile\n- `moondog profile explain <number>` - trace a saved finding to its evidence\n- `moondog profile corrections [--all]` - everything you've told me, including earlier choices\n- `moondog profile correct --artist <name> (--like|--avoid)` - like an artist, or keep them out\n- `moondog profile correct --track <title> --by <artist> (--like|--avoid)` - like a track, or keep it out\n- `moondog profile retract <correction-id>` - undo one of your choices\n- `moondog demo --offline [--json]` - a demo with made-up data, no sign-in needed\n- `moondog demo [prompt] [--json]` - the same demo, talking through your model\n- `moondog ask <prompt>` - ask one question and exit\n- `moondog remember <text>` - ask me to remember something\n- `moondog forget <memory-id>` - forget something\n- `moondog memory reflect [--dry-run] [--json]` - let me think over recent conversations now\n- `moondog` - open the listening room\n\nInside the listening room:\n\n- `/update [--check] [--channel latest|beta]` - check for updates, or save and close this session to install one\n- `/status` - see where things stand\n- `/sources [offset]` - see your import history\n- `/profile` or `/taste` - your profile, and why each song or artist is there\n- `/taste report` - the whole report on one page\n- `/profile build [--force]` - build or resume a saved reading; Ctrl+C keeps progress\n- `/profile saved [offset]` - read your saved profile\n- `/profile explain <number>` - inspect a saved finding's evidence\n- `/profile corrections [--all]` - everything you've told me\n- `/profile correct --track \"<title>\" --by \"<artist>\" (--like|--avoid)` - like a track, or keep it out\n- `/profile correct --artist \"<name>\" (--like|--avoid)` - like an artist, or keep them out\n- `/profile retract <correction-id>` - undo a choice\n- `/memory` - what I remember\n- `/tools` - what I can do right now\n- `/doctor` - check your setup\n- `/model` - pick the model I talk through\n- `/model <provider> <model>` - switch straight to a model\n- `/model refresh [provider]` - update public model choices; keep the selected model\n- `/model roles` - see what side tasks use: the model that reads images and the web search service\n- `/model vision auto|<provider> <model>` - choose the model that reads images\n- `/model web auto|deepseek|brave|codex` - choose the web search service\n- `/effort` - choose how hard the model thinks\n- `/auth [provider]` - sign in to a model provider\n- `/endpoint add` or `/endpoint remove <id>` - add a model service by its address, or remove it\n- `/web status|search|read` - look things up on public music sites\n- `/import [path]` - bring in your history, library, or a playlist\n- `/library` - your saved songs and playlists\n- `/library play <name>` - play a playlist\n- `/library save [playlist]` - keep the song playing now\n- `/library import <link>` - copy a playlist from a link\n- `/library export <name>` - send a playlist to Spotify\n- `/generation on|off` - turn Stable Audio 3 on or off. Moondog can write a score when it is off\n- `/generation download|use|remove|cancel` - set up a Stable Audio 3 model\n- `/onair` - go on air, or come off it\n- `/language` - choose the language Moondog uses\n- `/service [spotify|apple_music|netease]` - choose where I play music\n- `/spotify` - Spotify commands\n- `/spotify login [client-id]` - connect Spotify\n- `/spotify now|devices|queue` - see what's playing, where, and what's next\n- `/spotify recent|sync-recent` - see or save your latest plays\n- `/spotify import-history \"/path/to/spotify-history.zip\"` - add a Spotify ZIP, no sign-in needed\n- `/skip` or `/stop` - skip the current track or stop playback (Spotify pauses its active device)\n- `/home` - back to the record sleeve; the conversation stays\n- `/theme paper|charcoal|terminal|auto` - change the look\n- `/art braille|ascii|off` - change the artwork\n- `/motion on|off` - turn the animation on or off\n- `/lyrics` - the lyrics on the sleeve; `/lyrics sync` finds more\n- `/reload` - reload model settings and sign-ins\n- `/remember [kind] <text>` - ask me to remember something\n- `/forget <memory-id>` - forget something\n- `/rewind` or Alt+R - edit an earlier message in place; the messages after it are replaced\n- `/branch` - go on from here in a new conversation; this one stays saved\n- `/rewind latest` - edit the most recent message\n- `/resume` - pick up a saved conversation\n- `/resume <session-id>` - go straight to one\n- `/new` - start fresh; the last one stays saved\n- `/quit` - exit\n\nAnything you type that isn't a command goes to the model you picked with `/model`, or the one set in `MOONDOG_PROVIDER` and `MOONDOG_MODEL`.\nSign in with `/auth`, or set the provider's API key in your environment. `/auth openai` signs in with your ChatGPT subscription or an API key.\nOnce your profile is ready, I can search your library, explain what I see, and plan playlists with you.\nI can only control Spotify after `moondog spotify login`. I ask before I remove anything from your library, and I never post, send messages, or spend money.\nAsk me to move playback onto a device by name, such as your iPhone.");
|
|
574
747
|
}
|