DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
docs:update readme
Bingxi Zhao (Frank)d72b4f0d02c0
diff --git a/README.md b/README.mdindex d268e15a6..b685c1689 100644--- a/README.md+++ b/README.md@@ -34,7 +34,7 @@[](./Communication.md)[](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) · [Multi-User](#-multi-user--shared-deployments) · [Community](#-community)+[Features](#-key-features) · [Get Started](#-get-started) · [Explore](#-explore-deeptutor) · [CLI](#%EF%B8%8F-deeptutor-cli--agent-native-interface) · [Community](#-community)</div>@@ -147,23 +147,13 @@## ✨ Key Features-DeepTutor is organized around an agent-native runtime: a shared ChatOrchestrator routes every turn into capabilities, a ToolRegistry exposes single-shot tools when the model needs them, and a CapabilityRegistry lets deeper workflows take over the turn when the task needs structure.+DeepTutor is an agent-native learning workspace: Chat, Solve, Quiz, Research, Visualize, and Mastery Path run on one extensible tutoring runtime.-<div align="center">-<img src="assets/figs/system/system%20architecture.png" alt="DeepTutor system architecture" width="900">-</div>--**One learning workspace**--- **Chat as the default loop** — casual tutoring, source-grounded Q&A, Deep Solve, Deep Question, Deep Research, Visualize, and Auto Mode all share the same session context and source inventory.-- **Learning surfaces that stay connected** — Co-Writer drafts, Book pages, Knowledge Bases, Space assets, and Memory are separate workspaces, but they feed the same agent runtime instead of becoming isolated apps.-- **Partners for persistent companionship** — IM-connected companions now run on the same chat agent loop as the main product, with their own synthetic workspace and assigned library.--**Tools, memory, and control**--- **Composable tools** — RAG, source reading, memory read/write, notebooks, URL fetch, GitHub lookup, ask-user pauses, sandboxed execution, and optional brainstorm/web/paper/reason tools can be mounted according to context and settings.-- **Three-layer memory** — L1 traces, L2 per-surface summaries, and L3 cross-surface synthesis make personalization inspectable rather than hidden behind a black box.-- **Unified settings and CLI** — model catalogs, embeddings, search, network, MCP servers, tools, capabilities, and deployment settings are editable from the web UI and scriptable from `deeptutor`.+- **Multiple learning modes, one tutor runtime** — move between flexible chat, step-by-step solving, auto-validated quiz generation, multi-agent research, visual explanation, and mastery-based tutoring without switching systems.+- **Connected learning workspace** — Knowledge Bases, Book pages, Co-Writer drafts, Space assets, notebooks, and Memory give the tutor reusable context instead of scattering learning materials across isolated tools.+- **Extensible tool and skill ecosystem** — DeepTutor can use built-in tools, MCP tools, built-in skills, and community skills from ClawHub, so the tutor can grow with new workflows instead of being limited to a fixed feature set.+- **Inspectable long-term memory** — L1 traces, L2 surface summaries, and L3 cross-surface synthesis make personalization visible, editable, and traceable.+- **Persistent Partners** — IM-connected companions run on the same DeepTutor agent loop, each with its own soul, channels, workspace, and assigned library.---@@ -413,6 +403,10 @@ Project-root `.env` is **not** read as an application config file. For a minimalThe README tour follows the product surfaces in the order you will most often meet them: Chat, Partner, Co-Writer, Book, Knowledge, Space, Memory, and Settings. The screenshots below come from the reorganized `assets/figs` tree; archived legacy images are intentionally not used here.+<div align="center">+<img src="assets/figs/system/system%20architecture.png" alt="DeepTutor system architecture" width="900">+</div>+<details><summary><b>💬 Chat — The Agent Loop You Actually Use</b></summary>@@ -458,6 +452,10 @@ The channel layer is schema-driven and can connect to IM platforms such as Feish<details><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">+</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.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.@@ -537,6 +535,31 @@ Most settings use a draft-and-apply flow so users can test providers before comm</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+data/+├── user/ # Admin workspace + global settings+├── users/<uid>/ # Per-user scope: chat history, memory, notebooks, KBs+├── partners/<id>/workspace/ # Partner (synthetic-user) scope+└── system/ # auth/users.json · grants/<uid>.json · audit/usage.jsonl+```++The **first registered user becomes admin** and owns model catalogs, provider credentials, shared knowledge bases, skills, and per-user grants. Everyone else gets an isolated workspace and a redacted Settings page — admin-assigned models, KBs, and skills show up as scoped, read-only options, never as raw API keys.++**Enable it:** turn auth on in `data/user/settings/auth.json`, restart `deeptutor start`, register the first admin at `/register`, then add users from `/admin/users` and assign models, KBs, skills, tool/MCP policy, and code-execution access through grants.++> PocketBase stays a single-user integration — keep `integrations.pocketbase_url` blank for multi-user deployments unless you've wired up an external user store.++</details>+---## ⌨️ DeepTutor CLI — Agent-Native Interface@@ -578,37 +601,6 @@ The CLI-only distribution is present in `packaging/deeptutor-cli`; in this check----## 👥 Multi-User — Shared Deployments--<div align="center">-<img src="assets/figs/webui/multi-user.png" alt="DeepTutor multi-user admin workspace" width="900">-</div>--Authentication is optional and off by default. When enabled, DeepTutor becomes a shared deployment with one admin workspace, per-user workspaces, partner workspaces, and system state under one `data/` tree.--```text-data/-├── user/ # Admin workspace and settings-├── users/<uid>/ # Non-admin user scope-│ ├── user/chat_history.db-│ ├── user/settings/interface.json-│ ├── user/workspace/{chat,co-writer,book,memory,notebook,...}-│ └── knowledge_bases/...-├── partners/<id>/workspace/ # Partner synthetic-user scope-└── system/- ├── auth/users.json- ├── grants/<uid>.json- └── audit/usage.jsonl-```--The first registered user becomes admin and can configure model catalogs, provider credentials, knowledge bases, skills, and user grants. Non-admin users get isolated chat history, memory, notebooks, personal knowledge bases, and a redacted Settings page; admin-assigned resources appear as scoped, read-only options rather than exposing API keys or provider internals.--For a local trial, set `data/user/settings/auth.json` to enable auth, restart `deeptutor start`, register the first admin at `/register`, then create users from `/admin/users` and assign models, KBs, skills, tool policy, MCP policy, and code-execution access through grants.--PocketBase mode remains a single-user integration in this tree; multi-user deployments should keep `integrations.pocketbase_url` blank and use the default JSON/SQLite auth and session stores unless an external user store has been explicitly designed for the deployment.------## 🧩 Ecosystem — Hub Skills, One Command AwayDeepTutor skills speak the same language as the wider Agent-Skills ecosystem: a directory holding a `SKILL.md` playbook (YAML frontmatter + markdown) plus optional reference files. That makes external skill registries a native source for the skill library — [ClawHub](https://clawhub.ai/) is wired in out of the box:diff --git a/assets/figs/webui/cowriter.png b/assets/figs/webui/cowriter.pngnew file mode 100644index 000000000..e093a63bcBinary files /dev/null and b/assets/figs/webui/cowriter.png differdiff --git a/deeptutor/agents/notebook/prompts/en/summarize_agent.yaml b/deeptutor/agents/notebook/prompts/en/summarize_agent.yamlindex 99085bae5..eefabd634 100644--- a/deeptutor/agents/notebook/prompts/en/summarize_agent.yaml+++ b/deeptutor/agents/notebook/prompts/en/summarize_agent.yaml@@ -22,6 +22,7 @@ user_template: |# Per-record-type hints injected into `user_template` as `{record_hint}`.record_hints:chat: "A full chat transcript; focus on the question, conclusion, and next actions."+ tutorbot: "A conversation with a Partner (a named AI assistant); focus on what was asked, the Partner's conclusion, and any next actions."guided_learning: "A guided learning record; focus on topic, knowledge structure, and partial/final output."co_writer: "A Co-Writer markdown draft authored by the user; focus on the document's topic, structure, current completion state, and what makes it worth revisiting."default: "Summarize the most reusable information in this record."diff --git a/deeptutor/agents/notebook/prompts/zh/summarize_agent.yaml b/deeptutor/agents/notebook/prompts/zh/summarize_agent.yamlindex 4d9ca87db..766395317 100644--- a/deeptutor/agents/notebook/prompts/zh/summarize_agent.yaml+++ b/deeptutor/agents/notebook/prompts/zh/summarize_agent.yaml@@ -23,6 +23,7 @@ user_template: |# 各记录类型的提示语,会被注入到 user_template 的 {record_hint}。record_hints:chat: "一段完整聊天历史,重点提炼问题、结论与后续行动。"+ tutorbot: "一段与 Partner(具名 AI 助手)的对话,重点提炼提出的问题、Partner 给出的结论与后续行动。"guided_learning: "一段引导式学习记录,重点提炼学习主题、知识点结构与阶段性产出。"co_writer: "一份用户在 Co-Writer 中撰写的 Markdown 草稿,重点提炼文档主题、结构骨架、当前完成度,以及后续值得回顾的部分。"default: "请总结此记录中最值得复用的信息。"diff --git a/web/app/(workspace)/partners/[partnerId]/page.tsx b/web/app/(workspace)/partners/[partnerId]/page.tsxindex ce7920950..76ec581f1 100644--- a/web/app/(workspace)/partners/[partnerId]/page.tsx+++ b/web/app/(workspace)/partners/[partnerId]/page.tsx@@ -5,12 +5,14 @@* Header carries identity + run state; everything else lives in the tabs.*/-import { Suspense, useCallback, useEffect, useState } from "react";+import { Suspense, useCallback, useEffect, useMemo, useState } from "react";import Link from "next/link";import { useParams, useRouter, useSearchParams } from "next/navigation";import {ArrowLeft,Archive,+ BookmarkPlus,+ Download,Loader2,MessageCircle,Play,@@ -27,11 +29,16 @@ import {stopPartner,type PartnerInfo,} from "@/lib/partners-api";+import { downloadChatMarkdown, type ExportableMessage } from "@/lib/chat-export";import PartnerAvatar from "@/components/partners/PartnerAvatar";import PartnerChat from "@/components/partners/PartnerChat";import PartnerChannels from "@/components/partners/PartnerChannels";import PartnerConfigure from "@/components/partners/PartnerConfigure";import PartnerArchives from "@/components/partners/PartnerArchives";+import SaveToNotebookModal, {+ type NotebookSaveMessage,+ type NotebookSavePayload,+} from "@/components/notebook/SaveToNotebookModal";type Tab = "chat" | "configure" | "channels" | "archive";@@ -52,6 +59,13 @@ function PartnerDetail() {const [loading, setLoading] = useState(true);const [lifecycleBusy, setLifecycleBusy] = useState(false);const [toast, setToast] = useState("");+ // Conversation transcripts lifted from the Chat / Archive tabs so the header+ // can export whichever surface is active.+ const [chatMessages, setChatMessages] = useState<ExportableMessage[]>([]);+ const [archiveMessages, setArchiveMessages] = useState<ExportableMessage[]>(+ [],+ );+ const [showSaveModal, setShowSaveModal] = useState(false);useEffect(() => {if (!toast) return;@@ -59,6 +73,59 @@ function PartnerDetail() {return () => clearTimeout(timer);}, [toast]);+ const exportMessages = useMemo<ExportableMessage[]>(() => {+ if (tab === "chat") return chatMessages;+ if (tab === "archive") return archiveMessages;+ return [];+ }, [tab, chatMessages, archiveMessages]);++ const canExport = exportMessages.length > 0;++ const exportTitle = useMemo(() => {+ const firstUser = exportMessages+ .find((msg) => msg.role === "user")+ ?.content.trim();+ return firstUser?.slice(0, 80) || partner?.name || "Conversation";+ }, [exportMessages, partner?.name]);++ const savePayload = useMemo<NotebookSavePayload | null>(() => {+ if (!partner || !canExport) return null;+ return {+ recordType: "tutorbot",+ title: exportTitle,+ // The transcript / userQuery are rebuilt inside the modal from the+ // user's selected subset; these are just fallbacks.+ userQuery: "",+ output: "",+ metadata: {+ source: "partner",+ partner_id: partnerId,+ partner_name: partner.name,+ },+ };+ }, [partner, canExport, exportTitle, partnerId]);++ const saveMessages = useMemo<NotebookSaveMessage[]>(+ () =>+ exportMessages+ .filter(+ (msg) =>+ msg.role === "user" ||+ msg.role === "assistant" ||+ msg.role === "system",+ )+ .map((msg) => ({+ role: msg.role as NotebookSaveMessage["role"],+ content: msg.content,+ })),+ [exportMessages],+ );++ const handleDownload = useCallback(() => {+ if (!exportMessages.length) return;+ downloadChatMarkdown(exportMessages, { title: exportTitle });+ }, [exportMessages, exportTitle]);+const load = useCallback(async () => {try {setPartner(await getPartner(partnerId));@@ -195,6 +262,30 @@ function PartnerDetail() {))}</nav>+ {(tab === "chat" || tab === "archive") && (+ <>+ <button+ type="button"+ onClick={() => setShowSaveModal(true)}+ disabled={!canExport}+ title={t("Save to Notebook")}+ aria-label={t("Save to Notebook")}+ className="rounded-md p-1.5 text-[var(--muted-foreground)] hover:bg-[var(--muted)] hover:text-[var(--foreground)] disabled:cursor-not-allowed disabled:opacity-40"+ >+ <BookmarkPlus className="h-4 w-4" />+ </button>+ <button+ type="button"+ onClick={handleDownload}+ disabled={!canExport}+ title={t("Download chat history as Markdown")}+ aria-label={t("Download Markdown")}+ className="rounded-md p-1.5 text-[var(--muted-foreground)] hover:bg-[var(--muted)] hover:text-[var(--foreground)] disabled:cursor-not-allowed disabled:opacity-40"+ >+ <Download className="h-4 w-4" />+ </button>+ </>+ )}<buttontype="button"onClick={() => void toggleRunning()}@@ -230,11 +321,16 @@ function PartnerDetail() {emoji={partner.emoji}color={partner.color}avatar={partner.avatar}+ onMessagesChange={setChatMessages}/></div>) : tab === "archive" ? (<div className="mx-auto h-full max-w-5xl overflow-hidden px-5 py-5">- <PartnerArchives partnerId={partnerId} onToast={setToast} />+ <PartnerArchives+ partnerId={partnerId}+ onToast={setToast}+ onMessagesChange={setArchiveMessages}+ /></div>) : (<div className="mx-auto h-full max-w-3xl overflow-y-auto px-5 py-5">@@ -251,6 +347,17 @@ function PartnerDetail() {)}</div>+ <SaveToNotebookModal+ open={showSaveModal}+ payload={savePayload}+ messages={saveMessages}+ onClose={() => setShowSaveModal(false)}+ onSaved={() => {+ setShowSaveModal(false);+ setToast(t("Saved to notebook."));+ }}+ />+{toast && (<div className="pointer-events-none fixed bottom-6 left-1/2 z-50 -translate-x-1/2 rounded-lg bg-[var(--foreground)] px-3.5 py-2 text-[12.5px] text-[var(--background)] shadow-lg">{toast}diff --git a/web/components/partners/PartnerArchives.tsx b/web/components/partners/PartnerArchives.tsxindex 127702b48..081f9f17c 100644--- a/web/components/partners/PartnerArchives.tsx+++ b/web/components/partners/PartnerArchives.tsx@@ -8,6 +8,7 @@ import {getPartnerSessions,type PartnerSessionInfo,} from "@/lib/partners-api";+import type { ExportableMessage } from "@/lib/chat-export";interface HistoryMessage {role: string;@@ -31,9 +32,13 @@ function formatTime(value?: string) {export default function PartnerArchives({partnerId,onToast,+ onMessagesChange,}: {partnerId: string;onToast: (message: string) => void;+ /** Lifts the selected conversation up so the page header can export it.+ * Empty array when nothing is selected (or while loading). */+ onMessagesChange?: (messages: ExportableMessage[]) => void;}) {const { t } = useTranslation();const [sessions, setSessions] = useState<PartnerSessionInfo[]>([]);@@ -98,6 +103,20 @@ export default function PartnerArchives({};}, [partnerId, selectedKey, onToast, t]);+ // Report the selected conversation up for header export controls.+ useEffect(() => {+ if (!onMessagesChange) return;+ if (!selectedKey || loadingMessages) {+ onMessagesChange([]);+ return;+ }+ onMessagesChange(+ messages+ .filter((m) => m.role === "user" || m.role === "assistant")+ .map((m) => ({ role: m.role, content: m.content })),+ );+ }, [messages, selectedKey, loadingMessages, onMessagesChange]);+return (<div className="grid h-full min-h-0 grid-cols-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]"><div className="min-h-0 border-r border-[var(--border)] pr-4 lg:overflow-y-auto">diff --git a/web/components/partners/PartnerChat.tsx b/web/components/partners/PartnerChat.tsxindex bba0bd109..dde4628ac 100644--- a/web/components/partners/PartnerChat.tsx+++ b/web/components/partners/PartnerChat.tsx@@ -17,6 +17,7 @@ import dynamic from "next/dynamic";import { Paperclip } from "lucide-react";import { wsUrl } from "@/lib/api";import { getPartnerHistory } from "@/lib/partners-api";+import type { ExportableMessage } from "@/lib/chat-export";import type { StreamEvent } from "@/lib/unified-ws";import { docIconFor, formatBytes, isSvgFilename } from "@/lib/doc-attachments";import {@@ -157,12 +158,17 @@ export default function PartnerChat({emoji,color,avatar,+ onMessagesChange,}: {partnerId: string;partnerName: string;emoji?: string;color?: string;avatar?: string;+ /** Lifts the settled conversation up so the page header can export it.+ * Fires only on discrete message events (send / turn done / clear), not+ * per streamed token — the live `draft` is intentionally excluded. */+ onMessagesChange?: (messages: ExportableMessage[]) => void;}) {const { t } = useTranslation();const [messages, setMessages] = useState<ChatMsg[]>([]);@@ -299,6 +305,21 @@ export default function PartnerChat({};}, [partnerId, scrollToBottom]);+ // Report the settled transcript to the parent for header export controls.+ useEffect(() => {+ onMessagesChange?.(+ messages.map((msg) => ({+ role: msg.role,+ content: msg.content,+ attachments: msg.attachments?.map((a) => ({+ type: a.type,+ filename: a.filename,+ mime_type: a.mimeType,+ })),+ })),+ );+ }, [messages, onMessagesChange]);+const handleSend = useCallback((content: string, attachments: PartnerPendingAttachment[]) => {if (diff --git a/web/components/space/NotebooksSection.tsx b/web/components/space/NotebooksSection.tsxindex 4f719829c..f33c104ae 100644--- a/web/components/space/NotebooksSection.tsx+++ b/web/components/space/NotebooksSection.tsx@@ -172,21 +172,28 @@ export default function NotebooksSection() {return new Date(value * 1000).toLocaleString();};- const getRecordBadge = (type: string) => {- switch (type) {+ const getRecordBadge = (record: NotebookRecord) => {+ switch (record.type) {case "chat":return {label: t("Chat"),color: "bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-300",icon: MessageSquare,};- case "tutorbot":+ case "tutorbot": {+ // Partner conversations carry the partner's name in metadata so the+ // badge reads as that partner's own category, not a generic "Chat".+ const partnerName =+ typeof record.metadata?.partner_name === "string"+ ? record.metadata.partner_name.trim()+ : "";return {- label: t("Partner"),+ label: partnerName || t("Partner"),color:"bg-violet-100 text-violet-700 dark:bg-violet-900/40 dark:text-violet-300",icon: Bot,};+ }case "research":return {label: t("Research"),@@ -203,7 +210,7 @@ export default function NotebooksSection() {};default:return {- label: type,+ label: record.type,color:"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400",icon: NotebookPen,@@ -389,7 +396,7 @@ export default function NotebooksSection() {<div className="min-h-0 flex-1 overflow-y-auto pr-1"><div className="divide-y divide-[var(--border)]">{selected.records?.map((record) => {- const badge = getRecordBadge(record.type);+ const badge = getRecordBadge(record);const BadgeIcon = badge.icon;const expanded = expandedRecordId === record.id;const canOpenSession =diff --git a/web/lib/chat-export.ts b/web/lib/chat-export.tsindex 98b62b550..6c84fa37a 100644--- a/web/lib/chat-export.ts+++ b/web/lib/chat-export.ts@@ -1,15 +1,28 @@-import type {- MessageItem,- MessageAttachment,-} from "@/context/UnifiedChatContext";+/**+ * Minimal message/attachment shape the markdown exporter needs. Product chat's+ * `MessageItem` satisfies it structurally, and partner conversations map into+ * it too — so both surfaces share one serializer.+ */+export interface ExportableAttachment {+ type?: string;+ filename?: string;+ mime_type?: string;+}++export interface ExportableMessage {+ role: string;+ content: string;+ capability?: string;+ attachments?: ExportableAttachment[];+}-function roleHeading(role: MessageItem["role"]): string {+function roleHeading(role: string): string {if (role === "user") return "User";if (role === "assistant") return "Assistant";return "System";}-function formatAttachments(attachments?: MessageAttachment[]): string {+function formatAttachments(attachments?: ExportableAttachment[]): string {if (!attachments?.length) return "";const items = attachments.map((a) => {@@ -26,7 +39,7 @@ export interface BuildChatMarkdownOptions {}export function buildChatMarkdown(- messages: MessageItem[],+ messages: ExportableMessage[],options: BuildChatMarkdownOptions = {},): string {const title = options.title?.trim() || "Chat Session";@@ -53,7 +66,7 @@ function sanitizeFilename(input: string): string {}export function downloadChatMarkdown(- messages: MessageItem[],+ messages: ExportableMessage[],options: BuildChatMarkdownOptions = {},): void {if (!messages.length) return;