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

docs(Agent): Agent.md improve

xinyang_bali05be8fee8c0e
diff --git a/docs/assets/images/jiuwenswarm_file.png b/docs/assets/images/jiuwenswarm_file.png
new file mode 100644
index 0000000000..d76e961918
Binary files /dev/null and b/docs/assets/images/jiuwenswarm_file.png differ
diff --git a/docs/en/Agent.md b/docs/en/Agent.md
index dbd6828df9..a461d15b9b 100644
--- a/docs/en/Agent.md
+++ b/docs/en/Agent.md
@@ -1,150 +1,340 @@
# Agent
-`workspace` is JiuwenSwarm’s runtime directory for agent memory, skills, session data, and configurable heartbeat tasks. On first run (via `init` or `app`), the template under `jiuwenswarm/resources/agent/workspace/` is copied to `~/.jiuwenswarm/agent/workspace/`. Built-in skills live in the package at `jiuwenswarm/resources/agent/workspace/skills/`; marketplace/installed skills are stored in the user workspace.
+This guide explains what an **Agent** is in JiuwenSwarm, how it is structured, where files live on disk, and how to view or adjust configuration safely.
-![Workspace](../assets/images/agent.png)
+---
-## Layout overview
+## Concepts
-The **installed** runtime layout (`~/.jiuwenswarm/`):
+### What is an agent?
+In JiuwenSwarm, an **Agent** is a digital assistant that can act on its own. It is not just a large language model—it is an execution entity built from several cooperating parts.
+
+**Core definition:**
+
+**Agent = identity + tools + skills + memory + workspace**
+
+**How it differs from plain LLM chat:**
+
+| Aspect | Plain LLM chat | JiuwenSwarm agent |
+|--------|----------------|-------------------|
+| Execution | Text replies only | Can call tools (files, shell, web search, etc.) |
+| Memory | Short-term, within a session | Long-term across sessions; preferences and history |
+| Skills | Fixed capability | Loadable skill modules for specialized work |
+| Workspace | None | Dedicated workspace for tasks, todos, and state |
+| Personalization | None | Identity and config shape tone and behavior |
+
+**How the pieces fit together:**
+
+```text
+┌─────────────────────────────────────────────────────┐
+│ Agent │
+├─────────────────────────────────────────────────────┤
+│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
+│ │ Identity│ │ Tools │ │ Skills │ │ Memory │ │
+│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
+│ ┌───────────────────────────────────────────────┐ │
+│ │ Workspace │ │
+│ │ ┌─────────┐ ┌─────────┐ ┌─────────────────┐│ │
+│ │ │ Todo │ │ Config │ │ Sessions ││ │
+│ │ └─────────┘ └─────────┘ └─────────────────┘│ │
+│ └───────────────────────────────────────────────┘ │
+└─────────────────────────────────────────────────────┘
```
-~/.jiuwenswarm/
-├── .updates/ # Update state (generated)
-│ └── web_process.json
-├── agent/
-│ ├── .checkpoint/ # Checkpoint database (created at runtime)
-│ │ ├── checkpoint.db # SQLite checkpoint
-│ │ ├── checkpoint.db-shm # SQLite shared memory
-│ │ └── checkpoint.db-wal # SQLite WAL log
-│ ├── .logs/ # Agent process logs
-│ │ ├── agent_server.log
-│ │ ├── channel.log
-│ │ ├── full.log
-│ │ ├── gateway.log
-│ │ ├── permissions.log
-│ │ └── ws-dev.log
-│ ├── sessions/ # Sessions (generated)
-│ │ ├── sess_<id>/ # Normal sessions
-│ │ │ ├── history.json # Session history
-│ │ │ ├── metadata.json # Session metadata
-│ │ │ └── *.md, *.json
-│ │ └── heartbeat_<id>/ # Heartbeat sessions
-│ └── workspace/ # Agent workspace
-│ ├── agents/ # Agent work area (DeepAgent standard node)
-│ │ └── .workspace
-│ ├── coding_memory/ # Coding memory
-│ │ ├── .workspace
-│ │ └── MEMORY.md
-│ ├── context/ # Session context
-│ │ ├── .workspace
-│ │ └── session_memory.md
-│ ├── memory/ # Memory system
-│ │ ├── .workspace
-│ │ ├── MEMORY.md # Long-term memory (from MEMORY_ZH.md or MEMORY_EN.md at init)
-│ │ ├── daily_memory/ # Daily memory files (created at runtime)
-│ │ │ ├── .workspace
-│ │ │ ├── YYYY-MM-DD.md
-│ │ │ └── ...
-│ │ ├── memory.db # ChromaDB vector store (created at runtime)
-│ │ ├── memory.db-shm
-│ │ └── memory.db-wal
-│ ├── messages/ # Message work area (DeepAgent standard node)
-│ │ └── .workspace
-│ ├── skills/ # Marketplace/installed skills
-│ │ ├── .workspace
-│ │ ├── skills_state.json # Skill install/market state (generated)
-│ │ ├── _marketplace/ # Marketplace clone cache (created at runtime)
-│ │ └── <skill-name>/
-│ │ └── evolutions.json
-│ ├── todo/ # Todo work area (DeepAgent standard node)
-│ │ └── .workspace
-│ ├── extensions/ # Extension plugins (created at runtime)
-│ ├── interactions/ # Interaction contexts (created at runtime)
-│ ├── agent-data.json # Agent list metadata
-│ ├── AGENT.md # Agent identity
-│ ├── HEARTBEAT.md # Heartbeat tasks
-│ ├── IDENTITY.md # Identity
-│ ├── SOUL.md # Persona for system prompts
-│ └── USER.md # User profile
-├── auto-harness/ # Auto CI workflow (generated)
-│ └── config.yaml
-├── config/ # Configuration
-│ ├── config.yaml # Main config
-│ ├── .env # Environment variables
-│ ├── builtin_rules.yaml # Shell security rules
-│ └── runtime_state.yaml # Runtime state (generated)
-└── logs/ # Business logs
- └── logs/
- ├── llm.log # LLM call logs
- ├── memory.log # Memory module logs
- ├── runner.log # Runner logs
- ├── session.log # Session logs
- ├── sys_operation.log # System operation logs
- ├── interface/
- │ ├── jiuwen_interface.log
- │ └── jiuwen_prompt_builder_interface.log
- ├── performance/
- │ └── jiuwen_performance.log
- └── run/
- └── jiuwen.log
-```
-Built-in skills template lives at `jiuwenswarm/resources/agent/workspace/skills/`. These built-in skills are not copied to the user workspace on init (loaded directly from the package in source mode).
+**Takeaways:**
+
+1. **Identity** — who the agent is and how it communicates
+2. **Tools** — “hands” for files, search, code, shell, and media
+3. **Skills** — loadable modules (e.g. Git, document workflows)
+4. **Memory** — user profile, history, and decisions across sessions
+5. **Workspace** — the agent’s “desk” for tasks, config, and sessions
+
+> This section is conceptual only. Later sections go into each part in more detail.
---
-## Pre-configured content
+## Structure
+
+### What an agent is made of
+
+An agent has six main areas. You can focus on the ones you care about.
+
+**Overview:**
+
+| Part | Role | User focus | Main effect |
+|------|------|------------|-------------|
+| **Identity** | Who the agent is, tone, style | Customizable | Conversation style and behavior |
+| **Workspace** | Tasks, todos, sessions, runtime data | Good to understand | Task tracking and persistence |
+| **Tools** | Files, web, code, shell, media | Usually no edits | What operations are possible |
+| **Skills** | Professional modules (Git, PPT, etc.) | Load as needed | Extra capabilities |
+| **Memory** | Preferences, history, decisions | Mostly automatic | Continuity and personalization |
+| **Todo** | Task tracking | Day to day | Execution efficiency |
+| **Config** | Models, channels, permissions | Advanced users | Model, security, channel behavior |
+
+**Details:**
+
+#### 1. Identity
+
+Defines who the agent is and how it talks to you:
+
+- Role (e.g. personal assistant, technical advisor)
+- Personality (concise vs. thorough)
+- Principles (e.g. try first, then ask; respect trust)
+
+**Files:** `IDENTITY.md`, `SOUL.md`
+
+#### 2. Workspace
+
+Runtime environment for:
+
+- Current tasks and todos
+- Session history and state
+- Skills and local overrides
+- Temporary outputs
+
+**Location:** under the `.jiuwenswarm/` directory
-Shipped with the package or source; you can use or edit as needed:
+#### 3. Tools
-| Path (in workspace) | Description |
-|------|-------------|
-| `AGENT.md` | Agent identity description. Copied from `AGENT_ZH.md`/`AGENT_EN.md` by language at init. |
-| `IDENTITY.md` | Identity description. Copied from `IDENTITY_ZH.md`/`IDENTITY_EN.md` by language at init. |
-| `SOUL.md` | Persona for system prompts. Copied from `SOUL_ZH.md`/`SOUL_EN.md` by language at init. |
-| `USER.md` | User profile. Copied from template at init. |
-| `HEARTBEAT.md` | Heartbeat template (`jiuwenswarm/resources/agent/workspace/HEARTBEAT_ZH.md` or `HEARTBEAT_EN.md`, copied by language at init). If present and valid, the agent reads it on each heartbeat; otherwise only `HEARTBEAT_OK` is returned. Editable in the web UI. |
-| `skills/` | Marketplace/installed skills. Each skill has `SKILL.md`, `prompts/`, `references/`, etc. |
-| `skills/_marketplace/` | Marketplace clone cache; empty by default. |
-| `memory/` | Memory layout. `MEMORY.md` is copied from template at init. |
+Built-in capabilities, including:
+
+- Files: read, write, edit, search
+- Web: search, fetch pages
+- Code: Python, JavaScript
+- System: shell commands
+- Media: image OCR, audio transcription, video analysis
+
+**Note:** Tools are provided by the system; you normally do not change them manually.
+
+#### 4. Skills
+
+Loadable modules. Each skill typically defines goals, steps, tool usage, and output rules.
+
+**Examples:**
+
+- `gitcode-pr` — open a Pull Request on GitCode
+- `gitcode-pr-review-fix` — address PR review comments and update code
+
+**Location:** `skills/` directory
+
+#### 5. Memory
+
+Three kinds:
+
+- **User profile** — who you are, preferences, habits
+- **Episodic** — events, decisions, conversation snippets
+- **Semantic** — background knowledge and concepts
+
+**Note:** Memory is mostly automatic; you can search history when needed.
+
+#### 6. Config
+
+Controls runtime behavior:
+
+- Model choice and parameters (temperature, timeout, etc.)
+- Channels (Feishu, WeChat, Telegram, etc.)
+- Permissions (what needs your approval)
+- Memory and logging
+
+**File:** `config/config.yaml`
+
+> You do not need to edit everything by hand. In practice, focus on **identity** and **skills**; the rest is largely managed by the system.
---
-## Dynamically generated content
-
-Created or updated at runtime:
-
-| Path | Description |
-|------|-------------|
-| `agent/.checkpoint/checkpoint.db` | SQLite checkpoint database (.db-shm, .db-wal). |
-| `agent/.logs/*.log` | Agent process logs (gateway, agent_server, channel, full, permissions, ws-dev). |
-| `agent/sessions/<session_id>/` | One folder per session, containing `history.json`, `metadata.json`, and session-generated `*.md` / `*.json` files. |
-| `agent/sessions/<session_id>/todo.md` | Todo list created by `TodoToolkit` (optional). |
-| `agent/workspace/agent-data.json` | Generated by `scripts/generate-agent-folders.js` for the web UI. |
-| `agent/workspace/coding_memory/MEMORY.md` | Coding memory content. |
-| `agent/workspace/context/session_memory.md` | Session context memory. |
-| `agent/workspace/memory/daily_memory/YYYY-MM-DD.md` | Daily memory files created by `write_memory` tool. |
-| `agent/workspace/memory/memory.db` | ChromaDB vector store for `memory_search` (with `.db-shm`, `.db-wal`). |
-| `agent/workspace/skills/skills_state.json` | Maintained by `SkillManager` for installed marketplace plugins. |
-| `agent/workspace/skills/<skill>/evolutions.json` | Skill evolution records. |
-| `agent/workspace/skills/_marketplace/` | Marketplace clone cache (created by `_sync_marketplace_repos`). |
-| `agent/workspace/extensions/` | Extension plugins directory (created at runtime). |
-| `agent/workspace/interactions/` | Interaction contexts (created at runtime). |
-| `.updates/web_process.json` | Web process update state. |
-| `auto-harness/config.yaml` | Auto CI workflow configuration. |
-| `config/runtime_state.yaml` | Runtime state. |
-| `logs/logs/*.log` | Business logs (llm, memory, runner, session, sys_operation). |
-| `logs/logs/interface/jiuwen_interface.log` | Interface module logs. |
-| `logs/logs/interface/jiuwen_prompt_builder_interface.log` | Prompt builder interface logs. |
-| `logs/logs/performance/jiuwen_performance.log` | Performance logs. |
-| `logs/logs/run/jiuwen.log` | Runner logs. |
+## Directory layout
+
+### Local paths and key files
+
+High-level layout under your user data directory:
+
+**Overview:**
+
+```text
+C:\Users\<username>\.jiuwenswarm\
+│
+├── config/ # Configuration
+│ ├── config.yaml # Main config (models, channels, permissions)
+│ └── builtin_rules.yaml # Built-in rules
+│
+├── agent/ # Agent-related data
+│ └── <service_id>/ # Service instance
+│ └── <agent_id>/ # Agent instance
+│ ├── agent/ # Agent workspace
+│ │ ├── AGENT.md # Agent bootstrap config
+│ │ ├── IDENTITY.md # Identity
+│ │ ├── SOUL.md # Values and persona
+│ │ ├── HEARTBEAT.md # Heartbeat tasks
+│ │ └── sessions/ # Session data
+│ ├── config/ # Per-agent config overrides (optional)
+│ ├── memory/ # Agent memory store
+│ ├── skills/ # Skills
+│ └── todo/ # Todos
+│
+├── gateway/ # Gateway data
+├── logs/ # Log files
+├── memory/ # Global memory store
+├── received_files/ # Incoming external files
+└── web/ # Web channel assets
+```
+
+**Key files:**
+
+| Path | Purpose | Edit? | If you change it |
+|------|---------|-------|------------------|
+| `config/config.yaml` | Models, channels, permissions, memory | Advanced users, carefully | Affects models, channels, security; restart required |
+| `config/builtin_rules.yaml` | Built-in rules | Not recommended | Changes default system behavior |
+| `agent/<id>/agent/AGENT.md` | Bootstrap config | Yes, when needed | Affects startup behavior |
+| `agent/<id>/agent/IDENTITY.md` | Identity | Customizable | Affects how the agent sees its role |
+| `agent/<id>/agent/SOUL.md` | Values and persona | Customizable | Affects tone and style |
+| `agent/<id>/agent/HEARTBEAT.md` | Heartbeat tasks | Adjustable | Affects scheduled / proactive behavior |
+| `agent/<id>/skills/` | Skills | Add skills | Extends capabilities |
+| `agent/<id>/memory/` | Memory store | Do not edit by hand | Risk of corrupting memory data |
+| `agent/<id>/todo/` | Todos | System-managed | Affects task tracking |
+| `logs/` | Logs | View only | Used for troubleshooting |
+
+**Example (Windows):**
+
+```text
+C:\Users\Administrator\.jiuwenswarm\
+├── config\config.yaml
+├── service_default_service_id\
+│ └── agent_default_agent_id\
+│ └── agent\
+│ ├── AGENT.md
+│ ├── IDENTITY.md
+│ ├── SOUL.md
+│ ├── skills\
+│ └── sessions\
+```
+
+> **Notes:**
+> 1. Restart the service after changing config files.
+> 2. Do not hand-edit memory or session stores unless you know what you are doing.
+> 3. New skills must follow the skill format (see [Skills](Skills.md)).
---
-## Related configuration
+## Operations
+
+### Viewing and understanding agent configuration
+
+How to inspect settings and what is safe to change.
+
+#### View configuration
+
+**Option 1: Ask the agent**
+
+Examples:
+
+- “Show me the current configuration.”
+- “Where is my agent config file?”
+- “Read config.yaml for me.”
+
+The agent can read and summarize the files.
+
+**Option 2: Open the file directly**
+
+Use an editor (VS Code, Notepad++, etc.):
+
+```text
+C:\Users\<username>\.jiuwenswarm\config\config.yaml
+```
+
+#### Risk levels
+
+**Category 1 — safe to read**
+
+| Key | Meaning | Suggestion |
+|-----|---------|------------|
+| `preferred_language` | Preferred language | Read-only OK |
+| `logging.level` | Log level | Read-only OK |
+| `heartbeat.every` | Heartbeat interval | Read-only OK |
+| `channels.*.enabled` | Channel on/off | Read-only OK |
+
+**Category 2 — change with care**
+
+| Key | Meaning | Effect | Suggestion |
+|-----|---------|--------|------------|
+| `models.default.model_name` | Default model | Quality and speed | Confirm the model works first |
+| `models.default.temperature` | Temperature | Creativity vs. stability | Often 0.7–1.0 |
+| `heartbeat.active_hours` | Active window | When proactive runs fire | Match your schedule |
+| `permissions.tools.*` | Tool permissions | Safety | Understand risk before changing |
+
+**Category 3 — avoid unless you know why**
+
+| Key | Meaning | Risk | Suggestion |
+|-----|---------|------|------------|
+| `models.default.api_key` | API key | Leakage | Prefer environment variables |
+| `memory.external.*` | External memory engine | Memory may break | Keep defaults |
+| `gateway.*` | Gateway settings | Connectivity | Change only when deploying |
+| `permissions.rules.*` | Security rules | Security holes | Keep defaults |
+
+#### After you change config
+
+**Restart is required for changes to take effect.**
+
+```bash
+# Windows (depends on how you installed)
+# If running as a service:
+net stop jiuwenswarm
+net start jiuwenswarm
+
+# If running from the command line:
+# Stop the current process, then:
+jiuwenswarm-start
+# or: python -m jiuwenswarm.app
+```
+
+#### Common scenarios
+
+**Scenario 1: Switch model**
+
+```yaml
+# In config.yaml
+models:
+ default:
+ model_client_config:
+ model_name: "your-model-name" # e.g. deepseek-chat, gpt-4o
+```
+
+Restart the service.
+
+**Scenario 2: Adjust reply style**
+
+```yaml
+models:
+ default:
+ model_config_obj:
+ temperature: 0.8 # more creative
+ # temperature: 0.3 # more stable
+```
+
+**Scenario 3: Enable or disable a channel**
+
+```yaml
+channels:
+ feishu:
+ enabled: true
+ telegram:
+ enabled: false
+```
+
+#### Troubleshooting
+
+If something breaks after a config change:
+
+1. **Check logs** under `logs/`
+2. **Revert** the changed values
+3. **Restart** the service
+4. **Ask the agent** to help interpret errors
+
+> **Safety:**
+> - Back up `config.yaml` before editing.
+> - When unsure, ask the agent first.
+> - Put API keys in environment variables (`.env`), not plain text in YAML when possible.
+
+---
-- **Skill root**: `skill_base_dir` in `config/config.yaml`, default `agent/skills`.
-- **Agent workspace**: `~/.jiuwenswarm/agent/workspace/` (`get_agent_workspace_dir()`).
-- **Sessions**: `~/.jiuwenswarm/agent/sessions/`, one subfolder per `session_id`.
-- **SkillNet usage in Swarm**: see [Skills.md §5](Skills.md#5-how-skills-installed-via-skillnet-are-used-in-swarm).
+*Simplified Chinese: [智能体](../zh/智能体.md)*
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 347621dd0d..28d26e9cbf 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"
@@ -1,150 +1,338 @@
# 智能体
-`workspace` 是 JiuwenSwarm 的运行时工作目录,存放 Agent 的记忆、技能、会话数据及用户可配置的心跳任务。首次运行时(通过 `init` 或 `app`),`jiuwenswarm/resources/agent/workspace/` 下的模板会被复制到 `~/.jiuwenswarm/agent/workspace/`。内置技能位于包内的 `jiuwenswarm/resources/agent/workspace/skills/`;市场/安装的技能存储在用户 workspace 下。
+本文档帮助用户全面理解 JiuwenSwarm 中的"智能体"概念,包括其定义、组成结构、本地目录以及日常操作指导。
-![Workspace](../assets/images/agent.png)
+---
+
+## 概念科普
+
+### 智能体是什么
+
+JiuwenSwarm 中的"智能体"(Agent)是一个具备自主执行能力的数字化助手。它不是单纯的大语言模型,而是由多个组件协同构成的执行主体。
+
+**核心定义:**
+
+智能体 = 角色设定 + 工具 + 技能 + 记忆 + 工作空间
-## 目录结构总览
+**与普通大模型对话的区别:**
-**用户 workspace**(`~/.jiuwenswarm/`)的完整运行时布局:
+| 特性 | 普通大模型对话 | JiuwenSwarm 智能体 |
+|------|---------------|------------------|
+| 执行能力 | 仅生成文本回复 | 可调用工具执行实际操作(读写文件、运行命令、搜索网络等) |
+| 记忆能力 | 会话内短期记忆 | 跨会话长期记忆,可记住用户偏好、历史决策 |
+| 技能扩展 | 固定能力 | 可加载技能模块,扩展专业能力 |
+| 工作空间 | 无 | 拥有独立工作空间,管理任务、待办、配置 |
+| 个性化 | 无 | 可通过角色设定、配置定制行为风格 |
+
+**智能体与各组件的关系:**
```
-~/.jiuwenswarm/
-├── .updates/ # 更新状态(动态生成)
-│ └── web_process.json
-├── agent/
-│ ├── .checkpoint/ # 检查点数据库(运行时创建)
-│ │ ├── checkpoint.db # SQLite 检查点
-│ │ ├── checkpoint.db-shm # SQLite 共享内存
-│ │ └── checkpoint.db-wal # SQLite WAL 日志
-│ ├── .logs/ # Agent 进程日志
-│ │ ├── agent_server.log
-│ │ ├── channel.log
-│ │ ├── full.log
-│ │ ├── gateway.log
-│ │ ├── permissions.log
-│ │ └── ws-dev.log
-│ ├── sessions/ # 会话目录(动态生成)
-│ │ ├── sess_<id>/ # 普通会话
-│ │ │ ├── history.json # 会话历史
-│ │ │ ├── metadata.json # 会话元数据
-│ │ │ └── *.md, *.json # 会话中生成的文件
-│ │ └── heartbeat_<id>/ # 心跳任务会话
-│ └── workspace/ # Agent 标准工作空间
-│ ├── agents/ # Agent 工作区(DeepAgent 标准节点)
-│ │ └── .workspace # 节点标记文件
-│ ├── coding_memory/ # 编码记忆
-│ │ ├── .workspace
-│ │ └── MEMORY.md
-│ ├── context/ # 会话上下文
-│ │ ├── .workspace
-│ │ └── session_memory.md
-│ ├── memory/ # 记忆系统
-│ │ ├── .workspace
-│ │ ├── MEMORY.md # 长期记忆(init 时从 MEMORY_ZH/EN.md 复制)
-│ │ ├── daily_memory/ # 按日期的记忆文件(运行时创建)
-│ │ │ ├── .workspace
-│ │ │ ├── YYYY-MM-DD.md
-│ │ │ └── ...
-│ │ ├── memory.db # ChromaDB 向量数据库(运行时创建)
-│ │ ├── memory.db-shm
-│ │ └── memory.db-wal
-│ ├── messages/ # 消息工作区(DeepAgent 标准节点)
-│ │ └── .workspace
-│ ├── skills/ # 市场/安装的技能
-│ │ ├── .workspace
-│ │ ├── skills_state.json # Skill 安装/市场状态(动态生成)
-│ │ ├── _marketplace/ # 市场仓库克隆目录(运行时创建)
-│ │ └── <skill-name>/
-│ │ └── evolutions.json
-│ ├── todo/ # 待办工作区(DeepAgent 标准节点)
-│ │ └── .workspace
-│ ├── extensions/ # 扩展插件(运行时创建)
-│ ├── interactions/ # 交互上下文(运行时创建)
-│ ├── agent-data.json # Agent 列表元数据
-│ ├── AGENT.md # Agent 身份描述
-│ ├── HEARTBEAT.md # 心跳任务模板
-│ ├── IDENTITY.md # 身份描述
-│ ├── SOUL.md # Agent 灵魂/人格描述
-│ └── USER.md # 用户身份信息
-├── auto-harness/ # 自动 CI 流程(动态生成)
-│ └── config.yaml
-├── config/ # 配置目录
-│ ├── config.yaml # 主配置文件
-│ ├── .env # 环境变量
-│ ├── builtin_rules.yaml # 内置 shell 安全规则
-│ └── runtime_state.yaml # 运行时状态(动态生成)
-└── logs/ # 业务日志
- └── logs/
- ├── llm.log # LLM 调用日志
- ├── memory.log # 记忆模块日志
- ├── runner.log # Runner 日志
- ├── session.log # 会话日志
- ├── sys_operation.log # 系统操作日志
- ├── interface/
- │ ├── jiuwen_interface.log
- │ └── jiuwen_prompt_builder_interface.log
- ├── performance/
- │ └── jiuwen_performance.log
- └── run/
- └── jiuwen.log
+┌─────────────────────────────────────────────────────┐
+│ 智能体 (Agent) │
+├─────────────────────────────────────────────────────┤
+│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
+│ │ 角色设定 │ │ 工具 │ │ 技能 │ │ 记忆 │ │
+│ │(Identity)│ │(Tools) │ │(Skills)│ │(Memory)│ │
+│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
+│ ┌───────────────────────────────────────────────┐ │
+│ │ 工作空间 (Workspace) │ │
+│ │ ┌─────────┐ ┌─────────┐ ┌─────────────────┐│ │
+│ │ │ 待办 │ │ 配置 │ │ 会话管理 ││ │
+│ │ │ (Todo) │ │(Config)│ │ (Sessions) ││ │
+│ │ └─────────┘ └─────────┘ └─────────────────┘│ │
+│ └───────────────────────────────────────────────┘ │
+└─────────────────────────────────────────────────────┘
```
-内置技能模板位于 `jiuwenswarm/resources/agent/workspace/skills/`。这些内置技能不会在 init 时复制到用户 workspace(源码模式下直接从包内加载)。
+**理解要点:**
+
+1. **角色设定**:定义智能体的身份、性格、行为风格,决定"它是谁"
+2. **工具**:智能体的"手脚",用于执行文件操作、网络搜索、代码运行等
+3. **技能**:可加载的专业能力模块,如 Git 操作、文档生成等
+4. **记忆**:存储用户信息、历史对话、决策记录,实现跨会话连贯性
+5. **工作空间**:智能体的"办公桌",管理任务进度、配置、会话状态
+
+> **提示**:本节以理解概念为主,不涉及底层实现细节。后续章节将逐步展开各组件的具体内容。
---
-## 预置内容(Pre-configured)
+## 组成结构
+
+### 智能体由哪些部分组成
+
+智能体由六大核心部分组成,每部分承担不同职责。用户可根据需要关注和调整相应内容。
+
+**组成总览表:**
+
+| 组成部分 | 作用说明 | 用户关注程度 | 主要影响 |
+|----------|----------|--------------|----------|
+| **角色设定** | 定义智能体的身份、性格、回复风格 | 可定制 | 影响对话风格、行为偏好 |
+| **工作空间** | 存储任务、待办、会话、配置等运行数据 | 了解即可 | 影响任务管理、状态持久化 |
+| **工具** | 提供文件操作、网络搜索、代码执行等能力 | 一般不需修改 | 影响智能体可执行的操作范围 |
+| **技能** | 可加载的专业能力模块(如 Git 操作、PPT 制作) | 按需加载 | 扩展智能体的专业能力 |
+| **记忆** | 存储用户偏好、历史对话、重要决策 | 自动管理 | 影响跨会话连贯性、个性化服务 |
+| **待办** | 任务追踪与进度管理 | 日常使用 | 影响任务执行效率 |
+| **配置** | 模型参数、通道设置、权限控制等 | 高级用户可调整 | 影响模型选择、安全策略、通道连接 |
+
+**各部分详解:**
+
+#### 1. 角色设定 (Identity)
+
+角色设定决定了智能体"是谁"以及"如何与你交流"。包含:
+- 身份定位(如"私人智能助手"、"技术顾问")
+- 性格特征(如"简洁高效"、"详尽耐心")
+- 行为原则(如"先想办法再问"、"尊重信任")
+
+**文件位置**:`IDENTITY.md`、`SOUL.md`
+
+#### 2. 工作空间 (Workspace)
+
+工作空间是智能体的运行环境,存储:
+- 当前任务与待办事项
+- 会话历史与状态
+- 技能文件与配置
+- 临时文件与输出产物
+
+**文件位置**:`.jiuwenswarm/` 目录下
+
+#### 3. 工具 (Tools)
-随包或源码自带的、用户可直接使用或修改的内容:
+工具是智能体执行操作的能力集合,包括:
+- 文件操作:读取、写入、编辑、搜索
+- 网络操作:搜索、抓取网页
+- 代码执行:Python、JavaScript
+- 系统操作:Shell 命令
+- 多媒体处理:图片 OCR、音频转写、视频分析
-| 路径(workspace 下) | 说明 |
-|------|------|
-| `AGENT.md` | Agent 身份描述。从 `AGENT_ZH.md`/`AGENT_EN.md` 按语言复制。 |
-| `IDENTITY.md` | 身份描述。从 `IDENTITY_ZH.md`/`IDENTITY_EN.md` 按语言复制。 |
-| `SOUL.md` | Agent 灵魂/人格描述,用于系统提示词。从 `SOUL_ZH.md`/`SOUL_EN.md` 按语言复制。 |
-| `USER.md` | 用户身份信息。init 时从模板复制。 |
-| `HEARTBEAT.md` | 心跳任务模板(包内 `jiuwenswarm/resources/agent/workspace/HEARTBEAT_ZH.md` 或 `HEARTBEAT_EN.md`,初始化时按所选语言复制)。若存在且内容有效,Agent 会按心跳间隔读取并执行;否则仅返回 `HEARTBEAT_OK`。用户可在 Web 端编辑。 |
-| `skills/` | 市场/安装的技能。每个技能包含 `SKILL.md`、`prompts/`、`references/` 等。 |
-| `skills/_marketplace/` | 技能市场仓库克隆目录,预置为空。 |
-| `memory/` | 记忆目录结构。`MEMORY.md` 在 init 时从模板复制。 |
+**特点**:工具由系统预设,一般不需要用户手动修改。
+
+#### 4. 技能 (Skills)
+
+技能是可动态加载的专业能力模块,每个技能包含:
+- 任务目标定义
+- 执行步骤流程
+- 相关工具调用
+- 输出规范要求
+
+**示例技能**:
+- `gitcode-pr`:GitCode 平台创建 Pull Request
+- `gitcode-pr-review-fix`:处理 PR 检视意见并修改代码
+
+**文件位置**:`skills/` 目录
+
+#### 5. 记忆 (Memory)
+
+记忆系统分为三类:
+- **用户画像**:用户身份、偏好、习惯
+- **情景记忆**:具体事件、决策、对话片段
+- **语义记忆**:背景知识、技术细节、概念定义
+
+**特点**:记忆由系统自动管理,用户可通过搜索查询历史信息。
+
+#### 6. 配置 (Config)
+
+配置控制智能体的运行参数,包括:
+- 模型选择与参数(温度、超时等)
+- 通道设置(飞书、微信、Telegram 等)
+- 权限控制(哪些操作需要用户确认)
+- 记忆与日志设置
+
+**文件位置**:`config/config.yaml`
+
+> **重要提示**:并非所有内容都需要手动修改。大多数情况下,用户只需关注角色设定和技能加载,其他部分由系统自动管理。
---
-## 动态生成内容(Dynamically Generated)
-
-由系统或 Agent 在运行过程中创建和更新的内容:
-
-| 路径 | 说明 |
-|------|------|
-| `agent/.checkpoint/checkpoint.db` | SQLite 检查点数据库(附带 `.db-shm`、`.db-wal`)。 |
-| `agent/.logs/*.log` | Agent 进程日志(gateway、agent_server、channel、full、permissions、ws-dev)。 |
-| `agent/sessions/<session_id>/` | 每个会话对应一个子目录,内含 `history.json`(会话历史)、`metadata.json`(会话元数据)及会话中生成的 `*.md`、`*.json` 文件。 |
-| `agent/sessions/<session_id>/todo.md` | 由 `TodoToolkit` 创建,存储该会话的待办列表(可选)。 |
-| `agent/workspace/agent-data.json` | 由 `scripts/generate-agent-folders.js` 生成,供 Web 端展示 Agent 列表。 |
-| `agent/workspace/coding_memory/MEMORY.md` | 编码记忆内容。 |
-| `agent/workspace/context/session_memory.md` | 会话上下文记忆。 |
-| `agent/workspace/memory/daily_memory/YYYY-MM-DD.md` | 按日期生成的当日记忆文件,Agent 通过 `write_memory` 等工具写入。 |
-| `agent/workspace/memory/memory.db` | 向量检索数据库(ChromaDB),用于 `memory_search`(附带 `.db-shm`、`.db-wal`)。 |
-| `agent/workspace/skills/skills_state.json` | 由 `SkillManager` 维护,记录已安装的市场插件及状态。 |
-| `agent/workspace/skills/<skill>/evolutions.json` | 技能演化记录,由技能优化流程生成。 |
-| `agent/workspace/skills/_marketplace/` | 技能市场仓库克隆目录(运行 `_sync_marketplace_repos` 时创建)。 |
-| `agent/workspace/extensions/` | 扩展插件目录(运行时按需创建)。 |
-| `agent/workspace/interactions/` | 交互上下文目录(运行时按需创建)。 |
-| `.updates/web_process.json` | Web 进程更新状态。 |
-| `auto-harness/config.yaml` | 自动 CI 流程配置。 |
-| `config/runtime_state.yaml` | 运行时状态。 |
-| `logs/logs/*.log` | 业务日志(llm、memory、runner、session、sys_operation)。 |
-| `logs/logs/interface/jiuwen_interface.log` | Interface 模块日志。 |
-| `logs/logs/interface/jiuwen_prompt_builder_interface.log` | Prompt builder 接口日志。 |
-| `logs/logs/performance/jiuwen_performance.log` | 性能日志。 |
-| `logs/logs/run/jiuwen.log` | 运行日志。 |
+## 目录结构
+
+### 本地目录与关键文件
+
+JiuwenSwarm 的本地目录结构如下,帮助用户快速定位关键文件。
+
+**目录总览:**
+
+```
+C:\Users\<用户名>\.jiuwenswarm\
+│
+├── config/ # 配置目录
+│ ├── config.yaml # 主配置文件(模型、通道、权限等)
+│ └── builtin_rules.yaml # 内置规则配置
+│
+├── agent/ # 智能体相关
+│ └── <service_id>/ # 服务实例目录
+│ └── <agent_id>/ # 智能体实例目录
+│ ├── agent/ # 智能体工作空间
+│ │ ├── AGENT.md # 智能体启动配置
+│ │ ├── IDENTITY.md # 身份设定
+│ │ ├── SOUL.md # 灵魂与价值观
+│ │ ├── HEARTBEAT.md # 心跳任务配置
+│ │ └── sessions/ # 会话数据
+│ ├── config/ # 智能体级配置(可选覆盖)
+│ ├── memory/ # 智能体记忆存储
+│ ├── skills/ # 技能库
+│ └── todo/ # 待办事项
+│
+├── gateway/ # 网关相关
+├── logs/ # 日志文件
+├── memory/ # 全局记忆存储
+├── received_files/ # 接收的外部文件
+└── web/ # Web 通道相关
+```
+
+**关键文件说明:**
+
+| 文件路径 | 内容说明 | 是否建议修改 | 修改后影响 |
+|----------|----------|--------------|------------|
+| `config/config.yaml` | 主配置:模型、通道、权限、记忆等 | 高级用户可谨慎修改 | 影响模型调用、通道连接、安全策略;修改后需重启服务 |
+| `config/builtin_rules.yaml` | 内置规则 | 不建议修改 | 影响系统默认行为 |
+| `agent/<id>/agent/AGENT.md` | 智能体启动配置 | 可适当更新 | 影响智能体启动行为 |
+| `agent/<id>/agent/IDENTITY.md` | 身份设定 | 可定制 | 影响智能体身份认知 |
+| `agent/<id>/agent/SOUL.md` | 灵魂与价值观 | 可定制 | 影响智能体行为风格 |
+| `agent/<id>/agent/HEARTBEAT.md` | 心跳任务 | 可调整 | 影响定时任务、主动行为 |
+| `agent/<id>/skills/` | 技能库 | 可添加新技能 | 扩展智能体能力 |
+| `agent/<id>/memory/` | 记忆存储 | 不建议手动修改 | 影响记忆数据完整性 |
+| `agent/<id>/todo/` | 待办事项 | 系统自动管理 | 影响任务追踪 |
+| `logs/` | 日志文件 | 仅查看,不修改 | 用于问题排查 |
+
+**实际路径示例(Windows):**
+
+```
+C:\Users\Administrator\.jiuwenswarm\
+├── config\config.yaml # 主配置
+├── service_default_service_id\
+│ └── agent_default_agent_id\
+│ └── agent\
+│ ├── AGENT.md # 启动配置
+│ ├── IDENTITY.md # 身份
+│ ├── SOUL.md # 灵魂
+│ ├── skills\ # 技能
+│ └── sessions\ # 会话
+```
+
+> **注意事项**:
+> 1. 配置文件修改后通常需要重启服务才能生效
+> 2. 记忆和会话数据不建议手动修改,可能导致数据损坏
+> 3. 技能文件可添加,但需遵循技能规范格式
---
-## 相关配置
+## 操作指导
+
+### 如何查看和理解智能体配置
+
+本节指导用户如何查看智能体相关文件,并区分不同内容的修改风险。
+
+#### 查看配置文件
+
+**方法一:通过智能体询问**
+
+直接向智能体提问,如:
+- "查看一下当前的配置信息"
+- "我的智能体配置文件在哪里"
+- "帮我看看 config.yaml 的内容"
+
+智能体会自动读取并展示相关内容。
+
+**方法二:直接打开文件**
+
+使用文本编辑器(如 VS Code、Notepad++)打开:
+```
+C:\Users\<用户名>\.jiuwenswarm\config\config.yaml
+```
+
+#### 配置内容分类
+
+根据修改风险,将配置内容分为三类:
+
+**类别一:可读可理解(安全查看)**
+
+| 内容 | 说明 | 建议 |
+|------|------|------|
+| `preferred_language` | 首选语言 | 可查看 |
+| `logging.level` | 日志级别 | 可查看 |
+| `heartbeat.every` | 心跳间隔 | 可查看 |
+| `channels.*.enabled` | 通道启用状态 | 可查看 |
+
+**类别二:可谨慎修改(需了解影响)**
+
+| 内容 | 说明 | 修改影响 | 建议 |
+|------|------|----------|------|
+| `models.default.model_name` | 默认模型 | 影响回复质量和速度 | 确认模型可用后再改 |
+| `models.default.temperature` | 模型温度 | 影响回复创造性 | 0.7-1.0 为常用范围 |
+| `heartbeat.active_hours` | 活跃时段 | 影响主动行为时间 | 按个人作息调整 |
+| `permissions.tools.*` | 工具权限 | 影响操作安全性 | 了解风险后调整 |
+
+**类别三:非必要不建议修改(高风险)**
+
+| 内容 | 说明 | 修改风险 | 建议 |
+|------|------|----------|------|
+| `models.default.api_key` | API 密钥 | 密钥泄露风险 | 通过环境变量配置 |
+| `memory.external.*` | 记忆引擎配置 | 记忆功能失效 | 保持默认 |
+| `gateway.*` | 网关配置 | 连接中断 | 仅在部署时调整 |
+| `permissions.rules.*` | 安全规则 | 安全漏洞 | 保持默认 |
+
+#### 修改配置后的操作
+
+**重要:配置修改后需重启服务才能生效**
+
+```bash
+# Windows(以实际安装方式为准)
+# 如果是服务模式运行:
+net stop jiuwenswarm
+net start jiuwenswarm
+
+# 如果是命令行运行:
+# 关闭当前进程,重新启动
+jiuwenswarm-start
+# 或:python -m jiuwenswarm.app
+```
+
+#### 常见修改场景
+
+**场景一:更换模型**
+
+```yaml
+# config.yaml 中修改
+models:
+ default:
+ model_client_config:
+ model_name: "新模型名称" # 如 deepseek-chat、gpt-4 等
+```
+
+修改后重启服务。
+
+**场景二:调整回复风格**
+
+```yaml
+# config.yaml 中修改
+models:
+ default:
+ model_config_obj:
+ temperature: 0.8 # 提高创造性
+ # temperature: 0.3 # 降低创造性,更稳定
+```
+
+**场景三:启用/禁用通道**
+
+```yaml
+# config.yaml 中修改
+channels:
+ feishu:
+ enabled: true # 启用飞书通道
+ telegram:
+ enabled: false # 禁用 Telegram 通道
+```
+
+#### 问题排查
+
+如果修改配置后出现问题:
+
+1. **检查日志**:查看 `logs/` 目录下的日志文件
+2. **恢复默认**:将修改的内容恢复到原始值
+3. **重启服务**:确保配置生效
+4. **询问智能体**:让智能体帮助分析问题
-- **Skill 根目录**:`config/config.yaml` 中 `skill_base_dir` 默认为 `agent/skills`。
-- **Agent 工作空间**:`~/.jiuwenswarm/agent/workspace/`(`get_agent_workspace_dir()`)。
-- **会话目录**:`~/.jiuwenswarm/agent/sessions/`,每个 `session_id` 对应一个子目录。
-- **SkillNet 与技能在 Swarm 中的使用方式**:详见 [技能.md](技能.md#5-skillnet-安装的技能在-swarm-中如何被使用)。
+> **安全提示**:
+> - 修改前建议备份原配置文件
+> - 不确定的内容先询问智能体
+> - API 密钥等敏感信息通过环境变量配置,不要直接写入配置文件
\ No newline at end of file