@ohmynpm/dsh-youth-mode 0.0.0-stage → 1.0.0
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.en.md +142 -0
- package/README.md +141 -2
- package/audio/.gitkeep +0 -0
- package/client.js +1248 -0
- package/cordis.patch.yml +15 -0
- package/icon.svg +12 -0
- package/index.js +172 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +49 -4
package/README.en.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# dsh-youth-mode
|
|
2
|
+
|
|
3
|
+
A "Youth mode" tab for DSH conversations: a terminal-style log of tool calls, with local BGM.
|
|
4
|
+
|
|
5
|
+
The default conversation is untouched; this only adds another view. Switch to it and you get a CMD-like window that shows nothing but the commands the model runs.
|
|
6
|
+
|
|
7
|
+
[中文](README.md)
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
[18:55:39] ~/dsh-workspace-tmp $ npm test ✓ 4.4s
|
|
11
|
+
[18:57:42] ~/dsh-workspace-tmp $ python3 - <<'PY' (+32 lines) ✓ 0.1s
|
|
12
|
+
[--:--:--] ~/dsh-workspace-tmp $ █
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **Youth mode tab**: a new conversation view next to the normal chat; the default stays on chat.
|
|
18
|
+
- **Commands only**: a terminal transcript in the form `[time] ~/path $ command`; multi-line or huge commands collapse to the first line plus `(+N lines)`.
|
|
19
|
+
- **Typewriter**: commands reveal at `typeCps`, with a brief speed boost on pronounced bass hits. A system preference for reduced motion shows commands immediately.
|
|
20
|
+
- **Auto-scroll**: always follows new commands and streamed arguments.
|
|
21
|
+
- **BGM**:
|
|
22
|
+
- The playlist loads automatically. With BGM enabled, the first visit starts at the first track.
|
|
23
|
+
- Click the track name to open the playlist with play, pause, next track, and BGM controls. Next follows playlist order.
|
|
24
|
+
- Resume a manually paused track from the same position. With automatic BGM enabled, typing or model output can resume music that faded out after inactivity or the end of a turn.
|
|
25
|
+
- **Status bar**: run state, command count, current track, and playback controls. A 20-column segmented spectrum follows the music. Peak markers linger at the top of each hit and then fall slowly.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
### One-click inside DSH (recommended)
|
|
30
|
+
|
|
31
|
+
1. Open DSH and go to **Plugins** in the sidebar.
|
|
32
|
+
2. Click **Add plugin** and enter an installation source.
|
|
33
|
+
- Once the npm package is published, enter `@ohmynpm/dsh-youth-mode`.
|
|
34
|
+
- To install from GitHub, enter `https://github.com/Of-qinhai/dsh-youth-mode`.
|
|
35
|
+
- If you received a `.tgz` installer, enter its absolute file path.
|
|
36
|
+
|
|
37
|
+
3. Click **Install**, then **Enable now**.
|
|
38
|
+
4. Refresh the page and send a message; the **Youth mode** tab appears in the header.
|
|
39
|
+
|
|
40
|
+
> Requires the DSH Web UI with the Plugin Manager. The repository ships a prebuilt `client.js`; no extra build step is needed.
|
|
41
|
+
|
|
42
|
+
### Let the DSH agent install it
|
|
43
|
+
|
|
44
|
+
Tell DSH:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
Install the plugin https://github.com/Of-qinhai/dsh-youth-mode and enable it
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The agent uses `plugin_manager` to install and enable it.
|
|
51
|
+
|
|
52
|
+
### Local directory (for development)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git clone https://github.com/Of-qinhai/dsh-youth-mode.git
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
Configuration lives in the bundle's [cordis.patch.yml](cordis.patch.yml); after editing, let DSH recompose (restarting DSH is the safe way):
|
|
63
|
+
|
|
64
|
+
| Key | Default | Description |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| `tracks` | empty (scan `audio/`) | Optional selection of tracks. Relative names resolve under `audio/`. Absolute paths also work. |
|
|
67
|
+
| `inChars` | `24` | Input length that starts playback |
|
|
68
|
+
| `outChars` | `0` | Output length that starts playback; `0` = as soon as the model streams |
|
|
69
|
+
| `volume` | `0.45` | Target volume (0–1) |
|
|
70
|
+
| `idleMs` | `1500` | Silence before fading out |
|
|
71
|
+
| `fadeInMs` | `10000` | Fade-in duration (enforced minimum of 10 s) |
|
|
72
|
+
| `fadeOutMs` | `10000` | Fade-out duration |
|
|
73
|
+
| `typeCps` | `30` | Typewriter speed (chars/sec) |
|
|
74
|
+
| `mode` | `auto` | Default mode for the first run; the `♪` toggle remembers afterwards |
|
|
75
|
+
|
|
76
|
+
### Adding your own music
|
|
77
|
+
|
|
78
|
+
Bring your own music. Drop `.mp3`, `.m4a`, `.aac`, `.ogg`, `.opus`, `.wav`, or `.flac` files into `audio/`. Git ignores these local files. With Youth mode open, refocus the window or wait about 10 seconds for the files to appear in the playlist.
|
|
79
|
+
|
|
80
|
+
Set `tracks` only to play a specific selection:
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
tracks:
|
|
84
|
+
- 'my-song.mp3'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
DSH reads the audio locally. The browser receives the display name and an identifier.
|
|
88
|
+
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
| Action | Behaviour |
|
|
92
|
+
| --- | --- |
|
|
93
|
+
| Switch to the Youth mode tab | Shows the terminal log (history appears complete, no typing replay) |
|
|
94
|
+
| Send after typing a long prompt | BGM starts immediately and runs through the turn |
|
|
95
|
+
| Track name in the bottom bar | Open the playlist and select a track to play. |
|
|
96
|
+
| Top of the playlist | Open the music folder in the file manager, play or pause, skip to the next track in order, or toggle BGM. |
|
|
97
|
+
| Bottom of the playlist | Adjust the volume. The browser remembers your setting. |
|
|
98
|
+
|
|
99
|
+
## How it works
|
|
100
|
+
|
|
101
|
+
- **Host half** ([index.js](index.js)) provides authenticated music endpoints.
|
|
102
|
+
- `/api/youth-mode-bgm?config=1` returns the track list, including display names and stable identifiers, and the playback settings.
|
|
103
|
+
- `/api/youth-mode-bgm?key=…` returns the audio file. The identifier survives playlist reordering.
|
|
104
|
+
- `POST /api/youth-mode-bgm/open-folder` opens the plugin’s music folder on the DSH host.
|
|
105
|
+
- **Client half** ([client.js](client.js)) registers the tab through the `conversation.view` slot and folds the session event window (`tool/call`, `tool/result`, `assistant/live-chunk`) directly. It never subscribes to the model or writes session events.
|
|
106
|
+
- BGM is a browser `<audio>` element with timer-based volume ramps; the element is reused across tab switches.
|
|
107
|
+
|
|
108
|
+
## Known limitations
|
|
109
|
+
|
|
110
|
+
- 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.
|
|
111
|
+
- If the browser blocks autoplay, the first click or key press retries playback.
|
|
112
|
+
- Multi-line commands show only the first line plus a line count, not the full heredoc.
|
|
113
|
+
- History is shown complete when the tab opens; no typing replay.
|
|
114
|
+
- Depends on DSH client internals (`session.eventSource`, the `conversation.view` slot, exact `/api` routes); a DSH upgrade may require follow-up changes.
|
|
115
|
+
|
|
116
|
+
## Releasing
|
|
117
|
+
|
|
118
|
+
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.
|
|
119
|
+
|
|
120
|
+
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.
|
|
121
|
+
|
|
122
|
+
## Development
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
node test/smoke.mjs
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The offline smoke test covers the Host route bytes, config sanitisation, event folding, streamed command assembly and typewriter advancement.
|
|
129
|
+
|
|
130
|
+
## Layout
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
.
|
|
134
|
+
├── package.json # bundle manifest (dsh.bundle.patch + dsh.client)
|
|
135
|
+
├── cordis.patch.yml # plugin row and default config
|
|
136
|
+
├── index.js # Host half: /api/youth-mode-bgm
|
|
137
|
+
├── client.js # Client half: tab, terminal view, BGM
|
|
138
|
+
├── icon.svg
|
|
139
|
+
├── locale/ # Plugin Manager display strings
|
|
140
|
+
├── audio/ # local music directory
|
|
141
|
+
└── test/smoke.mjs
|
|
142
|
+
```
|
package/README.md
CHANGED
|
@@ -1,3 +1,142 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-youth-mode
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
给 DSH 对话加一个「青春模式」TAB:终端风格的命令日志 + 本机 BGM。
|
|
4
|
+
|
|
5
|
+
默认对话方式完全不变,只是多一个视图;切过去就像开了一个 CMD 窗口,只显示模型执行的工具调用和命令行。
|
|
6
|
+
|
|
7
|
+
[English](README.en.md)
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
[18:55:39] ~/dsh-workspace-tmp $ npm test ✓ 4.4s
|
|
11
|
+
[18:57:42] ~/dsh-workspace-tmp $ python3 - <<'PY' (+32 行) ✓ 0.1s
|
|
12
|
+
[--:--:--] ~/dsh-workspace-tmp $ █
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 功能
|
|
16
|
+
|
|
17
|
+
- **青春模式 TAB**:在原来的对话旁边新增一个视图,默认仍停在普通对话。
|
|
18
|
+
- **只显示命令**:`[时间] ~/路径 $ 命令` 的终端 transcript;多行/超长命令压成首行 + `(+N 行)`。
|
|
19
|
+
- **打字机**:命令按 `typeCps` 逐字显示,检测到明显的低频鼓点时短暂加速。开启系统「减少动态效果」后直接显示完整命令。
|
|
20
|
+
- **自动滚动**:新命令和流式参数出现时始终贴底。
|
|
21
|
+
- **BGM**:
|
|
22
|
+
- 自动读取歌单。首次进入且 BGM 开启时,从列表第一首开始播放;
|
|
23
|
+
- 点底栏曲名打开歌单,可播放、暂停、按列表顺序切到下一首,或开关 BGM;
|
|
24
|
+
- 手动暂停后,从原位置手动继续。自动播放模式下,长输入或模型输出可恢复因空闲或回合结束而淡出的音乐。
|
|
25
|
+
- **状态栏**:运行状态、命令数、当前曲目与播放控制。中间的 20 列分段频谱随 BGM 实时变化,峰值块停留片刻后缓慢回落。
|
|
26
|
+
|
|
27
|
+
## 安装
|
|
28
|
+
|
|
29
|
+
### 在 DSH 里一键安装(推荐)
|
|
30
|
+
|
|
31
|
+
1. 打开 DSH,点击侧边栏 **Plugins**。
|
|
32
|
+
2. 点 **Add plugin**,填入以下任一安装来源。
|
|
33
|
+
- npm 包发布后,可填 `@ohmynpm/dsh-youth-mode`。
|
|
34
|
+
- 从 GitHub 安装可填 `https://github.com/Of-qinhai/dsh-youth-mode`。
|
|
35
|
+
- 收到 `.tgz` 安装包时,填下载后的文件绝对路径。
|
|
36
|
+
|
|
37
|
+
3. 点 **Install**,完成后点 **Enable now**。
|
|
38
|
+
4. 刷新页面,随便发一条消息,标题栏出现 **青春模式** TAB。
|
|
39
|
+
|
|
40
|
+
> 需要 DSH 的 Web 界面与插件管理(Plugin Manager)。仓库自带已构建好的 `client.js`,安装时不需要额外构建。
|
|
41
|
+
|
|
42
|
+
### 让 DSH 助手帮你装
|
|
43
|
+
|
|
44
|
+
直接对 DSH 说:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
帮我安装插件 https://github.com/Of-qinhai/dsh-youth-mode 并启用
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
助手会通过 `plugin_manager` 完成安装和启用。
|
|
51
|
+
|
|
52
|
+
### 本地目录安装(开发用)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git clone https://github.com/Of-qinhai/dsh-youth-mode.git
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
然后在 **Plugins → Add plugin** 里填这个目录的**绝对路径**,安装并启用。本地目录安装是软链接,改完代码刷新页面即可。
|
|
59
|
+
|
|
60
|
+
## 配置
|
|
61
|
+
|
|
62
|
+
配置在插件包的 [cordis.patch.yml](cordis.patch.yml),修改后需要让 DSH 重新组合(重启 DSH 最稳):
|
|
63
|
+
|
|
64
|
+
| 键 | 默认 | 说明 |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| `tracks` | 空(自动扫描 `audio/`) | 只播指定曲目时才填;相对名从 `audio/` 读,也可写绝对路径 |
|
|
67
|
+
| `inChars` | `24` | 输入达到多少字符后开始播放 |
|
|
68
|
+
| `outChars` | `0` | 输出达到多少字符开始;`0` = 模型一开始输出就播 |
|
|
69
|
+
| `volume` | `0.45` | 目标音量(0–1) |
|
|
70
|
+
| `idleMs` | `1500` | 停止打字多久后开始淡出 |
|
|
71
|
+
| `fadeInMs` | `10000` | 渐入时长(最低按 10 秒执行) |
|
|
72
|
+
| `fadeOutMs` | `10000` | 渐出时长 |
|
|
73
|
+
| `typeCps` | `30` | 打字机速度(字符/秒) |
|
|
74
|
+
| `mode` | `auto` | 首次运行的默认模式;之后由界面上的 `♪` 记忆 |
|
|
75
|
+
|
|
76
|
+
### 添加自己的音乐
|
|
77
|
+
|
|
78
|
+
音乐由你本地提供。把 `.mp3` / `.m4a` / `.aac` / `.ogg` / `.opus` / `.wav` / `.flac` 放进插件的 `audio/` 目录即可。这些文件会被 Git 忽略。打开青春模式时,切回窗口或等待约 10 秒,新曲目就会出现在歌单里,无需刷新页面。
|
|
79
|
+
|
|
80
|
+
只想播其中几首时,才需要 `tracks`(相对名或绝对路径):
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
tracks:
|
|
84
|
+
- 'my-song.mp3'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
音频只由 DSH 宿主读取,页面拿到的是序号和显示名,绝对路径不会进浏览器。
|
|
88
|
+
|
|
89
|
+
## 使用
|
|
90
|
+
|
|
91
|
+
| 操作 | 行为 |
|
|
92
|
+
| --- | --- |
|
|
93
|
+
| 切到「青春模式」TAB | 显示终端日志(历史命令直接完整显示,不回放打字) |
|
|
94
|
+
| 长输入后发送 | BGM 立刻开始,贯穿本轮 |
|
|
95
|
+
| 底栏曲名 | 打开歌单,点击曲名直接播放 |
|
|
96
|
+
| 歌单顶部 | 在系统文件管理器中打开音乐目录,播放/暂停,按顺序切到下一首,或开关 BGM |
|
|
97
|
+
| 歌单底部 | 调节音量,设置会保存在当前浏览器中 |
|
|
98
|
+
|
|
99
|
+
## 原理
|
|
100
|
+
|
|
101
|
+
- **Host 半**([index.js](index.js))提供需要登录态的音乐接口。
|
|
102
|
+
- `/api/youth-mode-bgm?config=1` 返回曲目的序号、稳定标识、文件名及播放配置。
|
|
103
|
+
- `/api/youth-mode-bgm?key=…` 返回音频文件。目录重新排序时,标识仍指向同一首曲目。
|
|
104
|
+
- 向 `/api/youth-mode-bgm/open-folder` 发送 POST 请求会在 DSH 宿主机器上打开插件的音乐目录。
|
|
105
|
+
- **Client 半**([client.js](client.js))通过 `conversation.view` 插槽注册 TAB,直接折叠会话事件窗口(`tool/call` / `tool/result` / `assistant/live-chunk`),不订阅模型、不写会话日志。
|
|
106
|
+
- BGM 是浏览器 `<audio>`,音量用定时器做淡入淡出;歌曲元素在插件实例内复用,切 TAB 不会重新选歌。
|
|
107
|
+
|
|
108
|
+
## 已知限制
|
|
109
|
+
|
|
110
|
+
- 音频路由不支持 Range:切歌/首次加载会整首下载,慢的时候有一小段静音,之后才渐入。
|
|
111
|
+
- 如果浏览器拦截自动播放,点击或按键后会重试首播。
|
|
112
|
+
- 多行命令只显示首行摘要,不显示完整 heredoc。
|
|
113
|
+
- 历史命令在打开 TAB 时直接完整显示,不做打字回放。
|
|
114
|
+
- 依赖 DSH 客户端内部接口(`session.eventSource`、`conversation.view` 插槽、`/api` 精确路由),DSH 升级后可能需要跟随调整。
|
|
115
|
+
|
|
116
|
+
## 发布
|
|
117
|
+
|
|
118
|
+
用 Node.js 22 或更新版本运行 `npm test` 和 `npm run pack:release`。后者生成 `dist/ohmynpm-dsh-youth-mode-<版本>.tgz`,可直接分享。包内保留空音乐目录,本地曲目留在开发目录。
|
|
119
|
+
|
|
120
|
+
首次发布由有 `@ohmynpm` 发布权限的维护者上传此包。随后在 npm 为 `Of-qinhai/dsh-youth-mode` 的 `release.yml` 配置 Trusted Publishing。后续推送与版本号匹配的 `v<版本>` 标签,GitHub Actions 会测试并发布。
|
|
121
|
+
|
|
122
|
+
## 开发
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
node test/smoke.mjs
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
离线冒烟测试覆盖:Host 路由返回音频字节、配置脱敏、事件折叠、流式命令拼接、打字机推进。
|
|
129
|
+
|
|
130
|
+
## 目录
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
.
|
|
134
|
+
├── package.json # bundle 清单(dsh.bundle.patch + dsh.client)
|
|
135
|
+
├── cordis.patch.yml # 插件行与默认配置
|
|
136
|
+
├── index.js # Host 半:/api/youth-mode-bgm
|
|
137
|
+
├── client.js # Client 半:TAB、终端视图、BGM
|
|
138
|
+
├── icon.svg
|
|
139
|
+
├── locale/ # 插件管理器展示文案
|
|
140
|
+
├── audio/ # 本地音乐目录
|
|
141
|
+
└── test/smoke.mjs
|
|
142
|
+
```
|
package/audio/.gitkeep
ADDED
|
File without changes
|