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: 会话、定时任务
renquanjiab7309bf5e4f3
diff --git a/docs/assets/images/cron/chat_create_schedule_task.png b/docs/assets/images/cron/chat_create_schedule_task.pngnew file mode 100644index 0000000000..31c9877f9fBinary files /dev/null and b/docs/assets/images/cron/chat_create_schedule_task.png differdiff --git a/docs/assets/images/cron/create_schedule_task.png b/docs/assets/images/cron/create_schedule_task.pngnew file mode 100644index 0000000000..6d8965abb6Binary files /dev/null and b/docs/assets/images/cron/create_schedule_task.png differdiff --git a/docs/assets/images/cron/schedule_task_demo1.png b/docs/assets/images/cron/schedule_task_demo1.pngnew file mode 100644index 0000000000..4e56603ca3Binary files /dev/null and b/docs/assets/images/cron/schedule_task_demo1.png differdiff --git a/docs/assets/images/cron/schedule_task_demo2.png b/docs/assets/images/cron/schedule_task_demo2.pngnew file mode 100644index 0000000000..c40b26f11eBinary files /dev/null and b/docs/assets/images/cron/schedule_task_demo2.png differdiff --git a/docs/assets/images/cron/schedule_task_demo_daily_work_notice_1.png b/docs/assets/images/cron/schedule_task_demo_daily_work_notice_1.pngnew file mode 100644index 0000000000..71dd2876ebBinary files /dev/null and b/docs/assets/images/cron/schedule_task_demo_daily_work_notice_1.png differdiff --git a/docs/assets/images/cron/schedule_task_demo_daily_work_notice_2.png b/docs/assets/images/cron/schedule_task_demo_daily_work_notice_2.pngnew file mode 100644index 0000000000..9364d8b1aeBinary files /dev/null and b/docs/assets/images/cron/schedule_task_demo_daily_work_notice_2.png differdiff --git a/docs/assets/images/session/jiuwenclaw_session_history.png b/docs/assets/images/session/jiuwenclaw_session_history.pngnew file mode 100644index 0000000000..9571172e03Binary files /dev/null and b/docs/assets/images/session/jiuwenclaw_session_history.png differdiff --git a/docs/assets/images/session/jiuwenclaw_session_history_delete.png b/docs/assets/images/session/jiuwenclaw_session_history_delete.pngnew file mode 100644index 0000000000..f78adf2243Binary files /dev/null and b/docs/assets/images/session/jiuwenclaw_session_history_delete.png differdiff --git a/docs/assets/images/session/jiuwenclaw_session_history_json.png b/docs/assets/images/session/jiuwenclaw_session_history_json.pngnew file mode 100644index 0000000000..2b712dceaeBinary files /dev/null and b/docs/assets/images/session/jiuwenclaw_session_history_json.png differdiff --git a/docs/assets/images/session/jiuwenclaw_session_history_metadata.png b/docs/assets/images/session/jiuwenclaw_session_history_metadata.pngnew file mode 100644index 0000000000..ab43ff57d6Binary files /dev/null and b/docs/assets/images/session/jiuwenclaw_session_history_metadata.png differdiff --git a/docs/assets/images/session/jiuwenclaw_session_history_preview.png b/docs/assets/images/session/jiuwenclaw_session_history_preview.pngnew file mode 100644index 0000000000..69c47d8281Binary files /dev/null and b/docs/assets/images/session/jiuwenclaw_session_history_preview.png differdiff --git a/docs/assets/images/session/jiuwenclaw_session_recovery_history_1.png b/docs/assets/images/session/jiuwenclaw_session_recovery_history_1.pngnew file mode 100644index 0000000000..a2ae304a34Binary files /dev/null and b/docs/assets/images/session/jiuwenclaw_session_recovery_history_1.png differdiff --git a/docs/assets/images/session/jiuwenclaw_session_recovery_history_2.png b/docs/assets/images/session/jiuwenclaw_session_recovery_history_2.pngnew file mode 100644index 0000000000..1c9bf4040dBinary files /dev/null and b/docs/assets/images/session/jiuwenclaw_session_recovery_history_2.png differdiff --git "a/docs/assets/images/\344\274\232\350\257\235\345\210\227\350\241\250.png" "b/docs/assets/images/\344\274\232\350\257\235\345\210\227\350\241\250.png"new file mode 100644index 0000000000..8499f41d1bBinary files /dev/null and "b/docs/assets/images/\344\274\232\350\257\235\345\210\227\350\241\250.png" differdiff --git "a/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2411.png" "b/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2411.png"deleted file mode 100644index 71f3f0ec55..0000000000Binary files "a/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2411.png" and /dev/null differdiff --git "a/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2412.png" "b/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2412.png"deleted file mode 100644index 52bfed263a..0000000000Binary files "a/docs/assets/images/\345\256\232\346\227\266\344\273\273\345\212\2412.png" and /dev/null differdiff --git "a/docs/assets/images/\346\201\242\345\244\215\344\274\232\350\257\235.png" "b/docs/assets/images/\346\201\242\345\244\215\344\274\232\350\257\235.png"new file mode 100644index 0000000000..14d2cf2504Binary files /dev/null and "b/docs/assets/images/\346\201\242\345\244\215\344\274\232\350\257\235.png" differdiff --git a/docs/en/Channels.md b/docs/en/Channels.mdindex 1d0c1a1296..d7e2f2a384 100644--- a/docs/en/Channels.md+++ b/docs/en/Channels.md@@ -39,6 +39,8 @@ This tutorial focuses on **Web UI configuration**. Subsequent channel setup instFor manual configuration, edit the `config.yaml` file (default path: `~/.jiuwenswarm/config/config.yaml`), set the corresponding channel to `enabled: true` and fill in the credentials. Changes take effect automatically upon saving.+- **Edit `config.yaml` manually** — Default location is `~/.jiuwenswarm/config/config.yaml` (created automatically on first `jiuwenswarm-start`). Set the desired channel to `enabled: true` and fill in the credentials; saving triggers an automatic reload without restarting.+### Channel Feature DifferencesDifferent channels have varying capabilities regarding private/group chat support, trigger methods, and permission requirements:diff --git a/docs/en/SUMMARY.md b/docs/en/SUMMARY.mdindex 7bb61d3e5b..bf5770cccd 100644--- a/docs/en/SUMMARY.md+++ b/docs/en/SUMMARY.md@@ -31,8 +31,11 @@- [Coding Memory](CodingMemory.md)- [Skills](Skills.md)- [Symphony](symphony.md)+ - [Agentic Skill Retrieval](AgenticSkillRetrieval.md)+ - [Team Skills](TeamSkills.md)- [Skill self-evolution](SkillSelfEvolution.md)- [Agent & workspace](Agent.md)+ - [Session management](Session.md)- [Browser tools](Browser.md)- [MCP Configuration](MCPConfiguration.md)- [Packaging desktop executables](PackExeGuide.md)diff --git a/docs/en/ScheduledTasks.md b/docs/en/ScheduledTasks.mdindex 5d8d9f57b3..d9732ff497 100644--- a/docs/en/ScheduledTasks.md+++ b/docs/en/ScheduledTasks.md@@ -1,77 +1,282 @@-## Scheduled tasks (Cron)+# Scheduled Tasks (Cron)-How to create and manage a simple scheduled job in JiuwenSwarm and push results to a channel (e.g. web, Feishu).+Scheduled tasks (Cron) are an essential mechanism for automation in JiuwenSwarm.----### 1. What can cron jobs do?+## Concepts-- **Run a one-line instruction on a schedule**, e.g. “send me the weather in Hangzhou every morning at 9.”-- **Let the agent execute work** on a timer, such as running searches and generating results.-- **Team / SwarmFlow on a schedule** (`mode=team`, etc.): wake multi-agent workflows for reports, comparisons, and other complex jobs (see [§6](#6-team-mode-and-swarmflow-multi-agent-scheduled-jobs)).-- **Multi-channel delivery** — scheduled tasks are currently supported on web, Feishu, WeCom, DingTalk, and WeChat. Non-web channels must be enabled in channel management; see [Channels](Channels.md).+### What are Scheduled Tasks++A **Scheduled Task (Cron Job)** is a mechanism that automatically executes tasks according to a predefined schedule. In JiuwenSwarm, scheduled tasks allow the Agent to automatically perform specific operations at specified times and push results to designated channels.++**Core Capabilities:**++| Capability | Description |+|------------|-------------|+| **Scheduled Execution** | Automatically triggered based on Cron expression |+| **Natural Language Description** | Describe tasks in natural language, Agent understands and executes |+| **Multi-channel Delivery** | Results can be pushed to Web, Feishu, WeChat, etc. |+| **Auto Wake-up** | Wake up Agent in advance to ensure timely execution |+| **Team/SwarmFlow** | Support multi-agent collaboration for complex tasks (see [§6](#6-team-mode-and-swarmflow-multi-agent-scheduled-jobs)) |++**Typical Use Cases:**++- 📅 **Daily Reminders**: Send work reminders, health reminders at fixed times+- 📊 **Periodic Summaries**: Regularly summarize data, generate daily/weekly reports+- 🔄 **Scheduled Checks**: Periodically check system status, monitor task progress+- 📢 **Message Push**: Send messages or notifications to specific channels on schedule+- 🤝 **Collaborative Tasks**: Team mode multi-agent collaboration for complex analysis++### Cron Expression Syntax++Cron expressions are the standard format for defining when scheduled tasks execute.++**Basic Format:**++```+minute hour day month weekday+```++| Field | Range | Description |+|-------|-------|-------------|+| minute | 0-59 | Minute |+| hour | 0-23 | Hour |+| day | 1-31 | Day of month |+| month | 1-12 | Month |+| weekday | 0-6 | Day of week (0=Sunday) |++**Special Characters:**++| Character | Description | Example |+|-----------|-------------|---------|+| `*` | Any value | `* * * * *` = every minute |+| `,` | Multiple values | `0,30 * * * *` = 0th and 30th minute of every hour |+| `-` | Range | `0 9-17 * * *` = every hour from 9am to 5pm |+| `/` | Interval | `*/15 * * * *` = every 15 minutes |++**Common Expression Examples:**++| Expression | Meaning |+|------------|---------|+| `0 9 * * *` | Every day at 9:00 AM |+| `30 18 * * *` | Every day at 6:30 PM |+| `0 9 * * 1` | Every Monday at 9:00 AM |+| `0 9,18 * * *` | Every day at 9:00 AM and 6:00 PM |+| `*/30 * * * *` | Every 30 minutes |+| `0 0 * * *` | Every day at midnight |++### Difference between Cron and Heartbeat++JiuwenSwarm provides two automation mechanisms: **Scheduled Tasks (Cron)** and **Heartbeat**. For detailed comparison, see [Cron vs Heartbeat section in Heartbeat tutorial](Heartbeat.md#difference-between-cron-and-heartbeat).++| Aspect | Scheduled Tasks (Cron) | Heartbeat |+|--------|------------------------|-----------|+| **Trigger Method** | Triggered at fixed time points | Triggered at fixed intervals |+| **Time Definition** | Uses Cron expression (e.g., every day at 9am) | Uses interval duration (e.g., every 5 minutes) |+| **Use Cases** | Tasks with specific time points (reports, reminders, collaborative analysis) | Continuous checks, status monitoring |+| **Configuration** | Configure Cron expression | Configure heartbeat interval |+| **Execution Precision** | Precise to specified time point | Executes at interval cycles |----### 2. Create a job in the web UI+## Quick Start++### Create via Web Interface++**Steps:**++1. Open JiuwenSwarm Web interface, click **"Scheduled Tasks"** in the left navigation+2. Enter the scheduled tasks page, click **"Create"** button (highlighted in red box)+3. Fill in the task configuration form:++++| Field | Description | Example |+|-------|-------------|---------|+| **Task Name** | Task name (unique identifier) | `daily_reminder` |+| **Cron Expression** | Cron expression | `0 9 * * *` (every day at 9am) |+| **Status** | Task status | Enable/Disable |+| **Description** | Task content description | Generate today's work reminder |+| **Wake Offset Seconds** | Wake-up advance seconds | `300` (5 minutes advance) |+| **Delivery Channel** | Result delivery channel | `web`, `feishu`, `wechat`, `wecom`, `whatsapp`, `telegram`, etc. |++4. Click **"Create"**, the task will take effect automatically++**Storage Location:**++Scheduled task configurations are saved at:+```+~/.jiuwenswarm\agent\home\cron_jobs.json+```++### Create via Chat++When the Agent has the `cron_create_job` tool capability, you can create scheduled tasks directly through natural language conversation.++++**Example Conversation:**++```+User: Create a scheduled task to remind me to drink water every morning at 9.+```++The Agent will automatically:+1. Parse time intent → `cron_expr: "0 9 * * *"`+2. Understand task content → `description: "remind to drink water"`+3. Determine delivery channel → `targets: "web"`+4. Call the tool to create the task++> **Tip**: When creating tasks via chat, the Agent automatically infers reasonable defaults based on context, such as timezone and channel.++---++## Scheduled Task Execution++### Execution Process++When a scheduled task triggers at the fixed time, a running conversation will appear on the chat page.++**Execution Flow:**-1. Open **Cron / Scheduled tasks**.-2. Click **New job** and fill in:+1. **Trigger Time**: Reaches the time point defined by Cron expression+2. **Agent Wake-up**: Agent is woken up based on `wake_offset_seconds` advance+3. **Task Execution**: Agent starts executing the content described in the task+4. **Result Delivery**: After execution completes, results are pushed to the designated channel- - **Task name**: e.g. `Daily Hangzhou weather update`- - **Cron expression** (supports seven-field cron expressions):- - Every day at 09:00: `0 0 9 * * ? *`- - Minute 15 every hour: `0 15 * * * ? *`- - **Status (enabled)**: on means enabled- - **Description (task content)**: a natural-language description of what the agent should do at the scheduled time, e.g.- `Check the weather in Hangzhou and send it to the user`- - **Wake offset in seconds** (how long before the scheduled delivery time the task starts): `300` (default)- - **Timezone**: usually `Asia/Shanghai`- - **Delivery channel**: select from the dropdown:- - `Web (web)`: deliver to the web panel+**Execution Status:**-+| Status | Description |+|--------|-------------|+| **Pending** | Task created, waiting for trigger time |+| **Running** | Agent is executing the task |+| **Completed** | Task execution finished, results pushed |+| **Failed** | Error occurred during task execution |-3. Save. Jobs are stored in `~/.jiuwenswarm/agent/home/cron_jobs.json` and picked up by the scheduler.+### View Execution Results++The execution results of scheduled tasks can be viewed on the chat page.++++----### 3. Common cron expressions+## Scheduled Task Management-- **Daily 09:00**: `0 0 9 * * ? *`-- **Daily 18:30**: `0 30 18 * * ? *`-- **Monday 09:00**: `0 30 9 ? * MON *`-- **Every hour on the hour**: `0 0 * * * ? *`+After creation, tasks can be managed on the frontend page with the following operations:++| Operation | Description |+|-----------|-------------|+| **Run Now** | Manually trigger the task to execute immediately |+| **Preview** | View task configuration details |+| **Disable** | Pause the task, no longer auto-trigger |+| **Update** | Modify task configuration |+| **Delete** | Delete the task |-Format (7 fields, space-separated):-`second minute hour day month weekday year`----### 4. Create via chat (optional)+## Practical Examples++### Daily Work Reminder++**Scenario:** Automatically generate a work reminder every morning at 9 AM and push to the Web interface.++**Configuration Steps:**++1. Create a scheduled task, enter in the chat:+```+Every morning at 9 AM, automatically generate today's work reminder, including: 1) Todo list 2) Important schedule 3) Weather info+```++++2. After successful creation, the Agent will automatically execute and push results at 9:00 AM every day++**Data Source Explanation:** Todos, schedules, etc. are read by the Agent from `agent/memory/` memory files (written during daily conversations); weather info is obtained via search tools. Content not in memory typically won't appear in the reminder.++**Execution Result:**++++```+📋 Today's Work Reminder (May 20, 2026, Wednesday)++1️⃣ Todo List+Currently no pending todos.++2️⃣ Important Schedule+No important schedule for today.-If the agent has `cron_create_job`, you can say things like:+3️⃣ Weather Info+Today's weather:-> “Create a scheduled task to remind me to drink water on the web every morning at 8:30.”+- 🌫️ Condition: Cloudy+- 🌡️ Temperature: 16°C ~ 25°C+- 💨 Wind: East wind, light breeze+- 📍 Location: Beijing-The agent fills `cron_expr`, `description`, `targets`, etc., equivalent to using the form.+Three-day Forecast:-+- May 21 (Thu): Cloudy to light rain, 16°C ~ 24°C, south wind light breeze+- May 22 (Fri): Moderate rain to cloudy, 17°C ~ 23°C, south wind light breeze+- May 23 (Sat): Cloudy, 19°C ~ 28°C, southwest wind light breeze++Tips:++- Today is cloudy with moderate temperature, recommend wearing a light jacket+- Rain expected tomorrow and the day after, please prepare rain gear in advance+- Weekend weather will improve, suitable for outdoor activities+- Wish you a productive day! If you have new todos or schedule, feel free to tell me.+```----### 5. Push to the TUI channel+## FAQ++### Q1: What if the scheduled task doesn't execute on time?++**Troubleshooting Steps:**++1. Check if the task is enabled (`enabled: true`)+2. Verify the Cron expression is correct+3. Check if the timezone setting is correct+4. Ensure JiuwenSwarm service is running+5. Check log files for any errors++### Q2: How to modify an existing scheduled task?++In the scheduled task list on the Web interface, click the **"Edit"** button on the right side of the task, modify the configuration and save. The scheduler will automatically update after modification.++### Q3: Are scheduled task results saved?-When `targets` is `tui` (also the default for `/cron add`):+Scheduled task execution results are:+- Pushed to the designated channel (Web/Feishu, etc.)+- Saved as session history in corresponding session files+- Viewable through session management-- The scheduler **intentionally omits** `session_id`, so results are not filtered out after a TUI restart or session switch.-- The Gateway **broadcasts** these session-less notifications to **every connected TUI window**, so each open terminal receives the cron result.-- To scope reminders differently, use `targets=web`, or manage jobs via `/cron` in TUI and view them in the Web panel.+### Q4: What does wake_offset_seconds do?-Session-scoped chat streams are routed to a single TUI window by `session_id`; cron push to TUI is the exception and reaches all windows.+`wake_offset_seconds` defines how early to wake up the Agent. For example:+- Task scheduled for 9:00 AM+- `wake_offset_seconds: 300` (5 minutes)+- Agent starts preparing at 8:55 AM to ensure execution at 9:00 AM sharp++### Q5: Which delivery channels are supported?++Currently supported channels:+- `web` - Web interface+- `feishu` - Feishu+- `wechat` - WeChat+- `wecom` - WeCom (Enterprise WeChat)+- `whatsapp` - WhatsApp+- `telegram` - Telegram----### 6. Team mode and SwarmFlow (multi-agent scheduled jobs)+## 6. Team mode and SwarmFlow (multi-agent scheduled jobs)Besides the default single-agent path, cron jobs now support **Team mode**: at wake time the gateway starts multi-agent collaboration and may run a **SwarmFlow** workflow (see [Agent Team](AgentTeam.md) and [TUI SwarmFlow Guide](TUISwarmFlowGuide.md)).@@ -128,14 +333,14 @@ All `targets` channels (`web`, `tui`, Feishu, DingTalk, WeCom, etc.) share the s| Scenario | Push body format ||---|---|| **Successful completion** | `{agent output}` (no job-name prefix, no `[cron]` prefix) |-| **Failure / timeout / no valid report** | Status text starting with `[cron]` (e.g. `[cron] 任务执行失败: …`), not wrapped with a job-name prefix |+| **Failure / timeout / no valid report** | Status text starting with `[cron]` (e.g. `[cron] job execution failed: …`), not wrapped with a job-name prefix || **In-progress placeholder** | `{job name} 正在执行中,结果稍后补发(push_at=…)` |Channel differences are mainly **routing**, not body format:- **`web`**: delivered to the Web chat panel; placeholders can be replaced by final results via `payload.cron.is_placeholder` and `run_id`.- **`tui`**: intentionally omits `session_id`; Gateway **broadcasts** to every connected TUI window. Broadcast may be missed if no TUI is online at completion time.-- **Feishu / DingTalk / WeCom and other IM channels**: route via the job’s bound `session_id` and `metadata`; group-created jobs may use IMOutboundPipeline routing.+- **Feishu / DingTalk / WeCom and other IM channels**: route via the job's bound `session_id` and `metadata`; group-created jobs may use IMOutboundPipeline routing.Keep the gateway running, or inspect jobs via `/cron show` or the Web Cron panel.@@ -160,3 +365,18 @@ Structured signals (workflow completed + leader final, or harness leader final w| `channels/tui/.../cron.ts` | `/cron` subcommands and `mode` / `timeout_seconds` |See also [Slash commands — `/cron`](SlashCommands.md#cron-scheduled-task-management).++---++## Related Links++- [Heartbeat](Heartbeat.md) - Learn about the difference between heartbeat and scheduled tasks+- [Channels](Channels.md) - Configure message delivery channels+- [Task Planning](TaskPlanning.md) - Learn about task management+- [Agent Tutorial](Agent.md) - Learn about conversation features++---++*Document Version: v1.0*+*Target Audience: JiuwenClaw Users*+*Last Updated: 2026-05-05*diff --git a/docs/en/Session.md b/docs/en/Session.mdnew file mode 100644index 0000000000..4b868f4ebb--- /dev/null+++ b/docs/en/Session.md@@ -0,0 +1,226 @@+# Session++Sessions are the core mechanism in JiuwenSwarm for managing conversation history and context.++---++## Concepts++### What is a Session++A **Session** is a data unit in JiuwenSwarm used to record and manage single or multiple continuous conversation interactions. Each session contains:++- **Conversation History**: Complete message exchanges between user and AI+- **Context Information**: Current task status, execution progress, intermediate results, etc.+- **Metadata**: Session ID, creation time, last update time, and other identifiers++> **Tip**: Session and Memory are two different concepts:+> - **Session**: Temporary conversation history, disappears when closed or cleared+> - **Memory**: Persistently stored important information, retained across sessions++### Session File Structure++JiuwenSwarm session data is stored in the local workspace with the following structure:++```+.jiuwenswarm/+└── agent/+ └── sessions/+ ├── sess_19ddd41cbc0_fd1e4d/ # Regular session directory+ │ ├── metadata.json # Session metadata+ │ └── history.json # Conversation history+ ├── sess_19ddd5cc729_09bb02/ # Another session+ │ ├── metadata.json+ │ └── history.json+ ├── heartbeat_19de6f526fb_224694/ # Heartbeat session directory+ │ ├── metadata.json+ │ └── history.json+ └── ...+```++**Session Types:**++| Directory Prefix | Type | Description |+|------------------|------|-------------|+| `sess_` | Regular Session | Conversation sessions initiated via Web, Feishu, etc. |+| `heartbeat_` | Heartbeat Session | System heartbeat task sessions |+| `cron_` | Cron Session | Scheduled task sessions triggered by cron jobs |++**metadata.json File Content:**++++| Field | Description | Example |+|-------|-------------|---------|+| `session_id` | Unique session identifier | `sess_19ddd41cbc0_fd1e4d` |+| `channel_id` | Session source channel | `web`, `feishu`, `__heartbeat__` |+| `user_id` | User identifier | Empty or user ID |+| `created_at` | Session creation time (Unix timestamp) | `1716249600.732591` |+| `last_message_at` | Last message time | `1716253200.865117` |+| `title` | Session title (usually first message summary) | `Help me write a technical document` |+| `message_count` | Total message count | `15` |+| `mode` | Execution mode | `agent.plan` |++**history.json File Content:**++history.json is a JSON array that records complete conversation history. Each message contains the following fields:++++| Field | Description | Example |+|-------|-------------|---------|+| `id` | Unique message identifier, suffix `user` indicates user query, suffix `assistant` indicates agent response | `req_mol5noj7_22:user` |+| `role` | Message role | `user` or `assistant` |+| `request_id` | Request identifier | `req_mol5noj7_22` |+| `channel_id` | Message source channel | `web` |+| `timestamp` | Message timestamp | `1777533730.7309785` |+| `content` | Message content | User input or AI response text |+| `event_type` | Event type | `chat.delta`, `chat.final`, `chat.reasoning` |+| `tool_calls` | Tool call information (only in assistant messages) | Contains tool name, parameters, etc. |++> **Tip**: Agent response messages also contain `tool_calls` and other fields for recording tool call information.++### Why Sessions are Needed++The session mechanism plays an important role in JiuwenSwarm:++1. **Context Continuity**+ - Maintains conversation coherence, AI can understand previous exchanges+ - Supports information reference and supplementation in multi-turn conversations++2. **Task State Tracking**+ - Records task planning, execution progress, and intermediate results+ - Supports task interruption, resumption, and adjustment++3. **History Review**+ - Users can view previous conversation records+ - Facilitates review and problem-solving process tracing++4. **Resource Management**+ - Reasonably manages conversation context, avoids information overload+ - Supports context compression mechanism, optimizes token usage++### Session Use Cases++| Scenario | Description |+|----------|-------------|+| **Daily Conversation** | Q&A, consultation, content creation with AI |+| **Task Execution** | Execute complex tasks, track progress, adjust plans |+| **History Review** | View previous conversations, resume interrupted work |+| **Problem Investigation** | Trace issues through session records, analyze execution process |+| **Multi-task Switching** | Switch between different sessions, handle multiple independent tasks |+| **Cron Task Execution** | Scheduled tasks automatically trigger sessions, execute periodic work |+| **Multi-channel Conversation** | Conversations from different channels (Web, Feishu, WeChat, etc.) |++---++## Feature Demo++### View Session Chat History++You can view complete chat history of all sessions to understand past conversation content.++++**Steps:**++1. **Via Web Interface**+ - In JiuwenSwarm Web interface, click "Sessions" in the left navigation+ - Enter session management page to see all session list (as displayed in frontend session management)+ - Click any session to view its complete chat history++2. **Via Local Files**+ - Navigate to session storage directory: `.jiuwenswarm/agent/sessions/`+ - Enter the corresponding session directory (e.g., `sess_19ddd41cbc0_fd1e4d/`)+ - View conversation content in `history.json` file++> **Tip**: The frontend page has a "Conversation Preview" toggle to switch between JSON text format or conversation page format, convenient for viewing raw data or conversation content.++### Restore Session++Restoring a session syncs historical session content to the frontend to continue previous work.++++++**Steps:**++1. Find the session to restore in the session management page (recommend selecting an actual chat history session, not a heartbeat session)+2. Click the "Restore" button or double-click the session entry+3. System will load all historical messages for that session+4. After restoration, you can see complete conversation history in the chat page+5. Continue entering new content, AI will respond based on historical context++**Use Cases:**++| Scenario | Description |+|----------|-------------|+| **Interruption Recovery** | Previous work was interrupted, need to continue |+| **Task Continuation** | Complex task completed in multiple sessions, continue from last progress |+| **Content Supplement** | Not satisfied with previous results, need to add requirements or adjust |++**Notes:**++- After restoring a session, new messages will be appended to the original history+- If the session contains incomplete tasks, the system will attempt to restore task state+- Long inactive sessions may have been compressed and need decompression when restored++### Delete Historical Session++If a session is no longer needed, you can delete it directly in session management to free storage and keep the list tidy.++++**Steps:**++1. In JiuwenSwarm Web interface, click "Sessions" in the left navigation+2. Select the session to delete in the session management page+3. Click the delete icon in the right-side session detail area+4. In the popup confirmation dialog, click "Confirm"+5. After successful deletion, the session will be removed from the list++> **Tip**: Please make sure the selected session is no longer needed. Deleted sessions may not be recoverable.++---++## FAQ++### Q1: What's the difference between session and memory?++**Session** is temporary conversation history, storing all messages during the current conversation, disappears when cleared or closed. **Memory** is persistently stored important information like user preferences, key knowledge points, retained across sessions.++### Q2: How much storage space do sessions use?++Session data is usually small, each message is about a few KB. But if containing many file uploads or long conversations, a single session can reach several MB. It's recommended to periodically clean up unneeded historical sessions.++### Q3: Will previous task state be preserved after restoring a session?++Yes, when restoring a session, the system will attempt to restore previous task state including task list, execution progress, etc. However, some tasks that were being executed may need to be re-triggered.++### Q4: Where is session data stored?++Session data is stored in the `.jiuwenswarm/agent/sessions/` directory of the local workspace. Each session is an independent directory containing `metadata.json` and `history.json` files.++### Q5: How to backup important sessions?++You can:+1. Directly copy session JSON files to another location+2. Export session content as Markdown or text format+3. Write important information to memory for cross-session retention++---++## Related Links++- [Quick Start](Quickstart.md) - Learn JiuwenSwarm basics+- [Memory System](Memory.md) - Learn about persistent memory mechanism+- [Task Planning](TaskPlanning.md) - Learn about task management mechanism+- [Page Overview](Page-Overview.md) - Learn about interface layout+- [Agent Tutorial](Agent.md) - Learn about conversation features++---++*Document Version: v1.0*+*Target Audience: JiuwenSwarm Users*+*Last Updated: 2026-05-05*\ No newline at end of filediff --git a/docs/en/SwarmSkills.md b/docs/en/SwarmSkills.mdnew file mode 100644index 0000000000..2d4c4b2e5e--- /dev/null+++ b/docs/en/SwarmSkills.md@@ -0,0 +1,895 @@+# Team Skills++JiuwenClaw's **Team Skills** is a standardized capability package designed for multi-Agent collaboration. It is not a capability patch for a single Agent — rather, it captures a proven team collaboration workflow as a reusable, replicable, and evolvable team collaboration SOP, so that complex tasks no longer need to be improvised from scratch every time.++---++## 1. Concept Overview++### 1.1 What Are Team Skills?++Team Skills occupy the **multi-Agent collaboration layer** in JiuwenClaw's skill system. If an Agent Skill answers "how a single Agent does things," then a Team Skill answers "how a team of Agents works together."++In traditional AI Agent usage, when facing complex tasks, users often need to manually orchestrate how multiple Agents collaborate — who does what, who goes first, what happens when something goes wrong. This approach requires starting from scratch every time, produces inconsistent collaboration quality, and makes workflows hard to reuse. Team Skills exist precisely to solve this pain point:++- **Capture once, reuse repeatedly**: Encapsulate proven team collaboration workflows as standardized capability packages. When encountering similar tasks next time, simply invoke the skill — no need to re-orchestrate.+- **Evolvable workflows**: Collaboration workflows are not static. They can be continuously optimized and iterated based on real-world usage feedback.+- **Predictable quality**: Pre-defined role assignments, collaboration sequences, and exception handling strategies make output quality more consistent across runs.++### 1.2 Team Skills vs. Agent Skills++| Dimension | Agent Skill | Team Skill |+|-----------|-------------|------------|+| **Positioning** | Capability extension for a single Agent | Collaboration pattern encapsulation for a multi-Agent team |+| **Focus** | How a single Agent does things | How a team of Agents works together |+| **Structure** | Single `SKILL.md` file | Directory structure (SKILL.md + roles + workflow + bind + dependencies) |+| **Use cases** | Single tasks that one Agent can complete | Complex tasks requiring multi-role collaboration and workflow reuse |+| **Collaboration** | No collaboration — Agent executes independently | Pre-defined role assignments, collaboration workflow, and exception handling |+| **Reusability** | Capability is reusable | Collaboration workflow is reusable |++Simple analogy: An Agent Skill is like giving one person a professional skill (e.g., "can do data analysis"), while a Team Skill is like establishing a collaboration SOP for a team (e.g., "how a research team goes from investigation to writing to review to produce a report").++### 1.3 Cross-Framework Portability++Team Skills are not limited to the JiuwenClaw platform. Their core design philosophy — role assignments, collaboration workflows, boundary constraints — represents a universal way to encapsulate team collaboration capabilities, adaptable to other AI Agent frameworks that support similar collaboration standards. This means:++- A Team Skill created in JiuwenClaw can, in principle, be migrated to other platforms supporting similar collaboration standards.+- The standardized 5-file structure provides a foundation for cross-framework interoperability.+- Community-contributed Team Skills can be shared across different platforms, building a shared team skill ecosystem together.++---++## 2. Structure++A Team Skill is fundamentally a **structured directory**, not a single documentation file. This design allows each element of team collaboration — roles, workflows, boundaries, dependencies — to be clearly organized and maintained.++### 2.1 Directory Structure Overview++```+team-skill-name/+├── SKILL.md # Team skill entry file+├── roles/ # Role definitions directory+│ ├── coordinator.md # Coordinator role+│ ├── researcher.md # Researcher role+│ └── writer.md # Writer role+├── workflow.md # Collaboration workflow definition+├── bind.md # Boundary and exception handling rules+├── dependencies.yaml # External dependency declarations+├── examples/ # Optional: examples and templates+│ └── sample-case.md+├── templates/ # Optional: output templates+│ └── report-template.md+└── assets/ # Optional: resource files+ └── diagrams/+```++### 2.2 Key Files++| File | Purpose | Required |+|------|---------|----------|+| `SKILL.md` | Team skill entry file; defines metadata such as skill name, description, applicable scenarios, role list, and file index | Yes |+| `roles/*.md` | Role definition files; each file describes one Agent role's responsibilities, capabilities, and behavioral norms | Yes |+| `workflow.md` | Collaboration workflow definition; describes interaction sequences, task flows, and decision nodes between roles (includes mermaid flowchart) | Yes |+| `bind.md` | Boundary and exception handling rules; defines resource constraints, behavioral constraints, and failure handling strategies | Yes |+| `dependencies.yaml` | External dependency declarations; lists tools, other skills, etc. required for the skill to run | Yes |++### 2.3 Core File Details++#### SKILL.md — Team Entry Point++`SKILL.md` is the Team Skill's entry file, using YAML frontmatter to declare metadata:++```markdown+---+name: medical-consultation-team+version: 1.0.0+author: jiuwenclaw-team+description: |+ Multi-disciplinary medical expert consultation team skill, organizing specialists for parallel evaluation and opinion integration via a coordinator.+ Use when multiple specialist experts need to jointly evaluate a complex case and output structured treatment recommendations.+ Do NOT use for simple cases that a single specialty can independently judge.+kind: team-skill+roles:+ - id: coordinator+ purpose: Organize experts, consolidate opinions, output treatment recommendations+ skills: []+ tools: []+ - id: internist+ purpose: Evaluate cases from an internal medicine perspective+ skills: []+ tools: []+ - id: surgeon+ purpose: Evaluate cases from a surgical perspective+ skills: []+ tools: []+ - id: radiologist+ purpose: Analyze cases from a radiology perspective+ skills: []+ tools: []+---++# Medical Consultation Team Skill++This team skill uses a specialization pipeline pattern (Pattern C) to organize multi-disciplinary medical experts for case consultation, solving the convergence bias problem that arises when a single Agent role-plays multiple perspectives.++## Workflow++0. **Pre-flight: check dependencies** — read [dependencies.yaml](dependencies.yaml) and verify. Report missing items: `required: true` = likely fails without it; `required: false` = degraded but functional. **User decides** whether to proceed.+1. **coordinator receives case** — Analyze the case, determine expert needs, create consultation task.+2. **Experts evaluate in parallel** — internist / surgeon / radiologist independently evaluate and submit specialist opinions.+3. **coordinator integrates opinions** — Collect all expert opinions, identify disagreements, organize discussion if disagreements exist.+4. **Output treatment recommendation report** — coordinator integrates final opinions, outputs structured report.++## Roles++| id | Purpose | When dispatched | Input | Key dependencies | Role file |+|---|---------|----------------|-------|-----------------|-----------|+| coordinator | Organize experts, consolidate opinions | Every run | User-submitted case | — | [roles/coordinator.md](roles/coordinator.md) |+| internist | Evaluate from internal medicine perspective | Every run (parallel) | Distributed case materials | — | [roles/internist.md](roles/internist.md) |+| surgeon | Evaluate from surgical perspective | Every run (parallel) | Distributed case materials | — | [roles/surgeon.md](roles/surgeon.md) |+| radiologist | Analyze from radiology perspective | Every run (parallel) | Distributed case materials | — | [roles/radiologist.md](roles/radiologist.md) |++> Before dispatching each teammate, read the corresponding role file and extract the `## Inline Persona for Teammate` section — paste it directly into the dispatch prompt.++## Files++| File | What it contains | When to read |+|------|------------------|-------------|+| [workflow.md](workflow.md) | Mermaid flowchart, step-by-step protocol, integration rules, Final Report format | Before first dispatch — the complete playbook |+| [bind.md](bind.md) | Resource limits, behavioral constraints, failure handling and degraded modes | When hitting limits, handling failures, or needing degraded-mode rules |+| [roles/*.md](roles/) | Per-role identity, success criteria, output schema, Inline Persona for Teammate | Before dispatching each teammate — extract Inline Persona |+| [dependencies.yaml](dependencies.yaml) | External skills and tools required to run | **Startup** — verify deps, report missing items, user decides go/no-go |+```++**Key field descriptions**:++- **`name`**: Unique skill identifier; must match the directory name (kebab-case, conventionally ending with `-team`).+- **`kind`**: Must be `team-skill` (note: not `type`), distinguishing Team Skills from regular Agent Skills.+- **`roles`**: Role list; **at least 2 roles required**, each role must include `id` (role identifier), `purpose` (one-line responsibility description, ≤150 characters), `skills` (dependent skill list), and `tools` (dependent tool list).+- **`description`**: Skill description following conciseness principles (≤4 lines, ≤500 characters), using WHAT / WHEN / NOT three-line structure.++#### roles/*.md — Role Definitions++Each role file defines one Agent's responsibilities and behavior, containing 5 mandatory sections:++1. **`## Identity`**: Role identity definition. The first line must be a 1-line motto, e.g., `> *"I am trying to break this code in production."*` — this is the most important anti-convergence mechanism.+2. **`## Success Criteria`**: Success criteria; lists the goals the role needs to achieve.+3. **`## Boundary`**: Boundary definition; must include `**Forbidden**` (things the role must not do, preventing role overlap) and `**Mandatory**` (things the role must do, preventing laziness).+4. **`## Output Schema`**: Output format; defines the structure of the role's deliverables.+5. **`## Inline Persona for Teammate`**: Inline persona prompt; a complete pasteable prompt for the Leader to inject when dispatching tasks.++Example:++```markdown+---+role_name: coordinator+description: Consultation coordinator, responsible for organizing experts and consolidating opinions+---++# Coordinator Role++## Identity++> *"I ensure every expert's voice is heard, and the final recommendation is consensus, not compromise."*++The coordinator drives the consultation process. They do not provide medical opinions directly but ensure all expert opinions are fully expressed and integrated.++## Success Criteria++- All invited experts have submitted their specialist opinions+- Areas of disagreement have been identified and discussed+- The final treatment recommendation is structured and actionable++**Focus areas**: Opinion integration quality, process completeness++## Boundary++**Forbidden**:+- Providing direct medical diagnostic opinions+- Making professional judgments on behalf of experts+- Concealing disagreements between experts++**Mandatory**:+- Ensuring every expert receives complete case materials+- Noting areas of disagreement and how they were handled in the report+- Outputting structured treatment recommendations++## Output Schema++```markdown+# Consultation Report+## Patient Information+## Expert Opinion Summary+### [Expert 1] Opinion+### [Expert 2] Opinion+## Comprehensive Treatment Recommendations+## Urgency Level+```++## Inline Persona for Teammate++You are a consultation coordinator. Your responsibilities are:+1. Receive and analyze case information+2. Determine which types of experts are needed+3. Distribute case materials to each expert+4. Collect and consolidate expert opinions+5. Identify areas of disagreement and organize discussion+6. Output a structured treatment recommendation report++You do not provide direct medical diagnostic opinions; you ensure all expert opinions are fully expressed and integrated.+```++#### workflow.md — Collaboration Workflow++Defines interaction sequences and task flows between roles, containing 3 mandatory sections:++1. **`## Overview`**: Workflow overview; must include a mermaid flowchart — this is the core expressive difference between Team Skills and single-Agent Skills.+2. **`## Detailed Steps`**: Detailed steps; each step includes executor, input, output, serial/parallel designation, and quality gate.+3. **`## Acceptance Criteria`**: Acceptance criteria; standards for judging whether a collaboration run was successful.++Example:++```markdown+# Consultation Collaboration Workflow++## Overview++```mermaid+graph TD+ L[Leader receives user request] --> C[coordinator analyzes case]+ C --> C1[coordinator determines expert needs]+ C1 --> P1[internist evaluates]+ C1 --> P2[surgeon evaluates]+ C1 --> P3[radiologist evaluates]+ P1 --> I[coordinator collects opinions]+ P2 --> I+ P3 --> I+ I --> D{Any disagreements?}+ D -->|Yes| DISC[Organize expert discussion]+ D -->|No| R[Output treatment recommendations]+ DISC --> R+ R --> OUT[Leader returns results]+```++## Detailed Steps++### Step 1: Case Reception and Analysis+- **Executor**: coordinator+- **Input**: Case information submitted by user+- **Output**: Expert needs list + consultation task+- **Mode**: Serial+- **Quality gate**: If case information is insufficient, request supplementary information from user++### Step 2: Expert Evaluation+- **Executor**: internist / surgeon / radiologist (parallel)+- **Input**: Distributed case materials+- **Output**: Specialist opinions from each expert+- **Mode**: Parallel+- **Quality gate**: If an expert times out without responding, skip and note missing opinion in report++### Step 3: Opinion Integration+- **Executor**: coordinator+- **Input**: Expert opinions+- **Output**: Integrated opinions + disagreement identification+- **Mode**: Serial+- **Quality gate**: If serious disagreements exist, organize expert discussion++### Step 4: Output Results+- **Executor**: coordinator → Leader+- **Input**: Integrated opinions+- **Output**: Structured treatment recommendation report+- **Mode**: Serial+- **Quality gate**: Report must include all expert opinions and disagreement handling notes++## Acceptance Criteria++- All invited experts have submitted opinions (or missing opinions are noted)+- Areas of disagreement have been identified and handled+- The final report is structured and includes comprehensive treatment recommendations+```++#### bind.md — Boundary and Exception Handling++Defines collaboration constraints and exception handling strategies, containing 3 mandatory sections:++1. **`## Resource Constraints`**: Resource constraints; must include at least `max_parallel_teammates`, `total_wall_clock_budget`, `total_token_budget`.+2. **`## Behavioral Constraints`**: Behavioral constraints; team-level rules (e.g., Leader does not write content, teammates cannot see each other's output, etc.).+3. **`## Failure Handling`**: Failure handling; covers teammate failure (timeout, malformed output) and input-overscale degradation strategies.++Example:++```markdown+# Boundary and Exception Handling++## Resource Constraints++| Constraint | Value |+|------------|-------|+| max_parallel_teammates | 5 |+| total_wall_clock_budget | 30 minutes |+| total_token_budget | 50000 |++## Behavioral Constraints++- Leader does not write medical content directly; only responsible for scheduling and integration+- Experts cannot see each other's raw opinions (isolated evaluation)+- coordinator must note all areas of disagreement in the report+- Maximum 5 experts per consultation session++## Failure Handling++### Expert Unavailable+- **Strategy**: Skip the expert and note missing opinion in the report+- **Degradation**: If a critical expert is unavailable, prompt user to reschedule++### Serious Opinion Disagreement+- **Strategy**: Organize expert discussion and record each party's reasoning+- **Output**: Present different approaches and their supporting evidence in the report++### Insufficient Information+- **Strategy**: Request supplementary information from the user+- **Timeout**: If user does not respond, provide conservative recommendations based on available information++### Input Overscale+- **Strategy**: When case materials exceed 2000 characters, coordinator first summarizes before distributing to experts+```++#### dependencies.yaml — External Dependencies++Declares external resources required for the skill to run. Must include both `skills` and `tools` segments (even if empty, explicitly write `[]`):++```yaml+skills:+ - name: web-research+ source: local+ required: false+ purpose: Assist experts in searching latest medical literature+ - name: report-generator+ source: local+ required: true+ purpose: Generate structured treatment recommendation reports++tools:+ - name: readFile+ required: true+ purpose: Read case material files+ - name: writeFile+ required: true+ purpose: Output treatment recommendation reports+```++**Field Descriptions**:++| Field | Segment | Required | Description | Example Values |+|-------|---------|----------|-------------|----------------|+| `name` | skills, tools | Yes | Skill/tool name | `web-research`, `readFile` |+| `source` | skills | Yes | Skill source | `local` (local), `hub` (skill center) |+| `required` | skills, tools | Yes | Whether required | `true` (required), `false` (optional) |+| `purpose` | skills, tools | Yes | Purpose description (≤150 chars) | `Assist experts in searching latest medical literature` |++> **Note**: Even when there are no dependencies, you must explicitly write `skills: []` and `tools: []` (an empty list signals "checked, confirmed no dependency of this type" — different from omitting the segment, which is a spec violation).++---++## 3. Usage Guide++### 3.1 Getting Started with Team Skills++Users typically begin using Team Skills through the following steps:++**Step 1: Acquire a Team Skill from Team Skills Hub**++1. Open JiuwenClaw's "Skills" panel+2. Click "Team Skills Hub Online Search"+3. Enter keywords to search for the team skill you need (e.g., "medical consultation", "research report")+4. Click "Install" to add the skill to your workspace++You can also search and install via command line:++```+# Search Team Skills+/teamskills search "medical consultation"++# View Team Skill details+/teamskills info <asset_id> --version 1.0.0++# Install a Team Skill+/teamskills install <asset_id> --version 1.0.0+```++> **Tip**: `<asset_id>` is the unique skill identifier on Team Skills Hub (e.g., `sk-123`), shown in search results.++**Step 2: Use in JiuwenClaw**++After installation, the Team Skill automatically appears in the available skills list:++1. Describe your task objective in the conversation+2. The system recognizes and invokes the appropriate Team Skill+3. The team collaboration workflow runs automatically according to the predefined process+4. Receive structured output results++### 3.2 When to Use Team Skills++Team Skills are particularly suited for the following scenarios:++| Scenario Characteristic | Description | Example |+|-------------------------|-------------|---------|+| Long task chains | Complex tasks requiring multiple steps and stages | From research to writing to review to produce a research report |+| Clear role division | Tasks decomposable into sub-tasks across different professional domains | Multi-disciplinary medical consultation requiring internal medicine, surgery, and radiology experts |+| Desire to reuse proven workflows | Don't want to redesign collaboration every time | Regularly executed code reviews, security audits |+| Structured output needed | Need standardized reports, proposals, or recommendations | Treatment recommendation reports, research reports, audit reports |++**Comparison: When to use Agent Skill vs. Team Skill**++| Situation | Recommended Choice | Reason |+|-----------|-------------------|--------|+| Single task, one Agent can complete | Agent Skill | No multi-role collaboration needed; Team Skill adds unnecessary overhead |+| Multi-step reasoning needed, but no role division | Agent Skill + workflow | The process can be executed step-by-step by a single Agent |+| Multiple professional roles need to collaborate | **Team Skill** | Different roles' professional perspectives are irreplaceable |+| Fixed task workflow, needs reuse | **Team Skill** | Predefined workflows can be reused; quality is more stable |+| Adversarial checking needed (e.g., code review) | **Team Skill** | Single Agent role-playing multiple perspectives tends to produce convergence bias |++### 3.3 Key Usage Principles++The core value of Team Skills lies in: **choosing the right Team Skill and letting the team collaboration workflow run automatically**, rather than manually orchestrating each Agent.++Three key principles when using Team Skills:++1. **Choose the right Team Skill**: Select a team skill that matches your task characteristics. If existing skills don't perfectly match, you can modify an existing skill or create a new one using `teamskill-creator`.+2. **Provide clear input**: Provide complete task information as required by the skill. Clearer input leads to higher collaboration output quality.+3. **Understand the output structure**: Know the skill's output format for easier downstream processing and usage.++Three advantages of Team Skills over ad-hoc team assembly:++| Advantage | Ad-hoc Assembly | Team Skill |+|-----------|----------------|------------|+| Role assignment rules | Need to reassign every time; may miss or confuse | Pre-defined, stable and reliable |+| Collaboration sequence | May miss critical steps | workflow.md explicitly defines the sequence |+| Exception handling | Ad-hoc decisions, inconsistent | bind.md provides unified strategies |++### 3.4 Cross-Framework Reuse Potential++Team Skills use a standardized structure definition (5-file specification) with cross-framework reuse potential:++- Collaboration standards are based on a universal role-workflow-boundary model, not dependent on specific framework implementation details+- Adaptable to other AI Agent platforms supporting similar collaboration standards+- Facilitates migration and sharing of team collaboration experience across different frameworks+- Team Skills Hub serves as a community sharing platform, promoting cross-framework skill ecosystem development++---++## 4. Case Study++### 4.1 Case: Multi-Disciplinary Medical Expert Consultation++This case demonstrates the practical value of Team Skills in a medical consultation scenario.++#### Applicable Scenario++- Patient condition is complex, involving multiple systems+- Different specialist experts need to jointly evaluate+- Desire for comprehensive, structured treatment recommendations++#### User Input++```+Patient information:+- Male, 65 years old+- Chief complaint: Chest pain with difficulty breathing for 2 days+- Past medical history: Hypertension, diabetes+- Test results: ECG ST-segment elevation, elevated D-dimer++Please organize an expert consultation and provide treatment recommendations.+```++#### Team Collaboration Process++**Phase 1: Case Reception and Analysis**++```+[coordinator] Receives case information+[coordinator] Analysis: Chest pain + ECG abnormality + elevated D-dimer → involves cardiovascular and respiratory systems+[coordinator] Determines needed experts: Cardiology, Respiratory, Radiology+[coordinator] Creates consultation task #2024-001+```++**Phase 2: Expert Evaluation (Parallel)**++```+[cardiologist] Cardiovascular evaluation:+- ST-segment elevation suggests possible myocardial injury+- Recommendation: Complete cardiac enzyme panel, cardiac ultrasound+- Preliminary opinion: Rule out acute coronary syndrome++[respiratory] Respiratory system evaluation:+- Elevated D-dimer + difficulty breathing+- Recommendation: Complete pulmonary artery CTA+- Preliminary opinion: Rule out pulmonary embolism++[radiologist] Imaging analysis:+- Recommendation: Chest CT plain + enhanced scan+- Focus on pulmonary artery, coronary artery conditions+```++**Phase 3: Opinion Integration**++```+[coordinator] Collects expert opinions+[coordinator] Identifies key disagreement: Cardiogenic vs. Pulmonary origin+[coordinator] Organizes expert discussion+[Expert consensus]: Prioritize ruling out life-threatening conditions+ Recommend simultaneous cardiac and pulmonary vascular assessment+```++**Phase 4: Output Results**++```markdown+# Consultation Report #2024-001++## Patient Information+- Male, 65 years old, chest pain with difficulty breathing for 2 days++## Expert Opinion Summary++### Cardiology Opinion+- ST-segment elevation suggests myocardial injury; need to rule out acute coronary syndrome+- Recommended tests: Cardiac enzyme panel, cardiac ultrasound, coronary CTA++### Respiratory Opinion+- Elevated D-dimer requires vigilance for pulmonary embolism+- Recommended tests: Pulmonary artery CTA, blood gas analysis++### Radiology Opinion+- Recommend chest CT enhanced scan for one-stop assessment++## Comprehensive Treatment Recommendations+1. Immediately complete cardiac enzyme panel and blood gas analysis (emergency completion)+2. Perform chest CT enhanced scan, simultaneously assessing coronary and pulmonary arteries+3. ECG monitoring, monitor vital signs+4. Determine next-step treatment plan based on test results++## Urgency Level+⚠️ High risk - Requires immediate attention++---+Consultation time: 2024-01-15 14:30+Participating experts: Cardiology Dr. Zhang, Respiratory Dr. Li, Radiology Dr. Wang+```++#### Team Skills Advantage Demonstration++| Advantage | Ad-hoc Assembly | Team Skill |+|-----------|----------------|------------|+| Role assignment | Need to reassign who evaluates what every time | Pre-defined roles (cardiology/respiratory/radiology), stable and reliable |+| Collaboration sequence | May miss steps (e.g., forgetting to integrate disagreements) | workflow.md explicitly defines: analyze → evaluate → integrate → output |+| Exception handling | What if an expert times out? Ad-hoc decision | bind.md unified strategy: skip and note missing opinion |+| Output format | Different format every time | Structured, standardized report |+| Reusability | Next consultation starts from scratch again | Same Team Skill can be reused |++### 4.2 Case: Research and PPT Writing Team++This case demonstrates Team Skills in a content production scenario.++#### Applicable Scenario++- Complete pipeline from research investigation to PPT writing+- Research and writing require different professional capabilities+- Desire for structured presentation output++#### User Input++```+Please help me complete a research report PPT on "2024 AI Industry Trends",+including market data, technology trends, and future outlook.+```++#### Team Collaboration Process++**Phase 1: Task Decomposition**++```+[coordinator] Receives research topic: "2024 AI Industry Trends"+[coordinator] Decomposes research questions: market data, technology trends, future outlook+[coordinator] Assigns research tasks to researchers+```++**Phase 2: Parallel Research**++```+[researcher-1] Researches market data: market size, growth rate, major players+[researcher-2] Researches technology trends: large models, multimodal, Agent-based+[researcher-3] Researches future outlook: regulatory trends, application prospects, challenges+```++**Phase 3: Report Writing**++```+[writer] Integrates all research findings+[writer] Writes PPT content: slide titles, key points, data chart suggestions+```++**Phase 4: Review and Revision**++```+[reviewer] Reviews report: logical coherence, data accuracy, expression clarity+[writer] Revises based on review feedback+[coordinator] Outputs final PPT content+```++---++## 5. Creation Guide++### 5.1 Creating New Team Skills with teamskill-creator++JiuwenClaw provides the `teamskill-creator` skill to help users create, convert, or modify Team Skills. It includes standardized templates, decision trees, and an automated validator to ensure created Team Skills comply with the specification.++**Getting and Installing**:++`teamskill-creator` is a built-in skill in JiuwenClaw and requires no additional installation. If the skill is not available in your environment, you can obtain it through:++```bash+# Search and install from skill center+/skills search teamskill-creator+/skills install teamskill-creator+```++**Three modes**:++| Mode | Use Case | Output |+|------|----------|--------|+| **CREATE** | Create a new team skill from scratch | New `<teamskill-name>/` directory with the complete 5-file set |+| **CONVERT** | Convert an existing single-Agent Skill to a Team Skill | Transformed `<teamskill-name>/` directory + delta report |+| **MODIFY** | Modify an existing Team Skill (add/remove roles, adjust workflow, etc.) | Updated files |++#### Creation Workflow Example++The following demonstrates creating a "Research and Report Writing Team" as a complete creation process:++**Step 1: Determine if a Team Skill is needed**++First confirm: does this task truly require multi-role collaboration? A Team Skill is only worth creating when at least one of these applies:++1. **Adversarial blind spot**: A single Agent role-playing multiple perspectives produces converging outputs (e.g., code review, security audit)+2. **Parallel decomposition gain**: Multiple independent sub-tasks can run concurrently, and integration is non-trivial (e.g., multi-angle research)+3. **Specialization pipeline with hard handoffs**: Sequential stages with quality gates where blurring boundaries causes regressions (e.g., marketing copy: brief → draft → edit → audit)++If none apply → recommend using a single-Agent Skill instead.++**Step 2: Select collaboration pattern**++Choose a collaboration pattern based on task characteristics:++| Pattern | Use Case | Role Count | Inter-role Visibility |+|---------|----------|------------|----------------------|+| A. Adversarial / Cross-check | Blind spot problems | 2-4 | Not visible (isolation is the value) |+| B. Parallel decomposition | Independent sub-tasks | 2-N | Not visible until integration |+| C. Specialization pipeline | Sequential expert stages | 3-5 | Each stage sees prior stage output |+| Mixed | Multiple justifications stack | 4-6 | Pattern-by-stage |++The Research and Report Writing Team fits **C. Specialization pipeline** pattern (research → writing → review, sequential stages with quality gates).++**Step 3: Design roles**++Write `roles/<id>.md` files for each role, containing 5 mandatory sections:++```+research-report-team/+├── roles/+│ ├── coordinator.md # Coordinator: decompose tasks, integrate results+│ ├── researcher.md # Researcher: independent research, submit findings+│ ├── writer.md # Writer: integrate research, write report+│ └── reviewer.md # Reviewer: review report, suggest modifications+```++**Anti-overlap test**: Write each role's 1-line motto, then ask "could one role's deliverable substitute for another's?" If yes, boundaries are blurred — redesign before proceeding.++**Step 4: Write collaboration workflow**++Write `workflow.md` with mermaid flowchart, detailed steps, and acceptance criteria:++```markdown+## Overview++```mermaid+graph TD+ L[Leader] --> C[coordinator decomposes task]+ C --> R1[researcher-1 researches]+ C --> R2[researcher-2 researches]+ R1 --> W[writer writes report]+ R2 --> W+ W --> RV[reviewer reviews]+ RV -->|Pass| OUT[Output final report]+ RV -->|Needs revision| W+```+```++**Step 5: Write boundary and exception handling**++Write `bind.md` defining resource constraints, behavioral constraints, and failure handling:++```markdown+## Resource Constraints++| Constraint | Value |+|------------|-------|+| max_parallel_teammates | 3 |+| total_wall_clock_budget | 45 minutes |+| total_token_budget | 80000 |++## Behavioral Constraints++- Leader does not write content directly; only responsible for scheduling+- Researchers cannot see each other's research process (ensures independence)+- Writer must integrate all research findings without omission+- Maximum 2 review rounds++## Failure Handling++### Insufficient Research Information+- Strategy: Request additional research directions from user+- Timeout: Provide conservative conclusions based on available research++### Review Opinion Disagreement+- Strategy: Coordinator arbitrates, choosing the more reasonable revision direction+```++**Step 6: Write dependency declarations and entry file**++Write `dependencies.yaml` and `SKILL.md`, referencing content produced in previous steps.++**Step 7: Validate**++Run the automated validator to ensure the Team Skill complies with the specification:++```bash+# Method 1: Use TUI built-in command (recommended)+/teamskills validate path/to/research-report-team/ --type teamskills++# Method 2: Use standalone validation script+python scripts/validate_teamskill.py path/to/research-report-team/+```++The validator checks:+- All 5 files are present+- Frontmatter required fields are complete (`name`, `kind`, `roles`)+- `roles` has at least 2 entries, each with `id` and `purpose`, `id` must not repeat+- Role file names match `roles[].id`+- Each role file contains 5 mandatory sections+- workflow.md contains a mermaid diagram+- bind.md contains 3 mandatory sections+- dependencies.yaml contains `skills` and `tools` segments+- Skills/tools declared in SKILL.md appear in dependencies.yaml++**Exit code 0 = compliant**. Non-zero exit codes print specific failing checks.++### 5.2 Modifying an Existing Team Skill++Use `teamskill-creator`'s MODIFY mode to modify existing Team Skills:++| Change Type | Stages to Re-run | Files to Update |+|-------------|-----------------|----------------|+| Edit role Identity / Boundary / Schema | Stage 2 (affected role only) | `roles/<id>.md` |+| Add or remove a role | Stage 1a + 2 + 3 + 4 + 5 | All 5 files |+| Change workflow steps / topology | Stage 3 | `workflow.md` + `bind.md` (if constraints change) |+| Change bind constraints | Stage 4 | `bind.md` |+| Change dependencies | Stage 2 (auto-match) + 5 | `dependencies.yaml` + `SKILL.md` frontmatter |++**Important**: Regardless of edit size, Stage 7 (validation) must always be executed.++### 5.3 Converting a Single-Agent Skill to a Team Skill++Use `teamskill-creator`'s CONVERT mode to transform an existing single-Agent Skill into a Team Skill:++1. **Read the source SKILL.md** and identify natural role boundaries:+ - Find embedded multi-persona setups (e.g., "act as Persona 1 / Persona 2 / Persona 3")+ - Find sequential stages with quality gates (e.g., "first do X, then validate Y, then produce Z")+ - Find checklists that branch by category (e.g., "[ ] security [ ] performance [ ] readability")+2. **Articulate the conversion value**: What is lost in single-Agent form? This becomes the Team Skill's "why"+3. **Continue from Step 2** following the CREATE workflow++### 5.4 Publishing to Team Skills Hub++After creation, you can share your Team Skill with the community to build the team skill ecosystem together:++**Step 1: Validate completeness**++```bash+# Method 1: Use TUI built-in command (recommended)+/teamskills validate path/to/<teamskill-name>/ --type teamskills++# Method 2: Use standalone validation script+python scripts/validate_teamskill.py path/to/<teamskill-name>/+```++Ensure exit code is 0 (compliant).++**Step 2: Upload and publish**++In JiuwenClaw's "Skills" panel:+1. Click "Team Skills Hub"+2. Select the Team Skill to publish+3. Click "Upload"+4. First-time use requires authentication (enter your Team Skills Hub Token)++You can also publish via command line:++```+# Publish to Team Skills Hub (requires authentication)+/teamskills publish path/to/<teamskill-name> --version 1.0.0 --token <TOKEN>++# To overwrite an existing version, add --force+/teamskills publish path/to/<teamskill-name> --version 1.0.1 --token <TOKEN> --force+```++> **Authentication note**: Publish and delete operations require `--token` (user Token) or `--system-token` (system Token), and you must choose exactly one. You can pre-configure your token via `/teamskills config --token <TOKEN>` to avoid entering it manually each time.++**Step 3: Maintain and update**++After publishing, you can continuously iterate:+- Re-validate after modifying roles, workflows, or constraints+- Re-publish after updating the version number+- Optimize collaboration workflows based on community feedback++### 5.5 Best Practices++| Practice | Description |+|----------|-------------|+| Appropriate role granularity | Roles should not be too fine (increases coordination cost) or too coarse (loses division advantage) |+| Clear and concise workflow | Avoid overly complex collaboration workflows; maintain understandability |+| Explicit boundary conditions | Cover common exception scenarios in bind.md |+| Provide examples | Include usage examples in examples/ to reduce learning cost |+| Adversarial mottos | Each role's motto should reflect a unique perspective, preventing role convergence |+| Validation is mandatory | Run the validator after every creation or modification |+| Description follows conciseness principles | SKILL.md description ≤4 lines, ≤500 characters, using WHAT / WHEN / NOT structure |++---++## Appendix++### Quick Reference++| Operation | Command/Method |+|-----------|---------------|+| Search Team Skills | `/teamskills search <keyword>` |+| View Team Skill details | `/teamskills info <asset_id> --version <x.y.z>` |+| Install a Team Skill | `/teamskills install <asset_id> --version <x.y.z>` |+| List installed skills | `/teamskills list` |+| Uninstall a Team Skill | `/teamskills uninstall <name>` |+| Create Team Skill scaffold | `/teamskills init <name> --type teamskills` |+| Validate Team Skill | `/teamskills validate <path> --type teamskills` |+| Pack Team Skill | `/teamskills pack <path> --output <dir>` |+| Configure Hub URL and Token | `/teamskills config --market-url <url> --token <TOKEN>` |+| Publish to Team Skills Hub | `/teamskills publish <path> --version <x.y.z> --token <TOKEN>` |+| Delete skill from Hub | `/teamskills delete <skill_id> --version <x.y.z> --token <TOKEN>` |+| Create with teamskill-creator | Use `teamskill-creator` skill's CREATE mode |+| Modify with teamskill-creator | Use `teamskill-creator` skill's MODIFY mode |+| Convert with teamskill-creator | Use `teamskill-creator` skill's CONVERT mode |++### Frequently Asked Questions++**Q: What's the difference between a Team Skill and a regular Skill?**++A: A regular Skill is a capability extension for a single Agent ("how one Agent does things"), while a Team Skill encapsulates a complete multi-Agent collaboration pattern ("how a team of Agents works together"), including role assignments, collaboration workflows, and exception handling strategies.++**Q: How do I determine whether I need a Team Skill?**++A: A Team Skill is appropriate when: (1) a single Agent role-playing multiple perspectives would produce convergence bias; (2) multiple independent sub-tasks can run in parallel; (3) sequential stages have quality gates requiring specialized handling. If none apply, a single-Agent Skill is recommended.++**Q: Can I modify an installed Team Skill?**++A: Yes. Use `teamskill-creator`'s MODIFY mode to edit the local copy. After modification, re-run the validator to confirm compliance.++**Q: Are all 5 files in the Team Skill structure mandatory?**++A: Yes. SKILL.md, roles/, workflow.md, bind.md, and dependencies.yaml are all required files. The validator checks that all 5 files are present. Extension directories like `examples/`, `templates/`, and `assets/` are optional.++**Q: What is the default Team Skills Hub URL?**++A: The default URL is `https://teamskills.openjiuwen.com`, which can be overridden via the `TEAM_SKILLS_HUB_BASE_URL` environment variable.++---++*Document version: v2.0*+*Target audience: JiuwenClaw users, skill developers*+*Last updated: 2026-05-08*\ No newline at end of filediff --git a/docs/en/TeamSkills.md b/docs/en/TeamSkills.mdnew file mode 100644index 0000000000..2d4c4b2e5e--- /dev/null+++ b/docs/en/TeamSkills.md@@ -0,0 +1,895 @@+# Team Skills++JiuwenClaw's **Team Skills** is a standardized capability package designed for multi-Agent collaboration. It is not a capability patch for a single Agent — rather, it captures a proven team collaboration workflow as a reusable, replicable, and evolvable team collaboration SOP, so that complex tasks no longer need to be improvised from scratch every time.++---++## 1. Concept Overview++### 1.1 What Are Team Skills?++Team Skills occupy the **multi-Agent collaboration layer** in JiuwenClaw's skill system. If an Agent Skill answers "how a single Agent does things," then a Team Skill answers "how a team of Agents works together."++In traditional AI Agent usage, when facing complex tasks, users often need to manually orchestrate how multiple Agents collaborate — who does what, who goes first, what happens when something goes wrong. This approach requires starting from scratch every time, produces inconsistent collaboration quality, and makes workflows hard to reuse. Team Skills exist precisely to solve this pain point:++- **Capture once, reuse repeatedly**: Encapsulate proven team collaboration workflows as standardized capability packages. When encountering similar tasks next time, simply invoke the skill — no need to re-orchestrate.+- **Evolvable workflows**: Collaboration workflows are not static. They can be continuously optimized and iterated based on real-world usage feedback.+- **Predictable quality**: Pre-defined role assignments, collaboration sequences, and exception handling strategies make output quality more consistent across runs.++### 1.2 Team Skills vs. Agent Skills++| Dimension | Agent Skill | Team Skill |+|-----------|-------------|------------|+| **Positioning** | Capability extension for a single Agent | Collaboration pattern encapsulation for a multi-Agent team |+| **Focus** | How a single Agent does things | How a team of Agents works together |+| **Structure** | Single `SKILL.md` file | Directory structure (SKILL.md + roles + workflow + bind + dependencies) |+| **Use cases** | Single tasks that one Agent can complete | Complex tasks requiring multi-role collaboration and workflow reuse |+| **Collaboration** | No collaboration — Agent executes independently | Pre-defined role assignments, collaboration workflow, and exception handling |+| **Reusability** | Capability is reusable | Collaboration workflow is reusable |++Simple analogy: An Agent Skill is like giving one person a professional skill (e.g., "can do data analysis"), while a Team Skill is like establishing a collaboration SOP for a team (e.g., "how a research team goes from investigation to writing to review to produce a report").++### 1.3 Cross-Framework Portability++Team Skills are not limited to the JiuwenClaw platform. Their core design philosophy — role assignments, collaboration workflows, boundary constraints — represents a universal way to encapsulate team collaboration capabilities, adaptable to other AI Agent frameworks that support similar collaboration standards. This means:++- A Team Skill created in JiuwenClaw can, in principle, be migrated to other platforms supporting similar collaboration standards.+- The standardized 5-file structure provides a foundation for cross-framework interoperability.+- Community-contributed Team Skills can be shared across different platforms, building a shared team skill ecosystem together.++---++## 2. Structure++A Team Skill is fundamentally a **structured directory**, not a single documentation file. This design allows each element of team collaboration — roles, workflows, boundaries, dependencies — to be clearly organized and maintained.++### 2.1 Directory Structure Overview++```+team-skill-name/+├── SKILL.md # Team skill entry file+├── roles/ # Role definitions directory+│ ├── coordinator.md # Coordinator role+│ ├── researcher.md # Researcher role+│ └── writer.md # Writer role+├── workflow.md # Collaboration workflow definition+├── bind.md # Boundary and exception handling rules+├── dependencies.yaml # External dependency declarations+├── examples/ # Optional: examples and templates+│ └── sample-case.md+├── templates/ # Optional: output templates+│ └── report-template.md+└── assets/ # Optional: resource files+ └── diagrams/+```++### 2.2 Key Files++| File | Purpose | Required |+|------|---------|----------|+| `SKILL.md` | Team skill entry file; defines metadata such as skill name, description, applicable scenarios, role list, and file index | Yes |+| `roles/*.md` | Role definition files; each file describes one Agent role's responsibilities, capabilities, and behavioral norms | Yes |+| `workflow.md` | Collaboration workflow definition; describes interaction sequences, task flows, and decision nodes between roles (includes mermaid flowchart) | Yes |+| `bind.md` | Boundary and exception handling rules; defines resource constraints, behavioral constraints, and failure handling strategies | Yes |+| `dependencies.yaml` | External dependency declarations; lists tools, other skills, etc. required for the skill to run | Yes |++### 2.3 Core File Details++#### SKILL.md — Team Entry Point++`SKILL.md` is the Team Skill's entry file, using YAML frontmatter to declare metadata:++```markdown+---+name: medical-consultation-team+version: 1.0.0+author: jiuwenclaw-team+description: |+ Multi-disciplinary medical expert consultation team skill, organizing specialists for parallel evaluation and opinion integration via a coordinator.+ Use when multiple specialist experts need to jointly evaluate a complex case and output structured treatment recommendations.+ Do NOT use for simple cases that a single specialty can independently judge.+kind: team-skill+roles:+ - id: coordinator+ purpose: Organize experts, consolidate opinions, output treatment recommendations+ skills: []+ tools: []+ - id: internist+ purpose: Evaluate cases from an internal medicine perspective+ skills: []+ tools: []+ - id: surgeon+ purpose: Evaluate cases from a surgical perspective+ skills: []+ tools: []+ - id: radiologist+ purpose: Analyze cases from a radiology perspective+ skills: []+ tools: []+---++# Medical Consultation Team Skill++This team skill uses a specialization pipeline pattern (Pattern C) to organize multi-disciplinary medical experts for case consultation, solving the convergence bias problem that arises when a single Agent role-plays multiple perspectives.++## Workflow++0. **Pre-flight: check dependencies** — read [dependencies.yaml](dependencies.yaml) and verify. Report missing items: `required: true` = likely fails without it; `required: false` = degraded but functional. **User decides** whether to proceed.+1. **coordinator receives case** — Analyze the case, determine expert needs, create consultation task.+2. **Experts evaluate in parallel** — internist / surgeon / radiologist independently evaluate and submit specialist opinions.+3. **coordinator integrates opinions** — Collect all expert opinions, identify disagreements, organize discussion if disagreements exist.+4. **Output treatment recommendation report** — coordinator integrates final opinions, outputs structured report.++## Roles++| id | Purpose | When dispatched | Input | Key dependencies | Role file |+|---|---------|----------------|-------|-----------------|-----------|+| coordinator | Organize experts, consolidate opinions | Every run | User-submitted case | — | [roles/coordinator.md](roles/coordinator.md) |+| internist | Evaluate from internal medicine perspective | Every run (parallel) | Distributed case materials | — | [roles/internist.md](roles/internist.md) |+| surgeon | Evaluate from surgical perspective | Every run (parallel) | Distributed case materials | — | [roles/surgeon.md](roles/surgeon.md) |+| radiologist | Analyze from radiology perspective | Every run (parallel) | Distributed case materials | — | [roles/radiologist.md](roles/radiologist.md) |++> Before dispatching each teammate, read the corresponding role file and extract the `## Inline Persona for Teammate` section — paste it directly into the dispatch prompt.++## Files++| File | What it contains | When to read |+|------|------------------|-------------|+| [workflow.md](workflow.md) | Mermaid flowchart, step-by-step protocol, integration rules, Final Report format | Before first dispatch — the complete playbook |+| [bind.md](bind.md) | Resource limits, behavioral constraints, failure handling and degraded modes | When hitting limits, handling failures, or needing degraded-mode rules |+| [roles/*.md](roles/) | Per-role identity, success criteria, output schema, Inline Persona for Teammate | Before dispatching each teammate — extract Inline Persona |+| [dependencies.yaml](dependencies.yaml) | External skills and tools required to run | **Startup** — verify deps, report missing items, user decides go/no-go |+```++**Key field descriptions**:++- **`name`**: Unique skill identifier; must match the directory name (kebab-case, conventionally ending with `-team`).+- **`kind`**: Must be `team-skill` (note: not `type`), distinguishing Team Skills from regular Agent Skills.+- **`roles`**: Role list; **at least 2 roles required**, each role must include `id` (role identifier), `purpose` (one-line responsibility description, ≤150 characters), `skills` (dependent skill list), and `tools` (dependent tool list).+- **`description`**: Skill description following conciseness principles (≤4 lines, ≤500 characters), using WHAT / WHEN / NOT three-line structure.++#### roles/*.md — Role Definitions++Each role file defines one Agent's responsibilities and behavior, containing 5 mandatory sections:++1. **`## Identity`**: Role identity definition. The first line must be a 1-line motto, e.g., `> *"I am trying to break this code in production."*` — this is the most important anti-convergence mechanism.+2. **`## Success Criteria`**: Success criteria; lists the goals the role needs to achieve.+3. **`## Boundary`**: Boundary definition; must include `**Forbidden**` (things the role must not do, preventing role overlap) and `**Mandatory**` (things the role must do, preventing laziness).+4. **`## Output Schema`**: Output format; defines the structure of the role's deliverables.+5. **`## Inline Persona for Teammate`**: Inline persona prompt; a complete pasteable prompt for the Leader to inject when dispatching tasks.++Example:++```markdown+---+role_name: coordinator+description: Consultation coordinator, responsible for organizing experts and consolidating opinions+---++# Coordinator Role++## Identity++> *"I ensure every expert's voice is heard, and the final recommendation is consensus, not compromise."*++The coordinator drives the consultation process. They do not provide medical opinions directly but ensure all expert opinions are fully expressed and integrated.++## Success Criteria++- All invited experts have submitted their specialist opinions+- Areas of disagreement have been identified and discussed+- The final treatment recommendation is structured and actionable++**Focus areas**: Opinion integration quality, process completeness++## Boundary++**Forbidden**:+- Providing direct medical diagnostic opinions+- Making professional judgments on behalf of experts+- Concealing disagreements between experts++**Mandatory**:+- Ensuring every expert receives complete case materials+- Noting areas of disagreement and how they were handled in the report+- Outputting structured treatment recommendations++## Output Schema++```markdown+# Consultation Report+## Patient Information+## Expert Opinion Summary+### [Expert 1] Opinion+### [Expert 2] Opinion+## Comprehensive Treatment Recommendations+## Urgency Level+```++## Inline Persona for Teammate++You are a consultation coordinator. Your responsibilities are:+1. Receive and analyze case information+2. Determine which types of experts are needed+3. Distribute case materials to each expert+4. Collect and consolidate expert opinions+5. Identify areas of disagreement and organize discussion+6. Output a structured treatment recommendation report++You do not provide direct medical diagnostic opinions; you ensure all expert opinions are fully expressed and integrated.+```++#### workflow.md — Collaboration Workflow++Defines interaction sequences and task flows between roles, containing 3 mandatory sections:++1. **`## Overview`**: Workflow overview; must include a mermaid flowchart — this is the core expressive difference between Team Skills and single-Agent Skills.+2. **`## Detailed Steps`**: Detailed steps; each step includes executor, input, output, serial/parallel designation, and quality gate.+3. **`## Acceptance Criteria`**: Acceptance criteria; standards for judging whether a collaboration run was successful.++Example:++```markdown+# Consultation Collaboration Workflow++## Overview++```mermaid+graph TD+ L[Leader receives user request] --> C[coordinator analyzes case]+ C --> C1[coordinator determines expert needs]+ C1 --> P1[internist evaluates]+ C1 --> P2[surgeon evaluates]+ C1 --> P3[radiologist evaluates]+ P1 --> I[coordinator collects opinions]+ P2 --> I+ P3 --> I+ I --> D{Any disagreements?}+ D -->|Yes| DISC[Organize expert discussion]+ D -->|No| R[Output treatment recommendations]+ DISC --> R+ R --> OUT[Leader returns results]+```++## Detailed Steps++### Step 1: Case Reception and Analysis+- **Executor**: coordinator+- **Input**: Case information submitted by user+- **Output**: Expert needs list + consultation task+- **Mode**: Serial+- **Quality gate**: If case information is insufficient, request supplementary information from user++### Step 2: Expert Evaluation+- **Executor**: internist / surgeon / radiologist (parallel)+- **Input**: Distributed case materials+- **Output**: Specialist opinions from each expert+- **Mode**: Parallel+- **Quality gate**: If an expert times out without responding, skip and note missing opinion in report++### Step 3: Opinion Integration+- **Executor**: coordinator+- **Input**: Expert opinions+- **Output**: Integrated opinions + disagreement identification+- **Mode**: Serial+- **Quality gate**: If serious disagreements exist, organize expert discussion++### Step 4: Output Results+- **Executor**: coordinator → Leader+- **Input**: Integrated opinions+- **Output**: Structured treatment recommendation report+- **Mode**: Serial+- **Quality gate**: Report must include all expert opinions and disagreement handling notes++## Acceptance Criteria++- All invited experts have submitted opinions (or missing opinions are noted)+- Areas of disagreement have been identified and handled+- The final report is structured and includes comprehensive treatment recommendations+```++#### bind.md — Boundary and Exception Handling++Defines collaboration constraints and exception handling strategies, containing 3 mandatory sections:++1. **`## Resource Constraints`**: Resource constraints; must include at least `max_parallel_teammates`, `total_wall_clock_budget`, `total_token_budget`.+2. **`## Behavioral Constraints`**: Behavioral constraints; team-level rules (e.g., Leader does not write content, teammates cannot see each other's output, etc.).+3. **`## Failure Handling`**: Failure handling; covers teammate failure (timeout, malformed output) and input-overscale degradation strategies.++Example:++```markdown+# Boundary and Exception Handling++## Resource Constraints++| Constraint | Value |+|------------|-------|+| max_parallel_teammates | 5 |+| total_wall_clock_budget | 30 minutes |+| total_token_budget | 50000 |++## Behavioral Constraints++- Leader does not write medical content directly; only responsible for scheduling and integration+- Experts cannot see each other's raw opinions (isolated evaluation)+- coordinator must note all areas of disagreement in the report+- Maximum 5 experts per consultation session++## Failure Handling++### Expert Unavailable+- **Strategy**: Skip the expert and note missing opinion in the report+- **Degradation**: If a critical expert is unavailable, prompt user to reschedule++### Serious Opinion Disagreement+- **Strategy**: Organize expert discussion and record each party's reasoning+- **Output**: Present different approaches and their supporting evidence in the report++### Insufficient Information+- **Strategy**: Request supplementary information from the user+- **Timeout**: If user does not respond, provide conservative recommendations based on available information++### Input Overscale+- **Strategy**: When case materials exceed 2000 characters, coordinator first summarizes before distributing to experts+```++#### dependencies.yaml — External Dependencies++Declares external resources required for the skill to run. Must include both `skills` and `tools` segments (even if empty, explicitly write `[]`):++```yaml+skills:+ - name: web-research+ source: local+ required: false+ purpose: Assist experts in searching latest medical literature+ - name: report-generator+ source: local+ required: true+ purpose: Generate structured treatment recommendation reports++tools:+ - name: readFile+ required: true+ purpose: Read case material files+ - name: writeFile+ required: true+ purpose: Output treatment recommendation reports+```++**Field Descriptions**:++| Field | Segment | Required | Description | Example Values |+|-------|---------|----------|-------------|----------------|+| `name` | skills, tools | Yes | Skill/tool name | `web-research`, `readFile` |+| `source` | skills | Yes | Skill source | `local` (local), `hub` (skill center) |+| `required` | skills, tools | Yes | Whether required | `true` (required), `false` (optional) |+| `purpose` | skills, tools | Yes | Purpose description (≤150 chars) | `Assist experts in searching latest medical literature` |++> **Note**: Even when there are no dependencies, you must explicitly write `skills: []` and `tools: []` (an empty list signals "checked, confirmed no dependency of this type" — different from omitting the segment, which is a spec violation).++---++## 3. Usage Guide++### 3.1 Getting Started with Team Skills++Users typically begin using Team Skills through the following steps:++**Step 1: Acquire a Team Skill from Team Skills Hub**++1. Open JiuwenClaw's "Skills" panel+2. Click "Team Skills Hub Online Search"+3. Enter keywords to search for the team skill you need (e.g., "medical consultation", "research report")+4. Click "Install" to add the skill to your workspace++You can also search and install via command line:++```+# Search Team Skills+/teamskills search "medical consultation"++# View Team Skill details+/teamskills info <asset_id> --version 1.0.0++# Install a Team Skill+/teamskills install <asset_id> --version 1.0.0+```++> **Tip**: `<asset_id>` is the unique skill identifier on Team Skills Hub (e.g., `sk-123`), shown in search results.++**Step 2: Use in JiuwenClaw**++After installation, the Team Skill automatically appears in the available skills list:++1. Describe your task objective in the conversation+2. The system recognizes and invokes the appropriate Team Skill+3. The team collaboration workflow runs automatically according to the predefined process+4. Receive structured output results++### 3.2 When to Use Team Skills++Team Skills are particularly suited for the following scenarios:++| Scenario Characteristic | Description | Example |+|-------------------------|-------------|---------|+| Long task chains | Complex tasks requiring multiple steps and stages | From research to writing to review to produce a research report |+| Clear role division | Tasks decomposable into sub-tasks across different professional domains | Multi-disciplinary medical consultation requiring internal medicine, surgery, and radiology experts |+| Desire to reuse proven workflows | Don't want to redesign collaboration every time | Regularly executed code reviews, security audits |+| Structured output needed | Need standardized reports, proposals, or recommendations | Treatment recommendation reports, research reports, audit reports |++**Comparison: When to use Agent Skill vs. Team Skill**++| Situation | Recommended Choice | Reason |+|-----------|-------------------|--------|+| Single task, one Agent can complete | Agent Skill | No multi-role collaboration needed; Team Skill adds unnecessary overhead |+| Multi-step reasoning needed, but no role division | Agent Skill + workflow | The process can be executed step-by-step by a single Agent |+| Multiple professional roles need to collaborate | **Team Skill** | Different roles' professional perspectives are irreplaceable |+| Fixed task workflow, needs reuse | **Team Skill** | Predefined workflows can be reused; quality is more stable |+| Adversarial checking needed (e.g., code review) | **Team Skill** | Single Agent role-playing multiple perspectives tends to produce convergence bias |++### 3.3 Key Usage Principles++The core value of Team Skills lies in: **choosing the right Team Skill and letting the team collaboration workflow run automatically**, rather than manually orchestrating each Agent.++Three key principles when using Team Skills:++1. **Choose the right Team Skill**: Select a team skill that matches your task characteristics. If existing skills don't perfectly match, you can modify an existing skill or create a new one using `teamskill-creator`.+2. **Provide clear input**: Provide complete task information as required by the skill. Clearer input leads to higher collaboration output quality.+3. **Understand the output structure**: Know the skill's output format for easier downstream processing and usage.++Three advantages of Team Skills over ad-hoc team assembly:++| Advantage | Ad-hoc Assembly | Team Skill |+|-----------|----------------|------------|+| Role assignment rules | Need to reassign every time; may miss or confuse | Pre-defined, stable and reliable |+| Collaboration sequence | May miss critical steps | workflow.md explicitly defines the sequence |+| Exception handling | Ad-hoc decisions, inconsistent | bind.md provides unified strategies |++### 3.4 Cross-Framework Reuse Potential++Team Skills use a standardized structure definition (5-file specification) with cross-framework reuse potential:++- Collaboration standards are based on a universal role-workflow-boundary model, not dependent on specific framework implementation details+- Adaptable to other AI Agent platforms supporting similar collaboration standards+- Facilitates migration and sharing of team collaboration experience across different frameworks+- Team Skills Hub serves as a community sharing platform, promoting cross-framework skill ecosystem development++---++## 4. Case Study++### 4.1 Case: Multi-Disciplinary Medical Expert Consultation++This case demonstrates the practical value of Team Skills in a medical consultation scenario.++#### Applicable Scenario++- Patient condition is complex, involving multiple systems+- Different specialist experts need to jointly evaluate+- Desire for comprehensive, structured treatment recommendations++#### User Input++```+Patient information:+- Male, 65 years old+- Chief complaint: Chest pain with difficulty breathing for 2 days+- Past medical history: Hypertension, diabetes+- Test results: ECG ST-segment elevation, elevated D-dimer++Please organize an expert consultation and provide treatment recommendations.+```++#### Team Collaboration Process++**Phase 1: Case Reception and Analysis**++```+[coordinator] Receives case information+[coordinator] Analysis: Chest pain + ECG abnormality + elevated D-dimer → involves cardiovascular and respiratory systems+[coordinator] Determines needed experts: Cardiology, Respiratory, Radiology+[coordinator] Creates consultation task #2024-001+```++**Phase 2: Expert Evaluation (Parallel)**++```+[cardiologist] Cardiovascular evaluation:+- ST-segment elevation suggests possible myocardial injury+- Recommendation: Complete cardiac enzyme panel, cardiac ultrasound+- Preliminary opinion: Rule out acute coronary syndrome++[respiratory] Respiratory system evaluation:+- Elevated D-dimer + difficulty breathing+- Recommendation: Complete pulmonary artery CTA+- Preliminary opinion: Rule out pulmonary embolism++[radiologist] Imaging analysis:+- Recommendation: Chest CT plain + enhanced scan+- Focus on pulmonary artery, coronary artery conditions+```++**Phase 3: Opinion Integration**++```+[coordinator] Collects expert opinions+[coordinator] Identifies key disagreement: Cardiogenic vs. Pulmonary origin+[coordinator] Organizes expert discussion+[Expert consensus]: Prioritize ruling out life-threatening conditions+ Recommend simultaneous cardiac and pulmonary vascular assessment+```++**Phase 4: Output Results**++```markdown+# Consultation Report #2024-001++## Patient Information+- Male, 65 years old, chest pain with difficulty breathing for 2 days++## Expert Opinion Summary++### Cardiology Opinion+- ST-segment elevation suggests myocardial injury; need to rule out acute coronary syndrome+- Recommended tests: Cardiac enzyme panel, cardiac ultrasound, coronary CTA++### Respiratory Opinion+- Elevated D-dimer requires vigilance for pulmonary embolism+- Recommended tests: Pulmonary artery CTA, blood gas analysis++### Radiology Opinion+- Recommend chest CT enhanced scan for one-stop assessment++## Comprehensive Treatment Recommendations+1. Immediately complete cardiac enzyme panel and blood gas analysis (emergency completion)+2. Perform chest CT enhanced scan, simultaneously assessing coronary and pulmonary arteries+3. ECG monitoring, monitor vital signs+4. Determine next-step treatment plan based on test results++## Urgency Level+⚠️ High risk - Requires immediate attention++---+Consultation time: 2024-01-15 14:30+Participating experts: Cardiology Dr. Zhang, Respiratory Dr. Li, Radiology Dr. Wang+```++#### Team Skills Advantage Demonstration++| Advantage | Ad-hoc Assembly | Team Skill |+|-----------|----------------|------------|+| Role assignment | Need to reassign who evaluates what every time | Pre-defined roles (cardiology/respiratory/radiology), stable and reliable |+| Collaboration sequence | May miss steps (e.g., forgetting to integrate disagreements) | workflow.md explicitly defines: analyze → evaluate → integrate → output |+| Exception handling | What if an expert times out? Ad-hoc decision | bind.md unified strategy: skip and note missing opinion |+| Output format | Different format every time | Structured, standardized report |+| Reusability | Next consultation starts from scratch again | Same Team Skill can be reused |++### 4.2 Case: Research and PPT Writing Team++This case demonstrates Team Skills in a content production scenario.++#### Applicable Scenario++- Complete pipeline from research investigation to PPT writing+- Research and writing require different professional capabilities+- Desire for structured presentation output++#### User Input++```+Please help me complete a research report PPT on "2024 AI Industry Trends",+including market data, technology trends, and future outlook.+```++#### Team Collaboration Process++**Phase 1: Task Decomposition**++```+[coordinator] Receives research topic: "2024 AI Industry Trends"+[coordinator] Decomposes research questions: market data, technology trends, future outlook+[coordinator] Assigns research tasks to researchers+```++**Phase 2: Parallel Research**++```+[researcher-1] Researches market data: market size, growth rate, major players+[researcher-2] Researches technology trends: large models, multimodal, Agent-based+[researcher-3] Researches future outlook: regulatory trends, application prospects, challenges+```++**Phase 3: Report Writing**++```+[writer] Integrates all research findings+[writer] Writes PPT content: slide titles, key points, data chart suggestions+```++**Phase 4: Review and Revision**++```+[reviewer] Reviews report: logical coherence, data accuracy, expression clarity+[writer] Revises based on review feedback+[coordinator] Outputs final PPT content+```++---++## 5. Creation Guide++### 5.1 Creating New Team Skills with teamskill-creator++JiuwenClaw provides the `teamskill-creator` skill to help users create, convert, or modify Team Skills. It includes standardized templates, decision trees, and an automated validator to ensure created Team Skills comply with the specification.++**Getting and Installing**:++`teamskill-creator` is a built-in skill in JiuwenClaw and requires no additional installation. If the skill is not available in your environment, you can obtain it through:++```bash+# Search and install from skill center+/skills search teamskill-creator+/skills install teamskill-creator+```++**Three modes**:++| Mode | Use Case | Output |+|------|----------|--------|+| **CREATE** | Create a new team skill from scratch | New `<teamskill-name>/` directory with the complete 5-file set |+| **CONVERT** | Convert an existing single-Agent Skill to a Team Skill | Transformed `<teamskill-name>/` directory + delta report |+| **MODIFY** | Modify an existing Team Skill (add/remove roles, adjust workflow, etc.) | Updated files |++#### Creation Workflow Example++The following demonstrates creating a "Research and Report Writing Team" as a complete creation process:++**Step 1: Determine if a Team Skill is needed**++First confirm: does this task truly require multi-role collaboration? A Team Skill is only worth creating when at least one of these applies:++1. **Adversarial blind spot**: A single Agent role-playing multiple perspectives produces converging outputs (e.g., code review, security audit)+2. **Parallel decomposition gain**: Multiple independent sub-tasks can run concurrently, and integration is non-trivial (e.g., multi-angle research)+3. **Specialization pipeline with hard handoffs**: Sequential stages with quality gates where blurring boundaries causes regressions (e.g., marketing copy: brief → draft → edit → audit)++If none apply → recommend using a single-Agent Skill instead.++**Step 2: Select collaboration pattern**++Choose a collaboration pattern based on task characteristics:++| Pattern | Use Case | Role Count | Inter-role Visibility |+|---------|----------|------------|----------------------|+| A. Adversarial / Cross-check | Blind spot problems | 2-4 | Not visible (isolation is the value) |+| B. Parallel decomposition | Independent sub-tasks | 2-N | Not visible until integration |+| C. Specialization pipeline | Sequential expert stages | 3-5 | Each stage sees prior stage output |+| Mixed | Multiple justifications stack | 4-6 | Pattern-by-stage |++The Research and Report Writing Team fits **C. Specialization pipeline** pattern (research → writing → review, sequential stages with quality gates).++**Step 3: Design roles**++Write `roles/<id>.md` files for each role, containing 5 mandatory sections:++```+research-report-team/+├── roles/+│ ├── coordinator.md # Coordinator: decompose tasks, integrate results+│ ├── researcher.md # Researcher: independent research, submit findings+│ ├── writer.md # Writer: integrate research, write report+│ └── reviewer.md # Reviewer: review report, suggest modifications+```++**Anti-overlap test**: Write each role's 1-line motto, then ask "could one role's deliverable substitute for another's?" If yes, boundaries are blurred — redesign before proceeding.++**Step 4: Write collaboration workflow**++Write `workflow.md` with mermaid flowchart, detailed steps, and acceptance criteria:++```markdown+## Overview++```mermaid+graph TD+ L[Leader] --> C[coordinator decomposes task]+ C --> R1[researcher-1 researches]+ C --> R2[researcher-2 researches]+ R1 --> W[writer writes report]+ R2 --> W+ W --> RV[reviewer reviews]+ RV -->|Pass| OUT[Output final report]+ RV -->|Needs revision| W+```+```++**Step 5: Write boundary and exception handling**++Write `bind.md` defining resource constraints, behavioral constraints, and failure handling:++```markdown+## Resource Constraints++| Constraint | Value |+|------------|-------|+| max_parallel_teammates | 3 |+| total_wall_clock_budget | 45 minutes |+| total_token_budget | 80000 |++## Behavioral Constraints++- Leader does not write content directly; only responsible for scheduling+- Researchers cannot see each other's research process (ensures independence)+- Writer must integrate all research findings without omission+- Maximum 2 review rounds++## Failure Handling++### Insufficient Research Information+- Strategy: Request additional research directions from user+- Timeout: Provide conservative conclusions based on available research++### Review Opinion Disagreement+- Strategy: Coordinator arbitrates, choosing the more reasonable revision direction+```++**Step 6: Write dependency declarations and entry file**++Write `dependencies.yaml` and `SKILL.md`, referencing content produced in previous steps.++**Step 7: Validate**++Run the automated validator to ensure the Team Skill complies with the specification:++```bash+# Method 1: Use TUI built-in command (recommended)+/teamskills validate path/to/research-report-team/ --type teamskills++# Method 2: Use standalone validation script+python scripts/validate_teamskill.py path/to/research-report-team/+```++The validator checks:+- All 5 files are present+- Frontmatter required fields are complete (`name`, `kind`, `roles`)+- `roles` has at least 2 entries, each with `id` and `purpose`, `id` must not repeat+- Role file names match `roles[].id`+- Each role file contains 5 mandatory sections+- workflow.md contains a mermaid diagram+- bind.md contains 3 mandatory sections+- dependencies.yaml contains `skills` and `tools` segments+- Skills/tools declared in SKILL.md appear in dependencies.yaml++**Exit code 0 = compliant**. Non-zero exit codes print specific failing checks.++### 5.2 Modifying an Existing Team Skill++Use `teamskill-creator`'s MODIFY mode to modify existing Team Skills:++| Change Type | Stages to Re-run | Files to Update |+|-------------|-----------------|----------------|+| Edit role Identity / Boundary / Schema | Stage 2 (affected role only) | `roles/<id>.md` |+| Add or remove a role | Stage 1a + 2 + 3 + 4 + 5 | All 5 files |+| Change workflow steps / topology | Stage 3 | `workflow.md` + `bind.md` (if constraints change) |+| Change bind constraints | Stage 4 | `bind.md` |+| Change dependencies | Stage 2 (auto-match) + 5 | `dependencies.yaml` + `SKILL.md` frontmatter |++**Important**: Regardless of edit size, Stage 7 (validation) must always be executed.++### 5.3 Converting a Single-Agent Skill to a Team Skill++Use `teamskill-creator`'s CONVERT mode to transform an existing single-Agent Skill into a Team Skill:++1. **Read the source SKILL.md** and identify natural role boundaries:+ - Find embedded multi-persona setups (e.g., "act as Persona 1 / Persona 2 / Persona 3")+ - Find sequential stages with quality gates (e.g., "first do X, then validate Y, then produce Z")+ - Find checklists that branch by category (e.g., "[ ] security [ ] performance [ ] readability")+2. **Articulate the conversion value**: What is lost in single-Agent form? This becomes the Team Skill's "why"+3. **Continue from Step 2** following the CREATE workflow++### 5.4 Publishing to Team Skills Hub++After creation, you can share your Team Skill with the community to build the team skill ecosystem together:++**Step 1: Validate completeness**++```bash+# Method 1: Use TUI built-in command (recommended)+/teamskills validate path/to/<teamskill-name>/ --type teamskills++# Method 2: Use standalone validation script+python scripts/validate_teamskill.py path/to/<teamskill-name>/+```++Ensure exit code is 0 (compliant).++**Step 2: Upload and publish**++In JiuwenClaw's "Skills" panel:+1. Click "Team Skills Hub"+2. Select the Team Skill to publish+3. Click "Upload"+4. First-time use requires authentication (enter your Team Skills Hub Token)++You can also publish via command line:++```+# Publish to Team Skills Hub (requires authentication)+/teamskills publish path/to/<teamskill-name> --version 1.0.0 --token <TOKEN>++# To overwrite an existing version, add --force+/teamskills publish path/to/<teamskill-name> --version 1.0.1 --token <TOKEN> --force+```++> **Authentication note**: Publish and delete operations require `--token` (user Token) or `--system-token` (system Token), and you must choose exactly one. You can pre-configure your token via `/teamskills config --token <TOKEN>` to avoid entering it manually each time.++**Step 3: Maintain and update**++After publishing, you can continuously iterate:+- Re-validate after modifying roles, workflows, or constraints+- Re-publish after updating the version number+- Optimize collaboration workflows based on community feedback++### 5.5 Best Practices++| Practice | Description |+|----------|-------------|+| Appropriate role granularity | Roles should not be too fine (increases coordination cost) or too coarse (loses division advantage) |+| Clear and concise workflow | Avoid overly complex collaboration workflows; maintain understandability |+| Explicit boundary conditions | Cover common exception scenarios in bind.md |+| Provide examples | Include usage examples in examples/ to reduce learning cost |+| Adversarial mottos | Each role's motto should reflect a unique perspective, preventing role convergence |+| Validation is mandatory | Run the validator after every creation or modification |+| Description follows conciseness principles | SKILL.md description ≤4 lines, ≤500 characters, using WHAT / WHEN / NOT structure |++---++## Appendix++### Quick Reference++| Operation | Command/Method |+|-----------|---------------|+| Search Team Skills | `/teamskills search <keyword>` |+| View Team Skill details | `/teamskills info <asset_id> --version <x.y.z>` |+| Install a Team Skill | `/teamskills install <asset_id> --version <x.y.z>` |+| List installed skills | `/teamskills list` |+| Uninstall a Team Skill | `/teamskills uninstall <name>` |+| Create Team Skill scaffold | `/teamskills init <name> --type teamskills` |+| Validate Team Skill | `/teamskills validate <path> --type teamskills` |+| Pack Team Skill | `/teamskills pack <path> --output <dir>` |+| Configure Hub URL and Token | `/teamskills config --market-url <url> --token <TOKEN>` |+| Publish to Team Skills Hub | `/teamskills publish <path> --version <x.y.z> --token <TOKEN>` |+| Delete skill from Hub | `/teamskills delete <skill_id> --version <x.y.z> --token <TOKEN>` |+| Create with teamskill-creator | Use `teamskill-creator` skill's CREATE mode |+| Modify with teamskill-creator | Use `teamskill-creator` skill's MODIFY mode |+| Convert with teamskill-creator | Use `teamskill-creator` skill's CONVERT mode |++### Frequently Asked Questions++**Q: What's the difference between a Team Skill and a regular Skill?**++A: A regular Skill is a capability extension for a single Agent ("how one Agent does things"), while a Team Skill encapsulates a complete multi-Agent collaboration pattern ("how a team of Agents works together"), including role assignments, collaboration workflows, and exception handling strategies.++**Q: How do I determine whether I need a Team Skill?**++A: A Team Skill is appropriate when: (1) a single Agent role-playing multiple perspectives would produce convergence bias; (2) multiple independent sub-tasks can run in parallel; (3) sequential stages have quality gates requiring specialized handling. If none apply, a single-Agent Skill is recommended.++**Q: Can I modify an installed Team Skill?**++A: Yes. Use `teamskill-creator`'s MODIFY mode to edit the local copy. After modification, re-run the validator to confirm compliance.++**Q: Are all 5 files in the Team Skill structure mandatory?**++A: Yes. SKILL.md, roles/, workflow.md, bind.md, and dependencies.yaml are all required files. The validator checks that all 5 files are present. Extension directories like `examples/`, `templates/`, and `assets/` are optional.++**Q: What is the default Team Skills Hub URL?**++A: The default URL is `https://teamskills.openjiuwen.com`, which can be overridden via the `TEAM_SKILLS_HUB_BASE_URL` environment variable.++---++*Document version: v2.0*+*Target audience: JiuwenClaw users, skill developers*+*Last updated: 2026-05-08*\ No newline at end of filediff --git a/docs/zh/AgentTeam.md b/docs/zh/AgentTeam.mdindex 7967b7a4b5..53d8a0d673 100644--- a/docs/zh/AgentTeam.md+++ b/docs/zh/AgentTeam.md@@ -223,7 +223,7 @@ Agent Team 模式下同样支持技能(Skills)的使用和开发。团队中2. **共享工具资源**:团队共享技能可以让所有成员使用同一套工具,避免重复开发3. **协作效率提升**:技能可以让 Agent 更高效地完成分配的任务-> 有关 Team Skills 的详细使用和开发教程,请参阅 [Team Skill 开发指南](TeamSkill.md)。+> 有关 Team Skills 的详细使用和开发教程,请参阅 [Team Skill 开发指南](TeamSkills.md)。### 2.5 Team Memorydiff --git a/docs/zh/SUMMARY.md b/docs/zh/SUMMARY.mdindex c7518dfdce..25d4c99c6d 100644--- a/docs/zh/SUMMARY.md+++ b/docs/zh/SUMMARY.md@@ -33,9 +33,15 @@- [上下文压缩卸载](上下文压缩卸载.md)- [编码记忆](编码记忆.md)- [技能系统](技能.md)+<<<<<<< HEAD- [技能交响乐:技能检索、编排与分发](symphony-技能编排与分发.md)+=======+ - [Agentic 技能检索](Agentic技能检索.md)+ - [Team Skills 团队技能](TeamSkills.md)+>>>>>>> c84a5249 (doc: team skills 文档)- [Skill 自演进](Skill自演进.md)- [智能体与工作区](智能体.md)+ - [会话管理](会话.md)- [浏览器工具](浏览器.md)- [MCP 配置](MCP配置.md)- [打包 exe 指南](打包exe指南.md)diff --git a/docs/zh/TeamSkills.md b/docs/zh/TeamSkills.mdnew file mode 100644index 0000000000..65c9b7e8cf--- /dev/null+++ b/docs/zh/TeamSkills.md@@ -0,0 +1,895 @@+# Team Skills 团队技能++JiuwenClaw 的 **Team Skills(团队技能)** 是一种面向多 Agent 协作的标准化能力包。它不是单个 Agent 的能力补丁,而是把一次优秀的团队协作流程沉淀为可复用、可复制、可进化的团队协作 SOP,让复杂任务不再每次都从零开始临时编排。++---++## 1. 概念科普++### 1.1 Team Skills 的定位++Team Skills 是 JiuwenClaw 技能体系中的**多 Agent 协作层**。如果说 Agent Skill 解决的是"一个 Agent 怎么做事",那么 Team Skills 解决的就是"一个 Agent 团队怎么配合做事"。++在传统的 AI Agent 使用中,面对复杂任务时,用户往往需要手动编排多个 Agent 的协作方式——谁来做什么、谁先谁后、出了问题怎么办。这种方式每次都要从零开始,协作质量不稳定,流程难以复用。Team Skills 的出现,正是为了解决这个痛点:++- **一次沉淀,反复使用**:将经过验证的团队协作流程封装为标准化的能力包,下次遇到同类任务直接调用,无需重新编排。+- **流程可进化**:协作流程不是一成不变的,可以根据实际使用反馈持续优化和迭代。+- **质量可预期**:预定义的角色分工、协作顺序和异常处理策略,让每次协作的输出质量更加稳定。++### 1.2 Team Skills 与 Agent Skills 的区别++| 维度 | Agent Skill | Team Skill |+|------|-------------|------------|+| **定位** | 单个 Agent 的能力扩展 | 多 Agent 团队的协作模式封装 |+| **关注点** | 一个 Agent 怎么做事 | 一个 Agent 团队怎么配合做事 |+| **结构** | 单一 `SKILL.md` 文件 | 目录结构(SKILL.md + roles + workflow + bind + dependencies) |+| **适用场景** | 单一任务,一个 Agent 可完成 | 需要多角色协作、流程复用的复杂任务 |+| **协作方式** | 无协作,Agent 独立执行 | 预定义角色分工、协作流程和异常处理 |+| **复用性** | 能力可复用 | 协作流程可复用 |++简单类比:Agent Skill 像是给一个人增加一项专业技能(如"会做数据分析"),而 Team Skill 像是给一个团队制定一套协作 SOP(如"研究团队如何从调研到撰写到审核完成一份报告")。++### 1.3 Team Skills 的通用性++Team Skills 不只局限于 JiuwenClaw 平台。它的核心设计理念——角色分工、协作流程、边界约束——是一种通用的团队协作能力封装方式,可以适配到支持相关协作标准的其他 AI Agent 框架中。这意味着:++- 在 JiuwenClaw 中创建的 Team Skill,理论上可以迁移到其他支持类似协作标准的平台使用。+- Team Skills 的标准化结构(5 文件规范)为跨框架互操作提供了基础。+- 社区贡献的 Team Skill 可以在不同平台间共享,共建团队技能生态。++---++## 2. 组成结构++一个 Team Skill 本质上是一个**结构化的目录**,而非单一的说明文件。这种设计使得团队协作的各个要素——角色、流程、边界、依赖——能够被清晰地组织和维护。++### 2.1 目录结构概览++```+team-skill-name/+├── SKILL.md # 团队技能入口文件+├── roles/ # 角色定义目录+│ ├── coordinator.md # 协调者角色+│ ├── researcher.md # 研究员角色+│ └── writer.md # 撰写者角色+├── workflow.md # 协作流程定义+├── bind.md # 边界与异常处理规则+├── dependencies.yaml # 外部依赖声明+├── examples/ # 可选:示例与模板+│ └── sample-case.md+├── templates/ # 可选:输出模板+│ └── report-template.md+└── assets/ # 可选:资源文件+ └── diagrams/+```++### 2.2 关键文件说明++| 文件 | 作用 | 必需 |+|------|------|------|+| `SKILL.md` | 团队技能入口文件,定义技能名称、描述、适用场景等元信息,以及角色列表和文件索引 | 是 |+| `roles/*.md` | 角色定义文件,每个文件描述一个 Agent 角色的职责、能力和行为规范 | 是 |+| `workflow.md` | 协作流程定义,描述角色之间的交互顺序、任务流转和决策节点(含 mermaid 流程图) | 是 |+| `bind.md` | 边界与异常处理规则,定义协作的资源约束、行为约束和失败处理策略 | 是 |+| `dependencies.yaml` | 外部依赖声明,列出技能运行所需的工具、其他技能等 | 是 |++### 2.3 核心文件详解++#### SKILL.md — 团队入口++`SKILL.md` 是 Team Skill 的入口文件,采用 YAML frontmatter 声明元信息:++```markdown+---+name: medical-consultation-team+version: 1.0.0+author: jiuwenclaw-team+description: |+ 多学科医疗专家会诊团队技能,通过协调者组织多专科专家并行评估并整合意见。+ Use when 需要多学科专家共同评估复杂病例并输出结构化诊疗建议。+ Do NOT use for 单一专科可独立判断的简单病例。+kind: team-skill+roles:+ - id: coordinator+ purpose: 组织专家、汇总意见、输出诊疗建议+ skills: []+ tools: []+ - id: internist+ purpose: 从内科角度评估病例+ skills: []+ tools: []+ - id: surgeon+ purpose: 从外科角度评估病例+ skills: []+ tools: []+ - id: radiologist+ purpose: 从影像学角度分析病例+ skills: []+ tools: []+---++# 医疗会诊团队技能++本团队技能采用专业化流水线模式(C 模式),组织多学科医疗专家进行病例会诊,解决单 Agent 角色扮演多视角时产生的收敛偏差问题。++## Workflow++0. **预检:检查依赖** — 读取 [dependencies.yaml](dependencies.yaml) 并验证。报告缺失项:`required: true` = 缺少则可能失败;`required: false` = 降级但可用。**用户决定**是否继续。+1. **coordinator 接收病例** — 分析病例,确定专家需求,创建会诊任务。+2. **各专家并行评估** — internist / surgeon / radiologist 独立评估并提交专科意见。+3. **coordinator 整合意见** — 收集所有专家意见,识别分歧,如有分歧组织讨论。+4. **输出诊疗建议报告** — coordinator 整合最终意见,输出结构化报告。++## Roles++| id | Purpose | When dispatched | Input | Key dependencies | Role file |+|---|---------|----------------|-------|-----------------|-----------|+| coordinator | 组织专家、汇总意见 | 每次运行 | 用户提交的病例 | — | [roles/coordinator.md](roles/coordinator.md) |+| internist | 从内科角度评估 | 每次运行(并行) | 分发的病例资料 | — | [roles/internist.md](roles/internist.md) |+| surgeon | 从外科角度评估 | 每次运行(并行) | 分发的病例资料 | — | [roles/surgeon.md](roles/surgeon.md) |+| radiologist | 从影像学角度分析 | 每次运行(并行) | 分发的病例资料 | — | [roles/radiologist.md](roles/radiologist.md) |++> 在分派每个队友之前,读取对应的角色文件并提取 `## Inline Persona for Teammate` 部分,直接粘贴到分派提示词中。++## Files++| File | What it contains | When to read |+|------|------------------|-------------|+| [workflow.md](workflow.md) | Mermaid 流程图、步骤协议、集成规则、最终报告格式 | 首次分派前 — 完整执行手册 |+| [bind.md](bind.md) | 资源限制、行为约束、失败处理和降级模式 | 遇到限制、处理失败或需要降级规则时 |+| [roles/*.md](roles/) | 每个角色的身份、成功标准、输出格式、Inline Persona | 分派每个队友前 — 提取 Inline Persona |+| [dependencies.yaml](dependencies.yaml) | 外部技能和工具依赖 | **启动时** — 验证依赖,报告缺失项,用户决定是否继续 |+```++**关键字段说明**:++- **`name`**:技能的唯一标识符,必须与目录名一致(kebab-case,约定以 `-team` 结尾)。+- **`kind`**:必须为 `team-skill`(注意:不是 `type`),用于区分 Team Skill 和普通 Agent Skill。+- **`roles`**:角色列表,**至少 2 个角色**,每个角色必须包含 `id`(角色标识)、`purpose`(一句话职责描述,≤150 字符)、`skills`(依赖的技能列表)和 `tools`(依赖的工具列表)。+- **`description`**:技能描述,遵循简洁原则(≤4 行、≤500 字符),采用 WHAT / WHEN / NOT 三行结构。++#### roles/*.md — 角色定义++每个角色文件定义一个 Agent 的职责和行为,包含 5 个必需章节:++1. **`## Identity`**:角色身份定义,第一行必须是 1 行格言(motto),如 `> *"我试图在生产环境中破坏这段代码。"*`,这是最重要的反收敛机制。+2. **`## Success Criteria`**:成功标准,列出角色需要达成的目标。+3. **`## Boundary`**:边界定义,必须包含 `**Forbidden**`(禁止做的事,防止角色重叠)和 `**Mandatory**`(必须做的事,防止偷懒)。+4. **`## Output Schema`**:输出格式,定义角色产出的结构。+5. **`## Inline Persona for Teammate`**:内联人格提示词,完整的可粘贴提示词,供 Leader 在分派任务时直接注入。++示例:++```markdown+---+role_name: coordinator+description: 会诊协调者,负责组织专家、汇总意见+---++# 协调者角色++## Identity++> *"我负责让每位专家的声音被听见,并确保最终建议是共识而非妥协。*++协调者是会诊流程的驱动者,不直接给出医学意见,而是确保各专家意见被充分表达和整合。++## Success Criteria++- 所有受邀专家均提交了专科意见+- 意见分歧点已被识别并讨论+- 最终诊疗建议是结构化的、可执行的++**Focus areas**: 意见整合质量、流程完整性++## Boundary++**Forbidden**:+- 直接给出医学诊断意见+- 替代专家做专业判断+- 隐瞒专家间的分歧++**Mandatory**:+- 确保每位专家都收到完整的病例资料+- 在报告中标注意见分歧及处理方式+- 输出结构化的诊疗建议++## Output Schema++```markdown+# 会诊报告+## 患者信息+## 专家意见汇总+### [专家1] 意见+### [专家2] 意见+## 综合诊疗建议+## 紧急程度+```++## Inline Persona for Teammate++你是一位会诊协调者。你的职责是:+1. 接收并分析病例信息+2. 确定需要参与的专家类型+3. 向各专家分发病例资料+4. 收集并汇总各专家意见+5. 识别意见分歧并组织讨论+6. 输出结构化的诊疗建议报告++你不直接给出医学诊断意见,而是确保各专家意见被充分表达和整合。+```++#### workflow.md — 协作流程++定义角色之间的交互顺序和任务流转,包含 3 个必需章节:++1. **`## Overview`**:流程概览,必须包含 mermaid 流程图,这是 Team Skill 与单 Agent Skill 的核心表达差异。+2. **`## Detailed Steps`**:详细步骤,每步包含执行者、输入、输出、串行/并行标记和质量门控。+3. **`## Acceptance Criteria`**:验收标准,判断一次协作是否成功的标准。++示例:++```markdown+# 会诊协作流程++## Overview++```mermaid+graph TD+ L[Leader 接收用户请求] --> C[coordinator 分析病例]+ C --> C1[coordinator 确定专家需求]+ C1 --> P1[internist 评估]+ C1 --> P2[surgeon 评估]+ C1 --> P3[radiologist 评估]+ P1 --> I[coordinator 收集意见]+ P2 --> I+ P3 --> I+ I --> D{是否有分歧?}+ D -->|是| DISC[组织专家讨论]+ D -->|否| R[输出诊疗建议]+ DISC --> R+ R --> OUT[Leader 返回结果]+```++## Detailed Steps++### 步骤 1:病例接收与分析+- **执行者**: coordinator+- **输入**: 用户提交的病例信息+- **输出**: 专家需求列表 + 会诊任务+- **方式**: 串行+- **质量门控**: 如果病例信息不足,向用户请求补充++### 步骤 2:专家评估+- **执行者**: internist / surgeon / radiologist(并行)+- **输入**: 分发的病例资料+- **输出**: 各专科意见+- **方式**: 并行+- **质量门控**: 如果某专家超时未响应,跳过并在报告中标注缺失++### 步骤 3:意见整合+- **执行者**: coordinator+- **输入**: 各专家意见+- **输出**: 整合意见 + 分歧识别+- **方式**: 串行+- **质量门控**: 如果存在严重分歧,组织专家讨论++### 步骤 4:输出结果+- **执行者**: coordinator → Leader+- **输入**: 整合后的意见+- **输出**: 结构化诊疗建议报告+- **方式**: 串行+- **质量门控**: 报告必须包含所有专家意见和分歧处理说明++## Acceptance Criteria++- 所有受邀专家均提交了意见(或缺失意见已标注)+- 意见分歧已被识别和处理+- 最终报告是结构化的、包含综合诊疗建议+```++#### bind.md — 边界与异常处理++定义协作的约束条件和异常处理策略,包含 3 个必需章节:++1. **`## Resource Constraints`**:资源约束,至少包含 `max_parallel_teammates`、`total_wall_clock_budget`、`total_token_budget`。+2. **`## Behavioral Constraints`**:行为约束,团队级规则(如 Leader 不写内容、队友间不可互相看到输出等)。+3. **`## Failure Handling`**:失败处理,覆盖队友失败(超时、输出异常)和输入过大时的降级策略。++示例:++```markdown+# 边界与异常处理++## Resource Constraints++| 约束项 | 值 |+|--------|-----|+| max_parallel_teammates | 5 |+| total_wall_clock_budget | 30 分钟 |+| total_token_budget | 50000 |++## Behavioral Constraints++- Leader 不直接撰写医学内容,只负责调度和整合+- 各专家之间不可互相看到对方的原始意见(隔离评估)+- coordinator 必须在报告中标注所有意见分歧+- 单次会诊最多邀请 5 位专家++## Failure Handling++### 专家不可用+- **策略**: 跳过该专家,在报告中标注缺失意见+- **降级**: 如关键专家不可用,提示用户重新安排++### 意见严重分歧+- **策略**: 组织专家讨论,记录各方理由+- **输出**: 在报告中呈现不同方案及依据++### 信息不足+- **策略**: 向用户请求补充信息+- **超时**: 如用户未响应,基于现有信息给出保守建议++### 输入过大+- **策略**: 病例资料超过 2000 字时,coordinator 先做摘要再分发给专家+```++#### dependencies.yaml — 外部依赖++声明技能运行所需的外部资源,必须包含 `skills` 和 `tools` 两个段(即使为空也需显式写 `[]`):++```yaml+skills:+ - name: web-research+ source: local+ required: false+ purpose: 辅助专家查阅最新医学文献+ - name: report-generator+ source: local+ required: true+ purpose: 生成结构化诊疗建议报告++tools:+ - name: readFile+ required: true+ purpose: 读取病例资料文件+ - name: writeFile+ required: true+ purpose: 输出诊疗建议报告+```++**字段说明**:++| 字段 | 适用段 | 必需 | 说明 | 取值示例 |+|------|--------|------|------|----------|+| `name` | skills, tools | 是 | 技能/工具名称 | `web-research`, `readFile` |+| `source` | skills | 是 | 技能来源 | `local`(本地)、`hub`(技能中心) |+| `required` | skills, tools | 是 | 是否必需 | `true`(必需)、`false`(可选) |+| `purpose` | skills, tools | 是 | 用途说明(≤150字符) | `辅助专家查阅最新医学文献` |++> **注意**:即使没有依赖,也必须显式写 `skills: []` 和 `tools: []`(空列表表示"已检查,确认无依赖",与省略段不同,省略是规范违规)。++---++## 3. 使用指导++### 3.1 如何开始使用 Team Skills++用户通常通过以下步骤开始使用 Team Skills:++**步骤一:从 Team Skills Hub 获取现成技能**++1. 打开 JiuwenClaw 的「技能」面板+2. 点击「Team Skills Hub 在线搜索」+3. 输入关键词搜索所需的团队技能(如"医疗会诊"、"研究报告"等)+4. 点击「安装」将技能添加到工作区++也可以通过命令行搜索和安装:++```+# 搜索 Team Skills+/teamskills search "医疗会诊"++# 查看 Team Skill 详情+/teamskills info <asset_id> --version 1.0.0++# 安装 Team Skill+/teamskills install <asset_id> --version 1.0.0+```++> **提示**:`<asset_id>` 是 Team Skills Hub 上的技能唯一标识(如 `sk-123`),搜索结果中会显示。++**步骤二:在 JiuwenClaw 中使用**++安装完成后,Team Skill 会自动出现在可用技能列表中:++1. 在对话中描述你的任务目标+2. 系统会识别并调用相应的 Team Skill+3. 团队协作流程按既定方式自动运行+4. 获得结构化的输出结果++### 3.2 什么场景更适合使用 Team Skills++Team Skills 特别适合以下场景:++| 场景特征 | 说明 | 示例 |+|----------|------|------|+| 任务链路长 | 需要多个步骤、多个阶段才能完成的复杂任务 | 从调研到撰写到审核完成一份研究报告 |+| 角色分工明确 | 任务可以分解为不同专业领域的子任务 | 多学科医疗会诊需要内科、外科、影像科专家 |+| 希望复用成熟流程 | 不想每次都重新设计协作方式 | 定期执行的代码审查、安全审计 |+| 输出需要结构化 | 需要标准化的报告、方案或建议 | 诊疗建议报告、研究报告、审计报告 |++**对比:何时使用单 Agent Skill vs Team Skill**++| 情况 | 推荐选择 | 原因 |+|------|----------|------|+| 单一任务,一个 Agent 可完成 | 单 Agent Skill | 无需多角色协作,Team Skill 会增加不必要的开销 |+| 需要多步推理,但无需角色分工 | 单 Agent Skill + 工作流 | 流程可以由单个 Agent 按步骤执行 |+| 需要多个专业角色协作 | **Team Skill** | 不同角色的专业视角不可替代 |+| 任务流程固定、需要复用 | **Team Skill** | 预定义流程可反复使用,质量更稳定 |+| 需要对抗性检查(如代码审查) | **Team Skill** | 单 Agent 角色扮演多个视角容易产生收敛偏差 |++### 3.3 使用重点++Team Skills 的核心价值在于:**选择合适的 Team Skill,让团队协作流程按既定方式自动运行**,而不是手动编排每个 Agent。++使用时的三个重点:++1. **选择合适的 Team Skill**:根据任务特点选择匹配的团队技能。如果现有技能不完全匹配,可以基于 `teamskill-creator` 修改已有技能或创建新技能。+2. **提供清晰的输入**:按照技能要求提供完整的任务信息。输入越清晰,协作输出质量越高。+3. **理解输出结构**:了解技能的输出格式,便于后续处理和使用。++Team Skills 相比临时组队的三大优势:++| 优势点 | 临时组队 | Team Skill |+|--------|----------|------------|+| 分工规则 | 每次需重新分配,可能遗漏或混乱 | 预定义,稳定可靠 |+| 协作顺序 | 可能遗漏关键步骤 | workflow.md 明确规定 |+| 异常处理 | 临时决策,不一致 | bind.md 统一策略 |++### 3.4 跨框架复用潜力++Team Skills 采用标准化的结构定义(5 文件规范),具备跨框架复用潜力:++- 协作标准基于通用的角色-流程-边界模型,不依赖特定框架的实现细节+- 可适配到支持相关协作标准的其他 AI Agent 平台+- 便于在不同框架间迁移和共享团队协作经验+- Team Skills Hub 作为社区共享平台,促进跨框架的技能生态共建++---++## 4. 案例实践++### 4.1 案例:多学科医疗专家会诊++本案例展示 Team Skills 在医疗会诊场景中的实际应用价值。++#### 适用场景++- 患者病情复杂,涉及多个系统+- 需要不同专科专家共同评估+- 希望获得综合、结构化的诊疗建议++#### 用户输入++```+患者信息:+- 男性,65岁+- 主诉:胸痛伴呼吸困难2天+- 既往史:高血压、糖尿病+- 检查结果:心电图ST段抬高,D-二聚体升高++请组织专家会诊,给出诊疗建议。+```++#### 团队协作过程++**阶段一:病例接收与分析**++```+[coordinator] 接收病例信息+[coordinator] 分析:胸痛+心电图异常+D-二聚体升高 → 涉及心血管和呼吸系统+[coordinator] 确定需要专家:心内科、呼吸科、影像科+[coordinator] 创建会诊任务 #2024-001+```++**阶段二:专家评估(并行)**++```+[internist] 评估内科方面:+- ST段抬高提示心肌损伤可能+- 建议:完善心肌酶谱、心脏超声+- 初步意见:排除急性冠脉综合征++[surgeon] 评估外科方面:+- D-二聚体升高+呼吸困难+- 建议:完善肺动脉CTA+- 初步意见:排除肺栓塞++[radiologist] 影像分析:+- 建议胸部CT平扫+增强+- 关注肺动脉、冠状动脉情况+```++**阶段三:意见整合**++```+[coordinator] 收集专家意见+[coordinator] 识别关键分歧:心源性 vs 肺源性+[coordinator] 组织专家讨论+[专家共识]:优先排除危及生命的情况+ 建议同时进行心脏和肺血管评估+```++**阶段四:输出结果**++```markdown+# 会诊报告 #2024-001++## 患者信息+- 男性,65岁,胸痛伴呼吸困难2天++## 专家意见汇总++### 内科意见+- ST段抬高提示心肌损伤,需排除急性冠脉综合征+- 建议检查:心肌酶谱、心脏超声、冠脉CTA++### 外科意见+- D-二聚体升高需警惕肺栓塞+- 建议检查:肺动脉CTA、血气分析++### 影像科意见+- 建议胸部CT增强扫描,一站式评估++## 综合诊疗建议+1. 立即完善心肌酶谱、血气分析(急诊完成)+2. 行胸部CT增强扫描,同时评估冠脉和肺动脉+3. 心电监护,监测生命体征+4. 根据检查结果决定下一步治疗方案++## 紧急程度+⚠️ 高危 - 需立即处理++---+会诊时间:2024-01-15 14:30+参与专家:内科张医生、外科李医生、影像科王医生+```++#### Team Skills 的优势体现++| 优势点 | 临时组队 | Team Skill |+|--------|----------|------------|+| 分工规则 | 每次需重新分配谁看什么 | 预定义角色(内科/外科/影像科),稳定可靠 |+| 协作顺序 | 可能遗漏步骤(如忘记整合分歧) | workflow.md 明确规定:分析→评估→整合→输出 |+| 异常处理 | 专家超时怎么办?临时决定 | bind.md 统一策略:跳过并标注缺失 |+| 输出格式 | 每次格式不同 | 结构化、标准化报告 |+| 复用性 | 下次会诊又要从零开始 | 同一 Team Skill 可反复使用 |++### 4.2 案例:研究与 PPT 撰写团队++本案例展示 Team Skills 在内容生产场景中的应用。++#### 适用场景++- 需要从研究调研到 PPT 撰写的完整链路+- 研究和撰写需要不同专业能力+- 希望输出结构化的演示文稿++#### 用户输入++```+请帮我完成一份关于"2024年AI行业趋势"的研究报告PPT,+需要包含市场数据、技术趋势和未来展望。+```++#### 团队协作过程++**阶段一:任务分解**++```+[coordinator] 接收研究主题:"2024年AI行业趋势"+[coordinator] 分解研究问题:市场数据、技术趋势、未来展望+[coordinator] 分配研究任务给 researcher+```++**阶段二:并行研究**++```+[researcher-1] 研究市场数据:市场规模、增长率、主要玩家+[researcher-2] 研究技术趋势:大模型、多模态、Agent化+[researcher-3] 研究未来展望:监管趋势、应用前景、挑战+```++**阶段三:报告撰写**++```+[writer] 整合所有研究发现+[writer] 撰写 PPT 内容:每页标题、要点、数据图表建议+```++**阶段四:审核修订**++```+[reviewer] 审核报告:逻辑连贯性、数据准确性、表达清晰度+[writer] 根据审核意见修订+[coordinator] 输出最终 PPT 内容+```++---++## 5. 创建指导++### 5.1 使用 teamskill-creator 创建新的 Team Skill++JiuwenClaw 提供了 `teamskill-creator` 技能,帮助用户创建、转换或修改 Team Skill。它内置了标准化的模板、决策树和自动化验证器,确保创建的 Team Skill 符合规范。++**获取与安装**:++`teamskill-creator` 是 JiuwenClaw 的内置技能,无需额外安装。如果您的环境中没有该技能,可以通过以下方式获取:++```bash+# 从技能中心搜索并安装+/skills search teamskill-creator+/skills install teamskill-creator+```++**三种模式**:++| 模式 | 适用场景 | 输出 |+|------|----------|------|+| **CREATE** | 从零创建新的团队技能 | 新的 `<teamskill-name>/` 目录,包含完整的 5 文件集 |+| **CONVERT** | 将现有单 Agent Skill 转换为 Team Skill | 转换后的 `<teamskill-name>/` 目录 + 差异报告 |+| **MODIFY** | 修改已有 Team Skill(增删角色、调整流程等) | 更新后的文件 |++#### 创建流程示例++以下以创建「研究与报告撰写团队」为例,展示完整的创建过程:++**步骤一:判断是否需要 Team Skill**++首先确认:这个任务是否真的需要多角色协作?Team Skill 仅在以下情况才值得创建:++1. **对抗性盲区**:单 Agent 角色扮演多个视角会产生收敛偏差(如代码审查、安全审计)+2. **并行分解收益**:多个独立子任务可以并行执行,且整合非平凡(如多角度研究)+3. **专业化流水线**:顺序阶段有质量门控,模糊阶段边界会导致质量下降(如营销文案:简报→草稿→编辑→审核)++如果以上都不适用 → 建议使用单 Agent Skill。++**步骤二:选择协作模式**++根据任务特点选择协作模式:++| 模式 | 适用场景 | 角色数 | 角色间可见性 |+|------|----------|--------|-------------|+| A. 对抗/交叉检查 | 盲区问题 | 2-4 | 不可见(隔离是价值所在) |+| B. 并行分解 | 独立子任务 | 2-N | 直到整合阶段才可见 |+| C. 专业化流水线 | 顺序专家阶段 | 3-5 | 每阶段可见前一阶段输出 |+| 混合模式 | 多种理由叠加 | 4-6 | 按阶段区分 |++研究与报告撰写团队适合 **C. 专业化流水线** 模式(研究→撰写→审核,顺序阶段有质量门控)。++**步骤三:设计角色**++为每个角色编写 `roles/<id>.md` 文件,包含 5 个必需章节:++```+research-report-team/+├── roles/+│ ├── coordinator.md # 协调者:分解任务、整合结果+│ ├── researcher.md # 研究员:独立研究、提交发现+│ ├── writer.md # 撰写者:整合研究、撰写报告+│ └── reviewer.md # 审核者:审核报告、提出修改意见+```++**反重叠测试**:写出每个角色的 1 行格言,然后问"一个角色的产出能否替代另一个角色的?"如果可以,说明边界模糊,需要重新设计。++**步骤四:编写协作流程**++编写 `workflow.md`,包含 mermaid 流程图、详细步骤和验收标准:++```markdown+## Overview++```mermaid+graph TD+ L[Leader] --> C[coordinator 分解任务]+ C --> R1[researcher-1 研究]+ C --> R2[researcher-2 研究]+ R1 --> W[writer 撰写报告]+ R2 --> W+ W --> RV[reviewer 审核]+ RV -->|通过| OUT[输出最终报告]+ RV -->|需修改| W+```+```++**步骤五:编写边界与异常处理**++编写 `bind.md`,定义资源约束、行为约束和失败处理:++```markdown+## Resource Constraints++| 约束项 | 值 |+|--------|-----|+| max_parallel_teammates | 3 |+| total_wall_clock_budget | 45 分钟 |+| total_token_budget | 80000 |++## Behavioral Constraints++- Leader 不直接撰写内容,只负责调度+- researcher 之间不可互相看到对方的研究过程(保证独立性)+- writer 必须整合所有研究发现,不可遗漏+- 审核最多 2 轮++## Failure Handling++### 研究信息不足+- 策略:向用户请求补充研究方向+- 超时:基于现有研究给出保守结论++### 审核意见分歧+- 策略:coordinator 仲裁,选择更合理的修改方向+```++**步骤六:编写依赖声明和入口文件**++编写 `dependencies.yaml` 和 `SKILL.md`,这两文件引用前面步骤产出的内容。++**步骤七:验证**++运行自动化验证器,确保 Team Skill 符合规范:++```bash+# 方式一:使用 TUI 内置命令(推荐)+/teamskills validate path/to/research-report-team/ --type teamskills++# 方式二:使用独立验证脚本+python scripts/validate_teamskill.py path/to/research-report-team/+```++验证器检查:+- 5 文件是否齐全+- frontmatter 必需字段是否完整(`name`、`kind`、`roles`)+- `roles` 至少 2 个,每个角色有 `id` 和 `purpose`,`id` 不可重复+- 角色文件名是否与 `roles[].id` 一致+- 各角色文件是否包含 5 个必需章节+- workflow.md 是否包含 mermaid 图+- bind.md 是否包含 3 个必需章节+- dependencies.yaml 是否包含 `skills` 和 `tools` 段+- SKILL.md 中声明的 `skills`/`tools` 是否在 dependencies.yaml 中出现++**退出码 0 = 合规**。非零退出码会打印具体的失败检查项。++### 5.2 修改已有 Team Skill++使用 `teamskill-creator` 的 MODIFY 模式可以修改已有的 Team Skill:++| 修改类型 | 需要重新执行的步骤 | 需要更新的文件 |+|----------|-------------------|---------------|+| 编辑角色 Identity / Boundary / Schema | 步骤 2(受影响角色) | `roles/<id>.md` |+| 增删角色 | 步骤 1a + 2 + 3 + 4 + 5 | 所有 5 文件 |+| 修改协作流程 | 步骤 3 | `workflow.md` + `bind.md`(如约束变化) |+| 修改边界约束 | 步骤 4 | `bind.md` |+| 修改依赖 | 步骤 2(自动匹配) + 5 | `dependencies.yaml` + `SKILL.md` |++**重要**:无论修改大小,步骤 7(验证)都必须执行。++### 5.3 将单 Agent Skill 转换为 Team Skill++使用 `teamskill-creator` 的 CONVERT 模式可以将现有的单 Agent Skill 转换为 Team Skill:++1. **读取源 SKILL.md**,识别自然角色边界:+ - 找到嵌入的多角色设定(如"扮演 Persona 1 / Persona 2 / Persona 3")+ - 找到顺序阶段和质量门控(如"先做 X,再验证 Y,再产出 Z")+ - 找到按类别分支的检查清单(如"[ ] 安全 [ ] 性能 [ ] 可读性")+2. **明确转换价值**:单 Agent 形式下丢失了什么?这成为 Team Skill 的"为什么"+3. **继续从步骤 2 开始**,按 CREATE 流程完成++### 5.4 上传到 Team Skills Hub++创建完成后,可以将 Team Skill 分享到社区,共建团队技能生态:++**步骤一:验证完整性**++```bash+# 方式一:使用 TUI 内置命令(推荐)+/teamskills validate path/to/<teamskill-name>/ --type teamskills++# 方式二:使用独立验证脚本+python scripts/validate_teamskill.py path/to/<teamskill-name>/+```++确保退出码为 0(合规)。++**步骤二:上传发布**++在 JiuwenClaw 的「技能」面板中:+1. 点击「Team Skills Hub」+2. 选择要发布的 Team Skill+3. 点击「上传」+4. 首次使用需要认证(输入 Team Skills Hub Token)++也可以通过命令行发布:++```+# 发布到 Team Skills Hub(需要鉴权)+/teamskills publish path/to/<teamskill-name> --version 1.0.0 --token <TOKEN>++# 如需覆盖已有版本,添加 --force+/teamskills publish path/to/<teamskill-name> --version 1.0.1 --token <TOKEN> --force+```++> **鉴权说明**:发布和删除操作需要提供 `--token`(用户 Token)或 `--system-token`(系统 Token),且只能选择一种。Token 可通过 `/teamskills config --token <TOKEN>` 预配置,避免每次手动输入。++**步骤三:维护更新**++发布后可以持续迭代:+- 修改角色、流程或约束后重新验证+- 更新版本号后重新发布+- 根据社区反馈优化协作流程++### 5.5 最佳实践++| 实践 | 说明 |+|------|------|+| 角色粒度适中 | 角色不宜过细(增加协调成本)或过粗(失去分工优势) |+| 流程简洁清晰 | 避免过度复杂的协作流程,保持可理解性 |+| 边界条件明确 | 在 bind.md 中覆盖常见异常情况 |+| 提供示例 | 在 examples/ 中提供使用示例,降低学习成本 |+| 格言要有对抗性 | 每个角色的 motto 应体现独特视角,避免角色收敛 |+| 验证不可跳过 | 每次创建或修改后都必须运行验证器 |+| 描述遵循简洁原则 | SKILL.md description ≤4 行、≤500 字符,采用 WHAT / WHEN / NOT 结构 |++---++## 附录++### 快速参考++| 操作 | 命令/方式 |+|------|----------|+| 搜索 Team Skills | `/teamskills search <关键词>` |+| 查看 Team Skill 详情 | `/teamskills info <asset_id> --version <x.y.z>` |+| 安装 Team Skill | `/teamskills install <asset_id> --version <x.y.z>` |+| 查看已安装技能 | `/teamskills list` |+| 卸载 Team Skill | `/teamskills uninstall <name>` |+| 创建 Team Skill 脚手架 | `/teamskills init <name> --type teamskills` |+| 验证 Team Skill | `/teamskills validate <path> --type teamskills` |+| 打包 Team Skill | `/teamskills pack <path> --output <dir>` |+| 配置 Hub URL 和 Token | `/teamskills config --market-url <url> --token <TOKEN>` |+| 发布到 Team Skills Hub | `/teamskills publish <path> --version <x.y.z> --token <TOKEN>` |+| 删除 Hub 上的技能 | `/teamskills delete <skill_id> --version <x.y.z> --token <TOKEN>` |+| 使用 teamskill-creator 创建 | 使用 `teamskill-creator` 技能的 CREATE 模式 |+| 使用 teamskill-creator 修改 | 使用 `teamskill-creator` 技能的 MODIFY 模式 |+| 使用 teamskill-creator 转换 | 使用 `teamskill-creator` 技能的 CONVERT 模式 |++### 常见问题++**Q: Team Skill 和普通 Skill 有什么区别?**++A: 普通 Skill 是单一 Agent 的能力扩展("一个 Agent 怎么做事"),而 Team Skill 封装了多 Agent 协作的完整模式("一个 Agent 团队怎么配合做事"),包括角色分工、协作流程和异常处理策略。++**Q: 如何判断是否需要使用 Team Skill?**++A: 如果任务存在以下情况,适合使用 Team Skill:(1) 单 Agent 角色扮演多视角会产生收敛偏差;(2) 多个独立子任务可以并行执行;(3) 顺序阶段有质量门控需要专业化处理。如果以上都不适用,建议使用单 Agent Skill。++**Q: 可以修改已安装的 Team Skill 吗?**++A: 可以。使用 `teamskill-creator` 的 MODIFY 模式修改本地副本,修改后需重新运行验证器确认合规。++**Q: Team Skill 的 5 文件结构都是必需的吗?**++A: 是的。SKILL.md、roles/、workflow.md、bind.md、dependencies.yaml 都是必需文件。验证器会检查所有 5 个文件是否齐全。`examples/`、`templates/`、`assets/` 等扩展目录是可选的。++**Q: Team Skills Hub 的默认地址是什么?**++A: 默认地址为 `https://teamskills.openjiuwen.com`,可通过环境变量 `TEAM_SKILLS_HUB_BASE_URL` 覆盖。++---++*文档版本:v2.0*+*适用对象:JiuwenClaw 用户、技能开发者*+*最后更新:2026-05-08*\ No newline at end of filediff --git "a/docs/zh/\344\274\232\350\257\235.md" "b/docs/zh/\344\274\232\350\257\235.md"new file mode 100644index 0000000000..520f8eb20b--- /dev/null+++ "b/docs/zh/\344\274\232\350\257\235.md"@@ -0,0 +1,232 @@+# 会话++会话(Session)是 JiuwenSwarm 中管理对话历史和上下文的核心机制。++---++## 概念科普++### 什么是会话++**会话(Session)** 是 JiuwenSwarm 用于记录和管理单次或多次连续对话交互的数据单元。每个会话包含:++- **对话历史**:用户与 AI 之间的完整消息往来+- **上下文信息**:当前任务状态、执行进度、中间结果等+- **元数据**:会话 ID、创建时间、最后更新时间等标识信息++> **提示**:会话与记忆(Memory)是两个不同的概念:+> - **会话**:临时性的对话历史,关闭或清空后即消失+> - **记忆**:持久化存储的重要信息,跨会话保留++### 会话文件结构++JiuwenSwarm 的会话数据存储在本地工作空间中,典型的会话文件结构如下:++```+.jiuwenswarm/+└── agent/+ └── sessions/+ ├── sess_19ddd41cbc0_fd1e4d/ # 普通会话目录+ │ ├── metadata.json # 会话元数据+ │ └── history.json # 对话历史记录+ ├── sess_19ddd5cc729_09bb02/ # 另一个会话+ │ ├── metadata.json+ │ └── history.json+ ├── heartbeat_19de6f526fb_224694/ # 心跳会话目录+ │ ├── metadata.json+ │ └── history.json+ └── ...+```++**会话类型说明:**++| 目录前缀 | 类型 | 说明 |+|----------|------|------|+| `sess_` | 普通会话 | 用户通过 Web、飞书等渠道发起的对话会话 |+| `heartbeat_` | 心跳会话 | 系统定时执行的心跳任务会话 |+| `cron_` | 定时任务会话 | 定时任务触发的会话 |++**metadata.json 文件内容说明:**++++| 字段 | 说明 | 示例 |+|------|------|------|+| `session_id` | 会话唯一标识符 | `sess_19ddd41cbc0_fd1e4d` |+| `channel_id` | 会话来源渠道 | `web`、`feishu`、`__heartbeat__` |+| `user_id` | 用户标识 | 空或用户 ID |+| `created_at` | 会话创建时间(Unix 时间戳) | `1716249600.732591` |+| `last_message_at` | 最后一条消息时间 | `1716253200.865117` |+| `title` | 会话标题(通常为首条消息摘要) | `帮我写一份技术文档` |+| `message_count` | 消息总数 | `15` |+| `mode` | 执行模式 | `agent.plan` |++**history.json 文件内容说明:**++history.json 是一个 JSON 数组,记录了完整的对话历史。每条消息包含以下字段:++++| 字段 | 说明 | 示例 |+|------|------|------|+| `id` | 消息唯一标识,后缀为 `user` 表示用户 query 信息,后缀为 `assistant` 表示 agent 答复信息 | `req_mol5noj7_22:user` |+| `role` | 消息角色 | `user` 或 `assistant` |+| `request_id` | 请求标识 | `req_mol5noj7_22` |+| `channel_id` | 消息来源渠道 | `web` |+| `timestamp` | 消息时间戳 | `1777533730.7309785` |+| `content` | 消息内容 | 用户输入或 AI 回复文本 |+| `event_type` | 事件类型 | `chat.delta`、`chat.final`、`chat.reasoning` |+| `tool_calls` | 工具调用信息(仅 assistant 消息) | 包含工具名称、参数等 |++> **提示**:agent 答复消息中还会包含 `tool_calls` 等字段,用于记录工具调用信息。++### 为什么需要会话++会话机制在 JiuwenSwarm 中扮演着重要角色,主要原因包括:++1. **上下文连续性**+ - 保持对话的连贯性,AI 能够理解之前的交流内容+ - 支持多轮对话中的信息引用和补充++2. **任务状态追踪**+ - 记录任务规划、执行进度和中间结果+ - 支持任务的中断、恢复和调整++3. **历史回溯**+ - 用户可以查看之前的对话记录+ - 便于复盘和追溯问题解决过程++4. **资源管理**+ - 合理管理对话上下文,避免信息过载+ - 支持上下文压缩机制,优化 token 使用++### 会话使用场景++| 场景 | 说明 |+|------|------|+| **日常对话** | 与 AI 进行问答、咨询、内容创作等交互 |+| **任务执行** | 下达复杂任务,跟踪执行进度,调整任务计划 |+| **历史回顾** | 查看之前的对话内容,恢复中断的工作 |+| **问题排查** | 通过会话记录追溯问题,分析执行过程 |+| **多任务切换** | 在不同会话间切换,处理多个独立任务 |+| **定时任务执行** | 定时任务自动触发会话,执行周期性工作 |+| **多渠道对话** | 来自不同渠道的对话(Web、飞书、微信等) |++---++## 功能演示++### 查看会话聊天记录++您可以查看所有会话的完整聊天记录,了解历史对话内容。++++**操作步骤:**++1. **通过前端界面查看**+ - 在 JiuwenSwarm Web 界面左侧导航栏,点击「会话」菜单+ - 进入会话管理页面,可以看到所有会话列表(即前端会话管理中呈现的列表)+ - 点击任意会话,即可查看该会话的完整聊天记录++2. **通过本地文件查看**+ - 导航到会话存储目录:`.jiuwenswarm/agent/sessions/`+ - 进入对应会话目录(如 `sess_19ddd41cbc0_fd1e4d/`)+ - 查看 `history.json` 文件中的对话内容++> **提示**:前端页面有一个「对话预览」开关,可以切换显示 JSON 文本格式或对话页面格式,方便查看原始数据或对话内容。++### 恢复会话++恢复会话可以将历史会话内容同步到前端,继续之前的工作。++++上图展示了会话管理页面中可恢复的历史会话列表。++++上图展示了恢复会话后的对话页面,可以看到完整的历史对话内容。++**操作步骤:**++1. 在会话管理页面,找到需要恢复的会话(建议选择一个实际聊天的历史会话,而不是心跳会话)+2. 点击「恢复」按钮或双击会话条目+3. 系统将加载该会话的所有历史消息+4. 恢复后,您可以在对话页面看到完整的对话历史+5. 继续输入新内容,AI 将基于历史上下文进行回复++**使用场景:**++| 场景 | 说明 |+|------|------|+| **中断恢复** | 之前的工作被中断,需要继续完成 |+| **任务延续** | 复杂任务分多次完成,每次从上次进度继续 |+| **内容补充** | 对之前的结果不满意,需要补充要求或调整 |++**注意事项:**++- 恢复会话后,新消息将追加到原有对话历史中+- 如果会话包含未完成的任务,系统会尝试恢复任务状态+- 长时间未活动的会话可能已被压缩,恢复时需要解压+++### 删除历史会话++如果某个会话不再需要,您可以直接在会话管理页面删除该会话,释放存储空间并保持列表整洁。++++**操作步骤:**++1. 在 JiuwenSwarm Web 界面左侧导航栏,点击「会话」菜单+2. 在会话管理页面选择要删除的会话+3. 在右侧会话详情区域,点击“删除”图标+4. 弹出确认对话框后,点击“确认”按钮+5. 删除成功后,该会话将从列表中移除++> **提示**:请确认选择的是不再需要的历史会话。已删除的会话可能无法恢复。+++---++## 常见问题++### Q1: 会话和记忆有什么区别?++**会话**是临时的对话历史,存储当前对话过程中的所有消息,清空或关闭后即消失。**记忆**是持久化存储的重要信息,如用户偏好、关键知识点等,跨会话保留。++### Q2: 会话数据会占用多少存储空间?++会话数据通常较小,每条消息约几 KB。但如果包含大量文件上传或长对话,单个会话可能达到数 MB。建议定期清理不需要的历史会话。++### Q3: 恢复会话后,之前的任务状态会保留吗?++是的,恢复会话时,系统会尝试恢复之前的任务状态,包括任务列表、执行进度等。但部分正在执行的任务可能需要重新触发。++### Q4: 会话数据存储在哪里?++会话数据存储在本地工作空间的 `.jiuwenswarm/agent/sessions/` 目录下,每个会话是一个独立的目录,包含 `metadata.json` 和 `history.json` 两个文件。++### Q5: 如何备份重要会话?++您可以:+1. 直接复制会话 JSON 文件到其他位置+2. 导出会话内容为 Markdown 或文本格式+3. 将重要信息写入记忆,实现跨会话保留++---++## 相关链接++- [快速上手教程](Quickstart.md) - 了解 JiuwenSwarm 基本使用+- [记忆系统](记忆.md) - 了解持久化记忆机制+- [任务规划](任务规划.md) - 了解任务管理机制+- [页面概览](页面概览.md) - 了解界面布局+- [对话教程](智能体.md) - 了解对话功能++---++*文档版本:v1.0*+*适用对象:JiuwenSwarm 用户*+*最后更新:2026-05-05*diff --git "a/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md" "b/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md"index c70a22d374..01f64d42d9 100644--- "a/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md"+++ "b/docs/zh/\345\256\232\346\227\266\344\273\273\345\212\241.md"@@ -1,78 +1,285 @@-## 定时任务(Cron)快速上手+# 定时任务-本文介绍如何在 JiuwenSwarm 中创建和管理一个最简单的定时任务,并让它按固定时间把结果推送到指定频道(如 Web、飞书)。+定时任务(Cron)是 JiuwenSwarm 中实现自动化执行的重要机制。----### 1. 定时任务能做什么?+## 概念科普-- **定时执行一句话指令**:例如“每天早上 9 点给我推送杭州的天气”。-- **让 Agent 自己去跑任务**:定时跑搜索、生成结果等。-- **Team / SwarmFlow 定时协作**(`mode=team` 等):到点启动多 Agent 工作流,适合周报、对比分析等复杂任务(见 [§6](#6-team-模式与-swarmflow多智能体定时任务))。-- **多通道推送**:目前支持在 web、飞书、企业微信、钉钉、微信设置定时任务(非web频道需要在频道管理打开, 详情见频道文档)。+### 什么是定时任务++**定时任务(Cron Job)** 是一种按照预设时间计划自动执行任务的机制。在 JiuwenSwarm 中,定时任务可以让 Agent 在指定时间自动执行特定操作,并将结果推送到指定频道。++**核心能力:**++| 能力 | 说明 |+|------|------|+| **定时执行** | 按照 Cron 表达式定义的时间计划自动触发 |+| **自然语言描述** | 用自然语言描述任务内容,Agent 自动理解执行 |+| **多频道推送** | 结果可推送到 Web、飞书、微信等频道 |+| **自动唤醒** | 提前唤醒 Agent 做准备,确保准时执行 |+| **Team/SwarmFlow** | 支持多 Agent 协作,适合复杂任务(见 [§6](#6-team-模式与-swarmflow多智能体定时任务)) |++**典型应用场景:**++- 📅 **每日提醒**:每天固定时间发送工作提醒、健康提醒等+- 📊 **周期汇总**:定期汇总数据、生成日报/周报+- 🔄 **定时检查**:定时检查系统状态、监控任务进度+- 📢 **消息推送**:定时向指定频道推送消息或通知+- 🤝 **协作任务**:Team 模式下多 Agent 协作完成复杂分析任务++### Cron 表达式原理++Cron 表达式是定义定时任务执行时间规则的标准格式。++**基本格式:**++```+分 时 日 月 周+```++| 字段 | 取值范围 | 说明 |+|------|----------|------|+| 分 | 0-59 | 分钟 |+| 时 | 0-23 | 小时 |+| 日 | 1-31 | 日期 |+| 月 | 1-12 | 月份 |+| 周 | 0-6 | 星期(0=周日) |++**特殊字符:**++| 字符 | 说明 | 示例 |+|------|------|------|+| `*` | 任意值 | `* * * * *` = 每分钟 |+| `,` | 列举多个值 | `0,30 * * * *` = 每小时的第0和第30分钟 |+| `-` | 范围 | `0 9-17 * * *` = 9点到17点每小时 |+| `/` | 间隔 | `*/15 * * * *` = 每15分钟 |++**常用表达式示例:**++| 表达式 | 含义 |+|--------|------|+| `0 9 * * *` | 每天早上 9:00 |+| `30 18 * * *` | 每天下午 18:30 |+| `0 9 * * 1` | 每周一早上 9:00 |+| `0 9,18 * * *` | 每天 9:00 和 18:00 |+| `*/30 * * * *` | 每 30 分钟 |+| `0 0 * * *` | 每天凌晨 0:00 |++### 定时任务与心跳的区别++JiuwenSwarm 提供了两种自动化机制:**定时任务**和**心跳**。详细对比请参考 [心跳教程](心跳.md)。++| 对比项 | 定时任务 (Cron) | 心跳 (Heartbeat) |+|--------|-----------------|------------------|+| **触发方式** | 按固定时间计划触发 | 按固定间隔周期触发 |+| **时间定义** | 使用 Cron 表达式(如每天9点) | 使用间隔时间(如每5分钟) |+| **适用场景** | 有明确时间点的任务(日报、提醒、协作分析) | 持续性检查、状态监控 |+| **配置方式** | 配置 Cron 表达式 | 配置心跳间隔 |+| **执行精度** | 精确到指定时间点 | 按间隔周期执行 |++---++## 快速上手++### 通过 Web 界面创建++**操作步骤:**++1. 打开 JiuwenSwarm Web 界面,在左侧导航栏点击 **「定时任务」** 菜单+2. 进入定时任务管理页面,点击 **「创建」** 按钮(红框标注)+3. 填写任务配置表单:++++| 配置项 | 说明 | 示例 |+|--------|------|------|+| **任务名称** | 任务名称(唯一标识) | `daily_reminder` |+| **cron表达式** | Cron 表达式 | `0 9 * * *`(每天9点) |+| **时区** | 任务执行时区 | `Asia/Shanghai`(默认) |+| **状态** | 任务状态 | 启用/停用 |+| **描述** | 任务内容描述 | 生成今日工作提醒 |+| **唤醒偏移秒数** | 提前唤醒秒数 | `300`(提前5分钟) |+| **推送频道** | 结果推送频道 | `web`、`feishu`、`wechat`、`wecom`、`whatsapp`、`telegram` 等 |+| **执行模式** | Agent 执行模式 | `agent.plan`(默认) |++4. 点击 **「创建」**,任务将自动生效++**存储位置:**++定时任务配置保存在:+```+~/.jiuwenswarm/agent/home/cron_jobs.json+```++### 通过对话创建++当 Agent 具备 `cron_create_job` 工具能力时,您可以直接通过自然语言对话创建定时任务。++++**示例对话:**++```+用户:帮我创建一个定时任务,每天早上9点提醒我喝水。+```++Agent 会自动:+1. 解析时间意图 → `cron_expr: "0 9 * * *"`+2. 理解任务内容 → `description: "提醒喝水"`+3. 确定推送频道 → `targets: "web"`+4. 调用工具创建任务++> **提示**:通过对话创建任务时,Agent 会根据上下文自动推断合理的默认值,如时区、频道等。----### 2. 在 Web 面板创建一个最简单的定时任务+## 定时任务执行++### 执行过程++到固定时间触发定时任务后,对话页面会返回一个执行中的对话。-1. 打开 Web 界面,进入 **「定时任务 / Cron」** 面板。-2. 点击 **「新建任务」**,按下表填写:+**执行流程:**- - **任务名称**:例如 `每日杭州天气推送`- - **Cron 表达式(支持 cron 七段式)**:- - 每天早上 9:00:`0 0 9 * * ? *`- - 每小时第 15 分钟:`0 15 * * * ? *`- - **状态(是否启用)**:打开表示启用- - **描述(任务内容)**:一句自然语言,描述到点时要让 Agent 做什么,例如:- `查询杭州天气并推送给用户`- - **唤醒偏移秒数(定时任务在预定推送时间之前多久开始执行任务)**:300(默认300秒)- - **timezone(时区)**:一般用 `Asia/Shanghai`- - **推送频道**:从下拉中选择:- - `网页(web)`:推到 Web 面板+1. **触发时刻**:到达 Cron 表达式定义的时间点+2. **Agent 唤醒**:根据 `wake_offset_seconds` 提前唤醒 Agent+3. **任务执行**:Agent 开始执行任务描述中的内容+4. **结果推送**:执行完成后,结果推送到指定频道-+**执行状态:**-3. 保存后,任务会写入 `~/.jiuwenswarm/agent/home/cron_jobs.json`,调度器自动生效。+| 状态 | 说明 |+|------|------|+| **待执行** | 任务已创建,等待触发时间 |+| **执行中** | Agent 正在执行任务 |+| **已完成** | 任务执行完毕,结果已推送 |+| **执行失败** | 任务执行过程中出现错误 |+### 查看执行结果+定时任务执行完毕的返回结果可以在对话页面查看++++上图展示了定时任务触发后的执行过程。++++上图展示了定时任务执行完成后的结果展示。----### 3. 常见 Cron 表达式示例+## 定时任务管理-- **每天 9:00**:`0 0 9 * * ? *`-- **每天 18:30**:`0 30 18 * * ? *`-- **每周一 9:00**:`0 30 9 ? * MON *`-- **每小时整点**:`0 0 * * * ? *`+创建后任务可以在前端页面进行以下操作:-Cron 表达式格式为(7 段,空格分隔):-`秒 分 时 日 月 周 年`+| 操作 | 说明 |+|------|------|+| **立即执行** | 手动触发任务立即执行一次 |+| **预览** | 查看任务配置详情 |+| **停用** | 暂停任务,不再自动触发 |+| **更新** | 修改任务配置 |+| **删除** | 删除任务 |----### 4. 在聊天中通过工具创建任务(可选)+## 案例实践++### 每日工作提醒++**场景描述:** 每天早上 9 点自动生成工作提醒,推送到 Web 界面。++**配置步骤:**++1. 创建定时任务,对话框输入:+```每天早上 9 点自动生成今日工作提醒,包括:1) 待办事项列表 2) 重要日程提醒 3) 天气信息```++++2. 创建成功后,每天 9:00 Agent 会自动执行并推送结果++**数据获取说明:** 待办、日程等由 Agent 从 `agent/memory/` 记忆文件中读取(来自日常对话写入);天气等通过搜索工具获取。记忆里没有的内容,提醒中通常不会出现。+++**执行效果:**++++```+📋 今日工作提醒(2026年5月20日 星期三)+1️⃣ 待办事项列表+当前暂无待办事项。++2️⃣ 重要日程提醒+今日暂无重要日程安排。++3️⃣ 天气信息+今日天气:-当 Agent 具备 `cron_create_job` 工具能力时,你也可以直接在聊天中说:+- 🌫️ 天气状况:阴天+- 🌡️ 气温:16℃ ~ 25℃+- 💨 风向风力:东风,微风+- 📍 地区:北京-> “帮我创建一个定时任务,每天早上 8 点 30 在 web 上提醒我喝水”+未来三天预报:-Agent 会自动解析出 `cron_expr` / `description` / `targets` 等字段,并调用 `cron_create_job` 创建任务,等价于在前端面板上点“新建任务”并填写表单。-+- 5月21日(周四):多云转小雨,16℃ ~ 24℃,南风微风+- 5月22日(周五):中雨转阴,17℃ ~ 23℃,南风微风+- 5月23日(周六):多云,19℃ ~ 28℃,西南风微风++温馨提示:++- 今日阴天,气温适中,建议穿着轻薄外套+- 明后两天有降雨,请提前准备雨具+- 周末天气转好,适合户外活动+- 祝您工作顺利!如有新的待办事项或日程安排,随时告诉我。+```----### 5. 推送到 TUI 频道+## 常见问题++### Q1: 定时任务没有按时执行怎么办?++**排查步骤:**++1. 检查任务是否启用(`enabled: true`)+2. 检查 Cron 表达式是否正确+3. 检查时区设置是否正确+4. 检查 JiuwenSwarm 服务是否在运行+5. 查看日志文件确认是否有错误++### Q2: 如何修改已创建的定时任务?++在 Web 界面的定时任务列表中,点击任务右侧的 **「编辑」** 按钮,修改配置后保存即可。修改后调度器会自动更新。++### Q3: 定时任务的结果会保存吗?-当 `targets` 为 `tui` 时(也是 `/cron add` 的默认值):+定时任务执行的结果会:+- 推送到指定频道(Web/飞书等)+- 作为会话历史保存在对应的会话文件中+- 可通过会话管理查看历史执行记录-- 调度器**故意不绑定** `session_id`,避免 TUI 重启或切换会话后因 session 变化导致结果被前端过滤。-- Gateway 将这类**无 session 的全局通知**广播到当前已连接的所有 TUI 窗口,因此**每个打开的 TUI 终端都会收到**定时任务结果。-- 若只希望某个会话看到提醒,可在创建任务时改用 `targets=web`,或在 TUI 中通过 `/cron` 管理任务并配合 Web 面板查看。+### Q4: wake_offset_seconds 是什么作用?-与 [TUI 使用指南 — 多窗口 TUI](TUI使用指南.md#多窗口-tui) 配合理解:多窗口场景下,带 `session_id` 的聊天流式事件会精确路由;Cron 推送到 TUI 属于例外,会送达全部窗口。+`wake_offset_seconds` 定义了提前唤醒 Agent 的时间。例如:+- 任务设定 9:00 执行+- `wake_offset_seconds: 300`(5分钟)+- Agent 会在 8:55 开始准备,确保 9:00 准时执行++### Q5: 定时任务支持哪些推送频道?++目前支持的频道:+- `web` - Web 界面+- `feishu` - 飞书+- `wechat` - 微信+- `wecom` - 企业微信+- `whatsapp` - WhatsApp+- `telegram` - Telegram----### 6. Team 模式与 SwarmFlow(多智能体定时任务)+## 6. Team 模式与 SwarmFlow(多智能体定时任务)除默认的单 Agent 模式外,定时任务现已支持 **Team 模式**,可在到点时启动多智能体协作,并可选走 **SwarmFlow** 工作流(详见 [Agent Team 使用指南](AgentTeam.md)、[TUI 使用 SwarmFlow 指南](TUI使用SwarmFlow指南.md))。@@ -161,3 +368,18 @@ Gateway 与 AgentServer 共用 `jiuwenswarm/common/cron_team_completion.py` 中| `channels/tui/.../cron.ts` | `/cron` 子命令与 `mode`、`timeout_seconds` 参数 |更完整的 Slash 参数说明见 [Slash 命令表 — `/cron`](Slash命令表.md#cron定时任务管理)。++---++## 相关链接++- [心跳机制](心跳.md) - 了解心跳与定时任务的区别+- [频道配置](频道.md) - 配置消息推送频道+- [任务规划](任务规划.md) - 了解任务管理机制+- [对话教程](智能体.md) - 了解对话功能++---++*文档版本:v1.0*+*适用对象:JiuwenClaw 用户*+*最后更新:2026-05-05*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 2a84ab0b1b..ed4ea06feb 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"@@ -96,6 +96,7 @@ model_provider: OpenAI- 切换模型时(Web 下拉 / CLI `/model <name>`)可用 `alias` 或 `model_name` 作为标识符。列表首位为默认使用的模型;可在 UI 中拖拽排序或点击"设为默认"调整首位。+### 2.4 多模态模型效果展示当您配置了视频、音频或视觉模型后,JiuwenSwarm 将自动启用相应的多模态能力。以下是各模型的应用场景示例:@@ -183,7 +184,7 @@ Embed 模型的主要作用:## 四、第三方服务配置-本节汇总「搜索与外部服务」相关能力的配置。以下配置项均在 **配置信息** 面板中展示(均为可选)。+第三方服务配置用于启用 JiuwenSwarm 的各种外部能力,包括网页搜索、知识检索、代码仓库访问等。以下配置项均在 **配置信息** 面板中展示(均为可选)。| 配置项 | 说明 | 参考 || --- | --- | --- |