dsh-deeptutor 0.1.7 → 0.1.9

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.md CHANGED
@@ -1,181 +1,226 @@
1
- # dsh-deeptutor
2
-
3
- **English** | [简体中文](https://github.com/TecFancy/dsh-deeptutor/blob/main/README.zh.md)
4
-
5
- DeepTutor bridge **bundle** for **DeepSeek Harness (dsh)**, migrated from the
6
- pi coding-agent extension (`TecFancy/pi-extensions`, `extensions/deeptutor` +
7
- `skills/deeptutor`).
8
-
9
- Registers three model-facing tools that drive the
10
- [HKUDS/DeepTutor](https://github.com/HKUDS/DeepTutor) tutoring service:
11
-
12
- | Tool | Purpose |
13
- |---|---|
14
- | `deeptutor_run` | Run a learning capability: `deep_solve` / `deep_question` / `deep_research` / `chat` / `mastery_path` / `visualize` / `math_animator` (HTTP/WS first, CLI fallback) |
15
- | `deeptutor_kb` | List / search / info the user's personal knowledge bases (RAG) |
16
- | `deeptutor_note` | Archive Markdown learning notes to a server notebook |
17
-
18
- The seven capabilities above are the fixed enum accepted by `deeptutor_run`.
19
- The underlying DeepTutor CLI may expose more — enumerate the full command set
20
- with `deeptutor --help` / `deeptutor <cmd> --help`. The `deeptutor` skill
21
- instructs the agent to discover commands this way and, when the tool's enum
22
- doesn't cover a capability, to drive the CLI directly (local binary or over
23
- SSH).
24
-
25
- Deployment auto-detects local vs. remote: local `serve` (or local CLI) on this
26
- machine, or a server reached through an auto-started SSH tunnel (with SSH CLI
27
- fallback).
28
-
29
- ## Install into a profile (bundle)
30
-
31
- The package is published to npm as `dsh-deeptutor`. Recommended one-liner —
32
- runs the bundled installer (`scripts/install-profile.mjs`, exposed as the
33
- `dsh-deeptutor` binary), which wraps `dsh plugin add` and automatically
34
- handles the pnpm workspace-root check described below:
35
-
36
- ```sh
37
- pnpm dlx dsh-deeptutor --profile web
38
- ```
39
-
40
- From a checkout of this repo, the same installer runs directly:
41
-
42
- ```sh
43
- node scripts/install-profile.mjs --profile web
44
- ```
45
-
46
- Or run the underlying command yourself — `dsh plugin add` forwards to pnpm
47
- and then reconciles the profile's `dsh.profile.bundles` against the installed
48
- state, so a `dsh.bundle`-declaring package like this one is registered
49
- automatically (verified on dsh CLI 0.1.0-rc.6 + pnpm 8.15.6):
50
-
51
- ```sh
52
- dsh plugin --profile web add dsh-deeptutor -w
53
- ```
54
-
55
- > **Pitfall — pnpm workspace-root check.** The dsh profile scaffold always
56
- > writes a `pnpm-workspace.yaml` (`packages: ["."]`, `nodeLinker: hoisted`),
57
- > which makes the profile directory itself a pnpm workspace root. On
58
- > pnpm ≥ 8, `pnpm add` in a workspace root aborts with
59
- > `ERR_PNPM_ADDING_TO_ROOT` unless the workspace-root flag is explicit, so
60
- > the command above appends `-w`/`--workspace-root` (pnpm prints this error
61
- > on stdout on Windows, which is why a plain `dsh plugin add` without the
62
- > flag fails even though the output looks like a warning). Two ways to
63
- > handle it:
64
- >
65
- > 1. Use the installer / keep `-w` in the command (recommended — the
66
- > installer tries the plain command first and adds `-w` automatically
67
- > only when the check trips).
68
- > 2. Or allow the plain command permanently: add
69
- > `ignore-workspace-root-check: true` to
70
- > `~/.dsh/profiles/<name>/pnpm-workspace.yaml`, then
71
- > `dsh plugin --profile web add dsh-deeptutor` works as written.
72
-
73
- Verify the bundle is mounted, then restart dsh (the bundle list is resolved
74
- at boot):
75
-
76
- ```sh
77
- dsh --profile web --dump-config | grep dsh-deeptutor
78
- ```
79
-
80
- If your dsh CLI does not auto-register the bundle (older versions, or you
81
- installed the dependency manually), add it to the profile manifest
82
- (`~/.dsh/profiles/<name>/package.json`) and run `dsh plugin --profile web
83
- install`:
84
-
85
- ```json
86
- {
87
- "dependencies": { "dsh-deeptutor": "^0.1.0" },
88
- "dsh": {
89
- "profile": { "bundles": ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-web-app", "dsh-deeptutor"] }
90
- }
91
- }
92
- ```
93
-
94
- Alternatively, keep the manifest untouched and mount the bundle through a user
95
- patch layer (the npm package still has to be installed first):
96
-
97
- ```yaml
98
- # overlay.yml — insert the bundle row via a user patch layer
99
- - insert:
100
- - id: dsh-deeptutor
101
- name: 'dsh-deeptutor'
102
- ```
103
-
104
- ```sh
105
- dsh web --patch ./overlay.yml
106
- ```
107
-
108
- The bundle manifest (`dsh.bundle.patch → cordis.patch.yml`) inserts the plugin
109
- row; later patch layers can override or disable it by id.
110
-
111
- ## Develop against a checkout (no publish needed)
112
-
113
- ```sh
114
- dsh web --patch /path/to/dsh-deeptutor/cordis.yml
115
- ```
116
-
117
- ## Build & publish
118
-
119
- ```sh
120
- npm install
121
- npm run build # tsc → lib/ (relative .ts imports rewritten to .js)
122
- npm run typecheck
123
- npm pack # inspect dsh-deeptutor-0.1.0.tgz
124
- npm publish # set a scope/registry of your choice first
125
- ```
126
-
127
- Node ≥ 22.6 (type stripping) is needed to load the raw `src/*.ts` via
128
- `--patch`; the published bundle ships compiled `lib/`, so installed profiles
129
- run on plain Node ≥ 20 ESM.
130
-
131
- ## Skills
132
-
133
- Two skills ship inside this package (`skills/deeptutor` and
134
- `skills/html-doc`) and the bundled installer copies them to
135
- `<DSH_HOME>/skills/<name>/` (auto-discovered by dsh) whenever it runs — so
136
- `pnpm dlx dsh-deeptutor` installs the bundle **and** the skills in one shot:
137
-
138
- - `deeptutor` — the agent-facing learning workflow (`~/.dsh/skills/deeptutor/SKILL.md`)
139
- - `html-doc` — renders study answers to self-contained HTML pages
140
- (`~/.dsh/skills/html-doc/`); the bundle uses the same converter
141
- (`scripts/md-to-html.js`) when `deeptutor_run` gets an `html` path
142
-
143
- Installing a newer package version overwrites skill files in place; files not
144
- shipped by the package are never deleted.
145
-
146
- The files under `skills/` are byte-identical copies of the same skills in
147
- `TecFancy/pi-extensions` (single source of truth, agent-neutral). Sync them
148
- after upstream edits with `node scripts/sync-skills.mjs ../pi-extensions`.
149
-
150
- ## Configuration (env vars, agent-agnostic)
151
-
152
- ```bash
153
- # Remote deployment (DeepTutor on a server, reached through an SSH tunnel)
154
- export DEEPTUTOR_SSH_HOST="tencent-cloud" # SSH host alias (set = remote mode)
155
- export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # local tunnel address
156
- export DEEPTUTOR_REMOTE_BIN="/home/ubuntu/my-deeptutor/.venv/bin/deeptutor"
157
- export DEEPTUTOR_REMOTE_HOME="/home/ubuntu/my-deeptutor"
158
-
159
- # Local deployment — leave DEEPTUTOR_SSH_HOST unset
160
- # export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # local serve port
161
- # export DEEPTUTOR_LOCAL_BIN="deeptutor" # local CLI path (default: deeptutor on PATH)
162
- ```
163
-
164
- Restart dsh after changing env vars.
165
-
166
- ## Layout
167
-
168
- ```
169
- src/ # TypeScript sources (dev loading, typecheck)
170
- lib/ # compiled ESM (published entry, from `npm run build`)
171
- scripts/md-to-html.js # zero-dependency Markdown → HTML converter
172
- scripts/install-profile.mjs # one-shot profile installer (exposed as the `dsh-deeptutor` binary)
173
- skills/ # bundled skills: deeptutor/ + html-doc/ (installed to <DSH_HOME>/skills/)
174
- cordis.yml # dev overlay: insert src/index.ts by absolute path
175
- cordis.patch.yml # bundle patch: insert the package by name
176
- ```
177
-
178
- `src/index.ts` registers the tools; `config.ts` holds env config;
179
- `cli-exec.ts` local/SSH CLI execution; `http-api.ts` API probing + SSH tunnel;
180
- `turn.ts` one learning turn (WebSocket / CLI event folding + formatting);
181
- `html-render.ts` answer → self-contained HTML.
1
+ # dsh-deeptutor
2
+
3
+ **English** | [简体中文](https://github.com/TecFancy/dsh-deeptutor/blob/main/README.zh.md)
4
+
5
+ A **learning-assistant extension for DeepSeek Harness (dsh)**. It connects your
6
+ agent to a [HKUDS/DeepTutor](https://github.com/HKUDS/DeepTutor) tutoring
7
+ service, so a dsh session can explain topics in depth, quiz you, plan learning
8
+ paths, search your personal knowledge bases, and keep a study notebook — all
9
+ without leaving the harness.
10
+
11
+ Ask the agent *"teach me async/await"* and it can run a deep-solve, render the
12
+ answer as a self-contained HTML study page you can open in a browser, and
13
+ archive a summary into your notebook.
14
+
15
+ Migrated from the pi coding-agent extension
16
+ (`TecFancy/pi-extensions`, `extensions/deeptutor` + `skills/deeptutor`).
17
+
18
+ ## What it adds
19
+
20
+ Three agent-facing tools that the model uses whenever you ask for learning help:
21
+
22
+ | Tool | What it does |
23
+ |---|---|
24
+ | `deeptutor_run` | Runs one learning capability: `deep_solve` (in-depth explanation), `deep_question` (self-test questions), `deep_research`, `chat`, `mastery_path` (learning-path planning), `visualize` / `math_animator` (visualization). Can mount your knowledge bases (`kbs`) and tools (`rag`, `web_search`, `reason`, `code_execution`, …); returns a `session_id` so later turns continue the same context. |
25
+ | `deeptutor_kb` | Lists, searches, and inspects your personal knowledge bases (RAG) |
26
+ | `deeptutor_note` | Archives Markdown study notes (plans, summaries, wrong answers) into a server notebook |
27
+
28
+ The seven capabilities above are the fixed enum accepted by `deeptutor_run`.
29
+ The underlying DeepTutor CLI may expose more — enumerate the full command set
30
+ with `deeptutor --help` / `deeptutor <cmd> --help`. The `deeptutor` skill
31
+ instructs the agent to discover commands this way and, when the tool's enum
32
+ doesn't cover a capability, to drive the CLI directly (local binary or over
33
+ SSH).
34
+
35
+ ## Example session
36
+
37
+ A typical flow when you ask your agent for learning help:
38
+
39
+ 1. **Ask** — *"Explain C# generics covariance using my dotnet knowledge base, and generate a study page."*
40
+ 2. The agent grounds the answer in your own material: `deeptutor_kb` (`action=search`, `kb=dotnet`).
41
+ 3. It runs a deep-solve: `deeptutor_run` (`capability=deep_solve`, `kbs=[dotnet]`, `html=data/study/csharp-covariance.html`) — the answer comes back and a self-contained HTML page (plus the `.md` source) is written to disk.
42
+ 4. It files a summary: `deeptutor_note` (`notebook=dotnet-learning`, `type=solve`).
43
+
44
+ Nothing here is a fixed script — the agent picks the tools and parameters based
45
+ on what you ask for.
46
+
47
+ A real recording of exactly this flow (deep-solve on the async/await state
48
+ machine, mounted on a `dotnet-csharp` knowledge base, rendered to an HTML
49
+ study page, then archived to a notebook):
50
+
51
+ ![Final answer](docs/demo/en-final-answer.png)
52
+
53
+ ![Generated HTML study page](docs/demo/en-study-page.png)
54
+
55
+ ## Requirements
56
+
57
+ - A working DeepSeek Harness (dsh) install. Bundle auto-registration via
58
+ `dsh plugin add` is verified on dsh CLI 0.1.0-rc.6 + pnpm 8.15.6.
59
+ - A DeepTutor deployment, either:
60
+ - **Local** — `deeptutor serve` running on this machine, or the `deeptutor`
61
+ CLI on `PATH` (used as fallback);
62
+ - **Remote** — DeepTutor on a server, reached through an auto-started SSH
63
+ tunnel (with SSH CLI fallback).
64
+
65
+ ## Install into a profile (bundle)
66
+
67
+ The package is published to npm as `dsh-deeptutor`. Recommended one-liner —
68
+ runs the bundled installer (`scripts/install-profile.mjs`, exposed as the
69
+ `dsh-deeptutor` binary), which wraps `dsh plugin add` and automatically
70
+ handles the pnpm workspace-root check described below:
71
+
72
+ ```sh
73
+ pnpm dlx dsh-deeptutor --profile web
74
+ ```
75
+
76
+ From a checkout of this repo, the same installer runs directly:
77
+
78
+ ```sh
79
+ node scripts/install-profile.mjs --profile web
80
+ ```
81
+
82
+ Or run the underlying command yourself — `dsh plugin add` forwards to pnpm
83
+ and then reconciles the profile's `dsh.profile.bundles` against the installed
84
+ state, so a `dsh.bundle`-declaring package like this one is registered
85
+ automatically:
86
+
87
+ ```sh
88
+ dsh plugin --profile web add dsh-deeptutor -w
89
+ ```
90
+
91
+ > **Pitfall — pnpm workspace-root check.** The dsh profile scaffold always
92
+ > writes a `pnpm-workspace.yaml` (`packages: ["."]`, `nodeLinker: hoisted`),
93
+ > which makes the profile directory itself a pnpm workspace root. On
94
+ > pnpm ≥ 8, `pnpm add` in a workspace root aborts with
95
+ > `ERR_PNPM_ADDING_TO_ROOT` unless the workspace-root flag is explicit, so
96
+ > the command above appends `-w`/`--workspace-root` (pnpm prints this error
97
+ > on stdout on Windows, which is why a plain `dsh plugin add` without the
98
+ > flag fails even though the output looks like a warning). Two ways to
99
+ > handle it:
100
+ >
101
+ > 1. Use the installer / keep `-w` in the command (recommended — the
102
+ > installer tries the plain command first and adds `-w` automatically
103
+ > only when the check trips).
104
+ > 2. Or allow the plain command permanently: add
105
+ > `ignore-workspace-root-check: true` to
106
+ > `~/.dsh/profiles/<name>/pnpm-workspace.yaml`, then
107
+ > `dsh plugin --profile web add dsh-deeptutor` works as written.
108
+
109
+ Verify the bundle is mounted, then restart dsh (the bundle list is resolved
110
+ at boot):
111
+
112
+ ```sh
113
+ dsh --profile web --dump-config | grep dsh-deeptutor
114
+ ```
115
+
116
+ If your dsh CLI does not auto-register the bundle (older versions, or you
117
+ installed the dependency manually), add it to the profile manifest
118
+ (`~/.dsh/profiles/<name>/package.json`) and run `dsh plugin --profile web
119
+ install`:
120
+
121
+ ```json
122
+ {
123
+ "dependencies": { "dsh-deeptutor": "^0.1.0" },
124
+ "dsh": {
125
+ "profile": { "bundles": ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-web-app", "dsh-deeptutor"] }
126
+ }
127
+ }
128
+ ```
129
+
130
+ Alternatively, keep the manifest untouched and mount the bundle through a user
131
+ patch layer (the npm package still has to be installed first):
132
+
133
+ ```yaml
134
+ # overlay.yml — insert the bundle row via a user patch layer
135
+ - insert:
136
+ - id: dsh-deeptutor
137
+ name: 'dsh-deeptutor'
138
+ ```
139
+
140
+ ```sh
141
+ dsh web --patch ./overlay.yml
142
+ ```
143
+
144
+ The bundle manifest (`dsh.bundle.patch → cordis.patch.yml`) inserts the plugin
145
+ row; later patch layers can override or disable it by id.
146
+
147
+ ## Skills
148
+
149
+ Two skills ship inside this package (`skills/deeptutor` and
150
+ `skills/html-doc`) and the bundled installer copies them to
151
+ `<DSH_HOME>/skills/<name>/` (auto-discovered by dsh) whenever it runs — so
152
+ `pnpm dlx dsh-deeptutor` installs the bundle **and** the skills in one shot:
153
+
154
+ - `deeptutor` — the agent-facing learning workflow (`~/.dsh/skills/deeptutor/SKILL.md`)
155
+ - `html-doc` — renders study answers to self-contained HTML pages
156
+ (`~/.dsh/skills/html-doc/`); the bundle uses the same converter
157
+ (`scripts/md-to-html.js`) when `deeptutor_run` gets an `html` path
158
+
159
+ Installing a newer package version overwrites skill files in place; files not
160
+ shipped by the package are never deleted.
161
+
162
+ The files under `skills/` are byte-identical copies of the same skills in
163
+ `TecFancy/pi-extensions` (single source of truth, agent-neutral). Sync them
164
+ after upstream edits with `node scripts/sync-skills.mjs ../pi-extensions`.
165
+
166
+ ## Configuration (env vars, agent-agnostic)
167
+
168
+ ```bash
169
+ # Remote deployment (DeepTutor on a server, reached through an SSH tunnel)
170
+ export DEEPTUTOR_SSH_HOST="tencent-cloud" # SSH host alias (set = remote mode)
171
+ export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # local tunnel address
172
+ export DEEPTUTOR_REMOTE_BIN="/home/ubuntu/my-deeptutor/.venv/bin/deeptutor"
173
+ export DEEPTUTOR_REMOTE_HOME="/home/ubuntu/my-deeptutor"
174
+
175
+ # Local deployment — leave DEEPTUTOR_SSH_HOST unset
176
+ # export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # local serve port
177
+ # export DEEPTUTOR_LOCAL_BIN="deeptutor" # local CLI path (default: deeptutor on PATH)
178
+ ```
179
+
180
+ Restart dsh after changing env vars.
181
+
182
+ ## How it works
183
+
184
+ The plugin auto-detects the deployment: if a DeepTutor API is reachable (local
185
+ `serve`, or a remote server via tunnel), learning turns run over HTTP/WebSocket;
186
+ otherwise it falls back to the CLI — the local `deeptutor` binary, or the remote
187
+ binary over SSH. Remote mode starts the SSH tunnel on demand and tears it down
188
+ when the plugin unloads.
189
+
190
+ ## Develop against a checkout (no publish needed)
191
+
192
+ ```sh
193
+ dsh web --patch /path/to/dsh-deeptutor/cordis.yml
194
+ ```
195
+
196
+ ## Build & publish
197
+
198
+ ```sh
199
+ npm install
200
+ npm run build # tsc → lib/ (relative .ts imports rewritten to .js)
201
+ npm run typecheck
202
+ npm test # node:test + type stripping
203
+ npm pack # inspect dsh-deeptutor-<version>.tgz
204
+ npm publish # set a scope/registry of your choice first
205
+ ```
206
+
207
+ Node ≥ 22.6 (type stripping) is needed to load the raw `src/*.ts` via
208
+ `--patch`; the published bundle ships compiled `lib/`, so installed profiles
209
+ run on plain Node ≥ 20 ESM.
210
+
211
+ ## Layout
212
+
213
+ ```
214
+ src/ # TypeScript sources (dev loading, typecheck)
215
+ lib/ # compiled ESM (published entry, from `npm run build`)
216
+ scripts/md-to-html.js # zero-dependency Markdown → HTML converter
217
+ scripts/install-profile.mjs # one-shot profile installer (exposed as the `dsh-deeptutor` binary)
218
+ skills/ # bundled skills: deeptutor/ + html-doc/ (installed to <DSH_HOME>/skills/)
219
+ cordis.yml # dev overlay: insert src/index.ts by absolute path
220
+ cordis.patch.yml # bundle patch: insert the package by name
221
+ ```
222
+
223
+ `src/index.ts` registers the tools; `config.ts` holds env config;
224
+ `cli-exec.ts` local/SSH CLI execution; `http-api.ts` API probing + SSH tunnel;
225
+ `turn.ts` one learning turn (WebSocket / CLI event folding + formatting);
226
+ `html-render.ts` answer → self-contained HTML.