dsh-deeptutor 0.1.4 → 0.1.6

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
@@ -130,11 +130,18 @@ run on plain Node ≥ 20 ESM.
130
130
 
131
131
  ## Skills
132
132
 
133
- The agent-facing workflow lives in the `deeptutor` skill, installed at
134
- `~/.dsh/skills/deeptutor/SKILL.md` (auto-discovered by dsh). The companion
135
- `html-doc` skill (`~/.dsh/skills/html-doc/`) renders study answers to
136
- self-contained HTML pages; this plugin bundles the same converter under
137
- `scripts/md-to-html.js` and uses it when `deeptutor_run` gets an `html` path.
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.
138
145
 
139
146
  ## Configuration (env vars, agent-agnostic)
140
147
 
@@ -159,6 +166,7 @@ src/ # TypeScript sources (dev loading, typecheck)
159
166
  lib/ # compiled ESM (published entry, from `npm run build`)
160
167
  scripts/md-to-html.js # zero-dependency Markdown → HTML converter
161
168
  scripts/install-profile.mjs # one-shot profile installer (exposed as the `dsh-deeptutor` binary)
169
+ skills/ # bundled skills: deeptutor/ + html-doc/ (installed to <DSH_HOME>/skills/)
162
170
  cordis.yml # dev overlay: insert src/index.ts by absolute path
163
171
  cordis.patch.yml # bundle patch: insert the package by name
164
172
  ```
package/README.zh.md CHANGED
@@ -93,7 +93,12 @@ npm publish
93
93
 
94
94
  ## Skills
95
95
 
96
- 面向 agent 的工作流位于 `deeptutor` skill,安装于 `~/.dsh/skills/deeptutor/SKILL.md`(dsh 自动发现)。配套的 `html-doc` skill(`~/.dsh/skills/html-doc/`)将学习内容渲染为自包含 HTML 页面;本插件内置同一转换器(`scripts/md-to-html.js`),当 `deeptutor_run` 传入 `html` 路径时自动使用。
96
+ 本包携带两个 skill(`skills/deeptutor` 与 `skills/html-doc`),随包安装器每次运行时都会把它们复制到 `<DSH_HOME>/skills/<name>/`(dsh 自动发现)——所以 `pnpm dlx dsh-deeptutor` 一次装齐插件 **和** skill:
97
+
98
+ - `deeptutor` — 面向 agent 的学习工作流(`~/.dsh/skills/deeptutor/SKILL.md`)
99
+ - `html-doc` — 将学习内容渲染为自包含 HTML 页面(`~/.dsh/skills/html-doc/`);`deeptutor_run` 传入 `html` 路径时,插件内部使用同一转换器(`scripts/md-to-html.js`)
100
+
101
+ 升级包版本时会就地覆盖 skill 文件;包未携带的文件不会被删除。
97
102
 
98
103
  ## 配置(环境变量,与 agent 无关)
99
104
 
@@ -118,6 +123,7 @@ src/ # TypeScript 源码(开发加载、类型检查)
118
123
  lib/ # 编译产物(发布入口,由 npm run build 生成)
119
124
  scripts/md-to-html.js # 零依赖 Markdown → HTML 转换器
120
125
  scripts/install-profile.mjs # 一键 profile 安装器(以 `dsh-deeptutor` 二进制暴露)
126
+ skills/ # 随包 skill:deeptutor/ + html-doc/(安装到 <DSH_HOME>/skills/)
121
127
  cordis.yml # 开发 overlay:按绝对路径插入 src/index.ts
122
128
  cordis.patch.yml # bundle patch:按包名插入插件
123
129
  ```
package/lib/index.js CHANGED
@@ -158,7 +158,7 @@ export function apply(ctx) {
158
158
  },
159
159
  top_k: {
160
160
  type: "number",
161
- description: "Number of hits to return, default 5",
161
+ description: "Number of hits to return, default 5 (applied locally to the CLI search result; the deeptutor CLI has no --top-k flag)",
162
162
  },
163
163
  max_chars: {
164
164
  type: "number",
@@ -215,7 +215,8 @@ export function apply(ctx) {
215
215
  console.log(`[deeptutor] kb ${args.action} HTTP failed, falling back to CLI: ${err?.message}`);
216
216
  }
217
217
  }
218
- // CLI fallback (local or SSH)
218
+ // CLI fallback (local or SSH). NOTE: `kb search` has no --top-k flag
219
+ // (verified on deeptutor CLI 1.5.x); top_k is applied locally below.
219
220
  let argv;
220
221
  if (args.action === "list") {
221
222
  argv = ["kb", "list", "--format", "json"];
@@ -234,8 +235,6 @@ export function apply(ctx) {
234
235
  "--mode",
235
236
  args.mode ?? "hybrid",
236
237
  ];
237
- if (args.top_k)
238
- argv.push("--top-k", String(args.top_k));
239
238
  }
240
239
  const { stdout, stderr, code, killed } = await runCli(argv, {
241
240
  signal: exec.signal,
@@ -250,16 +249,32 @@ export function apply(ctx) {
250
249
  let body = stdout.trim() || "(empty result)";
251
250
  if (args.action === "search") {
252
251
  try {
253
- const arr = JSON.parse(stdout);
254
- if (Array.isArray(arr)) {
255
- body = arr
256
- .map((s, i) => {
257
- const text = s.text ?? s.content ?? s.snippet ?? JSON.stringify(s);
258
- const src = s.source ?? s.doc_name ?? s.file ?? "";
259
- return `[${i + 1}]${src ? ` source: ${src}` : ""}\n${typeof text === "string" ? text : JSON.stringify(text)}`;
260
- })
261
- .join("\n\n");
262
- body = `${arr.length} hits:\n\n` + body;
252
+ const parsed = JSON.parse(stdout);
253
+ const fmtHit = (s, i) => {
254
+ const text = s.text ?? s.content ?? s.snippet ?? JSON.stringify(s);
255
+ const src = s.source ?? s.doc_name ?? s.file ?? "";
256
+ const title = s.title ? ` title: ${s.title}` : "";
257
+ const score = typeof s.score === "number" ? ` score: ${s.score}` : "";
258
+ return `[${i + 1}]${src ? ` source: ${src}` : ""}${title}${score}\n${typeof text === "string" ? text : JSON.stringify(text)}`;
259
+ };
260
+ // Current deeptutor CLI (1.5.x) returns an object
261
+ // { query, answer, content, sources, provider }; older builds
262
+ // returned a bare array of hits. Accept both.
263
+ if (Array.isArray(parsed)) {
264
+ const hits = args.top_k ? parsed.slice(0, args.top_k) : parsed;
265
+ body = `${hits.length} hits:\n\n` + hits.map(fmtHit).join("\n\n");
266
+ }
267
+ else if (parsed && typeof parsed === "object") {
268
+ const parts = [];
269
+ if (parsed.query)
270
+ parts.push(`Query: ${parsed.query}`);
271
+ if (typeof parsed.answer === "string" && parsed.answer.trim())
272
+ parts.push(`Answer: ${parsed.answer.trim()}`);
273
+ const sources = Array.isArray(parsed.sources) ? parsed.sources : [];
274
+ const hits = args.top_k ? sources.slice(0, args.top_k) : sources;
275
+ parts.push(`${hits.length} hits:`);
276
+ parts.push(hits.map(fmtHit).join("\n\n"));
277
+ body = parts.join("\n\n");
263
278
  }
264
279
  }
265
280
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-deeptutor",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "DeepTutor bridge bundle for DeepSeek Harness: learning capabilities, knowledge bases, and note archiving (HTTP/WS first, CLI fallback; auto-adapts local/remote deployment).",
5
5
  "keywords": [
6
6
  "dsh",
@@ -16,7 +16,7 @@
16
16
  "main": "./lib/index.js",
17
17
  "types": "./lib/index.d.ts",
18
18
  "bin": {
19
- "dsh-deeptutor": "./scripts/install-profile.mjs"
19
+ "dsh-deeptutor": "scripts/install-profile.mjs"
20
20
  },
21
21
  "exports": {
22
22
  ".": {
@@ -25,6 +25,7 @@
25
25
  },
26
26
  "./cordis.patch.yml": "./cordis.patch.yml",
27
27
  "./scripts/*": "./scripts/*",
28
+ "./skills/*": "./skills/*",
28
29
  "./src/*": "./src/*",
29
30
  "./package.json": "./package.json"
30
31
  },
@@ -32,6 +33,7 @@
32
33
  "lib",
33
34
  "src",
34
35
  "scripts",
36
+ "skills",
35
37
  "cordis.patch.yml",
36
38
  "README.md",
37
39
  "README.zh.md"
@@ -18,13 +18,22 @@
18
18
  * Options:
19
19
  * -p, --profile <name> dsh profile to install into (default: web)
20
20
  * -h, --help show this help
21
+ *
22
+ * Besides installing the bundle, the installer copies the package's bundled
23
+ * skills (`skills/deeptutor`, `skills/html-doc`) into
24
+ * `<DSH_HOME>/skills/<name>/`, where dsh auto-discovers them. Existing files
25
+ * are overwritten; files not shipped by the package are never deleted.
21
26
  */
22
27
  import { spawnSync } from 'node:child_process';
23
- import { existsSync } from 'node:fs';
24
- import { delimiter, join } from 'node:path';
28
+ import { cpSync, existsSync, mkdirSync, readdirSync } from 'node:fs';
29
+ import { homedir } from 'node:os';
30
+ import { delimiter, dirname, join } from 'node:path';
31
+ import { fileURLToPath } from 'node:url';
25
32
 
26
33
  const PKG = 'dsh-deeptutor';
27
34
  const NAME = 'dsh-deeptutor-install';
35
+ const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
36
+ const SKILLS_DIR = join(SCRIPT_DIR, '..', 'skills');
28
37
 
29
38
  const USAGE = `usage: dsh-deeptutor [--profile <name>]
30
39
 
@@ -186,13 +195,39 @@ function main() {
186
195
  }
187
196
 
188
197
  function finish(profile) {
198
+ const skills = installSkills();
189
199
  console.log(`
190
200
  \u2714 ${PKG} installed into profile '${profile}'
191
- \u00b7 dependency added and dsh.profile.bundles reconciled (bundle patch auto-registered)
201
+ \u00b7 dependency added and dsh.profile.bundles reconciled (bundle patch auto-registered)${skills}
192
202
 
193
203
  next steps:
194
204
  1. restart dsh (the bundle list is resolved at boot)
195
205
  2. verify: ${verifyHint(profile)}`);
196
206
  }
197
207
 
208
+ /**
209
+ * Copy the package's bundled skills into <DSH_HOME>/skills/<name>/ (dsh
210
+ * auto-discovers skills there). Existing files are overwritten in place;
211
+ * anything not shipped by this package is left untouched. Returns a
212
+ * human-readable summary line (or '' when there is nothing to install).
213
+ */
214
+ function installSkills() {
215
+ if (!existsSync(SKILLS_DIR)) {
216
+ console.error(`\n${NAME}: warning: no skills/ directory in this package — skill install skipped (old version?)`);
217
+ return '';
218
+ }
219
+ const dshHome = process.env.DSH_HOME || join(homedir(), '.dsh');
220
+ const installed = [];
221
+ for (const entry of readdirSync(SKILLS_DIR, { withFileTypes: true })) {
222
+ if (!entry.isDirectory()) continue;
223
+ const src = join(SKILLS_DIR, entry.name);
224
+ const dest = join(dshHome, 'skills', entry.name);
225
+ mkdirSync(dest, { recursive: true });
226
+ cpSync(src, dest, { recursive: true, force: true });
227
+ installed.push(entry.name);
228
+ }
229
+ if (installed.length === 0) return '';
230
+ return `\n \u00b7 skills installed: ${installed.join(', ')} -> ${join(dshHome, 'skills')}`;
231
+ }
232
+
198
233
  main();
@@ -0,0 +1,106 @@
1
+ # DeepTutor Learning Assistant (dsh bundle + SKILL)
2
+
3
+ > This README is the human-facing documentation; `SKILL.md` is the agent-facing instruction file (loaded on demand).
4
+ > Bundle: the `dsh-deeptutor` npm package (tools) | Skill: `skills/deeptutor/SKILL.md` (shipped inside the same package, installed to `~/.dsh/skills/deeptutor/`)
5
+
6
+ Bridges **DeepTutor** (open-source personalized tutoring platform) into dsh: combines your **personal knowledge bases** (RAG retrieval) with **authoritative web sources** to generate learning content, self-test questions, and study plans — then archives your notes to a DeepTutor notebook for later review.
7
+
8
+ ## Features
9
+
10
+ | Capability | Description |
11
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------ |
12
+ | Deep Solve | In-depth explanation of a topic grounded in knowledge bases + web search, with multi-turn follow-up (session continuity) |
13
+ | Deep Question | Generate exercises from the same learning session |
14
+ | Deep Research | Long multi-stage research (report mode supported) |
15
+ | KB Retrieval | RAG hits from your personal knowledge bases (dotnet / sqlserver / react, …) |
16
+ | Note Archiving | Save study notes/plans to a server notebook for searchable review |
17
+ | Mastery Path | Multi-stage learning path planning |
18
+
19
+ ## Installation
20
+
21
+ The `deeptutor` skill ships inside the `dsh-deeptutor` npm package. The bundled
22
+ installer (`scripts/install-profile.mjs` in the package, or
23
+ `pnpm dlx dsh-deeptutor --profile web`) installs the bundle **and** copies this
24
+ skill to `~/.dsh/skills/deeptutor/` (dsh auto-discovers skills there):
25
+
26
+ ```bash
27
+ # One-shot: bundle + skill, from the published package
28
+ pnpm dlx dsh-deeptutor --profile web
29
+
30
+ # Or install the skill manually from a checkout
31
+ xcopy /e /i skills\deeptutor %USERPROFILE%\.dsh\skills\deeptutor # Windows
32
+ cp -r skills/deeptutor ~/.dsh/skills/deeptutor # macOS/Linux
33
+ ```
34
+
35
+ ## Configuration (environment variables)
36
+
37
+ Set these in `~/.bashrc` or `~/.zshrc` (inherited by any agent at startup — agent-agnostic):
38
+
39
+ ```bash
40
+ # —— Remote deployment (DeepTutor on a server, via SSH tunnel) ——
41
+ export DEEPTUTOR_SSH_HOST="tencent-cloud" # SSH alias (set = remote mode)
42
+ export DEEPTUTOR_API_BASE="http://127.0.0.1:8001" # local tunnel address (change port here)
43
+ export DEEPTUTOR_REMOTE_BIN="/home/ubuntu/my-deeptutor/.venv/bin/deeptutor"
44
+ export DEEPTUTOR_REMOTE_HOME="/home/ubuntu/my-deeptutor"
45
+
46
+ # —— Local deployment (DeepTutor on this machine) —— leave DEEPTUTOR_SSH_HOST unset for local mode
47
+ # export DEEPTUTOR_LOCAL_BIN="deeptutor" # local CLI path (default: deeptutor on PATH)
48
+ # export DEEPTUTOR_HOME="/path/to/local-workspace" # local workspace
49
+ ```
50
+
51
+ **Deployment auto-adapts**: API reachable (local serve or tunnel) → HTTP/WS; unreachable → local CLI or SSH CLI fallback.
52
+
53
+ ## Usage
54
+
55
+ Just talk to your agent:
56
+
57
+ ```
58
+ Deep-dive Span<T> with my dotnet knowledge base, quiz me with 5 questions, then archive the notes to a notebook
59
+ ```
60
+
61
+ The agent follows the SKILL workflow automatically:
62
+
63
+ 1. **Dual sourcing**: `web_search` for authoritative material (Microsoft Learn, etc.) + `deeptutor_kb search` on your personal KB
64
+ 2. **Deep Solve**: `deeptutor_run` (deep_solve, mount KB + rag + web_search, Chinese replies)
65
+ 3. **Follow-up turns**: reuse the returned `session_id` to continue context
66
+ 4. **Self-test**: `deep_question` (config `num_questions`)
67
+ 5. **Plan**: structured study plan combining authoritative links + KB highlights
68
+ 6. **Archive**: `deeptutor_note` into a notebook
69
+
70
+ ## Tools
71
+
72
+ | Tool | Key parameters |
73
+ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
74
+ | `deeptutor_run` | `capability` (deep_solve / deep_question / deep_research / chat / mastery_path / …), `kbs`, `tools` (rag / web_search), `session_id`, `config`, `language` |
75
+ | `deeptutor_kb` | `list` / `search` (kb + query + mode) / `info` |
76
+ | `deeptutor_note` | `notebook` (auto-created), `title`, `type` (chat/question/research/solve), `content` (Markdown) |
77
+
78
+ ## Troubleshooting
79
+
80
+ | Symptom | Cause & fix |
81
+ | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
82
+ | Connection timeout / host resolution failure | ① Check `DEEPTUTOR_SSH_HOST` is set and SSH passwordless login works ② Is `deeptutor serve` running? (`curl http://127.0.0.1:8001/api/v1/system/status`) |
83
+ | Tool returns "No DEEPTUTOR_* env vars detected" | One-time hint on first call; configure per the Configuration section and restart the agent |
84
+ | Local CLI garbled output / crashes | The extension injects `PYTHONUTF8=1` automatically; verify Python ≥ 3.11 otherwise |
85
+ | 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) |
86
+ | CLI-only package missing modules | Official `packaging/deeptutor-cli` has incomplete deps; `pip install <module>` per the error (known: loguru, fastapi) |
87
+
88
+ ## FAQ
89
+
90
+ **Q: Can local and remote be used at the same time?**
91
+ A: Yes. Switching only requires changing env vars (set/remove `DEEPTUTOR_SSH_HOST`); the SKILL and bundle stay unchanged.
92
+
93
+ **Q: What if I change servers or ports?**
94
+ A: Only env vars change (`DEEPTUTOR_SSH_HOST` / `DEEPTUTOR_API_BASE` / remote paths) — never the SKILL or bundle.
95
+
96
+ **Q: Is the knowledge base list hardcoded?**
97
+ A: No. Tools query `deeptutor_kb list` dynamically; new bases are picked up automatically.
98
+
99
+ **Q: Can other agents (Claude Code / Codex) use it?**
100
+ A: Yes. The SKILL follows the Agent Skills standard and can be linked into `~/.agents/skills/`; the tools themselves are registered by the dsh bundle.
101
+
102
+ ## Maintenance
103
+
104
+ - Bundle features: edit the relevant file under `src/` (`index.ts` for tool wiring, `cli-exec.ts`/`http-api.ts`/`turn.ts` for transport logic, `config.ts` for env vars/helpers) → rebuild with `npm run build`
105
+ - SKILL content: edit `skills/deeptutor/SKILL.md` (keep the `name` + `description` frontmatter)
106
+ - Release: bump the version in `package.json`, push a `v*` tag, then `npm publish` (see the repo README)
@@ -0,0 +1,182 @@
1
+ ---
2
+ name: deeptutor
3
+ description: Combine DeepTutor personal knowledge bases (RAG) with authoritative web sources to generate learning content, self-test questions, and study plans, and archive notes to a notebook. Works with both local and remote DeepTutor deployments. Use when the user wants to learn/review a technical topic (e.g. .NET, C#, SQL Server, React), get a deep explanation grounded in their own knowledge bases, generate exercises, or plan their learning.
4
+ ---
5
+
6
+ # DeepTutor Learning Assistant (Personal Knowledge Base)
7
+
8
+ Combines the user's **personal knowledge bases** (RAG retrieval) with
9
+ **authoritative web sources** to produce learning content, self-test
10
+ questions, and study plans, then archives notes to a DeepTutor notebook.
11
+
12
+ This skill is **agent-agnostic**: every action below has two equivalent
13
+ drivers —
14
+
15
+ - **dsh (with the dsh-deeptutor bundle installed):** the `deeptutor_*` tools.
16
+ They auto-adapt local/remote deployment (HTTP/WS first with an automatic
17
+ SSH tunnel, CLI fallback) and stream progress.
18
+ - **Any agent / plain CLI:** the `deeptutor` executable directly (local
19
+ binary on PATH, or over SSH for remote deployments). No extension needed.
20
+
21
+ Pick whichever path exists in your environment; the action, not the tool, is
22
+ what matters.
23
+
24
+ ## When to Use
25
+
26
+ - The user wants to learn or review a technical topic (.NET, C#, SQL Server, React, …)
27
+ - The user wants content grounded in their own notes/knowledge bases
28
+ - The user wants generated exercises, quizzes, or a learning plan
29
+ - The user wants to archive study notes for later review
30
+
31
+ ## Configuration (env vars, agent-agnostic)
32
+
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
+
35
+ ```bash
36
+ # Remote deployment (DeepTutor on a server, reached through an SSH tunnel)
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
+ export DEEPTUTOR_REMOTE_BIN="/home/ubuntu/my-deeptutor/.venv/bin/deeptutor"
40
+ export DEEPTUTOR_REMOTE_HOME="/home/ubuntu/my-deeptutor"
41
+
42
+ # 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
+ # export DEEPTUTOR_LOCAL_BIN="deeptutor" # local CLI path (default: deeptutor on PATH)
45
+ ```
46
+
47
+ - **dsh path:** API reachable (local serve or tunnel) → HTTP/WS; unreachable →
48
+ local CLI or SSH CLI fallback automatically. The bundle starts/recycles
49
+ the SSH tunnel; local mode needs no tunnel.
50
+ - **Plain CLI path:** run `deeptutor <subcommand>` locally, or
51
+ `ssh <DEEPTUTOR_SSH_HOST> <DEEPTUTOR_REMOTE_BIN> <subcommand>` for remote
52
+ deployments (the tunnel is the extension's job — CLI users don't need it).
53
+ - Migrating to another server or port only requires changing env vars — never this skill.
54
+
55
+ ## Actions Cheat Sheet
56
+
57
+ | Action | dsh (tools) | CLI equivalent (`deeptutor …`) |
58
+ | ---------------------------- | -------------------------------- | ------------------------------------------------------------ |
59
+ | List knowledge bases | `deeptutor_kb action=list` | `kb list --format json` |
60
+ | Search a knowledge base | `deeptutor_kb action=search` | `kb search <kb> "<query>" --format json --mode hybrid` |
61
+ | Show a knowledge base's info | `deeptutor_kb action=info` | `kb info <kb>` |
62
+ | Run a learning capability | `deeptutor_run capability=<cap>` | `run <cap> "<prompt>" --format json` |
63
+ | Archive a note to a notebook | `deeptutor_note` | `notebook add-md <nb-id> <file> --title "<t>" --type <type>` |
64
+ | View lightweight memory | — (CLI only) | `memory show` |
65
+ | List / inspect sessions | — (CLI only) | `session list` · `session show <id>` |
66
+ | Show a notebook's records | — (CLI only) | `notebook show <name>` |
67
+ | Inspect configuration | — (CLI only) | `config show` (troubleshooting) |
68
+
69
+ Capabilities: `deep_solve` / `deep_question` / `deep_research` / `chat` /
70
+ `mastery_path` / `visualize` / `math_animator`.
71
+
72
+ Useful `run` flags: `--kb <name>` (mount a knowledge base, repeatable),
73
+ `--tool <name>` (`rag`, `web_search`, `reason`, …, repeatable),
74
+ `--session <id>` (continue context), `--language zh`, `--config k=v`
75
+ (repeatable; e.g. `--config num_questions=5`), `--config-json '{"..."}'`
76
+ (complex config), `--notebook-ref <name>` / `--history-ref <id>` (reference
77
+ notebooks or past sessions from the prompt).
78
+
79
+ ## Discovering Commands
80
+
81
+ The command set evolves — this cheat sheet is a curated subset, not the full
82
+ surface. Before using a command not listed here, **discover it from the CLI
83
+ itself** and never invent flags:
84
+
85
+ ```bash
86
+ deeptutor --help # top-level commands
87
+ deeptutor <cmd> --help # one subcommand's options
88
+ ```
89
+
90
+ Read the output, then use only what it shows. If a needed capability is not
91
+ in `--help`, report that to the user instead of guessing.
92
+
93
+ ## Recommended Learning Workflow
94
+
95
+ ### 1. Gather material from both channels
96
+
97
+ - `web_search` for **authoritative sources**: official docs (Microsoft Learn / learn.microsoft.com), official blogs, trusted tutorials. Keep the source links.
98
+ - Search the user's personal knowledge base (pick the right one: dotnet-related → their dotnet base, database → sqlserver) to get their own curated notes:
99
+ - pi: `deeptutor_kb action=search kb=<kb> query="<topic>"`
100
+ - CLI: `deeptutor kb search <kb> "<topic>" --format json`
101
+ - Always list bases first (`deeptutor_kb action=list` / `deeptutor kb list --format json`) — never assume names.
102
+
103
+ ### 2. Deep Solve
104
+
105
+ - pi: `deeptutor_run capability=deep_solve prompt="<topic>" kbs=[<kb>] tools=[rag, web_search] language=zh`
106
+ - CLI: `deeptutor run deep_solve "<topic>" --kb <kb> --tool rag --tool web_search --language zh --format json`
107
+
108
+ **Always record the returned `session_id`** — reuse it for every follow-up turn so DeepTutor keeps the context (chat history, knowledge bases, tools).
109
+
110
+ ### 3. Follow-up questions / targeted reinforcement
111
+
112
+ Continue with the same `session_id`: details, code examples, common pitfalls, differences vs. authoritative sources.
113
+
114
+ ### 4. Self-test
115
+
116
+ - pi: `deeptutor_run capability=deep_question prompt="<topic essentials>" session_id=<same> config={num_questions: 5} kbs=[<kb>] language=zh`
117
+ - CLI: `deeptutor run deep_question "<topic essentials>" --session <same> --config num_questions=5 --kb <kb> --language zh --format json`
118
+
119
+ ### 5. Output a study plan
120
+
121
+ Combine all three material sources into a structured plan (Markdown):
122
+
123
+ - Learning goals and prerequisites
124
+ - Core concept list (marked: from personal KB / authoritative link)
125
+ - Phased schedule (each phase: concept → authoritative reading → KB review → exercises)
126
+ - Quiz questions and acceptance criteria
127
+ - Reference list (authoritative links + KB hit sources)
128
+
129
+ ### 5b. Render study material to local HTML (recommended)
130
+
131
+ When the user wants readable/browsable/printable study material, render the
132
+ answers to a self-contained HTML page (dark/light toggle, TOC, collapsible
133
+ quiz answers, print-friendly) with the **html-doc skill** (zero-dependency
134
+ Node converter):
135
+
136
+ ```bash
137
+ node skills/html-doc/scripts/md-to-html.js <answer.md> --out <page.html> --title "<主题>" --toc
138
+ ```
139
+
140
+ On dsh, `deeptutor_run` does this automatically when given the `html` param:
141
+
142
+ ```
143
+ deeptutor_run capability=deep_solve prompt=<topic> kbs=[...] tools=[rag, web_search]
144
+ html="data/study/<topic>/knowledge.html" html_title="<主题> · 知识点" language=zh
145
+ deeptutor_run capability=deep_question prompt=<topic essentials> config={num_questions: 5}
146
+ html="data/study/<topic>/quiz.html" html_title="<主题> · 自测题" language=zh
147
+ ```
148
+
149
+ Then tell the user the HTML file paths so they can open them in a browser.
150
+
151
+ ### 6. Archive
152
+
153
+ Store the final notes/plan in a server notebook (e.g. `dotnet-learning`) so they can be retrieved for review later:
154
+
155
+ - dsh: `deeptutor_note notebook=<name> title="<t>" type=solve content=<markdown>`
156
+ - CLI:
157
+ ```bash
158
+ deeptutor notebook list # find the notebook id
159
+ deeptutor notebook create <name> --description "archived" # only if missing
160
+ deeptutor notebook add-md <nb-id> <notes.md> --title "<t>" --type solve
161
+ ```
162
+
163
+ ## Safety Boundaries
164
+
165
+ Read-only exploration is always fine: `kb list/info/search`, `memory show`,
166
+ `session list/show`, `config show`, `notebook list/show`.
167
+
168
+ Never run destructive commands: `kb delete`, `memory clear`, `session delete`,
169
+ `notebook remove-record`. Creation/update commands (`kb create/add`,
170
+ `notebook create/add-md/replace-md`, `session rename`) only on the user's
171
+ explicit request — never proactively.
172
+
173
+ ## Notes
174
+
175
+ - On dsh, calls go through HTTP/WS first (tunnel), falling back to SSH CLI automatically when the tunnel is down; `deeptutor_run` streams over WebSocket so progress is visible.
176
+ - `deep_research` can take minutes: give a generous timeout (900+) or split long tasks.
177
+ - Results may be truncated (default 30000 chars) — ask to continue for the full content.
178
+ - RAG hits can be noisy; treat official sources as authoritative and point out conflicts to the user.
179
+ - Do not delete knowledge bases or run destructive operations (see Safety
180
+ Boundaries above); `kb create/add` is fine, but only on the user's explicit
181
+ request, never proactively.
182
+ - CLI output: add `--format json` for machine-readable events; without it you get human-readable text.
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: html-doc
3
+ description: Generates self-contained, browser-ready HTML files from Markdown content (study notes, documentation, quiz/exercise sheets) using a zero-dependency Node converter and a polished built-in template with dark/light theme toggle, collapsible answers, and print-friendly layout. Use when the user wants local HTML output for reading, reviewing, or sharing learning material and docs.
4
+ ---
5
+
6
+ # HTML Doc Generator
7
+
8
+ Convert Markdown into a beautiful, self-contained local HTML file (single file, inline CSS/JS, no network needed to open). Ideal for study notes, knowledge summaries, and self-test question sheets.
9
+
10
+ ## When to Use
11
+
12
+ - After a learning session (e.g. deeptutor deep_solve / deep_question), the user wants readable local HTML of the knowledge points and quiz questions
13
+ - Converting any Markdown notes/docs into a polished local HTML page
14
+
15
+ ## Files
16
+
17
+ ```
18
+ html-doc/
19
+ ├── SKILL.md # this file
20
+ ├── scripts/
21
+ │ └── md-to-html.js # zero-dependency Markdown → HTML converter (Node ≥ 18)
22
+ └── assets/
23
+ └── template.html # default HTML template (CSS + JS, customizable)
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```bash
29
+ # Basic: write Markdown to a file, then convert
30
+ node scripts/md-to-html.js notes.md --out notes.html --title "C# 抽象类学习笔记"
31
+
32
+ # From stdin (any tool output piped in)
33
+ cat notes.md | node scripts/md-to-html.js --title "Quiz" --theme dark --out quiz.html
34
+
35
+ # Options
36
+ # --out <file> output path (default: <input>.html)
37
+ # --title <text> page title (default: input filename or "Document")
38
+ # --theme <mode> dark | light (default: light; user can toggle in-page anyway)
39
+ # --toc generate a table of contents from headings (h2/h3)
40
+ # --lang <code> html lang attribute (default: zh-CN)
41
+ # --no-collapse disable <details> wrapping for quiz answers (default: collapse enabled)
42
+ ```
43
+
44
+ ## Supported Markdown
45
+
46
+ ATX headings (`#`–`######`), fenced code blocks (``` with optional language), inline code, bold, italic, links, unordered/ordered lists, task lists (`- [ ]` / `- [x]`), blockquotes, tables (pipe syntax), horizontal rules, paragraphs.
47
+
48
+ Anything unsupported falls back to a plain `<p>` — output always stays valid.
49
+
50
+ ## Recommended Workflow for Study Material
51
+
52
+ 1. Collect the learning content (e.g. from deeptutor_run answer) as Markdown files under a docs folder, e.g. `~/study/abstract-class/`:
53
+ - `knowledge.md` — the deep-solve explanation
54
+ - `quiz.md` — the self-test questions (mark answers inside `<details>` blocks so they collapse)
55
+ 2. Convert each file:
56
+ ```bash
57
+ node scripts/md-to-html.js knowledge.md --out knowledge.html --title "C# 抽象类 · 知识点" --toc
58
+ node scripts/md-to-html.js quiz.md --out quiz.html --title "C# 抽象类 · 自测题" --toc
59
+ ```
60
+ 3. Open the HTML files in the browser (or tell the user the file paths).
61
+
62
+ ## Quiz Answer Collapsing
63
+
64
+ The converter auto-detects quiz structure: any heading containing "答案" / "Answer" / "解析" / "Explanation" starts a `<details>` block whose following content (until the next heading) is collapsed. Also, a heading line that is immediately followed by content gets wrapped when the heading matches. This keeps the quiz readable while hiding answers until clicked.
65
+
66
+ To be explicit, authors can also wrap answers manually:
67
+
68
+ ```markdown
69
+ <details><summary>答案:C</summary>
70
+
71
+ 解析:...
72
+ </details>
73
+ ```
74
+
75
+ Raw `<details>`/`<summary>` blocks are preserved as-is (the only raw-HTML passthrough); everything else is treated as Markdown/text and HTML-escaped.
76
+
77
+ ## Customizing the Template
78
+
79
+ Edit `assets/template.html` — it uses `{{TITLE}}`, `{{BODY}}`, `{{THEME}}`, `{{LANG}}`, `{{TOC}}`, `{{GENERATED}}` placeholders. Keep placeholders intact; the converter does simple string replacement. The built-in template includes:
80
+
81
+ - CSS variables for light/dark theming with an in-page toggle button (remembers choice in localStorage)
82
+ - Print stylesheet (answers stay collapsed on paper)
83
+ - Code block styling with optional language badge
84
+ - Table styling, blockquote styling, task-list checkboxes
85
+ - Responsive layout (comfortable reading column)
86
+
87
+ ## Notes
88
+
89
+ - Zero dependencies — only `node` (≥ 18) is required; no npm install needed
90
+ - Output is fully self-contained: inline CSS + JS, no external fonts/CDN (offline-friendly)
91
+ - Escaping is handled: content is HTML-escaped before insertion. Raw-HTML passthrough is intentionally narrow (`<details>`/`<summary>` only) since `deeptutor_run` feeds model/web_search-sourced answers into this converter automatically — a wider tag whitelist would let untrusted `<script>`/`on*=` content ride along into the generated local HTML.