dsh-teacher 0.0.0-stage → 0.1.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/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +203 -2
- package/README.zh-CN.md +204 -0
- package/cordis.patch.yml +11 -0
- package/dist/client.js +3126 -0
- package/icon.svg +1 -0
- package/locale/en.json +1 -0
- package/locale/zh.json +1 -0
- package/package.json +89 -4
- package/scripts/adapt-teach.mjs +57 -0
- package/scripts/build.mjs +7 -0
- package/src/anchors.js +22 -0
- package/src/answer-policy.js +17 -0
- package/src/answers.js +55 -0
- package/src/bridge.js +328 -0
- package/src/client/answer-blocks.js +50 -0
- package/src/client/answer.jsx +36 -0
- package/src/client/backup.js +34 -0
- package/src/client/browser-view.jsx +36 -0
- package/src/client/browser.js +97 -0
- package/src/client/comments.js +340 -0
- package/src/client/i18n.js +132 -0
- package/src/client/icons.jsx +17 -0
- package/src/client/index.jsx +696 -0
- package/src/client/model.js +65 -0
- package/src/client/presentation.js +40 -0
- package/src/client/progress.js +86 -0
- package/src/client/review.jsx +207 -0
- package/src/client/selection.js +15 -0
- package/src/client/setup.jsx +116 -0
- package/src/client/store.js +292 -0
- package/src/client/styles.js +229 -0
- package/src/config.js +18 -0
- package/src/gestures.js +40 -0
- package/src/host.js +350 -0
- package/src/index.js +47 -0
- package/src/install-teach.js +91 -0
- package/src/protocol.js +38 -0
- package/vendor/teach/GLOSSARY-FORMAT.md +35 -0
- package/vendor/teach/LEARNING-RECORD-FORMAT.md +46 -0
- package/vendor/teach/LICENSE +21 -0
- package/vendor/teach/MISSION-FORMAT.md +31 -0
- package/vendor/teach/RESOURCES-FORMAT.md +32 -0
- package/vendor/teach/SKILL.md +140 -0
- package/vendor/teach/SOURCE.md +5 -0
- package/vendor/teach/agents/openai.yaml +5 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 更新记录
|
|
2
|
+
|
|
3
|
+
## 0.1.0 · 2026-11-27
|
|
4
|
+
|
|
5
|
+
首个公开开源版本,以 MIT 协议发布并支持 npm(`dsh-teacher`)、Release 分发包与本地源码安装。已在 macOS(DSH Desktop `0.2.2-rc.1` / `0.2.2-rc.2`)完成实机验收,并在 macOS 与 Linux(Ubuntu 24.04 arm64)通过全部自动化 Electron 回归与生产包安装验证。
|
|
6
|
+
|
|
7
|
+
### 核心阅读与导航
|
|
8
|
+
|
|
9
|
+
- 独立只读 Host 路由与受控阅读外壳,自动发现工作区内的 `MISSION.md`、课件、参考卡与静态资源,接管对话中的课件文件链接。
|
|
10
|
+
- 支持侧栏(Side)、浮窗(Float)、整页(Full)三种布局即时切换,偏好跨重启保留;窄侧栏自动优化标题与目录空间。
|
|
11
|
+
- 课件/参考卡内部跳转与页面返回栈,按工作区跨重启续读上次课件及滚动位置。
|
|
12
|
+
- 外链点击前展示目标站点与完整 URL 确认框,确认后支持在所有布局内原地浏览(含前进、后退、地址栏与系统浏览器切换),返回时无损恢复来源课件。
|
|
13
|
+
- 支持触控板横向手势返回,优先后退网页历史再返回来源课件,修复纵向阅读滚动后立即横滑被忽略的问题,并做好代码块横向滚动与惯性连退隔离。
|
|
14
|
+
- 目录索引复用未变化文件的元数据并限制并发读取;支持目录搜索、冷启动链接等待索引就绪、缺失/超限/不可读原因提示与重试,以及 Host/Client 协议版本错配检测。
|
|
15
|
+
|
|
16
|
+
### 批注追问与教学工作流
|
|
17
|
+
|
|
18
|
+
- 两阶段选区追问入口(悬浮胶囊按钮 → 原文旁评论气泡),历史问答以暖色高亮下划线锚定于原文并可随时点击重开;支持代码块、列表渲染、草稿保留、失败重试与同源窗口评论合并。
|
|
19
|
+
- 普通追问默认在工具执行层实施只读限制,修改课件通过次级入口「请求修改课件…」放入原对话由用户确认后发送;同时保留「插入输入框」原生引用模式。
|
|
20
|
+
- 内置固定版本的 `/teach` skill 与模板,支持在空工作区一键离线安装、自动适配阅读与测验回报并即时刷新会话技能列表,也提供已有 `/teach` 的适配与安全恢复脚本。
|
|
21
|
+
- 底栏提供「标记已学完」与「下一节未完成课件 →」入口;测验结果按课件内容版本保存,内容更新后提示复练。
|
|
22
|
+
- 复习面板分「学习」与「课件评论」双标签,集总进度条、续读、`learning-records/` 学习记录查看(自动提取 Markdown 标题)、全工作区问答搜索与 JSON 备份导出/去重合并导入。
|
|
23
|
+
- 视觉与交互全面对齐 DSH 原生风格,支持浅色/深色主题与中英文界面即时切换。
|
|
24
|
+
|
|
25
|
+
### 安全隔离与工程验证
|
|
26
|
+
|
|
27
|
+
- 严格目录与扩展名白名单、拒绝路径穿越与符号链接、owner 认证准入、`sandbox="allow-scripts"` 与 `connect-src 'none'` 双重 CSP 隔离,阻断课件对网络与 Host 接口的访问。
|
|
28
|
+
- 使用 HTML 解析安全定位桥接注入位置;损坏评论记录自动隔离并在覆盖前备份原始数据至 `.recovery` 键。
|
|
29
|
+
- 包含 92 项 Node 单元测试、6 组 Electron 桌面回归(CSP、评论、选区、导航、手势、阅读器)、独立生产包安装验证、依赖审计与 macOS GitHub Actions 工作流。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cigui
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,204 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-teacher
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
A lightweight, non-intrusive study workspace for `/teach`-generated HTML lessons inside **DeepSeek Harness (DSH) Desktop** — focused on side-by-side reading, inline highlight-to-ask annotations, in-reader web browsing, and progress review.
|
|
6
|
+
|
|
7
|
+
**No custom agent preset, no proprietary course format, and zero workspace lock-in.** `dsh-teacher` works directly with your existing agent setup and standard `/teach` HTML files (`MISSION.md`, `lessons/`, `reference/`, `assets/`, `learning-records/`). Unlike DSH's built-in Blob iframe preview — which breaks relative links, shared assets, and reading continuity — it serves lessons through a dedicated read-only Host route and sandboxed reader so you can read, annotate, check docs, and review without leaving your conversation.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Lesson & Reference Reader**: Automatically discovers `MISSION.md`, lessons, and reference cards in the current workspace, with working relative links, shared assets, directory search, and reading position persistence across restarts.
|
|
12
|
+
- **Highlight-to-Ask Annotations**: Select any passage and click the floating **Ask** pill to open a discussion bubble right beside the text. Discussions default to **read-only Q&A** (tool execution is blocked); past discussions stay anchored on the page as warm highlight underlines you can reopen anytime. Need to revise a lesson? Expand **Request a lesson edit...** to stage an explicit edit request in the main chat.
|
|
13
|
+
- **In-Reader External Browsing**: External links show a confirmation dialog with the target host and URL, then open right inside the lesson pane (with back/forward, address bar, and system browser fallback). Returning restores the source lesson and scroll position, with horizontal trackpad swipe-back support.
|
|
14
|
+
- **Progress, Quizzes & Review**: Mark lessons complete or jump to the next unfinished lesson from the footer bar. Quiz results are tracked per lesson content hash and prompt for a retry when a lesson changes. The **Review** panel combines a progress bar, recent reading, `learning-records/` notes, and workspace-wide discussion search.
|
|
15
|
+
- **Flexible Layouts & Bilingual UI**: Switch seamlessly between **Side**, **Float**, and **Full** layouts. The UI follows DSH's native light/dark theme and English/Chinese language settings.
|
|
16
|
+
- **Workspace Backup & Restore**: Annotations, drafts, progress, and reading positions are stored locally per workspace and can be exported or merge-imported as JSON.
|
|
17
|
+
|
|
18
|
+
## Compatibility & Requirements
|
|
19
|
+
|
|
20
|
+
| Item | Details |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| Version | `0.1.0` (`npm`, GitHub Release `.tgz`, or local directory) |
|
|
23
|
+
| Node.js | `>= 22.12.0` |
|
|
24
|
+
| Validated On | macOS (arm64), DSH Desktop `0.2.2-rc.1` / `0.2.2-rc.2` |
|
|
25
|
+
| Upstream DSH Notes | Expected to work on `0.2.2-rc.5`. DSH `0.2.3-alpha.x` introduces breaking plugin changes (Cordis 4.0, client bundle/style mounting, `fileAddressFor`, Node.js `24.22.3+`) that are not yet adapted or verified |
|
|
26
|
+
| Other Platforms | Automated Electron and package install regressions pass on Linux (Ubuntu 24.04 arm64); Windows, Linux Desktop, and Web GUI are not yet verified in the real DSH app; CLI mode is not supported |
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
### 1. Install the Plugin
|
|
31
|
+
|
|
32
|
+
#### Option A: Install from npm (recommended)
|
|
33
|
+
|
|
34
|
+
In DSH Desktop, go to **Plugins → Add plugin → Install a third-party plugin**, enter `dsh-teacher`, install it, and click **Enable now**.
|
|
35
|
+
|
|
36
|
+
#### Option B: Install from a Release `.tgz` Tarball
|
|
37
|
+
|
|
38
|
+
Download `dsh-teacher-0.1.0.tgz` and `SHA256SUMS` from GitHub Releases, verify and extract into a permanent directory, then install production dependencies only (the client bundle is prebuilt, so Electron and esbuild are not required):
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
shasum -a 256 -c SHA256SUMS
|
|
42
|
+
mkdir -p dsh-teacher-0.1.0
|
|
43
|
+
tar -xzf dsh-teacher-0.1.0.tgz -C dsh-teacher-0.1.0
|
|
44
|
+
cd dsh-teacher-0.1.0/package
|
|
45
|
+
npm install --omit=dev --ignore-scripts
|
|
46
|
+
pwd
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Paste the printed `package` directory path into **Plugins → Add plugin → Install a third-party plugin**, install, and enable. Keep this directory on disk because local plugins are linked.
|
|
50
|
+
|
|
51
|
+
#### Option C: Build from Source
|
|
52
|
+
|
|
53
|
+
Clone this repository into a permanent directory, then run:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
git clone https://github.com/cigui/dsh-teacher.git
|
|
57
|
+
cd dsh-teacher
|
|
58
|
+
npm ci
|
|
59
|
+
npm run check
|
|
60
|
+
pwd
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`npm run check` runs syntax checks, unit tests, and builds `dist/client.js`. Paste the printed directory path into **Plugins → Add plugin → Install a third-party plugin** and click **Enable now**.
|
|
64
|
+
|
|
65
|
+
### 2. Install `/teach` in Your Workspace
|
|
66
|
+
|
|
67
|
+
Open any DSH session with a working directory and click **Lessons** in the left sidebar or session header.
|
|
68
|
+
|
|
69
|
+
In the welcome card, click **Install `/teach` in this workspace**. The plugin installs the bundled `/teach` skill and templates offline, adapts them for inline reading and quiz reporting, and refreshes the session's skill list.
|
|
70
|
+
|
|
71
|
+
- **Install location**: Git repository root when inside a Git repo, otherwise the current session directory.
|
|
72
|
+
- **Already have `/teach`?** The setup guide detects your installation and provides the adaptation command (see [Adapting an Existing `/teach`](#adapting-an-existing-teach)).
|
|
73
|
+
|
|
74
|
+
### 3. Generate Your First Lesson
|
|
75
|
+
|
|
76
|
+
Click **Go to chat to run `/teach`** (or type `/teach` in chat) and tell the agent what you want to learn. Generated lessons appear in the **Contents** directory automatically with an unread badge so you can open them when ready.
|
|
77
|
+
|
|
78
|
+
To revisit setup status later, open **More (`⋯`) → View setup steps**.
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
### Reading, Navigation & External Links
|
|
83
|
+
|
|
84
|
+
- **Relative links & history**: Links between lessons and reference cards open directly in the reader. Use the top **Back** button to step back with scroll positions preserved. Internal back history lives for the current plugin session, while the last lesson and scroll position persist per workspace across restarts.
|
|
85
|
+
- **External links**: Clicking an external URL prompts for confirmation before opening in the in-reader browser (across Side, Float, and Full layouts) or your system browser.
|
|
86
|
+
- **Trackpad back gesture**: Horizontal swipe-back steps back through web history first, then returns to the source lesson, with isolation for vertical scrolling, horizontal code blocks, and scroll inertia. Swipe direction follows your system natural scrolling setting; the toolbar **Back** button is always available.
|
|
87
|
+
|
|
88
|
+
### Highlight-to-Ask Discussions
|
|
89
|
+
|
|
90
|
+
1. Select text in a lesson and click the floating **Ask** pill.
|
|
91
|
+
2. Pick a quick prompt or type your question, then click **Send**.
|
|
92
|
+
3. Read the answer (updated when the model turn completes; live streaming stays visible in the main chat) and ask follow-ups inline; close the bubble and click the warm highlight underline anytime to reopen it.
|
|
93
|
+
|
|
94
|
+
The toolbar **Discussions** list retains all Q&A for the current lesson even if the underlying text changes and an anchor can no longer be placed. Same-origin windows merge discussion updates for the same workspace.
|
|
95
|
+
|
|
96
|
+
> **Read-only Q&A vs. Lesson Edits**: Standard selection questions run in read-only mode (tool calls are blocked). To modify a lesson file, expand **Request a lesson edit...** at the bottom of the bubble to place an edit request into the main chat composer for your review. If you prefer editing questions before sending, switch **Ask behavior** to **Insert** under **More → Settings**.
|
|
97
|
+
|
|
98
|
+
### Progress, Review & Backups
|
|
99
|
+
|
|
100
|
+
- **Footer bar**: Shows completion and quiz status with one-click **Mark this lesson complete** and **Next unfinished lesson →** actions (advancing does not auto-complete the current lesson).
|
|
101
|
+
- **Review panel**: Switch between **Learning** (progress bar, resume reading, and `learning-records/` notes) and **Discussions** (search all Q&A across the workspace and jump back to the source passage).
|
|
102
|
+
- **Backup & import**: Export or merge-import workspace Q&A, drafts, and progress under **Review → Learning → Workspace learning backup**.
|
|
103
|
+
|
|
104
|
+
## Where Data Is Stored
|
|
105
|
+
|
|
106
|
+
| Data | Location |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| Lessons, reference cards, assets, learning records | Workspace files on disk (managed by `/teach`) |
|
|
109
|
+
| Discussions, text anchors, drafts, progress, reading positions | Local DSH client `localStorage` (scoped per workspace) |
|
|
110
|
+
| Layout & reader preferences | Local DSH client `localStorage` |
|
|
111
|
+
| Sent Q&A turns | Original DSH conversation (linked in Discussions) |
|
|
112
|
+
|
|
113
|
+
> Workspace backups include discussions, drafts, and progress — **not** lesson HTML files, learning records, or full DSH chat histories. Deleting a local discussion does not delete messages from the original DSH conversation. If corrupted discussion records are detected, invalid entries are quarantined and the raw data is backed up to a `.recovery` key before overwriting.
|
|
114
|
+
|
|
115
|
+
## Configuration
|
|
116
|
+
|
|
117
|
+
Everyday preferences can be changed in **More → Settings** (saved locally per device and taking precedence over plugin defaults). To configure defaults in DSH or your `cordis.patch.yml`:
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
- id: dsh-teacher
|
|
121
|
+
config:
|
|
122
|
+
layout: side
|
|
123
|
+
autoFocus: badge
|
|
124
|
+
askOnSelect: true
|
|
125
|
+
askSend: direct
|
|
126
|
+
externalLinks: sidebar
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
| Option | Default | Description |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| `layout` | `side` | `side`, `float`, or `panel` (full page) |
|
|
132
|
+
| `autoFocus` | `badge` | `badge` (notify with badge), `switch` (auto-open new lessons), or `off` |
|
|
133
|
+
| `askOnSelect` | `true` | Show the floating Ask action on new text selections |
|
|
134
|
+
| `askSend` | `direct` | `direct` (send from bubble) or `insert` (insert quote into chat composer) |
|
|
135
|
+
| `askMaxChars` | `2000` | Max quoted characters (`15`–`20000`); longer selections are truncated with notice |
|
|
136
|
+
| `quickPrompts` | 4 built-in prompts | Up to 12 quick prompts, max 100 characters each |
|
|
137
|
+
| `externalLinks` | `sidebar` | `sidebar` (open in-reader) or `system` (default browser) |
|
|
138
|
+
| `workspaceRoot` | `""` | Optional absolute path override for the workspace root |
|
|
139
|
+
| `pollIntervalMs` | `2000` | Polling interval (`500`–`60000` ms) when file watching is unavailable |
|
|
140
|
+
|
|
141
|
+
## Adapting an Existing `/teach`
|
|
142
|
+
|
|
143
|
+
If your workspace already has `/teach` installed, use the command shown in the setup guide or run from the repository root (supports both `.agents/skills/teach/SKILL.md` and single-file `teach.md`):
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
# Adapt existing /teach (backs up the original automatically)
|
|
147
|
+
node scripts/adapt-teach.mjs /absolute/workspace/.agents/skills/teach/SKILL.md
|
|
148
|
+
|
|
149
|
+
# Restore the original (aborts safely if manual edits are detected)
|
|
150
|
+
node scripts/adapt-teach.mjs --restore /absolute/workspace/.agents/skills/teach/SKILL.md
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Workspace Structure & Security Model
|
|
154
|
+
|
|
155
|
+
The plugin reads the following workspace layout:
|
|
156
|
+
|
|
157
|
+
```text
|
|
158
|
+
workspace/
|
|
159
|
+
├── MISSION.md # Learning goal (first paragraph shown in Contents)
|
|
160
|
+
├── lessons/*.html # Lessons sorted in natural order
|
|
161
|
+
├── reference/*.html # Reference / cheat-sheet cards
|
|
162
|
+
├── assets/ # Shared CSS, JS, images, fonts
|
|
163
|
+
└── learning-records/*.md # Study notes viewable in Review
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
- **Sandbox & CSP Isolation**: Lessons run inside `sandbox="allow-scripts"` (without `allow-same-origin`) with a strict CSP (`connect-src 'none'`). Only whitelisted static files under the session's workspace `assets/` are served; path traversal, symlinks, `fetch`, browser storage, and popups are blocked. Classic JavaScript, standard CSS, and system fonts are supported.
|
|
167
|
+
- **Custom Quiz Reporting**: Custom lessons can report quiz results after grading by dispatching:
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
document.dispatchEvent(new CustomEvent('dsh-teacher:quiz-result', {
|
|
171
|
+
detail: { passed: true },
|
|
172
|
+
}));
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Upgrade, Rollback & Uninstall
|
|
176
|
+
|
|
177
|
+
- **Upgrade**: For npm installs, update through DSH **Plugins** and restart DSH Desktop after Host or bridge changes. For local or tarball installs, keep the previous directory until verified, disable the old version before enabling the new directory (never enable two copies of the plugin simultaneously), and restart DSH. If the client loads ahead of an older Host, the reader displays a protocol mismatch banner prompting you to restart and re-check.
|
|
178
|
+
- **Rollback**: Disable the newer version in **Plugins**, re-enable the previous directory, and restart DSH. Do **not** wipe DSH application data — local discussions (`dsh-teacher.comments.v1.<workspace>`), progress, and workspace files remain compatible.
|
|
179
|
+
- **Uninstall**: Disable or uninstall **Lesson learning** in DSH **Plugins**. Panel entries and routes unregister automatically, chat links fall back to DSH's built-in preview, and your workspace lesson files remain untouched. Export a workspace backup first if you want to keep local discussions and progress.
|
|
180
|
+
|
|
181
|
+
## Development & Verification
|
|
182
|
+
|
|
183
|
+
```sh
|
|
184
|
+
npm run check # Syntax checks, Node unit tests, and client build
|
|
185
|
+
npm run test:electron # All 6 Electron desktop regressions (CSP, comments, selection, navigation, gestures, reader)
|
|
186
|
+
npm run test:package # Pack tarball and verify production install in an isolated project
|
|
187
|
+
npm run check:release # Full pre-release check + production dependency audit (outputs to artifacts/)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
To test against the exact Electron binary bundled with your DSH Desktop installation (e.g., Electron `44.7.0` in DSH `0.2.2-rc.2`):
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
DSH_ELECTRON=/absolute/path/to/Electron npm run test:electron
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
After editing `src/client/`, run `npm run build`. After editing Host (`src/index.js`, `src/host.js`) or bridge (`src/bridge.js`) files, restart DSH Desktop.
|
|
197
|
+
|
|
198
|
+
## Changelog & License
|
|
199
|
+
|
|
200
|
+
- [Changelog](CHANGELOG.md)
|
|
201
|
+
|
|
202
|
+
Licensed under the [MIT License](LICENSE).
|
|
203
|
+
|
|
204
|
+
The bundled `/teach` skill is derived from Matt Pocock's `skills` repository (pinned at commit `ad5400b930b297b0c0cb231ff1ffe42a7da666aa`) and is included under the MIT License — see [vendor/teach/SOURCE.md](vendor/teach/SOURCE.md) and [vendor/teach/LICENSE](vendor/teach/LICENSE).
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# dsh-teacher
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 简体中文
|
|
4
|
+
|
|
5
|
+
面向 **DeepSeek Harness(DSH)桌面端**的轻量、无侵入 `/teach` 学习工作台——专注做好侧栏精读、划词批注追问、原地查文档与进度复习。
|
|
6
|
+
|
|
7
|
+
**不替换默认 Agent 预设,不引入专有课程格式,对工作区零锁定。** `dsh-teacher` 直接配合你现有的对话预设与标准 `/teach` HTML 文件结构(`MISSION.md`、`lessons/`、`reference/`、`assets/`、`learning-records/`)工作。相比 DSH 自带的 Blob iframe 预览(相对链接、共享资源与阅读连续性均会失效),它通过独立的只读 Host 路由与沙箱阅读器承载课件,让你在不离开对话的前提下完成「精读 → 批注追问 → 原地查资料 → 复习」的完整闭环。
|
|
8
|
+
|
|
9
|
+
## 核心特性
|
|
10
|
+
|
|
11
|
+
- **原生阅读与跳转**:自动发现当前工作区的 `MISSION.md`、课件与参考卡;支持课件间相对链接、共享静态资源、目录搜索、阅读位置记忆与跨重启续读。
|
|
12
|
+
- **批注式选区追问**:选中任意段落点击悬浮「追问」胶囊,即可在原文旁展开气泡提问(默认**只读答疑**,不修改文件);历史问答以暖色高亮下划线锚定在原文上,随时点击回看或继续追问。需要修改课件时,可展开次级入口将修改请求安全放入原对话确认。
|
|
13
|
+
- **原地浏览外链**:点击课件外链经确认后直接在当前阅读区域内打开网页(支持前进、后退、地址栏与系统浏览器切换),返回时无损恢复来源课件及滚动位置,并支持触控板横向手势返回。
|
|
14
|
+
- **进度跟踪与复习面板**:底栏支持一键标记已学完与跳转「下一节未完成课件」,自动记录课件测验结果(内容更新后提示复练);复习面板分「学习」与「课件评论」双标签,集中查看进度条、最近阅读、`learning-records/` 学习记录与全工作区历史问答。
|
|
15
|
+
- **多布局与双语界面**:随时切换**右侧栏(Side)**、**浮动面板(Float)**、**整页面板(Full)**三种布局;视觉与交互对齐 DSH 原生风格,自动跟随 DSH 的浅色/深色主题与中英文语言设置。
|
|
16
|
+
- **本地持久化与备份**:按工作区隔离保存批注、草稿、进度与续读位置,支持 JSON 导出与合并导入。
|
|
17
|
+
|
|
18
|
+
## 环境要求与兼容范围
|
|
19
|
+
|
|
20
|
+
| 项目 | 说明 |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| 当前版本 | `0.1.0`(支持 `npm`、GitHub Release `.tgz` 分发包与本地源码安装) |
|
|
23
|
+
| Node.js | `>= 22.12.0` |
|
|
24
|
+
| 已验收环境 | macOS(arm64),DSH Desktop `0.2.2-rc.1` / `0.2.2-rc.2` |
|
|
25
|
+
| 上游版本说明 | `0.2.2-rc.5` 预计直接兼容;`0.2.3-alpha.x` 涉及 Cordis 4.0、客户端产物结构、`fileAddressFor` 与 Node.js `24.22.3+` 等底层变更,尚未完成适配与验收 |
|
|
26
|
+
| 其他平台 | Linux(Ubuntu 24.04 arm64)已通过全部自动化 Electron 回归与生产包安装测试;Windows、Linux 桌面端与 Web GUI 尚未在真实 DSH 应用中验收;不支持终端版 |
|
|
27
|
+
|
|
28
|
+
## 快速开始
|
|
29
|
+
|
|
30
|
+
### 1. 安装插件
|
|
31
|
+
|
|
32
|
+
#### 方式一:通过 npm 安装(推荐)
|
|
33
|
+
|
|
34
|
+
在 DSH 桌面端打开 **Plugins → Add plugin → Install a third-party plugin**,输入包名 `dsh-teacher`,安装后点击 **Enable now**。
|
|
35
|
+
|
|
36
|
+
#### 方式二:通过 Release `.tgz` 分发包安装
|
|
37
|
+
|
|
38
|
+
从 GitHub Releases 下载 `dsh-teacher-0.1.0.tgz` 与 `SHA256SUMS`,校验并解压到固定目录,仅安装生产依赖即可(包内已包含预构建的 `dist/client.js`,不需要安装 Electron 或 esbuild):
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
shasum -a 256 -c SHA256SUMS
|
|
42
|
+
mkdir -p dsh-teacher-0.1.0
|
|
43
|
+
tar -xzf dsh-teacher-0.1.0.tgz -C dsh-teacher-0.1.0
|
|
44
|
+
cd dsh-teacher-0.1.0/package
|
|
45
|
+
npm install --omit=dev --ignore-scripts
|
|
46
|
+
pwd
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
在 DSH 桌面端 **Plugins → Add plugin → Install a third-party plugin** 中填入 `pwd` 输出的 `package` 目录绝对路径并启用。本地插件以链接方式加载,请保留该目录。
|
|
50
|
+
|
|
51
|
+
#### 方式三:从源码构建安装
|
|
52
|
+
|
|
53
|
+
将本仓库克隆到一个固定目录,在根目录运行:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
git clone https://github.com/cigui/dsh-teacher.git
|
|
57
|
+
cd dsh-teacher
|
|
58
|
+
npm ci
|
|
59
|
+
npm run check
|
|
60
|
+
pwd
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`npm run check` 会执行语法检查、单元测试并生成 `dist/client.js`。随后在 DSH 桌面端 **Plugins → Add plugin → Install a third-party plugin** 中填入仓库绝对路径并启用。
|
|
64
|
+
|
|
65
|
+
### 2. 在工作区一键安装 `/teach`
|
|
66
|
+
|
|
67
|
+
进入任意包含工作目录的 DSH 会话,点击左侧导航或会话标题栏中的 **课件 / Lessons**。
|
|
68
|
+
|
|
69
|
+
在欢迎引导卡片中点击 **在本工作区安装 /teach**:插件会离线安装随包附带的 `/teach` skill 与模板,自动完成阅读与测验适配,并刷新当前会话技能列表。
|
|
70
|
+
|
|
71
|
+
- **安装位置**:Git 仓库内默认安装到仓库根目录,否则为当前会话目录。
|
|
72
|
+
- **已有 `/teach` 时**:引导会展示检测结果与适配命令,也可使用下文的[手动适配命令](#已有-teach-的适配与恢复)。
|
|
73
|
+
|
|
74
|
+
### 3. 生成并开始第一课
|
|
75
|
+
|
|
76
|
+
点击引导中的 **前往对话运行 `/teach`**(或在对话中直接输入 `/teach`),告诉 Agent 你想学的主题。生成的课件会自动出现在目录中,默认通过角标与通知提示,由你点击打开。
|
|
77
|
+
|
|
78
|
+
后续需要检查安装状态时,可通过阅读器右上角 **更多(⋯)→ 查看安装步骤** 重新打开引导。
|
|
79
|
+
|
|
80
|
+
## 使用指南
|
|
81
|
+
|
|
82
|
+
### 阅读、跳转与外链浏览
|
|
83
|
+
|
|
84
|
+
- **内部跳转与返回**:课件与参考卡之间的相对链接可直接点击跳转,顶部「返回」按历史栈恢复上一页与滚动位置;返回历史在本次插件运行中有效,上次阅读的课件与位置则按工作区跨重启保留。
|
|
85
|
+
- **外链安全确认**:点击外部链接先弹出目标域名与完整 URL 确认框,确认后默认在当前阅读区域内打开(不打断侧栏/浮窗/整页布局)。
|
|
86
|
+
- **触控板手势返回**:阅读区支持横向滑动返回——外链网页优先后退网页历史,无历史时回到来源课件,已针对纵向滚动、代码块横向滚动与惯性连退做专门隔离。手势方向受系统自然滚动设置影响,顶部返回按钮始终可用。
|
|
87
|
+
|
|
88
|
+
### 选区追问与批注
|
|
89
|
+
|
|
90
|
+
1. 拖拽或键盘选中课件中的文字,点击选区上方出现的深色 **追问 / Ask** 胶囊。
|
|
91
|
+
2. 点击快捷问法或输入问题并发送,在原文旁的气泡中直接查看回答(模型回合完成后更新,原对话仍实时流式显示)并继续追问。
|
|
92
|
+
3. 关闭后,原文保留暖色高亮下划线,点击即可重新展开完整讨论;工具栏「评论」列表可查看当前课件的全部问答(即使原文改写导致锚点失效,历史问答仍会保留)。同源窗口会自动合并同一工作区的评论更新。
|
|
93
|
+
|
|
94
|
+
> **只读答疑 vs. 修改课件**:普通追问默认拦截工具写入,仅做只读答疑;若确实需要修改课件,展开追问框底部的 **请求修改课件…**,系统会将修改指令放入原对话输入框由你确认后再发送。如需在发送前自由编辑提问,可在 **更多 → 设置** 中将追问方式改为「插入输入框」。
|
|
95
|
+
|
|
96
|
+
### 进度、复习与工作区备份
|
|
97
|
+
|
|
98
|
+
- **底栏操作**:阅读区底部显示当前完成与测验状态,可一键切换「标记已学完」或点击「下一节未完成课件 →」(切换下一课不会自动标记当前课完成)。测验结果按课件内容哈希保存,课件更新后会自动提示复练。
|
|
99
|
+
- **复习面板**:点击顶部 **复习 / Review** 可在两个分区间切换:
|
|
100
|
+
- **学习**:查看总进度条、续读上次课件、阅读 `learning-records/` 下的学习记录(自动提取 Markdown 标题)。
|
|
101
|
+
- **课件评论**:按关键词搜索全工作区的历史问答,并一键跳回原文位置。
|
|
102
|
+
- **导出与导入**:在 **复习 → 学习 → 工作区学习备份** 中导出当前工作区的问答、未提交草稿与学习进度;导入时会自动去重合并。
|
|
103
|
+
|
|
104
|
+
## 数据存放说明
|
|
105
|
+
|
|
106
|
+
| 数据类型 | 存储位置 |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| 课件、参考卡、静态资源、学习记录 | 当前工作区磁盘文件(由 `/teach` 维护) |
|
|
109
|
+
| 批注、文字锚点、追问草稿、学习进度、续读位置 | 本机 DSH 客户端 `localStorage`(按工作区隔离) |
|
|
110
|
+
| 布局与阅读器偏好 | 本机 DSH 客户端 `localStorage` |
|
|
111
|
+
| 已发送的问答记录 | 原 DSH 对话(在课件评论中关联展示) |
|
|
112
|
+
|
|
113
|
+
> 学习备份仅包含问答、草稿与进度,**不包含课件 HTML、学习记录或完整 DSH 对话**;迁移环境时请一并保留工作区文件。删除本机讨论不会删除原对话消息。若检测到损坏的评论存储,插件会自动隔离无效条目,并在覆盖前将原始数据备份至同名 `.recovery` 键。
|
|
114
|
+
|
|
115
|
+
## 配置
|
|
116
|
+
|
|
117
|
+
日常偏好可直接在阅读器右上角 **更多 → 设置** 中调整(立即生效并保存到本机,优先级高于插件默认配置)。如需统一配置默认值,可在 DSH 插件配置或 `cordis.patch.yml` 中设置:
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
- id: dsh-teacher
|
|
121
|
+
config:
|
|
122
|
+
layout: side
|
|
123
|
+
autoFocus: badge
|
|
124
|
+
askOnSelect: true
|
|
125
|
+
askSend: direct
|
|
126
|
+
externalLinks: sidebar
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
| 配置项 | 默认值 | 说明 |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| `layout` | `side` | `side`(右侧栏)、`float`(浮窗)、`panel`(整页) |
|
|
132
|
+
| `autoFocus` | `badge` | `badge`(角标与提示)、`switch`(自动打开新课件)、`off`(关闭提示) |
|
|
133
|
+
| `askOnSelect` | `true` | 是否显示新选区的追问入口;关闭后仍可查看已有批注与评论 |
|
|
134
|
+
| `askSend` | `direct` | `direct`(气泡内直接发送)或 `insert`(插入原对话输入框) |
|
|
135
|
+
| `askMaxChars` | `2000` | 单次引用字符上限(`15`–`20000`),超出时自动截断并提示 |
|
|
136
|
+
| `quickPrompts` | 解释一下、举个例子、为什么这样、换种讲法 | 快捷问法列表(最多 12 项,每项最多 100 字符) |
|
|
137
|
+
| `externalLinks` | `sidebar` | `sidebar`(阅读区内打开)或 `system`(系统默认浏览器) |
|
|
138
|
+
| `workspaceRoot` | 空 | 覆盖会话工作目录,填写时必须为绝对路径 |
|
|
139
|
+
| `pollIntervalMs` | `2000` | 文件监听不可用时的轮询间隔(`500`–`60000` ms) |
|
|
140
|
+
|
|
141
|
+
## 已有 `/teach` 的适配与恢复
|
|
142
|
+
|
|
143
|
+
工作区已有 `/teach` 时,优先使用引导页提供的命令;也可在仓库根目录手动运行(支持 `.agents/skills/teach/SKILL.md` 及 DSH 单文件 `teach.md`):
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
# 适配现有 teach(自动备份原版为 SKILL.original.md 或 teach.md.dsh-teacher-backup)
|
|
147
|
+
node scripts/adapt-teach.mjs /absolute/workspace/.agents/skills/teach/SKILL.md
|
|
148
|
+
|
|
149
|
+
# 恢复原版(若检测到后续人工修改会安全中止)
|
|
150
|
+
node scripts/adapt-teach.mjs --restore /absolute/workspace/.agents/skills/teach/SKILL.md
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## 课件目录约定与安全边界
|
|
154
|
+
|
|
155
|
+
插件按当前会话工作目录自动扫描以下结构:
|
|
156
|
+
|
|
157
|
+
```text
|
|
158
|
+
workspace/
|
|
159
|
+
├── MISSION.md # 学习目标(目录顶部展示首段正文)
|
|
160
|
+
├── lessons/*.html # 按自然编号排序的课件
|
|
161
|
+
├── reference/*.html # 速查卡 / 参考卡
|
|
162
|
+
├── assets/ # 共享样式、脚本、图片、字体等静态资源
|
|
163
|
+
└── learning-records/*.md # 学习记录(可在复习面板直接阅读)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
- **沙箱与 CSP 隔离**:课件运行在 `sandbox="allow-scripts"`(不含 `allow-same-origin`)与严格 CSP(`connect-src 'none'`)的双重隔离环境中,仅允许读取同会话工作区 `assets/` 下的白名单静态文件,拒绝路径穿越与符号链接,禁用 `fetch`、浏览器本地存储与弹窗。支持 classic JavaScript、常规 CSS 与系统字体。
|
|
167
|
+
- **自定义测验回报协议**:课件在判分完成后可派发以下事件同步测验状态:
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
document.dispatchEvent(new CustomEvent('dsh-teacher:quiz-result', {
|
|
171
|
+
detail: { passed: true },
|
|
172
|
+
}));
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## 升级、回滚与卸载
|
|
176
|
+
|
|
177
|
+
- **升级**:通过 npm 安装时可在 DSH **Plugins** 中更新,Host 或桥接更新后重启 DSH。通过本地目录或分发包升级时,先保留旧目录并在插件管理中停用旧版本,再切换到新目录并启用(切勿同时启用两份相同插件),随后重启 DSH。若升级时 Client 先于旧 Host 加载,面板会提示协议版本不一致,重启后点击「重新检测」即可。
|
|
178
|
+
- **回滚**:在插件管理中停用新版本,重新启用保留的旧目录并重启 DSH。切勿为回滚清除整个 DSH 应用数据——本地评论(`dsh-teacher.comments.v1.<工作区>`)、进度与工作区文件均保持兼容。
|
|
179
|
+
- **卸载**:在 DSH 的 **Plugins** 中停用或卸载 **Lesson learning / 课件学习**。插件路由与面板会自动注销,对话中的课件链接恢复使用 DSH 内置预览,工作区内的课件与学习记录文件保持不变。如需保留批注与进度,建议卸载前先导出工作区学习备份。
|
|
180
|
+
|
|
181
|
+
## 开发与验证
|
|
182
|
+
|
|
183
|
+
```sh
|
|
184
|
+
npm run check # 语法检查、Node 单元测试、Client 构建
|
|
185
|
+
npm run test:electron # 全部六组 Electron 桌面回归(CSP/评论/选区/导航/手势/阅读器)
|
|
186
|
+
npm run test:package # 打包并在独立消费项目中验证生产依赖安装
|
|
187
|
+
npm run check:release # 完整发布前检查与依赖安全审计(产物输出到 artifacts/)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
如需针对目标 DSH 的 Electron 版本(如 `0.2.2-rc.2` 使用的 `44.7.0`)回归,可指定可执行文件路径:
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
DSH_ELECTRON=/absolute/path/to/Electron npm run test:electron
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
> 修改 `src/client/` 后运行 `npm run build` 即可更新前端构建;修改 Host(`src/index.js`、`src/host.js`)或桥接(`src/bridge.js`)后请重启 DSH。
|
|
197
|
+
|
|
198
|
+
## 更新记录与许可
|
|
199
|
+
|
|
200
|
+
- [更新记录](CHANGELOG.md)
|
|
201
|
+
|
|
202
|
+
本项目基于 [MIT 协议](LICENSE)开源。
|
|
203
|
+
|
|
204
|
+
随包附带的 `/teach` 来自 Matt Pocock(上游提交 `ad5400b930b297b0c0cb231ff1ffe42a7da666aa`),按 MIT 许可保留原文与归属,详见[来源说明](vendor/teach/SOURCE.md)与[第三方许可](vendor/teach/LICENSE)。
|