@audiofool/moondog 0.3.0-beta.9 → 0.3.1

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.
Files changed (69) hide show
  1. package/README.md +100 -136
  2. package/package.json +9 -7
  3. package/scripts/moondog.mjs +47 -9
  4. package/src/core/apple-projection-domain-services.mjs +4 -0
  5. package/src/core/capability-catalog.mjs +46 -14
  6. package/src/core/host.mjs +30 -0
  7. package/src/core/library-store.mjs +82 -6
  8. package/src/core/listening-now.mjs +7 -2
  9. package/src/core/listening-profile-domain-services.mjs +4 -0
  10. package/src/core/moondog-application.mjs +412 -144
  11. package/src/i18n/messages/de.mjs +4 -3
  12. package/src/i18n/messages/en.mjs +4 -3
  13. package/src/i18n/messages/es.mjs +4 -3
  14. package/src/i18n/messages/fr.mjs +4 -3
  15. package/src/i18n/messages/it.mjs +4 -3
  16. package/src/i18n/messages/ja.mjs +4 -3
  17. package/src/i18n/messages/ko.mjs +4 -3
  18. package/src/i18n/messages/pt.mjs +4 -3
  19. package/src/i18n/messages/zh-Hant.mjs +4 -3
  20. package/src/i18n/messages/zh.mjs +4 -3
  21. package/src/i18n/screen/es.mjs +54 -7
  22. package/src/i18n/screen/ja.mjs +54 -7
  23. package/src/i18n/screen/pt.mjs +54 -7
  24. package/src/i18n/screen/zh.mjs +54 -7
  25. package/src/importers/zip-reader.mjs +61 -0
  26. package/src/integrations/apple-music/music-app.mjs +3 -2
  27. package/src/integrations/lastfm/history.mjs +2 -1
  28. package/src/integrations/lyrics/lrclib.mjs +1 -1
  29. package/src/integrations/netease/ncm-cli-player.mjs +62 -20
  30. package/src/integrations/open-music-similarity/artist-radio.mjs +3 -3
  31. package/src/integrations/playlist-links.mjs +114 -0
  32. package/src/integrations/public-playlists.mjs +41 -8
  33. package/src/integrations/spotify/account-data-history.mjs +63 -57
  34. package/src/integrations/spotify/authentication.mjs +2 -22
  35. package/src/integrations/spotify/extended-streaming-history.mjs +48 -40
  36. package/src/integrations/spotify/history-archive.mjs +2 -13
  37. package/src/integrations/spotify/service.mjs +88 -58
  38. package/src/integrations/spotify/web-api-client.mjs +12 -4
  39. package/src/integrations/user-agent.mjs +6 -0
  40. package/src/integrations/web/codex-web.mjs +3 -1
  41. package/src/integrations/web/deepseek-web.mjs +1 -1
  42. package/src/integrations/web/moondog-web.mjs +57 -0
  43. package/src/integrations/web/web-research.mjs +106 -22
  44. package/src/integrations/web/web-result.mjs +61 -12
  45. package/src/integrations/youtube-music/takeout.mjs +11 -16
  46. package/src/profile/history-import.mjs +3 -1
  47. package/src/profile/listening-history-store.mjs +55 -1
  48. package/src/profile/listening-profile-projection.mjs +1 -1
  49. package/src/profile/music-import-bundle.mjs +3 -1
  50. package/src/profile/music-providers.mjs +3 -0
  51. package/src/runtime/pi/agent-runtime.mjs +247 -148
  52. package/src/runtime/pi/configured-runtime.mjs +4 -1
  53. package/src/runtime/pi/image-input.mjs +148 -0
  54. package/src/runtime/pi/memory-agent-runtime.mjs +1 -1
  55. package/src/runtime/pi/model-roles.mjs +138 -0
  56. package/src/runtime/pi/model-settings.mjs +141 -6
  57. package/src/runtime/pi/model-transport.mjs +9 -0
  58. package/src/runtime/pi/moondog-model.mjs +159 -0
  59. package/src/runtime/pi/next-songs.mjs +71 -0
  60. package/src/runtime/pi/persistent-credential-store.mjs +2 -0
  61. package/src/runtime/pi/profile-build-runtime.mjs +1 -1
  62. package/src/runtime/pi/public-model-catalog.mjs +11 -4
  63. package/src/runtime/pi/runtime-settings.mjs +7 -3
  64. package/src/surfaces/cli/brand-components.mjs +3 -3
  65. package/src/surfaces/cli/command-completions.mjs +43 -3
  66. package/src/surfaces/cli/format-output.mjs +19 -7
  67. package/src/surfaces/cli/invite-command.mjs +65 -0
  68. package/src/surfaces/cli/model-roles-command.mjs +60 -0
  69. package/src/surfaces/cli/tui.mjs +91 -5
package/README.md CHANGED
@@ -4,27 +4,42 @@
4
4
 
5
5
  <h1 align="center">Moondog</h1>
6
6
 
7
- <p align="center">Source candidate 0.3.0-beta.9</p>
7
+ <p align="center">Version 0.3.1</p>
8
8
 
9
- <p align="center"><strong>A listening room that shows its work.</strong></p>
9
+ <p align="center"><strong>On the air, just for you.</strong></p>
10
10
 
11
11
  <p align="center">
12
- <img src="assets/demo/moondog-tui-home.png" width="1000" alt="Moondog's listening room in charcoal: a lunar record beside the wordmark, a four-line tracklist, and the line Is there anybody out there">
12
+ <picture>
13
+ <source media="(prefers-color-scheme: dark)" srcset="assets/demo/moondog-desktop-dark.png">
14
+ <img src="assets/demo/moondog-desktop-light.png" width="1000" alt="Moondog's desktop window: a request for a late train home, the host's answer with three songs, and the player with the cover of Last Tram Home and two songs up next">
15
+ </picture>
13
16
  </p>
14
17
 
15
- <p align="center"><sub>The real TUI, in charcoal, with fictional listening data.</sub></p>
18
+ <p align="center"><sub>The desktop app, with a made-up listener. The <a href="https://moondog.audiofool.ai">project page</a> plays the whole scene.</sub></p>
16
19
 
17
- Moondog is a listening room in your terminal.
18
- It reads the history your music services already keep, and turns it into a profile you can open, question, and correct.
19
- The profile works without a model, an API key, or a music-service login.
20
- When you want company, an agent can talk music with you, find songs you have not heard, and shape a playlist.
21
- Your data stays on your machine.
22
- The room is built on [Pi](https://github.com/earendil-works/pi).
20
+ Moondog is a radio host just for you.
21
+ It reads the history your music services already keep, learns your taste from it, and plays music for you on Spotify, Apple Music, or NetEase Music.
22
+ Ask it for something, and it answers like a host: what it picked, and why each song is there.
23
+ On a Mac it can also go on air with music it makes itself.
23
24
 
24
- ## Open the room
25
+ There are two clients on one core: a desktop app and a listening room in your terminal.
26
+ They share your profile, settings, sign-ins, and conversations.
27
+ Your profile works without a model, an API key, or a music-service login, and your data stays on your machine.
28
+ The agent is built on [Pi](https://github.com/earendil-works/pi).
25
29
 
26
- You need Node.js 22.19.0 or newer, on macOS or Linux.
27
- Install from this checkout to run the room shown here.
30
+ ## Get Moondog
31
+
32
+ | Where | How |
33
+ | --- | --- |
34
+ | Mac, Apple silicon | Download the signed, notarized app from the [project page](https://moondog.audiofool.ai) or [Releases](https://github.com/Audiofool934/moondog/releases/latest). |
35
+ | Windows, x64 | A test build from the same places. It is not code-signed yet, so SmartScreen asks before it opens. |
36
+ | Terminal, macOS or Linux | `npm install --global @audiofool/moondog`, then `moondog`. Needs Node.js 22.19.0 or newer. |
37
+
38
+ The desktop app updates itself, on a Stable or Beta channel you choose in Settings › About.
39
+ The terminal updates with `moondog update` or `/update`, on the npm `latest` or `beta` channel.
40
+ See [updating and release channels](docs/UPDATES.md).
41
+
42
+ To run from this checkout:
28
43
 
29
44
  ```bash
30
45
  git clone https://github.com/Audiofool934/moondog.git
@@ -33,62 +48,36 @@ npm ci
33
48
  npm start
34
49
  ```
35
50
 
36
- [@audiofool/moondog](https://www.npmjs.com/package/@audiofool/moondog) 0.2.2 is the published package; `npm install --global @audiofool/moondog` installs it.
37
- To see the agent work through fictional data, with no sign-in at all, run `npm run demo` from the checkout.
38
-
39
- The source version supports `moondog update` and `/update`, with stable (`latest`) and preview (`beta`) channels.
40
- Startup checks show a quiet notification; installation happens only when you request it.
41
- See [updating and release channels](docs/UPDATES.md), including the one-time upgrade needed for the older npm 0.1.0 package.
42
-
43
- ## Other ways in
44
-
45
- [Moondog for Mac](app/README.md) is a native window on the same core as the terminal room.
46
- It shares your profile, settings, sign-ins, and conversations with `moondog`, and draws its own conversation, now playing, and up next.
47
- Run it from this checkout with `cd app && npm ci && npm start`.
48
-
49
- 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
+ `npm run demo` shows the agent at work on fictional data, with no sign-in at all.
52
+ `cd app && npm ci && npm start` opens the desktop app; [app/README.md](app/README.md) covers its builds for macOS, Windows, and Linux.
50
53
 
51
- ## The sleeve
54
+ ## Where it plays
52
55
 
53
- The opening is a record sleeve drawn in characters.
54
- Nothing in the terminal is a picture.
55
- On a wide screen the record sits beside the title, with the wordmark level with the dog's eye.
56
- On a tall or narrow screen the record stacks above the title.
57
- Moondog uses whichever arrangement leaves the record larger.
58
- A lyric rests midway between the record and the input box, with room on both sides.
59
- The input asks what you have been listening to.
60
-
61
- Until your library has a line of its own, the sleeve rotates three short ones: "Where have you been?", "Is there anybody out there?", and "Wish you were here."
62
- When a matching line from music you have played is available, that line takes the place.
63
- Moondog asks [LRCLIB](https://lrclib.net/) for the original words only, and does not send your profile, your history, or the conversation.
56
+ | Service | What you get |
57
+ | --- | --- |
58
+ | Apple Music | Whole songs in the Mac app with a subscription; 30-second previews elsewhere, each with a link to the full song. |
59
+ | Spotify | Playback on your active device, after you connect your account. |
60
+ | NetEase Music | Whole songs through NetEase's own `ncm-cli`, for listeners in mainland China. |
64
61
 
65
- The room is black and white, like the moon.
66
- Paper is black ink on white.
67
- Charcoal is moonlight on a black sky.
68
- `/theme terminal` keeps your own colors.
69
- The only other colors are the six from the prism on *The Dark Side of the Moon*.
70
- Red means a step failed, orange is a caution, green confirms, and the spectrum shows while Moondog is working.
62
+ Pick the service beside the send button, or with `/service` in the terminal.
63
+ Moondog also sees what you already play: the song and playlist in the Music app on a Mac, or on Spotify's active device, so “more like this playlist” needs no names.
64
+ The Windows build plays Spotify and Apple Music previews; whole Apple Music songs and reading the Music app need macOS.
71
65
 
72
- Press Tab on an empty input to step onto the tracklist, then use the arrow keys and Enter.
66
+ ## A model to talk through
73
67
 
74
- | On the sleeve | Command |
75
- | --- | --- |
76
- | Listening profile | `/taste` |
77
- | Import your music | `/import` |
78
- | Appearance | `/theme` |
79
- | Help & commands | `/help` |
68
+ Testers with an invite code can use Moondog's own model, with no account and no API key.
69
+ Enter the code in Settings, or type `/invite <code>` in the terminal.
80
70
 
81
- While the room is idle, lunar marks travel the record, a highlight follows the groove, and the needle pulses.
82
- The dog and the wordmark stay still.
83
- `/motion off` holds the sleeve.
84
- `/art ascii` switches the drawing.
85
- `/home` returns here and leaves the conversation where it was.
71
+ Or bring your own.
72
+ GLM, Kimi, DeepSeek, Grok, GPT, Claude, Gemini, and OpenRouter are built in, and OpenAI takes your ChatGPT subscription or an API key.
73
+ Any service that speaks OpenAI's or Anthropic's API can be added by its address, in Settings or with `/endpoint`.
74
+ You can switch models in the middle of a conversation, or change settings by asking, such as the model or the language it replies in.
75
+ The [model setup guide](docs/TERMINAL_GUIDE.md#enable-agent-conversation) lists each provider.
86
76
 
87
77
  ## Bring your history
88
78
 
89
- Type `/import` and pick a service.
90
- Moondog shows you what is inside before anything is saved.
91
- When the import finishes, your profile opens in the same TUI session.
79
+ Import in the desktop app's Settings › Import, or drop the file on its window; in the terminal, type `/import`.
80
+ Moondog shows you what is inside before anything is saved, and the original files are never touched.
92
81
 
93
82
  | Service | What you can bring |
94
83
  | --- | --- |
@@ -99,22 +88,11 @@ When the import finishes, your profile opens in the same TUI session.
99
88
  | QQ Music and NetEase | Any public playlist, from its share link. |
100
89
  | ListenBrainz | A saved listens file. |
101
90
 
102
- A Spotify ZIP can also go straight in.
103
-
104
- ```text
105
- /import "/path/to/spotify-history.zip"
106
- ```
107
-
108
- Importing the same file twice changes nothing, and your original files are never touched.
109
- Apple's privacy download, and full QQ or NetEase listening history, are not supported yet.
110
91
  The [terminal guide](docs/TERMINAL_GUIDE.md#import-and-inspect-listening-history) has every format.
111
92
 
112
- With a connected model, `/profile build` writes a reading of everything you imported, usually in a few minutes.
93
+ With a model connected, Moondog writes a reading of everything you imported, usually in a few minutes.
113
94
  It names the threads in your listening, keeps what you played apart from what you saved, and marks its interpretations as interpretations.
114
95
  A second pass checks the draft for contradictions and invented claims, and the build fixes what it finds before saving.
115
- Use `/profile saved` to read it and `/profile explain 1` to trace a finding to its evidence, including after restarting.
116
- New imports or corrections mark it for an update; a cancelled build keeps its draft and your previous reading.
117
- The builder sends a compact summary of your music evidence to your configured model when you ask for it.
118
96
 
119
97
  ## Your profile
120
98
 
@@ -122,88 +100,74 @@ The profile says what you played, and what that cannot prove.
122
100
  Playing a song a lot does not, on its own, establish how much it matters to you.
123
101
 
124
102
  <p align="center">
125
- <img src="assets/demo/moondog-tui-profile.png" width="1000" alt="The listening profile for the fictional track Midnight Lines by Mara Vale, with the plays on one side and the limit of that evidence on the other">
103
+ <img src="assets/demo/moondog-tui-profile.png" width="1000" alt="The listening profile in the terminal for the fictional track Midnight Lines by Mara Vale, with the plays, what they cannot tell, and how sure Moondog is">
126
104
  </p>
127
105
 
128
- <p align="center"><sub>Fictional data, with the evidence and the limit of that evidence.</sub></p>
106
+ <p align="center"><sub>The terminal's profile, with fictional data: the evidence, and the limit of that evidence.</sub></p>
129
107
 
130
- | In the profile | What you can do |
131
- | --- | --- |
132
- | Find a song or artist | Type to filter, then open it. |
133
- | See why it is there | Read what you played, what that cannot prove, and what you told Moondog, each on its own. |
134
- | Make a choice | Choose **I like this** (Like) or **Keep it out** (Avoid), and the profile updates in place. You can also say it to the agent, for example “never play this again”. |
135
- | Change your mind | Choose **Undo my choice**, and the original listening history never changes. |
136
- | Find more like this | Start an editable request for three songs, from the track you picked. |
137
-
138
- Type `/taste report` for the long view.
139
- It walks the years one song at a time, names songs that went quiet and songs that came back, and ends on the dark side of the moon: what play counts can never tell anyone.
140
- You can save that report as a private page that works offline.
141
-
142
- ## An agent, when you want one
143
-
144
- Sign in with `/auth`, then pick a model with `/model`.
145
- GLM, Kimi, DeepSeek, Grok, GPT, Claude, Gemini, and OpenRouter are there.
146
- OpenAI takes your ChatGPT subscription or an API key.
147
- In the Mac app, any service that speaks OpenAI's or Anthropic's API can be added as an endpoint by its address, and `/endpoint` does it in the terminal.
148
- You can switch models in the middle of a conversation.
149
- The [model setup guide](docs/TERMINAL_GUIDE.md#enable-agent-conversation) lists each provider and the environment variable it reads.
150
-
151
- While an answer is on the way, each step appears in the conversation as it starts.
152
- The steps stay above the reply, with a count of what finished, what failed, and what was not confirmed.
153
- The agent can use musical knowledge and web research to find candidates, then verify the recordings on Spotify before playing or queueing them.
154
- Without Spotify, it plays 30-second Apple Music previews from the terminal instead, each next to a link to the full song.
155
- It also sees what you already play: the song and playlist in the Music app on a Mac, or on Spotify's active device, so “more like this playlist” needs no names.
156
- macOS asks once before Moondog may read the Music app.
157
- For example, “Pon doce de salsa clásica a la cola” asks it to add up to twelve verified songs directly; your history guides the choice without limiting it to your library.
158
- What it reads about the wider music world stays separate from what it knows about you.
159
- Under a queue or a set of songs, one line names the mix: how many you know well, how many come back after a while, and how many are new to you.
160
- Songs Moondog chose for you do not count as your own taste.
161
-
162
- | Optional connection | What it adds |
163
- | --- | --- |
164
- | A model through Pi | Conversation, discovery, and playlists built together. |
165
- | 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. |
166
- | Spotify sign-in | Playback, and private playlists made only when you ask. |
108
+ Open it from Taste in the desktop app's sidebar (⌥⌘T), or with `/taste` in the terminal.
109
+ Find a song or artist, see why it is there, and choose **I like this** or **Keep it out**; the profile updates in place, and **Undo my choice** puts it back.
110
+ You can also say it to the host, for example “never play this again”.
111
+ `/taste report` walks the years one song at a time and ends on what play counts can never tell anyone; you can keep it as a private page that works offline.
167
112
 
168
- Your profile never touches the network.
169
- The agent talks only to the services you set up.
170
- `/web` sends the question or the link you give it, and nothing from your profile, history, or files.
171
- A Spotify ZIP does not need a Spotify sign-in.
172
- Read the [connection and data details](docs/TERMINAL_GUIDE.md) before you connect anything.
113
+ ## On the air
114
+
115
+ Ask for music in your own words, in any of ten languages.
116
+ Each step shows in the conversation as it happens, and the host checks every recording on your service before it plays or queues it.
117
+ What it reads about the wider music world stays separate from what it knows about you, and songs it chose for you do not count as your own taste.
118
+ Under a set of songs, one line names the mix: how many you know well, how many come back after a while, and how many are new to you.
173
119
 
174
- ## Getting around
120
+ - **Up next.** The desktop player shows the queue: play a song now, or take one out. When it runs low, the host offers a few picks.
121
+ - **Your library.** Saved songs, your playlists, and the tracks Moondog made sit side by side. Import a Spotify, Apple Music, NetEase Music, or QQ Music playlist by its link, and export a playlist to Spotify.
122
+ - **Music it makes.** On an Apple silicon Mac, Moondog makes instrumental tracks offline with Stable Audio 3, powered by Stability AI. Set it up once in Settings › Playback, or with `/generation download medium`, after you agree to its licenses.
123
+ - **On Air.** Press the On Air mark, ⌃⌘O, or type `/onair`, and Moondog keeps making music from your taste until you stop it.
124
+
125
+ ## The terminal room
126
+
127
+ <p align="center">
128
+ <img src="assets/demo/moondog-tui-home.png" width="1000" alt="Moondog's listening room in the terminal, in charcoal: the record sleeve drawn in characters beside the wordmark, a four-line tracklist, and the line Where have you been">
129
+ </p>
175
130
 
176
- | Command or key | What it does |
131
+ <p align="center"><sub>The real terminal room, in charcoal, with fictional data.</sub></p>
132
+
133
+ The terminal opens on a record sleeve drawn in characters, with a lyric from music you have played.
134
+ Moondog asks [LRCLIB](https://lrclib.net/) for the original words only, and sends nothing about you.
135
+ The room is black and white, like the moon: `/theme paper`, `/theme charcoal`, or `/theme terminal` for your own colors.
136
+ Tab on an empty input steps onto the tracklist, and Ctrl+P searches every command.
137
+
138
+ | Command | What it does |
177
139
  | --- | --- |
178
140
  | `/taste` | Open your profile. |
179
- | Type, arrow keys, Enter | Filter, pick a row, and see why it is there, or make a choice. |
180
- | Tab in the profile | Switch between All, Tracks, Artists, and Your choices. |
181
- | Tab on the sleeve | Step onto the tracklist, then press Escape to return to the line you were writing. |
182
- | Esc | Go back, and the draft stays put. |
183
- | Ctrl+P | Search every command. |
184
- | Page Up, Page Down | Move through the conversation while the header, the draft, and the status line stay put. |
185
- | Up and Down in the draft | Recall what you typed in this conversation. |
186
- | Enter while Moondog is working | Queue the next message. It sends when this one finishes. |
141
+ | `/import` | Bring your history. |
142
+ | `/library` | Your saved songs and playlists. |
143
+ | `/onair` | Go on air, or come off it. |
144
+ | `/skip`, `/stop` | Skip to the next song or stream track, or stop. |
187
145
  | `/resume`, `/new` | Pick up a saved conversation, or start a fresh one. |
146
+ | `/rewind`, `/branch` | Change an earlier message, or go on in a new conversation. |
188
147
  | `/home` | Back to the sleeve, without clearing the conversation. |
189
- | `/skip`, `/stop` | Skip to the next song preview, or stop the previews. |
190
- | `/lyrics` | See which line is on the sleeve, and which song it came from. |
191
- | `/theme paper` | Black ink on white. |
192
- | `/theme charcoal` | Moonlight on a black sky. |
193
- | `/theme terminal` | Your terminal's own colors. |
194
- | `/language` | Choose the language Moondog replies in: English, 简体中文, 繁體中文, 日本語, 한국어, Español, Français, Deutsch, Português (Brasil), or Italiano. Screens follow in English, Español, Português (Brasil), 日本語, and 简体中文. |
148
+ | `/help` | Everything else. |
149
+
150
+ The [terminal guide](docs/TERMINAL_GUIDE.md) has every command and key.
151
+
152
+ ## Your data
195
153
 
196
- Each launch starts a new conversation.
197
- Your profile, and anything Moondog remembers, carry over.
154
+ Your profile never touches the network.
155
+ The agent talks only to the services you set up, and the profile builder sends a compact summary of your music evidence to your model only when you ask for a build.
156
+ Web search sends the question or the link you give it, and nothing from your profile, history, or files.
157
+ An image you attach goes to the model that reads it.
158
+ A Spotify ZIP does not need a Spotify sign-in.
159
+ Read the [connection and data details](docs/TERMINAL_GUIDE.md) before you connect anything.
198
160
 
199
161
  ## Further
200
162
 
201
163
  - [Terminal guide](docs/TERMINAL_GUIDE.md): import formats, commands, appearance, models, Spotify, memory, and your local data.
164
+ - [Desktop app](app/README.md): the window, its keys, builds, and updates.
165
+ - [Project page](site/README.md): how the page plays the scene in the app's real window, in a browser, on made-up data.
202
166
  - [Private Tasteprint](docs/PRIVATE_TASTEPRINT.md): what the evidence can support, and what a report reveals about you.
203
167
  - [Product charter](docs/PRODUCT_CHARTER.md) and [public roadmap](docs/ROADMAP.md): where Moondog is headed, and what it will not do.
204
168
  - [Voice](docs/VOICE.md): how Moondog talks, and where Pink Floyd shows up.
205
169
  - [The listening loop](docs/LISTENING_LOOP.md): how the agent keeps your choices, your recent listening, and its own picks apart.
206
- - [The agent harness](docs/AGENT_HARNESS.md): how the tools keep the model's part small, so every supported model can play what you ask, and how each model is measured.
170
+ - [The agent harness](docs/AGENT_HARNESS.md): how the tools keep the model's part small, so every supported model can play what you ask.
207
171
  - [Runtime architecture](docs/ADR_0001_AGENT_RUNTIME_AND_CLI.md) and [data contracts](contracts/README.md): how the pieces fit together.
208
172
  - [Contribution guide](CONTRIBUTING.md): local setup, checks, and how private data is kept out.
209
173
  - [Release status](docs/PUBLIC_RELEASE_READINESS.md): what is published, and what the checks cover.
@@ -213,4 +177,4 @@ Your profile, and anything Moondog remembers, carry over.
213
177
 
214
178
  Moondog is open source under the [Apache License 2.0](LICENSE).
215
179
  Copyright 2026 Audiofool.
216
- Music making runs Stable Audio 3, which you install yourself; [NOTICE](NOTICE) holds its attribution, and [licenses/](licenses/stability-ai-community-license.md) holds the Stability AI Community License.
180
+ Music making runs Stable Audio 3, which Moondog downloads from Stability AI when you ask, or your own install; [NOTICE](NOTICE) holds its attribution, and [licenses/](licenses/stability-ai-community-license.md) holds the Stability AI Community License.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@audiofool/moondog",
3
- "version": "0.3.0-beta.9",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
- "description": "Local-first personal AI music agent.",
5
+ "description": "A local-first AI radio host, just for you.",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
8
8
  "ai-agent",
@@ -63,15 +63,17 @@
63
63
  "verify": "npm run verify:release-tree && npm run verify:demo-history && npm run verify:demo && npm run verify:community && npm run verify:package && npm run validate:contracts && npm test",
64
64
  "doctor": "node --disable-warning=ExperimentalWarning scripts/moondog.mjs doctor",
65
65
  "validate:contracts": "node scripts/validate-contracts.mjs",
66
- "test": "node --test tests/contracts/*.test.mjs tests/core/*.test.mjs tests/importers/*.test.mjs tests/runtime/*.test.mjs"
66
+ "test": "node --test tests/contracts/*.test.mjs tests/core/*.test.mjs tests/importers/*.test.mjs tests/runtime/*.test.mjs gateway/tests/*.test.mjs"
67
67
  },
68
68
  "dependencies": {
69
- "@earendil-works/pi-agent-core": "1.0.1",
70
- "@earendil-works/pi-ai": "1.0.1",
71
- "@earendil-works/pi-tui": "1.0.1",
69
+ "@earendil-works/pi-agent-core": "1.6.0",
70
+ "@earendil-works/pi-ai": "1.6.0",
71
+ "@earendil-works/pi-tui": "1.6.0",
72
72
  "ajv": "8.20.0",
73
73
  "ajv-formats": "3.0.1",
74
- "plist": "5.0.0"
74
+ "plist": "5.0.0",
75
+ "typebox": "1.3.27",
76
+ "yauzl": "3.4.0"
75
77
  },
76
78
  "devDependencies": {
77
79
  "yaml": "2.9.0"
@@ -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";
@@ -28,11 +27,13 @@ import {
28
27
  } from "../src/surfaces/cli/format-output.mjs";
29
28
  import { runAuthCommand } from "../src/surfaces/cli/auth-command.mjs";
30
29
  import { runEndpointCommand } from "../src/surfaces/cli/endpoint-command.mjs";
30
+ import { runInviteCommand } from "../src/surfaces/cli/invite-command.mjs";
31
31
  import { runDataCommand } from "../src/surfaces/cli/data-command.mjs";
32
32
  import { runCatalogCommand } from "../src/surfaces/cli/catalog-command.mjs";
33
33
  import { runProfileCommand } from "../src/surfaces/cli/profile-command.mjs";
34
34
  import { runListenerProfileCommand, savedProfileActions } from "../src/surfaces/cli/listener-profile-command.mjs";
35
35
  import { createWebResearch } from "../src/integrations/web/web-research.mjs";
36
+ import { runModelRolesCommand } from "../src/surfaces/cli/model-roles-command.mjs";
36
37
  import { runWebCommand } from "../src/surfaces/cli/web-command.mjs";
37
38
  import { openSpotifyConnection } from "../src/integrations/spotify/connection.mjs";
38
39
  import { preferredIdleDevice, thisComputerName } from "../src/integrations/spotify/service.mjs";
@@ -45,6 +46,7 @@ import {
45
46
  import { runSpotifyCommand } from "../src/surfaces/cli/spotify-command.mjs";
46
47
  import { runListenBrainzCommand } from "../src/surfaces/cli/listenbrainz-command.mjs";
47
48
  import { openListeningHistoryStore } from "../src/profile/listening-history-store.mjs";
49
+ import { musicHash, prepareMusicBundle } from "../src/profile/music-import-bundle.mjs";
48
50
  import { commitSpotifyQuickImport, prepareHistoryImport, prepareSpotifyQuickImport } from "../src/profile/history-import.mjs";
49
51
  import { persistAppleLibraryImport, refreshAppleLibraryImport } from "../src/profile/apple-library-import.mjs";
50
52
  import { IMPORT_GUIDE_URLS } from "../src/surfaces/cli/import-guides.mjs";
@@ -150,6 +152,28 @@ function parseArguments(argv) {
150
152
  };
151
153
  }
152
154
 
155
+ // A playlist imported into the library adds its songs to the listener's taste evidence, as a kept playlist, the
156
+ // same way a public playlist imported from the Import guide does. Its source names where it came from.
157
+ const PLAYLIST_TASTE_SOURCES = { spotify: "spotify_playlist", apple_music: "apple_music_playlist", netease: "netease", qq_music: "qq_music" };
158
+ async function addPlaylistToTaste(found) {
159
+ const provider = PLAYLIST_TASTE_SOURCES[found.provider];
160
+ if (!provider) throw new Error("This playlist's service can't shape the profile.");
161
+ const historyStore = await openListeningHistoryStore();
162
+ try {
163
+ const appleSubjectId = await optionalAppleMusicSubjectId();
164
+ const subjectId = historyStore.localSubjectId({ ...(appleSubjectId ? { preferredSubjectId: appleSubjectId } : {}), create: true });
165
+ const rows = found.tracks.map((track, index) => ({ id: track.id, title: track.title, artist: track.artist, ...(track.album ? { album: track.album } : {}),
166
+ playlistId: found.id, playlistName: found.name, position: index + 1, member: "playlist-link.json", listenerMade: found.owned === true }));
167
+ const bytes = Buffer.from(JSON.stringify({ provider, id: found.id, name: found.name, rows }));
168
+ const prepared = prepareMusicBundle({ provider, subjectId, capturedAt: new Date().toISOString(), rows, digest: musicHash(bytes), size: bytes.length,
169
+ members: ["playlist-link.json"], fileName: found.name,
170
+ scopeNote: "A playlist the listener imported into their library. It shows what they keep, not what they played." });
171
+ return historyStore.ingestImport(prepared.bundle);
172
+ } finally {
173
+ historyStore.close();
174
+ }
175
+ }
176
+
153
177
  async function optionalAppleMusicSubjectId() {
154
178
  const source = await readAppleMusicSourceStatus();
155
179
  if (source.state === "missing") return null;
@@ -383,9 +407,7 @@ async function prepareTuiHistoryImport(filePath, { recentPage, librarySnapshot,
383
407
  async function openImportHelp(destination) {
384
408
  const url = IMPORT_GUIDE_URLS[destination];
385
409
  if (!url) throw new Error("Unknown import guide.");
386
- await promisify(execFile)(process.platform === "darwin" ? "open" : "xdg-open", [url], {
387
- timeout: 10_000,
388
- });
410
+ await openInDefaultBrowser(url);
389
411
  }
390
412
 
391
413
  function tasteCoverage(profile) {
@@ -746,6 +768,11 @@ async function main() {
746
768
  return;
747
769
  }
748
770
 
771
+ if (options.command === "invite") {
772
+ await runInviteCommand({ args: options.rest, json: options.json });
773
+ return;
774
+ }
775
+
749
776
  if (options.command === "spotify") {
750
777
  await runSpotifySurface({
751
778
  args: options.rest,
@@ -974,6 +1001,8 @@ async function main() {
974
1001
  domainServices, domainServicesError, spotifyConnection, locale, playbackService, playbackSelection, languageSelection, modelSwitch,
975
1002
  webResearch, memoryStore, musicCatalog, musicPreviewPlayer: previewPlayer, neteasePlayer, localGenerator, atmosphereStream, musicSimilarity, artistIdentityResolver,
976
1003
  spotifyTopArtists, musicApp, libraryStore,
1004
+ // A playlist that shapes the taste reloads the profile services at once, so the evidence counts in this session.
1005
+ playlistTaste: async (found) => { const receipt = await addPlaylistToTaste(found); replaceDomainServices(await loadDomainServices()); return receipt; },
977
1006
  });
978
1007
  const application = new MoondogApplication(applicationOptions({
979
1008
  ...domainState, spotifyConnection, locale: await resolveListenerLocale(), playbackService,
@@ -1023,6 +1052,8 @@ async function main() {
1023
1052
  process.stdout.write(
1024
1053
  `${options.json ? JSON.stringify(value, null, 2) : formatLocalResult(options.command, value)}\n`,
1025
1054
  );
1055
+ // A failed required check makes the checkup fail, so scripts can rely on it.
1056
+ if (options.command === "doctor" && !value.ok) process.exitCode = 1;
1026
1057
  return;
1027
1058
  }
1028
1059
 
@@ -1210,10 +1241,14 @@ async function main() {
1210
1241
  // The desktop window lists models and signs in here, with no terminal.
1211
1242
  modelSettings,
1212
1243
  // A model chosen or a sign-in made on the other surface. Model variables fix the model at
1213
- // launch, so a saved choice has nothing to change then.
1214
- watchModelSettings: (onChange) => (process.env.MOONDOG_PROVIDER !== undefined || process.env.MOONDOG_MODEL !== undefined
1215
- ? () => {}
1216
- : watchRuntimeSettings({ environment: process.env, onChange })),
1244
+ // launch, so a saved choice has nothing to change then; a role chosen elsewhere still does.
1245
+ watchModelSettings: (onChange) => {
1246
+ const fixed = process.env.MOONDOG_PROVIDER !== undefined || process.env.MOONDOG_MODEL !== undefined;
1247
+ return watchRuntimeSettings({ environment: process.env, onChange: (selection, changed) => {
1248
+ if (changed === "roles") return void webResearch.refresh().then(() => onChange(selection, changed), () => {});
1249
+ if (!fixed) onChange(selection, changed);
1250
+ } });
1251
+ },
1217
1252
  // The one-time music service and model setup, shared by the terminal and the window.
1218
1253
  firstRun: createFirstRun({ environment: process.env }),
1219
1254
  // A host with its own terminal streams takes the sign-in prompts. The
@@ -1238,7 +1273,10 @@ async function main() {
1238
1273
  progressOutput: host.terminalStreams.output,
1239
1274
  }),
1240
1275
  }),
1276
+ // The room says what came of an invite code in its own words, so the command prints nothing.
1277
+ runInvite: (args) => runInviteCommand({ args, output: { write() {} }, settings: modelSettings }),
1241
1278
  runWeb: (args, options) => runWebCommand({ args, webResearch, ...options }),
1279
+ runModelRoles: (args) => runModelRolesCommand({ args: args.map(String), modelSettings, webResearch }),
1242
1280
  runProfileAction: (args) => runProfileCommand({
1243
1281
  args,
1244
1282
  commandPrefix: "/profile",
@@ -1296,6 +1296,10 @@ export class AppleProjectionDomainServices {
1296
1296
  return this.#listeningHistoryStore?.recentAttention?.({ subjectId: this.#subjectId }) ?? null;
1297
1297
  }
1298
1298
 
1299
+ listeningDays() {
1300
+ return this.#listeningHistoryStore?.listeningDays?.({ subjectId: this.#subjectId }) ?? null;
1301
+ }
1302
+
1299
1303
  // Moondog's suggestions ledger and the declared mix (src/profile/moondog-suggestions.mjs).
1300
1304
  recordMoondogSuggestions(entries) {
1301
1305
  return this.#listeningHistoryStore?.recordMoondogSuggestions?.({ entries }) ?? null;
@@ -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",
@@ -628,6 +614,28 @@ const catalog = [
628
614
  label: N_("Save to the library"),
629
615
  },
630
616
  },
617
+ {
618
+ id: "collection.edit",
619
+ version: "1",
620
+ state: "enabled",
621
+ effect: "write_local",
622
+ description: "Rename one of the listener's playlists on this Mac, take songs out of it, or move songs within it, when they ask.",
623
+ agent_tool: {
624
+ name: "moondog_collection_edit",
625
+ label: N_("Change a playlist"),
626
+ },
627
+ },
628
+ {
629
+ id: "collection.import",
630
+ version: "1",
631
+ state: "enabled",
632
+ effect: "write_local",
633
+ description: "Import a playlist link from Spotify, Apple Music, NetEase Music or QQ Music into the listener's library on this Mac.",
634
+ agent_tool: {
635
+ name: "moondog_collection_import",
636
+ label: N_("Import a playlist"),
637
+ },
638
+ },
631
639
  {
632
640
  id: "collection.play",
633
641
  version: "1",
@@ -639,6 +647,30 @@ const catalog = [
639
647
  label: N_("Play from the library"),
640
648
  },
641
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
+ },
642
674
  {
643
675
  id: "music.generate.local",
644
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
+ }