Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

minor fixes & docs update

Bingxi Zhao (Frank)b364ffc59319
diff --git a/README.md b/README.md
index 05e8517c4..1db78a534 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@
[![Feishu](https://img.shields.io/badge/Feishu-Group-00D4AA?style=flat-square&logo=feishu&logoColor=white)](./Communication.md)
[![WeChat](https://img.shields.io/badge/WeChat-Group-07C160?style=flat-square&logo=wechat&logoColor=white)](https://github.com/HKUDS/DeepTutor/issues/78)
-[Features](#-key-features) · [Get Started](#-get-started) · [Explore](#-explore-deeptutor) · [CLI](#%EF%B8%8F-deeptutor-cli--agent-native-interface) · [Ecosystem](#-ecosystem--open-to-the-skills-community) · [Community](#-community)
+[Features](#-key-features) · [Get Started](#-get-started) · [Explore](#-explore-deeptutor) · [CLI](#%EF%B8%8F-deeptutor-cli--agent-native-interface) · [Ecosystem](#-ecosystem--eduhub--the-skills-community) · [Community](#-community)
</div>
@@ -42,17 +42,11 @@
> 🤝 **We welcome any kinds of contributing!** Vote on roadmap items or propose new ones at [`Roadmap`](https://github.com/HKUDS/DeepTutor/issues/498), and see our [Contributing Guide](CONTRIBUTING.md) for branching strategy, coding standards, and how to get started.
-> 📖 **Docs note:** The documentation at [deeptutor.info](https://deeptutor.info) currently reflects **v1.4.5** and will be updated to the latest release shortly.
-
### 📦 Releases
-> **[2026.6.18]** [v1.4.8](https://github.com/HKUDS/DeepTutor/releases/tag/v1.4.8) — Connect your own **Partners** under **My Agents** and consult them live in chat (their persona, library and skills answer through their own loop), and every Partner gains a private memory via `partner_read` / `partner_memorize` / `partner_search`.
-
-> **[2026.6.18]** [v1.4.7](https://github.com/HKUDS/DeepTutor/releases/tag/v1.4.7) — Connect your local **Claude Code / Codex** and consult it live mid-turn, **My Agents** graduates to a top-level `/agents`, and Partner conversations gain branch / resume / delete with a replayable trace.
+> **[2026.6.17]** [v1.4.6](https://github.com/HKUDS/DeepTutor/releases/tag/v1.4.6) — Consolidation across four surfaces: Space becomes a learning dashboard with importable **My Agents** and a top-level Memory, the **Knowledge Center** adds GraphRAG / PageIndex / LightRAG engines plus linked-KB and Obsidian mounts, Settings opens up document parsing / voice / image+video, and LLM capabilities are gated per assigned model.
-> **[2026.6.17]** [v1.4.6](https://github.com/HKUDS/DeepTutor/releases/tag/v1.4.6) — Four-surface consolidation: a **Knowledge Center** with GraphRAG / PageIndex / LightRAG engines and linked-KB / Obsidian mounts, a Space learning dashboard with **My Agents** and top-level Memory, plus document parsing / voice / media settings.
-
-> **[2026.6.14]** [v1.4.5](https://github.com/HKUDS/DeepTutor/releases/tag/v1.4.5) — Guided Learning rebuilt on the chat agent loop with a hard per-type mastery gate and a `/learning` dashboard, a new loop-plugin framework, plus Markdown export for Partner conversations.
+> **[2026.6.14]** [v1.4.5](https://github.com/HKUDS/DeepTutor/releases/tag/v1.4.5) — Guided Learning rebuilt on the chat agent loop with a hard per-type mastery gate and a `/learning` dashboard, a new extensible loop-plugin framework, plus Markdown export / save-to-notebook for Partner conversations.
> **[2026.6.13]** [v1.4.4](https://github.com/HKUDS/DeepTutor/releases/tag/v1.4.4) — Install community skills from [ClawHub](https://clawhub.ai/) with `deeptutor skill install` behind a security gate, plus real in-browser DOCX/XLSX previews for knowledge-base files.
@@ -152,11 +146,12 @@
DeepTutor is an agent-native learning workspace that connects tutoring, problem solving, quiz generation, research, visualization, and mastery practice in one extensible system.
-- **One runtime for every mode** — Chat, Solve, Quiz, Research, Visualize, and Mastery Path share the same tutoring engine, so context can move with the learner.
-- **Connected learning context** — Knowledge Bases, books, Co-Writer drafts, Space assets, notebooks, and Memory stay available across workflows instead of living in isolated tools.
-- **Extensible tools and skills** — Built-in tools, MCP tools, built-in skills, and installable community skills let DeepTutor grow with new learning workflows.
-- **Inspectable memory** — L1 traces, L2 surface summaries, and L3 synthesis make personalization visible, editable, and grounded in prior activity.
-- **Persistent Partners** — IM-connected companions run on the same agent loop, each with its own soul, channels, workspace, and assigned library.
+- **One runtime for every mode** — Chat, Quiz, Research, Visualize, Solve, and Mastery Path run on the same agent loop, so you switch the objective, not the engine, and context moves with the learner.
+- **Connected learning context** — Knowledge bases, books, Co-Writer drafts, notebooks, question banks, personas, and Memory stay available across every workflow instead of living in isolated tools.
+- **Subagents and Partners** — consult a live Claude Code, Codex, or Partner from any turn (or import their past conversations), and run persistent IM companions on the same brain.
+- **Multi-engine knowledge** — versioned RAG libraries across LlamaIndex, PageIndex, GraphRAG, LightRAG, or a linked Obsidian vault, with pluggable document parsing.
+- **Extensible tools and skills** — built-in tools, MCP servers, image / video / voice generation models, and installable community skills from EduHub.
+- **Inspectable memory** — L1 traces, L2 surface summaries, and L3 synthesis make personalization visible and editable, with a Memory Graph that traces every claim back to its evidence.
---
@@ -404,10 +399,10 @@ Project-root `.env` is **not** read as an application config file. For a minimal
## 📖 Explore DeepTutor
-Start with the main surfaces you will use day to day: Chat, Partners, Co-Writer, Book, Knowledge, Space, Memory, and Settings. The tour then covers Multi-User deployments for shared, isolated workspaces.
+Start with the main surfaces you will use day to day: Chat, Partners, My Agents, Co-Writer, Book, Knowledge Center, Learning Space, Memory, and Settings. The tour then covers Multi-User deployments for shared, isolated workspaces.
<div align="center">
-<img src="assets/figs/webui/chat.png" alt="DeepTutor chat workspace" width="900">
+<img src="assets/figs/web-1.4.6+/OVERVIEW.png" alt="DeepTutor home — the Chat workspace with every surface in the sidebar" width="900">
</div>
<details>
@@ -422,15 +417,23 @@ Start with the main surfaces you will use day to day: Chat, Partners, Co-Writer,
<details>
<summary><b>💬 Chat — The Agent Loop You Actually Use</b></summary>
-Chat is the default capability and the place where most work begins. A single thread can talk normally, call tools, ground itself in selected knowledge bases, read attachments, write notebook records, and continue with the same source inventory across turns.
+Chat is the default capability and where most work begins. A single thread can talk normally, call tools, ground itself in selected knowledge bases, read attachments, generate images, consult subagents, write notebook records, and continue with the same context across turns.
+
+<div align="center">
+<img src="assets/figs/web-1.4.6+/home/00-overview.png" alt="DeepTutor chat workspace" width="900">
+</div>
+
+The loop is deliberately simple: the model thinks in rounds, calls tools when useful, observes the results, and finishes with a tool-free message. `ask_user` is special — instead of guessing, the agent can pause the turn, ask a structured clarifying question, and resume once you answer.
<div align="center">
<img src="assets/figs/system/chat-agent-loop.png" alt="DeepTutor chat agent loop" width="900">
</div>
-The current loop is deliberately simple: the model thinks in rounds, calls tools when useful, observes the tool results, and finishes when it has enough evidence. User-toggleable tools are `brainstorm`, `web_search`, `paper_search`, and `reason`; contextual tools such as `rag`, `read_source`, `read_memory`, `write_memory`, `read_skill`, `load_tools`, `exec`, `web_fetch`, `ask_user`, `list_notebook`, `write_note`, and `github` mount when the turn has the right context.
+User-toggleable tools are `brainstorm`, `web_search`, `paper_search`, `reason`, and `geogebra_analysis` — plus `imagegen` and `videogen` once you configure the matching generation model. Contextual tools such as `rag`, `read_source`, `read_memory`, `write_memory`, `read_skill`, `load_tools`, `exec`, `web_fetch`, `ask_user`, `list_notebook`, `write_note`, `github`, and `consult_subagent` mount automatically when the turn has the right context.
-Chat is also the launch point for deeper capabilities: `deep_solve` for worked reasoning, `deep_question` for question generation, `deep_research` for cited reports, `visualize` and `math_animator` for visual outputs, and `mastery_path` for learning-plan flows.
+Context comes in two kinds: **sticky session context** (subagent, knowledge bases, persona, model, voice) lives on the composer toolbar and persists across turns; **one-time references** (files, chat history, books, notebooks, question bank, imported agents) come from the `+` menu for a single turn.
+
+Chat is also the launch point for deeper capabilities: **Quiz** for question generation, **Research** for cited reports, **Visualize** for charts / diagrams / animations, and — under *More Capabilities* — **Solve** for worked reasoning and **Mastery Path** for learning-plan flows.
</details>
@@ -438,22 +441,39 @@ Chat is also the launch point for deeper capabilities: `deep_solve` for worked r
<summary><b>🤝 Partner — Persistent Companions on the Same Brain</b></summary>
<div align="center">
-<img src="assets/figs/webui/partners.png" alt="DeepTutor partners workspace" width="900">
+<img src="assets/figs/web-1.4.6+/partners/00-partners%20overview.png" alt="DeepTutor partners workspace" width="900">
</div>
-Partners replace the older TutorBot engine with a cleaner model: every inbound web or IM message becomes a normal ChatOrchestrator turn inside a partner-scoped workspace. There is no separate bot brain to keep in sync.
+Partners are persistent companions with their own soul, model policy, library, memory, and channels. They are not a separate bot engine: every inbound web or IM message becomes a normal `ChatOrchestrator` turn inside a partner-scoped workspace. A partner is "a chat that has a personality and a phone number."
<div align="center">
<img src="assets/figs/system/partners-architecture.png" alt="DeepTutor partners architecture" width="900">
</div>
-Each partner has a `SOUL.md`, model selection, channels, tool policy, and assigned library. Knowledge bases, skills, and notebooks are copied into `data/partners/<id>/workspace/`, so the same RAG, skill, notebook, and memory tools work without special cases.
+Each partner has a `SOUL.md`, model selection, channels, tool policy, and assigned library. Knowledge bases, skills, and notebooks are copied into `data/partners/<id>/workspace/`, so the same RAG, skill, notebook, and memory tools work without special cases. A partner reads its owner's memory but writes only its own.
<div align="center">
-<img src="assets/figs/webui/partners02.png" alt="DeepTutor partner detail view" width="900">
+<img src="assets/figs/web-1.4.6+/partners/02-IM%20config%20for%20each%20partner.png" alt="Per-partner IM channel configuration" width="900">
</div>
-The channel layer is schema-driven and can connect to IM platforms such as Feishu, Telegram, Slack, DingTalk, QQ/Napcat, WeCom, WhatsApp, Zulip, Matrix, and Microsoft Teams depending on installed extras and configured credentials.
+The channel layer is schema-driven and can connect to IM platforms such as Feishu, Telegram, Slack, DingTalk, QQ/NapCat, WeCom, WhatsApp, Zulip, Matrix, and Microsoft Teams depending on installed extras and configured credentials. A partner can also be connected as a subagent and consulted from a normal chat turn — see **My Agents** below.
+
+</details>
+
+<details>
+<summary><b>🧑‍🚀 My Agents — Consult & Import Other Agents</b></summary>
+
+<div align="center">
+<img src="assets/figs/web-1.4.6+/myagents/00-overview.png" alt="DeepTutor My Agents workspace" width="900">
+</div>
+
+My Agents turns other agents into context for DeepTutor, and does two distinct things. **Connect a live agent** — a Claude Code or Codex CLI on your machine, or one of your Partners — and consult it from inside a chat turn: DeepTutor actually *runs* the other agent and streams its work into the Activity panel via the `consult_subagent` tool. Select it with the Agent chip (or type `@`), and set how many rounds the consult may take.
+
+<div align="center">
+<img src="assets/figs/web-1.4.6+/home/08-subagent%20demo%20with%20claude%20code.png" alt="Consulting a Claude Code subagent live" width="900">
+</div>
+
+**Import past conversations** — bring in your existing Claude Code and Codex history as named, searchable, resumable agents. Pick which days to import; refreshing re-syncs them. Reference an imported conversation from any chat turn via `+` → My Agents, and DeepTutor reads it as a third-party transcript — it stays *their* conversation, not DeepTutor's own voice.
</details>
@@ -461,55 +481,71 @@ The channel layer is schema-driven and can connect to IM platforms such as Feish
<summary><b>✍️ Co-Writer — Selection-Aware Markdown Drafting</b></summary>
<div align="center">
-<img src="assets/figs/webui/cowriter.png" alt="DeepTutor Co-Writer workspace" width="900">
+<img src="assets/figs/web-1.4.6+/co-writer/00-overview.png" alt="DeepTutor Co-Writer workspace" width="900">
</div>
-Co-Writer is a split-view Markdown workspace for reports, tutorials, notes, and long-form learning artifacts. Documents autosave, render a live preview, and can be saved back into notebooks when the draft becomes reusable context.
+Co-Writer is a split-view Markdown workspace for reports, tutorials, notes, and long-form learning artifacts. Documents autosave and render a live preview (KaTeX math, diagram fences), and can be saved back into notebooks when a draft becomes reusable context.
-Select text and ask DeepTutor to rewrite, expand, or shorten it. The edit agent keeps a trace of tool calls and can ground an edit in a knowledge base or web evidence, so Co-Writer behaves more like an editor with retrieval than a detached text box.
+<div align="center">
+<img src="assets/figs/web-1.4.6+/co-writer/01-edit%20panel.png" alt="Co-Writer editor with live preview" width="900">
+</div>
+
+Its defining idea is **surgical editing**: select a span and ask DeepTutor to rewrite, expand, or shorten it. The edit agent can ground the change in a knowledge base or web evidence, keeps a trace of its tool calls, and shows every change as an accept/reject diff — so nothing lands until you approve it.
</details>
<details>
<summary><b>📖 Book — Living Books from Your Materials</b></summary>
+<div align="center">
+<img src="assets/figs/web-1.4.6+/book/00-book_overview.png" alt="DeepTutor book library" width="900">
+</div>
+
+Book turns selected sources into an interactive **living book** — not a static PDF, but a reading environment built from typed blocks. A book can start from knowledge bases, notebooks, question banks, or chat history; the creation flow proposes a chapter outline before content is generated, so you review the shape instead of accepting a blind one-shot output.
+
<p align="center">
-<img src="assets/figs/webui/book01.png" alt="DeepTutor book reading view" width="31%">
+<img src="assets/figs/web-1.4.6+/book/01-book-demo-quiz%20card.png" alt="Book quiz block" width="31%">
&nbsp;
-<img src="assets/figs/webui/book02.png" alt="DeepTutor book interactive block view" width="31%">
+<img src="assets/figs/web-1.4.6+/book/02-book-demo-manim%20video.png" alt="Book Manim animation block" width="31%">
&nbsp;
-<img src="assets/figs/webui/book03.png" alt="DeepTutor book creation view" width="31%">
+<img src="assets/figs/web-1.4.6+/book/03-book-demo%20interactive%20module.png" alt="Book interactive widget block" width="31%">
</p>
-Book turns selected sources into interactive learning material. A book can start from knowledge bases, notebooks, question banks, or chat history; the creation flow proposes a structure before content is generated, so users can review the shape instead of accepting a blind one-shot output.
-
-The BookEngine compiles pages into typed blocks: text, sections, callouts, quizzes, flash cards, timelines, code, figures, interactive HTML, animations, concept graphs, deep dives, and user notes. Maintenance commands such as `deeptutor book health` and `deeptutor book refresh-fingerprints` help detect when source knowledge has drifted from compiled pages.
+Each chapter compiles into typed blocks — text, callouts, quizzes, flash cards, timelines, code, figures, interactive HTML, animations, concept graphs, deep dives, and user notes — and every page has its own Page Chat. Blocks are editable: insert, move, regenerate, or switch a block's type without rewriting the chapter. Maintenance commands such as `deeptutor book health` and `deeptutor book refresh-fingerprints` help detect when source knowledge has drifted from compiled pages.
</details>
<details>
-<summary><b>📚 Knowledge — Versioned RAG Libraries</b></summary>
+<summary><b>📚 Knowledge Center — Multi-Engine RAG Libraries</b></summary>
<div align="center">
-<img src="assets/figs/webui/knowledge.png" alt="DeepTutor knowledge base workspace" width="900">
+<img src="assets/figs/web-1.4.6+/knowledge/00-overview.png" alt="DeepTutor Knowledge Center" width="900">
</div>
-Knowledge Bases are the document collections behind RAG. The current stack is LlamaIndex-only, with a flat `version-N` storage layout keyed by embedding signature. Re-indexing preserves prior versions and avoids clobbering a working index while new documents are processed.
+Knowledge bases are the document collections behind RAG — they ground Chat turns, Co-Writer edits, Book generation, and Partner conversations. What's distinctive is a **choice of retrieval engines**: **LlamaIndex** (the default, local vector + BM25), **PageIndex** (hosted, reasoning retrieval with page-level citations), **GraphRAG** and **LightRAG** (knowledge-graph retrieval), or a linked **Obsidian** vault the tutor reads and writes in place. Each KB is indexed by one engine.
+
+<div align="center">
+<img src="assets/figs/web-1.4.6+/knowledge/01-create%20knowledge%20base.png" alt="Create a knowledge base" width="900">
+</div>
-The web workspace exposes files, upload, index versions, and settings. The CLI mirrors the same lifecycle with `deeptutor kb list`, `info`, `create`, `add`, `search`, `set-default`, and `delete`.
+Creating a KB, you either **create new** (upload documents and build a fresh index) or **link existing** (reuse an index built elsewhere, read in place with no re-index). Re-indexing writes a new flat `version-N` directory and keeps prior ones, so a working index is never destroyed mid-rebuild. Document parsing — Text-only, MinerU, Docling, or markitdown — is chosen in **Settings → Knowledge Base**, with local model downloads off by default. The CLI mirrors the lifecycle with `deeptutor kb list`, `info`, `create`, `add`, `search`, `set-default`, and `delete`.
</details>
<details>
-<summary><b>🌐 Space — Skills, Personas, and Reusable Context</b></summary>
+<summary><b>🌐 Learning Space — Skills, Personas, and Reusable Context</b></summary>
<div align="center">
-<img src="assets/figs/webui/space.png" alt="DeepTutor space workspace" width="900">
+<img src="assets/figs/web-1.4.6+/learning-space/00-overview.png" alt="DeepTutor Learning Space hub" width="900">
</div>
-Space is the library layer for reusable context. It brings together user-authored skills, personas, notebooks, chat history, and question-bank style assets so the agent can be steered with deliberate context instead of ad hoc prompting.
+Learning Space is the library and personalization layer — where the things that persist live. **Conversations & Materials** holds your chat history, notebooks, and a question bank (each saved question keeps your answer, the reference answer, and an explanation). **Personalization** holds mastery paths, personas (behavior presets such as *peer*, *research-assistant*, *teacher*), and skills (`SKILL.md` playbooks the model reads on demand). Everything here can be reused from Chat, Partners, Co-Writer, and Book.
+
+<div align="center">
+<img src="assets/figs/web-1.4.6+/learning-space/07-%20download%20skills%20from%20eduhub.png" alt="Import skills from EduHub" width="900">
+</div>
-Skills are stored as `SKILL.md` files under the user workspace and can be tagged, edited, or kept read-only when they are built in. Personas follow the same idea for role and voice. These assets can be assigned to partners, referenced in chat, and reused across learning workflows.
+You don't have to write every skill yourself — **Import from EduHub** browses the community catalog and downloads a skill straight into your library through a security gate (see [Ecosystem](#-ecosystem--eduhub--the-skills-community)).
</details>
@@ -517,16 +553,16 @@ Skills are stored as `SKILL.md` files under the user workspace and can be tagged
<summary><b>🧠 Memory — Inspectable Personalization</b></summary>
<div align="center">
-<img src="assets/figs/webui/memory01.png" alt="DeepTutor memory workbench" width="900">
+<img src="assets/figs/web-1.4.6+/memory/00-overview.png" alt="DeepTutor memory overview" width="900">
</div>
-Memory is a three-layer system rooted in the active user workspace: `trace/<surface>/<date>.jsonl` for L1 event traces, `L2/<surface>.md` for per-surface facts, and `L3/<recent|profile|scope|preferences>.md` for cross-surface synthesis.
+Memory is a file-backed, three-layer system you can read, curate, and audit — deliberately *not* a hidden vector store. **L1** is the workspace mirror plus an append-only event trace (`trace/<surface>/<date>.jsonl`); **L2** is per-surface curated facts (`L2/<surface>.md`); **L3** is cross-surface synthesis (`L3/<profile|recent|scope>.md`). Because L2 cites L1 and L3 cites L2, nothing in your profile is unaccountable.
<div align="center">
-<img src="assets/figs/webui/memory02.png" alt="DeepTutor memory graph" width="900">
+<img src="assets/figs/web-1.4.6+/memory/01-3%20layer%20memory%20graph.png" alt="DeepTutor memory graph" width="900">
</div>
-The supported memory surfaces are `chat`, `notebook`, `quiz`, `kb`, `book`, `tutorbot`, and `cowriter`. The legacy `tutorbot` surface name remains in the memory layer for compatibility even though the product-facing companion model is now Partners. The workbench lets you inspect, edit, run consolidation, and use the graph to trace synthesized claims back to their supporting facts and raw events.
+The Memory Graph shows the whole pyramid — L3 synthesis at the centre, L2 in the middle ring, L1 traces on the outside — so you can trace any synthesized claim back to the exact raw event behind it. Memory is tracked across `chat`, `notebook`, `quiz`, `kb`, `book`, partner, and `cowriter` surfaces; the consolidator's Update / Audit / Dedup budgets are tuned in **Settings → Memory**.
</details>
@@ -534,22 +570,22 @@ The supported memory surfaces are `chat`, `notebook`, `quiz`, `kb`, `book`, `tut
<summary><b>⚙️ Settings — One Control Plane</b></summary>
<div align="center">
-<img src="assets/figs/webui/settings.png" alt="DeepTutor settings workspace" width="900">
+<img src="assets/figs/web-1.4.6+/settings/00-setting%20overview.png" alt="DeepTutor settings hub" width="900">
</div>
-Settings is the operational control plane. It covers appearance, network ports and external API base, LLM and embedding catalogs, search providers, MinerU parsing, capability budgets, memory cadence, MCP servers, built-in tools, and the enabled optional tool list.
+Settings is the operational control plane, with a live status strip (Backend, LLM, Embedding, Search) and one card per area: **Appearance** (theme + UI language), **Network** (API base, ports, CORS), **Models** (LLM, Embedding, Search, Text-to-Speech, Speech-to-Text, Image Generation, Video Generation), **Knowledge Base** (document parsing engine), **Chat** (tools, MCP servers, per-capability parameters), **Partners & Agents** (the subagents you can consult from a turn), and **Memory** (the consolidator's budgets).
-Most settings use a draft-and-apply flow so users can test providers before committing them. Project-root `.env` files are intentionally ignored; runtime configuration lives under `data/user/settings/*.json` unless `DEEPTUTOR_HOME` or `deeptutor start --home` points the app elsewhere.
+<div align="center">
+<img src="assets/figs/web-1.4.6+/settings/01-appearance%20settings.png" alt="DeepTutor appearance settings and themes" width="900">
+</div>
+
+Most sections use a draft-and-apply flow, so you can test a provider before committing it. Four themes ship in the box — Default, Cream, Dark, and Glass. Project-root `.env` files are intentionally ignored; runtime configuration lives under `data/user/settings/*.json` unless `DEEPTUTOR_HOME` or `deeptutor start --home` points the app elsewhere.
</details>
<details>
<summary><b>👥 Multi-User — Shared Deployments</b> · optional auth, isolated per-user workspaces</summary>
-<div align="center">
-<img src="assets/figs/webui/multi-user.png" alt="DeepTutor multi-user admin workspace" width="900">
-</div>
-
Authentication is **off by default** — DeepTutor runs single-user. Turn it on and one `data/` tree hosts an admin workspace, isolated per-user workspaces, and partner workspaces side by side:
```text
@@ -621,7 +657,7 @@ The repo ships a root [`SKILL.md`](SKILL.md) — a ~150-line handover doc that t
| `deeptutor chat` | Interactive REPL with capability, tool, KB, notebook, and history controls |
| `deeptutor partner list/create/start/stop` | Manage IM-connected partners |
| `deeptutor kb list/info/create/add/search/set-default/delete` | Manage LlamaIndex knowledge bases |
-| `deeptutor skill search/install/list/remove` | Manage skills and install from hubs (`clawhub:<slug>`, see Ecosystem) |
+| `deeptutor skill search/install/list/remove/login/publish/update` | Manage skills, install from hubs, and publish your own (`eduhub:<slug>` by default, see Ecosystem) |
| `deeptutor memory show/clear` | Inspect L2/L3 memory docs or clear L1/all memory |
| `deeptutor session list/show/open/rename/delete` | Manage shared sessions |
| `deeptutor notebook list/create/show/add-md/replace-md/remove-record` | Manage notebooks from Markdown files |
@@ -645,25 +681,38 @@ It isn't published to PyPI yet, so the main [Get Started](#-get-started) section
</details>
-## 🧩 Ecosystem — Open to the Skills Community
+## 🧩 Ecosystem — EduHub & the Skills Community
-DeepTutor skills use the open **Agent-Skills** format, so any compatible community registry becomes a source for your library. [ClawHub](https://clawhub.ai/) ships wired in as the default hub.
+DeepTutor skills use the open **Agent-Skills** format — a folder with a `SKILL.md` playbook (YAML frontmatter + Markdown) and optional reference files. Nothing about it is DeepTutor-specific, so any registry that speaks the format becomes a source for your library. DeepTutor ships with **[EduHub](https://eduhub.deeptutor.info/)** — our own education-focused skill registry — wired in as the default hub.
<details>
-<summary><b>How it works</b></summary>
+<summary><b>EduHub — DeepTutor's skill ecosystem</b></summary>
-A DeepTutor skill is just a folder with a `SKILL.md` playbook (YAML frontmatter + markdown) and optional reference files — the same open format used across the wider agent ecosystem. Nothing about it is DeepTutor-specific, so any registry that speaks the format is a first-class source for your skill library — no bespoke packaging, no lock-in.
+[**EduHub**](https://eduhub.deeptutor.info/) is the community hub DeepTutor launched for sharing teaching-oriented agent skills — Socratic tutors, flashcard builders, essay feedback, exam blueprints, concept explainers, and more. It is built into DeepTutor, so there's nothing to configure: a bare slug or an `eduhub:` prefix resolves to it.
-Four commands cover the whole lifecycle:
+**Find and install** — in the browser, open **Learning Space → Skills → Import from EduHub** to browse the catalog and download a skill straight into your library. From the terminal:
```bash
-deeptutor skill search "<query>" # search a connected hub
-deeptutor skill install <slug> # fetch → verify → register (clawhub by default)
-deeptutor skill install <hub>:<slug>@<ver> # <hub>:<slug> picks the hub; @ pins a version
-deeptutor skill list # local skills with their hub provenance
+deeptutor skill search "socratic tutor" # search EduHub (the default hub)
+deeptutor skill install socratic-tutor # fetch → verify → register
+deeptutor skill install eduhub:[email protected] # pin a hub and a version
+deeptutor skill list # local skills with their hub provenance
```
-Add more registries in `settings/skill_hubs.json`: a `type: "clawhub"` entry points at any compatible HTTP API, while `type: "command"` wraps whatever fetch CLI a registry ships — both feed the same import gate.
+**Publish your own** — package a `SKILL.md` and share it back to the community:
+
+```bash
+deeptutor skill login # browser sign-in to EduHub
+deeptutor skill publish ./my-skill # interactive: pick a track + tags, then upload
+deeptutor skill update # roll back or release a new version
+```
+
+EduHub is also a standalone, ClawHub-compatible registry, so agents that aren't DeepTutor (Claude Code, Codex, …) can use it directly through the `eduhub` CLI — `npx eduhub install socratic-tutor`.
+
+</details>
+
+<details>
+<summary><b>The import safety gate</b></summary>
Whatever the source, every import passes the **same safety gate** before anything touches your workspace:
@@ -677,22 +726,17 @@ In multi-user deployments, installing is admin-only: a new skill lands in the ad
</details>
<details>
-<summary><b>With ClawHub</b></summary>
-
-Say you want a skill that turns git history into release notes. Search the default hub, install the match, and confirm it landed:
-
-```bash
-deeptutor skill search "git release notes" # → git-release-notes (Git Release Notes)
-deeptutor skill install git-release-notes # fetch → verify → register
-deeptutor skill list # shows it with clawhub provenance
-```
+<summary><b>Also compatible with ClawHub</b></summary>
-`git-release-notes` now lives in your skill library and the agent can call it like any other tool. To pin a version — or pull from another configured hub — use the fully-qualified form:
+Because DeepTutor speaks the open Agent-Skills format, **[ClawHub](https://clawhub.ai/)** works as a first-class source too — it's built in alongside EduHub. Pick it with the hub prefix:
```bash
+deeptutor skill search "git release notes" --hub clawhub
deeptutor skill install clawhub:[email protected]
```
+Add more registries in `settings/skill_hubs.json`: a `type: "clawhub"` entry points at any compatible HTTP API (EduHub and ClawHub both speak it), `type: "command"` wraps whatever fetch CLI a registry ships, and `"default"` chooses the hub used for bare slugs. All of them feed the same import gate.
+
</details>
## 🌐 Community
diff --git a/assets/figs/web-1.4.6+/OVERVIEW.png b/assets/figs/web-1.4.6+/OVERVIEW.png
new file mode 100644
index 000000000..78123677e
Binary files /dev/null and b/assets/figs/web-1.4.6+/OVERVIEW.png differ
diff --git a/assets/figs/web-1.4.6+/book/00-book_overview.png b/assets/figs/web-1.4.6+/book/00-book_overview.png
new file mode 100644
index 000000000..c9d03cd35
Binary files /dev/null and b/assets/figs/web-1.4.6+/book/00-book_overview.png differ
diff --git a/assets/figs/web-1.4.6+/book/01-book-demo-quiz card.png b/assets/figs/web-1.4.6+/book/01-book-demo-quiz card.png
new file mode 100644
index 000000000..793563c89
Binary files /dev/null and b/assets/figs/web-1.4.6+/book/01-book-demo-quiz card.png differ
diff --git a/assets/figs/web-1.4.6+/book/02-book-demo-manim video.png b/assets/figs/web-1.4.6+/book/02-book-demo-manim video.png
new file mode 100644
index 000000000..39ec52bf5
Binary files /dev/null and b/assets/figs/web-1.4.6+/book/02-book-demo-manim video.png differ
diff --git a/assets/figs/web-1.4.6+/book/03-book-demo interactive module.png b/assets/figs/web-1.4.6+/book/03-book-demo interactive module.png
new file mode 100644
index 000000000..dee4d9bd4
Binary files /dev/null and b/assets/figs/web-1.4.6+/book/03-book-demo interactive module.png differ
diff --git a/assets/figs/web-1.4.6+/book/04-book-demo side chat & mermaid.png b/assets/figs/web-1.4.6+/book/04-book-demo side chat & mermaid.png
new file mode 100644
index 000000000..dc25e612d
Binary files /dev/null and b/assets/figs/web-1.4.6+/book/04-book-demo side chat & mermaid.png differ
diff --git a/assets/figs/web-1.4.6+/book/05-book- add customize block for chapter.png b/assets/figs/web-1.4.6+/book/05-book- add customize block for chapter.png
new file mode 100644
index 000000000..88b759fe2
Binary files /dev/null and b/assets/figs/web-1.4.6+/book/05-book- add customize block for chapter.png differ
diff --git a/assets/figs/web-1.4.6+/book/06-book-switch the block type.png b/assets/figs/web-1.4.6+/book/06-book-switch the block type.png
new file mode 100644
index 000000000..6f8edbe25
Binary files /dev/null and b/assets/figs/web-1.4.6+/book/06-book-switch the block type.png differ
diff --git a/assets/figs/web-1.4.6+/co-writer/00-overview.png b/assets/figs/web-1.4.6+/co-writer/00-overview.png
new file mode 100644
index 000000000..9c3eb943b
Binary files /dev/null and b/assets/figs/web-1.4.6+/co-writer/00-overview.png differ
diff --git a/assets/figs/web-1.4.6+/co-writer/01-edit panel.png b/assets/figs/web-1.4.6+/co-writer/01-edit panel.png
new file mode 100644
index 000000000..fab5af8a5
Binary files /dev/null and b/assets/figs/web-1.4.6+/co-writer/01-edit panel.png differ
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.43.04.png" b/assets/figs/web-1.4.6+/home/00-overview.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.43.04.png"
rename to assets/figs/web-1.4.6+/home/00-overview.png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.43.15.png" b/assets/figs/web-1.4.6+/home/01-capabilities.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.43.15.png"
rename to assets/figs/web-1.4.6+/home/01-capabilities.png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.43.27.png" b/assets/figs/web-1.4.6+/home/02-add contexts.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.43.27.png"
rename to assets/figs/web-1.4.6+/home/02-add contexts.png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.43.42.png" b/assets/figs/web-1.4.6+/home/03-another use subagent.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.43.42.png"
rename to assets/figs/web-1.4.6+/home/03-another use subagent.png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.43.35.png" b/assets/figs/web-1.4.6+/home/03-use subagent.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.43.35.png"
rename to assets/figs/web-1.4.6+/home/03-use subagent.png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.44.19.png" b/assets/figs/web-1.4.6+/home/04-attatch knowledge base.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.44.19.png"
rename to assets/figs/web-1.4.6+/home/04-attatch knowledge base.png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.44.25.png" b/assets/figs/web-1.4.6+/home/05-customize persona.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.44.25.png"
rename to assets/figs/web-1.4.6+/home/05-customize persona.png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.44.31.png" b/assets/figs/web-1.4.6+/home/06-switch model.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.44.31.png"
rename to assets/figs/web-1.4.6+/home/06-switch model.png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.44.46.png" b/assets/figs/web-1.4.6+/home/07-side bar for various activities.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 20.44.46.png"
rename to assets/figs/web-1.4.6+/home/07-side bar for various activities.png
diff --git a/assets/figs/web-1.4.6+/home/08-another subagent demo with partners.png b/assets/figs/web-1.4.6+/home/08-another subagent demo with partners.png
new file mode 100644
index 000000000..29cf5e306
Binary files /dev/null and b/assets/figs/web-1.4.6+/home/08-another subagent demo with partners.png differ
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 22.16.32.png" b/assets/figs/web-1.4.6+/home/08-subagent demo with claude code.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 22.16.32.png"
rename to assets/figs/web-1.4.6+/home/08-subagent demo with claude code.png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 22.24.00.png" b/assets/figs/web-1.4.6+/home/09-demo with configured image-gen model(as a tool).png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 22.24.00.png"
rename to assets/figs/web-1.4.6+/home/09-demo with configured image-gen model(as a tool).png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 22.26.03.png" b/assets/figs/web-1.4.6+/home/10-configure models.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 22.26.03.png"
rename to assets/figs/web-1.4.6+/home/10-configure models.png
diff --git "a/assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 22.26.24.png" b/assets/figs/web-1.4.6+/home/11-configure and explore tools.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/home/\346\210\252\345\261\2172026-06-17 22.26.24.png"
rename to assets/figs/web-1.4.6+/home/11-configure and explore tools.png
diff --git "a/assets/figs/web-1.4.6+/knowledge/\346\210\252\345\261\2172026-06-17 22.25.27.png" b/assets/figs/web-1.4.6+/knowledge/00-overview.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/knowledge/\346\210\252\345\261\2172026-06-17 22.25.27.png"
rename to assets/figs/web-1.4.6+/knowledge/00-overview.png
diff --git "a/assets/figs/web-1.4.6+/knowledge/\346\210\252\345\261\2172026-06-17 22.25.37.png" b/assets/figs/web-1.4.6+/knowledge/01-create knowledge base.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/knowledge/\346\210\252\345\261\2172026-06-17 22.25.37.png"
rename to assets/figs/web-1.4.6+/knowledge/01-create knowledge base.png
diff --git "a/assets/figs/web-1.4.6+/knowledge/\346\210\252\345\261\2172026-06-17 22.25.44.png" b/assets/figs/web-1.4.6+/knowledge/02-panel for each knowledge base.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/knowledge/\346\210\252\345\261\2172026-06-17 22.25.44.png"
rename to assets/figs/web-1.4.6+/knowledge/02-panel for each knowledge base.png
diff --git "a/assets/figs/web-1.4.6+/knowledge/\346\210\252\345\261\2172026-06-17 22.25.51.png" b/assets/figs/web-1.4.6+/knowledge/03-config document parsing engine in settings.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/knowledge/\346\210\252\345\261\2172026-06-17 22.25.51.png"
rename to assets/figs/web-1.4.6+/knowledge/03-config document parsing engine in settings.png
diff --git a/assets/figs/web-1.4.6+/learning-space/00-overview.png b/assets/figs/web-1.4.6+/learning-space/00-overview.png
new file mode 100644
index 000000000..33e84c83e
Binary files /dev/null and b/assets/figs/web-1.4.6+/learning-space/00-overview.png differ
diff --git a/assets/figs/web-1.4.6+/learning-space/01-chat history.png b/assets/figs/web-1.4.6+/learning-space/01-chat history.png
new file mode 100644
index 000000000..6ca62bd3e
Binary files /dev/null and b/assets/figs/web-1.4.6+/learning-space/01-chat history.png differ
diff --git a/assets/figs/web-1.4.6+/learning-space/02-notebooks.png b/assets/figs/web-1.4.6+/learning-space/02-notebooks.png
new file mode 100644
index 000000000..385fa683c
Binary files /dev/null and b/assets/figs/web-1.4.6+/learning-space/02-notebooks.png differ
diff --git a/assets/figs/web-1.4.6+/learning-space/03-question bank.png b/assets/figs/web-1.4.6+/learning-space/03-question bank.png
new file mode 100644
index 000000000..8cdaaf64e
Binary files /dev/null and b/assets/figs/web-1.4.6+/learning-space/03-question bank.png differ
diff --git a/assets/figs/web-1.4.6+/learning-space/04-mastery path.png b/assets/figs/web-1.4.6+/learning-space/04-mastery path.png
new file mode 100644
index 000000000..dff1e201a
Binary files /dev/null and b/assets/figs/web-1.4.6+/learning-space/04-mastery path.png differ
diff --git a/assets/figs/web-1.4.6+/learning-space/05-personas.png b/assets/figs/web-1.4.6+/learning-space/05-personas.png
new file mode 100644
index 000000000..41c268e5a
Binary files /dev/null and b/assets/figs/web-1.4.6+/learning-space/05-personas.png differ
diff --git a/assets/figs/web-1.4.6+/learning-space/06-skills.png b/assets/figs/web-1.4.6+/learning-space/06-skills.png
new file mode 100644
index 000000000..93243dbe4
Binary files /dev/null and b/assets/figs/web-1.4.6+/learning-space/06-skills.png differ
diff --git a/assets/figs/web-1.4.6+/learning-space/07- download skills from eduhub.png b/assets/figs/web-1.4.6+/learning-space/07- download skills from eduhub.png
new file mode 100644
index 000000000..96e43ee69
Binary files /dev/null and b/assets/figs/web-1.4.6+/learning-space/07- download skills from eduhub.png differ
diff --git "a/assets/figs/web-1.4.6+/memory/\346\210\252\345\261\2172026-06-17 22.22.26.png" b/assets/figs/web-1.4.6+/memory/00-overview.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/memory/\346\210\252\345\261\2172026-06-17 22.22.26.png"
rename to assets/figs/web-1.4.6+/memory/00-overview.png
diff --git "a/assets/figs/web-1.4.6+/memory/\346\210\252\345\261\2172026-06-17 22.22.38.png" b/assets/figs/web-1.4.6+/memory/01-3 layer memory graph.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/memory/\346\210\252\345\261\2172026-06-17 22.22.38.png"
rename to assets/figs/web-1.4.6+/memory/01-3 layer memory graph.png
diff --git "a/assets/figs/web-1.4.6+/memory/\346\210\252\345\261\2172026-06-17 22.26.14.png" b/assets/figs/web-1.4.6+/memory/02-config memory params in settings.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/memory/\346\210\252\345\261\2172026-06-17 22.26.14.png"
rename to assets/figs/web-1.4.6+/memory/02-config memory params in settings.png
diff --git a/assets/figs/web-1.4.6+/myagents/00-overview.png b/assets/figs/web-1.4.6+/myagents/00-overview.png
new file mode 100644
index 000000000..d3d8f459c
Binary files /dev/null and b/assets/figs/web-1.4.6+/myagents/00-overview.png differ
diff --git a/assets/figs/web-1.4.6+/myagents/01-sync selective chat history from claude code or codex.png b/assets/figs/web-1.4.6+/myagents/01-sync selective chat history from claude code or codex.png
new file mode 100644
index 000000000..25a8b2c1f
Binary files /dev/null and b/assets/figs/web-1.4.6+/myagents/01-sync selective chat history from claude code or codex.png differ
diff --git "a/assets/figs/web-1.4.6+/partners/\346\210\252\345\261\2172026-06-17 22.19.26.png" b/assets/figs/web-1.4.6+/partners/00-partners overview.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/partners/\346\210\252\345\261\2172026-06-17 22.19.26.png"
rename to assets/figs/web-1.4.6+/partners/00-partners overview.png
diff --git "a/assets/figs/web-1.4.6+/partners/\346\210\252\345\261\2172026-06-17 22.20.14.png" b/assets/figs/web-1.4.6+/partners/01-chat with partners.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/partners/\346\210\252\345\261\2172026-06-17 22.20.14.png"
rename to assets/figs/web-1.4.6+/partners/01-chat with partners.png
diff --git "a/assets/figs/web-1.4.6+/partners/\346\210\252\345\261\2172026-06-17 22.21.02.png" b/assets/figs/web-1.4.6+/partners/02-IM config for each partner.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/partners/\346\210\252\345\261\2172026-06-17 22.21.02.png"
rename to assets/figs/web-1.4.6+/partners/02-IM config for each partner.png
diff --git "a/assets/figs/web-1.4.6+/settings/\346\210\252\345\261\2172026-06-17 22.26.00.png" b/assets/figs/web-1.4.6+/settings/00-setting overview.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/settings/\346\210\252\345\261\2172026-06-17 22.26.00.png"
rename to assets/figs/web-1.4.6+/settings/00-setting overview.png
diff --git "a/assets/figs/web-1.4.6+/settings/\346\210\252\345\261\2172026-06-17 22.26.30.png" b/assets/figs/web-1.4.6+/settings/01-appearance settings.png
similarity index 100%
rename from "assets/figs/web-1.4.6+/settings/\346\210\252\345\261\2172026-06-17 22.26.30.png"
rename to assets/figs/web-1.4.6+/settings/01-appearance settings.png
diff --git a/deeptutor/capabilities/mastery/loop.py b/deeptutor/capabilities/mastery/loop.py
index 4a58a429b..6e25c7838 100644
--- a/deeptutor/capabilities/mastery/loop.py
+++ b/deeptutor/capabilities/mastery/loop.py
@@ -45,6 +45,8 @@ class MasteryLoopCapability:
if self.is_active(context) and tool_name in MASTERY_TOOL_NAMES:
updated = dict(kwargs)
updated["_mastery_path_id"] = str(context.metadata.get("mastery_path_id") or "").strip()
+ updated["_session_id"] = str(context.session_id or "").strip()
+ updated["_turn_id"] = str(context.metadata.get("turn_id") or "").strip()
return updated
return kwargs
diff --git a/deeptutor/capabilities/mastery/tools.py b/deeptutor/capabilities/mastery/tools.py
index f71a79532..2e55795e7 100644
--- a/deeptutor/capabilities/mastery/tools.py
+++ b/deeptutor/capabilities/mastery/tools.py
@@ -16,6 +16,7 @@ race on a shared object.
from __future__ import annotations
import json
+import logging
from typing import TYPE_CHECKING, Any
import uuid
@@ -58,6 +59,7 @@ MASTERY_TOOL_NAMES: tuple[str, ...] = (
_QUESTION_TYPES = ("choice", "short", "open")
_ALLOWED_KP_TYPES = {t.value for t in KnowledgeType}
+logger = logging.getLogger(__name__)
def _new_service() -> LearningService:
@@ -71,6 +73,73 @@ def _resolve_path_id(kwargs: dict[str, Any]) -> str:
return str(kwargs.get("_mastery_path_id") or "").strip()
+def _resolve_session_id(kwargs: dict[str, Any]) -> str:
+ return str(kwargs.get("_session_id") or "").strip()
+
+
+def _resolve_turn_id(kwargs: dict[str, Any]) -> str:
+ return str(kwargs.get("_turn_id") or "").strip()
+
+
+def _question_bank_type(question_type: str) -> str:
+ qtype = str(question_type or "").strip().lower()
+ if qtype == "choice":
+ return "choice"
+ if qtype == "open":
+ return "written"
+ return "short_answer"
+
+
+def _question_bank_options(options: list[str]) -> dict[str, str]:
+ result: dict[str, str] = {}
+ for idx, raw in enumerate(options):
+ text = str(raw or "").strip()
+ if not text:
+ continue
+ if len(text) <= 3 and text.isalnum():
+ key = text.upper()
+ result[key] = text
+ continue
+ key = chr(ord("A") + idx) if idx < 26 else str(idx + 1)
+ result[key] = text
+ return result
+
+
+async def _sync_mastery_attempt_to_question_bank(
+ *,
+ session_id: str,
+ turn_id: str,
+ pending: PendingQuestion,
+ user_answer: str,
+ is_correct: bool,
+) -> None:
+ if not session_id:
+ return
+ item = {
+ "turn_id": turn_id,
+ "question_id": pending.question_id,
+ "question": pending.prompt,
+ "question_type": _question_bank_type(pending.question_type),
+ "options": _question_bank_options(list(pending.options or [])),
+ "correct_answer": pending.expected_answer,
+ "explanation": "",
+ "difficulty": "",
+ "user_answer": user_answer,
+ "is_correct": is_correct,
+ }
+ try:
+ from deeptutor.services.session import get_sqlite_session_store
+
+ await get_sqlite_session_store().upsert_notebook_entries(session_id, [item])
+ except Exception:
+ logger.warning(
+ "Failed to sync mastery question %s to question bank for session %s",
+ pending.question_id,
+ session_id,
+ exc_info=True,
+ )
+
+
def _json_result(payload: dict[str, Any], *, meta_key: str, success: bool = True) -> ToolResult:
return ToolResult(
content=json.dumps(payload, ensure_ascii=False),
@@ -280,6 +349,13 @@ class MasteryGradeTool(BaseTool):
question_type=pending.question_type,
scheduler=scheduler,
)
+ await _sync_mastery_attempt_to_question_bank(
+ session_id=_resolve_session_id(kwargs),
+ turn_id=_resolve_turn_id(kwargs),
+ pending=pending,
+ user_answer=answer,
+ is_correct=is_correct,
+ )
service.clear_pending_question(progress)
kp, _, _ = find_knowledge_point(progress, pending.knowledge_point_id)
mastered = bool(kp and is_mastered(progress, kp))
diff --git a/deeptutor/learning/tests/test_mastery_tools.py b/deeptutor/learning/tests/test_mastery_tools.py
index e11d1db26..8f121a98f 100644
--- a/deeptutor/learning/tests/test_mastery_tools.py
+++ b/deeptutor/learning/tests/test_mastery_tools.py
@@ -9,6 +9,7 @@ import json
import pytest
+from deeptutor.services.session.sqlite_store import SQLiteSessionStore
from deeptutor.learning.storage import LearningStore
from deeptutor.tools.mastery_tool import (
MasteryAssessTool,
@@ -26,6 +27,13 @@ def path_id(tmp_path, monkeypatch):
return "test_path"
+def session_store(tmp_path, monkeypatch):
+ store = SQLiteSessionStore(db_path=tmp_path / "chat.db")
+ monkeypatch.setattr("deeptutor.services.session.get_sqlite_session_store", lambda: store)
+ return store
+
+
def _store_init_factory(root):
def _init(self, root_arg=None): # mirrors LearningStore.__init__ signature
from pathlib import Path
@@ -179,6 +187,44 @@ async def test_wrong_answer_does_not_master(path_id):
assert result["mastered"] is False
+async def test_grade_syncs_mastery_attempt_to_question_bank(path_id, session_store):
+ session = await session_store.create_session(title="Mastery Session")
+ await _build_basic(path_id)
+ status = json.loads((await MasteryStatusTool().execute(_mastery_path_id=path_id)).content)
+ kp_id = status["next"]["knowledge_point_id"]
+ await MasteryQuizTool().execute(
+ _mastery_path_id=path_id,
+ knowledge_point_id=kp_id,
+ question="2+2?",
+ expected_answer="4",
+ question_type="short",
+ )
+
+ result = json.loads(
+ (
+ await MasteryGradeTool().execute(
+ _mastery_path_id=path_id,
+ _session_id=session["id"],
+ _turn_id="turn_mastery_1",
+ answer="5",
+ )
+ ).content
+ )
+
+ assert result["is_correct"] is False
+ wrong_entries = await session_store.list_notebook_entries(is_correct=False)
+ assert wrong_entries["total"] == 1
+ entry = wrong_entries["items"][0]
+ assert entry["session_title"] == "Mastery Session"
+ assert entry["turn_id"] == "turn_mastery_1"
+ assert entry["question"] == "2+2?"
+ assert entry["question_type"] == "short_answer"
+ assert entry["user_answer"] == "5"
+ assert entry["correct_answer"] == "4"
+ assert entry["is_correct"] is False
+
+
# ── assess: the qualitative gate ─────────────────────────────────────────────