JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
docs(dialog): Dialogue documentation
renquanjia163903a5ff61
diff --git a/docs/assets/images/conversation/chat_cluster_mode_1.png b/docs/assets/images/conversation/chat_cluster_mode_1.pngnew file mode 100644index 0000000000..785a2ac68eBinary files /dev/null and b/docs/assets/images/conversation/chat_cluster_mode_1.png differdiff --git a/docs/assets/images/conversation/chat_cluster_mode_2.png b/docs/assets/images/conversation/chat_cluster_mode_2.pngnew file mode 100644index 0000000000..9a96a4c9a2Binary files /dev/null and b/docs/assets/images/conversation/chat_cluster_mode_2.png differdiff --git a/docs/assets/images/conversation/chat_cluster_mode_3.png b/docs/assets/images/conversation/chat_cluster_mode_3.pngnew file mode 100644index 0000000000..b46621f4cfBinary files /dev/null and b/docs/assets/images/conversation/chat_cluster_mode_3.png differdiff --git a/docs/assets/images/conversation/chat_execution_modes.png b/docs/assets/images/conversation/chat_execution_modes.pngnew file mode 100644index 0000000000..6e2c090ae8Binary files /dev/null and b/docs/assets/images/conversation/chat_execution_modes.png differdiff --git a/docs/assets/images/conversation/chat_new_session.png b/docs/assets/images/conversation/chat_new_session.pngnew file mode 100644index 0000000000..d8639415cdBinary files /dev/null and b/docs/assets/images/conversation/chat_new_session.png differdiff --git a/docs/assets/images/conversation/chat_operation_flow.png b/docs/assets/images/conversation/chat_operation_flow.pngnew file mode 100644index 0000000000..e171c64397Binary files /dev/null and b/docs/assets/images/conversation/chat_operation_flow.png differdiff --git a/docs/assets/images/conversation/chat_page_overview.png b/docs/assets/images/conversation/chat_page_overview.pngnew file mode 100644index 0000000000..46d803b789Binary files /dev/null and b/docs/assets/images/conversation/chat_page_overview.png differdiff --git a/docs/assets/images/conversation/cluster_mode_sample_frontend.png b/docs/assets/images/conversation/cluster_mode_sample_frontend.pngnew file mode 100644index 0000000000..602c63589bBinary files /dev/null and b/docs/assets/images/conversation/cluster_mode_sample_frontend.png differdiff --git a/docs/assets/images/conversation/cluster_mode_sample_workspace_paths.png b/docs/assets/images/conversation/cluster_mode_sample_workspace_paths.pngnew file mode 100644index 0000000000..6a9f092476Binary files /dev/null and b/docs/assets/images/conversation/cluster_mode_sample_workspace_paths.png differdiff --git a/docs/assets/images/conversation/dynamic_insert_new_task.png b/docs/assets/images/conversation/dynamic_insert_new_task.pngnew file mode 100644index 0000000000..a4d99116cdBinary files /dev/null and b/docs/assets/images/conversation/dynamic_insert_new_task.png differdiff --git a/docs/assets/images/conversation/dynamic_insert_task.png b/docs/assets/images/conversation/dynamic_insert_task.pngnew file mode 100644index 0000000000..ae93265235Binary files /dev/null and b/docs/assets/images/conversation/dynamic_insert_task.png differdiff --git a/docs/assets/images/conversation/performance_mode_demo.png b/docs/assets/images/conversation/performance_mode_demo.pngnew file mode 100644index 0000000000..fb135594a6Binary files /dev/null and b/docs/assets/images/conversation/performance_mode_demo.png differdiff --git a/docs/en/Conversation.md b/docs/en/Conversation.mdnew file mode 100644index 0000000000..2967397d8b--- /dev/null+++ b/docs/en/Conversation.md@@ -0,0 +1,609 @@+# Conversation++Conversation is the most commonly used entry point in JiuwenSwarm. It is not just chat, but the primary interface for receiving and executing tasks. Here, you can ask questions, assign tasks, add requirements, and review both progress and outcomes.++---++## 1. Getting Started++### 1.1 Conversation Overview++**Positioning of the Conversation Page**++The conversation page is JiuwenSwarm's core interaction interface. It is not only a chat window, but a **workbench for task intake and execution**. Through conversation, you can:++- **Ask questions**: Obtain information and clarifications+- **Assign tasks**: Let the agent execute concrete operations+- **Add requirements**: Adjust scope dynamically during execution+- **Track progress**: See task status and outcomes in real time++++**Core Capabilities**++| Capability | Description |+|:---|:---|+| **Natural Language Understanding** | Describe needs in plain language without memorizing complex commands |+| **Task Planning** | Automatically break complex requests into executable subtask sequences |+| **Dynamic Adjustment** | Insert new requirements or modify plans at any point during execution |+| **Tool Orchestration** | Automatically choose and combine suitable tools to complete tasks |+| **Result Feedback** | Clearly present the execution process and final results |++---++### 1.2 How to Start a Conversation++**Basic Workflow**++1. **Describe your request**: Enter your requirement or task in the input box+2. **Send the message**: Click send or press Enter+3. **Review the response**: The agent interprets your request and starts execution+4. **Continue refining**: Add follow-up requirements or adjust direction based on progress++++**Tips for Better Prompts**++For better execution quality, include the following elements when describing requirements:++| Element | Description | Example |+|:---|:---|:---|+| **Goal** | What you want to achieve | "Generate API documentation" |+| **Scope** | Where the request applies | "For all interfaces in the `src/api` directory" |+| **Constraints** | Special requirements or limits | "Use Chinese and output in Markdown format" |+| **Output format** | Expected output form | "Write to `docs/api.md`" |++**Prompt Quality Comparison**++| Recommended ✅ | Too vague ❌ |+|:---|:---|+| "Help me organize all Markdown files in `docs/zh`, verify heading hierarchy, fix formatting issues, and produce a change checklist." | "Organize docs" |+| "Analyze the code structure in `src/core`, generate an architecture diagram as PNG, and save it to `docs/architecture.png`." | "Analyze code" |+| "Translate `README.md` into English while preserving the original format, and write to `README_EN.md`." | "Translate README" |++**First-time Usage Suggestions**++- Start with **small tasks with clear goals** to quickly understand agent capabilities+- If the first result is not ideal, **continue adding requirements** instead of starting over+- Use **follow-up questions and refinements** to improve execution quality++---++### 1.3 Common Operations During Conversation++During task execution, you can perform the following operations at any time:++**Dynamic Adjustment Actions**++| Action | Description | Typical scenario |+|:---|:---|:---|+| **Add requirements** | Append details or change direction on the current running task | Missing details, need to adjust output format or constraints |+| **Insert new task** | Add a brand-new independent task into the queue | A higher-priority independent need appears |+| **Interrupt task** | Stop a task currently in progress | Need to halt or change direction |+| **Adjust priority** | Reorder pending tasks | Re-prioritize execution sequence |+| **End task** | Mark a task completed or cancelled | Task is no longer needed |+| **View status** | Check current task list and progress | Understand overall progress |++> **Add requirements vs Insert new task**: "Add requirements" refines or extends an **existing task** (e.g., "also add charts to the report"), while "Insert new task" adds a **brand-new independent task** (e.g., "also translate another document for me").++**Core Feature: Adjust While Chatting**++JiuwenSwarm supports **real-time dynamic adjustment**. When you add new requirements while tasks are running, the system will:++1. **Understand the new requirement**: Parse your newly added input+2. **Assess impact**: Evaluate effects on current tasks+3. **Re-plan**: Integrate new requirements into the task queue+4. **Continue execution**: Proceed with the updated plan++**Example: Full Dynamic Adjustment Walkthrough**++The following example chains common dynamic adjustment operations, showing the complete process from task planning to execution, adjustment, and review:++**Step 1: Assign a task**++```+User: Process December invoice data and generate a summary report. Start by creating a todo list.++Agent: Task list:+ [1] Get December invoice data file 🔄 In progress+ [2] Read and parse invoice data ⏳ Pending+ [3] Data cleaning and validation ⏳ Pending+ [4] Generate summary report ⏳ Pending+ [5] Output report file ⏳ Pending++▶ Start task [1]...+```++++**Step 2: Insert a new task**++```+User: Also process January invoices, merge both months, and email finance.++Agent: Task list updated:+ [1] Get December and January invoice data files 🔄 In progress+ [2] Read and parse December and January invoice data ⏳ Pending+ [3] Data cleaning and validation (Dec + Jan) ⏳ Pending+ [4] Merge data and generate summary report ⏳ Pending+ [5] Export report file and email finance ⏳ Pending++▶ Continue execution...+```++++++---++## 2. Execution Modes++### 2.1 Mode Overview++JiuwenSwarm supports multiple execution modes. Different modes fit different scenarios, and you can choose based on task characteristics.++++**Mode Comparison**++| Mode | How it runs | Best for | Characteristics |+|:---|:---|:---|:---|+| **Task Planning** | Decomposes requirements into concrete steps and executes by plan | Complex and multi-step tasks requiring progress tracking | Clear and controllable process; supports dynamic adjustment |+| **Performance Mode** | Handles requests flexibly and supports parallel tasks | Clear goals where fast results are preferred | Fast response; efficiency-first |+| **Cluster Mode** | Multi-agent collaborative execution | Large-scale tasks requiring specialized division of labor | Complementary capabilities; collaborative processing |++**Mode Switching**++You can switch execution modes in the following ways:++- **UI switch**: Select the execution mode at the bottom of the conversation page+- **Command switch**: Use `/mode` or `/switch` (see [CLI Commands](#3-cli-commands))++---++### 2.2 Task Planning Mode++#### 2.2.1 Concept Overview++**What is task planning?**++Task planning is one of JiuwenSwarm's core capabilities. It gives the agent **structured task decomposition and dynamic management**. For complex or multi-step requests, the agent automatically parses them into executable subtasks and systematically records/tracks them through built-in todo tools.++**Core Value**++| Capability | Description |+|:---|:---|+| **Dynamic decomposition** | Automatically splits complex requests into executable subtask sequences |+| **Real-time tracking** | Updates subtask status as each step completes, making progress visible and controllable |+| **Flexible intervention** | Supports adding requirements or urgent insertions mid-execution without breaking the overall flow |+| **Goal preservation** | Reduces goal drift and execution gaps in long-running tasks |++**Applicable Scenarios**++- Tasks with many steps that need phased completion+- Tasks likely to change during execution+- Tasks where process transparency is important+- Tasks requiring confirmation at each stage++++---++### 2.3 Performance Mode++#### 2.3.1 Concept Overview++**What is performance mode?**++Performance Mode (Fast Mode) is optimized for simple and clear tasks. In this mode, the agent will:++- **Respond quickly**: Reduce planning overhead and execute directly+- **Process in parallel**: Run multiple independent tasks at the same time+- **Prioritize efficiency**: Complete work as fast as possible++**Applicable scenarios**++- Tasks with clear goals and straightforward steps+- Tasks where fast results are preferred+- Tasks that do not require detailed process decomposition+- Multiple simple tasks that need batch processing++#### 2.3.2 Practical Example++**Case: Batch document rewriting**++```+User: Rewrite the following two technical docs so they are easier for beginners:+1. docs/api.md+2. docs/architecture.md++Agent: 🔍 Processing docs in parallel...++ Rewriting completed! Both beginner-friendly versions are saved.++ Original file Beginner version+ ContextCompression.md ContextCompression_Beginner.md+ Heartbeat.md Heartbeat_Beginner.md++ 🎉 Both beginner-friendly docs are saved in the same directories as the originals. Want me to refine anything else?+```++++---++### 2.4 Cluster Mode++#### 2.4.1 Concept Overview++**What is cluster mode?**++Cluster Mode (Team Mode) is JiuwenSwarm's multi-agent collaboration mode. Multiple specialized agents work together, each owning a focused domain, to complete complex tasks.++**Core characteristics**++- **Specialized division of labor**: Different agents handle different domains+- **Collaborative execution**: Agents communicate and coordinate+- **Complementary capabilities**: Combine multiple specialized strengths+- **Result integration**: Aggregate outputs from all agents++**Applicable scenarios**++- Large-scale, cross-domain complex tasks+- Tasks requiring multiple professional skill sets+- Tasks difficult for a single agent to complete alone++#### 2.4.2 Practical Example++**Case: Full-stack project development**++```+User: Build a user management system including frontend UI, backend APIs, and database design.++Agent: 🤖 Starting cluster mode and assigning work:+[team_leader] I can help build a user management system. Before we start, I need to confirm several key details so the solution matches your requirements...++User: Use the default approach.++Agent:+[team_leader] ✅ Team formed and started!+[frontend-dev] Received! I have reviewed the task board.+[backend-dev] Project kickoff received!+[qa-engineer] Project kickoff received!+```++The screenshots below are ordered roughly as the conversation unfolds.++1. **Requirements alignment**+ Conversation UI where the Team Leader confirms scope and key details with the user before cluster startup.++++2. **Pickup and parallel start**+ Conversation and status UI when specialized agents pick up subtasks and start work in parallel.++++3. **Collaboration in progress**+ Conversation UI as multiple agents continue coordinated execution (exact layout depends on the product).++++4. **Workspace output paths**+ Example directory layout and important file paths under `workspace` after the task produces outputs.++++5. **Frontend showcase**+ Example frontend pages of the output user management system.++++> **Note**: The cluster mode example above demonstrates the basic multi-agent collaboration flow. In practice, please verify whether cluster mode can fully deliver your engineering goals based on your project needs.++---++## 3. CLI Commands++### 3.1 Command Overview++JiuwenSwarm supports controlling sessions and modes through "special prefix commands." These commands are recognized and processed by the system **before the message reaches the agent** — they do not need the agent to execute them, and instead directly change the system's running state (such as switching modes or creating new sessions).++> **All CLI commands can be typed directly in the chat input box** — you do not need a separate command-line terminal. Enter a slash command starting with `/` in the message box and the system will recognize and execute it.++> **Important: Whether a command takes effect depends on the channel.** Some commands are intercepted and handled by the system only on certain channels; on others they may be forwarded to the agent as ordinary messages. See "Channel Scope" below.++**Channel Scope**++JiuwenSwarm commands are categorized by handling layer:++| Level | Handler | Applicable channels | Description |+| :--- | :--- | :--- | :--- |+| **Gateway interception** | Gateway layer | Feishu, DingTalk, WeCom, WeChat, WhatsApp, Xiaoyi | Intercepted at the gateway — not forwarded to the agent — and change system state directly |+| **Client-side handling** | Client | TUI (terminal) | Handled locally by the TUI client; coordinates with AgentServer via `session.create` and similar calls |+| **No interception** | — | Web conversation page | Not intercepted — sent to the agent as a normal chat message for the agent to interpret |++> **Web conversation page**: Slash commands starting with `/` are **not** intercepted by the gateway and are treated as ordinary messages to the agent — they **will not truly switch sessions or modes**. To start a new chat or change modes in the Web UI, use on-page buttons and menus (such as **New Conversation** or the mode selector). For precise control via commands, use an IM-controlled channel or the TUI.++**Primary Mode and Secondary Mode Explained**++JiuwenSwarm's execution modes are organized in two levels:++- **Primary mode**: Determines the agent's overall working style, such as agent mode (`agent`), code mode (`code`), or team collaboration mode (`team`)+- **Secondary mode**: A finer execution strategy under the primary mode, such as planning mode (`plan`) which decomposes tasks before executing, or fast mode (`fast`) which executes directly++> **Note**: Not all primary modes have secondary modes. Currently `agent` and `code` support secondary modes (`plan`/`fast`/`normal`), while `team` does not yet support secondary mode switching. You can use `/mode` to specify a primary+secondary combination directly (e.g., `/mode agent.plan`), or use `/switch` to change only the secondary mode under the current primary mode.++**Command categories**++| Type | Command | Description | Applicable channels |+| :--- | :--- | :--- | :--- |+| **Session control** | `/new_session` | Create a new session | IM controlled channels |+| **Mode switching** | `/mode` | Switch primary mode (can also specify primary+secondary combination) | IM controlled channels |+| **Mode switching** | `/switch` | Switch secondary mode (under the current primary mode) | IM controlled channels |+| **Skill management** | `/skills list` | List available skills | IM controlled channels |+| **Workspace** | `/workspace_dir` | Set workspace path | TUI |+| **Session reset** | `/clear` (aliases `/new`, `/reset`) | Clear conversation history and create a new session | TUI |++**Usage suggestions**++- **Natural language first**: In most cases, describe your needs directly in natural language+- **Use commands as support**: Use commands when you need quick switching or precise control+- **Do not mix**: Avoid combining commands and natural language in a single message+- **Mind the channel**: Make sure your channel supports the command; otherwise it will be treated as a regular message only++---++### 3.2 Common Commands++#### `/new_session` — Create a New Session++**Purpose**++Think of this as **starting a new blank conversation inside the same channel**. The new conversation **does not** inherit the prior session's chat history — the agent only continues from this new session context. Existing records from earlier sessions **are not deleted**; they remain in the system and can be recalled or reopened later via history or session lists as needed.++On supported IM channels, the system switches to a new `session_id` before handling later messages and cancels still-running work on the old session. Under `workspace/session/`, the per-session directory is usually created **on first write** (e.g. todo or file save), so you do not need to rely on folders appearing the exact moment you issue the command.++**Channel scope**++| Channel | Description |+| :--- | :--- |+| **IM controlled channels** (Feishu, DingTalk, WeCom, WeChat, WhatsApp, Xiaoyi) | ✅ Supported: intercepted by gateway; subsequent messages run in the new session context |+| **TUI (terminal)** | The TUI **does not** expose gateway `/new_session`. Use **`/clear`** (**`/reset`** and **`/new`** are aliases — see table above) to start a fresh blank session |+| **Web conversation page** | ❌ **Do not rely on slash commands**: `/new_session` does not truly apply — use UI controls such as **New Conversation** |++**Usage**++On IM-controlled channels, send exactly one line consisting of **`/new_session` only**, with **no trailing parameters**.++```+/new_session+```++The TUI **does not** provide this gateway command. To start a new blank session in the TUI, send **`/clear`** (same behavior as **`/reset`** / **`/new`** — one built-in handler).++**What happens on IM controlled channels** (gateway: recognize control commands, then refresh session binding)++- The message **is not** passed to the agent for parsing.+- A new `session_id` is generated for this channel and saved in state; the **previous session** has cancellation signaled on gateway and AgentServer sides (including in-flight tasks).+- A fixed confirmation is echoed, e.g. `[CLI command received], session_id has been changed to <new_sid>`.+- You can still see **earlier** messages in the IM window; **from your next outgoing message**, traffic uses the new `session_id` and the agent uses the new session context.++**What happens in the TUI for `/clear`**++- If no task is running: generate a new `session_id`, attempt `session.create`, switch the active session, **clear the on-screen message list for this session**, fetch history for the new session, and show `Started a fresh conversation in <session_id>`.++**workspace/session/ example (written on demand)**++```+workspace/session/+ feishu_17f2b4b32e0_ab12cd/ ← new session dir (may appear once there is a write)+ todo.md ← todo and similar (created on first write)+```++**Notes**++- Old session data and history remain available; that is compatible with "open a new blank context"+- On IM controlled channels, `/new_session` cancels tasks still running on the old session (gateway and AgentServer)+- The command must be **on its own line and match exactly** `/new_session`; forms like `/new_session xxx` are invalid++---++#### `/mode` — Switch Primary Mode++**Purpose**++Set the primary execution mode for the current channel, which affects the Agent's execution strategy. You can also specify a primary+secondary combination directly.++**Channel scope**++| Channel | Handling | Actual effect |+| :--- | :--- | :--- |+| **IM controlled channels** (Feishu, DingTalk, WeCom, WeChat, WhatsApp, Xiaoyi) | Gateway intercepts → updates channel state → cancels old tasks → not forwarded to agent | ✅ Truly switches mode |+| **TUI (terminal)** | Client-side handling | ✅ Truly switches mode |+| **Web conversation page** | Gateway **does not intercept** → forwarded to agent as a regular message | ❌ Does not actually switch mode |++**Supported modes**++| Mode | Description |+| :--- | :--- |+| `agent` | Agent mode (default) |+| `code` | Code mode |+| `team` | Team collaboration mode |+| `agent.plan` | Agent mode + Planning secondary mode |+| `agent.fast` | Agent mode + Fast secondary mode |+| `code.plan` | Code mode + Planning secondary mode |+| `code.normal` | Code mode + Normal secondary mode |++> `/mode agent.plan` has the same effect as first running `/mode agent` then `/switch plan`, but is more concise.++**Usage**++**Template**: `/mode` + `<mode-field>`++`<mode-field>` can be a primary mode name (such as `agent`, `code`, or `team`), or a dot-joined primary+secondary combination (consistent with the **Supported modes** table above).++**Example**: Switch to Agent mode with Fast secondary mode:++```+/mode agent.fast+```++**System response**++```+mode has been changed to agent.fast+```++---++#### `/switch` — Switch Secondary Mode++**Purpose**++Switch the secondary execution strategy under the current primary mode. Only effective for primary modes that support secondary modes (currently `agent` and `code` support this; `team` does not yet).++**Channel scope**++Same as `/mode` — only truly effective on IM controlled channels and TUI; treated as a regular message on the Web conversation page.++**Supported modes**++| Mode | Description |+| :--- | :--- |+| `plan` | Planning mode — decompose tasks first, then execute step by step |+| `fast` | Fast mode — reduce planning, execute directly |+| `normal` | Normal mode — default execution strategy |++**Usage**++```+/switch plan+/switch fast+/switch normal+```++---++#### `/skills list` — List Skills++**Purpose**++List all currently available skills.++**Channel scope**++| Channel | Handling | Actual effect |+| :--- | :--- | :--- |+| **IM controlled channels** (Feishu, DingTalk, WeCom, WeChat, WhatsApp, Xiaoyi) | Gateway intercepts → calls `skills.list` → replies with notification | ✅ Truly lists skills |+| **TUI (terminal)** | Client-side handling | ✅ Truly lists skills |+| **Web conversation page** | Gateway **does not intercept** → forwarded to agent as a regular message | ❌ Agent responds in natural language; may be inaccurate |++**Usage**++```+/skills list+```++**System response**++```+[Skill List]+1. document-writer (skillnet)+ Document writing and optimization+2. code-analyzer (skillnet)+ Code analysis and refactoring+3. data-processor (clawhub)+ Data processing and transformation+...+```++---++#### `/workspace_dir` — Set Workspace Path (TUI Only)++**Purpose**++Set the workspace path for terminal UI outbound requests. This command is only available in TUI.++**Channel scope**++Only available in the TUI (terminal) client; not available on other channels.++**Usage**++```+/workspace_dir get # View current path+/workspace_dir set C:\Projects # Set path+/workspace_dir clear # Clear path+```++**Persistence**++Stored in `~/.jiuwenswarm/tui-workspace-dir`.++📢 For a more detailed command reference, see [Slash Commands Reference](SlashCommands.md).++---++## 4. Conversation Logic++### 4.1 Execution Flow++Basic logic behind JiuwenSwarm conversations:++```+User Input → Intent Understanding → Mode Selection → Task Handling → Result Feedback+```++**Detailed flow**++1. **Intent understanding**: Parse natural language and identify real requirements+2. **Mode selection**: Choose an execution strategy based on task traits and current mode+3. **Task handling**:+ - **Task planning mode**: Decompose into subtasks and execute by plan+ - **Performance mode**: Execute quickly, with parallel support+ - **Cluster mode**: Delegate to multiple agents for collaboration+4. **Result feedback**: Present results in a clear and understandable way++### 4.2 Dynamic Adjustment Mechanism++JiuwenSwarm can re-plan task lists during execution based on new user input:++- **Real-time listening**: Continuously receive new user messages+- **Impact evaluation**: Evaluate how new requirements affect current tasks+- **Intelligent merge**: Integrate new requirements into the queue appropriately+- **Seamless continuation**: Keep execution flow coherent and uninterrupted++### 4.3 Task Planning Mechanism Details++**Core mechanism**++Core logic of task planning mode:++1. **Requirement parsing**: Parse user requests into executable subtask sequences+2. **Task recording**: Systematically record all subtasks via todo tools+3. **Status tracking**: Update each subtask status in real time+4. **Dynamic adjustment**: Let users insert, modify, or cancel tasks anytime++**Tool support**++JiuwenSwarm provides a complete todo toolkit (`TodoToolkit`). Tasks are persisted as Markdown in `workspace/session/{session_id}/todo.md`, isolated by session with concurrency-safe read/write.++| Tool | Description |+| :--- | :--- |+| `todo_create` | Create the initial todo list |+| `todo_insert` | Insert a new task at a specified position |+| `todo_complete` | Mark a task as completed |+| `todo_remove` | Remove a specified task |+| `todo_list` | List all current todo items |++**Task states**++| State | Description |+| :--- | :--- |+| `waiting` | Pending execution |+| `running` | In progress |+| `completed` | Completed |+| `cancelled` | Cancelled |diff --git a/docs/en/SUMMARY.md b/docs/en/SUMMARY.mdindex 8bd4c9575c..7bb61d3e5b 100644--- a/docs/en/SUMMARY.md+++ b/docs/en/SUMMARY.md@@ -12,6 +12,7 @@- [Multi-Instance](MultiInstance.md)- [Auto Harness Feature Overview](AutoHarness.md)- [User guide](README.md)+ - [Conversation](Conversation.md)- [Channels](Channels.md)- [Discord](Discord.md)- [WhatsApp](WhatsApp.md)diff --git a/docs/zh/SUMMARY.md b/docs/zh/SUMMARY.mdindex 55652841c9..c7518dfdce 100644--- a/docs/zh/SUMMARY.md+++ b/docs/zh/SUMMARY.md@@ -14,6 +14,7 @@- [Auto Harness 特性说明](AutoHarness.md)- [单机多实例运行](单机多实例运行.md)- [使用指南](README.md)+ - [对话](对话.md)- [频道](频道.md)- [Discord](Discord.md)- [WhatsApp(中文)](whatsapp.md)diff --git "a/docs/zh/\345\257\271\350\257\235.md" "b/docs/zh/\345\257\271\350\257\235.md"new file mode 100644index 0000000000..6c31747117--- /dev/null+++ "b/docs/zh/\345\257\271\350\257\235.md"@@ -0,0 +1,610 @@+# 对话++对话是 JiuwenSwarm 最常用的使用入口,不只是聊天,而是接收任务并执行任务的主要入口。在这里,您可以提问、下达任务、补充要求、查看执行过程和结果。++---++## 1. 对话入门++### 1.1 对话简介++**对话页的定位**++对话页是 JiuwenSwarm 的核心交互界面,它不仅仅是一个聊天窗口,而是一个**任务接收与执行的工作台**。通过对话,您可以:++- **提问咨询**:获取信息、解答疑问+- **下达任务**:让智能体执行具体操作+- **补充要求**:在执行过程中动态调整+- **查看进度**:实时了解任务执行状态和结果++++**核心能力**++| 能力 | 说明 |+|:---|:---|+| **自然语言理解** | 用日常语言描述需求,无需记忆复杂指令 |+| **任务规划** | 复杂任务自动拆解为可执行的子任务序列 |+| **动态调整** | 执行过程中可随时插入新需求或修改计划 |+| **工具编排** | 自动选择和组合合适的工具完成任务 |+| **结果反馈** | 清晰展示执行过程和最终结果 |++---++### 1.2 如何开始对话++**基本操作流程**++1. **输入需求**:在输入框中描述您的需求或任务+2. **发送消息**:点击发送或按 Enter 键+3. **查看回复**:智能体会理解您的需求并开始执行+4. **继续补充**:根据执行结果,可以继续补充要求或调整方向++++**需求描述建议**++为了获得更好的执行效果,建议在描述需求时包含以下要素:++| 要素 | 说明 | 示例 |+|:---|:---|:---|+| **目标** | 明确要达成什么 | "生成 API 文档" |+| **范围** | 指定作用范围 | "针对 src/api 目录下的所有接口" |+| **限制条件** | 特殊要求或约束 | "使用中文,格式为 Markdown" |+| **输出形式** | 期望的结果形式 | "输出到 docs/api.md 文件" |++**提问示例对比**++| 推荐写法 ✅ | 不够清晰 ❌ |+|:---|:---|+| "帮我整理 `docs/zh` 目录下的所有 Markdown 文档,检查标题层级、修复格式问题,并生成一份修改清单" | "整理文档" |+| "分析 `src/core` 目录的代码结构,生成架构图并输出为 PNG 格式,保存到 `docs/architecture.png`" | "分析代码" |+| "将 `README.md` 翻译成英文,保持原有格式,输出到 `README_EN.md`" | "翻译 README" |++**首次使用建议**++- 从**目标明确的小任务**开始,逐步熟悉智能体的能力+- 如果第一次结果不符合预期,可以**继续补充要求**,而不是重新开始+- 善用**追问和细化**,帮助智能体更好地理解您的需求++---++### 1.3 对话中的常见操作++在对话过程中,您可以随时进行以下操作来调整任务执行:++**动态调整操作**++| 操作 | 说明 | 使用场景 |+|:---|:---|:---|+| **补充要求** | 对当前正在执行的任务追加细节或修改方向 | 发现遗漏细节、需要调整输出格式或约束条件 |+| **插入新任务** | 在任务队列中插入一个全新的独立任务 | 有更高优先级的独立需求出现 |+| **打断任务** | 中断当前正在执行的任务 | 需要停止或改变当前任务方向 |+| **调整优先级** | 改变待执行任务的顺序 | 重新安排执行顺序 |+| **结束任务** | 标记某个任务为已完成或取消 | 任务不再需要执行 |+| **查看状态** | 查看当前任务列表和执行进度 | 了解整体进展 |++> **补充要求 vs 插入新任务**:补充要求是对**已有任务**的细化或扩展(如"报表也加上图表"),插入新任务则是添加一个**全新的独立任务**(如"顺便帮我翻译另一份文档")。++**核心特性:边聊边调整**++JiuwenSwarm 的对话系统支持**实时动态调整**。当您在智能体执行任务过程中输入新需求时,系统会:++1. **理解新需求**:解析您的补充内容+2. **评估影响**:判断对当前任务的影响+3. **重新规划**:将新需求融入任务队列+4. **继续执行**:按照新的计划推进++**案例:动态调整全流程演示**++以下案例串联了常见的动态调整操作,展示从任务规划到执行、调整、查看的完整过程:++**步骤一:下达任务**++```+用户:处理 12 月的发票数据,生成汇总报表。先生成待办列表++智能体:任务列表:+ [1] 获取12月发票数据文件 🔄 进行中+ [2] 读取并解析发票数据 ⏳ 待执行+ [3] 数据清洗与校验 ⏳ 待执行+ [4] 生成汇总报表 ⏳ 待执行+ [5] 输出报表文件 ⏳ 待执行++▶ 开始执行任务 [1]...+```++++**步骤二:插入新任务**++```+用户:对了,1 月的发票也要处理,两份合并后发邮件给财务++智能体:任务列表更新:+ [1] 获取12月和1月发票数据文件 🔄 进行中+ [2] 读取并解析12月和1月发票数据 ⏳ 待执行+ [3] 数据清洗与校验(12月+1月) ⏳ 待执行+ [4] 合并数据并生成汇总报表 ⏳ 待执行+ [5] 导出报表文件并发邮件给财务 ⏳ 待执行++▶ 继续执行...+```++++++---++## 2. 执行模式++### 2.1 模式概览++JiuwenSwarm 支持多种执行模式,不同模式适用于不同的场景。您可以根据任务特点选择合适的模式。++++**模式对比**++| 模式 | 运行方式 | 适用场景 | 特点 |+|:---|:---|:---|:---|+| **任务规划** | 将需求分解为具体任务步骤,按计划执行 | 复杂任务、多步骤任务、需要跟踪进度 | 过程清晰可控,支持动态调整 |+| **性能模式** | 根据需求灵活处理,支持并行任务 | 目标明确、希望快速得到结果 | 响应迅速,效率优先 |+| **集群模式** | 多智能体协作执行 | 大规模任务、需要专业分工 | 能力互补,协同处理 |++**模式切换**++您可以通过以下方式切换执行模式:++- **界面切换**:在对话页面下方选择执行模式+- **命令切换**:使用 `/mode` 或 `/switch` 命令(详见[命令行指令](#3-命令行指令))++---++### 2.2 任务规划模式++#### 2.2.1 概念科普++**什么是任务规划?**++任务规划是 JiuwenSwarm 的一项核心能力,它赋予智能体**结构化的任务拆解与动态管理能力**。当您提出复杂或多步骤的请求时,智能体会自动将其解析为一系列可执行的子任务,并通过内置的待办工具进行系统性记录和追踪。++**核心价值**++| 能力 | 说明 |+|:---|:---|+| **动态拆解** | 复杂请求自动分解为可执行的子任务序列 |+| **实时追踪** | 每完成一个子任务,状态实时更新,进度清晰可控 |+| **灵活干预** | 支持用户中途追加需求、插入紧急事项,不打断整体流程 |+| **目标保持** | 有效解决长周期任务中的目标丢失与执行断层问题 |++**适用场景**++- 步骤较多、需要分阶段完成的任务+- 任务中途可能发生变化或调整+- 希望过程清晰可跟踪的任务+- 需要确认每个阶段结果的任务++++---++### 2.3 性能模式++#### 2.3.1 概念科普++**什么是性能模式?**++性能模式(Fast Mode)是 JiuwenSwarm 针对简单、明确任务优化的执行模式。在此模式下,智能体会:++- **快速响应**:减少规划环节,直接执行+- **并行处理**:多个独立任务可同时执行+- **效率优先**:以最快速度完成任务++**适用场景**++- 目标明确、步骤清晰的任务+- 希望尽快得到结果的任务+- 对过程拆解要求不高的任务+- 多个简单任务需要批量处理++#### 2.3.2 案例实践++**案例:批量文档改写**++```+用户:将以下两段技术文档改写为更适合新手阅读的版本:+1. docs/api.md+2. docs/architecture.md++智能体:🔍 正在并行处理文档...++ 已完成改写!两份新手版文档已保存++ 原文件 新手版文件+ 上下文压缩卸载.md 上下文压缩卸载_新手版.md+ 心跳.md 心跳_新手版.md++ 🎉 两份新手版文档都保存在原文件同目录下,需要我帮你做其他调整吗?+```++++---++### 2.4 集群模式++#### 2.4.1 概念科普++**什么是集群模式?**++集群模式(Team Mode)是 JiuwenSwarm 的多智能体协作模式。在此模式下,多个专业智能体协同工作,各自负责擅长的领域,共同完成复杂任务。++**核心特点**++- **专业分工**:不同智能体负责不同领域+- **协同处理**:智能体之间可以通信协作+- **能力互补**:组合多种专业能力+- **结果整合**:汇总各智能体的输出++**适用场景**++- 大规模、多领域的复杂任务+- 需要多种专业技能的任务+- 单一智能体难以完成的任务++#### 2.4.2 案例实践++**案例:全栈项目开发**++```+用户:开发一个用户管理系统,包括前端界面、后端 API 和数据库设计++智能体:🤖 启动集群模式,分配任务:+[team_leader] 我来帮你开发一个用户管理系统。在开始之前,我需要确认几个关键信息以确保方案符合你的需求...++用户:使用默认方案++智能体:+[team_leader] ✅ 团队已组建并启动!+[frontend-dev] 收到!我已查看任务板+[backend-dev] 收到项目启动通知!+[qa-engineer] 收到项目启动通知!++```++下文截取若干界面,大致按对话推进顺序排列。++1. **对齐需求**+ Team Leader 在集群启动前与用户确认需求与关键信息的对话界面。++++2. **认领与并行启动**+ 子任务拆分后,各角色智能体认领工作、并行启动时的对话与状态展示。++++3. **协作推进**+ 多智能体持续协作、同步进展的对话界面(具体布局以实际产品为准)。++++4. **工作区产物路径**+ 任务执行后在 `workspace` 中落地的目录与关键文件路径示例。++++5. **前端展示**+ 输出的用户管理系统前端页面示例。++++> **提示**:集群模式下的案例展示了多智能体协作的基本流程。实际使用中,请根据项目需求验证集群模式是否能完整交付您的工程目标。++---++## 3. 命令行指令++### 3.1 指令概览++JiuwenSwarm 支持通过「特殊前缀指令」控制会话和模式。这些指令在消息到达智能体之前就被系统识别并处理,**不需要智能体来执行**,而是直接改变系统的运行状态(比如切换模式或创建新会话)。++> **所有命令行指令都可以直接在对话框中输入即可**,无需使用命令行终端。只需在聊天输入框中输入以 `/` 开头的指令,系统会自动识别并执行。++> **重要:指令的生效范围取决于通道类型**。部分指令仅在特定通道中由系统拦截并执行,在其他通道中可能被当作普通消息转发给智能体。详见下方「通道适用范围」说明。++**通道适用范围**++JiuwenSwarm 的指令按处理层级分为两类:++| 层级 | 处理方 | 适用通道 | 说明 |+| :--- | :--- | :--- | :--- |+| **Gateway 拦截** | 网关层 | 飞书、钉钉、企微、微信、WhatsApp、小艺 | 指令在网关层被拦截,不转发给智能体,直接改变系统状态 |+| **客户端处理** | 客户端侧 | TUI(终端) | 指令由 TUI 客户端本地处理,通过 `session.create` 等请求与 AgentServer 协同完成状态变更 |+| **不拦截** | — | Web 对话页 | 指令不会被系统拦截,而是作为普通消息转发给智能体,由智能体自行理解和响应 |++> **Web 对话页**:以 `/` 开头的指令不会被网关拦截,会当作普通消息发给智能体,**不会让会话或模式真实切换**。要在 Web 里开新对话、换模式等,请用页面上的按钮或菜单(如「新建对话」、模式选择器);需要靠指令精确控制时,请使用 IM 受控通道或 TUI。++**一级模式与二级模式说明**++JiuwenSwarm 的执行模式分为两层:++- **一级模式**:决定智能体的整体工作方式,如智能体模式(`agent`)、代码模式(`code`)、团队协作模式(`team`)+- **二级模式**:在一级模式下的细化执行策略,如规划模式(`plan`)会先拆解任务再执行,快速模式(`fast`)则直接执行++> **注意**:并非所有一级模式都有二级模式。目前 `agent` 和 `code` 模式支持二级模式(`plan`/`fast`/`normal`),而 `team` 模式暂不支持二级模式切换。使用 `/mode` 可以直接指定一级+二级组合(如 `/mode agent.plan`),使用 `/switch` 则只切换当前一级模式下的二级模式。++**指令分类**++| 类型 | 指令 | 说明 | 适用通道 |+| :--- | :--- | :--- | :--- |+| **会话控制** | `/new_session` | 创建新会话 | IM 受控通道 |+| **模式切换** | `/mode` | 切换一级模式(也可指定一级+二级组合) | IM 受控通道 |+| **模式切换** | `/switch` | 切换二级模式(在当前一级模式下切换) | IM 受控通道 |+| **技能管理** | `/skills list` | 列出可用技能 | IM 受控通道 |+| **工作区** | `/workspace_dir` | 设置工作区路径 | TUI |+| **会话重置** | `/clear`(别名 `/new`、`/reset`) | 清空对话历史并创建新会话 | TUI |++**使用建议**++- **自然语言优先**:大多数情况下,直接用自然语言描述需求即可+- **命令行辅助**:在需要快速切换或精确控制时使用命令+- **避免混用**:同一消息中不要同时包含命令和自然语言+- **注意通道**:确认您使用的通道支持该指令,否则指令只会被当作普通消息处理++---++### 3.2 常用指令详解++#### `/new_session` —— 新建会话++**作用**++可以把它理解成:**在当前通道里开一段新的空白对话**。新对话里**没有**上一段会话的聊天历史,智能体只按新会话继续聊。上一段会话里的记录**不会因此被删掉**,仍保留在系统里,需要时可以通过历史或会话列表等方式**自行找回、恢复**。++在 IM 等受支持通道里,系统会先切到新的 `session_id` 再处理后续消息,并取消旧会话上仍在跑的任务。工作区里 `workspace/session/` 下的会话目录通常会在**首次产生待办、保存文件等写入**时按需创建,而不必在意「是否在输入指令的那一瞬就立刻建文件夹」。++**适用通道**++| 通道 | 说明 |+| :--- | :--- |+| **IM 受控通道**(飞书、钉钉、企微、微信、WhatsApp、小艺) | ✅ 可用:网关拦截后新建会话上下文,后续消息走新会话 |+| **TUI(终端)** | 终端**没有**网关里的 `/new_session`,请用 **`/clear`**(与 **`/reset`、`/new`** 同上表)新开空白会话 |+| **Web 对话页** | ❌ **勿用指令**:`/new_session` 不会真正生效,请用页面上的「新建对话」等控件 |++**使用方式**++IM 受控通道里单独发送一行:**整行必须恰好为 `/new_session`,不能带后缀参数。**++```+/new_session+```++终端 TUI **没有这一条网关指令**。要在 TUI 新开空白会话,请发送 **`/clear`**(与 **`/reset`、`/new`** 等价,由同一内置指令处理)。++**IM 受控通道的实际处理**(网关:先识别控制指令再更新会话)++- **不**把该消息交给智能体解析。+- 为当前通道轮换新的 `session_id` 并写入状态;对**旧会话**在网关与 AgentServer 侧发起取消(含进行中的任务)。+- 向会话回一条固定通知:`[收到 CLI 指令], session_id 已变更为 <new_sid>`。+- IM 聊天窗口里仍可看到**此前**的消息;**从下一条你发出的消息开始**,走新 `session_id`,智能体侧按新会话上下文处理。++**TUI:`/clear` 的实际处理**++- 若当前没有在跑任务:生成新 `session_id` 并尝试 `session.create`;切换当前会话并**清空终端里本会话的消息列表**,再拉取新会话历史,并显示:`Started a fresh conversation in <session_id>`。++**workspace/session/ 示意(按需落盘)**++```+workspace/session/+ feishu_17f2b4b32e0_ab12cd/ ← 新会话目录(有写入时再出现即可)+ todo.md ← 待办等事项(首次写入时生成)+```++**注意事项**++- 旧会话的数据与历史仍然保留,与「新开一段空白上下文」可以同时成立+- 在 IM 受控通道中,`/new_session` 会取消旧会话上正在执行的任务(含网关与 AgentServer 侧)+- 指令须**单独一行且完全匹配** `/new_session`;写成 `/new_session xxx` 等会被视为无效++---++#### `/mode` —— 切换一级模式++**作用**++为当前通道设置一级执行模式,影响 Agent 的行为策略。也可以直接指定一级+二级组合。++**适用通道**++| 通道 | 处理方式 | 实际效果 |+| :--- | :--- | :--- |+| **IM 受控通道**(飞书、钉钉、企微、微信、WhatsApp、小艺) | Gateway 拦截 → 更新 channel 状态 → 取消旧任务 → 不转发给智能体 | ✅ 真正切换模式 |+| **TUI(终端)** | 客户端侧处理 | ✅ 真正切换模式 |+| **Web 对话页** | Gateway **不拦截** → 当作普通消息转发给智能体 | ❌ 不会真正切换模式 |++**支持的模式**++| 模式 | 说明 |+| :--- | :--- |+| `agent` | 智能体模式(默认) |+| `code` | 代码模式 |+| `team` | 团队协作模式 |+| `agent.plan` | 智能体模式 + 规划二级模式 |+| `agent.fast` | 智能体模式 + 快速二级模式 |+| `code.plan` | 代码模式 + 规划二级模式 |+| `code.normal` | 代码模式 + 普通二级模式 |++> `/mode agent.plan` 和先 `/mode agent` 再 `/switch plan` 效果相同,前者更简洁。++**使用方式**++**模板**:`/mode` + `<模式字段>`++`<模式字段>` 可以是一级模式名(如 `agent`、`code`、`team`),也可以是一级与二级用 `.` 连接的组合(与上表「支持的模式」一致)。++**示例**:切换到智能体模式并指定二级「快速」:++```+/mode agent.fast+```++**系统响应**++```+mode 已变更为 agent.fast+```++---++#### `/switch` —— 切换二级模式++**作用**++在当前一级模式下,切换二级执行策略。仅对支持二级模式的一级模式有效(目前 `agent` 和 `code` 支持,`team` 暂不支持)。++**适用通道**++与 `/mode` 相同,仅在 IM 受控通道和 TUI 中真正生效,在 Web 对话页中作为普通消息处理。++**支持的模式**++| 模式 | 说明 |+| :--- | :--- |+| `plan` | 规划模式 —— 先拆解任务再逐步执行 |+| `fast` | 快速模式 —— 减少规划,直接执行 |+| `normal` | 普通模式 —— 默认执行策略 |++**使用方式**++```+/switch plan+/switch fast+/switch normal+```++---++#### `/skills list` —— 列出技能++**作用**++列出当前可用的所有技能。++**适用通道**++| 通道 | 处理方式 | 实际效果 |+| :--- | :--- | :--- |+| **IM 受控通道**(飞书、钉钉、企微、微信、WhatsApp、小艺) | Gateway 拦截 → 调用 `skills.list` → 以通知回复 | ✅ 真正列出技能 |+| **TUI(终端)** | 客户端侧处理 | ✅ 真正列出技能 |+| **Web 对话页** | Gateway **不拦截** → 当作普通消息转发给智能体 | ❌ 智能体以自然语言回复,可能不准确 |++**使用方式**++```+/skills list+```++**系统响应**++```+【技能列表】+1. document-writer (skillnet)+ 文档写作与优化+2. code-analyzer (skillnet)+ 代码分析与重构+3. data-processor (clawhub)+ 数据处理与转换+...+```++---++#### `/workspace_dir` —— 设置工作区路径(TUI 专用)++**作用**++设置终端 UI 的工作区路径,用于出站请求。此指令仅在 TUI 中可用。++**适用通道**++仅 TUI(终端)客户端支持,其他通道不可用。++**使用方式**++```+/workspace_dir get # 查看当前路径+/workspace_dir set C:\Projects # 设置路径+/workspace_dir clear # 清除路径+```++**持久化**++存储在 `~/.jiuwenswarm/tui-workspace-dir` 文件中。++📢更详细的指令详见:[Slash 命令速查表](Slash命令表.md)。++---++## 4. 对话逻辑++### 4.1 执行流程++JiuwenSwarm 在对话背后的基本逻辑:++```+用户输入 → 意图理解 → 模式判断 → 任务处理 → 结果反馈+```++**详细流程**++1. **意图理解**:解析用户自然语言,识别真实需求+2. **模式判断**:根据任务特点和当前模式,决定执行策略+3. **任务处理**:+ - **任务规划模式**:拆解为子任务,按计划执行+ - **性能模式**:快速执行,支持并行+ - **集群模式**:分配给多个智能体协同执行+4. **结果反馈**:以清晰的方式向用户呈现执行结果++### 4.2 动态调整机制++JiuwenSwarm 支持在执行过程中根据用户新输入重新规划任务列表:++- **实时监听**:持续接收用户的新输入+- **影响评估**:判断新需求对当前任务的影响+- **智能合并**:将新需求合理融入任务队列+- **无缝衔接**:保证执行流程的连贯性++### 4.3 任务规划机制详解++**核心机制**++任务规划模式的核心逻辑:++1. **需求解析**:将用户请求解析为可执行的子任务序列+2. **任务记录**:通过待办工具系统性记录所有子任务+3. **状态追踪**:实时更新每个子任务的执行状态+4. **动态调整**:支持用户随时插入、修改或取消任务++**工具赋能**++JiuwenSwarm 提供了完整的待办事项工具包(`TodoToolkit`),任务以 Markdown 形式持久化至 `workspace/session/{session_id}/todo.md`,按会话隔离,支持并发安全读写。++| 工具 | 说明 |+| :--- | :--- |+| `todo_create` | 创建初始待办清单 |+| `todo_insert` | 在指定位置插入新任务 |+| `todo_complete` | 标记任务为已完成 |+| `todo_remove` | 删除指定任务 |+| `todo_list` | 列出当前所有待办事项 |++**任务状态**++| 状态 | 说明 |+| :--- | :--- |+| `waiting` | 待执行 |+| `running` | 执行中 |+| `completed` | 已完成 |+| `cancelled` | 已取消 |\ No newline at end of file