Skip to content

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

doc: 刷新v0.1.11文档

cycong_1ca8359769b0b
diff --git a/OPEN_SOURCE_SOFTWARE_NOTICE.md b/OPEN_SOURCE_SOFTWARE_NOTICE.md
index 18ecd8ec81..8d07b56e88 100644
--- a/OPEN_SOURCE_SOFTWARE_NOTICE.md
+++ b/OPEN_SOURCE_SOFTWARE_NOTICE.md
@@ -126,4 +126,4 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
---
-*This notice is generated for the JiuwenBot project. The list of software and versions may vary with the actual installation. You may regenerate the dependency list using `pip install pip-licenses; pip-licenses` from the project environment.*
\ No newline at end of file
+*This notice is generated for the JiuwenClaw project. The list of software and versions may vary with the actual installation. You may regenerate the dependency list using `pip install pip-licenses; pip-licenses` from the project environment.*
\ No newline at end of file
diff --git a/README.md b/README.md
index 05ae76a069..dcd5848465 100644
--- a/README.md
+++ b/README.md
@@ -40,9 +40,7 @@ When you express dissatisfaction or an error occurs, JiuwenClaw automatically re
## ⚠️ Version Upgrade Notice
-**If you're upgrading from an earlier version to v0.1.7:**
-
-Due to breaking changes in this release, you **must** reinitialize JiuwenClaw after upgrading. The service will fail to start without reinitialization.
+If you're upgrading from an older version, check the changelog for any breaking changes. You **must** reinitialize JiuwenClaw if a breaking change is indicated. The service will fail to start without reinitialization.
### Backup Before Upgrading
@@ -104,22 +102,38 @@ Set up heartbeat tasks with your to-do items, and JiuwenClaw will wake up on sch
## 📚 Documentation
-| Document | Description |
+| Document | Description |
| :--------------------------------------------------- | :------------------------------------------------------- |
-| [📖 Quick Start](docs/en/Quickstart.md) | Get up and running with JiuwenClaw in 5 minutes |
-| [📖 Quick Start(TUI)](docs/en/Quickstart_tui.md) | Get up and running with JiuwenClaw-tui in 5 minutes |
-| [⚙️ Configuration & Workspace](docs/en/Configuration.md) | Environment setup and workspace management |
-| [📁 Workspace Structure](docs/en/Agent.md) | workspace directory layout, presets, and dynamic content |
-| [🛠️ Skill System](docs/en/Skills.md) | Guide to developing custom skills |
-| [📱 Channel Configuration](docs/en/Channels.md) | Integrating Feishu, Xiaoyi, and other channels |
-| [⌨️ CLI Commands](docs/en/CLI.md) | Command-line tool usage guide |
-| [⏰ Scheduled Tasks](docs/en/ScheduledTasks.md) | Scheduled task management |
-| [🧠 Memory](docs/en/Memory.md) | Intelligent memory and learning capabilities |
-| [🌐 Browser Automation](docs/en/Browser.md) | Web browsing and automation features |
-| [📋 Task Planning](docs/en/TaskPlanning.md) | Chat behavior and task flow |
-| [🔄 Skill Self-Evolution](docs/en/SkillSelfEvolution.md) | Mechanism for automatic skill evolution |
-| [📦 Context Compression](docs/en/ContextCompression.md) | Context compression and unloading |
-| [🚀 Development Practices](docs/en/development-practices/README.md) | Development practices and experience sharing |
+| [📖 Quick Start](docs/en/Quickstart.md) | Get up and running with JiuwenClaw in 5 minutes |
+| [📖 Quick Start (TUI)](docs/en/Quickstart_tui.md) | Get up and running with JiuwenClaw-tui in 5 minutes |
+| [⚙️ Configuration & Workspace](docs/en/Configuration.md) | Environment setup and workspace management |
+| [📁 Workspace Structure](docs/en/Agent.md) | workspace directory layout, presets, and dynamic content |
+| [🔄 Modes](docs/en/Modes.md) | PLAN / AGENT / CODE / TEAM mode switching and configuration |
+| [🛠️ Skill System](docs/en/Skills.md) | Guide to developing custom skills |
+| [🔄 Skill Self-Evolution](docs/en/SkillSelfEvolution.md) | Mechanism for automatic skill evolution |
+| [📱 Channel Configuration](docs/en/Channels.md) | Integrating Feishu, Xiaoyi, and other channels |
+| [💬 Discord](docs/en/Discord.md) | Discord channel setup and usage |
+| [💬 WhatsApp](docs/en/WhatsApp.md) | WhatsApp channel setup and usage |
+| [⌨️ CLI Commands](docs/en/CLI.md) | Command-line tool usage guide |
+| [⏰ Scheduled Tasks](docs/en/ScheduledTasks.md) | Scheduled task management |
+| [💓 Heartbeat](docs/en/Heartbeat.md) | Heartbeat mechanism and configuration |
+| [🧠 Memory](docs/en/Memory.md) | Intelligent memory and learning capabilities |
+| [💡 Task Memory](docs/en/TaskMemory.md) | Task-level experience retrieval and consolidation |
+| [📦 Context Compression](docs/en/ContextCompression.md) | Context compression and unloading |
+| [💻 Coding Memory](docs/en/CodingMemory.md) | Code-mode-specific memory system |
+| [📋 Task Planning](docs/en/TaskPlanning.md) | Chat behavior and task flow |
+| [🌐 Browser Automation](docs/en/Browser.md) | Web browsing and automation features |
+| [🔌 MCP Configuration](docs/en/MCPConfiguration.md) | MCP server integration and configuration |
+| [🔒 Tool Permissions & Security](docs/en/ToolPermissionsSecurity.md) | Permission model and security configuration |
+| [📝 Slash Commands](docs/en/SlashCommands.md) | Slash command reference |
+| [🏗️ Slash Command Architecture](docs/en/SlashCommandArchitecture.md) | Slash command internals and extension guide |
+| [📨 E2A Protocol](docs/en/E2A-protocol.md) | Gateway ↔ Agent request envelope specification |
+| [🤝 A2A Integration](docs/en/A2A.md) | A2A protocol integration guide |
+| [🔌 ACP Client Config](docs/en/ACP_Client_Config.md) | ACP client plugin configuration |
+| [👥 Distributed Team](docs/en/DistributedTeam.md) | Multi-process distributed team mode |
+| [🔀 Multi-Instance Operation](docs/en/MultiInstance.md) | Running multiple independent instances on one machine |
+| [📦 Packaging Desktop App](docs/en/PackExeGuide.md) | Build standalone desktop executables |
+| [🚀 Development Practices](docs/en/development-practices/README.md) | Development practices and experience sharing |
## 🤝 Contributing
diff --git a/README_CN.md b/README_CN.md
index 67fe47cd68..846ff48303 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -37,9 +37,7 @@
## ⚠️ 版本升级提醒
-**如果您从旧版本升级到 v0.1.7:**
-
-由于本版本包含重大变更,升级后**必须**重新初始化 JiuwenClaw,否则服务将无法启动。
+如果您从旧版本升级,请查看更新日志确认是否有重大变更。如有重大变更,升级后**必须**重新初始化 JiuwenClaw,否则服务将无法启动。
### 升级前备份数据
@@ -144,22 +142,38 @@ jiuwenclaw-tui
## 📚 文档导航
-| 文档 | 核心内容 |
-|:------------------------------------|:-------------------------|
-| [📖 快速开始](docs/zh/Quickstart.md) | 5分钟上手JiuwenClaw |
-| [📖 快速开始(TUI)](docs/zh/Quickstart_tui.md) | 5分钟上手JiuwenClaw-tui |
-| [⚙️ 配置与工作空间](docs/zh/配置信息.md) | 环境配置与工作区管理 |
-| [📁 工作区结构](docs/zh/智能体.md) | workspace 目录说明,预置与动态生成内容 |
-| [🛠️ 技能系统](docs/zh/技能.md) | 自定义技能开发指南 |
-| [📱 频道配置](docs/zh/频道.md) | 飞书、小艺等频道接入 |
-| [⌨️ 命令行指令](docs/zh/命令行指令.md) | 命令行工具使用指南 |
-| [⏰ 定时任务](docs/zh/定时任务.md) | 定时任务管理 |
-| [🧠 记忆功能](docs/zh/记忆.md) | 智能记忆与学习 |
-| [🌐 浏览器相关](docs/zh/浏览器.md) | 自动化浏览功能 |
-| [📋 任务规划](docs/zh/任务规划.md) | 任务规划与待办事项 |
-| [🔄 Skill自演进](docs/zh/Skill自演进.md) | Skill自演进机制 |
-| [📦 上下文压缩](docs/zh/上下文压缩卸载.md) | 上下文压缩与卸载 |
-| [🚀 开发实践](docs/zh/开发实践/) | 开发实践与经验分享 |
+| 文档 | 核心内容 |
+|:-----|:---------|
+| [📖 快速开始](docs/zh/Quickstart.md) | 5分钟上手JiuwenClaw |
+| [📖 快速开始(TUI)](docs/zh/Quickstart_tui.md) | 5分钟上手JiuwenClaw-tui |
+| [⚙️ 配置与工作空间](docs/zh/配置信息.md) | 环境配置与工作区管理 |
+| [📁 工作区结构](docs/zh/智能体.md) | workspace 目录说明,预置与动态生成内容 |
+| [🔄 模式系统](docs/zh/模式系统.md) | PLAN / AGENT / CODE / TEAM 模式切换与配置 |
+| [🛠️ 技能系统](docs/zh/技能.md) | 自定义技能开发指南 |
+| [🔄 Skill自演进](docs/zh/Skill自演进.md) | Skill自演进机制 |
+| [📱 频道配置](docs/zh/频道.md) | 飞书、小艺等频道接入 |
+| [💬 Discord](docs/zh/Discord.md) | Discord频道配置与使用 |
+| [💬 WhatsApp](docs/zh/whatsapp.md) | WhatsApp频道配置与使用 |
+| [⌨️ 命令行指令](docs/zh/命令行指令.md) | 命令行工具使用指南 |
+| [⏰ 定时任务](docs/zh/定时任务.md) | 定时任务管理 |
+| [💓 心跳](docs/zh/心跳.md) | 心跳机制与配置 |
+| [🧠 记忆功能](docs/zh/记忆.md) | 智能记忆与学习 |
+| [💡 经验记忆](docs/zh/经验记忆.md) | 任务级经验检索与沉淀 |
+| [📦 上下文压缩](docs/zh/上下文压缩卸载.md) | 上下文压缩与卸载 |
+| [💻 编码记忆](docs/zh/编码记忆.md) | Code模式专属记忆系统 |
+| [📋 任务规划](docs/zh/任务规划.md) | 任务规划与待办事项 |
+| [🌐 浏览器相关](docs/zh/浏览器.md) | 自动化浏览功能 |
+| [🔌 MCP配置](docs/zh/MCP配置.md) | MCP服务接入与配置 |
+| [🔒 工具权限与安全](docs/zh/工具权限与安全防护.md) | 权限模型与安全配置 |
+| [📝 Slash命令](docs/zh/Slash命令表.md) | Slash命令速查 |
+| [🏗️ Slash命令架构](docs/zh/SLASH_COMMAND_ARCHITECTURE.md) | Slash命令内部机制与扩展 |
+| [📨 E2A协议](docs/zh/E2A-protocol.md) | Gateway ↔ Agent 请求信封规范 |
+| [🤝 A2A接入](docs/zh/A2A.md) | A2A协议接入说明 |
+| [🔌 ACP插件配置](docs/zh/ACP插件使用.md) | ACP客户端插件配置 |
+| [👥 分布式Team](docs/zh/分布式Team.md) | 多进程分布式团队模式 |
+| [🔀 单机多实例](docs/zh/单机多实例运行.md) | 同一机器运行多个独立实例 |
+| [📦 打包桌面应用](docs/zh/打包exe指南.md) | 打包独立桌面可执行文件 |
+| [🚀 开发实践](docs/zh/开发实践/) | 开发实践与经验分享 |
## 🤝 参与贡献
diff --git a/docs/en/ACP_Client_Config.md b/docs/en/ACP_Client_Config.md
index e267f74dfb..3065ad4ace 100644
--- a/docs/en/ACP_Client_Config.md
+++ b/docs/en/ACP_Client_Config.md
@@ -12,15 +12,15 @@ Pre-installation Preparation
# VS Code ACP Client Setup (macOS / Linux)
1. Install the ACP Client extension from the marketplace. Search for `formulahendry.acp-client` and install it.
-![ACP](../assets/images/acp.png)
+![ACP](../assets/images/ACP插件.png)
2. In the extension, click the `+` button (`ACP: Add Agent Configuration`).
-![addAgent](../assets/images/addAgent.png)
+![addAgent](../assets/images/ACP插件添加agent.png)
3. Under `Add Acp Agent`, enter: jiuwenclaw.
-![name](../assets/images/name.png)
+![name](../assets/images/agent.png)
4. For `Agent Command`, enter the absolute path to run_gateway_acp.sh.
5. Leave `Agent Arguments` empty.
diff --git a/docs/en/Agent.md b/docs/en/Agent.md
index d9bcf46ce1..29af73c592 100644
--- a/docs/en/Agent.md
+++ b/docs/en/Agent.md
@@ -68,7 +68,7 @@ Created or updated at runtime:
## Related configuration
-- **Skill root**: `skill_base_dir` in `config/config.yaml`, default `workspace/agent/skills`.
+- **Skill root**: `skill_base_dir` in `config/config.yaml`, default `agent/skills`.
- **Memory workspace**: `workspace/agent` (`get_agent_workspace_dir()`).
- **Sessions**: `workspace/session`, one subfolder per `session_id`.
- **SkillNet usage in Claw**: see [Skills.md §5](Skills.md#5-how-skills-installed-via-skillnet-are-used-in-claw).
diff --git a/docs/en/CLI.md b/docs/en/CLI.md
index b3c0c206fe..f8f4317bee 100644
--- a/docs/en/CLI.md
+++ b/docs/en/CLI.md
@@ -3,7 +3,7 @@
JiuwenClaw supports **special prefix commands** to control sessions and modes. Common ones:
- `/new_session`: start a new `session_id` for the current channel
-- `/mode plan`, `/mode fast`, or `/mode team`: switch the channel’s working mode
+- `/mode plan`, `/mode fast`, `/mode team`, `/mode code`: switch the channel's working mode
These are handled in the Gateway **`MessageHandler`** and **are not** sent to the agent.
@@ -13,15 +13,18 @@ These are handled in the Gateway **`MessageHandler`** and **are not** sent to th
**Behavior**
-- For supported channels (`feishu` / `xiaoyi` / `dingtalk`), generates a new `session_id`, e.g.:
+- For supported channels (`feishu` / `xiaoyi` / `dingtalk` / `whatsapp` / `wecom` / `wechat`), generates a new `session_id`, e.g.:
- `feishu_<ms hex>_<random hex>`
- `xiaoyi_<ms hex>_<random hex>`
- `dingtalk_<ms hex>_<random hex>`
+ - `whatsapp_<ms hex>_<random hex>`
+ - `wecom_<ms hex>_<random hex>`
+ - `wechat_<ms hex>_<random hex>`
- Later messages on that channel use this id, so a new folder appears under `workspace/session/`.
**Usage**
-Send in the channel (Feishu / Xiaoyi / DingTalk):
+Send in a supported channel:
```text
/new_session
@@ -41,14 +44,21 @@ The Gateway will:
---
-### 2. `/mode` — channel mode (`plan` / `fast` / `team`)
+### 2. `/mode` — channel mode (`plan` / `fast` / `code` / `team`)
**Behavior**
- Sets a logical **mode** for the channel:
- `plan`: planning, explanation, decomposition (default)
- - `fast`: more hands-on execution (same internal semantics as the historical `agent` mode)
+ - `fast`: more hands-on execution
+ - `code`: code generation and execution mode (defaults to `code.normal`; use `/mode code.plan` for code planning)
- `team`: team mode
+- You can also specify sub-modes directly:
+ - `agent.plan` or `plan` → Agent Plan mode
+ - `agent.fast` or `fast` → Agent Fast mode
+ - `code.plan` → Code Plan mode
+ - `code.normal` or `code` → Code Normal mode
+ - `team` → Team mode
- Mode is passed in `params["mode"]` for prompt construction.
**Usage**
diff --git a/docs/en/Channels.md b/docs/en/Channels.md
index 3061ffa26b..3bf5a8e759 100644
--- a/docs/en/Channels.md
+++ b/docs/en/Channels.md
@@ -361,19 +361,19 @@ In JiuwenClaw **Channels → DingTalk**, enable and paste **client_id** / **clie
1. Open WeCom → **Workbench** → **Smart bot** → **Create bot** → **Manual creation**
- ![WeCom entry](../assets/images/wecom/1_企业微信创建机器人入口.png?msec=1774269205893)
+ ![WeCom entry](../assets/images/wecom/1_企业微信创建机器人入口.png)
- ![WeCom manual](../assets/images/wecom/2_创建机器人.png?msec=1774269205909)
+ ![WeCom manual](../assets/images/wecom/2_创建机器人.png)
- ![WeCom create form](../assets/images/wecom/3_手动创建.png?msec=1774269205918)
+ ![WeCom create form](../assets/images/wecom/3_手动创建.png)
2. Choose **API mode**.
- ![WeCom API mode](../assets/images/wecom/4_API模式创建.png?msec=1774269205918)
+ ![WeCom API mode](../assets/images/wecom/4_API模式创建.png)
3. Set connection to **Long connection**.
- ![WeCom long connection](../assets/images/wecom/5_选择长连接.png?msec=1774269205922)
+ ![WeCom long connection](../assets/images/wecom/5_选择长连接.png)
4. After creation, save **Bot ID** and **Secret** for JiuwenClaw.
@@ -383,23 +383,23 @@ In JiuwenClaw **Channels → DingTalk**, enable and paste **client_id** / **clie
2. Enter **bot id** and **secret**, then save.
- ![WeCom channel](../assets/images/wecom/6_频道.png?msec=1774269205907)
+ ![WeCom channel](../assets/images/wecom/6_频道.png)
- ![WeCom channel admin](../assets/images/wecom/7_频道管理.png?msec=1774269205918)
+ ![WeCom channel admin](../assets/images/wecom/7_频道管理.png)
## 3. Chat with the bot
> If you cannot find the bot: **Workbench → Smart bot → Details → Use → Send message**.
-![WeCom bot detail](../assets/images/wecom/8_机器人详情.png?msec=1774269205913)
+![WeCom bot detail](../assets/images/wecom/8_机器人详情.png)
-![WeCom bot use](../assets/images/wecom/9_使用机器人.png?msec=1774269205913)
+![WeCom bot use](../assets/images/wecom/9_使用机器人.png)
1. On PC WeCom, send a test message; a reply means success.
2. On mobile WeCom, do the same.
-![WeCom PC](../assets/images/wecom/10_客户端验证.png?msec=1774269205911)
+![WeCom PC](../assets/images/wecom/10_客户端验证.png)
![WeCom mobile](../assets/images/wecom/11_手机端验证.png)
## 4. Enable Group Digital Avatar (optional)
diff --git a/docs/en/CodingMemory.md b/docs/en/CodingMemory.md
new file mode 100644
index 0000000000..4933dd7c2a
--- /dev/null
+++ b/docs/en/CodingMemory.md
@@ -0,0 +1,88 @@
+# Coding Memory
+
+Coding Memory is a dedicated memory system for Code mode that allows the Agent to read, write, and edit persistent code context during coding tasks.
+
+---
+
+## Enabling
+
+Coding Memory is automatically enabled when switching to Code mode — no additional configuration required. Related settings are in the `modes.code` section of `config/config.yaml`:
+
+```yaml
+modes:
+ code:
+ rails:
+ - FileSystemRail
+ - SkillUseRail
+ - LspRail
+ tools:
+ - web_free_search
+ - web_fetch_webpage
+ - web_paid_search
+ - user_todos
+ embedding_config:
+ model_name: null # Empty = use global embedding config
+ base_url: null
+ api_key: null
+```
+
+---
+
+## Tools
+
+Coding Memory provides three tools, automatically registered by `CodingMemoryRail` within the subprocess:
+
+### coding_memory_read
+
+Read current coding memory content.
+
+| Parameter | Type | Description |
+|-----------|------|-------------|
+| `query` | string | Search keyword to retrieve relevant coding context |
+
+Returns matching code snippets and context descriptions.
+
+### coding_memory_write
+
+Write new code context or experience to coding memory.
+
+| Parameter | Type | Description |
+|-----------|------|-------------|
+| `content` | string | Code content or experience to write |
+| `section` | string | Category label (e.g. `architecture`, `bugfix`, `pattern`) |
+
+### coding_memory_edit
+
+Edit an existing coding memory entry.
+
+| Parameter | Type | Description |
+|-----------|------|-------------|
+| `memory_id` | string | ID of the memory entry to edit |
+| `content` | string | New content |
+| `section` | string | Optional; change the category label |
+
+---
+
+## Relationship to Other Memory Systems
+
+| Memory System | Applicable Modes | Description |
+|--------------|-----------------|-------------|
+| Built-in memory (`write_memory` / `read_memory`) | Agent mode | General conversation memory |
+| Experience memory (`experience_retrieve` / `experience_learn`) | All modes | Task-level experience retrieval and consolidation |
+| Coding memory (`coding_memory_read` / `write` / `edit`) | Code mode | Code context and coding experience |
+
+All three memory systems can coexist in Code mode.
+
+---
+
+## Storage
+
+Coding memory data is stored in the `workspace/agent/memory/` directory, sharing the storage path with built-in memory.
+
+---
+
+## See Also
+
+- [Modes](Modes.md) — Mode configuration and switching
+- [Memory](Memory.md) — Built-in memory and external memory
+- [Task Memory](TaskMemory.md) — Task-level experience retrieval
\ No newline at end of file
diff --git a/docs/en/Configuration.md b/docs/en/Configuration.md
index 925145b579..b06e780d75 100644
--- a/docs/en/Configuration.md
+++ b/docs/en/Configuration.md
@@ -26,6 +26,7 @@ These can be changed in the web app; values are written back to `.env` or config
| `video_model` | `VIDEO_MODEL_NAME` | Video processing model |
| `audio_model` | `AUDIO_MODEL_NAME` | Audio processing model |
| `vision_model` | `VISION_MODEL_NAME` | Vision model |
+| `image_gen_model` | `IMAGE_GEN_MODEL_NAME` | Image generation model |
| `jina_api_key` | `JINA_API_KEY` | Jina search API key |
| `serper_api_key` | `SERPER_API_KEY` | Serper search API key |
| `perplexity_api_key` | `PERPLEXITY_API_KEY` | Perplexity API key |
@@ -44,19 +45,150 @@ Edit **`config/config.yaml`** or **`.env`** directly; there is no UI for these.
| Path | Description |
|------|-------------|
| `react.agent_name` | Agent name, default `main_agent` |
-| `react.max_iterations` | Max iterations, default 50 |
+| `react.max_iterations` | Max iterations, default 100 |
| `react.context_engine_config.enable_reload` | Enable context reload |
| `react.evolution.enabled` | Enable online skill evolution |
-| `react.evolution.skill_base_dir` | Skill root, default `workspace/agent/skills` |
+| `react.evolution.skill_base_dir` | Skill root, default `agent/skills` |
| `tools` | Enabled tools (e.g. `todo`, `skill`) |
| `browser.remote_debugging_address` | Remote debugging address |
| `browser.remote_debugging_port` | Remote debugging port |
| `browser.user_data_dir` | Chrome user data directory |
| `browser.profile_directory` | Chrome profile directory |
+See also:
+- [Modes](Modes.md) — `modes` section configuration
+- [Tool Permissions & Security](ToolPermissionsSecurity.md) — `permissions` section configuration
+
+### 2.2 `models` section (Multi-Model Configuration)
+
+Configure multiple model profiles for different use cases (main agent, video, audio, vision, image generation).
+
+| Path | Description |
+|------|-------------|
+| `models.default.model_client_config` | Default (main) model connection: `api_base`, `api_key`, `model_name`, `client_provider`, `timeout`, `verify_ssl`, `custom_headers` |
+| `models.default.model_config_obj` | Default model generation params: `temperature`, etc. |
+| `models.video.model_client_config` | Video processing model |
+| `models.audio.model_client_config` | Audio processing model |
+| `models.vision.model_client_config` | Vision / image understanding model |
+| `models.image_gen.model_client_config` | Image generation model |
+| `models.image_gen.model_config_obj` | Image generation params: `temperature`, etc. |
+
+Each sub-model section supports the same `model_client_config` keys: `api_base`, `api_key`, `model_name`, `client_provider`, `timeout`, `verify_ssl`. Environment variable substitution (e.g. `${VIDEO_API_BASE}`) is used throughout.
+
+### 2.3 memory.external section (External Memory)
+
+| Path | Description |
+|------|-------------|
+| `memory.engine` | Engine switch: `builtin` \| `external` \| `both` \| `none` |
+| `memory.external.provider` | Provider name: `openjiuwen` \| `mem0` \| `openviking` \| `<plugin>` |
+| `memory.external.user_id` | Data isolation identifier |
+| `memory.external.scope_id` | Scope identifier |
+
+See [Memory](Memory.md) for details.
+
+### 2.4 team.runtime section (Distributed Team)
+
+| Path | Description |
+|------|-------------|
+| `team.runtime.mode` | Runtime mode: `local` \| `distributed` |
+| `team.runtime.role` | Process role: `leader` \| `teammate` |
+| `team.runtime.member_name` | Teammate name identifier |
+| `team.teammate_mode` | Teammate build method: `build_mode` |
+| `team.spawn_mode` | Teammate process mode: `inprocess` |
+
+See [Distributed Team](DistributedTeam.md) for details.
+
+### 2.5 task_memory section (Experience Memory)
+
+| Path | Description |
+|------|-------------|
+| `task_memory.enabled` | Enable experience memory tools, default `true` |
+| `task_memory.llm_model` | LLM model for experience memory (empty = main model) |
+| `task_memory.embedding_model` | Embedding model for experience memory |
+| `task_memory.api_key` | API key for experience memory (empty = main key) |
+| `task_memory.api_base` | API base URL for experience memory (empty = main base) |
+
+When enabled, the agent gains `experience_retrieve`, `experience_learn`, and `experience_clear` tools. Available retrieval algorithms: `ACE`, `ReasoningBank`, `ReMe`.
+
+### 2.6 email_settings section (Email)
+
+| Path | Description |
+|------|-------------|
+| `email_settings.email_address` | Sender email address |
+| `email_settings.token` | Email authorization code |
+| `email_settings.smtp_server` | SMTP server, default `smtp.gmail.com` |
+| `email_settings.port` | SMTP port, default `587` |
+
+### 2.7 extensions section (Extension Packages)
+
+| Path | Description |
+|------|-------------|
+| `extensions.extension_dirs` | Extension search directories, semicolon-separated (e.g. `E:/a;D:/b`), maps to env var `EXTENSION_DIRS` |
+
+### 2.8 mcp section (MCP Servers)
+
+| Path | Description |
+|------|-------------|
+| `mcp.servers` | MCP server list; each entry includes `name`, `enabled`, `transport` (`stdio`/`sse`/`streamable-http`), `command`, `args`, `url`, etc. |
+
+Browser MCP runtime is configured via environment variables (see below).
+
+### 2.9 updater section (Auto-Update)
+
+| Path | Description |
+|------|-------------|
+| `updater.enabled` | Enable auto-update, default `true` |
+| `updater.repo_owner` | GitHub repository owner |
+| `updater.repo_name` | GitHub repository name |
+| `updater.asset_name_pattern` | Release asset name pattern |
+| `updater.timeout_seconds` | Update check timeout, default `20` |
+
---
-### 2.2 Environment-only fields
+### 2.10 gateway section (Gateway Routing)
+
+| Key | Type | Default | Description |
+|-----|------|---------|-------------|
+| `gateway.session_map_scope` | string | `per_chat_bot` | SessionMap scope: `per_chat_bot` (shared session per chat+bot) or `per_chat_bot_user` (session per user). Enterprise channels only (e.g. Feishu Enterprise). |
+
+### 2.11 logging section (Logging)
+
+| Key | Type | Default | Description |
+|-----|------|---------|-------------|
+| `logging.level` | string | `INFO` | Global log level |
+| `logging.console_level` | string | `INFO` | Console log level |
+| `logging.gateway` | string | `INFO` | Gateway module log level |
+
+Log files are stored in `~/.jiuwenclaw/agent/.logs/`, split into `gateway.log`, `channel.log`, `agent_server.log`; `full.log` is the aggregate.
+
+### 2.12 telemetry section (OpenTelemetry)
+
+| Key | Type | Default | Description |
+|-----|------|---------|-------------|
+| `telemetry.enabled` | bool | `false` | Master switch (env var `OTEL_ENABLED` takes priority) |
+| `telemetry.exporter` | string | `otlp` | Exporter type: `otlp` / `console` / `none` |
+| `telemetry.endpoint` | string | `http://localhost:4317` | OTLP endpoint |
+| `telemetry.protocol` | string | `grpc` | Transport protocol: `grpc` / `http` |
+| `telemetry.headers` | map | `{}` | Common OTLP headers; can be overridden by traces/metrics |
+| `telemetry.log_messages` | bool | `true` | Whether to record full message content in span events |
+| `telemetry.service_name` | string | `jiuwenclaw` | Service name identifier |
+| `telemetry.provider_factory` | string | | Custom Provider Factory, format `module:function` |
+| `telemetry.traces.exporter` | string | | Trace exporter; falls back to `telemetry.exporter` |
+| `telemetry.traces.endpoint` | string | | Trace endpoint; falls back to `telemetry.endpoint` |
+| `telemetry.traces.protocol` | string | | Trace protocol; falls back to `telemetry.protocol` |
+| `telemetry.traces.headers` | map | `{}` | Trace-specific headers |
+| `telemetry.metrics.exporter` | string | | Metrics exporter; falls back to `telemetry.exporter` |
+| `telemetry.metrics.endpoint` | string | | Metrics endpoint; falls back to `telemetry.endpoint` |
+| `telemetry.metrics.protocol` | string | | Metrics protocol; falls back to `telemetry.protocol` |
+| `telemetry.metrics.headers` | map | `{}` | Metrics-specific headers |
+
+### 2.13 Other Settings
+
+| Key | Type | Default | Description |
+|-----|------|---------|-------------|
+| `preferred_language` | string | `zh` | Agent default reply language (`zh` / `en`) |
+
+### 2.14 Environment-only fields
| Variable | Description |
|----------|-------------|
@@ -66,10 +198,53 @@ Edit **`config/config.yaml`** or **`.env`** directly; there is no UI for these.
| `BROWSER_RUNTIME_MCP_ENABLED` | Enable browser MCP runtime |
| `BROWSER_RUNTIME_MCP_CLIENT_TYPE` | MCP client type (`stdio` / `sse` / `streamable-http`) |
| `BROWSER_RUNTIME_MCP_SERVER_PATH` | MCP server URL |
+| `BROWSER_RUNTIME_MCP_SERVER_ID` | MCP server identifier, default `playwright_runtime_wrapper` |
+| `BROWSER_RUNTIME_MCP_SERVER_NAME` | MCP server display name, default `playwright-runtime-wrapper` |
+| `BROWSER_RUNTIME_MCP_TIMEOUT_S` | MCP server request timeout (seconds), default `300` |
+| `BROWSER_RUNTIME_MCP_HOST` | MCP server host, default `127.0.0.1` |
+| `BROWSER_RUNTIME_MCP_PORT` | MCP server port, default `8940` |
+| `BROWSER_RUNTIME_MCP_PATH` | MCP server path, default `/mcp` |
+| `BROWSER_RUNTIME_MCP_COMMAND` | MCP server command (stdio mode, empty = use default) |
+| `BROWSER_RUNTIME_MCP_ARGS` | MCP server args (stdio mode, empty = use default) |
+| `BROWSER_RUNTIME_MCP_AUTO_SSE_FALLBACK` | Auto SSE fallback (stdio mode), default `1` |
| `PLAYWRIGHT_CDP_URL` | Playwright CDP URL for Chrome |
| `PLAYWRIGHT_TOOL_TIMEOUT_S` | Playwright tool timeout (seconds) |
| `BROWSER_TIMEOUT_S` | Browser task timeout (seconds) |
-| `JIUWENCLAW_CONFIG_DIR` | Custom config directory |
+| `BROWSER_DRIVER` | Browser driver mode: `managed` / `remote` / `extension` |
+| `BROWSER_ALLOW_SHORT_TIMEOUT_OVERRIDE` | Allow model-provided timeout shorter than `BROWSER_TIMEOUT_S`; default `0` (off) |
+| `BROWSER_PROFILE_NAME` | Browser profile name, default `Default` |
+| `PLAYWRIGHT_MCP_COMMAND` | Playwright MCP command, default `npx` |
+| `PLAYWRIGHT_MCP_ARGS` | Playwright MCP args, default `-y @playwright/mcp@latest` |
+| `CUSTOM_HEADERS` | Custom HTTP headers for model API calls (JSON or empty) |
+| `VIDEO_API_BASE` | Video model API base URL |
+| `VIDEO_API_KEY` | Video model API key |
+| `VIDEO_PROVIDER` | Video model provider |
+| `AUDIO_API_BASE` | Audio model API base URL |
+| `AUDIO_API_KEY` | Audio model API key |
+| `AUDIO_PROVIDER` | Audio model provider |
+| `VISION_API_BASE` | Vision model API base URL |
+| `VISION_API_KEY` | Vision model API key |
+| `VISION_PROVIDER` | Vision model provider |
+| `IMAGE_GEN_API_BASE` | Image generation model API base URL |
+| `IMAGE_GEN_API_KEY` | Image generation model API key |
+| `IMAGE_GEN_PROVIDER` | Image generation model provider |
+| `FREE_SEARCH_DDG_URL` | DuckDuckGo HTML endpoint URL |
+| `FREE_SEARCH_SSL_VERIFY` | Enable SSL verification for free search; default `true`, set `false` behind corporate proxies |
+| `NO_PROXY` | Comma-separated hosts to bypass proxy |
+| `EMAIL_ADDRESS` | Sender email address (maps to `email_settings.email_address`) |
+| `EMAIL_TOKEN` | Email authorization code (maps to `email_settings.token`) |
+| `EVOLUTION_AUTO_SCAN` | Auto-scan evolvable skills after each turn (`true`/`false`) |
+| `SKILLNET_DOWNLOAD_TIMEOUT` | SkillNet download timeout (seconds), default 60 |
+| `SKILLNET_MAX_RETRIES` | SkillNet download max retries, default 3 |
+| `OPENJIUWEN_MARKET_BASE_URL` | TeamSkillsHub market URL (empty = default) |
+| `OPENJIUWEN_MARKET_TIMEOUT` | Market request timeout (seconds), default 60 |
+| `OPENJIUWEN_ALLOWED_DOWNLOAD_HOSTS` | ZIP download host allowlist, comma-separated |
+| `MEMORY_MODE` | Memory mode (empty = `local` default) |
+| `EXTENSION_DIRS` | Extension search directories, semicolon-separated (maps to `extensions.extension_dirs`) |
+| `OTEL_ENABLED` | Enable OpenTelemetry (maps to `telemetry.enabled`) |
+| `OTEL_EXPORTER` | OTLP exporter type (maps to `telemetry.exporter`) |
+| `OTEL_ENDPOINT` | OTLP endpoint (maps to `telemetry.endpoint`) |
+| `JIUWENCLAW_CONFIG_DIR` | Custom config directory path |
| `JIUWENCLAW_DATA_DIR` | Absolute path to the user data root (`config/`, `agent/`, `.logs`, etc.). If unset, defaults to `~/.jiuwenclaw`. Set in the shell or service environment **before** starting the process so workspace paths resolve from the first import; defining it only in `config/.env` is often too late for that bootstrap. |
| `JIUWENCLAW_DISABLE_CRON_TOOLS` | Set to `1` to disable Agent-side cron tool registration and hide cron-tool prompt text |
@@ -77,7 +252,7 @@ See `.env.template` for more variables.
---
-### 2.3 Precedence
+### 2.15 Precedence
- **Environment variables** override **`config.yaml`**
- Example: `react.model_name: ${MODEL_NAME:-deepseek-chat}` reads `MODEL_NAME` first, then falls back to `deepseek-chat`.
diff --git a/docs/en/DistributedTeam.md b/docs/en/DistributedTeam.md
index f6a37557f3..971becec45 100644
--- a/docs/en/DistributedTeam.md
+++ b/docs/en/DistributedTeam.md
@@ -40,7 +40,56 @@ Typical keys for distributed integration (full template: `config.team.distribute
---
-## 3. Where to look in code
+## 3. pyzmq Transport Field Normalization
+
+When `transport.type == pyzmq` and **`pubsub_publish_addr` / `pubsub_subscribe_addr` not both set**, `TeamManager` auto-fills from topology:
+
+| Field | Description |
+|-------|-------------|
+| `direct_addr` | Direct communication address |
+| `pubsub_publish_addr` | Publish address |
+| `pubsub_subscribe_addr` | Subscribe address |
+| `known_peers` / `bootstrap_peers` | Node discovery list |
+| `metadata.pubsub_bind` | Bind pubsub (leader=True, teammate=False) |
+
+Default ports:
+- Leader: `direct_port=18555`, `pub_port=18556`, `sub_port=18557`
+- Teammate: `direct_port=18600`
+
+---
+
+## 4. PostgreSQL Bootstrap (Leader Role)
+
+When `team.storage.type=postgresql` and role is `leader`, startup auto-checks PostgreSQL availability:
+
+1. Check `pg_isready -h <host> -p <port>`
+2. If unreachable, attempt to start local cluster:
+ - Try `pg_ctlcluster <version> <cluster> start`
+ - Fallback to `systemctl start postgresql` or `service postgresql start`
+3. Wait up to 30 seconds for service ready
+
+Config example:
+
+```yaml
+team:
+ storage:
+ type: postgresql
+ params:
+ connection_string: postgresql+asyncpg://user:pass@host:5432/teamdb
+```
+
+---
+
+## 5. teammate_mode and spawn_mode
+
+| Config | Value | Description |
+|--------|-------|-------------|
+| `teammate_mode` | `build_mode` (default) | Teammate built via build flow |
+| `spawn_mode` | `inprocess` (default) | Teammate runs in same process |
+
+---
+
+## 6. Where to look in code
### 3.1 `TeamManager._load_team_spec`
diff --git a/docs/en/MCPConfiguration.md b/docs/en/MCPConfiguration.md
new file mode 100644
index 0000000000..48abae9d99
--- /dev/null
+++ b/docs/en/MCPConfiguration.md
@@ -0,0 +1,120 @@
+# MCP Server Configuration
+
+JiuwenClaw supports connecting to external tool services via MCP (Model Context Protocol). MCP lets the Agent call tools provided by third-party services, extending its capabilities.
+
+---
+
+## Two MCP Usage Scenarios
+
+| Scenario | Configuration | Description |
+|----------|--------------|-------------|
+| **Browser runtime MCP** | Environment variables (`.env`) | MCP wrapper for Playwright browser automation; see [Browser Tools](Browser.md) |
+| **General MCP servers** | `config.yaml` → `mcp.servers` | Connect any MCP service (stdio / sse / streamable-http); this document focuses on this |
+
+---
+
+## Configuring MCP Servers
+
+Add MCP servers in `config/config.yaml`:
+
+```yaml
+mcp:
+ servers:
+ - name: my-local-tool
+ enabled: true
+ transport: stdio
+ command: python
+ args: ["path/to/server.py", "--transport", "stdio"]
+ cwd: .
+ env:
+ LOG_LEVEL: INFO
+
+ - name: remote-api
+ enabled: false
+ transport: sse
+ url: http://127.0.0.1:9000/sse
+ headers:
+ Authorization: Bearer your-token-here
+ timeout_s: 30
+
+ - name: remote-streamable
+ enabled: true
+ transport: streamable-http
+ url: http://127.0.0.1:8000/mcp
+ timeout_s: 60
+```
+
+---
+
+## Field Reference
+
+| Field | Type | Required | Description |
+|-------|------|----------|-------------|
+| `name` | string | Yes | Server identifier; must be globally unique |
+| `enabled` | bool | Yes | Whether to enable this server |
+| `transport` | string | Yes | Transport protocol: `stdio`, `sse`, or `streamable-http` |
+| `command` | string | Required for stdio | Launch command (e.g. `python`, `npx`) |
+| `args` | list | No | Command arguments |
+| `cwd` | string | No | Working directory |
+| `env` | map | No | Environment variables passed to the subprocess |
+| `url` | string | Required for sse/streamable-http | Server URL |
+| `headers` | map | No | Request headers (e.g. Authorization) |
+| `timeout_s` | int | No | Request timeout in seconds |
+
+---
+
+## Transport Protocol Comparison
+
+| Protocol | Use case | Description |
+|----------|----------|-------------|
+| **stdio** | Local tool servers | Agent launches a subprocess and communicates via stdin/stdout. Suitable for local Python/Node scripts |
+| **sse** | Remote HTTP servers | Server-Sent Events protocol. Suitable for existing HTTP servers |
+| **streamable-http** | Remote HTTP servers (recommended) | HTTP-based streaming protocol with better performance than SSE. Recommended for remote servers |
+
+---
+
+## Agent-Side Management Commands
+
+Use `/mcp` commands during conversations to manage MCP servers:
+
+```
+/mcp list # List configured MCP servers and their status
+/mcp reload # Reload all MCP servers
+/mcp enable <name> # Enable a specific server
+/mcp disable <name> # Disable a specific server
+```
+
+---
+
+## Browser MCP Runtime
+
+Browser automation uses a separate MCP runtime configured via environment variables:
+
+| Variable | Description | Default |
+|----------|-------------|---------|
+| `BROWSER_RUNTIME_MCP_ENABLED` | Enable browser MCP runtime | `1` |
+| `BROWSER_RUNTIME_MCP_CLIENT_TYPE` | Client type: `streamable-http` / `sse` / `stdio` | `streamable-http` |
+| `BROWSER_RUNTIME_MCP_SERVER_PATH` | MCP server URL | `http://127.0.0.1:8940/mcp` |
+| `BROWSER_RUNTIME_MCP_TIMEOUT_S` | Timeout in seconds | `300` |
+| `BROWSER_RUNTIME_MCP_HOST` | Local wrapper host | `127.0.0.1` |
+| `BROWSER_RUNTIME_MCP_PORT` | Local wrapper port | `8940` |
+
+See [Browser Tools](Browser.md) for details.
+
+---
+
+## Environment Variables
+
+| Variable | Description |
+|----------|-------------|
+| `BROWSER_RUNTIME_MCP_ENABLED` | Enable/disable browser MCP runtime |
+| `BROWSER_RUNTIME_MCP_CLIENT_TYPE` | Browser MCP client type |
+| `BROWSER_RUNTIME_MCP_SERVER_PATH` | Browser MCP server URL |
+| `BROWSER_RUNTIME_MCP_TIMEOUT_S` | Browser MCP timeout |
+
+---
+
+## See Also
+
+- [Browser Tools](Browser.md) — Browser MCP runtime detailed configuration
+- [Configuration](Configuration.md) — Full configuration reference
\ No newline at end of file
diff --git a/docs/en/Memory.md b/docs/en/Memory.md
index 957f068f70..67bb4cc956 100644
--- a/docs/en/Memory.md
+++ b/docs/en/Memory.md
@@ -2,8 +2,27 @@
Memory gives JiuwenClaw **persistent, cross-session recall**: important facts are written to files and retrieved with semantic search (plus optional BM25).
+**External Memory Providers**, supporting third-party memory services (OpenJiuwen LTM, Mem0, OpenViking) or custom plugins.
+
+---
+
+## Engine Switch
+
+Control memory engine mounting via `memory.engine` config:
+
+| Value | Description |
+|-------|-------------|
+| `builtin` | Only built-in memory (default, backward-compatible) |
+| `external` | Only external memory (LTM / Mem0 / OpenViking / plugin) |
+| `both` | Built-in + external coexist |
+| `none` | All disabled |
+
+---
+
## Configuration
+### Built-in Memory
+
Retrieval defaults to BM25 full-text search. Configure **`EMBED_API_KEY`** (and related embed settings) for vector + BM25 hybrid search.
| Variable | Description |
@@ -14,6 +33,60 @@ Retrieval defaults to BM25 full-text search. Configure **`EMBED_API_KEY`** (and
![Memory config](../assets/images/memory_config.png)
+### External Memory
+
+Config location: `memory.external` section in `config.yaml`.
+
+```yaml
+memory:
+ engine: external # or both
+ external:
+ provider: mem0 # Choose one: openjiuwen | mem0 | openviking | <plugin-name>
+ user_id: __default__
+ scope_id: __default__
+
+ # Provider-specific config
+ openjiuwen:
+ kv_type: shelve
+ vector_type: chroma
+ db_type: sqlite
+ mem0:
+ api_key: ""
+ user_id: ""
+ agent_id: ""
+ rerank: true
+ openviking:
+ endpoint: http://127.0.0.1:1933
+ api_key: ""
+ account: root
+ user: default
+```
+
+#### Supported Providers
+
+| Provider | Description | Required Config |
+|----------|-------------|-----------------|
+| `openjiuwen` | Local long-term memory (KV + Vector + DB) | None (uses default ~/.jiuwenclaw/memory/ltm) |
+| `mem0` | Cloud fact extraction & semantic retrieval | `api_key` (from mem0.ai) |
+| `openviking` | ByteDance context database | `endpoint`, `api_key` |
+| `<plugin-name>` | Custom plugin | ~/.jiuwenclaw/plugins/memory/<name>/ |
+
+#### External Memory Environment Variables
+
+| Variable | Description |
+|----------|-------------|
+| `MEMORY_EXTERNAL_PROVIDER` | Provider name (overrides config.yaml) |
+| `MEMORY_USER_ID` | Data isolation identifier |
+| `MEMORY_SCOPE_ID` | Scope identifier |
+| `MEM0_API_KEY` | Mem0 API key |
+| `MEM0_USER_ID` | Mem0 user identifier |
+| `OPENVIKING_ENDPOINT` | OpenViking service address |
+| `OPENVIKING_API_KEY` | OpenViking API key |
+
+---
+
+## Built-in Memory File Layout
+
## File layout
diff --git a/docs/en/Modes.md b/docs/en/Modes.md
new file mode 100644
index 0000000000..5a30351f41
--- /dev/null
+++ b/docs/en/Modes.md
@@ -0,0 +1,142 @@
+# Modes
+
+JiuwenClaw supports multiple runtime modes, each with its own tool set, permission policy, and memory behavior. Users can switch modes during a conversation using the `/mode` command.
+
+---
+
+## Mode Overview
+
+| Mode | Code | Description |
+|------|------|-------------|
+| Agent (Plan) | `agent.plan` | Default mode. Full tools + proactive memory, focused on reasoning and planning |
+| Agent (Fast) | `agent.fast` | Full tools + passive memory, focused on quick responses |
+| Code (Plan) | `code.plan` | Code mode + coding memory, focused on code generation planning |
+| Code (Normal) | `code.normal` | Code mode + coding memory, focused on code execution |
+| Team | `team` | Multi-agent collaboration mode, based on the `team` definition in config |
+
+---
+
+## Switching Modes
+
+Use the following commands during a channel conversation:
+
+```
+/mode agent # Switch to Agent mode (defaults to agent.plan)
+/mode code # Switch to Code mode (defaults to code.normal)
+/mode team # Switch to Team mode
+/mode agent.plan # Switch directly to Agent Plan sub-mode
+/mode agent.fast # Switch directly to Agent Fast sub-mode
+/mode code.plan # Switch directly to Code Plan sub-mode
+/mode code.normal # Switch directly to Code Normal sub-mode
+```
+
+You can also use `/switch` to change sub-modes within the same category:
+
+```
+/switch plan # Under Agent → plan; under Code → plan
+/switch fast # Under Agent → fast
+/switch normal # Under Code → normal
+```
+
+---
+
+## Configuration
+
+Define mode tools and constraints in the `modes` section of `config/config.yaml`:
+
+```yaml
+modes:
+ agent:
+ fast:
+ memory:
+ enabled: true
+ is_proactive: false # Passive memory
+ rails: []
+ tools: []
+ plan:
+ memory:
+ enabled: true
+ is_proactive: true # Proactive memory
+ rails: []
+ tools: []
+
+ code:
+ rails:
+ - FileSystemRail # File system safety rails
+ - SkillUseRail # Skill invocation rails
+ - LspRail # LSP assistance rails
+ tools:
+ - web_free_search
+ - web_fetch_webpage
+ - web_paid_search
+ - user_todos
+ embedding_config:
+ model_name: null
+ base_url: null
+ api_key: null
+
+ team:
+ jiuwen_team:
+ team_name: jiuwen_team
+ lifecycle: persistent
+ teammate_mode: build_mode
+ spawn_mode: inprocess
+ leader:
+ member_name: team_leader
+ display_name: Team Leader
+ persona: "Expert project manager, skilled at task decomposition and team coordination"
+ agents:
+ leader:
+ workspace:
+ stable_base: true
+ max_iterations: 200
+ completion_timeout: 600.0
+ workspace:
+ enabled: true
+ transport:
+ type: inprocess
+ storage:
+ type: sqlite
+```
+
+### Section Reference
+
+| Path | Description |
+|------|-------------|
+| `modes.agent.fast` | Agent Fast mode: passive memory, no extra rails |
+| `modes.agent.plan` | Agent Plan mode: proactive memory, no extra rails |
+| `modes.code.rails` | Dynamic safety rails for Code mode (fixed rails are hardcoded) |
+| `modes.code.tools` | Dynamic tool whitelist for Code mode (`coding_memory_*` and `send_file_to_user` are registered at runtime) |
+| `modes.code.embedding_config` | Code-mode-specific embedding config (empty = use global) |
+| `modes.team.<name>` | Team mode definition: team name, lifecycle, leader/agents config |
+
+### Channel Default Mode
+
+Each channel can specify a default mode via `channels.<channel>.default_mode` in `config.yaml`:
+
+```yaml
+channels:
+ web:
+ enabled: true
+ default_mode: agent.plan # This channel defaults to Agent Plan mode
+```
+
+---
+
+## Mode Behavior Differences
+
+| Behavior | Agent (plan) | Agent (fast) | Code | Team |
+|----------|-------------|-------------|------|------|
+| Tool set | All tools | All tools | Whitelisted + coding memory | Per-team config |
+| Memory strategy | Proactive (auto read/write) | Passive (on-demand) | Coding memory | Per-team config |
+| Safety rails | None extra | None extra | FileSystemRail + SkillUseRail + LspRail | Per-team config |
+| Iteration limit | `react.max_iterations` | `react.max_iterations` | `react.max_iterations` | Leader can set `max_iterations` |
+
+---
+
+## See Also
+
+- [Configuration](Configuration.md) — Full `modes` section field reference in `config.yaml`
+- [CLI Commands](CLI.md) — Full command reference including `/mode` and `/switch`
+- [Slash Command Architecture](SlashCommandArchitecture.md) — Internal command parsing flow
+- [Distributed Team](DistributedTeam.md) — Distributed deployment for Team mode
\ No newline at end of file
diff --git a/docs/en/MultiInstance.md b/docs/en/MultiInstance.md
new file mode 100644
index 0000000000..8b775f3719
--- /dev/null
+++ b/docs/en/MultiInstance.md
@@ -0,0 +1,241 @@
+# Multi-Instance Operation
+
+Run multiple independent JiuwenClaw instances on the same machine, each with isolated workspace, configuration, and ports.
+
+## Use Cases
+
+- **Dev/Prod isolation**: Run test and production instances simultaneously on a development machine
+- **Multi-tenant environment**: Create independent Agent instances for different users or projects
+- **Parallel modes**: Run Agents with different configurations (models, permission policies) concurrently
+
+---
+
+## Core Concepts
+
+### Instance Isolation
+
+Each instance has independent:
+
+| Resource | Description |
+|----------|-------------|
+| **Workspace directory** | `workspace/` containing SOUL.md, skills, memory, etc. |
+| **Configuration file** | `.env` file with API_KEY, model settings, etc. |
+| **Ports** | Separate ports for AgentServer, Gateway, WebChannel, Frontend |
+| **Process** | Independent process group managed via PID file |
+| **Startup lock** | Prevents concurrent starts of the same instance |
+
+### Instance Naming Rules
+
+- Length: 1-64 characters
+- Allowed characters: letters, digits, underscore, hyphen
+- Cannot start with `.`
+- Reserved names: `default`, `config`, `tmp`, `jiuwenclaw`, `all`
+
+---
+
+## Configuration File
+
+### instances.yaml
+
+Location: `~/.jiuwenclaw/instances.yaml` (or repository root)
+
+```yaml
+instances:
+ dev:
+ workspace: ~/.jiuwenclaw_dev
+ ports:
+ agent_server: 19092
+ web: 20000
+ gateway: 20001
+ frontend: 6173
+ prod:
+ workspace: ~/.jiuwenclaw_prod
+ ports:
+ agent_server: 20092
+ web: 21000
+ gateway: 21001
+ frontend: 7173
+```
+
+### Port Auto-Allocation Algorithm
+
+Default port = base port + instance index × 1000
+
+| Service Type | Base Port | Default Instance (index=0) | First Named Instance (index=1) |
+|--------------|-----------|---------------------------|-------------------------------|
+| agent_server | 18092 | 18092 | 19092 |
+| web | 19000 | 19000 | 20000 |
+| gateway | 19001 | 19001 | 20001 |
+| frontend | 5173 | 5173 | 6173 |
+
+---
+
+## Commands
+
+### jiuwenclaw-init --name
+
+Create a named instance:
+
+```bash
+# Create dev instance
+jiuwenclaw-init --name dev
+
+# Create prod instance with specified workspace
+jiuwenclaw-init --name prod --workspace ~/.jiuwenclaw_prod
+```
+
+This will:
+1. Create workspace directory
+2. Generate instance-specific `.env` file
+3. Update `instances.yaml` configuration
+4. Allocate ports (auto or manual)
+
+### jiuwenclaw-start Management Commands
+
+```bash
+# List all instance statuses
+jiuwenclaw-start --list
+
+# Output example:
+# INSTANCE STATUS PID WORKSPACE PORTS
+# --------------------------------------------------------------------------------
+# default running 12345 ~/.jiuwenclaw as:18092,w:19000,g:19001,f:5173
+# dev stopped - ~/.jiuwenclaw_dev as:19092,w:20000,g:20001,f:6173
+# prod stopped - ~/.jiuwenclaw_prod as:20092,w:21000,g:21001,f:7173
+
+# Show specific instance details
+jiuwenclaw-start --status dev
+
+# Start named instance
+jiuwenclaw-start --name dev
+jiuwenclaw-start --name dev app # Start backend only
+jiuwenclaw-start --name dev web # Start web service only
+
+# Stop instance
+jiuwenclaw-start --stop dev
+
+# Restart instance
+jiuwenclaw-start --restart dev
+jiuwenclaw-start --restart dev --mode app
+```
+
+---
+
+## Startup Lock Mechanism
+
+To prevent concurrent starts of the same instance, the system uses file locks:
+
+- Lock file: `<workspace>/.instance.lock`
+- Lock timeout: 30 seconds (`STALE_LOCK_TIMEOUT`)
+- Cross-platform support:
+ - Unix: `fcntl.flock`
+ - Windows: exclusive file creation
+
+If lock conflict occurs during startup:
+
+```
+[start_services] ERROR: Instance 'dev' startup in progress by another process
+[start_services] Wait a few seconds or check if another terminal is starting this instance.
+```
+
+---
+
+## Environment Variables
+
+| Variable | Description |
+|----------|-------------|
+| `JIUWENCLAW_DATA_DIR` | Override data root directory (affects instances.yaml location) |
+| `JIUWENCLAW_CONFIG_DIR` | Override configuration directory |
+
+Use `--dotenv` at startup to specify instance-specific config:
+
+```bash
+# Internal mechanism: bootstrap .env is auto-loaded when starting named instance
+jiuwenclaw-start --name dev
+# Equivalent to loading ~/.jiuwenclaw_dev/.env
+```
+
+---
+
+## PID File
+
+Each instance maintains a PID file in the workspace directory:
+
+- Filename: `.instance.pid`
+- Content: Process ID + startup timestamp
+- Purpose:
+ - Status query (`--status`, `--list`)
+ - Process control (`--stop`, `--restart`)
+
+---
+
+## Best Practices
+
+### 1. Port Planning
+
+Avoid port conflicts:
+
+```bash
+# Check port usage
+jiuwenclaw-start --status dev
+# System auto-detects and reports conflicts
+```
+
+### 2. Configuration Isolation
+
+Use separate API keys or model configs for each instance:
+
+```bash
+# dev instance .env
+API_KEY="sk-dev-key"
+MODEL_NAME="deepseek-chat"
+
+# prod instance .env
+API_KEY="sk-prod-key"
+MODEL_NAME="gpt-4"
+```
+
+### 3. Workspace Management
+
+Instance workspace contains all Agent runtime data:
+
+```
+~/.jiuwenclaw_dev/
+├── .env # Instance config
+├── .instance.pid # Process management
+├── .instance.lock # Startup lock
+├── workspace/
+│ ├── agent/
+│ │ ├── SOUL.md # Agent personality
+│ │ ├── memory/ # Memory storage
+│ │ └── skills/ # Skills directory
+│ └── session/ # Session data
+```
+
+---
+
+## FAQ
+
+### Q: How to delete an instance?
+
+Manually remove workspace directory and instances.yaml entry:
+
+```bash
+rm -rf ~/.jiuwenclaw_dev
+# Edit ~/.jiuwenclaw/instances.yaml to remove corresponding entry
+```
+
+### Q: Difference between default and named instances?
+
+- **Default instance**: Started without `--name`, uses `~/.jiuwenclaw/` workspace
+- **Named instance**: Specified via `--name`, uses independent workspace and ports
+
+### Q: Can instances share configuration?
+
+Yes. Reference shared config in instance `.env`:
+
+```bash
+# ~/.jiuwenclaw_dev/.env
+source ~/.jiuwenclaw/.env # Shared base config
+MODEL_NAME="special-model" # Instance-specific override
+```
\ No newline at end of file
diff --git a/docs/en/PackExeGuide.md b/docs/en/PackExeGuide.md
index 9c5d85e69a..f9c3c05c64 100644
--- a/docs/en/PackExeGuide.md
+++ b/docs/en/PackExeGuide.md
@@ -109,7 +109,7 @@ chmod +x scripts/build-macos.sh
./scripts/build-macos.sh
```
-Produces `dist/JiuwenClaw.app` and e.g. `dist/JiuwenClaw-0.1.7.dmg`.
+Produces `dist/JiuwenClaw.app` and `dist/JiuwenClaw-<version>.dmg`.
- Open the `.app` or mount the `.dmg` and drag to **Applications**.
- Not codesigned/notarized — fine for local testing; for distribution add `.icns`, signing, and notarization.
diff --git a/docs/en/README.md b/docs/en/README.md
index 77b4fd4ad5..9eefaf5738 100644
--- a/docs/en/README.md
+++ b/docs/en/README.md
@@ -2,19 +2,38 @@
This section collects common usage notes and feature documentation for JiuwenClaw.
-- Install and run from scratch: [Quick start](Quickstart.md)
+- Install and run from scratch: [Quick start](Quickstart.md) / [TUI mode](Quickstart_tui.md)
- Unified Gateway↔Agent request envelope (E2A): [E2A protocol](E2A-protocol.md)([中文版](../zh/E2A-protocol.md))
+- A2A protocol integration: [A2A Integration Guide](A2A.md)([中文版](../zh/A2A.md))
+- ACP client configuration: [ACP Client Config](ACP_Client_Config.md)
- Model and system configuration: [Configuration](Configuration.md)
-- Topic guides: use the table of contents or start from:
- - [Channels](Channels.md)
- - [CLI commands](CLI.md)
- - [Heartbeat](Heartbeat.md)
- - [Scheduled tasks](ScheduledTasks.md)
- - [Task planning](TaskPlanning.md)
- - [Memory](Memory.md)
- - [Context compression & offload](ContextCompression.md)
- - [Skills](Skills.md)
- - [Skill self-evolution](SkillSelfEvolution.md)
- - [Agent & workspace](Agent.md)
- - [Browser tools](Browser.md)
- - [Packaging desktop executables](PackExeGuide.md)
+
+Topic guides:
+
+- [Channels](Channels.md) — Feishu, Discord, WhatsApp, Web, etc.
+- [Modes](Modes.md) — PLAN / AGENT / CODE / TEAM mode switching and configuration
+- [CLI commands](CLI.md)
+- [Heartbeat](Heartbeat.md)
+- [Scheduled tasks](ScheduledTasks.md)
+- [Task planning](TaskPlanning.md)
+- [Memory](Memory.md)
+- [Task Memory](TaskMemory.md) — Task-level experience retrieval and consolidation
+- [Context compression & offload](ContextCompression.md)
+- [Coding Memory](CodingMemory.md) — Code-mode-specific memory
+- [Skills](Skills.md)
+- [Skill self-evolution](SkillSelfEvolution.md)
+- [Agent & workspace](Agent.md)
+- [Browser tools](Browser.md)
+- [MCP Configuration](MCPConfiguration.md) — MCP server integration and configuration
+- [Tool permissions & security](ToolPermissionsSecurity.md)
+- [Slash command architecture](SlashCommandArchitecture.md)
+- [Slash command reference](SlashCommands.md)
+- [Distributed Team](DistributedTeam.md)([中文版](../zh/分布式Team.md))
+- [Multi-instance operation](MultiInstance.md)([中文版](../zh/单机多实例运行.md))
+- [Packaging desktop executables](PackExeGuide.md)
+- [Windows auto-update design](WindowsAutoUpdateDesign.md)
+
+Development practices:
+
+- [JiuwenClaw Code Review Assistant](development-practices/JiuwenClaw-Code-Review-Assistant.md)
+- [JiuwenClaw Daily Report Generator](development-practices/JiuwenClaw-Daily-Report-Generator.md)
\ No newline at end of file
diff --git a/docs/en/SUMMARY.md b/docs/en/SUMMARY.md
index c652b5dc07..2b14c2c247 100644
--- a/docs/en/SUMMARY.md
+++ b/docs/en/SUMMARY.md
@@ -1,25 +1,37 @@
# Summary
- [Quick start](Quickstart.md)
+- [Quick start (TUI)](Quickstart_tui.md)
- [E2A protocol (Gateway↔Agent)](E2A-protocol.md)
- [A2A integration](A2A.md)
- [Configuration](Configuration.md)
- [Distributed Team](DistributedTeam.md)
+- [Multi-Instance](MultiInstance.md)
- [User guide](README.md)
- [Channels](Channels.md)
- [Discord](Discord.md)
- [WhatsApp](WhatsApp.md)
+ - [Modes](Modes.md)
- [CLI commands](CLI.md)
+ - [Slash Commands Reference](SlashCommands.md)
+ - [Slash Command Architecture](SlashCommandArchitecture.md)
+ - [Tool Permissions & Security](ToolPermissionsSecurity.md)
- [Heartbeat](Heartbeat.md)
- [Scheduled tasks](ScheduledTasks.md)
- [Task planning](TaskPlanning.md)
- [Memory](Memory.md)
+ - [Task Memory](TaskMemory.md)
- [Context compression & offload](ContextCompression.md)
+ - [Coding Memory](CodingMemory.md)
- [Skills](Skills.md)
- [Skill self-evolution](SkillSelfEvolution.md)
- [Agent & workspace](Agent.md)
- [Browser tools](Browser.md)
+ - [MCP Configuration](MCPConfiguration.md)
- [Packaging desktop executables](PackExeGuide.md)
+ - [ACP Plugin Usage](ACP_Client_Config.md)
+ - [Windows auto-update design](WindowsAutoUpdateDesign.md)
- [Development practices](development-practices/README.md)
- [Daily report generator practice](development-practices/JiuwenClaw-Daily-Report-Generator.md)
- [Code review assistant practice](development-practices/JiuwenClaw-Code-Review-Assistant.md)
+- [Linux NFS Shared Filesystem](../linux-agent-teams-shared-filesystem.md)
\ No newline at end of file
diff --git a/docs/en/SlashCommandArchitecture.md b/docs/en/SlashCommandArchitecture.md
new file mode 100644
index 0000000000..eef3a76cd3
--- /dev/null
+++ b/docs/en/SlashCommandArchitecture.md
@@ -0,0 +1,143 @@
+# Slash Command Architecture
+
+> **Document type**: Architecture and evolution conventions — describes "single source of truth", layering boundaries, and implementation principles.
+> **Relationship to other docs**: See [`SlashCommands.md`](./SlashCommands.md) for the command reference table; [`CLI.md`](./CLI.md) for the CLI command list. This document does **not** enumerate all commands — it defines **how they are organized and how to prevent drift**.
+
+---
+
+## 1. Background & Problem
+
+Slash-prefixed commands (`/`) are currently implemented in multiple places:
+
+- **Gateway**: `MessageHandler._handle_channel_control` handles `/new_session`, `/mode …`, etc. on controlled channels, deciding whether to **intercept and NOT forward to Agent**.
+- **IM Pipeline / Channels**: e.g. `gateway/im_pipeline/im_inbound.py` maintains its own control message set; Feishu/WeCom channels may have text-based checks that **diverge from the main logic**.
+- **CLI TUI**: `jiuwenclaw/cli/src/core/commands/` has a local registry; some commands call the backend via WebSocket, others are purely local.
+
+Without clear layering and a single source of truth, the project risks: **semantic inconsistencies for the same command name, documentation-code drift, and duplicated parsing logic in new channels.**
+
+---
+
+## 2. Design Goals
+
+| Goal | Description |
+|------|-------------|
+| **Single Source of Truth (SSOT)** | For gateway-controlled slash commands, the command name, valid forms, and match semantics should be defined in one place. Other modules **reference** rather than copy. |
+| **Clear Boundaries** | Distinguish "Gateway-only", "Client-only", and "Name-aligned, execution-split" categories. Avoid stuffing all product slash commands into a single Gateway module. |
+| **Evolvable** | Adding a new controlled channel only requires checking the registry and `_control_channel_types` policies. |
+| **Consistent with REPL conventions** | Local-UI slash commands (help, diagnostics) are **resolved client-side first**; **unrecognized `/xxx` should NOT be forwarded as plain user content** by default (see REPL design doc). |
+
+### 2.1 Non-goals
+
+- All slash commands need NOT be executed in the Python Gateway (CLI-exclusive commands remain client-side).
+- A single big-bang refactor is not required; incremental migration of constants and parsing to SSOT is acceptable.
+
+---
+
+## 3. Three-Layer Classification (Mandatory)
+
+### 3.1 Category A: Gateway Channel Control
+
+**Definition**: User messages arriving at the Gateway that are identified by `MessageHandler` (or its unified entry point), potentially **only changing session/mode/routing without entering Agent conversation**.
+
+**Typical commands**: `/new_session`, `/mode agent|code|team` and `/switch plan|fast|normal` on controlled channels, plus direct forms like `/mode agent.plan|agent.fast|code.plan|code.normal` (per current implementation).
+
+**Requirements**:
+
+- Valid forms, match semantics (exact / prefix / multiline), and error messages should be described by the **SSOT**. `im_inbound` and IM channels that need pre-filtering must **import the same SSOT** — private subset copies are prohibited.
+- Registry entries must specify **applicable channel types** (aligned with `_control_channel_types` and `_session_map_channel_types`), avoiding blanket "all channels" defaults.
+
+### 3.2 Category B: Client-Only
+
+**Definition**: Commands parsed and executed **locally** in CLI TUI, Web REPL, etc., or commands that should NOT be semantically intercepted by the Gateway.
+
+**Typical commands**: UI toggles, `/resume`, `/model` (if purely local config), help/diagnostic stubs — per [`CLI.md`](./CLI.md).
+
+**Requirements**:
+
+- **NOT** included in the Gateway intercept table as the sole truth. If backend mode alignment is needed, use existing protocol fields (e.g. `params.mode`), not re-parsing CLI aliases in the Gateway.
+- Document the **processing process**: Node CLI / browser frontend, etc.
+
+### 3.3 Category C: Name-Aligned, Execution-Split (Hybrid)
+
+**Definition**: Commands where the **name** and help text should be consistent across CLI and IM, but **execution** spans client + backend (e.g. local validation then RPC).
+
+**Requirements**:
+
+- Add `canonical_name` + `cli_alias` fields in the SSOT or doc matrix, so name mismatches are traceable.
+- The Gateway **need NOT** understand CLI aliases; if future server-side recognition is needed, add it as a new requirement and extend the protocol explicitly.
+
+---
+
+## 4. Single Source of Truth (SSOT) — Proposed Shape
+
+### 4.1 Module Location (Proposed)
+
+- **Python side**: Implemented as `jiuwenclaw/gateway/slash_command.py` (controlled channel parsing, `CONTROL_MESSAGE_TEXTS`, first-batch command metadata `FIRST_BATCH_REGISTRY`). May evolve into `channel_control_slash.py` etc.
+ - **Data**: The set of controlled commands, match rules (exact / prefix / no-multi-line), metadata (description, whether to forward to Agent).
+ - **Pure functions**: Given a channel type and user text, return a **structured decision** (not hit / hit & valid / hit & invalid). **No IO** in SSOT module (no `create_task` for notifications).
+- **Naming suggestion**: If only containing Category A, the module name should avoid suggesting "all product slashes", preventing future contributors from stuffing Category B logic into the Gateway.
+
+### 4.2 Registry Minimum Fields (Proposed)
+
+| Field | Description |
+|-------|-------------|
+| `id` | Stable internal identifier (e.g. `new_session`, `mode_switch`). |
+| `patterns` | Valid user input forms (including whether to match whole-line only). |
+| `scope` | `gateway` (this design's scope). |
+| `channels` | `all_controlled` or explicit list, aligned with config channel types. |
+| `intercept` | Whether to withhold from Agent when hit and valid (per `_handle_channel_control` semantics). |
+| `notes` | Cross-reference to CLI aliases and doc anchors (links to `CLI.md` sections). |
+
+### 4.3 Relationship to `MessageHandler`
+
+- **Parsing & decision**: Call the SSOT module, reducing inline `startswith` chains in `message_handler.py`.
+- **Side effects**: Still in `MessageHandler` (or a dedicated service class) for task cancellation, notification dispatch, etc. — avoiding async side effects in the "table module" for testability.
+
+---
+
+## 5. How Each Entry Point Integrates (Principles)
+
+| Entry Point | Principle |
+|-------------|-----------|
+| **Gateway `MessageHandler`** | Before controlled-channel user text enters unified control logic, use SSOT for decisions. |
+| **`im_inbound` etc.** | If pre-filtering or statistics are needed, **import the same constants/functions** — no independent `frozenset` subsets. |
+| **Feishu / WeCom etc.** | If lightweight pre-checking is needed at the Channel layer, **reuse SSOT** or only do coarse "might be a control command" filtering. Final semantics always per Gateway. If dual-point checking exists, document in registry `notes` and load-test to avoid duplicate prompts. |
+| **CLI** | Continue maintaining the TS `registry`; align names with Category A per [`CLI.md`](./CLI.md) and §3.3 above. Do NOT duplicate Category B logic in the Gateway. |
+
+---
+
+## 6. "Unknown Slash" Protocol Conventions
+
+- **Client (REPL/TUI)**: Input starting with `/` should go through the local command router first. Unrecognized commands should prompt the user and **NOT** be sent as plain conversation content (per product UX).
+- **Gateway**: Only guarantees SSOT-based handling of Category A for **channels that actually reach the Gateway**. Does not need to recognize all CLI-only commands.
+
+---
+
+## 7. Testing & Quality Assurance
+
+- Provide **unit tests** for the SSOT: cover exact match, illegal suffix, multiline text, `/mode` first-level vs. direct-value forms, `/switch` valid/invalid combos, etc. — consistent with production behavior.
+- Regression note: **SessionMap** channel family vs. regular controlled channels' `session_id` behavior is still managed by the existing state machine. SSOT only addresses string-level consistency and maintainability.
+
+---
+
+## 8. Phased Implementation (Proposed)
+
+| Phase | Content |
+|-------|---------|
+| **P0** | Extract Category A commands into SSOT module; `im_inbound` etc. switch to imports, eliminating set drift. |
+| **P1** | Converge inline parsing in `message_handler.py` to SSOT calls; behavior unchanged. |
+| **P2** | Fill in Category B/C cross-references with `CLI.md` in the doc matrix. Optional: generate read-only manifest for frontend (if unified completion is needed). |
+
+---
+
+## 9. Summary
+
+- The "table" in the Gateway should primarily host **Category A (channel control)** SSOT, not all product slash commands.
+- **Category B** stays client-side; **Category C** uses documentation and fields for name alignment — centralized execution logic is unnecessary.
+- **Success criterion**: changing a command set in one place no longer causes divergence in pipelines and Gateway main paths; the CLI/IM experience boundary remains clear and documentable.
+
+---
+
+## 10. Current Command Status (based on `gateway/slash_command.py`)
+
+The current command list has been split into a separate document: [`SlashCommands.md`](./SlashCommands.md).
\ No newline at end of file
diff --git a/docs/en/SlashCommands.md b/docs/en/SlashCommands.md
index 47bbd97e5d..3e8bc7e9f0 100644
--- a/docs/en/SlashCommands.md
+++ b/docs/en/SlashCommands.md
@@ -39,6 +39,8 @@ Identified by Gateway and forwarded to AgentServer and other backend capabilitie
| `/model` | Model view, add, switch (see below) |
| `/mcp` | MCP server management (see below) |
| `/diff` | View session changes by turn (see below) |
+| `/compact` | Compress current context (see below) |
+| `/init` | Project initialization (see below) |
---
@@ -124,6 +126,27 @@ Manages directories AI can access for file read, edit, and execute operations.
- Without changes: Shows `No file changes in this session`.
- Scope: For viewing uncommitted per-turn change traces in current session, not a replacement for `git diff` full version control perspective.
+### `/compact` (Context Compression)
+
+- Usage: `/compact` (no parameters).
+- Function: Trigger context compression,清理对话 history but keep summary in context.
+- Data source: TUI requests Agent compression service via `command.compact`.
+- Results:
+ - `busy`: Compression in progress, retry later;
+ - `compressed`: Success, shows before/after token counts and savings ratio;
+ - `noop`: No compression needed, context already optimal.
+
+### `/init` (Project Initialization)
+
+- Usage: `/init` (no parameters).
+- Function: Initialize project AI collaboration config, generates `JIUWENCLAW.md` and optionally `JIUWENCLAW.local.md`.
+- Scope: Only runs in `code` mode.
+- Flow:
+ 1. Select scope: `Team-shared` (JIUWENCLAW.md), `Personal` (JIUWENCLAW.local.md), or `Both`.
+ 2. Detect existing configs: Auto-detect `CLAUDE.md`, `.cursorrules`, `copilot-instructions.md` etc.
+ 3. Generate configs: Create project config files based on selection.
+- Auto mode switch: If in `code.plan`, auto-switches to `code.normal` for write permission.
+
### `/mcp` (MCP Server Management)
- Usage:
@@ -169,8 +192,6 @@ Conclusion: IM uses `/skills list`, TUI uses `/skills`, current syntax differs (
| Command | Description |
|---|---|
-| `/compact` | Compress current context |
-| `/init` | Project initialization |
| `/btw` | Ask question |
| `/context` | Context status view |
| `/export` | Export related files |
diff --git a/docs/en/TaskMemory.md b/docs/en/TaskMemory.md
new file mode 100644
index 0000000000..d274709dc9
--- /dev/null
+++ b/docs/en/TaskMemory.md
@@ -0,0 +1,97 @@
+# Task Memory (Experience Memory)
+
+Task Memory is JiuwenClaw's built-in experience system that allows the Agent to retrieve, record, and consolidate lessons from past tasks — avoiding repeated mistakes and reusing effective solutions in future tasks.
+
+---
+
+## Configuration
+
+Configure in `config/config.yaml`:
+
+```yaml
+task_memory:
+ enabled: true # Master switch
+ retrieval_algo: ACE # Retrieval algorithm: ACE | ReasoningBank | ReMe
+ summary_algo: ACE # Summary algorithm: ACE | ReasoningBank | ReMe
+ llm_model: ${TASK_MEMORY_LLM_MODEL} # LLM model for task memory (empty = main model)
+ embedding_model: ${TASK_MEMORY_EMBED_MODEL}
+ api_key: ${TASK_MEMORY_API_KEY}
+ api_base: ${TASK_MEMORY_API_BASE}
+```
+
+When `enabled: true`, the Agent gains the three tools described below.
+
+---
+
+## Tools
+
+### experience_retrieve
+
+Retrieve relevant past experience based on a query.
+
+| Parameter | Type | Description |
+|-----------|------|-------------|
+| `query` | string | Describe the current task or question; the system matches the most relevant experience |
+
+Returns `memory_string` (readable text) and `retrieved_memory` (structured list).
+
+**Recommended: call this at the start of every task** to check for reusable experience.
+
+### experience_learn
+
+Record a key finding, rule, or insight from the current task and consolidate it into the experience store.
+
+| Parameter | Type | Required | Description |
+|-----------|------|----------|-------------|
+| `params.content` | string | Yes | The experience content to record |
+| `params.section` | string | No | Category label, default `general` |
+| `params.when_to_use` | string | No | When to apply this experience |
+| `params.title` | string | No | Experience title |
+| `params.description` | string | No | Detailed description |
+| `params.query` | string | No | Associated query |
+| `params.label` | string | No | Custom label |
+| `params.tools_used` | list | No | Tool call outcomes, e.g. `[{"tool": "web_search", "status": "success"}]` |
+
+**Recommended: call once before the final reply.** Recording failed tool calls is especially valuable.
+
+### experience_clear
+
+Wipe all stored task memory from `task-data.json`.
+
+> ⚠️ Only call when the user explicitly asks to clear. Always confirm first.
+
+---
+
+## Storage
+
+Experience data is persisted in `workspace/agent/task-data.json`. Even when the external experience service is unavailable, local persisted data is still accessible (returns `persisted_only` status).
+
+When the external service is healthy, retrieval results merge both local persisted data and service-side data.
+
+---
+
+## Retrieval Algorithms
+
+| Algorithm | Description |
+|-----------|-------------|
+| **ACE** | Default algorithm; embedding-similarity-based retrieval |
+| **ReasoningBank** | Reasoning-enhanced retrieval; suited for complex reasoning chains |
+| **ReMe** | Reflection-based retrieval; focuses on learning from failures |
+
+---
+
+## Environment Variables
+
+| Variable | Description |
+|----------|-------------|
+| `TASK_MEMORY_LLM_MODEL` | LLM model for task memory |
+| `TASK_MEMORY_EMBED_MODEL` | Embedding model for task memory |
+| `TASK_MEMORY_API_KEY` | API key for task memory |
+| `TASK_MEMORY_API_BASE` | API base URL for task memory |
+
+---
+
+## See Also
+
+- [Memory](Memory.md) — Built-in and external memory overview
+- [Configuration](Configuration.md) — Full `task_memory` section configuration
\ No newline at end of file
diff --git a/docs/en/ToolPermissionsSecurity.md b/docs/en/ToolPermissionsSecurity.md
new file mode 100644
index 0000000000..10fa2afc19
--- /dev/null
+++ b/docs/en/ToolPermissionsSecurity.md
@@ -0,0 +1,153 @@
+# Tool Permissions & Security
+
+This document explains how JiuwenClaw **tool call permissions** (`allow` / `ask` / `deny`) take effect, how they relate to **workspace-external paths**, **built-in security rules**, **user approval persistence**, and what the **CLI `/add-dir`** command changes in configuration.
+
+The main configuration file is typically `~/.jiuwenclaw/config/config.yaml`; you can override this via the `JIUWENCLAW_CONFIG_DIR` environment variable (consistent with [Configuration](Configuration.md)).
+
+---
+
+## 1. Overview
+
+| Capability | Description |
+|-----------|-------------|
+| **Three-tier actions** | `allow` executes directly; `ask` requires user confirmation (Web/CLI, etc.); `deny` rejects. |
+| **Master switch** | `permissions.enabled`; when disabled, the engine returns `allow` for all tool calls (still recommended to keep enabled in production). |
+| **Policy mode** | When `permissions.schema: tiered_policy` (and compatible aliases), **tiered policy** is enabled; otherwise, legacy tool-level matching is used. |
+| **Channels subject to checks** | Only when `channel_id` belongs to the engine's约定 set (`web` / `acp` / `cli`, etc.) are tool permission checks performed; others may skip. |
+
+In digital persona and group chat scenarios, `ask` may be downgraded to `deny` — see [Channels](Channels.md) for `owner_scopes` details.
+
+---
+
+## 2. Tiered Policy Resolution — How a Tool Call Gets Its Level
+
+This corresponds to `evaluate_tiered_policy()` in `jiuwenclaw/agentserver/permissions/tiered_policy.py`. Parameters are the current `tool_name` and `tool_args` (e.g. bash `command`, file-read `path`, etc.).
+
+### 2.1 Setup: `permission_mode` and `severity`
+
+- `permissions.permission_mode`: `normal` (default) or `strict`.
+- If a parameter-level rule (built-in or user) specifies an explicit **`action: allow|ask|deny`**, that action is used **directly** — `severity` is not consulted.
+- Without an explicit `action`, **`severity`** is mapped to an action based on `permission_mode`:
+
+| severity | normal mode | strict mode |
+|----------|-------------|-------------|
+| LOW | allow | allow |
+| MEDIUM | allow | **ask** |
+| HIGH | **ask** | **ask** |
+| CRITICAL | **ask** | **deny** |
+
+Unknown `severity` is treated as **HIGH**.
+
+### 2.2 How Parameter-Level Rules "Match"
+
+- A rule must include the current **`tool_name`**, and all tools listed in the same rule must belong to the **same category** (shell / path / network); otherwise the rule is skipped.
+- **Shell category**: `pattern` matches the full `command` / `cmd` string (supports glob and `re:` regex).
+- **Path category**: `pattern` matches path-like strings extracted from `tool_args` (common key names + path-like values); `re:` patterns normalize `\` → `/` before matching.
+- **Network category**: Currently not matched by parameter rules per product design (see code comments).
+- A single call can **match multiple** parameter rules; the **strictest** result wins (see §2.4).
+
+### 2.3 `evaluate_tiered_policy` Step-by-Step (Core Logic)
+
+1. **Whole-tool baseline** `_baseline_level`: reads `permissions.tools.<tool_name>`.
+ - If **`deny`**: **immediately return DENY** — no parameter rules, overrides, or defaults are consulted.
+ - If `allow` / `ask` / unconfigured: noted for later use when no parameter-level match occurs.
+
+2. **Collect built-in parameter rule hits** `builtin_hits` (from `builtin_rules.yaml` via `get_builtin_security_rules()`).
+ - If **any** hit is **DENY**: **immediately return** (finalized from built-in hits only; built-in **DENY takes precedence over same-level other results**).
+
+3. **Collect user parameter rule hits** `user_hits` (from `permissions.rules`).
+ - If **any** hit is **DENY**: **immediately return** (user parameter-level **DENY takes effect at this stage**).
+ - Note: this happens **before** `approval_overrides`, so a user rule `deny` can block an override that would otherwise match (the override is never evaluated).
+
+4. **`approval_overrides`** (only `action: allow` entries participate):
+ - If **at least one** matches the current `tool_name` + `tool_args`: **immediately return ALLOW**, with `matched_rule` prefixed `tiered_policy:approval_overrides:...`.
+ - Does **NOT** override step 2's built-in DENY (never reached). Does **NOT** override step 3's user parameter DENY.
+
+5. **If not returned by override**: if **`builtin_hits` is non-empty**, **`_finalize_hits(builtin_hits)` is returned** — **`user_hits` are NOT used** for final level merging.
+ - Meaning: if built-in has any parameter-level hit (and no deny or override has triggered), **only built-in hits determine the result**; user `rules` hits on the same call do not participate in cross-layer "strictest" merging.
+
+6. **If `builtin_hits` is empty** and **`user_hits` is non-empty**: `_finalize_hits(user_hits)` is returned.
+
+7. **If no parameter-level matches at all**: if the tool baseline **`bl` is configured** (`allow`/`ask`), return that level and `tools.<name>`.
+
+8. Otherwise, if **`defaults."*"`** exists, parse it as a level and return.
+
+9. Otherwise return **ASK** with `matched_rule` = `tiered_policy:fallback(no_config)` (the engine may treat this as "no configuration").
+
+`_finalize_hits`: if the hit list contains **DENY**, result is **DENY**; otherwise, take the **strictest** of `allow/ask` hits (strictness order: `deny > ask > allow`).
+
+### 2.4 What the Engine Does After `tiered_policy`
+
+In `PermissionEngine.evaluate_global_policy_directly`, after getting the `evaluate_tiered_policy` result:
+
+1. **`maybe_escalate_shell_operators`**: if the result is **NOT** from `approval_overrides`, and the tool is shell-type, **allow** may be escalated to **ask** if the command contains chaining/injection-risk characters.
+2. **`external_directory` (optional)**: if `include_external_directory=True`, `ExternalDirectoryChecker` evaluates paths outside the workspace; the result is **strictest-merged** with the current level. `matched_rule` may get `|external_directory.*` appended.
+
+On the `check_permission` path, tiered results are typically computed **without** external-directory first, then merged separately — this is equivalent to "compute in one step" from the user-visible perspective (see `core.py` for details).
+
+---
+
+## 3. Built-in Security Rules `builtin_rules.yaml`
+
+- **Package default**: `jiuwenclaw/resources/builtin_rules.yaml`.
+- **User override**: A `builtin_rules.yaml` in the **same directory** as `config.yaml` (i.e. `JIUWENCLAW_CONFIG_DIR` or default `~/.jiuwenclaw/config/`) takes **priority** if it exists.
+
+Built-in rules mostly cover **shell high-risk commands** (deletion, formatting, download-and-execute, privilege escalation, etc.), some with explicit `action: deny`. User `rules` cannot override built-in denials (built-in deny returns first).
+
+---
+
+## 4. `external_directory` (Workspace-External Paths)
+
+When a tool call involves **paths outside the agent workspace**, `ExternalDirectoryChecker` applies an additional check based on `permissions.external_directory`:
+
+- Configured as a **dict**: `"*": ask` means default to asking for external paths; **specific prefixes** can be set to `allow` / `deny` / `ask`.
+- **Keys** are path prefixes (use forward slashes, e.g. `C:/Users/me/data`); **overly short keys** (e.g. just a drive letter without `/`) may be skipped in implementation to avoid matching entire drives.
+- **Tools subject to checking** include:
+ - **Shell**: `bash`, `mcp_exec_command`, `create_terminal` (path extraction from command strings per rules).
+ - **Path tools**: same set as in tiered path-tool matching (`read_file`, `write_file`, `list_dir`, `grep`, etc. — paths collected from arguments).
+
+Configuring `approval_overrides` without `external_directory` may still result in `ask` on the external-directory dimension; they are commonly used together.
+
+---
+
+## 5. `approval_overrides` (User "Always Allow" Persistence)
+
+When the user selects **"Remember this rule"** or equivalent persistence logic during approval, an entry is appended to `permissions.approval_overrides`. Fields typically include:
+
+- `id`, `tools`, `match_type` (`path` / `command`), `pattern`, `action` (e.g. `allow`), `source` (e.g. `user_approval`, `cli_add_dir`).
+
+**Shell-type** `pattern` prefixed with `re:` is a regex matching the **entire command string**.
+**Path-type** `re:` patterns normalize `\` → `/` in path strings before matching.
+
+---
+
+## 6. CLI: `/add-dir` and `persist_cli_trusted_directory`
+
+In the terminal TUI, `/add-dir <path>` sends a `command.add_dir` request. The server calls `persist_cli_trusted_directory`. Key behaviors:
+
+1. **`external_directory`**: writes an `allow` entry for the resolved directory path (keyed by normalized path with forward slashes).
+2. **If `schema` is `tiered_policy`**: appends or updates two **`approval_overrides`** entries (one for **path tools**, one for **shell tools**), with `source` = `cli_add_dir`.
+3. **Shell-side pattern**: currently generates a literal match fragment using **forward-slash paths** (e.g. `re:.*C:/Users/me.*`), avoiding `C:\Users` in YAML double-quotes which would cause regex `\U` illegal escape and invalidate the entire rule.
+ At runtime, command text has `\` → `/` normalization applied before matching, ensuring compatibility with Windows command syntax.
+
+If not using `tiered_policy`, typically **only** `external_directory` is updated; `approval_overrides` is not written (log will explain).
+
+---
+
+## 7. Related Files (Developer Reference)
+
+| Module | Path |
+|--------|------|
+| Tiered policy | `jiuwenclaw/agentserver/permissions/tiered_policy.py` |
+| External directory checker | `jiuwenclaw/agentserver/permissions/checker.py` (`ExternalDirectoryChecker`) |
+| Persistence / `add_dir` | `jiuwenclaw/agentserver/permissions/patterns.py` (`persist_cli_trusted_directory`, etc.) |
+| Engine merging | `jiuwenclaw/agentserver/permissions/core.py` |
+| WebSocket command | `jiuwenclaw/agentserver/agent_ws_server.py` (`_handle_command_add_dir`) |
+
+---
+
+## 8. See Also
+
+- [Configuration](Configuration.md): `JIUWENCLAW_CONFIG_DIR`, configuration file location.
+- [CLI Commands](CLI.md): CLI/TUI entry points (including slash commands).
+- [Channels](Channels.md): `owner_scopes`, digital persona, and `ask` downgrade.
\ No newline at end of file
diff --git a/docs/en/WindowsAutoUpdateDesign.md b/docs/en/WindowsAutoUpdateDesign.md
index 983aef2bbf..880d4f3bb5 100644
--- a/docs/en/WindowsAutoUpdateDesign.md
+++ b/docs/en/WindowsAutoUpdateDesign.md
@@ -1,53 +1,53 @@
-# Windows auto-update design
+# Windows Auto-Update Design
-Minimal auto-update path for the **Windows desktop** build: stability first, not silent “magic” upgrades.
+This document describes the minimum viable auto-update solution for JiuwenClaw on Windows desktop. The goal is to prioritize stability over seamless upgrades.
## Scope
-- Windows desktop only
-- Check once at startup
-- Manual check from the sidebar **Update** page
-- Source: **GitHub Releases**
-- Installer: Inno Setup **`jiuwenclaw-setup-<version>.exe`**
-- After download, an external helper runs a **silent** install and restarts the app
+- Windows desktop edition only
+- Automatic update check on startup
+- Manual update check via the sidebar "Update" page
+- Update source: GitHub Releases
+- Download artifact: Inno Setup installer `jiuwenclaw-setup-<version>.exe`
+- After download, an external helper script performs a silent install and restarts the application
-## Out of scope
+## Out of Scope
-- Delta/patch updates
-- In-place self-replacement while running
-- macOS auto-install
-- Skip lists, staged rollouts, multiple channels
-- Forced updates
+- No incremental/delta updates
+- No in-process self-replacement
+- No macOS auto-install
+- No version-skip, canary releases, or multi-channel distribution
+- No forced updates
-## Flow
+## Core Flow
-1. After start, the frontend calls `updater.check` asynchronously.
-2. Backend calls the GitHub Releases API for the latest release.
-3. If newer, record version, published time, notes, and installer URL.
-4. User clicks **Download** on the **Update** page.
-5. Backend downloads the installer to `%USERPROFILE%\.jiuwenclaw\.updates`.
-6. When done, the frontend calls pywebview to **install**.
-7. The desktop process writes a temporary **cmd** helper that waits for exit.
-8. Helper runs Inno Setup **silently**, then restarts `jiuwenclaw.exe`.
+1. After app launch, the frontend asynchronously calls `updater.check`
+2. The backend requests the GitHub Releases API for the latest release
+3. If a new version is found, it records the latest version, publish date, release notes, and installer download URL
+4. The user clicks "Download Update" on the Update page
+5. The backend downloads the installer to `%USERPROFILE%\\.jiuwenclaw\\.updates` in the background
+6. After download completes, the frontend calls the pywebview API to trigger installation
+7. The desktop process writes a temporary `cmd` helper script that waits for the current process to exit
+8. The helper runs the Inno Setup installer silently, then restarts the application
-## Source
+## Update Source
-GitHub Releases API:
+Default GitHub Releases API:
```text
https://api.github.com/repos/{owner}/{repo}/releases/latest
```
-Read:
+Fields read from the release:
-- `tag_name` — version
+- `tag_name` — latest version number
- `body` — release notes
-- `published_at` — time
-- `assets[]` — installer and optional `.sha256`
+- `published_at` — publish date
+- `assets[]` — the installer and optional sha256 file
-## Config
+## Configuration
-`config.yaml` → `updater`:
+Update settings are in the `updater` section of `config.yaml`:
```yaml
updater:
@@ -60,15 +60,15 @@ updater:
timeout_seconds: 20
```
-## RPC
+## Backend API
-WebSocket RPC methods:
+Three WebSocket RPC methods are registered:
- `updater.get_status`
- `updater.check`
- `updater.download`
-States:
+Status values:
- `idle`
- `checking`
@@ -80,16 +80,18 @@ States:
- `error`
- `unsupported`
-## Install mechanics
+## Installation Execution
-The running exe is not replaced in-process.
+To avoid replacing files while the main process is running, installation is not performed within the current process.
-1. Desktop app writes a temp **cmd** helper.
-2. Helper waits for the main process to exit.
-3. Runs the installer:
+When the desktop process receives an install request from the frontend:
+
+1. It generates a temporary `cmd` helper script
+2. The helper waits for the desktop main process to exit
+3. The helper runs the installer with:
```text
/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /CLOSEAPPLICATIONS
```
-4. Starts `jiuwenclaw.exe` again after install completes.
+4. After installation completes, it restarts `jiuwenclaw.exe`
\ No newline at end of file
diff --git a/docs/en/development-practices/JiuwenClaw-Code-Review-Assistant.md b/docs/en/development-practices/JiuwenClaw-Code-Review-Assistant.md
index 01131d333b..5d9311da2e 100644
--- a/docs/en/development-practices/JiuwenClaw-Code-Review-Assistant.md
+++ b/docs/en/development-practices/JiuwenClaw-Code-Review-Assistant.md
@@ -1383,7 +1383,7 @@ ATOMGIT_TOKEN=xxx
```yaml
react:
agent_name: main_agent
- max_iterations: 50
+ max_iterations: 100
model_name: ${MODEL_NAME:-glm-4.7}
answer_chunk_size: 500
stream_chunk_threshold: 50
@@ -1399,7 +1399,7 @@ react:
evolution:
enabled: true
auto_scan: false
- skill_base_dir: "workspace/agent/skills"
+ skill_base_dir: "agent/skills"
tools:
- todo
diff --git "a/docs/zh/MCP\351\205\215\347\275\256.md" "b/docs/zh/MCP\351\205\215\347\275\256.md"
new file mode 100644
index 0000000000..71ff5b0b60
--- /dev/null
+++ "b/docs/zh/MCP\351\205\215\347\275\256.md"
@@ -0,0 +1,120 @@
+# MCP 服务配置
+
+JiuwenClaw 支持通过 MCP(Model Context Protocol)接入外部工具服务。MCP 使 Agent 可以调用由第三方提供的工具,扩展能力范围。
+
+---
+
+## 两种 MCP 使用场景
+
+| 场景 | 配置方式 | 说明 |
+|------|---------|------|
+| **浏览器运行时 MCP** | 环境变量(`.env`) | Playwright 浏览器自动化的 MCP 封装,详见 [浏览器工具](浏览器.md) |
+| **通用 MCP Server** | `config.yaml` → `mcp.servers` | 接入任意 MCP 服务(stdio / sse / streamable-http),本文档重点 |
+
+---
+
+## 配置 MCP Server
+
+在 `config/config.yaml` 中添加 MCP 服务:
+
+```yaml
+mcp:
+ servers:
+ - name: my-local-tool
+ enabled: true
+ transport: stdio
+ command: python
+ args: ["path/to/server.py", "--transport", "stdio"]
+ cwd: .
+ env:
+ LOG_LEVEL: INFO
+
+ - name: remote-api
+ enabled: false
+ transport: sse
+ url: http://127.0.0.1:9000/sse
+ headers:
+ Authorization: Bearer your-token-here
+ timeout_s: 30
+
+ - name: remote-streamable
+ enabled: true
+ transport: streamable-http
+ url: http://127.0.0.1:8000/mcp
+ timeout_s: 60
+```
+
+---
+
+## 字段说明
+
+| 字段 | 类型 | 必填 | 说明 |
+|------|------|------|------|
+| `name` | string | 是 | 服务标识,需全局唯一 |
+| `enabled` | bool | 是 | 是否启用该服务 |
+| `transport` | string | 是 | 传输协议:`stdio`、`sse`、`streamable-http` |
+| `command` | string | stdio 时必填 | 启动命令(如 `python`、`npx`) |
+| `args` | list | 否 | 命令参数列表 |
+| `cwd` | string | 否 | 工作目录 |
+| `env` | map | 否 | 传给子进程的环境变量 |
+| `url` | string | sse/streamable-http 时必填 | 服务端地址 |
+| `headers` | map | 否 | 请求头(如 Authorization) |
+| `timeout_s` | int | 否 | 请求超时秒数 |
+
+---
+
+## 传输协议对比
+
+| 协议 | 适用场景 | 说明 |
+|------|---------|------|
+| **stdio** | 本地工具服务 | Agent 启动子进程,通过标准输入/输出通信。适合本地 Python/Node 脚本 |
+| **sse** | 远程 HTTP 服务 | Server-Sent Events 协议。适合已有 HTTP 服务端 |
+| **streamable-http** | 远程 HTTP 服务(推荐) | 基于 HTTP 的流式协议,性能优于 SSE。推荐远程服务使用 |
+
+---
+
+## Agent 侧管理命令
+
+在对话中使用 `/mcp` 命令管理 MCP 服务:
+
+```
+/mcp list # 列出已配置的 MCP 服务及状态
+/mcp reload # 重新加载所有 MCP 服务
+/mcp enable <name> # 启用指定服务
+/mcp disable <name> # 禁用指定服务
+```
+
+---
+
+## 浏览器 MCP 运行时
+
+浏览器自动化使用独立的 MCP 运行时配置,通过环境变量控制:
+
+| 环境变量 | 说明 | 默认值 |
+|----------|------|--------|
+| `BROWSER_RUNTIME_MCP_ENABLED` | 是否启用浏览器 MCP 运行时 | `1` |
+| `BROWSER_RUNTIME_MCP_CLIENT_TYPE` | 客户端类型:`streamable-http` / `sse` / `stdio` | `streamable-http` |
+| `BROWSER_RUNTIME_MCP_SERVER_PATH` | MCP 服务地址 | `http://127.0.0.1:8940/mcp` |
+| `BROWSER_RUNTIME_MCP_TIMEOUT_S` | 超时秒数 | `300` |
+| `BROWSER_RUNTIME_MCP_HOST` | 本地包装器主机 | `127.0.0.1` |
+| `BROWSER_RUNTIME_MCP_PORT` | 本地包装器端口 | `8940` |
+
+详见 [浏览器工具](浏览器.md)。
+
+---
+
+## 环境变量
+
+| 变量 | 说明 |
+|------|------|
+| `BROWSER_RUNTIME_MCP_ENABLED` | 启用/禁用浏览器 MCP 运行时 |
+| `BROWSER_RUNTIME_MCP_CLIENT_TYPE` | 浏览器 MCP 客户端类型 |
+| `BROWSER_RUNTIME_MCP_SERVER_PATH` | 浏览器 MCP 服务地址 |
+| `BROWSER_RUNTIME_MCP_TIMEOUT_S` | 浏览器 MCP 超时 |
+
+---
+
+## 详见
+
+- [浏览器工具](浏览器.md) — 浏览器 MCP 运行时详细配置
+- [配置说明](配置信息.md) — 完整配置参考
\ No newline at end of file
diff --git a/docs/zh/Quickstart.md b/docs/zh/Quickstart.md
index 4665dd8233..d89771012d 100644
--- a/docs/zh/Quickstart.md
+++ b/docs/zh/Quickstart.md
@@ -92,7 +92,7 @@ JiuwenClaw提供两种安装方式:`pip安装`或`源码安装`。
uv run jiuwenclaw-start
```
- - 动态运行前端服务(适合生开发调试)
+ - 动态运行前端服务(适合开发调试)
```bash
cd ../../
uv run jiuwenclaw-init
@@ -140,7 +140,7 @@ JiuwenClaw提供两种安装方式:`pip安装`或`源码安装`。
jiuwenclaw-start
```
- - 动态运行前端服务(适合生开发调试)
+ - 动态运行前端服务(适合开发调试)
```bash
cd ../../
# 直接启动(不使用 uv run)
diff --git a/docs/zh/README.md b/docs/zh/README.md
index 26a25dd2bf..f15133435e 100644
--- a/docs/zh/README.md
+++ b/docs/zh/README.md
@@ -2,19 +2,38 @@
这里汇总 JiuwenClaw 的常用使用说明与功能文档。
-- 从零开始安装与启动:见 [快速开始](Quickstart.md)
+- 从零开始安装与启动:见 [快速开始](Quickstart.md) / [TUI 模式](Quickstart_tui.md)
- Gateway 与 AgentServer 统一请求信封(E2A):见 [E2A 协议](E2A-protocol.md)([English](../en/E2A-protocol.md))
+- A2A 协议接入:见 [A2A 接入说明](A2A.md)([English](../en/A2A.md))
+- ACP 插件配置:见 [ACP 插件使用](ACP插件使用.md)
- 配置模型与系统参数:见 [配置说明](配置信息.md)
-- 各功能专题文档:见左侧目录或直接从下列入口开始:
- - [频道](频道.md)
- - [命令行指令](命令行指令.md)
- - [心跳](心跳.md)
- - [定时任务](定时任务.md)
- - [任务规划](任务规划.md)
- - [记忆系统](记忆.md)
- - [上下文压缩卸载](上下文压缩卸载.md)
- - [技能系统](技能.md)
- - [Skill 自演进](Skill自演进.md)
- - [智能体与工作区](智能体.md)
- - [浏览器工具](浏览器.md)
- - [打包 exe 指南](打包exe指南.md)
+
+各功能专题文档:
+
+- [频道](频道.md) — 飞书、Discord、WhatsApp、Web 等
+- [模式系统](模式系统.md) — PLAN / AGENT / CODE / TEAM 模式切换与配置
+- [命令行指令](命令行指令.md)
+- [心跳](心跳.md)
+- [定时任务](定时任务.md)
+- [任务规划](任务规划.md)
+- [记忆系统](记忆.md)
+- [经验记忆](经验记忆.md) — 任务级经验检索与沉淀
+- [上下文压缩卸载](上下文压缩卸载.md)
+- [编码记忆](编码记忆.md) — Code 模式专属记忆
+- [技能系统](技能.md)
+- [Skill 自演进](Skill自演进.md)
+- [智能体与工作区](智能体.md)
+- [浏览器工具](浏览器.md)
+- [MCP 配置](MCP配置.md) — MCP 服务接入与配置
+- [工具权限与安全防护](工具权限与安全防护.md)
+- [Slash 命令架构](SLASH_COMMAND_ARCHITECTURE.md)
+- [Slash 命令速查](Slash命令表.md)
+- [分布式 Team](分布式Team.md)([English](../en/DistributedTeam.md))
+- [单机多实例运行](单机多实例运行.md)([English](../en/MultiInstance.md))
+- [打包 exe 指南](打包exe指南.md)
+- [Windows 自动更新设计](windows自动更新设计.md)
+
+开发实践:
+
+- [JiuwenClaw 代码审查助手](开发实践/JiuwenClaw代码审查助手开发实践.md)
+- [JiuwenClaw 日报生成器](开发实践/JiuwenClaw日报生成器开发实践.md)
\ No newline at end of file
diff --git a/docs/zh/SLASH_COMMAND_ARCHITECTURE.md b/docs/zh/SLASH_COMMAND_ARCHITECTURE.md
index 25aa362e91..c10864fb12 100644
--- a/docs/zh/SLASH_COMMAND_ARCHITECTURE.md
+++ b/docs/zh/SLASH_COMMAND_ARCHITECTURE.md
@@ -1,7 +1,7 @@
# Slash 命令体系设计(架构说明)
> **文档性质**:架构与演进约定,描述「单一事实来源」、分层边界与落地原则。
-> **与现有文档关系**:能力清单与入口对照见 [`CLI_COMMANDS.md`](./CLI_COMMANDS.md)、[`命令行指令.md`](./命令行指令.md);本文不重复罗列全部命令,只定义**如何组织与避免漂移**。
+> **与现有文档关系**:能力清单与入口对照见 [`命令行指令.md`](./命令行指令.md);本文不重复罗列全部命令,只定义**如何组织与避免漂移**。
---
@@ -50,7 +50,7 @@
**定义**:仅在 CLI TUI、Web REPL 等**本地**解析与执行,或明确不应经 Gateway 做语义拦截的命令。
-**典型**:CLI 的界面切换、`/resume`、`/model`(若仅本地配置)、帮助/诊断类 stub 等(以 [`CLI_COMMANDS.md`](./CLI_COMMANDS.md) 为准)。
+**典型**:CLI 的界面切换、`/resume`、`/model`(若仅本地配置)、帮助/诊断类 stub 等(以 [`命令行指令.md`](./命令行指令.md) 为准)。
**要求**:
@@ -86,7 +86,7 @@
| `scope` | `gateway`(本设计主体)。 |
| `channels` | `all_controlled` 或显式列表,与配置中的通道类型对齐。 |
| `intercept` | 命中且合法时是否不转发 Agent(与现 `_handle_channel_control` 语义一致)。 |
-| `notes` | 与 CLI 别名、文档锚点的交叉引用(链接到 `CLI_COMMANDS.md` 章节)。 |
+| `notes` | 与 CLI 别名、文档锚点的交叉引用(链接到 [`命令行指令.md`](./命令行指令.md) 章节)。 |
### 4.3 与 `MessageHandler` 的关系
@@ -102,7 +102,7 @@
| **Gateway `MessageHandler`** | 受控通道用户文本进入统一控制逻辑前,以 SSOT 为准做判定。 |
| **`im_inbound` 等管线** | 若需提前过滤或统计,**import 同一常量/函数**,禁止维护独立 `frozenset` 子集。 |
| **Feishu / WeCom 等 Channel** | 若因协议必须在 Channel 层做轻量判断,应**复用 SSOT**或仅做「是否可能为控制指令」的粗筛,最终语义以 Gateway 为准;若存在双点判断,须在注册表 `notes` 中写明并压测避免重复提示。 |
-| **CLI** | 继续维护 TS `registry`;与 A 类命令**名称对齐**见 [`CLI_COMMANDS.md`](./CLI_COMMANDS.md) 与本文第 3.3 节,不在 Gateway 重复实现 B 类。 |
+| **CLI** | 继续维护 TS `registry`;与 A 类命令**名称对齐**见 [`命令行指令.md`](./命令行指令.md) 与本文第 3.3 节,不在 Gateway 重复实现 B 类。 |
---
@@ -126,7 +126,7 @@
|------|------|
| **P0** | 提炼 A 类命令到 SSOT 模块;`im_inbound` 等改为引用,消除集合漂移。 |
| **P1** | 收敛 `message_handler.py` 内联解析到对 SSOT 的调用,行为不变。 |
-| **P2** | 在文档矩阵中补齐 B/C 类与 `CLI_COMMANDS.md` 的交叉引用;可选:生成给前端的只读清单(若未来需要统一补全)。 |
+| **P2** | 在文档矩阵中补齐 B/C 类与 [`命令行指令.md`](./命令行指令.md) 的交叉引用;可选:生成给前端的只读清单(若未来需要统一补全)。 |
---
diff --git a/docs/zh/SUMMARY.md b/docs/zh/SUMMARY.md
index fb7726a1d9..8758464594 100644
--- a/docs/zh/SUMMARY.md
+++ b/docs/zh/SUMMARY.md
@@ -1,27 +1,38 @@
# Summary
- [快速开始](Quickstart.md)
+- [快速开始(TUI)](Quickstart_tui.md)
- [E2A 协议(Gateway↔Agent)](E2A-protocol.md)
- [A2A 接入说明](A2A.md)
- [配置说明](配置信息.md)
- [分布式 Team](分布式Team.md)
+- [单机多实例运行](单机多实例运行.md)
- [使用指南](README.md)
- [频道](频道.md)
- [Discord](Discord.md)
- [WhatsApp(中文)](whatsapp.md)
- [WhatsApp(English)](../en/WhatsApp.md)
+ - [模式系统](模式系统.md)
- [命令行指令](命令行指令.md)
+ - [Slash 命令速查表](Slash命令表.md)
+ - [Slash 命令体系设计](SLASH_COMMAND_ARCHITECTURE.md)
+ - [工具权限与安全防护](工具权限与安全防护.md)
- [心跳](心跳.md)
- [定时任务](定时任务.md)
- [任务规划](任务规划.md)
- [记忆系统](记忆.md)
+ - [经验记忆](经验记忆.md)
- [上下文压缩卸载](上下文压缩卸载.md)
+ - [编码记忆](编码记忆.md)
- [技能系统](技能.md)
- [Skill 自演进](Skill自演进.md)
- [智能体与工作区](智能体.md)
- [浏览器工具](浏览器.md)
+ - [MCP 配置](MCP配置.md)
- [打包 exe 指南](打包exe指南.md)
+ - [ACP 插件使用](ACP插件使用.md)
+ - [Windows 自动更新设计](windows自动更新设计.md)
- [开发实践](开发实践/README.md)
- [日报生成器开发实践](开发实践/JiuwenClaw日报生成器开发实践.md)
- [代码审查助手开发实践](开发实践/JiuwenClaw代码审查助手开发实践.md)
-
+- [Linux NFS 共享文件系统](../linux-agent-teams-shared-filesystem.md)
\ No newline at end of file
diff --git "a/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md" "b/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md"
index 5b521d5083..e5f5bb86af 100644
--- "a/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md"
+++ "b/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md"
@@ -40,6 +40,7 @@
| `/mcp` | MCP 服务管理(见下文) |
| `/diff` | 查看当前会话按轮次改动(见下文) |
| `/compact` | 压缩当前上下文(见下文) |
+| `/init` | 项目初始化(见下文) |
---
@@ -135,6 +136,17 @@
- `compressed`:压缩成功,显示压缩前后 token 数及节省比例;
- `noop`:无需压缩,上下文已处于最优状态。
+### `/init`(项目初始化)
+
+- 用法:`/init`(无参数)。
+- 功能:初始化项目 AI 协作配置,生成 `JIUWENCLAW.md` 和可选的 `JIUWENCLAW.local.md`。
+- 适用范围:仅在 `code` 模式下运行。
+- 流程:
+ 1. 选择范围:`团队共享`(JIUWENCLAW.md)、`个人私有`(JIUWENCLAW.local.md)或 `都要`。
+ 2. 检测已有配置:自动检测 `CLAUDE.md`、`.cursorrules`、`copilot-instructions.md` 等文件。
+ 3. 生成配置:根据选择生成项目配置文件。
+- 自动模式切换:若当前处于 `code.plan` 模式,会自动切换到 `code.normal` 以便写入文件。
+
### `/mcp`(MCP 服务管理)
- 用法:
@@ -180,7 +192,6 @@
| 命令 | 说明 |
|----------------|---------|
-| `/init` | 项目初始化 |
| `/btw` | 提问 |
| `/context` | 上下文状态查看 |
| `/export` | 导出相关文件 |
diff --git "a/docs/zh/\345\210\206\345\270\203\345\274\217Team.md" "b/docs/zh/\345\210\206\345\270\203\345\274\217Team.md"
index 18c41543b9..f1425f7b0d 100644
--- "a/docs/zh/\345\210\206\345\270\203\345\274\217Team.md"
+++ "b/docs/zh/\345\210\206\345\270\203\345\274\217Team.md"
@@ -40,7 +40,56 @@ English: [Distributed Team](../en/DistributedTeam.md)
---
-## 3. 代码落点(改 bug / 跟逻辑时从这里进)
+## 3. pyzmq Transport 字段归一化
+
+当 `transport.type == pyzmq` 且 **`pubsub_publish_addr` / `pubsub_subscribe_addr` 尚未同时存在** 时,`TeamManager` 会根据 `params.leader` / `params.teammate` 等拓扑信息自动补全:
+
+| 字段 | 说明 |
+|------|------|
+| `direct_addr` | 本进程直接通信地址 |
+| `pubsub_publish_addr` | 发布地址 |
+| `pubsub_subscribe_addr` | 订阅地址 |
+| `known_peers` / `bootstrap_peers` | 节点发现列表 |
+| `metadata.pubsub_bind` | 是否绑定 pubsub(leader=True,teammate=False) |
+
+默认端口:
+- Leader: `direct_port=18555`, `pub_port=18556`, `sub_port=18557`
+- Teammate: `direct_port=18600`
+
+---
+
+## 4. PostgreSQL Bootstrap(Leader 角色)
+
+当 `team.storage.type=postgresql` 且当前进程角色为 `leader` 时,启动时会自动检测 PostgreSQL 可用性:
+
+1. 检查 `pg_isready -h <host> -p <port>`
+2. 若不可达,尝试启动本地 PostgreSQL 集群:
+ - 先尝试 `pg_ctlcluster <version> <cluster> start`
+ - 失败则尝试 `systemctl start postgresql` 或 `service postgresql start`
+3. 等待最多 30 秒确认服务就绪
+
+配置示例:
+
+```yaml
+team:
+ storage:
+ type: postgresql
+ params:
+ connection_string: postgresql+asyncpg://user:pass@host:5432/teamdb
+```
+
+---
+
+## 5. teammate_mode 与 spawn_mode
+
+| 配置 | 值 | 说明 |
+|------|-----|------|
+| `teammate_mode` | `build_mode`(默认) | teammate 通过 build 流程构建 |
+| `spawn_mode` | `inprocess`(默认) | teammate 在同一进程内运行 |
+
+---
+
+## 6. 代码落点(改 bug / 跟逻辑时从这里进)
### 3.1 `TeamManager._load_team_spec`
diff --git "a/docs/zh/\345\215\225\346\234\272\345\244\232\345\256\236\344\276\213\350\277\220\350\241\214.md" "b/docs/zh/\345\215\225\346\234\272\345\244\232\345\256\236\344\276\213\350\277\220\350\241\214.md"
new file mode 100644
index 0000000000..214212a759
--- /dev/null
+++ "b/docs/zh/\345\215\225\346\234\272\345\244\232\345\256\236\344\276\213\350\277\220\350\241\214.md"
@@ -0,0 +1,241 @@
+# 单机多实例运行
+
+支持在同一台机器上运行多个独立的 JiuwenClaw 实例,每个实例拥有独立的工作区、配置和端口。
+
+## 适用场景
+
+- **开发与生产隔离**:在开发机上同时运行测试实例和生产实例
+- **多租户环境**:为不同用户或项目创建独立的 Agent 实例
+- **多模式并行**:同时运行不同配置的 Agent(如不同模型、不同权限策略)
+
+---
+
+## 核心概念
+
+### 实例隔离
+
+每个实例具有独立的:
+
+| 资源 | 说明 |
+|------|------|
+| **工作区目录** | `workspace/` 目录,包含 SOUL.md、skills、memory 等 |
+| **配置文件** | `.env` 文件,包含 API_KEY、模型配置等 |
+| **端口** | AgentServer、Gateway、WebChannel、Frontend 各端口独立 |
+| **进程** | 独立进程组,通过 PID 文件管理 |
+| **启动锁** | 防止同一实例被多个终端同时启动 |
+
+### 实例命名规则
+
+- 长度:1-64 字符
+- 允许字符:字母、数字、下划线、连字符
+- 禁止以 `.` 开头
+- 保留名称:`default`、`config`、`tmp`、`jiuwenclaw`、`all`
+
+---
+
+## 配置文件
+
+### instances.yaml
+
+位置:`~/.jiuwenclaw/instances.yaml`(或仓库根目录)
+
+```yaml
+instances:
+ dev:
+ workspace: ~/.jiuwenclaw_dev
+ ports:
+ agent_server: 19092
+ web: 20000
+ gateway: 20001
+ frontend: 6173
+ prod:
+ workspace: ~/.jiuwenclaw_prod
+ ports:
+ agent_server: 20092
+ web: 21000
+ gateway: 21001
+ frontend: 7173
+```
+
+### 端口自动分配算法
+
+默认端口 = 基准端口 + 实例索引 × 1000
+
+| 服务类型 | 基准端口 | 默认实例 (index=0) | 第一个命名实例 (index=1) |
+|----------|----------|-------------------|-------------------------|
+| agent_server | 18092 | 18092 | 19092 |
+| web | 19000 | 19000 | 20000 |
+| gateway | 19001 | 19001 | 20001 |
+| frontend | 5173 | 5173 | 6173 |
+
+---
+
+## 命令使用
+
+### jiuwenclaw-init --name
+
+创建命名实例:
+
+```bash
+# 创建 dev 实例
+jiuwenclaw-init --name dev
+
+# 创建 prod 实例(指定工作区)
+jiuwenclaw-init --name prod --workspace ~/.jiuwenclaw_prod
+```
+
+执行后会:
+1. 创建工作区目录
+2. 生成实例专属 `.env` 文件
+3. 更新 `instances.yaml` 配置
+4. 分配端口(自动或手动指定)
+
+### jiuwenclaw-start 管理命令
+
+```bash
+# 列出所有实例状态
+jiuwenclaw-start --list
+
+# 输出示例:
+# INSTANCE STATUS PID WORKSPACE PORTS
+# --------------------------------------------------------------------------------
+# default running 12345 ~/.jiuwenclaw as:18092,w:19000,g:19001,f:5173
+# dev stopped - ~/.jiuwenclaw_dev as:19092,w:20000,g:20001,f:6173
+# prod stopped - ~/.jiuwenclaw_prod as:20092,w:21000,g:21001,f:7173
+
+# 查看指定实例详情
+jiuwenclaw-start --status dev
+
+# 启动命名实例
+jiuwenclaw-start --name dev
+jiuwenclaw-start --name dev app # 仅启动后端
+jiuwenclaw-start --name dev web # 仅启动 Web 服务
+
+# 停止实例
+jiuwenclaw-start --stop dev
+
+# 重启实例
+jiuwenclaw-start --restart dev
+jiuwenclaw-start --restart dev app --mode app
+```
+
+---
+
+## 启动锁机制
+
+为防止同一实例被多个终端同时启动,系统使用文件锁:
+
+- 锁文件:`<workspace>/.instance.lock`
+- 锁超时:30 秒(`STALE_LOCK_TIMEOUT`)
+- 跨平台支持:
+ - Unix:`fcntl.flock`
+ - Windows:独占文件创建
+
+若启动时遇到锁冲突:
+
+```
+[start_services] ERROR: Instance 'dev' startup in progress by another process
+[start_services] Wait a few seconds or check if another terminal is starting this instance.
+```
+
+---
+
+## 环境变量
+
+| 变量 | 说明 |
+|------|------|
+| `JIUWENCLAW_DATA_DIR` | 覆盖数据根目录(影响 instances.yaml 位置) |
+| `JIUWENCLAW_CONFIG_DIR` | 覆盖配置目录 |
+
+启动时可通过 `--dotenv` 指定实例专属配置:
+
+```bash
+# 内部机制:启动命名实例时自动加载 bootstrap .env
+jiuwenclaw-start --name dev
+# 等价于加载 ~/.jiuwenclaw_dev/.env
+```
+
+---
+
+## PID 文件
+
+每个实例在工作区目录维护 PID 文件:
+
+- 文件名:`.instance.pid`
+- 内容:进程 ID + 启动时间戳
+- 用途:
+ - 状态查询(`--status`、`--list`)
+ - 进程控制(`--stop`、`--restart`)
+
+---
+
+## 最佳实践
+
+### 1. 端口规划
+
+避免端口冲突:
+
+```bash
+# 检查端口占用
+jiuwenclaw-start --status dev
+# 系统会自动检测并报告冲突
+```
+
+### 2. 配置隔离
+
+每个实例使用独立的 API Key 或模型配置:
+
+```bash
+# dev 实例 .env
+API_KEY="sk-dev-key"
+MODEL_NAME="deepseek-chat"
+
+# prod 实例 .env
+API_KEY="sk-prod-key"
+MODEL_NAME="gpt-4"
+```
+
+### 3. 工作区管理
+
+实例工作区包含 Agent 所有运行数据:
+
+```
+~/.jiuwenclaw_dev/
+├── .env # 实例配置
+├── .instance.pid # 进程管理
+├── .instance.lock # 启动锁
+├── workspace/
+│ ├── agent/
+│ │ ├── SOUL.md # Agent 个性
+│ │ ├── memory/ # 记忆存储
+│ │ └── skills/ # 技能目录
+│ └── session/ # 会话数据
+```
+
+---
+
+## 常见问题
+
+### Q: 如何删除实例?
+
+手动删除工作区目录和 instances.yaml 条目:
+
+```bash
+rm -rf ~/.jiuwenclaw_dev
+# 编辑 ~/.jiuwenclaw/instances.yaml 移除对应条目
+```
+
+### Q: 默认实例与命名实例的区别?
+
+- **默认实例**:无 `--name` 参数启动,使用 `~/.jiuwenclaw/` 工作区
+- **命名实例**:通过 `--name` 指定,使用独立工作区和端口
+
+### Q: 多实例能否共享配置?
+
+可以。在实例 `.env` 中引用共享配置:
+
+```bash
+# ~/.jiuwenclaw_dev/.env
+source ~/.jiuwenclaw/.env # 共享基础配置
+MODEL_NAME="special-model" # 实例专属覆盖
+```
\ No newline at end of file
diff --git "a/docs/zh/\345\221\275\344\273\244\350\241\214\346\214\207\344\273\244.md" "b/docs/zh/\345\221\275\344\273\244\350\241\214\346\214\207\344\273\244.md"
index 69079f14de..74e871cda2 100644
--- "a/docs/zh/\345\221\275\344\273\244\350\241\214\346\214\207\344\273\244.md"
+++ "b/docs/zh/\345\221\275\344\273\244\350\241\214\346\214\207\344\273\244.md"
@@ -3,7 +3,7 @@
JiuwenClaw 支持通过「特殊前缀指令」控制会话和模式,最常用的是:
- `/new_session`:为当前通道切换到一个全新的 `session_id`
-- `/mode plan`、`/mode fast` 或 `/mode team`:切换当前通道的工作模式
+- `/mode`:切换当前通道的工作模式(`plan` / `fast` / `code` / `team`)
这些指令由 Gateway 层的 `MessageHandler` 解析,**不会发给 Agent 本身**。
@@ -13,15 +13,18 @@ JiuwenClaw 支持通过「特殊前缀指令」控制会话和模式,最常用
**作用:**
-- 针对受控通道(当前支持:`feishu` / `xiaoyi` / `dingtalk`),为该通道生成一个新的 `session_id`,形如:
+- 针对受控通道(当前支持:`feishu` / `xiaoyi` / `dingtalk` / `whatsapp` / `wecom` / `wechat`),为该通道生成一个新的 `session_id`,形如:
- `feishu_<毫秒时间戳hex>_<随机hex>`
- `xiaoyi_<毫秒时间戳hex>_<随机hex>`
- `dingtalk_<毫秒时间戳hex>_<随机hex>`
+ - `whatsapp_<毫秒时间戳hex>_<随机hex>`
+ - `wecom_<毫秒时间戳hex>_<随机hex>`
+ - `wechat_<毫秒时间戳hex>_<随机hex>`
- 后续从该通道进来的所有普通聊天消息,都会被强制覆盖为这个新的 `session_id`,从而在 `workspace/session/` 下形成一个新的会话目录。
**使用方式:**
-- 在通道(飞书 / 小艺 / 钉钉)中,直接发送一条消息:
+- 在通道(飞书 / 小艺 / 钉钉 / WhatsApp / 企业微信 / 微信)中,直接发送一条消息:
```text
/new_session
@@ -40,13 +43,16 @@ JiuwenClaw 支持通过「特殊前缀指令」控制会话和模式,最常用
---
-### 2. `/mode` —— 切换通道模式(plan / fast / team)
+### 2. `/mode` —— 切换通道模式(plan / fast / code / team)
**作用:**
- 为当前通道设置一个逻辑「模式」,用于告诉 Agent 是偏向:
- - `plan`:偏规划、解释、拆解任务(默认)
- - `fast`:偏自动执行、直接动手(内部与历史 `agent` 模式一致)
+ - `plan`:偏规划、解释、拆解任务(默认,即 `agent.plan`)
+ - `fast`:偏自动执行、直接动手(内部与历史 `agent` 模式一致,即 `agent.fast`)
+ - `code`:代码模式,Agent 通过代码执行工具与环境交互
+ - `code.plan`:代码模式 + 规划风格
+ - `code.normal`:代码模式 + 直接执行风格
- `team`:组队模式
- 模式信息会写入消息的 `params["mode"]` 中,Agent 在构造提示词和行为策略时可以使用。
@@ -64,6 +70,12 @@ JiuwenClaw 支持通过「特殊前缀指令」控制会话和模式,最常用
/mode fast
```
+ 或
+
+ ```text
+ /mode code
+ ```
+
- Gateway 会:
1. 识别这条消息为控制指令,不转发给 Agent
2. 更新内部 `ChannelControlState.mode`
diff --git "a/docs/zh/\345\274\200\345\217\221\345\256\236\350\267\265/JiuwenClaw\344\273\243\347\240\201\345\256\241\346\237\245\345\212\251\346\211\213\345\274\200\345\217\221\345\256\236\350\267\265.md" "b/docs/zh/\345\274\200\345\217\221\345\256\236\350\267\265/JiuwenClaw\344\273\243\347\240\201\345\256\241\346\237\245\345\212\251\346\211\213\345\274\200\345\217\221\345\256\236\350\267\265.md"
index 40550819c7..9ef88c1fa0 100644
--- "a/docs/zh/\345\274\200\345\217\221\345\256\236\350\267\265/JiuwenClaw\344\273\243\347\240\201\345\256\241\346\237\245\345\212\251\346\211\213\345\274\200\345\217\221\345\256\236\350\267\265.md"
+++ "b/docs/zh/\345\274\200\345\217\221\345\256\236\350\267\265/JiuwenClaw\344\273\243\347\240\201\345\256\241\346\237\245\345\212\251\346\211\213\345\274\200\345\217\221\345\256\236\350\267\265.md"
@@ -1474,7 +1474,7 @@ JiuwenClaw 配置文件内容:
```yaml
react:
agent_name: main_agent
- max_iterations: 50
+ max_iterations: 100
model_name: ${MODEL_NAME:-glm-4.7}
answer_chunk_size: 500
stream_chunk_threshold: 50
@@ -1491,7 +1491,7 @@ react:
evolution:
enabled: true
auto_scan: false
- skill_base_dir: "workspace/agent/skills"
+ skill_base_dir: "agent/skills"
tools:
- todo
@@ -1741,7 +1741,7 @@ Agent 会按照技能指引执行审查流程,返回包含评分、问题列
`D:\Download\jiuwenclaw\workspace\agent\skills\code-review\`
6. **Agent 迭代次数超限**
- 问题:复杂任务达到 max_iterations (50) 后未完成
+ 问题:复杂任务达到 max_iterations (100) 后未完成
表现:返回 "Max iterations reached without completion"
原因:Agent 用浏览器逐个访问文件,效率太低
解决:确保 Agent 读取技能文档并按技能指引使用正确工具
diff --git "a/docs/zh/\345\274\200\345\217\221\345\256\236\350\267\265/README.md" "b/docs/zh/\345\274\200\345\217\221\345\256\236\350\267\265/README.md"
new file mode 100644
index 0000000000..ea60c79ef3
--- /dev/null
+++ "b/docs/zh/\345\274\200\345\217\221\345\256\236\350\267\265/README.md"
@@ -0,0 +1,8 @@
+# 开发实践
+
+基于 JiuwenClaw 的真实项目开发实践记录。
+
+- [JiuwenClaw 日报生成器开发实践](JiuwenClaw日报生成器开发实践.md) — 多源日报/周报/月报,集成心跳与飞书推送。
+- [JiuwenClaw 代码审查助手开发实践](JiuwenClaw代码审查助手开发实践.md) — 分层静态分析、评分与 Markdown / 飞书报告。
+
+英文版: `docs/en/development-practices/`。
\ No newline at end of file
diff --git "a/docs/zh/\346\211\223\345\214\205exe\346\214\207\345\215\227.md" "b/docs/zh/\346\211\223\345\214\205exe\346\214\207\345\215\227.md"
index 96473df317..3cd9e1d48e 100644
--- "a/docs/zh/\346\211\223\345\214\205exe\346\214\207\345\215\227.md"
+++ "b/docs/zh/\346\211\223\345\214\205exe\346\214\207\345\215\227.md"
@@ -120,17 +120,17 @@ chmod +x scripts/build-macos.sh
./scripts/build-macos.sh
```
-脚本会自动完成:安装依赖 → 构建前端 → 使用 PyInstaller 生成 `JiuwenClaw.app` → 生成 `JiuwenClaw-0.1.7.dmg`。
+脚本会自动完成:安装依赖 → 构建前端 → 使用 PyInstaller 生成 `JiuwenClaw.app` → 生成 `JiuwenClaw-<version>.dmg`。
生成后的产物:
- `dist/JiuwenClaw.app`
-- `dist/JiuwenClaw-0.1.7.dmg`
+- `dist/JiuwenClaw-<version>.dmg`
验证方式:
1. 双击 `dist/JiuwenClaw.app`
-2. 或挂载 `dist/JiuwenClaw-0.1.7.dmg`
+2. 或挂载 `dist/JiuwenClaw-<version>.dmg`
3. 将 `JiuwenClaw.app` 拖到 `Applications`
注意事项:
diff --git "a/docs/zh/\346\231\272\350\203\275\344\275\223.md" "b/docs/zh/\346\231\272\350\203\275\344\275\223.md"
index 546eba3c45..b89e723af9 100644
--- "a/docs/zh/\346\231\272\350\203\275\344\275\223.md"
+++ "b/docs/zh/\346\231\272\350\203\275\344\275\223.md"
@@ -68,7 +68,7 @@ workspace/
## 相关配置
-- **Skill 根目录**:`config/config.yaml` 中 `skill_base_dir` 默认为 `workspace/agent/skills`。
+- **Skill 根目录**:`config/config.yaml` 中 `skill_base_dir` 默认为 `agent/skills`。
- **记忆工作目录**:`workspace/agent`(即 `get_agent_workspace_dir()`)。
- **会话目录**:`workspace/session`,每个 `session_id` 对应一个子目录。
- **SkillNet 与技能在 Claw 中的使用方式**:详见 [技能.md](技能.md#5-skillnet-安装的技能在-claw-中如何被使用)。
diff --git "a/docs/zh/\346\250\241\345\274\217\347\263\273\347\273\237.md" "b/docs/zh/\346\250\241\345\274\217\347\263\273\347\273\237.md"
new file mode 100644
index 0000000000..12e0b304ff
--- /dev/null
+++ "b/docs/zh/\346\250\241\345\274\217\347\263\273\347\273\237.md"
@@ -0,0 +1,142 @@
+# 模式系统(Modes)
+
+JiuwenClaw 支持多种运行模式,不同模式对应不同的工具集、权限策略和记忆行为。用户可通过 `/mode` 命令在对话中切换。
+
+---
+
+## 模式总览
+
+| 模式 | 代号 | 说明 |
+|------|------|------|
+| Agent(规划) | `agent.plan` | 默认模式。全工具 + 主动记忆,侧重推理与规划 |
+| Agent(快速) | `agent.fast` | 全工具 + 被动记忆,侧重快速响应 |
+| Code(规划) | `code.plan` | 编码模式 + 编码记忆,侧重代码生成的规划 |
+| Code(常规) | `code.normal` | 编码模式 + 编码记忆,侧重代码执行 |
+| Team | `team` | 多 Agent 协作模式,基于配置中的 `team` 定义 |
+
+---
+
+## 切换命令
+
+在频道对话中输入以下命令切换模式:
+
+```
+/mode agent # 切换到 Agent 模式(默认使用 agent.plan)
+/mode code # 切换到 Code 模式(默认使用 code.normal)
+/mode team # 切换到 Team 模式
+/mode agent.plan # 直达 Agent 规划子模式
+/mode agent.fast # 直达 Agent 快速子模式
+/mode code.plan # 直达 Code 规划子模式
+/mode code.normal # 直达 Code 常规子模式
+```
+
+也可用 `/switch` 在同一大类内切换子模式:
+
+```
+/switch plan # Agent 下切到 plan;Code 下切到 plan
+/switch fast # Agent 下切到 fast
+/switch normal # Code 下切到 normal
+```
+
+---
+
+## 配置
+
+在 `config/config.yaml` 的 `modes` 段中定义各模式的工具和约束:
+
+```yaml
+modes:
+ agent:
+ fast:
+ memory:
+ enabled: true
+ is_proactive: false # 被动记忆
+ rails: []
+ tools: []
+ plan:
+ memory:
+ enabled: true
+ is_proactive: true # 主动记忆
+ rails: []
+ tools: []
+
+ code:
+ rails:
+ - FileSystemRail # 文件系统安全约束
+ - SkillUseRail # 技能调用约束
+ - LspRail # LSP 辅助约束
+ tools:
+ - web_free_search
+ - web_fetch_webpage
+ - web_paid_search
+ - user_todos
+ embedding_config:
+ model_name: null
+ base_url: null
+ api_key: null
+
+ team:
+ jiuwen_team:
+ team_name: jiuwen_team
+ lifecycle: persistent
+ teammate_mode: build_mode
+ spawn_mode: inprocess
+ leader:
+ member_name: team_leader
+ display_name: 团队领导
+ persona: "天才项目管理专家,擅长任务分解和团队协调"
+ agents:
+ leader:
+ workspace:
+ stable_base: true
+ max_iterations: 200
+ completion_timeout: 600.0
+ workspace:
+ enabled: true
+ transport:
+ type: inprocess
+ storage:
+ type: sqlite
+```
+
+### 各段说明
+
+| 路径 | 说明 |
+|------|------|
+| `modes.agent.fast` | Agent 快速模式:被动记忆,无额外 Rails |
+| `modes.agent.plan` | Agent 规划模式:主动记忆,无额外 Rails |
+| `modes.code.rails` | Code 模式的动态安全 Rails(固定 Rails 不在此配置) |
+| `modes.code.tools` | Code 模式的动态工具白名单(`coding_memory_*` 和 `send_file_to_user` 由运行时自动注册) |
+| `modes.code.embedding_config` | Code 模式专属 Embedding 配置(留空则用全局配置) |
+| `modes.team.<name>` | Team 模式定义:团队名、lifecycle、leader/agents 配置 |
+
+### 通道默认模式
+
+每个频道可在 `config.yaml` 的 `channels.<channel>.default_mode` 中指定默认模式:
+
+```yaml
+channels:
+ web:
+ enabled: true
+ default_mode: agent.plan # 该频道对话默认使用 Agent 规划模式
+```
+
+---
+
+## 模式行为差异
+
+| 行为 | Agent (plan) | Agent (fast) | Code | Team |
+|------|-------------|-------------|------|------|
+| 工具集 | 全工具 | 全工具 | 白名单工具 + 编码记忆 | 全工具 |
+| 记忆策略 | 主动(自动读写) | 被动(按需读写) | 编码记忆 | 按团队配置 |
+| 安全 Rails | 无额外 | 无额外 | FileSystemRail + SkillUseRail + LspRail | 按团队配置 |
+| 迭代上限 | `react.max_iterations` | `react.max_iterations` | `react.max_iterations` | 团队 leader 可单独配置 `max_iterations` |
+
+---
+
+## 详见
+
+- [配置信息](配置信息.md) — `config.yaml` 中 `modes` 段的完整字段说明
+- [命令行指令](命令行指令.md) — `/mode` 和 `/switch` 的完整命令列表
+- [Slash 命令架构](SLASH_COMMAND_ARCHITECTURE.md) — 命令解析的内部处理流程
+- [分布式 Team](分布式Team.md) — Team 模式的分布式部署
\ No newline at end of file
diff --git "a/docs/zh/\346\265\217\350\247\210\345\231\250.md" "b/docs/zh/\346\265\217\350\247\210\345\231\250.md"
index a9e90f137c..97d97bf843 100644
--- "a/docs/zh/\346\265\217\350\247\210\345\231\250.md"
+++ "b/docs/zh/\346\265\217\350\247\210\345\231\250.md"
@@ -1,7 +1,7 @@
# 浏览器工具说明
## 1. 简介
-浏览器工具是 JiuwenBot 中用于驱动真实浏览器完成网页任务的一套能力。它适合处理需要表单填写、页面点击、文件上传、网页检索等场景。
+浏览器工具是 JiuwenClaw 中用于驱动真实浏览器完成网页任务的一套能力。它适合处理需要表单填写、页面点击、文件上传、网页检索等场景。
从使用方式上看,用户先在前端页面中配置本机 Chrome 路径并启动浏览器服务。系统会拉起一个可被授权的 Chrome 浏览器实例;后续在任务需要时,Agent 会连接并操控这个浏览器完成操作。
@@ -45,7 +45,7 @@
### 步骤 2:打开前端的“浏览器服务”面板
-1. 打开 JiuwenBot 前端页面。
+1. 打开 JiuwenClaw 前端页面。
![浏览器服务面板示意图](../assets/images/browser1.png)
@@ -262,7 +262,7 @@ BROWSER_ALLOW_SHORT_TIMEOUT_OVERRIDE=0
下面这些文件是浏览器工具链路中最重要的入口。
### 前端
-- `jiuwenbot/web/src/components/BrowserPanel/index.tsx`
+- `jiuwenclaw/web/src/components/BrowserPanel/index.tsx`
- 前端浏览器服务面板
- 负责读取路径、保存路径、触发“启动浏览器服务”
@@ -271,24 +271,24 @@ BROWSER_ALLOW_SHORT_TIMEOUT_OVERRIDE=0
- 提供 `path.get`、`path.set`、`browser.start` 等前端调用入口
### Chrome 启动脚本
-- `jiuwenbot/agentserver/tools/browser_start_client.py`
+- `jiuwenclaw/agentserver/tools/browser_start_client.py`
- 读取 `config/config.yaml` 中的 `browser.*` 配置
- 启动带远程调试能力的 Chrome
### 浏览器 MCP 接入
-- `jiuwenbot/agentserver/tools/browser_tools.py`
+- `jiuwenclaw/agentserver/tools/browser_tools.py`
- 浏览器 MCP wrapper 的接入、自动拉起、client patch、配置构建
### 浏览器运行时
-- `jiuwenbot/agentserver/tools/browser-move/src/playwright_runtime_mcp_server.py`
+- `jiuwenclaw/agentserver/tools/browser-move/src/playwright_runtime_mcp_server.py`
- 浏览器 runtime 的 MCP server 入口
-- `jiuwenbot/agentserver/tools/browser-move/src/playwright_runtime/runtime.py`
+- `jiuwenclaw/agentserver/tools/browser-move/src/playwright_runtime/runtime.py`
- 浏览器 runtime 编排层
-- `jiuwenbot/agentserver/tools/browser-move/src/playwright_runtime/service.py`
+- `jiuwenclaw/agentserver/tools/browser-move/src/playwright_runtime/service.py`
- 浏览器任务执行、session 复用、timeout guardrails
-- `jiuwenbot/agentserver/tools/browser-move/src/playwright_runtime/agents.py`
+- `jiuwenclaw/agentserver/tools/browser-move/src/playwright_runtime/agents.py`
- 主编排 agent 与浏览器 worker agent 的提示词和构造逻辑
-- `jiuwenbot/agentserver/tools/browser-move/src/playwright_runtime/config.py`
+- `jiuwenclaw/agentserver/tools/browser-move/src/playwright_runtime/config.py`
- Playwright MCP 与浏览器运行时配置解析
### 配置文件
diff --git "a/docs/zh/\347\273\217\351\252\214\350\256\260\345\277\206.md" "b/docs/zh/\347\273\217\351\252\214\350\256\260\345\277\206.md"
new file mode 100644
index 0000000000..6f78287a53
--- /dev/null
+++ "b/docs/zh/\347\273\217\351\252\214\350\256\260\345\277\206.md"
@@ -0,0 +1,97 @@
+# 经验记忆(Task Memory)
+
+经验记忆是 JiuwenClaw 的内建任务经验系统,使 Agent 能够从历史任务中检索、记录和沉淀经验教训,从而在后续任务中避免重复错误、复用有效方案。
+
+---
+
+## 启用与配置
+
+在 `config/config.yaml` 中配置:
+
+```yaml
+task_memory:
+ enabled: true # 总开关
+ retrieval_algo: ACE # 检索算法:ACE | ReasoningBank | ReMe
+ summary_algo: ACE # 摘要算法:ACE | ReasoningBank | ReMe
+ llm_model: ${TASK_MEMORY_LLM_MODEL} # 使用的 LLM 模型(留空则用主模型)
+ embedding_model: ${TASK_MEMORY_EMBED_MODEL}
+ api_key: ${TASK_MEMORY_API_KEY}
+ api_base: ${TASK_MEMORY_API_BASE}
+```
+
+`enabled: true` 后 Agent 将获得以下三个工具。
+
+---
+
+## 工具说明
+
+### experience_retrieve
+
+根据查询检索相关的历史经验。
+
+| 参数 | 类型 | 说明 |
+|------|------|------|
+| `query` | string | 描述当前任务或问题,系统据此匹配最相关的经验 |
+
+返回 `memory_string`(可读文本)和 `retrieved_memory`(结构化列表)。
+
+**建议在每次任务开始时调用**,检查是否有可复用的经验。
+
+### experience_learn
+
+记录当前任务中发现的关键规律、规则或洞见,并整合到经验库中。
+
+| 参数 | 类型 | 必填 | 说明 |
+|------|------|------|------|
+| `params.content` | string | 是 | 要记录的经验内容 |
+| `params.section` | string | 否 | 分类标签,默认 `general` |
+| `params.when_to_use` | string | 否 | 何时应该使用此经验 |
+| `params.title` | string | 否 | 经验标题 |
+| `params.description` | string | 否 | 详细描述 |
+| `params.query` | string | 否 | 关联查询 |
+| `params.label` | string | 否 | 自定义标签 |
+| `params.tools_used` | list | 否 | 工具调用结果列表,如 `[{"tool": "web_search", "status": "success"}]` |
+
+**建议在最终回复前调用一次**。记录失败的工具调用尤其有价值。
+
+### experience_clear
+
+清除所有存储的经验数据。
+
+> ⚠️ 仅在用户明确要求清除时调用,调用前需确认。
+
+---
+
+## 存储机制
+
+经验数据持久化在 `workspace/agent/task-data.json`。即使外接经验服务不可用,本地持久化数据仍然可用(返回 `persisted_only` 状态)。
+
+当外接服务正常时,检索结果会合并本地持久化数据和服务端数据。
+
+---
+
+## 检索算法
+
+| 算法 | 说明 |
+|------|------|
+| **ACE** | 默认算法,基于嵌入相似度的经验检索 |
+| **ReasoningBank** | 推理增强型检索,适合复杂推理链路 |
+| **ReMe** | 反思型检索,侧重于从错误中学习 |
+
+---
+
+## 环境变量
+
+| 变量 | 说明 |
+|------|------|
+| `TASK_MEMORY_LLM_MODEL` | 经验记忆专用的 LLM 模型名 |
+| `TASK_MEMORY_EMBED_MODEL` | 经验记忆专用的 Embedding 模型 |
+| `TASK_MEMORY_API_KEY` | 经验记忆 API 密钥 |
+| `TASK_MEMORY_API_BASE` | 经验记忆 API 地址 |
+
+---
+
+## 详见
+
+- [记忆系统](记忆.md) — 内建记忆与外接记忆概述
+- [配置信息](配置信息.md) — `task_memory` 段的完整配置字段
\ No newline at end of file
diff --git "a/docs/zh/\347\274\226\347\240\201\350\256\260\345\277\206.md" "b/docs/zh/\347\274\226\347\240\201\350\256\260\345\277\206.md"
new file mode 100644
index 0000000000..f65b184cfb
--- /dev/null
+++ "b/docs/zh/\347\274\226\347\240\201\350\256\260\345\277\206.md"
@@ -0,0 +1,88 @@
+# 编码记忆(Coding Memory)
+
+编码记忆是 Code 模式下的专属记忆系统,使 Agent 在代码任务中可以读取、写入和编辑持久化的代码上下文。
+
+---
+
+## 启用
+
+编码记忆在切换到 Code 模式时自动启用,无需额外配置。相关配置位于 `config/config.yaml` 的 `modes.code` 段:
+
+```yaml
+modes:
+ code:
+ rails:
+ - FileSystemRail
+ - SkillUseRail
+ - LspRail
+ tools:
+ - web_free_search
+ - web_fetch_webpage
+ - web_paid_search
+ - user_todos
+ embedding_config:
+ model_name: null # 留空则用全局 Embedding 配置
+ base_url: null
+ api_key: null
+```
+
+---
+
+## 工具说明
+
+编码记忆提供三个工具,由 `CodingMemoryRail` 在子进程内自动注册:
+
+### coding_memory_read
+
+读取当前编码记忆内容。
+
+| 参数 | 类型 | 说明 |
+|------|------|------|
+| `query` | string | 查询关键词,用于检索相关的编码上下文 |
+
+返回匹配的代码片段和上下文说明。
+
+### coding_memory_write
+
+向编码记忆写入新的代码上下文或经验。
+
+| 参数 | 类型 | 说明 |
+|------|------|------|
+| `content` | string | 要写入的代码内容或经验 |
+| `section` | string | 分类标签(如 `architecture`、`bugfix`、`pattern`) |
+
+### coding_memory_edit
+
+编辑已有的编码记忆条目。
+
+| 参数 | 类型 | 说明 |
+|------|------|------|
+| `memory_id` | string | 要编辑的记忆条目 ID |
+| `content` | string | 新的内容 |
+| `section` | string | 可选,修改分类标签 |
+
+---
+
+## 与其他记忆系统的关系
+
+| 记忆系统 | 适用模式 | 说明 |
+|----------|---------|------|
+| 内建记忆(`write_memory` / `read_memory`) | Agent 模式 | 通用对话记忆 |
+| 经验记忆(`experience_retrieve` / `experience_learn`) | 全模式 | 任务级经验检索与沉淀 |
+| 编码记忆(`coding_memory_read` / `write` / `edit`) | Code 模式 | 代码上下文与编码经验 |
+
+在 Code 模式下,三种记忆系统可以共存使用。
+
+---
+
+## 存储
+
+编码记忆数据存储在 `workspace/agent/memory/` 目录下,与内建记忆共享存储路径。
+
+---
+
+## 详见
+
+- [模式系统](模式系统.md) — 各模式配置与切换
+- [记忆系统](记忆.md) — 内建记忆与外接记忆
+- [经验记忆](经验记忆.md) — 任务级经验检索
\ No newline at end of file
diff --git "a/docs/zh/\350\256\260\345\277\206.md" "b/docs/zh/\350\256\260\345\277\206.md"
index e4f9d02f01..ee619242e3 100644
--- "a/docs/zh/\350\256\260\345\277\206.md"
+++ "b/docs/zh/\350\256\260\345\277\206.md"
@@ -2,8 +2,27 @@
记忆系统让 JiuwenClaw 拥有跨对话的持久记忆能力,自动将关键信息写入文件长期保存,配合语义检索随时召回。
+**外接记忆 Providers**,支持接入第三方记忆服务(OpenJiuwen LTM、Mem0、OpenViking)或自定义插件。
+
+---
+
+## 引擎开关
+
+通过 `memory.engine` 配置项控制记忆引擎挂载:
+
+| 值 | 说明 |
+|----|------|
+| `builtin` | 仅内置记忆(默认,兼容旧配置) |
+| `external` | 仅外接记忆(LTM / Mem0 / OpenViking / 插件) |
+| `both` | 内置 + 外接并存 |
+| `none` | 全部关闭 |
+
+---
+
## 配置说明
+### 内置记忆配置
+
记忆检索默认进行 BM25 全文检索,用户可选择配置 `EMBED_API_KEY`,使用向量 + BM25 混合检索以获得最佳召回效果。通过以下环境变量配置 Embedding 服务,用于语义向量搜索:
| 环境变量 | 说明 |
@@ -14,6 +33,60 @@
![记忆文件结构](../assets/images/memory_config.png)
+### 外接记忆配置
+
+配置位置:`config.yaml` 的 `memory.external` 段。
+
+```yaml
+memory:
+ engine: external # 或 both
+ external:
+ provider: mem0 # 选一个:openjiuwen | mem0 | openviking | <plugin-name>
+ user_id: __default__
+ scope_id: __default__
+
+ # Provider-specific 配置
+ openjiuwen:
+ kv_type: shelve
+ vector_type: chroma
+ db_type: sqlite
+ mem0:
+ api_key: ""
+ user_id: ""
+ agent_id: ""
+ rerank: true
+ openviking:
+ endpoint: http://127.0.0.1:1933
+ api_key: ""
+ account: root
+ user: default
+```
+
+#### 支持的 Providers
+
+| Provider | 说明 | 必要配置 |
+|----------|------|----------|
+| `openjiuwen` | 本地长期记忆(KV + 向量 + DB) | 无(使用默认路径 ~/.jiuwenclaw/memory/ltm) |
+| `mem0` | 云端事实抽取与语义检索 | `api_key`(从 mem0.ai 获取) |
+| `openviking` | 字节上下文数据库 | `endpoint`, `api_key` |
+| `<plugin-name>` | 自定义插件 | ~/.jiuwenclaw/plugins/memory/<name>/ |
+
+#### 外接记忆环境变量
+
+| 变量 | 说明 |
+|------|------|
+| `MEMORY_EXTERNAL_PROVIDER` | Provider 名称(覆盖 config.yaml) |
+| `MEMORY_USER_ID` | 数据隔离标识 |
+| `MEMORY_SCOPE_ID` | Scope 标识 |
+| `MEM0_API_KEY` | Mem0 API 密钥 |
+| `MEM0_USER_ID` | Mem0 用户标识 |
+| `OPENVIKING_ENDPOINT` | OpenViking 服务地址 |
+| `OPENVIKING_API_KEY` | OpenViking API 密钥 |
+
+---
+
+## 内置记忆文件结构
+
## 记忆文件结构
diff --git "a/docs/zh/\351\205\215\347\275\256\344\277\241\346\201\257.md" "b/docs/zh/\351\205\215\347\275\256\344\277\241\346\201\257.md"
index 0a9852e175..2c63b45902 100644
--- "a/docs/zh/\351\205\215\347\275\256\344\277\241\346\201\257.md"
+++ "b/docs/zh/\351\205\215\347\275\256\344\277\241\346\201\257.md"
@@ -26,6 +26,7 @@ JiuwenClaw 的配置来源包括:`config/config.yaml`、`.env` 环境变量、
| `video_model` | `VIDEO_MODEL_NAME` | 视频处理调用模型 |
| `audio_model` | `AUDIO_MODEL_NAME` | 音频处理调用模型 |
| `vision_model` | `VISION_MODEL_NAME` | 图像处理调用模型 |
+| `image_gen_model` | `IMAGE_GEN_MODEL_NAME` | 图片生成模型 |
| `jina_api_key` | `JINA_API_KEY` | Jina 搜索 API 密钥 |
| `serper_api_key` | `SERPER_API_KEY` | Serper 搜索 API 密钥 |
| `perplexity_api_key` | `PERPLEXITY_API_KEY` | Perplexity API 密钥 |
@@ -44,19 +45,150 @@ JiuwenClaw 的配置来源包括:`config/config.yaml`、`.env` 环境变量、
| 路径 | 说明 |
|------|------|
| `react.agent_name` | Agent 名称,默认 `main_agent` |
-| `react.max_iterations` | 最大迭代轮数,默认 50 |
+| `react.max_iterations` | 最大迭代轮数,默认 100 |
| `react.context_engine_config.enable_reload` | 是否启用上下文重载 |
| `react.evolution.enabled` | 是否启用 Skills 在线自演进 |
-| `react.evolution.skill_base_dir` | Skill 根目录,默认 `workspace/agent/skills` |
+| `react.evolution.skill_base_dir` | Skill 根目录,默认 `agent/skills` |
| `tools` | 启用的工具列表(如 `todo`、`skill`) |
| `browser.remote_debugging_address` | 远程调试地址 |
| `browser.remote_debugging_port` | 远程调试端口 |
| `browser.user_data_dir` | Chrome 用户数据目录 |
| `browser.profile_directory` | Chrome 配置文件目录 |
+另见:
+- [模式配置](Modes.md) — `modes` 配置段
+- [工具权限与安全](ToolPermissionsSecurity.md) — `permissions` 配置段
+
+### 2. models 配置段(多模型配置)
+
+可配置多个模型 Profile,分别用于主 Agent、视频、音频、视觉、图像生成等场景。
+
+| 路径 | 说明 |
+|------|------|
+| `models.default.model_client_config` | 默认(主)模型连接配置:`api_base`、`api_key`、`model_name`、`client_provider`、`timeout`、`verify_ssl`、`custom_headers` |
+| `models.default.model_config_obj` | 默认模型生成参数:`temperature` 等 |
+| `models.video.model_client_config` | 视频处理模型 |
+| `models.audio.model_client_config` | 音频处理模型 |
+| `models.vision.model_client_config` | 视觉 / 图像理解模型 |
+| `models.image_gen.model_client_config` | 图像生成模型 |
+| `models.image_gen.model_config_obj` | 图像生成参数:`temperature` 等 |
+
+每个子模型段均支持相同的 `model_client_config` 键:`api_base`、`api_key`、`model_name`、`client_provider`、`timeout`、`verify_ssl`。全部支持环境变量替换(如 `${VIDEO_API_BASE}`)。
+
+### 3. memory.external 配置段(外接记忆)
+
+| 路径 | 说明 |
+|------|------|
+| `memory.engine` | 引擎开关:`builtin` \| `external` \| `both` \| `none` |
+| `memory.external.provider` | Provider 名称:`openjiuwen` \| `mem0` \| `openviking` \| `<plugin>` |
+| `memory.external.user_id` | 数据隔离标识 |
+| `memory.external.scope_id` | Scope 标识 |
+
+详见 [记忆系统](记忆.md)。
+
+### 4. team.runtime 配置段(分布式 Team)
+
+| 路径 | 说明 |
+|------|------|
+| `team.runtime.mode` | 运行模式:`local` \| `distributed` |
+| `team.runtime.role` | 进程角色:`leader` \| `teammate` |
+| `team.runtime.member_name` | teammate 名称标识 |
+| `team.teammate_mode` | teammate 构建方式:`build_mode` |
+| `team.spawn_mode` | teammate 进程模式:`inprocess` |
+
+详见 [分布式 Team](分布式Team.md)。
+
+### 5. task_memory 配置段(经验记忆)
+
+| 路径 | 说明 |
+|------|------|
+| `task_memory.enabled` | 是否启用经验记忆工具,默认 `true` |
+| `task_memory.llm_model` | 经验记忆使用的 LLM 模型(留空则用主模型) |
+| `task_memory.embedding_model` | 经验记忆使用的 Embedding 模型 |
+| `task_memory.api_key` | 经验记忆 API 密钥(留空则用主密钥) |
+| `task_memory.api_base` | 经验记忆 API 地址(留空则用主地址) |
+
+启用后 Agent 将获得 `experience_retrieve`、`experience_learn`、`experience_clear` 三个工具。检索算法可选 `ACE`、`ReasoningBank`、`ReMe`。
+
+### 6. email_settings 配置段(邮件)
+
+| 路径 | 说明 |
+|------|------|
+| `email_settings.email_address` | 发件邮箱地址 |
+| `email_settings.token` | 邮箱授权码 |
+| `email_settings.smtp_server` | SMTP 服务器,默认 `smtp.gmail.com` |
+| `email_settings.port` | SMTP 端口,默认 `587` |
+
+### 7. extensions 配置段(扩展包)
+
+| 路径 | 说明 |
+|------|------|
+| `extensions.extension_dirs` | 扩展包搜索目录,分号分隔(如 `E:/a;D:/b`),对应环境变量 `EXTENSION_DIRS` |
+
+### 8. mcp 配置段(MCP 服务)
+
+| 路径 | 说明 |
+|------|------|
+| `mcp.servers` | MCP 服务列表,每项含 `name`、`enabled`、`transport`(`stdio`/`sse`/`streamable-http`)、`command`、`args`、`url` 等 |
+
+浏览器 MCP 运行时通过环境变量配置(见下方)。
+
+### 9. updater 配置段(自动更新)
+
+| 路径 | 说明 |
+|------|------|
+| `updater.enabled` | 是否启用自动更新,默认 `true` |
+| `updater.repo_owner` | GitHub 仓库 owner |
+| `updater.repo_name` | GitHub 仓库名 |
+| `updater.asset_name_pattern` | 资源文件名模式 |
+| `updater.timeout_seconds` | 更新检查超时,默认 `20` |
+
---
-### 2. 仅环境变量可配置的项
+### 10. gateway 配置段(网关路由)
+
+| 键 | 类型 | 默认值 | 说明 |
+|---|------|--------|------|
+| `gateway.session_map_scope` | string | `per_chat_bot` | SessionMap 作用域:`per_chat_bot`(同 chat+bot 共享会话)或 `per_chat_bot_user`(按 user 分会话)。仅企业场景使用,如飞书企业版等通道。 |
+
+### 11. logging 配置段(日志)
+
+| 键 | 类型 | 默认值 | 说明 |
+|---|------|--------|------|
+| `logging.level` | string | `INFO` | 全局日志级别 |
+| `logging.console_level` | string | `INFO` | 控制台日志级别 |
+| `logging.gateway` | string | `INFO` | Gateway 模块日志级别 |
+
+日志文件存放在 `~/.jiuwenclaw/agent/.logs/` 下,按 `gateway.log`、`channel.log`、`agent_server.log` 分流;`full.log` 为汇总。
+
+### 12. telemetry 配置段(OpenTelemetry 遥测)
+
+| 键 | 类型 | 默认值 | 说明 |
+|---|------|--------|------|
+| `telemetry.enabled` | bool | `false` | 总开关(环境变量 `OTEL_ENABLED` 优先) |
+| `telemetry.exporter` | string | `otlp` | 导出器类型:`otlp` / `console` / `none` |
+| `telemetry.endpoint` | string | `http://localhost:4317` | OTLP endpoint |
+| `telemetry.protocol` | string | `grpc` | 传输协议:`grpc` / `http` |
+| `telemetry.headers` | map | `{}` | 公共 OTLP headers,可被 traces/metrics 覆盖 |
+| `telemetry.log_messages` | bool | `true` | 是否在 span event 中记录完整消息内容 |
+| `telemetry.service_name` | string | `jiuwenclaw` | 服务名称标识 |
+| `telemetry.provider_factory` | string | | 自定义 Provider Factory,格式 `module:function` |
+| `telemetry.traces.exporter` | string | | Trace 导出器,留空回退到 `telemetry.exporter` |
+| `telemetry.traces.endpoint` | string | | Trace endpoint,留空回退到 `telemetry.endpoint` |
+| `telemetry.traces.protocol` | string | | Trace 协议,留空回退到 `telemetry.protocol` |
+| `telemetry.traces.headers` | map | `{}` | Trace 专用 headers |
+| `telemetry.metrics.exporter` | string | | Metrics 导出器,留空回退到 `telemetry.exporter` |
+| `telemetry.metrics.endpoint` | string | | Metrics endpoint,留空回退到 `telemetry.endpoint` |
+| `telemetry.metrics.protocol` | string | | Metrics 协议,留空回退到 `telemetry.protocol` |
+| `telemetry.metrics.headers` | map | `{}` | Metrics 专用 headers |
+
+### 13. 其他配置项
+
+| 键 | 类型 | 默认值 | 说明 |
+|---|------|--------|------|
+| `preferred_language` | string | `zh` | Agent 默认回复语言(`zh` / `en`) |
+
+### 14. 仅环境变量可配置的项
| 环境变量 | 说明 |
|----------|------|
@@ -69,6 +201,20 @@ JiuwenClaw 的配置来源包括:`config/config.yaml`、`.env` 环境变量、
| `PLAYWRIGHT_CDP_URL` | Playwright 连接 Chrome 的 CDP 地址 |
| `PLAYWRIGHT_TOOL_TIMEOUT_S` | Playwright 工具超时(秒) |
| `BROWSER_TIMEOUT_S` | 浏览器任务超时(秒) |
+| `BROWSER_DRIVER` | 浏览器驱动模式:`managed`(自管理)/ `remote`(远程)/ `extension`(插件) |
+| `EMAIL_ADDRESS` | 发件邮箱地址(对应 `email_settings.email_address`) |
+| `EMAIL_TOKEN` | 邮箱授权码(对应 `email_settings.token`) |
+| `EVOLUTION_AUTO_SCAN` | 是否每轮对话后自动扫描可演进技能(`true`/`false`) |
+| `SKILLNET_DOWNLOAD_TIMEOUT` | SkillNet 下载超时(秒),默认 60 |
+| `SKILLNET_MAX_RETRIES` | SkillNet 下载最大重试次数,默认 3 |
+| `OPENJIUWEN_MARKET_BASE_URL` | TeamSkillsHub 市场地址(空则用默认) |
+| `OPENJIUWEN_MARKET_TIMEOUT` | 市场请求超时(秒),默认 60 |
+| `OPENJIUWEN_ALLOWED_DOWNLOAD_HOSTS` | ZIP 下载主机白名单,逗号分隔 |
+| `MEMORY_MODE` | 记忆模式(空则默认 `local`) |
+| `EXTENSION_DIRS` | 扩展包搜索目录,分号分隔(对应 `extensions.extension_dirs`) |
+| `OTEL_ENABLED` | 是否启用 OpenTelemetry(对应 `telemetry.enabled`) |
+| `OTEL_EXPORTER` | OTLP 导出器类型(对应 `telemetry.exporter`) |
+| `OTEL_ENDPOINT` | OTLP endpoint(对应 `telemetry.endpoint`) |
| `JIUWENCLAW_CONFIG_DIR` | 自定义 config 目录路径 |
| `JIUWENCLAW_DATA_DIR` | 用户数据根目录的绝对路径(其下为 `config/`、`agent/`、日志等)。未设置时默认为 `~/.jiuwenclaw`。须在**启动进程前**在系统或 Shell 环境中设置,以便首次加载时解析路径;仅写在 `config/.env` 中通常无法在首次解析数据根时生效。 |
| `JIUWENCLAW_DISABLE_CRON_TOOLS` | 设为 `1` 时禁用 Agent 侧 cron 定时任务工具注册,并从提示词中隐藏相关说明 |
@@ -77,7 +223,7 @@ JiuwenClaw 的配置来源包括:`config/config.yaml`、`.env` 环境变量、
---
-### 3. 配置优先级
+### 15. 配置优先级
- **环境变量** > **config.yaml**
- 例如:`config.yaml` 中 `react.model_name: ${MODEL_NAME:-deepseek-chat}` 会先读 `MODEL_NAME` 环境变量,无则用默认值 `deepseek-chat`。
diff --git "a/docs/zh/\351\242\221\351\201\223.md" "b/docs/zh/\351\242\221\351\201\223.md"
index 19dfe0103d..c97fb1b8cc 100644
--- "a/docs/zh/\351\242\221\351\201\223.md"
+++ "b/docs/zh/\351\242\221\351\201\223.md"
@@ -379,19 +379,19 @@ channels:
1. 打开企业微信客户端,进入**工作台->智能机器人**,点击**创建机器人->手动创建**
-   ![企业微信创建机器人入口](../assets/images/wecom/1_企业微信创建机器人入口.png?msec=1774269205893)
+   ![企业微信创建机器人入口](../assets/images/wecom/1_企业微信创建机器人入口.png)
-   ![企业微信手动创建](../assets/images/wecom/2_创建机器人.png?msec=1774269205909)
+   ![企业微信手动创建](../assets/images/wecom/2_创建机器人.png)
-   ![企业微信创建页面](../assets/images/wecom/3_手动创建.png?msec=1774269205918)
+   ![企业微信创建页面](../assets/images/wecom/3_手动创建.png)
2. 进入创建页面后,选择**API模式创建**
-   ![企业微信API模式创建](../assets/images/wecom/4_API模式创建.png?msec=1774269205918)
+   ![企业微信API模式创建](../assets/images/wecom/4_API模式创建.png)
3. 在API配置页面,选择**连接方式为「使用长连接」**
-   ![企业微信长连接配置](../assets/images/wecom/5_选择长连接.png?msec=1774269205922)
+   ![企业微信长连接配置](../assets/images/wecom/5_选择长连接.png)
4. 配置完成后,页面将自动生成并展示**Bot ID**和**Secret**,妥善保存该信息(后续关联JiuwenClaw需使用)
@@ -401,23 +401,23 @@ channels:
2. 输入步骤一保存的botId以及secret。然后点击保存即可。
-   ![企业微信频道选择](../assets/images/wecom/6_频道.png?msec=1774269205907)
+   ![企业微信频道选择](../assets/images/wecom/6_频道.png)
-   ![企业微信频道配置](../assets/images/wecom/7_频道管理.png?msec=1774269205918)
+   ![企业微信频道配置](../assets/images/wecom/7_频道管理.png)
## 3. 与企业微信机器人对话
> ⚠️ **注意**:如配置完成后未能找到机器人,可在以下路径中找到:工作台->智能机器人->详情->去使用->发消息。
-![企业微信机器人入口1](../assets/images/wecom/8_机器人详情.png?msec=1774269205913)
+![企业微信机器人入口1](../assets/images/wecom/8_机器人详情.png)
-![企业微信机器人入口2](../assets/images/wecom/9_使用机器人.png?msec=1774269205913)
+![企业微信机器人入口2](../assets/images/wecom/9_使用机器人.png)
1. 在企业微信中,找到刚添加的机器人,发送验证消息,收到回复消息后,表示对接成功。
2. 在手机端企业微信中,发送验证消息,收到回复消息后,表示对接成功。
-![企业微信PC端对话](../assets/images/wecom/10_客户端验证.png?msec=1774269205911)
+![企业微信PC端对话](../assets/images/wecom/10_客户端验证.png)
![企业微信手机端对话](../assets/images/wecom/11_手机端验证.png)
## 4. 开启群聊数字分身(可选)
@@ -661,8 +661,8 @@ channels:
### 步骤 1:微信版本升级
- 在微信中依次进入「我」->「设置」->「关于微信」->「版本更新」:
- - IOS请升级到最新 `8.0.70` 版本。
- - 安卓请升级到最新 `8.0.69` 版本。
+ - IOS请升级到最新版本。
+ - 安卓请升级到最新版本。
![wechat_update](../assets/images/wechat_update.png)
diff --git a/jiuwenclaw/resources/config.yaml b/jiuwenclaw/resources/config.yaml
index e2a1202e8c..47bfb2c1e0 100644
--- a/jiuwenclaw/resources/config.yaml
+++ b/jiuwenclaw/resources/config.yaml
@@ -305,7 +305,7 @@ gateway:
session_map_scope: per_chat_bot
heartbeat:
- # 心跳间隔(秒),默认 60
+ # 心跳间隔(秒),默认 3600
every: 3600
# 心跳结果回传的 channel(如 "web"),
target: web