Saltar al contenido principal
O

dsh-youth-mode

of-qinhai/dsh-youth-mode

A local music player with a live spectrum and activity-driven playback for DSH conversations.

Instalar

dsh plugin --profile web add github:of-qinhai/dsh-youth-mode

README

DSH Youth Mode

@ohmynpm/dsh-youth-mode plays your local music above the DSH conversation input. It shows a live spectrum and can start playback automatically while you type or while DSH works.

简体中文 · npm

Youth Mode’s live audio spectrum and current track

Quick start

  1. In DSH Desktop or the Web UI, open Plugins → Add plugin and enter @ohmynpm/dsh-youth-mode.
  2. Choose Install → Enable now and open a conversation. The music bar sits above the message box, above the task list when it is visible.
  3. Click Choose a track or the current track in the music bar. In the playlist, click the folder icon to the left of Play and add music to the folder that opens.
  4. Return to DSH or wait about 10 seconds. Select a track or press Play. The volume slider is at the bottom of the playlist, and the browser remembers your setting.

You can also ask DSH to install and enable @ohmynpm/dsh-youth-mode. To install from GitHub or a .tgz archive, enter the repository URL or the archive’s absolute path in Add plugin. GitHub repository

Features

  • BGM:
    • Click the track name to open the playlist. Auto is the first control in its header. It starts playback when typing reaches inChars, when a response reaches outChars, or when a tool starts. After a turn or a pause in typing, playback fades out.
    • Play, pause, or choose a track to take manual control. Use the play button in the spectrum to resume from the same position.
    • Click Auto to return to conversation-driven playback. During an idle conversation, the player fades out and waits for activity.
  • Music bar: a 28-column spectrum and a translucent playback meter behind the track name. The track card shows Auto or Manual mode plus elapsed and total time once the audio loads. The bottom rows breathe in cyan during standby and ice blue when paused. During audible playback the columns follow the audio.
  • Terminal background: short summaries of live Bash calls rise behind the spectrum, growing and fading like lines in a terminal. Bass hits briefly speed up the scroll. Reduced motion displays the summaries in place.

Music and configuration

Scan the music folder automatically

The package ships with an empty audio/ folder. It accepts .mp3, .m4a, .aac, .ogg, .opus, .wav, and .flac files, sorted by filename. Put the files in the directory opened by the playlist’s folder button. For remote DSH sessions, this directory is on the host machine.

Choose tracks and their order

To keep music in a permanent location or play a specific set, add this override to your active DSH profile’s cordis.patch.yml. On macOS and Linux, the desktop profile is usually in ~/.dsh/profiles/desktop/.

- id: youth-mode
  name: '@ohmynpm/dsh-youth-mode'
  config:
    tracks:
      - '/Users/your-name/Music/Youth Mode/intro.mp3'
      - '/Users/your-name/Music/Youth Mode/chill.flac'
    volume: 0.45

Replace the example paths with real absolute paths on the DSH host. Relative filenames resolve inside the plugin’s audio/ folder. An explicit list plays in the order you enter, and tracks: [] restores automatic scanning. A saved slider setting takes precedence over volume. If you installed a local checkout or installed from GitHub, use @local/youth-mode for name.

Other options

See the bundle configuration for defaults. If changes do not take effect, reopen DSH.

KeyDefaultDescription
tracksempty (scan audio/)Optional selection of tracks. Relative names resolve under audio/. Absolute paths also work.
inChars24Input length that starts playback
outChars0Output length that starts playback; 0 = as soon as the model streams
volume0.45Target volume (0–1)
idleMs1500Silence before fading out
fadeInMs10000Fade-in duration (enforced minimum of 10 s)
fadeOutMs10000Fade-out duration
modeautoDefault mode. off starts in manual mode. The browser remembers the selected mode.

Troubleshooting

  • The playlist is empty. Check the folder opened by the playlist button, or check the paths in tracks. Return to DSH and wait for the playlist to refresh.
  • A track is listed but silent. Press Play and check the volume. Your browser may require an interaction before autoplay starts.
  • Tracks disappeared after an update. The plugin’s installation folder can change with each version. For music you want to keep across updates, store it in your own music folder and reference it through tracks.

Usage

ActionBehaviour
Send a long prompt with Auto onBGM plays through the turn, then fades out
Track name in the music barOpen the playlist and select a track to play.
Top of the playlistOpen the music folder in the file manager, play or pause, skip to the next track in order, or change Auto mode.
Bottom of the playlistAdjust the volume. The browser remembers your setting.

How it works

  • Host half (index.js) provides authenticated music endpoints.
    • /api/youth-mode-bgm?config=1 returns the track list, including display names and stable identifiers, and the playback settings.
    • /api/youth-mode-bgm?key=… returns the audio file. The identifier survives playlist reordering.
    • POST /api/youth-mode-bgm/open-folder opens the plugin’s music folder on the DSH host.
  • Client half (client.js) mounts the player in the conversation.input.dock slot. It reads conversation activity to start music during a turn and fade it out when the turn ends.
  • BGM uses a browser <audio> element and timer-based volume ramps.

Known limitations

  • The audio route does not support Range: the first load or a track switch downloads the whole file, so a slow file gives a short silence before the fade-in.
  • If the browser blocks autoplay, the first click or key press retries playback.
  • Depends on DSH client internals (session.eventSource, the conversation.input.dock slot, exact /api routes); a DSH upgrade may require follow-up changes.

Releasing

Run npm test and npm run pack:release on Node.js 22 or later. The latter creates a shareable dist/ohmynpm-dsh-youth-mode-<version>.tgz. The package starts with an empty music folder, and local tracks stay in the development checkout.

A maintainer with @ohmynpm publishing access uploads the first version. Then configure npm Trusted Publishing for release.yml in Of-qinhai/dsh-youth-mode. For subsequent releases, push a v<version> tag matching the package version to run the tests and publish through GitHub Actions.

Development

Local directory (for development)

git clone https://github.com/Of-qinhai/dsh-youth-mode.git

Then use Plugins → Add plugin with the absolute path of that directory, install and enable. Local installs are symlinked, so code changes show up after a page refresh.

node test/smoke.mjs

The offline smoke test covers the Host route bytes, config sanitisation, playback activity detection, dock registration, and spectrum response.

Layout

.
├── package.json         # bundle manifest (dsh.bundle.patch + dsh.client)
├── cordis.patch.yml     # plugin row and default config
├── index.js             # Host half: /api/youth-mode-bgm
├── client.js            # Client half: conversation dock and music player
├── icon.svg
├── locale/              # Plugin Manager display strings
├── audio/               # local music directory
└── test/smoke.mjs

Plugins relacionados