dsh-hackertube 0.1.6 → 0.2.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 (7) hide show
  1. package/README.en.md +146 -173
  2. package/README.md +147 -175
  3. package/client.js +3635 -2568
  4. package/index.js +4126 -3215
  5. package/mirror.js +768 -0
  6. package/package.json +7 -2
  7. package/recommend.js +431 -0
package/README.en.md CHANGED
@@ -1,250 +1,223 @@
1
- # HackerTube for DeepSeek Harness
1
+ <div align="center">
2
2
 
3
- [简体中文](README.md) | English
3
+ # HackerTube for DeepSeek Harness
4
4
 
5
- Browse and watch the videos Hacker News has recommended over two decades, without leaving the DeepSeek Harness panel. A high-quality English video library within reach, which makes the harness a richer and more enjoyable place to work.
5
+ **Two Decades of Hacker News Top Technical Videos — Right Inside Your IDE**
6
6
 
7
- ![Home](docs/home-en.png)
7
+ [![npm version](https://img.shields.io/npm/v/dsh-hackertube.svg?style=flat-square&color=cb3837)](https://www.npmjs.com/package/dsh-hackertube)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](LICENSE)
9
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg?style=flat-square)](https://nodejs.org)
10
+ [![DeepSeek Harness](https://img.shields.io/badge/DSH-Plugin-blueviolet.svg?style=flat-square)](https://github.com/chow651/dsh-hackertube)
11
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-success.svg?style=flat-square)](package.json)
8
12
 
9
- The dataset comes from [HackerTube](https://karpathy.bearblog.dev/hacker-tube/) by Andrej Karpathy. The site ships a complete data export, and the author describes its purpose in his post:
13
+ [English](README.en.md) | [简体中文](README.md)
10
14
 
11
- > Export of the site's data available to give to your agent to easily create your own version.
15
+ <br />
12
16
 
13
- This plugin consumes that official export. It is an unofficial project and is not affiliated with Andrej Karpathy, Hacker News, or YouTube.
17
+ <p align="center">
18
+ No need to switch back and forth between editor tabs and a browser.<br />
19
+ Browse and watch 6,454 high-impact engineering talks, lectures, and documentaries<br />
20
+ recommended over twenty years on Hacker News, directly in your <b>DeepSeek Harness</b> workspace.<br />
21
+ Featuring full bilingual support, subtitle-aware AI answers, and a native Agent search tool.
22
+ </p>
14
23
 
15
- The original site works fine on its own. Moving it into the panel changes two things. You no longer switch windows, and the interface is fully available in Chinese, including titles, categories, summaries, and comments.
24
+ ![HackerTube Home Preview](docs/home-en.png)
16
25
 
17
- ## Browse by category
26
+ </div>
18
27
 
19
- The 6,454 videos sort into 16 areas, and each area splits into subcategories, 150 in total. When you do not know what to watch, start from the categories page.
28
+ ---
20
29
 
21
- ![Categories page](docs/categories-en.png)
30
+ ## ✨ Key Features
22
31
 
23
- | Area | Subcategories | Videos |
24
- |---|---:|---:|
25
- | Software Engineering & Languages | 11 | 980 |
26
- | Systems, Networks & Security | 10 | 702 |
27
- | AI, Machine Learning & Data | 9 | 576 |
28
- | Mathematics & Theoretical CS | 9 | 360 |
29
- | Hardware & Electronics | 8 | 582 |
30
- | Computing History & Culture | 8 | 1026 |
31
- | Design, Graphics & Visual Media | 9 | 439 |
32
- | Business, Startups & Economics | 9 | 644 |
33
- | Politics, History & Society | 9 | 1018 |
34
- | Physics, Space & Chemistry | 8 | 600 |
35
- | Life Sciences, Mind & Health | 11 | 598 |
36
- | Earth, Energy & Environment | 8 | 354 |
37
- | Engineering, Transport & Making | 12 | 805 |
38
- | Games & Game Development | 8 | 355 |
39
- | Arts, Comedy, Music & Film | 12 | 1344 |
40
- | Ideas, Learning & Language | 9 | 689 |
32
+ - 📺 **Seamless In-Editor Player**: Dedicated local relay avoids third-party embed and referrer restrictions. Watch high-value engineering talks side-by-side with your code without tab-switching.
33
+ - 🤖 **Subtitle-Aware AI Q&A**: Asking "what is this part about?" extracts the exact subtitle window around your current playhead (±3 mins) for grounded, precise technical explanations.
34
+ - 🇨🇳 **Built-in Bilingual Localization**: Ships with 6,454 Chinese titles and 166 taxonomy categories ready on install. Summaries and discussions support both on-demand model translation and machine translation fallback.
35
+ - 🔍 **Native Agent Tool**: Registers `hackertube_search` so your AI agent can query 20 years of HN technical recommendations directly inside coding conversations.
36
+ - 🎯 **Smart Alternative Mirrors**: Automatically identifies quality mirrors and subtitled versions on Chinese platforms (Bilibili) using strict physical duration fingerprints. Shows a direct entry only when found; remains completely silent otherwise.
37
+ - ⚡ **Zero Runtime Dependencies & Vector Recommendations**: Pure native Node.js implementation with 384-dimensional vector centroid recommendations. Fast cold starts and host-side persistence.
41
38
 
42
- A video can belong to more than one area, so the video counts add up to more than 6,454.
39
+ ---
43
40
 
44
- ## Installation
41
+ ## 🚀 Quick Start
45
42
 
46
- Requires DeepSeek Harness.
43
+ > **Prerequisite**: A running installation of [DeepSeek Harness](https://github.com/chow651/dsh-hackertube).
47
44
 
48
- ### Let your agent install it
45
+ ### Option 1: Let Your Agent Install It (Recommended)
49
46
 
50
- Paste this into a DeepSeek Harness session. The agent installs the plugin, enables it, and checks the result:
47
+ Simply send this prompt to your agent inside DeepSeek Harness:
51
48
 
52
- ```
49
+ ```text
53
50
  Install and enable the HackerTube plugin: plugin_manager install_bundle target=dsh-hackertube.
54
51
  If npm fails, use target=github:chow651/dsh-hackertube instead.
55
52
  Then confirm dsh-hackertube is enabled in the plugin list and remind me to refresh the page.
56
53
  ```
57
54
 
58
- ### Install with the plugin manager
55
+ ### Option 2: Install via Plugin Manager
59
56
 
60
- The package is published on npm:
57
+ Run directly in the DSH terminal:
61
58
 
62
- ```
59
+ ```bash
63
60
  plugin_manager install_bundle target=dsh-hackertube
61
+ # Or directly from the GitHub repository:
62
+ # plugin_manager install_bundle target=github:chow651/dsh-hackertube
64
63
  ```
65
64
 
66
- It can also be installed straight from the Git repository, though how the host parses the install argument depends on its version:
67
-
68
- ```
69
- plugin_manager install_bundle target=github:chow651/dsh-hackertube
70
- ```
71
-
72
- ### Install with npm or pnpm
65
+ ### Option 3: Manual Package Install
73
66
 
74
- ```
67
+ ```bash
68
+ # Inside your DSH profile directory
75
69
  npm install dsh-hackertube
76
- ```
77
-
78
- ```
70
+ # or
79
71
  pnpm add dsh-hackertube
80
72
  ```
81
73
 
82
- DSH loads plugins from its profile directory, so installing into an ordinary project has no effect. Install inside that profile directory, add the package name to its `dsh.profile.bundles` array, then restart DSH. The `plugin_manager` command above does all three steps for you. Take the manual route only for scripting or bulk deployment.
74
+ Enable `dsh-hackertube` in your plugin list and refresh the workspace. **No API keys or manual database initialization required.**
83
75
 
84
- After installing, enable `dsh-hackertube` in the plugin list and refresh the page. No configuration, no API key, and no data to fetch beforehand.
76
+ ---
85
77
 
86
- ## Features
78
+ ## 🤖 Native Agent Tool Integration
87
79
 
88
- ![Watch page](docs/watch-en.png)
80
+ The plugin registers `hackertube_search` with DeepSeek Harness. Your agent can search the library semantically during development workflows:
89
81
 
90
- The panel holds 6,454 videos across 16 areas and 150 categories, ordered by how strongly Hacker News recommends them. The home grid loads 60 cards at first and appends more as you scroll.
82
+ ### Example Exchange
91
83
 
92
- The watch page has the player, the Hacker News discussion for that video, and a related rail on the right. The rail has a second pane for AI questions. It hands the model the subtitle lines within three minutes of the current playhead, so you can ask what a particular segment covers.
84
+ > **You**: Is there any video explaining the Raft consensus algorithm? Ideally by the author.
93
85
 
94
- Search works with English and Chinese queries. A Chinese query matches both the Chinese title and the English tags.
86
+ **Agent** calls `hackertube_search({ query: "Raft consensus", limit: 5 })` and replies:
95
87
 
96
- Likes, watch later, and history live on the host side, so clearing browser data does not lose them.
88
+ > Yes, Raft's author Diego Ongaro delivered a comprehensive lecture at Stanford: *Raft User Study Lecture* (58 min, recommended by 4 HN members). HN comments highlight that it is much more approachable than reading the paper alone. You can also watch the accompanying *Paxos Lecture* (67 min) for foundational background.
89
+ > 🔗 https://www.youtube.com/watch?v=YbZ3zDzDnrw
97
90
 
98
- ### Keyboard shortcuts
91
+ ### Tool Parameters
99
92
 
100
- | Key | Action |
101
- |---|---|
102
- | `/` | Focus the search field |
103
- | `j` `k` | Move between cards |
104
- | `Enter` | Open the focused card |
105
- | `l` | Like |
106
- | `w` | Add to watch later |
107
- | `h` | Back to home |
108
- | `?` | Show all shortcuts |
109
- | `Esc` | Close overlay |
93
+ | Parameter | Type | Required | Description |
94
+ |---|---|---|---|
95
+ | `query` | string | Yes | Search query in English or Chinese (e.g. `compiler optimization`, `micrograd`) |
96
+ | `limit` | number | No | Number of results to return (default `5`, max `15`) |
97
+ | `lang` | string | No | Language for returned text: `zh` (default) or `en` |
110
98
 
111
- ## A tool for your agent
99
+ ---
112
100
 
113
- The plugin registers a tool named `hackertube_search`. Once installed, your agent can search this video library from any conversation, without opening the panel.
101
+ ## 💡 Comparison with the Original Site
114
102
 
115
- ### One full exchange
103
+ Built upon Andrej Karpathy's open [HackerTube data export](https://karpathy.bearblog.dev/hacker-tube/), tailored specifically for developer environments:
116
104
 
117
- You ask:
118
-
119
- > Which video should I actually watch to understand backpropagation?
120
-
121
- The agent calls `hackertube_search({ query: "backpropagation", limit: 5, lang: "en" })`, and the tool returns (excerpt):
122
-
123
- ```
124
- 1. The spelled-out intro to neural networks and backpropagation: building micrograd — Andrej Karpathy · 146 min · 4.4M views · 17 recommenders
125
- HN: HN treats it as the best starting point for really understanding backprop and neural nets…
126
- https://www.youtube.com/watch?v=VMj-3S1tku0
127
-
128
- 2. Backpropagation, intuitively | Deep Learning Chapter 3 — 3Blue1Brown · 13 min · 6.4M views · 4 recommenders
129
- HN: Recommended as the most accessible introduction to backprop for people who struggle with the pure math.
130
- https://www.youtube.com/watch?v=Ilg3gGewQ5U
131
- ```
132
-
133
- The agent answers:
105
+ | Capability | Original Site | HackerTube DSH Plugin |
106
+ |---|---|---|
107
+ | **Context** | Standalone web browser | **Embedded inside DSH workspace** |
108
+ | **Localization** | English only | **Full EN/ZH bilingual**, 6,454 translated titles ready |
109
+ | **AI Q&A** | None | **Subtitle-aware temporal Q&A** |
110
+ | **Agent Tool** | None | **Native `hackertube_search` tool** |
111
+ | **Mirror Sources** | YouTube only | **Smart physical fingerprint matching for mirrors** |
112
+ | **State Persistence** | Ephemeral browser storage | **Host-side local persistence** (safe across cache clears) |
113
+ | **Recommendations** | None | **384-d vector centroid + HN co-recommendation graph** |
114
+ | **Offline Resilience** | Full network dependent | **Local caching + graceful offline degradation** |
134
115
 
135
- > Start with Karpathy's "building micrograd", 146 min. It has 17 recommenders, the strongest signal HN gives, and it builds backpropagation from scratch in code instead of explaining it on paper. If you want the intuition first, watch the 3Blue1Brown chapter (13 min) before it.
136
- > https://www.youtube.com/watch?v=VMj-3S1tku0
116
+ ---
137
117
 
138
- ### Good requests for it
118
+ ## 🖥️ Watch Page & Shortcuts
139
119
 
140
- - Any talk explaining Raft consensus
141
- - A few lectures on compiler optimization
142
- - Which Karpathy video covers backpropagation
120
+ ![Watch Page and AI Q&A](docs/watch-en.png)
143
121
 
144
- ### What it does
122
+ ### Keyboard Shortcuts
145
123
 
146
- Searches titles, channels, tags and categories in English and Chinese, plus each video's summary and Hacker News recommendation note. Results carry title, channel, duration, view count, recommender count, the recommendation note and a link, ordered by how strongly Hacker News recommends them. Chinese queries work, and titles come back in Chinese when a translation exists.
124
+ | Key | Action | Key | Action |
125
+ |---|---|---|---|
126
+ | `/` | Focus search bar | `j` / `k` | Navigate cards up/down |
127
+ | `Enter` | Open selected video | `l` | Like / Unlike |
128
+ | `w` | Add to Watch Later | `h` | Return to Home |
129
+ | `?` | Show shortcut cheatsheet | `Esc` | Close details or overlay |
147
130
 
148
- | Parameter | Meaning |
149
- |---|---|
150
- | `query` | Search terms, English or Chinese |
151
- | `limit` | Result count, default 5, max 15 |
152
- | `lang` | Language for the returned text, `zh` or `en`, default `zh` |
131
+ ### 🎯 Smart Alternative Mirrors
153
132
 
154
- ## First launch
133
+ For users facing network restrictions or seeking localized subtitles, the watch view dynamically checks for verified Chinese platform (Bilibili) mirrors:
155
134
 
156
- The plugin starts downloading the official export as soon as it loads, 17.8 MB in one request, and at the same time requests upstream pages to fill in YouTube duration, view count, and publish date. The list is only complete once both finish. A skeleton screen covers the panel in the meantime.
135
+ - **Strict Fingerprint Verification**: Compares exact duration (within ±2s tolerance), chronological release order, and bidirectional description references to rule out homonymous uploads or derivative commentary.
136
+ - **Tier Quality Ranking**: Prioritizes `Official Channel` → `Subtitled / Translated` → `High-definition Repost`.
137
+ - **Zero Noise & Silent Lookup**: Lookups are on-demand and cached locally. If no valid mirror exists, **no placeholder is rendered** — keeping the interface clean and distraction-free.
157
138
 
158
- | Scenario | Measured |
159
- |---|---|
160
- | First install, empty cache | about 10 seconds |
161
- | Later launches, list load | 45 ms |
162
- | Opening a watch page | 10 ms |
163
- | Related, the 3,778 videos with co-recommendation data | 2 ms |
164
- | Related, the other 2,676 videos, by vector similarity | about 0.7 s on first use |
165
- | Machine translation of summary and recommendation note | 0.4 to 1.8 s on first use |
139
+ <details>
140
+ <summary><b>📂 Click to expand: 16 Core Knowledge Domains (6,454 Videos)</b></summary>
166
141
 
167
- The export stays valid for seven days. YouTube metadata is cached for twenty-four hours.
142
+ <br />
168
143
 
169
- ## Chinese support
144
+ ![Categories View](docs/categories-en.png)
170
145
 
171
- Every interface string goes through `tx(lang, 中文, English)`, so neither language mode shows mixed text. Number units follow the language, with 万 and 亿 in Chinese and K and M in English.
146
+ | Area | Subcategories | Videos |
147
+ |---|---:|---:|
148
+ | Software Engineering & Languages | 11 | 980 |
149
+ | Systems, Networks & Security | 10 | 702 |
150
+ | AI, Machine Learning & Data | 9 | 576 |
151
+ | Mathematics & Theoretical CS | 9 | 360 |
152
+ | Hardware & Electronics | 8 | 582 |
153
+ | Computing History & Culture | 8 | 1026 |
154
+ | Design, Graphics & Visual Media | 9 | 439 |
155
+ | Business, Startups & Economics | 9 | 644 |
156
+ | Politics, History & Society | 9 | 1018 |
157
+ | Physics, Space & Chemistry | 8 | 600 |
158
+ | Life Sciences, Mind & Health | 11 | 598 |
159
+ | Earth, Energy & Environment | 8 | 354 |
160
+ | Engineering, Transport & Making | 12 | 805 |
161
+ | Games & Game Development | 8 | 355 |
162
+ | Arts, Comedy, Music & Film | 12 | 1344 |
163
+ | Ideas, Learning & Language | 9 | 689 |
172
164
 
173
- Content-level Chinese comes from four places.
165
+ > Note: Cross-domain videos may belong to multiple categories, so category totals exceed 6,454.
174
166
 
175
- | Content | Source | When it applies |
176
- |---|---|---|
177
- | 6,454 video titles | Translation table shipped in the repository | Immediately after install |
178
- | 166 category names | Shipped in the repository | Immediately after install |
179
- | Summary, recommendation note, quoted comment | Translated when the page opens | Model first, machine translation as fallback |
180
- | Hacker News comment bodies | Per comment or in bulk, on demand | About 1 second, then cached |
167
+ </details>
181
168
 
182
- Model output and machine translation are stored separately. Once a model is configured, its translations replace the machine output rather than being blocked by it.
169
+ ---
183
170
 
184
- Machine translation uses the public Google web translate endpoint. Comment bodies stay in English by default. Translation is an explicit action.
171
+ ## ⚡ Architecture & Performance
185
172
 
186
- ## Dependencies and degradation
173
+ - **Zero Runtime Dependencies**: Archive unpacking uses Node.js native `zlib`; no third-party npm packages required at runtime.
174
+ - **Latency Benchmarks**:
175
+ - Initial catalogue render: **~45 ms**
176
+ - Watch view open: **~10 ms**
177
+ - Co-recommendation query: **~2 ms**
178
+ - Vector cosine neighbor search: **~0.7 s** on initial run, instant in-memory afterwards
179
+ - **Graceful Degradation**:
187
180
 
188
- | Capability | Requires | Without it |
181
+ | Module | Requirements | Behavior When Missing / Offline |
189
182
  |---|---|---|
190
- | List, categories, search, playback | The DSH web server and network access | The panel or the player does not load |
191
- | Chinese titles and category names | Nothing | Shipped with the repository |
192
- | Chinese for summary and the other two fields | A model or network access | English source text is shown |
193
- | AI questions | A model configured in DSH | The panel reports the model is unavailable, everything else works |
194
- | Comment translation | Network access | The button does nothing and the text stays as written |
195
- | Subtitles and direct-stream fallback | `yt-dlp` and `ffmpeg` on PATH | Video still plays, the AI answers lose subtitle context |
196
-
197
- Both `yt-dlp` and `ffmpeg` are optional. They affect two things only, whether AI answers can use subtitles and whether playback can fall back to a direct stream when YouTube refuses the embed.
198
-
199
- ## Data source
183
+ | **Browsing & Basic Playback** | DSH Web Container & Network | Local offline search remains available |
184
+ | **Chinese Titles & Categories** | None | Shipped with repo, 100% offline available |
185
+ | **Summaries & Comment Translation** | Model or Translation Endpoint | Automatically falls back to English source |
186
+ | **AI Q&A** | Configured DSH model | Warns model unavailable; playback unaffected |
187
+ | **Subtitle Extraction** | Optional `yt-dlp` + `ffmpeg` | AI answers lose subtitle context; playback unaffected |
188
+ | **Alternative Mirror** | Domestic platform connectivity | Hides button silently; normal playback unaffected |
200
189
 
201
- `https://hackertube.org/download/hackertube-data.zip`, 17.8 MB, exported on 31 October 2026.
190
+ <details>
191
+ <summary><b>📁 Data Source & Local Cache Directory Layout</b></summary>
202
192
 
203
- ```
204
- videos.jsonl 6,454 videos with title, channel, summary, recommendation note, tags, categories, HN stats
205
- mentions.jsonl 39,834 HN comments with author, month, stance, and body
206
- related.jsonl 3,778 co-recommendation rows
207
- embeddings.npy 6,454 × 384 float16 vectors, used to fill in videos without co-recommendation data
208
- embedding_ids.json Row index to video id
209
- taxonomy.json 150 categories in 16 areas
210
- ```
211
-
212
- Unpacking uses the zlib module built into Node, so the plugin ships with no npm runtime dependencies.
213
-
214
- The export has no duration, view count, publish date, or thumbnail, since those are YouTube metadata. The list therefore still requests 65 upstream pages in parallel to fill them in, cached for one day.
193
+ <br />
215
194
 
216
- ## Cache
195
+ Cached under `$DSH_PROFILE_DIR/.dsh-hackertube/` (default: `~/.dsh/.dsh-hackertube/`):
217
196
 
218
- Everything lives under `$DSH_PROFILE_DIR/.dsh-hackertube/`, by default `~/.dsh/.dsh-hackertube/`. Deleting the directory resets the plugin to a clean state.
219
-
220
- ```
221
- export/ Unpacked official data, about 48 MB
222
- i18n/zh-titles.json Title translations
223
- i18n/zh-taxonomy.json Category translations
224
- i18n/zh.json Model translations for detail text
225
- i18n/zh-mt.json Machine translations for detail text
226
- i18n/zh-comments.json Comment translation cache
227
- list.json YouTube metadata and list snapshot
228
- prefs.json Likes, watch later, history
229
- subs/ Subtitles
197
+ ```text
198
+ .dsh-hackertube/
199
+ ├── export/ # Unpacked official export (~48 MB: videos, mentions, embeddings.npy)
200
+ ├── i18n/ # Translation caches (titles, taxonomy, model output, MT cache)
201
+ ├── list.json # YouTube metadata snapshot (views, duration, dates)
202
+ ├── prefs.json # Likes, watch later list, playback progress history
203
+ ├── subs/ # On-demand subtitle files
204
+ └── mirror.json # Alternative mirror lookup cache
230
205
  ```
231
206
 
232
- ## Known limitations
233
-
234
- Title translations are model output checked by rules. Most read naturally, and roughly a thousand remain close to word-for-word.
235
-
236
- A Chinese query is machine translated into English before it can reach English tags. That costs one request per query, debounced by 300 ms and cached in memory. Offline, only local matching applies.
207
+ Delete this directory at any time to reset to a pristine state.
237
208
 
238
- YouTube embeds follow upstream policy. Age-restricted and region-restricted videos are only available on YouTube.
209
+ </details>
239
210
 
240
- The playback relay listens on `127.0.0.1:18090`, falling back to 18091 and 18092 when the port is taken.
211
+ ---
241
212
 
242
- ## Credits
213
+ ## 📌 Credits & Disclaimer
243
214
 
244
- Thanks to Andrej Karpathy for building HackerTube and for publishing its data export. This plugin builds on that work.
215
+ - Core data is powered by the [HackerTube](https://karpathy.bearblog.dev/hacker-tube/) project created by **[Andrej Karpathy](https://github.com/karpathy)**.
216
+ - Discussion snippets originate from [Hacker News](https://news.ycombinator.com). Video content copyright belongs to respective YouTube creators.
217
+ - This is an independent open-source plugin and is not officially affiliated with Andrej Karpathy, Hacker News, or YouTube.
245
218
 
246
- Discussion content comes from [Hacker News](https://news.ycombinator.com). Videos are hosted on YouTube.
219
+ ---
247
220
 
248
- ## License
221
+ ## 📄 License
249
222
 
250
- MIT
223
+ [MIT License](LICENSE) © 2026