dsh-deeptutor 0.1.11 → 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.
- package/.agents/skills/deeptutor/README.md +17 -36
- package/.agents/skills/deeptutor/SKILL.md +14 -14
- package/.agents/skills/html-doc/scripts/md-to-html.js +16 -7
- package/README.md +29 -22
- package/README.zh.md +13 -11
- package/lib/cli-exec.js +13 -2
- package/lib/config.d.ts +6 -6
- package/lib/config.js +16 -17
- package/lib/index.d.ts +8 -9
- package/lib/index.js +5 -111
- package/lib/turn.d.ts +2 -4
- package/lib/turn.js +4 -95
- package/lib/win-cmd.d.ts +27 -0
- package/lib/win-cmd.js +108 -0
- package/package.json +2 -2
- package/scripts/md-to-html.js +16 -7
- package/src/cli-exec.ts +18 -7
- package/src/config.ts +16 -17
- package/src/index.ts +13 -136
- package/src/turn.ts +5 -94
- package/src/win-cmd.ts +129 -0
- package/lib/http-api.d.ts +0 -10
- package/lib/http-api.js +0 -94
- package/scripts/sync-skills.mjs +0 -47
- package/src/http-api.ts +0 -98
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# DeepTutor Learning Assistant (
|
|
1
|
+
# DeepTutor Learning Assistant (dsh bundle + SKILL)
|
|
2
2
|
|
|
3
3
|
> This README is the human-facing documentation; `SKILL.md` is the agent-facing instruction file (loaded on demand).
|
|
4
|
-
> The
|
|
4
|
+
> The bundle and this skill both live in `TecFancy/dsh-deeptutor`.
|
|
5
5
|
|
|
6
6
|
Bridges **DeepTutor** (open-source personalized tutoring platform) into your
|
|
7
7
|
agent: combines your **personal knowledge bases** (RAG retrieval) with
|
|
@@ -9,8 +9,8 @@ agent: combines your **personal knowledge bases** (RAG retrieval) with
|
|
|
9
9
|
questions, and study plans — then archives your notes to a DeepTutor notebook
|
|
10
10
|
for later review.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Shipped as the npm bundle `dsh-deeptutor` for DeepSeek Harness (dsh); the
|
|
13
|
+
installer also copies this skill to `~/.dsh/skills/deeptutor/`.
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
16
|
|
|
@@ -25,25 +25,13 @@ for later review.
|
|
|
25
25
|
|
|
26
26
|
## Installation
|
|
27
27
|
|
|
28
|
-
### pi
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
# Install the pi package (extension + SKILL)
|
|
32
|
-
pi install git:github.com/TecFancy/pi-extensions
|
|
33
|
-
|
|
34
|
-
# Local development: /reload after editing (local path installs are not copied)
|
|
35
|
-
pi install D:/source/personal/pi-extensions
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### dsh
|
|
39
|
-
|
|
40
28
|
```bash
|
|
41
29
|
# One-shot: bundle + skill, from the published package
|
|
42
30
|
pnpm dlx dsh-deeptutor --profile web
|
|
43
31
|
|
|
44
32
|
# Or install the skill manually from a checkout
|
|
45
|
-
xcopy /e /i skills\deeptutor %USERPROFILE%\.dsh\skills\deeptutor # Windows
|
|
46
|
-
cp -r skills/deeptutor ~/.dsh/skills/deeptutor # macOS/Linux
|
|
33
|
+
xcopy /e /i .agents\skills\deeptutor %USERPROFILE%\.dsh\skills\deeptutor # Windows
|
|
34
|
+
cp -r .agents/skills/deeptutor ~/.dsh/skills/deeptutor # macOS/Linux
|
|
47
35
|
```
|
|
48
36
|
|
|
49
37
|
## Configuration (environment variables)
|
|
@@ -51,9 +39,8 @@ cp -r skills/deeptutor ~/.dsh/skills/deeptutor # macOS/Linux
|
|
|
51
39
|
Set these in `~/.bashrc` or `~/.zshrc` (inherited by any agent at startup — agent-agnostic):
|
|
52
40
|
|
|
53
41
|
```bash
|
|
54
|
-
# —— Remote deployment (DeepTutor on a server,
|
|
42
|
+
# —— Remote deployment (DeepTutor on a server, driven over SSH) ——
|
|
55
43
|
export DEEPTUTOR_SSH_HOST="tencent-cloud" # SSH alias (set = remote mode)
|
|
56
|
-
export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # local tunnel address (change port here)
|
|
57
44
|
export DEEPTUTOR_REMOTE_BIN="/home/ubuntu/my-deeptutor/.venv/bin/deeptutor"
|
|
58
45
|
export DEEPTUTOR_REMOTE_HOME="/home/ubuntu/my-deeptutor"
|
|
59
46
|
|
|
@@ -62,7 +49,7 @@ export DEEPTUTOR_REMOTE_HOME="/home/ubuntu/my-deeptutor"
|
|
|
62
49
|
# export DEEPTUTOR_HOME="/path/to/local-workspace" # local workspace
|
|
63
50
|
```
|
|
64
51
|
|
|
65
|
-
**
|
|
52
|
+
**How calls run**: the tools always drive the DeepTutor CLI — the local binary, or the remote one over SSH when `DEEPTUTOR_SSH_HOST` is set. `deeptutor serve` does not need to be reachable.
|
|
66
53
|
|
|
67
54
|
## Usage
|
|
68
55
|
|
|
@@ -93,37 +80,31 @@ The agent follows the SKILL workflow automatically:
|
|
|
93
80
|
|
|
94
81
|
| Symptom | Cause & fix |
|
|
95
82
|
| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
96
|
-
| Connection timeout / host resolution failure | ① Check `DEEPTUTOR_SSH_HOST` is set and SSH passwordless login works ②
|
|
83
|
+
| Connection timeout / host resolution failure | ① Check `DEEPTUTOR_SSH_HOST` is set and SSH passwordless login works ② Does the remote CLI run? (`ssh <alias> <DEEPTUTOR_REMOTE_BIN> kb list --format json`) |
|
|
97
84
|
| Tool returns "No DEEPTUTOR_* env vars detected" | One-time hint on first call; configure per the Configuration section and restart the agent |
|
|
98
85
|
| Local CLI garbled output / crashes | The tools inject `PYTHONUTF8=1` automatically; verify Python ≥ 3.11 otherwise |
|
|
99
86
|
| DNS resolution fails (Windows) | Common on corporate networks: if `nslookup` works but curl/python can't resolve, fix `C:\Windows\System32\drivers\etc\hosts` (when appending entries, always start with a newline) |
|
|
100
87
|
| CLI-only package missing modules | Official `packaging/deeptutor-cli` has incomplete deps; `pip install <module>` per the error (known: loguru, fastapi) |
|
|
88
|
+
| `No such command 'kb'` / capability unknown | DeepTutor 1.7+ ships features as modules; check `deeptutor module list`, then `deeptutor module install <name>` (e.g. `knowledge`, `notebook`, `solve`) |
|
|
101
89
|
|
|
102
90
|
## FAQ
|
|
103
91
|
|
|
104
92
|
**Q: Can local and remote be used at the same time?**
|
|
105
93
|
A: Yes. Switching only requires changing env vars (set/remove `DEEPTUTOR_SSH_HOST`); the SKILL and tools stay unchanged.
|
|
106
94
|
|
|
107
|
-
**Q: What if I change servers
|
|
108
|
-
A: Only env vars change (`DEEPTUTOR_SSH_HOST` /
|
|
95
|
+
**Q: What if I change servers?**
|
|
96
|
+
A: Only env vars change (`DEEPTUTOR_SSH_HOST` / remote paths) — never the SKILL or tools.
|
|
109
97
|
|
|
110
98
|
**Q: Is the knowledge base list hardcoded?**
|
|
111
99
|
A: No. Tools query `deeptutor_kb list` dynamically; new bases are picked up automatically.
|
|
112
100
|
|
|
113
101
|
**Q: Can other agents (Claude Code / Codex) use it?**
|
|
114
|
-
A: Yes. The SKILL follows the Agent Skills standard and can be linked into `~/.agents/skills/`; the `deeptutor_*` tools are registered by the
|
|
102
|
+
A: Yes. The SKILL follows the Agent Skills standard and can be linked into `~/.agents/skills/`; the `deeptutor_*` tools are registered by the dsh bundle; other agents use the plain CLI path described in the SKILL.
|
|
115
103
|
|
|
116
104
|
## Maintenance
|
|
117
105
|
|
|
118
|
-
|
|
119
|
-
repo (pi-extensions)** and are kept agent-neutral. `dsh-deeptutor` ships
|
|
120
|
-
byte-identical copies; after editing, sync with:
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
cd ../dsh-deeptutor && node scripts/sync-skills.mjs ../pi-extensions
|
|
124
|
-
```
|
|
106
|
+
The bundle code (`src/`) and this skill live in `TecFancy/dsh-deeptutor`; edit both there.
|
|
125
107
|
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
- Release
|
|
129
|
-
- Release dsh: bump the version in `package.json`, push a `v*` tag → CI publishes to npm
|
|
108
|
+
- Code: `src/index.ts` for tool wiring, `cli-exec.ts` / `turn.ts` for CLI execution, `config.ts` for env vars/helpers → `npm run typecheck && npm test && npm run build`
|
|
109
|
+
- Skill: edit `.agents/skills/deeptutor/` directly and keep it in step with the tool parameters
|
|
110
|
+
- Release: bump the version in `package.json`, push a `v*` tag → CI publishes to npm
|
|
@@ -12,9 +12,9 @@ questions, and study plans, then archives notes to a DeepTutor notebook.
|
|
|
12
12
|
This skill is **agent-agnostic**: every action below has two equivalent
|
|
13
13
|
drivers —
|
|
14
14
|
|
|
15
|
-
- **
|
|
16
|
-
They
|
|
17
|
-
|
|
15
|
+
- **dsh (with the `dsh-deeptutor` bundle installed):** the `deeptutor_*` tools.
|
|
16
|
+
They drive the DeepTutor CLI for you, locally or over SSH for remote
|
|
17
|
+
deployments.
|
|
18
18
|
- **Any agent / plain CLI:** the `deeptutor` executable directly (local
|
|
19
19
|
binary on PATH, or over SSH for remote deployments). No extension needed.
|
|
20
20
|
|
|
@@ -30,27 +30,27 @@ what matters.
|
|
|
30
30
|
|
|
31
31
|
## Configuration (env vars, agent-agnostic)
|
|
32
32
|
|
|
33
|
-
Nothing is hardcoded in this skill; all server parameters come from environment variables (put them in `~/.bashrc` or `~/.zshrc`; any agent —
|
|
33
|
+
Nothing is hardcoded in this skill; all server parameters come from environment variables (put them in `~/.bashrc` or `~/.zshrc`; any agent — dsh / Claude Code / Codex / opencode — inherits them at startup). **Deployment mode adapts automatically**:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
# Remote deployment (DeepTutor on a server,
|
|
36
|
+
# Remote deployment (DeepTutor on a server, driven over SSH)
|
|
37
37
|
export DEEPTUTOR_SSH_HOST="tencent-cloud" # SSH host alias (set = remote mode)
|
|
38
|
-
export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # local tunnel address (change port/server here)
|
|
39
38
|
export DEEPTUTOR_REMOTE_BIN="/home/ubuntu/my-deeptutor/.venv/bin/deeptutor"
|
|
40
39
|
export DEEPTUTOR_REMOTE_HOME="/home/ubuntu/my-deeptutor"
|
|
41
40
|
|
|
42
41
|
# Local deployment (DeepTutor on this machine) — leave DEEPTUTOR_SSH_HOST unset for local mode
|
|
43
|
-
# export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # local serve port
|
|
44
42
|
# export DEEPTUTOR_LOCAL_BIN="deeptutor" # local CLI path (default: deeptutor on PATH)
|
|
45
43
|
```
|
|
46
44
|
|
|
47
|
-
- **Tools path:**
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
- **Tools path:** the bundle runs the local `deeptutor` CLI, or the remote one
|
|
46
|
+
over SSH when `DEEPTUTOR_SSH_HOST` is set. `deeptutor serve` does not need to
|
|
47
|
+
be reachable from this machine.
|
|
50
48
|
- **Plain CLI path:** run `deeptutor <subcommand>` locally, or
|
|
51
49
|
`ssh <DEEPTUTOR_SSH_HOST> <DEEPTUTOR_REMOTE_BIN> <subcommand>` for remote
|
|
52
|
-
deployments
|
|
53
|
-
-
|
|
50
|
+
deployments.
|
|
51
|
+
- DeepTutor 1.7+ ships `kb`, `notebook` and most capabilities as optional
|
|
52
|
+
modules; `deeptutor module list` shows which are installed and enabled.
|
|
53
|
+
- Migrating to another server only requires changing env vars — never this skill.
|
|
54
54
|
|
|
55
55
|
## Actions Cheat Sheet
|
|
56
56
|
|
|
@@ -172,8 +172,8 @@ explicit request — never proactively.
|
|
|
172
172
|
|
|
173
173
|
## Notes
|
|
174
174
|
|
|
175
|
-
- Tool calls
|
|
176
|
-
- CLI-only flags (not exposed as `deeptutor_run` tool parameters): `--
|
|
175
|
+
- Tool calls run the DeepTutor CLI (locally or over SSH) and return when the turn finishes; there is no live progress stream.
|
|
176
|
+
- CLI-only flags (not exposed as `deeptutor_run` tool parameters): `--notebook-ref`, `--history-ref`. The tool's `config` object is passed as `--config k=v` for scalars and `--config-json` for nested values.
|
|
177
177
|
- `deep_research` can take minutes: give a generous timeout (900+) or split long tasks.
|
|
178
178
|
- Results may be truncated (default 30000 chars) — ask to continue for the full content.
|
|
179
179
|
- RAG hits can be noisy; treat official sources as authoritative and point out conflicts to the user.
|
|
@@ -360,13 +360,22 @@ function main() {
|
|
|
360
360
|
fail(`template.html not found (looked in: ${templateCandidates.join(", ")})`);
|
|
361
361
|
}
|
|
362
362
|
let template = fs.readFileSync(templatePath, "utf8");
|
|
363
|
-
template
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
363
|
+
// One pass over the template with a replacer function: the inserted text is
|
|
364
|
+
// used verbatim (a replacement *string* would expand `$$`, `$&`, `` $` ``,
|
|
365
|
+
// `$'`), and text already inserted (e.g. a literal `{{TOC}}` in the body)
|
|
366
|
+
// is never scanned for placeholders again.
|
|
367
|
+
const values = {
|
|
368
|
+
TITLE: esc(title),
|
|
369
|
+
BODY: html,
|
|
370
|
+
TOC: tocHtml,
|
|
371
|
+
THEME: opts.theme,
|
|
372
|
+
LANG: opts.lang,
|
|
373
|
+
GENERATED: generated,
|
|
374
|
+
};
|
|
375
|
+
template = template.replace(
|
|
376
|
+
/\{\{(TITLE|BODY|TOC|THEME|LANG|GENERATED)\}\}/g,
|
|
377
|
+
(_, key) => values[key],
|
|
378
|
+
);
|
|
370
379
|
|
|
371
380
|
if (opts.out) {
|
|
372
381
|
fs.writeFileSync(opts.out, template, "utf8");
|
package/README.md
CHANGED
|
@@ -12,9 +12,6 @@ Ask the agent *"teach me async/await"* and it can run a deep-solve, render the
|
|
|
12
12
|
answer as a self-contained HTML study page you can open in a browser, and
|
|
13
13
|
archive a summary into your notebook.
|
|
14
14
|
|
|
15
|
-
Migrated from the pi coding-agent extension
|
|
16
|
-
(`TecFancy/pi-extensions`, `extensions/deeptutor` + `skills/deeptutor`).
|
|
17
|
-
|
|
18
15
|
## What it adds
|
|
19
16
|
|
|
20
17
|
Three agent-facing tools that the model uses whenever you ask for learning help:
|
|
@@ -61,10 +58,14 @@ study page, then archived to a notebook):
|
|
|
61
58
|
activation breaks. Bundle auto-registration via `dsh plugin add` was verified
|
|
62
59
|
on dsh CLI 0.1.0-rc.6, 0.2.1-rc.2 and 0.2.1-rc.3.
|
|
63
60
|
- A DeepTutor deployment, either:
|
|
64
|
-
- **Local** — `deeptutor
|
|
65
|
-
|
|
66
|
-
- **Remote** — DeepTutor on a server
|
|
67
|
-
|
|
61
|
+
- **Local** — the `deeptutor` CLI installed on this machine (on `PATH`, or
|
|
62
|
+
pointed to by `DEEPTUTOR_LOCAL_BIN`);
|
|
63
|
+
- **Remote** — DeepTutor installed on a server you can reach with
|
|
64
|
+
passwordless SSH; the plugin runs the server's CLI over SSH.
|
|
65
|
+
|
|
66
|
+
Tested against DeepTutor 1.7.1. Since 1.7 the `kb` and `notebook` commands
|
|
67
|
+
and most capabilities come from optional modules; check that the ones you
|
|
68
|
+
use are installed and enabled with `deeptutor module list`.
|
|
68
69
|
|
|
69
70
|
## Install into a profile (bundle)
|
|
70
71
|
|
|
@@ -124,7 +125,7 @@ install`:
|
|
|
124
125
|
|
|
125
126
|
```json
|
|
126
127
|
{
|
|
127
|
-
"dependencies": { "dsh-deeptutor": "^0.
|
|
128
|
+
"dependencies": { "dsh-deeptutor": "^0.2.0" },
|
|
128
129
|
"dsh": {
|
|
129
130
|
"profile": { "bundles": ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-web-app", "dsh-deeptutor"] }
|
|
130
131
|
}
|
|
@@ -163,34 +164,40 @@ Two skills ship inside this package (`.agents/skills/deeptutor` and
|
|
|
163
164
|
Installing a newer package version overwrites skill files in place; files not
|
|
164
165
|
shipped by the package are never deleted.
|
|
165
166
|
|
|
166
|
-
The
|
|
167
|
-
skills in `TecFancy/pi-extensions` (single source of truth, agent-neutral).
|
|
168
|
-
Sync them after upstream edits with
|
|
169
|
-
`node scripts/sync-skills.mjs ../pi-extensions`.
|
|
167
|
+
The skills are maintained in this repo under `.agents/skills/`.
|
|
170
168
|
|
|
171
169
|
## Configuration (env vars, agent-agnostic)
|
|
172
170
|
|
|
173
171
|
```bash
|
|
174
|
-
# Remote deployment (DeepTutor on a server,
|
|
172
|
+
# Remote deployment (DeepTutor on a server, driven over SSH)
|
|
175
173
|
export DEEPTUTOR_SSH_HOST="tencent-cloud" # SSH host alias (set = remote mode)
|
|
176
|
-
export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # local tunnel address
|
|
177
174
|
export DEEPTUTOR_REMOTE_BIN="/home/ubuntu/my-deeptutor/.venv/bin/deeptutor"
|
|
178
175
|
export DEEPTUTOR_REMOTE_HOME="/home/ubuntu/my-deeptutor"
|
|
179
176
|
|
|
180
177
|
# Local deployment — leave DEEPTUTOR_SSH_HOST unset
|
|
181
|
-
# export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # local serve port
|
|
182
178
|
# export DEEPTUTOR_LOCAL_BIN="deeptutor" # local CLI path (default: deeptutor on PATH)
|
|
183
179
|
```
|
|
184
180
|
|
|
185
181
|
Restart dsh after changing env vars.
|
|
186
182
|
|
|
183
|
+
**Windows, local mode:** point `DEEPTUTOR_LOCAL_BIN` at `deeptutor.exe`
|
|
184
|
+
(for a pip/venv install: `<venv>\Scripts\deeptutor.exe`). A `.cmd`/`.bat`
|
|
185
|
+
wrapper also works: one that only forwards `%*` to an `.exe` is bypassed and
|
|
186
|
+
the `.exe` is run directly; any other wrapper runs through `cmd.exe`, which
|
|
187
|
+
cannot pass multi-line prompts, so those calls fail with a hint to use the
|
|
188
|
+
`.exe`.
|
|
189
|
+
|
|
187
190
|
## How it works
|
|
188
191
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
Every tool call drives the DeepTutor CLI: the local `deeptutor` binary, or the
|
|
193
|
+
remote binary over SSH when `DEEPTUTOR_SSH_HOST` is set. `deeptutor serve` does
|
|
194
|
+
not need to be reachable from this machine.
|
|
195
|
+
|
|
196
|
+
Earlier versions tried the HTTP/WebSocket API first (`/api/v1/...` through an
|
|
197
|
+
SSH tunnel) and only then fell back to the CLI. DeepTutor 1.7 serves those
|
|
198
|
+
routes under different paths and behind a login, so the probe always failed
|
|
199
|
+
and each call waited about 30 seconds before reaching the CLI. That path was
|
|
200
|
+
removed; `DEEPTUTOR_API_BASE` is no longer read.
|
|
194
201
|
|
|
195
202
|
## Develop against a checkout (no publish needed)
|
|
196
203
|
|
|
@@ -226,6 +233,6 @@ cordis.patch.yml # bundle patch: insert the package by name
|
|
|
226
233
|
```
|
|
227
234
|
|
|
228
235
|
`src/index.ts` registers the tools; `config.ts` holds env config;
|
|
229
|
-
`cli-exec.ts` local/SSH CLI execution; `
|
|
230
|
-
`turn.ts` one learning turn (
|
|
236
|
+
`cli-exec.ts` local/SSH CLI execution; `win-cmd.ts` starting a `.cmd`/`.bat` CLI on Windows;
|
|
237
|
+
`turn.ts` one learning turn (CLI JSONL event folding + formatting);
|
|
231
238
|
`html-render.ts` answer → self-contained HTML.
|
package/README.zh.md
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
只要对 agent 说 *"给我讲讲 async/await"*,它就能跑一次 deep-solve,把答案渲染成可在浏览器打开的自包含 HTML 学习页,再把摘要归档进你的笔记本。
|
|
8
8
|
|
|
9
|
-
本扩展由 pi 编码 agent 扩展迁移而来(`TecFancy/pi-extensions`,`extensions/deeptutor` + `skills/deeptutor`)。
|
|
10
|
-
|
|
11
9
|
## 它带来什么
|
|
12
10
|
|
|
13
11
|
三个 agent 可见工具,当你请求学习帮助时由模型调用:
|
|
@@ -41,8 +39,10 @@
|
|
|
41
39
|
|
|
42
40
|
- 可用的 DeepSeek Harness (dsh) 安装,0.1.0-rc.6 或更新版本。清单里只写下限不写上限,新版本 dsh 发布后不会再在安装时被拒绝;替代办法是定时拿 npm 上 `latest` 和 `next` 两个通道的宿主各冷启动一次,插件起不来就开 issue。`dsh plugin add` 自动登记 bundle 已在 dsh CLI 0.1.0-rc.6、0.2.1-rc.2 与 0.2.1-rc.3 上验证。
|
|
43
41
|
- 一个 DeepTutor 部署,二选一:
|
|
44
|
-
- **本地** ——
|
|
45
|
-
- **远程** —— DeepTutor
|
|
42
|
+
- **本地** —— 本机装有 `deeptutor` CLI(在 PATH 上,或由 `DEEPTUTOR_LOCAL_BIN` 指定);
|
|
43
|
+
- **远程** —— DeepTutor 装在一台能免密 SSH 登录的服务器上,插件经 SSH 调用服务器上的 CLI。
|
|
44
|
+
|
|
45
|
+
已在 DeepTutor 1.7.1 上验证。从 1.7 起,`kb`、`notebook` 命令和大部分 capability 由可选模块提供,用 `deeptutor module list` 确认要用的模块已安装并启用。
|
|
46
46
|
|
|
47
47
|
## 安装到 profile(bundle 方式)
|
|
48
48
|
|
|
@@ -79,7 +79,7 @@ dsh --profile web --dump-config | grep dsh-deeptutor
|
|
|
79
79
|
|
|
80
80
|
```json
|
|
81
81
|
{
|
|
82
|
-
"dependencies": { "dsh-deeptutor": "^0.
|
|
82
|
+
"dependencies": { "dsh-deeptutor": "^0.2.0" },
|
|
83
83
|
"dsh": {
|
|
84
84
|
"profile": { "bundles": ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-web-app", "dsh-deeptutor"] }
|
|
85
85
|
}
|
|
@@ -110,27 +110,29 @@ bundle 清单(`dsh.bundle.patch → cordis.patch.yml`)负责插入插件行;上
|
|
|
110
110
|
|
|
111
111
|
升级包版本时会就地覆盖 skill 文件;包未携带的文件不会被删除。
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
skill 就在本仓库的 `.agents/skills/` 下维护。
|
|
114
114
|
|
|
115
115
|
## 配置(环境变量,与 agent 无关)
|
|
116
116
|
|
|
117
117
|
```bash
|
|
118
|
-
# 远程部署(DeepTutor
|
|
118
|
+
# 远程部署(DeepTutor 在服务器上,经 SSH 调用)
|
|
119
119
|
export DEEPTUTOR_SSH_HOST="tencent-cloud" # SSH 主机别名(设置 = 远程模式)
|
|
120
|
-
export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # 本地隧道地址
|
|
121
120
|
export DEEPTUTOR_REMOTE_BIN="/home/ubuntu/my-deeptutor/.venv/bin/deeptutor"
|
|
122
121
|
export DEEPTUTOR_REMOTE_HOME="/home/ubuntu/my-deeptutor"
|
|
123
122
|
|
|
124
123
|
# 本地部署 —— 不要设置 DEEPTUTOR_SSH_HOST
|
|
125
|
-
# export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # 本地 serve 端口
|
|
126
124
|
# export DEEPTUTOR_LOCAL_BIN="deeptutor" # 本地 CLI 路径(默认: PATH 上的 deeptutor)
|
|
127
125
|
```
|
|
128
126
|
|
|
129
127
|
修改环境变量后需重启 dsh。
|
|
130
128
|
|
|
129
|
+
**Windows 本地模式:** 把 `DEEPTUTOR_LOCAL_BIN` 指向 `deeptutor.exe`(pip/venv 安装时是 `<venv>\Scripts\deeptutor.exe`)。`.cmd`/`.bat` 包装脚本也能用:只把 `%*` 转给某个 `.exe` 的包装脚本会被绕过,直接运行那个 `.exe`;其他包装脚本经 `cmd.exe` 运行,而 `cmd.exe` 传不了多行提示词,这类调用会报错并提示改用 `.exe`。
|
|
130
|
+
|
|
131
131
|
## 工作原理
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
每次工具调用都走 DeepTutor CLI:本地的 `deeptutor` 二进制,或在设置了 `DEEPTUTOR_SSH_HOST` 时经 SSH 调用远程二进制。本机不需要能访问 `deeptutor serve`。
|
|
134
|
+
|
|
135
|
+
早期版本先尝试 HTTP/WebSocket API(经 SSH 隧道访问 `/api/v1/...`),失败后才回退到 CLI。DeepTutor 1.7 的这些接口换了路径并要求登录,探测总是失败,每次调用都要先等约 30 秒才轮到 CLI。这条路径已移除,`DEEPTUTOR_API_BASE` 不再读取。
|
|
134
136
|
|
|
135
137
|
## 源码开发(无需发布)
|
|
136
138
|
|
|
@@ -163,4 +165,4 @@ cordis.yml # 开发 overlay:按绝对路径插入 src/index.ts
|
|
|
163
165
|
cordis.patch.yml # bundle patch:按包名插入插件
|
|
164
166
|
```
|
|
165
167
|
|
|
166
|
-
`src/index.ts` 注册工具;`config.ts` 环境配置;`cli-exec.ts` 本地/SSH CLI 执行;`
|
|
168
|
+
`src/index.ts` 注册工具;`config.ts` 环境配置;`cli-exec.ts` 本地/SSH CLI 执行;`win-cmd.ts` 在 Windows 上启动 `.cmd`/`.bat` 形式的 CLI;`turn.ts` 单次学习回合(CLI JSONL 事件折叠与格式化);`html-render.ts` 答案 → 自包含 HTML。
|
package/lib/cli-exec.js
CHANGED
|
@@ -7,6 +7,7 @@ import { rmSync, writeFileSync } from "node:fs";
|
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
import { DEEPTUTOR_BIN, DEEPTUTOR_HOME, LOCAL_BIN, SSH_HOST } from "./config.js";
|
|
10
|
+
import { resolveLocalCommand } from "./win-cmd.js";
|
|
10
11
|
// Remote runner: reads argv from a JSON file and executes without a shell (avoids all quoting/escaping).
|
|
11
12
|
const PY_RUNNER = [
|
|
12
13
|
"import json, subprocess, sys",
|
|
@@ -53,6 +54,7 @@ function execFileResolved(file, args, opts = {}) {
|
|
|
53
54
|
const child = execFile(file, args, {
|
|
54
55
|
env: opts.env ? { ...process.env, ...opts.env } : process.env,
|
|
55
56
|
windowsHide: true,
|
|
57
|
+
windowsVerbatimArguments: opts.windowsVerbatimArguments,
|
|
56
58
|
timeout: opts.timeoutMs,
|
|
57
59
|
}, (err, stdout, stderr) => {
|
|
58
60
|
const e = err;
|
|
@@ -109,8 +111,17 @@ export async function runCli(args, opts = {}) {
|
|
|
109
111
|
if (SSH_HOST) {
|
|
110
112
|
return sshExec([DEEPTUTOR_BIN, ...args], opts);
|
|
111
113
|
}
|
|
112
|
-
// Local mode: execute directly (force UTF-8 output to avoid Windows cp1252 console crashes)
|
|
113
|
-
|
|
114
|
+
// Local mode: execute directly (force UTF-8 output to avoid Windows cp1252 console crashes).
|
|
115
|
+
// On Windows a .cmd/.bat LOCAL_BIN needs special handling (spawn EINVAL otherwise, issue #8).
|
|
116
|
+
const cmd = resolveLocalCommand(LOCAL_BIN, args);
|
|
117
|
+
if (cmd.error)
|
|
118
|
+
return { stdout: "", stderr: cmd.error, code: 1, killed: false };
|
|
119
|
+
const res = await execFileResolved(cmd.file, cmd.args, {
|
|
120
|
+
signal: opts.signal,
|
|
121
|
+
timeoutMs: opts.timeoutMs,
|
|
122
|
+
env: { PYTHONUTF8: "1", PYTHONIOENCODING: "utf-8" },
|
|
123
|
+
windowsVerbatimArguments: cmd.windowsVerbatimArguments,
|
|
124
|
+
});
|
|
114
125
|
const out = res.stdout ?? "";
|
|
115
126
|
const [stdout, stderr] = out.split("__DT_STDERR__");
|
|
116
127
|
return {
|
package/lib/config.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DeepTutor bridge: shared configuration (env vars) and small helpers.
|
|
3
3
|
*
|
|
4
|
+
* Every call goes through the deeptutor CLI. DeepTutor 1.7 moved its HTTP/WS routes off
|
|
5
|
+
* /api/v1 and put them behind a login, so the plugin no longer talks to `deeptutor serve`.
|
|
6
|
+
*
|
|
4
7
|
* Config (optional env vars, agent-agnostic):
|
|
5
8
|
* DEEPTUTOR_SSH_HOST SSH host alias (remote deployment; unset/empty = local deployment)
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* DEEPTUTOR_REMOTE_HOME remote DEEPTUTOR_HOME workspace (remote)
|
|
9
|
+
* DEEPTUTOR_LOCAL_BIN local deeptutor executable (default: deeptutor on PATH)
|
|
10
|
+
* DEEPTUTOR_REMOTE_BIN remote deeptutor binary path (remote deployment)
|
|
11
|
+
* DEEPTUTOR_REMOTE_HOME remote DEEPTUTOR_HOME workspace (remote deployment)
|
|
10
12
|
*/
|
|
11
13
|
export declare const SSH_HOST: string;
|
|
12
|
-
export declare const API_BASE: string;
|
|
13
|
-
export declare const TUNNEL_PORT: number;
|
|
14
14
|
export declare const LOCAL_BIN: string;
|
|
15
15
|
export declare const DEEPTUTOR_BIN: string;
|
|
16
16
|
export declare const DEEPTUTOR_HOME: string;
|
package/lib/config.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DeepTutor bridge: shared configuration (env vars) and small helpers.
|
|
3
3
|
*
|
|
4
|
+
* Every call goes through the deeptutor CLI. DeepTutor 1.7 moved its HTTP/WS routes off
|
|
5
|
+
* /api/v1 and put them behind a login, so the plugin no longer talks to `deeptutor serve`.
|
|
6
|
+
*
|
|
4
7
|
* Config (optional env vars, agent-agnostic):
|
|
5
8
|
* DEEPTUTOR_SSH_HOST SSH host alias (remote deployment; unset/empty = local deployment)
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* DEEPTUTOR_REMOTE_HOME remote DEEPTUTOR_HOME workspace (remote)
|
|
9
|
+
* DEEPTUTOR_LOCAL_BIN local deeptutor executable (default: deeptutor on PATH)
|
|
10
|
+
* DEEPTUTOR_REMOTE_BIN remote deeptutor binary path (remote deployment)
|
|
11
|
+
* DEEPTUTOR_REMOTE_HOME remote DEEPTUTOR_HOME workspace (remote deployment)
|
|
10
12
|
*/
|
|
11
13
|
export const SSH_HOST = process.env.DEEPTUTOR_SSH_HOST ?? "";
|
|
12
|
-
export const API_BASE = process.env.DEEPTUTOR_API_BASE ?? "http://127.0.0.1:8001";
|
|
13
|
-
export const TUNNEL_PORT = Number(new URL(API_BASE).port || 8001);
|
|
14
14
|
export const LOCAL_BIN = process.env.DEEPTUTOR_LOCAL_BIN ?? "deeptutor";
|
|
15
15
|
export const DEEPTUTOR_BIN = process.env.DEEPTUTOR_REMOTE_BIN ?? "/home/ubuntu/my-deeptutor/.venv/bin/deeptutor";
|
|
16
16
|
export const DEEPTUTOR_HOME = process.env.DEEPTUTOR_REMOTE_HOME ?? "/home/ubuntu/my-deeptutor";
|
|
17
17
|
// Whether the user explicitly configured anything (show a one-time hint when not)
|
|
18
18
|
const IS_CONFIGURED = Boolean(process.env.DEEPTUTOR_SSH_HOST ||
|
|
19
|
-
process.env.DEEPTUTOR_API_BASE ||
|
|
20
19
|
process.env.DEEPTUTOR_LOCAL_BIN ||
|
|
21
20
|
process.env.DEEPTUTOR_REMOTE_BIN ||
|
|
22
21
|
process.env.DEEPTUTOR_REMOTE_HOME);
|
|
@@ -25,25 +24,25 @@ export function configHint() {
|
|
|
25
24
|
if (IS_CONFIGURED || configHintShown)
|
|
26
25
|
return "";
|
|
27
26
|
configHintShown = true;
|
|
28
|
-
return ("⚠️ No DEEPTUTOR_* env vars detected; running in local-deployment mode (
|
|
29
|
-
' Local deployment: export
|
|
30
|
-
' Remote deployment: export DEEPTUTOR_SSH_HOST="your-ssh-alias" plus
|
|
31
|
-
" (See the SKILL's Configuration section; changing server
|
|
27
|
+
return ("⚠️ No DEEPTUTOR_* env vars detected; running in local-deployment mode (deeptutor CLI on PATH).\n" +
|
|
28
|
+
' Local deployment: optionally export DEEPTUTOR_LOCAL_BIN="/path/to/deeptutor"\n' +
|
|
29
|
+
' Remote deployment: export DEEPTUTOR_SSH_HOST="your-ssh-alias" plus DEEPTUTOR_REMOTE_BIN / DEEPTUTOR_REMOTE_HOME\n' +
|
|
30
|
+
" (See the SKILL's Configuration section; changing server only requires env vars)\n");
|
|
32
31
|
}
|
|
33
32
|
export function configGuide() {
|
|
34
33
|
return ("\n--- Configuration troubleshooting ---\n" +
|
|
35
|
-
"Local deployment (deeptutor
|
|
36
|
-
' export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" (serve port)\n' +
|
|
34
|
+
"Local deployment (deeptutor installed on this machine):\n" +
|
|
37
35
|
' export DEEPTUTOR_LOCAL_BIN="deeptutor" (local CLI path, optional)\n' +
|
|
38
36
|
" Note: do NOT set DEEPTUTOR_SSH_HOST (empty = local mode)\n" +
|
|
39
|
-
" Verify
|
|
40
|
-
"Remote deployment (deeptutor on a server):\n" +
|
|
37
|
+
" Verify the CLI works: deeptutor kb list --format json\n" +
|
|
38
|
+
"Remote deployment (deeptutor on a server, driven over SSH):\n" +
|
|
41
39
|
' export DEEPTUTOR_SSH_HOST="your-ssh-alias"\n' +
|
|
42
|
-
' export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" (local tunnel address; port must match the server\'s serve)\n' +
|
|
43
40
|
' export DEEPTUTOR_REMOTE_BIN="remote-deeptutor-binary-path"\n' +
|
|
44
41
|
' export DEEPTUTOR_REMOTE_HOME="remote-DEEPTUTOR_HOME-workspace"\n' +
|
|
45
|
-
" Verify serve is running on the server (ssh to it: curl http://127.0.0.1:8001/api/v1/system/status)\n" +
|
|
46
42
|
" Verify passwordless SSH login works (ssh alias + BatchMode)\n" +
|
|
43
|
+
" Verify the remote CLI works: ssh <alias> <DEEPTUTOR_REMOTE_BIN> kb list --format json\n" +
|
|
44
|
+
"DeepTutor 1.7+: the kb / notebook commands and most capabilities need their modules\n" +
|
|
45
|
+
" installed and enabled (check with: deeptutor module list).\n" +
|
|
47
46
|
'PowerShell users: use $env:VAR="value" instead of export VAR=value.\n' +
|
|
48
47
|
"Restart the agent after configuring.\n");
|
|
49
48
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DeepTutor bridge plugin for DeepSeek Harness (dsh).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - deeptutor_run — execute a DeepTutor learning capability (HTTP/WS first, CLI fallback)
|
|
4
|
+
* Registers three model-facing tools:
|
|
5
|
+
* - deeptutor_run — execute a DeepTutor learning capability
|
|
7
6
|
* - deeptutor_kb — list / search / info knowledge bases
|
|
8
7
|
* - deeptutor_note — archive a Markdown learning note to a server notebook
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
* - Local:
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* Transport: every tool drives the deeptutor CLI.
|
|
10
|
+
* - Local: DEEPTUTOR_SSH_HOST unset → runs the local CLI (DEEPTUTOR_LOCAL_BIN).
|
|
11
|
+
* - Remote: DEEPTUTOR_SSH_HOST set → runs the server's CLI over SSH.
|
|
12
|
+
* The HTTP/WS API was dropped: DeepTutor 1.7 moved it off /api/v1 and put it behind
|
|
13
|
+
* a login, so the old probe always 404'd and cost ~30s per call before the CLI ran anyway.
|
|
15
14
|
*
|
|
16
|
-
* Env config (agent-agnostic): DEEPTUTOR_SSH_HOST /
|
|
15
|
+
* Env config (agent-agnostic): DEEPTUTOR_SSH_HOST / DEEPTUTOR_LOCAL_BIN /
|
|
17
16
|
* DEEPTUTOR_REMOTE_BIN / DEEPTUTOR_REMOTE_HOME — see src/config.ts and
|
|
18
17
|
* .agents/skills/deeptutor/SKILL.md.
|
|
19
18
|
*/
|